Re: [PATCH v2 3/5] Introduce new pretty formats %g[sdD] for reflog information
- From
Thomas Rast <trast@student.ethz.ch>
- Date
- Oct 16, 2009, 08:50 UTC
- Message-ID
- <200910161050.32378.trast@student.ethz.ch>
- In-Reply-To
- <20091016053230.GB10629@coredump.intra.peff.net>
Jeff King wrote:
Show 10 quoted lines
> > + if (shorten) {
> > + if (last_ref != commit_reflog->reflogs->ref) {
> > + free(last_short_ref);
> > + last_short_ref = shorten_unambiguous_ref(commit_reflog->reflogs->ref, 0);
> > + }
> > + printed_ref = last_short_ref;
>
> Clever. I hadn't considered caching, but you are right that
> shorten_unambiguous_ref is a bit heavyweight to be calling for every
> entry.I had a slightly better idea today: We can just put an extra member into the complete_reflogs struct, i.e., a short_ref to go along with the ref. It'll take a bit of auditing to verify that all allocations are zeroed, but since the struct is local to the file that shouldn't be so hard.
> A test for '%gd' would be nice. A squashable one is below. I am tempted > to test all three forms in t6006, since the intent of that script is to > test all format specifiers. However, those tests would be somewhat > redundant with your t1411 tests.
Ah, yeah, I looked for "reflog" instead of something about pretty, so I ended up with t1411. t6006 is a better fit. Thanks for the extra test!
--
Thomas Rast
trast@{inf,student}.ethz.ch