[PATCH] path_treatment: also ignore $GIT_DIR if it's not .git

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We always ignore anything named .git, but we should also ignore the git
directory if the user overrides it by setting $GIT_DIR

Reported-By: Ingy döt Net <ingy@xxxxxxxx>
Signed-off-by: Dennis Kaarsemaker <dennis@xxxxxxxxxxxxxxx>
---
 dir.c             | 2 +-
 t/t7508-status.sh | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/dir.c b/dir.c
index 23b6de4..884b37d 100644
--- a/dir.c
+++ b/dir.c
@@ -1198,7 +1198,7 @@ static enum path_treatment treat_path(struct dir_struct *dir,
 		return path_none;
 	strbuf_setlen(path, baselen);
 	strbuf_addstr(path, de->d_name);
-	if (simplify_away(path->buf, path->len, simplify))
+	if (simplify_away(path->buf, path->len, simplify) || is_git_directory(path->buf))
 		return path_none;
 
 	dtype = DTYPE(de);
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index c987b5e..2bd7ef1 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -198,6 +198,13 @@ test_expect_success 'status -s' '
 
 '
 
+test_expect_success 'status -s with non-standard $GIT_DIR' '
+	mv .git .foo &&
+	GIT_DIR=.foo git status -s >output &&
+	test_cmp expect output &&
+	mv .foo .git
+'
+
 test_expect_success 'status with gitignore' '
 	{
 		echo ".gitignore" &&
-- 
1.8.5-386-gb78cb96


-- 
Dennis Kaarsemaker <dennis@xxxxxxxxxxxxxxx>
http://twitter.com/seveas
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]