arxanas / git-branchless

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

smartlog: show rebase(/etc.) status #1210

Open talios opened 5 months ago

talios commented 5 months ago

Description of the bug

I seem to have gotten my repository into a bit of a pickle with branchless and I'm not sure how to proceed, beyond trashing my repository.

The first problem is we primarily use git-flow, tho I've been trying to use branchless for local work, committing my stacks on the develop branch, things were working fine til I was trying to amend a stack, and ran git sync by accident rather than git restack, and everything went to hell.

It turns out I had legit installed, along with various legit aliases defined in my main ~/.gitconfig file which seems to have been used in favour of branchless (it would be good for the init process to check that maybe).

Anyway, my repository now seems to be stuck on a rebase even tho the smart log shows me on the current stack:

$ git sl
◇ 6546e6e 6d (master) Initial commit
┃
◯ a1bd9e9 2d NNNNNNN
┃
◯ 52ace35 2d NNNNNNNN
┃
● 8a4047e 30m (ᐅ develop) NNNNNNN

Expected behavior

I shouldn't be stuck in a rebase.

Actual behavior

I'm stuck in a rebase.

Version of rustc

No response

Automated bug report

Software version

git-branchless 0.8.0

Operating system

macOS 14.3 (Darwin 23.3.0)

Command-line

/Users/amrk/.cargo/bin/git-branchless bug-report 

Environment variables

SHELL=/usr/local/bin/fish
EDITOR=<not set>

Git version

> git version 
git version 2.43.0

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 ## START BRANCHLESS CONFIG git branchless hook post-checkout "$@" ## END BRANCHLESS CONFIG ``` ##### Hook `post-commit` ``` #!/bin/sh ## START BRANCHLESS CONFIG git branchless hook post-commit "$@" ## END BRANCHLESS CONFIG ``` ##### Hook `post-merge` ``` #!/bin/sh ## START BRANCHLESS CONFIG git branchless hook post-merge "$@" ## END BRANCHLESS CONFIG ``` ##### 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: 138, transaction ID: 100 (message: hook-post-checkout) 1. `RefUpdateEvent { timestamp: 1707117144.43711, event_tx_id: EventTransactionId(100), ref_name: ReferenceName("HEAD"), old_oid: 6546e6e211e8b06c02d647b99f08fd0eb02c8681, new_oid: 8a4047e05e1f4817d2552214356ca254b884e1cc, message: None }` ``` O 6546e6e 6d (master) xxxxxxx xxxxxx | o a1bd9e9 2d xxxx xxxxxxx xxxxxxxx xxxxxxxx xxxxxxx xxxxxx | o 52ace35 2d xxxx xxx xxxxxxx xxxxx xxxxxxxx | @ 8a4047e 22m (redacted-ref-0) xxxx xxx xxx xxxxxxxxxxxx xxxxxxx xxxxxxxxx xxxxx ``` ##### Event ID: 137, transaction ID: 99 (message: next) 1. `WorkingCopySnapshot { timestamp: 1707117094.804958, event_tx_id: EventTransactionId(99), head_oid: 6546e6e211e8b06c02d647b99f08fd0eb02c8681, commit_oid: NonZeroOid(41b7ea79748c97f27d51d2c70c77dcdfd56da430), ref_name: None }` ``` O 6546e6e 6d (master) xxxxxxx xxxxxx | o a1bd9e9 2d xxxx xxxxxxx xxxxxxxx xxxxxxxx xxxxxxx xxxxxx | o 52ace35 2d xxxx xxx xxxxxxx xxxxx xxxxxxxx | @ 8a4047e 22m (redacted-ref-0) xxxx xxx xxx xxxxxxxxxxxx xxxxxxx xxxxxxxxx xxxxx ``` ##### Event ID: 136, transaction ID: 97 (message: reference-transaction) 1. `RefUpdateEvent { timestamp: 1707116978.66539, event_tx_id: EventTransactionId(97), ref_name: ReferenceName("HEAD"), old_oid: 86d431e9e613738c37e41f50bfd76d07ed401df2, new_oid: 6546e6e211e8b06c02d647b99f08fd0eb02c8681, message: None }` ``` O 6546e6e 6d (master) xxxxxxx xxxxxx | o a1bd9e9 2d xxxx xxxxxxx xxxxxxxx xxxxxxxx xxxxxxx xxxxxx | o 52ace35 2d xxxx xxx xxxxxxx xxxxx xxxxxxxx | @ 8a4047e 22m (redacted-ref-0) xxxx xxx xxx xxxxxxxxxxxx xxxxxxx xxxxxxxxx xxxxx ``` ##### Event ID: 135, transaction ID: 95 (message: reference-transaction) 1. `RefUpdateEvent { timestamp: 1707116779.157762, event_tx_id: EventTransactionId(95), ref_name: ReferenceName("HEAD"), old_oid: a1bd9e9db6d731bdff8cb517488512ad529cf2c2, new_oid: 86d431e9e613738c37e41f50bfd76d07ed401df2, message: None }` ``` O 6546e6e 6d (master) xxxxxxx xxxxxx | o a1bd9e9 2d xxxx xxxxxxx xxxxxxxx xxxxxxxx xxxxxxx xxxxxx | o 52ace35 2d xxxx xxx xxxxxxx xxxxx xxxxxxxx | @ 8a4047e 22m (redacted-ref-0) xxxx xxx xxx xxxxxxxxxxxx xxxxxxx xxxxxxxxx xxxxx ``` ##### Event ID: 132, transaction ID: 94 (message: prev) 1. `WorkingCopySnapshot { timestamp: 1707116703.064876, event_tx_id: EventTransactionId(94), head_oid: 52ace35d4df6ec52bb19d7e00e4e05bba53d987a, commit_oid: NonZeroOid(5d345433de077f8ae46c0f72f795c248e49ac3df), ref_name: None }` 1. `RefUpdateEvent { timestamp: 1707116703.160629, event_tx_id: EventTransactionId(94), ref_name: ReferenceName("HEAD"), old_oid: 0000000000000000000000000000000000000000, new_oid: a1bd9e9db6d731bdff8cb517488512ad529cf2c2, message: None }` 1. `RefUpdateEvent { timestamp: 1707116703.20267, event_tx_id: EventTransactionId(94), ref_name: ReferenceName("HEAD"), old_oid: 52ace35d4df6ec52bb19d7e00e4e05bba53d987a, new_oid: a1bd9e9db6d731bdff8cb517488512ad529cf2c2, message: None }` ``` O 6546e6e 6d (master) xxxxxxx xxxxxx | o a1bd9e9 2d xxxx xxxxxxx xxxxxxxx xxxxxxxx xxxxxxx xxxxxx | o 52ace35 2d xxxx xxx xxxxxxx xxxxx xxxxxxxx | @ 8a4047e 22m (redacted-ref-0) xxxx xxx xxx xxxxxxxxxxxx xxxxxxx xxxxxxxxx xxxxx ```

Version of git-branchless

No response

Version of git

No response

talios commented 5 months ago

...interesting - aborting the rebase, then cherry-picking the latest sha seems to have resolved the issue.

arxanas commented 5 months ago

The smartlog doesn't indicate the current rebase status (but maybe it should).

Generally speaking, if you're stuck in a rebase, then you should use git rebase --abort; it shouldn't be different when git-branchless is involved. (It's true that git-branchless initiates some rebases for you.)

I think git sync behaving poorly with rewritten commits, as you've done, is basically a footgun. It's also discussed at https://github.com/arxanas/git-branchless/issues/1137. I'll leave that issue open for that, and rename this issue to address smartlog rebase status.