git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Do not generate full commit log message if it is not going to be used

From
Alex Riesen <raa.lkml@gmail.com>
Date
Nov 28, 2007, 21:13 UTC
Message-ID
<20071128211308.GB3173@steel.home>
In-Reply-To
<20071128211059.GA3173@steel.home>
Like when it is already specified through -C, -F or -m to git-commit.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
Alex Riesen, Wed, Nov 28, 2007 22:10:59 +0100:
Show 14 quoted lines
> Johannes Schindelin, Wed, Nov 28, 2007 13:18:10 +0100:
> > Besides, would this not be more elegant as
> > 
> > 		setup_revisions(0, NULL, &rev, "HEAD");
> 
> Hmm... And I was so puzzled as to what that "def" argument could
> possibly mean... Still am, in fact. But it works.
> 
> > > +		(void)run_diff_index(&rev, 1 /* cached */);
> > 
> > (void)?
> 
> I'll remove them and resubmit. Stupid custom.
> 
Here it goes.
 builtin-commit.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index a35881e..1a9a256 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -367,6 +367,28 @@ static int prepare_log_message(const char *index_file, const char *prefix)
 
 	strbuf_release(&sb);
 
+	if (no_edit) {
+		struct rev_info rev;
+		unsigned char sha1[40];
+
+		fclose(fp);
+
+		if (!active_nr && read_cache() < 0)
+			die("Cannot read index");
+
+		if (get_sha1("HEAD", sha1) != 0)
+			return !!active_nr;
+
+		init_revisions(&rev, "");
+		rev.abbrev = 0;
+		setup_revisions(0, NULL, &rev, "HEAD");
+		DIFF_OPT_SET(&rev.diffopt, QUIET);
+		DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
+		run_diff_index(&rev, 1 /* cached */);
+
+		return !!DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES);
+	}
+
 	if (in_merge && !no_edit)
 		fprintf(fp,
 			"#\n"
-- 
1.5.3.6.1014.g3543
Previous: Alex RiesenNext: Johannes Schindelin
Message 13 of 14 in “builtin-commit: add --cached to operate only on index”
  1. builtin-commit: add --cached to operate only on indexAlex Riesen, Nov 27, 2007
  2. Johannes SchindelinNov 27, 2007
  3. Alex RiesenNov 27, 2007
  4. Johannes SixtNov 27, 2007
  5. Alex RiesenNov 27, 2007
  6. Junio C HamanoNov 27, 2007
  7. Alex RiesenNov 27, 2007
  8. Alex RiesenNov 27, 2007
  9. Do not generate full commit log message if it not going to be usedAlex Riesen, Nov 27, 2007
  10. Alex RiesenNov 27, 2007
  11. Johannes SchindelinNov 28, 2007
  12. Alex RiesenNov 28, 2007
  13. Do not generate full commit log message if it is not going to be usedAlex Riesen, Nov 28, 2007
  14. Johannes SchindelinNov 28, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.