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