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

Fatal Git Error #132

Closed
rsekhar19 opened this issue Jul 10, 2017 · 8 comments
Closed

Fatal Git Error #132

rsekhar19 opened this issue Jul 10, 2017 · 8 comments

Comments

@rsekhar19
Copy link

rsekhar19 commented Jul 10, 2017

Hi,

My project is tracked by git. The coffee files are already in that repo. I do not understand why I get the following fatal git error. Any help is highly appreciated.

$ bulk-decaffeinate --config Dashboard.Web/bulk-decaffeinate.config.js -f Dashboard.Web/Scripts/config/RenameTablesCtrl.coffee convert
Verifying that decaffeinate can successfully convert these files...
1/1
Backing up files to .original.coffee...
1/1
Renaming files from .coffee to .js...
1/1
Generating the first commit: "decaffeinate: Rename RenameTablesCtrl.coffee from .coffee to .js"...
fatal: C:\project\Dashboard.Web\Scripts\config\RenameTablesCtrl.coffee: 'C:\project\Dashboard.Web\Scripts\config\RenameTablesCtrl.coffee' is outside repository

Error: fatal: C:\project\Dashboard.Web\Scripts\config\RenameTablesCtrl.coffee: 'C:\project\Dashboard.Web\Scripts\config\RenameTablesCtrl.coffee' is outside repository

    at C:\Users\rsappidi\AppData\Roaming\npm\node_modules\bulk-decaffeinate\node_modules\simple-git\promise.js:21:26
    at Git.<anonymous> (C:\Users\rsappidi\AppData\Roaming\npm\node_modules\bulk-decaffeinate\node_modules\simple-git\src\git.js:1195:18)
    at Git.<anonymous> (C:\Users\rsappidi\AppData\Roaming\npm\node_modules\bulk-decaffeinate\node_modules\simple-git\src\git.js:1272:21)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:886:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Thanks

@alangpierce
Copy link
Member

What directory are you running bulk-decaffeinate from? It runs all git commands from the working directory, I think, so you should make sure you're inside the right git repo when you run bulk-decaffeinate. Another thing to try is running git add C:\project\Dashboard.Web\Scripts\config\RenameTablesCtrl.coffee and make sure that works.

It's also possible that it's a Windows issue. I haven't tested Windows much, but certainly the intention is to support it.

@rsekhar19
Copy link
Author

I ran bulk-decaffeinate convert in the C:\project folder which has the .git directory.

I even tried the following, making a new folder and adding a coffee file.

$ mkdir tempCode

$ cd tempCode

$ vi tempfile.coffee

$ git init
Initialized empty Git repository in C:/tempCode/.git/

$ git st
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        tempfile.coffee

nothing added to commit but untracked files present (use "git add" to track)

$ git add tempfile.coffee
warning: LF will be replaced by CRLF in tempfile.coffee.
The file will have its original line endings in your working directory.

$ git commit -m 'Temp Commit'
[master (root-commit) 390d882] Temp Commit
 1 file changed, 2 insertions(+)
 create mode 100644 tempfile.coffee

$ bulk-decaffeinate convert
Verifying that decaffeinate can successfully convert these files...
1/1
Backing up files to .original.coffee...
1/1
Renaming files from .coffee to .js...
1/1
Generating the first commit: "decaffeinate: Rename tempfile.coffee from .coffee to .js"...
fatal: C:\tempCode\tempfile.coffee: 'C:\tempCode\tempfile.coffee' is outside repository

Error: fatal: C:\tempCode\tempfile.coffee: 'C:\tempCode\tempfile.coffee' is outside repository

    at C:\Users\rsappidi\AppData\Roaming\npm\node_modules\bulk-decaffeinate\node_modules\simple-git\promise.js:21:26
    at Git.<anonymous> (C:\Users\rsappidi\AppData\Roaming\npm\node_modules\bulk-decaffeinate\node_modules\simple-git\src\git.js:1195:18)
    at Git.<anonymous> (C:\Users\rsappidi\AppData\Roaming\npm\node_modules\bulk-decaffeinate\node_modules\simple-git\src\git.js:1272:21)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:886:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

@alangpierce
Copy link
Member

Thanks for the detailed repro steps! I bet Windows git has trouble with absolute paths or something, or maybe the simple-git library is doing something wrong. I'll take a look when I get a chance. In case it matters, what Windows version are you using, and is this just in cmd or something else (cygwin, powershell, windows subsystem for linux)?

Alternatively, happy to accept a PR if you want to dig into this. My guess is the fix will be to provide relative paths when invoking git rather than absolute paths.

Here's the line that invokes git:
https://github.com/decaffeinate/bulk-decaffeinate/blob/master/src/convert.js#L69

And here's an existing example of using relative paths:
https://github.com/decaffeinate/bulk-decaffeinate/blob/master/src/modernize/runFixImports.js#L30

@rsekhar19
Copy link
Author

I am using Windows 10 and invoking from git bash.

@alangpierce
Copy link
Member

Hmm, I just tried your same steps on Windows 10 with git bash and it seems to be working for me. (Technically it fails later when running eslint, but I'll investigate that as a separate issue.)

What git version are you using (git --version)? I ran it with 2.13.3.windows.1. Maybe try upgrading to the latest git bash and see if that helps?

It looks like there are potentially some issues with git bash and absolute paths:
moby/moby#24029
phpro/grumphp#55

@rsekhar19
Copy link
Author

My git version is 2.12.0.windows.1

By using relative paths to git I was able to make it work. However, it failed at the eslint step and was trying to figure out a fix for that.

eslint works from the command line but not from the program. I tried different ways to specify the path but none worked.

I will upgrade my git version and check if that fixes the original issue.

@rsekhar19
Copy link
Author

It works on my machine too with latest git version 2.13.3.windows.1

eslint still fails

@alangpierce
Copy link
Member

Interesting, good to hear your original issues is fixed. I filed #133 as a follow-up for the eslint issue.

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

No branches or pull requests

2 participants