From fc35eccdc0e09987fd7be7a1aa7214435684ae7e Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Wed, 10 Aug 2016 22:19:02 -0400 Subject: [PATCH] Improve XDG_CONFIG_HOME tests and document the new behaviour --- doc/tig.1.adoc | 9 +++++- test/tigrc/xdg-config-home-test | 51 +++++++++++++++++---------------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/doc/tig.1.adoc b/doc/tig.1.adoc index f94f45bea..98d687931 100644 --- a/doc/tig.1.adoc +++ b/doc/tig.1.adoc @@ -222,8 +222,15 @@ TIG_NO_DISPLAY:: FILES ----- +'$XDG_CONFIG_HOME/tig/config:: +'~/.config/tig/config':: '~/.tigrc':: - User configuration file. See manpage:tigrc[5] for examples. + The Tig user configuration file is loaded in the following way. If + `$XDG_CONFIG_HOME` is set, read user configuration from + `$XDG_CONFIG_HOME/tig/config`. If `$XDG_CONFIG_HOME` is empty or + undefined, read user configuration from `~/.config/tig/config` if it + exists and fall back to `~/.tigrc` if it does not exist. See + manpage:tigrc[5] for examples. '{sysconfdir}/tigrc':: System wide configuration file. diff --git a/test/tigrc/xdg-config-home-test b/test/tigrc/xdg-config-home-test index 8b9ad3bf0..2b65c0714 100755 --- a/test/tigrc/xdg-config-home-test +++ b/test/tigrc/xdg-config-home-test @@ -2,27 +2,30 @@ . libtest.sh -tigrc < -" - -#export TIGRC_SYSTEM="should-not-be-loaded" -export XDG_CONFIG_HOME="$HOME/.config" -mkdir -p "$XDG_CONFIG_HOME/tig" - -cat > "$XDG_CONFIG_HOME/tig/config" < @sh -c 'echo ran > ~/RUNME' -EOF - -test_tig status - -assert_equals stderr <' + echo "bind generic @sh -c 'echo $name >> $HOME/$TEST_NAME.out'" > "$path" + test_tig status + assert_equals "$TEST_NAME.out" "$name" + assert_equals "$TEST_NAME.stderr" '' +} + +unset XDG_CONFIG_HOME + +check .tigrc +check .config/tig/config +check .config/tig/config XDG_CONFIG_HOME="$HOME" +check etc/tig/config XDG_CONFIG_HOME="$HOME/etc"