Producing patchs for hg with git

As noted in a previous post, I am keeping the clang patches that are still pending in a git clone. A small inconvenience is formating them for review.

If I just use git show, the reviewers don’t get the commit message and cannot just use hg import or hg qimport.

I could keep an hg repo on the side just for generating the patches, but that looks like an overkill.

With some help from Ehsan I found how to produce an hg compatible patch directly from git:

git show --format="From: %an <%ae>%n%s%n%b"
This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Producing patchs for hg with git

  1. Rail says:

    Thanks for the tip. I’ve added -U8 to be consistent with my hg settings. The ~/.gitconfig file looks like this now:

    [alias]
    hgp = show --format=\"From: %an %n%s%n%b\" -U8

  2. glandium says:

    You can also use:
    git format-patch -U8 -o /some/directory -k HEAD^!
    (you can also replace HEAD with any commit, and HEAD^! with a commit range)
    hg import/qimport will even keep the commit date.

  3. respindola says:

    I remember trying format-patch, but hg was having problems importing some commits. Unfortunately I cannot remember what the problem was…