git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: git@vger.kernel.org, gitster@pobox.com
Cc: peff@peff.net, Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [PATCH] ignore: make sure we have an xdg path before using it
Date: Tue, 24 Jul 2012 14:26:51 +0200	[thread overview]
Message-ID: <1343132811-2296-1-git-send-email-Matthieu.Moy@imag.fr> (raw)
In-Reply-To: <20120724115357.GA7353@sigill.intra.peff.net>

Commit e3ebc35 (config: fix several access(NULL) calls, 2012-07-12) was
fixing access(NULL) calls when trying to access $HOME/.config/git/config,
but missed the ones when trying to access $HOME/.config/git/ignore. Fix
and test this.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
This can be appended to Jeff's serie. I thought if we had 3 bug
instances and already fixed 2, why not fix the (hopefully last)
one ;-).

 dir.c                | 2 +-
 t/t1306-xdg-files.sh | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/dir.c b/dir.c
index a772c6d..240bf0c 100644
--- a/dir.c
+++ b/dir.c
@@ -1313,7 +1313,7 @@ void setup_standard_excludes(struct dir_struct *dir)
 	}
 	if (!access(path, R_OK))
 		add_excludes_from_file(dir, path);
-	if (!access(excludes_file, R_OK))
+	if (excludes_file && !access(excludes_file, R_OK))
 		add_excludes_from_file(dir, excludes_file);
 }
 
diff --git a/t/t1306-xdg-files.sh b/t/t1306-xdg-files.sh
index 097184b..6d9e8cd 100755
--- a/t/t1306-xdg-files.sh
+++ b/t/t1306-xdg-files.sh
@@ -108,6 +108,13 @@ test_expect_success 'Exclusion in a non-XDG global ignore file' '
 	test_must_fail git add to_be_excluded
 '
 
+test_expect_success 'Checking XDG ignore file when HOME is unset' '
+	>expected &&
+	(sane_unset HOME &&
+	 git config --unset core.excludesfile &&
+	 git ls-files --exclude-standard --ignored >actual) &&
+	test_cmp expected actual
+'
 
 test_expect_success 'Checking attributes in the XDG attributes file' '
 	echo foo >f &&
-- 
1.7.11.2.402.g04c525e.dirty

  reply	other threads:[~2012-07-24 12:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-24 11:53 [PATCH 1/3] test-lib.sh: unset XDG_CONFIG_HOME Jeff King
2012-07-24 11:53 ` [PATCH 2/3] attr: make sure we have an xdg path before using it Jeff King
2012-07-24 12:26   ` Matthieu Moy [this message]
2012-07-24 13:32     ` [PATCH] ignore: " Jeff King
2012-07-24 11:54 ` [PATCH 3/3] t1306: check that XDG_CONFIG_HOME works Jeff King
2012-07-24 12:06 ` [PATCH 1/3] test-lib.sh: unset XDG_CONFIG_HOME Matthieu Moy
2012-07-24 12:27   ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343132811-2296-1-git-send-email-Matthieu.Moy@imag.fr \
    --to=matthieu.moy@imag.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).