Skip to content

Commit e6a7c75

Browse files
peffgitster
authored andcommitted
show-branch: drop head_len variable
We copy the result of resolving HEAD into a buffer and keep track of its length. But we never actually use the length for anything besides the copy. Let's stop passing it around. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c3808ca commit e6a7c75

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

builtin/show-branch.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static void snarf_refs(int head, int remotes)
470470
}
471471
}
472472

473-
static int rev_is_head(char *head, int headlen, char *name,
473+
static int rev_is_head(char *head, char *name,
474474
unsigned char *head_sha1, unsigned char *sha1)
475475
{
476476
if ((!head[0]) ||
@@ -623,7 +623,6 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
623623
enum rev_sort_order sort_order = REV_SORT_IN_GRAPH_ORDER;
624624
char head[128];
625625
const char *head_p;
626-
int head_len;
627626
struct object_id head_oid;
628627
int merge_base = 0;
629628
int independent = 0;
@@ -790,11 +789,10 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
790789
head_p = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
791790
head_oid.hash, NULL);
792791
if (head_p) {
793-
head_len = strlen(head_p);
792+
size_t head_len = strlen(head_p);
794793
memcpy(head, head_p, head_len + 1);
795794
}
796795
else {
797-
head_len = 0;
798796
head[0] = 0;
799797
}
800798

@@ -805,7 +803,6 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
805803
* HEAD points at.
806804
*/
807805
if (rev_is_head(head,
808-
head_len,
809806
ref_name[i],
810807
head_oid.hash, NULL))
811808
has_head++;
@@ -864,7 +861,6 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
864861
for (i = 0; i < num_rev; i++) {
865862
int j;
866863
int is_head = rev_is_head(head,
867-
head_len,
868864
ref_name[i],
869865
head_oid.hash,
870866
rev[i]->object.oid.hash);

0 commit comments

Comments
 (0)