jung-kim / atom-ungit

Atom plugin for Ungit project
MIT License
75 stars 12 forks source link

error: during stashing on windows atom #43

Closed JasCodes closed 8 years ago

JasCodes commented 8 years ago

Using windows 10 and got following error. Error: Ungit tried to run a git command that resulted in an unhandled error. An automatic bug report was sent.

Command

-c color.ui=false -c core.quotepath=false -c core.pager=cat stash pop stash@{0} Error

fatal: ambiguous argument 'stash@0': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]' Stderr

fatal: ambiguous argument 'stash@0': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]'

jung-kim commented 8 years ago

Can you confirm that this happens when you try to drop the stash or restore the stash?

Also can you confirm that running below work in windows 10?

git stash pop stash@`{0`}
JasCodes commented 8 years ago

For this in cmd.exe win10 : git stash pop stash@{0}

fatal: ambiguous argument 'stash@0': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]'

Although following cmds do work git stash pop stash@{0} git stash pop stash@"{0}" git stash pop stash@'{0}'

Let me know if you need something more.

Thx Jas

jung-kim commented 8 years ago

That's strange, error message is complaining about git stash pop stash@{0}. I guess somehow node child_process spawns a power shell instance but you are trying with normal terminal, or vice versa.

But whatever child_process spawns is eating up the bracket and reading stash@{0} as stash@0.

jung-kim commented 8 years ago

can you try one more thing? is git stash pop stash@\{0\} working for you?

If that works and want to go above and beyond, can you manually change ungit's code to see if this fixes for you? You would have to change this line to below.

git(['stash', type, 'stash@\{' + req.params['id'] + '\}'], req.query['path'])

(ungit source is more then likely to be found via npm list -g)

JasCodes commented 8 years ago

Hi there Sorry in my last response there were some issues while posting. Let me post again correctly.

JasCodes commented 8 years ago

--> Corrected For this in cmd.exe win10 : git stash pop stash{0}

fatal: ambiguous argument 'stash@0': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]'

Although following cmds do work git stash pop stash@{0} git stash pop stash@"{0}" git stash pop stash@'{0}'

Let me know if you need something more.

Thx Jas

JasCodes commented 8 years ago

double backslash worked for me but not single as suggested by you. git(['stash', type, 'stash@\{' + req.params['id'] + '\}'], req.query['path'])

Jas

jung-kim commented 8 years ago

Can you confirm that below solution works?

I really wanted to have a command that works for both windows and *nix but it seems like I have to handle it conditionally as double bracket doesn't work for mac.

app.delete(exports.pathPrefix + '/stashes/:id', ensureAuthenticated, ensurePathExists, function(req, res){
    var type = req.query.pop === 'true' ? 'pop' : 'drop';
    var bracketEscape = /^win/.test(process.platform) ? '\\' : '';
    git(['stash', type, 'stash@' +  bracketEscape + '{' + req.params['id'] + bracketEscape + '}'], req.query['path'])
      .always(jsonResultOrFail.bind(null, res))
      .always(emitGitDirectoryChanged.bind(null, req.query['path']))
      .always(emitWorkingTreeChanged.bind(null, req.query['path']))
      .start();
  });
jung-kim commented 8 years ago

Oh and thank you so much for discovering and debugging this issue with me.

JasCodes commented 8 years ago

Hey np. Thx for awesome plugin as well :).

The above patch do work on my win10 so you are good to go with the patch.

Thx Jas

jung-kim commented 8 years ago

Also, you would have to upgrade ungit itself since this is a fix for ungit itself once new ungit is published.

or just be content with manual fix you just did... :D

JasCodes commented 8 years ago

Pretty contented; No OCD's :)

Thx for patching it.