FFmpeg: create patch for git HEAD

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
peter_b
Chatterbox
Posts: 383
Joined: Tue Nov 12, 2013 2:05 am

FFmpeg: create patch for git HEAD

Post by peter_b »

Here's a small and short HowTo about how to create a proper patch after making changes to FFmpeg.
It will assume the target revision to be "git HEAD".

1) Checkout the current git version:

Code: Select all

$ git clone git://source.ffmpeg.org/ffmpeg.git
2) Keep a fresh, untouched copy:
Before touching the git checkout, make a copy. This makes it easier to rollback or do other stuff against a fresh git revision, rather than pulling it off the server all the time.
I'll call the folder copy "ffmpeg-git-FRESH":

Code: Select all

cp -av ffmpeg-git ffmpeg-git-FRESH
2) Make your changes:
Now, edit your copy of FFmpeg as it fits your needs.

3) Add and commit your changes:
For those SVN users (like me) who'd now think: "commit my changes? upstream? me? how?!?"
Committing your changes to your git tree are only done locally. Then fill out a proper commit message (as you'd normally do with any version control system).

NOTE: Repeat this step for each change you'd consider to be reasonable to have its own patch file.
This makes reviewing patches easier for maintainers, and allows a more granular way of applying and reversing changes.

4) Update to recent git HEAD:
During the time you've been working on your changes, it's very likely that the hard-working, sedulous contributors and maintainers of FFmpeg have uploaded changes themselves.
Therefore, it's a good thing to update your working copy to the most recent state:

Code: Select all

$ git pull
Don't worry: This will merge other's changes wherever possible - and your modifications will (of course) stay in place.
It's a good thing to do a "make clean", recompile and test this version to see avoid conflicts of any kind.

5) Rebase:
In case your reflog says the following after "git pull":
HEAD@{0}: pull: Merge made by the 'recursive' strategy.
And "git format-patch" generates patches for other people's commits contained in that pull, you have to "rebase" to the right branch: "origin/master"

Code: Select all

$ git rebase origin/master
5) Create the patch:

Code: Select all

$ git format-patch HEAD~~
This will create patches for each commit and automatically number and name them, according to your entered commit-notes.
They will start with a zero-padded number. A patch filename may look like this for example:
0001-My_first_awesome_contribution_to_ffmpeg.patch
That's it! :)


Links:
Post Reply