Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatheus Tavares <matheus.bernardino@usp.br>2020-12-02 02:45:04 +0300
committerJunio C Hamano <gitster@pobox.com>2020-12-03 01:35:51 +0300
commiteb3c027e1779d0d1b5bd3b4e96a108461c9759a5 (patch)
tree31443e01cff697ad2ff0ec3e39f353bd3b4a7e9c /sha1-file.c
parent898f80736c75878acc02dc55672317fcc0e0a5a6 (diff)
apply: don't use core.sharedRepository to create working tree files
core.sharedRepository defines which permissions Git should set when creating files in $GIT_DIR, so that the repository may be shared with other users. But (in its current form) the setting shouldn't affect how files are created in the working tree. This is not respected by apply and am (which uses apply), when creating leading directories: $ cat d.patch diff --git a/d/f b/d/f new file mode 100644 index 0000000..e69de29 Apply without the setting: $ umask 0077 $ git apply d.patch $ ls -ld d drwx------ Apply with the setting: $ umask 0077 $ git -c core.sharedRepository=0770 apply d.patch $ ls -ld d drwxrws--- Only the leading directories are affected. That's because they are created with safe_create_leading_directories(), which calls adjust_shared_perm() to set the directories' permissions based on core.sharedRepository. To fix that, let's introduce a variant of this function that ignores the setting, and use it in apply. Also add a regression test and a note in the function documentation about the use of each variant according to the destination (working tree or git dir). Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1-file.c')
-rw-r--r--sha1-file.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sha1-file.c b/sha1-file.c
index dd65bd5c68..c3c49d2fa5 100644
--- a/sha1-file.c
+++ b/sha1-file.c
@@ -291,7 +291,7 @@ int mkdir_in_gitdir(const char *path)
return adjust_shared_perm(path);
}
-enum scld_error safe_create_leading_directories(char *path)
+static enum scld_error safe_create_leading_directories_1(char *path, int share)
{
char *next_component = path + offset_1st_component(path);
enum scld_error ret = SCLD_OK;
@@ -337,7 +337,7 @@ enum scld_error safe_create_leading_directories(char *path)
ret = SCLD_VANISHED;
else
ret = SCLD_FAILED;
- } else if (adjust_shared_perm(path)) {
+ } else if (share && adjust_shared_perm(path)) {
ret = SCLD_PERMS;
}
*slash = slash_character;
@@ -345,6 +345,16 @@ enum scld_error safe_create_leading_directories(char *path)
return ret;
}
+enum scld_error safe_create_leading_directories(char *path)
+{
+ return safe_create_leading_directories_1(path, 1);
+}
+
+enum scld_error safe_create_leading_directories_no_share(char *path)
+{
+ return safe_create_leading_directories_1(path, 0);
+}
+
enum scld_error safe_create_leading_directories_const(const char *path)
{
int save_errno;