You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

418 lines
11KB

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