627890d7d895618b8c0d9ff8d66a3265e9e2fdad
   1#!/bin/sh
   2
   3test_description='magic pathspec tests using git-log'
   4
   5. ./test-lib.sh
   6
   7test_expect_success 'setup' '
   8        test_commit initial &&
   9        test_tick &&
  10        git commit --allow-empty -m empty &&
  11        mkdir sub
  12'
  13
  14test_expect_success '"git log :/" should not be ambiguous' '
  15        git log :/
  16'
  17
  18test_expect_success '"git log :/a" should be ambiguous (applied both rev and worktree)' '
  19        : >a &&
  20        test_must_fail git log :/a 2>error &&
  21        test_i18ngrep ambiguous error
  22'
  23
  24test_expect_success '"git log :/a -- " should not be ambiguous' '
  25        git log :/a --
  26'
  27
  28test_expect_success '"git log -- :/a" should not be ambiguous' '
  29        git log -- :/a
  30'
  31
  32# This differs from the ":/a" check above in that :/in looks like a pathspec,
  33# but doesn't match an actual file.
  34test_expect_success '"git log :/in" should not be ambiguous' '
  35        git log :/in
  36'
  37
  38test_expect_success '"git log :" should be ambiguous' '
  39        test_must_fail git log : 2>error &&
  40        test_i18ngrep ambiguous error
  41'
  42
  43test_expect_success 'git log -- :' '
  44        git log -- :
  45'
  46
  47test_expect_success 'git log HEAD -- :/' '
  48        cat >expected <<-EOF &&
  49        24b24cf initial
  50        EOF
  51        (cd sub && git log --oneline HEAD -- :/ >../actual) &&
  52        test_cmp expected actual
  53'
  54
  55test_expect_success '"git log :^sub" is not ambiguous' '
  56        git log :^sub
  57'
  58
  59test_expect_success '"git log :^does-not-exist" does not match anything' '
  60        test_must_fail git log :^does-not-exist
  61'
  62
  63test_expect_success  '"git log :!" behaves the same as :^' '
  64        git log :!sub &&
  65        test_must_fail git log :!does-not-exist
  66'
  67
  68test_expect_success 'command line pathspec parsing for "git log"' '
  69        git reset --hard &&
  70        >a &&
  71        git add a &&
  72        git commit -m "add an empty a" --allow-empty &&
  73        echo 1 >a &&
  74        git commit -a -m "update a to 1" &&
  75        git checkout HEAD^ &&
  76        echo 2 >a &&
  77        git commit -a -m "update a to 2" &&
  78        test_must_fail git merge master &&
  79        git add a &&
  80        git log --merge -- a
  81'
  82
  83test_done