#!/bin/sh global test_description := ''test log -L'' source ./test-lib.sh test_expect_success 'setup (import history)' ' git fast-import < "$TEST_DIRECTORY"/t4211/history.export && git reset --hard ' proc canned_test_1 { test_expect_$1 $2 " git log $2 >actual && test_cmp \"\$TEST_DIRECTORY\"/t4211/expect.$3 actual " } proc canned_test { canned_test_1 success @Argv } proc canned_test_failure { canned_test_1 failure @Argv } proc test_bad_opts { test_expect_success "invalid args: $1" " test_must_fail git log $1 2>errors && grep '$2' errors " } canned_test "-L 4,12:a.c simple" simple-f canned_test "-L 4,+9:a.c simple" simple-f canned_test "-L '/long f/,/^}/:a.c' simple" simple-f canned_test "-L :f:a.c simple" simple-f-to-main canned_test "-L '/main/,/^}/:a.c' simple" simple-main canned_test "-L :main:a.c simple" simple-main-to-end canned_test "-L 1,+4:a.c simple" beginning-of-file canned_test "-L 20:a.c simple" end-of-file canned_test "-L '/long f/',/^}/:a.c -L /main/,/^}/:a.c simple" two-ranges canned_test "-L 24,+1:a.c simple" vanishes-early canned_test "-M -L '/long f/,/^}/:b.c' move-support" move-support-f canned_test "-M -L ':f:b.c' parallel-change" parallel-change-f-to-main canned_test "-L 4,12:a.c -L :main:a.c simple" multiple canned_test "-L 4,18:a.c -L ^:main:a.c simple" multiple-overlapping canned_test "-L :main:a.c -L 4,18:a.c simple" multiple-overlapping canned_test "-L 4:a.c -L 8,12:a.c simple" multiple-superset canned_test "-L 8,12:a.c -L 4:a.c simple" multiple-superset test_bad_opts "-L" "switch.*requires a value" test_bad_opts "-L b.c" "argument not .start,end:file" test_bad_opts "-L 1:" "argument not .start,end:file" test_bad_opts "-L 1:nonexistent" "There is no path" test_bad_opts "-L 1:simple" "There is no path" test_bad_opts "-L '/foo:b.c'" "argument not .start,end:file" test_bad_opts "-L 1000:b.c" "has only.*lines" test_bad_opts "-L 1,1000:b.c" "has only.*lines" test_bad_opts "-L :b.c" "argument not .start,end:file" test_bad_opts "-L :foo:b.c" "no match" test_expect_success '-L X (X == nlines)' ' n=$(wc -l output && test ! -s output && test_line_count = 70 log ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"test log -L">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <"setup (import history)">)} { (SQ <"\n"> <"\tgit fast-import < \"$TEST_DIRECTORY\"/t4211/history.export &&\n"> <"\tgit reset --hard\n"> ) } ) (FuncDef name: canned_test_1 body: (BraceGroup children: [ (C {(test_expect_) ($ VSub_Number "$1")} {(DQ ($ VSub_Number "$2"))} { (DQ ("\n") ("\t\tgit log ") ($ VSub_Number "$2") (" >actual &&\n") ("\t\ttest_cmp ") (EscapedLiteralPart token:) (EscapedLiteralPart token:) (TEST_DIRECTORY) (EscapedLiteralPart token:) (/t4211/expect.) ($ VSub_Number "$3") (" actual\n") ("\t") ) } ) ] spids: [32] ) spids: [27 31] ) (FuncDef name: canned_test body: (BraceGroup children: [(C {(canned_test_1)} {(success)} {(DQ ($ VSub_At "$@"))})] spids: [66] ) spids: [61 65] ) (FuncDef name: canned_test_failure body: (BraceGroup children: [(C {(canned_test_1)} {(failure)} {(DQ ($ VSub_At "$@"))})] spids: [84] ) spids: [79 83] ) (FuncDef name: test_bad_opts body: (BraceGroup children: [ (C {(test_expect_success)} {(DQ ("invalid args: ") ($ VSub_Number "$1"))} { (DQ ("\n") ("\t\ttest_must_fail git log ") ($ VSub_Number "$1") (" 2>errors &&\n") ("\t\tgrep '") ($ VSub_Number "$2") ("' errors\n") ("\t") ) } ) ] spids: [103] ) spids: [98 102] ) (C {(canned_test)} {(DQ ("-L 4,12:a.c simple"))} {(simple-f)}) (C {(canned_test)} {(DQ ("-L 4,+9:a.c simple"))} {(simple-f)}) (C {(canned_test)} {(DQ ("-L '/long f/,/^}/:a.c' simple"))} {(simple-f)}) (C {(canned_test)} {(DQ ("-L :f:a.c simple"))} {(simple-f-to-main)}) (C {(canned_test)} {(DQ ("-L '/main/,/^}/:a.c' simple"))} {(simple-main)}) (C {(canned_test)} {(DQ ("-L :main:a.c simple"))} {(simple-main-to-end)}) (C {(canned_test)} {(DQ ("-L 1,+4:a.c simple"))} {(beginning-of-file)}) (C {(canned_test)} {(DQ ("-L 20:a.c simple"))} {(end-of-file)}) (C {(canned_test)} {(DQ ("-L '/long f/',/^}/:a.c -L /main/,/^}/:a.c simple"))} {(two-ranges)}) (C {(canned_test)} {(DQ ("-L 24,+1:a.c simple"))} {(vanishes-early)}) (C {(canned_test)} {(DQ ("-M -L '/long f/,/^}/:b.c' move-support"))} {(move-support-f)}) (C {(canned_test)} {(DQ ("-M -L ':f:b.c' parallel-change"))} {(parallel-change-f-to-main)}) (C {(canned_test)} {(DQ ("-L 4,12:a.c -L :main:a.c simple"))} {(multiple)}) (C {(canned_test)} {(DQ ("-L 4,18:a.c -L ^:main:a.c simple"))} {(multiple-overlapping)}) (C {(canned_test)} {(DQ ("-L :main:a.c -L 4,18:a.c simple"))} {(multiple-overlapping)}) (C {(canned_test)} {(DQ ("-L 4:a.c -L 8,12:a.c simple"))} {(multiple-superset)}) (C {(canned_test)} {(DQ ("-L 8,12:a.c -L 4:a.c simple"))} {(multiple-superset)}) (C {(test_bad_opts)} {(DQ (-L))} {(DQ ("switch.*requires a value"))}) (C {(test_bad_opts)} {(DQ ("-L b.c"))} {(DQ ("argument not .start,end:file"))}) (C {(test_bad_opts)} {(DQ ("-L 1:"))} {(DQ ("argument not .start,end:file"))}) (C {(test_bad_opts)} {(DQ ("-L 1:nonexistent"))} {(DQ ("There is no path"))}) (C {(test_bad_opts)} {(DQ ("-L 1:simple"))} {(DQ ("There is no path"))}) (C {(test_bad_opts)} {(DQ ("-L '/foo:b.c'"))} {(DQ ("argument not .start,end:file"))}) (C {(test_bad_opts)} {(DQ ("-L 1000:b.c"))} {(DQ ("has only.*lines"))}) (C {(test_bad_opts)} {(DQ ("-L 1,1000:b.c"))} {(DQ ("has only.*lines"))}) (C {(test_bad_opts)} {(DQ ("-L :b.c"))} {(DQ ("argument not .start,end:file"))}) (C {(test_bad_opts)} {(DQ ("-L :foo:b.c"))} {(DQ ("no match"))}) (C {(test_expect_success)} {(SQ <"-L X (X == nlines)">)} {(SQ <"\n"> <"\tn=$(wc -l <"\tgit log -L $n:b.c\n">)} ) (C {(test_expect_success)} {(SQ <"-L X (X == nlines + 1)">)} {(SQ <"\n"> <"\tn=$(expr $(wc -l <"\ttest_must_fail git log -L $n:b.c\n">)} ) (C {(test_expect_success)} {(SQ <"-L X (X == nlines + 2)">)} {(SQ <"\n"> <"\tn=$(expr $(wc -l <"\ttest_must_fail git log -L $n:b.c\n">)} ) (C {(test_expect_success)} {(SQ <"-L ,Y (Y == nlines)">)} {(SQ <"\n"> <"\tn=$(printf \"%d\" $(wc -l <"\tgit log -L ,$n:b.c\n">)} ) (C {(test_expect_success)} {(SQ <"-L ,Y (Y == nlines + 1)">)} {(SQ <"\n"> <"\tn=$(expr $(wc -l <"\ttest_must_fail git log -L ,$n:b.c\n">)} ) (C {(test_expect_success)} {(SQ <"-L ,Y (Y == nlines + 2)">)} {(SQ <"\n"> <"\tn=$(expr $(wc -l <"\ttest_must_fail git log -L ,$n:b.c\n">)} ) (C {(test_expect_success)} {(SQ <"-L with --first-parent and a merge">)} {(SQ <"\n"> <"\tgit checkout parallel-change &&\n"> <"\tgit log --first-parent -L 1,1:b.c\n">)} ) (C {(test_expect_success)} {(SQ <"-L with --output">)} { (SQ <"\n"> <"\tgit checkout parallel-change &&\n"> <"\tgit log --output=log -L :main:b.c >output &&\n"> <"\ttest ! -s output &&\n"> <"\ttest_line_count = 70 log\n"> ) } ) (C {(test_done)}) ] )