Skip to content

Commit

Permalink
Merge branch 'core-longpaths-everywhere'
Browse files Browse the repository at this point in the history
Git for Windows supports the core.longPaths config setting to allow
writing/reading long paths via the \\?\ trick for a long time now.

However, for that support to work, it is absolutely necessary that
git_default_config() is given a chance to parse the config. Otherwise
Git will be non the wiser.

So let's make sure that as many commands that previously failed to
parse the core.* settings now do that, implicitly enabling long path
support in a lot more places.

Note: this is not a perfect solution, and it cannot be, as there is
a chicken-and-egg problem in reading the config itself...

This fixes #1218

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
Git for Windows Build Agent committed Sep 6, 2017
2 parents 05f2fb0 + 8c56c54 commit 0b73a41
Show file tree
Hide file tree
Showing 35 changed files with 69 additions and 8 deletions.
2 changes: 2 additions & 0 deletions builtin/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions builtin/bisect--helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "cache.h"
#include "parse-options.h"
#include "bisect.h"
#include "config.h"

static const char * const git_bisect_helper_usage[] = {
N_("git bisect--helper --next-all [--no-checkout]"),
Expand All @@ -20,6 +21,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);

Expand Down
2 changes: 2 additions & 0 deletions builtin/bundle.c
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions builtin/check-ref-format.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] [<options>] <refname>\n"
Expand Down Expand Up @@ -55,6 +56,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);

Expand Down
2 changes: 2 additions & 0 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
struct refspec *refspec;
const char *fetch_pattern;

git_config(platform_core_config, NULL);

packet_trace_identity("clone");
argc = parse_options(argc, argv, prefix, builtin_clone_options,
builtin_clone_usage, 0);
Expand Down
2 changes: 2 additions & 0 deletions builtin/column.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions builtin/credential.c
Original file line number Diff line number Diff line change
@@ -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]";
Expand All @@ -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];
Expand Down
3 changes: 3 additions & 0 deletions builtin/fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "remote.h"
#include "connect.h"
#include "sha1-array.h"
#include "config.h"

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

git_config(git_default_config, NULL);

packet_trace_identity("fetch-pack");

memset(&args, 0, sizeof(args));
Expand Down
2 changes: 2 additions & 0 deletions builtin/get-tar-commit-id.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 < HEADERSIZE)
die("git get-tar-commit-id: read error");
Expand Down
2 changes: 2 additions & 0 deletions builtin/interpret-trailers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <token>[(=|:)<value>])...] [<file>...]"),
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,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) {
Expand Down
2 changes: 2 additions & 0 deletions builtin/ls-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "cache.h"
#include "transport.h"
#include "remote.h"
#include "config.h"

static const char * const ls_remote_usage[] = {
N_("git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n"
Expand Down Expand Up @@ -71,6 +72,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 *));
Expand Down
2 changes: 2 additions & 0 deletions builtin/mailinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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=<encoding> | -n] [--scissors | --no-scissors] <msg> <patch> < mail >info";
Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions builtin/mailsplit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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<prec>] [-f<n>] [-b] [--keep-cr] -o<directory> [(<mbox>|<Maildir>)...]";
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions builtin/merge-index.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "run-command.h"
#include "config.h"

static const char *pgm;
static int one_shot, quiet;
Expand Down Expand Up @@ -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] <merge-program> (-a | [--] [<filename>...])");

Expand Down
2 changes: 2 additions & 0 deletions builtin/merge-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "blob.h"
#include "exec_cmd.h"
#include "merge-blobs.h"
#include "config.h"

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

Expand Down Expand Up @@ -366,6 +367,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]);
Expand Down
2 changes: 2 additions & 0 deletions builtin/mktag.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "tag.h"
#include "config.h"

/*
* A signature file has a very simple fixed format: four lines
Expand Down Expand Up @@ -156,6 +157,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");
}
Expand Down
2 changes: 2 additions & 0 deletions builtin/mktree.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "quote.h"
#include "tree.h"
#include "parse-options.h"
#include "config.h"

static struct treeent {
unsigned mode;
Expand Down Expand Up @@ -156,6 +157,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;

Expand Down
2 changes: 2 additions & 0 deletions builtin/pack-refs.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "builtin.h"
#include "parse-options.h"
#include "refs.h"
#include "config.h"

static char const * const pack_refs_usage[] = {
N_("git pack-refs [<options>]"),
Expand All @@ -15,6 +16,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(), flags);
Expand Down
2 changes: 2 additions & 0 deletions builtin/prune-packed.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "progress.h"
#include "parse-options.h"
#include "packfile.h"
#include "config.h"

static const char * const prune_packed_usage[] = {
N_("git prune-packed [-n | --dry-run] [-q | --quiet]"),
Expand Down Expand Up @@ -59,6 +60,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);

Expand Down
3 changes: 3 additions & 0 deletions builtin/prune.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "reachable.h"
#include "parse-options.h"
#include "progress.h"
#include "config.h"

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

git_config(git_default_config, NULL);

expire = TIME_MAX;
save_commit_buffer = 0;
check_replace_refs = 0;
Expand Down
1 change: 1 addition & 0 deletions builtin/reflog.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ static const char reflog_usage[] =

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

Expand Down
2 changes: 2 additions & 0 deletions builtin/remote-ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "transport.h"
#include "run-command.h"
#include "pkt-line.h"
#include "config.h"

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

git_config(git_default_config, NULL);
return command_loop(argv[2]);
}
1 change: 1 addition & 0 deletions builtin/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,7 @@ int cmd_remote(int argc, const char **argv, const char *prefix)
};
int result;

git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options, builtin_remote_usage,
PARSE_OPT_STOP_AT_NON_OPTION);

Expand Down
1 change: 1 addition & 0 deletions builtin/rev-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
struct option *opts = NULL;
int onb = 0, osz = 0, unb = 0, usz = 0;

git_config(git_default_config, NULL);
strbuf_addstr(&parsed, "set --");
argc = parse_options(argc, argv, prefix, parseopt_opts, parseopt_usage,
PARSE_OPT_KEEP_DASHDASH);
Expand Down
2 changes: 1 addition & 1 deletion builtin/send-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static int send_pack_config(const char *k, const char *v, void *cb)
}
}
}
return 0;
return git_default_config(k, v, cb);
}

int cmd_send_pack(int argc, const char **argv, const char *prefix)
Expand Down
2 changes: 2 additions & 0 deletions builtin/show-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "tag.h"
#include "string-list.h"
#include "parse-options.h"
#include "config.h"

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

int cmd_show_ref(int argc, const char **argv, const char *prefix)
{
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, show_ref_options,
show_ref_usage, 0);

Expand Down
5 changes: 2 additions & 3 deletions builtin/stripspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
if (argc)
usage_with_options(stripspace_usage, options);

if (mode == STRIP_COMMENTS || mode == COMMENT_LINES) {
if (mode == STRIP_COMMENTS || mode == COMMENT_LINES)
setup_git_directory_gently(NULL);
git_config(git_default_config, NULL);
}
git_config(git_default_config, NULL);

if (strbuf_read(&buf, 0, 1024) < 0)
die_errno("could not read the input");
Expand Down
Loading

0 comments on commit 0b73a41

Please sign in to comment.