git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-commit: '--no-status' Allow suppression of status summary in commit msg
@ 2008-08-28 18:46 Marcus Griep
  2008-08-28 19:09 ` Junio C Hamano
  2008-08-28 19:13 ` Alex Riesen
  0 siblings, 2 replies; 7+ messages in thread
From: Marcus Griep @ 2008-08-28 18:46 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Marcus Griep

Currently, using any editor to edit a commit message for 'git commit'
kicks of a 'git status' which is then included as comments to give
the commit author some context. However, in some situations, such as
having a working tree of many hundred thousand files or on an inefficient
filesystem, a 'git status' can take a long time to process before
displaying the commit for editing.

This patch provides an option to disable the status summary, documents it
and provides test cases for its operation.

Signed-off-by: Marcus Griep <marcus@griep.us>
---
 Documentation/git-commit.txt |    9 +++++++++
 builtin-commit.c             |   16 +++++++++++-----
 t/t7500-commit.sh            |   32 ++++++++++++++++++++++++++++++++
 t/t7500/check-for-status     |    9 +++++++++
 4 files changed, 61 insertions(+), 5 deletions(-)
 create mode 100755 t/t7500/check-for-status

diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 0e25bb8..0d5d35c 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -190,6 +190,15 @@ specified.
 --quiet::
 	Suppress commit summary message.
 
+-S::
+--no-status::
+	Suppress inclusion of the git status summary comments
+	that are normally included when the commit message
+	editor is invoked. This can be helpful if `git status`
+	is an expensive operation on your machine, and you
+	don't wish to incur that cost when editing a commit
+	message.
+
 \--::
 	Do not interpret any more arguments as options.
 
diff --git a/builtin-commit.c b/builtin-commit.c
index 649c8be..153f436 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -51,7 +51,7 @@ static const char *template_file;
 static char *edit_message, *use_message;
 static char *author_name, *author_email, *author_date;
 static int all, edit_flag, also, interactive, only, amend, signoff;
-static int quiet, verbose, no_verify, allow_empty;
+static int quiet, verbose, no_verify, no_status, allow_empty;
 static char *untracked_files_arg;
 /*
  * The default commit message cleanup mode will remove the lines
@@ -103,6 +103,7 @@ static struct option builtin_commit_options[] = {
 	OPT_BOOLEAN(0, "interactive", &interactive, "interactively add files"),
 	OPT_BOOLEAN('o', "only", &only, "commit only specified files"),
 	OPT_BOOLEAN('n', "no-verify", &no_verify, "bypass pre-commit hook"),
+	OPT_BOOLEAN('S', "no-status", &no_status, "don't include status summary comments in editor"),
 	OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
 	{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
 	OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"),
@@ -590,10 +591,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
 		if (ident_shown)
 			fprintf(fp, "#\n");
 
-		saved_color_setting = wt_status_use_color;
-		wt_status_use_color = 0;
-		commitable = run_status(fp, index_file, prefix, 1);
-		wt_status_use_color = saved_color_setting;
+		if (!no_status) {
+			saved_color_setting = wt_status_use_color;
+			wt_status_use_color = 0;
+			commitable = run_status(fp, index_file, prefix, 1);
+			wt_status_use_color = saved_color_setting;
+		}
 	} else {
 		struct rev_info rev;
 		unsigned char sha1[20];
@@ -893,6 +896,9 @@ static int git_commit_config(const char *k, const char *v, void *cb)
 	if (!strcmp(k, "commit.template"))
 		return git_config_string(&template_file, k, v);
 
+	if (!strcmp(k, "commit.nostatus"))
+		return git_config_bool_or_int(k, v, &no_status);
+
 	return git_status_config(k, v, cb);
 }
 
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index 7ae0bd0..5579463 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -186,4 +186,36 @@ test_expect_success 'commit message from stdin' '
 	commit_msg_is "Log with foo word"
 '
 
+test_expect_success 'commit message in editor should include status' '
+	echo "Test status" > fooey &&
+	git add fooey &&
+	(
+		test_set_editor "$TEST_DIRECTORY"/t7500/check-for-status &&
+		git commit
+	) &&
+	commit_msg_is "Status"
+'
+
+test_expect_success 'no-status flag should suppress including status summary' '
+	echo "Test no-status" > fooey &&
+	git add fooey &&
+	(
+		test_set_editor "$TEST_DIRECTORY"/t7500/check-for-status &&
+		git commit --no-status
+	) &&
+	commit_msg_is "No Status"
+'
+
+test_expect_success 'no-status config should suppress status summary' '
+	echo "Test no-status config" > fooey &&
+	git add fooey &&
+	(
+		git config commit.nostatus true &&
+		test_set_editor "$TEST_DIRECTORY"/t7500/check-for-status &&
+		git commit &&
+		git config --unset commit.nostatus
+	) &&
+	commit_msg_is "No Status"
+'
+
 test_done
diff --git a/t/t7500/check-for-status b/t/t7500/check-for-status
new file mode 100755
index 0000000..5c6efdf
--- /dev/null
+++ b/t/t7500/check-for-status
@@ -0,0 +1,9 @@
+#!/bin/sh
+val=`sed -n 's/^# On branch .*$/1/p' "$1"`
+cat "$1"
+if [ $val ]; then
+	echo Status >> "$1"
+else
+	echo No Status >> "$1"
+fi
+exit 0
-- 
1.6.0.rc3.286.gd4df

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] git-commit: '--no-status' Allow suppression of status summary in commit msg
  2008-08-28 18:46 [PATCH] git-commit: '--no-status' Allow suppression of status summary in commit msg Marcus Griep
@ 2008-08-28 19:09 ` Junio C Hamano
  2008-08-28 19:34   ` Alex Riesen
  2008-08-28 19:13 ` Alex Riesen
  1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2008-08-28 19:09 UTC (permalink / raw)
  To: Marcus Griep; +Cc: Git Mailing List, Marius Storm-Olsen

Marcus Griep <marcus@griep.us> writes:

> Currently, using any editor to edit a commit message for 'git commit'
> kicks of a 'git status' which is then included as comments to give
> the commit author some context. However, in some situations, such as
> having a working tree of many hundred thousand files or on an inefficient
> filesystem,

I am not interested in this particular patch, especially the part that
hoards a short-and-nice -S flag that we could use for something more
useful.  Also calling the configuration variable "nostatus" is backwards;
I'd name it to "showstatus" that defaults to "true" if I were doing this.

You did not mention exactly how the "hundred thousand files on an
inefficient filesystem" is a problem, but if it is about listing untracked
files, I thought Marius Storm-Olsen added a feature to address that with
4bfee30 (Add an optional <mode> argument to commit/status -u|--untracked-files
option, 2008-06-05).

If that is not still enough for your particular use case, I think you can
have a custom wrapper that does:

	#!/bin/sh
	: >.log-message-file &&
        vi .log-message-file &&
        git commit -F .log-message-file "$@" &&
        rm -f .log-message-file 

without touching git at all.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] git-commit: '--no-status' Allow suppression of status summary in commit msg
  2008-08-28 18:46 [PATCH] git-commit: '--no-status' Allow suppression of status summary in commit msg Marcus Griep
  2008-08-28 19:09 ` Junio C Hamano
@ 2008-08-28 19:13 ` Alex Riesen
  2008-08-28 19:24   ` Marcus Griep
  1 sibling, 1 reply; 7+ messages in thread
From: Alex Riesen @ 2008-08-28 19:13 UTC (permalink / raw)
  To: Marcus Griep; +Cc: Git Mailing List, Junio C Hamano

Marcus Griep, Thu, Aug 28, 2008 20:46:55 +0200:
> Currently, using any editor to edit a commit message for 'git commit'
> kicks of a 'git status' which is then included as comments to give
> the commit author some context. However, in some situations, such as
> having a working tree of many hundred thousand files or on an inefficient
> filesystem, a 'git status' can take a long time to process before
> displaying the commit for editing.
> 
> This patch provides an option to disable the status summary, documents it
> and provides test cases for its operation.

There is prior art:

    http://thread.gmane.org/gmane.comp.version-control.git/66183/focus=66251

and resolution (in the thread, somewhat unclear).

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] git-commit: '--no-status' Allow suppression of status summary in commit msg
  2008-08-28 19:13 ` Alex Riesen
@ 2008-08-28 19:24   ` Marcus Griep
  2008-08-29  5:39     ` Marius Storm-Olsen
  0 siblings, 1 reply; 7+ messages in thread
From: Marcus Griep @ 2008-08-28 19:24 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Git Mailing List, Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 1428 bytes --]

Using --untracked-files=no cuts the time to display the editor from down to 12 seconds,
so that is perfectly fine.  The patch can be ignored.  However, would config option to
change the default --untracked-files value be entertained?  Allowing:

[commit]
	untrackedfiles=no

which defaults (as stated in the documentation for --untracked-files) to all?

Alex Riesen wrote:
> Marcus Griep, Thu, Aug 28, 2008 20:46:55 +0200:
>> Currently, using any editor to edit a commit message for 'git commit'
>> kicks of a 'git status' which is then included as comments to give
>> the commit author some context. However, in some situations, such as
>> having a working tree of many hundred thousand files or on an inefficient
>> filesystem, a 'git status' can take a long time to process before
>> displaying the commit for editing.
>>
>> This patch provides an option to disable the status summary, documents it
>> and provides test cases for its operation.
> 
> There is prior art:
> 
>     http://thread.gmane.org/gmane.comp.version-control.git/66183/focus=66251
> 
> and resolution (in the thread, somewhat unclear).
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Marcus Griep
GPG Key ID: 0x5E968152
——
http://www.boohaunt.net
את.ψο´


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 793 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] git-commit: '--no-status' Allow suppression of status summary in commit msg
  2008-08-28 19:09 ` Junio C Hamano
@ 2008-08-28 19:34   ` Alex Riesen
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Riesen @ 2008-08-28 19:34 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Marcus Griep, Git Mailing List, Marius Storm-Olsen

Junio C Hamano, Thu, Aug 28, 2008 21:09:35 +0200:
> Marcus Griep <marcus@griep.us> writes:
> 
> > Currently, using any editor to edit a commit message for 'git commit'
> > kicks of a 'git status' which is then included as comments to give
> > the commit author some context. However, in some situations, such as
> > having a working tree of many hundred thousand files or on an inefficient
> > filesystem,
> 
> I am not interested in this particular patch, especially the part that
> hoards a short-and-nice -S flag that we could use for something more
> useful.  Also calling the configuration variable "nostatus" is backwards;
> I'd name it to "showstatus" that defaults to "true" if I were doing this.

I like it (almost. I agree, it is not a very good idea to use up "-S"
for such a thing). Not because of "inefficient filesystem" (I have
proper systems at home), but because I more often need no file list in
the commit message than I do need one. It is just annoyance.  OTOH,
maybe I'm just too used to put things in the index and trust that. Or
maybe it is again that stupid user-friendliness.

> If that is not still enough for your particular use case, I think you can
> have a custom wrapper that does:
> 
> 	#!/bin/sh
> 	: >.log-message-file &&
>         vi .log-message-file &&
>         git commit -F .log-message-file "$@" &&
>         rm -f .log-message-file 
> 
> without touching git at all.

That's not enough. Consider "-mMessage -e", "-t" or "-c" flags of git
commit. The wrapper would have to catch them all! Not to mention the
future flags in the same ballpark.

ATM, I just use that "--cached" (from the patch I mentioned in the
other mail) with "--cleanup=verbatim" to get the commit message just
how I like them.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] git-commit: '--no-status' Allow suppression of status summary in commit msg
  2008-08-28 19:24   ` Marcus Griep
@ 2008-08-29  5:39     ` Marius Storm-Olsen
  2008-08-29  5:49       ` Marius Storm-Olsen
  0 siblings, 1 reply; 7+ messages in thread
From: Marius Storm-Olsen @ 2008-08-29  5:39 UTC (permalink / raw)
  To: Marcus Griep; +Cc: Alex Riesen, Git Mailing List, Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

Marcus Griep said the following on 28.08.2008 21:24:
> Using --untracked-files=no cuts the time to display the editor from down to 12 seconds,
> so that is perfectly fine.  The patch can be ignored.  However, would config option to
> change the default --untracked-files value be entertained?  Allowing:
> 
> [commit]
> 	untrackedfiles=no
> 
> which defaults (as stated in the documentation for --untracked-files) to all?

That was already added in the commit d6293d. Just set
     status.showUntrackedFiles=no

-- 
.marius [@trolltech.com]
'if you know what you're doing, it's not research'


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 187 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] git-commit: '--no-status' Allow suppression of status summary in commit msg
  2008-08-29  5:39     ` Marius Storm-Olsen
@ 2008-08-29  5:49       ` Marius Storm-Olsen
  0 siblings, 0 replies; 7+ messages in thread
From: Marius Storm-Olsen @ 2008-08-29  5:49 UTC (permalink / raw)
  To: Marcus Griep; +Cc: Alex Riesen, Git Mailing List, Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 750 bytes --]

Marius Storm-Olsen said the following on 29.08.2008 07:39:
> Marcus Griep said the following on 28.08.2008 21:24:
>> Using --untracked-files=no cuts the time to display the editor from down to 12 seconds,
>> so that is perfectly fine.  The patch can be ignored.  However, would config option to
>> change the default --untracked-files value be entertained?  Allowing:
>>
>> [commit]
>> 	untrackedfiles=no
>>
>> which defaults (as stated in the documentation for --untracked-files) to all?
> 
> That was already added in the commit d6293d. Just set
>      status.showUntrackedFiles=no
With that, I of course mean:

[status]
	showUntrackedFiles=no

-- 
.marius [@trolltech.com]
'if you know what you're doing, it's not research'


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 187 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-08-29  5:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-28 18:46 [PATCH] git-commit: '--no-status' Allow suppression of status summary in commit msg Marcus Griep
2008-08-28 19:09 ` Junio C Hamano
2008-08-28 19:34   ` Alex Riesen
2008-08-28 19:13 ` Alex Riesen
2008-08-28 19:24   ` Marcus Griep
2008-08-29  5:39     ` Marius Storm-Olsen
2008-08-29  5:49       ` Marius Storm-Olsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).