Merge branch 'js/transport-helper-error-reporting-fix' into fc/makefile
authorJunio C Hamano <gitster@pobox.com>
Fri, 7 Jun 2013 23:15:32 +0000 (16:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 7 Jun 2013 23:15:32 +0000 (16:15 -0700)
* js/transport-helper-error-reporting-fix:
git-remote-testgit: build it to run under $SHELL_PATH
git-remote-testgit: further remove some bashisms
git-remote-testgit: avoid process substitution
t5801: "VAR=VAL shell_func args" is forbidden
transport-helper: update remote helper namespace
transport-helper: trivial code shuffle
transport-helper: warn when refspec is not used
transport-helper: clarify pushing without refspecs
transport-helper: update refspec documentation
transport-helper: clarify *:* refspec
transport-helper: improve push messages
transport-helper: mention helper name when it dies
transport-helper: report errors properly

Conflicts:
t/t5801-remote-helpers.sh

1  2 
Documentation/gitremote-helpers.txt
Makefile
git-remote-testgit.sh
t/t5801-remote-helpers.sh
transport-helper.c
Simple merge
diff --cc Makefile
Simple merge
index 0000000000000000000000000000000000000000,b5289493e2ca84bbbff58734bcb0abcae2145312..e83315f0e31af1e89207557136aee6d40604e66f
mode 000000,100755..100755
--- /dev/null
@@@ -1,0 -1,115 +1,116 @@@
+ #!/bin/sh
+ # Copyright (c) 2012 Felipe Contreras
+ alias=$1
+ url=$2
+ dir="$GIT_DIR/testgit/$alias"
+ prefix="refs/testgit/$alias"
+ default_refspec="refs/heads/*:${prefix}/heads/*"
+ refspec="${GIT_REMOTE_TESTGIT_REFSPEC-$default_refspec}"
+ test -z "$refspec" && prefix="refs"
+ export GIT_DIR="$url/.git"
+ mkdir -p "$dir"
+ if test -z "$GIT_REMOTE_TESTGIT_NO_MARKS"
+ then
+       gitmarks="$dir/git.marks"
+       testgitmarks="$dir/testgit.marks"
+       test -e "$gitmarks" || >"$gitmarks"
+       test -e "$testgitmarks" || >"$testgitmarks"
+ fi
+ while read line
+ do
+       case $line in
+       capabilities)
+               echo 'import'
+               echo 'export'
+               test -n "$refspec" && echo "refspec $refspec"
+               if test -n "$gitmarks"
+               then
+                       echo "*import-marks $gitmarks"
+                       echo "*export-marks $gitmarks"
+               fi
++              test -n "$GIT_REMOTE_TESTGIT_SIGNED_TAGS" && echo "signed-tags"
+               echo
+               ;;
+       list)
+               git for-each-ref --format='? %(refname)' 'refs/heads/'
+               head=$(git symbolic-ref HEAD)
+               echo "@$head HEAD"
+               echo
+               ;;
+       import*)
+               # read all import lines
+               while true
+               do
+                       ref="${line#* }"
+                       refs="$refs $ref"
+                       read line
+                       test "${line%% *}" != "import" && break
+               done
+               if test -n "$gitmarks"
+               then
+                       echo "feature import-marks=$gitmarks"
+                       echo "feature export-marks=$gitmarks"
+               fi
+               if test -n "$GIT_REMOTE_TESTGIT_FAILURE"
+               then
+                       echo "feature done"
+                       exit 1
+               fi
+               echo "feature done"
+               git fast-export \
+                       ${testgitmarks:+"--import-marks=$testgitmarks"} \
+                       ${testgitmarks:+"--export-marks=$testgitmarks"} \
+                       $refs |
+               sed -e "s#refs/heads/#${prefix}/heads/#g"
+               echo "done"
+               ;;
+       export)
+               if test -n "$GIT_REMOTE_TESTGIT_FAILURE"
+               then
+                       # consume input so fast-export doesn't get SIGPIPE;
+                       # git would also notice that case, but we want
+                       # to make sure we are exercising the later
+                       # error checks
+                       while read line; do
+                               test "done" = "$line" && break
+                       done
+                       exit 1
+               fi
+               before=$(git for-each-ref --format=' %(refname) %(objectname) ')
+               git fast-import \
+                       ${testgitmarks:+"--import-marks=$testgitmarks"} \
+                       ${testgitmarks:+"--export-marks=$testgitmarks"} \
+                       --quiet
+               # figure out which refs were updated
+               git for-each-ref --format='%(refname) %(objectname)' |
+               while read ref a
+               do
+                       case "$before" in
+                       *" $ref $a "*)
+                               continue ;;     # unchanged
+                       esac
+                       echo "ok $ref"
+               done
+               echo
+               ;;
+       '')
+               exit
+               ;;
+       esac
+ done
index dbb02e2afd16b2ca53f18107f5f07af37f217c9b,0a83db8875cc221906ce292dd6247a0323ac6348..61479c3b16841c13798486590c56f265d821176c
@@@ -6,13 -6,7 +6,8 @@@
  test_description='Test remote-helper import and export commands'
  
  . ./test-lib.sh
 +. "$TEST_DIRECTORY"/lib-gpg.sh
  
- if ! type "${BASH-bash}" >/dev/null 2>&1; then
-       skip_all='skipping remote-testgit tests, bash not available'
-       test_done
- fi
  compare_refs() {
        git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
        git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
@@@ -167,25 -150,38 +151,57 @@@ test_expect_success 'push ref with exis
        compare_refs local dup server dup
  '
  
 +test_expect_success GPG 'push signed tag' '
 +      (cd local &&
 +      git checkout master &&
 +      git tag -s -m signed-tag signed-tag &&
 +      git push origin signed-tag
 +      ) &&
 +      compare_refs local signed-tag^{} server signed-tag^{} &&
 +      test_must_fail compare_refs local signed-tag server signed-tag
 +'
 +
 +test_expect_success GPG 'push signed tag with signed-tags capability' '
 +      (cd local &&
 +      git checkout master &&
 +      git tag -s -m signed-tag signed-tag-2 &&
 +      GIT_REMOTE_TESTGIT_SIGNED_TAGS=1 git push origin signed-tag-2
 +      ) &&
 +      compare_refs local signed-tag-2 server signed-tag-2
 +'
 +
+ test_expect_success 'push update refs' '
+       (cd local &&
+       git checkout -b update master &&
+       echo update >>file &&
+       git commit -a -m update &&
+       git push origin update
+       git rev-parse --verify remotes/origin/update >expect &&
+       git rev-parse --verify testgit/origin/heads/update >actual &&
+       test_cmp expect actual
+       )
+ '
+ test_expect_success 'proper failure checks for fetching' '
+       (GIT_REMOTE_TESTGIT_FAILURE=1 &&
+       export GIT_REMOTE_TESTGIT_FAILURE &&
+       cd local &&
+       test_must_fail git fetch 2> error &&
+       cat error &&
+       grep -q "Error while running fast-import" error
+       )
+ '
+ test_expect_success 'proper failure checks for pushing' '
+       (GIT_REMOTE_TESTGIT_FAILURE=1 &&
+       export GIT_REMOTE_TESTGIT_FAILURE &&
+       cd local &&
+       test_must_fail git push --all 2> error &&
+       cat error &&
+       grep -q "Reading from helper .git-remote-testgit. failed" error
+       )
+ '
  test_expect_success 'push messages' '
        (cd local &&
        git checkout -b new_branch master &&
index 522d79178e2cc4909a5df21fe483946fc3d1ad0e,92174095eda4f2446f97bdb2854e533080c0c834..f11d78a55a675ea2ea6dca0818ef796ae7fc74e3
@@@ -214,9 -212,12 +215,11 @@@ static struct child_process *get_helper
                int i;
                data->refspec_nr = refspec_nr;
                data->refspecs = parse_fetch_refspec(refspec_nr, refspecs);
 -              for (i = 0; i < refspec_nr; i++) {
 +              for (i = 0; i < refspec_nr; i++)
                        free((char *)refspecs[i]);
 -              }
                free(refspecs);
+       } else if (data->import || data->bidi_import || data->export) {
+               warning("This remote helper should implement refspec capability.");
        }
        strbuf_release(&buf);
        if (debug)