git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/3] test-lib.sh: unset XDG_CONFIG_HOME

From
Jeff King <peff@peff.net>
Date
Jul 24, 2012, 12:27 UTC
Message-ID
<20120724122710.GB12066@sigill.intra.peff.net>
In-Reply-To
<vpqpq7l8iss.fsf@bauges.imag.fr>
On Tue, Jul 24, 2012 at 02:06:43PM +0200, Matthieu Moy wrote:
Show 8 quoted lines
> Thanks (for the 3 patches, all of them look good).
> 
> the "unset XDG_CONFIG_HOME" part was already discussed here:
> 
>   http://thread.gmane.org/gmane.comp.version-control.git/201609
> 
> But Michael did not continue the thread. I think your solution (unset
> $XDG_CONFIG_HOME instead of setting it to $HOME/.config/git) is better.

Yeah, setting it to $HOME/.config/git is actively wrong; I agree with the reasoning in that thread (which I did not read until just now).

> In the thread above, I also proposed checking that $XDG_CONFIG_HOME was
> taken into account, but for the "git config" part (while you test the
> attributes part).
Yeah, I see.
> I think it makes sense to add stg like this to your PATCH 3:
Agreed. And one for the exclude section, too, just for completeness.
Revised patch 3 is below.
-- >8 --
Subject: [PATCHv2 3/3] t1306: check that XDG_CONFIG_HOME works
This should override $HOME/.config, but we never actually
tested it.
---
 t/t1306-xdg-files.sh | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff --git a/t/t1306-xdg-files.sh b/t/t1306-xdg-files.sh
index 1569596..a62c3fb 100755
--- a/t/t1306-xdg-files.sh
+++ b/t/t1306-xdg-files.sh
@@ -38,6 +38,13 @@ test_expect_success 'read with --get: xdg file exists and ~/.gitconfig doesn'\''
 	test_cmp expected actual
 '
 
+test_expect_success '"$XDG_CONFIG_HOME overrides $HOME/.config/git' '
+	mkdir -p "$HOME"/xdg/git &&
+	echo "[user]name = in_xdg" >"$HOME"/xdg/git/config &&
+	echo in_xdg >expected &&
+	XDG_CONFIG_HOME="$HOME"/xdg git config --get-all user.name >actual &&
+	test_cmp expected actual
+'
 
 test_expect_success 'read with --get: xdg file exists and ~/.gitconfig exists' '
 	>.gitconfig &&
@@ -80,6 +87,17 @@ test_expect_success 'Exclusion of a file in the XDG ignore file' '
 	test_must_fail git add to_be_excluded
 '
 
+test_expect_success '$XDG_CONFIG_HOME overrides $HOME/.config/ignore' '
+	mkdir -p "$HOME"/xdg/git &&
+	echo content >excluded_by_xdg_only &&
+	echo excluded_by_xdg_only >"$HOME"/xdg/git/ignore &&
+	test_when_finished "git read-tree --empty" &&
+	(XDG_CONFIG_HOME="$HOME/xdg" &&
+	 export XDG_CONFIG_HOME &&
+	 git add to_be_excluded &&
+	 test_must_fail git add excluded_by_xdg_only
+	)
+'
 
 test_expect_success 'Exclusion in both XDG and local ignore files' '
 	echo to_be_excluded >.gitignore &&
@@ -113,6 +131,14 @@ test_expect_success 'Checking XDG attributes when HOME is unset' '
 	test_cmp expected actual
 '
 
+test_expect_success '$XDG_CONFIG_HOME overrides $HOME/.config/attributes' '
+	mkdir -p "$HOME"/xdg/git &&
+	echo "f attr_f=xdg" >"$HOME"/xdg/git/attributes &&
+	echo "f: attr_f: xdg" >expected &&
+	XDG_CONFIG_HOME="$HOME/xdg" git check-attr -a f >actual &&
+	test_cmp expected actual
+'
+
 test_expect_success 'Checking attributes in both XDG and local attributes files' '
 	echo "f -attr_f" >.gitattributes &&
 	echo "f: attr_f: unset" >expected &&
Previous: Matthieu Moy
Message 7 of 7 in “test-lib.sh: unset XDG_CONFIG_HOME”
  1. 1/3 test-lib.sh: unset XDG_CONFIG_HOMEJeff King, Jul 24, 2012
  2. 2/3 attr: make sure we have an xdg path before using itJeff King, Jul 24, 2012
  3. ignore: make sure we have an xdg path before using itMatthieu Moy, Jul 24, 2012
  4. Jeff KingJul 24, 2012
  5. 3/3 t1306: check that XDG_CONFIG_HOME worksJeff King, Jul 24, 2012
  6. Matthieu MoyJul 24, 2012
  7. Jeff KingJul 24, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.