X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=show-branch.c;h=8429c171cf6e6ddbac2f1a95da4a05f7ce8d34a3;hb=79a9d8ea0d88a3667ad19be8e705405ab5d896f1;hp=c117c536da61af0fe2cb12a1257e4537eaef92e3;hpb=1f8af483df5ea7070c421489eff40ca8e508b778;p=git.git diff --git a/show-branch.c b/show-branch.c index c117c536..8429c171 100644 --- a/show-branch.c +++ b/show-branch.c @@ -138,7 +138,20 @@ static void name_commits(struct commit_list *list, nth++; if (p->object.util) continue; - sprintf(newname, "%s^%d", n->head_name, nth); + switch (n->generation) { + case 0: + sprintf(newname, "%s^%d", + n->head_name, nth); + break; + case 1: + sprintf(newname, "%s^^%d", + n->head_name, nth); + break; + default: + sprintf(newname, "%s~%d^%d", + n->head_name, n->generation, + nth); + } name_commit(p, strdup(newname), 0); i++; name_first_parent_chain(p); @@ -196,8 +209,11 @@ static void show_one_commit(struct commit *commit) { char pretty[128], *cp; struct commit_name *name = commit->object.util; - pretty_print_commit(CMIT_FMT_ONELINE, commit->buffer, ~0, - pretty, sizeof(pretty)); + if (commit->object.parsed) + pretty_print_commit(CMIT_FMT_ONELINE, commit->buffer, ~0, + pretty, sizeof(pretty)); + else + strcpy(pretty, "(unavailable)"); if (!strncmp(pretty, "[PATCH] ", 8)) cp = pretty + 8; else @@ -333,6 +349,7 @@ int main(int ac, char **av) int all_heads = 0, all_tags = 0; int all_mask, all_revs, shown_merge_point; char head_path[128]; + const char *head_path_p; int head_path_len; unsigned char head_sha1[20]; int merge_base = 0; @@ -414,11 +431,15 @@ int main(int ac, char **av) if (0 <= extra) join_revs(&list, &seen, num_rev, extra); - head_path_len = readlink(".git/HEAD", head_path, sizeof(head_path)-1); - if ((head_path_len < 0) || get_sha1("HEAD", head_sha1)) + head_path_p = resolve_ref(git_path("HEAD"), head_sha1, 1); + if (head_path_p) { + head_path_len = strlen(head_path_p); + memcpy(head_path, head_path_p, head_path_len + 1); + } + else { + head_path_len = 0; head_path[0] = 0; - else - head_path[head_path_len] = 0; + } if (merge_base) return show_merge_base(seen, num_rev); @@ -427,7 +448,7 @@ int main(int ac, char **av) return show_independent(rev, num_rev, ref_name, rev_mask); /* Show list; --more=-1 means list-only */ - if (1 < num_rev) { + if (1 < num_rev || extra < 0) { for (i = 0; i < num_rev; i++) { int j; int is_head = rev_is_head(head_path,