{"thread":{"id":"53182","subject":"subtle bug in git-am","startedAt":"2020-04-07T18:48:24Z","lastAt":"2020-04-30T14:26:50Z","messageCount":4,"participants":["Andy Shevchenko","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"394995","messageId":"20200407184823.GA3932679@smile.fi.intel.com","threadId":"53182","inReplyTo":null,"subject":"subtle bug in git-am","fromName":"Andy Shevchenko","fromEmail":"andriy.shevchenko@linux.intel.com","sentAt":"2020-04-07T18:48:23Z","receivedAt":"2020-04-07T18:48:24Z","isPatch":false,"sender":{"key":"andriy.shevchenko@linux.intel.com","avatar":"https://gravatar.com/avatar/507bf7f59fddb7004f6bf72b211f6216082913376b9d961221004ab9481d97ca?d=mp&s=160"},"body":"Hi!\n\nWhat I would like to do is to apply patch from one repository to another with\nsame files but *different directory structure*.\n\nWhen I try to change directory in the target repo to the folder of files, I run\ngit-am -p5 my_cool_patch.patch.\n\nInstead of the expected result (files and their contents is the same!) I got\nfileXXX is not in index.\n\nSo, I think this is a bug, because -p<n> use in git-am makes little to no sense\nwithout above feature.\n\nPerhaps I didn't understand something.\nPlease, advise.\n\n$ git version\ngit version 2.25.1\n\n\n-- \nWith Best Regards,\nAndy Shevchenko\n\n\n"},{"id":"395036","messageId":"20200408011830.GA6549@camp.crustytoothpaste.net","threadId":"53182","inReplyTo":"20200407184823.GA3932679@smile.fi.intel.com","subject":"Re: subtle bug in git-am","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-04-08T01:18:30Z","receivedAt":"2020-04-08T01:18:38Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2020-04-07 at 18:48:23, Andy Shevchenko wrote:\n> Hi!\n> \n> What I would like to do is to apply patch from one repository to another with\n> same files but *different directory structure*.\n> \n> When I try to change directory in the target repo to the folder of files, I run\n> git-am -p5 my_cool_patch.patch.\n> \n> Instead of the expected result (files and their contents is the same!) I got\n> fileXXX is not in index.\n> \n> So, I think this is a bug, because -p<n> use in git-am makes little to no sense\n> without above feature.\n\nSo if I understand correctly, you're expecting git am to apply relative\nto the current directory in the repository.  I have also expected that\nbehavior in the past, and found it surprising when it did not.\n\nWhat git am does is apply relative to the root of the repository.  If\nyou'd instead like to apply to a specific subdirectory of the\nrepository, you can use the --directory option to specify to which\ndirectory your patch should apply.\n\nThis is the behavior of git apply, which underpins git am.  However,\noutside of a repository, it _does_ apply relative to the current\ndirectory, since there's no repository root to consider.  I, at least,\nfound this confusing, but that's how it works.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"395066","messageId":"CAHp75Vfuuth05wn-0x_AZa_LFSmQMHB6LGM5b4KNMoaxce1S-g@mail.gmail.com","threadId":"53182","inReplyTo":"20200408011830.GA6549@camp.crustytoothpaste.net","subject":"Re: subtle bug in git-am","fromName":"Andy Shevchenko","fromEmail":"andy.shevchenko@gmail.com","sentAt":"2020-04-08T09:29:43Z","receivedAt":"2020-04-08T09:29:54Z","isPatch":false,"sender":{"key":"andy.shevchenko@gmail.com","avatar":"https://gravatar.com/avatar/e7fccbe23f198167f8b4c119a3a8729d3cec5b3268293ffe07ee15a50c39938b?d=mp&s=160"},"body":"On Wed, Apr 8, 2020 at 4:19 AM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>\n> On 2020-04-07 at 18:48:23, Andy Shevchenko wrote:\n> > Hi!\n> >\n> > What I would like to do is to apply patch from one repository to another with\n> > same files but *different directory structure*.\n> >\n> > When I try to change directory in the target repo to the folder of files, I run\n> > git-am -p5 my_cool_patch.patch.\n> >\n> > Instead of the expected result (files and their contents is the same!) I got\n> > fileXXX is not in index.\n> >\n> > So, I think this is a bug, because -p<n> use in git-am makes little to no sense\n> > without above feature.\n>\n> So if I understand correctly, you're expecting git am to apply relative\n> to the current directory in the repository.  I have also expected that\n> behavior in the past, and found it surprising when it did not.\n>\n> What git am does is apply relative to the root of the repository.  If\n> you'd instead like to apply to a specific subdirectory of the\n> repository, you can use the --directory option to specify to which\n> directory your patch should apply.\n>\n> This is the behavior of git apply, which underpins git am.  However,\n> outside of a repository, it _does_ apply relative to the current\n> directory, since there's no repository root to consider.  I, at least,\n> found this confusing, but that's how it works.\n\nThank you for the prompt reply with useful information. I will try it\nwhenever I will need similar flow again.\n\n\n-- \nWith Best Regards,\nAndy Shevchenko\n"},{"id":"396660","messageId":"CAHp75VceVXMsTRAd9iW8D6-uqVR1Z6A9Crgsvyv_-KaSx7JR9Q@mail.gmail.com","threadId":"53182","inReplyTo":"CAHp75Vfuuth05wn-0x_AZa_LFSmQMHB6LGM5b4KNMoaxce1S-g@mail.gmail.com","subject":"Re: subtle bug in git-am","fromName":"Andy Shevchenko","fromEmail":"andy.shevchenko@gmail.com","sentAt":"2020-04-30T14:26:41Z","receivedAt":"2020-04-30T14:26:50Z","isPatch":false,"sender":{"key":"andy.shevchenko@gmail.com","avatar":"https://gravatar.com/avatar/e7fccbe23f198167f8b4c119a3a8729d3cec5b3268293ffe07ee15a50c39938b?d=mp&s=160"},"body":"On Wed, Apr 8, 2020 at 12:29 PM Andy Shevchenko\n<andy.shevchenko@gmail.com> wrote:\n> On Wed, Apr 8, 2020 at 4:19 AM brian m. carlson\n> <sandals@crustytoothpaste.net> wrote:\n> > On 2020-04-07 at 18:48:23, Andy Shevchenko wrote:\n\n> > > What I would like to do is to apply patch from one repository to another with\n> > > same files but *different directory structure*.\n> > >\n> > > When I try to change directory in the target repo to the folder of files, I run\n> > > git-am -p5 my_cool_patch.patch.\n> > >\n> > > Instead of the expected result (files and their contents is the same!) I got\n> > > fileXXX is not in index.\n> > >\n> > > So, I think this is a bug, because -p<n> use in git-am makes little to no sense\n> > > without above feature.\n> >\n> > So if I understand correctly, you're expecting git am to apply relative\n> > to the current directory in the repository.  I have also expected that\n> > behavior in the past, and found it surprising when it did not.\n> >\n> > What git am does is apply relative to the root of the repository.  If\n> > you'd instead like to apply to a specific subdirectory of the\n> > repository, you can use the --directory option to specify to which\n> > directory your patch should apply.\n> >\n> > This is the behavior of git apply, which underpins git am.  However,\n> > outside of a repository, it _does_ apply relative to the current\n> > directory, since there's no repository root to consider.  I, at least,\n> > found this confusing, but that's how it works.\n>\n> Thank you for the prompt reply with useful information. I will try it\n> whenever I will need similar flow again.\n\nToday I have needed something similar and I checked proposed w/a and it works!\nThanks!\n\n-- \nWith Best Regards,\nAndy Shevchenko\n"}]}