Merge branch 'jk/empty-archive' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 3 Apr 2013 16:25:15 +0000 (09:25 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Apr 2013 16:25:15 +0000 (09:25 -0700)
"git archive" reports a failure when asked to create an archive out
of an empty tree. It would be more intuitive to give an empty
archive back in such a case.

* jk/empty-archive:
archive: handle commits with an empty tree
test-lib: factor out $GIT_UNZIP setup

1  2 
t/t5003-archive-zip.sh
t/test-lib.sh
diff --combined t/t5003-archive-zip.sh
index 6a33606d28eba61281252cf28f6d5820dc452f1d,0f5b42b8eddc358dca7bd318368edbac88fed349..4e7b05dd2391125b1c9e58404c552647107099cd
@@@ -3,15 -3,9 +3,9 @@@
  test_description='git archive --format=zip test'
  
  . ./test-lib.sh
- GIT_UNZIP=${GIT_UNZIP:-unzip}
  
  SUBSTFORMAT=%H%n
  
- test_lazy_prereq UNZIP '
-       "$GIT_UNZIP" -v
-       test $? -ne 127
- '
  test_lazy_prereq UNZIP_SYMLINKS '
        (
                mkdir unzip-symlinks &&
@@@ -76,12 -70,6 +70,12 @@@ test_expect_success 
       git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
       git commit-tree $treeid </dev/null)'
  
 +test_expect_success 'setup export-subst' '
 +      echo "substfile?" export-subst >>.git/info/attributes &&
 +      git log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \
 +              >a/substfile1
 +'
 +
  test_expect_success \
      'create bare clone' \
      'git clone --bare . bare.git &&
diff --combined t/test-lib.sh
index 9e7f6b424d77ee88c3cd36507cd421a437ec7bfa,e20fc6992267ea14b2af75ab928408fc8cc76b88..1f510252ad7cb7a5afae67731bc37fccf941b654
@@@ -214,13 -214,11 +214,13 @@@ the
                error)
                        tput bold; tput setaf 1;; # bold red
                skip)
 -                      tput bold; tput setaf 2;; # bold green
 +                      tput setaf 4;; # blue
 +              warn)
 +                      tput setaf 3;; # brown/yellow
                pass)
 -                      tput setaf 2;;            # green
 +                      tput setaf 2;; # green
                info)
 -                      tput setaf 3;;            # brown
 +                      tput setaf 6;; # cyan
                *)
                        test -n "$quiet" && return;;
                esac
@@@ -302,7 -300,7 +302,7 @@@ test_ok_ () 
  
  test_failure_ () {
        test_failure=$(($test_failure + 1))
 -      say_color error "not ok - $test_count $1"
 +      say_color error "not ok $test_count - $1"
        shift
        echo "$@" | sed -e 's/^/#       /'
        test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
  
  test_known_broken_ok_ () {
        test_fixed=$(($test_fixed+1))
 -      say_color "" "ok $test_count - $@ # TODO known breakage"
 +      say_color error "ok $test_count - $@ # TODO known breakage vanished"
  }
  
  test_known_broken_failure_ () {
        test_broken=$(($test_broken+1))
 -      say_color skip "not ok $test_count - $@ # TODO known breakage"
 +      say_color warn "not ok $test_count - $@ # TODO known breakage"
  }
  
  test_debug () {
@@@ -408,18 -406,13 +408,18 @@@ test_done () 
  
        if test "$test_fixed" != 0
        then
 -              say_color pass "# fixed $test_fixed known breakage(s)"
 +              say_color error "# $test_fixed known breakage(s) vanished; please update test(s)"
        fi
        if test "$test_broken" != 0
        then
 -              say_color error "# still have $test_broken known breakage(s)"
 -              msg="remaining $(($test_count-$test_broken)) test(s)"
 +              say_color warn "# still have $test_broken known breakage(s)"
 +      fi
 +      if test "$test_broken" != 0 || test "$test_fixed" != 0
 +      then
 +              test_remaining=$(( $test_count - $test_broken - $test_fixed ))
 +              msg="remaining $test_remaining test(s)"
        else
 +              test_remaining=$test_count
                msg="$test_count test(s)"
        fi
        case "$test_failure" in
  
                if test $test_external_has_tap -eq 0
                then
 -                      if test $test_count -gt 0
 +                      if test $test_remaining -gt 0
                        then
                                say_color pass "# passed all $msg"
                        fi
@@@ -624,7 -617,7 +624,7 @@@ for skp in $GIT_SKIP_TEST
  do
        case "$this_test" in
        $skp)
 -              say_color skip >&3 "skipping test $this_test altogether"
 +              say_color info >&3 "skipping test $this_test altogether"
                skip_all="skip all tests in $this_test"
                test_done
        esac
@@@ -666,14 -659,12 +666,14 @@@ case $(uname -s) i
        # backslashes in pathspec are converted to '/'
        # exec does not inherit the PID
        test_set_prereq MINGW
 +      test_set_prereq NOT_CYGWIN
        test_set_prereq SED_STRIPS_CR
        ;;
  *CYGWIN*)
        test_set_prereq POSIXPERM
        test_set_prereq EXECKEEPSPID
        test_set_prereq NOT_MINGW
 +      test_set_prereq CYGWIN
        test_set_prereq SED_STRIPS_CR
        ;;
  *)
        test_set_prereq BSLASHPSPEC
        test_set_prereq EXECKEEPSPID
        test_set_prereq NOT_MINGW
 +      test_set_prereq NOT_CYGWIN
        ;;
  esac
  
@@@ -760,3 -750,9 +760,9 @@@ test_lazy_prereq AUTOIDENT 
  # When the tests are run as root, permission tests will report that
  # things are writable when they shouldn't be.
  test -w / || test_set_prereq SANITY
+ GIT_UNZIP=${GIT_UNZIP:-unzip}
+ test_lazy_prereq UNZIP '
+       "$GIT_UNZIP" -v
+       test $? -ne 127
+ '