How can I create a custom cleanup mode for git?
Posted
by Danny
on Stack Overflow
See other posts from Stack Overflow
or by Danny
Published on 2010-04-07T14:41:42Z
Indexed on
2010/04/07
14:43 UTC
Read the original article
Hit count: 220
Git's default cleanup of strip removes all lines starting with a #
character. Unfortunately, the Trac engine's wiki formatter uses hashes in the beginning of a code block to denote the syntax type. Additionally any code added verbatim might include hashes as they are a common comment prefix; Perl comes to mind. In the following example the comments all get destroyed by git's cleanup mode.
Example:
{{{
#!/usr/bin/perl
use strict;
# say hi to the user.
print "hello world\n";
}}}
I'd like to use a custom filter that removes all lines beginning with a hash from the bottom of the file upwards. Leaving those lines that being with a hash that are embedded in the commit message I wrote alone. Where or how can I specify this in git?
Note, creating a sed or perl script to perform the operation is not a problem, just knowing where to hook it into git is the question.
© Stack Overflow or respective owner