[PATCH] clone: fix refspec on "--single-branch" option
- From
Ralf Thielow <ralf.thielow@gmail.com>
- Date
- Sep 14, 2012, 05:09 UTC
- Message-ID
- <1347599357-15533-1-git-send-email-ralf.thielow@gmail.com>
- In-Reply-To
- <CAN0XMOKszADpeaCG7VhL-AZ3m7_hSWV3NhEmPuH6FETzs=eDNg@mail.gmail.com>
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@gmail.com> --- 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