Re: [RFC/PATCH] revision.c: add --format option for 'git log'
- From
Felipe Contreras <felipe.contreras@gmail.com>
- Date
- Feb 22, 2009, 17:18 UTC
- Message-ID
- <94a0d4530902220918oc6f8ab9vc1fd0b55cad014a2@mail.gmail.com>
- In-Reply-To
- <7vtz6m1knv.fsf@gitster.siamese.dyndns.org>
On Sun, Feb 22, 2009 at 6:49 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 10 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes: > >> --format=:foo is a shorthand for --pretty=tformat:foo, otherwise this >> new option acts just like --pretty=foo, except it's more intuitive for >> users of 'git log'. > > It's been quite a long time since the earlier discussion, but I wonder why > you need the colon before "foo" for this new shorthand. I *think* you are > also introducing "--format=short" as a synonym to "--pretty=short", but > I do not think it is necessary.
Well, my hope was to replace --pretty=short with --format=short, but you said that would break other scripts.
>> As discussed in the mailing list, this is implemented as an undocumented >> option. > > Maybe somebody wants to document it.
Ah, I would gladly add the documentation, shall I write that it's an 'alternative' option similar to --pretty?
> Needs trivial tests.
All right.
Show 16 quoted lines
>> + } else if (!prefixcmp(arg, "--format=")) {
>> + char *modified = NULL;
>> + revs->verbose_header = 1;
>> + if (arg[9] == ':') {
>> + modified = xmalloc(strlen(arg+9) + 7 + 1);
>> + strcpy(modified, "tformat");
>> + strcat(modified, arg+9);
>> + }
>> + get_commit_format(modified ? modified : arg+9, revs);
>> + free(modified);
>
> struct strbuf fmt = STRBUF_INIT;
> revs->verbose_header = 1;
> strbuf_addf(&fmt, "tformat:%s", arg + 9);
> get_commit_format(fmt.buf, revs);
> strbuf_release(&fmt);Ah, I felt there must be a utility like that but I couldn't find examples of that. Thanks.
-- Felipe Contreras