diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG
index 009b49b100a299d99cea1b578bceddb462492f5d..7569b6a1ca7ed1566a419f2dc34ccd454d66ea42 100644
--- a/smartmontools/CHANGELOG
+++ b/smartmontools/CHANGELOG
@@ -43,6 +43,9 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [CF] do_release: Add support to release from a dir below 'branches'.
+       Accept partial checkouts.
+
 smartmontools 5.39 2009-12-09
 
   [CF] do_release: Commit CHANGELOG and NEWS also. Allow to review changes.
diff --git a/smartmontools/do_release b/smartmontools/do_release
index 73e3dd2f9c85bcab0447e9816fbf6ceebdfca6bf..3070bfef55f4418db2808a1a834a43cb030c24c3 100755
--- a/smartmontools/do_release
+++ b/smartmontools/do_release
@@ -43,25 +43,26 @@ esac
 
 # Check workdir
 case "`/bin/pwd`" in
-  */trunk/smartmontools) ;;
-  *) echo "not run from trunk checkout"; exit 1 ;;
+  */trunk/smartmontools)      WDROOT="../..";    DIRPAT="trunk"      ;;
+  */branches/*/smartmontools) WDROOT="../../.."; DIRPAT="branches/*" ;;
+  *) echo "`/bin/pwd`: no trunk or branch working dir"; exit 1 ;;
 esac
 
-if [ ! -d ../../tags ]; then
+if [ ! -d "$WDROOT/tags" ]; then
   echo "tags directory missing"; exit 1
 fi
 
-REV=`(cd ../.. && svnversion)` || exit 1
-if [ -z "`echo "$REV" | sed -n '/^[0-9][0-9]*M\?$/p'`" ]; then
-  echo "Working directory not clean: $REV"; exit 1
+REVX="`(cd $WDROOT && svnversion)`" || exit 1
+REV="${REVX/%[PM]/}"; REV="${REV/%[PM]/}"
+if [ -n "${REV//[0-9]/}" ]; then
+  echo "Working directory not clean: $REVX"; exit 1
 fi
-REV="${REV%M}"
 
-(cd ../.. && svn status) | while read s; do
+(cd $WDROOT && svn status) | while read s; do
   case "$s" in
-    "M       trunk/smartmontools/CHANGELOG")    echo "$s: OK";;
-    "M       trunk/smartmontools/NEWS")         echo "$s: OK";;
-    "M       trunk/smartmontools/configure.in") echo "$s: OK";;
+    "M       "$DIRPAT/smartmontools/CHANGELOG)    echo "$s: OK";;
+    "M       "$DIRPAT/smartmontools/NEWS)         echo "$s: OK";;
+    "M       "$DIRPAT/smartmontools/configure.in) echo "$s: OK";;
     *) echo "$s: not allowed"; exit 1;;
   esac
 done
@@ -82,7 +83,7 @@ if [ "$RC" ]; then
   RELEASE="${RELEASE}_${RC}"
 fi
 
-if [ -e "../../tags/$RELEASE" ]; then
+if [ -e "$WDROOT/tags/$RELEASE" ]; then
   echo "tags/$RELEASE exists"; exit 1
 fi
 
@@ -103,13 +104,11 @@ sleep 20
 set -v
 
 # Create tag and commit
-cd ../..
 if [ "$COMMIT" = "yes" ]; then
-  svn mkdir tags/$RELEASE
-  svn copy trunk/smartmontools tags/$RELEASE/smartmontools
-  svn commit -m "Release $VERSIONRC $RELEASE"
+  svn mkdir $WDROOT/tags/$RELEASE
+  svn copy ../smartmontools $WDROOT/tags/$RELEASE/smartmontools
+  svn commit -m "Release $VERSIONRC $RELEASE" $WDROOT
 fi
-cd trunk/smartmontools
 
 # Build
 ./autogen.sh
@@ -130,7 +129,7 @@ md5sum $TARFILE > $TARFILE.md5
 sha1sum $TARFILE > $TARFILE.sha1
 
 # Increase release number
-if [ -z "$RC" ]; then
+if [ -z "$RC" -a "$DIRPAT" = "trunk" ]; then
   inc_release
   if [ "$COMMIT" = "yes" ]; then
     perl -p -i.bak -e "s/$PERL_OLD/$PERL_NEW/" configure.in