Make the diff_options bitfields be an unsigned with explicit masks.
reverse_diff was a bit-value in disguise, it's merged in the flags now.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Pierre Habouzit17 years agocommitted byJunio C Hamano
@ -121,7 +121,7 @@ static int queue_diff(struct diff_options *o,
@@ -121,7 +121,7 @@ static int queue_diff(struct diff_options *o,
} else {
struct diff_filespec *d1, *d2;
if (o->reverse_diff) {
if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
unsigned tmp;
const char *tmp_c;
tmp = mode1; mode1 = mode2; mode2 = tmp;
@ -188,8 +188,8 @@ static int handle_diff_files_args(struct rev_info *revs,
@@ -188,8 +188,8 @@ static int handle_diff_files_args(struct rev_info *revs,
else if (!strcmp(argv[1], "-n") ||
!strcmp(argv[1], "--no-index")) {
revs->max_count = -2;
revs->diffopt.exit_with_status = 1;
revs->diffopt.no_index = 1;
DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
}
else if (!strcmp(argv[1], "-q"))
*silent = 1;
@ -207,7 +207,7 @@ static int handle_diff_files_args(struct rev_info *revs,
@@ -207,7 +207,7 @@ static int handle_diff_files_args(struct rev_info *revs,
if (!is_in_index(revs->diffopt.paths[0]) ||
!is_in_index(revs->diffopt.paths[1])) {
revs->max_count = -2;
revs->diffopt.no_index = 1;
DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
}
}
@ -258,7 +258,7 @@ int setup_diff_no_index(struct rev_info *revs,
@@ -258,7 +258,7 @@ int setup_diff_no_index(struct rev_info *revs,
break;
} else if (i < argc - 3 && !strcmp(argv[i], "--no-index")) {
i = argc - 3;
revs->diffopt.exit_with_status = 1;
DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
break;
}
if (argc != i + 2 || (!is_outside_repo(argv[i + 1], nongit, prefix) &&
@ -296,7 +296,7 @@ int setup_diff_no_index(struct rev_info *revs,
@@ -296,7 +296,7 @@ int setup_diff_no_index(struct rev_info *revs,
else
revs->diffopt.paths = argv + argc - 2;
revs->diffopt.nr_paths = 2;
revs->diffopt.no_index = 1;
DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
revs->max_count = -2;
if (diff_setup_done(&revs->diffopt) < 0)
die("diff_setup_done failed");
@ -310,7 +310,7 @@ int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)
@@ -310,7 +310,7 @@ int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)
if (handle_diff_files_args(revs, argc, argv, &silent_on_removed))
return -1;
if (revs->diffopt.no_index) {
if (DIFF_OPT_TST(&revs->diffopt, NO_INDEX)) {
if (revs->diffopt.nr_paths != 2)
return error("need two files/directories with --no-index");
if (queue_diff(&revs->diffopt, revs->diffopt.paths[0],
@ -346,7 +346,8 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
@@ -346,7 +346,8 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
struct cache_entry *ce = active_cache[i];
int changed;
if (revs->diffopt.quiet && revs->diffopt.has_changes)
if (DIFF_OPT_TST(&revs->diffopt, QUIET) &&
DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
break;
if (!ce_path_match(ce, revs->prune_data))
@ -442,7 +443,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
@@ -442,7 +443,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
continue;
}
changed = ce_match_stat(ce, &st, 0);
if (!changed && !revs->diffopt.find_copies_harder)
if (!changed && !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)
@ -270,7 +270,7 @@ static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree
@@ -270,7 +270,7 @@ static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree
if (!t2)
return REV_TREE_DIFFERENT;
tree_difference = REV_TREE_SAME;
revs->pruning.has_changes = 0;
DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
if (diff_tree_sha1(t1->object.sha1, t2->object.sha1, "",
&revs->pruning) < 0)
return REV_TREE_DIFFERENT;
@ -294,7 +294,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)
@@ -294,7 +294,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)