Browse Source

Merge branch 'jc/shared'

* jc/shared:
  shared repository: optionally allow reading to "others".
maint
Junio C Hamano 19 years ago
parent
commit
d9faecac64
  1. 15
      builtin-init-db.c
  2. 6
      cache.h
  3. 2
      environment.c
  4. 14
      path.c
  5. 17
      setup.c

15
builtin-init-db.c

@ -263,7 +263,9 @@ int cmd_init_db(int argc, const char **argv, char **envp) @@ -263,7 +263,9 @@ int cmd_init_db(int argc, const char **argv, char **envp)
if (!strncmp(arg, "--template=", 11))
template_dir = arg+11;
else if (!strcmp(arg, "--shared"))
shared_repository = 1;
shared_repository = PERM_GROUP;
else if (!strncmp(arg, "--shared=", 9))
shared_repository = git_config_perm("arg", arg+9);
else
die(init_db_usage);
}
@ -301,8 +303,15 @@ int cmd_init_db(int argc, const char **argv, char **envp) @@ -301,8 +303,15 @@ int cmd_init_db(int argc, const char **argv, char **envp)
strcpy(path+len, "/info");
safe_create_dir(path, 1);

if (shared_repository)
git_config_set("core.sharedrepository", "true");
if (shared_repository) {
char buf[10];
/* We do not spell "group" and such, so that
* the configuration can be read by older version
* of git.
*/
sprintf(buf, "%d", shared_repository);
git_config_set("core.sharedrepository", buf);
}

return 0;
}

6
cache.h

@ -208,6 +208,12 @@ extern const unsigned char null_sha1[20]; @@ -208,6 +208,12 @@ extern const unsigned char null_sha1[20];

int git_mkstemp(char *path, size_t n, const char *template);

enum sharedrepo {
PERM_UMASK = 0,
PERM_GROUP,
PERM_EVERYBODY
};
int git_config_perm(const char *var, const char *value);
int adjust_shared_perm(const char *path);
int safe_create_leading_directories(char *path);
size_t safe_strncpy(char *, const char *, size_t);

2
environment.c

@ -18,7 +18,7 @@ int log_all_ref_updates = 0; @@ -18,7 +18,7 @@ int log_all_ref_updates = 0;
int warn_ambiguous_refs = 1;
int repository_format_version = 0;
char git_commit_encoding[MAX_ENCODING_LENGTH] = "utf-8";
int shared_repository = 0;
int shared_repository = PERM_UMASK;
const char *apply_default_whitespace = NULL;

static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,

14
path.c

@ -267,11 +267,21 @@ int adjust_shared_perm(const char *path) @@ -267,11 +267,21 @@ int adjust_shared_perm(const char *path)
return -1;
mode = st.st_mode;
if (mode & S_IRUSR)
mode |= S_IRGRP;
mode |= (shared_repository == PERM_GROUP
? S_IRGRP
: (shared_repository == PERM_EVERYBODY
? (S_IRGRP|S_IROTH)
: 0));

if (mode & S_IWUSR)
mode |= S_IWGRP;

if (mode & S_IXUSR)
mode |= S_IXGRP;
mode |= (shared_repository == PERM_GROUP
? S_IXGRP
: (shared_repository == PERM_EVERYBODY
? (S_IXGRP|S_IXOTH)
: 0));
if (S_ISDIR(mode))
mode |= S_ISGID;
if (chmod(path, mode) < 0)

17
setup.c

@ -219,12 +219,27 @@ const char *setup_git_directory_gently(int *nongit_ok) @@ -219,12 +219,27 @@ const char *setup_git_directory_gently(int *nongit_ok)
return cwd + offset;
}

int git_config_perm(const char *var, const char *value)
{
if (value) {
if (!strcmp(value, "umask"))
return PERM_UMASK;
if (!strcmp(value, "group"))
return PERM_GROUP;
if (!strcmp(value, "all") ||
!strcmp(value, "world") ||
!strcmp(value, "everybody"))
return PERM_EVERYBODY;
}
return git_config_bool(var, value);
}

int check_repository_format_version(const char *var, const char *value)
{
if (strcmp(var, "core.repositoryformatversion") == 0)
repository_format_version = git_config_int(var, value);
else if (strcmp(var, "core.sharedrepository") == 0)
shared_repository = git_config_bool(var, value);
shared_repository = git_config_perm(var, value);
return 0;
}


Loading…
Cancel
Save