Skip to content

Commit aedfa93

Browse files
committed
range-diff: indent the diffs just like tbdiff
The main information in the `range-diff` view comes from the list of matching and non-matching commits, the diffs are additional information. Indenting them helps with the reading flow. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent aaa6eb0 commit aedfa93

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

builtin/range-diff.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ N_("git range-diff [<options>] <base> <old-tip> <new-tip>"),
1111
NULL
1212
};
1313

14+
static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
15+
{
16+
return data;
17+
}
18+
1419
int cmd_range_diff(int argc, const char **argv, const char *prefix)
1520
{
1621
int creation_factor = 60;
@@ -21,12 +26,16 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
2126
OPT_END()
2227
};
2328
int i, j, res = 0;
29+
struct strbuf four_spaces = STRBUF_INIT;
2430
struct strbuf range1 = STRBUF_INIT, range2 = STRBUF_INIT;
2531

2632
git_config(git_diff_ui_config, NULL);
2733

2834
diff_setup(&diffopt);
2935
diffopt.output_format = DIFF_FORMAT_PATCH;
36+
diffopt.output_prefix = output_prefix_cb;
37+
strbuf_addstr(&four_spaces, " ");
38+
diffopt.output_prefix_data = &four_spaces;
3039

3140
argc = parse_options(argc, argv, NULL, options,
3241
builtin_range_diff_usage, PARSE_OPT_KEEP_UNKNOWN);
@@ -78,6 +87,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
7887

7988
strbuf_release(&range1);
8089
strbuf_release(&range2);
90+
strbuf_release(&four_spaces);
8191

8292
return res;
8393
}

0 commit comments

Comments
 (0)