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

[RFD PATCH] revlist/rev-parse: Introduce --heads and --locals revision specifiers

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
May 1, 2010, 18:36 UTC
Message-ID
<83fc6259c434cc63f8e64ddf9ac8f90bae0ab2eb.1272557175.git.git@drmicha.warpmail.net>

Due to the increasing usage of the ref namespace (e.g. notes, replace) the revision specifier "--all" becomes decreasingly useful. But "something like --all" is ineeded for getting a quick overview of the development state of a repository.

Introduce --heads and --locals specifiers in order to help with that:

--heads == HEAD --branches --remotes --locals = HEAD --branches --tags

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
RFD for several reasons:
- It's incredibly useful, I want it - do others? ;)
- names of the options (let the bikeshedding begin)
- should rev-parse include HEAD?
- tests and doc, of course

rev-parse does not include HEAD even with --all, but rev-list does. The patch keeps with that tradition (the commit message does not quite convey this). I don't feel it's a good one. Cleaning that up requires more work, though.

 builtin/rev-list.c  |    2 ++
 builtin/rev-parse.c |   12 ++++++++++++
 revision.c          |   12 ++++++++++++
 3 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 51ceb19..fb8208c 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -20,7 +20,9 @@ static const char rev_list_usage[] =
 "    --all\n"
 "    --branches\n"
 "    --tags\n"
+"    --locals\n"
 "    --remotes\n"
+"    --heads\n"
 "    --stdin\n"
 "    --quiet\n"
 "  ordering output:\n"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 8fbf9d0..c739479 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -44,6 +44,8 @@ static int is_rev_argument(const char *arg)
 		"--branches=",
 		"--branches",
 		"--header",
+		"--heads",
+		"--locals",
 		"--max-age=",
 		"--max-count=",
 		"--min-age=",
@@ -598,6 +600,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 				for_each_tag_ref(show_reference, NULL);
 				continue;
 			}
+			if (!strcmp(arg, "--locals")) {
+				for_each_branch_ref(show_reference, NULL);
+				for_each_tag_ref(show_reference, NULL);
+				continue;
+			}
 			if (!prefixcmp(arg, "--glob=")) {
 				for_each_glob_ref(show_reference, arg + 7, NULL);
 				continue;
@@ -611,6 +618,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 				for_each_remote_ref(show_reference, NULL);
 				continue;
 			}
+			if (!strcmp(arg, "--heads")) {
+				for_each_branch_ref(show_reference, NULL);
+				for_each_remote_ref(show_reference, NULL);
+				continue;
+			}
 			if (!strcmp(arg, "--show-toplevel")) {
 				const char *work_tree = get_git_work_tree();
 				if (work_tree)
diff --git a/revision.c b/revision.c
index f4b8b38..04f9be7 100644
--- a/revision.c
+++ b/revision.c
@@ -1399,10 +1399,22 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 				handle_refs(revs, flags, for_each_tag_ref);
 				continue;
 			}
+			if (!strcmp(arg, "--locals")) {
+				handle_refs(revs, flags, for_each_branch_ref);
+				handle_refs(revs, flags, for_each_tag_ref);
+				handle_refs(revs, flags, head_ref);
+				continue;
+			}
 			if (!strcmp(arg, "--remotes")) {
 				handle_refs(revs, flags, for_each_remote_ref);
 				continue;
 			}
+			if (!strcmp(arg, "--heads")) {
+				handle_refs(revs, flags, for_each_remote_ref);
+				handle_refs(revs, flags, for_each_branch_ref);
+				handle_refs(revs, flags, head_ref);
+				continue;
+			}
 			if (!prefixcmp(arg, "--glob=")) {
 				struct all_refs_cb cb;
 				init_all_refs_cb(&cb, revs, flags);
-- 
1.7.1.328.g9993c
Next: Jakub Narebski
Message 1 of 27 in “revlist/rev-parse: Introduce --heads and --locals revision specifiers”
  1. revlist/rev-parse: Introduce --heads and --locals revision specifiersMichael J Gruber, May 1, 2010
  2. Jakub NarebskiMay 1, 2010
  3. Michael J GruberMay 1, 2010
  4. Jakub NarebskiMay 1, 2010
  5. Jeff KingMay 2, 2010
  6. Michael J GruberMay 2, 2010
  7. Jeff KingMay 5, 2010
  8. 0/4 All is too muchMichael J Gruber, May 13, 2010
  9. Jeff KingMay 14, 2010
  10. Michael J GruberMay 14, 2010
  11. Git methodology questionAkhbari, Farshad, May 14, 2010
  12. Chris PackhamMay 14, 2010
  13. Avery PennarunMay 14, 2010
  14. 0/4 All is too muchMichael J Gruber, May 14, 2010
  15. 1/4 rev-parse: deprecate use as an option sifterMichael J Gruber, May 14, 2010
  16. 2/4 t6018: add tests for rev-list's --branches and --tagsMichael J Gruber, May 14, 2010
  17. 3/4 t6018: make sure all tested symbolic names are different revsMichael J Gruber, May 14, 2010
  18. 4/4 revlist: Introduce --lrbranches and --locals revision specifiersMichael J Gruber, May 14, 2010
  19. 1/4 rev-parse: deprecate use as an option sifterMichael J Gruber, May 13, 2010
  20. Jakub NarebskiMay 14, 2010
  21. Michael J GruberMay 14, 2010
  22. Jakub NarebskiMay 14, 2010
  23. Michael J GruberMay 14, 2010
  24. Thomas RastMay 17, 2010
  25. 2/4 t6018: add tests for rev-list's --branches and --tagsMichael J Gruber, May 13, 2010
  26. 3/4 t6018: make sure all tested symbolic names are different revsMichael J Gruber, May 13, 2010
  27. 4/4 revlist: Introduce --lrbranches and --locals revision specifiersMichael J Gruber, May 13, 2010

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.