Skip to content

Commit 4dcf951

Browse files
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 <[email protected]>
1 parent 2999837 commit 4dcf951

31 files changed

+56
-4
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
{
@@ -93,6 +94,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
9394
OPT_END()
9495
};
9596

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

builtin/bisect--helper.c

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

1314
static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
1415
static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV")
@@ -1322,6 +1323,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
13221323
};
13231324
struct bisect_terms terms = { .term_good = NULL, .term_bad = NULL };
13241325

1326+
git_config(git_default_config, NULL);
13251327
argc = parse_options(argc, argv, prefix, options,
13261328
git_bisect_helper_usage,
13271329
PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_UNKNOWN);

builtin/bundle.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 "cache.h"
55
#include "bundle.h"
6+
#include "config.h"
67

78
/*
89
* Basic handler for bundle files to connect repositories via sneakernet.
@@ -110,6 +111,7 @@ static int cmd_bundle_verify(int argc, const char **argv, const char *prefix) {
110111
};
111112
char *bundle_file;
112113

114+
git_config(git_default_config, NULL);
113115
argc = parse_options_cmd_bundle(argc, argv, prefix,
114116
builtin_bundle_verify_usage, options, &bundle_file);
115117
/* bundle internals use argv[1] as further parameters */

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
@@ -900,6 +900,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
900900
struct transport_ls_refs_options transport_ls_refs_options =
901901
TRANSPORT_LS_REFS_OPTIONS_INIT;
902902

903+
git_config(git_default_core_config, NULL);
904+
903905
packet_trace_identity("clone");
904906

905907
git_config(git_clone_config, NULL);

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(git_default_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-store.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "credential.h"
55
#include "string-list.h"
66
#include "parse-options.h"
7+
#include "config.h"
78

89
static struct lock_file credential_lock;
910

@@ -165,6 +166,8 @@ int cmd_credential_store(int argc, const char **argv, const char *prefix)
165166

166167
umask(077);
167168

169+
git_config(git_default_config, NULL);
170+
168171
argc = parse_options(argc, (const char **)argv, prefix, options, usage, 0);
169172
if (argc != 1)
170173
usage_with_options(usage, options);

builtin/fetch-pack.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "connect.h"
66
#include "oid-array.h"
77
#include "protocol.h"
8+
#include "config.h"
89

910
static const char fetch_pack_usage[] =
1011
"git fetch-pack [--all] [--stdin] [--quiet | -q] [--keep | -k] [--thin] "
@@ -57,6 +58,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
5758
struct packet_reader reader;
5859
enum protocol_version version;
5960

61+
git_config(git_default_config, NULL);
6062
fetch_if_missing = 0;
6163

6264
packet_trace_identity("fetch-pack");

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";
@@ -27,6 +28,7 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
2728
if (argc != 1)
2829
usage(builtin_get_tar_commit_id_usage);
2930

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

builtin/log.c

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

2367+
git_config(git_default_config, NULL);
23672368
argc = parse_options(argc, argv, prefix, options, cherry_usage, 0);
23682369

23692370
switch (argc) {

builtin/ls-remote.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "ref-filter.h"
55
#include "remote.h"
66
#include "refs.h"
7+
#include "config.h"
78

89
static const char * const ls_remote_usage[] = {
910
N_("git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n"
@@ -86,6 +87,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
8687

8788
packet_trace_identity("ls-remote");
8889

90+
git_config(git_default_config, NULL);
8991
if (argc > 1) {
9092
int i;
9193
CALLOC_ARRAY(pattern, argc);

builtin/mailinfo.c

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

1213
static const char * const mailinfo_usage[] = {
1314
/* TRANSLATORS: keep <> in "<" mail ">" info. */
@@ -78,6 +79,7 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
7879
OPT_END()
7980
};
8081

82+
git_config(git_default_config, NULL);
8183
setup_mailinfo(&mi);
8284
meta_charset.policy = CHARSET_DEFAULT;
8385

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>)...]";
@@ -277,6 +278,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)
277278
const char **argp;
278279
static const char *stdin_only[] = { "-", NULL };
279280

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

builtin/merge-index.c

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

56
static const char *pgm;
67
static int one_shot, quiet;
@@ -77,6 +78,8 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix)
7778
*/
7879
signal(SIGCHLD, SIG_DFL);
7980

81+
git_config(git_default_config, NULL);
82+
8083
if (argc < 3)
8184
usage("git merge-index [-o] [-q] <merge-program> (-a | [--] [<filename>...])");
8285

builtin/merge-tree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "blob.h"
88
#include "exec-cmd.h"
99
#include "merge-blobs.h"
10+
#include "config.h"
1011

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

@@ -375,6 +376,7 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
375376
if (argc != 4)
376377
usage(merge_tree_usage);
377378

379+
git_config(git_default_config, NULL);
378380
buf1 = get_tree_descriptor(r, t+0, argv[1]);
379381
buf2 = get_tree_descriptor(r, t+1, argv[2]);
380382
buf3 = get_tree_descriptor(r, t+2, argv[3]);

builtin/mktag.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ int cmd_mktag(int argc, const char **argv, const char *prefix)
8484
builtin_mktag_options,
8585
builtin_mktag_usage, 0);
8686

87+
git_config(git_default_config, NULL);
8788
if (strbuf_read(&buf, 0, 0) < 0)
8889
die_errno(_("could not read from stdin"));
8990

builtin/mktree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "tree.h"
99
#include "parse-options.h"
1010
#include "object-store.h"
11+
#include "config.h"
1112

1213
static struct treeent {
1314
unsigned mode;
@@ -164,6 +165,7 @@ int cmd_mktree(int ac, const char **av, const char *prefix)
164165
OPT_END()
165166
};
166167

168+
git_config(git_default_config, NULL);
167169
ac = parse_options(ac, av, prefix, option, mktree_usage, 0);
168170
getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf;
169171

builtin/pack-refs.c

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

78
static char const * const pack_refs_usage[] = {
89
N_("git pack-refs [<options>]"),

builtin/prune-packed.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 "prune-packed.h"
4+
#include "config.h"
45

56
static const char * const prune_packed_usage[] = {
67
"git prune-packed [-n | --dry-run] [-q | --quiet]",
@@ -18,6 +19,7 @@ int cmd_prune_packed(int argc, const char **argv, const char *prefix)
1819
OPT_END()
1920
};
2021

22+
git_config(git_default_config, NULL);
2123
argc = parse_options(argc, argv, prefix, prune_packed_options,
2224
prune_packed_usage, 0);
2325

builtin/prune.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "prune-packed.h"
1010
#include "object-store.h"
1111
#include "shallow.h"
12+
#include "config.h"
1213

1314
static const char * const prune_usage[] = {
1415
N_("git prune [-n] [-v] [--progress] [--expire <time>] [--] [<head>...]"),
@@ -152,6 +153,8 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
152153
};
153154
char *s;
154155

156+
git_config(git_default_config, NULL);
157+
155158
expire = TIME_MAX;
156159
save_commit_buffer = 0;
157160
read_replace_refs = 0;

builtin/reflog.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ int cmd_reflog(int argc, const char **argv, const char *prefix)
408408
OPT_END()
409409
};
410410

411+
git_config(git_default_config, NULL);
411412
argc = parse_options(argc, argv, prefix, options, reflog_usage,
412413
PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_ARGV0 |
413414
PARSE_OPT_KEEP_UNKNOWN |

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
@@ -1736,6 +1736,7 @@ int cmd_remote(int argc, const char **argv, const char *prefix)
17361736
};
17371737
int result;
17381738

1739+
git_config(git_default_config, NULL);
17391740
argc = parse_options(argc, argv, prefix, options, builtin_remote_usage,
17401741
PARSE_OPT_STOP_AT_NON_OPTION);
17411742

builtin/rev-parse.c

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

429+
git_config(git_default_config, NULL);
429430
strbuf_addstr(&parsed, "set --");
430431
argc = parse_options(argc, argv, prefix, parseopt_opts, parseopt_usage,
431432
PARSE_OPT_KEEP_DASHDASH);

builtin/show-index.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 "pack.h"
44
#include "parse-options.h"
5+
#include "config.h"
56

67
static const char *const show_index_usage[] = {
78
"git show-index [--object-format=<hash-algorithm>]",
@@ -23,6 +24,7 @@ int cmd_show_index(int argc, const char **argv, const char *prefix)
2324
OPT_END()
2425
};
2526

27+
git_config(git_default_config, NULL);
2628
argc = parse_options(argc, argv, prefix, show_index_options, show_index_usage, 0);
2729

2830
if (hash_name) {

builtin/show-ref.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "tag.h"
88
#include "string-list.h"
99
#include "parse-options.h"
10+
#include "config.h"
1011

1112
static const char * const show_ref_usage[] = {
1213
N_("git show-ref [-q | --quiet] [--verify] [--head] [-d | --dereference] [-s | --hash[=<n>]] [--abbrev[=<n>]] [--tags] [--heads] [--] [<pattern>...]"),

builtin/stripspace.c

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

49-
if (mode == STRIP_COMMENTS || mode == COMMENT_LINES) {
49+
if (mode == STRIP_COMMENTS || mode == COMMENT_LINES)
5050
setup_git_directory_gently(&nongit);
51-
git_config(git_default_config, NULL);
52-
}
51+
git_config(git_default_config, NULL);
5352

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

builtin/submodule--helper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3399,6 +3399,7 @@ static struct cmd_struct commands[] = {
33993399
int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
34003400
{
34013401
int i;
3402+
git_config(git_default_config, NULL);
34023403
if (argc < 2 || !strcmp(argv[1], "-h"))
34033404
usage("git submodule--helper <command>");
34043405

builtin/upload-archive.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "sideband.h"
99
#include "run-command.h"
1010
#include "strvec.h"
11+
#include "config.h"
1112

1213
static const char upload_archive_usage[] =
1314
"git upload-archive <repo>";
@@ -28,6 +29,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
2829
if (!enter_repo(argv[1], 0))
2930
die("'%s' does not appear to be a git repository", argv[1]);
3031

32+
git_config(git_default_config, NULL);
3133
init_archivers();
3234

3335
/* put received options in sent_argv[] */
@@ -79,6 +81,7 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
7981
{
8082
struct child_process writer = CHILD_PROCESS_INIT;
8183

84+
git_config(git_default_config, NULL);
8285
if (argc == 2 && !strcmp(argv[1], "-h"))
8386
usage(upload_archive_usage);
8487

0 commit comments

Comments
 (0)