[PATCH] clone: fix refspec on "--single-branch" option

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

 



After using "git clone" with the "--single-branch"
option, the configured refspec for this repo was
"+refs/heads/*:refs/remotes/origin/*".
After fetching changes from this repo again, it'll
receive all refs instead of the single ref which
was used in "--single-branch". Fixing the refspec
that it just contains the ref of the branch which
was cloned.

Signed-off-by: Ralf Thielow <ralf.thielow@xxxxxxxxx>
---
 builtin/clone.c | 5 ++++-
 1 Datei geändert, 4 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 5e8f3ba..3e74d55 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -754,7 +754,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
 	}
 
-	strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
+	if (option_single_branch)
+		strbuf_addf(&value, "+%s%s:%s%s", src_ref_prefix, option_branch, branch_top.buf, option_branch);
+	else
+		strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
 
 	if (option_mirror || !option_bare) {
 		/* Configure the remote */
-- 
1.7.12.395.g6b149ce.dirty

--
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]