Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't auto-apply stash when switching branches #959

Open
dkerkow opened this issue Sep 9, 2017 · 7 comments
Open

Don't auto-apply stash when switching branches #959

dkerkow opened this issue Sep 9, 2017 · 7 comments

Comments

@dkerkow
Copy link

dkerkow commented Sep 9, 2017

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.

@jung-kim
Copy link
Collaborator

jung-kim commented Sep 10, 2017

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,

@dkerkow
Copy link
Author

dkerkow commented Sep 11, 2017

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"):
auswahl_059

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.

@jung-kim
Copy link
Collaborator

jung-kim commented Sep 11, 2017

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

@dkerkow
Copy link
Author

dkerkow commented Sep 14, 2017

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.

@ylecuyer
Copy link
Contributor

ylecuyer commented Jan 29, 2018

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

@jung-kim
Copy link
Collaborator

Yes we need to add english language dependency to README as we parse git result to detect it's states.

@PhoneixS
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants