Skip to content

Commit c50ee29

Browse files
pabloosabaterrgitster
authored andcommitted
graph: add --graph-lane-limit option
Repositories that have many active branches at the same time produce wide graphs. A lane consists of two columns, the edge and the space padding, each branch takes a lane in the graph and there is no way to limit how many can be shown. Add '--graph-lane-limit=<n>' revision option that caps the number of visible lanes to n. This option requires '--graph', without it a limit to the graph has no meaning, in this case error out. Zero and negative values are valid inputs but silently ignored treating them as "no limit", the same as not using the option. This follows what '--max-parents' does with negative values. Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6e8d538 commit c50ee29

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

graph.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,15 @@ struct git_graph {
317317
struct strbuf prefix_buf;
318318
};
319319

320+
static int graph_needs_truncation(struct git_graph *graph, int lane)
321+
{
322+
int max = graph->revs->graph_max_lanes;
323+
/*
324+
* Ignore values <= 0, meaning no limit.
325+
*/
326+
return max > 0 && lane >= max;
327+
}
328+
320329
static const char *diff_output_prefix_callback(struct diff_options *opt, void *data)
321330
{
322331
struct git_graph *graph = data;

revision.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2605,6 +2605,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
26052605
} else if (!strcmp(arg, "--no-graph")) {
26062606
graph_clear(revs->graph);
26072607
revs->graph = NULL;
2608+
} else if (skip_prefix(arg, "--graph-lane-limit=", &optarg)) {
2609+
revs->graph_max_lanes = parse_count(optarg);
26082610
} else if (!strcmp(arg, "--encode-email-headers")) {
26092611
revs->encode_email_headers = 1;
26102612
} else if (!strcmp(arg, "--no-encode-email-headers")) {
@@ -3172,6 +3174,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
31723174

31733175
if (revs->no_walk && revs->graph)
31743176
die(_("options '%s' and '%s' cannot be used together"), "--no-walk", "--graph");
3177+
3178+
if (revs->graph_max_lanes > 0 && !revs->graph)
3179+
die(_("option '%s' requires '%s'"), "--graph-lane-limit", "--graph");
3180+
31753181
if (!revs->reflog_info && revs->grep_filter.use_reflog_filter)
31763182
die(_("the option '%s' requires '%s'"), "--grep-reflog", "--walk-reflogs");
31773183

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ struct rev_info {
304304

305305
/* Display history graph */
306306
struct git_graph *graph;
307+
int graph_max_lanes;
307308

308309
/* special limits */
309310
int skip_count;

0 commit comments

Comments
 (0)