In a custom pretty format, using the '+' or ' ' combinators to prefix a non-empty expansion with whitespace will erroneously truncate subsequent expansions of the same type. Normally '%+X' inserts a newline before <X>, IFF the expansion of X is non-empty: $ git log -n 1 --pretty='format:newline:%+an' newline: MyName For the abbreviated commit hash placeholder ('h'), pretty.c uses add_again() to cache the result of the expansion, and then uses that result in future expansions. This causes problems when the expansion includes whitespace: $ git log -n 1 --pretty='format:newline:%+h%nno_newline:%h' newline: a0b1c2d no_newline: a0b1c2 The second expansion of the hash added an unwanted newline and removed the final character. It seemingly used the cached expansion *starting from the inserted newline*. The expected output is: $ git log -n 1 --pretty='format:newline:%+h%nno_newline:%h' newline: a0b1c2d no_newline:a0b1c2d /CC René from commit b9c62321 and Junio from 9fa708d