Re: [PATCH 1/2] Make git blame's date output format configurable, like git log
- From
- Eugene Letuchy <eletuchy@gmail.com>
- Date
- Feb 23, 2009, 09:09 UTC
- Message-ID
- <fbb390660902230109k15ed55b7le2ab08bb7dc274b6@mail.gmail.com>
- In-Reply-To
- <20090222230358.GA19011@coredump.intra.peff.net>
On Sun, Feb 22, 2009 at 3:03 PM, Jeff King <peff@peff.net> wrote:
Show 22 quoted lines
> On Fri, Feb 20, 2009 at 02:51:11PM -0800, eletuchy@gmail.com wrote:
>
>> @@ -1975,6 +1975,9 @@ static int git_blame_config(const char *var, const char *value, void *cb)
>> blank_boundary = git_config_bool(var, value);
>> return 0;
>> }
>> + if (!strcmp(var, "blame.date") && value[0]) {
>> + blame_date_mode = parse_date_format(value);
>> + }
>> return git_default_config(var, value, cb);
>> }
>
> When there is a config value we are expecting to have a value rather
> than a boolean, we usually print an error rather than silently
> discarding. IOW, something like this:
>
> if (!strcmp(var, "blame.date")) {
> if (!value)
> return config_error_nonbool(var);
> blame_date_mode = parse_date_format(value);
> }
>I'll make that change to the patch.
Show 23 quoted lines
>> + switch (blame_date_mode) {
>> + case DATE_RFC2822:
>> + blame_date_width = sizeof("Thu, 19 Oct 2006 16:00:04 -0700");
>> + break;
>> + case DATE_ISO8601:
>> + blame_date_width = sizeof("2006-10-19 16:00:04 -0700");
>> + break;
>> + case DATE_SHORT:
>> + blame_date_width = sizeof("2006-10-19");
>> + break;
>> + case DATE_RELATIVE:
>> + /* unfortunately "normal" is the fallback for "relative" */
>> + /* blame_date_width = sizeof("14 minutes ago"); */
>> + /* break; */
>> + case DATE_LOCAL:
>> + case DATE_NORMAL:
>> + blame_date_width = sizeof("Thu Oct 19 16:00:04 2006 -0700");
>> + break;
>> + }
>> + blame_date_width -= 1; /* strip the null */
>
> Maybe this should be a date_format_width() library function?
>I think that's a possible change, but unfortunately my next two patches would not apply cleanly with a date_format_width change.
I'm a n00b with respect to git contribution, but is there a procedure for pushing my blame_date branch remotely so that it's possible to track a series of patches?
Show 5 quoted lines
> > Other than that, the patch looks reasonable to me. > > -Peff >
-- Eugene