The argument to --pretty=format: or --pretty=tformat: (most users need tformat, but this code is using -z which adds a NUL character after each commit) contains both directives like %m and %H, and literal text that is simply transcribed:

Here, the hello and world strings were simply copied through, while %x25 was interpreted. Since it means "print character with hex code 25" which is the percent sign %, and -n 3 told git log to stop after logging three commits, we got three copies of hello%world.

The literal X works because %m prints one character that is not X, %H and %P print hashes that do not contain X, and %n prints a newline—so whatever is reading this output can be sure that each commit begins with the marker character, an X, the commit hash, another X, and each parent hash with a space between each, then a newline.

The %s%n%b sequence is not entirely necessary (one could simply use %B instead). I'm not sure off-hand, though, whether this adjusts the way that "unusually formatted" commits—those that are not a single subject line, followed by a newline, followed by a commit body—come out. It probably does.