summaryrefslogtreecommitdiff
path: root/builtin-log.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <junkio@cox.net>2006-06-06 14:31:29 -0700
committerLibravatar Junio C Hamano <junkio@cox.net>2006-06-06 14:31:29 -0700
commit68a40e5096add9a4d8f2dc0fecce19e9438eaba1 (patch)
treeee8b10943b4f5275903f0b18a6b01090fe5bd60c /builtin-log.c
parentMerge branch 'vb/sendemail' into next (diff)
parentref-log: style fixes. (diff)
downloadtgif-68a40e5096add9a4d8f2dc0fecce19e9438eaba1.tar.xz
Merge branch 'jc/lockfile' into next
* jc/lockfile: ref-log: style fixes. refs.c: convert it to use lockfile interface. Make index file locking code reusable to others. HTTP cleanup HTTP cleanup git-format-patch: add --output-directory long option again
Diffstat (limited to 'builtin-log.c')
-rw-r--r--builtin-log.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/builtin-log.c b/builtin-log.c
index 6612f4c2a8..29a885121d 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -103,7 +103,7 @@ static int git_format_config(const char *var, const char *value)
static FILE *realstdout = NULL;
-static char *output_directory = NULL;
+static const char *output_directory = NULL;
static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
{
@@ -206,14 +206,14 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
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], "--output-directory") ||
+ !strcmp(argv[i], "-o")) {
i++;
+ if (argc <= i)
+ die("Which directory?");
+ if (output_directory)
+ die("Two output directories?");
+ output_directory = argv[i];
}
else if (!strcmp(argv[i], "--signoff") ||
!strcmp(argv[i], "-s")) {
@@ -243,6 +243,14 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
if (argc > 1)
die ("unrecognized argument: %s", argv[1]);
+ if (output_directory) {
+ if (use_stdout)
+ die("standard output, or directory, which one?");
+ 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);
@@ -293,8 +301,6 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
if (!use_stdout)
fclose(stdout);
}
- if (output_directory)
- free(output_directory);
free(list);
return 0;
}