Skip to content

Commit

Permalink
commit: support commit.status, --status, and --no-status
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
James P. Howard, II authored and Junio C Hamano committed Jan 13, 2010
1 parent b809d9c commit bed575e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,11 @@ color.ui::
terminal. When more specific variables of color.* are set, they always
take precedence over this setting. Defaults to false.

commit.status
A boolean to enable/disable inclusion of status information in the
commit message template when using an editor to prepare the commit
message. Defaults to true.

commit.template::
Specify a file to use as the template for new commit messages.
"{tilde}/" is expanded to the value of `$HOME` and "{tilde}user/" to the
Expand Down
14 changes: 13 additions & 1 deletion Documentation/git-commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ SYNOPSIS
'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
[(-c | -C) <commit>] [-F <file> | -m <msg>] [--reset-author]
[--allow-empty] [--no-verify] [-e] [--author=<author>]
[--cleanup=<mode>] [--] [[-i | -o ]<file>...]
[--cleanup=<mode>] [--status | --no-status] [--]
[[-i | -o ]<file>...]

DESCRIPTION
-----------
Expand Down Expand Up @@ -207,6 +208,17 @@ specified.
to be committed, paths with local changes that will be left
uncommitted and paths that are untracked.

--status::
Include the output of linkgit:git-status[1] in the commit
message template when using an editor to prepare the commit
message. Defaults to on, but can be used to override
configuration variable commit.status.

--no-status::
Do not include the output of linkgit:git-status[1] in the
commit message template when using an editor to prepare the
default commit message.

\--::
Do not interpret any more arguments as options.

Expand Down
9 changes: 7 additions & 2 deletions builtin-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static enum {
} cleanup_mode;
static char *cleanup_arg;

static int use_editor = 1, initial_commit, in_merge;
static int use_editor = 1, initial_commit, in_merge, include_status = 1;
static const char *only_include_assumed;
static struct strbuf message;

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

OPT_GROUP("Commit contents options"),
OPT_BOOLEAN('a', "all", &all, "commit all changed files"),
Expand Down Expand Up @@ -547,7 +548,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,

/* This checks if committer ident is explicitly given */
git_committer_info(0);
if (use_editor) {
if (use_editor && include_status) {
char *author_ident;
const char *committer_ident;

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

if (!strcmp(k, "commit.template"))
return git_config_pathname(&template_file, k, v);
if (!strcmp(k, "commit.status")) {
include_status = git_config_bool(k, v);
return 0;
}

return git_status_config(k, v, s);
}
Expand Down

0 comments on commit bed575e

Please sign in to comment.