{"thread":{"id":"35497","subject":"[PATCH v8 1/6] transport-helper: mismerge fix","startedAt":"2013-12-07T21:08:06Z","lastAt":"2013-12-09T21:04:34Z","messageCount":8,"participants":["Felipe Contreras","Junio C Hamano"],"isPatch":true,"patchVersion":8,"patchTotal":6},"messages":[{"id":"231743","messageId":"1386450492-22348-1-git-send-email-felipe.contreras@gmail.com","threadId":"35497","inReplyTo":null,"subject":"[PATCH v8 0/6] transport-helper: fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-07T21:08:06Z","receivedAt":"2013-12-07T21:08:06Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nThese patches add support for remote helpers --force, --dry-run, and reporting\nforced update.\n\nNo changes since last version.\n\nThe later patches for renaming branches, deleting them, custom refspecs have\nbeend dropped because Junio doesn't like the name --refspec, although the\nargument is clearly a refspec as it's used that way extensively through Git.\n\nFelipe Contreras (4):\n  transport-helper: mismerge fix\n  transport-helper: don't update refs in dry-run\n  transport-helper: add 'force' to 'export' helpers\n  transport-helper: check for 'forced update' message\n\nRichard Hansen (2):\n  test-hg.sh: tests are now expected to pass\n  remote-bzr: support the new 'force' option\n\n Documentation/gitremote-helpers.txt   |  4 ++++\n contrib/remote-helpers/git-remote-bzr | 31 ++++++++++++++++++++++++++++++-\n contrib/remote-helpers/test-bzr.sh    | 22 +++++++++++++++++++++-\n contrib/remote-helpers/test-hg.sh     |  4 ++--\n git-remote-testgit.sh                 | 18 ++++++++++++++++++\n t/t5801-remote-helpers.sh             | 13 +++++++++++++\n transport-helper.c                    | 25 +++++++++++++++++--------\n 7 files changed, 105 insertions(+), 12 deletions(-)\n\n-- \n1.8.5.1+fc1\n"},{"id":"231742","messageId":"1386450492-22348-2-git-send-email-felipe.contreras@gmail.com","threadId":"35497","inReplyTo":"1386450492-22348-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v8 1/6] transport-helper: mismerge fix","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-07T21:08:07Z","receivedAt":"2013-12-07T21:08:07Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Commit 9c51558 (transport-helper: trivial code shuffle) moved these\nlines above, but 99d9ec0 (Merge branch 'fc/transport-helper-no-refspec')\nhad a wrong merge conflict and readded them.\n\nReported-by: Richard Hansen <rhansen@bbn.com>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n transport-helper.c | 3 ---\n 1 file changed, 3 deletions(-)\n\ndiff --git a/transport-helper.c b/transport-helper.c\nindex 673b7c2..b66c7fd 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -875,9 +875,6 @@ static int push_refs_with_export(struct transport *transport,\n \t\t}\n \t\tfree(private);\n \n-\t\tif (ref->deletion)\n-\t\t\tdie(\"remote-helpers do not support ref deletion\");\n-\n \t\tif (ref->peer_ref) {\n \t\t\tif (strcmp(ref->peer_ref->name, ref->name))\n \t\t\t\tdie(\"remote-helpers do not support old:new syntax\");\n-- \n1.8.5.1+fc1\n"},{"id":"231746","messageId":"1386450492-22348-3-git-send-email-felipe.contreras@gmail.com","threadId":"35497","inReplyTo":"1386450492-22348-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v8 2/6] transport-helper: don't update refs in dry-run","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-07T21:08:08Z","receivedAt":"2013-12-07T21:08:08Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The remote helper namespace should not be updated.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n transport-helper.c | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/transport-helper.c b/transport-helper.c\nindex b66c7fd..9558a0d 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -728,7 +728,8 @@ static int push_update_ref_status(struct strbuf *buf,\n }\n \n static void push_update_refs_status(struct helper_data *data,\n-\t\t\t\t    struct ref *remote_refs)\n+\t\t\t\t    struct ref *remote_refs,\n+\t\t\t\t    int flags)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct ref *ref = remote_refs;\n@@ -742,7 +743,7 @@ static void push_update_refs_status(struct helper_data *data,\n \t\tif (push_update_ref_status(&buf, &ref, remote_refs))\n \t\t\tcontinue;\n \n-\t\tif (!data->refspecs || data->no_private_update)\n+\t\tif (flags & TRANSPORT_PUSH_DRY_RUN || !data->refspecs || data->no_private_update)\n \t\t\tcontinue;\n \n \t\t/* propagate back the update to the remote namespace */\n@@ -833,7 +834,7 @@ static int push_refs_with_push(struct transport *transport,\n \tsendline(data, &buf);\n \tstrbuf_release(&buf);\n \n-\tpush_update_refs_status(data, remote_refs);\n+\tpush_update_refs_status(data, remote_refs, flags);\n \treturn 0;\n }\n \n@@ -887,7 +888,7 @@ static int push_refs_with_export(struct transport *transport,\n \n \tif (finish_command(&exporter))\n \t\tdie(\"Error while running fast-export\");\n-\tpush_update_refs_status(data, remote_refs);\n+\tpush_update_refs_status(data, remote_refs, flags);\n \treturn 0;\n }\n \n-- \n1.8.5.1+fc1\n"},{"id":"231744","messageId":"1386450492-22348-4-git-send-email-felipe.contreras@gmail.com","threadId":"35497","inReplyTo":"1386450492-22348-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v8 3/6] transport-helper: add 'force' to 'export' helpers","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-07T21:08:09Z","receivedAt":"2013-12-07T21:08:09Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Otherwise they cannot know when to force the push or not (other than\nhacks).\n\nTests-by: Richard Hansen <rhansen@bbn.com>\nDocumentation-by: Richard Hansen <rhansen@bbn.com>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/gitremote-helpers.txt |  4 ++++\n git-remote-testgit.sh               | 18 ++++++++++++++++++\n t/t5801-remote-helpers.sh           | 13 +++++++++++++\n transport-helper.c                  |  5 +++++\n 4 files changed, 40 insertions(+)\n\ndiff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt\nindex f1f4ca9..e75699c 100644\n--- a/Documentation/gitremote-helpers.txt\n+++ b/Documentation/gitremote-helpers.txt\n@@ -437,6 +437,10 @@ set by Git if the remote helper has the 'option' capability.\n 'option check-connectivity' \\{'true'|'false'\\}::\n \tRequest the helper to check connectivity of a clone.\n \n+'option force' \\{'true'|'false'\\}::\n+\tRequest the helper to perform a force update.  Defaults to\n+\t'false'.\n+\n SEE ALSO\n --------\n linkgit:git-remote[1]\ndiff --git a/git-remote-testgit.sh b/git-remote-testgit.sh\nindex 6d2f282..1c006a0 100755\n--- a/git-remote-testgit.sh\n+++ b/git-remote-testgit.sh\n@@ -15,6 +15,8 @@ test -z \"$refspec\" && prefix=\"refs\"\n \n export GIT_DIR=\"$url/.git\"\n \n+force=\n+\n mkdir -p \"$dir\"\n \n if test -z \"$GIT_REMOTE_TESTGIT_NO_MARKS\"\n@@ -39,6 +41,7 @@ do\n \t\tfi\n \t\ttest -n \"$GIT_REMOTE_TESTGIT_SIGNED_TAGS\" && echo \"signed-tags\"\n \t\ttest -n \"$GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE\" && echo \"no-private-update\"\n+\t\techo 'option'\n \t\techo\n \t\t;;\n \tlist)\n@@ -93,6 +96,7 @@ do\n \t\tbefore=$(git for-each-ref --format=' %(refname) %(objectname) ')\n \n \t\tgit fast-import \\\n+\t\t\t${force:+--force} \\\n \t\t\t${testgitmarks:+\"--import-marks=$testgitmarks\"} \\\n \t\t\t${testgitmarks:+\"--export-marks=$testgitmarks\"} \\\n \t\t\t--quiet\n@@ -115,6 +119,20 @@ do\n \n \t\techo\n \t\t;;\n+\toption\\ *)\n+\t\tread cmd opt val <<-EOF\n+\t\t$line\n+\t\tEOF\n+\t\tcase $opt in\n+\t\tforce)\n+\t\t\ttest $val = \"true\" && force=\"true\" || force=\n+\t\t\techo \"ok\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\techo \"unsupported\"\n+\t\t\t;;\n+\t\tesac\n+\t\t;;\n \t'')\n \t\texit\n \t\t;;\ndiff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh\nindex 613f69a..c33cc25 100755\n--- a/t/t5801-remote-helpers.sh\n+++ b/t/t5801-remote-helpers.sh\n@@ -94,6 +94,19 @@ 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 'forced push' '\n+\t(cd local &&\n+\tgit checkout -b force-test &&\n+\techo content >> file &&\n+\tgit commit -a -m eight &&\n+\tgit push origin force-test &&\n+\techo content >> file &&\n+\tgit commit -a --amend -m eight-modified &&\n+\tgit push --force origin force-test\n+\t) &&\n+\tcompare_refs local refs/heads/force-test server refs/heads/force-test\n+'\n+\n test_expect_success 'cloning without refspec' '\n \tGIT_REMOTE_TESTGIT_REFSPEC=\"\" \\\n \tgit clone \"testgit::${PWD}/server\" local2 2>error &&\ndiff --git a/transport-helper.c b/transport-helper.c\nindex 9558a0d..60fba99 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -855,6 +855,11 @@ static int push_refs_with_export(struct transport *transport,\n \t\t\tdie(\"helper %s does not support dry-run\", data->name);\n \t}\n \n+\tif (flags & TRANSPORT_PUSH_FORCE) {\n+\t\tif (set_helper_option(transport, \"force\", \"true\") != 0)\n+\t\t\twarning(\"helper %s does not support 'force'\", data->name);\n+\t}\n+\n \thelper = get_helper(transport);\n \n \twrite_constant(helper->in, \"export\\n\");\n-- \n1.8.5.1+fc1\n"},{"id":"231745","messageId":"1386450492-22348-5-git-send-email-felipe.contreras@gmail.com","threadId":"35497","inReplyTo":"1386450492-22348-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v8 4/6] transport-helper: check for 'forced update' message","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-07T21:08:10Z","receivedAt":"2013-12-07T21:08:10Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"So the remote-helpers can tell us when a forced push was needed.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n transport-helper.c | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/transport-helper.c b/transport-helper.c\nindex 60fba99..23af747 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -644,7 +644,7 @@ static int push_update_ref_status(struct strbuf *buf,\n \t\t\t\t   struct ref *remote_refs)\n {\n \tchar *refname, *msg;\n-\tint status;\n+\tint status, forced = 0;\n \n \tif (!prefixcmp(buf->buf, \"ok \")) {\n \t\tstatus = REF_STATUS_OK;\n@@ -702,6 +702,11 @@ static int push_update_ref_status(struct strbuf *buf,\n \t\t\tfree(msg);\n \t\t\tmsg = NULL;\n \t\t}\n+\t\telse if (!strcmp(msg, \"forced update\")) {\n+\t\t\tforced = 1;\n+\t\t\tfree(msg);\n+\t\t\tmsg = NULL;\n+\t\t}\n \t}\n \n \tif (*ref)\n@@ -723,6 +728,7 @@ static int push_update_ref_status(struct strbuf *buf,\n \t}\n \n \t(*ref)->status = status;\n+\t(*ref)->forced_update = forced;\n \t(*ref)->remote_status = msg;\n \treturn !(status == REF_STATUS_OK);\n }\n-- \n1.8.5.1+fc1\n"},{"id":"231747","messageId":"1386450492-22348-6-git-send-email-felipe.contreras@gmail.com","threadId":"35497","inReplyTo":"1386450492-22348-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v8 5/6] test-hg.sh: tests are now expected to pass","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-07T21:08:11Z","receivedAt":"2013-12-07T21:08:11Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"From: Richard Hansen <rhansen@bbn.com>\n\nSigned-off-by: Richard Hansen <rhansen@bbn.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-hg.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 72f745d..aacd8a9 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -599,7 +599,7 @@ test_expect_success 'remote big push fetch first' '\n \t)\n '\n \n-test_expect_failure 'remote big push force' '\n+test_expect_success 'remote big push force' '\n \ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n \n \tsetup_big_push\n@@ -629,7 +629,7 @@ test_expect_failure 'remote big push force' '\n \tcheck_bookmark hgrepo new_bmark six\n '\n \n-test_expect_failure 'remote big push dry-run' '\n+test_expect_success 'remote big push dry-run' '\n \ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n \n \tsetup_big_push\n-- \n1.8.5.1+fc1\n"},{"id":"231748","messageId":"1386450492-22348-7-git-send-email-felipe.contreras@gmail.com","threadId":"35497","inReplyTo":"1386450492-22348-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v8 6/6] remote-bzr: support the new 'force' option","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-07T21:08:12Z","receivedAt":"2013-12-07T21:08:12Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"From: Richard Hansen <rhansen@bbn.com>\n\nSigned-off-by: Richard Hansen <rhansen@bbn.com>\nAcked-by: Felipe Contreras <felipe.contreras@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-bzr | 31 ++++++++++++++++++++++++++++++-\n contrib/remote-helpers/test-bzr.sh    | 22 +++++++++++++++++++++-\n 2 files changed, 51 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr\nindex 054161a..f1ba477 100755\n--- a/contrib/remote-helpers/git-remote-bzr\n+++ b/contrib/remote-helpers/git-remote-bzr\n@@ -685,7 +685,8 @@ def do_export(parser):\n                 peer = bzrlib.branch.Branch.open(peers[name],\n                                                  possible_transports=transports)\n                 try:\n-                    peer.bzrdir.push_branch(branch, revision_id=revid)\n+                    peer.bzrdir.push_branch(branch, revision_id=revid,\n+                                            overwrite=force)\n                 except bzrlib.errors.DivergedBranches:\n                     print \"error %s non-fast forward\" % ref\n                     continue\n@@ -719,8 +720,32 @@ def do_capabilities(parser):\n         print \"*import-marks %s\" % path\n     print \"*export-marks %s\" % path\n \n+    print \"option\"\n     print\n \n+class InvalidOptionValue(Exception):\n+    pass\n+\n+def get_bool_option(val):\n+    if val == 'true':\n+        return True\n+    elif val == 'false':\n+        return False\n+    else:\n+        raise InvalidOptionValue()\n+\n+def do_option(parser):\n+    global force\n+    opt, val = parser[1:3]\n+    try:\n+        if opt == 'force':\n+            force = get_bool_option(val)\n+            print 'ok'\n+        else:\n+            print 'unsupported'\n+    except InvalidOptionValue:\n+        print \"error '%s' is not a valid value for option '%s'\" % (val, opt)\n+\n def ref_is_valid(name):\n     return not True in [c in name for c in '~^: \\\\']\n \n@@ -883,6 +908,7 @@ def main(args):\n     global is_tmp\n     global branches, peers\n     global transports\n+    global force\n \n     alias = args[1]\n     url = args[2]\n@@ -896,6 +922,7 @@ def main(args):\n     branches = {}\n     peers = {}\n     transports = []\n+    force = False\n \n     if alias[5:] == url:\n         is_tmp = True\n@@ -931,6 +958,8 @@ def main(args):\n             do_import(parser)\n         elif parser.check('export'):\n             do_export(parser)\n+        elif parser.check('option'):\n+            do_option(parser)\n         else:\n             die('unhandled command: %s' % line)\n         sys.stdout.flush()\ndiff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh\nindex 5c50251..ae26dbb 100755\n--- a/contrib/remote-helpers/test-bzr.sh\n+++ b/contrib/remote-helpers/test-bzr.sh\n@@ -65,13 +65,33 @@ test_expect_success 'pushing' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'forced pushing' '\n+\t(\n+\tcd gitrepo &&\n+\techo three-new >content &&\n+\tgit commit -a --amend -m three-new &&\n+\tgit push -f\n+\t) &&\n+\n+\t(\n+\tcd bzrrepo &&\n+\t# the forced update overwrites the bzr branch but not the bzr\n+\t# working directory (it tries to merge instead)\n+\tbzr revert\n+\t) &&\n+\n+\techo three-new >expected &&\n+\tcat bzrrepo/content >actual &&\n+\ttest_cmp expected actual\n+'\n+\n test_expect_success 'roundtrip' '\n \t(\n \tcd gitrepo &&\n \tgit pull &&\n \tgit log --format=\"%s\" -1 origin/master >actual\n \t) &&\n-\techo three >expected &&\n+\techo three-new >expected &&\n \ttest_cmp expected actual &&\n \n \t(cd gitrepo && git push && git pull) &&\n-- \n1.8.5.1+fc1\n"},{"id":"231819","messageId":"xmqqzjo9wxb1.fsf@gitster.dls.corp.google.com","threadId":"35497","inReplyTo":"1386450492-22348-2-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v8 1/6] transport-helper: mismerge fix","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-12-09T21:04:34Z","receivedAt":"2013-12-09T21:04:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Will re-queue these 6 for now.  Thanks.\n"}]}