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

Re: [PATCH v2 3/3] last-modified: verify revision argument is a commit-ish

From
Patrick Steinhardt <ps@pks.im>
Date
Jan 14, 2026, 10:56 UTC
Message-ID
<aWd2VcX7gERTDK2t@pks.im>
In-Reply-To
<20260114-toon-last-modified-tree-v2-3-ba3b1860898f@iotcl.com>
On Wed, Jan 14, 2026 at 11:24:47AM +0100, Toon Claes wrote:
> Passing a tree OID to git-last-modified(1) would trigger BUG behavior.
I guess passing a blob OID would cause the same. So maybe:
    Passing a non-committish revision to git-lsat-modified(1) triggers
    the following BUG:
Show 6 quoted lines
>     git last-modified HEAD^{tree}
>     BUG: builtin/last-modified.c:456: paths remaining beyond boundary in last-modified
> 
> Fix this error by verifying the parsed revision peels to a commit-ish.
> 
> While at it, also fix a memory leak in populate_paths_from_revs().

You fixed this memory leak in a preceding commit now, so this remark is not accurate anymore.

Show 18 quoted lines
> diff --git a/t/t8020-last-modified.sh b/t/t8020-last-modified.sh
> index 1183ae667b..22635de447 100755
> --- a/t/t8020-last-modified.sh
> +++ b/t/t8020-last-modified.sh
> @@ -55,6 +56,13 @@ test_expect_success 'last-modified recursive' '
>  	EOF
>  '
>  
> +test_expect_success 'last-modified on annotated tag' '
> +	check_last_modified t2 <<-\EOF
> +	2 a
> +	1 file
> +	EOF
> +'
> +
>  test_expect_success 'last-modified recursive with show-trees' '
>  	check_last_modified -r -t <<-\EOF
>  	3 a/b
Nice, thanks for adding this test.
Show 8 quoted lines
> @@ -235,4 +243,9 @@ test_expect_success 'last-modified complains about unknown arguments' '
>  	grep "unknown last-modified argument: --foo" err
>  '
>  
> +test_expect_success 'last-modified expects commit-ish' '
> +	test_must_fail git last-modified HEAD^{tree} 2>err &&
> +	grep "revision argument is not a commit-ish" err
> +'

We typically use `test_grep ()` so that we know what the actual contents are in case the assertion ever fails.

Patrick
Previous: Toon ClaesNext: Kristoffer Haugsbakk
Message 19 of 55 in “last-modified: verify revision argument is a commit-ish”
  1. last-modified: verify revision argument is a commit-ishToon Claes, Jan 12, 2026
  2. Junio C HamanoJan 12, 2026
  3. Patrick SteinhardtJan 13, 2026
  4. 0/3 Fix git-last-modified(1) bug triggered when passing a tree-ishToon Claes, Jan 14, 2026
  5. 1/3 last-modified: rewrite error message when more than one revision givenToon Claes, Jan 14, 2026
  6. Patrick SteinhardtJan 14, 2026
  7. Toon ClaesJan 15, 2026
  8. Patrick SteinhardtJan 15, 2026
  9. Kristoffer HaugsbakkJan 15, 2026
  10. Patrick SteinhardtJan 16, 2026
  11. Toon ClaesJan 16, 2026
  12. Junio C HamanoJan 16, 2026
  13. Patrick SteinhardtJan 19, 2026
  14. Kristoffer HaugsbakkJan 25, 2026
  15. Kristoffer HaugsbakkJan 15, 2026
  16. 2/3 last-modified: remove double error messageToon Claes, Jan 14, 2026
  17. Patrick SteinhardtJan 14, 2026
  18. 3/3 last-modified: verify revision argument is a commit-ishToon Claes, Jan 14, 2026
  19. Patrick SteinhardtJan 14, 2026
  20. Kristoffer HaugsbakkJan 15, 2026
  21. Junio C HamanoJan 15, 2026
  22. Toon ClaesJan 16, 2026
  23. 0/4 Fix git-last-modified(1) bug triggered when passing a tree-ishToon Claes, Jan 16, 2026
  24. 1/4 last-modified: rewrite error message when more than one revision givenToon Claes, Jan 16, 2026
  25. Junio C HamanoJan 16, 2026
  26. 2/4 last-modified: fix memory leak when more than one revision is givenToon Claes, Jan 16, 2026
  27. 3/4 last-modified: remove double error messageToon Claes, Jan 16, 2026
  28. Junio C HamanoJan 16, 2026
  29. 4/4 last-modified: verify revision argument is a commit-ishToon Claes, Jan 16, 2026
  30. Junio C HamanoJan 16, 2026
  31. 0/4 Fix git-last-modified(1) bug triggered when passing a tree-ishToon Claes, Jan 23, 2026
  32. 1/4 last-modified: rewrite error message when more than one revision givenToon Claes, Jan 23, 2026
  33. Junio C HamanoJan 23, 2026
  34. 2/4 last-modified: fix memory leak when more than one revision is givenToon Claes, Jan 23, 2026
  35. Junio C HamanoJan 23, 2026
  36. 3/4 last-modified: remove double error messageToon Claes, Jan 23, 2026
  37. Junio C HamanoJan 23, 2026
  38. 4/4 last-modified: verify revision argument is a commit-ishToon Claes, Jan 23, 2026
  39. Junio C HamanoJan 23, 2026
  40. Junio C HamanoJan 23, 2026
  41. 0/4 Fix git-last-modified(1) bug triggered when passing a tree-ishToon Claes, Jan 27, 2026
  42. 1/4 last-modified: rewrite error message when more than one commit givenToon Claes, Jan 27, 2026
  43. 2/4 last-modified: fix memory leak when more than one commit is givenToon Claes, Jan 27, 2026
  44. 3/4 last-modified: remove double error messageToon Claes, Jan 27, 2026
  45. 4/4 last-modified: verify revision argument is a commit-ishToon Claes, Jan 27, 2026
  46. Junio C HamanoJan 27, 2026
  47. Toon ClaesJan 29, 2026
  48. 0/4 Fix git-last-modified(1) bug triggered when passing a tree-ishToon Claes, Jan 30, 2026
  49. 1/4 last-modified: rewrite error message when more than one commit givenToon Claes, Jan 30, 2026
  50. 2/4 last-modified: fix memory leak when more than one commit is givenToon Claes, Jan 30, 2026
  51. 3/4 last-modified: remove double error messageToon Claes, Jan 30, 2026
  52. 4/4 last-modified: verify revision argument is a commit-ishToon Claes, Jan 30, 2026
  53. Patrick SteinhardtFeb 6, 2026
  54. Junio C HamanoJan 30, 2026
  55. Patrick SteinhardtFeb 6, 2026

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.