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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
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
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;
-}
 
/* 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
 */

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]