Skip to content

Conversation

@To1ne
Copy link

@To1ne To1ne commented Jan 27, 2026

Recently there was a bug reported1 passing a tree OID triggers a BUG:

$ git last-modified fb06ce04173d47aaaa498385621cba8b8dfd7584
BUG: builtin/last-modified.c:456: paths remaining beyond boundary in last-modified
[1]    690163 IOT instruction (core dumped)  git last-modified

`fb06ce04173d47aaaa498385621cba8b8dfd7584` is the tree commit id of web_src. I
suppose this should've returned a nice error message or blank output.

Fix this bug by checking the revision argument.

Cc: Patrick Steinhardt ps@pks.im
Cc: Kristoffer Haugsbakk kristofferhaugsbakk@fastmail.com


Changes in v5:

Changes in v4:

Changes in v3:

Changes in v2:

To1ne added 4 commits January 27, 2026 12:05
Recently there was a bug reported[1] passing a tree OID triggers a BUG:

    $ git last-modified fb06ce04173d47aaaa498385621cba8b8dfd7584
    BUG: builtin/last-modified.c:456: paths remaining beyond boundary in last-modified
    [1]    690163 IOT instruction (core dumped)  git last-modified

    `fb06ce04173d47aaaa498385621cba8b8dfd7584` is the tree commit id of web_src. I
    suppose this should've returned a nice error message or blank output.

Fix this bug by checking the revision argument.

[1]: https://lore.kernel.org/git/03f96860-29fc-42a7-a220-c3ec65eb8516@codeberg.org/

Cc: Patrick Steinhardt <ps@pks.im>
Cc: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>

---
Changes in v6:
- EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v5: https://patch.msgid.link/20260127-toon-last-modified-tree-v5-0-38d18a0956d4@iotcl.com

Changes in v5:
- Use 'commit' instead of 'revision'.
- Small typo fixes.
- Link to v4: https://patch.msgid.link/20260123-toon-last-modified-tree-v4-0-86bf97bad4e2@iotcl.com

Changes in v4:
- Extend the error message when revision is not a tree
- Extend the test to verify the error message when more than one
  revision is given.
- Link to v3: https://patch.msgid.link/20260116-toon-last-modified-tree-v3-0-e6ade4dc35ab@iotcl.com

Changes in v3:
- Split the change to plug the leak into a separate commit.
- Small changes to commit messages.
- Link to v2: https://patch.msgid.link/20260114-toon-last-modified-tree-v2-0-ba3b1860898f@iotcl.com

Changes in v2:
- Prepend the change with a commit that modifies the error message
  when more than one revision is given.
- Prepend another commit that removes double error message.
- Add test to ensure the command works with annotated tags too.
- Link to v1: https://patch.msgid.link/20260112-toon-last-modified-tree-v1-1-ecbc78341f76@iotcl.com

--- b4-submit-tracking ---
# This section is used internally by b4 prep for tracking purposes.
{
  "series": {
    "revision": 6,
    "change-id": "20260112-toon-last-modified-tree-fdd96b2feaf7",
    "prefixes": [],
    "presubject": "",
    "history": {
      "v1": [
        "20260112-toon-last-modified-tree-v1-1-ecbc78341f76@iotcl.com"
      ],
      "v2": [
        "20260114-toon-last-modified-tree-v2-0-ba3b1860898f@iotcl.com"
      ],
      "v3": [
        "20260116-toon-last-modified-tree-v3-0-e6ade4dc35ab@iotcl.com"
      ],
      "v4": [
        "20260123-toon-last-modified-tree-v4-0-86bf97bad4e2@iotcl.com"
      ],
      "v5": [
        "20260127-toon-last-modified-tree-v5-0-38d18a0956d4@iotcl.com"
      ]
    }
  }
}
When more than one commit is passed to the git-last-modified(1) command,
this error message was printed:

    error: last-modified can only operate on one tree at a time

Calling these a "tree" is technically not correct. git-last-modified(1)
expects revisions that peel to a commit.

Rephrase the error message to:

    error: last-modified can only operate on one commit at a time

While at it, modify the test to ensure the correct error message is
printed.

Signed-off-by: Toon Claes <toon@iotcl.com>
When more than one commit is given, the function
populate_paths_from_revs() leaks a `struct pathspec`. Plug it.

Signed-off-by: Toon Claes <toon@iotcl.com>
When the user passes two revisions, they get the following output:

    $ git last-modified HEAD HEAD~
    error: last-modified can only operate on one revision at a time
    error: unable to setup last-modified

The error message about "unable to setup" is not very informative,
remove it.

Signed-off-by: Toon Claes <toon@iotcl.com>
@gitgitgadget
Copy link

gitgitgadget bot commented Jan 27, 2026

There are issues in commit 398ac26:
Fix git-last-modified(1) bug triggered when passing a tree-ish

  • Commit not signed off
  • Lines in the body of the commit messages should be wrapped between 60 and 76 characters.
    Indented lines, and lines without whitespace, are exempt

@To1ne
Copy link
Author

To1ne commented Jan 27, 2026

Pushing here because I saw a CI failure on test:msvc-meson 2/10.

@To1ne
Copy link
Author

To1ne commented Jan 27, 2026

Oh it's green. Well, I can close then.

@To1ne To1ne closed this Jan 27, 2026
@To1ne To1ne reopened this Jan 27, 2026
Passing a non-committish revision to git-last-modified(1) triggers the
following BUG:

    git last-modified HEAD^{tree}
    BUG: builtin/last-modified.c:456: paths remaining beyond boundary in last-modified

Fix this error by ensuring that the given revision peels to a commit.

Reported-by: Gusted <gusted@codeberg.org>
Signed-off-by: Toon Claes <toon@iotcl.com>
@To1ne
Copy link
Author

To1ne commented Jan 28, 2026

@dscho Is it me, or does it seem like the CI job win+Meson test (2) isn't doing anything? https://github.com/gitgitgadget/git/actions/runs/21417237509/job/61672262076

always upload reports, not only on failure

upload meson logs

remove unused script

print failures

no verbose log with meson

it causes us to write somewhere else, but we want it in the meson test
log
@To1ne To1ne force-pushed the b4/toon-last-modified-tree branch from 9a810e1 to 16c4761 Compare January 29, 2026 10:48
@gitgitgadget
Copy link

gitgitgadget bot commented Jan 29, 2026

There are issues in commit 7da62d2:
Fix git-last-modified(1) bug triggered when passing a tree-ish

  • Commit not signed off
  • Lines in the body of the commit messages should be wrapped between 60 and 76 characters.
    Indented lines, and lines without whitespace, are exempt

@gitgitgadget
Copy link

gitgitgadget bot commented Jan 29, 2026

There is an issue in commit 16c4761:
ci: all the fixes

  • Commit not signed off

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants