git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/4] revision: add rev_input_given flag
Date: Wed, 02 Aug 2017 15:41:52 -0700	[thread overview]
Message-ID: <xmqqd18dr3rj.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170802222527.mnn7e6hlyevsgk7a@sigill.intra.peff.net> (Jeff King's message of "Wed, 2 Aug 2017 18:25:27 -0400")

Jeff King <peff@peff.net> writes:

> Normally a caller that invokes setup_revisions() has to
> check rev.pending to see if anything was actually queued for
> the traversal. But they can't tell the difference between
> two cases:
>
>   1. The user gave us no tip from which to start a
>      traversal.
>
>   2. The user tried to give us tips via --glob, --all, etc,
>      but their patterns ended up being empty.
>
> Let's set a flag in the rev_info struct that callers can use
> to tell the difference.  We can set this from the
> init_all_refs_cb() function.  That's a little funny because
> it's not exactly about initializing the "cb" struct itself.
> But that function is the common setup place for doing
> pattern traversals that is used by --glob, --all, etc.

...and "--bisect", which is an oddball so we probably do not have to
care.  I didn't check if there is a fallout on that codepath.




> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  revision.c | 1 +
>  revision.h | 7 +++++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/revision.c b/revision.c
> index 6603af944..08d5806b8 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -1168,6 +1168,7 @@ static void init_all_refs_cb(struct all_refs_cb *cb, struct rev_info *revs,
>  {
>  	cb->all_revs = revs;
>  	cb->all_flags = flags;
> +	revs->rev_input_given = 1;
>  }
>  
>  void clear_ref_exclusion(struct string_list **ref_excludes_p)
> diff --git a/revision.h b/revision.h
> index f96e7f7f4..c8f4e91f2 100644
> --- a/revision.h
> +++ b/revision.h
> @@ -71,6 +71,13 @@ struct rev_info {
>  	const char *def;
>  	struct pathspec prune_data;
>  
> +	/*
> +	 * Whether the arguments parsed by setup_revisions() included any
> +	 * "input" revisions that might still have yielded an empty pending
> +	 * list (e.g., patterns like "--all" or "--glob").
> +	 */
> +	int rev_input_given;
> +
>  	/* topo-sort */
>  	enum rev_sort_order sort_order;

  reply	other threads:[~2017-08-02 22:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-02 22:24 [PATCH 0/4] handling empty inputs in the revision machinery Jeff King
2017-08-02 22:24 ` [PATCH 1/4] t6018: flesh out empty input/output rev-list tests Jeff King
2017-08-02 22:25 ` [PATCH 2/4] revision: add rev_input_given flag Jeff King
2017-08-02 22:41   ` Junio C Hamano [this message]
2017-08-02 23:11     ` Jeff King
2017-08-02 22:26 ` [PATCH 3/4] rev-list: don't show usage when we see empty ref patterns Jeff King
2017-08-02 22:30 ` [PATCH 4/4] revision: do not fallback to default when rev_input_given is set Jeff King
2017-08-02 22:44   ` Junio C Hamano
2017-08-02 23:22     ` Stefan Beller
2017-08-02 22:34 ` [PATCH DONOTAPPLY 5/4] revision: let --stdin set rev_input_given Jeff King
2017-08-03 15:59   ` Junio C Hamano
2017-08-03 17:00     ` Jeff King
2017-08-02 22:35 ` [PATCH 0/4] handling empty inputs in the revision machinery Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqd18dr3rj.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).