Permalink
Browse files

cleaned trailing whitespace in some files

  • Loading branch information...
payload committed May 18, 2011
1 parent 718e0ce commit 166f142057b0f557391d9a22f25ef481f2bb7f22
Showing with 231 additions and 285 deletions.
  1. +38 −53 lib/git/commit.js
  2. +15 −15 lib/git/diff.js
  3. +131 −149 lib/git/git.js
  4. +47 −68 lib/git/repo.js
View
@@ -20,35 +20,35 @@ var Commit = exports.Commit = function(repo, id, parents, tree, author, authored
Object.defineProperty(this, "repo", { get: function() { return _repo; }, set: function(value) { _repo = value; }, enumerable: true, configurable:true});
Object.defineProperty(this, "id", { get: function() { return _id; }, set: function(value) { _id = value; }, enumerable: true, configurable:true});
Object.defineProperty(this, "sha", { get: function() { return _id; }, set: function(value) { _id = value; }, enumerable: true, configurable:true});
- Object.defineProperty(this, "parents", { get: function() {
+ Object.defineProperty(this, "parents", { get: function() {
_parents = lazy_reader(_repo, _id, 'parents', _parents);
- return _parents;
+ return _parents;
}, set: function(value) { _parents = value; }, enumerable: true, configurable:true});
- Object.defineProperty(this, "tree", { get: function() {
+ Object.defineProperty(this, "tree", { get: function() {
_tree = lazy_reader(_repo, _id, 'tree', _tree);
return _tree;
}, set: function(value) { _tree = value; }, enumerable: true, configurable:true});
- Object.defineProperty(this, "author", { get: function() {
+ Object.defineProperty(this, "author", { get: function() {
_author = lazy_reader(_repo, _id, 'author', _author);
return _author;
}, set: function(value) { _author = value; }, enumerable: true, configurable:true});
- Object.defineProperty(this, "authored_date", { get: function() {
+ Object.defineProperty(this, "authored_date", { get: function() {
_authored_date = lazy_reader(_repo, _id, 'authored_date', _authored_date);
return _authored_date;
}, set: function(value) { _authored_date = value; }, enumerable: true, configurable:true});
- Object.defineProperty(this, "committer", { get: function() {
+ Object.defineProperty(this, "committer", { get: function() {
_committer = lazy_reader(_repo, _id, 'comitter', _committer);
return _committer;
}, set: function(value) { _comitter = value; }, enumerable: true, configurable:true});
- Object.defineProperty(this, "committed_date", { get: function() {
+ Object.defineProperty(this, "committed_date", { get: function() {
_committed_date = lazy_reader(_repo, _id, 'committed_date', _committed_date);
return _committed_date;
}, set: function(value) { _committed_date = value; }, enumerable: true, configurable:true});
- Object.defineProperty(this, "message", { get: function() {
+ Object.defineProperty(this, "message", { get: function() {
_message = lazy_reader(_repo, _id, 'message', _message);
return _message;
}, set: function(value) { _message = value; }, enumerable: true, configurable:true});
- Object.defineProperty(this, "short_message", { get: function() {
+ Object.defineProperty(this, "short_message", { get: function() {
_short_message = lazy_reader(_repo, _id, 'short_message', _short_message);
return _short_message;
}, set: function(value) { _short_message = value; }, enumerable: true, configurable:true});
@@ -69,13 +69,13 @@ var lazy_reader = function(repo, id, name, variable) {
})
while(!done) {};
- return value ? value : '';
+ return value ? value : '';
}
// Load a commit
Commit.prototype.load = function(callback) {
var self = this;
-
+
Commit.find_all(this.repo, this.id, {max_count:1}, function(err, commits) {
if(err) return callback(err, commits);
var commit = commits[0];
@@ -94,7 +94,7 @@ var chomp = function chomp(raw_text) {
// Fetch the short form of an id
Commit.prototype.id_abbrev = function(callback) {
var self = this;
-
+
if(this._id_abbrev) return callback(null, this._id_abbrev);
this.repo.git.rev_parse({}, this.id, 0, function(err, id) {
if(err) return callback(err, id);
@@ -118,10 +118,10 @@ Commit.list_from_string = function(repo, text) {
var lines = text.split("\n");
var commits = [];
// Parse all commit messages
- while(lines.length > 0) {
+ while(lines.length > 0) {
var id = lines.shift().split(/ /).pop();
var tree = new Tree(repo, lines.shift().split(/ /).pop());
-
+
// Let's get the parents
var parents = [];
while(lines[0].match(/^parent/)) {
@@ -137,14 +137,14 @@ Commit.list_from_string = function(repo, text) {
// Unpack encoding
var encoding = lines[0].match(/^encoding/) ? lines.shift().split().pop() : '';
// Jump empty space
- lines.shift();
+ lines.shift();
// Unpack message lines
- var message_lines = [];
+ var message_lines = [];
while(lines.length > 0 && lines[0].match(/^ {4}/)) {
var message_line = lines.shift();
message_lines.push(message_line.substring(4, message_line.length)) ;
}
-
+
// Move and point to next message
while(lines[0] != null && lines[0] == '') lines.shift();
// Create commit object
@@ -159,27 +159,27 @@ Commit.find_all = function(repo, reference, options, callback) {
var self = this;
var args = Array.prototype.slice.call(arguments, 1);
callback = args.pop();
- reference = args.length ? args.shift() : null;
- options = args.length ? args.shift() : {};
-
+ reference = args.length ? args.shift() : null;
+ options = args.length ? args.shift() : {};
+
// Merge the options with the default_options
- if(!options.pretty) options['pretty'] = 'raw';
+ if(!options.pretty) options['pretty'] = 'raw';
// If we have a reference use that for the lookup
if(!reference) options['all'] = true;
-
- // Locate revisions
+
+ // Locate revisions
if(reference) {
- repo.git.rev_list(options, reference, function(err, revision_output) {
+ repo.git.rev_list(options, reference, function(err, revision_output) {
if(err) return callback(err, []);
// Turn string into a list of revisions
callback(null, Commit.list_from_string(repo, revision_output));
- });
+ });
} else {
repo.git.rev_list(options, function(err, revision_output) {
if(err) return callback(err, []);
// Turn string into a list of revisions
callback(null, Commit.list_from_string(repo, revision_output));
- });
+ });
}
}
@@ -204,14 +204,14 @@ Commit.diff = function(repo, a, b, paths, callback) {
var args = Array.prototype.slice.call(arguments, 2);
callback = args.pop();
b = args.length ? args.shift() : null;
- paths = args.length ? args.shift() : [];
-
+ paths = args.length ? args.shift() : [];
+
// If b is an array we skipped the b parameter
if(Array.isArray(b)) {
paths = b;
b = null;
}
-
+
// Set up parameters correctly
if(paths.length > 0) {
if(paths.length > 0) paths.unshift("--");
@@ -221,19 +221,19 @@ Commit.diff = function(repo, a, b, paths, callback) {
repo.git.call_git('', 'diff', '', {full_index:true}, paths, function(err, text) {
// Create a list of diffs from the string
if(text) {
- Diff.list_from_string(repo, text, callback);
+ Diff.list_from_string(repo, text, callback);
} else {
callback(null, []);
- }
+ }
});
} else {
repo.git.diff(a, b, {full_index:true}, function(err, text) {
// Create a list of diffs from the string
if(text) {
- Diff.list_from_string(repo, text, callback);
+ Diff.list_from_string(repo, text, callback);
} else {
callback(null, []);
- }
+ }
});
}
}
@@ -253,7 +253,7 @@ Commit.prototype.show = function(callback) {
var parents = this.parents;
var diff = null
var self = this;
-
+
if(parents.length > 1) {
this.repo.git.native_call("diff " + parents[0].id + "..." + parents[1].id, {full_index:true}, function(err, diff) {
if(err) return callback(err, diff);
@@ -262,19 +262,19 @@ Commit.prototype.show = function(callback) {
} else {
this.repo.git.show({full_index:true, pretty:'raw'}, this.id, function(err, diff) {
if(err) return callback(err, diff);
- process_diff(this.repo, diff, callback);
+ process_diff(this.repo, diff, callback);
});
- }
+ }
}
// Return the diffs for a commit
Commit.prototype.diffs = function(callback) {
- var parents = this.parents;
+ var parents = this.parents;
// If we have no parents
if(parents.length == 0) {
this.show(callback);
} else {
- Commit.diff(this.repo, parents[0].id, this.id, callback)
+ Commit.diff(this.repo, parents[0].id, this.id, callback)
}
}
@@ -288,18 +288,3 @@ Commit.prototype.toPatch = function(callback) {
this.repo.git.format_patch({'1':true, stdout:true}, this.id, callback);
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
View
@@ -1,6 +1,6 @@
var Blob = require('./blob').Blob;
-var Diff = exports.Diff = function(repo, a_path, b_path, a_blob, b_blob, a_mode, b_mode, new_file, deleted_file, diff) {
+var Diff = exports.Diff = function(repo, a_path, b_path, a_blob, b_blob, a_mode, b_mode, new_file, deleted_file, diff) {
var _repo = repo, _a_path = a_path, _b_path = b_path
var _a_mode = a_mode, _b_mode = b_mode, _diff = diff;
// Create blob objects
@@ -10,16 +10,16 @@ var Diff = exports.Diff = function(repo, a_path, b_path, a_blob, b_blob, a_mode,
var _new_file = new_file || _a_blob == null;
var _deleted_file = deleted_file || _b_blob == null;
- Object.defineProperty(this, "repo", { get: function() { return _repo; }, enumerable: true});
- Object.defineProperty(this, "a_path", { get: function() { return _a_path; }, enumerable: true});
- Object.defineProperty(this, "b_path", { get: function() { return _b_path; }, enumerable: true});
- Object.defineProperty(this, "a_mode", { get: function() { return _a_mode; }, enumerable: true});
- Object.defineProperty(this, "b_mode", { get: function() { return _b_mode; }, enumerable: true});
- Object.defineProperty(this, "diff", { get: function() { return _diff; }, enumerable: true});
- Object.defineProperty(this, "a_blob", { get: function() { return _a_blob; }, enumerable: true});
- Object.defineProperty(this, "b_blob", { get: function() { return _b_blob; }, enumerable: true});
- Object.defineProperty(this, "new_file", { get: function() { return _new_file; }, enumerable: true});
- Object.defineProperty(this, "deleted_file", { get: function() { return _deleted_file; }, enumerable: true});
+ Object.defineProperty(this, "repo", { get: function() { return _repo; }, enumerable: true});
+ Object.defineProperty(this, "a_path", { get: function() { return _a_path; }, enumerable: true});
+ Object.defineProperty(this, "b_path", { get: function() { return _b_path; }, enumerable: true});
+ Object.defineProperty(this, "a_mode", { get: function() { return _a_mode; }, enumerable: true});
+ Object.defineProperty(this, "b_mode", { get: function() { return _b_mode; }, enumerable: true});
+ Object.defineProperty(this, "diff", { get: function() { return _diff; }, enumerable: true});
+ Object.defineProperty(this, "a_blob", { get: function() { return _a_blob; }, enumerable: true});
+ Object.defineProperty(this, "b_blob", { get: function() { return _b_blob; }, enumerable: true});
+ Object.defineProperty(this, "new_file", { get: function() { return _new_file; }, enumerable: true});
+ Object.defineProperty(this, "deleted_file", { get: function() { return _deleted_file; }, enumerable: true});
}
// Create a list of diffs from a diff text
@@ -31,22 +31,22 @@ Diff.list_from_string = function(repo, text, callback) {
var diffs = [];
var a_path, b_path, a_mode, b_mode, new_file = false, deleted_file = false;
var a_blob, b_blob;
-
+
while(text.length > 0 && lines.length > 0) {
// Extract a line
var parts = lines.shift().match(/^diff --git a\/(.+?) b\/(.+)$/);
// Unpack parts
var a_path = parts[1];
var b_path = parts[2];
-
+
if(lines[0].match(/^old mode/)) {
a_mode = lines.shift().match(/^old mode (\d+)/)[1]
b_mode = lines.shift().match(/^new mode (\d+)/)[1]
}
-
+
if(lines.length == 0 || lines[0].match(/^diff --git/)) {
diffs.push(new Diff(repo, a_path, b_path, null, null, a_mode, b_mode, false, false, null));
- } else {
+ } else {
if(lines[0].match(/^new file/)) {
b_mode = lines.shift().match(/^new file mode (.+)$/)[1];
a_mode = null;
Oops, something went wrong.

0 comments on commit 166f142

Please sign in to comment.