arxanas / git-branchless

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

Commits often lost, requiring `unhide` (sometimes immediately after `record` and `sw`) #1380

Closed pswaminathan closed 3 months ago

pswaminathan commented 3 months ago

Description of the bug

I don't really know how to describe this, but this sequence happens somewhat regularly:

  1. git record
  2. git prev
  3. git next -> no commit. The commit recorded in 1 disappears
$ git record
branchless: processing 1 update: ref HEAD
[detached HEAD 4c0600514] New work
 7 files changed, 105 insertions(+), 2 deletions(-)

$ git prev
branchless: creating working copy snapshot
branchless: running command: git checkout 40e39f92e43fe8d140d80a27e6e527c0bed31c84
Previous HEAD position was 4c0600514 New work
branchless: processing 1 update: ref HEAD
HEAD is now at 40e39f92e Older work
⋮
◇ 9a9180b 1d (main) main branch
┣━┓
┃ ◯ 2f78db0 1d some other work
┃
◯ 79f6d1f 1d Starting work
┃
◯ bb27b07 1d Oldest work
┃
● 40e39f9 46m Older work

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

This is within seconds—that is to say, I am not calling git hide. If I git sw then git sync, it appears to stay. Or if I git unhide, it appears to stay. But occasionally I have missed that this happened, cleared away my past terminal output, and lost the commit. I then had to dig through the branchless sqlite database and try hashes.

Expected behavior

After git record, the commit is in the smartlog unless I manually hide it.

Actual behavior

The commit disappears from the smartlog if I switch away from it.

Version of rustc

No response

Automated bug report

git branchless bug-report

Software version

git-branchless 0.9.0

Operating system

macOS 14.5 (Darwin 23.5.0)

Command-line

/opt/homebrew/bin/git-branchless bug-report

Environment variables

SHELL=/bin/zsh
EDITOR='subl -nw'

Git version

> git version
git version 2.39.3 (Apple Git-146)

Hooks

Show 7 hooks ##### Hook `post-applypatch` ``` #!/bin/sh ## START BRANCHLESS CONFIG git branchless hook post-applypatch "$@" ## END BRANCHLESS CONFIG ``` ##### Hook `post-checkout` ``` #!/bin/sh command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-checkout' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; } git lfs post-checkout "$@" ``` ##### Hook `post-commit` ``` #!/bin/sh command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-commit' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; } git lfs post-commit "$@" ``` ##### Hook `post-merge` ``` #!/bin/sh command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-merge' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; } git lfs post-merge "$@" ``` ##### Hook `post-rewrite` ``` #!/bin/sh ## START BRANCHLESS CONFIG git branchless hook post-rewrite "$@" ## END BRANCHLESS CONFIG ``` ##### Hook `pre-auto-gc` ``` #!/bin/sh ## START BRANCHLESS CONFIG git branchless hook pre-auto-gc "$@" ## END BRANCHLESS CONFIG ``` ##### Hook `reference-transaction` ``` #!/bin/sh ## START BRANCHLESS CONFIG # Avoid canceling the reference transaction in the case that `branchless` fails # for whatever reason. git branchless hook reference-transaction "$@" || ( echo 'branchless: Failed to process reference transaction!' echo 'branchless: Some events (e.g. branch updates) may have been lost.' echo 'branchless: This is a bug. Please report it.' ) ## END BRANCHLESS CONFIG ```

Events

Show 5 events ##### Event ID: 5492, transaction ID: 2424 (message: reference-transaction) 1. `RefUpdateEvent { timestamp: 1723132503.874605, event_tx_id: Id(2424), ref_name: ReferenceName("refs/remotes/redacted-ref-0"), old_oid: eeaf42075e7798f3a88dc62232bc90e3948ec1a7, new_oid: 05ea06d16ce7aa2539a50c8947394fa91f1c3e34, message: None }` ``` : O 27b777a 20h (main) xxxxxxx xxxxx xxxxxxxx |\ | o 0bf9b3e 9m xxxxxxx xxxxxxx xx xxxxx x |\ | o 36c665b 9m xxxxxxx xxx xxxxxxx xxxxx | | | o 1a90069 9m xxxxxxx xxx xxxxx |\ | o 68f6acb 9m xxx xxxxxxxxx xxxxx xxxxxxx xxxxxxx |\ | o 87baffb 9m xxxxxxxxxxxxxxxx xxxx xxx xxx xxx xxxxx xx xxxxxxx xxxxxxx | | | o 1563bd2 9m xxxxxxxxx xxxx xxxxxxxxx xxx xxx xxx xxx xxxxx xx xxxxxxx xxxxxxx | | | o fc4a5f3 9m xxxxxxxxxxxxxx xxx xxxxxxxx xxxxxxx xxxxx | | | @ 05b8831 9m xxxxxx xxx xxxxx xxxxxxxx xxxxxxx xxxxx xxxxxxxxxxx |\ | o 88093bf 9m xxxxxxxxx xxxxxx xxxx xxxxxx xx xxxxxx xxx xxxxxx |\ | o 8cd0b6f 9m xxxxxxxxxxx xxxxxxxxxx xxxxxxxx xxxxx xxx xxxx xxxxxxxxxxx | | | o 25beb50 9m xxxxxxxxxxx xxxxxxxx xxxxxx xxxx xx xx xxxx xxxxxxxxx | | | o 5d0dc28 9m xxxxxxxxxxx xxxxxx xxxxx xxxxxxxxx xxxx xx xxxxxxxx | | | o 1df1ec0 9m xxxxxxxxxxx xxx xxxxx xxxx | | | o a80c666 9m xxx xxxxxxxxx xxxxxx xx xxx xxxxxxx | | | o cdbb628 9m xxxxx xxxxxx | | | o d9a0716 9m (redacted-ref-1) xxxxxxx xxxxx xxx |\ | o b9f56bb 9m xxxxxx xxxxxxx xxxxxx |\ | o f0d7b21 9m xxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxx | o e10dcad 8m xxxxxxxx xxxxxxx xx xxxx xxx xxx xxxxxx xx xxx | o 7dac310 8m xxxxxxxxx xxxxxxxxx xxx xxxx xxx ``` ##### Event ID: 5490, transaction ID: 2423 (message: checkout) 1. `WorkingCopySnapshot { timestamp: 1723132460.605989, event_tx_id: Id(2423), head_oid: 7dac31038209d60d595648a937cfb88a433e3488, commit_oid: NonZeroOid(f3cac8d808db17156fd80b747aa011c1e55092ce), ref_name: None }` 1. `RefUpdateEvent { timestamp: 1723132460.712148, event_tx_id: Id(2423), ref_name: ReferenceName("HEAD"), old_oid: 0000000000000000000000000000000000000000, new_oid: 05b88317cd3edb54974fb049766cbd05ded33f30, message: None }` ``` : O 27b777a 20h (main) xxxxxxx xxxxx xxxxxxxx |\ | o 0bf9b3e 9m xxxxxxx xxxxxxx xx xxxxx x |\ | o 36c665b 9m xxxxxxx xxx xxxxxxx xxxxx | | | o 1a90069 9m xxxxxxx xxx xxxxx |\ | o 68f6acb 9m xxx xxxxxxxxx xxxxx xxxxxxx xxxxxxx |\ | o 87baffb 9m xxxxxxxxxxxxxxxx xxxx xxx xxx xxx xxxxx xx xxxxxxx xxxxxxx | | | o 1563bd2 9m xxxxxxxxx xxxx xxxxxxxxx xxx xxx xxx xxx xxxxx xx xxxxxxx xxxxxxx | | | o fc4a5f3 9m xxxxxxxxxxxxxx xxx xxxxxxxx xxxxxxx xxxxx | | | @ 05b8831 9m xxxxxx xxx xxxxx xxxxxxxx xxxxxxx xxxxx xxxxxxxxxxx |\ | o 88093bf 9m xxxxxxxxx xxxxxx xxxx xxxxxx xx xxxxxx xxx xxxxxx |\ | o 8cd0b6f 9m xxxxxxxxxxx xxxxxxxxxx xxxxxxxx xxxxx xxx xxxx xxxxxxxxxxx | | | o 25beb50 9m xxxxxxxxxxx xxxxxxxx xxxxxx xxxx xx xx xxxx xxxxxxxxx | | | o 5d0dc28 9m xxxxxxxxxxx xxxxxx xxxxx xxxxxxxxx xxxx xx xxxxxxxx | | | o 1df1ec0 9m xxxxxxxxxxx xxx xxxxx xxxx | | | o a80c666 9m xxx xxxxxxxxx xxxxxx xx xxx xxxxxxx | | | o cdbb628 9m xxxxx xxxxxx | | | o d9a0716 9m (redacted-ref-1) xxxxxxx xxxxx xxx |\ | o b9f56bb 9m xxxxxx xxxxxxx xxxxxx |\ | o f0d7b21 9m xxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxx | o e10dcad 8m xxxxxxxx xxxxxxx xx xxxx xxx xxx xxxxxx xx xxx | o 7dac310 8m xxxxxxxxx xxxxxxxxx xxx xxxx xxx ``` ##### Event ID: 5488, transaction ID: 2422 (message: checkout) 1. `WorkingCopySnapshot { timestamp: 1723132454.537789, event_tx_id: Id(2422), head_oid: 05b88317cd3edb54974fb049766cbd05ded33f30, commit_oid: NonZeroOid(9df4e0c8ad9bdfd72cdeb7197596ec4096ad0418), ref_name: None }` 1. `RefUpdateEvent { timestamp: 1723132454.642262, event_tx_id: Id(2422), ref_name: ReferenceName("HEAD"), old_oid: 0000000000000000000000000000000000000000, new_oid: 7dac31038209d60d595648a937cfb88a433e3488, message: None }` ``` : O 27b777a 20h (main) xxxxxxx xxxxx xxxxxxxx |\ | o 0bf9b3e 9m xxxxxxx xxxxxxx xx xxxxx x |\ | o 36c665b 9m xxxxxxx xxx xxxxxxx xxxxx | | | o 1a90069 9m xxxxxxx xxx xxxxx |\ | o 68f6acb 9m xxx xxxxxxxxx xxxxx xxxxxxx xxxxxxx |\ | o 87baffb 9m xxxxxxxxxxxxxxxx xxxx xxx xxx xxx xxxxx xx xxxxxxx xxxxxxx | | | o 1563bd2 9m xxxxxxxxx xxxx xxxxxxxxx xxx xxx xxx xxx xxxxx xx xxxxxxx xxxxxxx | | | o fc4a5f3 9m xxxxxxxxxxxxxx xxx xxxxxxxx xxxxxxx xxxxx | | | @ 05b8831 9m xxxxxx xxx xxxxx xxxxxxxx xxxxxxx xxxxx xxxxxxxxxxx |\ | o 88093bf 9m xxxxxxxxx xxxxxx xxxx xxxxxx xx xxxxxx xxx xxxxxx |\ | o 8cd0b6f 9m xxxxxxxxxxx xxxxxxxxxx xxxxxxxx xxxxx xxx xxxx xxxxxxxxxxx | | | o 25beb50 9m xxxxxxxxxxx xxxxxxxx xxxxxx xxxx xx xx xxxx xxxxxxxxx | | | o 5d0dc28 9m xxxxxxxxxxx xxxxxx xxxxx xxxxxxxxx xxxx xx xxxxxxxx | | | o 1df1ec0 9m xxxxxxxxxxx xxx xxxxx xxxx | | | o a80c666 9m xxx xxxxxxxxx xxxxxx xx xxx xxxxxxx | | | o cdbb628 9m xxxxx xxxxxx | | | o d9a0716 9m (redacted-ref-1) xxxxxxx xxxxx xxx |\ | o b9f56bb 9m xxxxxx xxxxxxx xxxxxx |\ | o f0d7b21 9m xxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxx | o e10dcad 8m xxxxxxxx xxxxxxx xx xxxx xxx xxx xxxxxx xx xxx | o 7dac310 8m xxxxxxxxx xxxxxxxxx xxx xxxx xxx ``` ##### Event ID: 5484, transaction ID: 2421 (message: hook-post-rewrite) 1. `RewriteEvent { timestamp: 1723132442.767411, event_tx_id: Id(2421), old_commit_oid: f1dbe8433d0a28cde4aec2957cf6d7a58ab034e5, new_commit_oid: e10dcad23994b7d09169c40011a5a1ea206c0724 }` 1. `RewriteEvent { timestamp: 1723132442.767411, event_tx_id: Id(2421), old_commit_oid: 6a4eae8461acef69e67f755dd7d2138467f7c553, new_commit_oid: 7dac31038209d60d595648a937cfb88a433e3488 }` 1. `WorkingCopySnapshot { timestamp: 1723132442.856452, event_tx_id: Id(2421), head_oid: 7dac31038209d60d595648a937cfb88a433e3488, commit_oid: NonZeroOid(f3cac8d808db17156fd80b747aa011c1e55092ce), ref_name: None }` 1. `RefUpdateEvent { timestamp: 1723132442.967149, event_tx_id: Id(2421), ref_name: ReferenceName("HEAD"), old_oid: 0000000000000000000000000000000000000000, new_oid: 05b88317cd3edb54974fb049766cbd05ded33f30, message: None }` ``` : O 27b777a 20h (main) xxxxxxx xxxxx xxxxxxxx |\ | o 0bf9b3e 9m xxxxxxx xxxxxxx xx xxxxx x |\ | o 36c665b 9m xxxxxxx xxx xxxxxxx xxxxx | | | o 1a90069 9m xxxxxxx xxx xxxxx |\ | o 68f6acb 9m xxx xxxxxxxxx xxxxx xxxxxxx xxxxxxx |\ | o 87baffb 9m xxxxxxxxxxxxxxxx xxxx xxx xxx xxx xxxxx xx xxxxxxx xxxxxxx | | | o 1563bd2 9m xxxxxxxxx xxxx xxxxxxxxx xxx xxx xxx xxx xxxxx xx xxxxxxx xxxxxxx | | | o fc4a5f3 9m xxxxxxxxxxxxxx xxx xxxxxxxx xxxxxxx xxxxx | | | @ 05b8831 9m xxxxxx xxx xxxxx xxxxxxxx xxxxxxx xxxxx xxxxxxxxxxx |\ | o 88093bf 9m xxxxxxxxx xxxxxx xxxx xxxxxx xx xxxxxx xxx xxxxxx |\ | o 8cd0b6f 9m xxxxxxxxxxx xxxxxxxxxx xxxxxxxx xxxxx xxx xxxx xxxxxxxxxxx | | | o 25beb50 9m xxxxxxxxxxx xxxxxxxx xxxxxx xxxx xx xx xxxx xxxxxxxxx | | | o 5d0dc28 9m xxxxxxxxxxx xxxxxx xxxxx xxxxxxxxx xxxx xx xxxxxxxx | | | o 1df1ec0 9m xxxxxxxxxxx xxx xxxxx xxxx | | | o a80c666 9m xxx xxxxxxxxx xxxxxx xx xxx xxxxxxx | | | o cdbb628 9m xxxxx xxxxxx | | | o d9a0716 9m (redacted-ref-1) xxxxxxx xxxxx xxx |\ | o b9f56bb 9m xxxxxx xxxxxxx xxxxxx |\ | o f0d7b21 9m xxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxx | o e10dcad 8m xxxxxxxx xxxxxxx xx xxxx xxx xxx xxxxxx xx xxx | o 7dac310 8m xxxxxxxxx xxxxxxxxx xxx xxxx xxx ``` ##### Event ID: 5483, transaction ID: 2418 (message: reference-transaction) 1. `RefUpdateEvent { timestamp: 1723132442.449345, event_tx_id: Id(2418), ref_name: ReferenceName("HEAD"), old_oid: e10dcad23994b7d09169c40011a5a1ea206c0724, new_oid: 7dac31038209d60d595648a937cfb88a433e3488, message: None }` ``` : O 27b777a 20h (main) xxxxxxx xxxxx xxxxxxxx |\ | o 0bf9b3e 9m xxxxxxx xxxxxxx xx xxxxx x |\ | o 36c665b 9m xxxxxxx xxx xxxxxxx xxxxx | | | o 1a90069 9m xxxxxxx xxx xxxxx |\ | o 68f6acb 9m xxx xxxxxxxxx xxxxx xxxxxxx xxxxxxx |\ | o 87baffb 9m xxxxxxxxxxxxxxxx xxxx xxx xxx xxx xxxxx xx xxxxxxx xxxxxxx | | | o 1563bd2 9m xxxxxxxxx xxxx xxxxxxxxx xxx xxx xxx xxx xxxxx xx xxxxxxx xxxxxxx | | | o fc4a5f3 9m xxxxxxxxxxxxxx xxx xxxxxxxx xxxxxxx xxxxx | | | @ 05b8831 9m xxxxxx xxx xxxxx xxxxxxxx xxxxxxx xxxxx xxxxxxxxxxx |\ | o 88093bf 9m xxxxxxxxx xxxxxx xxxx xxxxxx xx xxxxxx xxx xxxxxx |\ | o 8cd0b6f 9m xxxxxxxxxxx xxxxxxxxxx xxxxxxxx xxxxx xxx xxxx xxxxxxxxxxx | | | o 25beb50 9m xxxxxxxxxxx xxxxxxxx xxxxxx xxxx xx xx xxxx xxxxxxxxx | | | o 5d0dc28 9m xxxxxxxxxxx xxxxxx xxxxx xxxxxxxxx xxxx xx xxxxxxxx | | | o 1df1ec0 9m xxxxxxxxxxx xxx xxxxx xxxx | | | o a80c666 9m xxx xxxxxxxxx xxxxxx xx xxx xxxxxxx | | | o cdbb628 9m xxxxx xxxxxx | | | o d9a0716 9m (redacted-ref-1) xxxxxxx xxxxx xxx |\ | o b9f56bb 9m xxxxxx xxxxxxx xxxxxx |\ | o f0d7b21 9m xxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxx | o e10dcad 8m xxxxxxxx xxxxxxx xx xxxx xxx xxx xxxxxx xx xxx | o 7dac310 8m xxxxxxxxx xxxxxxxxx xxx xxxx xxx ```

Version of git-branchless

No response

Version of git

No response

pswaminathan commented 3 months ago

Looking at this now, it looks like git-lfs overwrote the branchless hooks. Really nice that the bugreport spits out the hooks. I re-ran git branchless init and I see the hooks in there now. Let me see if this still occurs, and if not, I'll close this out.

pswaminathan commented 3 months ago

unhide now reports that it wasn't hidden so nothing was done, so I think this is in fact just a case of git-lfs overriding the commit hooks.

arxanas commented 2 months ago

@pswaminathan You might consider filing a bug to Git LFS. git-branchless tries to avoid clobbering existing hooks by appending its own contents rather than overwriting the file; presumably Git LFS should do the same.