Skip to content

Commit a5aa930

Browse files
Uwe Kleine-Königgitster
authored andcommitted
rev-list: add --branches, --tags and --remotes
These flags are already known to rev-parse and have the same meaning. This patch allows to run gitk as follows: gitk --branches --not --remotes to show only your local work. Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 419e383 commit a5aa930

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

Documentation/git-rev-list.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ SYNOPSIS
2020
[ \--full-history ]
2121
[ \--not ]
2222
[ \--all ]
23+
[ \--branches ]
24+
[ \--tags ]
25+
[ \--remotes ]
2326
[ \--stdin ]
2427
[ \--quiet ]
2528
[ \--topo-order ]

builtin-rev-list.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ static const char rev_list_usage[] =
2525
" --no-merges\n"
2626
" --remove-empty\n"
2727
" --all\n"
28+
" --branches\n"
29+
" --tags\n"
30+
" --remotes\n"
2831
" --stdin\n"
2932
" --quiet\n"
3033
" ordering output:\n"

revision.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,12 +633,13 @@ static int handle_one_ref(const char *path, const unsigned char *sha1, int flag,
633633
return 0;
634634
}
635635

636-
static void handle_all(struct rev_info *revs, unsigned flags)
636+
static void handle_refs(struct rev_info *revs, unsigned flags,
637+
int (*for_each)(each_ref_fn, void *))
637638
{
638639
struct all_refs_cb cb;
639640
cb.all_revs = revs;
640641
cb.all_flags = flags;
641-
for_each_ref(handle_one_ref, &cb);
642+
for_each(handle_one_ref, &cb);
642643
}
643644

644645
static void handle_one_reflog_commit(unsigned char *sha1, void *cb_data)
@@ -1015,7 +1016,19 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
10151016
continue;
10161017
}
10171018
if (!strcmp(arg, "--all")) {
1018-
handle_all(revs, flags);
1019+
handle_refs(revs, flags, for_each_ref);
1020+
continue;
1021+
}
1022+
if (!strcmp(arg, "--branches")) {
1023+
handle_refs(revs, flags, for_each_branch_ref);
1024+
continue;
1025+
}
1026+
if (!strcmp(arg, "--tags")) {
1027+
handle_refs(revs, flags, for_each_tag_ref);
1028+
continue;
1029+
}
1030+
if (!strcmp(arg, "--remotes")) {
1031+
handle_refs(revs, flags, for_each_remote_ref);
10191032
continue;
10201033
}
10211034
if (!strcmp(arg, "--first-parent")) {

0 commit comments

Comments
 (0)