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

On writing builtin-reset.c, a question about git-reset.sh

From
CRCarlos Rica <jasampler@gmail.com>
Date
Aug 19, 2007, 23:45 UTC
Message-ID
<46C8D604.4090203@gmail.com>

Hi, I'm writing builtin-reset.c and I'm really stuck with a little code in git-reset.sh:

if orig=$(git rev-parse --verify HEAD 2>/dev/null)
then
	echo "$orig" >"$GIT_DIR/ORIG_HEAD"
else
	rm -f "$GIT_DIR/ORIG_HEAD"
fi

My question is about when this condition could fail (and then the rm executed), and if you would be able to reproduce it in tests. I couldn't, and asking for this in the IRC didn't help me at all.

This code was introduced in 45d197, when different reset types were introduced, and it seems that there was a reason for doing it that way, looking at the change.

Thanks in advance for your support.

-- Carlos

Next: Junio C Hamano
Message 1 of 2 in “On writing builtin-reset.c, a question about git-reset.sh”
  1. Carlos RicaAug 19, 2007
  2. Junio C HamanoAug 20, 2007

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.