Skip to content

Commit 7ba8262

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0c5dc74 commit 7ba8262

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

revision.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,7 @@ static void init_all_refs_cb(struct all_refs_cb *cb, struct rev_info *revs,
11681168
{
11691169
cb->all_revs = revs;
11701170
cb->all_flags = flags;
1171+
revs->rev_input_given = 1;
11711172
}
11721173

11731174
void clear_ref_exclusion(struct string_list **ref_excludes_p)

revision.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ struct rev_info {
7171
const char *def;
7272
struct pathspec prune_data;
7373

74+
/*
75+
* Whether the arguments parsed by setup_revisions() included any
76+
* "input" revisions that might still have yielded an empty pending
77+
* list (e.g., patterns like "--all" or "--glob").
78+
*/
79+
int rev_input_given;
80+
7481
/* topo-sort */
7582
enum rev_sort_order sort_order;
7683

0 commit comments

Comments
 (0)