{"thread":{"id":"19817","subject":"A question about using 'add -p' to split the patch","startedAt":"2009-06-15T03:08:51Z","lastAt":"2009-06-15T08:56:40Z","messageCount":5,"participants":["Ping Yin","David Aguilar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"116307","messageId":"46dff0320906142008v4f278d3ek3eebfa36f7fcf06a@mail.gmail.com","threadId":"19817","inReplyTo":null,"subject":"A question about using 'add -p' to split the patch","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2009-06-15T03:08:51Z","receivedAt":"2009-06-15T03:08:51Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"file bt.php in the HEAD:\n\nfunction bt_add($path) {\n return;\n}\n\nfile bt.php in the working directory:\n\nfunction bt_move($path, $pos) {\n  return;\n}\nfunction bt_add($path, $pos) {\n  bt_move($path, $pos)\n  return;\n}\n\nNow i want to split the change into two parts:\nFirst introduce bt_move\nThen add a param pos to bt_add and call bt_move\n\nWith the 'e' action of 'add -p', i got\n\n-function bt_add($path) {\n+function bt_move($path, $pos) {\n+  return;\n+}\n+function bt_add($path, $pos) {\n+  bt_move($path, $pos)\n   return;\n }\n\nThen, i want to edit the patch to get\n\n\nfunction bt_move($path, $pos) {\n  return;\n}\nfunction bt_add($path) {\n  return;\n}\n\nHowever, whatever i do, the patch fails to apply. Any suggestion?\n\n-\n\n\nPing Yin\n"},{"id":"116313","messageId":"20090615061211.GA53136@gmail.com","threadId":"19817","inReplyTo":"46dff0320906142008v4f278d3ek3eebfa36f7fcf06a@mail.gmail.com","subject":"Re: A question about using 'add -p' to split the patch","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-06-15T06:12:12Z","receivedAt":"2009-06-15T06:12:12Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Mon, Jun 15, 2009 at 11:08:51AM +0800, Ping Yin wrote:\n> file bt.php in the HEAD:\n> \n> function bt_add($path) {\n>  return;\n> }\n> \n> file bt.php in the working directory:\n> \n> function bt_move($path, $pos) {\n>   return;\n> }\n> function bt_add($path, $pos) {\n>   bt_move($path, $pos)\n>   return;\n> }\n> \n> Now i want to split the change into two parts:\n> First introduce bt_move\n> Then add a param pos to bt_add and call bt_move\n> \n> With the 'e' action of 'add -p', i got\n> \n> -function bt_add($path) {\n> +function bt_move($path, $pos) {\n> +  return;\n> +}\n> +function bt_add($path, $pos) {\n> +  bt_move($path, $pos)\n>    return;\n>  }\n> \n> Then, i want to edit the patch to get\n> \n> \n> function bt_move($path, $pos) {\n>   return;\n> }\n> function bt_add($path) {\n>   return;\n> }\n> \n> However, whatever i do, the patch fails to apply. Any suggestion?\n\nUse git-gui or git-cola to select just bt_move() for addition.\nYou can stage specific lines.\n\nAfter doing that it's often a good idea to git stash --keep-index\nso you can test it before committing.\n\nenjoy,\n\n-- \n\t\tDavid\n"},{"id":"116316","messageId":"46dff0320906142324i191e50d5v1e89ba6311377a47@mail.gmail.com","threadId":"19817","inReplyTo":"20090615061211.GA53136@gmail.com","subject":"Re: A question about using 'add -p' to split the patch","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2009-06-15T06:24:39Z","receivedAt":"2009-06-15T06:24:39Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Mon, Jun 15, 2009 at 2:12 PM, David Aguilar<davvid@gmail.com> wrote:\n> On Mon, Jun 15, 2009 at 11:08:51AM +0800, Ping Yin wrote:\n>> file bt.php in the HEAD:\n>>\n>> function bt_add($path) {\n>>  return;\n>> }\n>>\n>> file bt.php in the working directory:\n>>\n>> function bt_move($path, $pos) {\n>>   return;\n>> }\n>> function bt_add($path, $pos) {\n>>   bt_move($path, $pos)\n>>   return;\n>> }\n>>\n>> Now i want to split the change into two parts:\n>> First introduce bt_move\n>> Then add a param pos to bt_add and call bt_move\n>>\n>> With the 'e' action of 'add -p', i got\n>>\n>> -function bt_add($path) {\n>> +function bt_move($path, $pos) {\n>> +  return;\n>> +}\n>> +function bt_add($path, $pos) {\n>> +  bt_move($path, $pos)\n>>    return;\n>>  }\n>>\n>> Then, i want to edit the patch to get\n>>\n>>\n>> function bt_move($path, $pos) {\n>>   return;\n>> }\n>> function bt_add($path) {\n>>   return;\n>> }\n>>\n>> However, whatever i do, the patch fails to apply. Any suggestion?\n>\n> Use git-gui or git-cola to select just bt_move() for addition.\n> You can stage specific lines.\n\nDoesn't the 'e' action of 'add -p' do the same job with git-gui?\n"},{"id":"116318","messageId":"20090615073635.GA53643@gmail.com","threadId":"19817","inReplyTo":"46dff0320906142324i191e50d5v1e89ba6311377a47@mail.gmail.com","subject":"Re: A question about using 'add -p' to split the patch","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-06-15T07:36:43Z","receivedAt":"2009-06-15T07:36:43Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Mon, Jun 15, 2009 at 02:24:39PM +0800, Ping Yin wrote:\n> On Mon, Jun 15, 2009 at 2:12 PM, David Aguilar<davvid@gmail.com> wrote:\n> > On Mon, Jun 15, 2009 at 11:08:51AM +0800, Ping Yin wrote:\n> >> file bt.php in the HEAD:\n> >>\n> >> function bt_add($path) {\n> >>  return;\n> >> }\n> >>\n> >> file bt.php in the working directory:\n> >>\n> >> function bt_move($path, $pos) {\n> >>   return;\n> >> }\n> >> function bt_add($path, $pos) {\n> >>   bt_move($path, $pos)\n> >>   return;\n> >> }\n> >>\n> >> Now i want to split the change into two parts:\n> >> First introduce bt_move\n> >> Then add a param pos to bt_add and call bt_move\n> >>\n> >> With the 'e' action of 'add -p', i got\n> >>\n> >> -function bt_add($path) {\n> >> +function bt_move($path, $pos) {\n> >> +  return;\n> >> +}\n> >> +function bt_add($path, $pos) {\n> >> +  bt_move($path, $pos)\n> >>    return;\n> >>  }\n> >>\n> >> Then, i want to edit the patch to get\n> >>\n> >>\n> >> function bt_move($path, $pos) {\n> >>   return;\n> >> }\n> >> function bt_add($path) {\n> >>   return;\n> >> }\n> >>\n> >> However, whatever i do, the patch fails to apply. Any suggestion?\n> >\n> > Use git-gui or git-cola to select just bt_move() for addition.\n> > You can stage specific lines.\n> \n> Doesn't the 'e' action of 'add -p' do the same job with git-gui?\n\nIt should.\n\nI tried it in git-{cola,gui} and I was able to do it by first staging\nthe +bt_add(a,b) line, and then staging only the -bt_add(a) line.\n\nFor add -e I got it to work by editing the patch to;\n\n+function bt_move($path, $pos) {\n+  return;\n+}\n function bt_add($path) {\n   return;\n }\n\nThe reason it's hard to get right is that you have to\nreconstruct the context of the original content for the\nadds/removes and remember to add the space before the\nreconstructed bt_add($path).\n\nThose kinda details are usually easier for software to get right\n;-)\n\n-- \n\t\tDavid\n"},{"id":"116324","messageId":"46dff0320906150156mf9ac4dek99c94a6cc59e1db@mail.gmail.com","threadId":"19817","inReplyTo":"20090615073635.GA53643@gmail.com","subject":"Re: A question about using 'add -p' to split the patch","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2009-06-15T08:56:40Z","receivedAt":"2009-06-15T08:56:40Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":">\n> For add -e I got it to work by editing the patch to;\n>\n> +function bt_move($path, $pos) {\n> +  return;\n> +}\n>  function bt_add($path) {\n>    return;\n>  }\n>\n> The reason it's hard to get right is that you have to\n> reconstruct the context of the original content for the\n> adds/removes and remember to add the space before the\n> reconstructed bt_add($path).\n>\n\nThanks very much, i forgot the space before the reconstructed bt_add($path) :-)\n"}]}