Additionally this fixes two minor issues: (1) git-format-patch left an empty directory behind if an invalid option was given on the command line. (2) mkdir() was called with a NULL argument (argv[argc]), if -o was the last option on the command line. Signed-off-by: Dennis Stosberg <dennis@xxxxxxxxxxxx> --- builtin-log.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/builtin-log.c b/builtin-log.c index 6612f4c..0018d13 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -206,14 +206,12 @@ int cmd_format_patch(int argc, const cha keep_subject = 1; rev.total = -1; } - else if (!strcmp(argv[i], "-o")) { - if (argc < 3) - die ("Which directory?"); - if (mkdir(argv[i + 1], 0777) < 0 && errno != EEXIST) - die("Could not create directory %s", - argv[i + 1]); - output_directory = strdup(argv[i + 1]); + else if (!strcmp(argv[i], "-o") || + !strcmp(argv[i], "--output-directory")) { i++; + if (i == argc) + die ("Which directory?"); + output_directory = strdup(argv[i]); } else if (!strcmp(argv[i], "--signoff") || !strcmp(argv[i], "-s")) { @@ -243,6 +241,12 @@ int cmd_format_patch(int argc, const cha if (argc > 1) die ("unrecognized argument: %s", argv[1]); + if (output_directory && !stdout) { + if (mkdir(output_directory, 0777) < 0 && errno != EEXIST) + die("Could not create directory %s", + output_directory); + } + if (rev.pending_objects && rev.pending_objects->next == NULL) { rev.pending_objects->item->flags |= UNINTERESTING; add_head(&rev); -- 1.3.3+git20060602-dest0 - : send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html