diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-10-18 11:40:48 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-10-18 11:40:48 +0900 |
commit | f1afbb063ff86e40caeaee31146f62c7a3c10c57 (patch) | |
tree | f0f53736727b23d496cd4b1e27adb11e6d0dc147 /builtin/log.c | |
parent | Merge branch 'bb/compat-util-comment-fix' (diff) | |
parent | format-patch: create leading components of output directory (diff) | |
download | tgif-f1afbb063ff86e40caeaee31146f62c7a3c10c57.tar.xz |
Merge branch 'bw/format-patch-o-create-leading-dirs'
"git format-patch -o <outdir>" did an equivalent of "mkdir <outdir>"
not "mkdir -p <outdir>", which is being corrected.
* bw/format-patch-o-create-leading-dirs:
format-patch: create leading components of output directory
Diffstat (limited to 'builtin/log.c')
-rw-r--r-- | builtin/log.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/builtin/log.c b/builtin/log.c index c4b35fdaf9..89873d2dc2 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1766,10 +1766,26 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) setup_pager(); if (output_directory) { + int saved; if (rev.diffopt.use_color != GIT_COLOR_ALWAYS) rev.diffopt.use_color = GIT_COLOR_NEVER; if (use_stdout) die(_("standard output, or directory, which one?")); + /* + * We consider <outdir> as 'outside of gitdir', therefore avoid + * applying adjust_shared_perm in s-c-l-d. + */ + saved = get_shared_repository(); + set_shared_repository(0); + switch (safe_create_leading_directories_const(output_directory)) { + case SCLD_OK: + case SCLD_EXISTS: + break; + default: + die(_("could not create leading directories " + "of '%s'"), output_directory); + } + set_shared_repository(saved); if (mkdir(output_directory, 0777) < 0 && errno != EEXIST) die_errno(_("could not create directory '%s'"), output_directory); |