]> granicus.if.org Git - git/commitdiff
for-each-ref: clean up code
authorKarthik Nayak <karthik.188@gmail.com>
Sat, 13 Jun 2015 19:37:20 +0000 (01:07 +0530)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Jun 2015 18:48:08 +0000 (11:48 -0700)
In 'grab_single_ref()' remove the extra count variable 'cnt' and
use the variable 'grab_cnt' of structure 'grab_ref_cbdata' directly
instead.

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/for-each-ref.c

index cc65620930235c5edb6d0a92bf540a371e7e1f36..f0d7d448a62fe49a359a451c685759a9ddfa9890 100644 (file)
@@ -897,7 +897,6 @@ static int grab_single_ref(const char *refname, const struct object_id *oid,
 {
        struct grab_ref_cbdata *cb = cb_data;
        struct refinfo *ref;
-       int cnt;
 
        if (flag & REF_BAD_NAME) {
                  warning("ignoring ref with broken name %s", refname);
@@ -914,10 +913,8 @@ static int grab_single_ref(const char *refname, const struct object_id *oid,
         */
        ref = new_refinfo(refname, oid->hash, flag);
 
-       cnt = cb->grab_cnt;
-       REALLOC_ARRAY(cb->grab_array, cnt + 1);
-       cb->grab_array[cnt++] = ref;
-       cb->grab_cnt = cnt;
+       REALLOC_ARRAY(cb->grab_array, cb->grab_cnt + 1);
+       cb->grab_array[cb->grab_cnt++] = ref;
        return 0;
 }