Re: [PATCH 00/28] Use main as default branch name

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

 



Jeff King <peff@xxxxxxxx> writes:

> I think Eric's suggestion of using the directory name as a default was
> not previously mentioned. I'm not sure I would like that myself (I find
> value in having a consistent "this is the main branch" name across
> different repositories, at least for my workflows). And it creates all
> of the same "every tutorial is now out of date" issues. But it is
> neutral. I wouldn't be opposed to seeing it as a configurable option.

I actually recall hearing it from Eric, not on this list, directly
back in the timeframe of these previous dicsussions.  I somehow
thought I relayed it to the community, perhaps #git-devel on
freenode, but apparently not to this list.

Yes, init.defaultBranchName is defined to be a string, so it is a
bit tricky to introduce special values that mean "no, not a
hardcoded value but derive dynamically based on X".  Perhaps use a
prefix that is not allowed in a refname, perhaps like this update to
the function that uses the value read from the init.defaultBranch
configuration variable.

 refs.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git c/refs.c w/refs.c
index 392f0bbf68..3fbc697cd8 100644
--- c/refs.c
+++ w/refs.c
@@ -576,6 +576,12 @@ char *repo_default_branch_name(struct repository *r)
 
 	if (!ret)
 		ret = xstrdup("master");
+	else if (!strcmp(ret, ":dirname"))
+		ret = ... do the $(basename $(cwd)) thing ...;
+	else if (!strcmp(ret, ":some other magic"))
+		ret = ... do some other magic thing ...;
+	else if (ret[0] == ':')
+		die(_("%s - unrecognised magic", ret);
 
 	full_ref = xstrfmt("refs/heads/%s", ret);
 	if (check_refname_format(full_ref, 0))



[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