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 2/2] notes: allow non-writable actions on refs outside of refs/notes
Date: Wed, 16 Sep 2015 15:06:34 -0700 [thread overview]
Message-ID: <1442441194-5506-3-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>
Allow non-destructive notes actions which do not require write
permission to be performed on refs outside of refs/notes/. The primary
advantage of this is to allow fetching remote refs to such location as
"refs/remote-notes/<remote>/foo" and then performing merges into
refs/notes/
It is not reasonable to put remote notes inside refs/notes as users may
already have conflicting names inside the notes namespace.
Remove one test case regarding merge from refs/heads/master, which will
now pass under current code. It may be worth looking how to prevent
some of these more obviously wrong merges.
Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
---
builtin/notes.c | 13 +++++--------
t/t3308-notes-merge.sh | 1 -
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/builtin/notes.c b/builtin/notes.c
index 0f55d38983f0..ff056014d953 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -333,14 +333,14 @@ static struct notes_tree *init_notes_check(const char *subcommand,
int flags)
{
struct notes_tree *t;
- const char *ref;
init_notes(NULL, NULL, NULL, flags);
t = &default_notes_tree;
- ref = (flags & NOTES_INIT_WRITABLE) ? t->update_ref : t->ref;
- if (!starts_with(ref, "refs/notes/"))
- die("Refusing to %s notes in %s (outside of refs/notes/)",
- subcommand, ref);
+ if (flags & NOTES_INIT_WRITABLE) {
+ if (!starts_with(t->update_ref, "refs/notes"))
+ die("Refusing to %s notes in %s (outside of refs/notes/)",
+ subcommand, t->update_ref);
+ }
return t;
}
@@ -810,9 +810,6 @@ 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;
diff --git a/t/t3308-notes-merge.sh b/t/t3308-notes-merge.sh
index 24d82b49bbea..f0feb64bae6e 100755
--- a/t/t3308-notes-merge.sh
+++ b/t/t3308-notes-merge.sh
@@ -90,7 +90,6 @@ test_expect_success 'fail to merge various non-note-trees' '
test_must_fail git notes merge refs/notes/ &&
test_must_fail git notes merge refs/notes/dir &&
test_must_fail git notes merge refs/notes/dir/ &&
- test_must_fail git notes merge refs/heads/master &&
test_must_fail git notes merge x: &&
test_must_fail git notes merge x:foo &&
test_must_fail git notes merge foo^{bar
--
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 ` [PATCH 1/2] notes: don't expand qualified refs in expand_notes_ref Jacob Keller
2015-09-16 22:34 ` 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 ` Jacob Keller [this message]
2015-09-16 22:36 ` [PATCH 0/2] notes: allow read only notes actions on refs outside of refs/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-3-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.