2341351e1be8ae966992c93981ad5c787b15944d
   1#!/bin/sh
   2
   3test_description='test log -L'
   4. ./test-lib.sh
   5
   6test_expect_success 'setup (import history)' '
   7        git fast-import < "$TEST_DIRECTORY"/t4211/history.export &&
   8        git reset --hard
   9'
  10
  11canned_test () {
  12        test_expect_success "$1" "
  13                git log $1 >actual &&
  14                test_cmp \"\$TEST_DIRECTORY\"/t4211/expect.$2 actual
  15        "
  16}
  17
  18test_bad_opts () {
  19        test_expect_success "invalid args: $1" "
  20                test_must_fail git log $1 2>errors &&
  21                grep '$2' errors
  22        "
  23}
  24
  25canned_test "-L 4,12:a.c simple" simple-f
  26canned_test "-L 4,+9:a.c simple" simple-f
  27canned_test "-L '/long f/,/^}/:a.c' simple" simple-f
  28canned_test "-L :f:a.c simple" simple-f-to-main
  29
  30canned_test "-L '/main/,/^}/:a.c' simple" simple-main
  31canned_test "-L :main:a.c simple" simple-main-to-end
  32
  33canned_test "-L 1,+4:a.c simple" beginning-of-file
  34
  35canned_test "-L 20:a.c simple" end-of-file
  36
  37canned_test "-L '/long f/',/^}/:a.c -L /main/,/^}/:a.c simple" two-ranges
  38canned_test "-L 24,+1:a.c simple" vanishes-early
  39
  40canned_test "-L '/long f/,/^}/:b.c' move-support" move-support-f
  41
  42canned_test "-L 4,12:a.c -L :main:a.c simple" multiple
  43canned_test "-L 4,18:a.c -L :main:a.c simple" multiple-overlapping
  44canned_test "-L :main:a.c -L 4,18:a.c simple" multiple-overlapping
  45canned_test "-L 4:a.c -L 8,12:a.c simple" multiple-superset
  46canned_test "-L 8,12:a.c -L 4:a.c simple" multiple-superset
  47
  48test_bad_opts "-L" "switch.*requires a value"
  49test_bad_opts "-L b.c" "argument.*not of the form"
  50test_bad_opts "-L 1:" "argument.*not of the form"
  51test_bad_opts "-L 1:nonexistent" "There is no path"
  52test_bad_opts "-L 1:simple" "There is no path"
  53test_bad_opts "-L '/foo:b.c'" "argument.*not of the form"
  54test_bad_opts "-L 1000:b.c" "has only.*lines"
  55test_bad_opts "-L 1,1000:b.c" "has only.*lines"
  56test_bad_opts "-L :b.c" "argument.*not of the form"
  57test_bad_opts "-L :foo:b.c" "no match"
  58
  59test_done