diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-02-24 00:58:03 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-02-24 00:58:03 (GMT) |
commit | 8813596531c08ed7488f85805cd0ec974a9c7c96 (patch) | |
tree | daabc937eaf2047f85c64811e8ac9c2bf05155af /revision.c | |
parent | ebb866adae4f2a13939d0a4bd6901a506e911dba (diff) | |
parent | 087c745833be1edd3b3e4d8ea5d8b1a09fc6c245 (diff) | |
download | git-8813596531c08ed7488f85805cd0ec974a9c7c96.zip git-8813596531c08ed7488f85805cd0ec974a9c7c96.tar.gz git-8813596531c08ed7488f85805cd0ec974a9c7c96.tar.bz2 |
Merge branch 'ah/log-no-graph'
"git log --graph --graph" used to leak a graph structure, and there
was no way to countermand "--graph" that appear earlier on the
command line. A "--no-graph" option has been added and resource
leakage has been plugged.
* ah/log-no-graph:
log: add a --no-graph option
log: fix memory leak if --graph is passed multiple times
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -2434,9 +2434,11 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->pretty_given = 1; revs->abbrev_commit = 1; } else if (!strcmp(arg, "--graph")) { - revs->topo_order = 1; - revs->rewrite_parents = 1; + graph_clear(revs->graph); revs->graph = graph_init(revs); + } else if (!strcmp(arg, "--no-graph")) { + graph_clear(revs->graph); + revs->graph = NULL; } else if (!strcmp(arg, "--encode-email-headers")) { revs->encode_email_headers = 1; } else if (!strcmp(arg, "--no-encode-email-headers")) { @@ -2533,8 +2535,6 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg unkv[(*unkc)++] = arg; return opts; } - if (revs->graph && revs->track_linear) - die(_("options '%s' and '%s' cannot be used together"), "--show-linear-break", "--graph"); return 1; } @@ -2553,6 +2553,17 @@ void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx, ctx->argc -= n; } +void revision_opts_finish(struct rev_info *revs) +{ + if (revs->graph && revs->track_linear) + die(_("options '%s' and '%s' cannot be used together"), "--show-linear-break", "--graph"); + + if (revs->graph) { + revs->topo_order = 1; + revs->rewrite_parents = 1; + } +} + static int for_each_bisect_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data, const char *term) { @@ -2795,6 +2806,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s break; } } + revision_opts_finish(revs); if (prune_data.nr) { /* |