]> git.sesse.net Git - ffmpeg/blob - doc/git-howto.texi
Replace av_dlog with ff_dlog.
[ffmpeg] / doc / git-howto.texi
1 \input texinfo @c -*- texinfo -*-
2 @documentencoding UTF-8
3
4 @settitle Using git to develop FFmpeg
5
6 @titlepage
7 @center @titlefont{Using git to develop FFmpeg}
8 @end titlepage
9
10 @top
11
12 @contents
13
14 @chapter Introduction
15
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:
19
20 @example
21 git --help
22 man git
23 @end example
24
25 shows you the available subcommands,
26
27 @example
28 git <command> --help
29 man git-<command>
30 @end example
31
32 shows information about the subcommand <command>.
33
34 Additional information could be found on the
35 @url{http://gitref.org, Git Reference} website
36
37 For more information about the Git project, visit the
38
39 @url{http://git-scm.com/, Git website}
40
41 Consult these resources whenever you have problems, they are quite exhaustive.
42
43 What follows now is a basic introduction to Git and some FFmpeg-specific
44 guidelines to ease the contribution to the project
45
46 @chapter Basics Usage
47
48 @section Get GIT
49
50 You can get git from @url{http://git-scm.com/}
51 Most distribution and operating system provide a package for it.
52
53
54 @section Cloning the source tree
55
56 @example
57 git clone git://source.ffmpeg.org/ffmpeg <target>
58 @end example
59
60 This will put the FFmpeg sources into the directory @var{<target>}.
61
62 @example
63 git clone git@@source.ffmpeg.org:ffmpeg <target>
64 @end example
65
66 This will put the FFmpeg sources into the directory @var{<target>} and let
67 you push back your changes to the remote repository.
68
69 Make sure that you do not have Windows line endings in your checkouts,
70 otherwise you may experience spurious compilation failures. One way to
71 achieve this is to run
72
73 @example
74 git config --global core.autocrlf false
75 @end example
76
77
78 @anchor{Updating the source tree to the latest revision}
79 @section Updating the source tree to the latest revision
80
81 @example
82 git pull (--rebase)
83 @end example
84
85 pulls in the latest changes from the tracked branch. The tracked branch
86 can be remote. By default the master branch tracks the branch master in
87 the remote origin.
88
89 @float IMPORTANT
90 @command{--rebase} (see below) is recommended.
91 @end float
92
93 @section Rebasing your local branches
94
95 @example
96 git pull --rebase
97 @end example
98
99 fetches the changes from the main repository and replays your local commits
100 over it. This is required to keep all your local changes at the top of
101 FFmpeg's master tree. The master tree will reject pushes with merge commits.
102
103
104 @section Adding/removing files/directories
105
106 @example
107 git add [-A] <filename/dirname>
108 git rm [-r] <filename/dirname>
109 @end example
110
111 GIT needs to get notified of all changes you make to your working
112 directory that makes files appear or disappear.
113 Line moves across files are automatically tracked.
114
115
116 @section Showing modifications
117
118 @example
119 git diff <filename(s)>
120 @end example
121
122 will show all local modifications in your working directory as unified diff.
123
124
125 @section Inspecting the changelog
126
127 @example
128 git log <filename(s)>
129 @end example
130
131 You may also use the graphical tools like gitview or gitk or the web
132 interface available at http://source.ffmpeg.org/
133
134 @section Checking source tree status
135
136 @example
137 git status
138 @end example
139
140 detects all the changes you made and lists what actions will be taken in case
141 of a commit (additions, modifications, deletions, etc.).
142
143
144 @section Committing
145
146 @example
147 git diff --check
148 @end example
149
150 to double check your changes before committing them to avoid trouble later
151 on. All experienced developers do this on each and every commit, no matter
152 how small.
153 Every one of them has been saved from looking like a fool by this many times.
154 It's very easy for stray debug output or cosmetic modifications to slip in,
155 please avoid problems through this extra level of scrutiny.
156
157 For cosmetics-only commits you should get (almost) empty output from
158
159 @example
160 git diff -w -b <filename(s)>
161 @end example
162
163 Also check the output of
164
165 @example
166 git status
167 @end example
168
169 to make sure you don't have untracked files or deletions.
170
171 @example
172 git add [-i|-p|-A] <filenames/dirnames>
173 @end example
174
175 Make sure you have told git your name and email address
176
177 @example
178 git config --global user.name "My Name"
179 git config --global user.email my@@email.invalid
180 @end example
181
182 Use @var{--global} to set the global configuration for all your git checkouts.
183
184 Git will select the changes to the files for commit. Optionally you can use
185 the interactive or the patch mode to select hunk by hunk what should be
186 added to the commit.
187
188
189 @example
190 git commit
191 @end example
192
193 Git will commit the selected changes to your current local branch.
194
195 You will be prompted for a log message in an editor, which is either
196 set in your personal configuration file through
197
198 @example
199 git config --global core.editor
200 @end example
201
202 or set by one of the following environment variables:
203 @var{GIT_EDITOR}, @var{VISUAL} or @var{EDITOR}.
204
205 Log messages should be concise but descriptive. Explain why you made a change,
206 what you did will be obvious from the changes themselves most of the time.
207 Saying just "bug fix" or "10l" is bad. Remember that people of varying skill
208 levels look at and educate themselves while reading through your code. Don't
209 include filenames in log messages, Git provides that information.
210
211 Possibly make the commit message have a terse, descriptive first line, an
212 empty line and then a full description. The first line will be used to name
213 the patch by git format-patch.
214
215 @section Preparing a patchset
216
217 @example
218 git format-patch <commit> [-o directory]
219 @end example
220
221 will generate a set of patches for each commit between @var{<commit>} and
222 current @var{HEAD}. E.g.
223
224 @example
225 git format-patch origin/master
226 @end example
227
228 will generate patches for all commits on current branch which are not
229 present in upstream.
230 A useful shortcut is also
231
232 @example
233 git format-patch -n
234 @end example
235
236 which will generate patches from last @var{n} commits.
237 By default the patches are created in the current directory.
238
239 @section Sending patches for review
240
241 @example
242 git send-email <commit list|directory>
243 @end example
244
245 will send the patches created by @command{git format-patch} or directly
246 generates them. All the email fields can be configured in the global/local
247 configuration or overridden by command line.
248 Note that this tool must often be installed separately (e.g. @var{git-email}
249 package on Debian-based distros).
250
251
252 @section Renaming/moving/copying files or contents of files
253
254 Git automatically tracks such changes, making those normal commits.
255
256 @example
257 mv/cp path/file otherpath/otherfile
258 git add [-A] .
259 git commit
260 @end example
261
262
263 @chapter Git configuration
264
265 In order to simplify a few workflows, it is advisable to configure both
266 your personal Git installation and your local FFmpeg repository.
267
268 @section Personal Git installation
269
270 Add the following to your @file{~/.gitconfig} to help @command{git send-email}
271 and @command{git format-patch} detect renames:
272
273 @example
274 [diff]
275         renames = copy
276 @end example
277
278 @section Repository configuration
279
280 In order to have @command{git send-email} automatically send patches
281 to the ffmpeg-devel mailing list, add the following stanza
282 to @file{/path/to/ffmpeg/repository/.git/config}:
283
284 @example
285 [sendemail]
286         to = ffmpeg-devel@@ffmpeg.org
287 @end example
288
289 @chapter FFmpeg specific
290
291 @section Reverting broken commits
292
293 @example
294 git reset <commit>
295 @end example
296
297 @command{git reset} will uncommit the changes till @var{<commit>} rewriting
298 the current branch history.
299
300 @example
301 git commit --amend
302 @end example
303
304 allows one to amend the last commit details quickly.
305
306 @example
307 git rebase -i origin/master
308 @end example
309
310 will replay local commits over the main repository allowing to edit, merge
311 or remove some of them in the process.
312
313 @float NOTE
314 @command{git reset}, @command{git commit --amend} and @command{git rebase}
315 rewrite history, so you should use them ONLY on your local or topic branches.
316 The main repository will reject those changes.
317 @end float
318
319 @example
320 git revert <commit>
321 @end example
322
323 @command{git revert} will generate a revert commit. This will not make the
324 faulty commit disappear from the history.
325
326 @section Pushing changes to remote trees
327
328 @example
329 git push origin master --dry-run
330 @end example
331
332 Will simulate a push of the local master branch to the default remote
333 (@var{origin}). And list which branches and ranges or commits would have been
334 pushed.
335 Git will prevent you from pushing changes if the local and remote trees are
336 out of sync. Refer to @ref{Updating the source tree to the latest revision}.
337
338 @example
339 git remote add <name> <url>
340 @end example
341
342 Will add additional remote with a name reference, it is useful if you want
343 to push your local branch for review on a remote host.
344
345 @example
346 git push <remote> <refspec>
347 @end example
348
349 Will push the changes to the @var{<remote>} repository.
350 Omitting @var{<refspec>} makes @command{git push} update all the remote
351 branches matching the local ones.
352
353 @section Finding a specific svn revision
354
355 Since version 1.7.1 git supports @var{:/foo} syntax for specifying commits
356 based on a regular expression. see man gitrevisions
357
358 @example
359 git show :/'as revision 23456'
360 @end example
361
362 will show the svn changeset @var{r23456}. With older git versions searching in
363 the @command{git log} output is the easiest option (especially if a pager with
364 search capabilities is used).
365 This commit can be checked out with
366
367 @example
368 git checkout -b svn_23456 :/'as revision 23456'
369 @end example
370
371 or for git < 1.7.1 with
372
373 @example
374 git checkout -b svn_23456 $SHA1
375 @end example
376
377 where @var{$SHA1} is the commit hash from the @command{git log} output.
378
379
380 @chapter pre-push checklist
381
382 Once you have a set of commits that you feel are ready for pushing,
383 work through the following checklist to doublecheck everything is in
384 proper order. This list tries to be exhaustive. In case you are just
385 pushing a typo in a comment, some of the steps may be unnecessary.
386 Apply your common sense, but if in doubt, err on the side of caution.
387
388 First, make sure that the commits and branches you are going to push
389 match what you want pushed and that nothing is missing, extraneous or
390 wrong. You can see what will be pushed by running the git push command
391 with --dry-run first. And then inspecting the commits listed with
392 @command{git log -p 1234567..987654}. The @command{git status} command
393 may help in finding local changes that have been forgotten to be added.
394
395 Next let the code pass through a full run of our testsuite.
396
397 @itemize
398 @item @command{make distclean}
399 @item @command{/path/to/ffmpeg/configure}
400 @item @command{make check}
401 @item if fate fails due to missing samples run @command{make fate-rsync} and retry
402 @end itemize
403
404 Make sure all your changes have been checked before pushing them, the
405 testsuite only checks against regressions and that only to some extend. It does
406 obviously not check newly added features/code to be working unless you have
407 added a test for that (which is recommended).
408
409 Also note that every single commit should pass the test suite, not just
410 the result of a series of patches.
411
412 Once everything passed, push the changes to your public ffmpeg clone and post a
413 merge request to ffmpeg-devel. You can also push them directly but this is not
414 recommended.
415
416 @chapter Server Issues
417
418 Contact the project admins @email{root@@ffmpeg.org} if you have technical
419 problems with the GIT server.