Skip to content
  • Jeff King's avatar
    filter-branch: avoid passing commit message through sed · df062010
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    On some systems (like OS X), if sed encounters input without
    a trailing newline, it will silently add it. As a result,
    "git filter-branch" on such systems may silently rewrite
    commit messages that omit a trailing newline. Even though
    this is not something we generate ourselves with "git
    commit", it's better for filter-branch to preserve the
    original data as closely as possible.
    
    We're using sed here only to strip the header fields from
    the commit object. We can accomplish the same thing with a
    shell loop. Since shell "read" calls are slow (usually one
    syscall per byte), we use "cat" once we've skipped past the
    header. Depending on the size of your commit messages, this
    is probably faster (you pay the cost to fork, but then read
    the data in saner-sized chunks). This idea is shamelessly
    stolen from Junio.
    
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    df062010