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