You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this is out of the scope of NodeGit, which is attempting to bind 1:1 to libgit2 and where possible provide some convenience over repetitive tasks. By allowing either Unix or Windows style, we'd be breaking a convention from within Git.
You can normalize with a simple enough replace regex: path = path.replace(/\\/g, '/');
Activity
tbranyen commentedon Mar 30, 2015
Git uses forward slashes internally, we should never ever change them to be back slashes.
Globegitter commentedon Mar 30, 2015
ahh ok, so what is the recommend approach on windows then? Just not use the nodejs
pathmodule?tbranyen commentedon Mar 30, 2015
Node normalizes paths for you. Can you paste an example where this isn't true?
Globegitter commentedon Mar 30, 2015
That is exactly the problem in this case - node normalizes the path to windows style, so
path\to\filebut git usespath/to/file.tbranyen commentedon Mar 30, 2015
Try using: https://nodejs.org/api/path.html#path_path_format_pathobject
tbranyen commentedon Apr 20, 2015
I think this is out of the scope of NodeGit, which is attempting to bind 1:1 to libgit2 and where possible provide some convenience over repetitive tasks. By allowing either Unix or Windows style, we'd be breaking a convention from within Git.
You can normalize with a simple enough replace regex:
path = path.replace(/\\/g, '/');maxkorp commentedon Apr 22, 2015
I agree that it's out of scope, but just a small suggestion, @Globegitter could you not call path.normalize on the returned value, like so?