changing commit comments

Ted Pavlic ted at tedpavlic.com
Tue Jul 15 10:12:39 CDT 2008


> Just a question: what is the '--git' option about?
> All of you seems to use it, but i can't find any mention of it on the hg wiki.

Standard "diff" doesn't work well with binary files. For example, from a 
UNIX prompt:

$ diff /bin/bash /bin/ksh
Binary files /bin/bash and /bin/ksh differ

Mercurial doesn't use diff to store changes to binary files internally. 
However, when you produce patches for export (e.g., to e-mail to someone 
else), the standard "diff" format cannot handle those binary files and 
you get useless messages like the one above.

To combat this problem, gitdiff base-64 encodes binary files into long 
text files that can be diff'd. Any Mercurial command that produces a 
"patch" can be put into git mode to produce textual summaries of binary 
changes too (which are easy to e-mail, post, etc.).

MQ converts changesets (which are internally managed within Mercurial) 
to patches (which you can easily modify and re-order). The conversion 
from changeset to patch is only safe for binary files if your patches 
are using a gitdiff convention. Otherwise, your binary files are clobbered.

In your .hgrc, you can put:

[diff]
git = 1

which forces any command that produces a patch to use diff's in git 
format. However, with the --git flag, you can also manually force 
individual commands to use gitdiff.

The downside to using gitdiff is that you cannot use those patch files 
with standard UNIX patch. However, if you are using MQ/Mercurial as your 
interface to patches, then that's not a problem.

--TEd


-- 
Ted Pavlic <ted at tedpavlic.com>


More information about the Mercurial mailing list