Skip to content

Commit 14e940d

Browse files
committed
submodule summary: do not fail before the first commit
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 <[email protected]>
1 parent caa9c3c commit 14e940d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

git-submodule.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@ cmd_summary() {
559559
test $# = 0 || shift
560560
elif test -z "$1" -o "$1" = "HEAD"
561561
then
562-
return
562+
# before the first commit: compare with an empty tree
563+
head=$(git hash-object -w -t tree --stdin </dev/null)
563564
else
564565
head="HEAD"
565566
fi

0 commit comments

Comments
 (0)