git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] get_sha1_oneline: allow to input commit_list
@ 2010-12-12 10:56 Nguyễn Thái Ngọc Duy
  2010-12-12 10:56 ` [PATCH 2/2] get_sha1: support ref^{/regex} syntax Nguyễn Thái Ngọc Duy
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-12-12 10:56 UTC (permalink / raw)
  To: git, Junio C Hamano
  Cc: Kevin Ballard, Yann Dirson, Jeff King, Jakub Narebski,
	Jonathan Niedier, Thiago Farina,
	Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 sha1_name.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 2c3a5fb..c298285 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -690,7 +690,9 @@ static int handle_one_ref(const char *path,
 	return 0;
 }
 
-static int get_sha1_oneline(const char *prefix, unsigned char *sha1)
+static int get_sha1_oneline(const char *prefix,
+			    unsigned char *sha1,
+			    struct commit_list *original_list)
 {
 	struct commit_list *list = NULL, *backup = NULL, *l;
 	int retval = -1;
@@ -706,7 +708,12 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1)
 	if (regcomp(&regex, prefix, REG_EXTENDED))
 		die("Invalid search pattern: %s", prefix);
 
-	for_each_ref(handle_one_ref, &list);
+	for (l = original_list; l; l = l->next) {
+		commit_list_insert(l->item, &list);
+		l->item->object.flags |= ONELINE_SEEN;
+	}
+	if (!list)
+		for_each_ref(handle_one_ref, &list);
 	for (l = list; l; l = l->next)
 		commit_list_insert(l->item, &backup);
 	while (list) {
@@ -1090,7 +1097,7 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1,
 		int pos;
 		if (namelen > 2 && name[1] == '/')
 			/* don't need mode for commit */
-			return get_sha1_oneline(name + 2, sha1);
+			return get_sha1_oneline(name + 2, sha1, NULL);
 		if (namelen < 3 ||
 		    name[2] != ':' ||
 		    name[1] < '0' || '3' < name[1])
-- 
1.7.3.3.476.g893a9

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH 0/2] [RFD] Using gitrevisions :/search style with other operators
@ 2010-12-08 14:58 Nguyễn Thái Ngọc Duy
  2010-12-08 14:58 ` [PATCH 1/2] get_sha1_oneline: allow to input commit_list Nguyễn Thái Ngọc Duy
  0 siblings, 1 reply; 7+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-12-08 14:58 UTC (permalink / raw)
  To: git, Junio C Hamano, Kevin Ballard, Yann Dirson, Jeff King,
	Jakub Narebski
  Cc: Nguyễn Thái Ngọc Duy

Let's start off from where the previous discussion [1] stopped. People
seem to agree ref^{/regex} is a good choice. But we have not come to
conclusion how to specify the count yet. Possible suggestions are

 - ref^{/foo}2
 - ref^{2/foo}
 - ref^{:2/foo}
 - ref^{2nd/foo}

For whatever syntax chosen, :/ should benefit too. I notice that :/!
is reserved for future use. Perhaps :/!2/regex is not too cryptic?

I'd also like to do case-insensitive regex, by the way. :/!2i/regex
looks a bit ugly.

[1] http://mid.gmane.org/9D675671-693D-4B59-AF2A-0EFE4C537362@sb.org

Nguyễn Thái Ngọc Duy (2):
  get_sha1_oneline: allow to input commit_list
  get_sha1: support ref^{/regex} syntax

 Documentation/revisions.txt |    7 ++++++
 sha1_name.c                 |   45 ++++++++++++++++++++++++++++++++----------
 2 files changed, 41 insertions(+), 11 deletions(-)

-- 
1.7.3.2.316.gda8b3

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

end of thread, other threads:[~2010-12-13  0:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-12 10:56 [PATCH 1/2] get_sha1_oneline: allow to input commit_list Nguyễn Thái Ngọc Duy
2010-12-12 10:56 ` [PATCH 2/2] get_sha1: support ref^{/regex} syntax Nguyễn Thái Ngọc Duy
2010-12-12 17:38   ` Jonathan Nieder
2010-12-12 17:34 ` [PATCH 1/2] get_sha1_oneline: allow to input commit_list Jonathan Nieder
2010-12-13  0:29 ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2010-12-08 14:58 [PATCH 0/2] [RFD] Using gitrevisions :/search style with other operators Nguyễn Thái Ngọc Duy
2010-12-08 14:58 ` [PATCH 1/2] get_sha1_oneline: allow to input commit_list Nguyễn Thái Ngọc Duy
2010-12-08 15:11   ` Thiago Farina

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).