Skip to content

Commit 19feebc

Browse files
Junio C HamanoLinus Torvalds
authored andcommitted
[PATCH] Clean up diff_setup() to make it more extensible.
This changes the argument of diff_setup() from an integer that says if we are feeding reversed diff to a bitmask, so that later global options can be added more easily. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 09d9d1a commit 19feebc

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

diff-cache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ static int cached_only = 0;
55
static int diff_output_format = DIFF_FORMAT_HUMAN;
66
static int match_nonexisting = 0;
77
static int detect_rename = 0;
8-
static int reverse_diff = 0;
8+
static int diff_setup_opt = 0;
99
static int diff_score_opt = 0;
1010
static const char *pickaxe = NULL;
1111

@@ -202,7 +202,7 @@ int main(int argc, const char **argv)
202202
continue;
203203
}
204204
if (!strcmp(arg, "-R")) {
205-
reverse_diff = 1;
205+
diff_setup_opt |= DIFF_SETUP_REVERSE;
206206
continue;
207207
}
208208
if (!strcmp(arg, "-S")) {
@@ -224,7 +224,7 @@ int main(int argc, const char **argv)
224224
usage(diff_cache_usage);
225225

226226
/* The rest is for paths restriction. */
227-
diff_setup(reverse_diff);
227+
diff_setup(diff_setup_opt);
228228

229229
mark_merge_entries();
230230

diff-files.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static const char *diff_files_usage =
1111

1212
static int diff_output_format = DIFF_FORMAT_HUMAN;
1313
static int detect_rename = 0;
14-
static int reverse_diff = 0;
14+
static int diff_setup_opt = 0;
1515
static int diff_score_opt = 0;
1616
static const char *pickaxe = NULL;
1717
static int silent = 0;
@@ -51,7 +51,7 @@ int main(int argc, const char **argv)
5151
else if (!strcmp(argv[1], "-z"))
5252
diff_output_format = DIFF_FORMAT_MACHINE;
5353
else if (!strcmp(argv[1], "-R"))
54-
reverse_diff = 1;
54+
diff_setup_opt |= DIFF_SETUP_REVERSE;
5555
else if (!strcmp(argv[1], "-S"))
5656
pickaxe = argv[1] + 2;
5757
else if (!strncmp(argv[1], "-M", 2)) {
@@ -75,7 +75,7 @@ int main(int argc, const char **argv)
7575
exit(1);
7676
}
7777

78-
diff_setup(reverse_diff);
78+
diff_setup(diff_setup_opt);
7979

8080
for (i = 0; i < entries; i++) {
8181
struct stat st;

diff-tree.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ static int show_tree_entry_in_recursive = 0;
1010
static int read_stdin = 0;
1111
static int diff_output_format = DIFF_FORMAT_HUMAN;
1212
static int detect_rename = 0;
13-
static int reverse_diff = 0;
13+
static int diff_setup_opt = 0;
1414
static int diff_score_opt = 0;
1515
static const char *pickaxe = NULL;
1616
static const char *header = NULL;
@@ -255,7 +255,7 @@ static int diff_tree_sha1(const unsigned char *old, const unsigned char *new, co
255255

256256
static void call_diff_setup(void)
257257
{
258-
diff_setup(reverse_diff);
258+
diff_setup(diff_setup_opt);
259259
}
260260

261261
static int call_diff_flush(void)
@@ -497,7 +497,7 @@ int main(int argc, const char **argv)
497497
continue;
498498
}
499499
if (!strcmp(arg, "-R")) {
500-
reverse_diff = 1;
500+
diff_setup_opt |= DIFF_SETUP_REVERSE;
501501
continue;
502502
}
503503
if (!strcmp(arg, "-p")) {

diff.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,10 @@ static void run_diff(const char *name,
492492
run_external_diff(pgm, name, other, one, two, xfrm_msg);
493493
}
494494

495-
void diff_setup(int reverse_diff_)
495+
void diff_setup(int flags)
496496
{
497-
reverse_diff = reverse_diff_;
497+
if (flags & DIFF_SETUP_REVERSE)
498+
reverse_diff = 1;
498499
}
499500

500501
struct diff_queue_struct diff_queued_diff;

diff.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ extern void diff_unmerge(const char *path);
2828

2929
extern int diff_scoreopt_parse(const char *opt);
3030

31-
#define DIFF_FORMAT_HUMAN 0
32-
#define DIFF_FORMAT_MACHINE 1
33-
#define DIFF_FORMAT_PATCH 2
34-
#define DIFF_FORMAT_NO_OUTPUT 3
35-
extern void diff_setup(int reverse);
31+
#define DIFF_SETUP_REVERSE 1
32+
extern void diff_setup(int flags);
3633

3734
#define DIFF_DETECT_RENAME 1
3835
#define DIFF_DETECT_COPY 2
@@ -44,6 +41,11 @@ extern void diffcore_pathspec(const char **pathspec);
4441

4542
extern int diff_queue_is_empty(void);
4643

44+
#define DIFF_FORMAT_HUMAN 0
45+
#define DIFF_FORMAT_MACHINE 1
46+
#define DIFF_FORMAT_PATCH 2
47+
#define DIFF_FORMAT_NO_OUTPUT 3
48+
4749
extern void diff_flush(int output_style, int resolve_rename_copy);
4850

4951
#endif /* DIFF_H */

0 commit comments

Comments
 (0)