Skip to content

Commit

Permalink
Merge pull request #656 from blevz/turn-off-gc-in-subrepos
Browse files Browse the repository at this point in the history
Turn off GC in submodules on open
  • Loading branch information
novalis committed Aug 22, 2018
2 parents 4883e15 + a633dc3 commit 4f9477a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions node/lib/util/config_util.js
Expand Up @@ -62,13 +62,13 @@ exports.getConfigString = co.wrap(function *(config, key) {
/**
* Returns whether a config variable is, according to git's reckoning,
* true. That is, it's set to 'true', 'yes', or 'on'. If the variable is not
* se at all, return null.
* set at all, return null.
* @async
* @param {NodeGit.Repository} repo
* @param {NodeGit.Commit} configVar
* @return {Bool|null}
* @throws if the configuration variable doesn't exist
*/
*/
exports.configIsTrue = co.wrap(function*(repo, configVar) {
assert.instanceOf(repo, NodeGit.Repository);
assert.isString(configVar);
Expand Down
4 changes: 4 additions & 0 deletions node/lib/util/open.js
Expand Up @@ -85,6 +85,10 @@ exports.openOnCommit = co.wrap(function *(fetcher,
submoduleUrl,
templatePath);

// Turn off GC for the submodule
const config = yield submoduleRepo.config();
config.setInt64("gc.auto", 0);

// Fetch the needed sha. Close if the fetch fails; otherwise, the
// repository ends up in a state where it things the submodule is open, but
// it's actually not.
Expand Down
11 changes: 10 additions & 1 deletion node/test/util/open.js
Expand Up @@ -34,6 +34,7 @@ const assert = require("chai").assert;
const co = require("co");
const NodeGit = require("nodegit");

const ConfigUtil = require("../../lib/util/config_util");
const Open = require("../../lib/util/open");
const RepoASTTestUtil = require("../../lib/util/repo_ast_test_util");
const SubmoduleFetcher = require("../../lib/util/submodule_fetcher");
Expand Down Expand Up @@ -117,6 +118,10 @@ describe("openOnCommit", function () {
const base = yield SubmoduleUtil.getRepo(repo, "s");
assert.equal(s1, s2, "not re-opened");
assert.equal(s1.workdir(), base.workdir(), "right path");
const config = yield s1.config();
const gcConfig = yield ConfigUtil.getConfigString(config,
"gc.auto");
assert.equal("0", gcConfig);
}));
it("different commit", co.wrap(function *() {
const state = "a=B:Ca-1;Ba=a|x=U:C3-2 s=Sa:a;Bfoo=3";
Expand Down Expand Up @@ -203,9 +208,13 @@ describe("openOnCommit", function () {
const w = yield RepoASTTestUtil.createMultiRepos(state);
const repo = w.repos.x;
const opener = new Open.Opener(repo, null);
yield opener.getSubrepo("s");
const s = yield opener.getSubrepo("s");
const result = yield opener.isOpen("s");
assert.equal(true, result);
const config = yield s.config();
const gcConfig = yield ConfigUtil.getConfigString(config,
"gc.auto");
assert.equal("0", gcConfig);
}));
it("getOpenSubs, true immediately", co.wrap(function *() {
const state = "a=B|x=U:Os";
Expand Down

0 comments on commit 4f9477a

Please sign in to comment.