How to create custom cleanup mode for git?

I would like to have a cleanup commit message that does not necessarily delete lines starting with #in the message itself. By default --cleanup=strip, all strings starting with a character are deleted #.

Unfortunately, the reason is that the Trac engine wiki formatter uses hashes at the beginning of the code to indicate the type of syntax. This makes it difficult to use the syntax in my commit messages.

Example:

Created demo of perl added to helloworld.pl

{{{
#!/usr/bin/perl
use strict;
# say hi to the user.
print "hello world\n";

}}}

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
#   (use "git reset HEAD^1 <file>..." to unstage)
#
#   added:   helloworld.pl
# and so on and so forth...

I would like to get the following result in the final logged commit message:

commit 1234567890123456789012345678901234567890
Author: Danny <...>
Date:   Wed Apr 7 13:34:29 2010 -0400

     Created demo of perl added to helloworld.pl

     {{{
     #!/usr/bin/perl
     use strict;
     # say hi to the user.
     print "hello world\n";

     }}}

, , . , . git?

, sed perl script , , git, - .

, , .

+3
1

, :

  • . git commit --cleanup=<mode>; --cleanup=whitespace, git . , , , () . . , .

  • commit-msg . , githooks, , .git/hooks, . commit-msg - , . , ( ), . , script .git/hooks/commit-msg, , , . , hooks ; , - - , .git/hooks/commit-msg.

+4

Source: https://habr.com/ru/post/1740174/


All Articles