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

$(git notes merge FETCH_HEAD) doesn't work

From
Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date
Feb 20, 2014, 15:30 UTC
Message-ID
<20140220153045.GI6988@pengutronix.de>
Hello,

I started playing around with sharing git notes and so was happy to see that git-notes learned about merging since I last tried.

My first try looked as follows (using git 1:1.9.0-1 from Debian):
	$ git fetch $someremote refs/notes/commits
	...
	$ git notes merge FETCH_HEAD
	$ echo $?
	0
	$ git log --oneline refs/notes/commits..FETCH_HEAD | wc -l
	2
Looking at the source I see:
	/* argv[0] holds "FETCH_HEAD" here */
	strbuf_addstr(&remote_ref, argv[0]);
	expand_notes_ref(&remote_ref);

After the call to expand_notes_ref remote_ref contains "refs/notes/FETCH_HEAD" which isn't what I intended and I'm quite surprised by. The problem seems to be:

	/* Dereference o->remote_ref into remote_sha1 */
	if (get_sha1(o->remote_ref, remote_sha1)) {
		/*
		 * Failed to get remote_sha1. If o->remote_ref looks like an
		 * unborn ref, perform the merge using an empty notes tree.
		 */
		if (!check_refname_format(o->remote_ref, 0)) {
			hashclr(remote_sha1);
			remote = NULL;
		} else {
			die("Failed to resolve remote notes ref '%s'",
			    o->remote_ref);
		}
	} ...

The workaround is obvious (i.e. git update-ref refs/notes/somestring FETCH_HEAD; git notes merge somestring), but still I think this behaviour is not optimal. I don't know why one might want to treat a broken remote side as empty but at least a diagnostic message would be nice. The same happens if I pass an explicit sha1 instead of "FETCH_HEAD".

Best regards Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Message 1 of 1 in “$(git notes merge FETCH_HEAD) doesn't work”
  1. Uwe Kleine-KönigFeb 20, 2014

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.