[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

XDG Base Directory Support

From: Earnestly <zibeon_at_googlemail.com>
Date: Thu, 17 Sep 2015 23:29:54 +0100


This is a proposal for supporting the XDG Base Directory Specification[1] in

Subversion by default creates its configuration and cache data under

This can be controlled via the --config-dir option in a wrapper script or
alias. The latter of which won't work if svn is used within a script and the
former becomes deployment specific.

In order to adopt this specification (which has superseded its initial
historical intent) the following minimal changes would be needed for a

    * HOME/.subversion/config -> XDG_CONFIG_HOME/subversion/config
    * HOME/.subversion/servers -> XDG_CONFIG_HOME/subversion/servers
    * HOME/.subversion/hairstyles -> XDG_CONFIG_HOME/subversion/hairstyles

    * HOME/.subversion/auth -> XDG_DATA_HOME/subversion/auth

    [You may not need to include the auth directory itself if moved to
     XDG_DATA_HOME but this more work and can break API if users depend
     on the /auth/ section being present.]

Subversion would first look for HOME/.subversion and if it doesn't exist
fall back on the new locations.

Here the XDG_CONFIG_HOME and XDG_DATA_HOME variables are environmental and are
unlikely to be defined by the user. In fact their default position is to be
undefined. Instead fall backs are defined via the specification.

For XDG_CONFIG_HOME this is defined as HOME/.config and for XDG_DATA_HOME this
is HOME/.local/share.

I have summarised the use of XDG environment variables here:

It is important to note that the XDG_*_HOME environments should contain an
absolute path, this is similar when checking for HOME.

The key here is that installations which already have a HOME/.subversion will
continue to function normally. This procedure is usually chosen by many
projects which have since switched to the XDG Base Directory Specification[2]

    [In the above reference I have included links to various commits from
     projects which have sinced moved to basedir, they're here if developers
     would like to use them as case studies.]

An example for handling the latter half might look like this:

    [In bad C, sorry about that :-(]

    /* if HOME/.subversion does not exist then do the following: */

    const char path[4096] = {0};
    char *home = getenv("XDG_CONFIG_HOME");

    if (home && home[0] == '/')
        sprintf(path, "%s/%s", home, "subversion");

    else {
        * If HOME is not set one would fall back on getpwuid() and pw_dir as
        * usual, if this fails, POSIX defines the result to be unspecified.
        home = getenv("HOME");

        /* Here we would use "%s/.local/share/%s" for XDG_DATA_HOME */
        sprintf(path, "%s/.config/%s", home, "subversion");

    return path;

1 http://standards.freedesktop.org/basedir-spec/latest/
2 https://wiki.archlinux.org/index.php/XDG_Base_Directory_support#Supported
Received on 2015-09-18 05:21:32 CEST

This is an archived mail posted to the Subversion Dev mailing list.