arxanas / git-branchless

High-velocity, monorepo-scale workflow for Git
Apache License 2.0
3.37k stars 80 forks source link

New commits appear to be hidden by default #1323

Closed scottjacobsen closed 1 month ago

scottjacobsen commented 1 month ago

Description of the bug

When I commit a few times and then run git sl I see this: ┃ ◯ aba6ab9 3m test ┃ ┃ ┃ ◯ b147149 2m test2 ┃ ┃ ┃ ● e37e0ee 6s test3

Then when I run git prev I see this: ┃ ◯ aba6ab9 6m test ┃ ┃ ┃ ● b147149 4m test2

Here I would still expect to see e37e0ee as the next commit but it seems hidden

> git next
No more child commits to go to after traversing 0 children.

Then I do:

> git unhide e37e0ee
Unhid commit: e37e0ee test3
> git sl

And then I see: ┃ ◯ aba6ab9 8m test ┃ ┃ ┃ ● b147149 6m test2 ┃ ┃ ┃ ◯ e37e0ee 4m test3

After than I can do git next and git prev as usual. So it seems like new commits are defaulting to the hidden state.

Expected behavior

I expect new commits not to be hidden.

Actual behavior

New commits appear to be hidden after switching to a different commit.

Version of rustc

No response

Automated bug report

No response

Version of git-branchless

git-branchless-opts 0.8.0

Version of git

git version 2.45.1

scottjacobsen commented 1 month ago

It appears it is a conflict with overcommit which clobbers the hooks installed by this project. Is it possible to "namespace" hooks so they don't collide, or is this a git limitation?

arxanas commented 1 month ago

@scottjacobsen The lack of support for multiple hooks of a given kind is a Git limitation, but sounds like overcommit itself is the solution for that?

git-branchless assumes that the hook is a shell script and then tries pretty hard to insert its own configuration without disturbing other configuration: https://github.com/arxanas/git-branchless/blob/ce1aa49015eacf68e1c3bfdd9dd0635bba9c5069/git-branchless-init/src/lib.rs#L151-L173

There is in principle support for using different hook management systems, if you wanted to try to add support for overcommit: https://github.com/arxanas/git-branchless/blob/ce1aa49015eacf68e1c3bfdd9dd0635bba9c5069/git-branchless-init/src/lib.rs#L107-L121

As an ad-hoc solution, it seems like you should be able to add the git-branchless hooks to overcommit: https://github.com/sds/overcommit?tab=readme-ov-file#adding-existing-git-hooks