git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Make git-rev-list understand --tags/--branches/--remotes
@ 2006-05-17 21:44 Linus Torvalds
  0 siblings, 0 replies; only message in thread
From: Linus Torvalds @ 2006-05-17 21:44 UTC (permalink / raw
  To: Junio C Hamano, Git Mailing List


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@osdl.org>
---

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")) {

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2006-05-17 21:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-17 21:44 Make git-rev-list understand --tags/--branches/--remotes Linus Torvalds

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).