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.

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