All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Vega <vega.james@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: git-apply fails on creating a new file, with both -p and --directory specified
Date: Tue, 8 Dec 2009 01:49:44 -0500	[thread overview]
Message-ID: <20091208064944.GM14401@jamessan.com> (raw)
In-Reply-To: <20091208060109.GB9951@coredump.intra.peff.net>

On Tue, Dec 08, 2009 at 01:01:09AM -0500, Jeff King wrote:
> On Tue, Dec 08, 2009 at 12:47:24AM -0500, Jeff King wrote:
> 
> > There is a slightly different approach we could take, too: keep the
> > "deletion" hunk as a first-class hunk, and just meld the content hunk's
> > output into it. Then both cases would get the "Stage deletion" question
> > instead of the "Stage this hunk" you get now for non-empty files (which
> > just happens to trigger a deletion due to the headers).
> 
> BTW, the code for this is the much smaller change below. If you prefer
> that, I can squash in the test and write up an appropriate commit
> message.
> 
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index 35f4ef1..02e97b9 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -1217,7 +1217,11 @@ sub patch_update_file {
>  	if (@{$mode->{TEXT}}) {
>  		unshift @hunk, $mode;
>  	}
> -	if (@{$deletion->{TEXT}} && !@hunk) {
> +	if (@{$deletion->{TEXT}}) {
> +		foreach my $hunk (@hunk) {
> +			push @{$deletion->{TEXT}}, @{$hunk->{TEXT}};
> +			push @{$deletion->{DISPLAY}}, @{$hunk->{DISPLAY}};
> +		}
>  		@hunk = ($deletion);
>  	}
>  

Thanks for the quick patches.  This was similar to what I was working on, but
cleaner than what I had.  Works well for me.

-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <vega.james@gmail.com>

  reply	other threads:[~2009-12-08  6:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-23 19:45 git-apply fails on creating a new file, with both -p and --directory specified Steven J. Murdoch
2009-11-25 10:56 ` Junio C Hamano
2009-12-07 21:35   ` James Vega
2009-12-08  2:59     ` Junio C Hamano
2009-12-08  3:20       ` Junio C Hamano
2009-12-08  5:47         ` Jeff King
2009-12-08  6:01           ` Jeff King
2009-12-08  6:49             ` James Vega [this message]
2009-12-08  7:28             ` Junio C Hamano
2009-12-08  7:49               ` Jeff King
2009-12-08  7:53                 ` Junio C Hamano
2009-12-08  7:11           ` Junio C Hamano
2009-12-08  7:38             ` Jeff King
2009-12-08  3:39       ` James Vega
  -- strict thread matches above, loose matches on Subject: below --
2010-04-28 12:29 Matthias Lehmann
2010-04-29  8:20 ` Matthias Lehmann

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=20091208064944.GM14401@jamessan.com \
    --to=vega.james@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --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 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.