From: Jacob Keller <jacob.e.keller@intel.com>
To: git@vger.kernel.org
Cc: Mike Hommey <mh@glandium.org>, Johan Herland <johan@herland.net>,
Michael Haggerty <mhagger@alum.mit.edu>,
Jacob Keller <jacob.keller@gmail.com>
Subject: [PATCH 1/2] notes: don't expand qualified refs in expand_notes_ref
Date: Wed, 16 Sep 2015 15:06:33 -0700 [thread overview]
Message-ID: <1442441194-5506-2-git-send-email-jacob.e.keller@intel.com> (raw)
In-Reply-To: <1442441194-5506-1-git-send-email-jacob.e.keller@intel.com>
From: Jacob Keller <jacob.keller@gmail.com>
The documentation for --refs says that it will treat unqualified refs as
under refs/notes. Current behavior is to prefix refs/notes to all
strings that do not start with refs/notes or notes/, resulting in
performing actions on refs such as "refs/notes/refs/foo/bar" instead of
attempting to perform actions on "refs/foo/bar". A future patch will
introduce the idea of performing non-writable actions to refs outside of
refs/notes. Change the behavior of expand_notes_ref to leave qualified
refs under refs/* alone.
In addition, fix git notes merge <ref> to prevent merges from refs which
are not under refs/notes, in a similar way to how we already check note
refs in init_notes_check. This is required in order to keep current
tests passing without change. A future patch will change the behavior of
git notes merge so that it can merge from a ref outside of refs/notes.
Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
---
builtin/notes.c | 4 ++++
notes.c | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/builtin/notes.c b/builtin/notes.c
index 6371d536d164..0f55d38983f0 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -810,6 +810,10 @@ static int merge(int argc, const char **argv, const char *prefix)
o.local_ref = default_notes_ref();
strbuf_addstr(&remote_ref, argv[0]);
expand_notes_ref(&remote_ref);
+ if (!starts_with(remote_ref.buf, "refs/notes"))
+ die("Refusing to merge notes from %s (outside of refs/notes/)",
+ remote_ref.buf);
+
o.remote_ref = remote_ref.buf;
t = init_notes_check("merge", NOTES_INIT_WRITABLE);
diff --git a/notes.c b/notes.c
index 6ef347ca3ac4..d49168fb3f01 100644
--- a/notes.c
+++ b/notes.c
@@ -1296,8 +1296,8 @@ int copy_note(struct notes_tree *t,
void expand_notes_ref(struct strbuf *sb)
{
- if (starts_with(sb->buf, "refs/notes/"))
- return; /* we're happy */
+ if (starts_with(sb->buf, "refs/"))
+ return; /* fully qualified, so we're happy */
else if (starts_with(sb->buf, "notes/"))
strbuf_insert(sb, 0, "refs/", 5);
else
--
2.6.0.rc2.248.g5b5be23
next prev parent reply other threads:[~2015-09-16 22:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 22:06 [PATCH 0/2] notes: allow read only notes actions on refs outside of refs/notes Jacob Keller
2015-09-16 22:06 ` Jacob Keller [this message]
2015-09-16 22:34 ` [PATCH 1/2] notes: don't expand qualified refs in expand_notes_ref Junio C Hamano
2015-09-16 23:00 ` Jacob Keller
2015-09-22 6:50 ` Jacob Keller
2015-09-22 14:17 ` Junio C Hamano
2015-09-22 15:26 ` Jacob Keller
2015-09-22 17:54 ` Jacob Keller
2015-09-22 18:37 ` Junio C Hamano
2015-09-22 18:48 ` Jacob Keller
2015-09-16 22:06 ` [PATCH 2/2] notes: allow non-writable actions on refs outside of refs/notes Jacob Keller
2015-09-16 22:36 ` [PATCH 0/2] notes: allow read only notes " Mike Hommey
2015-09-16 23:01 ` Jacob Keller
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=1442441194-5506-2-git-send-email-jacob.e.keller@intel.com \
--to=jacob.e.keller@intel.com \
--cc=git@vger.kernel.org \
--cc=jacob.keller@gmail.com \
--cc=johan@herland.net \
--cc=mh@glandium.org \
--cc=mhagger@alum.mit.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.