diff options
author | Karthik Nayak <karthik.188@gmail.com> | 2015-06-14 01:07:20 +0530 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-06-15 11:48:08 -0700 |
commit | fc80edcae1cdaac42b2e09c64df2e5cd06e3a336 (patch) | |
tree | 0f9f177c55a47c5b073b12b6ec2a9cb4b19f3694 /builtin/for-each-ref.c | |
parent | ed01e206ba53a52d0094abcd9f99237b4e2847c9 (diff) | |
download | git-fc80edcae1cdaac42b2e09c64df2e5cd06e3a336.tar.gz git-fc80edcae1cdaac42b2e09c64df2e5cd06e3a336.tar.xz |
for-each-ref: clean up code
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>
Diffstat (limited to 'builtin/for-each-ref.c')
-rw-r--r-- | builtin/for-each-ref.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index cc6562093..f0d7d448a 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -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; } |