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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Feb 14, 2017 at 12:26 UTC
e6a7c75298001996790059e3ae70c627b3204dd9
1 file changed
+2
-6
builtin/show-branch.c
+2
-6
@@ -470,7 +470,7 @@ static void snarf_refs(int head, int remotes)
470
}
471
}
472
473
-static int rev_is_head(char *head, int headlen, char *name,
473
+static int rev_is_head(char *head, char *name,
474
unsigned char *head_sha1, unsigned char *sha1)
475
{
476
if ((!head[0]) ||
@@ -623,7 +623,6 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
623
enum rev_sort_order sort_order = REV_SORT_IN_GRAPH_ORDER;
624
char head[128];
625
const char *head_p;
626
- int head_len;
626
struct object_id head_oid;
627
int merge_base = 0;
628
int independent = 0;
@@ -790,11 +789,10 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
789
head_p = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
790
head_oid.hash, NULL);
791
if (head_p) {
793
- head_len = strlen(head_p);
792
+ size_t head_len = strlen(head_p);
793
memcpy(head, head_p, head_len + 1);
794
}
795
else {
797
- head_len = 0;
796
head[0] = 0;
797
}
798
@@ -805,7 +803,6 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
803
* HEAD points at.
804
*/
805
if (rev_is_head(head,
808
- head_len,
806
ref_name[i],
807
head_oid.hash, NULL))
808
has_head++;
@@ -864,7 +861,6 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
861
for (i = 0; i < num_rev; i++) {
862
int j;
863
int is_head = rev_is_head(head,
867
- head_len,
864
ref_name[i],
865
head_oid.hash,
866
rev[i]->object.oid.hash);