{"thread":{"id":"6453","subject":"[BUG] Problem with \"stgit push\" causing data loss","startedAt":"2007-01-20T15:01:13Z","lastAt":"2007-01-21T23:27:45Z","messageCount":4,"participants":["Yann Dirson","Catalin Marinas"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"32155","messageId":"20070120150113.GB4665@nan92-1-81-57-214-146.fbx.proxad.net","threadId":"6453","inReplyTo":null,"subject":"[BUG] Problem with \"stgit push\" causing data loss","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-01-20T15:01:13Z","receivedAt":"2007-01-20T15:01:13Z","isPatch":false,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"Well, \"data loss\" is a bit strong, since the data is still available\nto find using git-lost-found.\n\nI first tried to reproduce with a simple test-case, but could not, so\nhere is my way to reproduce it, on a clone of the stgit official\nworkspace.\n\nstgit$ stg branch --create test origin\nBranch \"test\" created.\n\n The test patch is my previous work on \"pull --to\", now superceded\n by \"rebase\".  Patch to reproduce attached to this mail - I just use\n \"pick\" since it's easier for me:\n\nstgit$ ./stg pick -n pull-to 9abaec589753ab190d378b534ceaa6a5af5d0dd3\nChecking for changes in the working directory... done\nImporting commit 9abaec589753ab190d378b534ceaa6a5af5d0dd3... done\nNow at patch \"pull-to\"\nstgit$ stg files pull-to\nM stgit/commands/pull.py\nA t/t2100-pull-to.sh\n\n Now move the testcase in a new patch below, using my\n stg-fold-files-from already sent to the list:\n\nstgit$ stg pop\nPopping patch \"pull-to\"... done\nNo patches applied\nstgit$ stg new test -m test\nstgit$ stg-fold-files-from pull-to 't/*'\nFolding patch from stdin... done\nstgit$ stg refresh\nRefreshing patch \"test\"... done\nstgit$ stg files\nA t/t2100-pull-to.sh\n\n And then push the old file over that:\n\n$ stg push\nPushing patch \"pull-to\"...\nTraceback (most recent call last):\n  File \"/usr/bin/stg\", line 43, in ?\n    main()\n  File \"/var/lib/python-support/python2.4/stgit/main.py\", line 261, in main\n    command.func(parser, options, args)\n  File \"/var/lib/python-support/python2.4/stgit/commands/push.py\", line 101, in func\n    push_patches(patches, options.merged)\n  File \"/var/lib/python-support/python2.4/stgit/commands/common.py\", line 190, in push_patches\n    modified = crt_series.push_patch(p)\n  File \"/var/lib/python-support/python2.4/stgit/stack.py\", line 916, in push_patch\n    git.merge(bottom, head, top)\n  File \"/var/lib/python-support/python2.4/stgit/git.py\", line 535, in merge\n    stages['2'][0], stages['3'][0]) != 0:\n  File \"/var/lib/python-support/python2.4/stgit/gitmergeonefile.py\", line 203, in merge\n    print >> sys.stderr, \\\nTypeError: not all arguments converted during string formatting\n\n State of things now:\n\nstgit$ stg status\n? t/t2100-pull-to.sh.current\n? t/t2100-pull-to.sh.patched\nM stgit/commands/pull.py\nstgit$ diff t/t2100-pull-to.sh.*; echo $?\n0\nstgit$ stg files pull-to\nstgit$ stg top\ntest\n\n As you can see, the pull-to patch is now in a situation that's not\n obvious to untangle by hand.  Also \"stg push -m\" exhibits the same\n issue.\n\nBest regards,\n-- \nYann.\n"},{"id":"32156","messageId":"20070120150949.GB4684@nan92-1-81-57-214-146.fbx.proxad.net","threadId":"6453","inReplyTo":"20070120150113.GB4665@nan92-1-81-57-214-146.fbx.proxad.net","subject":"Re: [BUG] Problem with \"stgit push\" causing data loss","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-01-20T15:09:49Z","receivedAt":"2007-01-20T15:09:49Z","isPatch":false,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"On Sat, Jan 20, 2007 at 04:01:13PM +0100, Yann Dirson wrote:\n>  The test patch is my previous work on \"pull --to\", now superceded\n>  by \"rebase\".  Patch to reproduce attached to this mail\n\nWell... to *this* mail indeed :}\n\n\ncommit 9abaec589753ab190d378b534ceaa6a5af5d0dd3\nAuthor: Yann Dirson <ydirson@altern.org>\nDate:   Wed Jan 17 22:11:58 2007 +0100\n\n    Pull to arbitrary commit\n\ndiff --git a/stgit/commands/pull.py b/stgit/commands/pull.py\nindex 7c5db22..865bfd6 100644\n--- a/stgit/commands/pull.py\n+++ b/stgit/commands/pull.py\n@@ -42,7 +42,9 @@ options = [make_option('-n', '--nopush',\n                        action = 'store_true'),\n            make_option('-m', '--merged',\n                        help = 'check for patches merged upstream',\n-                       action = 'store_true')]\n+                       action = 'store_true'),\n+           make_option('--to', metavar = 'COMMITID',\n+                       help = 'move the stack base to COMMITID')]\n \n def func(parser, options, args):\n     \"\"\"Pull the changes from a remote repository\n@@ -78,10 +80,15 @@ def func(parser, options, args):\n         crt_series.pop_patch(applied[0])\n         print 'done'\n \n-    # pull the remote changes\n-    print 'Pulling from \"%s\"...' % repository\n-    git.pull(repository, refspec)\n-    print 'done'\n+    # FIXME: check git_id/rev_parse(options.to) first and maybe try to fetch if not found\n+    if options.to:\n+        print 'Rebasing to \"%s\"...' % options.to\n+        git.move_branch(options.to)\n+    else:\n+        # pull the remote changes\n+        print 'Pulling from \"%s\"...' % repository\n+        git.pull(repository, refspec)\n+        print 'done'\n \n     # push the patches back\n     if not options.nopush:\ndiff --git a/t/t2100-pull-to.sh b/t/t2100-pull-to.sh\nnew file mode 100755\nindex 0000000..0bf5f16\n--- /dev/null\n+++ b/t/t2100-pull-to.sh\n@@ -0,0 +1,58 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Yann Dirson\n+#\n+\n+test_description='Test the \"pull --to\" command.'\n+\n+. ./test-lib.sh\n+\n+# don't need this repo, but better not drop it, see t1100\n+#rm -rf .git\n+\n+# Need a repo to clone\n+test_create_repo foo\n+\n+test_expect_success \\\n+    'Setup and clone tree, and setup changes' \\\n+    'cd foo &&\n+      stg init && stg new patch -m . &&\n+      printf \"a\\nb\\n\" > file && stg add file && stg refresh &&\n+      cd .. &&\n+     stg clone foo bar &&\n+     cd bar &&\n+      stg new p1 -m p1 &&\n+      echo \"c\" > file2 && stg add file2 && stg refresh &&\n+      cd .. &&\n+     cp -a bar bar2\n+'\n+\n+test_expect_success \\\n+    'Modify original stack' \\\n+    '(cd foo && echo \"c\" >> file && stg refresh)'\n+\n+#test_debug bash\n+#test_done\n+\n+#test_debug \"cd foo && gitk --all && cd ..\"\n+\n+test_expect_success \\\n+    'Pull without --to' \\\n+    '(cd bar &&\n+     a=$(git rev-parse HEAD) &&\n+     stg pull &&\n+     test \"$a\" == $(git rev-parse HEAD))'\n+\n+#test_debug \"cd bar && gitk --all && cd ..\"\n+\n+test_expect_success \\\n+    'Pull with --to' \\\n+    '(cd bar2 &&\n+     a=$(git rev-parse HEAD) &&\n+     git fetch origin +refs/heads/master:refs/heads/origin &&\n+     stg pull --to origin &&\n+     test \"$a\" != $(git rev-parse HEAD) )'\n+\n+test_debug \"cd bar2 && gitk --all && cd ..\"\n+\n+test_done\n"},{"id":"32237","messageId":"b0943d9e0701211442q503396ack2bf2d088325fc4a0@mail.gmail.com","threadId":"6453","inReplyTo":"20070120150113.GB4665@nan92-1-81-57-214-146.fbx.proxad.net","subject":"Re: [BUG] Problem with \"stgit push\" causing data loss","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2007-01-21T22:42:18Z","receivedAt":"2007-01-21T22:42:18Z","isPatch":false,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On 20/01/07, Yann Dirson <ydirson@altern.org> wrote:\n> Well, \"data loss\" is a bit strong, since the data is still available\n> to find using git-lost-found.\n>\n> I first tried to reproduce with a simple test-case, but could not, so\n> here is my way to reproduce it, on a clone of the stgit official\n> workspace.\n\nI tried to somehow emulate this without the fold script but didn't\nmanage to trigger the bug. I'll try with your script tomorrow but\nfirst:\n\nDo you use the latest HEAD in the StGIT repository? I'm asking because\nthe line numbers reported in your backtrace are different from mine. I\nalso made some changes in this area in the past couple of weeks which\nmight have fixed or broken things.\n\n-- \nCatalin\n"},{"id":"32244","messageId":"20070121232745.GE4665@nan92-1-81-57-214-146.fbx.proxad.net","threadId":"6453","inReplyTo":"b0943d9e0701211442q503396ack2bf2d088325fc4a0@mail.gmail.com","subject":"Re: [BUG] Problem with \"stgit push\" causing data loss","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-01-21T23:27:45Z","receivedAt":"2007-01-21T23:27:45Z","isPatch":false,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"On Sun, Jan 21, 2007 at 10:42:18PM +0000, Catalin Marinas wrote:\n> On 20/01/07, Yann Dirson <ydirson@altern.org> wrote:\n> >Well, \"data loss\" is a bit strong, since the data is still available\n> >to find using git-lost-found.\n> >\n> >I first tried to reproduce with a simple test-case, but could not, so\n> >here is my way to reproduce it, on a clone of the stgit official\n> >workspace.\n> \n> I tried to somehow emulate this without the fold script but didn't\n> manage to trigger the bug. I'll try with your script tomorrow but\n> first:\n> \n> Do you use the latest HEAD in the StGIT repository? I'm asking because\n> the line numbers reported in your backtrace are different from mine. I\n> also made some changes in this area in the past couple of weeks which\n> might have fixed or broken things.\n\nHere is where I am:\n\nstgit$ git-rev-parse origin\n0f4eba6a37c1a5454560b097873e5a22bfcde908\n"}]}