On Mon, Sep 24, 2012 at 08:25:39PM -0400, Jeff King wrote:

> @@ -1168,7 +1180,11 @@ void format_commit_message(const struct commit *commit,
>               free(enc);
>       }
>  
> -     strbuf_expand(sb, format, format_commit_item, &context);
> +     if (pretty_ctx->fmt == CMIT_FMT_USERFORMAT)
> +             strbuf_expand(sb, format, format_commit_item, &context);
> +     else if (pretty_ctx->fmt == CMIT_FMT_LUA)
> +             lua_commit_format(sb, &context);
> +

This hunk breaks lots of tests. I know we are not seriously considering
the lua series as-is, but in case anybody wants to play with it, here is
the fix (and we would need the same fix regardless of language, anyway).

You might want to queue this on jk/lua-hackery (probably it would be
squashed in for a real series).

-- >8 --
Subject: [PATCH] pretty: fix up one-off format_commit_message calls

If the usual pretty-print code invokes format_commit_message,
the "fmt" field of the pretty_print_context will always have
either CMIT_FMT_USERFORMAT or CMIT_FMT_LUA in it, and we can
just choose which to use.

However, many call sites invoke format_commit_message
directly without bothering to set the "fmt" field of the
context; they expect format_commit_message to just default
to CMIT_FMT_USERFORMAT in that case, since previously that
was the only format it handled.

The recent addition of the lua formatter broke that
assumption. Rather than require each caller to be more
strict, let's just default to USERFORMAT when the format is
set to something nonsensical.

Signed-off-by: Jeff King <p...@peff.net>
---
 pretty.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pretty.c b/pretty.c
index fdd4258..7289590 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1180,10 +1180,10 @@ void format_commit_message(const struct commit *commit,
                free(enc);
        }
 
-       if (pretty_ctx->fmt == CMIT_FMT_USERFORMAT)
-               strbuf_expand(sb, format, format_commit_item, &context);
-       else if (pretty_ctx->fmt == CMIT_FMT_LUA)
+       if (pretty_ctx->fmt == CMIT_FMT_LUA)
                lua_commit_format(sb, &context);
+       else
+               strbuf_expand(sb, format, format_commit_item, &context);
 
        rewrap_message_tail(sb, &context, 0, 0, 0);
 
-- 
1.8.0.rc0.22.g285fd2d

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

Reply via email to