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

Re: Fatal error running status in new repo

From
Jeff King <peff@peff.net>
Date
Feb 16, 2010, 07:21 UTC
Message-ID
<20100216072154.GF2169@coredump.intra.peff.net>
In-Reply-To
<20100216062422.GC10296@vfb-9.home>
On Mon, Feb 15, 2010 at 10:24:22PM -0800, Jacob Helwig wrote:
[in an empty repo]
Show 6 quoted lines
> $ GIT_TRACE=1 git status
> trace: built-in: git 'status'
> # On branch master
> #
> # Initial commit
> #
[...]
> trace: run_command: 'git-submodule' 'summary' '--cached' '--for-status' '--summary-limit' '-1' 'HEAD'
[...]
> trace: built-in: git 'rev-parse' '-q' '--verify' 'HEAD^0'
> warning: ignoring dangling symref HEAD.
[...]
> trace: built-in: git 'diff-index' '--cached' '--raw' 'HEAD' '--' 'HEAD'
> fatal: bad revision 'HEAD'

The patch I just posted elsewhere in the thread fixes the "ignoring dangling symref" message. The "bad revision 'HEAD'" comes from diff-index. But as you can see, that diff-index invocation is somewhat bogus.

It looks like this code (git-submodule.sh:556-562):
        if rev=$(git rev-parse -q --verify "$1^0")
        then
                head=$rev
                shift
        else
                head=HEAD
        fi

is meant to guess whether the argument is a revision or a file limiter, and if the latter, assume HEAD was meant. Which obviously breaks down when the argument is HEAD and it is invalid. The patch below seems to fix it for me, but I have no idea if I am breaking something else.

Can somebody more clueful about the submodule script take a look?
-Peff
---
diff --git a/git-submodule.sh b/git-submodule.sh
index 664f217..4332992 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -555,10 +555,12 @@ cmd_summary() {
 
 	if rev=$(git rev-parse -q --verify "$1^0")
 	then
 		head=$rev
 		shift
+	elif test "$1" = "HEAD"; then
+		return
 	else
 		head=HEAD
 	fi
 
 	if [ -n "$files" ]
Previous: Jeff KingNext: Johan Herland
Message 6 of 8 in “Fatal error running status in new repo”
  1. Jacob HelwigFeb 16, 2010
  2. Jeff KingFeb 16, 2010
  3. Jacob HelwigFeb 16, 2010
  4. Jeff KingFeb 16, 2010
  5. dwim_ref: fix dangling symref warningJeff King, Feb 16, 2010
  6. Jeff KingFeb 16, 2010
  7. submodule summary: Don't barf when invoked in an empty repoJohan Herland, Feb 16, 2010
  8. Jeff KingFeb 17, 2010

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.