git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeenu Viswambharan <jeenuv@gmail.com>
To: git@vger.kernel.org
Subject: git add -p refuses to apply an edited patch that otherwise applies
Date: Tue, 1 Mar 2016 20:04:39 +0000	[thread overview]
Message-ID: <CAKCW0Y6GT1aKoCLtPaX+-Qk4u6qGdpAZ7RCFFb29qwteJzY1ww@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 890 bytes --]

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

[-- Attachment #2: full.patch --]
[-- Type: text/x-patch, Size: 544 bytes --]

diff --git a/site.css b/site.css
index 68a88ae..143838c 100644
--- a/site.css
+++ b/site.css
@@ -53,14 +57,23 @@ h4 {
   overflow-y: auto;
 }
 
-p {
-  margin: 15px 0px;
+/* Table of contents */
+#toc {
+  margin: 20px 0px 20px 0px;
+  padding-left: 5px;
 }
-
-h1, h2, h3, h4 {
+#toc li {
+  display: block;
+}
+#toc ul {
+  padding-left: 10px;
   margin: 5px 0px;
 }
 
+p {
+  margin: 15px 0px;
+}
+
 /*
  * For screen wider than 480px, fix the left bar, and set 25/75 split.
  * Also set a max width of 250px and 750px max-width respectively

[-- Attachment #3: no_problem.patch --]
[-- Type: text/x-patch, Size: 159 bytes --]

diff --git a/site.css b/site.css
index 68a88ae..143838c 100644
--- a/site.css
+++ b/site.css
@@ -58,6 +60,9 @@
 }
-
-h1, h2, h3, h4 {
-  margin: 5px 0px;
-}
 

[-- Attachment #4: site.css --]
[-- Type: text/css, Size: 1031 bytes --]


/* Styles to be applied for every one */
body {
  position: relative;

  font-family: "PT Sans", sans-serif;
  font-size: 16px;
  text-rendering: optimizeLegibility;

  line-height: 1.4em;
  word-spacing: 0.05em;

  box-sizing: border-box;

  margin: 0px;
  padding: 0px;

  color: #333;
}

/* Use progressively smaller headings */
h1 {
  font-size: 2em;
}
h2 {
  font-size: 1.7em;
}
h3 {
  font-size: 1.5em;
}
h4 {
  font-size: 1.3em;
}

#left-bar, #main {
  /* Use border box */
  box-sizing: border-box;

  /* Use 5px padding overall; a little more on the left */
  padding: 5px;
  padding-left: 10px;
}

#left-bar {
  /* Use a smaller font */
  font-size: 0.9em;

  /* Extra padding to right */
  padding-right: 10px;

  /* Fix height at 100% so that we get a scrollbar */
  max-height: 100%;
  overflow-y: auto;
}

p {
  margin: 15px 0px;
}

h1, h2, h3, h4 {
  margin: 5px 0px;
}

/*
 * For screen wider than 480px, fix the left bar, and set 25/75 split.
 * Also set a max width of 250px and 750px max-width respectively
 */

                 reply	other threads:[~2016-03-01 20:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAKCW0Y6GT1aKoCLtPaX+-Qk4u6qGdpAZ7RCFFb29qwteJzY1ww@mail.gmail.com \
    --to=jeenuv@gmail.com \
    --cc=git@vger.kernel.org \
    /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 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).