[PATCH] log --reflog: use dwim_log

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Johannes Schindelin
Date: Thursday, February 8, 2007 - 5:28 pm

Since "git log origin/master" uses dwim_log() to match
"refs/remotes/origin/master", it makes sense to do that for
"git log --reflog", too.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---

	I changed dwim_ref() to dwim_log() as per Nico's request.

 cache.h       |    1 +
 reflog-walk.c |   13 +++++++++++++
 sha1_name.c   |    2 +-
 3 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/cache.h b/cache.h
index 6f55fdc..44941c0 100644
--- a/cache.h
+++ b/cache.h
@@ -304,6 +304,7 @@ extern char *sha1_to_hex(const unsigned char *sha1);	/* static buffer result! */
 extern int read_ref(const char *filename, unsigned char *sha1);
 extern const char *resolve_ref(const char *path, unsigned char *sha1, int, int *);
 extern int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref);
+extern int dwim_log(const char *str, int len, unsigned char *sha1, char **ref);
 
 extern int create_symref(const char *ref, const char *refs_heads_master, const char *logmsg);
 extern int validate_headref(const char *ref);
diff --git a/reflog-walk.c b/reflog-walk.c
index 653ec95..e0f1332 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -174,6 +174,19 @@ void add_reflog_for_walk(struct reflog_walk_info *info,
 			branch = xstrdup(head);
 		}
 		reflogs = read_complete_reflog(branch);
+		if (!reflogs || reflogs->nr == 0) {
+			unsigned char sha1[20];
+			char *b;
+			if (dwim_log(branch, strlen(branch), sha1, &b) == 1) {
+				if (reflogs) {
+					free(reflogs->ref);
+					free(reflogs);
+				}
+				free(branch);
+				branch = b;
+				reflogs = read_complete_reflog(branch);
+			}
+		}
 		if (!reflogs || reflogs->nr == 0)
 			die("No reflogs found for '%s'", branch);
 		path_list_insert(branch, &info->complete_reflogs)->util
diff --git a/sha1_name.c b/sha1_name.c
index d0d9536..c50a378 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -268,7 +268,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, unsigned char *sha1, char **log)
+int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
 {
 	const char **p;
 	int logs_found = 0;
-- 
1.5.0.rc4.2051.g679c-dirty


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [BUG] Empty reflogs and &quot;git log -g&quot;, Jakub Narebski, (Thu Feb 8, 12:37 pm)
Re: [BUG] Empty reflogs and &quot;git log -g&quot;, Johannes Schindelin, (Thu Feb 8, 12:46 pm)
Re: [BUG] Empty reflogs and &quot;git log -g&quot;, Junio C Hamano, (Thu Feb 8, 4:18 pm)
[PATCH] for_each_reflog_ent: be forgiving about missing me ..., Johannes Schindelin, (Thu Feb 8, 4:59 pm)
[PATCH] log --reflog: use dwim_log, Johannes Schindelin, (Thu Feb 8, 5:28 pm)
Re: [PATCH] log --reflog: use dwim_log, Junio C Hamano, (Thu Feb 8, 8:43 pm)
Re: [PATCH] log --reflog: use dwim_log, Junio C Hamano, (Fri Feb 9, 12:19 am)