How to check if a directory is under svn version control?
7,300
Solution 1
Store the return code from the svn
command in a variable and test that-:
pushd $PWD
svn info
ERR=$?
popd
if [ $ERR -ne 0 ];then
echo "Directory ${WD} not under version control"
fi
Solution 2
Subversion uses a hidden directory called .svn
(just like .git
for Git).
First, a directory not under SVN control:
riemann$ if [ ! -d ".svn" ]; then echo "Directory not under version control"; fi;
Directory not under version control
riemann$
Next, a directory which is under SVN control (Crypto++ use SVN):
riemann::cryptopp$ if [ ! -d ".svn" ]; then echo "Directory not under version control"; fi;
riemann::cryptopp$
And:
riemann::cryptopp$ ls -al .*
-rw-r--r--@ 1 jwalton staff 6148 Jul 20 06:46 .DS_Store
.:
total 440904
drwx------ 462 jwalton staff 15708 Aug 10 16:00 .
drwx------ 59 jwalton staff 2006 Aug 10 15:50 ..
drwx------ 7 jwalton staff 238 Jul 17 07:41 .svn
...
Related videos on Youtube
Author by
Alex
Updated on September 18, 2022Comments
-
Alex almost 2 years
From a linux bash script, how can I verify if some directory is under svn version control? I am using svn version 1.7.9.
When I try the following
pushd ${WD}; svn info; popd
and check the error code I always get a zero, because
popd
succeeded, even ifsvn info
returned an error. How to perform a check on a directory in the following way?if [ ... ]; then echo "Directory ${WD} not under version control" fi
-
Alex almost 10 yearsI have updated the question as your suggestion does not work; I do not have a
.svn
directory. Maybe its depending on the version? -
Ben almost 10 yearsSubdirectories in SVN 1.6.x and earlier all had a .svn and could be used like a full working copy on their own. In 1.7 and higher, only the working copy root has such a directory.