@matheusbsbs / matheus-bagliano / commits / eb3a48221f
Fork 0

log --reflog: use dwim_log

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> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Feb 9, 2007 at 01:28 UTC eb3a48221fd4a0b38c31976028dbab7df51be6d4
3 files changed +15 -1
cache.h
+1
@@ -302,6 +302,7 @@ extern char *sha1_to_hex(const unsigned char *sha1); /* static buffer result! */
302 extern int read_ref(const char *filename, unsigned char *sha1);
303 extern const char *resolve_ref(const char *path, unsigned char *sha1, int, int *);
304 extern int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref);
305 +extern int dwim_log(const char *str, int len, unsigned char *sha1, char **ref);
306
307 extern int create_symref(const char *ref, const char *refs_heads_master, const char *logmsg);
308 extern int validate_headref(const char *ref);
reflog-walk.c
+13
@@ -174,6 +174,19 @@ void add_reflog_for_walk(struct reflog_walk_info *info,
174 branch = xstrdup(head);
175 }
176 reflogs = read_complete_reflog(branch);
177 + if (!reflogs || reflogs->nr == 0) {
178 + unsigned char sha1[20];
179 + char *b;
180 + if (dwim_log(branch, strlen(branch), sha1, &b) == 1) {
181 + if (reflogs) {
182 + free(reflogs->ref);
183 + free(reflogs);
184 + }
185 + free(branch);
186 + branch = b;
187 + reflogs = read_complete_reflog(branch);
188 + }
189 + }
190 if (!reflogs || reflogs->nr == 0)
191 die("No reflogs found for '%s'", branch);
192 path_list_insert(branch, &info->complete_reflogs)->util
sha1_name.c
+1 -1
@@ -267,7 +267,7 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
267 return refs_found;
268 }
269
270 -static int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
270 +int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
271 {
272 const char **p;
273 int logs_found = 0;