arxanas / git-branchless

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

main branch rewritten as 00000000 #1217

Open ppwwyyxx opened 7 months ago

ppwwyyxx commented 7 months ago

Description of the bug

  1. Create a commit locally with a branch name and create a PR from it
  2. Merge the PR on github. With fast-forward merge (no merge commit)
  3. In the local repo, do git commit --amend, then immediately save and exit. Do not apply any actual changes in the amend window.
  4. do git restack
  5. do git sync --pull

Expected behavior

No "rewritten as 000000" appears

Actual behavior

image

Version of rustc

rustc 1.73.0 (cc66ad468 2023-10-03)

Automated bug report

#### Software version

git-branchless 0.8.0

#### Command-line

```bash
/home/XXX/.cargo/bin/git-branchless bug-report 

Environment variables

SHELL=/bin/zsh
EDITOR=nvim

Git version

> git version 
git version 2.25.1

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: 38, transaction ID: 25 (message: sync) 1. `RefUpdateEvent { timestamp: 1707671477.1453016, event_tx_id: EventTransactionId(25), ref_name: ReferenceName("refs/heads/redacted-ref-0"), old_oid: 79b98014e60919903c48c9971b3966322f994fa9, new_oid: 0000000000000000000000000000000000000000, message: None }` 1. `RewriteEvent { timestamp: 1707671477.1720936, event_tx_id: EventTransactionId(25), old_commit_oid: 79b98014e60919903c48c9971b3966322f994fa9, new_commit_oid: 0000000000000000000000000000000000000000 }` 1. `WorkingCopySnapshot { timestamp: 1707671477.1937, event_tx_id: EventTransactionId(25), head_oid: 79b98014e60919903c48c9971b3966322f994fa9, commit_oid: NonZeroOid(d07687388112a95fb07afb1cfaaba9dfc1a2b1e1), ref_name: None }` 1. `RefUpdateEvent { timestamp: 1707671477.2118502, event_tx_id: EventTransactionId(25), ref_name: ReferenceName("HEAD"), old_oid: 79b98014e60919903c48c9971b3966322f994fa9, new_oid: 0c219685cd7ef34f297fc191650a03a8ca69df68, message: None }` ``` : % 0c21968 6m (rewritten as 00000000) (master) xxxxxxxx ``` ##### Event ID: 37, transaction ID: 23 (message: restack) 1. `RefUpdateEvent { timestamp: 1707671457.734186, event_tx_id: EventTransactionId(23), ref_name: ReferenceName("refs/heads/redacted-ref-0"), old_oid: 154b1cbbbf6a8b2767e14aaef85976799d1459b0, new_oid: 79b98014e60919903c48c9971b3966322f994fa9, message: None }` ``` : % 0c21968 6m (rewritten as 79b98014) (master) xxxxxxxx ``` ##### Event ID: 36, transaction ID: 22 (message: hook-post-rewrite) 1. `RewriteEvent { timestamp: 1707671457.6811366, event_tx_id: EventTransactionId(22), old_commit_oid: 154b1cbbbf6a8b2767e14aaef85976799d1459b0, new_commit_oid: 79b98014e60919903c48c9971b3966322f994fa9 }` ``` : % 0c21968 6m (rewritten as 79b98014) (master) xxxxxxxx ``` ##### Event ID: 35, transaction ID: 21 (message: post-commit) 1. `CommitEvent { timestamp: 1707671456.0, event_tx_id: EventTransactionId(21), commit_oid: NonZeroOid(79b98014e60919903c48c9971b3966322f994fa9) }` ``` : % 0c21968 6m (rewritten as 154b1cbb) (master) xxxxxxxx ``` ##### Event ID: 31, transaction ID: 20 (message: reword) 1. `RefUpdateEvent { timestamp: 1707671451.2447162, event_tx_id: EventTransactionId(20), ref_name: ReferenceName("refs/heads/redacted-ref-0"), old_oid: 0c219685cd7ef34f297fc191650a03a8ca69df68, new_oid: 154b1cbbbf6a8b2767e14aaef85976799d1459b0, message: None }` 1. `RewriteEvent { timestamp: 1707671451.2619314, event_tx_id: EventTransactionId(20), old_commit_oid: 0c219685cd7ef34f297fc191650a03a8ca69df68, new_commit_oid: 154b1cbbbf6a8b2767e14aaef85976799d1459b0 }` 1. `WorkingCopySnapshot { timestamp: 1707671451.2790852, event_tx_id: EventTransactionId(20), head_oid: 0c219685cd7ef34f297fc191650a03a8ca69df68, commit_oid: NonZeroOid(71683f298583a6df722ff286ae5dc6cd18a7a250), ref_name: None }` 1. `RefUpdateEvent { timestamp: 1707671451.2962728, event_tx_id: EventTransactionId(20), ref_name: ReferenceName("HEAD"), old_oid: 0c219685cd7ef34f297fc191650a03a8ca69df68, new_oid: 154b1cbbbf6a8b2767e14aaef85976799d1459b0, message: None }` ``` : % 0c21968 6m (rewritten as 154b1cbb) (master) xxxxxxxx ```


### Version of `git-branchless`

_No response_

### Version of `git`

_No response_