Thread (8 messages) flat view 8 messages, 3 authors, 2016-06-15

Re: Fatal error running status in new repo

From: Jeff King <hidden>
Date: 2016-06-15 22:48:17
Subsystem: the rest · Maintainer: Linus Torvalds

On Mon, Feb 15, 2010 at 10:24:22PM -0800, Jacob Helwig wrote:

[in an empty repo]
$ 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" ]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help