threads / discuss / 31934

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

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

## tl;dr

2 messages between Oct 24, 2012 and Oct 26, 2012.

replies: 1people: 1as markdown or json

Sergey Shelukhin· Oct 24, 2012, 20:54 UTC · lore

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
....
Sergey Shelukhin· Oct 26, 2012, 22:14 UTC · re: Sergey Shelukhin · lore

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

Hi. Any pointers? Is there some bug tracking system to file a bug to? Thanks.

On Wed, Oct 24, 2012 at 1:54 PM, Sergey Shelukhin <sergey@hortonworks.com> wrote:

Show 58 quoted lines
> 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
> ....

← back to recent threads