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

Fixes segfault issue recorded in #406 by tbranyen · Pull Request #419 · nodegit/nodegit · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cc  (1) .js  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
14 changes: 14 additions & 0 deletions generate/templates/partials/field_accessors.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@
return;
}

{% each field.args|argsInfo as arg %}
{% if arg.name == "payload" %}
{%-- Do nothing --%}
{% elsif arg.isJsArg %}
if (baton->{{ arg.name }} == NULL) {
{% if arg.cType == "const char *" %}
baton->{{ arg.name }} = "";
{% elsif arg.cType == "unsigned int" %}
baton->{{ arg.name }} = 0;
{% endif %}
}
{% endif %}
{% endeach %}

Local<Value> argv[{{ field.args|jsArgsCount }}] = {
{% each field.args|argsInfo as arg %}
{% if arg.name == "payload" %}
Expand Down
75 changes: 56 additions & 19 deletions test/tests/clone.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe("Clone", function() {
var http = local("../repos/http");
var https = local("../repos/https");
var ssh = local("../repos/ssh");
var sshManual = local("../repos/sshmanual");
var git = local("../repos/git");
var file = local("../repos/file");

Expand All @@ -22,15 +21,15 @@ describe("Clone", function() {
// Set a reasonable timeout here now that our repository has grown.
this.timeout(15000);

function prepTestAndClean(url, location, opts) {
return fse.remove(location)
.then(function() {
return Clone.clone(url, location, opts);
})
.then(function(repo) {
assert.ok(repo instanceof Repository);
});
}
beforeEach(function() {
return NodeGit.Promise.all([
fse.remove(http),
fse.remove(https),
fse.remove(ssh),
fse.remove(git),
fse.remove(file)
]).catch(function unhandledFunction() {});
});

it.skip("can clone with http", function() {
var url = "http://github.com/nodegit/test.git";
Expand All @@ -42,7 +41,9 @@ describe("Clone", function() {
}
};

return prepTestAndClean(url, http, opts);
return Clone.clone(url, http, opts).then(function(repo) {
assert.ok(repo instanceof Repository);
});
});

it("can clone with https", function() {
Expand All @@ -55,28 +56,36 @@ describe("Clone", function() {
}
};

return prepTestAndClean(url, https, opts);
return Clone.clone(url, https, opts).then(function(repo) {
assert.ok(repo instanceof Repository);
});
});

it("can clone with ssh", function() {
var url = "git@github.com:nodegit/test.git";
var opts = {
ignoreCertErrors: 1,
remoteCallbacks: {
certificateCheck: function() {
return 1;
},
credentials: function(url, userName) {
return NodeGit.Cred.sshKeyFromAgent(userName);
}
}
};

return prepTestAndClean(url, ssh, opts);
return Clone.clone(url, ssh, opts).then(function(repo) {
assert.ok(repo instanceof Repository);
});
});

it("can clone with ssh while manually loading a key", function() {
var url = "git@github.com:nodegit/test.git";
var opts = {
ignoreCertErrors: 1,
remoteCallbacks: {
certificateCheck: function() {
return 1;
},
credentials: function(url, userName) {
return NodeGit.Cred.sshKeyNew(
userName,
Expand All @@ -87,20 +96,48 @@ describe("Clone", function() {
}
};

return prepTestAndClean(url, sshManual, opts);
return Clone.clone(url, ssh, opts).then(function(repo) {
assert.ok(repo instanceof Repository);
});
});

it("can clone with git", function() {
var url = "git://github.com/nodegit/test.git";
var opts = { ignoreCertErrors: 1 };
var opts = {
remoteCallbacks: {
certificateCheck: function() {
return 1;
}
}
};

return prepTestAndClean(url, git, opts);
return Clone.clone(url, git, opts).then(function(repo) {
assert.ok(repo instanceof Repository);
});
});

it("can clone with filesystem", function() {
var prefix = process.platform === "win32" ? "" : "file://";
var url = prefix + local("../repos/empty");

return prepTestAndClean(url, file);
return Clone.clone(url, file).then(function(repo) {
assert.ok(repo instanceof Repository);
});
});

it("will not segfault when accessing a url without username", function() {
var url = "https://github.com/nodegit/private";

return Clone.clone(url, git, {
remoteCallbacks: {
certificateCheck: function() {
return 1;
},
credentials: function() {
return NodeGit.Cred.userpassPlaintextNew("fake-token",
"x-oauth-basic");
}
}
}).catch(function unhandledError() { });
});
});

Back | FazBrowse Home | New Git URL