Skip to content

Commit

Permalink
Sync with 2.44.2
Browse files Browse the repository at this point in the history
* maint-2.44:
  Git 2.44.2
  Git 2.43.5
  Git 2.42.3
  Git 2.41.2
  Git 2.40.3
  Git 2.39.5
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  • Loading branch information
dscho committed May 22, 2024
2 parents 2c7b491 + aec5a9b commit f9dd4b1
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 249 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ jobs:
cc: clang
pool: macos-13
- jobname: osx-gcc
cc: gcc
cc_package: gcc-13
cc: gcc-13
pool: macos-13
- jobname: linux-gcc-default
cc: gcc
Expand Down
25 changes: 25 additions & 0 deletions Documentation/RelNotes/2.39.5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Git 2.39.5 Release Notes
========================

Relative to Git 2.39.5, this release has fixes for regressions that
were introduced in 2.39.4, most notably the error message shown when
cloning Git LFS-enabled repositories. It also contains a fix for the
`osx-gcc` CI job.

Fixes since Git 2.39.4
----------------------

* Some clone protections introduced in v2.39.4 broke Git LFS-enabled
clones and have therefore been dropped.

* The `core.hooksPath` setting is allowed in repository-local
configs again; The benefits of making it protected were
outweighed by the cost.

* Fix a memory leak.

* CI fix.

* Adjust to newer Term::ReadLine to prevent it from breaking
the interactive prompt code in send-email.
(merge c016726c2d jk/send-email-with-new-readline later to maint).
6 changes: 6 additions & 0 deletions Documentation/RelNotes/2.40.3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Git v2.40.3 Release Notes
=========================

This release merges up the regression bug fixes in v2.39.5,
most notably the bug where cloning Git LFS-enabled repositories
failed; see the release notes for that version for details.
7 changes: 7 additions & 0 deletions Documentation/RelNotes/2.41.2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Git v2.41.2 Release Notes
=========================

This release merges up the regression bug fixes in v2.39.5 and
v2.40.3, most notably the bug where cloning Git LFS-enabled
repositories failed; see the release notes for these versions
for details.
7 changes: 7 additions & 0 deletions Documentation/RelNotes/2.42.3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Git v2.42.3 Release Notes
=========================

This release merges up the regression bug fixes in v2.39.5,
v2.40.3 and v2.41.2, most notably the bug where cloning Git
LFS-enabled repositories failed; see the release notes for these
versions for details.
7 changes: 7 additions & 0 deletions Documentation/RelNotes/2.43.5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Git v2.43.5 Release Notes
=========================

This release merges up the regression bug fixes in v2.39.5,
v2.40.3, v2.41.2 and v2.42.3, most notably the bug where cloning
Git LFS-enabled repositories failed; see the release notes for
these versions for details.
7 changes: 7 additions & 0 deletions Documentation/RelNotes/2.44.2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Git v2.44.2 Release Notes
=========================

This release merges up the regression bug fixes in v2.39.5,
v2.40.3, v2.41.2, v2.42.3 and v2.43.5, most notably the bug where
cloning Git LFS-enabled repositories failed; see the release
notes for these versions for details.
13 changes: 2 additions & 11 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,8 +967,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
int hash_algo;
unsigned int ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN;
const int do_not_override_repo_unix_permissions = -1;
const char *template_dir;
char *template_dir_dup = NULL;

struct transport_ls_refs_options transport_ls_refs_options =
TRANSPORT_LS_REFS_OPTIONS_INIT;
Expand All @@ -988,13 +986,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
usage_msg_opt(_("You must specify a repository to clone."),
builtin_clone_usage, builtin_clone_options);

xsetenv("GIT_CLONE_PROTECTION_ACTIVE", "true", 0 /* allow user override */);
template_dir = get_template_dir(option_template);
if (*template_dir && !is_absolute_path(template_dir))
template_dir = template_dir_dup =
absolute_pathdup(template_dir);
xsetenv("GIT_CLONE_TEMPLATE_DIR", template_dir, 1);

if (option_depth || option_since || option_not.nr)
deepen = 1;
if (option_single_branch == -1)
Expand Down Expand Up @@ -1156,7 +1147,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
* repository, and reference backends may persist that information into
* their on-disk data structures.
*/
init_db(git_dir, real_git_dir, template_dir, GIT_HASH_UNKNOWN,
init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN,
ref_storage_format, NULL,
do_not_override_repo_unix_permissions, INIT_DB_QUIET | INIT_DB_SKIP_REFDB);

Expand Down Expand Up @@ -1545,7 +1536,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
free(dir);
free(path);
free(repo_to_free);
free(template_dir_dup);
UNLEAK(repo);
junk_mode = JUNK_LEAVE_ALL;

transport_ls_refs_options_release(&transport_ls_refs_options);
Expand Down
2 changes: 0 additions & 2 deletions ci/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ macos-*)
export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1
# Uncomment this if you want to run perf tests:
# brew install gnu-time
test -z "$BREW_INSTALL_PACKAGES" ||
brew install $BREW_INSTALL_PACKAGES
brew link --force gettext

mkdir -p "$P4_PATH"
Expand Down
13 changes: 1 addition & 12 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1416,19 +1416,8 @@ static int git_default_core_config(const char *var, const char *value,
if (!strcmp(var, "core.attributesfile"))
return git_config_pathname(&git_attributes_file, var, value);

if (!strcmp(var, "core.hookspath")) {
if (ctx->kvi && ctx->kvi->scope == CONFIG_SCOPE_LOCAL &&
git_env_bool("GIT_CLONE_PROTECTION_ACTIVE", 0))
die(_("active `core.hooksPath` found in the local "
"repository config:\n\t%s\nFor security "
"reasons, this is disallowed by default.\nIf "
"this is intentional and the hook should "
"actually be run, please\nrun the command "
"again with "
"`GIT_CLONE_PROTECTION_ACTIVE=false`"),
value);
if (!strcmp(var, "core.hookspath"))
return git_config_pathname(&git_hooks_path, var, value);
}

if (!strcmp(var, "core.bare")) {
is_bare_repository_cfg = git_config_bool(var, value);
Expand Down
58 changes: 0 additions & 58 deletions copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,61 +70,3 @@ int copy_file_with_time(const char *dst, const char *src, int mode)
return copy_times(dst, src);
return status;
}

static int do_symlinks_match(const char *path1, const char *path2)
{
struct strbuf buf1 = STRBUF_INIT, buf2 = STRBUF_INIT;
int ret = 0;

if (!strbuf_readlink(&buf1, path1, 0) &&
!strbuf_readlink(&buf2, path2, 0))
ret = !strcmp(buf1.buf, buf2.buf);

strbuf_release(&buf1);
strbuf_release(&buf2);
return ret;
}

int do_files_match(const char *path1, const char *path2)
{
struct stat st1, st2;
int fd1 = -1, fd2 = -1, ret = 1;
char buf1[8192], buf2[8192];

if ((fd1 = open_nofollow(path1, O_RDONLY)) < 0 ||
fstat(fd1, &st1) || !S_ISREG(st1.st_mode)) {
if (fd1 < 0 && errno == ELOOP)
/* maybe this is a symbolic link? */
return do_symlinks_match(path1, path2);
ret = 0;
} else if ((fd2 = open_nofollow(path2, O_RDONLY)) < 0 ||
fstat(fd2, &st2) || !S_ISREG(st2.st_mode)) {
ret = 0;
}

if (ret)
/* to match, neither must be executable, or both */
ret = !(st1.st_mode & 0111) == !(st2.st_mode & 0111);

if (ret)
ret = st1.st_size == st2.st_size;

while (ret) {
ssize_t len1 = read_in_full(fd1, buf1, sizeof(buf1));
ssize_t len2 = read_in_full(fd2, buf2, sizeof(buf2));

if (len1 < 0 || len2 < 0 || len1 != len2)
ret = 0; /* read error or different file size */
else if (!len1) /* len2 is also 0; hit EOF on both */
break; /* ret is still true */
else
ret = !memcmp(buf1, buf2, len1);
}

if (fd1 >= 0)
close(fd1);
if (fd2 >= 0)
close(fd2);

return ret;
}
14 changes: 0 additions & 14 deletions copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,4 @@ int copy_fd(int ifd, int ofd);
int copy_file(const char *dst, const char *src, int mode);
int copy_file_with_time(const char *dst, const char *src, int mode);

/*
* Compare the file mode and contents of two given files.
*
* If both files are actually symbolic links, the function returns 1 if the link
* targets are identical or 0 if they are not.
*
* If any of the two files cannot be accessed or in case of read failures, this
* function returns 0.
*
* If the file modes and contents are identical, the function returns 1,
* otherwise it returns 0.
*/
int do_files_match(const char *path1, const char *path2);

#endif /* COPY_H */
33 changes: 0 additions & 33 deletions hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,6 @@
#include "strbuf.h"
#include "environment.h"
#include "setup.h"
#include "copy.h"

static int identical_to_template_hook(const char *name, const char *path)
{
const char *env = getenv("GIT_CLONE_TEMPLATE_DIR");
const char *template_dir = get_template_dir(env && *env ? env : NULL);
struct strbuf template_path = STRBUF_INIT;
int found_template_hook, ret;

strbuf_addf(&template_path, "%s/hooks/%s", template_dir, name);
found_template_hook = access(template_path.buf, X_OK) >= 0;
#ifdef STRIP_EXTENSION
if (!found_template_hook) {
strbuf_addstr(&template_path, STRIP_EXTENSION);
found_template_hook = access(template_path.buf, X_OK) >= 0;
}
#endif
if (!found_template_hook)
return 0;

ret = do_files_match(template_path.buf, path);

strbuf_release(&template_path);
return ret;
}

const char *find_hook(const char *name)
{
Expand Down Expand Up @@ -70,14 +45,6 @@ const char *find_hook(const char *name)
}
return NULL;
}
if (!git_hooks_path && git_env_bool("GIT_CLONE_PROTECTION_ACTIVE", 0) &&
!identical_to_template_hook(name, path.buf))
die(_("active `%s` hook found during `git clone`:\n\t%s\n"
"For security reasons, this is disallowed by default.\n"
"If this is intentional and the hook should actually "
"be run, please\nrun the command again with "
"`GIT_CLONE_PROTECTION_ACTIVE=false`"),
name, path.buf);
return path.buf;
}

Expand Down
10 changes: 0 additions & 10 deletions t/helper/test-path-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,6 @@ int cmd__path_utils(int argc, const char **argv)
return !!res;
}

if (argc == 4 && !strcmp(argv[1], "do_files_match")) {
int ret = do_files_match(argv[2], argv[3]);

if (ret)
printf("equal\n");
else
printf("different\n");
return !ret;
}

fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
argv[1] ? argv[1] : "(there was none)");
return 1;
Expand Down
41 changes: 0 additions & 41 deletions t/t0060-path-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -610,45 +610,4 @@ test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD '%(prefix)/ works'
test_cmp expect actual
'

test_expect_success 'do_files_match()' '
test_seq 0 10 >0-10.txt &&
test_seq -1 10 >-1-10.txt &&
test_seq 1 10 >1-10.txt &&
test_seq 1 9 >1-9.txt &&
test_seq 0 8 >0-8.txt &&
test-tool path-utils do_files_match 0-10.txt 0-10.txt >out &&
assert_fails() {
test_must_fail \
test-tool path-utils do_files_match "$1" "$2" >out &&
grep different out
} &&
assert_fails 0-8.txt 1-9.txt &&
assert_fails -1-10.txt 0-10.txt &&
assert_fails 1-10.txt 1-9.txt &&
assert_fails 1-10.txt .git &&
assert_fails does-not-exist 1-10.txt &&
if test_have_prereq FILEMODE
then
cp 0-10.txt 0-10.x &&
chmod a+x 0-10.x &&
assert_fails 0-10.txt 0-10.x
fi &&
if test_have_prereq SYMLINKS
then
ln -sf 0-10.txt symlink &&
ln -s 0-10.txt another-symlink &&
ln -s over-the-ocean yet-another-symlink &&
ln -s "$PWD/0-10.txt" absolute-symlink &&
assert_fails 0-10.txt symlink &&
test-tool path-utils do_files_match symlink another-symlink &&
assert_fails symlink yet-another-symlink &&
assert_fails symlink absolute-symlink
fi
'

test_done
7 changes: 7 additions & 0 deletions t/t1350-config-hooks-path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,11 @@ test_expect_success 'git rev-parse --git-path hooks' '
test .git/custom-hooks/abc = "$(cat actual)"
'

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

test_done
15 changes: 0 additions & 15 deletions t/t1800-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,4 @@ test_expect_success 'stdin to hooks' '
test_cmp expect actual
'

test_expect_success 'clone protections' '
test_config core.hooksPath "$(pwd)/my-hooks" &&
mkdir -p my-hooks &&
write_script my-hooks/test-hook <<-\EOF &&
echo Hook ran $1
EOF
git hook run test-hook 2>err &&
test_grep "Hook ran" err &&
test_must_fail env GIT_CLONE_PROTECTION_ACTIVE=true \
git hook run test-hook 2>err &&
test_grep "active .core.hooksPath" err &&
test_grep ! "Hook ran" err
'

test_done
Loading

0 comments on commit f9dd4b1

Please sign in to comment.