t / t7103-reset-bare.shon commit unpack-trees.c: look ahead in the index (730f728)
   1#!/bin/sh
   2
   3test_description='git reset in a bare repository'
   4. ./test-lib.sh
   5
   6test_expect_success 'setup non-bare' '
   7        echo one >file &&
   8        git add file &&
   9        git commit -m one &&
  10        echo two >file &&
  11        git commit -a -m two
  12'
  13
  14test_expect_success 'hard reset requires a worktree' '
  15        (cd .git &&
  16         test_must_fail git reset --hard)
  17'
  18
  19test_expect_success 'merge reset requires a worktree' '
  20        (cd .git &&
  21         test_must_fail git reset --merge)
  22'
  23
  24test_expect_success 'mixed reset is ok' '
  25        (cd .git && git reset)
  26'
  27
  28test_expect_success 'soft reset is ok' '
  29        (cd .git && git reset --soft)
  30'
  31
  32test_expect_success 'setup bare' '
  33        git clone --bare . bare.git &&
  34        cd bare.git
  35'
  36
  37test_expect_success 'hard reset is not allowed in bare' '
  38        test_must_fail git reset --hard HEAD^
  39'
  40
  41test_expect_success 'merge reset is not allowed in bare' '
  42        test_must_fail git reset --merge HEAD^
  43'
  44
  45test_expect_success 'mixed reset is not allowed in bare' '
  46        test_must_fail git reset --mixed HEAD^
  47'
  48
  49test_expect_success 'soft reset is allowed in bare' '
  50        git reset --soft HEAD^ &&
  51        test "`git show --pretty=format:%s | head -n 1`" = "one"
  52'
  53
  54test_done