combine-diff: factor out stat-format mask
There are several conditionals in the combine diff code that check if we're doing --stat or --numstat output. Since these must all remain in sync, let's pull them out into a separate bit-mask. Arguably this could go into diff.h along with the other DIFF_FORMAT macros, but it's not clear that the definition of "which formats are stat" is universal (e.g., does --dirstat count? --summary?). So let's keep this local to combine-diff.c, where the meaning is more clearly "stat formats that combine-diff supports". Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
48edf3a02a
commit
8817f0cc67
@ -1321,6 +1321,11 @@ static const char *path_path(void *obj)
|
|||||||
return path->path;
|
return path->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Diff stat formats which we always compute solely against the first parent.
|
||||||
|
*/
|
||||||
|
#define STAT_FORMAT_MASK (DIFF_FORMAT_NUMSTAT \
|
||||||
|
| DIFF_FORMAT_DIFFSTAT)
|
||||||
|
|
||||||
/* find set of paths that every parent touches */
|
/* find set of paths that every parent touches */
|
||||||
static struct combine_diff_path *find_paths_generic(const struct object_id *oid,
|
static struct combine_diff_path *find_paths_generic(const struct object_id *oid,
|
||||||
@ -1342,8 +1347,7 @@ static struct combine_diff_path *find_paths_generic(const struct object_id *oid,
|
|||||||
* show stat against the first parent even when doing
|
* show stat against the first parent even when doing
|
||||||
* combined diff.
|
* combined diff.
|
||||||
*/
|
*/
|
||||||
int stat_opt = (output_format &
|
int stat_opt = output_format & STAT_FORMAT_MASK;
|
||||||
(DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIFFSTAT));
|
|
||||||
if (i == 0 && stat_opt)
|
if (i == 0 && stat_opt)
|
||||||
opt->output_format = stat_opt;
|
opt->output_format = stat_opt;
|
||||||
else
|
else
|
||||||
@ -1470,8 +1474,7 @@ void diff_tree_combined(const struct object_id *oid,
|
|||||||
* show stat against the first parent even
|
* show stat against the first parent even
|
||||||
* when doing combined diff.
|
* when doing combined diff.
|
||||||
*/
|
*/
|
||||||
stat_opt = (opt->output_format &
|
stat_opt = opt->output_format & STAT_FORMAT_MASK;
|
||||||
(DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIFFSTAT));
|
|
||||||
if (stat_opt) {
|
if (stat_opt) {
|
||||||
diffopts.output_format = stat_opt;
|
diffopts.output_format = stat_opt;
|
||||||
|
|
||||||
@ -1515,8 +1518,7 @@ void diff_tree_combined(const struct object_id *oid,
|
|||||||
show_raw_diff(p, num_parent, rev);
|
show_raw_diff(p, num_parent, rev);
|
||||||
needsep = 1;
|
needsep = 1;
|
||||||
}
|
}
|
||||||
else if (opt->output_format &
|
else if (opt->output_format & STAT_FORMAT_MASK)
|
||||||
(DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIFFSTAT))
|
|
||||||
needsep = 1;
|
needsep = 1;
|
||||||
else if (opt->output_format & DIFF_FORMAT_CALLBACK)
|
else if (opt->output_format & DIFF_FORMAT_CALLBACK)
|
||||||
handle_combined_callback(opt, paths, num_parent, num_paths);
|
handle_combined_callback(opt, paths, num_parent, num_paths);
|
||||||
|
Loading…
Reference in New Issue
Block a user