From fc407f9821840041757975045c4a1ca01effa27a Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 28 Nov 2012 23:11:01 +0100 Subject: Add new simplified git-remote-testgit Exercising the python remote helper framework is for another tool and another test. This is about testing the remote-helper interface. It's way simpler, it exercises the same features of remote helpers, it's easy to read and understand, and it doesn't depend on python. For now let's just copy the old remote-helpers test script, although some of those tests don't make sense. In addition, this script would be able to test other features not currently being tested. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- git-remote-testgit | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 git-remote-testgit (limited to 'git-remote-testgit') diff --git a/git-remote-testgit b/git-remote-testgit new file mode 100755 index 0000000000..5042f5a11f --- /dev/null +++ b/git-remote-testgit @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +# Copyright (c) 2012 Felipe Contreras + +alias=$1 +url=$2 + +# huh? +url="${url#file://}" + +dir="$GIT_DIR/testgit/$alias" +prefix="refs/testgit/$alias" +refspec="refs/heads/*:${prefix}/heads/*" + +gitmarks="$dir/git.marks" +testgitmarks="$dir/testgit.marks" + +export GIT_DIR="$url/.git" + +mkdir -p "$dir" + +test -e "$gitmarks" || > "$gitmarks" +test -e "$testgitmarks" || > "$testgitmarks" + +while read line +do + case $line in + capabilities) + echo 'import' + echo 'export' + echo "refspec $refspec" + echo "*import-marks $gitmarks" + echo "*export-marks $gitmarks" + 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 + + echo "feature import-marks=$gitmarks" + echo "feature export-marks=$gitmarks" + git fast-export --use-done-feature --{import,export}-marks="$testgitmarks" $refs | + sed -e "s#refs/heads/#${prefix}/heads/#g" + ;; + export) + git fast-import --{import,export}-marks="$testgitmarks" --quiet + echo + ;; + '') + exit + ;; + esac +done -- cgit v1.2.3 From 984f37681c937be0c7c1135e86141a83920edcc1 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 28 Nov 2012 23:11:02 +0100 Subject: remote-testgit: remove non-local functionality This only makes sense for the python remote helpers framework. The tests don't exercise any feature of transport helper. Remove them. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- git-remote-testgit | 3 --- 1 file changed, 3 deletions(-) (limited to 'git-remote-testgit') diff --git a/git-remote-testgit b/git-remote-testgit index 5042f5a11f..5117ab5fe0 100755 --- a/git-remote-testgit +++ b/git-remote-testgit @@ -4,9 +4,6 @@ alias=$1 url=$2 -# huh? -url="${url#file://}" - dir="$GIT_DIR/testgit/$alias" prefix="refs/testgit/$alias" refspec="refs/heads/*:${prefix}/heads/*" -- cgit v1.2.3 From ee10fbf90c74c14ae16a27f4bce8a2dd1704c9cb Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 28 Nov 2012 23:11:05 +0100 Subject: remote-testgit: exercise more features Unfortunately a lot of these tests fail. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- git-remote-testgit | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'git-remote-testgit') diff --git a/git-remote-testgit b/git-remote-testgit index 5117ab5fe0..efda74bee3 100755 --- a/git-remote-testgit +++ b/git-remote-testgit @@ -6,17 +6,25 @@ url=$2 dir="$GIT_DIR/testgit/$alias" prefix="refs/testgit/$alias" -refspec="refs/heads/*:${prefix}/heads/*" -gitmarks="$dir/git.marks" -testgitmarks="$dir/testgit.marks" +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" -test -e "$gitmarks" || > "$gitmarks" -test -e "$testgitmarks" || > "$testgitmarks" +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" + testgitmarks_args=( "--"{import,export}"-marks=$testgitmarks" ) +fi while read line do @@ -24,9 +32,12 @@ do capabilities) echo 'import' echo 'export' - echo "refspec $refspec" - echo "*import-marks $gitmarks" - echo "*export-marks $gitmarks" + test -n "$refspec" && echo "refspec $refspec" + if test -n "$gitmarks" + then + echo "*import-marks $gitmarks" + echo "*export-marks $gitmarks" + fi echo ;; list) @@ -45,13 +56,16 @@ do test "${line%% *}" != "import" && break done - echo "feature import-marks=$gitmarks" - echo "feature export-marks=$gitmarks" - git fast-export --use-done-feature --{import,export}-marks="$testgitmarks" $refs | + if test -n "$gitmarks" + then + echo "feature import-marks=$gitmarks" + echo "feature export-marks=$gitmarks" + fi + git fast-export --use-done-feature "${testgitmarks_args[@]}" $refs | sed -e "s#refs/heads/#${prefix}/heads/#g" ;; export) - git fast-import --{import,export}-marks="$testgitmarks" --quiet + git fast-import "${testgitmarks_args[@]}" --quiet echo ;; '') -- cgit v1.2.3 From 93b5cf9cd12a0b9491559429969b351daa3638a5 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 28 Nov 2012 23:11:06 +0100 Subject: remote-testgit: report success after an import Doesn't make a difference for the tests, but it does for the ones seeking reference. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- git-remote-testgit | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'git-remote-testgit') diff --git a/git-remote-testgit b/git-remote-testgit index efda74bee3..6fb8780677 100755 --- a/git-remote-testgit +++ b/git-remote-testgit @@ -65,7 +65,20 @@ do sed -e "s#refs/heads/#${prefix}/heads/#g" ;; export) + before=$(git for-each-ref --format='%(refname) %(objectname)') + git fast-import "${testgitmarks_args[@]}" --quiet + + after=$(git for-each-ref --format='%(refname) %(objectname)') + + # figure out which refs were updated + join -e 0 -o '0 1.2 2.2' -a 2 <(echo "$before") <(echo "$after") | + while read ref a b + do + test $a == $b && continue + echo "ok $ref" + done + echo ;; '') -- cgit v1.2.3 From 1d3f9a30938e12b8ef7b807df7565b40b743d421 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 28 Nov 2012 23:11:07 +0100 Subject: remote-testgit: implement the "done" feature manually People who want to write their own remote-helper will find it more useful to see clearly how they are supposed to advertise and implement the "done" feature themselves. Right now we are relying on fast-export to do that by using the --use-done-feature argument. However, people writing their own remote-helper would probably not have such an option, as they would probably be writing the fast-export functionality themselves. It should now be clearer to them. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- git-remote-testgit | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'git-remote-testgit') diff --git a/git-remote-testgit b/git-remote-testgit index 6fb8780677..b395c8de59 100755 --- a/git-remote-testgit +++ b/git-remote-testgit @@ -61,8 +61,10 @@ do echo "feature import-marks=$gitmarks" echo "feature export-marks=$gitmarks" fi - git fast-export --use-done-feature "${testgitmarks_args[@]}" $refs | + echo "feature done" + git fast-export "${testgitmarks_args[@]}" $refs | sed -e "s#refs/heads/#${prefix}/heads/#g" + echo "done" ;; export) before=$(git for-each-ref --format='%(refname) %(objectname)') -- cgit v1.2.3