Don't auto-apply stash when switching branches
dkerkow opened this issue · 7 comments
I may get something wrong here, but it is not clear to me why ungit automatically applies the stash I created on one branch to another branch on checkout. At first, I thought I might have some customized setting triggering that behavior, but I could not find anything like that.
From my understanding of git (and what I use as workflow), the idea is that you can use ´git stash´ to save your uncommited changes on Branch A, checkout another branch B, do some work, get back to Branch A, apply the stash and find everything like it was the moment you left.
Maybe also relevant: If I don't have any stashes and change branches, ungit will throw an error, reporting that theres no stash available.
That is odd.... Ungit has a default flag autoStashAndPop
that "stash -> operation -> stash pop" if there are modified files. This seems to be working fine on my end and it is super odd to me that it will throw an error when there are no changes at all.
Could you possibly share below data?
- Browser side error message you receive when you do this operation without any changes
- server side log while doing above with
logGitCommands
set to true. - git version
Thanks,
Ok, found the config flag myself in the meantime, and setting it to false fixes the issue for me.
But when it is enabled and I switch between branches without any local changes and without any stashes, I get the following error (german message means "No stash found"):
Log message is:
2017-09-11T15:16:30.637Z - warn: Responding with ERROR:
{"isGitError":true,
"errorCode":"unknown",
"command":"-c color.ui=false -c core.quotepath=false -c core.pager=cat stash pop",
"workingDirectory":"/home/daniel/projects/xxx",
"error":"Kein Stash-Eintrag gefunden.\n",
"message":"Kein Stash-Eintrag gefunden.",
"stderr":"Kein Stash-Eintrag gefunden.\n",
"stdout":""}
Git version is 2.7.4 (Ubuntu 16.04)
Especially the config option core.pager=cat stash pop
in the git call seems a little odd to me, as I would expect a pager and not another git call. I tried to reinstall ungit to see if it's an artifact from an early version, because I've been running ungit for quite a while now, but that didn't change anything. The issue itself is pretty old, too, but I never got to take a look after it.
Oh wow, can you please try changing git language to english and try it? This article may help you.
My suspicion is that git language being german confused ungi as ungit does parse results of git command to detect it's state
You are right with your suspicion: changing language of git to english using alias git='LANGUAGE=en_US.UTF-8 git'
does not trigger the bug. Stash is not being touched upon changing branches.
I had the same issue. Adding alias ungit='LANGUAGE=en_US.UTF-8 ungit'
fixes the problem.
@jung-kim maybe there should be a better handling of no stash or add git to be in english as a requirement in the README
Edit: The LANG hack doesn't work for me because LANGUAGE is set system wide to fr_FR and it takes precedence over LANG
Yes we need to add english language dependency to README as we parse git result to detect it's states.
I don't know if it's possible but can it check the current language, change the language to English, run the command, and then restore the language?