From fe33f3e754685be7814d4c1c555c7f4ece05c8f7 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 30 Aug 2017 01:28:22 +0200 Subject: [PATCH] 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 https://github.com/git-for-windows/git/issues/1218 Signed-off-by: Johannes Schindelin --- builtin/archive.c | 2 ++ builtin/bisect--helper.c | 2 ++ builtin/bundle.c | 2 ++ builtin/check-ref-format.c | 2 ++ builtin/clone.c | 1 + builtin/column.c | 2 ++ builtin/credential.c | 3 +++ builtin/fetch-pack.c | 2 ++ builtin/get-tar-commit-id.c | 2 ++ builtin/interpret-trailers.c | 2 ++ builtin/log.c | 1 + builtin/ls-remote.c | 2 ++ builtin/mailinfo.c | 2 ++ builtin/mailsplit.c | 2 ++ builtin/merge-index.c | 3 +++ builtin/merge-tree.c | 2 ++ builtin/mktag.c | 2 ++ builtin/mktree.c | 2 ++ builtin/pack-refs.c | 2 ++ builtin/prune-packed.c | 2 ++ builtin/prune.c | 3 +++ builtin/reflog.c | 1 + builtin/remote-ext.c | 2 ++ builtin/remote.c | 1 + builtin/rev-parse.c | 1 + builtin/show-index.c | 2 ++ builtin/show-ref.c | 2 ++ builtin/stripspace.c | 5 ++--- builtin/submodule--helper.c | 1 + builtin/upload-archive.c | 3 +++ credential-store.c | 3 +++ http-backend.c | 1 + refs.c | 2 +- 33 files changed, 63 insertions(+), 4 deletions(-) diff --git a/builtin/archive.c b/builtin/archive.c index e74f675390d975..27b6984f789a3b 100644 --- a/builtin/archive.c +++ b/builtin/archive.c @@ -9,6 +9,7 @@ #include "parse-options.h" #include "pkt-line.h" #include "sideband.h" +#include "config.h" static void create_output_file(const char *output_file) { @@ -94,6 +95,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix) OPT_END() }; + git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, local_opts, NULL, PARSE_OPT_KEEP_ALL); diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 4b5fadcbe1ae6a..f6742e8077b38a 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -3,6 +3,7 @@ #include "parse-options.h" #include "bisect.h" #include "refs.h" +#include "config.h" static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS") 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) OPT_END() }; + git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, options, git_bisect_helper_usage, 0); diff --git a/builtin/bundle.c b/builtin/bundle.c index d0de59b94ff23e..da8c94123fefe9 100644 --- a/builtin/bundle.c +++ b/builtin/bundle.c @@ -1,6 +1,7 @@ #include "builtin.h" #include "cache.h" #include "bundle.h" +#include "config.h" /* * 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) const char *cmd, *bundle_file; int bundle_fd = -1; + git_config(git_default_config, NULL); if (argc < 3) usage(builtin_bundle_usage); diff --git a/builtin/check-ref-format.c b/builtin/check-ref-format.c index bc67d3f0a83d35..abee1be4721055 100644 --- a/builtin/check-ref-format.c +++ b/builtin/check-ref-format.c @@ -6,6 +6,7 @@ #include "refs.h" #include "builtin.h" #include "strbuf.h" +#include "config.h" static const char builtin_check_ref_format_usage[] = "git check-ref-format [--normalize] [] \n" @@ -58,6 +59,7 @@ int cmd_check_ref_format(int argc, const char **argv, const char *prefix) int flags = 0; const char *refname; + git_config(git_default_config, NULL); if (argc == 2 && !strcmp(argv[1], "-h")) usage(builtin_check_ref_format_usage); diff --git a/builtin/clone.c b/builtin/clone.c index 2c7a1d973a85bc..e62df8ec504e4b 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -900,6 +900,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) struct refspec rs = REFSPEC_INIT_FETCH; struct argv_array ref_prefixes = ARGV_ARRAY_INIT; + git_config(platform_core_config, NULL); fetch_if_missing = 0; packet_trace_identity("clone"); diff --git a/builtin/column.c b/builtin/column.c index 5228ccf37a5c8f..a046a1d5959ea3 100644 --- a/builtin/column.c +++ b/builtin/column.c @@ -34,6 +34,8 @@ int cmd_column(int argc, const char **argv, const char *prefix) OPT_END() }; + git_config(platform_core_config, NULL); + /* This one is special and must be the first one */ if (argc > 1 && starts_with(argv[1], "--command=")) { command = argv[1] + 10; diff --git a/builtin/credential.c b/builtin/credential.c index 879acfbcda7514..d75dcdc64aa3c3 100644 --- a/builtin/credential.c +++ b/builtin/credential.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "credential.h" #include "builtin.h" +#include "config.h" static const char usage_msg[] = "git credential [fill|approve|reject]"; @@ -10,6 +11,8 @@ int cmd_credential(int argc, const char **argv, const char *prefix) const char *op; struct credential c = CREDENTIAL_INIT; + git_config(git_default_config, NULL); + if (argc != 2 || !strcmp(argv[1], "-h")) usage(usage_msg); op = argv[1]; diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index 1a1bc63566b44b..208a97a9163e23 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -5,6 +5,7 @@ #include "connect.h" #include "sha1-array.h" #include "protocol.h" +#include "config.h" static const char fetch_pack_usage[] = "git fetch-pack [--all] [--stdin] [--quiet | -q] [--keep | -k] [--thin] " @@ -55,6 +56,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) struct string_list deepen_not = STRING_LIST_INIT_DUP; struct packet_reader reader; + git_config(git_default_config, NULL); fetch_if_missing = 0; packet_trace_identity("fetch-pack"); diff --git a/builtin/get-tar-commit-id.c b/builtin/get-tar-commit-id.c index 2706fcfaf2261e..afb3dbf9176f52 100644 --- a/builtin/get-tar-commit-id.c +++ b/builtin/get-tar-commit-id.c @@ -6,6 +6,7 @@ #include "tar.h" #include "builtin.h" #include "quote.h" +#include "config.h" static const char builtin_get_tar_commit_id_usage[] = "git get-tar-commit-id"; @@ -25,6 +26,7 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix) if (argc != 1) usage(builtin_get_tar_commit_id_usage); + git_config(git_default_config, NULL); n = read_in_full(0, buffer, HEADERSIZE); if (n < 0) die_errno("git get-tar-commit-id: read error"); diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c index b742539d4de203..4778fe23205f84 100644 --- a/builtin/interpret-trailers.c +++ b/builtin/interpret-trailers.c @@ -10,6 +10,7 @@ #include "parse-options.h" #include "string-list.h" #include "trailer.h" +#include "config.h" static const char * const git_interpret_trailers_usage[] = { N_("git interpret-trailers [--in-place] [--trim-empty] [(--trailer [(=|:)])...] [...]"), @@ -109,6 +110,7 @@ int cmd_interpret_trailers(int argc, const char **argv, const char *prefix) OPT_END() }; + git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, options, git_interpret_trailers_usage, 0); diff --git a/builtin/log.c b/builtin/log.c index e094560d9abca6..4532c55a871c8c 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1915,6 +1915,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) OPT_END() }; + git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, options, cherry_usage, 0); switch (argc) { diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c index 1a25df7ee15b45..a917af265d49f2 100644 --- a/builtin/ls-remote.c +++ b/builtin/ls-remote.c @@ -4,6 +4,7 @@ #include "ref-filter.h" #include "remote.h" #include "refs.h" +#include "config.h" static const char * const ls_remote_usage[] = { N_("git ls-remote [--heads] [--tags] [--refs] [--upload-pack=]\n" @@ -84,6 +85,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) PARSE_OPT_STOP_AT_NON_OPTION); dest = argv[0]; + git_config(git_default_config, NULL); if (argc > 1) { int i; pattern = xcalloc(argc, sizeof(const char *)); diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index cfb667a594c845..150fe3d942371d 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -7,6 +7,7 @@ #include "utf8.h" #include "strbuf.h" #include "mailinfo.h" +#include "config.h" static const char mailinfo_usage[] = "git mailinfo [-k | -b] [-m | --message-id] [-u | --encoding= | -n] [--scissors | --no-scissors] < mail >info"; @@ -18,6 +19,7 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix) int status; char *msgfile, *patchfile; + git_config(git_default_config, NULL); setup_mailinfo(&mi); def_charset = get_commit_output_encoding(); diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c index 664400b8169b67..472d2eb8a4d6f7 100644 --- a/builtin/mailsplit.c +++ b/builtin/mailsplit.c @@ -8,6 +8,7 @@ #include "builtin.h" #include "string-list.h" #include "strbuf.h" +#include "config.h" static const char git_mailsplit_usage[] = "git mailsplit [-d] [-f] [-b] [--keep-cr] -o [(|)...]"; @@ -276,6 +277,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix) const char **argp; static const char *stdin_only[] = { "-", NULL }; + git_config(git_default_config, NULL); for (argp = argv+1; *argp; argp++) { const char *arg = *argp; diff --git a/builtin/merge-index.c b/builtin/merge-index.c index c99443b095bd8a..caaef0c03d7431 100644 --- a/builtin/merge-index.c +++ b/builtin/merge-index.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "run-command.h" +#include "config.h" static const char *pgm; static int one_shot, quiet; @@ -74,6 +75,8 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix) */ signal(SIGCHLD, SIG_DFL); + git_config(git_default_config, NULL); + if (argc < 3) usage("git merge-index [-o] [-q] (-a | [--] [...])"); diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index f8023bae1e2ece..ffbcf8b6777616 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -6,6 +6,7 @@ #include "blob.h" #include "exec-cmd.h" #include "merge-blobs.h" +#include "config.h" static const char merge_tree_usage[] = "git merge-tree "; @@ -369,6 +370,7 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix) if (argc != 4) usage(merge_tree_usage); + git_config(git_default_config, NULL); buf1 = get_tree_descriptor(t+0, argv[1]); buf2 = get_tree_descriptor(t+1, argv[2]); buf3 = get_tree_descriptor(t+2, argv[3]); diff --git a/builtin/mktag.c b/builtin/mktag.c index 6fb7dc8578d685..ab9468713b2ff0 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -2,6 +2,7 @@ #include "tag.h" #include "replace-object.h" #include "object-store.h" +#include "config.h" /* * A signature file has a very simple fixed format: four lines @@ -158,6 +159,7 @@ int cmd_mktag(int argc, const char **argv, const char *prefix) if (argc != 1) usage("git mktag"); + git_config(git_default_config, NULL); if (strbuf_read(&buf, 0, 4096) < 0) { die_errno("could not read from stdin"); } diff --git a/builtin/mktree.c b/builtin/mktree.c index 2dc4ad6ba8f227..426f22734efa61 100644 --- a/builtin/mktree.c +++ b/builtin/mktree.c @@ -8,6 +8,7 @@ #include "tree.h" #include "parse-options.h" #include "object-store.h" +#include "config.h" static struct treeent { unsigned mode; @@ -157,6 +158,7 @@ int cmd_mktree(int ac, const char **av, const char *prefix) OPT_END() }; + git_config(git_default_config, NULL); ac = parse_options(ac, av, prefix, option, mktree_usage, 0); getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf; diff --git a/builtin/pack-refs.c b/builtin/pack-refs.c index f3353564f99205..ce8a5e0fc4467c 100644 --- a/builtin/pack-refs.c +++ b/builtin/pack-refs.c @@ -2,6 +2,7 @@ #include "parse-options.h" #include "refs.h" #include "repository.h" +#include "config.h" static char const * const pack_refs_usage[] = { N_("git pack-refs []"), @@ -16,6 +17,7 @@ int cmd_pack_refs(int argc, const char **argv, const char *prefix) OPT_BIT(0, "prune", &flags, N_("prune loose refs (default)"), PACK_REFS_PRUNE), OPT_END(), }; + git_config(git_default_config, NULL); if (parse_options(argc, argv, prefix, opts, pack_refs_usage, 0)) usage_with_options(pack_refs_usage, opts); return refs_pack_refs(get_main_ref_store(the_repository), flags); diff --git a/builtin/prune-packed.c b/builtin/prune-packed.c index a9e7b552b9d117..99189d22005d2c 100644 --- a/builtin/prune-packed.c +++ b/builtin/prune-packed.c @@ -4,6 +4,7 @@ #include "parse-options.h" #include "packfile.h" #include "object-store.h" +#include "config.h" static const char * const prune_packed_usage[] = { N_("git prune-packed [-n | --dry-run] [-q | --quiet]"), @@ -60,6 +61,7 @@ int cmd_prune_packed(int argc, const char **argv, const char *prefix) OPT_END() }; + git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, prune_packed_options, prune_packed_usage, 0); diff --git a/builtin/prune.c b/builtin/prune.c index 4916a4daa264ee..eea876cc063e33 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -7,6 +7,7 @@ #include "parse-options.h" #include "progress.h" #include "object-store.h" +#include "config.h" static const char * const prune_usage[] = { N_("git prune [-n] [-v] [--progress] [--expire