X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=reflog-walk.c;h=86d18843f52046d87741bffa9f865ec973a2ae73;hb=56efd9d2524694717adf5405fccad90e2791ebfa;hp=caba4f743f2dcc1cf7046cec294f242b2af19052;hpb=03f94ae9f909952ed5a78917ab319a312889354b;p=git.git diff --git a/reflog-walk.c b/reflog-walk.c index caba4f743..86d18843f 100644 --- a/reflog-walk.c +++ b/reflog-walk.c @@ -50,9 +50,13 @@ static struct complete_reflogs *read_complete_reflog(const char *ref) for_each_reflog_ent(ref, read_one_reflog, reflogs); if (reflogs->nr == 0) { unsigned char sha1[20]; - const char *name = resolve_ref(ref, sha1, 1, NULL); - if (name) + const char *name; + void *name_to_free; + name = name_to_free = resolve_refdup(ref, sha1, 1, NULL); + if (name) { for_each_reflog_ent(name, read_one_reflog, reflogs); + free(name_to_free); + } } if (reflogs->nr == 0) { int len = strlen(ref); @@ -162,17 +166,17 @@ int add_reflog_for_walk(struct reflog_walk_info *info, } else recno = 0; - item = string_list_lookup(branch, &info->complete_reflogs); + item = string_list_lookup(&info->complete_reflogs, branch); if (item) reflogs = item->util; else { if (*branch == '\0') { unsigned char sha1[20]; - const char *head = resolve_ref("HEAD", sha1, 0, NULL); - if (!head) - die ("No current branch"); free(branch); - branch = xstrdup(head); + branch = resolve_refdup("HEAD", sha1, 0, NULL); + if (!branch) + die ("No current branch"); + } reflogs = read_complete_reflog(branch); if (!reflogs || reflogs->nr == 0) { @@ -190,7 +194,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info, } if (!reflogs || reflogs->nr == 0) return -1; - string_list_insert(branch, &info->complete_reflogs)->util + string_list_insert(&info->complete_reflogs, branch)->util = reflogs; } @@ -239,7 +243,6 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit) commit->parents = xcalloc(sizeof(struct commit_list), 1); commit->parents->item = commit_info->commit; - commit->object.flags &= ~(ADDED | SEEN | SHOWN); } void get_reflog_selector(struct strbuf *sb, @@ -292,6 +295,18 @@ void get_reflog_message(struct strbuf *sb, strbuf_add(sb, info->message, len); } +const char *get_reflog_ident(struct reflog_walk_info *reflog_info) +{ + struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog; + struct reflog_info *info; + + if (!commit_reflog) + return NULL; + + info = &commit_reflog->reflogs->items[commit_reflog->recno+1]; + return info->email; +} + void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline, enum date_mode dmode) {