git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-format-patch: add --output-directory long option again
@ 2006-06-06 14:19 Dennis Stosberg
  2006-06-06 14:53 ` Johannes Schindelin
  2006-06-06 15:46 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Dennis Stosberg @ 2006-06-06 14:19 UTC (permalink / raw)
  To: git

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@stosberg.net>
---
 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-06-06 18:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-06 14:19 [PATCH] git-format-patch: add --output-directory long option again Dennis Stosberg
2006-06-06 14:53 ` Johannes Schindelin
2006-06-06 15:46 ` Junio C Hamano
2006-06-06 18:22   ` Dennis Stosberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).