@@ -697,6 +697,7 @@ static int do_fetch(struct transport *transport,
697
697
struct ref * ref_map ;
698
698
struct ref * rm ;
699
699
int autotags = (transport -> remote -> fetch_tags == 1 );
700
+ int retcode = 0 ;
700
701
701
702
for_each_ref (add_existing , & existing_refs );
702
703
@@ -712,9 +713,9 @@ static int do_fetch(struct transport *transport,
712
713
713
714
/* if not appending, truncate FETCH_HEAD */
714
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 ;
718
719
}
719
720
720
721
ref_map = get_ref_map (transport , refs , ref_count , tags , & autotags );
@@ -736,7 +737,8 @@ static int do_fetch(struct transport *transport,
736
737
transport_set_option (transport , TRANS_OPT_FOLLOWTAGS , "1" );
737
738
if (fetch_refs (transport , ref_map )) {
738
739
free_refs (ref_map );
739
- return 1 ;
740
+ retcode = 1 ;
741
+ goto cleanup ;
740
742
}
741
743
if (prune ) {
742
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,
779
781
free_refs (ref_map );
780
782
}
781
783
782
- return 0 ;
784
+ cleanup :
785
+ string_list_clear (& existing_refs , 0 );
786
+ return retcode ;
783
787
}
784
788
785
789
static void set_option (const char * name , const char * value )
0 commit comments