revision: add rev_input_given flag

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.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2017-08-02 18:25:27 -04:00 committed by Junio C Hamano
parent 0c5dc7431a
commit 7ba826290a
2 changed files with 8 additions and 0 deletions

View File

@ -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_revs = revs;
cb->all_flags = flags; cb->all_flags = flags;
revs->rev_input_given = 1;
} }
void clear_ref_exclusion(struct string_list **ref_excludes_p) void clear_ref_exclusion(struct string_list **ref_excludes_p)

View File

@ -71,6 +71,13 @@ struct rev_info {
const char *def; const char *def;
struct pathspec prune_data; 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 */ /* topo-sort */
enum rev_sort_order sort_order; enum rev_sort_order sort_order;