diff --git a/test/test-init.sh b/test/test-init.sh new file mode 100755 index 00000000..c66a34f5 --- /dev/null +++ b/test/test-init.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +. "test/testlib.sh" + +begin_test "init again" +( + set -e + + [ "git-lfs smudge %f" = "$(git config filter.lfs.smudge)" ] + [ "git-lfs clean %f" = "$(git config filter.lfs.clean)" ] + + git lfs init + + [ "git-lfs smudge %f" = "$(git config filter.lfs.smudge)" ] + [ "git-lfs clean %f" = "$(git config filter.lfs.clean)" ] +) +end_test + +begin_test "init with old settings" +( + set -e + + git config --global filter.lfs.smudge "git lfs smudge %f" + git config --global filter.lfs.clean "git lfs clean %f" + + git lfs init 2> init.log + + grep "clean filter should be" init.log + + [ "git lfs smudge %f" = "$(git config filter.lfs.smudge)" ] + [ "git lfs clean %f" = "$(git config filter.lfs.clean)" ] +) +end_test diff --git a/test/testhelpers.sh b/test/testhelpers.sh index 6fc3c935..712b3ee9 100644 --- a/test/testhelpers.sh +++ b/test/testhelpers.sh @@ -124,12 +124,16 @@ setup() { LFSTEST_URL="$LFS_URL_FILE" LFSTEST_DIR="$REMOTEDIR" lfstest-gitserver > "$REMOTEDIR/gitserver.log" 2>&1 & mkdir $HOME - git config -f "$HOME/.gitconfig" filter.lfs.required true - git config -f "$HOME/.gitconfig" filter.lfs.smudge "git lfs smudge %f" - git config -f "$HOME/.gitconfig" filter.lfs.clean "git lfs clean %f" - git config -f "$HOME/.gitconfig" credential.helper lfstest - git config -f "$HOME/.gitconfig" user.name "Git LFS Tests" - git config -f "$HOME/.gitconfig" user.email "git-lfs@example.com" + git lfs init + git config --global credential.helper lfstest + git config --global user.name "Git LFS Tests" + git config --global user.email "git-lfs@example.com" + grep "git-lfs clean" "$REMOTEDIR/home/.gitconfig" > /dev/null || { + echo "global git config should be set in $REMOTEDIR/home" + ls -al "$REMOTEDIR/home" + exit 1 + } + cp "$HOME/.gitconfig" "$HOME/.gitconfig-backup" wait_for_file "$LFS_URL_FILE" } diff --git a/test/testlib.sh b/test/testlib.sh index 993636ac..021b6d6a 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -73,6 +73,9 @@ begin_test () { err="$TRASHDIR/err" exec 1>"$out" 2>"$err" + # reset global git config + cp "$HOME/.gitconfig-backup" "$HOME/.gitconfig" + # allow the subshell to exit non-zero without exiting this process set -x +e }