git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 2/2] submodule summary: do not fail before the first commit
Date: Wed,  3 Mar 2010 14:19:10 -0800	[thread overview]
Message-ID: <1267654750-30911-2-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1267654750-30911-1-git-send-email-gitster@pobox.com>

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 |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 383dc45..eab2549 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -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
-- 
1.7.0.1.290.g2d87e

  reply	other threads:[~2010-03-03 22:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-03 22:19 [PATCH 1/2] submodule summary: do not shift a non-existent positional variable Junio C Hamano
2010-03-03 22:19 ` Junio C Hamano [this message]
2010-03-03 23:12   ` [PATCH 2/2] submodule summary: do not fail before the first commit Johan Herland
2010-03-03 23:12 ` [PATCH 1/2] submodule summary: do not shift a non-existent positional variable Johan Herland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1267654750-30911-2-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).