Thread (1 message) 1 message, 1 author, 2016-06-15

Re: Latest master failing t7401 submodule tests

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:48:23
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Junio C Hamano [off-list ref] writes:
Jeff King [off-list ref] writes:
quoted
I did see it on my debian unstable box with with dash as /bin/sh (though
3deea89 (submodule summary: Don't barf when invoked in an empty repo,
2010-02-16) looks broken.  It shifts $1 unconditionally when:

 - "git submodule summary", no arguments given and defaults to HEAD which
   is _not_ unborn (we shouldn't shift in this case);

 - "git submodule summary HEAD path...", which is not unborn (we should shift);

 - "git submodule summary path...", defaults to HEAD which is _not_ unborn
   (we shouldn't shift).
IOW, shouldn't the code look more like this?

	if test $# != 0 && head=$(git rev-parse -q --verify "$1")
	then
		shift
	else
		git rev-parse -q --verify HEAD >/dev/null || return 0
		head=HEAD
	fi

That is, if a specific version might be there, we see if it is a version
and shift it out only if that is the case.  Otherwise we default to HEAD
but special case for an unborn HEAD (and report success).


 git-submodule.sh |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 5869c00..bd3a8d4 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -553,15 +553,12 @@ cmd_summary() {
 
 	test $summary_limit = 0 && return
 
-	if rev=$(git rev-parse -q --verify --default HEAD ${1+"$1"})
+	if test $# != 0 && head=$(git rev-parse -q --verify "$1")
 	then
-		head=$rev
 		shift
-	elif test -z "$1" -o "$1" = "HEAD"
-	then
-		return
 	else
-		head="HEAD"
+		git rev-parse -q --verify HEAD >/dev/null || return 0
+		head=HEAD
 	fi
 
 	if [ -n "$files" ]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help