Skip to content

Potential example issue in add-and-commit.js L45-48 #409

Closed

Description

@jeffwilcox

At line 45 of https://github.com/nodegit/nodegit/blob/master/examples/add-and-commit.js#L45 the sample calls return index.addByPath(fileName); line 48 then calls the same method but with the directory name as well: return index.addByPath(path.join(directoryName, fileName));

Should l45 be removed? They feel redundant, and in the case that you're working with a subdirectory and similarly named files (like index.html), it's possible that this code could actually add two different fles to the index...

Activity

  1. tbranyen commented on Feb 16, 2015

    @tbranyen
    Member

    That's an interesting point, I hadn't noticed that before. I'd be inclined to agree that 45 should be removed. Have you tested that it still works as expected with it gone?

  2. jeffwilcox commented on Feb 16, 2015

    @jeffwilcox
    ContributorAuthor

    I haven't tested that way, as I'm actually not able to get file adds to work at all right now in my local development environment.

    I suspect user error on my part

  3. johnhaley81 commented on Feb 17, 2015

    @johnhaley81
    Collaborator

    That's committing 2 different files (and I can see how that would be hard to notice).

    I'll modify the example so that it's more clear.

  4. jeffwilcox commented on Feb 17, 2015

    @jeffwilcox
    ContributorAuthor

    Got it... thx.

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