gitext-rs / git-stack

Stacked branch management for Git
Apache License 2.0
505 stars 19 forks source link

git stack --pull issue with a feature branch with no commits #142

Closed amardeep closed 2 years ago

amardeep commented 2 years ago

Description

When there is a feature branch with HEAD same as local master HEAD - for eg. if I started a feature branch from master, but haven't gotten around to actually committing anything yet - doing a git stack --pull doesn't update that branch, and I have to manually rebase that branch on main. Is this expected behaviour?

For eg., consider following steps:

Version

git-stack 0.4.8

Steps to reproduce

$ git clone https://github.com/epage/git-stack.git

# change main to point to any older commit to check behaviour for git stack --pull
$ git reset --hard HEAD^
HEAD is now at 844b115 chore: Ease debugging

$ git-stack
main (3 behind) chore: Ease debugging

$ git checkout -b feature1

$ git-stack --pull
From https://github.com/epage/git-stack
 * branch            main       -> FETCH_HEAD
feature1 (no remote) chore: Ease debugging
└── main Merge pull request #141 from epage/onto
To undo, run `git branch-stash pop git-stack`

# After manual rebase
$ git rebase main
Successfully rebased and updated refs/heads/feature1.

$ git stack
feature1 (no remote), main Merge pull request #141 from epage/onto

Actual Behaviour

after git stack --pull, I see:

From https://github.com/epage/git-stack
 * branch            main       -> FETCH_HEAD
feature1 (no remote) chore: Ease debugging
└── main Merge pull request #141 from epage/onto

Expected Behaviour

I was expecting git stack to be

feature1 (no remote), main Merge pull request #141 from epage/onto

Debug Output

No response

epage commented 2 years ago

Thanks for reporting this!

Yes, this exists but it isn't ideal and we should do better.