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

[PATCH 1/2] get_sha1_oneline: allow to input commit_list

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Dec 12, 2010, 10:56 UTC
Message-ID
<1292151419-30678-1-git-send-email-pclouds@gmail.com>
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
Next: Nguyễn Thái Ngọc Duy
Message 1 of 5 in “get_sha1_oneline: allow to input commit_list”
  1. 1/2 get_sha1_oneline: allow to input commit_listNguyễn Thái Ngọc Duy, Dec 12, 2010
  2. 2/2 get_sha1: support ref^{/regex} syntaxNguyễn Thái Ngọc Duy, Dec 12, 2010
  3. Jonathan NiederDec 12, 2010
  4. Jonathan NiederDec 12, 2010
  5. Junio C HamanoDec 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.