Make git-rev-list understand --tags/--branches/--remotes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We shouldn't add stuff to git-rev-parse without teaching git-rev-list and 
all the other tools to do the same.

In fact, these days there is much less reason for git-rev-parse in the 
first place: it's usually used to verify a particular reference, or to 
just split the different argument types up from each other. Most tools 
don't need or use it any more (eg "gitk" will just pass its arguments 
directly to git-rev-list).

With this, you can now do (for example)

	gitk HEAD --not --tags

to see all the work on all the main branch that hasn't been included in a 
tagged version (replace HEAD with "--branches" to show all branches, of 
course).

Signed-off-by: Linus Torvalds <torvalds@xxxxxxxx>
---

diff --git a/revision.c b/revision.c
index 2294b16..1fc6725 100644
--- a/revision.c
+++ b/revision.c
@@ -470,11 +470,13 @@ static int handle_one_ref(const char *pa
 	return 0;
 }
 
-static void handle_all(struct rev_info *revs, unsigned flags)
+typedef int (*ref_fn_t)(int (*)(const char *, const unsigned char *));
+
+static void handle_ref(ref_fn_t fn, struct rev_info *revs, unsigned flags)
 {
 	all_revs = revs;
 	all_flags = flags;
-	for_each_ref(handle_one_ref);
+	fn(handle_one_ref);
 }
 
 static int add_parents_only(struct rev_info *revs, const char *arg, int flags)
@@ -614,7 +616,19 @@ int setup_revisions(int argc, const char
 				continue;
 			}
 			if (!strcmp(arg, "--all")) {
-				handle_all(revs, flags);
+				handle_ref(for_each_ref, revs, flags);
+				continue;
+			}
+			if (!strcmp(arg, "--branches")) {
+				handle_ref(for_each_branch_ref, revs, flags);
+				continue;
+			}
+			if (!strcmp(arg, "--tags")) {
+				handle_ref(for_each_tag_ref, revs, flags);
+				continue;
+			}
+			if (!strcmp(arg, "--remotes")) {
+				handle_ref(for_each_remote_ref, revs, flags);
 				continue;
 			}
 			if (!strcmp(arg, "--not")) {
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]