diff options
Diffstat (limited to 'archive.c')
-rw-r--r-- | archive.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -387,17 +387,27 @@ static int parse_archive_args(int argc, const char **argv, int write_archive(int argc, const char **argv, const char *prefix, int setup_prefix) { + int nongit = 0; const struct archiver *ar = NULL; struct archiver_args args; - argc = parse_archive_args(argc, argv, &ar, &args); if (setup_prefix && prefix == NULL) - prefix = setup_git_directory(); + prefix = setup_git_directory_gently(&nongit); + + git_config(git_default_config, NULL); + + argc = parse_archive_args(argc, argv, &ar, &args); + if (nongit) { + /* + * We know this will die() with an error, so we could just + * die ourselves; but its error message will be more specific + * than what we could write here. + */ + setup_git_directory(); + } parse_treeish_arg(argv, &args, prefix); parse_pathspec_arg(argv + 1, &args); - git_config(git_default_config, NULL); - return ar->write_archive(&args); } |