mirror of
https://github.com/git/git
synced 2024-10-02 14:45:21 +00:00
show-branch: simplify rev_is_head()
Only one of the callers of rev_is_head() provides two hashes to compare. Move that check there and convert it to struct object_id. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
225bc32a98
commit
e4f8d27585
|
@ -482,10 +482,9 @@ static void snarf_refs(int head, int remotes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rev_is_head(const char *head, const char *name,
|
static int rev_is_head(const char *head, const char *name)
|
||||||
unsigned char *head_sha1, unsigned char *sha1)
|
|
||||||
{
|
{
|
||||||
if (!head || (head_sha1 && sha1 && !hasheq(head_sha1, sha1)))
|
if (!head)
|
||||||
return 0;
|
return 0;
|
||||||
skip_prefix(head, "refs/heads/", &head);
|
skip_prefix(head, "refs/heads/", &head);
|
||||||
if (!skip_prefix(name, "refs/heads/", &name))
|
if (!skip_prefix(name, "refs/heads/", &name))
|
||||||
|
@ -806,9 +805,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
|
||||||
/* We are only interested in adding the branch
|
/* We are only interested in adding the branch
|
||||||
* HEAD points at.
|
* HEAD points at.
|
||||||
*/
|
*/
|
||||||
if (rev_is_head(head,
|
if (rev_is_head(head, ref_name[i]))
|
||||||
ref_name[i],
|
|
||||||
head_oid.hash, NULL))
|
|
||||||
has_head++;
|
has_head++;
|
||||||
}
|
}
|
||||||
if (!has_head) {
|
if (!has_head) {
|
||||||
|
@ -867,10 +864,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
|
||||||
if (1 < num_rev || extra < 0) {
|
if (1 < num_rev || extra < 0) {
|
||||||
for (i = 0; i < num_rev; i++) {
|
for (i = 0; i < num_rev; i++) {
|
||||||
int j;
|
int j;
|
||||||
int is_head = rev_is_head(head,
|
int is_head = rev_is_head(head, ref_name[i]) &&
|
||||||
ref_name[i],
|
oideq(&head_oid, &rev[i]->object.oid);
|
||||||
head_oid.hash,
|
|
||||||
rev[i]->object.oid.hash);
|
|
||||||
if (extra < 0)
|
if (extra < 0)
|
||||||
printf("%c [%s] ",
|
printf("%c [%s] ",
|
||||||
is_head ? '*' : ' ', ref_name[i]);
|
is_head ? '*' : ' ', ref_name[i]);
|
||||||
|
|
Loading…
Reference in a new issue