From 7149589c5cd0f70c1d3cf5f3096fee3f34febc3e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 2 Oct 2018 21:55:11 +0200 Subject: [PATCH 1/2] fixup! tests: replace mingw_test_cmp with a helper in C The /dev/null trick does not even work... It makes `git diff --no-index` fail because it tries to access the XDG config as `\\.\GLOBALROOT\Device\Null/.config/git/config`, which is not even a valid path (and therefore the `access_error_is_ok()` check fails). Let's just use a known-missing path on Windows. Signed-off-by: Johannes Schindelin --- t/helper/test-cmp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/t/helper/test-cmp.c b/t/helper/test-cmp.c index 98dd079152..1c646a54bf 100644 --- a/t/helper/test-cmp.c +++ b/t/helper/test-cmp.c @@ -5,6 +5,12 @@ #include "parse-options.h" #include "run-command.h" +#ifdef WIN32 +#define NO_SUCH_DIR "\\\\.\\GLOBALROOT\\invalid" +#else +#define NO_SUCH_DIR "/dev/null" +#endif + static int run_diff(const char *path1, const char *path2) { const char *argv[] = { @@ -12,8 +18,8 @@ static int run_diff(const char *path1, const char *path2) }; const char *env[] = { "GIT_PAGER=cat", - "GIT_DIR=/dev/null", - "HOME=/dev/null", + "GIT_DIR=" NO_SUCH_DIR, + "HOME=" NO_SUCH_DIR, NULL }; From a00c26c1898d5cbaa50753c821d471fbf63a0548 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 2 Oct 2018 22:05:17 +0200 Subject: [PATCH 2/2] t0001: fix on case-insensitive filesystems On a case-insensitive filesystem, such as HFS+ or NTFS, it is possible that the idea Bash has of the current directory differs in case from what Git thinks it is. That's totally okay, though, and we should not expect otherwise. Reported by Jameson Miller. Signed-off-by: Johannes Schindelin --- t/t0001-init.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 7c48ed2aba..7f19368fc1 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -307,10 +307,20 @@ test_expect_success 'init prefers command line to GIT_DIR' ' test_path_is_missing otherdir/refs ' +downcase_on_case_insensitive_fs () { + test false = "$(git config --get core.filemode)" || return 0 + for f + do + tr A-Z a-z <"$f" >"$f".downcased && + mv -f "$f".downcased "$f" || return 1 + done +} + test_expect_success 'init with separate gitdir' ' rm -rf newdir && git init --separate-git-dir realgitdir newdir && echo "gitdir: $(pwd)/realgitdir" >expected && + downcase_on_case_insensitive_fs expected newdir/.git && test_cmp expected newdir/.git && test_path_is_dir realgitdir/refs ' @@ -365,6 +375,7 @@ test_expect_success 're-init to update git link' ' git init --separate-git-dir ../surrealgitdir ) && echo "gitdir: $(pwd)/surrealgitdir" >expected && + downcase_on_case_insensitive_fs expected newdir/.git && test_cmp expected newdir/.git && test_path_is_dir surrealgitdir/refs && test_path_is_missing realgitdir/refs @@ -378,6 +389,7 @@ test_expect_success 're-init to move gitdir' ' git init --separate-git-dir ../realgitdir ) && echo "gitdir: $(pwd)/realgitdir" >expected && + downcase_on_case_insensitive_fs expected newdir/.git && test_cmp expected newdir/.git && test_path_is_dir realgitdir/refs '