[PATCH 1.5/2] fix git-rev-parse for ...@{0}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My patch enabling HEAD@{...} broke the @{0} case.

Signed-off-by: Nicolas Pitre <nico@xxxxxxx>
---
 sha1_name.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 9841b05..d77f770 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -267,7 +267,7 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
 	return refs_found;
 }
 
-static int dwim_log(const char *str, int len, char **log)
+static int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
 {
 	const char **p;
 	int logs_found = 0;
@@ -278,8 +278,10 @@ static int dwim_log(const char *str, int len, char **log)
 		char *path = mkpath(*p, len, str);
 		if (!stat(git_path("logs/%s", path), &st) &&
 		    S_ISREG(st.st_mode)) {
-			if (!logs_found++)
+			if (!logs_found++) {
 				*log = xstrdup(path);
+				resolve_ref(path, sha1, 0, NULL);
+			}
 			if (!warn_ambiguous_refs)
 				break;
 		}
@@ -317,7 +319,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
 		/* allow "@{...}" to mean the current branch reflog */
 		refs_found = dwim_ref("HEAD", 4, sha1, &real_ref);
 	} else if (reflog_len)
-		refs_found = dwim_log(str, len, &real_ref);
+		refs_found = dwim_log(str, len, sha1, &real_ref);
 	else
 		refs_found = dwim_ref(str, len, sha1, &real_ref);
 
-- 
1.5.0.rc2.652.g4dfde-dirty

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]