summaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorJohan Herland <johan@herland.net>2010-02-16 10:21:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-02-17 19:14:04 (GMT)
commit3deea89c5feb0dfdfb99ea752f83497d97a3bdd5 (patch)
treed44dac620a12cedcc1e8c73724b166ff35423a78 /git-submodule.sh
parente923eaeb901ff056421b9007adcbbce271caa7b6 (diff)
downloadgit-3deea89c5feb0dfdfb99ea752f83497d97a3bdd5.zip
git-3deea89c5feb0dfdfb99ea752f83497d97a3bdd5.tar.gz
git-3deea89c5feb0dfdfb99ea752f83497d97a3bdd5.tar.bz2
submodule summary: Don't barf when invoked in an empty repo
When invoking "git submodule summary" in an empty repo (which can be indirectly done by setting status.submodulesummary = true), it currently emits an error message (via "git diff-index") since HEAD points to an unborn branch. This patch adds handling of the HEAD-points-to-unborn-branch special case, so that "git submodule summary" no longer emits this error message. The patch also adds a test case that verifies the fix. Suggested-by: Jeff King <peff@peff.net> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh7
1 files changed, 5 insertions, 2 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 664f217..5869c00 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -553,12 +553,15 @@ cmd_summary() {
test $summary_limit = 0 && return
- if rev=$(git rev-parse -q --verify "$1^0")
+ if rev=$(git rev-parse -q --verify --default HEAD ${1+"$1"})
then
head=$rev
shift
+ elif test -z "$1" -o "$1" = "HEAD"
+ then
+ return
else
- head=HEAD
+ head="HEAD"
fi
if [ -n "$files" ]