git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* bug in git-apply
@ 2008-04-06 23:53 Karl Hasselström
  2008-04-07  1:11 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Karl Hasselström @ 2008-04-06 23:53 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Catalin Marinas

StGit's test suite has started failing, and it's due to a change in
git that I'm pretty sure is a bug. I built a small test case using
just git for easier testing:

  mkdir foo
  cd foo

  git init
  touch xx
  git add xx
  git commit -m 'first'

  git checkout -b branch

  echo aaa >> xx
  git add xx
  git commit -m 'second'

  git checkout master

  echo bbb >> xx
  git add xx
  git commit -m 'third'

  git diff branch^ branch > p
  git apply < p && echo "this should not succeed!"

Basically, we have a file containing "aaa\n", and a patch that tries
to take the file from "" to "bbb\n". A recent enough git-apply will
accept this patch without complaining, and put "aaa\nbbb\n" in the
file.

I bisected, and the culprit was this commit:

commit dc41976a3eed1d9c93fdc08c448bab969db4e0ec
Author: Junio C Hamano <gitster@pobox.com>
Date:   Sat Jan 19 01:58:34 2008 -0800

    builtin-apply.c: push match-beginning/end logic down

    This moves the logic to force match at the beginning and/or at
    the end of the buffer to the actual function that finds the
    match from its caller.  This is a necessary preparation for the
    next step to allow matching disregarding certain differences,
    such as whitespace changes.

    We probably could optimize this even more by taking advantage of
    the fact that match_beginning and match_end forces the match to
    be at an exact location (anchored at the beginning and/or the
    end), but that's for another commit.

    Signed-off-by: Junio C Hamano <gitster@pobox.com>

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-07  7:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-06 23:53 bug in git-apply Karl Hasselström
2008-04-07  1:11 ` Junio C Hamano
2008-04-07  7:04   ` Karl Hasselström
2008-04-07  7:12     ` Junio C Hamano

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).