Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I check if a file/folder is already committed to svn ? I have a shell script where I want to ensure that the file/folder selected by user for check-in isn't already committed. For eg if I try to check-in a folder that's already committed using

svn add myfolder

I get the following warning:

svn: warning: 'myfolder' is already under version control

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Use the return code of svn info. It's 0 if under version control, non-zero otherwise.

My shell displays non-zero return codes after a command, so it looks like this:

$ svn info trunk
Path: trunk
URL: https://(...)/trunk
Repository Root: https://(...)
Repository UUID: 651713a4-5a46-7e42-a99e-f31e79777eab
Revision: 213
Node Kind: directory
(...)

$ touch foo
$ svn info foo 
foo:  (Not a versioned resource)

svn: A problem occurred; see other errors for details

rc: 1

How you'd do it in a bash script (similar in other shells), with suppressing info output:

svn info <filename> 1>/dev/null 2>&1
echo $?
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.