Re: [PATCH] commit: allow --pretty= args to be abbreviated
- From
Junio C Hamano <junkio@cox.net>
- Date
- May 15, 2006, 20:47 UTC
- Message-ID
- <7vac9jhv66.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <20060515003405.GA5533@localdomain>
Eric Wong <normalperson@yhbt.net> writes:
> Unlike the original one, this one only does prefix matches, so > you can't do --pretty=er anymore :)
Sounds good. But then you know how long the unique prefix are for each candidate, so wouldn't this rather be redundant, I wonder?
Show 15 quoted lines
> +
> + /* look for abbreviations */
> + len = strlen(arg);
> + found = -1;
> + for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
> + if (!strncmp(cmt_fmts[i].n, arg, len)) {
> + if (found >= 0)
> + die("invalid --pretty format: %s", arg);
> + found = i;
> + }
> + }
> + if (found >= 0)
> + return cmt_fmts[found].v;
> + die("invalid --pretty format: %s", arg);
> }It would probably be better to say "ambiguous" not "invalid" in the die() message.