]> asedeno.scripts.mit.edu Git - git.git/commitdiff
submodule summary: do not fail before the first commit
authorJunio C Hamano <gitster@pobox.com>
Wed, 3 Mar 2010 22:19:10 +0000 (14:19 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Mar 2010 22:33:22 +0000 (14:33 -0800)
When "git status" collects changes for the index (usually relative to
HEAD), it compares the index with an empty tree when the repository does
not have an initial commit yet.  "git submodule summary" is about asking
what submodule changes would be recorded if a commit is made right now,
and should do the same comparison to report all the added submodules,
instead of punting and being silent.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-submodule.sh

index 383dc451191fef4e078e9f46aaf3fdb3190ebc9a..9aa57dd6f7c939ec3d50386a039f1640ce2aa929 100755 (executable)
@@ -559,7 +559,8 @@ cmd_summary() {
                test $# = 0 || shift
        elif test -z "$1" -o "$1" = "HEAD"
        then
-               return
+               # before the first commit: compare with an empty tree
+               head=$(git hash-object -w -t tree --stdin </dev/null)
        else
                head="HEAD"
        fi