Subversion pre-commit hook

Posted on 2006-05-02
Last Modified: 2013-12-16
Hi I use TortoiseSVN on Windows and have a running SVN Server without apache just the svn daemon.

I need a pre-commit hook that forces users to make a log entry.
The example file of the pre-commit hook contains code for this but it doesn't work.
When I use the example file for real I cannot commit with or withour log message.

Furthermore I don't get the stdErr that should be passed to the Client.
It just says that the commit has failed but without giving the reason that is printed to stdErr.

Here is the code I'm using right now and which doesn't work in any way.


# Make sure that the log message contains some text.
$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" > /dev/null || exit 1

# Check that the author of this commit has the rights to perform
# the commit on the files and directories being modified. "$REPOS" "$TXN" commit-access-control.cfg || exit 1

# All checks passed, so allow the commit.
exit 0

I need a hook script that
a) works
b) passes the stdErr to the client so that the User knows why the commit has failed.
Question by:michi3012

    Author Comment

    Btw. I know that Tortoise offers me to configure an option to prevent the user to commit without a log message.
    But I also use AnkhSVN as the Visual Studio Plugin and I wasn't able to find an option for Ankh to behave.....
    Maybe there is a possibility in the config file but I couldn't figure it out.
    LVL 15

    Accepted Solution

    I'd start with:

    1. Verifying that /usr/bin/svnlook is there
    2. Verifying that is there
    3. replacing one "exit 1" with "exit 0"  at a time in these two checks and finding out which one actually fails

    To echo something to a stderr from this script use

    echo "Comment required" >&2


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now