From a7174688b2dd17d6c12580570aa30b1a663b1a52 Mon Sep 17 00:00:00 2001 From: Josh Shaw Date: Mon, 29 Feb 2016 14:10:39 +1300 Subject: [PATCH 1/2] fixes #852 should not be an array with null in it --- lib/repository.js | 5 ++++- test/tests/repository.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/repository.js b/lib/repository.js index 61d221729..30692c6bb 100644 --- a/lib/repository.js +++ b/lib/repository.js @@ -535,13 +535,16 @@ Repository.prototype.createCommitOnHead = function( .then(function(treeOid) { return repo.getHeadCommit() .then(function(parent) { + if (parent !== null) { // To handle a fresh repo with no commits + parent = [parent]; + } return repo.createCommit( "HEAD", author, committer, message, treeOid, - [parent] + parent ); }); }, callback); diff --git a/test/tests/repository.js b/test/tests/repository.js index adaec151e..6f710ef10 100644 --- a/test/tests/repository.js +++ b/test/tests/repository.js @@ -231,4 +231,33 @@ describe("Repository", function() { assert(!commit); }); }); + + it("can commit on head on a empty repo with createCommitOnHead", function() { + var fileName = "my-new-file-that-shouldnt-exist.file"; + var fileContent = "new file from repository test"; + var repo = this.emptyRepo; + var filePath = path.join(repo.workdir(), fileName); + var authSig = repo.defaultSignature(); + var commitSig = repo.defaultSignature(); + var commitMsg = "Doug this has been commited"; + + return fse.writeFile(filePath, fileContent) + .then(function() { + return repo.createCommitOnHead( + [filePath], + authSig, + commitSig, + commitMsg + ); + }) + .then(function(oidResult) { + return repo.getHeadCommit() + .then(function(commit) { + assert.equal( + commit.toString(), + oidResult.toString() + ); + }); + }); + }); }); From 1973dfb9eb7e13816007e1729d8a534d44464c67 Mon Sep 17 00:00:00 2001 From: Josh Shaw Date: Tue, 1 Mar 2016 09:47:18 +1300 Subject: [PATCH 2/2] fixes #852 fixed tab issue PR #927 --- lib/repository.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/repository.js b/lib/repository.js index 30692c6bb..47e2220e9 100644 --- a/lib/repository.js +++ b/lib/repository.js @@ -535,9 +535,9 @@ Repository.prototype.createCommitOnHead = function( .then(function(treeOid) { return repo.getHeadCommit() .then(function(parent) { - if (parent !== null) { // To handle a fresh repo with no commits - parent = [parent]; - } + if (parent !== null) { // To handle a fresh repo with no commits + parent = [parent]; + } return repo.createCommit( "HEAD", author,