From 1e1c3a46e6754981efe2be03aa699ebdf03d4fef Mon Sep 17 00:00:00 2001 From: 0xLogN Date: Fri, 29 Apr 2022 18:34:11 -0700 Subject: [PATCH] add git gc command --- src/js/git/commands.js | 8 ++++++++ src/js/git/index.js | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/js/git/commands.js b/src/js/git/commands.js index 03b68cd0..e08122dd 100644 --- a/src/js/git/commands.js +++ b/src/js/git/commands.js @@ -208,6 +208,14 @@ var commandConfig = { } }, + gc: { + displayName: 'gc', + regex: /^git +gc($|\s)/, + execute: function(engine, command) { + engine.pruneTree(false); + } + }, + pull: { regex: /^git +pull($|\s)/, options: [ diff --git a/src/js/git/index.js b/src/js/git/index.js index b5970d2f..c624be11 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -1836,7 +1836,7 @@ GitEngine.prototype.pruneTreeAndPlay = function() { this.animationFactory.playRefreshAnimationSlow(this.gitVisuals); }; -GitEngine.prototype.pruneTree = function() { +GitEngine.prototype.pruneTree = function(doPrintWarning = true) { var set = this.getUpstreamBranchSet(); // don't prune commits that HEAD depends on var headSet = Graph.getUpstreamSet(this, 'HEAD'); @@ -1857,7 +1857,7 @@ GitEngine.prototype.pruneTree = function() { // the switch sync return; } - if (this.command) { + if (this.command && doPrintWarning) { this.command.addWarning(intl.str('hg-prune-tree')); }