]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/contributor/source-code.itexi
Doc: CG: clarify lily-git.tcl and git-cl.
[lilypond.git] / Documentation / contributor / source-code.itexi
1 @c -*- coding: utf-8; mode: texinfo; -*-
2
3
4 @node Working with source code
5 @chapter Working with source code
6
7 New contributors should only read @ref{Using lily-git}.  Please
8 ignore the rest of this chapter.
9
10 Advanced contributors will find the rest of this material quite
11 useful, particularly if they are working on major new features.
12
13 @menu
14 * Using lily-git::
15 * Starting with Git::
16 * Basic Git procedures::
17 * Advanced Git procedures::
18 * Git on Windows::
19 * Repository directory structure::
20 * Other Git documentation::
21 @end menu
22
23
24 @c if you change this node name, you'll need to change the @ref in
25 @c web/ and/or included/, along with all the translations.
26 @node Using lily-git
27 @section Using lily-git
28
29 @command{lily-git.tcl} is a graphical tool to help you access and
30 share changes to the lilypond source code.
31
32 @menu
33 * Install and configuration of lily-git.tcl::
34 * Daily use of lily-git.tcl::
35 @end menu
36
37 @node Install and configuration of lily-git.tcl
38 @unnumberedsubsec Install and configuration of @command{lily-git.tcl}
39
40 @enumerate
41 @item
42 If you haven't already, download and install Git.
43
44 @itemize
45
46 @item
47 Lilybuntu users: git has already been installed for you.
48
49 @item Windows users: download the @code{.exe} file labeled
50 @qq{Full installer for official Git} from:
51
52 @example
53 @uref{http://code.google.com/p/msysgit/downloads/list}
54 @end example
55
56 @item Other operating systems: either install @command{git} with
57 your package manager, or download it from the @qq{Binaries}
58 section of:
59
60 @example
61 @uref{http://git-scm.com/download}
62 @end example
63
64 @end itemize
65
66
67 @item
68 Download the @command{lily-git.tcl} script from:
69
70 @c don't change the cgit link below to gitweb; gitweb uses
71 @c long filenames like "scripts_auxiliar_lily-git.tcl"
72
73 @example
74 @uref{http://git.sv.gnu.org/cgit/lilypond.git/plain/scripts/auxiliar/lily-git.tcl}
75 @end example
76
77 @item
78 To run the program from the command line, navigate to the
79 directory containing @command{lily-git.tcl} and enter:
80
81 @example
82 wish lily-git.tcl
83 @end example
84
85 @item
86 Click on the @qq{Get source} button.
87
88 This will create a directory called @file{lilypond-git/} within
89 your home directory, and will download the source code into that
90 directory (around 55Mb).  When the process is finished, the
91 @qq{Command output} window will display @qq{Done}, and the button
92 label will change to say @qq{Update source}.
93
94 @item
95 Navigate to the @file{lilypond-git/} directory to view the source
96 files.  You should now be able to modify the source files using
97 your normal text editor.
98
99 @end enumerate
100
101 @quotation
102 Advanced note: The @qq{Get source} button does not fetch the
103 entire history of the git repository, so utilities like
104 @command{gitk} will only be able to display the most recent
105 additions.  As you continue to work with @command{lily-git.tcl}, the
106 @qq{Update source} button will take any new additions and add it
107 to whatever is currently in your repository's history.
108 @end quotation
109
110
111 @node Daily use of lily-git.tcl
112 @unnumberedsubsec Daily use of @command{lily-git.tcl}
113
114 @warning{Only work on one set of changes at once.  Do not start
115 work on any new changes until your first set has been accepted.}
116
117 @subsubheading 1. Update source
118
119 At the beginning of each session of lilypond work, you should
120 click the @qq{Update source} button to get the latest changes to
121 the source code.
122
123 @warning{In some rare and unfortunate circumstances, this will
124 result in a @emph{merge conflict}.  If this occurs, follow the
125 instructions for @qq{Abort changes}, below.  Your work will not be
126 lost.}
127
128
129 @subsubheading 2a. New local commit
130
131 A single commit typically represents one logical set of related
132 changes (such as a bug-fix), and may incorporate changes to
133 multiple files at the same time.
134
135 When you're finished making the changes for a commit, click the
136 @qq{New local commit} button.  This will open the @qq{Git Commit
137 Message} window.  The message header is required, and the message
138 body is optional.
139
140 After entering a commit message, click @qq{OK} to finalize the
141 commit.
142
143 @quotation
144 Advanced note: For more information regarding commits and commit
145 messages, see @ref{Commits and patches}.
146 @end quotation
147
148
149 @subsubheading 2b. Amend previous commit
150
151 You can go back and make changes to the most recent commit with
152 the @qq{Amend previous commit} button.  This is useful if a
153 mistake is found after you have clicked the @qq{New local commit}
154 button.
155
156 To amend the most recent commit, re-edit the source files as
157 needed and then click the @qq{Amend previous commit} button.  The
158 earlier version of the commit is not saved, but is replaced by the
159 new one.
160
161 @warning{This does not update the patch @strong{files}; if you
162 have a patch file from an earlier version of the commit, you will
163 need to make another patch set when using this feature.  The old
164 patch file will not be saved, but will be replaced by the new one
165 after you click on @qq{Make patch set}.}
166
167
168 @subsubheading 3. Make patch set
169
170 Before making a patch set from any commits, you should click the
171 @qq{Update source} button to make sure the commits are based on
172 the most recent remote snapshot.
173
174 When you click the @qq{Make patch set} button,
175 @command{lily-git.tcl} will produce patch files for any new
176 commits, saving them to the current directory.  The command output
177 will display the name of the new patch files near the end of the
178 output:
179
180 @example
181 0001-CG-add-lily-git-instructions.patch
182 Done.
183 @end example
184
185 Send patch files to the appropriate place:
186
187 @itemize
188 @item
189 If you have a mentor, send it to them via email.
190
191 @item
192 New contributors should send the patch attached to an email (must
193 be less than 64KB) to @email{frogs@@lilynet.net}.
194
195 @item
196 Translators should send patches to
197 @email{translations@@lilynet.net}.
198
199 @item
200 More experienced contributors should upload the patch for
201 web-based review.  This requires additional software and use of
202 the command-line; see @ref{Uploading a patch for review}.
203
204 @end itemize
205
206
207 @subsubheading The @qq{Abort changes -- Reset to origin} button
208
209 @warning{Only use this if your local commit history gets
210 hopelessly confused!}
211
212 The button labeled @qq{Abort changes -- Reset to origin} will copy
213 all changed files to a subdirectory of @file{lilypond-git/} named
214 @file{aborted_edits/}, and will reset the repository to the
215 current state of the remote repository (at @code{git.sv.gnu.org}).
216
217
218 @node Starting with Git
219 @section Starting with Git
220
221
222 Using the Git program directly (as opposed to using the
223 @command{lily-git.tcl} GUI) allows you to have much greater control
224 over the contributing process.  You should consider using Git if
225 you want to work on complex projects, or if you want to work on
226 multiple projects concurrently.
227
228
229 @menu
230 * Setting up::
231 * Downloading remote branches::
232 @end menu
233
234
235 @node Setting up
236 @subsection Setting up
237
238
239 TODO: Remove this note if incorporating Windows instructions
240 throughout this section:
241
242 @warning{These instructions assume that you are using the
243 command-line version of Git 1.5 or higher.  Windows users should
244 skip to @ref{Git on Windows}.}
245
246 @menu
247 * Installing Git::
248 * Initializing a repository::
249 * Configuring Git::
250 @end menu
251
252
253 @node Installing Git
254 @unnumberedsubsubsec Installing Git
255
256
257 If you are using a Unix-based machine, the easiest way to download
258 and install Git is through a package manager such as @command{rpm}
259 or @command{apt-get}---the installation is generally automatic.
260 The only required package is (usually) called @command{git-core},
261 although some of the auxiliary @command{git@var{*}} packages are
262 also useful (such as @command{gitk}).
263
264 Alternatively, you can visit the Git website
265 (@uref{http://git-scm.com/}) for downloadable binaries and
266 tarballs.
267
268 TODO: add Windows installation instructions (or @@ref@{Git on
269 Windows@}).
270
271
272 @node Initializing a repository
273 @unnumberedsubsubsec Initializing a repository
274
275
276 Once Git is installed, you'll need to create a new directory where
277 your initial repository will be stored (the example below uses
278 @file{~/lilypond-git/}, where @code{~} represents your home
279 directory).  Run @command{git@tie{}init} from within the new
280 directory to initialize an empty repository:
281
282 @example
283 mkdir ~/lilypond-git/; cd ~/lilypond-git/
284 git init
285 @end example
286
287 @subsubheading Technical details
288
289 This creates (within the @file{~/lilypond-git/} directory) a
290 subdirectory called @file{.git/}, which Git uses to keep track of
291 changes to the repository, among other things.  Normally you don't
292 need to access it, but it's good to know it's there.
293
294
295 @node Configuring Git
296 @unnumberedsubsubsec Configuring Git
297
298 @warning{Throughout the rest of this manual, all command-line
299 input should be entered from the top directory of the Git
300 repository being discussed (eg. @file{~/lilypond-git/}).  This is
301 referred to as a @emph{top source directory}.}
302
303 Before downloading a copy of the main LilyPond repository, you
304 should configure some basic settings with the
305 @command{git@tie{}config} command.  Git allows you to set both
306 global and repository-specific options.
307
308 To configure settings that affect all repositories, use the
309 @command{--global} command line option.  For example, the first
310 two options that you should always set are your @var{name} and
311 @var{email}, since Git needs these to keep track of commit
312 authors:
313
314 @example
315 git config --global user.name "@var{John Smith}"
316 git config --global user.email @var{john@@example.com}
317 @end example
318
319 To configure Git to use colored output where possible, use:
320
321 @example
322 git config --global color.ui auto
323 @end example
324
325 The text editor that opens when using @command{git@tie{}commit}
326 can also be changed.  If none of your editor-related environment
327 variables are set ($GIT_EDITOR, $VISUAL, or $EDITOR), the default
328 editor is usually @command{vi} or @command{vim}.  If you're not
329 familiar with either of these, you should probably change the
330 default to an editor that you know how to use.  For example, to
331 change the default editor to @command{nano}, enter:
332
333 @example
334 git config --global core.editor @var{nano}
335 @end example
336
337 TODO: Add instructions for changing the editor on Windows, which
338 is a little different, I think. -mp
339
340 @subsubheading Technical details
341
342 Git stores the information entered with
343 @command{git@tie{}config@tie{}--global} in the file
344 @file{.gitconfig}, located in your home directory.  This file can
345 also be modified directly, without using
346 @command{git@tie{}config}.  The @file{.gitconfig} file generated
347 by the above commands would look like this:
348
349 @example
350 [user]
351         name = John Smith
352         email = john@@example.com
353 [color]
354         ui = auto
355 [core]
356         editor = nano
357 @end example
358
359 Using the @command{git@tie{}config} command @emph{without} the
360 @command{--global} option configures repository-specific settings,
361 which are stored in the file @file{.git/config}.  This file is
362 created when a repository is initialized (using
363 @command{git@tie{}init}), and by default contains these lines:
364
365 @example
366 [core]
367         repositoryformatversion = 0
368         filemode = true
369         bare = false
370         logallrefupdates = true
371 @end example
372
373 However, since different repository-specific options are
374 recommended for different development tasks, it is best to avoid
375 setting any now.  Specific recommendations will be mentioned later
376 in this manual.
377
378
379 @node Downloading remote branches
380 @subsection Downloading remote branches
381
382
383 @menu
384 * Organization of remote branches::
385 * LilyPond repository sources::
386 * Downloading individual branches::
387 * Downloading all remote branches::
388 * Other branches::
389 @end menu
390
391
392 @node Organization of remote branches
393 @unnumberedsubsubsec Organization of remote branches
394
395
396 The main LilyPond repository is organized into @emph{branches} to
397 facilitate development.  These are often called @emph{remote}
398 branches to distinguish them from @emph{local} branches you might
399 create yourself (see @ref{Using local branches}).
400
401 The @code{master} branch contains all the source files used to
402 build LilyPond, which includes the program itself (both stable and
403 development releases), the documentation (and its translations),
404 and the website.  Generally, the @code{master} branch is expected
405 to compile successfully.
406
407 The @code{lilypond/translation} branch is a side branch that
408 allows translators to work without needing to worry about
409 compilation problems.  Periodically, the Translation Meister
410 (after verifying that it doesn't break compilation), will
411 @emph{merge} this branch back into @code{master} to incorporate
412 recent translations.  Similarly, the @code{master} branch is
413 usually merged into the @code{lilypond/translation} branch after
414 significant changes to the English documentation.  See
415 @ref{Translating the documentation} for details.
416
417
418 @node LilyPond repository sources
419 @unnumberedsubsubsec LilyPond repository sources
420
421
422 The recommended source for downloading a copy of the main
423 repository is:
424
425 @example
426 git://git.sv.gnu.org/lilypond.git
427 @end example
428
429 However, if your internet router filters out connections using the
430 GIT protocol, or if you experience difficulty connecting via GIT,
431 you can try these other sources:
432
433 @example
434 ssh://git.sv.gnu.org/srv/git/lilypond.git
435 http://git.sv.gnu.org/r/lilypond.git
436 @end example
437
438 The SSH protocol can only be used if your system is properly set
439 up to use it.  Also, the HTTP protocol is slowest, so it should
440 only be used as a last resort.
441
442
443 @node Downloading individual branches
444 @unnumberedsubsubsec Downloading individual branches
445
446
447 Once you have initialized an empty Git repository on your system
448 (see @ref{Initializing a repository}), you can download a remote
449 branch into it.  Make sure you know which branch you want to start
450 with.
451
452 To download the @code{master} branch, enter the following:
453
454 @example
455 git remote add -ft master -m master \
456   origin git://git.sv.gnu.org/lilypond.git/
457 @end example
458
459 To download the @code{lilypond/translation} branch, enter:
460
461 @example
462 git remote add -ft lilypond/translation -m \
463   lilypond/translation origin git://git.sv.gnu.org/lilypond.git/
464 @end example
465
466 The @command{git@tie{}remote@tie{}add} process could take up to
467 ten minutes, depending on the speed of your connection.  The
468 output will be something like this:
469
470 @example
471 Updating origin
472 remote: Counting objects: 235967, done.
473 remote: Compressing objects: 100% (42721/42721), done.
474 remote: Total 235967 (delta 195098), reused 233311 (delta 192772)
475 Receiving objects: 100% (235967/235967), 68.37 MiB | 479 KiB/s, done.
476 Resolving deltas: 100% (195098/195098), done.
477 From git://git.sv.gnu.org/lilypond
478  * [new branch]      master     -> origin/master
479 From git://git.sv.gnu.org/lilypond
480  * [new tag]         flower/1.0.1 -> flower/1.0.1
481  * [new tag]         flower/1.0.10 -> flower/1.0.10
482 â‹®
483  * [new tag]         release/2.9.6 -> release/2.9.6
484  * [new tag]         release/2.9.7 -> release/2.9.7
485 @end example
486
487 When @command{git@tie{}remote@tie{}add} is finished, the remote
488 branch should be downloaded into your repository---though not yet
489 in a form that you can use.  In order to browse the source code
490 files, you need to @emph{create} and @emph{checkout} your own
491 local branch.  In this case, however, it is easier to have Git
492 create the branch automatically by using the @command{checkout}
493 command on a non-existent branch.  Enter the following:
494
495 @example
496 git checkout -b @var{branch} origin/@var{branch}
497 @end example
498
499 @noindent
500 where @code{@var{branch}} is the name of your tracking branch,
501 either @code{master} or @code{lilypond/translation}.
502
503 Git will issue some warnings; this is normal:
504
505 @example
506 warning: You appear to be on a branch yet to be born.
507 warning: Forcing checkout of origin/master.
508 Branch master set up to track remote branch master from origin.
509 Already on 'master'
510 @end example
511
512 By now the source files should be accessible---you should be able
513 to edit any files in the @file{lilypond-git/} directory using a
514 text editor of your choice.  But don't start just yet!  Before
515 editing any source files, learn how to keep your changes organized
516 and prevent problems later---read @ref{Basic Git procedures}.
517
518 @subsubheading Technical Details
519
520 The @command{git@tie{}remote@tie{}add} command should add some
521 lines to your local repository's @file{.git/config} file:
522
523 @example
524 [remote "origin"]
525         url = git://git.sv.gnu.org/lilypond.git/
526         fetch = +refs/heads/master:refs/remotes/origin/master
527 @end example
528
529
530 @node Downloading all remote branches
531 @unnumberedsubsubsec Downloading all remote branches
532
533
534 To download all remote branches at once, you can @command{clone}
535 the entire repository:
536
537 @example
538 git clone git://git.sv.gnu.org/lilypond.git
539 @end example
540
541
542 @node Other branches
543 @unnumberedsubsubsec Other branches
544
545 Most contributors will never need to touch the other branches.  If
546 you wish to do so, you will need more familiarity with Git; please
547 see @ref{Other Git documentation}.
548
549 @itemize
550 @item @code{dev/XYZ}:
551 These branches are for individual developers.  They store code
552 which is not yet stable enough to be added to the @code{master}
553 branch.
554
555 @item @code{stable/XYZ}:
556 The branches are kept for archival reasons.
557
558 @end itemize
559
560 Another item of interest might be the Grand Unified Builder, our
561 cross-platform building tool.  Since it is used by projects as
562 well, it is not stored in our gub repository.  For more info, see
563 @uref{http://lilypond.org/gub}.  The git location is
564 @uref{http://github.com/janneke/gub}.
565
566
567 @node Basic Git procedures
568 @section Basic Git procedures
569
570
571 @menu
572 * The Git contributor's cycle::
573 * Pulling and rebasing::
574 * Using local branches::
575 * Commits and patches::
576 @end menu
577
578
579 @node The Git contributor's cycle
580 @subsection The Git contributor's cycle
581
582
583 Here is a simplified view of the contribution process on Git:
584
585 @enumerate
586 @item
587 Update your local repository by @emph{pulling} the most recent
588 updates from the remote repository.
589
590 @item
591 Edit source files within your local repository's @emph{working
592 directory}.
593
594 @item
595 @emph{Commit} the changes you've made to a local @emph{branch}.
596
597 @item
598 Generate a @emph{patch} to share your changes with the developers.
599 @end enumerate
600
601
602 @node Pulling and rebasing
603 @subsection Pulling and rebasing
604
605
606 When developers push new patches to the @code{git.sv.gnu.org}
607 repository, your local repository is @strong{not} automatically
608 updated.  It is important to keep your repository up-to-date by
609 periodically @emph{pulling} the most recent @emph{commits} from
610 the remote branch.  Developers expect patches to be as current as
611 possible, since outdated patches require extra work before they
612 can be used.
613
614 Occasionally you may need to rework some of your own modifications
615 to match changes made to the remote branch (see @ref{Resolving
616 conflicts}), and it's considerably easier to rework things
617 incrementally.  If you don't update your repository along the way,
618 you may have to spend a lot of time resolving branch conflicts and
619 reconfiguring much of the work you've already done.
620
621 Fortunately, Git is able to resolve certain types of branch
622 conflicts automatically with a process called @emph{rebasing}.
623 When rebasing, Git tries to modify your old commits so they appear
624 as new commits (based on the latest updates).  For a more involved
625 explanation, see the @command{git-rebase} man page.
626
627 To pull without rebasing (recommended for translators), use the
628 following command:
629
630 @example
631 git pull    # recommended for translators
632 @end example
633
634 If you're tracking the remote @code{master} branch, you should add
635 the @code{-r} option (short for @code{--rebase}) to keep commits
636 on your local branch current:
637
638 @example
639 git pull -r # use with caution when translating
640 @end example
641
642 If you don't edit translated documentation and don't want to type
643 @code{-r} every time, configure the master branch to rebase by
644 default with this command:
645
646 @example
647 git config branch.master.rebase true
648 @end example
649
650 If pull fails because of a message like
651
652 @example
653 error: Your local changes to 'Documentation/learning/tutorial.itely'
654 would be overwritten by merge.  Aborting.
655 @end example
656
657 @noindent
658 or
659
660 @example
661 Documentation/learning/tutorial.itely: needs update
662 refusing to pull with rebase: your working tree is not up-to-date
663 @end example
664
665 @noindent
666 it means that you have modified some files in you working tree
667 without committing changes (see @ref{Commits and patches}); you
668 can use the @command{git@tie{}stash} command to work around this:
669
670 @example
671 git stash      # save uncommitted changes
672 git pull -r    # pull using rebase (translators omit "-r")
673 git stash pop  # reapply previously saved changes
674 @end example
675
676 Note that @command{git@tie{}stash@tie{}pop} will try to apply a
677 patch, and this may create a conflict.  If this happens, see
678 @ref{Resolving conflicts}.
679
680 TODO: I think the next paragraph is confusing.  Perhaps prepare
681 the reader for new terms `committish' and `head'?  -mp
682
683 @warning{translators and documentation editors, if you have
684 changed committishes in the head of translated files using commits
685 you have not yet pushed to @code{git.sv.gnu.org}, please do not
686 rebase.  If you want to avoid wondering whether you should rebase
687 each time you pull, please always use committishes from master
688 and/or lilypond/translation branch on @code{git.sv.gnu.org}, which
689 in particular implies that you must push your changes to
690 documentation except committishes updates (possibly after having
691 rebased), then update the committishes and push them.}
692
693 TODO: when committishes automatic conditional update have been
694 tested and documented, append the following to the warning above:
695 Note that using update-committishes make target generally touches
696 committishes.
697
698 @subsubheading Technical details
699
700 The @command{git@tie{}config} command mentioned above adds the
701 line @code{rebase = true} to the master branch in your local
702 repository's @file{.git/config} file:
703
704 @example
705 [branch "master"]
706         remote = origin
707         merge = refs/heads/master
708         rebase = true
709 @end example
710
711
712 @node Using local branches
713 @subsection Using local branches
714
715
716 @menu
717 * Creating and removing branches::
718 * Listing branches and remotes::
719 * Checking out branches::
720 * Merging branches::
721 @end menu
722
723
724 @node Creating and removing branches
725 @unnumberedsubsubsec Creating and removing branches
726
727
728 Local branches are useful when you're working on several different
729 projects concurrently.  To create a new branch, enter:
730
731 @example
732 git branch @var{name}
733 @end example
734
735 To delete a branch, enter:
736
737 @example
738 git branch -d @var{name}
739 @end example
740
741 Git will ask you for confirmation if it sees that data would be
742 lost by deleting the branch.  Use @code{-D} instead of @code{-d}
743 to bypass this.  Note that you cannot delete a branch if it is
744 currently checked out.
745
746
747 @node Listing branches and remotes
748 @unnumberedsubsubsec Listing branches and remotes
749
750 You can get the exact path or URL of all remote branches by
751 running:
752
753 @example
754 git remote -v
755 @end example
756
757 To list Git branches on your local repositories, run
758
759 @example
760 git branch     # list local branches only
761 git branch -r  # list remote branches
762 git branch -a  # list all branches
763 @end example
764
765
766 @node Checking out branches
767 @unnumberedsubsubsec Checking out branches
768
769 To know the currently checked out branch, i.e. the branch whose
770 source files are present in your working tree, read the first line
771 of the output of
772
773 @example
774 git status
775 @end example
776
777 @noindent
778 The currently checked out branch is also marked with an asterisk
779 in the output of @command{git branch}.
780
781 You can check out another branch @code{@var{other_branch}}, i.e.
782 check out @code{@var{other_branch}} to the working tree, by
783 running
784
785 @example
786 git checkout @var{other_branch}
787 @end example
788
789 Note that it is possible to check out another branch while having
790 uncommitted changes, but it is not recommended unless you know
791 what you are doing; it is recommended to run @command{git status}
792 to check this kind of issue before checking out another branch.
793
794 @node Merging branches
795 @unnumberedsubsubsec Merging branches
796
797 To merge branch @code{@var{foo}} into branch @code{@var{bar}},
798 i.e. to @qq{add} all changes made in branch @code{@var{foo}} to
799 branch @code{@var{bar}}, run
800
801 @example
802 git checkout @var{bar}
803 git merge @var{foo}
804 @end example
805
806 If any conflict happens, see @ref{Resolving conflicts}.
807
808 There are common usage cases for merging: as a translator, you
809 will often want to merge @code{master} into
810 @code{lilypond/translation}; on the other hand, the Translations
811 meister wants to merge @code{lilypond/translation} into
812 @code{master} whenever he has checked that
813 @code{lilypond/translation} builds successfully.
814
815
816 @node Commits and patches
817 @subsection Commits and patches
818
819
820 @menu
821 * Understanding commits::
822 * Making commits::
823 * Commit messages::
824 * Making patches::
825 * Uploading a patch for review::
826 @end menu
827
828
829 @node Understanding commits
830 @unnumberedsubsubsec Understanding commits
831
832 Technically, a @emph{commit} is a single point in the history of a
833 branch, but most developers use the term to mean a @emph{commit
834 object}, which stores information about a particular revision.  A
835 single commit can record changes to multiple source files, and
836 typically represents one logical set of related changes (such as a
837 bug-fix).  You can list the ten most recent commits in your
838 current branch with this command:
839
840 @example
841 git log -10 --oneline
842 @end example
843
844 If you're using an older version of Git and get an @q{unrecognized
845 argument} error, use this instead:
846
847 @example
848 git log -10 --pretty=oneline --abbrev-commit
849 @end example
850
851 More interactive lists of the commits on the remote @code{master}
852 branch are available at
853 @uref{http://git.sv.gnu.org/gitweb/?p=lilypond.git;a=shortlog} and
854 @uref{http://git.sv.gnu.org/cgit/lilypond.git/log/}.
855
856
857 @node Making commits
858 @unnumberedsubsubsec Making commits
859
860
861 Once you have modified some source files in your working
862 directory, you can make a commit with the following procedure:
863
864 @enumerate
865 @item
866 Make sure you've configured Git properly (see @ref{Configuring
867 Git}).  Check that your changes meet the requirements described in
868 @ref{Code style} and/or @ref{Documentation policy}.  For advanced
869 edits, you may also want to verify that the changes don't break
870 the compilation process.
871
872 @item
873 Run the following command:
874
875 @example
876 git status
877 @end example
878
879 @noindent
880 to make sure you're on the right branch, and to see which files
881 have been modified, added or removed, etc.  You may need to tell
882 Git about any files you've added by running one of these:
883
884 @example
885 git add @var{file}  # add untracked @var{file} individually
886 git add .     # add all untracked files in current directory
887 @end example
888
889 @noindent
890 After @command{git@tie{}add}, run @command{git@tie{}status} again
891 to make sure you got everything.  You may also need to modify
892 @file{GNUmakefile}.
893
894 @item
895 Preview the changes about to be committed (to make sure everything
896 looks right) with:
897
898 @example
899 git diff HEAD
900 @end example
901
902 @noindent
903 The @code{HEAD} argument refers to the most recent commit on the
904 currently checked-out branch.
905
906 @item
907 Generate the commit with:
908
909 @example
910 git commit -a
911 @end example
912
913 @noindent
914 The @code{-a} is short for @code{--all} which includes modified
915 and deleted files, but only those newly created files that have
916 previously been added.
917
918 @end enumerate
919
920
921 @node Commit messages
922 @unnumberedsubsubsec Commit messages
923
924
925 When you run the @command{git@tie{}commit@tie{}-a} command, Git
926 automatically opens the default text editor so you can enter a
927 @emph{commit message}.  If you find yourself in a foreign editing
928 environment, you're probably in @command{vi} or @command{vim}.  If
929 you want to switch to an editor you're more familiar with, quit by
930 typing @code{:q!} and pressing @code{<Enter>}.  See
931 @ref{Configuring Git} for instructions on changing the default
932 editor.
933
934 In any case, Git will open a text file for your commit message
935 that looks like this:
936
937 @example
938
939 # Please enter the commit message for your changes.  Lines starting
940 # with '#' will be ignored, and an empty message aborts the commit.
941 # On branch master
942 # Changes to be committed:
943 #   (use "git reset HEAD <file>..." to unstage)
944 #
945 #       modified:   working.itexi
946 #
947 @end example
948
949 Your commit message should begin with a one-line summary
950 describing the change (no more than 50 characters long), and if
951 necessary a blank line followed by several lines giving the
952 details:
953
954 @c $ git log -1 --pretty=medium 4d6f1e5
955 @example
956 Doc: add Baerenreiter and Henle solo cello suites
957
958 Added comparison of solo cello suite engravings to new essay with
959 high-res images, fixed cropping on Finale example.
960 @end example
961
962 Commit messages often start with a short prefix describing the
963 general location of the changes.  If a commit affects the
964 documentation in English (or in several languages simultaneously)
965 the commit message should be prefixed with @qq{Doc:@tie{}}.  If
966 the commit affects only one of the translations, the commit
967 message should be prefixed with @qq{Doc-@var{**}:@tie{}}, where
968 @var{**} is the two-letter language code.  Commits that affect the
969 website should use @qq{Web:@tie{}} for English, and
970 @qq{Web-@var{**}:@tie{}} for the other languages.  Also, changes
971 to a single file are often prefixed with the name of the file
972 involved.  Visit the links listed in @ref{Understanding commits}
973 for examples.
974
975
976 @node Making patches
977 @unnumberedsubsubsec Making patches
978
979 If you want to share your changes with other contributors and
980 developers, you need to generate @emph{patches} from your commits.
981 We prefer it if you follow the instructions in
982 @ref{Uploading a patch for review}.  However, we present an
983 alternate method here.
984
985 You should always run @command{git@tie{}pull@tie{}-r} (translators
986 should leave off the @code{-r}) before doing this to ensure that
987 your patches are as current as possible.
988
989 Once you have made one or more commits in your local repository,
990 and pulled the most recent commits from the remote branch, you can
991 generate patches from your local commits with the command:
992
993 @example
994 git format-patch origin
995 @end example
996
997 The @code{origin} argument refers to the remote tracking branch at
998 @code{git.sv.gnu.org}.  This command generates a separate patch
999 for each commit that's in the current branch but not in the remote
1000 branch.  Patches are placed in the current working directory and
1001 will have names that look something like this:
1002
1003 @example
1004 0001-Doc-Fix-typos.patch
1005 0002-Web-Remove-dead-links.patch
1006 â‹®
1007 @end example
1008
1009 Send an email (must be less than 64 KB) to
1010 @email{lilypond-devel@@gnu.org} briefly explaining your work, with
1011 the patch files attached.  Translators should send patches to
1012 @email{translations@@lilynet.net}.  After your patches are
1013 reviewed, the developers may push one or more of them to the main
1014 repository or discuss them with you.
1015
1016
1017 @node Uploading a patch for review
1018 @unnumberedsubsubsec Uploading a patch for review
1019
1020 Any non-trivial change should be uploaded to our @qq{Rietveld}
1021 code review website:
1022
1023 @example
1024 @uref{http://codereview.appspot.com/}
1025 @end example
1026
1027 @subsubheading Initial setup
1028
1029 @enumerate
1030
1031 @item
1032 You must have a gmail account.
1033
1034 @item
1035 Install @command{git-cl} by entering:
1036
1037 @example
1038 git clone git://neugierig.org/git-cl.git
1039 @end example
1040
1041 @item
1042 Add the @file{git-cl/} directory to your PATH, or create a
1043 symbolic link to the @command{git-cl} and @command{upload.py}
1044 scripts in one of your PATH directories (such as
1045 @file{$HOME/bin}).
1046
1047
1048 @item
1049 Move into the top source directory and then configure
1050 @command{git cl}.  If you do not understand any question, just
1051 answer with a newline (CR).
1052
1053 @example
1054 cd $HOME/lilypond-git/
1055 git cl config
1056 @end example
1057
1058 @end enumerate
1059
1060 @subsubheading Uploading patch set
1061
1062 @warning{Unless you are familiar with branches, only work on one
1063 set of changes at once.}
1064
1065 There are two methods, depending on your git setup.
1066
1067 @itemize
1068 @item
1069 @strong{Master branch}: (easy option, and used in @command{lily-git.tcl})
1070
1071 If you added your patch to @code{master}, then:
1072
1073 @example
1074 git pull -r
1075 git cl upload origin/master
1076 @end example
1077
1078 If you have git push ability, make sure that you @emph{remove}
1079 your patch (with @command{git rebase} or @command{git reset})
1080 before pushing other stuff.
1081
1082 @item
1083 @strong{Separate branch}: (complicated option)
1084
1085 Ensure your changes are committed in a separate branch, which
1086 should differ from the reference branch to be used by just the
1087 changes to be uploaded.  If the reference branch is to be
1088 origin/master, ensure this is up-to-date.  If necessary, use git
1089 rebase to rebase the branch containing the changes to the head of
1090 origin/master.  Finally, check out branch with the changes and
1091 enter the command:
1092
1093 @example
1094 git cl upload <reference SHA1 ID>
1095 @end example
1096
1097 @noindent
1098 where <reference SHA1 ID> is the SHA1 ID of the commit to be used
1099 as a reference source for the patch.  Generally, this will be the
1100 SHA1 ID of origin/master, and in that case the command:
1101
1102 @example
1103 git cl upload origin/master
1104 @end example
1105
1106 @noindent
1107 can be used.
1108
1109 @end itemize
1110
1111 After prompting for your Google email address and password, the
1112 patch set will be posted to Rietveld.
1113
1114 @subsubheading Announcing your patch set
1115
1116 You should then announce the patch by sending an email to
1117 @code{lilypond-devel}, with a subject line starting with PATCH:,
1118 asking for comments on the patch.  Alternately, you may Publish +
1119 Mail a (bogus) comment, in order to send an email to
1120 lilypond-devel.
1121
1122 @subsubheading Revisions
1123
1124 As revisions are made in response to comments, successive patch sets
1125 for the same issue can be uploaded by reissuing the git-cl command
1126 with the modified branch checked out.
1127
1128 Sometimes in response to comments on revisions, the best way to
1129 work may require creation of a new branch in git.  In order to
1130 associate the new branch with an existing Rietveld issue,
1131 the following command can be used:
1132
1133 @example
1134 git cl issue issue-number
1135 @end example
1136
1137 @noindent
1138 where @code{issue-number} is the number of the existing Rietveld
1139 issue.
1140
1141 @subsubheading Resetting git cl
1142
1143 If @command{git cl} becomes confused, you can @qq{reset} it by
1144 running:
1145
1146 @example
1147 git cl issue 0
1148 @end example
1149
1150
1151 @node Advanced Git procedures
1152 @section Advanced Git procedures
1153
1154
1155 @warning{This section is not necessary for normal contributors;
1156 these commands are presented for information for people interested
1157 in learning more about git.}
1158
1159 It is possible to work with several branches on the same local Git
1160 repository; this is especially useful for translators who may have
1161 to deal with both @code{lilypond/translation} and a stable branch,
1162 e.g. @code{stable/2.12}.
1163
1164 Some Git commands are introduced first, then a workflow with
1165 several Git branches of LilyPond source code is presented.
1166
1167
1168 @menu
1169 * Advanced Git concepts::
1170 * Resolving conflicts::
1171 * Reverting all local changes::
1172 * Working with remote branches::
1173 * Git log::
1174 * Applying remote patches::
1175 * Sending and receiving patches via email::
1176 * Commit access::
1177 @end menu
1178
1179
1180 @node Advanced Git concepts
1181 @subsection Advanced Git concepts
1182
1183
1184 A bit of Git vocabulary will be explained below.  The following is
1185 only introductory; for a better understanding of Git concepts, you
1186 may wish to read @ref{Other Git documentation}.
1187
1188 The @code{git@tie{}pull@tie{}origin} command above is just a
1189 shortcut for this command:
1190
1191 @example
1192 git pull git://git.sv.gnu.org/lilypond.git/ @var{branch}:origin/@var{branch}
1193 @end example
1194
1195 @noindent
1196 where @code{@var{branch}} is typically @code{master} or
1197 @code{lilypond/translation}; if you do not know or remember, see
1198 @ref{Downloading remote branches} to remember which commands you
1199 issued or which source code you wanted to get.
1200
1201 A @emph{commit} is a set of changes made to the sources; it also
1202 includes the committish of the parent commit, the name and e-mail
1203 of the @emph{author} (the person who wrote the changes), the name
1204 and e-mail of the @emph{committer} (the person who brings these
1205 changes into the Git repository), and a commit message.
1206
1207 A @emph{committish} is the SHA1 checksum of a commit, a number
1208 made of 40 hexadecimal digits, which acts as the internal unique
1209 identifier for this commit.  To refer to a particular revision,
1210 don't use vague references like the (approximative) date, simply
1211 copy and paste the committish.
1212
1213 A @emph{branch} is nothing more than a pointer to a particular
1214 commit, which is called the @emph{head} of the branch; when
1215 referring to a branch, one often actually thinks about its head
1216 and the ancestor commits of the head.
1217
1218 Now we will explain the two last commands you used to get the
1219 source code from Git---see @ref{Downloading individual branches}.
1220
1221 @example
1222 git remote add -ft @var{branch} -m @var{branch} \
1223   origin git://git.sv.gnu.org/lilypond.git/
1224
1225 git checkout -b @var{branch} origin/@var{branch}
1226 @end example
1227
1228 The @command{git@tie{}remote} has created a branch called
1229 @code{origin/@var{branch}} in your local Git repository.  As this
1230 branch is a copy of the remote branch web from git.sv.gnu.org
1231 LilyPond repository, it is called a @emph{remote branch}, and is
1232 meant to track the changes on the branch from git.sv.gnu.org: it
1233 will be updated every time you run
1234 @command{git@tie{}pull@tie{}origin} or
1235 @command{git@tie{}fetch@tie{}origin}.
1236
1237 The @command{git@tie{}checkout} command has created a branch named
1238 @code{@var{branch}}.  At the beginning, this branch is identical
1239 to @code{origin/@var{branch}}, but it will differ as soon as you
1240 make changes, e.g. adding newly translated pages or editing some
1241 documentation or code source file.  Whenever you pull, you merge
1242 the changes from @code{origin/@var{branch}} and
1243 @code{@var{branch}} since the last pulling.  If you do not have
1244 push (i.e. @qq{write}) access on git.sv.gnu.org, your
1245 @code{@var{branch}} will always differ from
1246 @code{origin/@var{branch}}.  In this case, remember that other
1247 people working like you with the remote branch @code{@var{branch}}
1248 of git://git.sv.gnu.org/lilypond.git/ (called
1249 @code{origin/@var{branch}} on your local repository) know nothing
1250 about your own @code{@var{branch}}: this means that whenever you
1251 use a committish or make a patch, others expect you to take the
1252 latest commit of @code{origin/@var{branch}} as a reference.
1253
1254 Finally, please remember to read the man page of every Git command
1255 you will find in this manual in case you want to discover
1256 alternate methods or just understand how it works.
1257
1258
1259 @node Resolving conflicts
1260 @subsection Resolving conflicts
1261
1262
1263 Occasionally an update may result in conflicts -- this happens
1264 when you and somebody else have modified the same part of the same
1265 file and git cannot figure out how to merge the two versions
1266 together.  When this happens, you must manually merge the two
1267 versions.
1268
1269 If you need some documentation to understand and resolve
1270 conflicts, see paragraphs @emph{How conflicts are presented} and
1271 @emph{How to resolve conflicts} in @command{git merge} man page.
1272
1273 If all else fails, you can follow the instructions in
1274 @ref{Reverting all local changes}.  Be aware that this eliminates
1275 any changes you have made!
1276
1277
1278 @node Reverting all local changes
1279 @subsection Reverting all local changes
1280
1281 Sometimes git will become hopelessly confused, and you just want
1282 to get back to a known, stable state.  This command destroys any
1283 local changes you have made, but at least you get back to the
1284 current online version:
1285
1286 @example
1287 git reset --hard origin/master
1288 @end example
1289
1290
1291 @node Working with remote branches
1292 @subsection Working with remote branches
1293
1294
1295 @subsubheading Fetching new branches from git.sv.gnu.org
1296
1297 To fetch and check out a new branch named @code{@var{branch}} on
1298 git.sv.gnu.org, run from top of the Git repository
1299
1300 @example
1301 git config --add remote.origin.fetch \
1302   +refs/heads/@var{branch}:refs/remotes/origin/@var{branch}
1303
1304 git checkout --track -b @var{branch} origin/@var{branch}
1305 @end example
1306
1307 After this, you can pull @code{@var{branch}} from git.sv.gnu.org
1308 with:
1309
1310 @example
1311 git pull
1312 @end example
1313
1314 Note that this command generally fetches all branches you added
1315 with @command{git@tie{}remote@tie{}add} (when you initialized the
1316 repository) or @command{git@tie{}config@tie{}--add}, i.e. it
1317 updates all remote branches from remote @code{origin}, then it
1318 merges the remote branch tracked by the current branch into the
1319 current branch.  For example, if your current branch is
1320 @code{master}, @code{origin/master} will be merged into
1321 @code{master}.
1322
1323
1324 @subsubheading Local clones, or having several working trees
1325
1326 If you play with several Git branches, e.g. @code{master},
1327 @code{lilypond/translation}, @code{stable/2.12}), you may want to
1328 have one source and build tree for each branch; this is possible
1329 with subdirectories of your local Git repository, used as local
1330 cloned subrepositories.  To create a local clone for the branch
1331 named @code{@var{branch}}, run
1332
1333 @example
1334 git checkout @var{branch}
1335 git clone -lsn . @var{subdir}
1336 cd @var{subdir}
1337 git reset --hard
1338 @end example
1339
1340 Note that @code{@var{subdir}} must be a directory name which does
1341 not already exist.  In @code{@var{subdir}}, you can use all Git
1342 commands to browse revisions history, commit and uncommit changes;
1343 to update the cloned subrepository with changes made on the main
1344 repository, cd into @code{@var{subdir}} and run
1345 @command{git@tie{}pull}; to send changes made on the subrepository
1346 back to the main repository, run @command{git@tie{}push} from
1347 @code{@var{subdir}}.  Note that only one branch (the currently
1348 checked out branch) is created in the subrepository by default; it
1349 is possible to have several branches in a subrepository and do
1350 usual operations (checkout, merge, create, delete...) on these
1351 branches, but this possibility is not detailed here.
1352
1353 When you push @code{@var{branch}} from @code{@var{subdir}} to the
1354 main repository, and @code{@var{branch}} is checked out in the
1355 main repository, you must save uncommitted changes (see
1356 @command{git@tie{}stash}) and do
1357 @command{git@tie{}reset@tie{}--hard} in the main repository in
1358 order to apply pushed changes in the working tree of the main
1359 repository.
1360
1361
1362 @node Git log
1363 @subsection Git log
1364
1365
1366 The commands above don't only bring you the latest version of the
1367 sources, but also the full history of revisions (revisions, also
1368 called commits, are changes made to the sources), stored in the
1369 @file{.git} directory.  You can browse this history with
1370
1371 @example
1372 git log     # only shows the logs (author, committish and commit message)
1373 git log -p  # also shows diffs
1374 gitk        # shows history graphically
1375 @end example
1376
1377 @warning{The @code{gitk} command may require a separate
1378 @code{gitk} package, available in the appropriate distribution's
1379 repositories.}
1380
1381
1382 @node Applying remote patches
1383 @subsection Applying remote patches
1384
1385
1386 TODO: Explain how to determine if a patch was created with
1387 @code{git@tie{}format-patch}.
1388
1389 Well-formed git patches created with @code{git@tie{}format-patch}
1390 should be committed with the following command:
1391
1392 @example
1393 git am @var{patch}
1394 @end example
1395
1396 Patches created without @code{git@tie{}format-patch} can be
1397 applied in two steps.  The first step is to apply the patch to the
1398 working tree:
1399
1400 @example
1401 git apply @var{patch}
1402 @end example
1403
1404 @noindent
1405 The second step is to commit the changes and give credit to the
1406 author of the patch.  This can be done with the following command:
1407
1408 @example
1409 git commit -a --author="@var{John Smith} <@var{john@@example.com}>"
1410 @end example
1411
1412
1413 @node Sending and receiving patches via email
1414 @subsection Sending and receiving patches via email
1415
1416
1417 The default @code{x-diff} MIME type associated with patch files
1418 (i.e., files whose name ends in @code{.patch}) means that the
1419 encoding of line endings may be changed from UNIX to DOS format
1420 when they are sent as attachments.  Attempting to apply such an
1421 inadvertently altered patch will cause git to fail with a message
1422 about @q{whitespace errors}.
1423
1424 The solution to such problems is surprisingly simple---just change
1425 the default file extension of patches generated by git to end in
1426 @code{.txt}, for example:
1427
1428 @example
1429 git config format.suffix '.patch.txt'
1430 @end example
1431
1432 This should cause email programs to apply the correct base64
1433 encoding to attached patches.
1434
1435 If you receive a patch with DOS instead of UNIX line-endings, it
1436 can be converted back using the @code{dos2unix} utility.
1437
1438 Lots of useful information on email complications with patches is
1439 provided on the Wine wiki at
1440 @uref{http://wiki.winehq.org/GitWine}.
1441
1442
1443 @node Commit access
1444 @subsection Commit access
1445
1446
1447 Most contributors are not able to commit patches directly to the
1448 main repository---only members of the LilyPond development team
1449 have @emph{commit access}.  If you are a contributor and are
1450 interested in joining the development team, contact the Project
1451 Manager through the mailing list
1452 (@email{lilypond-devel@@gnu.org}).  Generally, only contributors
1453 who have already provided a number of patches which have been
1454 pushed to the main repository will be considered for membership.
1455
1456 If you have been approved by the Project Manager, use the
1457 following procedure to obtain commit access:
1458
1459 @enumerate
1460 @item
1461 If you don't already have one, set up a Savannah user account at
1462 @uref{https://savannah.gnu.org/account/register.php}.  If your web
1463 browser responds with an @qq{untrusted connection} message when
1464 you visit the link, follow the steps for including the CAcert root
1465 certificate in your browser, given at
1466 @uref{http://savannah.gnu.org/tls/tutorial/}.
1467
1468
1469 @item
1470 After registering, if you are not logged in automatically, login
1471 at @uref{https://savannah.gnu.org/account/login.php}---this should
1472 take you to your @qq{my} page
1473 (@uref{https://savannah.gnu.org/my/}).
1474
1475
1476 @item
1477 Click on the @qq{My Groups} link to access the @qq{My Group
1478 Membership} page.  From there, find the @qq{Request for Inclusion}
1479 box and search for @qq{LilyPond}.  Among the search results, check
1480 the box labeled @qq{GNU LilyPond Music Typesetter} and write a
1481 brief (required) message for the Project Manager (@qq{Hey it's
1482 me!} should be fine).
1483
1484 Note that you will not have commit access until the Project
1485 Manager activates your membership.  Once your membership is
1486 activated, LilyPond should appear under the heading @qq{Groups I'm
1487 Contributor of} on your @qq{My Group Membership} page.
1488
1489
1490 @item
1491 Generate an SSH @q{dsa} key pair.  Enter the following at the
1492 command prompt:
1493
1494 @example
1495 ssh-keygen -t dsa
1496 @end example
1497
1498 When prompted for a location to save the key, press <ENTER> to
1499 accept the default location (@file{~/.ssh/id_dsa}).
1500
1501 Next you are asked to enter an optional passphrase.  On most
1502 systems, if you use a passphrase, you will likely be prompted for
1503 it every time you use @command{git@tie{}push} or
1504 @command{git@tie{}pull}.  You may prefer this since it can protect
1505 you from your own mistakes (like pushing when you mean to pull),
1506 though you may find it tedious to keep re-entering it.
1507
1508 You can change/enable/disable your passphrase at any time with:
1509
1510 @example
1511 ssh-keygen -f ~/.ssh/id_dsa -p
1512 @end example
1513
1514 Note that the GNOME desktop has a feature which stores your
1515 passphrase for you for an entire GNOME session.  If you use a
1516 passphrase to @qq{protect you from yourself}, you will want to
1517 disable this feature, since you'll only be prompted once.  Run the
1518 following command, then logout of GNOME and log back in:
1519
1520 @example
1521 gconftool-2 --set -t bool \
1522   /apps/gnome-keyring/daemon-components/ssh false
1523 @end example
1524
1525 After setting up your passphrase, your private key is saved as
1526 @file{~/.ssh/id_dsa} and your public key is saved as
1527 @file{~/.ssh/id_dsa.pub}.
1528
1529
1530 @item
1531 Register your public SSH @q{dsa} key with Savannah.  From the
1532 @qq{My Account Configuration} page, click on @qq{Edit SSH Keys},
1533 then paste the contents of your @file{~/.ssh/id_dsa.pub} file into
1534 one of the @qq{Authorized keys} text fields, and click
1535 @qq{Update}.
1536
1537 Savannah should respond with something like:
1538
1539 @example
1540 Success: Key #1 seen Keys registered
1541 @end example
1542
1543
1544 @item
1545 Configure Git to use the SSH protocol (instead of the GIT
1546 protocol).  From your local Git repository, enter:
1547
1548 @example
1549 git config remote.origin.url \
1550   ssh://@var{user}@@git.sv.gnu.org/srv/git/lilypond.git
1551 @end example
1552
1553 @noindent
1554 where @var{user} is your username on Savannah.
1555
1556
1557 @item
1558 After your membership has been activated and you've configured Git
1559 to use SSH, test the connection with:
1560
1561 @example
1562 git pull --verbose
1563 @end example
1564
1565 SSH should issue the following warning:
1566
1567 @example
1568 The authenticity of host 'git.sv.gnu.org (140.186.70.72)' can't
1569 be established.
1570 RSA key fingerprint is
1571 80:5a:b0:0c:ec:93:66:29:49:7e:04:2b:fd:ba:2c:d5.
1572 Are you sure you want to continue connecting (yes/no)?
1573 @end example
1574
1575 Make sure the RSA key fingerprint displayed matches the one above.
1576 If it doesn't, respond @qq{no} and check that you configured Git
1577 properly in the previous step.  If it does match, respond
1578 @qq{yes}.  SSH should then issue another warning:
1579
1580 @example
1581 Warning: Permanently added 'git.sv.gnu.org,140.186.70.72' (RSA) to
1582 the list of known hosts.
1583 @end example
1584
1585 The list of known hosts is stored in the file
1586 @file{~/.ssh/known_hosts}.
1587
1588 At this point, you are prompted for your passphrase if you have
1589 one, then Git will attempt a pull.
1590
1591 If @command{git@tie{}pull@tie{}--verbose} fails, you should see
1592 error messages like these:
1593
1594 @example
1595 Permission denied (publickey).
1596 fatal: The remote end hung up unexpectedly
1597 @end example
1598
1599 If you get the above error, you may have made a mistake when
1600 registering your SSH key at Savannah.  If the key is properly
1601 registered, you probably just need to wait for the Savannah server
1602 to activate it.  It usually takes a few minutes for the key to be
1603 active after registering it, but if it still doesn't work after an
1604 hour, ask for help on the mailing list.
1605
1606 If @command{git@tie{}pull@tie{}--verbose} succeeds, the output
1607 will include a @q{From} line that shows @q{ssh} as the protocol:
1608
1609 @example
1610 From ssh://@var{user}@@git.sv.gnu.org/srv/git/lilypond
1611 @end example
1612
1613 If the protocol shown is not @q{ssh}, check that you configured
1614 Git properly in the previous step.
1615
1616
1617 @item
1618 Test your commit access with a dry run:
1619
1620 @example
1621 git push --dry-run --verbose
1622 @end example
1623
1624 Note that recent versions of Git (Git 1.6.3 or later) will issue a
1625 big warning if the above command is used.  The simplest solution
1626 is to tell Git to push all matching branches by default:
1627
1628 @example
1629 git config push.default matching
1630 @end example
1631
1632 @noindent
1633 Then @code{git@tie{}push} should work as before.  For more
1634 details, consult the @code{git@tie{}push} man page.
1635 @end enumerate
1636
1637
1638 @subsubheading Technical details
1639
1640 @itemize
1641 @item
1642 On Firefox, to view or remove the CAcert root certificate, go to:
1643 Edit > Preferences > Advanced > Encryption > View Certificates >
1644 Authorities > Certificate Name > Root CA > CA Cert Signing
1645 Authority.
1646
1647 @item
1648 The @command{git@tie{}config} commands above should modify your
1649 local repository's @file{.git/config} file.  These lines:
1650
1651 @example
1652 [remote "origin"]
1653         url = git://git.sv.gnu.org/lilypond.git/
1654 @end example
1655
1656 @noindent
1657 should now be changed to:
1658
1659 @example
1660 [remote "origin"]
1661         url = ssh://@var{user}@@git.sv.gnu.org/srv/git/lilypond.git
1662 @end example
1663
1664 @noindent
1665 where @var{user} is your login name on Savannah.
1666
1667 @item
1668 Similarly, the
1669 @command{git@tie{}config@tie{}push.default@tie{}matching} command
1670 should add these lines to @file{.git/config}:
1671
1672 @example
1673 [push]
1674         default = matching
1675 @end example
1676 @end itemize
1677
1678 @knownissues
1679 Encryption protocols, including ssh, generally do not permit packet
1680 fragmentation to avoid introducing a point of insecurity.  This
1681 means that the maximum packet size must not exceed the smallest
1682 MTU (Maximum Transmission Unit) set in the routers along the path.
1683 This smallest MTU is determined by a procedure during call set-up
1684 which relies on the transmission over the path of ICMP packets.
1685 If any of the routers in the path block ICMP packets this mechanism
1686 fails, resulting in the possibility of packets being transmitted
1687 which exceed the MTU of one of the routers.  If this happens the
1688 packet is discarded, causing the ssh session to hang, timeout or
1689 terminate with the error message
1690
1691 @example
1692 ssh: connect to host <host ip addr> port 22: Bad file number
1693 fatal: The remote end hung up unexpectedly
1694 @end example
1695
1696 depending on precisely when in the proceedings the first large
1697 packet is transmitted.  Most routers on the internet have MTU
1698 set to 1500, but routers installed in homes to connect via
1699 broadband may use a slightly smaller MTU for efficient transmission
1700 over ATM.  If this problem is encountered a possible work-around is
1701 to set the MTU in the local router to 1500.
1702
1703 @node Git on Windows
1704 @section Git on Windows
1705
1706 @c Some of this may duplicate stuff in other sections
1707 @c But it is probably best for windows users to have it all together
1708 @c If necessary, clear this up later  -td
1709
1710 TODO: Decide what to do with this...  Pare it down?  Move
1711 paragraphs next to analogous Unix instructions? -mp
1712
1713 @subsection Background to nomenclature
1714
1715 Git is a system for tracking the changes made to source files by a
1716 distributed set of editors.  It is designed to work without a
1717 master repository, but we have chosen to have a master repository
1718 for LilyPond files.  Editors hold a local copy of the master
1719 repository together with any changes they have made locally.
1720 Local changes are held in a local @q{branch}, of which there may
1721 be several, but these instructions assume you are using just one.
1722 The files visible in the local repository always correspond to
1723 those on the currently @q{checked out} local branch.
1724
1725 Files are edited on a local branch, and in that state the changes
1726 are said to be @q{unstaged}.  When editing is complete, the
1727 changes are moved to being @q{staged for commit}, and finally the
1728 changes are @q{committed} to the local branch.  Once committed,
1729 the changes (called a @q{commit}) are given a unique 40-digit
1730 hexadecimal reference number called the @q{Committish} or @q{SHA1
1731 ID} which identifies the commit to Git.  Such committed changes
1732 can be sent to the master repository by @q{pushing} them (if you
1733 have write permission) or by sending them by email to someone who
1734 has, either as a complete file or as a @q{diff} or @q{patch}
1735 (which send just the differences from the master repository).
1736
1737 @subsection Installing git
1738
1739 Obtain Git from
1740 @uref{http://code.google.com/p/msysgit/downloads/list} (note, not
1741 msysGit, which is for Git developers and not PortableGit, which is
1742 not a full git installation) and install it.
1743
1744 Note that most users will not need to install SSH.  That is not
1745 required until you have been granted direct push permissions to
1746 the master git repository.
1747
1748 Start Git by clicking on the desktop icon.  This will bring up a
1749 command line bash shell.  This may be unfamiliar to Windows users.
1750 If so, follow these instructions carefully.  Commands are entered
1751 at a $ prompt and are terminated by keying a newline.
1752
1753 @subsection Initialising Git
1754
1755 Decide where you wish to place your local Git repository, creating
1756 the folders in Windows as necessary.  Here we call the folder to
1757 contain the repository @code{[path]/Git}, but if you intend using
1758 Git for other projects a directory name like @code{lilypond-git}
1759 might be better.  You will need to have space for around
1760 100Mbytes.
1761
1762 Start the Git bash shell by clicking on the desk-top icon
1763 installed with Git and type
1764
1765 @example
1766 cd [path]/Git
1767 @end example
1768
1769 to position the shell at your new Git repository.
1770
1771 Note: if [path] contains folders with names containing spaces use
1772
1773 @example
1774 cd "[path]/Git"
1775 @end example
1776
1777 Then type
1778
1779 @example
1780 git init
1781 @end example
1782
1783 to initialize your Git repository.
1784
1785 Then type (all on one line; the shell will wrap automatically)
1786
1787 @example
1788 git remote add -ft master origin git://git.sv.gnu.org/lilypond.git
1789 @end example
1790
1791 to download the lilypond master files.
1792
1793 @warning{Be patient!  Even on a broadband connection this can take
1794 10 minutes or more.  Wait for lots of [new tag] messages and the $
1795 prompt.}
1796
1797 We now need to generate a local copy of the downloaded files in a
1798 new local branch.  Your local branch needs to have a name.  It is
1799 usual to call it @q{master} and we shall do that here.
1800
1801 To do this, type
1802
1803 @example
1804 git checkout -b master origin/master
1805 @end example
1806
1807 This creates a second branch called @q{master}.  You will see two
1808 warnings (ignore these), and a message advising you that your
1809 local branch @q{master} has been set up to track the remote
1810 branch.  You now have two branches, a local branch called
1811 @q{master}, and a tracking branch called @q{origin/master}, which
1812 is a shortened form of @q{remotes/origin/master}.
1813
1814 Return to Windows Explorer and look in your Git repository.  You
1815 should see lots of folders.  For example, the LilyPond
1816 documentation can be found in [path]/Git/Documentation/.
1817
1818 The Git bash shell is terminated by typing @code{exit} or by
1819 clicking on the usual Windows close-window widget.
1820
1821 @subsection Git GUI
1822
1823 Almost all subsequent work will use the Git Graphical User
1824 Interface, which avoids having to type command line commands.  To
1825 start Git GUI first start the Git bash shell by clicking on the
1826 desktop icon, and type
1827
1828 @example
1829 cd [path]/Git
1830 git gui
1831 @end example
1832
1833 The Git GUI will open in a new window.  It contains four panels
1834 and 7 pull-down menus.  At this stage do not use any of the
1835 commands under Branch, Commit, Merge or Remote.  These will be
1836 explained later.
1837
1838 The top panel on the left contains the names of files which you
1839 are in the process of editing (Unstaged Changes), and the lower
1840 panel on the left contains the names of files you have finished
1841 editing and have staged ready for committing (Staged Changes).  At
1842 present, these panels will be empty as you have not yet made any
1843 changes to any file.  After a file has been edited and saved the
1844 top panel on the right will display the differences between the
1845 edited file selected in one of the panels on the left and the last
1846 version committed on the current branch.
1847
1848 The panel at bottom right is used to enter a descriptive message
1849 about the change before committing it.
1850
1851 The Git GUI is terminated by entering CNTL-Q while it is the
1852 active window or by clicking on the usual Windows close-window
1853 widget.
1854
1855 @subsection Personalising your local git repository
1856
1857 Open the Git GUI, click on
1858
1859 @example
1860 Edit -> Options
1861 @end example
1862
1863 and enter your name and email address in the left-hand (Git
1864 Repository) panel.  Leave everything else unchanged and save it.
1865
1866 Note that Windows users must leave the default setting for line
1867 endings unchanged.  All files in a git repository must have lines
1868 terminated by just a LF, as this is required for Merge to work,
1869 but Windows files are terminated by CRLF by default.  The git
1870 default setting causes the line endings of files in a Windows git
1871 repository to be flipped automatically between LF and CRLF as
1872 required.  This enables files to be edited by any Windows editor
1873 without causing problems in the git repository.
1874
1875 @subsection Checking out a branch
1876
1877 At this stage you have two branches in your local repository,
1878 both identical.  To see them click on
1879
1880 @example
1881 Branch -> Checkout
1882 @end example
1883
1884 You should have one local branch called @q{master} and one
1885 tracking branch called @q{origin/master}.  The latter is your
1886 local copy of the @q{remotes/origin/master} branch in the master
1887 LilyPond repository.  The local @q{master} branch is where you
1888 will make your local changes.
1889
1890 When a particular branch is selected, i.e., checked out, the files
1891 visible in your repository are changed to reflect the state of the
1892 files on that branch.
1893
1894 @subsection Updating files from @q{remote/origin/master}
1895
1896 Before starting the editing of a file, ensure your local
1897 repository contains the latest version of the files in the remote
1898 repository by first clicking
1899
1900 @example
1901 Remote -> Fetch from -> origin
1902 @end example
1903
1904 @noindent
1905 in the Git GUI.
1906
1907 This will place the latest version of every file, including all
1908 the changes made by others, into the @q{origin/master} branch of
1909 the tracking branches in your git repository.  You can see these
1910 files by checking out this branch, but you must @emph{never} edit
1911 any files while this branch is checked out.  Check out your local
1912 @q{master} branch again.
1913
1914 You then need to merge these fetched files into your local
1915 @q{master} branch by clicking on
1916
1917 @example
1918 Merge -> Local Merge
1919 @end example
1920
1921 @noindent
1922 and if necessary select the local @q{master} branch.
1923
1924 Note that a merge cannot be completed if you have made any local
1925 changes which have not yet been committed.
1926
1927 This merge will update all the files in the @q{master} branch to
1928 reflect the current state of the @q{origin/master} branch.  If any
1929 of the changes conflict with changes you have made yourself
1930 recently you will be notified of the conflict (see below).
1931
1932 @subsection Editing files
1933
1934 First ensure your @q{master} branch is checked out, then simply
1935 edit the files in your local Git repository with your favourite
1936 editor and save them back there.  If any file contains non-ASCII
1937 characters ensure you save it in UTF-8 format.  Git will detect
1938 any changes whenever you restart Git GUI and the file names will
1939 then be listed in the Unstaged Changes panel.  Or you can click
1940 the Rescan button to refresh the panel contents at any time.  You
1941 may break off and resume editing any time.
1942
1943 The changes you have made may be displayed in diff form in the top
1944 right-hand panel of Git GUI by clicking on the file name shown in
1945 one of the left panels.
1946
1947 When your editing is complete, move the files from being Unstaged
1948 to Staged by clicking the document symbol to the left of each
1949 name.  If you change your mind it can be moved back by clicking on
1950 the ticked box to the left of the name.
1951
1952 Finally the changes you have made may be committed to your
1953 @q{master} branch by entering a brief message in the Commit
1954 Message box and clicking the Commit button.
1955
1956 If you wish to amend your changes after a commit has been made,
1957 the original version and the changes you made in that commit may
1958 be recovered by selecting
1959
1960 @example
1961 Commit -> Amend Last Commit
1962 @end example
1963
1964 @noindent
1965 or by checking the Amend Last Commit radio button at bottom right.
1966 This will return the changes to the Staged state, so further
1967 editing made be carried out within that commit.  This must only be
1968 done @emph{before} the changes have been Pushed or sent to your
1969 mentor for Pushing - after that it is too late and corrections
1970 have to be made as a separate commit.
1971
1972
1973 @subsection Sending changes to @q{remotes/origin/master}
1974
1975 If you do not have write access to @q{remotes/origin/master} you
1976 will need to send your changes by email to someone who does.
1977
1978 First you need to create a diff or patch file containing your
1979 changes.  To create this, the file must first be committed.  Then
1980 terminate the Git GUI.  In the git bash shell first cd to your Git
1981 repository with
1982
1983 @example
1984 cd [path]/Git
1985 @end example
1986
1987 if necessary, then produce the patch with
1988
1989 @example
1990 git format-patch origin
1991 @end example
1992
1993 This will create a patch file for all the locally committed files
1994 which differ from @q{origin/master}.  The patch file can be found
1995 in [path]/Git and will have a name formed from the commit message.
1996
1997 @subsection Resolving merge conflicts
1998
1999 As soon as you have committed a changed file your local
2000 @code{master} branch has diverged from @code{origin/master}, and
2001 will remain diverged until your changes have been committed in
2002 @code{remotes/origin/master} and Fetched back into your
2003 @code{origin/master} branch.  Similarly, if a new commit has been
2004 made to @code{remotes/origin/master} by someone else and Fetched,
2005 your local @code{master} branch is divergent.  You can detect a
2006 divergent branch by clicking on
2007
2008 @example
2009 Repository -> Visualise all branch history
2010 @end example
2011
2012 This opens up a very useful new window called @q{gitk}.  Use this
2013 to browse all the commits made by yourself and others.
2014
2015 If the diagram at top left of the resulting window does not show
2016 your @code{master} tag on the same node as the
2017 @code{remotes/origin/master} tag your branch has diverged from
2018 @code{origin/master}.  This is quite normal if files you have
2019 modified yourself have not yet been Pushed to
2020 @code{remotes/origin/master} and Fetched, or if files modified and
2021 committed by others have been Fetched since you last Merged
2022 @code{origin/master} into your local @code{master} branch.
2023
2024 If a file being merged from @code{origin/master} differs from one
2025 you have modified in a way that cannot be resolved automatically
2026 by git, Merge will report a Conflict which you must resolve by
2027 editing the file to create the version you wish to keep.
2028
2029 This could happen if the person updating
2030 @code{remotes/origin/master} for you has added some changes of his
2031 own before committing your changes to
2032 @code{remotes/origin/master}, or if someone else has changed the
2033 same file since you last fetched the file from
2034 @code{remotes/origin/master}.
2035
2036 Open the file in your editor and look for sections which are
2037 delimited with ...
2038
2039 [to be completed when I next have a merge conflict to be sure I
2040 give the right instructions  -td]
2041
2042
2043 @subsection Other actions
2044
2045 The instructions above describe the simplest way of using git on
2046 Windows.  Other git facilities which may usefully supplement these
2047 include
2048
2049 @itemize
2050 @item Using multiple local branches (Create, Rename, Delete)
2051 @item Resetting branches
2052 @item Cherry-picking commits
2053 @item Pushing commits to @w{remote/origin/master}
2054 @item Using gitk to review history
2055 @end itemize
2056
2057 Once familiarity with using git on Windows has been gained the
2058 standard git manuals can be used to learn about these.
2059
2060
2061 @node Repository directory structure
2062 @section Repository directory structure
2063
2064
2065 @c TODO: integrate the roadmap better
2066 @verbatiminclude ROADMAP
2067
2068
2069 @node Other Git documentation
2070 @section Other Git documentation
2071
2072 @itemize
2073 @item
2074 Official git man pages:
2075 @uref{http://www.kernel.org/pub/software/scm/git/docs/}
2076
2077 @item
2078 More in-depth tutorials: @uref{http://git-scm.com/documentation}
2079
2080 @item
2081 Book about git: @uref{http://progit.org/,Pro Git}
2082 @end itemize
2083