Junio C Hamano <[email protected]> writes:
> Alternatively, if you can move the logic to set up this
> configuration further down so that it happens after we talked to the
> other side and figured out remote_head_points_at, you could instead
> set it up to keep a single remote tracking branch.
>
> Even if you did so, guess_remote_head() may not find any branch when
> the other repository's HEAD is detached, so you would need to decide
> what to do in such a case, and "fetch and integrate their HEAD
> without using any remote tracking branch" may be a reasonable thing
> to do in such a case.
Along the lines of this, perhaps.
builtin/clone.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git i/builtin/clone.c w/builtin/clone.c
index 5e8f3ba..c9e099d 100644
--- i/builtin/clone.c
+++ w/builtin/clone.c
@@ -853,6 +853,22 @@ int cmd_clone(int argc, const char **argv, const char
*prefix)
"refs/heads/master");
}
+ if (option_single_branch) {
+ /* Fix up the refspec for fetch */
+ strbuf_reset(&value);
+ if (!remote_head_points_at)
+ strbuf_addf(&value, "HEAD");
+ else
+ strbuf_addf(&value, "%s:%s%s",
+ remote_head_points_at->name,
+ branch_top.buf,
+ skip_prefix(remote_head_points_at->name,
"refs/heads/"));
+
+ strbuf_reset(&key);
+ strbuf_addf(&key, "remote.%s.fetch", option_origin);
+ git_config_set_multivar(key.buf, value.buf, NULL, 1);
+ }
+
if (is_local)
clone_local(path, git_dir);
else if (refs && complete_refs_before_fetch)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html