git commit --amend -C nice

This commit is contained in:
Peter Cottle 2012-11-04 23:30:10 -08:00
parent 925497377e
commit 89b7e97e1d
3 changed files with 42 additions and 14 deletions

View file

@ -282,7 +282,8 @@ OptionParser.prototype.getMasterOptionMap = function() {
'--amend': false, '--amend': false,
'-a': false, // warning '-a': false, // warning
'-am': false, // warning '-am': false, // warning
'-m': false '-m': false,
'-C': false
}, },
status: {}, status: {},
log: {}, log: {},
@ -291,7 +292,8 @@ OptionParser.prototype.getMasterOptionMap = function() {
branch: { branch: {
'-d': false, '-d': false,
'-D': false, '-D': false,
'-f': false '-f': false,
'--contains': false
}, },
checkout: { checkout: {
'-b': false, '-b': false,

View file

@ -281,8 +281,19 @@ GitEngine.prototype.getBranches = function() {
return toReturn; return toReturn;
}; };
GitEngine.prototype.printBranches = function() { GitEngine.prototype.printBranchesWithout = function(without) {
var branches = this.getBranches(); var commitToBranches = this.getUpstreamBranchSet();
var commitID = this.getCommitFromRef(without).get('id');
var toPrint = [];
_.each(commitToBranches[commitID], function(branchJSON) {
branchJSON.selected = this.HEAD.get('target').get('id') == branchJSON.id;
toPrint.push(branchJSON);
}, this);
this.printBranches(toPrint);
};
GitEngine.prototype.printBranches = function(branches) {
var result = ''; var result = '';
_.each(branches, function(branch) { _.each(branches, function(branch) {
result += (branch.selected ? '* ' : '') + branch.id + '\n'; result += (branch.selected ? '* ' : '') + branch.id + '\n';
@ -292,13 +303,6 @@ GitEngine.prototype.printBranches = function() {
}); });
}; };
GitEngine.prototype.logBranches = function() {
var branches = this.getBranches();
_.each(branches, function(branch) {
console.log((branch.selected ? '* ' : '') + branch.id);
});
};
GitEngine.prototype.makeCommit = function(parents, id, options) { GitEngine.prototype.makeCommit = function(parents, id, options) {
// ok we need to actually manually create commit IDs now because // ok we need to actually manually create commit IDs now because
// people like nikita (thanks for finding this!) could // people like nikita (thanks for finding this!) could
@ -527,10 +531,23 @@ GitEngine.prototype.commitStarter = function() {
GitEngine.prototype.commit = function() { GitEngine.prototype.commit = function() {
var targetCommit = this.getCommitFromRef(this.HEAD); var targetCommit = this.getCommitFromRef(this.HEAD);
var id = undefined; var id = undefined;
// if we want to ammend, go one above // if we want to ammend, go one above
if (this.commandOptions['--amend']) { if (this.commandOptions['--amend']) {
targetCommit = this.resolveID('HEAD~1'); targetCommit = this.resolveID('HEAD~1');
// if they specify -C, go there
if (this.commandOptions['-C']) {
this.validateArgBounds(this.commandOptions['-C'], 1, 1, '-C');
targetCommit = this.numBackFrom(this.getCommitFromRef(this.commandOptions['-C'][0]), 1);
}
id = this.rebaseAltID(this.getCommitFromRef('HEAD').get('id')); id = this.rebaseAltID(this.getCommitFromRef('HEAD').get('id'));
} else {
if (this.commandOptions['-C']) {
throw new GitError({
msg: 'I only support -C when doing --amend, sorry'
});
}
} }
var newCommit = this.makeCommit([targetCommit], id); var newCommit = this.makeCommit([targetCommit], id);
@ -1188,6 +1205,13 @@ GitEngine.prototype.branchStarter = function() {
return; return;
} }
if (this.commandOptions['--contains']) {
var args = this.commandOptions['--contains'];
this.validateArgBounds(args, 1, 1, '--contains');
this.printBranchesWithout(args[0]);
return;
}
if (this.commandOptions['-f']) { if (this.commandOptions['-f']) {
var args = this.commandOptions['-f']; var args = this.commandOptions['-f'];
this.twoArgsImpliedHead(args, '-f'); this.twoArgsImpliedHead(args, '-f');
@ -1199,7 +1223,7 @@ GitEngine.prototype.branchStarter = function() {
if (this.generalArgs.length == 0) { if (this.generalArgs.length == 0) {
this.printBranches(); this.printBranches(this.getBranches());
return; return;
} }

View file

@ -23,6 +23,9 @@ Big Bugs to fix:
- load and save no longer work... - load and save no longer work...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pre-publish things: Pre-publish things:
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
- cross browser support - cross browser support
@ -31,12 +34,11 @@ Pre-publish things:
extra command ideas: extra command ideas:
git branch --contains
git log branchA ^branchB git log branchA ^branchB
git status -sb
git commit --amend -C HEAD git commit --amend -C HEAD
2013 Things 2013 Things
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tree layout with the layout engine provided in d3.js, that white-paper algorithm. Only tricky thing is that merge commits mess up the "tree" aspect and it doesn't directly support weighting, but I can probably throw that in. Tree layout with the layout engine provided in d3.js, that white-paper algorithm. Only tricky thing is that merge commits mess up the "tree" aspect and it doesn't directly support weighting, but I can probably throw that in.
Would require mixing both algorthims and probably some real time dedication