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

Re: [PATCH 3/3] commit: Show the committer ident when is different from the parent

From
Jeff King <peff@peff.net>
Date
Apr 30, 2008, 14:50 UTC
Message-ID
<20080430145017.GA922@sigill.intra.peff.net>
In-Reply-To
<1209545236-4266-4-git-send-email-sbejar@gmail.com>
On Wed, Apr 30, 2008 at 10:47:16AM +0200, Santi Béjar wrote:
Show 6 quoted lines
>   it does not work with the initial commit, I don't know why.
>   Even with this:
> 	if (!commit)
> 		return NULL;
> 
>   Can someone help me? Thanks

It segfaults for me, since you try to strdup NULL. I think you want to return "" if there is no initial commit, so you can strcmp against the current committer (or alternatively, explicitly check for NULL).

Show 6 quoted lines
> +		parent_ident = xstrdup(get_parent_ident());
> +		if (strcmp(parent_ident, committer_ident))
> +			fprintf(fp,
> +				"# Committer: %s\n",
> +				committer_ident);
> +

Why strdup at all here, which leaks? Nobody else uses this variable, so it should be sufficient to strcmp(get_parent_ident(), committer_ident) once get_parent_ident promises to always return a valid string. Or alternatively:

  parent_ident = get_parent_ident();
  if (!parent_ident || strcmp(parent_ident, committer_ident))
A few other comments (I like the idea overall):
  - I haven't looked at the code organization, so maybe it is not
    feasible, but it seems like this stuff should go into wt-status's
    implementation, which would show up in a git-status.
  - The output looks very cluttered. It would be nice to have
    # enter your commit message...
    #
    # Author: whatever
    # Committer: whatever
    #
    # other stuff
    IOW, put in a blank line on either side, but not between the two
    identities if both are shown.
-Peff
Previous: Santi BéjarNext: Jeff King
Message 5 of 15 in “Show author and/or committer in some cases”
  1. 0/3 Show author and/or committer in some casesSanti Béjar, Apr 30, 2008
  2. 1/3 Preparation to call determine_author_info from prepare_to_commitSanti Béjar, Apr 30, 2008
  3. 2/3 commit: Show author if different from committerSanti Béjar, Apr 30, 2008
  4. 3/3 commit: Show the committer ident when is different from the parentSanti Béjar, Apr 30, 2008
  5. Jeff KingApr 30, 2008
  6. Jeff KingApr 30, 2008
  7. Jeff KingApr 30, 2008
  8. Santi BéjarApr 30, 2008
  9. Jeff KingApr 30, 2008
  10. Santi BéjarMay 1, 2008
  11. Jeff KingMay 1, 2008
  12. Junio C HamanoMay 1, 2008
  13. Jeff KingMay 1, 2008
  14. Santi BéjarMay 2, 2008
  15. Alex RiesenApr 30, 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.