Skip to content

Commit 75e7cd2

Browse files
committed
Merge branch 'fixes/2.45.1/2.40' into maint-2.40
* fixes/2.45.1/2.40: 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 b9b439e + 48440f6 commit 75e7cd2

19 files changed

+26
-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
@@ -2747,7 +2747,7 @@ exec-cmd.sp exec-cmd.s exec-cmd.o: EXTRA_CPPFLAGS = \
27472747
'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
27482748

27492749
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
2750-
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
2750+
setup.sp setup.s setup.o: EXTRA_CPPFLAGS = \
27512751
-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
27522752

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

builtin/clone.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -938,8 +938,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
938938
int err = 0, complete_refs_before_fetch = 1;
939939
int submodule_progress;
940940
int filter_submodules = 0;
941-
const char *template_dir;
942-
char *template_dir_dup = NULL;
943941

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

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

1116-
init_db(git_dir, real_git_dir, template_dir, GIT_HASH_UNKNOWN, NULL,
1107+
init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN, NULL,
11171108
INIT_DB_QUIET);
11181109

11191110
if (real_git_dir) {
@@ -1457,7 +1448,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
14571448
free(dir);
14581449
free(path);
14591450
free(repo_to_free);
1460-
free(template_dir_dup);
1451+
UNLEAK(repo);
14611452
junk_mode = JUNK_LEAVE_ALL;
14621453

14631454
transport_ls_refs_options_release(&transport_ls_refs_options);

cache.h

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

1794-
/*
1795-
* Compare the file mode and contents of two given files.
1796-
*
1797-
* If both files are actually symbolic links, the function returns 1 if the link
1798-
* targets are identical or 0 if they are not.
1799-
*
1800-
* If any of the two files cannot be accessed or in case of read failures, this
1801-
* function returns 0.
1802-
*
1803-
* If the file modes and contents are identical, the function returns 1,
1804-
* otherwise it returns 0.
1805-
*/
1806-
int do_files_match(const char *path1, const char *path2);
1807-
18081794
void write_or_die(int fd, const void *buf, size_t count);
18091795
void fsync_or_die(int fd, const char *);
18101796
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, '\\'))) {
@@ -1271,56 +1269,6 @@ static int fsck_blob(const struct object_id *oid, const char *buf,
12711269
}
12721270
}
12731271

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

@@ -1419,10 +1367,6 @@ int fsck_finish(struct fsck_options *options)
14191367
FSCK_MSG_GITATTRIBUTES_MISSING, FSCK_MSG_GITATTRIBUTES_BLOB,
14201368
options, ".gitattributes");
14211369

1422-
ret |= fsck_blobs(&options->symlink_targets_found, &options->symlink_targets_done,
1423-
FSCK_MSG_SYMLINK_TARGET_MISSING, FSCK_MSG_SYMLINK_TARGET_BLOB,
1424-
options, "<symlink-target>");
1425-
14261370
return ret;
14271371
}
14281372

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>
@@ -936,17 +924,19 @@ sub get_patch_subject {
936924
do_edit(@files);
937925
}
938926
939-
sub term {
940-
my $term = eval {
927+
{
928+
# Only instantiate one $term per program run, since some
929+
# Term::ReadLine providers refuse to create a second instance.
930+
my $term;
931+
sub term {
941932
require Term::ReadLine;
942-
$ENV{"GIT_SEND_EMAIL_NOTTY"}
943-
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
944-
: Term::ReadLine->new('git-send-email');
945-
};
946-
if ($@) {
947-
$term = FakeTerm->new("$@: going non-interactive");
933+
if (!defined $term) {
934+
$term = $ENV{"GIT_SEND_EMAIL_NOTTY"}
935+
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
936+
: Term::ReadLine->new('git-send-email');
937+
}
938+
return $term;
948939
}
949-
return $term;
950940
}
951941
952942
sub ask {

0 commit comments

Comments
 (0)