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 https://git.ffmpeg.org/ffmpeg.git <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 git@@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.
75 If you don't have write-access to the ffmpeg-web repository, you can
76 create patches after making a read-only ffmpeg-web clone:
79 git clone git://ffmpeg.org/ffmpeg-web <target>
82 Make sure that you do not have Windows line endings in your checkouts,
83 otherwise you may experience spurious compilation failures. One way to
84 achieve this is to run
87 git config --global core.autocrlf false
91 @anchor{Updating the source tree to the latest revision}
92 @section Updating the source tree to the latest revision
98 pulls in the latest changes from the tracked branch. The tracked branch
99 can be remote. By default the master branch tracks the branch master in
103 @command{--rebase} (see below) is recommended.
106 @section Rebasing your local branches
112 fetches the changes from the main repository and replays your local commits
113 over it. This is required to keep all your local changes at the top of
114 FFmpeg's master tree. The master tree will reject pushes with merge commits.
117 @section Adding/removing files/directories
120 git add [-A] <filename/dirname>
121 git rm [-r] <filename/dirname>
124 Git needs to get notified of all changes you make to your working
125 directory that makes files appear or disappear.
126 Line moves across files are automatically tracked.
129 @section Showing modifications
132 git diff <filename(s)>
135 will show all local modifications in your working directory as unified diff.
138 @section Inspecting the changelog
141 git log <filename(s)>
144 You may also use the graphical tools like @command{gitview} or @command{gitk}
145 or the web interface available at @url{http://source.ffmpeg.org/}.
147 @section Checking source tree status
153 detects all the changes you made and lists what actions will be taken in case
154 of a commit (additions, modifications, deletions, etc.).
163 to double check your changes before committing them to avoid trouble later
164 on. All experienced developers do this on each and every commit, no matter
167 Every one of them has been saved from looking like a fool by this many times.
168 It's very easy for stray debug output or cosmetic modifications to slip in,
169 please avoid problems through this extra level of scrutiny.
171 For cosmetics-only commits you should get (almost) empty output from
174 git diff -w -b <filename(s)>
177 Also check the output of
183 to make sure you don't have untracked files or deletions.
186 git add [-i|-p|-A] <filenames/dirnames>
189 Make sure you have told Git your name, email address and GPG key
192 git config --global user.name "My Name"
193 git config --global user.email my@@email.invalid
194 git config --global user.signingkey ABCDEF0123245
197 Enable signing all commits or use -S
200 git config --global commit.gpgsign true
203 Use @option{--global} to set the global configuration for all your Git checkouts.
205 Git will select the changes to the files for commit. Optionally you can use
206 the interactive or the patch mode to select hunk by hunk what should be
214 Git will commit the selected changes to your current local branch.
216 You will be prompted for a log message in an editor, which is either
217 set in your personal configuration file through
220 git config --global core.editor
223 or set by one of the following environment variables:
224 @var{GIT_EDITOR}, @var{VISUAL} or @var{EDITOR}.
226 @section Writing a commit message
228 Log messages should be concise but descriptive.
230 The first line must contain the context, a colon and a very short
231 summary of what the commit does. Details can be added, if necessary,
232 separated by an empty line. These details should not exceed 60-72 characters
233 per line, except when containing code.
235 Example of a good commit message:
238 avcodec/cbs: add a helper to read extradata within packet side data
240 Using ff_cbs_read() on the raw buffer will not parse it as extradata,
241 resulting in parsing errors for example when handling ISOBMFF avcC.
242 This helper works around that.
249 If the summary on the first line is not enough, in the body of the message,
250 explain why you made a change, what you did will be obvious from the changes
251 themselves most of the time. Saying just "bug fix" or "10l" is bad. Remember
252 that people of varying skill levels look at and educate themselves while
253 reading through your code. Don't include filenames in log messages except in
254 the context, Git provides that information.
256 If the commit fixes a registered issue, state it in a separate line of the
257 body: @code{Fix Trac ticket #42.}
259 The first line will be used to name
260 the patch by @command{git format-patch}.
262 Common mistakes for the first line, as seen in @command{git log --oneline}
263 include: missing context at the beginning; description of what the code did
264 before the patch; line too long or wrapped to the second line.
266 @section Preparing a patchset
269 git format-patch <commit> [-o directory]
272 will generate a set of patches for each commit between @var{<commit>} and
273 current @var{HEAD}. E.g.
276 git format-patch origin/master
279 will generate patches for all commits on current branch which are not
281 A useful shortcut is also
287 which will generate patches from last @var{n} commits.
288 By default the patches are created in the current directory.
290 @section Sending patches for review
293 git send-email <commit list|directory>
296 will send the patches created by @command{git format-patch} or directly
297 generates them. All the email fields can be configured in the global/local
298 configuration or overridden by command line.
299 Note that this tool must often be installed separately (e.g. @var{git-email}
300 package on Debian-based distros).
303 @section Renaming/moving/copying files or contents of files
305 Git automatically tracks such changes, making those normal commits.
308 mv/cp path/file otherpath/otherfile
314 @chapter Git configuration
316 In order to simplify a few workflows, it is advisable to configure both
317 your personal Git installation and your local FFmpeg repository.
319 @section Personal Git installation
321 Add the following to your @file{~/.gitconfig} to help @command{git send-email}
322 and @command{git format-patch} detect renames:
329 @section Repository configuration
331 In order to have @command{git send-email} automatically send patches
332 to the ffmpeg-devel mailing list, add the following stanza
333 to @file{/path/to/ffmpeg/repository/.git/config}:
337 to = ffmpeg-devel@@ffmpeg.org
340 @chapter FFmpeg specific
342 @section Reverting broken commits
348 @command{git reset} will uncommit the changes till @var{<commit>} rewriting
349 the current branch history.
355 allows one to amend the last commit details quickly.
358 git rebase -i origin/master
361 will replay local commits over the main repository allowing to edit, merge
362 or remove some of them in the process.
365 @command{git reset}, @command{git commit --amend} and @command{git rebase}
366 rewrite history, so you should use them ONLY on your local or topic branches.
367 The main repository will reject those changes.
374 @command{git revert} will generate a revert commit. This will not make the
375 faulty commit disappear from the history.
377 @section Pushing changes to remote trees
380 git push origin master --dry-run
383 Will simulate a push of the local master branch to the default remote
384 (@var{origin}). And list which branches and ranges or commits would have been
386 Git will prevent you from pushing changes if the local and remote trees are
387 out of sync. Refer to @ref{Updating the source tree to the latest revision}.
390 git remote add <name> <url>
393 Will add additional remote with a name reference, it is useful if you want
394 to push your local branch for review on a remote host.
397 git push <remote> <refspec>
400 Will push the changes to the @var{<remote>} repository.
401 Omitting @var{<refspec>} makes @command{git push} update all the remote
402 branches matching the local ones.
404 @section Finding a specific svn revision
406 Since version 1.7.1 Git supports @samp{:/foo} syntax for specifying commits
407 based on a regular expression. see man gitrevisions
410 git show :/'as revision 23456'
413 will show the svn changeset @samp{r23456}. With older Git versions searching in
414 the @command{git log} output is the easiest option (especially if a pager with
415 search capabilities is used).
417 This commit can be checked out with
420 git checkout -b svn_23456 :/'as revision 23456'
423 or for Git < 1.7.1 with
426 git checkout -b svn_23456 $SHA1
429 where @var{$SHA1} is the commit hash from the @command{git log} output.
432 @chapter gpg key generation
434 If you have no gpg key yet, we recommend that you create a ed25519 based key as it
435 is small, fast and secure. Especially it results in small signatures in git.
438 gpg --default-new-key-algo "ed25519/cert,sign+cv25519/encr" --quick-generate-key "human@@server.com"
441 When generating a key, make sure the email specified matches the email used in git as some sites like
442 github consider mismatches a reason to declare such commits unverified. After generating a key you
443 can add it to the MAINTAINER file and upload it to a keyserver.
445 @chapter Pre-push checklist
447 Once you have a set of commits that you feel are ready for pushing,
448 work through the following checklist to doublecheck everything is in
449 proper order. This list tries to be exhaustive. In case you are just
450 pushing a typo in a comment, some of the steps may be unnecessary.
451 Apply your common sense, but if in doubt, err on the side of caution.
453 First, make sure that the commits and branches you are going to push
454 match what you want pushed and that nothing is missing, extraneous or
455 wrong. You can see what will be pushed by running the git push command
456 with @option{--dry-run} first. And then inspecting the commits listed with
457 @command{git log -p 1234567..987654}. The @command{git status} command
458 may help in finding local changes that have been forgotten to be added.
460 Next let the code pass through a full run of our test suite.
463 @item @command{make distclean}
464 @item @command{/path/to/ffmpeg/configure}
465 @item @command{make fate}
466 @item if fate fails due to missing samples run @command{make fate-rsync} and retry
469 Make sure all your changes have been checked before pushing them, the
470 test suite only checks against regressions and that only to some extend. It does
471 obviously not check newly added features/code to be working unless you have
472 added a test for that (which is recommended).
474 Also note that every single commit should pass the test suite, not just
475 the result of a series of patches.
477 Once everything passed, push the changes to your public ffmpeg clone and post a
478 merge request to ffmpeg-devel. You can also push them directly but this is not
481 @chapter Server Issues
483 Contact the project admins at @email{root@@ffmpeg.org} if you have technical
484 problems with the Git server.