Download raw body.
diff vs. patch, path-prefix
On Tue, Apr 12, 2022 at 10:53:26AM +0200, Omar Polo wrote: > Stefan Sperling <stsp@stsp.name> wrote: > > On Mon, Apr 11, 2022 at 04:07:32PM +0200, Christian Weisgerber wrote: > > > Is it overly naive by me to expect got diff | got patch to work? > > > > > > E.g.: > > > $ cd /usr/src > > > $ ssh host 'cd /usr/src && got diff master work' | got patch > > > > > > That is fine of course. > > > > > > However, when you check out subtrees, it breaks. > > > > > > E.g.: > > > $ cd sys # previously checked out with -p sys > > > $ ssh host 'cd sys && got diff master work' | got patch > > > > > > Diff always produces full paths from the repository root. > > > Patch tries to match paths against the work tree. > > > Individually that makes sense, but the combination somehow feels > > > inconsistent. > > > > > > Hmm. > > > > I believe we decided that got patch needs a -pN option argument > > for this case to work as expected. > > well, -pN is a workaround for sure, but i'd like to fix 'got patch' for > the subtrees too. In theory, it's not hard: we already know if we're in > a subtree and its path prefix; in practice tho I haven't found the time > to do it yet! sorry Indeed, we could strip the path-prefix by default in sub-tree work trees, provided the path-prefix matches the beginning of every path in the patch file (after removing a/ b/ in case of a Git-style diff), and the user did not specify a -pN option. With explicit -pN such logic should be disabled, otherwise it becomes too difficult to tell what the result of -pN will be.
diff vs. patch, path-prefix