[PATCH] builtin-clone: create remotes/origin/HEAD symref, if guessed

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

 



Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
---

	On Tue, 26 Feb 2008, Daniel Barkalow wrote:

	> On Tue, 26 Feb 2008, Johan Herland wrote:
	> 
	> > I've tried to test this by diffing a cloned repo against an 
	> > equivalent clone done by the old script. Below I pasted in a 
	> > few immediate fixes I found. With these fixes, the only 
	> > remaining diff between the clones is that 
	> > refs/remotes/origin/HEAD used to be a symbolic ref (with no
	> > reflog), but is now a "regular" ref (with reflog).
	> 
	> I think that's just a call to the wrong function (and a lack of 
	> very very explicit documentation).

	This fixes it.

 builtin-clone.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/builtin-clone.c b/builtin-clone.c
index 89ef665..bd09b0f 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -518,33 +518,35 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		git_config_set_multivar(key, value, "^$", 0);
 	}
 
+	if (head_points_at)
+		/* Local default branch */
+		create_symref("HEAD", head_points_at->name, NULL);
+
 	if (option_bare) {
-		if (head_points_at) {
-			/* Local default branch */
-			create_symref("HEAD", head_points_at->name, NULL);
-		}
 		junk_work_tree = NULL;
 		junk_git_dir = NULL;
 		return 0;
 	}
 
 	if (head_points_at) {
+		struct strbuf buf;
+
 		if (strrchr(head_points_at->name, '/'))
 			head = strrchr(head_points_at->name, '/') + 1;
 		else
 			head = head_points_at->name;
 
-		/* Local default branch */
-		create_symref("HEAD", head_points_at->name, NULL);
-
 		/* Tracking branch for the primary branch at the remote. */
 		update_ref(NULL, "HEAD", head_points_at->old_sha1,
 			   NULL, 0, DIE_ON_ERR);
-	/*
-		rm -f "refs/remotes/$origin/HEAD"
-		git symbolic-ref "refs/remotes/$origin/HEAD" \
-			"refs/remotes/$origin/$head_points_at" &&
-	*/
+
+		strbuf_init(&buf, 0);
+		strbuf_addstr(&buf, branch_top);
+		strbuf_addstr(&buf, "/HEAD");
+		delete_ref(buf.buf, head_points_at->old_sha1);
+		create_symref(buf.buf, head_points_at->name,
+				"clone from $repo");
+		strbuf_release(&buf);
 
 		snprintf(key, sizeof key, "branch.%s.remote", head);
 		git_config_set(key, option_origin);
-- 
1.5.4.3.446.gbe8932

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

  Powered by Linux