{"thread":{"id":"41584","subject":"git add -p refuses to apply an edited patch that otherwise applies","startedAt":"2016-03-01T20:04:39Z","lastAt":"2016-03-01T20:04:39Z","messageCount":1,"participants":["Jeenu Viswambharan"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"279999","messageId":"CAKCW0Y6GT1aKoCLtPaX+-Qk4u6qGdpAZ7RCFFb29qwteJzY1ww@mail.gmail.com","threadId":"41584","inReplyTo":null,"subject":"git add -p refuses to apply an edited patch that otherwise applies","fromName":"Jeenu Viswambharan","fromEmail":"jeenuv@gmail.com","sentAt":"2016-03-01T20:04:39Z","receivedAt":"2016-03-01T20:04:39Z","isPatch":false,"sender":{"key":"jeenuv@gmail.com","avatar":"https://gravatar.com/avatar/0fae51e727209ba442f53fbab775dec62add0884f7a1bf1eb9fee94fb876f2b0?d=mp&s=160"},"body":"Hi,\n\nAs subject, the problem I'm facing is that, while doing an interactive\nadd, an edited patch fails to apply. The same patch content\nsuccessfully applies otherwise, with git apply.\n\nTo reproduce the problem:\n\n  - Add the attached site.css to an empty git repository, and make an\ninitial commit\n  - Apply the attached full.patch using 'patch -p1'\n  - Do 'git add -p', and choose to edit the second hunk (i.e., s, n, e)\n  - Edit the presented patch look like the content of attached\nno_problem.patch; write and quit\n\nThe patch fails to apply.\n\nTo see git apply the patch normally, do 'git reset --hard'. Now apply\nthe no_problem.patch as\n\ngit apply --cached --recount < no_problem.patch\n\nAFAIU, the command above is what the interactive script uses to apply\nthe patch to the index, but I'm confused as to why an edited patch\nfails.\n\nAny thoughts? FWIW, I'm using version 2.7.2.\n\n-- \nJeenu\n\n\ndiff --git a/site.css b/site.css\nindex 68a88ae..143838c 100644\n--- a/site.css\n+++ b/site.css\n@@ -53,14 +57,23 @@ h4 {\n   overflow-y: auto;\n }\n \n-p {\n-  margin: 15px 0px;\n+/* Table of contents */\n+#toc {\n+  margin: 20px 0px 20px 0px;\n+  padding-left: 5px;\n }\n-\n-h1, h2, h3, h4 {\n+#toc li {\n+  display: block;\n+}\n+#toc ul {\n+  padding-left: 10px;\n   margin: 5px 0px;\n }\n \n+p {\n+  margin: 15px 0px;\n+}\n+\n /*\n  * For screen wider than 480px, fix the left bar, and set 25/75 split.\n  * Also set a max width of 250px and 750px max-width respectively\n\n\ndiff --git a/site.css b/site.css\nindex 68a88ae..143838c 100644\n--- a/site.css\n+++ b/site.css\n@@ -58,6 +60,9 @@\n }\n-\n-h1, h2, h3, h4 {\n-  margin: 5px 0px;\n-}\n \n\n\n\n/* Styles to be applied for every one */\nbody {\n  position: relative;\n\n  font-family: \"PT Sans\", sans-serif;\n  font-size: 16px;\n  text-rendering: optimizeLegibility;\n\n  line-height: 1.4em;\n  word-spacing: 0.05em;\n\n  box-sizing: border-box;\n\n  margin: 0px;\n  padding: 0px;\n\n  color: #333;\n}\n\n/* Use progressively smaller headings */\nh1 {\n  font-size: 2em;\n}\nh2 {\n  font-size: 1.7em;\n}\nh3 {\n  font-size: 1.5em;\n}\nh4 {\n  font-size: 1.3em;\n}\n\n#left-bar, #main {\n  /* Use border box */\n  box-sizing: border-box;\n\n  /* Use 5px padding overall; a little more on the left */\n  padding: 5px;\n  padding-left: 10px;\n}\n\n#left-bar {\n  /* Use a smaller font */\n  font-size: 0.9em;\n\n  /* Extra padding to right */\n  padding-right: 10px;\n\n  /* Fix height at 100% so that we get a scrollbar */\n  max-height: 100%;\n  overflow-y: auto;\n}\n\np {\n  margin: 15px 0px;\n}\n\nh1, h2, h3, h4 {\n  margin: 5px 0px;\n}\n\n/*\n * For screen wider than 480px, fix the left bar, and set 25/75 split.\n * Also set a max width of 250px and 750px max-width respectively\n */\n"}]}