arxanas / git-branchless

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

Squashing commits leaves an extra visible commit #1412

Closed cf-coheretech closed 1 month ago

cf-coheretech commented 1 month ago

Description of the bug

Starting condition: git branchless repo initialized with a 'main' branch and branch0 previously merged to main

Steps:

  1. Create 'branch1'
  2. Create 3 commits on branch1
  3. Use git rebase -i HEAD~4 and squash the last 2 commits into the 3rd last commit
  4. Observe the 'git sl' output

Expected behavior

A single visible commit in branch1

Actual behavior

An extra commit not an a branch

combination git:(branch1) git sl
⋮
◇ f13cbb5 3m (branch0, main) Modify existing file
┣━┓
┃ ◯ 47188f4 20s # This is a combination of 2 commits. # This is the 1st commit message:
┃
● 5e4f49e 20s (ᐅ branch1) kscdjn

Checking out the extra commit and lloking at the normal git log shows this

commit 47188f4370e273908ad28e56f3bba2704fac29d6 (HEAD)
Author: Caleb Fujimori <caleb.fujimori@cohere-tech.com>
Date:   Mon Oct 7 13:19:18 2024 -0700

    # This is a combination of 2 commits.
    # This is the 1st commit message:

    kscdjn

    # This is the commit message #2:

    alckm

Version of rustc

No response

Automated bug report

Software version

git-branchless 0.9.0

Operating system

macOS 15.0.1 (Darwin 24.0.0)

Command-line

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

Environment variables

SHELL=/bin/zsh
EDITOR=mvim

Git version

> git version 
git version 2.39.5 (Apple Git-154)

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: 27, transaction ID: 25 (message: hook-post-checkout) 1. `RefUpdateEvent { timestamp: 1728333572.514004, event_tx_id: Id(25), ref_name: ReferenceName("HEAD"), old_oid: 5e4f49e5210c338fb69b686bbb93de269b8553ab, new_oid: 47188f4370e273908ad28e56f3bba2704fac29d6, message: None }` ``` : O f13cbb5 23m (main, redacted-ref-0) xxxxxx xxxxxxxx xxxx |\ | @ 47188f4 20m x xxxx xx x xxxxxxxxxxx xx x xxxxxxxx x xxxx xx xxx xxx xxxxxx xxxxxxxx | o 5e4f49e 20m (redacted-ref-1) xxxxxx ``` ##### Event ID: 26, transaction ID: 24 (message: reference-transaction) 1. `RefUpdateEvent { timestamp: 1728333572.499676, event_tx_id: Id(24), ref_name: ReferenceName("HEAD"), old_oid: 0000000000000000000000000000000000000000, new_oid: 47188f4370e273908ad28e56f3bba2704fac29d6, message: None }` ``` : O f13cbb5 23m (main, redacted-ref-0) xxxxxx xxxxxxxx xxxx |\ | @ 47188f4 20m x xxxx xx x xxxxxxxxxxx xx x xxxxxxxx x xxxx xx xxx xxx xxxxxx xxxxxxxx | o 5e4f49e 20m (redacted-ref-1) xxxxxx ``` ##### Event ID: 21, transaction ID: 23 (message: hook-post-rewrite) 1. `CommitEvent { timestamp: 1728332449.094685, event_tx_id: Id(23), commit_oid: NonZeroOid(47188f4370e273908ad28e56f3bba2704fac29d6) }` 1. `CommitEvent { timestamp: 1728332449.094685, event_tx_id: Id(23), commit_oid: NonZeroOid(5e4f49e5210c338fb69b686bbb93de269b8553ab) }` 1. `RewriteEvent { timestamp: 1728332449.094685, event_tx_id: Id(23), old_commit_oid: 63110bccaa1c4b828ca055274a63f7cfaa1dac9f, new_commit_oid: 5e4f49e5210c338fb69b686bbb93de269b8553ab }` 1. `RewriteEvent { timestamp: 1728332449.094685, event_tx_id: Id(23), old_commit_oid: 4c53ab7df70333139dec5358e24e6fa5096d9016, new_commit_oid: 5e4f49e5210c338fb69b686bbb93de269b8553ab }` 1. `RewriteEvent { timestamp: 1728332449.094685, event_tx_id: Id(23), old_commit_oid: c4fb5b2714bf22de147aaa2a36e85e744173b7e0, new_commit_oid: 5e4f49e5210c338fb69b686bbb93de269b8553ab }` ``` : O f13cbb5 23m (main, redacted-ref-0) xxxxxx xxxxxxxx xxxx |\ | @ 47188f4 20m x xxxx xx x xxxxxxxxxxx xx x xxxxxxxx x xxxx xx xxx xxx xxxxxx xxxxxxxx | o 5e4f49e 20m (redacted-ref-1) xxxxxx ``` ##### Event ID: 20, transaction ID: 22 (message: reference-transaction) 1. `RefUpdateEvent { timestamp: 1728332449.07723, event_tx_id: Id(22), ref_name: ReferenceName("refs/heads/redacted-ref-1"), old_oid: c4fb5b2714bf22de147aaa2a36e85e744173b7e0, new_oid: 5e4f49e5210c338fb69b686bbb93de269b8553ab, message: None }` ``` : O f13cbb5 23m (main, redacted-ref-0) xxxxxx xxxxxxxx xxxx |\ | @ 47188f4 20m x xxxx xx x xxxxxxxxxxx xx x xxxxxxxx x xxxx xx xxx xxx xxxxxx xxxxxxxx | o 5e4f49e 20m (redacted-ref-1) xxxxxx ``` ##### Event ID: 19, transaction ID: 21 (message: reference-transaction) 1. `RefUpdateEvent { timestamp: 1728332448.991679, event_tx_id: Id(21), ref_name: ReferenceName("HEAD"), old_oid: 47188f4370e273908ad28e56f3bba2704fac29d6, new_oid: 5e4f49e5210c338fb69b686bbb93de269b8553ab, message: None }` ``` : O f13cbb5 23m (main, redacted-ref-0) xxxxxx xxxxxxxx xxxx |\ | @ 47188f4 20m x xxxx xx x xxxxxxxxxxx xx x xxxxxxxx x xxxx xx xxx xxx xxxxxx xxxxxxxx | o 5e4f49e 20m (redacted-ref-1) xxxxxx ```

Version of git-branchless

No response

Version of git

No response

arxanas commented 1 month ago

Hi @cf-coheretech, I believe this is a duplicate of https://github.com/arxanas/git-branchless/issues/1088. You could try to fix it 😉.