# "svn diff" ignores newly added directories



## bkouhi (Nov 15, 2013)

Hi all.

I've added two files into a svn repository:


```
[CMD]% svn status[/CMD]
A       files
A       files/patch-src__lib__3rdparty__processinfo.h
```

files/ is a directory, the other is just a regular file. The problem is when I generate a patch file with `svn diff`, the generated patch does not contain the files/ directory and it simply ignores this newly added directory. When I try to apply the patch on another working copy, I get the following error:


```
[CMD]% patch < /root/qupwork/qupzilla.diff [/CMD]
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: files/patch-src__lib__3rdparty__processinfo.h
|===================================================================
|--- files/patch-src__lib__3rdparty__processinfo.h	(revision 0)
|+++ files/patch-src__lib__3rdparty__processinfo.h	(working copy)
--------------------------
(Creating file patch-src__lib__3rdparty__processinfo.h...)
Patching file patch-src__lib__3rdparty__processinfo.h using Plan A...
Hunk #1 succeeded at 1.
Hmm...  Ignoring the trailing garbage.
done
[CMD]% ls[/CMD]
Makefile					patch-src__lib__3rdparty__processinfo.h		pkg-descr
distinfo					patch-src__lib__3rdparty__processinfo.h.orig	pkg-plist
```

This is the actual patch file: http://codepad.org/HBxvampr

Thanks.


----------



## cpm@ (Nov 15, 2013)

Hi @bkouhi,

Probably, this might help you: http://stackoverflow.com/questions/4248768/including-new-files-in-svn-diff.


----------



## kpa (Nov 15, 2013)

I'm not sure how SVN handles files that are just added but GIT treats them as "staged" meaning they are pending for commit and not normally shown in `git diff` unless you use the form `git diff --staged` that will show the differences in pending for commit files. SVN may use a similar mechanism, maybe someone here is more familiar with SVN?


----------



## wblock@ (Nov 15, 2013)

New files and directories are not managed until they are added with `svn add`.  Or create the directories with `svn mkdir`.


----------



## bkouhi (Nov 15, 2013)

Thanks for the replies guys.

I forgot to mention that I ran `svn add` over those files. So, they should be managed by svn.


```
[CMD]% touch f1[/CMD]
[CMD]% svn status[/CMD]
?       f1
A       files
A       files/patch-src__lib__3rdparty__processinfo.h
```

f1 is not added yet, so svn shows it as "?" but the two other files are already added and svn shows them as "A". Even with those files already added, the generated patch is still unable to create the files/ directory on another working copy.


----------



## kpa (Nov 15, 2013)

Oh ok, your problem is that patch(1) will not create those directories unless you use -p0 to tell it to treat the paths as absolute. Without -p0 it will ignore the files part of the path and looks for the files in the current directory.


`patch -p0 </root/qupwork/qupzilla.diff`


----------



## cpm@ (Nov 15, 2013)

kpa said:
			
		

> Oh ok, your problem is that patch(1) will not create those directories unless you use -p0 to tell it to treat the paths as absolute. Without -p0 it will ignore the files part of the path and looks for the files in the current directory.
> 
> 
> `patch -p0 </root/qupwork/qupzilla.diff`



Good point, @kpa :e


----------

