do_fetch(): clean up existing_refs before exiting
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
May 25, 2013 at 11:08 UTC
5b87d8d3f53c1dfb54027123af612488abc85006
1 file changed
+9
-5
builtin/fetch.c
+9
-5
@@ -697,6 +697,7 @@ static int do_fetch(struct transport *transport,
697
struct ref *ref_map;
698
struct ref *rm;
699
int autotags = (transport->remote->fetch_tags == 1);
700
+ int retcode = 0;
701
702
for_each_ref(add_existing, &existing_refs);
703
@@ -712,9 +713,9 @@ static int do_fetch(struct transport *transport,
713
714
/* if not appending, truncate FETCH_HEAD */
715
if (!append && !dry_run) {
715
- int errcode = truncate_fetch_head();
716
- if (errcode)
717
- return errcode;
716
+ retcode = truncate_fetch_head();
717
+ if (retcode)
718
+ goto cleanup;
719
}
720
721
ref_map = get_ref_map(transport, refs, ref_count, tags, &autotags);
@@ -736,7 +737,8 @@ static int do_fetch(struct transport *transport,
737
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
738
if (fetch_refs(transport, ref_map)) {
739
free_refs(ref_map);
739
- return 1;
740
+ retcode = 1;
741
+ goto cleanup;
742
}
743
if (prune) {
744
/* If --tags was specified, pretend the user gave us the canonical tags refspec */
@@ -779,7 +781,9 @@ static int do_fetch(struct transport *transport,
781
free_refs(ref_map);
782
}
783
782
- return 0;
784
+ cleanup:
785
+ string_list_clear(&existing_refs, 0);
786
+ return retcode;
787
}
788
789
static void set_option(const char *name, const char *value)