{"thread":{"id":"32181","subject":"[PATCH v6 p1.1 00/14] fast-export and remote-testgit improvements","startedAt":"2012-11-24T03:17:00Z","lastAt":"2012-11-26T23:52:31Z","messageCount":18,"participants":["Felipe Contreras","Junio C Hamano"],"isPatch":true,"patchVersion":6,"patchTotal":14},"messages":[{"id":"203728","messageId":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":null,"subject":"[PATCH v6 p1.1 00/14] fast-export and remote-testgit improvements","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:00Z","receivedAt":"2012-11-24T03:17:00Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nI'm rerolling this series with the changes fron Junio, plus a bit more cleanups.\n\nI dropped the last patch, because I found an issue and a separate patch series\nwould take care of that. Other than that the main changes remain the same.\n\nThe old remote-testgit is now remote-testpy (as it's testing the python\nframework, not really remote helpers). The tests are simplified, and exercise\nmore features of transport-helper, and unsuprisingly, find more bugs.\n\nCheers.\n\nInterdiff:\n\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 60e8f3b..31bfbee 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -529,9 +529,7 @@ static void get_tags_and_duplicates(struct object_array *pending,\n \t\t * sure it gets properly updated eventually.\n \t\t */\n \t\tif (commit->util || commit->object.flags & SHOWN)\n-\t\t\tif (!(commit->object.flags & UNINTERESTING))\n-\t\t\t\tstring_list_append(extra_refs, full_name)->util = commit;\n-\n+\t\t\tstring_list_append(extra_refs, full_name)->util = commit;\n \t\tif (!commit->util)\n \t\t\tcommit->util = full_name;\n \t}\n@@ -620,7 +618,7 @@ static void import_marks(char *input_file)\n \t\tif (object->flags & SHOWN)\n \t\t\terror(\"Object %s already has a mark\", sha1_to_hex(sha1));\n \n-\t\tif (object->type != 1)\n+\t\tif (object->type != OBJ_COMMIT)\n \t\t\t/* only commits */\n \t\t\tcontinue;\n \ndiff --git a/git-remote-testgit b/git-remote-testgit\nindex 4a00387..0389545 100755\n--- a/git-remote-testgit\n+++ b/git-remote-testgit\n@@ -11,9 +11,6 @@ default_refspec=\"refs/heads/*:${prefix}/heads/*\"\n \n refspec=\"${GIT_REMOTE_TESTGIT_REFSPEC-$default_refspec}\"\n \n-gitmarks=\"$dir/git.marks\"\n-testgitmarks=\"$dir/testgit.marks\"\n-\n test -z \"$refspec\" && prefix=\"refs\"\n \n export GIT_DIR=\"$url/.git\"\n@@ -22,11 +19,11 @@ mkdir -p \"$dir\"\n \n if test -z \"$GIT_REMOTE_TESTGIT_NO_MARKS\"\n then\n+\tgitmarks=\"$dir/git.marks\"\n+\ttestgitmarks=\"$dir/testgit.marks\"\n \ttest -e \"$gitmarks\" || >\"$gitmarks\"\n \ttest -e \"$testgitmarks\" || >\"$testgitmarks\"\n-else\n-\t>\"$gitmarks\"\n-\t>\"$testgitmarks\"\n+\ttestgitmarks_args=( \"--\"{import,export}\"-marks=$testgitmarks\" )\n fi\n \n while read line\n@@ -36,8 +33,11 @@ do\n \t\techo 'import'\n \t\techo 'export'\n \t\ttest -n \"$refspec\" && echo \"refspec $refspec\"\n-\t\techo \"*import-marks $gitmarks\"\n-\t\techo \"*export-marks $gitmarks\"\n+\t\tif test -n \"$gitmarks\"\n+\t\tthen\n+\t\t\techo \"*import-marks $gitmarks\"\n+\t\t\techo \"*export-marks $gitmarks\"\n+\t\tfi\n \t\techo\n \t\t;;\n \tlist)\n@@ -56,17 +56,20 @@ do\n \t\t\ttest \"${line%% *}\" != \"import\" && break\n \t\tdone\n \n-\t\techo \"feature import-marks=$gitmarks\"\n-\t\techo \"feature export-marks=$gitmarks\"\n+\t\tif test -n \"$gitmarks\"\n+\t\tthen\n+\t\t\techo \"feature import-marks=$gitmarks\"\n+\t\t\techo \"feature export-marks=$gitmarks\"\n+\t\tfi\n \t\techo \"feature done\"\n-\t\tgit fast-export --{import,export}-marks=\"$testgitmarks\" $refs |\n+\t\tgit fast-export \"${testgitmarks_args[@]}\" $refs |\n \t\tsed -e \"s#refs/heads/#${prefix}/heads/#g\"\n \t\techo \"done\"\n \t\t;;\n \texport)\n \t\tbefore=$(git for-each-ref --format='%(refname) %(objectname)')\n \n-\t\tgit fast-import --{import,export}-marks=\"$testgitmarks\" --quiet\n+\t\tgit fast-import \"${testgitmarks_args[@]}\" --quiet\n \n \t\tafter=$(git for-each-ref --format='%(refname) %(objectname)')\n \ndiff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh\nindex b6cc5c0..b2782a2 100755\n--- a/t/t5801-remote-helpers.sh\n+++ b/t/t5801-remote-helpers.sh\n@@ -112,37 +112,40 @@ test_expect_success 'pulling without refspecs' '\n '\n \n test_expect_failure 'pushing without refspecs' '\n+\ttest_when_finished \"(cd local2 && git reset --hard origin)\" &&\n \t(cd local2 &&\n \techo content >>file &&\n-\tgit commit -a -m three &&\n+\tgit commit -a -m ten &&\n \tGIT_REMOTE_TESTGIT_REFSPEC=\"\" git push) &&\n \tcompare_refs local2 HEAD server HEAD\n '\n \n-test_expect_failure 'pulling with straight refspec' '\n+test_expect_success 'pulling with straight refspec' '\n \t(cd local2 &&\n \tGIT_REMOTE_TESTGIT_REFSPEC=\"*:*\" git pull) &&\n \tcompare_refs local2 HEAD server HEAD\n '\n \n test_expect_failure 'pushing with straight refspec' '\n+\ttest_when_finished \"(cd local2 && git reset --hard origin)\" &&\n \t(cd local2 &&\n \techo content >>file &&\n-\tgit commit -a -m three &&\n+\tgit commit -a -m eleven &&\n \tGIT_REMOTE_TESTGIT_REFSPEC=\"*:*\" git push) &&\n \tcompare_refs local2 HEAD server HEAD\n '\n \n-test_expect_failure 'pulling without marks' '\n+test_expect_success 'pulling without marks' '\n \t(cd local2 &&\n \tGIT_REMOTE_TESTGIT_NO_MARKS=1 git pull) &&\n \tcompare_refs local2 HEAD server HEAD\n '\n \n test_expect_failure 'pushing without marks' '\n+\ttest_when_finished \"(cd local2 && git reset --hard origin)\" &&\n \t(cd local2 &&\n \techo content >>file &&\n-\tgit commit -a -m three &&\n+\tgit commit -a -m twelve &&\n \tGIT_REMOTE_TESTGIT_NO_MARKS=1 git push) &&\n \tcompare_refs local2 HEAD server HEAD\n '\ndiff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh\nindex 15357a1..237d2e5 100755\n--- a/t/t9350-fast-export.sh\n+++ b/t/t9350-fast-export.sh\n@@ -461,7 +461,7 @@ from :12\n EOF\n \n test_expect_success 'refs are updated even if no commits need to be exported' '\n-\techo -n > tmp-marks &&\n+\t> tmp-marks &&\n \tgit fast-export --import-marks=tmp-marks \\\n \t\t--export-marks=tmp-marks master > /dev/null &&\n \tgit fast-export --import-marks=tmp-marks \\\n@@ -469,10 +469,4 @@ test_expect_success 'refs are updated even if no commits need to be exported' '\n \ttest_cmp expected actual\n '\n \n-test_expect_success 'proper extra refs handling' '\n-\tgit fast-export master ^master master..master > actual &&\n-\techo -n > expected &&\n-\ttest_cmp expected actual\n-'\n-\n test_done\n\n .gitignore                           |   2 +-\n Documentation/git-remote-testgit.txt |   2 +-\n Makefile                             |   2 +-\n builtin/fast-export.c                |  16 ++-\n git-remote-testgit                   |  90 ++++++++++++\n git-remote-testgit.py                | 272 -----------------------------------\n git-remote-testpy.py                 | 272 +++++++++++++++++++++++++++++++++++\n git_remote_helpers/git/importer.py   |   2 +-\n t/t5800-remote-helpers.sh            | 148 -------------------\n t/t5800-remote-testpy.sh             | 148 +++++++++++++++++++\n t/t5801-remote-helpers.sh            | 161 +++++++++++++++++++++\n t/t9350-fast-export.sh               |  35 ++++-\n 12 files changed, 719 insertions(+), 431 deletions(-)\n create mode 100755 git-remote-testgit\n delete mode 100644 git-remote-testgit.py\n create mode 100644 git-remote-testpy.py\n delete mode 100755 t/t5800-remote-helpers.sh\n create mode 100755 t/t5800-remote-testpy.sh\n create mode 100755 t/t5801-remote-helpers.sh\n\n-- \n1.8.0\n"},{"id":"203730","messageId":"1353727034-24698-2-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 01/14] fast-export: avoid importing blob marks","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:01Z","receivedAt":"2012-11-24T03:17:01Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We want to be able to import, and then export, using the same marks, so\nthat we don't push things that the other side already received.\n\nUnfortunately, fast-export doesn't store blobs in the marks, but\nfast-import does. This creates a mismatch when fast export is reusing a\nmark that was previously stored by fast-import.\n\nThere is no point in one tool saving blobs, and the other not, but for\nnow let's just check in fast-export that the objects are indeed commits.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin/fast-export.c  |  4 ++++\n t/t9350-fast-export.sh | 14 ++++++++++++++\n 2 files changed, 18 insertions(+)\n\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 12220ad..9b70ec1 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -614,6 +614,10 @@ static void import_marks(char *input_file)\n \t\tif (object->flags & SHOWN)\n \t\t\terror(\"Object %s already has a mark\", sha1_to_hex(sha1));\n \n+\t\tif (object->type != OBJ_COMMIT)\n+\t\t\t/* only commits */\n+\t\t\tcontinue;\n+\n \t\tmark_object(object, mark);\n \t\tif (last_idnum < mark)\n \t\t\tlast_idnum = mark;\ndiff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh\nindex 3e821f9..5948b65 100755\n--- a/t/t9350-fast-export.sh\n+++ b/t/t9350-fast-export.sh\n@@ -440,4 +440,18 @@ test_expect_success 'fast-export quotes pathnames' '\n \t)\n '\n \n+test_expect_success 'test bidirectionality' '\n+\t>marks-cur &&\n+\t>marks-new &&\n+\tgit init marks-test &&\n+\tgit fast-export --export-marks=marks-cur --import-marks=marks-cur --branches | \\\n+\tgit --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks=marks-new &&\n+\t(cd marks-test &&\n+\tgit reset --hard &&\n+\techo Wohlauf > file &&\n+\tgit commit -a -m \"back in time\") &&\n+\tgit --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks=marks-new --branches | \\\n+\tgit fast-import --export-marks=marks-cur --import-marks=marks-cur\n+'\n+\n test_done\n-- \n1.8.0\n"},{"id":"203729","messageId":"1353727034-24698-3-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 02/14] remote-testgit: fix direction of marks","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:02Z","receivedAt":"2012-11-24T03:17:02Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Basically this is what we want:\n\n  == pull ==\n\n\ttestgit\t\t\ttransport-helper\n\n\t* export ->\t\timport\n\n\t# testgit.marks\t\tgit.marks\n\n  == push ==\n\n\ttestgit\t\t\ttransport-helper\n\n\t* import\t\t<- export\n\n\t# testgit.marks\t\tgit.marks\n\nEach side should be agnostic of the other side. Because testgit.marks\n(our helper marks) could be anything, not necessarily a format parsable\nby fast-export or fast-import. In this test they happen to be compatible,\nbecause we use those tools, but in the real world it would be something\ncompletely different. For example, they might be mapping marks to\nmercurial revisions (certainly not parsable by fast-import/export).\n\nThis is what we have:\n\n  == pull ==\n\n\ttestgit\t\t\ttransport-helper\n\n\t* export ->\t\timport\n\n\t# testgit.marks\t\tgit.marks\n\n  == push ==\n\n\ttestgit\t\t\ttransport-helper\n\n\t* import\t\t<- export\n\n\t# git.marks\t\ttestgit.marks\n\nThe only reason this is working is that git.marks and testgit.marks are\nroughly the same.\n\nThis new behavior used to not be possible before due to a bug in\nfast-export, but with the bug fixed, it works fine.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n git-remote-testgit.py              | 2 +-\n git_remote_helpers/git/importer.py | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-remote-testgit.py b/git-remote-testgit.py\nindex 5f3ebd2..ade797b 100644\n--- a/git-remote-testgit.py\n+++ b/git-remote-testgit.py\n@@ -91,7 +91,7 @@ def do_capabilities(repo, args):\n     if not os.path.exists(dirname):\n         os.makedirs(dirname)\n \n-    path = os.path.join(dirname, 'testgit.marks')\n+    path = os.path.join(dirname, 'git.marks')\n \n     print \"*export-marks %s\" % path\n     if os.path.exists(path):\ndiff --git a/git_remote_helpers/git/importer.py b/git_remote_helpers/git/importer.py\nindex 5c6b595..e28cc8f 100644\n--- a/git_remote_helpers/git/importer.py\n+++ b/git_remote_helpers/git/importer.py\n@@ -39,7 +39,7 @@ class GitImporter(object):\n             gitdir = self.repo.gitpath\n         else:\n             gitdir = os.path.abspath(os.path.join(dirname, '.git'))\n-        path = os.path.abspath(os.path.join(dirname, 'git.marks'))\n+        path = os.path.abspath(os.path.join(dirname, 'testgit.marks'))\n \n         if not os.path.exists(dirname):\n             os.makedirs(dirname)\n-- \n1.8.0\n"},{"id":"203731","messageId":"1353727034-24698-4-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 03/14] remote-helpers: fix failure message","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:03Z","receivedAt":"2012-11-24T03:17:03Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This is remote-testgit, not remote-hg.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/t5800-remote-helpers.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t5800-remote-helpers.sh b/t/t5800-remote-helpers.sh\nindex e7dc668..d46fa40 100755\n--- a/t/t5800-remote-helpers.sh\n+++ b/t/t5800-remote-helpers.sh\n@@ -8,7 +8,7 @@ test_description='Test remote-helper import and export commands'\n . ./test-lib.sh\n \n if ! test_have_prereq PYTHON ; then\n-\tskip_all='skipping git-remote-hg tests, python not available'\n+\tskip_all='skipping remote-testgit tests, python not available'\n \ttest_done\n fi\n \n@@ -17,7 +17,7 @@ import sys\n if sys.hexversion < 0x02040000:\n     sys.exit(1)\n ' || {\n-\tskip_all='skipping git-remote-hg tests, python version < 2.4'\n+\tskip_all='skipping remote-testgit tests, python version < 2.4'\n \ttest_done\n }\n \n-- \n1.8.0\n"},{"id":"203733","messageId":"1353727034-24698-5-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 04/14] Rename git-remote-testgit to git-remote-testpy","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:04Z","receivedAt":"2012-11-24T03:17:04Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This script is not really exercising the remote-helper functionality,\nbut more the python framework for remote helpers that live in\ngit_remote_helpers.\n\nIt's also not a good example of how to write remote-helpers, unless you\nare planning to use python, and even then you might not want to use this\nframework.\n\nSo let's use a more appropriate name: git-remote-testpy.\n\nA patch that replaces git-remote-testgit with a simpler version is on\nthe way.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n .gitignore                |   2 +-\n Makefile                  |   2 +-\n git-remote-testgit.py     | 272 ----------------------------------------------\n git-remote-testpy.py      | 272 ++++++++++++++++++++++++++++++++++++++++++++++\n t/t5800-remote-helpers.sh | 148 -------------------------\n t/t5800-remote-testpy.sh  | 148 +++++++++++++++++++++++++\n 6 files changed, 422 insertions(+), 422 deletions(-)\n delete mode 100644 git-remote-testgit.py\n create mode 100644 git-remote-testpy.py\n delete mode 100755 t/t5800-remote-helpers.sh\n create mode 100755 t/t5800-remote-testpy.sh\n\ndiff --git a/.gitignore b/.gitignore\nindex a188a82..48d1bbb 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -124,7 +124,7 @@\n /git-remote-ftps\n /git-remote-fd\n /git-remote-ext\n-/git-remote-testgit\n+/git-remote-testpy\n /git-repack\n /git-replace\n /git-repo-config\ndiff --git a/Makefile b/Makefile\nindex f69979e..e18ee48 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -470,7 +470,7 @@ SCRIPT_PERL += git-relink.perl\n SCRIPT_PERL += git-send-email.perl\n SCRIPT_PERL += git-svn.perl\n \n-SCRIPT_PYTHON += git-remote-testgit.py\n+SCRIPT_PYTHON += git-remote-testpy.py\n SCRIPT_PYTHON += git-p4.py\n \n SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \\\ndiff --git a/git-remote-testgit.py b/git-remote-testgit.py\ndeleted file mode 100644\nindex ade797b..0000000\n--- a/git-remote-testgit.py\n+++ /dev/null\n@@ -1,272 +0,0 @@\n-#!/usr/bin/env python\n-\n-# This command is a simple remote-helper, that is used both as a\n-# testcase for the remote-helper functionality, and as an example to\n-# show remote-helper authors one possible implementation.\n-#\n-# This is a Git <-> Git importer/exporter, that simply uses git\n-# fast-import and git fast-export to consume and produce fast-import\n-# streams.\n-#\n-# To understand better the way things work, one can activate debug\n-# traces by setting (to any value) the environment variables\n-# GIT_TRANSPORT_HELPER_DEBUG and GIT_DEBUG_TESTGIT, to see messages\n-# from the transport-helper side, or from this example remote-helper.\n-\n-# hashlib is only available in python >= 2.5\n-try:\n-    import hashlib\n-    _digest = hashlib.sha1\n-except ImportError:\n-    import sha\n-    _digest = sha.new\n-import sys\n-import os\n-import time\n-sys.path.insert(0, os.getenv(\"GITPYTHONLIB\",\".\"))\n-\n-from git_remote_helpers.util import die, debug, warn\n-from git_remote_helpers.git.repo import GitRepo\n-from git_remote_helpers.git.exporter import GitExporter\n-from git_remote_helpers.git.importer import GitImporter\n-from git_remote_helpers.git.non_local import NonLocalGit\n-\n-def get_repo(alias, url):\n-    \"\"\"Returns a git repository object initialized for usage.\n-    \"\"\"\n-\n-    repo = GitRepo(url)\n-    repo.get_revs()\n-    repo.get_head()\n-\n-    hasher = _digest()\n-    hasher.update(repo.path)\n-    repo.hash = hasher.hexdigest()\n-\n-    repo.get_base_path = lambda base: os.path.join(\n-        base, 'info', 'fast-import', repo.hash)\n-\n-    prefix = 'refs/testgit/%s/' % alias\n-    debug(\"prefix: '%s'\", prefix)\n-\n-    repo.gitdir = os.environ[\"GIT_DIR\"]\n-    repo.alias = alias\n-    repo.prefix = prefix\n-\n-    repo.exporter = GitExporter(repo)\n-    repo.importer = GitImporter(repo)\n-    repo.non_local = NonLocalGit(repo)\n-\n-    return repo\n-\n-\n-def local_repo(repo, path):\n-    \"\"\"Returns a git repository object initalized for usage.\n-    \"\"\"\n-\n-    local = GitRepo(path)\n-\n-    local.non_local = None\n-    local.gitdir = repo.gitdir\n-    local.alias = repo.alias\n-    local.prefix = repo.prefix\n-    local.hash = repo.hash\n-    local.get_base_path = repo.get_base_path\n-    local.exporter = GitExporter(local)\n-    local.importer = GitImporter(local)\n-\n-    return local\n-\n-\n-def do_capabilities(repo, args):\n-    \"\"\"Prints the supported capabilities.\n-    \"\"\"\n-\n-    print \"import\"\n-    print \"export\"\n-    print \"refspec refs/heads/*:%s*\" % repo.prefix\n-\n-    dirname = repo.get_base_path(repo.gitdir)\n-\n-    if not os.path.exists(dirname):\n-        os.makedirs(dirname)\n-\n-    path = os.path.join(dirname, 'git.marks')\n-\n-    print \"*export-marks %s\" % path\n-    if os.path.exists(path):\n-        print \"*import-marks %s\" % path\n-\n-    print # end capabilities\n-\n-\n-def do_list(repo, args):\n-    \"\"\"Lists all known references.\n-\n-    Bug: This will always set the remote head to master for non-local\n-    repositories, since we have no way of determining what the remote\n-    head is at clone time.\n-    \"\"\"\n-\n-    for ref in repo.revs:\n-        debug(\"? refs/heads/%s\", ref)\n-        print \"? refs/heads/%s\" % ref\n-\n-    if repo.head:\n-        debug(\"@refs/heads/%s HEAD\" % repo.head)\n-        print \"@refs/heads/%s HEAD\" % repo.head\n-    else:\n-        debug(\"@refs/heads/master HEAD\")\n-        print \"@refs/heads/master HEAD\"\n-\n-    print # end list\n-\n-\n-def update_local_repo(repo):\n-    \"\"\"Updates (or clones) a local repo.\n-    \"\"\"\n-\n-    if repo.local:\n-        return repo\n-\n-    path = repo.non_local.clone(repo.gitdir)\n-    repo.non_local.update(repo.gitdir)\n-    repo = local_repo(repo, path)\n-    return repo\n-\n-\n-def do_import(repo, args):\n-    \"\"\"Exports a fast-import stream from testgit for git to import.\n-    \"\"\"\n-\n-    if len(args) != 1:\n-        die(\"Import needs exactly one ref\")\n-\n-    if not repo.gitdir:\n-        die(\"Need gitdir to import\")\n-\n-    ref = args[0]\n-    refs = [ref]\n-\n-    while True:\n-        line = sys.stdin.readline()\n-        if line == '\\n':\n-            break\n-        if not line.startswith('import '):\n-            die(\"Expected import line.\")\n-\n-        # strip of leading 'import '\n-        ref = line[7:].strip()\n-        refs.append(ref)\n-\n-    repo = update_local_repo(repo)\n-    repo.exporter.export_repo(repo.gitdir, refs)\n-\n-    print \"done\"\n-\n-\n-def do_export(repo, args):\n-    \"\"\"Imports a fast-import stream from git to testgit.\n-    \"\"\"\n-\n-    if not repo.gitdir:\n-        die(\"Need gitdir to export\")\n-\n-    update_local_repo(repo)\n-    changed = repo.importer.do_import(repo.gitdir)\n-\n-    if not repo.local:\n-        repo.non_local.push(repo.gitdir)\n-\n-    for ref in changed:\n-        print \"ok %s\" % ref\n-    print\n-\n-\n-COMMANDS = {\n-    'capabilities': do_capabilities,\n-    'list': do_list,\n-    'import': do_import,\n-    'export': do_export,\n-}\n-\n-\n-def sanitize(value):\n-    \"\"\"Cleans up the url.\n-    \"\"\"\n-\n-    if value.startswith('testgit::'):\n-        value = value[9:]\n-\n-    return value\n-\n-\n-def read_one_line(repo):\n-    \"\"\"Reads and processes one command.\n-    \"\"\"\n-\n-    sleepy = os.environ.get(\"GIT_REMOTE_TESTGIT_SLEEPY\")\n-    if sleepy:\n-        debug(\"Sleeping %d sec before readline\" % int(sleepy))\n-        time.sleep(int(sleepy))\n-\n-    line = sys.stdin.readline()\n-\n-    cmdline = line\n-\n-    if not cmdline:\n-        warn(\"Unexpected EOF\")\n-        return False\n-\n-    cmdline = cmdline.strip().split()\n-    if not cmdline:\n-        # Blank line means we're about to quit\n-        return False\n-\n-    cmd = cmdline.pop(0)\n-    debug(\"Got command '%s' with args '%s'\", cmd, ' '.join(cmdline))\n-\n-    if cmd not in COMMANDS:\n-        die(\"Unknown command, %s\", cmd)\n-\n-    func = COMMANDS[cmd]\n-    func(repo, cmdline)\n-    sys.stdout.flush()\n-\n-    return True\n-\n-\n-def main(args):\n-    \"\"\"Starts a new remote helper for the specified repository.\n-    \"\"\"\n-\n-    if len(args) != 3:\n-        die(\"Expecting exactly three arguments.\")\n-        sys.exit(1)\n-\n-    if os.getenv(\"GIT_DEBUG_TESTGIT\"):\n-        import git_remote_helpers.util\n-        git_remote_helpers.util.DEBUG = True\n-\n-    alias = sanitize(args[1])\n-    url = sanitize(args[2])\n-\n-    if not alias.isalnum():\n-        warn(\"non-alnum alias '%s'\", alias)\n-        alias = \"tmp\"\n-\n-    args[1] = alias\n-    args[2] = url\n-\n-    repo = get_repo(alias, url)\n-\n-    debug(\"Got arguments %s\", args[1:])\n-\n-    more = True\n-\n-    sys.stdin = os.fdopen(sys.stdin.fileno(), 'r', 0)\n-    while (more):\n-        more = read_one_line(repo)\n-\n-if __name__ == '__main__':\n-    sys.exit(main(sys.argv))\ndiff --git a/git-remote-testpy.py b/git-remote-testpy.py\nnew file mode 100644\nindex 0000000..ade797b\n--- /dev/null\n+++ b/git-remote-testpy.py\n@@ -0,0 +1,272 @@\n+#!/usr/bin/env python\n+\n+# This command is a simple remote-helper, that is used both as a\n+# testcase for the remote-helper functionality, and as an example to\n+# show remote-helper authors one possible implementation.\n+#\n+# This is a Git <-> Git importer/exporter, that simply uses git\n+# fast-import and git fast-export to consume and produce fast-import\n+# streams.\n+#\n+# To understand better the way things work, one can activate debug\n+# traces by setting (to any value) the environment variables\n+# GIT_TRANSPORT_HELPER_DEBUG and GIT_DEBUG_TESTGIT, to see messages\n+# from the transport-helper side, or from this example remote-helper.\n+\n+# hashlib is only available in python >= 2.5\n+try:\n+    import hashlib\n+    _digest = hashlib.sha1\n+except ImportError:\n+    import sha\n+    _digest = sha.new\n+import sys\n+import os\n+import time\n+sys.path.insert(0, os.getenv(\"GITPYTHONLIB\",\".\"))\n+\n+from git_remote_helpers.util import die, debug, warn\n+from git_remote_helpers.git.repo import GitRepo\n+from git_remote_helpers.git.exporter import GitExporter\n+from git_remote_helpers.git.importer import GitImporter\n+from git_remote_helpers.git.non_local import NonLocalGit\n+\n+def get_repo(alias, url):\n+    \"\"\"Returns a git repository object initialized for usage.\n+    \"\"\"\n+\n+    repo = GitRepo(url)\n+    repo.get_revs()\n+    repo.get_head()\n+\n+    hasher = _digest()\n+    hasher.update(repo.path)\n+    repo.hash = hasher.hexdigest()\n+\n+    repo.get_base_path = lambda base: os.path.join(\n+        base, 'info', 'fast-import', repo.hash)\n+\n+    prefix = 'refs/testgit/%s/' % alias\n+    debug(\"prefix: '%s'\", prefix)\n+\n+    repo.gitdir = os.environ[\"GIT_DIR\"]\n+    repo.alias = alias\n+    repo.prefix = prefix\n+\n+    repo.exporter = GitExporter(repo)\n+    repo.importer = GitImporter(repo)\n+    repo.non_local = NonLocalGit(repo)\n+\n+    return repo\n+\n+\n+def local_repo(repo, path):\n+    \"\"\"Returns a git repository object initalized for usage.\n+    \"\"\"\n+\n+    local = GitRepo(path)\n+\n+    local.non_local = None\n+    local.gitdir = repo.gitdir\n+    local.alias = repo.alias\n+    local.prefix = repo.prefix\n+    local.hash = repo.hash\n+    local.get_base_path = repo.get_base_path\n+    local.exporter = GitExporter(local)\n+    local.importer = GitImporter(local)\n+\n+    return local\n+\n+\n+def do_capabilities(repo, args):\n+    \"\"\"Prints the supported capabilities.\n+    \"\"\"\n+\n+    print \"import\"\n+    print \"export\"\n+    print \"refspec refs/heads/*:%s*\" % repo.prefix\n+\n+    dirname = repo.get_base_path(repo.gitdir)\n+\n+    if not os.path.exists(dirname):\n+        os.makedirs(dirname)\n+\n+    path = os.path.join(dirname, 'git.marks')\n+\n+    print \"*export-marks %s\" % path\n+    if os.path.exists(path):\n+        print \"*import-marks %s\" % path\n+\n+    print # end capabilities\n+\n+\n+def do_list(repo, args):\n+    \"\"\"Lists all known references.\n+\n+    Bug: This will always set the remote head to master for non-local\n+    repositories, since we have no way of determining what the remote\n+    head is at clone time.\n+    \"\"\"\n+\n+    for ref in repo.revs:\n+        debug(\"? refs/heads/%s\", ref)\n+        print \"? refs/heads/%s\" % ref\n+\n+    if repo.head:\n+        debug(\"@refs/heads/%s HEAD\" % repo.head)\n+        print \"@refs/heads/%s HEAD\" % repo.head\n+    else:\n+        debug(\"@refs/heads/master HEAD\")\n+        print \"@refs/heads/master HEAD\"\n+\n+    print # end list\n+\n+\n+def update_local_repo(repo):\n+    \"\"\"Updates (or clones) a local repo.\n+    \"\"\"\n+\n+    if repo.local:\n+        return repo\n+\n+    path = repo.non_local.clone(repo.gitdir)\n+    repo.non_local.update(repo.gitdir)\n+    repo = local_repo(repo, path)\n+    return repo\n+\n+\n+def do_import(repo, args):\n+    \"\"\"Exports a fast-import stream from testgit for git to import.\n+    \"\"\"\n+\n+    if len(args) != 1:\n+        die(\"Import needs exactly one ref\")\n+\n+    if not repo.gitdir:\n+        die(\"Need gitdir to import\")\n+\n+    ref = args[0]\n+    refs = [ref]\n+\n+    while True:\n+        line = sys.stdin.readline()\n+        if line == '\\n':\n+            break\n+        if not line.startswith('import '):\n+            die(\"Expected import line.\")\n+\n+        # strip of leading 'import '\n+        ref = line[7:].strip()\n+        refs.append(ref)\n+\n+    repo = update_local_repo(repo)\n+    repo.exporter.export_repo(repo.gitdir, refs)\n+\n+    print \"done\"\n+\n+\n+def do_export(repo, args):\n+    \"\"\"Imports a fast-import stream from git to testgit.\n+    \"\"\"\n+\n+    if not repo.gitdir:\n+        die(\"Need gitdir to export\")\n+\n+    update_local_repo(repo)\n+    changed = repo.importer.do_import(repo.gitdir)\n+\n+    if not repo.local:\n+        repo.non_local.push(repo.gitdir)\n+\n+    for ref in changed:\n+        print \"ok %s\" % ref\n+    print\n+\n+\n+COMMANDS = {\n+    'capabilities': do_capabilities,\n+    'list': do_list,\n+    'import': do_import,\n+    'export': do_export,\n+}\n+\n+\n+def sanitize(value):\n+    \"\"\"Cleans up the url.\n+    \"\"\"\n+\n+    if value.startswith('testgit::'):\n+        value = value[9:]\n+\n+    return value\n+\n+\n+def read_one_line(repo):\n+    \"\"\"Reads and processes one command.\n+    \"\"\"\n+\n+    sleepy = os.environ.get(\"GIT_REMOTE_TESTGIT_SLEEPY\")\n+    if sleepy:\n+        debug(\"Sleeping %d sec before readline\" % int(sleepy))\n+        time.sleep(int(sleepy))\n+\n+    line = sys.stdin.readline()\n+\n+    cmdline = line\n+\n+    if not cmdline:\n+        warn(\"Unexpected EOF\")\n+        return False\n+\n+    cmdline = cmdline.strip().split()\n+    if not cmdline:\n+        # Blank line means we're about to quit\n+        return False\n+\n+    cmd = cmdline.pop(0)\n+    debug(\"Got command '%s' with args '%s'\", cmd, ' '.join(cmdline))\n+\n+    if cmd not in COMMANDS:\n+        die(\"Unknown command, %s\", cmd)\n+\n+    func = COMMANDS[cmd]\n+    func(repo, cmdline)\n+    sys.stdout.flush()\n+\n+    return True\n+\n+\n+def main(args):\n+    \"\"\"Starts a new remote helper for the specified repository.\n+    \"\"\"\n+\n+    if len(args) != 3:\n+        die(\"Expecting exactly three arguments.\")\n+        sys.exit(1)\n+\n+    if os.getenv(\"GIT_DEBUG_TESTGIT\"):\n+        import git_remote_helpers.util\n+        git_remote_helpers.util.DEBUG = True\n+\n+    alias = sanitize(args[1])\n+    url = sanitize(args[2])\n+\n+    if not alias.isalnum():\n+        warn(\"non-alnum alias '%s'\", alias)\n+        alias = \"tmp\"\n+\n+    args[1] = alias\n+    args[2] = url\n+\n+    repo = get_repo(alias, url)\n+\n+    debug(\"Got arguments %s\", args[1:])\n+\n+    more = True\n+\n+    sys.stdin = os.fdopen(sys.stdin.fileno(), 'r', 0)\n+    while (more):\n+        more = read_one_line(repo)\n+\n+if __name__ == '__main__':\n+    sys.exit(main(sys.argv))\ndiff --git a/t/t5800-remote-helpers.sh b/t/t5800-remote-helpers.sh\ndeleted file mode 100755\nindex d46fa40..0000000\n--- a/t/t5800-remote-helpers.sh\n+++ /dev/null\n@@ -1,148 +0,0 @@\n-#!/bin/sh\n-#\n-# Copyright (c) 2010 Sverre Rabbelier\n-#\n-\n-test_description='Test remote-helper import and export commands'\n-\n-. ./test-lib.sh\n-\n-if ! test_have_prereq PYTHON ; then\n-\tskip_all='skipping remote-testgit tests, python not available'\n-\ttest_done\n-fi\n-\n-\"$PYTHON_PATH\" -c '\n-import sys\n-if sys.hexversion < 0x02040000:\n-    sys.exit(1)\n-' || {\n-\tskip_all='skipping remote-testgit tests, python version < 2.4'\n-\ttest_done\n-}\n-\n-compare_refs() {\n-\tgit --git-dir=\"$1/.git\" rev-parse --verify $2 >expect &&\n-\tgit --git-dir=\"$3/.git\" rev-parse --verify $4 >actual &&\n-\ttest_cmp expect actual\n-}\n-\n-test_expect_success 'setup repository' '\n-\tgit init --bare server/.git &&\n-\tgit clone server public &&\n-\t(cd public &&\n-\t echo content >file &&\n-\t git add file &&\n-\t git commit -m one &&\n-\t git push origin master)\n-'\n-\n-test_expect_success 'cloning from local repo' '\n-\tgit clone \"testgit::${PWD}/server\" localclone &&\n-\ttest_cmp public/file localclone/file\n-'\n-\n-test_expect_success 'cloning from remote repo' '\n-\tgit clone \"testgit::file://${PWD}/server\" clone &&\n-\ttest_cmp public/file clone/file\n-'\n-\n-test_expect_success 'create new commit on remote' '\n-\t(cd public &&\n-\t echo content >>file &&\n-\t git commit -a -m two &&\n-\t git push)\n-'\n-\n-test_expect_success 'pulling from local repo' '\n-\t(cd localclone && git pull) &&\n-\ttest_cmp public/file localclone/file\n-'\n-\n-test_expect_success 'pulling from remote remote' '\n-\t(cd clone && git pull) &&\n-\ttest_cmp public/file clone/file\n-'\n-\n-test_expect_success 'pushing to local repo' '\n-\t(cd localclone &&\n-\techo content >>file &&\n-\tgit commit -a -m three &&\n-\tgit push) &&\n-\tcompare_refs localclone HEAD server HEAD\n-'\n-\n-# Generally, skip this test.  It demonstrates a now-fixed race in\n-# git-remote-testgit, but is too slow to leave in for general use.\n-: test_expect_success 'racily pushing to local repo' '\n-\ttest_when_finished \"rm -rf server2 localclone2\" &&\n-\tcp -R server server2 &&\n-\tgit clone \"testgit::${PWD}/server2\" localclone2 &&\n-\t(cd localclone2 &&\n-\techo content >>file &&\n-\tgit commit -a -m three &&\n-\tGIT_REMOTE_TESTGIT_SLEEPY=2 git push) &&\n-\tcompare_refs localclone2 HEAD server2 HEAD\n-'\n-\n-test_expect_success 'synch with changes from localclone' '\n-\t(cd clone &&\n-\t git pull)\n-'\n-\n-test_expect_success 'pushing remote local repo' '\n-\t(cd clone &&\n-\techo content >>file &&\n-\tgit commit -a -m four &&\n-\tgit push) &&\n-\tcompare_refs clone HEAD server HEAD\n-'\n-\n-test_expect_success 'fetch new branch' '\n-\t(cd public &&\n-\t git checkout -b new &&\n-\t echo content >>file &&\n-\t git commit -a -m five &&\n-\t git push origin new\n-\t) &&\n-\t(cd localclone &&\n-\t git fetch origin new\n-\t) &&\n-\tcompare_refs public HEAD localclone FETCH_HEAD\n-'\n-\n-test_expect_success 'fetch multiple branches' '\n-\t(cd localclone &&\n-\t git fetch\n-\t) &&\n-\tcompare_refs server master localclone refs/remotes/origin/master &&\n-\tcompare_refs server new localclone refs/remotes/origin/new\n-'\n-\n-test_expect_success 'push when remote has extra refs' '\n-\t(cd clone &&\n-\t echo content >>file &&\n-\t git commit -a -m six &&\n-\t git push\n-\t) &&\n-\tcompare_refs clone master server master\n-'\n-\n-test_expect_success 'push new branch by name' '\n-\t(cd clone &&\n-\t git checkout -b new-name  &&\n-\t echo content >>file &&\n-\t git commit -a -m seven &&\n-\t git push origin new-name\n-\t) &&\n-\tcompare_refs clone HEAD server refs/heads/new-name\n-'\n-\n-test_expect_failure 'push new branch with old:new refspec' '\n-\t(cd clone &&\n-\t git push origin new-name:new-refspec\n-\t) &&\n-\tcompare_refs clone HEAD server refs/heads/new-refspec\n-'\n-\n-test_done\ndiff --git a/t/t5800-remote-testpy.sh b/t/t5800-remote-testpy.sh\nnew file mode 100755\nindex 0000000..6750961\n--- /dev/null\n+++ b/t/t5800-remote-testpy.sh\n@@ -0,0 +1,148 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Sverre Rabbelier\n+#\n+\n+test_description='Test python remote-helper framework'\n+\n+. ./test-lib.sh\n+\n+if ! test_have_prereq PYTHON ; then\n+\tskip_all='skipping python remote-helper tests, python not available'\n+\ttest_done\n+fi\n+\n+\"$PYTHON_PATH\" -c '\n+import sys\n+if sys.hexversion < 0x02040000:\n+    sys.exit(1)\n+' || {\n+\tskip_all='skipping python remote-helper tests, python version < 2.4'\n+\ttest_done\n+}\n+\n+compare_refs() {\n+\tgit --git-dir=\"$1/.git\" rev-parse --verify $2 >expect &&\n+\tgit --git-dir=\"$3/.git\" rev-parse --verify $4 >actual &&\n+\ttest_cmp expect actual\n+}\n+\n+test_expect_success 'setup repository' '\n+\tgit init --bare server/.git &&\n+\tgit clone server public &&\n+\t(cd public &&\n+\t echo content >file &&\n+\t git add file &&\n+\t git commit -m one &&\n+\t git push origin master)\n+'\n+\n+test_expect_success 'cloning from local repo' '\n+\tgit clone \"testpy::${PWD}/server\" localclone &&\n+\ttest_cmp public/file localclone/file\n+'\n+\n+test_expect_success 'cloning from remote repo' '\n+\tgit clone \"testpy::file://${PWD}/server\" clone &&\n+\ttest_cmp public/file clone/file\n+'\n+\n+test_expect_success 'create new commit on remote' '\n+\t(cd public &&\n+\t echo content >>file &&\n+\t git commit -a -m two &&\n+\t git push)\n+'\n+\n+test_expect_success 'pulling from local repo' '\n+\t(cd localclone && git pull) &&\n+\ttest_cmp public/file localclone/file\n+'\n+\n+test_expect_success 'pulling from remote remote' '\n+\t(cd clone && git pull) &&\n+\ttest_cmp public/file clone/file\n+'\n+\n+test_expect_success 'pushing to local repo' '\n+\t(cd localclone &&\n+\techo content >>file &&\n+\tgit commit -a -m three &&\n+\tgit push) &&\n+\tcompare_refs localclone HEAD server HEAD\n+'\n+\n+# Generally, skip this test.  It demonstrates a now-fixed race in\n+# git-remote-testpy, but is too slow to leave in for general use.\n+: test_expect_success 'racily pushing to local repo' '\n+\ttest_when_finished \"rm -rf server2 localclone2\" &&\n+\tcp -R server server2 &&\n+\tgit clone \"testpy::${PWD}/server2\" localclone2 &&\n+\t(cd localclone2 &&\n+\techo content >>file &&\n+\tgit commit -a -m three &&\n+\tGIT_REMOTE_TESTGIT_SLEEPY=2 git push) &&\n+\tcompare_refs localclone2 HEAD server2 HEAD\n+'\n+\n+test_expect_success 'synch with changes from localclone' '\n+\t(cd clone &&\n+\t git pull)\n+'\n+\n+test_expect_success 'pushing remote local repo' '\n+\t(cd clone &&\n+\techo content >>file &&\n+\tgit commit -a -m four &&\n+\tgit push) &&\n+\tcompare_refs clone HEAD server HEAD\n+'\n+\n+test_expect_success 'fetch new branch' '\n+\t(cd public &&\n+\t git checkout -b new &&\n+\t echo content >>file &&\n+\t git commit -a -m five &&\n+\t git push origin new\n+\t) &&\n+\t(cd localclone &&\n+\t git fetch origin new\n+\t) &&\n+\tcompare_refs public HEAD localclone FETCH_HEAD\n+'\n+\n+test_expect_success 'fetch multiple branches' '\n+\t(cd localclone &&\n+\t git fetch\n+\t) &&\n+\tcompare_refs server master localclone refs/remotes/origin/master &&\n+\tcompare_refs server new localclone refs/remotes/origin/new\n+'\n+\n+test_expect_success 'push when remote has extra refs' '\n+\t(cd clone &&\n+\t echo content >>file &&\n+\t git commit -a -m six &&\n+\t git push\n+\t) &&\n+\tcompare_refs clone master server master\n+'\n+\n+test_expect_success 'push new branch by name' '\n+\t(cd clone &&\n+\t git checkout -b new-name  &&\n+\t echo content >>file &&\n+\t git commit -a -m seven &&\n+\t git push origin new-name\n+\t) &&\n+\tcompare_refs clone HEAD server refs/heads/new-name\n+'\n+\n+test_expect_failure 'push new branch with old:new refspec' '\n+\t(cd clone &&\n+\t git push origin new-name:new-refspec\n+\t) &&\n+\tcompare_refs clone HEAD server refs/heads/new-refspec\n+'\n+\n+test_done\n-- \n1.8.0\n"},{"id":"203735","messageId":"1353727034-24698-6-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 05/14] Add new simplified git-remote-testgit","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:05Z","receivedAt":"2012-11-24T03:17:05Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Exercising the python remote helper framework is for another tool and\nanother test. This is about testing the remote-helper interface.\n\nIt's way simpler, it exercises the same features of remote helpers, it's\neasy to read and understand, and it doesn't depend on python.\n\nFor now let's just copy the old remote-helpers test script, although\nsome of those tests don't make sense. In addition, this script would be\nable to test other features not currently being tested.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/git-remote-testgit.txt |   2 +-\n git-remote-testgit                   |  64 ++++++++++++++++\n t/t5801-remote-helpers.sh            | 139 +++++++++++++++++++++++++++++++++++\n 3 files changed, 204 insertions(+), 1 deletion(-)\n create mode 100755 git-remote-testgit\n create mode 100755 t/t5801-remote-helpers.sh\n\ndiff --git a/Documentation/git-remote-testgit.txt b/Documentation/git-remote-testgit.txt\nindex 2a67d45..612a625 100644\n--- a/Documentation/git-remote-testgit.txt\n+++ b/Documentation/git-remote-testgit.txt\n@@ -19,7 +19,7 @@ testcase for the remote-helper functionality, and as an example to\n show remote-helper authors one possible implementation.\n \n The best way to learn more is to read the comments and source code in\n-'git-remote-testgit.py'.\n+'git-remote-testgit'.\n \n SEE ALSO\n --------\ndiff --git a/git-remote-testgit b/git-remote-testgit\nnew file mode 100755\nindex 0000000..a50d6f1\n--- /dev/null\n+++ b/git-remote-testgit\n@@ -0,0 +1,64 @@\n+#!/bin/bash\n+# Copyright (c) 2012 Felipe Contreras\n+\n+alias=$1\n+url=$2\n+\n+# huh?\n+url=\"${url#file://}\"\n+\n+dir=\"$GIT_DIR/testgit/$alias\"\n+prefix=\"refs/testgit/$alias\"\n+refspec=\"refs/heads/*:${prefix}/heads/*\"\n+\n+gitmarks=\"$dir/git.marks\"\n+testgitmarks=\"$dir/testgit.marks\"\n+\n+export GIT_DIR=\"$url/.git\"\n+\n+mkdir -p \"$dir\"\n+\n+test -e \"$gitmarks\" || > \"$gitmarks\"\n+test -e \"$testgitmarks\" || > \"$testgitmarks\"\n+\n+while read line\n+do\n+\tcase $line in\n+\tcapabilities)\n+\t\techo 'import'\n+\t\techo 'export'\n+\t\techo \"refspec $refspec\"\n+\t\techo \"*import-marks $gitmarks\"\n+\t\techo \"*export-marks $gitmarks\"\n+\t\techo\n+\t\t;;\n+\tlist)\n+\t\tgit for-each-ref --format='? %(refname)' 'refs/heads/'\n+\t\thead=$(git symbolic-ref HEAD)\n+\t\techo \"@$head HEAD\"\n+\t\techo\n+\t\t;;\n+\timport*)\n+\t\t# read all import lines\n+\t\twhile true\n+\t\tdo\n+\t\t\tref=\"${line#* }\"\n+\t\t\trefs=\"$refs $ref\"\n+\t\t\tread line\n+\t\t\ttest \"${line%% *}\" != \"import\" && break\n+\t\tdone\n+\n+\t\techo \"feature import-marks=$gitmarks\"\n+\t\techo \"feature export-marks=$gitmarks\"\n+\t\tgit fast-export --use-done-feature --{import,export}-marks=\"$testgitmarks\" $refs |\n+\t\tsed -e \"s#refs/heads/#${prefix}/heads/#g\"\n+\t\t;;\n+\texport)\n+\t\tgit fast-import --{import,export}-marks=\"$testgitmarks\" --quiet\n+\t\techo\n+\t\t;;\n+\t'')\n+\t\texit\n+\t\t;;\n+\tesac\n+done\ndiff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh\nnew file mode 100755\nindex 0000000..f52ab14\n--- /dev/null\n+++ b/t/t5801-remote-helpers.sh\n@@ -0,0 +1,139 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Sverre Rabbelier\n+#\n+\n+test_description='Test remote-helper import and export commands'\n+\n+. ./test-lib.sh\n+\n+if ! type \"${BASH-bash}\" >/dev/null 2>&1; then\n+\tskip_all='skipping remote-testgit tests, bash not available'\n+\ttest_done\n+fi\n+\n+compare_refs() {\n+\tgit --git-dir=\"$1/.git\" rev-parse --verify $2 >expect &&\n+\tgit --git-dir=\"$3/.git\" rev-parse --verify $4 >actual &&\n+\ttest_cmp expect actual\n+}\n+\n+test_expect_success 'setup repository' '\n+\tgit init --bare server/.git &&\n+\tgit clone server public &&\n+\t(cd public &&\n+\t echo content >file &&\n+\t git add file &&\n+\t git commit -m one &&\n+\t git push origin master)\n+'\n+\n+test_expect_success 'cloning from local repo' '\n+\tgit clone \"testgit::${PWD}/server\" localclone &&\n+\ttest_cmp public/file localclone/file\n+'\n+\n+test_expect_success 'cloning from remote repo' '\n+\tgit clone \"testgit::file://${PWD}/server\" clone &&\n+\ttest_cmp public/file clone/file\n+'\n+\n+test_expect_success 'create new commit on remote' '\n+\t(cd public &&\n+\t echo content >>file &&\n+\t git commit -a -m two &&\n+\t git push)\n+'\n+\n+test_expect_success 'pulling from local repo' '\n+\t(cd localclone && git pull) &&\n+\ttest_cmp public/file localclone/file\n+'\n+\n+test_expect_success 'pulling from remote remote' '\n+\t(cd clone && git pull) &&\n+\ttest_cmp public/file clone/file\n+'\n+\n+test_expect_success 'pushing to local repo' '\n+\t(cd localclone &&\n+\techo content >>file &&\n+\tgit commit -a -m three &&\n+\tgit push) &&\n+\tcompare_refs localclone HEAD server HEAD\n+'\n+\n+# Generally, skip this test.  It demonstrates a now-fixed race in\n+# git-remote-testgit, but is too slow to leave in for general use.\n+: test_expect_success 'racily pushing to local repo' '\n+\ttest_when_finished \"rm -rf server2 localclone2\" &&\n+\tcp -R server server2 &&\n+\tgit clone \"testgit::${PWD}/server2\" localclone2 &&\n+\t(cd localclone2 &&\n+\techo content >>file &&\n+\tgit commit -a -m three &&\n+\tGIT_REMOTE_TESTGIT_SLEEPY=2 git push) &&\n+\tcompare_refs localclone2 HEAD server2 HEAD\n+'\n+\n+test_expect_success 'synch with changes from localclone' '\n+\t(cd clone &&\n+\t git pull)\n+'\n+\n+test_expect_success 'pushing remote local repo' '\n+\t(cd clone &&\n+\techo content >>file &&\n+\tgit commit -a -m four &&\n+\tgit push) &&\n+\tcompare_refs clone HEAD server HEAD\n+'\n+\n+test_expect_success 'fetch new branch' '\n+\t(cd public &&\n+\t git checkout -b new &&\n+\t echo content >>file &&\n+\t git commit -a -m five &&\n+\t git push origin new\n+\t) &&\n+\t(cd localclone &&\n+\t git fetch origin new\n+\t) &&\n+\tcompare_refs public HEAD localclone FETCH_HEAD\n+'\n+\n+test_expect_success 'fetch multiple branches' '\n+\t(cd localclone &&\n+\t git fetch\n+\t) &&\n+\tcompare_refs server master localclone refs/remotes/origin/master &&\n+\tcompare_refs server new localclone refs/remotes/origin/new\n+'\n+\n+test_expect_success 'push when remote has extra refs' '\n+\t(cd clone &&\n+\t echo content >>file &&\n+\t git commit -a -m six &&\n+\t git push\n+\t) &&\n+\tcompare_refs clone master server master\n+'\n+\n+test_expect_success 'push new branch by name' '\n+\t(cd clone &&\n+\t git checkout -b new-name  &&\n+\t echo content >>file &&\n+\t git commit -a -m seven &&\n+\t git push origin new-name\n+\t) &&\n+\tcompare_refs clone HEAD server refs/heads/new-name\n+'\n+\n+test_expect_failure 'push new branch with old:new refspec' '\n+\t(cd clone &&\n+\t git push origin new-name:new-refspec\n+\t) &&\n+\tcompare_refs clone HEAD server refs/heads/new-refspec\n+'\n+\n+test_done\n-- \n1.8.0\n"},{"id":"203734","messageId":"1353727034-24698-7-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 06/14] remote-testgit: remove non-local functionality","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:06Z","receivedAt":"2012-11-24T03:17:06Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This only makes sense for the python remote helpers framework. The tests\ndon't exercise any feature of transport helper. Remove them.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n git-remote-testgit        |  3 ---\n t/t5801-remote-helpers.sh | 50 ++++++++++++++++++++---------------------------\n 2 files changed, 21 insertions(+), 32 deletions(-)\n\ndiff --git a/git-remote-testgit b/git-remote-testgit\nindex a50d6f1..bf4d22c 100755\n--- a/git-remote-testgit\n+++ b/git-remote-testgit\n@@ -4,9 +4,6 @@\n alias=$1\n url=$2\n \n-# huh?\n-url=\"${url#file://}\"\n-\n dir=\"$GIT_DIR/testgit/$alias\"\n prefix=\"refs/testgit/$alias\"\n refspec=\"refs/heads/*:${prefix}/heads/*\"\ndiff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh\nindex f52ab14..2f7fc10 100755\n--- a/t/t5801-remote-helpers.sh\n+++ b/t/t5801-remote-helpers.sh\n@@ -33,11 +33,6 @@ test_expect_success 'cloning from local repo' '\n \ttest_cmp public/file localclone/file\n '\n \n-test_expect_success 'cloning from remote repo' '\n-\tgit clone \"testgit::file://${PWD}/server\" clone &&\n-\ttest_cmp public/file clone/file\n-'\n-\n test_expect_success 'create new commit on remote' '\n \t(cd public &&\n \t echo content >>file &&\n@@ -50,11 +45,6 @@ test_expect_success 'pulling from local repo' '\n \ttest_cmp public/file localclone/file\n '\n \n-test_expect_success 'pulling from remote remote' '\n-\t(cd clone && git pull) &&\n-\ttest_cmp public/file clone/file\n-'\n-\n test_expect_success 'pushing to local repo' '\n \t(cd localclone &&\n \techo content >>file &&\n@@ -76,19 +66,6 @@ test_expect_success 'pushing to local repo' '\n \tcompare_refs localclone2 HEAD server2 HEAD\n '\n \n-test_expect_success 'synch with changes from localclone' '\n-\t(cd clone &&\n-\t git pull)\n-'\n-\n-test_expect_success 'pushing remote local repo' '\n-\t(cd clone &&\n-\techo content >>file &&\n-\tgit commit -a -m four &&\n-\tgit push) &&\n-\tcompare_refs clone HEAD server HEAD\n-'\n-\n test_expect_success 'fetch new branch' '\n \t(cd public &&\n \t git checkout -b new &&\n@@ -102,6 +79,20 @@ test_expect_success 'fetch new branch' '\n \tcompare_refs public HEAD localclone FETCH_HEAD\n '\n \n+#\n+# This is only needed because of a bug not detected by this script. It will be\n+# fixed shortly, but for now lets not cause regressions.\n+#\n+test_expect_success 'bump commit in public' '\n+\t(cd public &&\n+\tgit checkout master &&\n+\tgit pull &&\n+\techo content >>file &&\n+\tgit commit -a -m four &&\n+\tgit push) &&\n+\tcompare_refs public HEAD server HEAD\n+'\n+\n test_expect_success 'fetch multiple branches' '\n \t(cd localclone &&\n \t git fetch\n@@ -111,29 +102,30 @@ test_expect_success 'fetch multiple branches' '\n '\n \n test_expect_success 'push when remote has extra refs' '\n-\t(cd clone &&\n+\t(cd localclone &&\n+\t git reset --hard origin/master &&\n \t echo content >>file &&\n \t git commit -a -m six &&\n \t git push\n \t) &&\n-\tcompare_refs clone master server master\n+\tcompare_refs localclone master server master\n '\n \n test_expect_success 'push new branch by name' '\n-\t(cd clone &&\n+\t(cd localclone &&\n \t git checkout -b new-name  &&\n \t echo content >>file &&\n \t git commit -a -m seven &&\n \t git push origin new-name\n \t) &&\n-\tcompare_refs clone HEAD server refs/heads/new-name\n+\tcompare_refs localclone HEAD server refs/heads/new-name\n '\n \n test_expect_failure 'push new branch with old:new refspec' '\n-\t(cd clone &&\n+\t(cd localclone &&\n \t git push origin new-name:new-refspec\n \t) &&\n-\tcompare_refs clone HEAD server refs/heads/new-refspec\n+\tcompare_refs localclone HEAD server refs/heads/new-refspec\n '\n \n test_done\n-- \n1.8.0\n"},{"id":"203732","messageId":"1353727034-24698-8-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 07/14] remote-testgit: remove irrelevant test","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:07Z","receivedAt":"2012-11-24T03:17:07Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This was only to cover a bug that was fixed in remote-testpy not to\nresurface.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/t5801-remote-helpers.sh | 13 -------------\n 1 file changed, 13 deletions(-)\n\ndiff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh\nindex 2f7fc10..6801529 100755\n--- a/t/t5801-remote-helpers.sh\n+++ b/t/t5801-remote-helpers.sh\n@@ -53,19 +53,6 @@ test_expect_success 'pushing to local repo' '\n \tcompare_refs localclone HEAD server HEAD\n '\n \n-# Generally, skip this test.  It demonstrates a now-fixed race in\n-# git-remote-testgit, but is too slow to leave in for general use.\n-: test_expect_success 'racily pushing to local repo' '\n-\ttest_when_finished \"rm -rf server2 localclone2\" &&\n-\tcp -R server server2 &&\n-\tgit clone \"testgit::${PWD}/server2\" localclone2 &&\n-\t(cd localclone2 &&\n-\techo content >>file &&\n-\tgit commit -a -m three &&\n-\tGIT_REMOTE_TESTGIT_SLEEPY=2 git push) &&\n-\tcompare_refs localclone2 HEAD server2 HEAD\n-'\n-\n test_expect_success 'fetch new branch' '\n \t(cd public &&\n \t git checkout -b new &&\n-- \n1.8.0\n"},{"id":"203736","messageId":"1353727034-24698-9-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 08/14] remote-testgit: cleanup tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:08Z","receivedAt":"2012-11-24T03:17:08Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We don't need a bare 'server' and an intermediary 'public'. The repos\ncan talk to each other directly; that's what we want to exercise.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/t5801-remote-helpers.sh | 63 ++++++++++++++++++++++-------------------------\n 1 file changed, 29 insertions(+), 34 deletions(-)\n\ndiff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh\nindex 6801529..bc0b5f7 100755\n--- a/t/t5801-remote-helpers.sh\n+++ b/t/t5801-remote-helpers.sh\n@@ -19,100 +19,95 @@ compare_refs() {\n }\n \n test_expect_success 'setup repository' '\n-\tgit init --bare server/.git &&\n-\tgit clone server public &&\n-\t(cd public &&\n+\tgit init server &&\n+\t(cd server &&\n \t echo content >file &&\n \t git add file &&\n-\t git commit -m one &&\n-\t git push origin master)\n+\t git commit -m one)\n '\n \n test_expect_success 'cloning from local repo' '\n-\tgit clone \"testgit::${PWD}/server\" localclone &&\n-\ttest_cmp public/file localclone/file\n+\tgit clone \"testgit::${PWD}/server\" local &&\n+\ttest_cmp server/file local/file\n '\n \n test_expect_success 'create new commit on remote' '\n-\t(cd public &&\n+\t(cd server &&\n \t echo content >>file &&\n-\t git commit -a -m two &&\n-\t git push)\n+\t git commit -a -m two)\n '\n \n test_expect_success 'pulling from local repo' '\n-\t(cd localclone && git pull) &&\n-\ttest_cmp public/file localclone/file\n+\t(cd local && git pull) &&\n+\ttest_cmp server/file local/file\n '\n \n test_expect_success 'pushing to local repo' '\n-\t(cd localclone &&\n+\t(cd local &&\n \techo content >>file &&\n \tgit commit -a -m three &&\n \tgit push) &&\n-\tcompare_refs localclone HEAD server HEAD\n+\tcompare_refs local HEAD server HEAD\n '\n \n test_expect_success 'fetch new branch' '\n-\t(cd public &&\n+\t(cd server &&\n+\t git reset --hard &&\n \t git checkout -b new &&\n \t echo content >>file &&\n-\t git commit -a -m five &&\n-\t git push origin new\n+\t git commit -a -m five\n \t) &&\n-\t(cd localclone &&\n+\t(cd local &&\n \t git fetch origin new\n \t) &&\n-\tcompare_refs public HEAD localclone FETCH_HEAD\n+\tcompare_refs server HEAD local FETCH_HEAD\n '\n \n #\n # This is only needed because of a bug not detected by this script. It will be\n # fixed shortly, but for now lets not cause regressions.\n #\n-test_expect_success 'bump commit in public' '\n-\t(cd public &&\n+test_expect_success 'bump commit in server' '\n+\t(cd server &&\n \tgit checkout master &&\n-\tgit pull &&\n \techo content >>file &&\n-\tgit commit -a -m four &&\n-\tgit push) &&\n-\tcompare_refs public HEAD server HEAD\n+\tgit commit -a -m four) &&\n+\tcompare_refs server HEAD server HEAD\n '\n \n test_expect_success 'fetch multiple branches' '\n-\t(cd localclone &&\n+\t(cd local &&\n \t git fetch\n \t) &&\n-\tcompare_refs server master localclone refs/remotes/origin/master &&\n-\tcompare_refs server new localclone refs/remotes/origin/new\n+\tcompare_refs server master local refs/remotes/origin/master &&\n+\tcompare_refs server new local refs/remotes/origin/new\n '\n \n test_expect_success 'push when remote has extra refs' '\n-\t(cd localclone &&\n+\t(cd local &&\n \t git reset --hard origin/master &&\n \t echo content >>file &&\n \t git commit -a -m six &&\n \t git push\n \t) &&\n-\tcompare_refs localclone master server master\n+\tcompare_refs local master server master\n '\n \n test_expect_success 'push new branch by name' '\n-\t(cd localclone &&\n+\t(cd local &&\n \t git checkout -b new-name  &&\n \t echo content >>file &&\n \t git commit -a -m seven &&\n \t git push origin new-name\n \t) &&\n-\tcompare_refs localclone HEAD server refs/heads/new-name\n+\tcompare_refs local HEAD server refs/heads/new-name\n '\n \n test_expect_failure 'push new branch with old:new refspec' '\n-\t(cd localclone &&\n+\t(cd local &&\n \t git push origin new-name:new-refspec\n \t) &&\n-\tcompare_refs localclone HEAD server refs/heads/new-refspec\n+\tcompare_refs local HEAD server refs/heads/new-refspec\n '\n \n test_done\n-- \n1.8.0\n"},{"id":"203737","messageId":"1353727034-24698-10-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 09/14] remote-testgit: exercise more features","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:09Z","receivedAt":"2012-11-24T03:17:09Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Unfortunately a lot of these tests fail.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n git-remote-testgit        | 38 +++++++++++++++++++++++-----------\n t/t5801-remote-helpers.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 78 insertions(+), 12 deletions(-)\n\ndiff --git a/git-remote-testgit b/git-remote-testgit\nindex bf4d22c..e140282 100755\n--- a/git-remote-testgit\n+++ b/git-remote-testgit\n@@ -6,17 +6,25 @@ url=$2\n \n dir=\"$GIT_DIR/testgit/$alias\"\n prefix=\"refs/testgit/$alias\"\n-refspec=\"refs/heads/*:${prefix}/heads/*\"\n \n-gitmarks=\"$dir/git.marks\"\n-testgitmarks=\"$dir/testgit.marks\"\n+default_refspec=\"refs/heads/*:${prefix}/heads/*\"\n+\n+refspec=\"${GIT_REMOTE_TESTGIT_REFSPEC-$default_refspec}\"\n+\n+test -z \"$refspec\" && prefix=\"refs\"\n \n export GIT_DIR=\"$url/.git\"\n \n mkdir -p \"$dir\"\n \n-test -e \"$gitmarks\" || > \"$gitmarks\"\n-test -e \"$testgitmarks\" || > \"$testgitmarks\"\n+if test -z \"$GIT_REMOTE_TESTGIT_NO_MARKS\"\n+then\n+\tgitmarks=\"$dir/git.marks\"\n+\ttestgitmarks=\"$dir/testgit.marks\"\n+\ttest -e \"$gitmarks\" || >\"$gitmarks\"\n+\ttest -e \"$testgitmarks\" || >\"$testgitmarks\"\n+\ttestgitmarks_args=( \"--\"{import,export}\"-marks=$testgitmarks\" )\n+fi\n \n while read line\n do\n@@ -24,9 +32,12 @@ do\n \tcapabilities)\n \t\techo 'import'\n \t\techo 'export'\n-\t\techo \"refspec $refspec\"\n-\t\techo \"*import-marks $gitmarks\"\n-\t\techo \"*export-marks $gitmarks\"\n+\t\ttest -n \"$refspec\" && echo \"refspec $refspec\"\n+\t\tif test -n \"$gitmarks\"\n+\t\tthen\n+\t\t\techo \"*import-marks $gitmarks\"\n+\t\t\techo \"*export-marks $gitmarks\"\n+\t\tfi\n \t\techo\n \t\t;;\n \tlist)\n@@ -45,13 +56,16 @@ do\n \t\t\ttest \"${line%% *}\" != \"import\" && break\n \t\tdone\n \n-\t\techo \"feature import-marks=$gitmarks\"\n-\t\techo \"feature export-marks=$gitmarks\"\n-\t\tgit fast-export --use-done-feature --{import,export}-marks=\"$testgitmarks\" $refs |\n+\t\tif test -n \"$gitmarks\"\n+\t\tthen\n+\t\t\techo \"feature import-marks=$gitmarks\"\n+\t\t\techo \"feature export-marks=$gitmarks\"\n+\t\tfi\n+\t\tgit fast-export --use-done-feature \"${testgitmarks_args[@]}\" $refs |\n \t\tsed -e \"s#refs/heads/#${prefix}/heads/#g\"\n \t\t;;\n \texport)\n-\t\tgit fast-import --{import,export}-marks=\"$testgitmarks\" --quiet\n+\t\tgit fast-import \"${testgitmarks_args[@]}\" --quiet\n \t\techo\n \t\t;;\n \t'')\ndiff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh\nindex bc0b5f7..12ae256 100755\n--- a/t/t5801-remote-helpers.sh\n+++ b/t/t5801-remote-helpers.sh\n@@ -110,4 +110,56 @@ test_expect_failure 'push new branch with old:new refspec' '\n \tcompare_refs local HEAD server refs/heads/new-refspec\n '\n \n+test_expect_success 'cloning without refspec' '\n+\tGIT_REMOTE_TESTGIT_REFSPEC=\"\" \\\n+\tgit clone \"testgit::${PWD}/server\" local2 &&\n+\tcompare_refs local2 HEAD server HEAD\n+'\n+\n+test_expect_success 'pulling without refspecs' '\n+\t(cd local2 &&\n+\tgit reset --hard &&\n+\tGIT_REMOTE_TESTGIT_REFSPEC=\"\" git pull) &&\n+\tcompare_refs local2 HEAD server HEAD\n+'\n+\n+test_expect_failure 'pushing without refspecs' '\n+\ttest_when_finished \"(cd local2 && git reset --hard origin)\" &&\n+\t(cd local2 &&\n+\techo content >>file &&\n+\tgit commit -a -m ten &&\n+\tGIT_REMOTE_TESTGIT_REFSPEC=\"\" git push) &&\n+\tcompare_refs local2 HEAD server HEAD\n+'\n+\n+test_expect_success 'pulling with straight refspec' '\n+\t(cd local2 &&\n+\tGIT_REMOTE_TESTGIT_REFSPEC=\"*:*\" git pull) &&\n+\tcompare_refs local2 HEAD server HEAD\n+'\n+\n+test_expect_failure 'pushing with straight refspec' '\n+\ttest_when_finished \"(cd local2 && git reset --hard origin)\" &&\n+\t(cd local2 &&\n+\techo content >>file &&\n+\tgit commit -a -m eleven &&\n+\tGIT_REMOTE_TESTGIT_REFSPEC=\"*:*\" git push) &&\n+\tcompare_refs local2 HEAD server HEAD\n+'\n+\n+test_expect_success 'pulling without marks' '\n+\t(cd local2 &&\n+\tGIT_REMOTE_TESTGIT_NO_MARKS=1 git pull) &&\n+\tcompare_refs local2 HEAD server HEAD\n+'\n+\n+test_expect_failure 'pushing without marks' '\n+\ttest_when_finished \"(cd local2 && git reset --hard origin)\" &&\n+\t(cd local2 &&\n+\techo content >>file &&\n+\tgit commit -a -m twelve &&\n+\tGIT_REMOTE_TESTGIT_NO_MARKS=1 git push) &&\n+\tcompare_refs local2 HEAD server HEAD\n+'\n+\n test_done\n-- \n1.8.0\n"},{"id":"203738","messageId":"1353727034-24698-11-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 10/14] remote-testgit: report success after an import","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:10Z","receivedAt":"2012-11-24T03:17:10Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Doesn't make a difference for the tests, but it does for the ones\nseeking reference.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n git-remote-testgit | 13 +++++++++++++\n 1 file changed, 13 insertions(+)\n\ndiff --git a/git-remote-testgit b/git-remote-testgit\nindex e140282..aba3502 100755\n--- a/git-remote-testgit\n+++ b/git-remote-testgit\n@@ -65,7 +65,20 @@ do\n \t\tsed -e \"s#refs/heads/#${prefix}/heads/#g\"\n \t\t;;\n \texport)\n+\t\tbefore=$(git for-each-ref --format='%(refname) %(objectname)')\n+\n \t\tgit fast-import \"${testgitmarks_args[@]}\" --quiet\n+\n+\t\tafter=$(git for-each-ref --format='%(refname) %(objectname)')\n+\n+\t\t# figure out which refs were updated\n+\t\tjoin -e 0 -o '0 1.2 2.2' -a 2 <(echo \"$before\") <(echo \"$after\") |\n+\t\twhile read ref a b\n+\t\tdo\n+\t\t\ttest $a == $b && continue\n+\t\t\techo \"ok $ref\"\n+\t\tdone\n+\n \t\techo\n \t\t;;\n \t'')\n-- \n1.8.0\n"},{"id":"203739","messageId":"1353727034-24698-12-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 11/14] remote-testgit: implement the \"done\" feature manually","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:11Z","receivedAt":"2012-11-24T03:17:11Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"People who want to write their own remote-helper will find it more\nuseful to see clearly how they are supposed to advertise and implement\nthe \"done\" feature themselves.\n\nRight now we are relying on fast-export to do that by using the\n--use-done-feature argument. However, people writing their own\nremote-helper would probably not have such an option, as they would\nprobably be writing the fast-export functionality themselves.\n\nIt should now be clearer to them.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n git-remote-testgit | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/git-remote-testgit b/git-remote-testgit\nindex aba3502..0389545 100755\n--- a/git-remote-testgit\n+++ b/git-remote-testgit\n@@ -61,8 +61,10 @@ do\n \t\t\techo \"feature import-marks=$gitmarks\"\n \t\t\techo \"feature export-marks=$gitmarks\"\n \t\tfi\n-\t\tgit fast-export --use-done-feature \"${testgitmarks_args[@]}\" $refs |\n+\t\techo \"feature done\"\n+\t\tgit fast-export \"${testgitmarks_args[@]}\" $refs |\n \t\tsed -e \"s#refs/heads/#${prefix}/heads/#g\"\n+\t\techo \"done\"\n \t\t;;\n \texport)\n \t\tbefore=$(git for-each-ref --format='%(refname) %(objectname)')\n-- \n1.8.0\n"},{"id":"203742","messageId":"1353727034-24698-13-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 12/14] fast-export: trivial cleanup","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:12Z","receivedAt":"2012-11-24T03:17:12Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Setting 'commit' to 'commit' is a no-op. It might have been there to\navoid a compiler warning, but if so, it was the compiler to blame, and\nit's certainly not there any more.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin/fast-export.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 9b70ec1..191936c 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -483,7 +483,7 @@ static void get_tags_and_duplicates(struct object_array *pending,\n \tfor (i = 0; i < pending->nr; i++) {\n \t\tstruct object_array_entry *e = pending->objects + i;\n \t\tunsigned char sha1[20];\n-\t\tstruct commit *commit = commit;\n+\t\tstruct commit *commit;\n \t\tchar *full_name;\n \n \t\tif (dwim_ref(e->name, strlen(e->name), sha1, &full_name) != 1)\n-- \n1.8.0\n"},{"id":"203740","messageId":"1353727034-24698-14-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 13/14] fast-export: fix comparison in tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:13Z","receivedAt":"2012-11-24T03:17:13Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"First the expected, then the actual, otherwise the diff would be the\nopposite of what we want.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/t9350-fast-export.sh | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh\nindex 5948b65..1f59862 100755\n--- a/t/t9350-fast-export.sh\n+++ b/t/t9350-fast-export.sh\n@@ -303,7 +303,7 @@ test_expect_success 'dropping tag of filtered out object' '\n (\n \tcd limit-by-paths &&\n \tgit fast-export --tag-of-filtered-object=drop mytag -- there > output &&\n-\ttest_cmp output expected\n+\ttest_cmp expected output\n )\n '\n \n@@ -320,7 +320,7 @@ test_expect_success 'rewriting tag of filtered out object' '\n (\n \tcd limit-by-paths &&\n \tgit fast-export --tag-of-filtered-object=rewrite mytag -- there > output &&\n-\ttest_cmp output expected\n+\ttest_cmp expected output\n )\n '\n \n@@ -351,7 +351,7 @@ test_expect_failure 'no exact-ref revisions included' '\n \t(\n \t\tcd limit-by-paths &&\n \t\tgit fast-export master~2..master~1 > output &&\n-\t\ttest_cmp output expected\n+\t\ttest_cmp expected output\n \t)\n '\n \n-- \n1.8.0\n"},{"id":"203741","messageId":"1353727034-24698-15-git-send-email-felipe.contreras@gmail.com","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 p1.1 14/14] fast-export: make sure updated refs get updated","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T03:17:14Z","receivedAt":"2012-11-24T03:17:14Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"When an object has already been exported (and thus is in the marks) it's\nflagged as SHOWN, so it will not be exported again, even if in a later\ntime it's exported through a different ref.\n\nWe don't need the object to be exported again, but we want the ref\nupdated, which doesn't happen.\n\nSince we can't know if a ref was exported or not, let's just assume that\nif the commit was marked (flags & SHOWN), the user still wants the ref\nupdated.\n\nIOW: If it's specified in the command line, it will get updated,\nregardless of whether or not the object was marked.\n\nSo:\n\n % git branch test master\n % git fast-export $mark_flags master\n % git fast-export $mark_flags test\n\nWould export 'test' properly.\n\nAdditionally, this fixes issues with remote helpers; now they can push\nrefs whose objects have already been exported, and a few other issues as\nwell. Update the tests accordingly.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin/fast-export.c     | 10 +++++++---\n t/t5801-remote-helpers.sh | 20 ++++++++------------\n t/t9350-fast-export.sh    | 15 +++++++++++++++\n 3 files changed, 30 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 191936c..31bfbee 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -523,10 +523,14 @@ static void get_tags_and_duplicates(struct object_array *pending,\n \t\t\t\ttypename(e->item->type));\n \t\t\tcontinue;\n \t\t}\n-\t\tif (commit->util)\n-\t\t\t/* more than one name for the same object */\n+\n+\t\t/*\n+\t\t * This ref will not be updated through a commit, lets make\n+\t\t * sure it gets properly updated eventually.\n+\t\t */\n+\t\tif (commit->util || commit->object.flags & SHOWN)\n \t\t\tstring_list_append(extra_refs, full_name)->util = commit;\n-\t\telse\n+\t\tif (!commit->util)\n \t\t\tcommit->util = full_name;\n \t}\n }\ndiff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh\nindex 12ae256..b2782a2 100755\n--- a/t/t5801-remote-helpers.sh\n+++ b/t/t5801-remote-helpers.sh\n@@ -63,18 +63,6 @@ test_expect_success 'fetch new branch' '\n \tcompare_refs server HEAD local FETCH_HEAD\n '\n \n-#\n-# This is only needed because of a bug not detected by this script. It will be\n-# fixed shortly, but for now lets not cause regressions.\n-#\n-test_expect_success 'bump commit in server' '\n-\t(cd server &&\n-\tgit checkout master &&\n-\techo content >>file &&\n-\tgit commit -a -m four) &&\n-\tcompare_refs server HEAD server HEAD\n-'\n-\n test_expect_success 'fetch multiple branches' '\n \t(cd local &&\n \t git fetch\n@@ -162,4 +150,12 @@ test_expect_failure 'pushing without marks' '\n \tcompare_refs local2 HEAD server HEAD\n '\n \n+test_expect_success 'push ref with existing object' '\n+\t(cd local &&\n+\tgit branch dup master &&\n+\tgit push origin dup\n+\t) &&\n+\tcompare_refs local dup server dup\n+'\n+\n test_done\ndiff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh\nindex 1f59862..237d2e5 100755\n--- a/t/t9350-fast-export.sh\n+++ b/t/t9350-fast-export.sh\n@@ -454,4 +454,19 @@ test_expect_success 'test bidirectionality' '\n \tgit fast-import --export-marks=marks-cur --import-marks=marks-cur\n '\n \n+cat > expected << EOF\n+reset refs/heads/master\n+from :12\n+\n+EOF\n+\n+test_expect_success 'refs are updated even if no commits need to be exported' '\n+\t> tmp-marks &&\n+\tgit fast-export --import-marks=tmp-marks \\\n+\t\t--export-marks=tmp-marks master > /dev/null &&\n+\tgit fast-export --import-marks=tmp-marks \\\n+\t\t--export-marks=tmp-marks master > actual &&\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n1.8.0\n"},{"id":"203946","messageId":"7vd2z0otie.fsf@alter.siamese.dyndns.org","threadId":"32181","inReplyTo":"1353727034-24698-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v6 p1.1 00/14] fast-export and remote-testgit improvements","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-26T23:04:57Z","receivedAt":"2012-11-26T23:04:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> I'm rerolling this series with the changes fron Junio, plus a bit more cleanups.\n>\n> I dropped the last patch, because I found an issue and a separate patch series\n> would take care of that. Other than that the main changes remain the same.\n>\n> The old remote-testgit is now remote-testpy (as it's testing the python\n> framework, not really remote helpers). The tests are simplified, and exercise\n> more features of transport-helper, and unsuprisingly, find more bugs.\n\nThanks.\n\nI've queued [v6 p1.1] but not later parts (yet).  The result merged\nto 'pu' however seems to break t5800.  It could be a stupid and\ntrivial merge error or something, but I didn't look into the\ndetails.\n\nCould interested parties take a look? \n\n$ cd t && sh ./t5800-remote-testpy.sh\n\nok 1 - setup repository\nok 2 - cloning from local repo\nok 3 - cloning from remote repo\nok 4 - create new commit on remote\nok 5 - pulling from local repo\nok 6 - pulling from remote remote\nok 7 - pushing to local repo\nnot ok 8 - synch with changes from localclone\n#\n#               (cd clone &&\n#                git pull)\n#\nnot ok 9 - pushing remote local repo\n#\n#               (cd clone &&\n#               echo content >>file &&\n#               git commit -a -m four &&\n#               git push) &&\n#               compare_refs clone HEAD server HEAD\n#\nok 10 - fetch new branch\nnot ok 11 - fetch multiple branches\n#\n#               (cd localclone &&\n#                git fetch\n#               ) &&\n#               compare_refs server master localclone refs/remotes/origin/master &&\n#               compare_refs server new localclone refs/remotes/origin/new\n#\nnot ok 12 - push when remote has extra refs\n#\n#               (cd clone &&\n#                echo content >>file &&\n#                git commit -a -m six &&\n#                git push\n#               ) &&\n#               compare_refs clone master server master\n#\nok 13 - push new branch by name\nnot ok 14 - push new branch with old:new refspec # TODO known breakage\nok 15 - proper failure checks for fetching\nnot ok 16 - proper failure checks for pushing # TODO known breakage\n# still have 2 known breakage(s)\n# failed 4 among remaining 14 test(s)\n1..16\n"},{"id":"203949","messageId":"CAMP44s3LR6T6H8z0LPJr7DHXde-JUoN9X4mWhju-5ECvG7wDpg@mail.gmail.com","threadId":"32181","inReplyTo":"7vd2z0otie.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v6 p1.1 00/14] fast-export and remote-testgit improvements","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-26T23:23:44Z","receivedAt":"2012-11-26T23:23:44Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Nov 27, 2012 at 12:04 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> I'm rerolling this series with the changes fron Junio, plus a bit more cleanups.\n>>\n>> I dropped the last patch, because I found an issue and a separate patch series\n>> would take care of that. Other than that the main changes remain the same.\n>>\n>> The old remote-testgit is now remote-testpy (as it's testing the python\n>> framework, not really remote helpers). The tests are simplified, and exercise\n>> more features of transport-helper, and unsuprisingly, find more bugs.\n>\n> Thanks.\n>\n> I've queued [v6 p1.1] but not later parts (yet).  The result merged\n> to 'pu' however seems to break t5800.  It could be a stupid and\n> trivial merge error or something, but I didn't look into the\n> details.\n\nYeah, the last patch triggers that. It should be moved to part2. The\npatch \"fast-export: don't handle uninteresting refs\" should fix that,\nwhich is why I believe it should be applied first. Didn't I already\nsay that?\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"203955","messageId":"7v38zvq5vk.fsf@alter.siamese.dyndns.org","threadId":"32181","inReplyTo":"CAMP44s3LR6T6H8z0LPJr7DHXde-JUoN9X4mWhju-5ECvG7wDpg@mail.gmail.com","subject":"Re: [PATCH v6 p1.1 00/14] fast-export and remote-testgit improvements","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-26T23:52:31Z","receivedAt":"2012-11-26T23:52:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> On Tue, Nov 27, 2012 at 12:04 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>>\n>>> I'm rerolling this series with the changes fron Junio, plus a bit more cleanups.\n>>>\n>>> I dropped the last patch, because I found an issue and a separate patch series\n>>> would take care of that. Other than that the main changes remain the same.\n>>>\n>>> The old remote-testgit is now remote-testpy (as it's testing the python\n>>> framework, not really remote helpers). The tests are simplified, and exercise\n>>> more features of transport-helper, and unsuprisingly, find more bugs.\n>>\n>> Thanks.\n>>\n>> I've queued [v6 p1.1] but not later parts (yet).  The result merged\n>> to 'pu' however seems to break t5800.  It could be a stupid and\n>> trivial merge error or something, but I didn't look into the\n>> details.\n>\n> Yeah, the last patch triggers that. It should be moved to part2. The\n> patch \"fast-export: don't handle uninteresting refs\" should fix that,\n> which is why I believe it should be applied first. Didn't I already\n> say that?\n\nYou may have, but I am leaky ;-) as I am not 100% focused on this\nseries alone.\n\nIn the meantime, I'll drop the last one, push out the 'pu' branch\nafter rebuilding, and then revisit it when I queue the part 2.\n\nThanks.\n"}]}