git/list[1] front-page[2] threads[3] people[4] search[5] about
 

strange problems applying --no-prefix patch with -p0 and added files

From
SSSergey Shelukhin <sergey@hortonworks.com>
Date
Oct 24, 2012, 20:54 UTC
Message-ID
<CAHXxaiCELHomSPQoZWw+SdV61Y0gVb9MEdRv-gCOfkJG50xCeQ@mail.gmail.com>

Hello. I am trying to apply a patch made via {git diff somehash^ somehash > ....} before (same version of Git, same machine). I have no-prefix enabled by default. If I try to apply the patch with -p0, it fails. If I go to a directory where all the changed files are ("src/" below) to "simulate" the prefix for -p1, it silently does nothing. Only if I make it a -p1 patch, it actually tries to do apply (and applies the new files that cause problems in -p0 alright too, if used with --reject).

I am relatively new to git, so while researching I realized I might be using wrong ways to do things (e.g. not using cherry-pick), but this seems like a bug regardless.

Here's the log of my interactions with git:

reznor-mbp:git-hbase-089 sergey$ git version git version 1.7.10.2 (Apple Git-33) reznor-mbp:git-hbase-089 sergey$ git status # On branch 0.94 # Untracked files: # (use "git add <file>..." to include in what will be committed) # # HBASE-6371.patch nothing added to commit but untracked files present (use "git add" to track) reznor-mbp:git-hbase-089 sergey$ git apply -p0 HBASE-6371.patch fatal: git apply: bad git-diff - inconsistent new filename on line 128 reznor-mbp:git-hbase-089 sergey$ sed -n 125,129p HBASE-6371.patch

diff --git src/main/java/org/apache/
hadoop/hbase/regionserver/CompactSelection.java
src/main/java/org/apache/hadoop/hbase/regionserver/CompactSelection.java
new file mode 100644
index 0000000..a9ee0d4
--- /dev/null
+++ src/main/java/org/apache/hadoop/hbase/regionserver/CompactSelection.java
reznor-mbp:git-hbase-089 sergey$ cd src
reznor-mbp:src sergey$ git apply -p1 -v --whitespace=nowarn ../HBASE-6371.patch
[ there's nothing here, e.g. no output ]
reznor-mbp:src sergey$ git status
# On branch 0.94
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    ../HBASE-6371.patch
nothing added to commit but untracked files present (use "git add" to track)
reznor-mbp:src sergey$ cd ..
reznor-mbp:git-hbase-089 sergey$ sed -E "s/(--git|---) src/\1 a\/src/"
HBASE-6371.patch | sed -E "s/ src\// b\/src\//" >
HBASE-6371-prefix.patch
reznor-mbp:git-hbase-089 sergey$ git apply HBASE-6371-prefix.patch
HBASE-6371-prefix.patch:169: trailing whitespace.
 ...
error: patch failed:
src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java:64
error: src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java:
patch does not apply
....
Next: Sergey Shelukhin
Message 1 of 2 in “strange problems applying --no-prefix patch with -p0 and added files”
  1. Sergey ShelukhinOct 24, 2012
  2. Sergey ShelukhinOct 26, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.