Set default diff output format after parsing command line
Initialize output_format to 0 instead of DIFF_FORMAT_RAW so that we can see later if any command line options changed it. Default value is set only if output format was not specified. Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Timo Hirvonen committed
Jun 24, 2006 at 20:24 UTC
c9b5ef998a3027d9f11b0820bb13896096833ccb
7 files changed
+18
-3
builtin-diff-files.c
+3
@@ -36,6 +36,9 @@ int cmd_diff_files(int argc, const char **argv, char **envp)
36
usage(diff_files_usage);
37
argv++; argc--;
38
}
39
+ if (!rev.diffopt.output_format)
40
+ rev.diffopt.output_format = DIFF_FORMAT_RAW;
41
+
42
/*
43
* Make sure there are NO revision (i.e. pending object) parameter,
44
* rev.max_count is reasonable (0 <= n <= 3),
builtin-diff-index.c
+3
@@ -28,6 +28,9 @@ int cmd_diff_index(int argc, const char **argv, char **envp)
28
else
29
usage(diff_cache_usage);
30
}
31
+ if (!rev.diffopt.output_format)
32
+ rev.diffopt.output_format = DIFF_FORMAT_RAW;
33
+
34
/*
35
* Make sure there is one revision (i.e. pending object),
36
* and there is no revision filtering parameters.
builtin-diff-stages.c
+3
@@ -85,6 +85,9 @@ int cmd_diff_stages(int ac, const char **av, char **envp)
85
ac--; av++;
86
}
87
88
+ if (!diff_options.output_format)
89
+ diff_options.output_format = DIFF_FORMAT_RAW;
90
+
91
if (ac < 3 ||
92
sscanf(av[1], "%d", &stage1) != 1 ||
93
! (0 <= stage1 && stage1 <= 3) ||
builtin-diff-tree.c
+3
@@ -84,6 +84,9 @@ int cmd_diff_tree(int argc, const char **argv, char **envp)
84
usage(diff_tree_usage);
85
}
86
87
+ if (!opt->diffopt.output_format)
88
+ opt->diffopt.output_format = DIFF_FORMAT_RAW;
89
+
90
/*
91
* NOTE! We expect "a ^b" to be equal to "a..b", so we
92
* reverse the order of the objects if the second one
builtin-diff.c
+3
-1
@@ -252,9 +252,11 @@ int cmd_diff(int argc, const char **argv, char **envp)
252
253
git_config(git_diff_config);
254
init_revisions(&rev);
255
- rev.diffopt.output_format = DIFF_FORMAT_PATCH;
255
256
argc = setup_revisions(argc, argv, &rev, NULL);
257
+ if (!rev.diffopt.output_format)
258
+ rev.diffopt.output_format = DIFF_FORMAT_PATCH;
259
+
260
/* Do we have --cached and not have a pending object, then
261
* default to HEAD by hand. Eek.
262
*/
builtin-log.c
+3
-1
@@ -178,7 +178,6 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
178
rev.diff = 1;
179
rev.combine_merges = 0;
180
rev.ignore_merges = 1;
181
- rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
181
182
git_config(git_format_config);
183
rev.extra_headers = extra_headers;
@@ -247,6 +246,9 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
246
if (argc > 1)
247
die ("unrecognized argument: %s", argv[1]);
248
249
+ if (!rev.diffopt.output_format)
250
+ rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
251
+
252
if (output_directory) {
253
if (use_stdout)
254
die("standard output, or directory, which one?");
diff.c
-1
@@ -1420,7 +1420,6 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
1420
void diff_setup(struct diff_options *options)
1421
{
1422
memset(options, 0, sizeof(*options));
1423
- options->output_format = DIFF_FORMAT_RAW;
1423
options->line_termination = '\n';
1424
options->break_opt = -1;
1425
options->rename_limit = -1;