Merge branch 'jh/maint-submodule-status-in-void'
authorJunio C Hamano <gitster@pobox.com>
Wed, 24 Mar 2010 23:55:37 +0000 (16:55 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Mar 2010 23:55:37 +0000 (16:55 -0700)
* jh/maint-submodule-status-in-void:
git submodule summary: Handle HEAD as argument when on an unborn branch
submodule summary: do not fail before the first commit

1  2 
git-submodule.sh
diff --combined git-submodule.sh
index f21d0bfce7020edeaed8c0066760e5f55e7facb9,5a9d3c0b305cc57e45b8f15b0d2c522bb8bb3285..2dd372a21d82a109774e80e014f9959485202b3e
@@@ -222,7 -222,7 +222,7 @@@ cmd_add(
  
                module_clone "$path" "$realrepo" "$reference" || exit
                (
 -                      unset GIT_DIR
 +                      clear_local_git_env
                        cd "$path" &&
                        # ash fails to wordsplit ${branch:+-b "$branch"...}
                        case "$branch" in
@@@ -278,7 -278,7 +278,7 @@@ cmd_foreach(
                        name=$(module_name "$path")
                        (
                                prefix="$prefix$path/"
 -                              unset GIT_DIR
 +                              clear_local_git_env
                                cd "$path" &&
                                eval "$@" &&
                                if test -n "$recursive"
@@@ -434,7 -434,7 +434,7 @@@ cmd_update(
                        module_clone "$path" "$url" "$reference"|| exit
                        subsha1=
                else
 -                      subsha1=$(unset GIT_DIR; cd "$path" &&
 +                      subsha1=$(clear_local_git_env; cd "$path" &&
                                git rev-parse --verify HEAD) ||
                        die "Unable to find current revision in submodule path '$path'"
                fi
  
                        if test -z "$nofetch"
                        then
 -                              (unset GIT_DIR; cd "$path" &&
 +                              (clear_local_git_env; cd "$path" &&
                                        git-fetch) ||
                                die "Unable to fetch in submodule path '$path'"
                        fi
                                ;;
                        esac
  
 -                      (unset GIT_DIR; cd "$path" && $command "$sha1") ||
 +                      (clear_local_git_env; cd "$path" && $command "$sha1") ||
                        die "Unable to $action '$sha1' in submodule path '$path'"
                        say "Submodule path '$path': $msg '$sha1'"
                fi
  
                if test -n "$recursive"
                then
 -                      (unset GIT_DIR; cd "$path" && cmd_update $orig_args) ||
 +                      (clear_local_git_env; cd "$path" && cmd_update $orig_args) ||
                        die "Failed to recurse into submodule path '$path'"
                fi
        done
  
  set_name_rev () {
        revname=$( (
 -              unset GIT_DIR
 +              clear_local_git_env
                cd "$1" && {
                        git describe "$2" 2>/dev/null ||
                        git describe --tags "$2" 2>/dev/null ||
@@@ -559,7 -559,9 +559,9 @@@ 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)
+               test -z "$1" || shift
        else
                head="HEAD"
        fi
@@@ -760,7 -762,7 +762,7 @@@ cmd_status(
                else
                        if test -z "$cached"
                        then
 -                              sha1=$(unset GIT_DIR; cd "$path" && git rev-parse --verify HEAD)
 +                              sha1=$(clear_local_git_env; cd "$path" && git rev-parse --verify HEAD)
                                set_name_rev "$path" "$sha1"
                        fi
                        say "+$sha1 $displaypath$revname"
                then
                        (
                                prefix="$displaypath/"
 -                              unset GIT_DIR
 +                              clear_local_git_env
                                cd "$path" &&
                                cmd_status $orig_args
                        ) ||
@@@ -821,7 -823,7 +823,7 @@@ cmd_sync(
                if test -e "$path"/.git
                then
                (
 -                      unset GIT_DIR
 +                      clear_local_git_env
                        cd "$path"
                        remote=$(get_default_remote)
                        say "Synchronizing submodule url for '$name'"