git-branchless icon indicating copy to clipboard operation
git-branchless copied to clipboard

If there is no history, an error occurs.

Open black7375 opened this issue 1 year ago • 3 comments

Description of the bug

After the initialization of the git-branchless, panic occurs without any commit.

↳ git init           
Alias tip: g init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
Initialized empty Git repository in /tmp/branchless/.git

↳ git branchless init
Alias tip: g branchless init
Created config file at /tmp/branchless/.git/branchless/config
Your main branch name could not be auto-detected!
Examples of a main branch: master, main, trunk, etc.
See https://github.com/arxanas/git-branchless/wiki/Concepts#main-branch
Enter the name of your main branch: master
Installing hook: post-commit
Installing hook: post-merge
Installing hook: post-rewrite
Installing hook: post-checkout
Installing hook: pre-auto-gc
Installing hook: reference-transaction
Successfully installed git-branchless.
To uninstall, run: git branchless init --uninstall

↳ git sl             
Alias tip: g sl
The application panicked (crashed).
Message:  A fatal error occurred: 
   0: Could not find repository main branch

Location:
   /home/black7375/.cargo/registry/src/github.com-1ecc6299db9ec823/git-branchless-lib-0.6.0/src/core/repo_ext.rs:74

Suggestion: 
The main branch "master" could not be found in your repository
at path: "/tmp/branchless/.git/".
These branches exist: []
Either create it, or update the main branch setting by running:

    git branchless init --main-branch <branch>

Note that remote main branches are no longer supported as of v0.6.0. See
https://github.com/arxanas/git-branchless/discussions/595 for more details.

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
Location: /home/black7375/.cargo/registry/src/github.com-1ecc6299db9ec823/git-branchless-0.6.0/src/commands/mod.rs:464

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Expected behavior

Instead of panic, it is better to get a message that there is no commit.


Sample message:

your current branch 'master' does not have any commits yet

Actual behavior

No response

Version of rustc

rustc 1.67.0-nightly (01fbc5ae7 2022-12-07)

Automated bug report

Software version

git-branchless 0.6.0

Operating system

Linux 6.0.11-zen1-1-zen

Command-line

/home/black7375/.cargo/bin/git-branchless bug-report 

Environment variables

SHELL=/usr/bin/zsh
EDITOR=vim

Git version

> git version 
git version 2.38.1

Hooks

Show 6 hooks
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 post-checkout
#!/bin/sh
## START BRANCHLESS CONFIG

git branchless hook-post-checkout "$@"
## 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

Error: Could not find repository main branch

Version of git-branchless

No response

Version of git

No response

black7375 avatar Dec 08 '22 12:12 black7375