Skip to content

Commit

Permalink
ref_remote_duplicates(): extract a function handle_duplicate()
Browse files Browse the repository at this point in the history
It will become more complex in a moment.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Oct 30, 2013
1 parent b9afe66 commit df02ebd
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,15 @@ int for_each_remote(each_remote_fn fn, void *priv)
return result;
}

static void handle_duplicate(struct ref *ref1, struct ref *ref2)
{
if (strcmp(ref1->name, ref2->name))
die("%s tracks both %s and %s",
ref2->peer_ref->name, ref1->name, ref2->name);
free(ref2->peer_ref);
free(ref2);
}

struct ref *ref_remove_duplicates(struct ref *ref_map)
{
struct string_list refs = STRING_LIST_INIT_NODUP;
Expand All @@ -766,14 +775,7 @@ struct ref *ref_remove_duplicates(struct ref *ref_map)

if (item->util) {
/* Entry already existed */
if (strcmp(((struct ref *)item->util)->name,
ref->name))
die("%s tracks both %s and %s",
ref->peer_ref->name,
((struct ref *)item->util)->name,
ref->name);
free(ref->peer_ref);
free(ref);
handle_duplicate((struct ref *)item->util, ref);
} else {
*p = ref;
p = &ref->next;
Expand Down

0 comments on commit df02ebd

Please sign in to comment.