git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] notes: allow non-writable actions on refs outside of refs/notes

From
Jacob Keller <jacob.e.keller@intel.com>
Date
Sep 16, 2015, 22:06 UTC
Message-ID
<1442441194-5506-3-git-send-email-jacob.e.keller@intel.com>
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
Previous: Jacob KellerNext: Mike Hommey
Message 11 of 13 in “notes: allow read only notes actions on refs outside of refs/notes”
  1. 0/2 notes: allow read only notes actions on refs outside of refs/notesJacob Keller, Sep 16, 2015
  2. 1/2 notes: don't expand qualified refs in expand_notes_refJacob Keller, Sep 16, 2015
  3. Junio C HamanoSep 16, 2015
  4. Jacob KellerSep 16, 2015
  5. Jacob KellerSep 22, 2015
  6. Junio C HamanoSep 22, 2015
  7. Jacob KellerSep 22, 2015
  8. Jacob KellerSep 22, 2015
  9. Junio C HamanoSep 22, 2015
  10. Jacob KellerSep 22, 2015
  11. 2/2 notes: allow non-writable actions on refs outside of refs/notesJacob Keller, Sep 16, 2015
  12. Mike HommeySep 16, 2015
  13. Jacob KellerSep 16, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.