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

Re: [PATCH 1/2] commit: Show committer if automatic

From
Junio C Hamano <gitster@pobox.com>
Date
May 3, 2008, 18:33 UTC
Message-ID
<7vmyn7tezi.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1209752541-19111-2-git-send-email-sbejar@gmail.com>
Santi Béjar <sbejar@gmail.com> writes:
> To remind the committer ident in case it is not what you want
> (taken from the gecos field, want to use different ident in
> different repositories).
That's not the only thing this patch does.
Show 41 quoted lines
> Signed-off-by: Santi Béjar <sbejar@gmail.com>
> ---
>  builtin-commit.c  |   40 +++++++++++++++++++++++++++++++++++++---
>  cache.h           |    1 +
>  config.c          |    4 ++++
>  environment.c     |    1 +
>  ident.c           |    3 +++
>  t/t7502-commit.sh |   13 +++++++++++++
>  6 files changed, 59 insertions(+), 3 deletions(-)
>
> diff --git a/builtin-commit.c b/builtin-commit.c
> index 057749b..b7cc382 100644
> --- a/builtin-commit.c
> +++ b/builtin-commit.c
> @@ -437,6 +437,29 @@ static void determine_author_info()
>  	author_date = date;
>  }
>  
> +const char *get_parent_ident()
> +{
> +	unsigned char sha1[20];
> +	struct commit *commit;
> +	const char *a, *lb, *rb, *eol;
> +
> +
> +	get_sha1("HEAD", sha1);
> +	commit = lookup_commit_reference(sha1);
> +	if (!commit)
> +		return NULL;
> +
> +	a = strstr(commit->buffer, "\ncommitter ");
> +
> +	lb = strstr(a + 11, " <");
> +	rb = strstr(a + 11, "> ");
> +	eol = strchr(a + 11, '\n');
> +	if (!lb || !rb || !eol)
> +		return NULL;
> +
> +	return xstrndup(a + 11, rb + 1 - (a + 11));
> +}
> +

Drop this hunk; nobody uses it after applying this patch, and "the same committer as the HEAD commit" is not a good heuristic.

Show 16 quoted lines
>  static int prepare_to_commit(const char *index_file, const char *prefix)
>  {
>  	struct stat statbuf;
> @@ -448,6 +471,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
>  	const char *hook_arg2 = NULL;
>  	const char *author_ident;
>  	const char *committer_ident;
> +	int showed_ident = 0;
>  
>  	if (!no_verify && run_hook(index_file, "pre-commit", NULL))
>  		return 0;
> @@ -528,6 +552,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
>  	strbuf_release(&sb);
>  
>  	determine_author_info();
> +	git_committer_info(0);

This call needs a comment to justify it, as it feels wrong to call a function that usually is used for its return string and discard the return value.

Show 11 quoted lines
> @@ -558,11 +583,20 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
>  					 getenv("GIT_COMMITTER_EMAIL")));
>  		if (strcmp(author_ident, committer_ident))
>  			fprintf(fp,
> -				"#\n"
> -				"# Author:    %s\n"
> -				"#\n",
> +				"%s"
> +				"# Author:    %s\n",
> +				showed_ident++ ? "" : "#\n",
>  				fmt_name(author_name, author_email));
This part should have been [0/2] as it has been agreed it is a good idea.
Previous: Santi BéjarNext: Santi Béjar
Message 3 of 11 in “Show committer ident in some cases”
  1. 0/2 Show committer ident in some casesSanti Béjar, May 2, 2008
  2. 1/2 commit: Show committer if automaticSanti Béjar, May 2, 2008
  3. Junio C HamanoMay 3, 2008
  4. Santi BéjarMay 3, 2008
  5. 2/2 user.warnautomatic: add config to control if the committer ident is shownSanti Béjar, May 2, 2008
  6. Junio C HamanoMay 2, 2008
  7. Santi BéjarMay 2, 2008
  8. Junio C HamanoMay 2, 2008
  9. Santi BéjarMay 3, 2008
  10. Jeff KingMay 5, 2008
  11. Junio C HamanoMay 5, 2008

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.