Skip to content

Commit

Permalink
Merge branch 'jh/maint-submodule-status-in-void'
Browse files Browse the repository at this point in the history
* jh/maint-submodule-status-in-void:
  submodule summary: Don't barf when invoked in an empty repo
  • Loading branch information
Junio C Hamano committed Mar 2, 2010
2 parents 39914cb + 3deea89 commit 490b8ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions git-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
7 changes: 7 additions & 0 deletions t/t7401-submodule-summary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,11 @@ test_expect_success 'fail when using --files together with --cached' "
test_must_fail git submodule summary --files --cached
"

test_expect_success 'should not fail in an empty repo' "
git init xyzzy &&
cd xyzzy &&
git submodule summary >output 2>&1 &&
test_cmp output /dev/null
"

test_done

0 comments on commit 490b8ad

Please sign in to comment.