Skip to content

index.removeByPath stops execution #97

Closed

Description

@dcolens

trying to use removeByPath by using repo.openIndex, index.read, index.removeByPath and the scripts stops execution, no error, no logs, return code is 0.

nodegit@0.1.0
node v0.10.13
OS: OSX 10.8.5

var git = require('nodegit')

git.Repo.open(repoPath, function(openError, repo) {
    if (openError) throw openError;
        repo.openIndex(function(openIndexError, index) {
        if (openIndexError) throw openIndexError;
        index.read(function(readError) {
            if (readError) throw readError;
            index.removeByPath(fileName, function(removeByPathError,r) {
                if (removeByPathError) throw removeByPathError; 
                console.log('ok');
            });
        });
    });
});

Steps to repro:

  • set repoPath to the path of a checked out repo
  • set fileName to the filename to delete from the repo

Expectations: prints 'ok' or throws removeByPathError
Actual: process stops without error.

Activity

  1. nkallen commented on Oct 1, 2013

    @nkallen
    Contributor

    Probably a segfault. I wont be able to get to this for a few days. You can speed up the process by running this in gdb and pasting the backtrace.

  2. nkallen commented on Oct 1, 2013

    @nkallen
    Contributor

    Actually not a segfault. It turns out index.removeByPath(fileName) is not async; it doesn't take a callback, so just call it directly and it will throw if there is an error.

    Looking through the libgit2 source code, I believe this is correct behavior (it does not IO, unlike index.addByPath which reads from the filesystem).

  3. dcolens commented on Oct 2, 2013

    @dcolens
    ContributorAuthor

    damn stupid me!

    Thanks :)

    Did
    On 01 Oct 2013, at 19:44, Nick Kallen notifications@github.com wrote:

    Actually not a segfault. It turns out index.removeByPath(fileName) is not async; it doesn't take a callback, so just call it directly and it will throw if there is an error.

    Looking through the libgit2 source code, I believe this is correct behavior (it does not IO, unlike index.addByPath which reads from the filesystem).

    —
    Reply to this email directly or view it on GitHub.

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