Skip to content

Commit 8817f0c

Browse files
peffgitster
authored andcommitted
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>
1 parent 48edf3a commit 8817f0c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

combine-diff.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,11 @@ static const char *path_path(void *obj)
13211321
return path->path;
13221322
}
13231323

1324+
/*
1325+
* Diff stat formats which we always compute solely against the first parent.
1326+
*/
1327+
#define STAT_FORMAT_MASK (DIFF_FORMAT_NUMSTAT \
1328+
| DIFF_FORMAT_DIFFSTAT)
13241329

13251330
/* find set of paths that every parent touches */
13261331
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,
13421347
* show stat against the first parent even when doing
13431348
* combined diff.
13441349
*/
1345-
int stat_opt = (output_format &
1346-
(DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIFFSTAT));
1350+
int stat_opt = output_format & STAT_FORMAT_MASK;
13471351
if (i == 0 && stat_opt)
13481352
opt->output_format = stat_opt;
13491353
else
@@ -1470,8 +1474,7 @@ void diff_tree_combined(const struct object_id *oid,
14701474
* show stat against the first parent even
14711475
* when doing combined diff.
14721476
*/
1473-
stat_opt = (opt->output_format &
1474-
(DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIFFSTAT));
1477+
stat_opt = opt->output_format & STAT_FORMAT_MASK;
14751478
if (stat_opt) {
14761479
diffopts.output_format = stat_opt;
14771480

@@ -1515,8 +1518,7 @@ void diff_tree_combined(const struct object_id *oid,
15151518
show_raw_diff(p, num_parent, rev);
15161519
needsep = 1;
15171520
}
1518-
else if (opt->output_format &
1519-
(DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIFFSTAT))
1521+
else if (opt->output_format & STAT_FORMAT_MASK)
15201522
needsep = 1;
15211523
else if (opt->output_format & DIFF_FORMAT_CALLBACK)
15221524
handle_combined_callback(opt, paths, num_parent, num_paths);

0 commit comments

Comments
 (0)