git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Junio C Hamano <junkio@cox.net>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: [PATCH] Teach 'git apply' to look at $GIT_DIR/config
Date: Mon, 19 Feb 2007 16:11:02 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0702191601300.20368@woody.linux-foundation.org> (raw)
In-Reply-To: <7vwt2d4s6c.fsf@assigned-by-dhcp.cox.net>



On Mon, 19 Feb 2007, Junio C Hamano wrote:
> 
> Hmm.  I am puzzled.  Are you suggesting to change behaviour of
> "git apply" with --index?

Yeah. Or at least _verify_ that the patch is within the subdirectory we 
are in right now. Right now, we do neither, and it will actually change 
files outside that subdirectory, which I think is a bit dangerous.

> git generated patch, or patches on the kernel list that are not
> generated with git are always relative to the top-level, so I
> think the current --index behaviour makes tons of sense.

I agree that it is sensible, but it's sensible only within the context of 
purely self-generated patches, where the patch itself was generated not 
just with git, but with that exact project.

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.

(Again, "Makefile" is a common case, since you often have it at multiple 
levels - maybe it would try to apply the changes to the top-level 
Makefile, even though I was in the drivers/usb/ subdirectory).

Now, I personally actually always work in the top-level directory, so I 
don't actually much care. I'm so used to editing the patches themselves 
that that is what I always end up doing, but I do believe that I'm odd in 
that. Few enough people have worked with unified diffs for over 15 years, 
and are perfectly happy to edit not just the headers, but the actual 
contents too, and fixing up the line numbers to make it all come out 
right. I do that regularly (not daily, but I probably do it almost once a 
month - I decide that I like somebody's patch and want to apply it, but 
fix up some whitespace issue in the patch where he had the opening brace 
of an "if"-statement on the wrong line etc).

So while I *personally* would probably never be impacted, just because I 
alway work in the top directory anyway, I do that partly exactly because 
I'm the top-level maintainer. Somebody who maintains drivers/usb/ might 
well get patches to a driver that only edits the xyzzy.c and xyzzy.h files 
within that subdirectory, and it really does make sense that he be able to 
do "git apply < patch" in that situation.

		Linus

  reply	other threads:[~2007-02-20  0:13 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 [this message]
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
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.0702191601300.20368@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.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).