Skip to content

Commit f20b96a

Browse files
committed
Merge branch 'fixes/2.45.1/2.41' into maint-2.41
* fixes/2.45.1/2.41: 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 0f15832 + 4f215d2 commit f20b96a

19 files changed

+26
-390
lines changed

.github/workflows/main.yml

+1-2
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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2743,7 +2743,7 @@ exec-cmd.sp exec-cmd.s exec-cmd.o: EXTRA_CPPFLAGS = \
27432743
'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
27442744

27452745
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
2746-
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
2746+
setup.sp setup.s setup.o: EXTRA_CPPFLAGS = \
27472747
-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
27482748

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

builtin/clone.c

+2-11
Original file line numberDiff line numberDiff line change
@@ -959,8 +959,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
959959
int submodule_progress;
960960
int filter_submodules = 0;
961961
int hash_algo;
962-
const char *template_dir;
963-
char *template_dir_dup = NULL;
964962

965963
struct transport_ls_refs_options transport_ls_refs_options =
966964
TRANSPORT_LS_REFS_OPTIONS_INIT;
@@ -980,13 +978,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
980978
usage_msg_opt(_("You must specify a repository to clone."),
981979
builtin_clone_usage, builtin_clone_options);
982980

983-
xsetenv("GIT_CLONE_PROTECTION_ACTIVE", "true", 0 /* allow user override */);
984-
template_dir = get_template_dir(option_template);
985-
if (*template_dir && !is_absolute_path(template_dir))
986-
template_dir = template_dir_dup =
987-
absolute_pathdup(template_dir);
988-
xsetenv("GIT_CLONE_TEMPLATE_DIR", template_dir, 1);
989-
990981
if (option_depth || option_since || option_not.nr)
991982
deepen = 1;
992983
if (option_single_branch == -1)
@@ -1134,7 +1125,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11341125
}
11351126
}
11361127

1137-
init_db(git_dir, real_git_dir, template_dir, GIT_HASH_UNKNOWN, NULL,
1128+
init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN, NULL,
11381129
INIT_DB_QUIET);
11391130

11401131
if (real_git_dir) {
@@ -1478,7 +1469,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
14781469
free(dir);
14791470
free(path);
14801471
free(repo_to_free);
1481-
free(template_dir_dup);
1472+
UNLEAK(repo);
14821473
junk_mode = JUNK_LEAVE_ALL;
14831474

14841475
transport_ls_refs_options_release(&transport_ls_refs_options);

ci/install-dependencies.sh

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

+1-12
Original file line numberDiff line numberDiff line change
@@ -1596,19 +1596,8 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
15961596
if (!strcmp(var, "core.attributesfile"))
15971597
return git_config_pathname(&git_attributes_file, var, value);
15981598

1599-
if (!strcmp(var, "core.hookspath")) {
1600-
if (current_config_scope() == CONFIG_SCOPE_LOCAL &&
1601-
git_env_bool("GIT_CLONE_PROTECTION_ACTIVE", 0))
1602-
die(_("active `core.hooksPath` found in the local "
1603-
"repository config:\n\t%s\nFor security "
1604-
"reasons, this is disallowed by default.\nIf "
1605-
"this is intentional and the hook should "
1606-
"actually be run, please\nrun the command "
1607-
"again with "
1608-
"`GIT_CLONE_PROTECTION_ACTIVE=false`"),
1609-
value);
1599+
if (!strcmp(var, "core.hookspath"))
16101600
return git_config_pathname(&git_hooks_path, var, value);
1611-
}
16121601

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

copy.c

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

copy.h

-14
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,4 @@ int copy_fd(int ifd, int ofd);
77
int copy_file(const char *dst, const char *src, int mode);
88
int copy_file_with_time(const char *dst, const char *src, int mode);
99

10-
/*
11-
* Compare the file mode and contents of two given files.
12-
*
13-
* If both files are actually symbolic links, the function returns 1 if the link
14-
* targets are identical or 0 if they are not.
15-
*
16-
* If any of the two files cannot be accessed or in case of read failures, this
17-
* function returns 0.
18-
*
19-
* If the file modes and contents are identical, the function returns 1,
20-
* otherwise it returns 0.
21-
*/
22-
int do_files_match(const char *path1, const char *path2);
23-
2410
#endif /* COPY_H */

fsck.c

-56
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,6 @@ static int fsck_tree(const struct object_id *tree_oid,
639639
retval += report(options, tree_oid, OBJ_TREE,
640640
FSCK_MSG_MAILMAP_SYMLINK,
641641
".mailmap is a symlink");
642-
oidset_insert(&options->symlink_targets_found,
643-
entry_oid);
644642
}
645643

646644
if ((backslash = strchr(name, '\\'))) {
@@ -1274,56 +1272,6 @@ static int fsck_blob(const struct object_id *oid, const char *buf,
12741272
}
12751273
}
12761274

1277-
if (oidset_contains(&options->symlink_targets_found, oid)) {
1278-
const char *ptr = buf;
1279-
const struct object_id *reported = NULL;
1280-
1281-
oidset_insert(&options->symlink_targets_done, oid);
1282-
1283-
if (!buf || size > PATH_MAX) {
1284-
/*
1285-
* A missing buffer here is a sign that the caller found the
1286-
* blob too gigantic to load into memory. Let's just consider
1287-
* that an error.
1288-
*/
1289-
return report(options, oid, OBJ_BLOB,
1290-
FSCK_MSG_SYMLINK_TARGET_LENGTH,
1291-
"symlink target too long");
1292-
}
1293-
1294-
while (!reported && ptr) {
1295-
const char *p = ptr;
1296-
char c, *slash = strchrnul(ptr, '/');
1297-
char *backslash = memchr(ptr, '\\', slash - ptr);
1298-
1299-
c = *slash;
1300-
*slash = '\0';
1301-
1302-
while (!reported && backslash) {
1303-
*backslash = '\0';
1304-
if (is_ntfs_dotgit(p))
1305-
ret |= report(options, reported = oid, OBJ_BLOB,
1306-
FSCK_MSG_SYMLINK_POINTS_TO_GIT_DIR,
1307-
"symlink target points to git dir");
1308-
*backslash = '\\';
1309-
p = backslash + 1;
1310-
backslash = memchr(p, '\\', slash - p);
1311-
}
1312-
if (!reported && is_ntfs_dotgit(p))
1313-
ret |= report(options, reported = oid, OBJ_BLOB,
1314-
FSCK_MSG_SYMLINK_POINTS_TO_GIT_DIR,
1315-
"symlink target points to git dir");
1316-
1317-
if (!reported && is_hfs_dotgit(ptr))
1318-
ret |= report(options, reported = oid, OBJ_BLOB,
1319-
FSCK_MSG_SYMLINK_POINTS_TO_GIT_DIR,
1320-
"symlink target points to git dir");
1321-
1322-
*slash = c;
1323-
ptr = c ? slash + 1 : NULL;
1324-
}
1325-
}
1326-
13271275
return ret;
13281276
}
13291277

@@ -1422,10 +1370,6 @@ int fsck_finish(struct fsck_options *options)
14221370
FSCK_MSG_GITATTRIBUTES_MISSING, FSCK_MSG_GITATTRIBUTES_BLOB,
14231371
options, ".gitattributes");
14241372

1425-
ret |= fsck_blobs(&options->symlink_targets_found, &options->symlink_targets_done,
1426-
FSCK_MSG_SYMLINK_TARGET_MISSING, FSCK_MSG_SYMLINK_TARGET_BLOB,
1427-
options, "<symlink-target>");
1428-
14291373
return ret;
14301374
}
14311375

fsck.h

-12
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ enum fsck_msg_type {
6464
FUNC(GITATTRIBUTES_LARGE, ERROR) \
6565
FUNC(GITATTRIBUTES_LINE_LENGTH, ERROR) \
6666
FUNC(GITATTRIBUTES_BLOB, ERROR) \
67-
FUNC(SYMLINK_TARGET_MISSING, ERROR) \
68-
FUNC(SYMLINK_TARGET_BLOB, ERROR) \
6967
/* warnings */ \
7068
FUNC(EMPTY_NAME, WARN) \
7169
FUNC(FULL_PATHNAME, WARN) \
@@ -75,8 +73,6 @@ enum fsck_msg_type {
7573
FUNC(NULL_SHA1, WARN) \
7674
FUNC(ZERO_PADDED_FILEMODE, WARN) \
7775
FUNC(NUL_IN_COMMIT, WARN) \
78-
FUNC(SYMLINK_TARGET_LENGTH, WARN) \
79-
FUNC(SYMLINK_POINTS_TO_GIT_DIR, WARN) \
8076
/* infos (reported as warnings, but ignored by default) */ \
8177
FUNC(BAD_FILEMODE, INFO) \
8278
FUNC(GITMODULES_PARSE, INFO) \
@@ -144,8 +140,6 @@ struct fsck_options {
144140
struct oidset gitmodules_done;
145141
struct oidset gitattributes_found;
146142
struct oidset gitattributes_done;
147-
struct oidset symlink_targets_found;
148-
struct oidset symlink_targets_done;
149143
kh_oid_map_t *object_names;
150144
};
151145

@@ -155,8 +149,6 @@ struct fsck_options {
155149
.gitmodules_done = OIDSET_INIT, \
156150
.gitattributes_found = OIDSET_INIT, \
157151
.gitattributes_done = OIDSET_INIT, \
158-
.symlink_targets_found = OIDSET_INIT, \
159-
.symlink_targets_done = OIDSET_INIT, \
160152
.error_func = fsck_error_function \
161153
}
162154
#define FSCK_OPTIONS_STRICT { \
@@ -165,8 +157,6 @@ struct fsck_options {
165157
.gitmodules_done = OIDSET_INIT, \
166158
.gitattributes_found = OIDSET_INIT, \
167159
.gitattributes_done = OIDSET_INIT, \
168-
.symlink_targets_found = OIDSET_INIT, \
169-
.symlink_targets_done = OIDSET_INIT, \
170160
.error_func = fsck_error_function, \
171161
}
172162
#define FSCK_OPTIONS_MISSING_GITMODULES { \
@@ -175,8 +165,6 @@ struct fsck_options {
175165
.gitmodules_done = OIDSET_INIT, \
176166
.gitattributes_found = OIDSET_INIT, \
177167
.gitattributes_done = OIDSET_INIT, \
178-
.symlink_targets_found = OIDSET_INIT, \
179-
.symlink_targets_done = OIDSET_INIT, \
180168
.error_func = fsck_error_cb_print_missing_gitmodules, \
181169
}
182170

git-send-email.perl

+11-21
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>
@@ -971,17 +959,19 @@ sub get_patch_subject {
971959
do_edit(@files);
972960
}
973961
974-
sub term {
975-
my $term = eval {
962+
{
963+
# Only instantiate one $term per program run, since some
964+
# Term::ReadLine providers refuse to create a second instance.
965+
my $term;
966+
sub term {
976967
require Term::ReadLine;
977-
$ENV{"GIT_SEND_EMAIL_NOTTY"}
978-
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
979-
: Term::ReadLine->new('git-send-email');
980-
};
981-
if ($@) {
982-
$term = FakeTerm->new("$@: going non-interactive");
968+
if (!defined $term) {
969+
$term = $ENV{"GIT_SEND_EMAIL_NOTTY"}
970+
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
971+
: Term::ReadLine->new('git-send-email');
972+
}
973+
return $term;
983974
}
984-
return $term;
985975
}
986976
987977
sub ask {

0 commit comments

Comments
 (0)