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

Re: [PATCH 1/2] notes get-ref: --expand expands the output notes ref.

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 6, 2012, 19:47 UTC
Message-ID
<7vr4qf2atd.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120906061147.GA11770@odin.tremily.us>
"W. Trevor King" <wking@tremily.us> writes:
Show 8 quoted lines
> On Wed, Sep 05, 2012 at 10:23:54PM -0700, Junio C Hamano wrote:
>> Really?  Would "git log --expand master" be useful?
>
> I'm clearly not an expert on this, but isn't that what
>
>   git show-ref master
>
> is for?

But then can't you say the same against "git notes get-ref --expand" with "git show-ref refs/remotes/origin/notes/foobla"?

My primary point is that I think it is a UI mistake if the DWIM ignores the user input that directly names that can be interpreted without DWIMming. When the user wants to avoid ambiguity, it should always be possible to spell it out without having to worry about the DWIM code to get in the way.

The problem with the current notes.c:expand_notes_ref() is that it does not allow you to do that, and if you fixed that problem, the user never has to ask "what does this expand to", no?

Perhaps something like this. Note that this only deals with an existing ref, and that is semi-deliberate (because I am not yet convinced that it is a good idea to let any ref outside refs/notes/ to be created to hold a notes tree).

 notes.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git i/notes.c w/notes.c
index 93e9868..126839e 100644
--- i/notes.c
+++ w/notes.c
@@ -1289,6 +1289,8 @@ int copy_note(struct notes_tree *t,
 
 void expand_notes_ref(struct strbuf *sb)
 {
+	if (!prefixcmp(sb->buf, "refs/") && ref_exists(sb->buf))
+		return;
 	if (!prefixcmp(sb->buf, "refs/notes/"))
 		return; /* we're happy */
 	else if (!prefixcmp(sb->buf, "notes/"))
Previous: W. Trevor KingNext: Johan Herland
Message 6 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.