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

[PATCH 2/2] notes: don't alter refs starting with 'refs/' in expand_notes_ref

From
W. Trevor King <wking@tremily.us>
Date
Sep 5, 2012, 12:52 UTC
Message-ID
<8c65d450f545ad3f6a241ef1b95fca272ec3a38a.1346849556.git.wking@tremily.us>
In-Reply-To
<cover.1346848834.git.wking@tremily.us>
From: "W. Trevor King" <wking@tremily.us>
This avoids surprising cases like:
  $ GIT_NOTES_REF=refs/remotes/origin/notes/commits git notes get-ref --expand
  refs/notes/refs/remotes/origin/notes/commits

With the old implementation, all note refs had to live under 'refs/notes/' which was not mentioned in the git-notes.txt.

Signed-off-by: W. Trevor King <wking@tremily.us>
---
 notes.c          | 2 +-
 t/t3301-notes.sh | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/notes.c b/notes.c
index 93e9868..60394c8 100644
--- a/notes.c
+++ b/notes.c
@@ -1289,7 +1289,7 @@ int copy_note(struct notes_tree *t,
 
 void expand_notes_ref(struct strbuf *sb)
 {
-	if (!prefixcmp(sb->buf, "refs/notes/"))
+	if (!prefixcmp(sb->buf, "refs/"))
 		return; /* we're happy */
 	else if (!prefixcmp(sb->buf, "notes/"))
 		strbuf_insert(sb, 0, "refs/", 5);
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index c0486a0..707d7e6 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -1230,4 +1230,8 @@ test_expect_success 'git notes get-ref (--expand)' '
 	test "$(GIT_NOTES_REF=commits git notes get-ref --expand)" = "refs/notes/commits"
 '
 
+test_expect_success 'git notes get-ref (--expand)' '
+	test "$(GIT_NOTES_REF=refs/remotes/origin/notes/commits git notes get-ref --expand)" = "refs/remotes/origin/notes/commits"
+'
+
 test_done
-- 
1.7.12.176.g3fc0e4c.dirty
Previous: Johan HerlandNext: Johan Herland
Message 8 of 11 in “Add --expand to 'git notes get-ref'”
  1. 0/2 Add --expand to 'git notes get-ref'W. Trevor King, Sep 5, 2012
  2. 1/2 notes get-ref: --expand expands the output notes ref.W. Trevor King, Sep 5, 2012
  3. Johan HerlandSep 5, 2012
  4. Junio C HamanoSep 6, 2012
  5. W. Trevor KingSep 6, 2012
  6. Junio C HamanoSep 6, 2012
  7. Johan HerlandSep 10, 2012
  8. 2/2 notes: don't alter refs starting with 'refs/' in expand_notes_refW. Trevor King, Sep 5, 2012
  9. Johan HerlandSep 5, 2012
  10. W. Trevor KingSep 5, 2012
  11. Johan HerlandSep 5, 2012

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.