vector-of-bool / vscode-gitflow

Gitflow integration for Visual Studio Code
90 stars 22 forks source link

error: "git" returned status 1 #10

Open xinde opened 7 years ago

xinde commented 7 years ago

when I select 'Initialize repository for gitflow' ,at last step,an error occurred

error: "git" returned status 1


windows 10 vs code 1.8.1

kevintechie commented 7 years ago

I get the same error.

Linux Mint vs code 1.8.1 git 2.11.0

ajsb85 commented 7 years ago

I get the same error.

image

vector-of-bool commented 7 years ago

I'm unable to reproduce the issue on my local systems, could I see some of the console output from the developer console when you try to run the failing commands?

ajsb85 commented 7 years ago

Hi @vector-of-bool

I can see this message with the command > Gitflow: Initialize repository for gitflow

[Extension Host] [gitflow] Execute git config --get gitflow.branch.master
[Extension Host] [gitflow] Command "git" returned code -4058: 
spawn git ENOENT: Error: spawn git ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
WARNING: Promise with no error callback:94
Object {exception: null, error: Error: spawn git ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess…, promise: n.C…s.d…e._oncancel, handler: undefined, id: 94…}
spawn git ENOENT
d-schiffner commented 7 years ago

I would believe, this error comes, because git is not in the path.

I had a look in the vscode discovery for the git config. They are using the @IGitService to access the internal git, which automatically detects the os specific git installation

ajsb85 commented 7 years ago

Hi @d-schiffner

Git works in VS Code.

image

I have only the GitHub Desktop app and their shell.

In the PATH it's not ready.

image

d-schiffner commented 7 years ago

Hi @ajsb85,

yes, VS Code searches internally for the correct path and then uses it. However, this plugin does not use the available service but instead calls git via shell, which is not defined.

Not tested workaround: Add git to path

vector-of-bool commented 7 years ago

@d-schiffner, thanks for the tips! I wasn't aware VSCode did that to find git. That should be helpful in fixing this problem now that I have a lead on what it actually going on.

ajsb85 commented 7 years ago

Hi @vector-of-bool so just use vscode.workspace.getConfiguration("git").get("path", "git") instead of "git"

d-schiffner commented 7 years ago

This only works, if you have defined a path there, or fall back to the normal assumption, that git is available from the path.

kevintechie commented 7 years ago

Git is in my path on linux, but I still get the error.

My debug console output is different, however:

[gitflow] Execute git config --get gitflow.branch.master
[gitflow] Command "git" returned code 1: 
[gitflow] Execute git config --get gitflow.branch.develop
[gitflow] Command "git" returned code 1: 
[gitflow] Execute git rev-parse --quiet --verify HEAD
[gitflow] Command "git" returned code 1: 
[gitflow] Execute git symbolic-ref HEAD refs/head/master
[gitflow] Command "git" returned code 0: 
[gitflow] Execute git commit --allow-empty --quiet -m Initial commit
[gitflow] Command "git" returned code 0: 
[gitflow] Execute git branch --no-color
[gitflow] Command "git" returned code 128: fatal: HEAD not found below refs/heads!
[gitflow] Execute git branch -r --no-color
[gitflow] Command "git" returned code 128: fatal: HEAD not found below refs/heads!
[gitflow] Execute git branch --no-color
[gitflow] Command "git" returned code 128: fatal: HEAD not found below refs/heads!
[gitflow] Execute git branch -r --no-color
[gitflow] Command "git" returned code 128: fatal: HEAD not found below refs/heads!
[gitflow] Execute git branch --no-track develop master
[gitflow] Execute git checkout develop
[gitflow] Command "git" returned code 128: fatal: HEAD not found below refs/heads!
[gitflow] Command "git" returned code 1: error: pathspec 'develop' did not match any file(s) known to git.
kevintechie commented 7 years ago

So it turns out that my error is caused because I was using a newly initialized repository without any commits. The git rev-parse --quiet --verify HEAD returned nothing causing git symbolic-ref HEAD refs/head/master to be executed. Unfortunately, refs/head/master is not a valid link. The path head should be heads.

The invalid HEAD state causes the rest of the script to fail and the extension return code to be 1.

The typo is in line 121.

vector-of-bool commented 7 years ago

Thanks, @d-schiffner, for the awesome PR. I've just pushed out the changes, and, hopefully, this will fix the problems with Git.

d-schiffner commented 7 years ago

@vector-of-bool: You're welcome. Keep up the good work ;)

jonathanfishbein1 commented 7 years ago

Hello I seem to still be experiencing this problem and suggestions on how I can fix it?

kevintechie commented 7 years ago

@jonathanfishbein1 are you starting with a repository that doesn't have any commits? If so, there is a bug that is not fixed by the latest release.

ajsb85 commented 7 years ago

After the changes in the new version of TypeScript you need to review in deep this extension @vector-of-bool

kevintechie commented 7 years ago

I have created a pull request to fix the typo in the symbolic-ref:

https://github.com/vector-of-bool/vscode-gitflow/pull/12

This bug will also cause the error where git will return 1.

vector-of-bool commented 7 years ago

Is any still experiencing this exact issue?

jsvg commented 7 years ago

Still experiencing here. Latest OSX and VS Code. Tried in both newly initialized git projects (with and w/o commits), and in existing projects. No luck. VSCode doesn't appear to have any other problems accessing git. Git is in path.

kevintechie commented 7 years ago

You will continue to get this error until the next release or you can clone the latest code and build it yourself.

vector-of-bool commented 7 years ago

Anyone still experiencing this issue in the latest version?

endquote commented 7 years ago

I just installed the extension on vscode for Mac and got this error after running "initialize repository for gitflow"

SeanRoberts commented 7 years ago

I also got the same error on VS Code for Mac. All other git functions work as expected.

xiagw commented 5 years ago

I just installed the extension on vscode for Mac and got this error after running "initialize repository for gitflow"

yes, same error. image

stephen-commits commented 3 years ago

This issue is still opened so I put it here. I faced the same problem when I created a new project, the solution I found is create the develop branch manually and initialize git flow command worked for me. I hope it will work for people facing the same problem.

ngrcode commented 1 year ago

this is bcs you haven't had master and develop as branch in your local