[PATCH v2 21/23] ref_remote_duplicates(): extract a function handle_duplicate()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It will become more complex in a moment.

Signed-off-by: Michael Haggerty <mhagger@xxxxxxxxxxxx>
---
 remote.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/remote.c b/remote.c
index c90a2bf..2deb2db 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;
-- 
1.8.4.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]