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