FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Path issues windows · Issue #522 · nodegit/nodegit · GitHub

Repository navigation

Path issues windows #522

Description

When using patch.oldFile().path(); as per example seen here https://github.com/nodegit/nodegit/blob/master/examples/walk-history-for-file.js#L27 the path returned here stays with forward-slashes (/), where-as when you use nodejs' path it returns backwards-slashes. This now makes comparing part of the path quite hard.

The workaround I currently have it just to replace all slashes in the path string, so they match.

Activity

  1. tbranyen commented on Mar 30, 2015

    Member

    Git uses forward slashes internally, we should never ever change them to be back slashes.

  2. Globegitter commented on Mar 30, 2015

    Author

    ahh ok, so what is the recommend approach on windows then? Just not use the nodejs path module?

  3. tbranyen commented on Mar 30, 2015

    Member

    Node normalizes paths for you. Can you paste an example where this isn't true?

  4. Globegitter commented on Mar 30, 2015

    Author

    That is exactly the problem in this case - node normalizes the path to windows style, so path\to\file but git uses path/to/file.

  5. tbranyen commented on Mar 30, 2015

    Member
  6. tbranyen commented on Apr 20, 2015

    Member

    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, '/');

  7. maxkorp commented on Apr 22, 2015

    Collaborator

    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?

    path.normalize(patch.oldFile().path());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL