Skip to content

Commit 16db4f1

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
mingw: ensure that core.longPaths is handled *always*
A ton of Git commands simply do not read (or at least parse) the core.* settings. This is not good, as Git for Windows relies on the core.longPaths setting to be read quite early on. So let's just make sure that all commands read the config and give platform_core_config() a chance. This patch teaches tons of Git commands to respect the config setting `core.longPaths = true`, including `pack-refs`, thereby fixing #1218 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 1ec2bc7 commit 16db4f1

34 files changed

+66
-5
lines changed

builtin/archive.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "parse-options.h"
1010
#include "pkt-line.h"
1111
#include "sideband.h"
12+
#include "config.h"
1213

1314
static void create_output_file(const char *output_file)
1415
{
@@ -94,6 +95,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
9495
OPT_END()
9596
};
9697

98+
git_config(git_default_config, NULL);
9799
argc = parse_options(argc, argv, prefix, local_opts, NULL,
98100
PARSE_OPT_KEEP_ALL);
99101

builtin/bisect--helper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "parse-options.h"
44
#include "bisect.h"
55
#include "refs.h"
6+
#include "config.h"
67

78
static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
89
static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV")
@@ -129,6 +130,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
129130
OPT_END()
130131
};
131132

133+
git_config(git_default_config, NULL);
132134
argc = parse_options(argc, argv, prefix, options,
133135
git_bisect_helper_usage, 0);
134136

builtin/bundle.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "builtin.h"
22
#include "cache.h"
33
#include "bundle.h"
4+
#include "config.h"
45

56
/*
67
* Basic handler for bundle files to connect repositories via sneakernet.
@@ -21,6 +22,7 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
2122
const char *cmd, *bundle_file;
2223
int bundle_fd = -1;
2324

25+
git_config(git_default_config, NULL);
2426
if (argc < 3)
2527
usage(builtin_bundle_usage);
2628

builtin/check-ref-format.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "refs.h"
77
#include "builtin.h"
88
#include "strbuf.h"
9+
#include "config.h"
910

1011
static const char builtin_check_ref_format_usage[] =
1112
"git check-ref-format [--normalize] [<options>] <refname>\n"
@@ -58,6 +59,7 @@ int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
5859
int flags = 0;
5960
const char *refname;
6061

62+
git_config(git_default_config, NULL);
6163
if (argc == 2 && !strcmp(argv[1], "-h"))
6264
usage(builtin_check_ref_format_usage);
6365

builtin/clone.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
885885
struct refspec *refspec;
886886
const char *fetch_pattern;
887887

888+
git_config(platform_core_config, NULL);
889+
888890
packet_trace_identity("clone");
889891
argc = parse_options(argc, argv, prefix, builtin_clone_options,
890892
builtin_clone_usage, 0);

builtin/column.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ int cmd_column(int argc, const char **argv, const char *prefix)
3434
OPT_END()
3535
};
3636

37+
git_config(platform_core_config, NULL);
38+
3739
/* This one is special and must be the first one */
3840
if (argc > 1 && starts_with(argv[1], "--command=")) {
3941
command = argv[1] + 10;

builtin/credential.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "git-compat-util.h"
22
#include "credential.h"
33
#include "builtin.h"
4+
#include "config.h"
45

56
static const char usage_msg[] =
67
"git credential [fill|approve|reject]";
@@ -10,6 +11,8 @@ int cmd_credential(int argc, const char **argv, const char *prefix)
1011
const char *op;
1112
struct credential c = CREDENTIAL_INIT;
1213

14+
git_config(git_default_config, NULL);
15+
1316
if (argc != 2 || !strcmp(argv[1], "-h"))
1417
usage(usage_msg);
1518
op = argv[1];

builtin/fetch-pack.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "remote.h"
55
#include "connect.h"
66
#include "sha1-array.h"
7+
#include "config.h"
78

89
static const char fetch_pack_usage[] =
910
"git fetch-pack [--all] [--stdin] [--quiet | -q] [--keep | -k] [--thin] "
@@ -53,6 +54,8 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
5354
struct oid_array shallow = OID_ARRAY_INIT;
5455
struct string_list deepen_not = STRING_LIST_INIT_DUP;
5556

57+
git_config(git_default_config, NULL);
58+
5659
packet_trace_identity("fetch-pack");
5760

5861
memset(&args, 0, sizeof(args));

builtin/get-tar-commit-id.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "tar.h"
77
#include "builtin.h"
88
#include "quote.h"
9+
#include "config.h"
910

1011
static const char builtin_get_tar_commit_id_usage[] =
1112
"git get-tar-commit-id";
@@ -25,6 +26,7 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
2526
if (argc != 1)
2627
usage(builtin_get_tar_commit_id_usage);
2728

29+
git_config(git_default_config, NULL);
2830
n = read_in_full(0, buffer, HEADERSIZE);
2931
if (n < 0)
3032
die_errno("git get-tar-commit-id: read error");

builtin/interpret-trailers.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "parse-options.h"
1111
#include "string-list.h"
1212
#include "trailer.h"
13+
#include "config.h"
1314

1415
static const char * const git_interpret_trailers_usage[] = {
1516
N_("git interpret-trailers [--in-place] [--trim-empty] [(--trailer <token>[(=|:)<value>])...] [<file>...]"),
@@ -109,6 +110,7 @@ int cmd_interpret_trailers(int argc, const char **argv, const char *prefix)
109110
OPT_END()
110111
};
111112

113+
git_config(git_default_config, NULL);
112114
argc = parse_options(argc, argv, prefix, options,
113115
git_interpret_trailers_usage, 0);
114116

builtin/log.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
18901890
OPT_END()
18911891
};
18921892

1893+
git_config(git_default_config, NULL);
18931894
argc = parse_options(argc, argv, prefix, options, cherry_usage, 0);
18941895

18951896
switch (argc) {

builtin/ls-remote.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "cache.h"
33
#include "transport.h"
44
#include "remote.h"
5+
#include "config.h"
56

67
static const char * const ls_remote_usage[] = {
78
N_("git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n"
@@ -71,6 +72,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
7172
PARSE_OPT_STOP_AT_NON_OPTION);
7273
dest = argv[0];
7374

75+
git_config(git_default_config, NULL);
7476
if (argc > 1) {
7577
int i;
7678
pattern = xcalloc(argc, sizeof(const char *));

builtin/mailinfo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "utf8.h"
88
#include "strbuf.h"
99
#include "mailinfo.h"
10+
#include "config.h"
1011

1112
static const char mailinfo_usage[] =
1213
"git mailinfo [-k | -b] [-m | --message-id] [-u | --encoding=<encoding> | -n] [--scissors | --no-scissors] <msg> <patch> < mail >info";
@@ -18,6 +19,7 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
1819
int status;
1920
char *msgfile, *patchfile;
2021

22+
git_config(git_default_config, NULL);
2123
setup_mailinfo(&mi);
2224

2325
def_charset = get_commit_output_encoding();

builtin/mailsplit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "builtin.h"
99
#include "string-list.h"
1010
#include "strbuf.h"
11+
#include "config.h"
1112

1213
static const char git_mailsplit_usage[] =
1314
"git mailsplit [-d<prec>] [-f<n>] [-b] [--keep-cr] -o<directory> [(<mbox>|<Maildir>)...]";
@@ -276,6 +277,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)
276277
const char **argp;
277278
static const char *stdin_only[] = { "-", NULL };
278279

280+
git_config(git_default_config, NULL);
279281
for (argp = argv+1; *argp; argp++) {
280282
const char *arg = *argp;
281283

builtin/merge-index.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "builtin.h"
22
#include "run-command.h"
3+
#include "config.h"
34

45
static const char *pgm;
56
static int one_shot, quiet;
@@ -74,6 +75,8 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix)
7475
*/
7576
signal(SIGCHLD, SIG_DFL);
7677

78+
git_config(git_default_config, NULL);
79+
7780
if (argc < 3)
7881
usage("git merge-index [-o] [-q] <merge-program> (-a | [--] [<filename>...])");
7982

builtin/merge-tree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "blob.h"
55
#include "exec_cmd.h"
66
#include "merge-blobs.h"
7+
#include "config.h"
78

89
static const char merge_tree_usage[] = "git merge-tree <base-tree> <branch1> <branch2>";
910

@@ -366,6 +367,7 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
366367
if (argc != 4)
367368
usage(merge_tree_usage);
368369

370+
git_config(git_default_config, NULL);
369371
buf1 = get_tree_descriptor(t+0, argv[1]);
370372
buf2 = get_tree_descriptor(t+1, argv[2]);
371373
buf3 = get_tree_descriptor(t+2, argv[3]);

builtin/mktag.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "builtin.h"
22
#include "tag.h"
3+
#include "config.h"
34

45
/*
56
* A signature file has a very simple fixed format: four lines
@@ -156,6 +157,7 @@ int cmd_mktag(int argc, const char **argv, const char *prefix)
156157
if (argc != 1)
157158
usage("git mktag");
158159

160+
git_config(git_default_config, NULL);
159161
if (strbuf_read(&buf, 0, 4096) < 0) {
160162
die_errno("could not read from stdin");
161163
}

builtin/mktree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "quote.h"
88
#include "tree.h"
99
#include "parse-options.h"
10+
#include "config.h"
1011

1112
static struct treeent {
1213
unsigned mode;
@@ -156,6 +157,7 @@ int cmd_mktree(int ac, const char **av, const char *prefix)
156157
OPT_END()
157158
};
158159

160+
git_config(git_default_config, NULL);
159161
ac = parse_options(ac, av, prefix, option, mktree_usage, 0);
160162
getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf;
161163

builtin/pack-refs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "builtin.h"
22
#include "parse-options.h"
33
#include "refs.h"
4+
#include "config.h"
45

56
static char const * const pack_refs_usage[] = {
67
N_("git pack-refs [<options>]"),
@@ -15,6 +16,7 @@ int cmd_pack_refs(int argc, const char **argv, const char *prefix)
1516
OPT_BIT(0, "prune", &flags, N_("prune loose refs (default)"), PACK_REFS_PRUNE),
1617
OPT_END(),
1718
};
19+
git_config(git_default_config, NULL);
1820
if (parse_options(argc, argv, prefix, opts, pack_refs_usage, 0))
1921
usage_with_options(pack_refs_usage, opts);
2022
return refs_pack_refs(get_main_ref_store(), flags);

builtin/prune-packed.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "progress.h"
44
#include "parse-options.h"
55
#include "packfile.h"
6+
#include "config.h"
67

78
static const char * const prune_packed_usage[] = {
89
N_("git prune-packed [-n | --dry-run] [-q | --quiet]"),
@@ -59,6 +60,7 @@ int cmd_prune_packed(int argc, const char **argv, const char *prefix)
5960
OPT_END()
6061
};
6162

63+
git_config(git_default_config, NULL);
6264
argc = parse_options(argc, argv, prefix, prune_packed_options,
6365
prune_packed_usage, 0);
6466

builtin/prune.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "reachable.h"
77
#include "parse-options.h"
88
#include "progress.h"
9+
#include "config.h"
910

1011
static const char * const prune_usage[] = {
1112
N_("git prune [-n] [-v] [--expire <time>] [--] [<head>...]"),
@@ -111,6 +112,8 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
111112
};
112113
char *s;
113114

115+
git_config(git_default_config, NULL);
116+
114117
expire = TIME_MAX;
115118
save_commit_buffer = 0;
116119
check_replace_refs = 0;

builtin/reflog.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ static const char reflog_usage[] =
728728

729729
int cmd_reflog(int argc, const char **argv, const char *prefix)
730730
{
731+
git_config(git_default_config, NULL);
731732
if (argc > 1 && !strcmp(argv[1], "-h"))
732733
usage(reflog_usage);
733734

builtin/remote-ext.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "transport.h"
33
#include "run-command.h"
44
#include "pkt-line.h"
5+
#include "config.h"
56

67
static const char usage_msg[] =
78
"git remote-ext <remote> <url>";
@@ -198,5 +199,6 @@ int cmd_remote_ext(int argc, const char **argv, const char *prefix)
198199
if (argc != 3)
199200
usage(usage_msg);
200201

202+
git_config(git_default_config, NULL);
201203
return command_loop(argv[2]);
202204
}

builtin/remote.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,7 @@ int cmd_remote(int argc, const char **argv, const char *prefix)
16001600
};
16011601
int result;
16021602

1603+
git_config(git_default_config, NULL);
16031604
argc = parse_options(argc, argv, prefix, options, builtin_remote_usage,
16041605
PARSE_OPT_STOP_AT_NON_OPTION);
16051606

builtin/rev-parse.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
419419
struct option *opts = NULL;
420420
int onb = 0, osz = 0, unb = 0, usz = 0;
421421

422+
git_config(git_default_config, NULL);
422423
strbuf_addstr(&parsed, "set --");
423424
argc = parse_options(argc, argv, prefix, parseopt_opts, parseopt_usage,
424425
PARSE_OPT_KEEP_DASHDASH);

builtin/send-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static int send_pack_config(const char *k, const char *v, void *cb)
120120
}
121121
}
122122
}
123-
return 0;
123+
return git_default_config(k, v, cb);
124124
}
125125

126126
int cmd_send_pack(int argc, const char **argv, const char *prefix)

builtin/show-ref.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "tag.h"
66
#include "string-list.h"
77
#include "parse-options.h"
8+
#include "config.h"
89

910
static const char * const show_ref_usage[] = {
1011
N_("git show-ref [-q | --quiet] [--verify] [--head] [-d | --dereference] [-s | --hash[=<n>]] [--abbrev[=<n>]] [--tags] [--heads] [--] [<pattern>...]"),
@@ -180,6 +181,7 @@ static const struct option show_ref_options[] = {
180181

181182
int cmd_show_ref(int argc, const char **argv, const char *prefix)
182183
{
184+
git_config(git_default_config, NULL);
183185
argc = parse_options(argc, argv, prefix, show_ref_options,
184186
show_ref_usage, 0);
185187

builtin/stripspace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
4545
if (argc)
4646
usage_with_options(stripspace_usage, options);
4747

48-
if (mode == STRIP_COMMENTS || mode == COMMENT_LINES) {
48+
if (mode == STRIP_COMMENTS || mode == COMMENT_LINES)
4949
setup_git_directory_gently(NULL);
50-
git_config(git_default_config, NULL);
51-
}
50+
git_config(git_default_config, NULL);
5251

5352
if (strbuf_read(&buf, 0, 1024) < 0)
5453
die_errno("could not read the input");

0 commit comments

Comments
 (0)