git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dennis Stosberg <dennis@stosberg.net>
To: git@vger.kernel.org
Subject: [PATCH] git-format-patch: add --output-directory long option again
Date: Tue, 6 Jun 2006 16:19:46 +0200	[thread overview]
Message-ID: <20060606141946.G59b8a1fd@leonov.stosberg.net> (raw)

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

             reply	other threads:[~2006-06-06 14:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-06 14:19 Dennis Stosberg [this message]
2006-06-06 14:53 ` [PATCH] git-format-patch: add --output-directory long option again Johannes Schindelin
2006-06-06 15:46 ` Junio C Hamano
2006-06-06 18:22   ` Dennis Stosberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060606141946.G59b8a1fd@leonov.stosberg.net \
    --to=dennis@stosberg.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).