Re: [PATCH v2 2/3] pretty: make %H/%h dependent on --abbrev[-commit]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Apr 25, 2010 at 10:11:37PM -0500, Jonathan Nieder wrote:

> Here’s an alternative implementation of the more controversial half of
> your patch, for your amusement.  The big downside is that it requires
> one to specify --abbrev-commit before the --format option.

That is not insurmountable, as we could just check after the parsing
stage. But there is a worse problem:

> +static void abbreviate_commit_hashes(char *fmt)
> +{
> +	char *p;
> +	for (p = fmt; p != NULL; p = strchr(p + 1, '%')) {
> +		p++;
> +		switch (*p) {
> +		case 'H':
> +			*p = 'h';
> +			break;
> +		case 'P':
> +			*p = 'p';
> +			break;
> +		case 'T':
> +		default:
> +			break;
> +		}
> +	}
> +}

You parse '%%H' incorrectly. I would really rather not see ad-hoc
parsers for the format like this, but rather use or extend strbuf_expand
as appropriate. That would make things less painful if and when we
decide to tweak the syntax.

I think a lot of this might be more pleasant if we had some extensible
and backwards compatible syntax like %(placeholder, arg, ...) and could
do "%(H, abbrev=always)" or "%(H, abbrev=config)". Yeah, it's long, but
it is readable and explicit.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]