Subject: [PATCH] git-format-patch: fix bug using -o in subdirectories

From: Matthias Lederhofer <[email-masked]>
Date: Thu, 28 Sep 2006 21:55:35 +0200

This was introduced by me in commit v1.4.2.1-gc08e524.

Signed-off-by: Matthias Lederhofer <[email-masked]>
---
Junio C Hamano <[email-masked]> wrote:
> "Nguyen Thai Ngoc Duy" <[email-masked]> writes:
> 
> > This patch works great. I assume you forgot it?
> 
> Thanks for reminding.
Argh, there is a bug.  When prefix is not NULL and -o is specified
git-format-patch fails:
~/src/git/a% ../git-format-patch -o ./b HEAD~1
fatal: Two output directories?
---
 builtin-log.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/builtin-log.c b/builtin-log.c
index 130b53a..9d1ceae 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -270,8 +270,6 @@ int cmd_format_patch(int argc, const cha
 
 	rev.extra_headers = extra_headers;
 
-	output_directory = prefix;
-
 	/*
 	 * Parse the arguments before setup_revisions(), or something
 	 * like "git fmt-patch -o a123 HEAD^.." may fail; a123 is
@@ -350,6 +348,9 @@ int cmd_format_patch(int argc, const cha
 	if (!rev.diffopt.output_format)
 		rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
 
+	if (!output_directory)
+		output_directory = prefix;
+
 	if (output_directory) {
 		if (use_stdout)
 			die("standard output, or directory, which one?");
-- 
1.4.2.1.ge767