From: Junio C Hamano Date: Fri, 7 Jun 2013 23:15:32 +0000 (-0700) Subject: Merge branch 'js/transport-helper-error-reporting-fix' into fc/makefile X-Git-Tag: v1.8.4-rc0~162^2~3 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/81b4f18fb8f9356477157a3b9f0652d371cba835?hp=--cc Merge branch 'js/transport-helper-error-reporting-fix' into fc/makefile * 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 --- 81b4f18fb8f9356477157a3b9f0652d371cba835 diff --cc git-remote-testgit.sh index 0000000000,b5289493e2..e83315f0e3 mode 000000,100755..100755 --- a/git-remote-testgit.sh +++ b/git-remote-testgit.sh @@@ -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 diff --cc t/t5801-remote-helpers.sh index dbb02e2afd,0a83db8875..61479c3b16 --- a/t/t5801-remote-helpers.sh +++ b/t/t5801-remote-helpers.sh @@@ -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 && diff --cc transport-helper.c index 522d79178e,92174095ed..f11d78a55a --- a/transport-helper.c +++ b/transport-helper.c @@@ -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)