git add -p refuses to apply an edited patch that otherwise applies

From: Jeenu Viswambharan <hidden>
Date: 2016-06-15 23:08:35

Hi,

As subject, the problem I'm facing is that, while doing an interactive
add, an edited patch fails to apply. The same patch content
successfully applies otherwise, with git apply.

To reproduce the problem:

  - Add the attached site.css to an empty git repository, and make an
initial commit
  - Apply the attached full.patch using 'patch -p1'
  - Do 'git add -p', and choose to edit the second hunk (i.e., s, n, e)
  - Edit the presented patch look like the content of attached
no_problem.patch; write and quit

The patch fails to apply.

To see git apply the patch normally, do 'git reset --hard'. Now apply
the no_problem.patch as

git apply --cached --recount < no_problem.patch

AFAIU, the command above is what the interactive script uses to apply
the patch to the index, but I'm confused as to why an edited patch
fails.

Any thoughts? FWIW, I'm using version 2.7.2.

-- 
Jeenu

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help