Make --raw option available for all diff commands
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:23 UTC
a610786f4bc282410d348aba97316115a57740a0
2 files changed
+14
-36
builtin-diff.c
+12
-36
@@ -39,8 +39,6 @@ static int builtin_diff_files(struct rev_info *revs,
39
revs->max_count = 3;
40
else if (!strcmp(arg, "-q"))
41
silent = 1;
42
- else if (!strcmp(arg, "--raw"))
43
- revs->diffopt.output_format = DIFF_FORMAT_RAW;
42
else
43
usage(builtin_diff_usage);
44
argv++; argc--;
@@ -107,14 +105,9 @@ static int builtin_diff_b_f(struct rev_info *revs,
105
/* Blob vs file in the working tree*/
106
struct stat st;
107
110
- while (1 < argc) {
111
- const char *arg = argv[1];
112
- if (!strcmp(arg, "--raw"))
113
- revs->diffopt.output_format = DIFF_FORMAT_RAW;
114
- else
115
- usage(builtin_diff_usage);
116
- argv++; argc--;
117
- }
108
+ if (argc > 1)
109
+ usage(builtin_diff_usage);
110
+
111
if (lstat(path, &st))
112
die("'%s': %s", path, strerror(errno));
113
if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)))
@@ -137,14 +130,9 @@ static int builtin_diff_blobs(struct rev_info *revs,
130
*/
131
unsigned mode = canon_mode(S_IFREG | 0644);
132
140
- while (1 < argc) {
141
- const char *arg = argv[1];
142
- if (!strcmp(arg, "--raw"))
143
- revs->diffopt.output_format = DIFF_FORMAT_RAW;
144
- else
145
- usage(builtin_diff_usage);
146
- argv++; argc--;
147
- }
133
+ if (argc > 1)
134
+ usage(builtin_diff_usage);
135
+
136
stuff_change(&revs->diffopt,
137
mode, mode,
138
blob[1].sha1, blob[0].sha1,
@@ -162,8 +150,6 @@ static int builtin_diff_index(struct rev_info *revs,
150
const char *arg = argv[1];
151
if (!strcmp(arg, "--cached"))
152
cached = 1;
165
- else if (!strcmp(arg, "--raw"))
166
- revs->diffopt.output_format = DIFF_FORMAT_RAW;
153
else
154
usage(builtin_diff_usage);
155
argv++; argc--;
@@ -185,14 +171,9 @@ static int builtin_diff_tree(struct rev_info *revs,
171
{
172
const unsigned char *(sha1[2]);
173
int swap = 0;
188
- while (1 < argc) {
189
- const char *arg = argv[1];
190
- if (!strcmp(arg, "--raw"))
191
- revs->diffopt.output_format = DIFF_FORMAT_RAW;
192
- else
193
- usage(builtin_diff_usage);
194
- argv++; argc--;
195
- }
174
+
175
+ if (argc > 1)
176
+ usage(builtin_diff_usage);
177
178
/* We saw two trees, ent[0] and ent[1].
179
* if ent[1] is unintesting, they are swapped
@@ -214,14 +195,9 @@ static int builtin_diff_combined(struct rev_info *revs,
195
const unsigned char (*parent)[20];
196
int i;
197
217
- while (1 < argc) {
218
- const char *arg = argv[1];
219
- if (!strcmp(arg, "--raw"))
220
- revs->diffopt.output_format = DIFF_FORMAT_RAW;
221
- else
222
- usage(builtin_diff_usage);
223
- argv++; argc--;
224
- }
198
+ if (argc > 1)
199
+ usage(builtin_diff_usage);
200
+
201
if (!revs->dense_combined_merges && !revs->combine_merges)
202
revs->dense_combined_merges = revs->combine_merges = 1;
203
parent = xmalloc(ents * sizeof(*parent));
diff.c
+2
@@ -1533,6 +1533,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
1533
options->output_format |= DIFF_FORMAT_PATCH;
1534
else if (opt_arg(arg, 'U', "unified", &options->context))
1535
options->output_format |= DIFF_FORMAT_PATCH;
1536
+ else if (!strcmp(arg, "--raw"))
1537
+ options->output_format |= DIFF_FORMAT_RAW;
1538
else if (!strcmp(arg, "--patch-with-raw")) {
1539
options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW;
1540
}