git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Linus Torvalds <torvalds@osdl.org>
Date
May 17, 2006, 21:44 UTC
Message-ID
<Pine.LNX.4.64.0605171439371.10823@g5.osdl.org>

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")) {
Message 1 of 1 in “Make git-rev-list understand --tags/--branches/--remotes”
  1. Linus TorvaldsMay 17, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.