Re: [PATCH] show-branch: fix --no-sparse
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 21, 2023, 14:42 UTC
- Message-ID
- <xmqqwmytxr59.fsf@gitster.g>
- In-Reply-To
- <3f590f19-11a2-36d7-2520-1d1625ca1a25@web.de>
René Scharfe <l.s.r@web.de> writes:
> Since 57343652a5 (show-branch: migrate to parse-options API, 2009-05-21) > git show-branch has accepted the option --no-sparse, but it does the > same as --sparse. That's because it's defined using OPT_SET_INT with a > value of 0, which sets 0 when negated, too.
Hmph, am I expected to compare these patches with what I sent a few days ago and pick whichever are the better ones? Can I delegate that task to somebody else ;-)?
jc/am-parseopt-fix <xmqqr0p5gjv3.fsf@gitster.g>
jc/branch-parseopt-fix <xmqqjzuxgjmi.fsf@gitster.g>
jc/describe-parseopt-fix <xmqqy1jcgbiv.fsf@gitster.g>
jc/parse-options-reset <xmqq1qh4c998.fsf@gitster.g>
jc/parse-options-short-help <xmqq5y6gg8fn.fsf@gitster.g>
jc/parse-options-show-branch <xmqqh6pzc15n.fsf@gitster.g>
jc/transport-parseopt-fix <xmqqedl4gag8.fsf@gitster.g>Some of them are already in 'next' as they were so trivial.
Thanks.
Show 45 quoted lines
> Turn --no-sparse into the opposite of --sparse by using OPT_BOOL and
> storing the option's status directly in a variable named "sparse"
> instead of in negative form in "dense".
>
> Suggested-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> builtin/show-branch.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/show-branch.c b/builtin/show-branch.c
> index a86b3c7677..99b3f4a09a 100644
> --- a/builtin/show-branch.c
> +++ b/builtin/show-branch.c
> @@ -649,7 +649,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,
> @@ -676,8 +676,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_BOOL(0, "sparse", &sparse,
> + N_("show merges reachable from only one tip")),
> OPT_SET_INT(0, "date-order", &sort_order,
> N_("topologically sort, maintaining date order "
> "where possible"),
> @@ -940,7 +940,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++) {
> --
> 2.41.0