1 \input texinfo @c -*- texinfo -*-
2 @documentencoding UTF-8
4 @settitle Using Git to develop FFmpeg
7 @center @titlefont{Using Git to develop FFmpeg}
16 This document aims in giving some quick references on a set of useful Git
17 commands. You should always use the extensive and detailed documentation
18 provided directly by Git:
25 shows you the available subcommands,
32 shows information about the subcommand <command>.
34 Additional information could be found on the
35 @url{http://gitref.org, Git Reference} website.
37 For more information about the Git project, visit the
38 @url{http://git-scm.com/, Git website}.
40 Consult these resources whenever you have problems, they are quite exhaustive.
42 What follows now is a basic introduction to Git and some FFmpeg-specific
43 guidelines to ease the contribution to the project.
49 You can get Git from @url{http://git-scm.com/}
50 Most distribution and operating system provide a package for it.
53 @section Cloning the source tree
56 git clone git://source.ffmpeg.org/ffmpeg <target>
59 This will put the FFmpeg sources into the directory @var{<target>}.
62 git clone git@@source.ffmpeg.org:ffmpeg <target>
65 This will put the FFmpeg sources into the directory @var{<target>} and let
66 you push back your changes to the remote repository.
69 git clone gil@@ffmpeg.org:ffmpeg-web <target>
72 This will put the source of the FFmpeg website into the directory
73 @var{<target>} and let you push back your changes to the remote repository.
74 (Note that @var{gil} stands for GItoLite and is not a typo of @var{git}.)
76 If you don't have write-access to the ffmpeg-web repository, you can
77 create patches after making a read-only ffmpeg-web clone:
80 git clone git://ffmpeg.org/ffmpeg-web <target>
83 Make sure that you do not have Windows line endings in your checkouts,
84 otherwise you may experience spurious compilation failures. One way to
85 achieve this is to run
88 git config --global core.autocrlf false
92 @anchor{Updating the source tree to the latest revision}
93 @section Updating the source tree to the latest revision
99 pulls in the latest changes from the tracked branch. The tracked branch
100 can be remote. By default the master branch tracks the branch master in
104 @command{--rebase} (see below) is recommended.
107 @section Rebasing your local branches
113 fetches the changes from the main repository and replays your local commits
114 over it. This is required to keep all your local changes at the top of
115 FFmpeg's master tree. The master tree will reject pushes with merge commits.
118 @section Adding/removing files/directories
121 git add [-A] <filename/dirname>
122 git rm [-r] <filename/dirname>
125 Git needs to get notified of all changes you make to your working
126 directory that makes files appear or disappear.
127 Line moves across files are automatically tracked.
130 @section Showing modifications
133 git diff <filename(s)>
136 will show all local modifications in your working directory as unified diff.
139 @section Inspecting the changelog
142 git log <filename(s)>
145 You may also use the graphical tools like @command{gitview} or @command{gitk}
146 or the web interface available at @url{http://source.ffmpeg.org/}.
148 @section Checking source tree status
154 detects all the changes you made and lists what actions will be taken in case
155 of a commit (additions, modifications, deletions, etc.).
164 to double check your changes before committing them to avoid trouble later
165 on. All experienced developers do this on each and every commit, no matter
168 Every one of them has been saved from looking like a fool by this many times.
169 It's very easy for stray debug output or cosmetic modifications to slip in,
170 please avoid problems through this extra level of scrutiny.
172 For cosmetics-only commits you should get (almost) empty output from
175 git diff -w -b <filename(s)>
178 Also check the output of
184 to make sure you don't have untracked files or deletions.
187 git add [-i|-p|-A] <filenames/dirnames>
190 Make sure you have told Git your name, email address and GPG key
193 git config --global user.name "My Name"
194 git config --global user.email my@@email.invalid
195 git config --global user.signingkey ABCDEF0123245
198 Enable signing all commits or use -S
201 git config --global commit.gpgsign true
204 Use @option{--global} to set the global configuration for all your Git checkouts.
206 Git will select the changes to the files for commit. Optionally you can use
207 the interactive or the patch mode to select hunk by hunk what should be
215 Git will commit the selected changes to your current local branch.
217 You will be prompted for a log message in an editor, which is either
218 set in your personal configuration file through
221 git config --global core.editor
224 or set by one of the following environment variables:
225 @var{GIT_EDITOR}, @var{VISUAL} or @var{EDITOR}.
227 @section Writing a commit message
229 Log messages should be concise but descriptive.
231 The first line must contain the context, a colon and a very short
232 summary of what the commit does. Details can be added, if necessary,
233 separated by an empty line. These details should not exceed 60-72 characters
234 per line, except when containing code.
236 Example of a good commit message:
239 avcodec/cbs: add a helper to read extradata within packet side data
241 Using ff_cbs_read() on the raw buffer will not parse it as extradata,
242 resulting in parsing errors for example when handling ISOBMFF avcC.
243 This helper works around that.
250 If the summary on the first line is not enough, in the body of the message,
251 explain why you made a change, what you did will be obvious from the changes
252 themselves most of the time. Saying just "bug fix" or "10l" is bad. Remember
253 that people of varying skill levels look at and educate themselves while
254 reading through your code. Don't include filenames in log messages except in
255 the context, Git provides that information.
257 If the commit fixes a registered issue, state it in a separate line of the
258 body: @code{Fix Trac ticket #42.}
260 The first line will be used to name
261 the patch by @command{git format-patch}.
263 Common mistakes for the first line, as seen in @command{git log --oneline}
264 include: missing context at the beginning; description of what the code did
265 before the patch; line too long or wrapped to the second line.
267 @section Preparing a patchset
270 git format-patch <commit> [-o directory]
273 will generate a set of patches for each commit between @var{<commit>} and
274 current @var{HEAD}. E.g.
277 git format-patch origin/master
280 will generate patches for all commits on current branch which are not
282 A useful shortcut is also
288 which will generate patches from last @var{n} commits.
289 By default the patches are created in the current directory.
291 @section Sending patches for review
294 git send-email <commit list|directory>
297 will send the patches created by @command{git format-patch} or directly
298 generates them. All the email fields can be configured in the global/local
299 configuration or overridden by command line.
300 Note that this tool must often be installed separately (e.g. @var{git-email}
301 package on Debian-based distros).
304 @section Renaming/moving/copying files or contents of files
306 Git automatically tracks such changes, making those normal commits.
309 mv/cp path/file otherpath/otherfile
315 @chapter Git configuration
317 In order to simplify a few workflows, it is advisable to configure both
318 your personal Git installation and your local FFmpeg repository.
320 @section Personal Git installation
322 Add the following to your @file{~/.gitconfig} to help @command{git send-email}
323 and @command{git format-patch} detect renames:
330 @section Repository configuration
332 In order to have @command{git send-email} automatically send patches
333 to the ffmpeg-devel mailing list, add the following stanza
334 to @file{/path/to/ffmpeg/repository/.git/config}:
338 to = ffmpeg-devel@@ffmpeg.org
341 @chapter FFmpeg specific
343 @section Reverting broken commits
349 @command{git reset} will uncommit the changes till @var{<commit>} rewriting
350 the current branch history.
356 allows one to amend the last commit details quickly.
359 git rebase -i origin/master
362 will replay local commits over the main repository allowing to edit, merge
363 or remove some of them in the process.
366 @command{git reset}, @command{git commit --amend} and @command{git rebase}
367 rewrite history, so you should use them ONLY on your local or topic branches.
368 The main repository will reject those changes.
375 @command{git revert} will generate a revert commit. This will not make the
376 faulty commit disappear from the history.
378 @section Pushing changes to remote trees
381 git push origin master --dry-run
384 Will simulate a push of the local master branch to the default remote
385 (@var{origin}). And list which branches and ranges or commits would have been
387 Git will prevent you from pushing changes if the local and remote trees are
388 out of sync. Refer to @ref{Updating the source tree to the latest revision}.
391 git remote add <name> <url>
394 Will add additional remote with a name reference, it is useful if you want
395 to push your local branch for review on a remote host.
398 git push <remote> <refspec>
401 Will push the changes to the @var{<remote>} repository.
402 Omitting @var{<refspec>} makes @command{git push} update all the remote
403 branches matching the local ones.
405 @section Finding a specific svn revision
407 Since version 1.7.1 Git supports @samp{:/foo} syntax for specifying commits
408 based on a regular expression. see man gitrevisions
411 git show :/'as revision 23456'
414 will show the svn changeset @samp{r23456}. With older Git versions searching in
415 the @command{git log} output is the easiest option (especially if a pager with
416 search capabilities is used).
418 This commit can be checked out with
421 git checkout -b svn_23456 :/'as revision 23456'
424 or for Git < 1.7.1 with
427 git checkout -b svn_23456 $SHA1
430 where @var{$SHA1} is the commit hash from the @command{git log} output.
433 @chapter gpg key generation
435 If you have no gpg key yet, we recommend that you create a ed25519 based key as it
436 is small, fast and secure. Especially it results in small signatures in git.
439 gpg --default-new-key-algo "ed25519/cert,sign+cv25519/encr" --quick-generate-key "human@@server.com"
442 When generating a key, make sure the email specified matches the email used in git as some sites like
443 github consider mismatches a reason to declare such commits unverified. After generating a key you
444 can add it to the MAINTAINER file and upload it to a keyserver.
446 @chapter Pre-push checklist
448 Once you have a set of commits that you feel are ready for pushing,
449 work through the following checklist to doublecheck everything is in
450 proper order. This list tries to be exhaustive. In case you are just
451 pushing a typo in a comment, some of the steps may be unnecessary.
452 Apply your common sense, but if in doubt, err on the side of caution.
454 First, make sure that the commits and branches you are going to push
455 match what you want pushed and that nothing is missing, extraneous or
456 wrong. You can see what will be pushed by running the git push command
457 with @option{--dry-run} first. And then inspecting the commits listed with
458 @command{git log -p 1234567..987654}. The @command{git status} command
459 may help in finding local changes that have been forgotten to be added.
461 Next let the code pass through a full run of our test suite.
464 @item @command{make distclean}
465 @item @command{/path/to/ffmpeg/configure}
466 @item @command{make fate}
467 @item if fate fails due to missing samples run @command{make fate-rsync} and retry
470 Make sure all your changes have been checked before pushing them, the
471 test suite only checks against regressions and that only to some extend. It does
472 obviously not check newly added features/code to be working unless you have
473 added a test for that (which is recommended).
475 Also note that every single commit should pass the test suite, not just
476 the result of a series of patches.
478 Once everything passed, push the changes to your public ffmpeg clone and post a
479 merge request to ffmpeg-devel. You can also push them directly but this is not
482 @chapter Server Issues
484 Contact the project admins at @email{root@@ffmpeg.org} if you have technical
485 problems with the Git server.