Skip to content

Commit bed575e

Browse files
howardjpgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b809d9c commit bed575e

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

Documentation/config.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,11 @@ color.ui::
705705
terminal. When more specific variables of color.* are set, they always
706706
take precedence over this setting. Defaults to false.
707707

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+
708713
commit.template::
709714
Specify a file to use as the template for new commit messages.
710715
"{tilde}/" is expanded to the value of `$HOME` and "{tilde}user/" to the

Documentation/git-commit.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ SYNOPSIS
1111
'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
1212
[(-c | -C) <commit>] [-F <file> | -m <msg>] [--reset-author]
1313
[--allow-empty] [--no-verify] [-e] [--author=<author>]
14-
[--cleanup=<mode>] [--] [[-i | -o ]<file>...]
14+
[--cleanup=<mode>] [--status | --no-status] [--]
15+
[[-i | -o ]<file>...]
1516

1617
DESCRIPTION
1718
-----------
@@ -207,6 +208,17 @@ specified.
207208
to be committed, paths with local changes that will be left
208209
uncommitted and paths that are untracked.
209210

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+
210222
\--::
211223
Do not interpret any more arguments as options.
212224

builtin-commit.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static enum {
6767
} cleanup_mode;
6868
static char *cleanup_arg;
6969

70-
static int use_editor = 1, initial_commit, in_merge;
70+
static int use_editor = 1, initial_commit, in_merge, include_status = 1;
7171
static const char *only_include_assumed;
7272
static struct strbuf message;
7373

@@ -97,6 +97,7 @@ static struct option builtin_commit_options[] = {
9797
OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
9898
OPT_FILENAME('t', "template", &template_file, "use specified template file"),
9999
OPT_BOOLEAN('e', "edit", &edit_flag, "force edit of commit"),
100+
OPT_BOOLEAN(0, "status", &include_status, "include status in commit message template"),
100101

101102
OPT_GROUP("Commit contents options"),
102103
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,
547548

548549
/* This checks if committer ident is explicitly given */
549550
git_committer_info(0);
550-
if (use_editor) {
551+
if (use_editor && include_status) {
551552
char *author_ident;
552553
const char *committer_ident;
553554

@@ -1006,6 +1007,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
10061007

10071008
if (!strcmp(k, "commit.template"))
10081009
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+
}
10091014

10101015
return git_status_config(k, v, s);
10111016
}

0 commit comments

Comments
 (0)