diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-07-19 14:37:39 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-07-19 19:16:37 +0300 |
commit | 83bb8e5a0689e236f06a24ffede0b4c823b4a0b2 (patch) | |
tree | 8f2f9e11fee38d4a7f44193289d969428c8f8a9a /builtin | |
parent | fb7d80edcae482f4fa5d4be0227dc3054734e5f3 (diff) |
show-branch: --no-sparse should give dense output
"git show-branch --no-sparse" behaved exactly the same way as "git
show-branch --sparse", which did not make any sense. This was
because it used a variable "dense" initialized to 1 by default to
give "non sparse" behaviour, and OPT_SET_INT() to set the varilable
to 0 in response to the "--sparse" option. Unfortunately,
OPT_SET_INT() sets 0 to the given variable when the option is
negated.
Flip the polarity of the variable "dense" by renaming it to "sparse"
and initializing it to 0, and have OPT_SET_INT() set the variable to
1 when "--sparse" is given. This way, "--no-sparse" would set 0 to
the variable and would give us the "dense" behaviour.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/show-branch.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 7ef4a642c1..67f3ef0639 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -645,7 +645,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) int with_current_branch = 0; int head_at = -1; int topics = 0; - int dense = 1; + int sparse = 0; const char *reflog_base = NULL; struct option builtin_show_branch_options[] = { OPT_BOOL('a', "all", &all_heads, @@ -672,8 +672,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) REV_SORT_IN_GRAPH_ORDER), OPT_BOOL(0, "topics", &topics, N_("show only commits not on the first branch")), - OPT_SET_INT(0, "sparse", &dense, - N_("show merges reachable from only one tip"), 0), + OPT_SET_INT(0, "sparse", &sparse, + N_("show merges reachable from only one tip"), 1), OPT_SET_INT(0, "date-order", &sort_order, N_("topologically sort, maintaining date order " "where possible"), @@ -936,7 +936,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) !is_merge_point && (this_flag & (1u << REV_SHIFT))) continue; - if (dense && is_merge && + if (!sparse && is_merge && omit_in_dense(commit, rev, num_rev)) continue; for (i = 0; i < num_rev; i++) { |