From: Linus Torvalds <torvalds@linux-foundation.org>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: Junio C Hamano <junkio@cox.net>, Jeff King <peff@peff.net>,
git@vger.kernel.org
Subject: Re: [PATCH] Teach 'git apply' to look at $GIT_DIR/config
Date: Wed, 21 Feb 2007 08:44:05 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.64.0702210836210.4043@woody.linux-foundation.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0702210014140.6485@iabervon.org>
On Wed, 21 Feb 2007, Daniel Barkalow wrote:
> On Mon, 19 Feb 2007, Linus Torvalds wrote:
> > Imagine somebody sending you a patch to a set of files, and they didn't
> > use git to generate that patch. What would it look right? Right, it might
> > well look like
> >
> > diff -u file.c.orig file.c
> > --- file.c.orig
> > +++ file.c
> > @@ -29,6 +29,7 @@
> > ...
> >
> > and it happens to be in some subdirectory. What would you do?
> >
> > I'd use "git apply". And I would be really upset *if* git-apply actually
> > applied the patch to some *other* subdirectory than the one I was in.
>
> "git apply" should be able to notice the many clues that this patch
> doesn't go at the root: (1) it's not -r; (2) it's not a rename, but the
> filenames aren't the same; (3) there isn't an extra path element to
> remove.
(4): it doesn't say "diff --git" with all the git-specific info.
We actually already *do* act differently for native git patches and for
"traditional unified diffs", and yeah, we could certainly extend that to
the whole "what to do about subdirectories" thing.
For traditional unified diffs, we already have extra rules about guessing
the pathname, so this isn't even really a "new" rule, it's just an
extension of the old ones. With traditional diffs, you *have* to guess at
the pathnames, because the pathnames aren't well-defined (never mind
renames, it's true for file create/delete events too, and it's true
exactly because you often have two different filenames for the *same*
file, like in my example).
> I think "git apply" should just know that if the filenames don't match,
> and it's not a rename, and the --- filename isn't /dev/null, then add the
> current directory and use -p0.
Well, "-p1" is still the saner default - even unified diff people tend to
use that (and if there is no path at all, it's still safe - there's
nothing to remove).
As to the traditional vs git patches: we already have totally separate
functions for parsing what they are:
- parse_git_header() parses git-only patches and understands all the
extended syntax, and has sanity checks
- parse_traditional_patch() has this magic heuristic which knows about
the "/dev/null" special cases, and uses a magic "find_name()" function
that will choose whichever name makes more sense.
We could just make "parse_traditional_patch()" try to take the prefix
information into account instead. That would be a better choice than doing
it unconditionally even for native git patches.
Junio?
Linus
next prev parent reply other threads:[~2007-02-21 16:44 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-17 20:37 [PATCH] Teach core.autocrlf to 'git apply' Junio C Hamano
2007-02-17 21:12 ` [PATCH] Teach 'git apply' to look at $GIT_DIR/config Junio C Hamano
2007-02-17 23:26 ` Jeff King
2007-02-17 23:31 ` Junio C Hamano
2007-02-17 23:32 ` Jeff King
2007-02-19 22:57 ` Linus Torvalds
2007-02-19 23:04 ` Shawn O. Pearce
2007-02-19 23:14 ` Junio C Hamano
2007-02-19 23:37 ` Linus Torvalds
2007-02-19 23:57 ` Junio C Hamano
2007-02-20 0:11 ` Linus Torvalds
2007-02-20 0:35 ` Junio C Hamano
2007-02-20 0:53 ` Johannes Schindelin
2007-02-20 1:29 ` Junio C Hamano
2007-02-20 1:43 ` Johannes Schindelin
2007-02-20 1:57 ` [PATCH] git-apply: require -p<n> when working in a subdirectory Junio C Hamano
2007-02-20 2:33 ` [PATCH] apply: fix memory leak in prefix_one() Johannes Schindelin
2007-02-20 2:39 ` Junio C Hamano
2007-02-20 2:45 ` Johannes Schindelin
2007-02-20 1:58 ` [PATCH] git-apply: do not lose cwd when run from a subdirectory Junio C Hamano
2007-02-20 1:28 ` [PATCH] Teach 'git apply' to look at $GIT_DIR/config Junio C Hamano
2007-02-20 1:38 ` Linus Torvalds
2007-02-21 5:39 ` Daniel Barkalow
2007-02-21 11:22 ` Junio C Hamano
2007-02-21 17:00 ` Daniel Barkalow
2007-02-21 16:44 ` Linus Torvalds [this message]
2007-02-21 19:35 ` Junio C Hamano
2007-02-21 22:31 ` [PATCH] git-apply: notice "diff --git" patch again Junio C Hamano
2007-02-22 0:24 ` [PATCH] git-apply: guess correct -p<n> value for non-git patches Junio C Hamano
2007-02-20 0:16 ` [PATCH] Teach 'git apply' to look at $GIT_DIR/config Johannes Schindelin
2007-02-20 0:36 ` Simon 'corecode' Schubert
2007-02-18 0:08 ` Johannes Schindelin
2007-02-18 0:28 ` Junio C Hamano
2007-02-18 0:40 ` Johannes Schindelin
2007-02-18 1:03 ` Junio C Hamano
2007-02-18 1:15 ` Johannes Schindelin
2007-02-18 1:47 ` Junio C Hamano
2007-02-18 2:00 ` Johannes Schindelin
2007-02-18 2:15 ` Junio C Hamano
2007-02-18 11:40 ` Johannes Schindelin
2007-02-18 1:48 ` Jakub Narebski
2007-02-18 0:06 ` Johannes Schindelin
2007-02-18 0:31 ` Junio C Hamano
2007-02-18 0:53 ` Johannes Schindelin
2007-02-18 1:20 ` Junio C Hamano
2007-02-18 1:29 ` Johannes Schindelin
2007-02-18 1:48 ` Junio C Hamano
2007-02-18 2:01 ` Johannes Schindelin
2007-02-18 2:10 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0702210836210.4043@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=barkalow@iabervon.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).