From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
sbeller@google.com, mehul.jain2029@gmail.com,
sandals@crustytoothpaste.net,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: Re: git-apply does not work in a sub-directory of a Git repository
Date: Thu, 24 Mar 2016 18:56:15 +0700 [thread overview]
Message-ID: <1458820579-31621-1-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <CACsJy8CTix-ZwN04MwYTB+JEtDCV27QVf7_0vWmhUSVCwU29Jg@mail.gmail.com>
+Brian who also had issues with git-apply.
On Thu, Mar 24, 2016 at 5:49 PM, Duy Nguyen <pclouds@gmail.com> wrote:
> On Wed, Mar 23, 2016 at 11:55 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Junio C Hamano <gitster@pobox.com> writes:
>>
>>> See
>>>
>>> http://thread.gmane.org/gmane.comp.version-control.git/288316/focus=288321
>>>
>>> I agree it is bad that it silently ignores the path outside the
>>> directory. When run with --verbose, we should say "Skipped X that
>>> is outside the directory." or something like that, just like we
>>> issue notices when we applied with offset, etc.
Implemented in [04/04] apply: report patch skipping in verbose mode.
>> Another thing we may want to do is to loosen (or redo) the logic
>> in builtin/apply.c::use_patch()
>>
>> static int use_patch(struct patch *p)
>> {
>> const char *pathname = p->new_name ? p->new_name : p->old_name;
>> int i;
>>
>> /* Paths outside are not touched regardless of "--include" */
>> if (0 < prefix_length) {
>> int pathlen = strlen(pathname);
>> if (pathlen <= prefix_length ||
>> memcmp(prefix, pathname, prefix_length))
>> return 0;
>> }
>>
>> The include/exclude mechanism does use wildmatch() but does not use
>> the pathspec mechanism (it predates the pathspec machinery that was
>> made reusable in places like this). We should be able to
>>
>> $ cd d/e/e/p/d/i/r
>> $ git apply --include=:/ ../../../../../../../patch
>>
>> to lift this limitation. IOW, we can think of the use_patch() to
>> include only the paths in the subdirectory we are in by default, but
>> we can make it allow --include/--exclude command line option to
>> override that default.
I went with a new option instead of changing --include. Making it
pathspec can still bite people. And pathspec is not exactly compatible
with wildmatch either. This is in
[03/04] apply: add --whole to apply git patch without prefix filtering
> git-apply.txt should
> probably mention about this because (at least to me) it sounds more
> naturally that if I give a patch, git-apply should apply the whole
> patch.
[02/04] git-apply.txt: mention the behavior inside a subdir
> We probably should show a warning if everything file is filtered out
> too because silence usually means "good" from a typical unix command.
> It could be guarded with advice config key, and should only show if it
> looks like there are matching paths on worktree, but filtered out.
I'm holding this back. Too much heuristics.
--
Duy
next prev parent reply other threads:[~2016-03-24 11:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-22 12:10 git-apply does not work in a sub-directory of a Git repository Mehul Jain
2016-03-22 22:14 ` Stefan Beller
2016-03-23 10:15 ` Duy Nguyen
2016-03-23 15:21 ` Junio C Hamano
2016-03-23 16:55 ` Junio C Hamano
2016-03-24 10:49 ` Duy Nguyen
2016-03-24 11:56 ` Nguyễn Thái Ngọc Duy [this message]
2016-03-24 11:56 ` [PATCH 1/4] git-apply.txt: remove a space Nguyễn Thái Ngọc Duy
2016-03-24 11:56 ` [PATCH 2/4] git-apply.txt: mention the behavior inside a subdir Nguyễn Thái Ngọc Duy
2016-03-24 11:56 ` [PATCH 3/4] apply: add --whole to apply git patch without prefix filtering Nguyễn Thái Ngọc Duy
2016-03-24 11:56 ` [PATCH 4/4] apply: report patch skipping in verbose mode Nguyễn Thái Ngọc Duy
2016-03-24 16:50 ` git-apply does not work in a sub-directory of a Git repository Junio C Hamano
2016-03-24 17:32 ` Junio C Hamano
2016-03-30 1:05 ` Duy Nguyen
2016-03-30 17:13 ` Junio C Hamano
2016-03-30 9:33 ` Duy Nguyen
2016-03-24 16:29 ` Junio C Hamano
2016-03-23 17:24 ` Mehul Jain
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=1458820579-31621-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mehul.jain2029@gmail.com \
--cc=sandals@crustytoothpaste.net \
--cc=sbeller@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.