Before the strbuf conversion, result was a char pointer. The if statement checked for it being not NULL, which meant that no "$Format:...$" string had been found and no replacement had to be made. format_subst() returned NULL in that case -- the caller then simply kept the original file content, as it was unaffected by the expansion. The length of the string being 0 is not the same as the string being NULL (expansion to an empty string vs. no expansion at all), so checking result.len != 0 is not a full replacement for the old NULL check. However, I doubt the subtle optimization explained above resulted in a notable speed-up anyway. Simplify the code and add the tail of the file to the expanded string unconditionally. Signed-off-by: Rene Scharfe <rene.scharfe@xxxxxxxxxxxxxx> --- builtin-archive.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/builtin-archive.c b/builtin-archive.c index b50d5ad..6fa424d 100644 --- a/builtin-archive.c +++ b/builtin-archive.c @@ -111,9 +111,7 @@ static void *format_subst(const struct commit *commit, const char *format, a = c + 1; } - if (result.len && len) { - strbuf_add(&result, a, len); - } + strbuf_add(&result, a, len); *sizep = result.len; - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html