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

Directory becomes file when applying patch

From: Dmitry Pavlenko <pavlenko_at_tmatesoft.com>
Date: Mon, 16 Jul 2018 17:00:01 +0200

When I apply Git format patch that adds a directory with properties, a file is
added instead.

Here I provide a reproducing script and also add a file for comparison.

I think the origin of the problem in the fact that SVN patch doesn't keep
"node kind". But a patch in "svn diff --git" format does. Here's the example
of the patch. Notice

 a) "Property changes on: dir" and "Property changes on: file" lines;
 b) "new file mode 10644" for file and no such line for directory;

allowing to distinguish between files and directories.

I don't know whether it's a known issue or not but I think it would be nice to
infer "node kind" from that information and also (if this is not already done)
by the following logic: if patch changes "dir" and "dir/someFile", then "dir"
is probably a directory.

Index: /tmp/wc/dir
diff --git a/dir b/dir
--- a/dir (nonexistent)
+++ b/dir (working copy)

Property changes on: dir
Added: propName
## -0,0 +1 ##
\ No newline at end of property
Index: /tmp/wc/file
diff --git a/file b/file
new file mode 10644

Property changes on: file
Added: propName
## -0,0 +1 ##
\ No newline at end of property

The reproducing script:



#1. Create an empty SVN repository.


svnadmin create "$REPOSITORY_PATH"

# 2. Add a file with properties and a directory with properties to the



touch $WC_PATH/file

$SVN add $WC_PATH/file
$SVN mkdir $WC_PATH/dir

$SVN propset propName propValue $WC_PATH/file
$SVN propset propName propValue $WC_PATH/dir

# 3. Create diff between repository HEAD and working copy:



# 4. Cleanup the working copy

$SVN revert $WC_PATH/file
$SVN revert $WC_PATH/dir

rm $WC_PATH/file
rmdir $WC_PATH/dir

# 5. Apply the patch back:


# 6. Make sure that the file is file and that dir is directory

FILE_TYPE=`stat -c "%F" $WC_PATH/file`
DIRECTORY_TYPE=`stat -c "%F" $WC_PATH/dir`

if [ "$FILE_TYPE" != "regular empty file" ] ; then
  echo "================"
  echo "File is not file but $FILE_TYPE"
  echo "================"

if [ "$DIRECTORY_TYPE" != "directory" ] ; then
  echo "================"
  echo "Dir is not directory but $DIRECTORY_TYPE"
  echo "================"

Dmitry Pavlenko,
TMate Software,
http://subgit.com/ - git-svn bridge
Received on 2018-07-16 17:00:30 CEST

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

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