Fix core.sharedRepository = 2
For compatibility reasons, "git init --shared=all" does not write "all" into the config, but a number. In the shared setup, you really have to support even older clients on the _same_ repository. But git_config_perm() did not pick up on it. Also, "git update-server-info" failed to pick up on the shared permissions. This patch fixes both issues, and adds a test to prove it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Tested-by: martin f krafft <madduck@madduck.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jul 11, 2007 at 15:18 UTC
835252272e0192bd26983e22428480c5c89775fb
3 files changed
+33
server-info.c
+2
@@ -38,6 +38,7 @@ static int update_info_refs(int force)
38
return error("unable to update %s", path0);
39
for_each_ref(add_info_ref, NULL);
40
fclose(info_ref_fp);
41
+ adjust_shared_perm(path1);
42
rename(path1, path0);
43
free(path0);
44
free(path1);
@@ -227,6 +228,7 @@ static int update_info_packs(int force)
228
return error("cannot open %s", name);
229
write_pack_info_file(fp);
230
fclose(fp);
231
+ adjust_shared_perm(name);
232
rename(name, infofile);
233
return 0;
234
}
setup.c
+4
@@ -364,6 +364,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
364
int git_config_perm(const char *var, const char *value)
365
{
366
if (value) {
367
+ int i;
368
if (!strcmp(value, "umask"))
369
return PERM_UMASK;
370
if (!strcmp(value, "group"))
@@ -372,6 +373,9 @@ int git_config_perm(const char *var, const char *value)
373
!strcmp(value, "world") ||
374
!strcmp(value, "everybody"))
375
return PERM_EVERYBODY;
376
+ i = atoi(value);
377
+ if (i > 1)
378
+ return i;
379
}
380
return git_config_bool(var, value);
381
}
t/t1301-shared-repo.sh
new
+27
@@ -0,0 +1,27 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2007 Johannes Schindelin
4
+#
5
+
6
+test_description='Test shared repository initialization'
7
+
8
+. ./test-lib.sh
9
+
10
+test_expect_success 'shared=all' '
11
+ mkdir sub &&
12
+ cd sub &&
13
+ git init --shared=all &&
14
+ test 2 = $(git config core.sharedrepository)
15
+'
16
+
17
+test_expect_success 'update-server-info honors core.sharedRepository' '
18
+ : > a1 &&
19
+ git add a1 &&
20
+ test_tick &&
21
+ git commit -m a1 &&
22
+ umask 0277 &&
23
+ git update-server-info &&
24
+ test 444 = $(stat -c %a .git/info/refs)
25
+'
26
+
27
+test_done