@matheusbsbs / matheus-bagliano / commits / bed575e400
Fork 0

commit: support commit.status, --status, and --no-status

A new configuration variable commit.status, and new command line options --status, and --no-status control whether or not the git status information is included in the commit message template when using an editor to prepare the commit message. It does not affect the effects of a user's commit.template settings. Signed-off-by: James P. Howard, II <jh@jameshoward.us> Signed-off-by: Junio C Hamano <gitster@pobox.com>

James P. Howard, II committed Dec 7, 2009 at 17:45 UTC bed575e4002cfa1dfa7d87b9db38e69c6f600e2e
3 files changed +25 -3
Documentation/config.txt
+5
@@ -705,6 +705,11 @@ color.ui::
705 terminal. When more specific variables of color.* are set, they always
706 take precedence over this setting. Defaults to false.
707
708 +commit.status
709 + A boolean to enable/disable inclusion of status information in the
710 + commit message template when using an editor to prepare the commit
711 + message. Defaults to true.
712 +
713 commit.template::
714 Specify a file to use as the template for new commit messages.
715 "{tilde}/" is expanded to the value of `$HOME` and "{tilde}user/" to the
Documentation/git-commit.txt
+13 -1
@@ -11,7 +11,8 @@ SYNOPSIS
11 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
12 [(-c | -C) <commit>] [-F <file> | -m <msg>] [--reset-author]
13 [--allow-empty] [--no-verify] [-e] [--author=<author>]
14 - [--cleanup=<mode>] [--] [[-i | -o ]<file>...]
14 + [--cleanup=<mode>] [--status | --no-status] [--]
15 + [[-i | -o ]<file>...]
16
17 DESCRIPTION
18 -----------
@@ -207,6 +208,17 @@ specified.
208 to be committed, paths with local changes that will be left
209 uncommitted and paths that are untracked.
210
211 +--status::
212 + Include the output of linkgit:git-status[1] in the commit
213 + message template when using an editor to prepare the commit
214 + message. Defaults to on, but can be used to override
215 + configuration variable commit.status.
216 +
217 +--no-status::
218 + Do not include the output of linkgit:git-status[1] in the
219 + commit message template when using an editor to prepare the
220 + default commit message.
221 +
222 \--::
223 Do not interpret any more arguments as options.
224
builtin-commit.c
+7 -2
@@ -67,7 +67,7 @@ static enum {
67 } cleanup_mode;
68 static char *cleanup_arg;
69
70 -static int use_editor = 1, initial_commit, in_merge;
70 +static int use_editor = 1, initial_commit, in_merge, include_status = 1;
71 static const char *only_include_assumed;
72 static struct strbuf message;
73
@@ -97,6 +97,7 @@ static struct option builtin_commit_options[] = {
97 OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
98 OPT_FILENAME('t', "template", &template_file, "use specified template file"),
99 OPT_BOOLEAN('e', "edit", &edit_flag, "force edit of commit"),
100 + OPT_BOOLEAN(0, "status", &include_status, "include status in commit message template"),
101
102 OPT_GROUP("Commit contents options"),
103 OPT_BOOLEAN('a', "all", &all, "commit all changed files"),
@@ -547,7 +548,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
548
549 /* This checks if committer ident is explicitly given */
550 git_committer_info(0);
550 - if (use_editor) {
551 + if (use_editor && include_status) {
552 char *author_ident;
553 const char *committer_ident;
554
@@ -1006,6 +1007,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
1007
1008 if (!strcmp(k, "commit.template"))
1009 return git_config_pathname(&template_file, k, v);
1010 + if (!strcmp(k, "commit.status")) {
1011 + include_status = git_config_bool(k, v);
1012 + return 0;
1013 + }
1014
1015 return git_status_config(k, v, s);
1016 }