git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFD PATCH] revlist/rev-parse: Introduce --heads and --locals revision specifiers
@ 2010-05-01 18:36 Michael J Gruber
  2010-05-01 19:42 ` Jakub Narebski
  2010-05-02  5:00 ` Jeff King
  0 siblings, 2 replies; 27+ messages in thread
From: Michael J Gruber @ 2010-05-01 18:36 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2010-05-17 14:27 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-01 18:36 [RFD PATCH] revlist/rev-parse: Introduce --heads and --locals revision specifiers Michael J Gruber
2010-05-01 19:42 ` Jakub Narebski
2010-05-01 19:47   ` Michael J Gruber
2010-05-01 19:51     ` Jakub Narebski
2010-05-02  5:00 ` Jeff King
2010-05-02 13:43   ` Michael J Gruber
2010-05-05  3:35     ` Jeff King
2010-05-13 14:24       ` [PATCH 0/4] All is too much Michael J Gruber
2010-05-13 14:24         ` [PATCH 1/4] rev-parse: deprecate use as an option sifter Michael J Gruber
2010-05-14 15:41           ` Jakub Narebski
2010-05-14 18:52             ` Michael J Gruber
2010-05-14 19:01               ` Jakub Narebski
2010-05-14 19:22                 ` Michael J Gruber
2010-05-17 14:26                 ` Thomas Rast
2010-05-13 14:24         ` [PATCH 2/4] t6018: add tests for rev-list's --branches and --tags Michael J Gruber
2010-05-13 14:24         ` [PATCH 3/4] t6018: make sure all tested symbolic names are different revs Michael J Gruber
2010-05-13 14:24         ` [PATCH 4/4] revlist: Introduce --lrbranches and --locals revision specifiers Michael J Gruber
2010-05-14  6:06         ` [PATCH 0/4] All is too much Jeff King
2010-05-14 16:08           ` Michael J Gruber
2010-05-14 16:14             ` Git methodology question Akhbari, Farshad
2010-05-14 21:44               ` Chris Packham
2010-05-14 21:54               ` Avery Pennarun
2010-05-14 18:26             ` [PATCH v2 0/4] All is too much Michael J Gruber
2010-05-14 18:26               ` [PATCH v2 1/4] rev-parse: deprecate use as an option sifter Michael J Gruber
2010-05-14 18:26               ` [PATCH v2 2/4] t6018: add tests for rev-list's --branches and --tags Michael J Gruber
2010-05-14 18:26               ` [PATCH v2 3/4] t6018: make sure all tested symbolic names are different revs Michael J Gruber
2010-05-14 18:26               ` [PATCH v2 4/4] revlist: Introduce --lrbranches and --locals revision specifiers Michael J Gruber

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 NNTP newsgroup(s).