Skip to content

Commit 7eb9152

Browse files
committed
Merge branch 'jc/fix-2.45.1-and-friends-for-2.39' into maint-2.39
* jc/fix-2.45.1-and-friends-for-2.39: Revert "fsck: warn about symlink pointing inside a gitdir" 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 send-email: avoid creating more than one Term::ReadLine object send-email: drop FakeTerm hack
2 parents 47b6d90 + 1991703 commit 7eb9152

19 files changed

+25
-389
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ jobs:
264264
cc: clang
265265
pool: macos-13
266266
- jobname: osx-gcc
267-
cc: gcc
268-
cc_package: gcc-13
267+
cc: gcc-13
269268
pool: macos-13
270269
- jobname: linux-gcc-default
271270
cc: gcc

Documentation/fsck-msgids.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,6 @@
157157
`nullSha1`::
158158
(WARN) Tree contains entries pointing to a null sha1.
159159

160-
`symlinkPointsToGitDir`::
161-
(WARN) Symbolic link points inside a gitdir.
162-
163-
`symlinkTargetBlob`::
164-
(ERROR) A non-blob found instead of a symbolic link's target.
165-
166-
`symlinkTargetLength`::
167-
(WARN) Symbolic link target longer than maximum path length.
168-
169-
`symlinkTargetMissing`::
170-
(ERROR) Unable to read symbolic link target's blob.
171-
172160
`treeNotSorted`::
173161
(ERROR) A tree is not properly sorted.
174162

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);

ci/install-dependencies.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ macos-*)
3434
export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1
3535
# Uncomment this if you want to run perf tests:
3636
# brew install gnu-time
37-
test -z "$BREW_INSTALL_PACKAGES" ||
38-
brew install $BREW_INSTALL_PACKAGES
3937
brew link --force gettext
4038
mkdir -p $HOME/bin
4139
(

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-
}

fsck.c

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,6 @@ static int fsck_tree(const struct object_id *tree_oid,
636636
retval += report(options, tree_oid, OBJ_TREE,
637637
FSCK_MSG_MAILMAP_SYMLINK,
638638
".mailmap is a symlink");
639-
oidset_insert(&options->symlink_targets_found,
640-
entry_oid);
641639
}
642640

643641
if ((backslash = strchr(name, '\\'))) {
@@ -1230,56 +1228,6 @@ static int fsck_blob(const struct object_id *oid, const char *buf,
12301228
}
12311229
}
12321230

1233-
if (oidset_contains(&options->symlink_targets_found, oid)) {
1234-
const char *ptr = buf;
1235-
const struct object_id *reported = NULL;
1236-
1237-
oidset_insert(&options->symlink_targets_done, oid);
1238-
1239-
if (!buf || size > PATH_MAX) {
1240-
/*
1241-
* A missing buffer here is a sign that the caller found the
1242-
* blob too gigantic to load into memory. Let's just consider
1243-
* that an error.
1244-
*/
1245-
return report(options, oid, OBJ_BLOB,
1246-
FSCK_MSG_SYMLINK_TARGET_LENGTH,
1247-
"symlink target too long");
1248-
}
1249-
1250-
while (!reported && ptr) {
1251-
const char *p = ptr;
1252-
char c, *slash = strchrnul(ptr, '/');
1253-
char *backslash = memchr(ptr, '\\', slash - ptr);
1254-
1255-
c = *slash;
1256-
*slash = '\0';
1257-
1258-
while (!reported && backslash) {
1259-
*backslash = '\0';
1260-
if (is_ntfs_dotgit(p))
1261-
ret |= report(options, reported = oid, OBJ_BLOB,
1262-
FSCK_MSG_SYMLINK_POINTS_TO_GIT_DIR,
1263-
"symlink target points to git dir");
1264-
*backslash = '\\';
1265-
p = backslash + 1;
1266-
backslash = memchr(p, '\\', slash - p);
1267-
}
1268-
if (!reported && is_ntfs_dotgit(p))
1269-
ret |= report(options, reported = oid, OBJ_BLOB,
1270-
FSCK_MSG_SYMLINK_POINTS_TO_GIT_DIR,
1271-
"symlink target points to git dir");
1272-
1273-
if (!reported && is_hfs_dotgit(ptr))
1274-
ret |= report(options, reported = oid, OBJ_BLOB,
1275-
FSCK_MSG_SYMLINK_POINTS_TO_GIT_DIR,
1276-
"symlink target points to git dir");
1277-
1278-
*slash = c;
1279-
ptr = c ? slash + 1 : NULL;
1280-
}
1281-
}
1282-
12831231
return ret;
12841232
}
12851233

@@ -1371,10 +1319,6 @@ int fsck_finish(struct fsck_options *options)
13711319
FSCK_MSG_GITATTRIBUTES_MISSING, FSCK_MSG_GITATTRIBUTES_BLOB,
13721320
options, ".gitattributes");
13731321

1374-
ret |= fsck_blobs(&options->symlink_targets_found, &options->symlink_targets_done,
1375-
FSCK_MSG_SYMLINK_TARGET_MISSING, FSCK_MSG_SYMLINK_TARGET_BLOB,
1376-
options, "<symlink-target>");
1377-
13781322
return ret;
13791323
}
13801324

fsck.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ enum fsck_msg_type {
6363
FUNC(GITATTRIBUTES_LARGE, ERROR) \
6464
FUNC(GITATTRIBUTES_LINE_LENGTH, ERROR) \
6565
FUNC(GITATTRIBUTES_BLOB, ERROR) \
66-
FUNC(SYMLINK_TARGET_MISSING, ERROR) \
67-
FUNC(SYMLINK_TARGET_BLOB, ERROR) \
6866
/* warnings */ \
6967
FUNC(EMPTY_NAME, WARN) \
7068
FUNC(FULL_PATHNAME, WARN) \
@@ -74,8 +72,6 @@ enum fsck_msg_type {
7472
FUNC(NULL_SHA1, WARN) \
7573
FUNC(ZERO_PADDED_FILEMODE, WARN) \
7674
FUNC(NUL_IN_COMMIT, WARN) \
77-
FUNC(SYMLINK_TARGET_LENGTH, WARN) \
78-
FUNC(SYMLINK_POINTS_TO_GIT_DIR, WARN) \
7975
/* infos (reported as warnings, but ignored by default) */ \
8076
FUNC(BAD_FILEMODE, INFO) \
8177
FUNC(GITMODULES_PARSE, INFO) \
@@ -143,8 +139,6 @@ struct fsck_options {
143139
struct oidset gitmodules_done;
144140
struct oidset gitattributes_found;
145141
struct oidset gitattributes_done;
146-
struct oidset symlink_targets_found;
147-
struct oidset symlink_targets_done;
148142
kh_oid_map_t *object_names;
149143
};
150144

@@ -154,8 +148,6 @@ struct fsck_options {
154148
.gitmodules_done = OIDSET_INIT, \
155149
.gitattributes_found = OIDSET_INIT, \
156150
.gitattributes_done = OIDSET_INIT, \
157-
.symlink_targets_found = OIDSET_INIT, \
158-
.symlink_targets_done = OIDSET_INIT, \
159151
.error_func = fsck_error_function \
160152
}
161153
#define FSCK_OPTIONS_STRICT { \
@@ -164,8 +156,6 @@ struct fsck_options {
164156
.gitmodules_done = OIDSET_INIT, \
165157
.gitattributes_found = OIDSET_INIT, \
166158
.gitattributes_done = OIDSET_INIT, \
167-
.symlink_targets_found = OIDSET_INIT, \
168-
.symlink_targets_done = OIDSET_INIT, \
169159
.error_func = fsck_error_function, \
170160
}
171161
#define FSCK_OPTIONS_MISSING_GITMODULES { \
@@ -174,8 +164,6 @@ struct fsck_options {
174164
.gitmodules_done = OIDSET_INIT, \
175165
.gitattributes_found = OIDSET_INIT, \
176166
.gitattributes_done = OIDSET_INIT, \
177-
.symlink_targets_found = OIDSET_INIT, \
178-
.symlink_targets_done = OIDSET_INIT, \
179167
.error_func = fsck_error_cb_print_missing_gitmodules, \
180168
}
181169

git-send-email.perl

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,6 @@
2626

2727
Getopt::Long::Configure qw/ pass_through /;
2828

29-
package FakeTerm;
30-
sub new {
31-
my ($class, $reason) = @_;
32-
return bless \$reason, shift;
33-
}
34-
sub readline {
35-
my $self = shift;
36-
die "Cannot use readline on FakeTerm: $$self";
37-
}
38-
package main;
39-
40-
4129
sub usage {
4230
print <<EOT;
4331
git send-email' [<options>] <file|directory>
@@ -929,17 +917,19 @@ sub get_patch_subject {
929917
do_edit(@files);
930918
}
931919
932-
sub term {
933-
my $term = eval {
920+
{
921+
# Only instantiate one $term per program run, since some
922+
# Term::ReadLine providers refuse to create a second instance.
923+
my $term;
924+
sub term {
934925
require Term::ReadLine;
935-
$ENV{"GIT_SEND_EMAIL_NOTTY"}
936-
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
937-
: Term::ReadLine->new('git-send-email');
938-
};
939-
if ($@) {
940-
$term = FakeTerm->new("$@: going non-interactive");
926+
if (!defined $term) {
927+
$term = $ENV{"GIT_SEND_EMAIL_NOTTY"}
928+
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
929+
: Term::ReadLine->new('git-send-email');
930+
}
931+
return $term;
941932
}
942-
return $term;
943933
}
944934
945935
sub ask {

0 commit comments

Comments
 (0)