summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2013-10-30 06:33:10 +0100
committerJunio C Hamano <gitster@pobox.com>2013-10-30 14:16:41 -0700
commitdf02ebdac8bdf0edd30e85c9902d177dccfac276 (patch)
treef9c6debfb465bc0e01d8e660cdc92aae440a6198 /remote.c
parentb9afe6654db2bfb776db933f832e7e03052adf98 (diff)
downloadgit-df02ebdac8bdf0edd30e85c9902d177dccfac276.tar.gz
ref_remote_duplicates(): extract a function handle_duplicate()
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>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/remote.c b/remote.c
index f803990760..4bed101da6 100644
--- a/remote.c
+++ b/remote.c
@@ -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;
@@ -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;