jhillyerd / plugin-git

Git aliases plugin for the Fish shell (similar to oh-my-zsh git)
MIT License
607 stars 85 forks source link

feat: use git init.defaultBranch if set #61

Closed tvlieg closed 3 years ago

tvlieg commented 3 years ago

My first line of fish shell script, so please let me know if did anything off the hook!

The main goal of this PR is to use the return value for git config --get init.defaultBranch, if set, for function __git.default_branch.fish.

jhillyerd commented 3 years ago

Hi, thanks for sending this, I wasn't aware of this setting.

Unfortunately, this change would break folks, as the global git setting will be returned if the local repository does not have it configured. As an example, this repo:

❯ omf cd git
git on master
❯ git config --get init.defaultBranch
main
tvlieg commented 3 years ago

That's a fair point; I've pushed a new commit that first checks for the existence of the configured defaultBranch, and only returns it if the current repo has that branch. Would that work?

tvlieg commented 3 years ago

Btw, I'm running into the issue in which I have a repo with both a master, but also a develop branch, in which I would like the default branch to be develop.

jhillyerd commented 3 years ago

Thanks!

tvlieg commented 3 years ago

And thank you as well for thinking along :)