Git fork
at reftables-rust 73 lines 1.6 kB view raw
1#!/bin/sh 2 3test_description='git reset in a bare repository' 4 5. ./test-lib.sh 6 7test_expect_success 'setup non-bare' ' 8 echo one >file && 9 git add file && 10 git commit -m one && 11 echo two >file && 12 git commit -a -m two 13' 14 15test_expect_success '"hard" reset requires a worktree' ' 16 (cd .git && 17 test_must_fail git reset --hard) 18' 19 20test_expect_success '"merge" reset requires a worktree' ' 21 (cd .git && 22 test_must_fail git reset --merge) 23' 24 25test_expect_success '"keep" reset requires a worktree' ' 26 (cd .git && 27 test_must_fail git reset --keep) 28' 29 30test_expect_success '"mixed" reset is ok' ' 31 (cd .git && git reset) 32' 33 34test_expect_success '"soft" reset is ok' ' 35 (cd .git && git reset --soft) 36' 37 38test_expect_success 'hard reset works with GIT_WORK_TREE' ' 39 mkdir worktree && 40 GIT_WORK_TREE=$PWD/worktree GIT_DIR=$PWD/.git git reset --hard && 41 test_cmp file worktree/file 42' 43 44test_expect_success 'setup bare' ' 45 git clone --bare . bare.git && 46 cd bare.git 47' 48 49test_expect_success '"hard" reset is not allowed in bare' ' 50 test_must_fail git reset --hard HEAD^ 51' 52 53test_expect_success '"merge" reset is not allowed in bare' ' 54 test_must_fail git reset --merge HEAD^ 55' 56 57test_expect_success '"keep" reset is not allowed in bare' ' 58 test_must_fail git reset --keep HEAD^ 59' 60 61test_expect_success '"mixed" reset is not allowed in bare' ' 62 test_must_fail git reset --mixed HEAD^ 63' 64 65test_expect_success '"soft" reset is allowed in bare' ' 66 git reset --soft HEAD^ && 67 git show --pretty=format:%s >out && 68 echo one >expect && 69 head -n 1 out >actual && 70 test_cmp expect actual 71' 72 73test_done