Commit 1510c839e3f1402633f5652133ea013854f2d58b

Stefan Sperling 2020-03-20T18:49:54

really make 'got fetch' create/update references correctly in mirror mode (fixes commit fed0b873)

diff --git a/got/got.c b/got/got.c
index 61b79dc..8f68b8f 100644
--- a/got/got.c
+++ b/got/got.c
@@ -1454,22 +1454,12 @@ cmd_fetch(int argc, char *argv[])
 		struct got_reference *ref;
 		char *remote_refname;
 
-		if (remote->mirror_references) {
-			error = got_ref_alloc(&ref, refname, id);
-			if (error)
-				goto done;
-			error = got_ref_write(ref, repo);
-			got_ref_close(ref);
-			if (error)
-				goto done;
-			continue;
-		}
-
 		error = got_object_id_str(&id_str, id);
 		if (error)
 			goto done;
 
-		if (strncmp("refs/tags/", refname, 10) == 0) {
+		if (remote->mirror_references ||
+		    strncmp("refs/tags/", refname, 10) == 0) {
 			error = got_ref_open(&ref, repo, refname, 0);
 			if (error) {
 				if (error->code != GOT_ERR_NOT_REF)