summaryrefslogtreecommitdiff
path: root/builtin/for-each-ref.c
diff options
context:
space:
mode:
authorKarthik Nayak <karthik.188@gmail.com>2015-06-13 19:37:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-06-15 18:48:08 (GMT)
commitfc80edcae1cdaac42b2e09c64df2e5cd06e3a336 (patch)
tree0f9f177c55a47c5b073b12b6ec2a9cb4b19f3694 /builtin/for-each-ref.c
parented01e206ba53a52d0094abcd9f99237b4e2847c9 (diff)
downloadgit-fc80edcae1cdaac42b2e09c64df2e5cd06e3a336.zip
git-fc80edcae1cdaac42b2e09c64df2e5cd06e3a336.tar.gz
git-fc80edcae1cdaac42b2e09c64df2e5cd06e3a336.tar.bz2
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.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index cc65620..f0d7d44 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;
}