<commit_before>var chp = require('child_process');

var Git = {
	stageFile: function(modulePath, file, callback) {
		if (file.status === 'deleted') {
			this._exec(modulePath, 'rm', [file.name], callback);
		} else {
			this._exec(modulePath, 'add', [file.name], callback);
		}
	},
	
	unstageFile: function(modulePath, file, callback) {
		this._exec(modulePath, 'reset HEAD', [file.name], callback);
	},
	
	commit: function(modulePath, message, callback) {
		this._exec(modulePath, 'commit -m', [message], callback);
	},
	
	push: function(modulePath, callback) {
		this._exec(modulePath, 'push', [], callback);
	},
	
	_exec: function(modulePath, cmd, args, callback) {
		var escapedArgs = args.map(function(arg) {
			return '"' + arg.replace(/["\\]/g, '\\$1') + '"';
		}).join(' ');
		cmd = 'git ' + cmd + ' ' + escapedArgs;
		chp.exec(cmd, {cwd: modulePath}, function(err, stdout, stderr) {
			if (err) console.error(err, stdout, stderr);
			callback(null, stdout);
		});
	}
};

module.exports = Git;<commit_msg>Correctly stage submodules<commit_after>var chp = require('child_process');

var Git = {
	stageFile: function(modulePath, file, callback) {
		if (file.status === 'deleted') {
			this._exec(modulePath, 'rm', [file.name], callback);
		} else {
			if (file.type === 'submodule') this.exec(modulePath, 'submodule add', [file.name], callback);
			else this._exec(modulePath, 'add', [file.name], callback);
		}
	},
	
	unstageFile: function(modulePath, file, callback) {
		this._exec(modulePath, 'reset HEAD', [file.name], callback);
	},
	
	commit: function(modulePath, message, callback) {
		this._exec(modulePath, 'commit -m', [message], callback);
	},
	
	push: function(modulePath, callback) {
		this._exec(modulePath, 'push', [], callback);
	},
	
	_exec: function(modulePath, cmd, args, callback) {
		var escapedArgs = args.map(function(arg) {
			return '"' + arg.replace(/["\\]/g, '\\$1') + '"';
		}).join(' ');
		cmd = 'git ' + cmd + ' ' + escapedArgs;
		chp.exec(cmd, {cwd: modulePath}, function(err, stdout, stderr) {
			if (err) console.error(err, stdout, stderr);
			callback(null, stdout);
		});
	}
};

module.exports = Git;
{'fraction_non_alphanumeric': 0.19710415693601122, 'fraction_numerical': 0.0009341429238673517, 'mean_word_length': 4.341645885286783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6619977', 'n_tokens_mistral': 806, 'n_tokens_neox': 745, 'n_words': 162}