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