Skip to content

Cloning locks up when more than 3 at the same time.  #364

@drieks

Description

@drieks

Hello,

it seems that there is a problem with ssh agent support. this example works fine:

var remote = "https://github.com/nodegit/nodegit.git"
var git = require("nodegit");

var fs = require("fs");
var path = require("path");
function rmdirSync(path) {
    var files = [];
    if( fs.existsSync(path) ) {
        files = fs.readdirSync(path);
        files.forEach(function(file,index){
            var curPath = path + "/" + file;
            if(fs.lstatSync(curPath).isDirectory()) { // recurse
                rmdirSync(curPath);
            } else { // delete file
                fs.unlinkSync(curPath);
            }
        });
        fs.rmdirSync(path);
    }
}

function clone(to) {
    rmdirSync(to);
    return git.Clone.clone(remote, to).then(function () {
        console.log("ok!", to);
    }, function (err) {
        console.log("failed!", to, err);
    });
}

console.log("start");

clone("/tmp/nodegit-testA").then(function() {
    clone("/tmp/nodegit-testB").then(function() {
        clone("/tmp/nodegit-testC").then(function() {
            clone("/tmp/nodegit-testD").then(function() {
                clone("/tmp/nodegit-testE").then(function() {
                    for (var i = 0; i < 10; i++) {
                        var to = "/tmp/nodegit-test" + i;
                        console.log("start", i);
                        clone(to);
                    }
                });
            });
        });
    });
});

console.log("end");

output:

start
end
ok! /tmp/nodegit-testA
ok! /tmp/nodegit-testB
ok! /tmp/nodegit-testC
ok! /tmp/nodegit-testD
ok! /tmp/nodegit-testE
start 0
start 1
start 2
start 3
start 4
start 5
start 6
start 7
start 8
start 9
ok! /tmp/nodegit-test2
ok! /tmp/nodegit-test3
ok! /tmp/nodegit-test1
ok! /tmp/nodegit-test0
ok! /tmp/nodegit-test4
ok! /tmp/nodegit-test5
ok! /tmp/nodegit-test6
ok! /tmp/nodegit-test7
ok! /tmp/nodegit-test8
ok! /tmp/nodegit-test9

This is fine and expected, but when I switch to using ssh agent key :

return git.Clone.clone(remote, to, {
    remoteCallbacks: {
        credentials: function (url, userName) {
            return git.Cred.sshKeyFromAgent("");
        }
    }
}).then(function () {

(and a git ssh server) then nodegit can checkout one by one as before:

ok! /tmp/nodegit-testA
ok! /tmp/nodegit-testB
ok! /tmp/nodegit-testC
ok! /tmp/nodegit-testD
ok! /tmp/nodegit-testE

but will hang when called multiple times at once and never return. (No ok or failed messages for /tmp/nodegit-test0 - /tmp/nodegit-test9)

Direcotrys /tmp/nodegit-test0 to /tmp/nodegit-test3 are created:

find /tmp/nodegit-test0/
/tmp/nodegit-test0/
/tmp/nodegit-test0/.git
/tmp/nodegit-test0/.git/config
/tmp/nodegit-test0/.git/HEAD
/tmp/nodegit-test0/.git/description
/tmp/nodegit-test0/.git/info
/tmp/nodegit-test0/.git/info/exclude
/tmp/nodegit-test0/.git/hooks
/tmp/nodegit-test0/.git/hooks/README.sample
/tmp/nodegit-test0/.git/refs
/tmp/nodegit-test0/.git/refs/tags
/tmp/nodegit-test0/.git/refs/heads
/tmp/nodegit-test0/.git/objects
/tmp/nodegit-test0/.git/objects/pack
/tmp/nodegit-test0/.git/objects/info

but there is no working copy.

Can anyone give me he hint what I'm doing wrong? it is not allowed to call multiple checkout commands at the same time?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions