@matheusbsbs / matheus-bagliano / commits / a5aa930d50
Fork 0

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>

Uwe Kleine-König committed Feb 28, 2008 at 08:24 UTC a5aa930d506689df0f77dded8a3f5aa248b485ee
3 files changed +22 -3
Documentation/git-rev-list.txt
+3
@@ -20,6 +20,9 @@ SYNOPSIS
20 [ \--full-history ]
21 [ \--not ]
22 [ \--all ]
23 + [ \--branches ]
24 + [ \--tags ]
25 + [ \--remotes ]
26 [ \--stdin ]
27 [ \--quiet ]
28 [ \--topo-order ]
builtin-rev-list.c
+3
@@ -25,6 +25,9 @@ static const char rev_list_usage[] =
25 " --no-merges\n"
26 " --remove-empty\n"
27 " --all\n"
28 +" --branches\n"
29 +" --tags\n"
30 +" --remotes\n"
31 " --stdin\n"
32 " --quiet\n"
33 " ordering output:\n"
revision.c
+16 -3
@@ -633,12 +633,13 @@ static int handle_one_ref(const char *path, const unsigned char *sha1, int flag,
633 return 0;
634 }
635
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 *))
638 {
639 struct all_refs_cb cb;
640 cb.all_revs = revs;
641 cb.all_flags = flags;
641 - for_each_ref(handle_one_ref, &cb);
642 + for_each(handle_one_ref, &cb);
643 }
644
645 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
1016 continue;
1017 }
1018 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);
1032 continue;
1033 }
1034 if (!strcmp(arg, "--first-parent")) {