Skip to content

Commit 68b05d9

Browse files
committed
Merge branch 'js/fix-v2.39.4-regressions' into maint-2.39
Fix regressions introduced in v2.39.4. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2 parents ecc8616 + af8282d commit 68b05d9

13 files changed

+13
-250
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2751,7 +2751,7 @@ exec-cmd.sp exec-cmd.s exec-cmd.o: EXTRA_CPPFLAGS = \
27512751
'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
27522752

27532753
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
2754-
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
2754+
setup.sp setup.s setup.o: EXTRA_CPPFLAGS = \
27552755
-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
27562756

27572757
config.sp config.s config.o: GIT-PREFIX

builtin/clone.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
937937
int err = 0, complete_refs_before_fetch = 1;
938938
int submodule_progress;
939939
int filter_submodules = 0;
940-
const char *template_dir;
941-
char *template_dir_dup = NULL;
942940

943941
struct transport_ls_refs_options transport_ls_refs_options =
944942
TRANSPORT_LS_REFS_OPTIONS_INIT;
@@ -958,13 +956,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
958956
usage_msg_opt(_("You must specify a repository to clone."),
959957
builtin_clone_usage, builtin_clone_options);
960958

961-
xsetenv("GIT_CLONE_PROTECTION_ACTIVE", "true", 0 /* allow user override */);
962-
template_dir = get_template_dir(option_template);
963-
if (*template_dir && !is_absolute_path(template_dir))
964-
template_dir = template_dir_dup =
965-
absolute_pathdup(template_dir);
966-
xsetenv("GIT_CLONE_TEMPLATE_DIR", template_dir, 1);
967-
968959
if (option_depth || option_since || option_not.nr)
969960
deepen = 1;
970961
if (option_single_branch == -1)
@@ -1112,7 +1103,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11121103
}
11131104
}
11141105

1115-
init_db(git_dir, real_git_dir, template_dir, GIT_HASH_UNKNOWN, NULL,
1106+
init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN, NULL,
11161107
INIT_DB_QUIET);
11171108

11181109
if (real_git_dir) {
@@ -1430,7 +1421,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
14301421
free(unborn_head);
14311422
free(dir);
14321423
free(path);
1433-
free(template_dir_dup);
14341424
UNLEAK(repo);
14351425
junk_mode = JUNK_LEAVE_ALL;
14361426

cache.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,20 +1785,6 @@ int copy_fd(int ifd, int ofd);
17851785
int copy_file(const char *dst, const char *src, int mode);
17861786
int copy_file_with_time(const char *dst, const char *src, int mode);
17871787

1788-
/*
1789-
* Compare the file mode and contents of two given files.
1790-
*
1791-
* If both files are actually symbolic links, the function returns 1 if the link
1792-
* targets are identical or 0 if they are not.
1793-
*
1794-
* If any of the two files cannot be accessed or in case of read failures, this
1795-
* function returns 0.
1796-
*
1797-
* If the file modes and contents are identical, the function returns 1,
1798-
* otherwise it returns 0.
1799-
*/
1800-
int do_files_match(const char *path1, const char *path2);
1801-
18021788
void write_or_die(int fd, const void *buf, size_t count);
18031789
void fsync_or_die(int fd, const char *);
18041790
int fsync_component(enum fsync_component component, int fd);

config.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,19 +1525,8 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
15251525
if (!strcmp(var, "core.attributesfile"))
15261526
return git_config_pathname(&git_attributes_file, var, value);
15271527

1528-
if (!strcmp(var, "core.hookspath")) {
1529-
if (current_config_scope() == CONFIG_SCOPE_LOCAL &&
1530-
git_env_bool("GIT_CLONE_PROTECTION_ACTIVE", 0))
1531-
die(_("active `core.hooksPath` found in the local "
1532-
"repository config:\n\t%s\nFor security "
1533-
"reasons, this is disallowed by default.\nIf "
1534-
"this is intentional and the hook should "
1535-
"actually be run, please\nrun the command "
1536-
"again with "
1537-
"`GIT_CLONE_PROTECTION_ACTIVE=false`"),
1538-
value);
1528+
if (!strcmp(var, "core.hookspath"))
15391529
return git_config_pathname(&git_hooks_path, var, value);
1540-
}
15411530

15421531
if (!strcmp(var, "core.bare")) {
15431532
is_bare_repository_cfg = git_config_bool(var, value);

copy.c

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -65,61 +65,3 @@ int copy_file_with_time(const char *dst, const char *src, int mode)
6565
return copy_times(dst, src);
6666
return status;
6767
}
68-
69-
static int do_symlinks_match(const char *path1, const char *path2)
70-
{
71-
struct strbuf buf1 = STRBUF_INIT, buf2 = STRBUF_INIT;
72-
int ret = 0;
73-
74-
if (!strbuf_readlink(&buf1, path1, 0) &&
75-
!strbuf_readlink(&buf2, path2, 0))
76-
ret = !strcmp(buf1.buf, buf2.buf);
77-
78-
strbuf_release(&buf1);
79-
strbuf_release(&buf2);
80-
return ret;
81-
}
82-
83-
int do_files_match(const char *path1, const char *path2)
84-
{
85-
struct stat st1, st2;
86-
int fd1 = -1, fd2 = -1, ret = 1;
87-
char buf1[8192], buf2[8192];
88-
89-
if ((fd1 = open_nofollow(path1, O_RDONLY)) < 0 ||
90-
fstat(fd1, &st1) || !S_ISREG(st1.st_mode)) {
91-
if (fd1 < 0 && errno == ELOOP)
92-
/* maybe this is a symbolic link? */
93-
return do_symlinks_match(path1, path2);
94-
ret = 0;
95-
} else if ((fd2 = open_nofollow(path2, O_RDONLY)) < 0 ||
96-
fstat(fd2, &st2) || !S_ISREG(st2.st_mode)) {
97-
ret = 0;
98-
}
99-
100-
if (ret)
101-
/* to match, neither must be executable, or both */
102-
ret = !(st1.st_mode & 0111) == !(st2.st_mode & 0111);
103-
104-
if (ret)
105-
ret = st1.st_size == st2.st_size;
106-
107-
while (ret) {
108-
ssize_t len1 = read_in_full(fd1, buf1, sizeof(buf1));
109-
ssize_t len2 = read_in_full(fd2, buf2, sizeof(buf2));
110-
111-
if (len1 < 0 || len2 < 0 || len1 != len2)
112-
ret = 0; /* read error or different file size */
113-
else if (!len1) /* len2 is also 0; hit EOF on both */
114-
break; /* ret is still true */
115-
else
116-
ret = !memcmp(buf1, buf2, len1);
117-
}
118-
119-
if (fd1 >= 0)
120-
close(fd1);
121-
if (fd2 >= 0)
122-
close(fd2);
123-
124-
return ret;
125-
}

hook.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,6 @@
33
#include "run-command.h"
44
#include "config.h"
55

6-
static int identical_to_template_hook(const char *name, const char *path)
7-
{
8-
const char *env = getenv("GIT_CLONE_TEMPLATE_DIR");
9-
const char *template_dir = get_template_dir(env && *env ? env : NULL);
10-
struct strbuf template_path = STRBUF_INIT;
11-
int found_template_hook, ret;
12-
13-
strbuf_addf(&template_path, "%s/hooks/%s", template_dir, name);
14-
found_template_hook = access(template_path.buf, X_OK) >= 0;
15-
#ifdef STRIP_EXTENSION
16-
if (!found_template_hook) {
17-
strbuf_addstr(&template_path, STRIP_EXTENSION);
18-
found_template_hook = access(template_path.buf, X_OK) >= 0;
19-
}
20-
#endif
21-
if (!found_template_hook)
22-
return 0;
23-
24-
ret = do_files_match(template_path.buf, path);
25-
26-
strbuf_release(&template_path);
27-
return ret;
28-
}
29-
306
const char *find_hook(const char *name)
317
{
328
static struct strbuf path = STRBUF_INIT;
@@ -62,14 +38,6 @@ const char *find_hook(const char *name)
6238
}
6339
return NULL;
6440
}
65-
if (!git_hooks_path && git_env_bool("GIT_CLONE_PROTECTION_ACTIVE", 0) &&
66-
!identical_to_template_hook(name, path.buf))
67-
die(_("active `%s` hook found during `git clone`:\n\t%s\n"
68-
"For security reasons, this is disallowed by default.\n"
69-
"If this is intentional and the hook should actually "
70-
"be run, please\nrun the command again with "
71-
"`GIT_CLONE_PROTECTION_ACTIVE=false`"),
72-
name, path.buf);
7341
return path.buf;
7442
}
7543

path.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,6 @@ const char *enter_repo(const char *path, int strict)
840840
if (!suffix[i])
841841
return NULL;
842842
gitfile = read_gitfile(used_path.buf);
843-
die_upon_dubious_ownership(gitfile, NULL, used_path.buf);
844843
if (gitfile) {
845844
strbuf_reset(&used_path);
846845
strbuf_addstr(&used_path, gitfile);
@@ -851,7 +850,6 @@ const char *enter_repo(const char *path, int strict)
851850
}
852851
else {
853852
const char *gitfile = read_gitfile(path);
854-
die_upon_dubious_ownership(gitfile, NULL, path);
855853
if (gitfile)
856854
path = gitfile;
857855
if (chdir(path))

t/helper/test-path-utils.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -495,16 +495,6 @@ int cmd__path_utils(int argc, const char **argv)
495495
return !!res;
496496
}
497497

498-
if (argc == 4 && !strcmp(argv[1], "do_files_match")) {
499-
int ret = do_files_match(argv[2], argv[3]);
500-
501-
if (ret)
502-
printf("equal\n");
503-
else
504-
printf("different\n");
505-
return !ret;
506-
}
507-
508498
fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
509499
argv[1] ? argv[1] : "(there was none)");
510500
return 1;

t/t0060-path-utils.sh

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -560,45 +560,4 @@ test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD '%(prefix)/ works'
560560
test_cmp expect actual
561561
'
562562

563-
test_expect_success 'do_files_match()' '
564-
test_seq 0 10 >0-10.txt &&
565-
test_seq -1 10 >-1-10.txt &&
566-
test_seq 1 10 >1-10.txt &&
567-
test_seq 1 9 >1-9.txt &&
568-
test_seq 0 8 >0-8.txt &&
569-
570-
test-tool path-utils do_files_match 0-10.txt 0-10.txt >out &&
571-
572-
assert_fails() {
573-
test_must_fail \
574-
test-tool path-utils do_files_match "$1" "$2" >out &&
575-
grep different out
576-
} &&
577-
578-
assert_fails 0-8.txt 1-9.txt &&
579-
assert_fails -1-10.txt 0-10.txt &&
580-
assert_fails 1-10.txt 1-9.txt &&
581-
assert_fails 1-10.txt .git &&
582-
assert_fails does-not-exist 1-10.txt &&
583-
584-
if test_have_prereq FILEMODE
585-
then
586-
cp 0-10.txt 0-10.x &&
587-
chmod a+x 0-10.x &&
588-
assert_fails 0-10.txt 0-10.x
589-
fi &&
590-
591-
if test_have_prereq SYMLINKS
592-
then
593-
ln -sf 0-10.txt symlink &&
594-
ln -s 0-10.txt another-symlink &&
595-
ln -s over-the-ocean yet-another-symlink &&
596-
ln -s "$PWD/0-10.txt" absolute-symlink &&
597-
assert_fails 0-10.txt symlink &&
598-
test-tool path-utils do_files_match symlink another-symlink &&
599-
assert_fails symlink yet-another-symlink &&
600-
assert_fails symlink absolute-symlink
601-
fi
602-
'
603-
604563
test_done

t/t0411-clone-from-partial.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ test_expect_success 'create evil repo' '
2323
>evil/.git/shallow
2424
'
2525

26-
test_expect_success 'local clone must not fetch from promisor remote and execute script' '
26+
test_expect_failure 'local clone must not fetch from promisor remote and execute script' '
2727
rm -f script-executed &&
2828
test_must_fail git clone \
2929
--upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
@@ -33,7 +33,7 @@ test_expect_success 'local clone must not fetch from promisor remote and execute
3333
test_path_is_missing script-executed
3434
'
3535

36-
test_expect_success 'clone from file://... must not fetch from promisor remote and execute script' '
36+
test_expect_failure 'clone from file://... must not fetch from promisor remote and execute script' '
3737
rm -f script-executed &&
3838
test_must_fail git clone \
3939
--upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
@@ -43,7 +43,7 @@ test_expect_success 'clone from file://... must not fetch from promisor remote a
4343
test_path_is_missing script-executed
4444
'
4545

46-
test_expect_success 'fetch from file://... must not fetch from promisor remote and execute script' '
46+
test_expect_failure 'fetch from file://... must not fetch from promisor remote and execute script' '
4747
rm -f script-executed &&
4848
test_must_fail git fetch \
4949
--upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \

t/t1350-config-hooks-path.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,11 @@ test_expect_success 'git rev-parse --git-path hooks' '
4141
test .git/custom-hooks/abc = "$(cat actual)"
4242
'
4343

44+
test_expect_success 'core.hooksPath=/dev/null' '
45+
git clone -c core.hooksPath=/dev/null . no-templates &&
46+
value="$(git -C no-templates config --local core.hooksPath)" &&
47+
# The Bash used by Git for Windows rewrites `/dev/null` to `nul`
48+
{ test /dev/null = "$value" || test nul = "$value"; }
49+
'
50+
4451
test_done

t/t1800-hook.sh

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,4 @@ test_expect_success 'git hook run a hook with a bad shebang' '
177177
test_cmp expect actual
178178
'
179179

180-
test_expect_success 'clone protections' '
181-
test_config core.hooksPath "$(pwd)/my-hooks" &&
182-
mkdir -p my-hooks &&
183-
write_script my-hooks/test-hook <<-\EOF &&
184-
echo Hook ran $1
185-
EOF
186-
187-
git hook run test-hook 2>err &&
188-
grep "Hook ran" err &&
189-
test_must_fail env GIT_CLONE_PROTECTION_ACTIVE=true \
190-
git hook run test-hook 2>err &&
191-
grep "active .core.hooksPath" err &&
192-
! grep "Hook ran" err
193-
'
194-
195180
test_done

t/t5601-clone.sh

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -771,57 +771,6 @@ test_expect_success 'batch missing blob request does not inadvertently try to fe
771771
git clone --filter=blob:limit=0 "file://$(pwd)/server" client
772772
'
773773

774-
test_expect_success 'clone with init.templatedir runs hooks' '
775-
git init tmpl/hooks &&
776-
write_script tmpl/hooks/post-checkout <<-EOF &&
777-
echo HOOK-RUN >&2
778-
echo I was here >hook.run
779-
EOF
780-
git -C tmpl/hooks add . &&
781-
test_tick &&
782-
git -C tmpl/hooks commit -m post-checkout &&
783-
784-
test_when_finished "git config --global --unset init.templateDir || :" &&
785-
test_when_finished "git config --unset init.templateDir || :" &&
786-
(
787-
sane_unset GIT_TEMPLATE_DIR &&
788-
NO_SET_GIT_TEMPLATE_DIR=t &&
789-
export NO_SET_GIT_TEMPLATE_DIR &&
790-
791-
git -c core.hooksPath="$(pwd)/tmpl/hooks" \
792-
clone tmpl/hooks hook-run-hookspath 2>err &&
793-
! grep "active .* hook found" err &&
794-
test_path_is_file hook-run-hookspath/hook.run &&
795-
796-
git -c init.templateDir="$(pwd)/tmpl" \
797-
clone tmpl/hooks hook-run-config 2>err &&
798-
! grep "active .* hook found" err &&
799-
test_path_is_file hook-run-config/hook.run &&
800-
801-
git clone --template=tmpl tmpl/hooks hook-run-option 2>err &&
802-
! grep "active .* hook found" err &&
803-
test_path_is_file hook-run-option/hook.run &&
804-
805-
git config --global init.templateDir "$(pwd)/tmpl" &&
806-
git clone tmpl/hooks hook-run-global-config 2>err &&
807-
git config --global --unset init.templateDir &&
808-
! grep "active .* hook found" err &&
809-
test_path_is_file hook-run-global-config/hook.run &&
810-
811-
# clone ignores local `init.templateDir`; need to create
812-
# a new repository because we deleted `.git/` in the
813-
# `setup` test case above
814-
git init local-clone &&
815-
cd local-clone &&
816-
817-
git config init.templateDir "$(pwd)/../tmpl" &&
818-
git clone ../tmpl/hooks hook-run-local-config 2>err &&
819-
git config --unset init.templateDir &&
820-
! grep "active .* hook found" err &&
821-
test_path_is_missing hook-run-local-config/hook.run
822-
)
823-
'
824-
825774
. "$TEST_DIRECTORY"/lib-httpd.sh
826775
start_httpd
827776

0 commit comments

Comments
 (0)