Copying/Diffing unversioned SVN files via Bash
First off, my knowledge of bash usage and syntax is very limited. Everything I've done so far as been 'hacked' together so if you see something dumb please let me know :)
I'm trying to write a nightly 'backup' script that will throw the results of svn diff
into a separate folder. My problem is that the command ignores unversioned files. I'd like the diffs to include those files OR the entire file itself.
Aside: Eclipse(pdt) accomplishes this if you right-click in the Explorer window and select Team -> Create Patch
. This might be a feature of Subclipse.
I've searched high a low for some way to force this output out of svn diff
but I'm pretty sure it's not possible.
Here's what I have so far (goal is to copy all unversioned files to my backups folder with the current date):
svn status | grep ^? | awk '{print $2}'
File1.php
File2.php
F开发者_运维问答ile3.php
This outputs a list of files with paths relative to where svn status
was invoked. I tried piping cp
to the end but ran into issues with the naming.
TLDR: I'd LIKE to append all unversioned files to the result of svn diff > backups/project.diff
so it includes versioned and unversioned changes.
Alternatively, how can I copy all unversioned files to a specific location (as I was attempting to do in the example above)?
Version infos: Ubuntu 11.04, svn 1.6.12
If I'm understanding correctly, it seems like you want xargs
. You could copy:
svn status | grep ^? | awk '{print $2}' | xargs -J % cp % backups/
Or do the append using cat
:
svn status | grep ^? | awk '{print $2}' | xargs cat >> backups/project.diff
Be careful of spaces in filenames.
精彩评论