git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v9a 3/5] Implement line-history search (git log -L)

From
Antoine Pelisse <apelisse@gmail.com>
Date
Mar 23, 2013, 10:31 UTC
Message-ID
<CALWbr2xW1SsNXq0wCh9jd_qGVrACLuQT-UETcG+zoxw9xjKSHw@mail.gmail.com>
In-Reply-To
<b8cabd5ca63a17577fca524891046e5a3d3dfc60.1364020899.git.trast@student.ethz.ch>
Show 44 quoted lines
> diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh
> new file mode 100755
> index 0000000..286390d
> --- /dev/null
> +++ b/t/t4211-line-log.sh
> @@ -0,0 +1,38 @@
> +#!/bin/sh
> +
> +test_description='test log -L'
> +. ./test-lib.sh
> +
> +test_expect_success 'setup (import history)' '
> +       git fast-import < "$TEST_DIRECTORY"/t4211/history.export &&
> +       git reset --hard
> +'
> +
> +canned_test () {
> +       test_expect_success "$1" "
> +               git log $1 >actual &&
> +               test_cmp \"\$TEST_DIRECTORY\"/t4211/expect.$2 actual
> +       "
> +}
> +
> +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 '/main/,/^}/:a.c' simple" simple-main
> +
> +canned_test "-L 1,+4:a.c simple" beginning-of-file
> +
> +canned_test "-L 20:a.c simple" end-of-file
> +
> +test_expect_success "-L 20,10000:a.c (bogus end)" '
> +       test_must_fail git log -L 20,10000:a.c simple 2>errors &&
> +       grep "has only.*lines" errors
> +'
> +
> +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 "-L '/long f/,/^}/:b.c' move-support" move-support-f
> +
> +test_done
Hi Thomas,

You should probably add some failing tests (for example when the input parameters are not correct), and as a matter of fact, I have the following segfault with v9:

Starting program: /home/antoine/code/git/git-log -M -L :git.c [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x000000000050164d in parse_range_funcname (arg=0x84f2d0 ":git.c",
    nth_line_cb=0, cb_data=0x0, lines=0, begin=0x0, end=0x0, path=0x0)
    at line-range.c:160
#2  0x0000000000501d28 in skip_range_arg (arg=0x84f2d0 ":git.c")
    at line-range.c:229
#3  0x00000000004fda78 in parse_lines (commit=0x86ea60, prefix=0x0,
    args=0x7fad48) at line-log.c:544
#4  0x00000000004fd75a in line_log_init (rev=0x7fffffffd9a8, prefix=0x0,
    args=0x7fad48) at line-log.c:701
#5  0x0000000000457189 in cmd_log_init_finish (argc=1, argv=0x7fffffffe238,
    prefix=0x0, rev=0x7fffffffd9a8, opt=0x7fffffffd988) at builtin/log.c:192
#6  0x0000000000455d2c in cmd_log_init (argc=4, argv=0x7fffffffe238,
    prefix=0x0, rev=0x7fffffffd9a8, opt=0x7fffffffd988) at builtin/log.c:201
#7  0x0000000000457250 in cmd_log (argc=4, argv=0x7fffffffe238, prefix=0x0)
    at builtin/log.c:612
#8  0x00000000004056cf in run_builtin (p=0x7f7af8, argc=4,
    argv=0x7fffffffe238) at git.c:281
#9  0x00000000004047aa in handle_internal_command (argc=4,
    argv=0x7fffffffe238) at git.c:443
#10 0x0000000000404506 in main (argc=4, argv=0x7fffffffe238) at git.c:532
Previous: Thomas RastNext: Antoine Pelisse
Message 5 of 8 in “git log -L”
  1. 0/5 git log -LThomas Rast, Mar 23, 2013
  2. 1/5 Refactor parse_locThomas Rast, Mar 23, 2013
  3. 2/5 Export rewrite_parents() for 'log -L'Thomas Rast, Mar 23, 2013
  4. 3/5 Implement line-history search (git log -L)Thomas Rast, Mar 23, 2013
  5. Antoine PelisseMar 23, 2013
  6. Antoine PelisseMar 23, 2013
  7. 4/5 log -L: :pattern:file syntax to find by funcnameThomas Rast, Mar 23, 2013
  8. 5/5 Speed up log -L... -MThomas Rast, Mar 23, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.