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

Re: [PATCH 09/10] t4213: test --function-name option

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 28, 2014, 08:21 UTC
Message-ID
<CAPig+cSp0iJZjUAUSKyjVvYe=xR5h4c7OHQdSK0Op8vUD_mnhQ@mail.gmail.com>
In-Reply-To
<533523F9.2000108@viscovery.net>
On Fri, Mar 28, 2014 at 3:25 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 43 quoted lines
> Am 3/27/2014 19:50, schrieb David A. Dalrymple (and Bhushan G. Lodha):
>> From: "Bhushan G. Lodha & David A. Dalrymple" <dad-bgl@mit.edu>
>>
>> This test builds a sample C file, adding and removing functions, and
>> checks that the right commits are filtered by --function-name matching.
>
> This is probably the most important patch in your series as it documents
> the expected behavior. Unfortunately, I find its clarity very lacking. :(
>
> This new feature uses the userdiff driver, IIUC. Does it do so in all
> respects? In particular, does it also evaluate the negative patterns? For
> example, when there is a label in the code, is it not mistaken as the
> beginning of a function? A test for this case would be very instructive.
>
> Furthermore, consider a patch for a change at the very beginning of a
> function. Then the function name would appear in the pre-context of the
> hunk, but the hunk header would show the function before the one with the
> change. Would such a change confuse your implementation? I guess not.
> Again, a test case would remove any doubts.
>
> Is it possible to search for a change that is before any functions? It
> would be useful to enumerate commits that change #include lines.
>
>>
>> Signed-off-by: David Dalrymple (on zayin) <davidad@alum.mit.edu>
>> ---
>>  t/t4213-log-function-name.sh | 73 ++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 73 insertions(+)
>>  create mode 100755 t/t4213-log-function-name.sh
>>
>> diff --git a/t/t4213-log-function-name.sh b/t/t4213-log-function-name.sh
>> new file mode 100755
>> index 0000000..1243ce5
>> --- /dev/null
>> +++ b/t/t4213-log-function-name.sh
>> @@ -0,0 +1,73 @@
>> +#!/bin/sh
>> +
>> +test_description='log --function-name'
>> +. ./test-lib.sh
>> +
>> +test_expect_success setup '
>> +     echo "* diff=cpp" > .gitattributes
Broken &&-chain here, as well.
Show 90 quoted lines
>> +
>> +     >file &&
>> +     git add file &&
>> +     test_tick &&
>> +     git commit -m initial &&
>> +
>> +     printf "int main(){\n\treturn 0;\n}\n" >> file &&
>> +     test_tick &&
>> +     git commit -am second
>
> Broken && chain here and later as well. Please be careful.
>
>> +
>> +     printf "void newfunc(){\n\treturn;\n}\n" >> file &&
>> +     test_tick &&
>> +     git commit -am third
>
>         git commit -am "append a function" &&
>
>> +
>> +     printf "void newfunc2(){\n\treturn;\n}\n" | cat - file > temp &&
>> +     mv temp file &&
>> +     test_tick &&
>> +     git commit -am fourth
>
>         git commit -am "prepend a function" &&
>
> etc. You get the picture.
>
>> +
>> +     printf "void newfunc3(){\n\treturn;\n}\n" | cat - file > temp &&
>> +     mv temp file &&
>> +     test_tick &&
>> +     git commit -am fifth
>> +
>> +     sed -i -e "s/void newfunc2/void newfunc4/" file &&
>> +     test_tick &&
>> +     git commit -am sixth
>> +'
>> +
>> +test_expect_success 'log --function-name=main' '
>
> test_expect_success 'log --function-name finds a function with a change' '
>
>> +     git log --function-name=main >actual &&
>> +     git log --grep=second >expect &&
>> +     test_cmp expect actual
>> +'
>> +
>> +test_expect_success 'log --function-name "newfunc\W"' '
>
> test_expect_success 'log --function-name with extended regexp' '
>
> etc. You get the picture.
>
>> +     git log --function-name "newfunc\W" >actual &&
>> +     git log --grep=third >expect &&
>> +     test_cmp expect actual
>> +'
>> +
>> +test_expect_success 'log --function-name "newfunc2"' '
>> +     git log --function-name newfunc2 >actual &&
>> +     git log -E --grep "sixth|fourth" >expect &&
>> +     test_cmp expect actual
>> +'
>> +
>> +test_expect_success 'log --function-name "newfunc3"' '
>> +     git log --function-name newfunc3 >actual &&
>> +     git log --grep=fifth >expect &&
>> +     test_cmp expect actual
>> +'
>> +
>> +test_expect_success 'log --function-name "newfunc4"' '
>> +     git log --function-name newfunc4 >actual &&
>> +     git log --grep=sixth >expect &&
>> +     test_cmp expect actual
>> +'
>> +
>> +test_expect_success 'log --function-name "newfunc"' '
>> +     git log --function-name newfunc >actual &&
>> +     git log -E --grep "third|fourth|fifth|sixth" >expect &&
>> +     test_cmp expect actual
>> +'
>> +
>> +test_done
>>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Johannes SixtNext: Johannes Sixt
Message 18 of 23 in “[RFC] pickaxe for function names”
  1. 00/10 [RFC] pickaxe for function namesDavid A. Dalrymple (and Bhushan G. Lodha), Mar 27, 2014
  2. 01/10 .gitattributes: specify the language usedDavid A. Dalrymple (and Bhushan G. Lodha), Mar 27, 2014
  3. 02/10 diffcore-pickaxe.c: refactor regex compilationDavid A. Dalrymple (and Bhushan G. Lodha), Mar 27, 2014
  4. 03/10 diffcore-pickaxe.c: Refactor pickaxe_fn signatureDavid A. Dalrymple (and Bhushan G. Lodha), Mar 27, 2014
  5. Jakub NarębskiApr 4, 2014
  6. 04/10 diff.c/diff.h: expose userdiff_funcnameDavid A. Dalrymple (and Bhushan G. Lodha), Mar 27, 2014
  7. 05/10 diffcore-pickaxe.c: set up funcname patternDavid A. Dalrymple (and Bhushan G. Lodha), Mar 27, 2014
  8. 06/10 log: --function-name pickaxeDavid A. Dalrymple (and Bhushan G. Lodha), Mar 27, 2014
  9. René ScharfeApr 3, 2014
  10. Junio C HamanoApr 3, 2014
  11. Jakub NarębskiApr 4, 2014
  12. Junio C HamanoApr 4, 2014
  13. Bhushan LodhaApr 28, 2014
  14. 07/10 xdiff: add XDL_EMIT_MOREFUNCNAMESDavid A. Dalrymple (and Bhushan G. Lodha), Mar 27, 2014
  15. 08/10 xdiff: add XDL_EMIT_MOREHUNKHEADSDavid A. Dalrymple (and Bhushan G. Lodha), Mar 27, 2014
  16. 09/10 t4213: test --function-name optionDavid A. Dalrymple (and Bhushan G. Lodha), Mar 27, 2014
  17. Johannes SixtMar 28, 2014
  18. Eric SunshineMar 28, 2014
  19. Johannes SixtMar 28, 2014
  20. Jakub NarębskiApr 4, 2014
  21. 10/10 Documentation: Document --function-name usageDavid A. Dalrymple (and Bhushan G. Lodha), Mar 27, 2014
  22. Eric SunshineMar 28, 2014
  23. Jeff KingMar 27, 2014

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.