salcode / salcode-git

My Git configuration.
MIT License
3 stars 1 forks source link

Show branch name when using - with is-up-to-date-with #34

Closed salcode closed 1 month ago

salcode commented 4 months ago

I'm a big fan of the git is-up-to-date-with alias added in #28

e.g.

$ git is-up-to-date-with main
Yes, this branch is up to date with main

It Supports the Previous Branch with -

I'm glad this alias supports - for the previous branch 🎉

What I don't like is using - displays @{-1} instead of the branch name 🙁

$ git is-up-to-date-with -
Yes, this branch is up to date with @{-1}

Possible Solution

I think if we replace

https://github.com/salcode/salcode-git/blob/49d973dadedddf789f1ebd01f2a44cadbdd3ef5f/gitconfig#L24

with

branch=$(git rev-parse --abbrev-ref @{-1}); \

it will output the branch name when using -

e.g.

$ git is-up-to-date-with -
Yes, this branch is up to date with main

Related Work

We should probably update https://salferrarello.com/is-git-branch-up-to-date/ with this change as well.