Re: What's cooking in git.git (Jan 2009, #07; Wed, 28)

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

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Johannes Schindelin <Johannes.Schindelin@xxxxxx> writes:
>
>> How about installing
>>
>> 	[branch "master"]
>> 		remote = origin
>> 		merge = refs/heads/master
>>
>> by default?  It is a safe bet that this will be the case for 99% of all 
>> users that want to clone an empty repository (especially if they are 
>> putting their public repositories on something like repo.or.cz, where you 
>> cannot change the default branch from "master" to something else).
>
> I think this is a reasonable thing to do.

So I've been sort of waiting for a trivial patch to materialize, and then
almost forgot about it like everybody else did.  Before all of us forget,
here is my attempt to do the above.

We seem to have acquired a bad habit of discussing and agreeing on a
potential improvement and then not following through, forgetting it
altogether.

Exciting new features we can count on original submitters to stick to them
and push them forward whether we go into a release freeze, but the more
boring kind of patches that we already know what we want to see by the
next release are actually the more important to the overall project;
sadly, they tend to get lost somewhere in the crack.  I wonder if we can
do anything about it.

And no, a bug tracker is not the answer, even though it could be a (small)
part of the solution.

-- >8 --
Subject: Install the default "master" branch configuration after cloning a void

After "cloning from an empty repository", we have a configuration to
describe the remote's URL and the default ref mappings, but we lack the
branch configuration for the default branch we create on our end,
"master".

It is likely that the empty repository we cloned from will point the
default "master" branch with its HEAD, so prepare the local configuration
to match.

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 builtin-clone.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/builtin-clone.c b/builtin-clone.c
index f73029e..431c136 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -350,6 +350,18 @@ static struct ref *write_remote_refs(const struct ref *refs,
 	return local_refs;
 }
 
+static void install_branch_config(const char *origin, const char *local,
+				  const char *remote)
+{
+	struct strbuf key = STRBUF_INIT;
+	strbuf_addf(&key, "branch.%s.remote", local);
+	git_config_set(key.buf, origin);
+	strbuf_reset(&key);
+	strbuf_addf(&key, "branch.%s.merge", local);
+	git_config_set(key.buf, remote);
+	strbuf_release(&key);
+}
+
 int cmd_clone(int argc, const char **argv, const char *prefix)
 {
 	int use_local_hardlinks = 1;
@@ -539,6 +551,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		head_points_at = NULL;
 		remote_head = NULL;
 		option_no_checkout = 1;
+		if (!option_bare)
+			install_branch_config(option_origin, "master",
+					      "refs/heads/master");
 	}
 
 	if (head_points_at) {
@@ -567,11 +582,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 				      head_points_at->peer_ref->name,
 				      reflog_msg.buf);
 
-			strbuf_addf(&key, "branch.%s.remote", head);
-			git_config_set(key.buf, option_origin);
-			strbuf_reset(&key);
-			strbuf_addf(&key, "branch.%s.merge", head);
-			git_config_set(key.buf, head_points_at->name);
+			install_branch_config(option_origin, head,
+					      head_points_at->name);
 		}
 	} else if (remote_head) {
 		/* Source had detached HEAD pointing somewhere. */
--
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