Skip to content

Commit

Permalink
Merge pull request #1859 from dscho/funny-cased-cwd
Browse files Browse the repository at this point in the history
Fix t0001 when the current working directory differs in case from the canonical form
  • Loading branch information
dscho committed Oct 17, 2018
2 parents 6cbf663 + a00c26c commit d4f95fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
10 changes: 8 additions & 2 deletions t/helper/test-cmp.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@
#include "parse-options.h" #include "parse-options.h"
#include "run-command.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) static int run_diff(const char *path1, const char *path2)
{ {
const char *argv[] = { const char *argv[] = {
"diff", "--no-index", NULL, NULL, NULL "diff", "--no-index", NULL, NULL, NULL
}; };
const char *env[] = { const char *env[] = {
"GIT_PAGER=cat", "GIT_PAGER=cat",
"GIT_DIR=/dev/null", "GIT_DIR=" NO_SUCH_DIR,
"HOME=/dev/null", "HOME=" NO_SUCH_DIR,
NULL NULL
}; };


Expand Down
12 changes: 12 additions & 0 deletions t/t0001-init.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -307,10 +307,20 @@ test_expect_success 'init prefers command line to GIT_DIR' '
test_path_is_missing otherdir/refs 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' ' test_expect_success 'init with separate gitdir' '
rm -rf newdir && rm -rf newdir &&
git init --separate-git-dir realgitdir newdir && git init --separate-git-dir realgitdir newdir &&
echo "gitdir: $(pwd)/realgitdir" >expected && echo "gitdir: $(pwd)/realgitdir" >expected &&
downcase_on_case_insensitive_fs expected newdir/.git &&
test_cmp expected newdir/.git && test_cmp expected newdir/.git &&
test_path_is_dir realgitdir/refs test_path_is_dir realgitdir/refs
' '
Expand Down Expand Up @@ -365,6 +375,7 @@ test_expect_success 're-init to update git link' '
git init --separate-git-dir ../surrealgitdir git init --separate-git-dir ../surrealgitdir
) && ) &&
echo "gitdir: $(pwd)/surrealgitdir" >expected && echo "gitdir: $(pwd)/surrealgitdir" >expected &&
downcase_on_case_insensitive_fs expected newdir/.git &&
test_cmp expected newdir/.git && test_cmp expected newdir/.git &&
test_path_is_dir surrealgitdir/refs && test_path_is_dir surrealgitdir/refs &&
test_path_is_missing realgitdir/refs test_path_is_missing realgitdir/refs
Expand All @@ -378,6 +389,7 @@ test_expect_success 're-init to move gitdir' '
git init --separate-git-dir ../realgitdir git init --separate-git-dir ../realgitdir
) && ) &&
echo "gitdir: $(pwd)/realgitdir" >expected && echo "gitdir: $(pwd)/realgitdir" >expected &&
downcase_on_case_insensitive_fs expected newdir/.git &&
test_cmp expected newdir/.git && test_cmp expected newdir/.git &&
test_path_is_dir realgitdir/refs test_path_is_dir realgitdir/refs
' '
Expand Down

0 comments on commit d4f95fc

Please sign in to comment.