git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] apply: when -R, also reverse list of sections

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Oct 20, 2020, 21:36 UTC
Message-ID
<20201020213651.691101-1-jonathantanmy@google.com>
In-Reply-To
<xmqqo8kwaagx.fsf@gitster.c.googlers.com>
Show 18 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > I wish you told that to those who added fn_table kludge to apply.c
> > back when they did so.  They apparently wanted to have a patch that
> > has more than one "diff --git a/hello.c b/hello.c" that talks about
> > the same file applied with a single invocation of "git apply".
> > Perhaps what they did is already broken with "apply -R", and blind
> > reversal of everything magically makes it work?  Or what they did
> > already works with "apply -R" and your blind reversal would break,
> > unless you undo what they did?
> 
> ;-)  It turns out that it was the former.
> 
> Without your "blindly reverse everything" patch, the attached patch
> illustrates how the "touch the same path more than once" support
> introduced in 7a07841c (git-apply: handle a patch that touches the
> same path more than once better, 2008-06-27) is broken with respect
> to "apply -R".
Ah, thanks for checking.
Show 32 quoted lines
> So, you should be able to sell the change to fix _two_ bugs ;-)
> 
> Thanks.
> 
> diff --git a/t/t4127-apply-same-fn.sh b/t/t4127-apply-same-fn.sh
> index 972946c174..fa824ac09f 100755
> --- a/t/t4127-apply-same-fn.sh
> +++ b/t/t4127-apply-same-fn.sh
> @@ -30,7 +30,7 @@ test_expect_success 'apply same filename with independent changes' '
>  	test_cmp same_fn same_fn2
>  '
>  
> -test_expect_success 'apply same filename with overlapping changes' '
> +test_expect_failure 'apply same filename with overlapping changes' '
>  	git reset --hard &&
>  	modify "s/^d/z/" same_fn &&
>  	git diff > patch0 &&
> @@ -39,8 +39,13 @@ test_expect_success 'apply same filename with overlapping changes' '
>  	git diff >> patch0 &&
>  	cp same_fn same_fn2 &&
>  	git reset --hard &&
> +	cp same_fn same_fn1 &&
> +
>  	git apply patch0 &&
> -	test_cmp same_fn same_fn2
> +	test_cmp same_fn same_fn2 &&
> +
> +	git apply -R patch0 &&
> +	test_cmp same_fn same_fn1
>  '
>  
>  test_expect_success 'apply same new filename after rename' '
Indeed, with my patch, this test passes instead of fails.

Should I resend a version 2 that includes this test or will you apply this to your local copy?

Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 8 in “apply: when -R, also reverse list of sections”
  1. apply: when -R, also reverse list of sectionsJonathan Tan, Sep 28, 2020
  2. Junio C HamanoSep 28, 2020
  3. Jonathan TanOct 20, 2020
  4. Junio C HamanoOct 20, 2020
  5. Junio C HamanoOct 20, 2020
  6. Jonathan TanOct 20, 2020
  7. Junio C HamanoOct 20, 2020
  8. apply: when -R, also reverse list of sectionsJonathan Tan, Oct 20, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.