On Mon, Nov 11, 2019 at 03:47:10PM -0800, Denton Liu wrote: > On Sun, Nov 10, 2019 at 03:25:41PM +0900, Junio C Hamano wrote: > > René Scharfe <l.s.r@xxxxxx> writes: > > > > > Hmm, that's quite a lot of code to add to the formatting code with its > > > repeated special-case checks. Why not implement it as a built-in user > > > format, like making it an alias for something like this? > > > > > > git log --format='%C(auto)%h ("%s", %as)' > > > > > > We don't have %as, yet, but making --date=short available as a > > > placeholder would be a good idea anyway (patch below). > > > > Yes! Implementing the 'summary' internally as merely an alias to a > > canned user format does sound like the right approach. > > We don't have any canned user formats currently, do we? I'm trying to > figure out where to insert the code to do this. > > Is the idea to just insert a row in the builtin_formats[] table in > setup_commit_formats() with the `user_format` field populated? Yeah, it's as simple as adding: { "reference", CMIT_FMT_USERFORMAT, 1, 0, 0, "%C(auto)%h (%s, %as)" } Works like a charm, I've been using it for a few years now: https://github.com/szeder/git/commit/3604d0c28e7e2da5415986468994ef71a972e4ed but never seriously considered for submission, because I didn't want to argue about removing the double-quotes around the subject, and couldn't be bothered to check the corner cases (e.g. what if a user sets a pretty format alias with the same name in the configuration?).