{"thread":{"id":"4996","subject":"[PATCH 1/2] t7001: add test for git-mv dir1 dir2/","startedAt":"2006-07-26T17:41:05Z","lastAt":"2006-07-28T19:36:57Z","messageCount":22,"participants":["Johannes Schindelin","Jon Smirl","Junio C Hamano","Josef Weidendorfer","Petr Baudis","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"24142","messageId":"Pine.LNX.4.63.0607261940090.29667@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4996","inReplyTo":null,"subject":"[PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-07-26T17:41:05Z","receivedAt":"2006-07-26T17:41:05Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nIf dir2 already exists, git-mv should move dir1 _into_dir2/.\nNoticed by Jon Smirl.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\n\tJon, this was your problem, right?\n\n t/t7001-mv.sh |   15 +++++++++++++++\n 1 files changed, 15 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t7001-mv.sh b/t/t7001-mv.sh\nindex d78c56a..322eaad 100755\n--- a/t/t7001-mv.sh\n+++ b/t/t7001-mv.sh\n@@ -59,4 +59,19 @@ test_expect_success \\\n      git-diff-tree -r -M --name-status  HEAD^ HEAD | \\\n      grep -E \"^R100.+path0/README.+path2/README\"'\n \n+test_expect_success \\\n+    'moving whole subdirectory into subdirectory' \\\n+    'git-mv path2 path1'\n+\n+test_expect_success \\\n+    'commiting the change' \\\n+    'git-commit -m dir-move -a'\n+\n+test_expect_success \\\n+    'checking the commit' \\\n+    'git-diff-tree -r -M --name-status  HEAD^ HEAD | \\\n+     grep -E \"^R100.+path2/COPYING.+path1/path2/COPYING\" &&\n+     git-diff-tree -r -M --name-status  HEAD^ HEAD | \\\n+     grep -E \"^R100.+path2/README.+path1/path2/README\"'\n+\n test_done\n-- \n1.4.2.rc2.g96f2-dirty\n"},{"id":"24145","messageId":"9e4733910607261050k5f8d8d5dke5ded3a806b46f21@mail.gmail.com","threadId":"4996","inReplyTo":"Pine.LNX.4.63.0607261940090.29667@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Jon Smirl","fromEmail":"jonsmirl@gmail.com","sentAt":"2006-07-26T17:50:54Z","receivedAt":"2006-07-26T17:50:54Z","isPatch":true,"sender":{"key":"jonsmirl@gmail.com","avatar":"https://gravatar.com/avatar/cff3bf5bfdfa6708b905712ff91f0f9b8aaca161659f38c02b787920d5d28b7e?d=mp&s=160"},"body":"An exact test case:\n\ngit clone git foo\ngit clone git foo1\ncd foo\nmkdir zzz\ngit mv gitweb zzz\ncg diff >patch\ncd ../foo1\ncg patch <../foo/patch\n\nThis patch won't apply because zzz does not exist in foo1\n\n-- \nJon Smirl\njonsmirl@gmail.com\n"},{"id":"24147","messageId":"7virlkrzr4.fsf@assigned-by-dhcp.cox.net","threadId":"4996","inReplyTo":"9e4733910607261050k5f8d8d5dke5ded3a806b46f21@mail.gmail.com","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-26T18:23:59Z","receivedAt":"2006-07-26T18:23:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Jon Smirl\" <jonsmirl@gmail.com> writes:\n\n> An exact test case:\n>\n> git clone git foo\n> git clone git foo1\n> cd foo\n> mkdir zzz\n> git mv gitweb zzz\n> cg diff >patch\n> cd ../foo1\n> cg patch <../foo/patch\n>\n> This patch won't apply because zzz does not exist in foo1\n\nA short and sweet reproduction recipe is essential for a problem\nreport like this, and I appreciate it very much.  \"git mv\" in\n\"master\" should do the right thing and I see Johannes fixing (or\nfixed) the problem of \"git mv\" failing in his version.\n\nWe should correctly handle cases that fit your general\ndescription (the test t/t4112-apply-renames.sh has a file in\n\"klibc/arch/x86_64\" which is renamed and copied to two different\nlocations under \"include/arch\").  The above does not reproduce\nfor me if I used \"git diff HEAD >patch\" in place of \"cg diff\" (I\ncannot make cg behave on my machine).\n\n$ mkdir zzz\n$ ~/git-master/bin/git-mv gitweb zzz/\n$ LANG=C LC_ALL=C find gitweb zzz -type f -print\nfind: gitweb: No such file or directory\nzzz/gitweb/README\nzzz/gitweb/gitweb.cgi\nzzz/gitweb/gitweb.css\nzzz/gitweb/test/M??rchen\nzzz/gitweb/test/file with spaces\nzzz/gitweb/test/file+plus+sign\n$ git diff HEAD >patch\n$ git checkout -f HEAD\n$ LANG=C LC_ALL=C find gitweb zzz -type f -print\ngitweb/README\ngitweb/gitweb.cgi\ngitweb/gitweb.css\ngitweb/test/M??rchen\ngitweb/test/file with spaces\ngitweb/test/file+plus+sign\nfind: zzz: No such file or directory\n$ git apply --index <patch\n$ LANG=C LC_ALL=C find gitweb zzz -type f -print\nzzz/gitweb/README\nzzz/gitweb/gitweb.cgi\nzzz/gitweb/gitweb.css\nzzz/gitweb/test/M??rchen\nzzz/gitweb/test/file with spaces\nzzz/gitweb/test/file+plus+sign\n\nA couple of weeks ago test t/t4114-apply-typechange.sh was added\nby Eric Wong, and it caught cases where git-apply was assuming\nthat leading directories of a new file already exists or was\ncomplaining when you create file \"foo\" and remove a file\n\"foo/bar\" (that is, you used to have directory at \"foo\").  The\nproblems that test found were all fixed as far as I recall.\n"},{"id":"24148","messageId":"9e4733910607261131q195defa7vbedd72cb0b938ba3@mail.gmail.com","threadId":"4996","inReplyTo":"7virlkrzr4.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Jon Smirl","fromEmail":"jonsmirl@gmail.com","sentAt":"2006-07-26T18:31:46Z","receivedAt":"2006-07-26T18:31:46Z","isPatch":true,"sender":{"key":"jonsmirl@gmail.com","avatar":"https://gravatar.com/avatar/cff3bf5bfdfa6708b905712ff91f0f9b8aaca161659f38c02b787920d5d28b7e?d=mp&s=160"},"body":"On 7/26/06, Junio C Hamano <junkio@cox.net> wrote:\n> We should correctly handle cases that fit your general\n> description (the test t/t4112-apply-renames.sh has a file in\n> \"klibc/arch/x86_64\" which is renamed and copied to two different\n> locations under \"include/arch\").  The above does not reproduce\n> for me if I used \"git diff HEAD >patch\" in place of \"cg diff\" (I\n> cannot make cg behave on my machine).\n\ncg diff makes a patch this looks like this\n\ndiff --git a/gitweb/README b/zzz/gitweb/README\nsimilarity index 100%\nrename from gitweb/README\nrename to zzz/gitweb/README\ndiff --git a/gitweb/gitweb.cgi b/zzz/gitweb/gitweb.cgi\nsimilarity index 100%\nrename from gitweb/gitweb.cgi\nrename to zzz/gitweb/gitweb.cgi\ndiff --git a/gitweb/gitweb.css b/zzz/gitweb/gitweb.css\nsimilarity index 100%\nrename from gitweb/gitweb.css\nrename to zzz/gitweb/gitweb.css\ndiff --git \"a/gitweb/test/M\\303\\244rchen\" \"b/zzz/gitweb/test/M\\303\\244rchen\"\nsimilarity index 100%\nrename from \"gitweb/test/M\\303\\244rchen\"\nrename to \"zzz/gitweb/test/M\\303\\244rchen\"\ndiff --git a/gitweb/test/file with spaces b/zzz/gitweb/test/file with spaces\nsimilarity index 100%\nrename from gitweb/test/file with spaces\nrename to zzz/gitweb/test/file with spaces\ndiff --git a/gitweb/test/file+plus+sign b/zzz/gitweb/test/file+plus+sign\nsimilarity index 100%\nrename from gitweb/test/file+plus+sign\nrename to zzz/gitweb/test/file+plus+sign\n\ngit diff HEAD makes a much longer patch that deltas out the existing\nfiles and delta in the new file.\n\nIt's applying patches in the extended git format that fails.\n\n-- \nJon Smirl\njonsmirl@gmail.com\n"},{"id":"24150","messageId":"200607262039.25155.Josef.Weidendorfer@gmx.de","threadId":"4996","inReplyTo":"Pine.LNX.4.63.0607261940090.29667@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Josef Weidendorfer","fromEmail":"josef.weidendorfer@gmx.de","sentAt":"2006-07-26T18:39:24Z","receivedAt":"2006-07-26T18:39:24Z","isPatch":true,"sender":{"key":"josef.weidendorfer@gmx.de","avatar":null},"body":"On Wednesday 26 July 2006 19:41, Johannes Schindelin wrote:\n> \n> If dir2 already exists, git-mv should move dir1 _into_dir2/.\n> Noticed by Jon Smirl.\n\nThanks for adding this test.\nBTW, the original PERL script passes it quite fine.\n\nI just looked at Jon's problem. Doesn't seem to be related to\ngit-mv or git at all, but more a cogito problem.\nI have some cogito-0.18pre installed, and cg-patch is patching\nthe stuff all itself, not using git for this. Pasky?\n\nDoing the same with git, i.e. in a rep with existing dir/\n\n mkdir new\n git mv dir new\n git diff --cached -M -C >patch\n git reset --hard\n git apply <patch\n\nHowever, \"git status\" shows the \"new/\" directory totally\nuntracked afterwards. Is this expected?\n\nJosef\n"},{"id":"24152","messageId":"Pine.LNX.4.63.0607262047160.29667@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4996","inReplyTo":"9e4733910607261050k5f8d8d5dke5ded3a806b46f21@mail.gmail.com","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-07-26T18:47:34Z","receivedAt":"2006-07-26T18:47:34Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 26 Jul 2006, Jon Smirl wrote:\n\n> An exact test case:\n> \n> git clone git foo\n> git clone git foo1\n> cd foo\n> mkdir zzz\n> git mv gitweb zzz\n> cg diff >patch\n> cd ../foo1\n> cg patch <../foo/patch\n> \n> This patch won't apply because zzz does not exist in foo1\n\nOkay, I got it wrong, then. Thanks for the clarification!\n\nCiao,\nDscho\n"},{"id":"24153","messageId":"7vejw8ry5f.fsf@assigned-by-dhcp.cox.net","threadId":"4996","inReplyTo":"9e4733910607261131q195defa7vbedd72cb0b938ba3@mail.gmail.com","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-26T18:58:36Z","receivedAt":"2006-07-26T18:58:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Jon Smirl\" <jonsmirl@gmail.com> writes:\n\n> git diff HEAD makes a much longer patch that deltas out the existing\n> files and delta in the new file.\n>\n> It's applying patches in the extended git format that fails.\n\nThanks.\n"},{"id":"24154","messageId":"7vac6wrxtg.fsf@assigned-by-dhcp.cox.net","threadId":"4996","inReplyTo":"200607262039.25155.Josef.Weidendorfer@gmx.de","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-26T19:05:47Z","receivedAt":"2006-07-26T19:05:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Josef Weidendorfer <Josef.Weidendorfer@gmx.de> writes:\n\n> On Wednesday 26 July 2006 19:41, Johannes Schindelin wrote:\n>> \n>> If dir2 already exists, git-mv should move dir1 _into_dir2/.\n>> Noticed by Jon Smirl.\n>\n> Thanks for adding this test.\n> BTW, the original PERL script passes it quite fine.\n>\n> I just looked at Jon's problem. Doesn't seem to be related to\n> git-mv or git at all, but more a cogito problem.\n> I have some cogito-0.18pre installed, and cg-patch is patching\n> the stuff all itself, not using git for this. Pasky?\n\n\"git apply\" seems to grok this just fine.\n\n> Doing the same with git, i.e. in a rep with existing dir/\n>\n>  mkdir new\n>  git mv dir new\n>  git diff --cached -M -C >patch\n>  git reset --hard\n>  git apply <patch\n>\n> However, \"git status\" shows the \"new/\" directory totally\n> untracked afterwards. Is this expected?\n\nRunning \"git apply --index <patch\" I see the \"renamed: \" in\nthere and zzz (or your \"new\") is tracked.\n"},{"id":"24157","messageId":"7vmzawqi1m.fsf@assigned-by-dhcp.cox.net","threadId":"4996","inReplyTo":"7vejw8ry5f.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-26T19:31:49Z","receivedAt":"2006-07-26T19:31:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> \"Jon Smirl\" <jonsmirl@gmail.com> writes:\n>\n>> git diff HEAD makes a much longer patch that deltas out the existing\n>> files and delta in the new file.\n>>\n>> It's applying patches in the extended git format that fails.\n>\n> Thanks.\n\n... and it turns out that \"git apply\" (with or without --index)\ngroks it just fine.  I suspect the fix is quite recent (not in\nv1.4.2-rc1 but in v1.4.2-rc2).\n"},{"id":"24162","messageId":"9e4733910607261333k3ec961f7yd012566aa9aa6ed8@mail.gmail.com","threadId":"4996","inReplyTo":"7vmzawqi1m.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Jon Smirl","fromEmail":"jonsmirl@gmail.com","sentAt":"2006-07-26T20:33:06Z","receivedAt":"2006-07-26T20:33:06Z","isPatch":true,"sender":{"key":"jonsmirl@gmail.com","avatar":"https://gravatar.com/avatar/cff3bf5bfdfa6708b905712ff91f0f9b8aaca161659f38c02b787920d5d28b7e?d=mp&s=160"},"body":"On 7/26/06, Junio C Hamano <junkio@cox.net> wrote:\n> Junio C Hamano <junkio@cox.net> writes:\n>\n> > \"Jon Smirl\" <jonsmirl@gmail.com> writes:\n> >\n> >> git diff HEAD makes a much longer patch that deltas out the existing\n> >> files and delta in the new file.\n> >>\n> >> It's applying patches in the extended git format that fails.\n> >\n> > Thanks.\n>\n> ... and it turns out that \"git apply\" (with or without --index)\n> groks it just fine.  I suspect the fix is quite recent (not in\n> v1.4.2-rc1 but in v1.4.2-rc2).\n\nI can confirm that git apply is handling this correctly with code from\nthe current git tree. cogito is failing this case.\n\n-- \nJon Smirl\njonsmirl@gmail.com\n"},{"id":"24274","messageId":"20060728013038.GH13776@pasky.or.cz","threadId":"4996","inReplyTo":"200607262039.25155.Josef.Weidendorfer@gmx.de","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-07-28T01:30:38Z","receivedAt":"2006-07-28T01:30:38Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Wed, Jul 26, 2006 at 08:39:24PM CEST, I got a letter\nwhere Josef Weidendorfer <Josef.Weidendorfer@gmx.de> said that...\n> On Wednesday 26 July 2006 19:41, Johannes Schindelin wrote:\n> > \n> > If dir2 already exists, git-mv should move dir1 _into_dir2/.\n> > Noticed by Jon Smirl.\n> \n> Thanks for adding this test.\n> BTW, the original PERL script passes it quite fine.\n> \n> I just looked at Jon's problem. Doesn't seem to be related to\n> git-mv or git at all, but more a cogito problem.\n> I have some cogito-0.18pre installed, and cg-patch is patching\n> the stuff all itself, not using git for this. Pasky?\n\nUnfortunately, git-apply is still quite unusable for Cogito. It can do\nfuzzy merging now, but here's some random list of more issues I still\nhave with it (I'm leaving for some two weeks or so of holiday soon so I\nwon't have to fix them soon personally; it'd be nice if someone did,\nthough ;) :\n\n  (i) No git-apply -R - well, it seems to me that I revert patches all\nthe time, don't you?\n\n  (ii) I'd like git-apply to be as verbose as patch is, that is list\nthe files it touches as it goes\n\n  (iii) There's no reject handling besides \"panic\" right now - it should\nbe able to create .rej files so that the user can fix things up\n\n  (iv) I need git-apply to add/remove to/from index new/gone files,\nwhile at the same time...\n\n  (v) I want to allow applying of patches to working copy that is not\ncompletely clean, even on top of modified files\n\nBut yes, I'd like cg-patch to move to use git-apply. It's currently\n_way_ too scary.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nSnow falling on Perl. White noise covering line noise.\nHides all the bugs too. -- J. Putnam\n"},{"id":"24277","messageId":"7vvepimoxr.fsf@assigned-by-dhcp.cox.net","threadId":"4996","inReplyTo":"20060728013038.GH13776@pasky.or.cz","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-28T02:41:04Z","receivedAt":"2006-07-28T02:41:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n>   (i) No git-apply -R - well, it seems to me that I revert patches all\n> the time, don't you?\n>\n>   (ii) I'd like git-apply to be as verbose as patch is, that is list\n> the files it touches as it goes\n>\n>   (iii) There's no reject handling besides \"panic\" right now - it should\n> be able to create .rej files so that the user can fix things up\n>\n>   (iv) I need git-apply to add/remove to/from index new/gone files,\n> while at the same time...\n>\n>   (v) I want to allow applying of patches to working copy that is not\n> completely clean, even on top of modified files\n\nYou probably should be able to talk me into doing these, but\ndoesn't it already do (iv) and (v)?\n"},{"id":"24278","messageId":"20060728025619.GK13776@pasky.or.cz","threadId":"4996","inReplyTo":"7vvepimoxr.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-07-28T02:56:19Z","receivedAt":"2006-07-28T02:56:19Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Jul 28, 2006 at 04:41:04AM CEST, I got a letter\nwhere Junio C Hamano <junkio@cox.net> said that...\n> Petr Baudis <pasky@suse.cz> writes:\n> >   (iv) I need git-apply to add/remove to/from index new/gone files,\n> > while at the same time...\n> >\n> >   (v) I want to allow applying of patches to working copy that is not\n> > completely clean, even on top of modified files\n> \n> You probably should be able to talk me into doing these, but\n> doesn't it already do (iv) and (v)?\n\nWell, at once? I can do (iv) by adding --index but that contradicts (v).\nBut maybe I'm missing something.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nSnow falling on Perl. White noise covering line noise.\nHides all the bugs too. -- J. Putnam\n"},{"id":"24279","messageId":"7vr706mj0u.fsf@assigned-by-dhcp.cox.net","threadId":"4996","inReplyTo":"20060728025619.GK13776@pasky.or.cz","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-28T04:48:49Z","receivedAt":"2006-07-28T04:48:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n> Dear diary, on Fri, Jul 28, 2006 at 04:41:04AM CEST, I got a letter\n> where Junio C Hamano <junkio@cox.net> said that...\n>> Petr Baudis <pasky@suse.cz> writes:\n>> >   (iv) I need git-apply to add/remove to/from index new/gone files,\n>> > while at the same time...\n>> >\n>> >   (v) I want to allow applying of patches to working copy that is not\n>> > completely clean, even on top of modified files\n>> \n>> You probably should be able to talk me into doing these, but\n>> doesn't it already do (iv) and (v)?\n>\n> Well, at once? I can do (iv) by adding --index but that contradicts (v).\n> But maybe I'm missing something.\n\nWhat should the semantics of such operation be?  Apply to index\non paths that are clean while leave the index entries untouched\nfor paths that are dirty?  What should happen on renamed paths\nthat are dirty?\n"},{"id":"24296","messageId":"Pine.LNX.4.63.0607281213250.29667@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4996","inReplyTo":"20060728013038.GH13776@pasky.or.cz","subject":"[PATCH] Teach git-apply about '-R'","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-07-28T10:14:46Z","receivedAt":"2006-07-28T10:14:46Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\nOn Fri, 28 Jul 2006, Petr Baudis wrote:\n\n>   (i) No git-apply -R - well, it seems to me that I revert patches all\n> the time, don't you?\n\n builtin-apply.c         |   68 ++++++++++++++++++++++++++++++++++++++++-------\n t/t4102-apply-rename.sh |   24 +++++++++++++++--\n 2 files changed, 80 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex d924ac3..eb3eda1 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -120,7 +120,7 @@ struct fragment {\n struct patch {\n \tchar *new_name, *old_name, *def_name;\n \tunsigned int old_mode, new_mode;\n-\tint is_rename, is_copy, is_new, is_delete, is_binary;\n+\tint is_rename, is_copy, is_new, is_delete, is_binary, is_reverse;\n #define BINARY_DELTA_DEFLATED 1\n #define BINARY_LITERAL_DEFLATED 2\n \tunsigned long deflate_origlen;\n@@ -1119,6 +1119,37 @@ static int parse_chunk(char *buffer, uns\n \treturn offset + hdrsize + patchsize;\n }\n \n+/* a and b may not overlap! */\n+static void memswap(void *a, void *b, unsigned int len)\n+{\n+\tchar *ap = a, *bp = b;\n+\tint i;\n+\tchar c;\n+\n+\tfor (i = 0; i < len; i++) {\n+\t\tc = ap[i]; ap[i] = bp[i]; bp[i] = c;\n+\t}\n+}\n+\n+static void reverse_patches(struct patch *p)\n+{\n+\tfor (; p; p = p->next) {\n+\t\tstruct fragment *frag = p->fragments;\n+\n+\t\tmemswap(p->new_name, p->old_name, sizeof(char *));\n+\t\tmemswap(&p->new_mode, &p->old_mode, sizeof(unsigned int));\n+\t\tmemswap(&p->is_new, &p->is_delete, sizeof(int));\n+\t\tmemswap(&p->lines_added, &p->lines_deleted, sizeof(int));\n+\t\tmemswap(p->old_sha1_prefix, p->new_sha1_prefix, 41);\n+\n+\t\tfor (; frag; frag = frag->next) {\n+\t\t\tmemswap(&frag->newpos, &frag->oldpos, sizeof(int));\n+\t\t\tmemswap(&frag->newlines, &frag->oldlines, sizeof(int));\n+\t\t}\n+\t\tp->is_reverse = !p->is_reverse;\n+\t}\n+}\n+\n static const char pluses[] = \"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\";\n static const char minuses[]= \"----------------------------------------------------------------------\";\n \n@@ -1336,7 +1367,7 @@ static int apply_line(char *output, cons\n }\n \n static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag,\n-\tint inaccurate_eof)\n+\tint reverse, int inaccurate_eof)\n {\n \tint match_beginning, match_end;\n \tchar *buf = desc->buffer;\n@@ -1350,6 +1381,7 @@ static int apply_one_fragment(struct buf\n \tint pos, lines;\n \n \twhile (size > 0) {\n+\t\tchar first;\n \t\tint len = linelen(patch, size);\n \t\tint plen;\n \n@@ -1366,16 +1398,23 @@ static int apply_one_fragment(struct buf\n \t\tplen = len-1;\n \t\tif (len < size && patch[len] == '\\\\')\n \t\t\tplen--;\n-\t\tswitch (*patch) {\n+\t\tfirst = *patch;\n+\t\tif (reverse) {\n+\t\t\tif (first == '-')\n+\t\t\t\tfirst = '+';\n+\t\t\telse if (first == '+')\n+\t\t\t\tfirst = '-';\n+\t\t}\n+\t\tswitch (first) {\n \t\tcase ' ':\n \t\tcase '-':\n \t\t\tmemcpy(old + oldsize, patch + 1, plen);\n \t\t\toldsize += plen;\n-\t\t\tif (*patch == '-')\n+\t\t\tif (first == '-')\n \t\t\t\tbreak;\n \t\t/* Fall-through for ' ' */\n \t\tcase '+':\n-\t\t\tif (*patch != '+' || !no_add)\n+\t\t\tif (first != '+' || !no_add)\n \t\t\t\tnewsize += apply_line(new + newsize, patch,\n \t\t\t\t\t\t      plen);\n \t\t\tbreak;\n@@ -1615,7 +1654,8 @@ static int apply_fragments(struct buffer\n \t\treturn apply_binary(desc, patch);\n \n \twhile (frag) {\n-\t\tif (apply_one_fragment(desc, frag, patch->inaccurate_eof) < 0)\n+\t\tif (apply_one_fragment(desc, frag, patch->is_reverse,\n+\t\t\t\t\tpatch->inaccurate_eof) < 0)\n \t\t\treturn error(\"patch failed: %s:%ld\",\n \t\t\t\t     name, frag->oldpos);\n \t\tfrag = frag->next;\n@@ -2142,7 +2182,8 @@ static int use_patch(struct patch *p)\n \treturn 1;\n }\n \n-static int apply_patch(int fd, const char *filename, int inaccurate_eof)\n+static int apply_patch(int fd, const char *filename,\n+\t\tint reverse, int inaccurate_eof)\n {\n \tunsigned long offset, size;\n \tchar *buffer = read_patch_file(fd, &size);\n@@ -2162,6 +2203,8 @@ static int apply_patch(int fd, const cha\n \t\tnr = parse_chunk(buffer + offset, size, patch);\n \t\tif (nr < 0)\n \t\t\tbreak;\n+\t\tif (reverse)\n+\t\t\treverse_patches(patch);\n \t\tif (use_patch(patch)) {\n \t\t\tpatch_stats(patch);\n \t\t\t*listp = patch;\n@@ -2226,6 +2269,7 @@ int cmd_apply(int argc, const char **arg\n {\n \tint i;\n \tint read_stdin = 1;\n+\tint reverse = 0;\n \tint inaccurate_eof = 0;\n \n \tconst char *whitespace_option = NULL;\n@@ -2236,7 +2280,7 @@ int cmd_apply(int argc, const char **arg\n \t\tint fd;\n \n \t\tif (!strcmp(arg, \"-\")) {\n-\t\t\tapply_patch(0, \"<stdin>\", inaccurate_eof);\n+\t\t\tapply_patch(0, \"<stdin>\", reverse, inaccurate_eof);\n \t\t\tread_stdin = 0;\n \t\t\tcontinue;\n \t\t}\n@@ -2313,6 +2357,10 @@ int cmd_apply(int argc, const char **arg\n \t\t\tparse_whitespace_option(arg + 13);\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"-R\") || !strcmp(arg, \"--reverse\")) {\n+\t\t\treverse = 1;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"--inaccurate-eof\")) {\n \t\t\tinaccurate_eof = 1;\n \t\t\tcontinue;\n@@ -2333,12 +2381,12 @@ int cmd_apply(int argc, const char **arg\n \t\t\tusage(apply_usage);\n \t\tread_stdin = 0;\n \t\tset_default_whitespace_mode(whitespace_option);\n-\t\tapply_patch(fd, arg, inaccurate_eof);\n+\t\tapply_patch(fd, arg, reverse, inaccurate_eof);\n \t\tclose(fd);\n \t}\n \tset_default_whitespace_mode(whitespace_option);\n \tif (read_stdin)\n-\t\tapply_patch(0, \"<stdin>\", inaccurate_eof);\n+\t\tapply_patch(0, \"<stdin>\", reverse, inaccurate_eof);\n \tif (whitespace_error) {\n \t\tif (squelch_whitespace_errors &&\n \t\t    squelch_whitespace_errors < whitespace_error) {\ndiff --git a/t/t4102-apply-rename.sh b/t/t4102-apply-rename.sh\nindex fbb508d..22da6a0 100755\n--- a/t/t4102-apply-rename.sh\n+++ b/t/t4102-apply-rename.sh\n@@ -13,8 +13,8 @@ # setup\n cat >test-patch <<\\EOF\n diff --git a/foo b/bar\n similarity index 47%\n-copy from foo\n-copy to bar\n+rename from foo\n+rename to bar\n --- a/foo\n +++ b/bar\n @@ -1 +1 @@\n@@ -39,4 +39,24 @@ else\n \t    'test -f bar && ls -l bar | grep \"^-..x......\"'\n fi\n \n+test_expect_success 'apply reverse' \\\n+    'git-apply -R --index --stat --summary --apply test-patch &&\n+     test \"$(cat foo)\" = \"This is foo\"'\n+\n+cat >test-patch <<\\EOF\n+diff --git a/foo b/bar\n+similarity index 47%\n+copy from foo\n+copy to bar\n+--- a/foo\n++++ b/bar\n+@@ -1 +1 @@\n+-This is foo\n++This is bar\n+EOF\n+\n+test_expect_success 'apply copy' \\\n+    'git-apply --index --stat --summary --apply test-patch &&\n+     test \"$(cat bar)\" = \"This is bar\" -a \"$(cat foo)\" = \"This is foo\"'\n+\n test_done\n-- \n1.4.2.rc2.g813d5-dirty\n"},{"id":"24305","messageId":"Pine.LNX.4.64.0607280809550.4168@g5.osdl.org","threadId":"4996","inReplyTo":"Pine.LNX.4.63.0607281213250.29667@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Teach git-apply about '-R'","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-07-28T15:14:35Z","receivedAt":"2006-07-28T15:14:35Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 28 Jul 2006, Johannes Schindelin wrote:\n>\n> +/* a and b may not overlap! */\n> +static void memswap(void *a, void *b, unsigned int len)\n\nThis is disgusting.\n\nEspecially since it's also slow as hell.\n\n> +\t\tmemswap(p->new_name, p->old_name, sizeof(char *));\n> +\t\tmemswap(&p->new_mode, &p->old_mode, sizeof(unsigned int));\n> +\t\tmemswap(&p->is_new, &p->is_delete, sizeof(int));\n> +\t\tmemswap(&p->lines_added, &p->lines_deleted, sizeof(int));\n> +\t\tmemswap(p->old_sha1_prefix, p->new_sha1_prefix, 41);\n> +\n> +\t\tfor (; frag; frag = frag->next) {\n> +\t\t\tmemswap(&frag->newpos, &frag->oldpos, sizeof(int));\n> +\t\t\tmemswap(&frag->newlines, &frag->oldlines, sizeof(int));\n\nAll but one of those are register sizes, so doing a horribly ugly \n\"memswap()\"to do them is truly nasty, when you could have done\n\n\t#define swap(a,b) myswap((a),(b),sizeof(a))\n\n\t#define myswap(a,b,size) do {\t\t\\\n\t\tunsigned char mytmp[size];\t\\\n\t\tmemcpy(tmp, &a, size);\t\t\\\n\t\tmemcpy(&a, &b, size);\t\t\\\n\t\tmemcpy(&b, mytmp, size);\t\\\n\t} while (0)\n\nand it would have worked MUCH more efficiently, since any sane compiler \nwould immediately have noticed that you're doing word-sized copies, and \noptimized the hell out of it.\n\n(Untested, of course).\n\n\t\tLinus\n"},{"id":"24306","messageId":"7v3bcln3m5.fsf@assigned-by-dhcp.cox.net","threadId":"4996","inReplyTo":"Pine.LNX.4.63.0607281213250.29667@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Teach git-apply about '-R'","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-28T15:36:18Z","receivedAt":"2006-07-28T15:36:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\nA quick comment without looking much at the code.  Do you sanely\nbail out when asked to reverse-apply a binary patch?\n\nAlso what was the reason to change an existing test vector in\n4102?  That does not look like related to -R flag.\n"},{"id":"24308","messageId":"Pine.LNX.4.63.0607281736550.29667@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4996","inReplyTo":"Pine.LNX.4.64.0607280809550.4168@g5.osdl.org","subject":"[PATCH v2] Teach git-apply about '-R'","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-07-28T15:46:11Z","receivedAt":"2006-07-28T15:46:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\nOn Fri, 28 Jul 2006, Linus Torvalds wrote:\n\n> On Fri, 28 Jul 2006, Johannes Schindelin wrote:\n> >\n> > +/* a and b may not overlap! */\n> > +static void memswap(void *a, void *b, unsigned int len)\n> \n> This is disgusting.\n\nYes, it is. Sorry, was just meant for prototyping. I had in mind to \nreplace it with temporary variables, but your solution seems way \nnicer.\n\n builtin-apply.c         |   65 ++++++++++++++++++++++++++++++++++++++++-------\n t/t4102-apply-rename.sh |   24 ++++++++++++++++-\n 2 files changed, 77 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex d924ac3..6b38a8a 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -120,7 +120,7 @@ struct fragment {\n struct patch {\n \tchar *new_name, *old_name, *def_name;\n \tunsigned int old_mode, new_mode;\n-\tint is_rename, is_copy, is_new, is_delete, is_binary;\n+\tint is_rename, is_copy, is_new, is_delete, is_binary, is_reverse;\n #define BINARY_DELTA_DEFLATED 1\n #define BINARY_LITERAL_DEFLATED 2\n \tunsigned long deflate_origlen;\n@@ -1119,6 +1119,34 @@ static int parse_chunk(char *buffer, uns\n \treturn offset + hdrsize + patchsize;\n }\n \n+#define swap(a,b) myswap((a),(b),sizeof(a))\n+\n+#define myswap(a, b, size) do {\t\t\\\n+\tunsigned char mytmp[size];\t\\\n+\tmemcpy(mytmp, &a, size);\t\t\\\n+\tmemcpy(&a, &b, size);\t\t\\\n+\tmemcpy(&b, mytmp, size);\t\t\\\n+} while (0)\n+\n+static void reverse_patches(struct patch *p)\n+{\n+\tfor (; p; p = p->next) {\n+\t\tstruct fragment *frag = p->fragments;\n+\n+\t\tswap(p->new_name, p->old_name);\n+\t\tswap(p->new_mode, p->old_mode);\n+\t\tswap(p->is_new, p->is_delete);\n+\t\tswap(p->lines_added, p->lines_deleted);\n+\t\tswap(p->old_sha1_prefix, p->new_sha1_prefix);\n+\n+\t\tfor (; frag; frag = frag->next) {\n+\t\t\tswap(frag->newpos, frag->oldpos);\n+\t\t\tswap(frag->newlines, frag->oldlines);\n+\t\t}\n+\t\tp->is_reverse = !p->is_reverse;\n+\t}\n+}\n+\n static const char pluses[] = \"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\";\n static const char minuses[]= \"----------------------------------------------------------------------\";\n \n@@ -1336,7 +1364,7 @@ static int apply_line(char *output, cons\n }\n \n static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag,\n-\tint inaccurate_eof)\n+\tint reverse, int inaccurate_eof)\n {\n \tint match_beginning, match_end;\n \tchar *buf = desc->buffer;\n@@ -1350,6 +1378,7 @@ static int apply_one_fragment(struct buf\n \tint pos, lines;\n \n \twhile (size > 0) {\n+\t\tchar first;\n \t\tint len = linelen(patch, size);\n \t\tint plen;\n \n@@ -1366,16 +1395,23 @@ static int apply_one_fragment(struct buf\n \t\tplen = len-1;\n \t\tif (len < size && patch[len] == '\\\\')\n \t\t\tplen--;\n-\t\tswitch (*patch) {\n+\t\tfirst = *patch;\n+\t\tif (reverse) {\n+\t\t\tif (first == '-')\n+\t\t\t\tfirst = '+';\n+\t\t\telse if (first == '+')\n+\t\t\t\tfirst = '-';\n+\t\t}\n+\t\tswitch (first) {\n \t\tcase ' ':\n \t\tcase '-':\n \t\t\tmemcpy(old + oldsize, patch + 1, plen);\n \t\t\toldsize += plen;\n-\t\t\tif (*patch == '-')\n+\t\t\tif (first == '-')\n \t\t\t\tbreak;\n \t\t/* Fall-through for ' ' */\n \t\tcase '+':\n-\t\t\tif (*patch != '+' || !no_add)\n+\t\t\tif (first != '+' || !no_add)\n \t\t\t\tnewsize += apply_line(new + newsize, patch,\n \t\t\t\t\t\t      plen);\n \t\t\tbreak;\n@@ -1615,7 +1651,8 @@ static int apply_fragments(struct buffer\n \t\treturn apply_binary(desc, patch);\n \n \twhile (frag) {\n-\t\tif (apply_one_fragment(desc, frag, patch->inaccurate_eof) < 0)\n+\t\tif (apply_one_fragment(desc, frag, patch->is_reverse,\n+\t\t\t\t\tpatch->inaccurate_eof) < 0)\n \t\t\treturn error(\"patch failed: %s:%ld\",\n \t\t\t\t     name, frag->oldpos);\n \t\tfrag = frag->next;\n@@ -2142,7 +2179,8 @@ static int use_patch(struct patch *p)\n \treturn 1;\n }\n \n-static int apply_patch(int fd, const char *filename, int inaccurate_eof)\n+static int apply_patch(int fd, const char *filename,\n+\t\tint reverse, int inaccurate_eof)\n {\n \tunsigned long offset, size;\n \tchar *buffer = read_patch_file(fd, &size);\n@@ -2162,6 +2200,8 @@ static int apply_patch(int fd, const cha\n \t\tnr = parse_chunk(buffer + offset, size, patch);\n \t\tif (nr < 0)\n \t\t\tbreak;\n+\t\tif (reverse)\n+\t\t\treverse_patches(patch);\n \t\tif (use_patch(patch)) {\n \t\t\tpatch_stats(patch);\n \t\t\t*listp = patch;\n@@ -2226,6 +2266,7 @@ int cmd_apply(int argc, const char **arg\n {\n \tint i;\n \tint read_stdin = 1;\n+\tint reverse = 0;\n \tint inaccurate_eof = 0;\n \n \tconst char *whitespace_option = NULL;\n@@ -2236,7 +2277,7 @@ int cmd_apply(int argc, const char **arg\n \t\tint fd;\n \n \t\tif (!strcmp(arg, \"-\")) {\n-\t\t\tapply_patch(0, \"<stdin>\", inaccurate_eof);\n+\t\t\tapply_patch(0, \"<stdin>\", reverse, inaccurate_eof);\n \t\t\tread_stdin = 0;\n \t\t\tcontinue;\n \t\t}\n@@ -2313,6 +2354,10 @@ int cmd_apply(int argc, const char **arg\n \t\t\tparse_whitespace_option(arg + 13);\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"-R\") || !strcmp(arg, \"--reverse\")) {\n+\t\t\treverse = 1;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"--inaccurate-eof\")) {\n \t\t\tinaccurate_eof = 1;\n \t\t\tcontinue;\n@@ -2333,12 +2378,12 @@ int cmd_apply(int argc, const char **arg\n \t\t\tusage(apply_usage);\n \t\tread_stdin = 0;\n \t\tset_default_whitespace_mode(whitespace_option);\n-\t\tapply_patch(fd, arg, inaccurate_eof);\n+\t\tapply_patch(fd, arg, reverse, inaccurate_eof);\n \t\tclose(fd);\n \t}\n \tset_default_whitespace_mode(whitespace_option);\n \tif (read_stdin)\n-\t\tapply_patch(0, \"<stdin>\", inaccurate_eof);\n+\t\tapply_patch(0, \"<stdin>\", reverse, inaccurate_eof);\n \tif (whitespace_error) {\n \t\tif (squelch_whitespace_errors &&\n \t\t    squelch_whitespace_errors < whitespace_error) {\ndiff --git a/t/t4102-apply-rename.sh b/t/t4102-apply-rename.sh\nindex fbb508d..22da6a0 100755\n--- a/t/t4102-apply-rename.sh\n+++ b/t/t4102-apply-rename.sh\n@@ -13,8 +13,8 @@ # setup\n cat >test-patch <<\\EOF\n diff --git a/foo b/bar\n similarity index 47%\n-copy from foo\n-copy to bar\n+rename from foo\n+rename to bar\n --- a/foo\n +++ b/bar\n @@ -1 +1 @@\n@@ -39,4 +39,24 @@ else\n \t    'test -f bar && ls -l bar | grep \"^-..x......\"'\n fi\n \n+test_expect_success 'apply reverse' \\\n+    'git-apply -R --index --stat --summary --apply test-patch &&\n+     test \"$(cat foo)\" = \"This is foo\"'\n+\n+cat >test-patch <<\\EOF\n+diff --git a/foo b/bar\n+similarity index 47%\n+copy from foo\n+copy to bar\n+--- a/foo\n++++ b/bar\n+@@ -1 +1 @@\n+-This is foo\n++This is bar\n+EOF\n+\n+test_expect_success 'apply copy' \\\n+    'git-apply --index --stat --summary --apply test-patch &&\n+     test \"$(cat bar)\" = \"This is bar\" -a \"$(cat foo)\" = \"This is foo\"'\n+\n test_done\n-- \n1.4.2.rc2.g8b063-dirty\n"},{"id":"24309","messageId":"20060728154713.GP13776@pasky.or.cz","threadId":"4996","inReplyTo":"7vr706mj0u.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/2] t7001: add test for git-mv dir1 dir2/","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-07-28T15:47:13Z","receivedAt":"2006-07-28T15:47:13Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Jul 28, 2006 at 06:48:49AM CEST, I got a letter\nwhere Junio C Hamano <junkio@cox.net> said that...\n> Petr Baudis <pasky@suse.cz> writes:\n> > Well, at once? I can do (iv) by adding --index but that contradicts (v).\n> > But maybe I'm missing something.\n> \n> What should the semantics of such operation be?  Apply to index\n> on paths that are clean while leave the index entries untouched\n> for paths that are dirty?  What should happen on renamed paths\n> that are dirty?\n\nKeep the original sha1 but change the name. If an entry with the new\nname already exists, we might just leave the index alone and create a\n.rej file. (Alternatively we might create two stages in the index file\nbut we can't do that in case of regular rejects so I'd rather stay\nconsistent.)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nSnow falling on Perl. White noise covering line noise.\nHides all the bugs too. -- J. Putnam\n"},{"id":"24310","messageId":"Pine.LNX.4.63.0607281748390.29667@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4996","inReplyTo":"7v3bcln3m5.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Teach git-apply about '-R'","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-07-28T15:50:27Z","receivedAt":"2006-07-28T15:50:27Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 28 Jul 2006, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> \n> A quick comment without looking much at the code.  Do you sanely\n> bail out when asked to reverse-apply a binary patch?\n\nNope. I swap old_sha1_prefix and new_sha1_prefix in that case, I hoped \nthat is enough?\n\n> Also what was the reason to change an existing test vector in\n> 4102?  That does not look like related to -R flag.\n\nI changed \"copy\" to \"rename\", so that I could reuse that patch to test -R, \ntoo. Note that in the end, the original test vector is written, and \ntested.\n\nCiao,\nDscho\n"},{"id":"24316","messageId":"7vhd11leny.fsf@assigned-by-dhcp.cox.net","threadId":"4996","inReplyTo":"Pine.LNX.4.63.0607281748390.29667@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Teach git-apply about '-R'","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-28T19:20:33Z","receivedAt":"2006-07-28T19:20:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Fri, 28 Jul 2006, Junio C Hamano wrote:\n>> \n>> A quick comment without looking much at the code.  Do you sanely\n>> bail out when asked to reverse-apply a binary patch?\n>\n> Nope. I swap old_sha1_prefix and new_sha1_prefix in that case, I hoped \n> that is enough?\n\nYou would need something like this, at least for now, since both\ndeflated literal and deflated delta methods are irreversible.\nI'll cook up another binary diff output that can go\nbidirectional.\n\nNote that --allow-binary-replacement uses the blob object name\nrecorded on index lines of binary patch, and uses it to cheat\n(iow, when it knows your version is the old version recorded on\nindex line and your repository happens to have the resulting\nblob, it just uses the blob without looking at the binary\ncontents recorded in the patch), so you have to work a bit hard\nto cause it to fail in t/trash repository after you run t4103\ntest.  Resetting to \"master\", apply BF.diff, and immediately\nreverse apply BF.diff would _work_, only because \"master\" and\n\"binary\" branch keep both preimage and postimage.\n\n-- >8 --\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex 6b38a8a..d4381d9 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -1535,6 +1535,12 @@ static int apply_binary_fragment(struct \n \tvoid *data;\n \tvoid *result;\n \n+\t/* Binary patch is irreversible */\n+\tif (patch->is_reverse)\n+\t\treturn error(\"cannot reverse-apply a binary patch to '%s'\",\n+\t\t\t     patch->new_name\n+\t\t\t     ? patch->new_name : patch->old_name);\n+\n \tdata = inflate_it(fragment->patch, fragment->size,\n \t\t\t  patch->deflate_origlen);\n \tif (!data)\n"},{"id":"24317","messageId":"Pine.LNX.4.63.0607282135380.29667@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4996","inReplyTo":"7vhd11leny.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Teach git-apply about '-R'","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-07-28T19:36:57Z","receivedAt":"2006-07-28T19:36:57Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 28 Jul 2006, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > On Fri, 28 Jul 2006, Junio C Hamano wrote:\n> >> \n> >> A quick comment without looking much at the code.  Do you sanely\n> >> bail out when asked to reverse-apply a binary patch?\n> >\n> > Nope. I swap old_sha1_prefix and new_sha1_prefix in that case, I hoped \n> > that is enough?\n> \n> You would need something like this, at least for now, since both\n> deflated literal and deflated delta methods are irreversible.\n\nSomehow I had the impression that binary diff meant that you needed both \nobjects in the object database. I was wrong.\n\nCiao,\nDscho\n"}]}