From: Junio C Hamano <junkio@cox.net>
To: git@vger.kernel.org
Subject: [RFC] Suffix /HEAD everywhere.
Date: Fri, 21 Apr 2006 22:55:47 -0700 [thread overview]
Message-ID: <7vhd4mnogs.fsf@assigned-by-dhcp.cox.net> (raw)
This is another throw-away idea, but people doing Porcelain
might be interested.
We currently allow "origin" to mean $GIT_DIR/refs/remotes/origin/HEAD,
to give consistent "git fetch origin" semantics for repositories
cloned with the --use-separate-remote option.
Why not extend this to places other than "refs/remotes/*"?
With this patch, I could arrange the refs like this:
$GIT_DIR/refs/heads/master/
$GIT_DIR/refs/heads/master/HEAD (symref points at somewhere)
$GIT_DIR/refs/heads/master/master (perhaps here)
$GIT_DIR/refs/heads/master/topic1 (topic branched from "master")
$GIT_DIR/refs/heads/master/topic2 (another)
and I can just say "master" to mean refs/heads/master/master,
and say "master/topic1", "master/topic1" to name the topic
branches.
This patch only does the reading side, and when somebody tries
to implement creation/update side, some unsurmountable problems
may be discovered, but it just seemed an interesting idea. I do
not know how useful it is, tho.
-jc
diff --git a/sha1_name.c b/sha1_name.c
index 345935b..ab2eaf7 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -237,13 +237,15 @@ static int ambiguous_path(const char *pa
static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
{
static const char *fmt[] = {
- "%.*s",
- "refs/%.*s",
- "refs/tags/%.*s",
- "refs/heads/%.*s",
- "refs/remotes/%.*s",
- "refs/remotes/%.*s/HEAD",
- NULL
+ "%.*s%s",
+ "refs/%.*s%s",
+ "refs/tags/%.*s%s",
+ "refs/heads/%.*s%s",
+ "refs/remotes/%.*s%s",
+ };
+ static const char *sfx[] = {
+ "",
+ "/HEAD",
};
const char **p;
const char *warning = "warning: refname '%.*s' is ambiguous.\n";
@@ -259,17 +261,21 @@ static int get_sha1_basic(const char *st
if (ambiguous_path(str, len))
return -1;
- for (p = fmt; *p; p++) {
- this_result = already_found ? sha1_from_ref : sha1;
- pathname = git_path(*p, len, str);
- if (!read_ref(pathname, this_result)) {
- if (warn_ambiguous_refs) {
- if (already_found)
- fprintf(stderr, warning, len, str);
- already_found++;
+ for (p = fmt; p < fmt + ARRAY_SIZE(fmt); p++) {
+ const char **s;
+ for (s = sfx; s < sfx + ARRAY_SIZE(sfx); s++) {
+ this_result = already_found ? sha1_from_ref : sha1;
+ pathname = git_path(*p, len, str, *s);
+ if (!read_ref(pathname, this_result)) {
+ if (warn_ambiguous_refs) {
+ if (already_found)
+ fprintf(stderr, warning,
+ len, str);
+ already_found++;
+ }
+ else
+ return 0;
}
- else
- return 0;
}
}
if (already_found)
reply other threads:[~2006-04-22 19:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vhd4mnogs.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).