1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3 <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
7 Using git to develop FFmpeg
9 <meta name="viewport" content="width=device-width,initial-scale=1.0">
10 <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
11 <link rel="stylesheet" type="text/css" href="style.min.css">
14 <div style="width: 95%; margin: auto">
16 Using git to develop FFmpeg
23 <a name="SEC_Top"></a>
25 <a name="SEC_Contents"></a>
26 <h2 class="contents-heading">Table of Contents</h2>
28 <div class="contents">
30 <ul class="no-bullet">
31 <li><a name="toc-Introduction" href="#Introduction">1 Introduction</a></li>
32 <li><a name="toc-Basics-Usage" href="#Basics-Usage">2 Basics Usage</a>
33 <ul class="no-bullet">
34 <li><a name="toc-Get-GIT" href="#Get-GIT">2.1 Get GIT</a></li>
35 <li><a name="toc-Cloning-the-source-tree" href="#Cloning-the-source-tree">2.2 Cloning the source tree</a></li>
36 <li><a name="toc-Updating-the-source-tree-to-the-latest-revision-1" href="#Updating-the-source-tree-to-the-latest-revision-1">2.3 Updating the source tree to the latest revision</a></li>
37 <li><a name="toc-Rebasing-your-local-branches" href="#Rebasing-your-local-branches">2.4 Rebasing your local branches</a></li>
38 <li><a name="toc-Adding_002fremoving-files_002fdirectories" href="#Adding_002fremoving-files_002fdirectories">2.5 Adding/removing files/directories</a></li>
39 <li><a name="toc-Showing-modifications" href="#Showing-modifications">2.6 Showing modifications</a></li>
40 <li><a name="toc-Inspecting-the-changelog" href="#Inspecting-the-changelog">2.7 Inspecting the changelog</a></li>
41 <li><a name="toc-Checking-source-tree-status" href="#Checking-source-tree-status">2.8 Checking source tree status</a></li>
42 <li><a name="toc-Committing" href="#Committing">2.9 Committing</a></li>
43 <li><a name="toc-Preparing-a-patchset" href="#Preparing-a-patchset">2.10 Preparing a patchset</a></li>
44 <li><a name="toc-Sending-patches-for-review" href="#Sending-patches-for-review">2.11 Sending patches for review</a></li>
45 <li><a name="toc-Renaming_002fmoving_002fcopying-files-or-contents-of-files" href="#Renaming_002fmoving_002fcopying-files-or-contents-of-files">2.12 Renaming/moving/copying files or contents of files</a></li>
47 <li><a name="toc-Git-configuration" href="#Git-configuration">3 Git configuration</a>
48 <ul class="no-bullet">
49 <li><a name="toc-Personal-Git-installation" href="#Personal-Git-installation">3.1 Personal Git installation</a></li>
50 <li><a name="toc-Repository-configuration" href="#Repository-configuration">3.2 Repository configuration</a></li>
52 <li><a name="toc-FFmpeg-specific" href="#FFmpeg-specific">4 FFmpeg specific</a>
53 <ul class="no-bullet">
54 <li><a name="toc-Reverting-broken-commits" href="#Reverting-broken-commits">4.1 Reverting broken commits</a></li>
55 <li><a name="toc-Pushing-changes-to-remote-trees" href="#Pushing-changes-to-remote-trees">4.2 Pushing changes to remote trees</a></li>
56 <li><a name="toc-Finding-a-specific-svn-revision" href="#Finding-a-specific-svn-revision">4.3 Finding a specific svn revision</a></li>
58 <li><a name="toc-pre_002dpush-checklist" href="#pre_002dpush-checklist">5 pre-push checklist</a></li>
59 <li><a name="toc-Server-Issues" href="#Server-Issues">6 Server Issues</a></li>
64 <a name="Introduction"></a>
65 <h2 class="chapter">1 Introduction<span class="pull-right"><a class="anchor hidden-xs" href="#Introduction" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Introduction" aria-hidden="true">TOC</a></span></h2>
67 <p>This document aims in giving some quick references on a set of useful git
68 commands. You should always use the extensive and detailed documentation
69 provided directly by git:
72 <pre class="example">git --help
76 <p>shows you the available subcommands,
79 <pre class="example">git <command> --help
80 man git-<command>
83 <p>shows information about the subcommand <command>.
85 <p>Additional information could be found on the
86 <a href="http://gitref.org">Git Reference</a> website
88 <p>For more information about the Git project, visit the
90 <p><a href="http://git-scm.com/">Git website</a>
92 <p>Consult these resources whenever you have problems, they are quite exhaustive.
94 <p>What follows now is a basic introduction to Git and some FFmpeg-specific
95 guidelines to ease the contribution to the project
97 <a name="Basics-Usage"></a>
98 <h2 class="chapter">2 Basics Usage<span class="pull-right"><a class="anchor hidden-xs" href="#Basics-Usage" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Basics-Usage" aria-hidden="true">TOC</a></span></h2>
100 <a name="Get-GIT"></a>
101 <h3 class="section">2.1 Get GIT<span class="pull-right"><a class="anchor hidden-xs" href="#Get-GIT" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Get-GIT" aria-hidden="true">TOC</a></span></h3>
103 <p>You can get git from <a href="http://git-scm.com/">http://git-scm.com/</a>
104 Most distribution and operating system provide a package for it.
107 <a name="Cloning-the-source-tree"></a>
108 <h3 class="section">2.2 Cloning the source tree<span class="pull-right"><a class="anchor hidden-xs" href="#Cloning-the-source-tree" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Cloning-the-source-tree" aria-hidden="true">TOC</a></span></h3>
110 <div class="example">
111 <pre class="example">git clone git://source.ffmpeg.org/ffmpeg <target>
114 <p>This will put the FFmpeg sources into the directory <var><target></var>.
116 <div class="example">
117 <pre class="example">git clone git@source.ffmpeg.org:ffmpeg <target>
120 <p>This will put the FFmpeg sources into the directory <var><target></var> and let
121 you push back your changes to the remote repository.
123 <p>Make sure that you do not have Windows line endings in your checkouts,
124 otherwise you may experience spurious compilation failures. One way to
125 achieve this is to run
127 <div class="example">
128 <pre class="example">git config --global core.autocrlf false
132 <a name="Updating-the-source-tree-to-the-latest-revision"></a><a name="Updating-the-source-tree-to-the-latest-revision-1"></a>
133 <h3 class="section">2.3 Updating the source tree to the latest revision<span class="pull-right"><a class="anchor hidden-xs" href="#Updating-the-source-tree-to-the-latest-revision-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Updating-the-source-tree-to-the-latest-revision-1" aria-hidden="true">TOC</a></span></h3>
135 <div class="example">
136 <pre class="example">git pull (--rebase)
139 <p>pulls in the latest changes from the tracked branch. The tracked branch
140 can be remote. By default the master branch tracks the branch master in
143 <div class="warning">
144 <p><code>--rebase</code> (see below) is recommended.
146 <a name="Rebasing-your-local-branches"></a>
147 <h3 class="section">2.4 Rebasing your local branches<span class="pull-right"><a class="anchor hidden-xs" href="#Rebasing-your-local-branches" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Rebasing-your-local-branches" aria-hidden="true">TOC</a></span></h3>
149 <div class="example">
150 <pre class="example">git pull --rebase
153 <p>fetches the changes from the main repository and replays your local commits
154 over it. This is required to keep all your local changes at the top of
155 FFmpeg’s master tree. The master tree will reject pushes with merge commits.
158 <a name="Adding_002fremoving-files_002fdirectories"></a>
159 <h3 class="section">2.5 Adding/removing files/directories<span class="pull-right"><a class="anchor hidden-xs" href="#Adding_002fremoving-files_002fdirectories" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Adding_002fremoving-files_002fdirectories" aria-hidden="true">TOC</a></span></h3>
161 <div class="example">
162 <pre class="example">git add [-A] <filename/dirname>
163 git rm [-r] <filename/dirname>
166 <p>GIT needs to get notified of all changes you make to your working
167 directory that makes files appear or disappear.
168 Line moves across files are automatically tracked.
171 <a name="Showing-modifications"></a>
172 <h3 class="section">2.6 Showing modifications<span class="pull-right"><a class="anchor hidden-xs" href="#Showing-modifications" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Showing-modifications" aria-hidden="true">TOC</a></span></h3>
174 <div class="example">
175 <pre class="example">git diff <filename(s)>
178 <p>will show all local modifications in your working directory as unified diff.
181 <a name="Inspecting-the-changelog"></a>
182 <h3 class="section">2.7 Inspecting the changelog<span class="pull-right"><a class="anchor hidden-xs" href="#Inspecting-the-changelog" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Inspecting-the-changelog" aria-hidden="true">TOC</a></span></h3>
184 <div class="example">
185 <pre class="example">git log <filename(s)>
188 <p>You may also use the graphical tools like gitview or gitk or the web
189 interface available at http://source.ffmpeg.org/
191 <a name="Checking-source-tree-status"></a>
192 <h3 class="section">2.8 Checking source tree status<span class="pull-right"><a class="anchor hidden-xs" href="#Checking-source-tree-status" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Checking-source-tree-status" aria-hidden="true">TOC</a></span></h3>
194 <div class="example">
195 <pre class="example">git status
198 <p>detects all the changes you made and lists what actions will be taken in case
199 of a commit (additions, modifications, deletions, etc.).
202 <a name="Committing"></a>
203 <h3 class="section">2.9 Committing<span class="pull-right"><a class="anchor hidden-xs" href="#Committing" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Committing" aria-hidden="true">TOC</a></span></h3>
205 <div class="example">
206 <pre class="example">git diff --check
209 <p>to double check your changes before committing them to avoid trouble later
210 on. All experienced developers do this on each and every commit, no matter
212 Every one of them has been saved from looking like a fool by this many times.
213 It’s very easy for stray debug output or cosmetic modifications to slip in,
214 please avoid problems through this extra level of scrutiny.
216 <p>For cosmetics-only commits you should get (almost) empty output from
218 <div class="example">
219 <pre class="example">git diff -w -b <filename(s)>
222 <p>Also check the output of
224 <div class="example">
225 <pre class="example">git status
228 <p>to make sure you don’t have untracked files or deletions.
230 <div class="example">
231 <pre class="example">git add [-i|-p|-A] <filenames/dirnames>
234 <p>Make sure you have told git your name and email address
236 <div class="example">
237 <pre class="example">git config --global user.name "My Name"
238 git config --global user.email my@email.invalid
241 <p>Use <var>–global</var> to set the global configuration for all your git checkouts.
243 <p>Git will select the changes to the files for commit. Optionally you can use
244 the interactive or the patch mode to select hunk by hunk what should be
248 <div class="example">
249 <pre class="example">git commit
252 <p>Git will commit the selected changes to your current local branch.
254 <p>You will be prompted for a log message in an editor, which is either
255 set in your personal configuration file through
257 <div class="example">
258 <pre class="example">git config --global core.editor
261 <p>or set by one of the following environment variables:
262 <var>GIT_EDITOR</var>, <var>VISUAL</var> or <var>EDITOR</var>.
264 <p>Log messages should be concise but descriptive. Explain why you made a change,
265 what you did will be obvious from the changes themselves most of the time.
266 Saying just "bug fix" or "10l" is bad. Remember that people of varying skill
267 levels look at and educate themselves while reading through your code. Don’t
268 include filenames in log messages, Git provides that information.
270 <p>Possibly make the commit message have a terse, descriptive first line, an
271 empty line and then a full description. The first line will be used to name
272 the patch by git format-patch.
274 <a name="Preparing-a-patchset"></a>
275 <h3 class="section">2.10 Preparing a patchset<span class="pull-right"><a class="anchor hidden-xs" href="#Preparing-a-patchset" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Preparing-a-patchset" aria-hidden="true">TOC</a></span></h3>
277 <div class="example">
278 <pre class="example">git format-patch <commit> [-o directory]
281 <p>will generate a set of patches for each commit between <var><commit></var> and
282 current <var>HEAD</var>. E.g.
284 <div class="example">
285 <pre class="example">git format-patch origin/master
288 <p>will generate patches for all commits on current branch which are not
290 A useful shortcut is also
292 <div class="example">
293 <pre class="example">git format-patch -n
296 <p>which will generate patches from last <var>n</var> commits.
297 By default the patches are created in the current directory.
299 <a name="Sending-patches-for-review"></a>
300 <h3 class="section">2.11 Sending patches for review<span class="pull-right"><a class="anchor hidden-xs" href="#Sending-patches-for-review" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Sending-patches-for-review" aria-hidden="true">TOC</a></span></h3>
302 <div class="example">
303 <pre class="example">git send-email <commit list|directory>
306 <p>will send the patches created by <code>git format-patch</code> or directly
307 generates them. All the email fields can be configured in the global/local
308 configuration or overridden by command line.
309 Note that this tool must often be installed separately (e.g. <var>git-email</var>
310 package on Debian-based distros).
313 <a name="Renaming_002fmoving_002fcopying-files-or-contents-of-files"></a>
314 <h3 class="section">2.12 Renaming/moving/copying files or contents of files<span class="pull-right"><a class="anchor hidden-xs" href="#Renaming_002fmoving_002fcopying-files-or-contents-of-files" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Renaming_002fmoving_002fcopying-files-or-contents-of-files" aria-hidden="true">TOC</a></span></h3>
316 <p>Git automatically tracks such changes, making those normal commits.
318 <div class="example">
319 <pre class="example">mv/cp path/file otherpath/otherfile
325 <a name="Git-configuration"></a>
326 <h2 class="chapter">3 Git configuration<span class="pull-right"><a class="anchor hidden-xs" href="#Git-configuration" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Git-configuration" aria-hidden="true">TOC</a></span></h2>
328 <p>In order to simplify a few workflows, it is advisable to configure both
329 your personal Git installation and your local FFmpeg repository.
331 <a name="Personal-Git-installation"></a>
332 <h3 class="section">3.1 Personal Git installation<span class="pull-right"><a class="anchor hidden-xs" href="#Personal-Git-installation" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Personal-Git-installation" aria-hidden="true">TOC</a></span></h3>
334 <p>Add the following to your <samp>~/.gitconfig</samp> to help <code>git send-email</code>
335 and <code>git format-patch</code> detect renames:
337 <div class="example">
338 <pre class="example">[diff]
342 <a name="Repository-configuration"></a>
343 <h3 class="section">3.2 Repository configuration<span class="pull-right"><a class="anchor hidden-xs" href="#Repository-configuration" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Repository-configuration" aria-hidden="true">TOC</a></span></h3>
345 <p>In order to have <code>git send-email</code> automatically send patches
346 to the ffmpeg-devel mailing list, add the following stanza
347 to <samp>/path/to/ffmpeg/repository/.git/config</samp>:
349 <div class="example">
350 <pre class="example">[sendemail]
351 to = ffmpeg-devel@ffmpeg.org
354 <a name="FFmpeg-specific"></a>
355 <h2 class="chapter">4 FFmpeg specific<span class="pull-right"><a class="anchor hidden-xs" href="#FFmpeg-specific" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-FFmpeg-specific" aria-hidden="true">TOC</a></span></h2>
357 <a name="Reverting-broken-commits"></a>
358 <h3 class="section">4.1 Reverting broken commits<span class="pull-right"><a class="anchor hidden-xs" href="#Reverting-broken-commits" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Reverting-broken-commits" aria-hidden="true">TOC</a></span></h3>
360 <div class="example">
361 <pre class="example">git reset <commit>
364 <p><code>git reset</code> will uncommit the changes till <var><commit></var> rewriting
365 the current branch history.
367 <div class="example">
368 <pre class="example">git commit --amend
371 <p>allows one to amend the last commit details quickly.
373 <div class="example">
374 <pre class="example">git rebase -i origin/master
377 <p>will replay local commits over the main repository allowing to edit, merge
378 or remove some of them in the process.
381 <p><code>git reset</code>, <code>git commit --amend</code> and <code>git rebase</code>
382 rewrite history, so you should use them ONLY on your local or topic branches.
383 The main repository will reject those changes.
385 <div class="example">
386 <pre class="example">git revert <commit>
389 <p><code>git revert</code> will generate a revert commit. This will not make the
390 faulty commit disappear from the history.
392 <a name="Pushing-changes-to-remote-trees"></a>
393 <h3 class="section">4.2 Pushing changes to remote trees<span class="pull-right"><a class="anchor hidden-xs" href="#Pushing-changes-to-remote-trees" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Pushing-changes-to-remote-trees" aria-hidden="true">TOC</a></span></h3>
395 <div class="example">
396 <pre class="example">git push
399 <p>Will push the changes to the default remote (<var>origin</var>).
400 Git will prevent you from pushing changes if the local and remote trees are
401 out of sync. Refer to <a href="#Updating-the-source-tree-to-the-latest-revision">Updating the source tree to the latest revision</a>.
403 <div class="example">
404 <pre class="example">git remote add <name> <url>
407 <p>Will add additional remote with a name reference, it is useful if you want
408 to push your local branch for review on a remote host.
410 <div class="example">
411 <pre class="example">git push <remote> <refspec>
414 <p>Will push the changes to the <var><remote></var> repository.
415 Omitting <var><refspec></var> makes <code>git push</code> update all the remote
416 branches matching the local ones.
418 <a name="Finding-a-specific-svn-revision"></a>
419 <h3 class="section">4.3 Finding a specific svn revision<span class="pull-right"><a class="anchor hidden-xs" href="#Finding-a-specific-svn-revision" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Finding-a-specific-svn-revision" aria-hidden="true">TOC</a></span></h3>
421 <p>Since version 1.7.1 git supports <var>:/foo</var> syntax for specifying commits
422 based on a regular expression. see man gitrevisions
424 <div class="example">
425 <pre class="example">git show :/'as revision 23456'
428 <p>will show the svn changeset <var>r23456</var>. With older git versions searching in
429 the <code>git log</code> output is the easiest option (especially if a pager with
430 search capabilities is used).
431 This commit can be checked out with
433 <div class="example">
434 <pre class="example">git checkout -b svn_23456 :/'as revision 23456'
437 <p>or for git < 1.7.1 with
439 <div class="example">
440 <pre class="example">git checkout -b svn_23456 $SHA1
443 <p>where <var>$SHA1</var> is the commit hash from the <code>git log</code> output.
446 <a name="pre_002dpush-checklist"></a>
447 <h2 class="chapter">5 pre-push checklist<span class="pull-right"><a class="anchor hidden-xs" href="#pre_002dpush-checklist" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-pre_002dpush-checklist" aria-hidden="true">TOC</a></span></h2>
449 <p>Once you have a set of commits that you feel are ready for pushing,
450 work through the following checklist to doublecheck everything is in
451 proper order. This list tries to be exhaustive. In case you are just
452 pushing a typo in a comment, some of the steps may be unnecessary.
453 Apply your common sense, but if in doubt, err on the side of caution.
455 <p>First, make sure that the commits and branches you are going to push
456 match what you want pushed and that nothing is missing, extraneous or
457 wrong. You can see what will be pushed by running the git push command
458 with –dry-run first. And then inspecting the commits listed with
459 <code>git log -p 1234567..987654</code>. The <code>git status</code> command
460 may help in finding local changes that have been forgotten to be added.
462 <p>Next let the code pass through a full run of our testsuite.
465 <li> <code>make distclean</code>
466 </li><li> <code>/path/to/ffmpeg/configure</code>
467 </li><li> <code>make check</code>
468 </li><li> if fate fails due to missing samples run <code>make fate-rsync</code> and retry
471 <p>Make sure all your changes have been checked before pushing them, the
472 testsuite only checks against regressions and that only to some extend. It does
473 obviously not check newly added features/code to be working unless you have
474 added a test for that (which is recommended).
476 <p>Also note that every single commit should pass the test suite, not just
477 the result of a series of patches.
479 <p>Once everything passed, push the changes to your public ffmpeg clone and post a
480 merge request to ffmpeg-devel. You can also push them directly but this is not
483 <a name="Server-Issues"></a>
484 <h2 class="chapter">6 Server Issues<span class="pull-right"><a class="anchor hidden-xs" href="#Server-Issues" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Server-Issues" aria-hidden="true">TOC</a></span></h2>
486 <p>Contact the project admins <a href="mailto:root@ffmpeg.org">root@ffmpeg.org</a> if you have technical
487 problems with the GIT server.
489 <p style="font-size: small;">
490 This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.