Commit Diff


commit - 060e4bc5aff897f77640114eac72635dcd4e4f67
commit + ad24f7125f40392151477f227319ba2262d39f8c
blob - cc02089bfcb70faf1775da8b8a38eb7bfd903018
blob + 4181bc79115b549c541be0a74f00f51030a6135d
--- include/got_error.h
+++ include/got_error.h
@@ -188,6 +188,7 @@
 #define GOT_ERR_BUNDLE_FORMAT 171
 #define GOT_ERR_BAD_KEYWORD	172
 #define GOT_ERR_UNKNOWN_CAPA	173
+#define GOT_ERR_REF_DUP_ENTRY	174
 
 struct got_error {
         int code;
blob - a983354f342d03a44ca16cbc218c0893b984f89c
blob + c5d59f16626b38afb601f327b16f0972dee3ff03
--- lib/error.c
+++ lib/error.c
@@ -247,6 +247,7 @@ static const struct got_error got_errors[] = {
 	{ GOT_ERR_BUNDLE_FORMAT, "unknown git bundle version" },
 	{ GOT_ERR_BAD_KEYWORD, "invalid commit keyword" },
 	{ GOT_ERR_UNKNOWN_CAPA, "unknown capability" },
+	{ GOT_ERR_REF_DUP_ENTRY, "duplicate reference entry" },
 };
 
 static struct got_custom_error {
blob - 5eef14a20c2095f7d3e35d90b6f6c9df86504786
blob + 0d59d0619bb61265301d9a21f60750d827128d4c
--- lib/fetch.c
+++ lib/fetch.c
@@ -309,10 +309,12 @@ got_fetch_pack(struct got_object_id **pack_hash, struc
 			packfile_size_cur = 0;
 		if (!done && refname && id) {
 			err = got_pathlist_insert(&pe, refs, refname, id);
-			if (err)
-				goto done;
-			if (pe == NULL)
+			if (err || pe == NULL) {
 				free(id);
+				free(refname);
+				if (err != NULL)
+					goto done;
+			}
 		} else if (!done && server_progress) {
 			char *p;
 			/*
blob - 2b7c36baf89ab7470fda3802cbe1bf5fcea0195f
blob + 9f22802cbb4d97bfcac3e127e9faea01132d9c9f
--- lib/send.c
+++ lib/send.c
@@ -198,10 +198,13 @@ insert_sendable_ref(struct got_pathlist_head *refs, co
 	}
 
 	err = got_pathlist_insert(&new, refs, target_refname, id);
+	if (new == NULL && err == NULL)
+		err = got_error(GOT_ERR_REF_DUP_ENTRY);
+
 done:
 	if (ref)
 		got_ref_close(ref);
-	if (err || new == NULL /* duplicate */)
+	if (err)
 		free(id);
 	return err;
 }
@@ -384,8 +387,12 @@ got_send_pack(const char *remote_name, struct got_path
 			}
 		}
 		err = insert_sendable_ref(&have_refs, branchname, s, repo);
-		if (err)
-			goto done;
+		if (err) {
+			if (err->code != GOT_ERR_REF_DUP_ENTRY)
+				goto done;
+			err = NULL;
+			free(s);
+		}
 		s = NULL;
 	}
 
@@ -420,8 +427,12 @@ got_send_pack(const char *remote_name, struct got_path
 			}
 		}
 		err = insert_sendable_ref(&have_refs, s, s, repo);
-		if (err)
-			goto done;
+		if (err) {
+			if (err->code != GOT_ERR_REF_DUP_ENTRY)
+				goto done;
+			err = NULL;
+			free(s);
+		}
 		s = NULL;
 	}