Skip to content

Main branch deleted after git sync #476

@mikepqr

Description

@mikepqr

Description of the bug

I get an error (warning?) that the main branch could not be found every time I git sync after landing a change. I'm left on a detached HEAD (possibly this is expected?) and git sl fails (definitely not expected!). If I then explicitly checkout master I get back to a working state.

Expected behavior

git sync and git sl work without an error.

Actual behavior

$ git fetch
origin: Extents updated: 1283 transactions
origin: Updating from https://git.twitter.biz/source/objects/journals/32.bin
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  307k  100  307k    0     0   739k      0 --:--:-- --:--:-- --:--:--  739k
Replaying transactions: 100% (1283/1283), done.
cannot delete non-empty directory: reference-transaction.d

$ git branch
* master

$ git sync
Attempting rebase in-memory...
[1/1] Skipped commit (was already applied upstream): a618c8d3 TNB. Move overnight build to early morning
branchless: processing 1 rewritten commit
The application panicked (crashed).
Message:  A fatal error occurred:
   0: Could not find repository main branch
Location:
   /Users/mleewilliams/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/git-branchless-lib-0.3.12/src/git/repo.rs:404
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   0: branchless::git::repo::get_main_branch_oid with self=<Git repository at: "/Users/mleewilliams/workspace/source/.git/">
      at /Users/mleewilliams/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/git-branchless-lib-0.3.12/src/git/repo.rs:412
   1: branchless::core::rewrite::rewrite_hooks::warn_abandoned with effects=<Output fancy=false> repo=<Git repository at: "/Users/mleewilliams/workspace/source/.git/"> conn=Connection { path: Some("/Users/mleewilliams/workspace/source/.git/branchless/db.sqlite3") } event_log_db=<EventLogDb>
      at /Users/mleewilliams/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/git-branchless-lib-0.3.12/src/core/rewrite/rewrite_hooks.rs:193
   2: branchless::core::rewrite::rewrite_hooks::hook_post_rewrite with effects=<Output fancy=false> git_run_info=<GitRunInfo path_to_git="git" working_directory="/Users/mleewilliams/workspace/source" env=not shown> rewrite_type="rebase"
      at /Users/mleewilliams/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/git-branchless-lib-0.3.12/src/core/rewrite/rewrite_hooks.rs:105
Suggestion:
The main branch "master" could not be found in your repository
at path: "/Users/mleewilliams/workspace/source/.git/".
These branches exist: []
Either create it, or update the main branch setting by running:
    git config branchless.core.mainBranch <branch>
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
Location: /Users/mleewilliams/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/git-branchless-0.3.12/src/commands/mod.rs:298
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
branchless: running command: git checkout 10cacf4f994e837bf97e25f9d99760f9c2be49e9
⠖ Syncing commit stacks (5.0s)                                                                                       ░░░░░░░░░░░░░░░░░░░░ 0/1
Previous HEAD position was a618c8d3e49a4 TNB. Move overnight build to early morning
HEAD is now at 10cacf4f994e8 Docbird: Edit 12086 applied automatically from browser, without review. AUTOMATED_COMMIT=true
branchless: processing checkout
In-memory rebase succeeded.
Synced a618c8d3 TNB. Move overnight build to early morning
(HEAD detached at 10cacf4f994e8)

$ git sl
The application panicked (crashed).
Message:  A fatal error occurred:
   0: Could not find repository main branch
Location:
   /Users/mleewilliams/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/git-branchless-lib-0.3.12/src/git/repo.rs:404
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   0: branchless::git::repo::get_main_branch_oid with self=<Git repository at: "/Users/mleewilliams/workspace/source/.git/">
      at /Users/mleewilliams/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/git-branchless-lib-0.3.12/src/git/repo.rs:412
   1: git_branchless::commands::smartlog::smartlog with effects=<Output fancy=true> git_run_info=<GitRunInfo path_to_git="git" working_directory="/Users/mleewilliams/workspace/source" env=not shown> options=SmartlogOptions { show_hidden_commits: false, only_show_branches: false }
      at /Users/mleewilliams/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/git-branchless-0.3.12/src/commands/smartlog.rs:533
Suggestion:
The main branch "master" could not be found in your repository
at path: "/Users/mleewilliams/workspace/source/.git/".
These branches exist: []
Either create it, or update the main branch setting by running:
    git config branchless.core.mainBranch <branch>
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
Location: /Users/mleewilliams/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/git-branchless-0.3.12/src/commands/mod.rs:298
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
(HEAD detached at 10cacf4f994e8)

$ git checkout master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Switched to a new branch 'master'
Your branch is up to date with 'origin/master'.
branchless: processing checkout

$ git sl
⋮
◆ 10cacf4 2m (remote origin/master, ᐅ master) Docbird: Edit 12086 applied automatically from browser, without review. AUTOMATED_COMMIT=true

Version of rustc

rustc 1.59.0

Automated bug report

#### Software version

git-branchless 0.3.12

#### Operating system

macOS 12.5 (Darwin 21.6.0)

#### Command-line

```bash
/Users/mleewilliams/.cargo/bin/git-branchless bug-report 

Environment variables

SHELL=/bin/bash
EDITOR=nvim

Git version

> git version 
git version 2.25.0.853.g5575ef6-twtrsrc

Events

Show 5 events
Event ID: 451, transaction ID: 475
  1. RefUpdateEvent { timestamp: 1658965620.970999, event_tx_id: EventTransactionId(475), ref_name: "HEAD", old_oid: 10cacf4f994e837bf97e25f9d99760f9c2be49e9, new_oid: 10cacf4f994e837bf97e25f9d99760f9c2be49e9, message: None }
:
@ 10cacf4 24m (redacted-ref-0) xxxxxxxx xxxx xxxxx xxxxxxx xxxxxxxxxxxxx xxxx xxxxxxxx xxxxxxx xxxxxxx xxxxxxxxxxxxxxxxxxxxx
:
O 3d197ce 3m (remote origin/master) xxxxxxxxxxxxxxxxxx xxx xxxx xxxxx xxxxxxxx
Event ID: 449, transaction ID: 474
  1. RewriteEvent { timestamp: 1658965570.51185, event_tx_id: EventTransactionId(474), old_commit_oid: a618c8d3e49a48df84c072281958c4059ce820d6, new_commit_oid: 0000000000000000000000000000000000000000 }
  2. RefUpdateEvent { timestamp: 1658965596.124385, event_tx_id: EventTransactionId(474), ref_name: "HEAD", old_oid: a618c8d3e49a48df84c072281958c4059ce820d6, new_oid: 10cacf4f994e837bf97e25f9d99760f9c2be49e9, message: None }
:
@ 10cacf4 24m (redacted-ref-0) xxxxxxxx xxxx xxxxx xxxxxxx xxxxxxxxxxxxx xxxx xxxxxxxx xxxxxxx xxxxxxx xxxxxxxxxxxxxxxxxxxxx
:
O 3d197ce 3m (remote origin/master) xxxxxxxxxxxxxxxxxx xxx xxxx xxxxx xxxxxxxx
Event ID: 448, transaction ID: 472
  1. RewriteEvent { timestamp: 1658944229.534632, event_tx_id: EventTransactionId(472), old_commit_oid: 2b250d3c4fd0fcf156cc8eaf5f4b95814c9fcc22, new_commit_oid: a618c8d3e49a48df84c072281958c4059ce820d6 }
:
@ 10cacf4 24m (redacted-ref-0) xxxxxxxx xxxx xxxxx xxxxxxx xxxxxxxxxxxxx xxxx xxxxxxxx xxxxxxx xxxxxxx xxxxxxxxxxxxxxxxxxxxx
:
O 3d197ce 3m (remote origin/master) xxxxxxxxxxxxxxxxxx xxx xxxx xxxxx xxxxxxxx
Event ID: 447, transaction ID: 471
  1. CommitEvent { timestamp: 1658944228.0, event_tx_id: EventTransactionId(471), commit_oid: NonZeroOid(a618c8d3e49a48df84c072281958c4059ce820d6) }
:
@ 10cacf4 24m (redacted-ref-0) xxxxxxxx xxxx xxxxx xxxxxxx xxxxxxxxxxxxx xxxx xxxxxxxx xxxxxxx xxxxxxx xxxxxxxxxxxxxxxxxxxxx
:
O 3d197ce 3m (remote origin/master) xxxxxxxxxxxxxxxxxx xxx xxxx xxxxx xxxxxxxx
Event ID: 446, transaction ID: 470
  1. CommitEvent { timestamp: 1658943942.0, event_tx_id: EventTransactionId(470), commit_oid: NonZeroOid(2b250d3c4fd0fcf156cc8eaf5f4b95814c9fcc22) }
:
@ 10cacf4 24m (redacted-ref-0) xxxxxxxx xxxx xxxxx xxxxxxx xxxxxxxxxxxxx xxxx xxxxxxxx xxxxxxx xxxxxxx xxxxxxxxxxxxxxxxxxxxx
:
O 3d197ce 3m (remote origin/master) xxxxxxxxxxxxxxxxxx xxx xxxx xxxxx xxxxxxxx
```

Version of git-branchless

No response

Version of git

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions