[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Failure using "svn patch" with Git patch that adds files. Wrong path is used.

From: Konstantin Kolinko <knst.kolinko_at_gmail.com>
Date: Sat, 5 Nov 2011 18:29:16 +0400

2011/11/5 Konstantin Kolinko <knst.kolinko_at_gmail.com>:
> Hi!
>
> My colleague uses Git to work on one of Apache projects. He published
> a patch, but I have problems trying to apply it cleanly with "svn
> patch".
>
> Source code:
> https://svn.apache.org/repos/asf/tomcat/trunk@1197793
> Patch:
> http://people.apache.org/~markt/patches/2011-11-03-redeploy-trunk-v2.patch
>
> The patch is in Git format, with most changes being written with the
> following header:
> [[[
> diff --git a/conf/context.xml b/conf/context.xml
> index 745bf95..d9d94af 100644
> --- a/conf/context.xml
> +++ b/conf/context.xml
> ]]]
>
> But it also contains an added file:
> [[[
> diff --git a/java/org/apache/catalina/startup/FailedContext.java
> b/java/org/apache/catalina/startup/FailedContext.java
> new file mode 100644
> index 0000000..63f6544
> --- /dev/null
> +++ b/java/org/apache/catalina/startup/FailedContext.java
> ]]]
>
> I am on WindowsXP, using svn, version 1.7.1 (r1186859) compiled Oct 21
> 2011, 22:59:27
>
> I tried the following:
> a) svn patch 2011-11-03-redeploy-trunk-v2.patch
>
> It processed the added file correctly,
> but fails to process the modified files.
> [[[
> Skipped missing target: 'b\conf\context.xml'
> ...
> ]]]

Correction: It fails to process both modified and added files.
It just skips all them:
[[[Skipped missing target: 'b\conf\context.xml'
Skipped missing target: 'b\java\org\apache\catalina\Context.java'
Skipped missing target: 'b\java\org\apache\catalina\core\ContainerBase.java'
Skipped missing target: 'b\java\org\apache\catalina\core\StandardContext.java'
Skipped missing target: 'b\java\org\apache\catalina\core\mbeans-descriptors.xml'
Skipped missing target: 'b\java\org\apache\catalina\startup\ContextConfig.java'
Skipped missing target: 'b\java\org\apache\catalina\startup\ContextRuleSet.java'
A java\org\apache\catalina\startup\FailedContext.java
Skipped missing target: '\dev\null'
Skipped missing target: 'b\java\org\apache\catalina\startup\HostConfig.java'
Skipped missing target:
'b\java\org\apache\catalina\startup\LocalStrings.properties'
Skipped missing target: 'b\java\org\apache\catalina\util\LifecycleBase.java'
Skipped missing target:
'b\java\org\apache\catalina\util\LocalStrings.properties'
Skipped missing target: 'b\webapps\docs\config\context.xml'
Skipped missing target: 'b\webapps\docs\deployer-howto.xml'
Summary of conflicts:
  Skipped paths: 14
]]]

The added FailedContext.java is empty - 0 bytes.

It is a different issue, but if an empty "FailedContext.java" is
already there and not under subversion control (a remnant from
reverting the add), all 15 files are skipped as missing.
The message is misleading as it does not say that the file is already there:
[[[
Skipped missing target: 'b\conf\context.xml'
Skipped missing target: 'b\java\org\apache\catalina\Context.java'
Skipped missing target: 'b\java\org\apache\catalina\core\ContainerBase.java'
Skipped missing target: 'b\java\org\apache\catalina\core\StandardContext.java'
Skipped missing target: 'b\java\org\apache\catalina\core\mbeans-descriptors.xml'
Skipped missing target: 'b\java\org\apache\catalina\startup\ContextConfig.java'
Skipped missing target: 'b\java\org\apache\catalina\startup\ContextRuleSet.java'
Skipped missing target: 'java\org\apache\catalina\startup\FailedContext.java'
Skipped missing target: '\dev\null'
Skipped missing target: 'b\java\org\apache\catalina\startup\HostConfig.java'
Skipped missing target:
'b\java\org\apache\catalina\startup\LocalStrings.properties'
Skipped missing target: 'b\java\org\apache\catalina\util\LifecycleBase.java'
Skipped missing target:
'b\java\org\apache\catalina\util\LocalStrings.properties'
Skipped missing target: 'b\webapps\docs\config\context.xml'
Skipped missing target: 'b\webapps\docs\deployer-howto.xml'
Summary of conflicts:
  Skipped paths: 15
]]]

Note how path to "FailedContext.java" was stripped of first component
and that "/dev/null" is used as is.

>
> b) svn patch --strip 1 2011-11-03-redeploy-trunk-v2.patch
>
> It processes the modified files correctly,
> but fails to process the added file:

[[[
U conf\context.xml
U java\org\apache\catalina\Context.java
U java\org\apache\catalina\core\ContainerBase.java
U java\org\apache\catalina\core\StandardContext.java
U java\org\apache\catalina\core\mbeans-descriptors.xml
U java\org\apache\catalina\startup\ContextConfig.java
U java\org\apache\catalina\startup\ContextRuleSet.java
A org
A org\apache
A org\apache\catalina
A org\apache\catalina\startup
A org\apache\catalina\startup\FailedContext.java
A dev
A dev\null
U java\org\apache\catalina\startup\HostConfig.java
U java\org\apache\catalina\startup\LocalStrings.properties
U java\org\apache\catalina\util\LifecycleBase.java
U java\org\apache\catalina\util\LocalStrings.properties
U webapps\docs\config\context.xml
U webapps\docs\deployer-howto.xml
]]]

> This creates the following folders in my working copy
> dev/null
>   - empty
> org/apache/catalina/startup
>   - with file "FailedContext.java"

Correction:
The folders are dev/ and org/apache/catalina/startup/

dev/null is a file with full content of FailedContext.java (21759 bytes)

org/apache/catalina/startup/FailedContext.java is empty (0 bytes)

It is an odd way to process addition of a file.
I wonder what happens if I add two files.

>
> The created folders and file are added to version control.
>
> So a workaround is to apply a) followed by b) and then revert the odd
> folders and file created by b).

Use b) and then create the added file manually.

>
> I think that the proper recipe to apply such patch is b) "svn patch --strip 1"
> (or maybe add --git option in svn 1.8, or autodetect Git patch format).
>
> I do not understand why "svn patch --strip 1" strips two components
> from the path to the added file,
> and why it creates "dev/null" in my working copy on Windows.
>
> Note that it is "/dev/null" in the patch, with proper "/" slash at the
> beginning, unlike all other paths that do not start with "/".

Best regards,
Konstantin Kolinko
Received on 2011-11-05 15:29:51 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.