Merge branch 'master' of git://repo.or.cz/git/fastimport
authorJunio C Hamano <junkio@cox.net>
Wed, 7 Feb 2007 16:39:16 +0000 (08:39 -0800)
committerJunio C Hamano <junkio@cox.net>
Wed, 7 Feb 2007 16:39:16 +0000 (08:39 -0800)
* 'master' of git://repo.or.cz/git/fastimport:
Add a Tips and Tricks section to fast-import's manual.
Don't crash fast-import if the marks cannot be exported.
Dump all refs and marks during a checkpoint in fast-import.
Teach fast-import how to sit quietly in the corner.
Teach fast-import how to clear the internal branch content.
Minor timestamp related documentation corrections for fast-import.

104 files changed:
.gitignore
Documentation/Makefile
Documentation/SubmittingPatches
Documentation/config.txt
Documentation/core-tutorial.txt
Documentation/diff-format.txt
Documentation/docbook-xsl.css [new file with mode: 0644]
Documentation/git-blame.txt
Documentation/git-cat-file.txt
Documentation/git-checkout.txt
Documentation/git-cvsexportcommit.txt
Documentation/git-diff-stages.txt
Documentation/git-for-each-ref.txt
Documentation/git-rebase.txt
Documentation/git-remote.txt
Documentation/git-resolve.txt
Documentation/git-rev-parse.txt
Documentation/git-send-pack.txt
Documentation/git-show-branch.txt
Documentation/git-svn.txt
Documentation/git-symbolic-ref.txt
Documentation/git-tools.txt
Documentation/git.txt
Documentation/gitk.txt
Documentation/hooks.txt
Documentation/tutorial-2.txt
Documentation/tutorial.txt
Documentation/user-manual.conf [new file with mode: 0644]
Documentation/user-manual.txt [new file with mode: 0644]
GIT-VERSION-GEN
Makefile
builtin-annotate.c
builtin-blame.c
builtin-branch.c
builtin-for-each-ref.c
builtin-fsck.c
builtin-init-db.c
builtin-ls-files.c
builtin-push.c
builtin-reflog.c
builtin-rev-parse.c
builtin-show-branch.c
builtin-symbolic-ref.c
builtin-update-index.c
cache.h
combine-diff.c
commit.c
config.c
contrib/blameview/blameview.perl
contrib/colordiff/README [deleted file]
contrib/colordiff/colordiff.perl [deleted file]
contrib/completion/git-completion.bash
contrib/emacs/git-blame.el [new file with mode: 0644]
contrib/hg-to-git/hg-to-git.py [new file with mode: 0755]
contrib/hg-to-git/hg-to-git.txt [new file with mode: 0644]
daemon.c
diff-lib.c
diff.h
git-archimport.perl
git-bisect.sh
git-checkout.sh
git-clone.sh
git-commit.sh
git-cvsexportcommit.perl
git-fetch.sh
git-ls-remote.sh
git-merge-resolve.sh
git-parse-remote.sh
git-quiltimport.sh
git-rebase.sh
git-remote.perl
git-revert.sh
git-sh-setup.sh
git-svn.perl
git-tag.sh
git.c
git.spec.in
gitweb/gitweb.perl
ident.c
merge-recursive.c
pager.c
perl/Git.pm
perl/private-Error.pm
ppc/sha1ppc.S
reachable.c
reflog-walk.c
refs.c
refs.h
server-info.c
sha1_file.c
sha1_name.c
t/annotate-tests.sh
t/t1004-read-tree-m-u-wf.sh
t/t1020-subdirectory.sh
t/t3800-mktag.sh
t/t5000-tar-tree.sh
t/t5600-clone-fail-cleanup.sh
t/t5700-clone-reference.sh
t/t6023-merge-rename-nocruft.sh
t/t9101-git-svn-props.sh
t/t9200-git-cvsexportcommit.sh
t/test-lib.sh
templates/Makefile
templates/hooks--update
index d49994903e33744294edf494a7e18ebba6519e95..d99372afc48a96e73da49b1f0787861efaeac1ee 100644 (file)
@@ -72,7 +72,6 @@ git-merge-tree
 git-merge-octopus
 git-merge-one-file
 git-merge-ours
-git-merge-recur
 git-merge-recursive
 git-merge-resolve
 git-merge-stupid
index 5314068d32f1e9205ec7b76c9356674a414d773c..266af47176a7f09000ed90f43b5ed83af74db8ea 100644 (file)
@@ -17,7 +17,7 @@ ARTICLES += hooks
 ARTICLES += everyday
 ARTICLES += git-tools
 # with their own formatting rules.
-SP_ARTICLES = glossary howto/revert-branch-rebase
+SP_ARTICLES = glossary howto/revert-branch-rebase user-manual
 
 DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
 
@@ -99,6 +99,12 @@ clean:
 %.xml : %.txt
        asciidoc -b docbook -d manpage -f asciidoc.conf $<
 
+user-manual.xml: user-manual.txt user-manual.conf
+       asciidoc -b docbook -d book $<
+
+user-manual.html: user-manual.xml
+       xmlto html-nochunks $<
+
 glossary.html : glossary.txt sort_glossary.pl
        cat $< | \
        perl sort_glossary.pl | \
index ce85d06c6214d6757c44119fe2d04ec15f6054ad..285781d9db8d337dadf5a59bbf46183d2f816fac 100644 (file)
@@ -316,7 +316,6 @@ settings but I haven't tried, yet.
        mail.identity.id?.compose_html          => false
 
 
-
 Gnus
 ----
 
@@ -331,3 +330,20 @@ whitespaces (fatal in patches).  Running 'C-u g' to display the
 message in raw form before using '|' to run the pipe can work
 this problem around.
 
+
+KMail
+-----
+
+This should help you to submit patches inline using KMail.
+
+1) Prepare the patch as a text file.
+
+2) Click on New Mail.
+
+3) Go under "Options" in the Composer window and be sure that
+"Word wrap" is not set.
+
+4) Use Message -> Insert file... and insert the patch.
+
+5) Back in the compose window: add whatever other text you wish to the
+message, complete the addressing and subject fields, and press send.
index e5e019fedd8a774877162c9e4bb5e001564e7d47..4e650af01af9e0c528805b472e6970e5e24322e4 100644 (file)
@@ -39,7 +39,7 @@ in the section header, like in example below:
 
 Subsection names can contain any characters except newline (doublequote
 '`"`' and backslash have to be escaped as '`\"`' and '`\\`',
-respecitvely) and are case sensitive.  Section header cannot span multiple
+respectively) and are case sensitive.  Section header cannot span multiple
 lines.  Variables may belong directly to a section or to a given subsection.
 You can have `[section]` if you have `[section "subsection"]`, but you
 don't need to.
index 86a9c7521aeeb59d05aab1d2fc9d664950087422..9c28bea62e5848e30137c063ca8fa91de737ca01 100644 (file)
@@ -624,7 +624,7 @@ name for the state at that point.
 Copying repositories
 --------------------
 
-git repositories are normally totally self-sufficient and relocatable
+git repositories are normally totally self-sufficient and relocatable.
 Unlike CVS, for example, there is no separate notion of
 "repository" and "working tree". A git repository normally *is* the
 working tree, with the local git information hidden in the `.git`
@@ -1118,7 +1118,7 @@ You could do without using any branches at all, by
 keeping as many local repositories as you would like to have
 branches, and merging between them with `git pull`, just like
 you merge between branches. The advantage of this approach is
-that it lets you keep set of files for each `branch` checked
+that it lets you keep set of files for each `branch` checked
 out and you may find it easier to switch back and forth if you
 juggle multiple lines of development simultaneously. Of
 course, you will pay the price of more disk usage to hold
@@ -1300,7 +1300,7 @@ differences since stage 2 (i.e. your version).
 Publishing your work
 --------------------
 
-So we can use somebody else's work from a remote repository; but
+So, we can use somebody else's work from a remote repository, but
 how can *you* prepare a repository to let other people pull from
 it?
 
@@ -1469,8 +1469,8 @@ Working with Others
 Although git is a truly distributed system, it is often
 convenient to organize your project with an informal hierarchy
 of developers. Linux kernel development is run this way. There
-is a nice illustration (page 17, "Merges to Mainline") in Randy
-Dunlap's presentation (`http://tinyurl.com/a2jdg`).
+is a nice illustration (page 17, "Merges to Mainline") in
+link:http://tinyurl.com/a2jdg[Randy Dunlap's presentation].
 
 It should be stressed that this hierarchy is purely *informal*.
 There is nothing fundamental in git that enforces the "chain of
index 883c1bb0a638d97278cdb66e288bc766a32626af..378e72f38f37eef50135c3907ccd605652f4fd96 100644 (file)
@@ -159,7 +159,7 @@ or like this (when '--cc' option is used):
        deleted file mode <mode>,<mode>
 +
 The `mode <mode>,<mode>..<mode>` line appears only if at least one of
-the <mode> is diferent from the rest. Extended headers with
+the <mode> is different from the rest. Extended headers with
 information about detected contents movement (renames and
 copying detection) are designed to work with diff of two
 <tree-ish> and are not used by combined diff format.
diff --git a/Documentation/docbook-xsl.css b/Documentation/docbook-xsl.css
new file mode 100644 (file)
index 0000000..8821e30
--- /dev/null
@@ -0,0 +1,286 @@
+/*\r
+  CSS stylesheet for XHTML produced by DocBook XSL stylesheets.\r
+  Tested with XSL stylesheets 1.61.2, 1.67.2\r
+*/\r
+\r
+span.strong {\r
+  font-weight: bold;\r
+}\r
+\r
+body blockquote {\r
+  margin-top: .75em;\r
+  line-height: 1.5;\r
+  margin-bottom: .75em;\r
+}\r
+\r
+html body {\r
+  margin: 1em 5% 1em 5%;\r
+  line-height: 1.2;\r
+}\r
+\r
+body div {\r
+  margin: 0;\r
+}\r
+\r
+h1, h2, h3, h4, h5, h6,\r
+div.toc p b,\r
+div.list-of-figures p b,\r
+div.list-of-tables p b,\r
+div.abstract p.title\r
+{\r
+  color: #527bbd;\r
+  font-family: tahoma, verdana, sans-serif;\r
+}\r
+\r
+div.toc p:first-child,\r
+div.list-of-figures p:first-child,\r
+div.list-of-tables p:first-child,\r
+div.example p.title\r
+{\r
+  margin-bottom: 0.2em;\r
+}\r
+\r
+body h1 {\r
+  margin: .0em 0 0 -4%;\r
+  line-height: 1.3;\r
+  border-bottom: 2px solid silver;\r
+}\r
+\r
+body h2 {\r
+  margin: 0.5em 0 0 -4%;\r
+  line-height: 1.3;\r
+  border-bottom: 2px solid silver;\r
+}\r
+\r
+body h3 {\r
+  margin: .8em 0 0 -3%;\r
+  line-height: 1.3;\r
+}\r
+\r
+body h4 {\r
+  margin: .8em 0 0 -3%;\r
+  line-height: 1.3;\r
+}\r
+\r
+body h5 {\r
+  margin: .8em 0 0 -2%;\r
+  line-height: 1.3;\r
+}\r
+\r
+body h6 {\r
+  margin: .8em 0 0 -1%;\r
+  line-height: 1.3;\r
+}\r
+\r
+body hr {\r
+  border: none; /* Broken on IE6 */\r
+}\r
+div.footnotes hr {\r
+  border: 1px solid silver;\r
+}\r
+\r
+div.navheader th, div.navheader td, div.navfooter td {\r
+  font-family: sans-serif;\r
+  font-size: 0.9em;\r
+  font-weight: bold;\r
+  color: #527bbd;\r
+}\r
+div.navheader img, div.navfooter img {\r
+  border-style: none;\r
+}\r
+div.navheader a, div.navfooter a {\r
+  font-weight: normal;\r
+}\r
+div.navfooter hr {\r
+  border: 1px solid silver;\r
+}\r
+\r
+body td {\r
+  line-height: 1.2\r
+}\r
+\r
+body th {\r
+  line-height: 1.2;\r
+}\r
+\r
+ol {\r
+  line-height: 1.2;\r
+}\r
+\r
+ul, body dir, body menu {\r
+  line-height: 1.2;\r
+}\r
+\r
+html {\r
+  margin: 0; \r
+  padding: 0;\r
+}\r
+\r
+body h1, body h2, body h3, body h4, body h5, body h6 {\r
+  margin-left: 0\r
+} \r
+\r
+body pre {\r
+  margin: 0.5em 10% 0.5em 1em;\r
+  line-height: 1.0;\r
+  color: navy;\r
+}\r
+\r
+tt.literal, code.literal {\r
+  color: navy;\r
+}\r
+\r
+div.literallayout p {\r
+  padding: 0em;\r
+  margin: 0em;\r
+}\r
+\r
+div.literallayout {\r
+  font-family: monospace;\r
+#  margin: 0.5em 10% 0.5em 1em;\r
+  margin: 0em;\r
+  color: navy;\r
+  border: 1px solid silver;\r
+  background: #f4f4f4;\r
+  padding: 0.5em;\r
+}\r
+\r
+.programlisting, .screen {\r
+  border: 1px solid silver;\r
+  background: #f4f4f4;\r
+  margin: 0.5em 10% 0.5em 0;\r
+  padding: 0.5em 1em;\r
+}\r
+\r
+div.sidebar {\r
+  background: #ffffee;\r
+  margin: 1.0em 10% 0.5em 0;\r
+  padding: 0.5em 1em;\r
+  border: 1px solid silver;\r
+}\r
+div.sidebar * { padding: 0; }\r
+div.sidebar div { margin: 0; }\r
+div.sidebar p.title {\r
+  font-family: sans-serif;\r
+  margin-top: 0.5em;\r
+  margin-bottom: 0.2em;\r
+}\r
+\r
+div.bibliomixed {\r
+  margin: 0.5em 5% 0.5em 1em;\r
+}\r
+\r
+div.glossary dt {\r
+  font-weight: bold;\r
+}\r
+div.glossary dd p {\r
+  margin-top: 0.2em;\r
+}\r
+\r
+dl {\r
+  margin: .8em 0;\r
+  line-height: 1.2;\r
+}\r
+\r
+dt {\r
+  margin-top: 0.5em;\r
+}\r
+\r
+dt span.term {\r
+  font-style: italic;\r
+}\r
+\r
+div.variablelist dd p {\r
+  margin-top: 0;\r
+}\r
+\r
+div.itemizedlist li, div.orderedlist li {\r
+  margin-left: -0.8em;\r
+  margin-top: 0.5em;\r
+}\r
+\r
+ul, ol {\r
+    list-style-position: outside;\r
+}\r
+\r
+div.sidebar ul, div.sidebar ol {\r
+    margin-left: 2.8em;\r
+}\r
+\r
+div.itemizedlist p.title,\r
+div.orderedlist p.title,\r
+div.variablelist p.title\r
+{\r
+  margin-bottom: -0.8em;\r
+}\r
+\r
+div.revhistory table {\r
+  border-collapse: collapse;\r
+  border: none;\r
+}\r
+div.revhistory th {\r
+  border: none;\r
+  color: #527bbd;\r
+  font-family: tahoma, verdana, sans-serif;\r
+}\r
+div.revhistory td {\r
+  border: 1px solid silver;\r
+}\r
+\r
+/* Keep TOC and index lines close together. */\r
+div.toc dl, div.toc dt,\r
+div.list-of-figures dl, div.list-of-figures dt,\r
+div.list-of-tables dl, div.list-of-tables dt,\r
+div.indexdiv dl, div.indexdiv dt\r
+{\r
+  line-height: normal;\r
+  margin-top: 0;\r
+  margin-bottom: 0;\r
+}\r
+\r
+/*\r
+  Table styling does not work because of overriding attributes in\r
+  generated HTML.\r
+*/\r
+div.table table,\r
+div.informaltable table\r
+{\r
+    margin-left: 0;\r
+    margin-right: 5%;\r
+    margin-bottom: 0.8em;\r
+}\r
+div.informaltable table\r
+{\r
+    margin-top: 0.4em\r
+}\r
+div.table thead,\r
+div.table tfoot,\r
+div.table tbody,\r
+div.informaltable thead,\r
+div.informaltable tfoot,\r
+div.informaltable tbody\r
+{\r
+    /* No effect in IE6. */\r
+    border-top: 2px solid #527bbd;\r
+    border-bottom: 2px solid #527bbd;\r
+}\r
+div.table thead, div.table tfoot,\r
+div.informaltable thead, div.informaltable tfoot\r
+{\r
+    font-weight: bold;\r
+}\r
+\r
+div.mediaobject img {\r
+    border: 1px solid silver;\r
+    margin-bottom: 0.8em;\r
+}\r
+div.figure p.title,\r
+div.table p.title\r
+{\r
+  margin-top: 1em;\r
+  margin-bottom: 0.4em;\r
+}\r
+\r
+@media print {\r
+  div.navheader, div.navfooter { display: none; }\r
+}\r
index 0ee887d73c704fc877db845b6f5f7ab3b9b10363..5c9888d0143ec8e6c8f7c6782139cde38a25ff17 100644 (file)
@@ -9,7 +9,7 @@ SYNOPSIS
 --------
 [verse]
 'git-blame' [-c] [-l] [-t] [-f] [-n] [-p] [--incremental] [-L n,m] [-S <revs-file>]
-            [-M] [-C] [-C] [--since=<date>] [<rev>] [--] <file>
+            [-M] [-C] [-C] [--since=<date>] [<rev> | --contents <file>] [--] <file>
 
 DESCRIPTION
 -----------
@@ -67,6 +67,13 @@ OPTIONS
        Show the result incrementally in a format designed for
        machine consumption.
 
+--contents <file>::
+       When <rev> is not specified, the command annotates the
+       changes starting backwards from the working tree copy.
+       This flag makes the command pretend as if the working
+       tree copy has the contents of he named file (specify
+       `-` to make the command read from the standard input).
+
 -M::
        Detect moving lines in the file as well.  When a commit
        moves a block of lines in a file (e.g. the original file
index 7e90ce91bc4732a2f68e6ac2433f24d8cd3ecd62..075c0d05efca85c2357e09aa640aa4b7f0305419 100644 (file)
@@ -19,7 +19,9 @@ or '-s' is used to find the object size.
 OPTIONS
 -------
 <object>::
-       The sha1 identifier of the object.
+       The name of the object to show.
+       For a more complete list of ways to spell object names, see
+       "SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1].
 
 -t::
        Instead of the content, show the object type identified by
index c44a4a8004a49e42c01bcd238ae22b8d32b33cc3..55c9289438e65d62d960ac909f6481b178f1d80e 100644 (file)
@@ -8,8 +8,8 @@ git-checkout - Checkout and switch to a branch
 SYNOPSIS
 --------
 [verse]
-'git-checkout' [-f] [-b <new_branch> [-l]] [-m] [<branch>]
-'git-checkout' [<branch>] <paths>...
+'git-checkout' [-q] [-f] [-b <new_branch> [-l]] [-m] [<branch>]
+'git-checkout' [<tree-ish>] <paths>...
 
 DESCRIPTION
 -----------
@@ -22,15 +22,20 @@ be created.
 
 When <paths> are given, this command does *not* switch
 branches.  It updates the named paths in the working tree from
-the index file (i.e. it runs `git-checkout-index -f -u`).  In
+the index file (i.e. it runs `git-checkout-index -f -u`), or a
+named commit.  In
 this case, `-f` and `-b` options are meaningless and giving
-either of them results in an error.  <branch> argument can be
-used to specify a specific tree-ish to update the index for the
-given paths before updating the working tree.
+either of them results in an error.  <tree-ish> argument can be
+used to specify a specific tree-ish (i.e. commit, tag or tree)
+to update the index for the given paths before updating the
+working tree.
 
 
 OPTIONS
 -------
+-q::
+       Quiet, supress feedback messages.
+
 -f::
        Force a re-read of everything.
 
index 347cbcec353f0ed82e1bdc57766610e6251d7f96..27d531b888ef0468022e2ec0780729acc5151147 100644 (file)
@@ -8,7 +8,7 @@ git-cvsexportcommit - Export a single commit to a CVS checkout
 
 SYNOPSIS
 --------
-'git-cvsexportcommit' [-h] [-v] [-c] [-p] [-a] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
+'git-cvsexportcommit' [-h] [-v] [-c] [-P] [-p] [-a] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
 
 
 DESCRIPTION
@@ -46,6 +46,9 @@ OPTIONS
 -f::
        Force the merge even if the files are not up to date.
 
+-P::
+       Force the parent commit, even if it is not a direct parent.
+
 -m::
        Prepend the commit message with the provided prefix. 
        Useful for patch series and the like.
index 120d14e87e4641e6b5d84cb5127074860623c6ed..b8f45b8cdc2d4d2598e392efbbbed9d867080f62 100644 (file)
@@ -12,6 +12,8 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
+DEPRECATED and will be removed in 1.5.1.
+
 Compares the content and mode of the blobs in two stages in an
 unmerged index file.
 
index da52eba7b3619667537c1df3c58a927010f1c8ab..f49b0d944c613a9d5f4a6c5b6713d5c556f0390e 100644 (file)
@@ -66,7 +66,7 @@ keys.
 For all objects, the following names can be used:
 
 refname::
-       The name of the ref (the part after $GIT_DIR/refs/).
+       The name of the ref (the part after $GIT_DIR/).
 
 objecttype::
        The type of the object (`blob`, `tree`, `commit`, `tag`).
index 0cb9e1f10a26866eb0c908ed9a6f7a81d23532e7..977f661b9d7a1b92d27959429c48450a416c08b8 100644 (file)
@@ -114,6 +114,27 @@ would result in:
 
 This is useful when topicB does not depend on topicA.
 
+A range of commits could also be removed with rebase.  If we have
+the following situation:
+
+------------
+    E---F---G---H---I---J  topicA
+------------
+
+then the command
+
+    git-rebase --onto topicA~5 topicA~2 topicA
+
+would result in the removal of commits F and G:
+
+------------
+    E---H'---I'---J'  topicA
+------------
+
+This is useful if F and G were flawed in some way, or should not be
+part of topicA.  Note that the argument to --onto and the <upstream>
+parameter can be any valid commit-ish.
+
 In case of conflict, git-rebase will stop at the first problematic commit
 and leave conflict markers in the tree.  You can use git diff to locate
 the markers (<<<<<<) and make edits to resolve the conflict.  For each
@@ -141,10 +162,12 @@ OPTIONS
 <newbase>::
        Starting point at which to create the new commits. If the
        --onto option is not specified, the starting point is
-       <upstream>.
+       <upstream>.  May be any valid commit, and not just an
+       existing branch name.
 
 <upstream>::
-       Upstream branch to compare against.
+       Upstream branch to compare against.  May be any valid commit,
+       not just an existing branch name.
 
 <branch>::
        Working branch; defaults to HEAD.
index 358c1acfc393f5c94ecf34c372c8f492b016f2ce..a60c31a3150ca8109b1fb16aaf8ff485b57c9932 100644 (file)
@@ -12,19 +12,39 @@ SYNOPSIS
 'git-remote'
 'git-remote' add <name> <url>
 'git-remote' show <name>
+'git-remote' prune <name>
 
 DESCRIPTION
 -----------
 
 Manage the set of repositories ("remotes") whose branches you track.
 
-With no arguments, shows a list of existing remotes.
 
-In the second form, adds a remote named <name> for the repository at
+COMMANDS
+--------
+
+With no arguments, shows a list of existing remotes.  Several
+subcommands are available to perform operations on the remotes.
+
+'add'::
+
+Adds a remote named <name> for the repository at
 <url>.  The command `git fetch <name>` can then be used to create and
 update remote-tracking branches <name>/<branch>.
 
-In the third form, gives some information about the remote <name>.
+'show'::
+
+Gives some information about the remote <name>.
+
+'prune'::
+
+Deletes all stale tracking branches under <name>.
+These stale branches have already been removed from the remote repository
+referenced by <name>, but are still locally available in "remotes/<name>".
+
+
+DISCUSSION
+----------
 
 The remote configuration is achieved using the `remote.origin.url` and
 `remote.origin.fetch` configuration variables.  (See
index 0925973f12edcb863ede32cf1e95d9e9ebac1cf5..7fde665fb5a0fe477c4ac534668419fef1ffe719 100644 (file)
@@ -12,7 +12,7 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-DEPRECATED.  Use `git-merge` instead.
+DEPRECATED and will be removed in 1.5.1.  Use `git-merge` instead.
 
 Given two commits and a merge message, merge the <merged> commit
 into <current> commit, with the commit log message <message>.
index aeb37b65d26dbc2873438bd7b2c36bf89d24b056..4041a1607081ee6e8d93065c67fc72a513c20b17 100644 (file)
@@ -160,6 +160,10 @@ blobs contained in a commit.
   immediately following a ref name and the ref must have an existing
   log ($GIT_DIR/logs/<ref>).
 
+* You can use the '@' construct with an empty ref part to get at a
+  reflog of the current branch. For example, if you are on the
+  branch 'blabla', then '@\{1\}' means the same as 'blabla@\{1\}'.
+
 * A suffix '{caret}' to a revision parameter means the first parent of
   that commit object.  '{caret}<n>' means the <n>th parent (i.e.
   'rev{caret}'
index 2f6267ce6048a217feb1ee9b92910697c0a8ed33..205bfd2d259abd33873305d28281166a42285f6e 100644 (file)
@@ -3,7 +3,7 @@ git-send-pack(1)
 
 NAME
 ----
-git-send-pack - Push objects over git protocol to another reposiotory
+git-send-pack - Push objects over git protocol to another repository
 
 
 SYNOPSIS
index b38633c3973a21860428a02ef3344110f65cec0f..ba5313d51f8ba8380bd5519bf0c15a491a9bc83a 100644 (file)
@@ -11,7 +11,7 @@ SYNOPSIS
 'git-show-branch' [--all] [--remotes] [--topo-order] [--current]
                [--more=<n> | --list | --independent | --merge-base]
                [--no-name | --sha1-name] [--topics] [<rev> | <glob>]...
-'git-show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] <ref>
+'git-show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]
 
 DESCRIPTION
 -----------
@@ -97,11 +97,13 @@ OPTIONS
        will show the revisions given by "git rev-list {caret}master
        topic1 topic2"
 
---reflog[=<n>[,<base>]] <ref>::
+--reflog[=<n>[,<base>]] [<ref>]::
        Shows <n> most recent ref-log entries for the given
        ref.  If <base> is given, <n> entries going back from
        that entry.  <base> can be specified as count or date.
-       `-g` can be used as a short-hand for this option.
+       `-g` can be used as a short-hand for this option.  When
+       no explicit <ref> parameter is given, it defaults to the
+       current branch (or `HEAD` if it is detached).
 
 Note that --more, --list, --independent and --merge-base options
 are mutually exclusive.
index aea4a6bf5faae61ca02a0cc3e8a40f5d2d735191..6ce6a3944de5c1b815cd922b26f5eca2be08ed84 100644 (file)
@@ -133,7 +133,7 @@ manually joining branches on commit.
 
 'multi-init'::
        This command supports git-svnimport-like command-line syntax for
-       importing repositories that are layed out as recommended by the
+       importing repositories that are laid out as recommended by the
        SVN folks.  This is a bit more tolerant than the git-svnimport
        command-line syntax and doesn't require the user to figure out
        where the repository URL ends and where the repository path
index f93b79a85e1259f789551a94ab422a846cf4cf65..a88f7228605ee35002573123f3dbe63c3e405dc6 100644 (file)
@@ -7,7 +7,7 @@ git-symbolic-ref - Read and modify symbolic refs
 
 SYNOPSIS
 --------
-'git-symbolic-ref' [-q] <name> [<ref>]
+'git-symbolic-ref' [-q] [-m <reason>] <name> [<ref>]
 
 DESCRIPTION
 -----------
@@ -31,6 +31,10 @@ OPTIONS
        symbolic ref but a detached HEAD; instead exit with
        non-zero status silently.
 
+-m::
+       Update the reflog for <name> with <reason>.  This is valid only
+       when creating or updating a symbolic ref.
+
 NOTES
 -----
 In the past, `.git/HEAD` was a symbolic link pointing at
index 6b407f9adf86ee7d9a82e1c45b202ce67bb15e2b..10653ff898c2278f127f097ddf4a79db5615c802 100644 (file)
@@ -86,6 +86,14 @@ Foreign SCM interface
    series in git back and forth.
 
 
+   - *hg-to-git* (contrib/)
+
+   hg-to-git converts a Mercurial repository into a git one, and
+   preserves the full branch history in the process. hg-to-git can
+   also be used in an incremental way to keep the git repository
+   in sync with the master Mercurial repository.
+
+
 Others
 ------
 
index 7cd346798615eb31fbf4d6b8a329a7ff36d78741..29ee24c34f5a27517238d81ee7f240fc49939bbb 100644 (file)
@@ -22,6 +22,9 @@ See this link:tutorial.html[tutorial] to get started, then see
 link:everyday.html[Everyday Git] for a useful minimum set of commands, and
 "man git-commandname" for documentation of each command.  CVS users may
 also want to read link:cvs-migration.html[CVS migration].
+link:user-manual.html[Git User's Manual] is still work in
+progress, but when finished hopefully it will guide a new user
+in a coherent way to git enlightenment ;-).
 
 The COMMAND is either a name of a Git command (see below) or an alias
 as defined in the configuration file (see gitlink:git-config[1]).
index 5bdaa601f07929d515d751ed441fa95c925ae384..48c5894736ac3065e80a36e1a5230d86004bee2e 100644 (file)
@@ -54,7 +54,7 @@ frequently used options.
 
        Limit commits to the ones touching files in the given paths. Note, to
        avoid ambiguity wrt. revision names use "--" to separate the paths
-       from any preceeding options.
+       from any preceding options.
 
 Examples
 --------
index e3b76f96eb303dc7eda20472c8c546cf51a54e67..b083290d120b36e882c2a6d190e58ae1ee07b02f 100644 (file)
@@ -90,9 +90,6 @@ parameter, and is invoked after a commit is made.
 This hook is meant primarily for notification, and cannot affect
 the outcome of `git-commit`.
 
-The default 'post-commit' hook, when enabled, demonstrates how to
-send out a commit notification e-mail.
-
 update
 ------
 
@@ -130,6 +127,8 @@ The standard output of this hook is sent to `stderr`, so if you
 want to report something to the `git-send-pack` on the other end,
 you can simply `echo` your messages.
 
+The default 'update' hook, when enabled, demonstrates how to
+send out a notification e-mail.
 
 post-update
 -----------
index f363d17f0bedb8145f003ecef29832faf18a0730..8d899927124104d2b472f1ce63f97346a84e2d2c 100644 (file)
@@ -352,24 +352,23 @@ situation:
 
 ------------------------------------------------
 $ git status
-#
-# Added but not yet committed:
-#   (will commit)
+# On branch master
+# Changes to be committed:
+#   (use "git reset HEAD <file>..." to unstage)
 #
 #       new file: closing.txt
 #
-#
-# Changed but not added:
-#   (use "git add file1 file2" to include for commit)
+# Changed but not updated:
+#   (use "git add <file>..." to update what will be committed)
 #
 #       modified: file.txt
 #
 ------------------------------------------------
 
 Since the current state of closing.txt is cached in the index file,
-it is listed as "added but not yet committed".  Since file.txt has
+it is listed as "Changes to be committed".  Since file.txt has
 changes in the working directory that aren't reflected in the index,
-it is marked "changed but not added".  At this point, running "git
+it is marked "changed but not updated".  At this point, running "git
 commit" would create a commit that added closing.txt (with its new
 contents), but that didn't modify file.txt.
 
index adb1e327502e274382417ce2d4f305d4dbe88649..129c5c5f5b8657175db7efed2c06078affd05ab6 100644 (file)
@@ -101,27 +101,27 @@ want to commit together. This can be done in a few different ways:
 
 1) By using 'git add <file_spec>...'
 
-   This can be performed multiple times before a commit.  Note that this
-   is not only for adding new files.  Even modified files must be
-   added to the set of changes about to be committed.  The "git status"
-   command gives you a summary of what is included so far for the
-   next commit.  When done you should use the 'git commit' command to
-   make it real.
-
-   Note: don't forget to 'add' a file again if you modified it after the
-   first 'add' and before 'commit'. Otherwise only the previous added
-   state of that file will be committed. This is because git tracks
-   content, so what you're really 'add'ing to the commit is the *content*
-   of the file in the state it is in when you 'add' it.
+This can be performed multiple times before a commit.  Note that this
+is not only for adding new files.  Even modified files must be
+added to the set of changes about to be committed.  The "git status"
+command gives you a summary of what is included so far for the
+next commit.  When done you should use the 'git commit' command to
+make it real.
+
+Note: don't forget to 'add' a file again if you modified it after the
+first 'add' and before 'commit'. Otherwise only the previous added
+state of that file will be committed. This is because git tracks
+content, so what you're really 'add'ing to the commit is the *content*
+of the file in the state it is in when you 'add' it.
 
 2) By using 'git commit -a' directly
 
-   This is a quick way to automatically 'add' the content from all files
-   that were modified since the previous commit, and perform the actual
-   commit without having to separately 'add' them beforehand.  This will
-   not add content from new files i.e. files that were never added before.
-   Those files still have to be added explicitly before performing a
-   commit.
+This is a quick way to automatically 'add' the content from all files
+that were modified since the previous commit, and perform the actual
+commit without having to separately 'add' them beforehand.  This will
+not add content from new files i.e. files that were never added before.
+Those files still have to be added explicitly before performing a
+commit.
 
 But here's a twist. If you do 'git commit <file1> <file2> ...' then only
 the  changes belonging to those explicitly specified files will be
@@ -458,9 +458,11 @@ $ git reset --hard HEAD^ # reset your current branch and working
 Be careful with that last command: in addition to losing any changes
 in the working directory, it will also remove all later commits from
 this branch.  If this branch is the only branch containing those
-commits, they will be lost.  (Also, don't use "git reset" on a
-publicly-visible branch that other developers pull from, as git will
-be confused by history that disappears in this way.)
+commits, they will be lost.  Also, don't use "git reset" on a
+publicly-visible branch that other developers pull from, as it will
+force needless merges on other developers to clean up the history.
+If you need to undo changes that you have pushed, use gitlink:git-revert[1]
+instead.
 
 The git grep command can search for strings in any version of your
 project, so
diff --git a/Documentation/user-manual.conf b/Documentation/user-manual.conf
new file mode 100644 (file)
index 0000000..92b01ec
--- /dev/null
@@ -0,0 +1,21 @@
+[titles]
+       underlines="__","==","--","~~","^^"
+
+[attributes]
+caret=^
+startsb=&#91;
+endsb=&#93;
+tilde=&#126;
+
+[gitlink-inlinemacro]
+<ulink url="{target}.html">{target}{0?({0})}</ulink>
+
+ifdef::backend-docbook[]
+# "unbreak" docbook-xsl v1.68 for manpages. v1.69 works with or without this.
+[listingblock]
+<example><title>{title}</title>
+<literallayout>
+|
+</literallayout>
+{title#}</example>
+endif::backend-docbook[]
diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
new file mode 100644 (file)
index 0000000..c5e9ea8
--- /dev/null
@@ -0,0 +1,2961 @@
+Git User's Manual
+_________________
+
+This manual is designed to be readable by someone with basic unix
+commandline skills, but no previous knowledge of git.
+
+Chapter 1 gives a brief overview of git commands, without any
+explanation; you may prefer to skip to chapter 2 on a first reading.
+
+Chapters 2 and 3 explain how to fetch and study a project using
+git--the tools you'd need to build and test a particular version of a
+software project, to search for regressions, and so on.
+
+Chapter 4 explains how to do development with git, and chapter 5 how
+to share that development with others.
+
+Further chapters cover more specialized topics.
+
+Comprehensive reference documentation is available through the man
+pages.  For a command such as "git clone", just use
+
+------------------------------------------------
+$ man git-clone
+------------------------------------------------
+
+Git Quick Start
+===============
+
+This is a quick summary of the major commands; the following chapters
+will explain how these work in more detail.
+
+Creating a new repository
+-------------------------
+
+From a tarball:
+
+-----------------------------------------------
+$ tar xzf project.tar.gz
+$ cd project
+$ git init
+Initialized empty Git repository in .git/
+$ git add .
+$ git commit
+-----------------------------------------------
+
+From a remote repository:
+
+-----------------------------------------------
+$ git clone git://example.com/pub/project.git
+$ cd project
+-----------------------------------------------
+
+Managing branches
+-----------------
+
+-----------------------------------------------
+$ git branch        # list all branches in this repo
+$ git checkout test  # switch working directory to branch "test"
+$ git branch new     # create branch "new" starting at current HEAD
+$ git branch -d new  # delete branch "new"
+-----------------------------------------------
+
+Instead of basing new branch on current HEAD (the default), use:
+
+-----------------------------------------------
+$ git branch new test    # branch named "test"
+$ git branch new v2.6.15 # tag named v2.6.15
+$ git branch new HEAD^   # commit before the most recent
+$ git branch new HEAD^^  # commit before that
+$ git branch new test~10 # ten commits before tip of branch "test"
+-----------------------------------------------
+
+Create and switch to a new branch at the same time:
+
+-----------------------------------------------
+$ git checkout -b new v2.6.15
+-----------------------------------------------
+
+Update and examine branches from the repository you cloned from:
+
+-----------------------------------------------
+$ git fetch            # update
+$ git branch -r                # list
+  origin/master
+  origin/next
+  ...
+$ git branch checkout -b masterwork origin/master
+-----------------------------------------------
+
+Fetch a branch from a different repository, and give it a new
+name in your repository:
+
+-----------------------------------------------
+$ git fetch git://example.com/project.git theirbranch:mybranch
+$ git fetch git://example.com/project.git v2.6.15:mybranch
+-----------------------------------------------
+
+Keep a list of repositories you work with regularly:
+
+-----------------------------------------------
+$ git remote add example git://example.com/project.git
+$ git remote                   # list remote repositories
+example
+origin
+$ git remote show example      # get details
+* remote example
+  URL: git://example.com/project.git
+  Tracked remote branches
+    master next ...
+$ git fetch example            # update branches from example
+$ git branch -r                        # list all remote branches
+-----------------------------------------------
+
+
+Exploring history
+-----------------
+
+-----------------------------------------------
+$ gitk                     # visualize and browse history
+$ git log                  # list all commits
+$ git log src/             # ...modifying src/
+$ git log v2.6.15..v2.6.16  # ...in v2.6.16, not in v2.6.15
+$ git log master..test     # ...in branch test, not in branch master
+$ git log test..master     # ...in branch master, but not in test
+$ git log test...master            # ...in one branch, not in both
+$ git log -S'foo()'        # ...where difference contain "foo()"
+$ git log --since="2 weeks ago"
+$ git log -p               # show patches as well
+$ git show                 # most recent commit
+$ git diff v2.6.15..v2.6.16 # diff between two tagged versions
+$ git diff v2.6.15..HEAD    # diff with current head
+$ git grep "foo()"         # search working directory for "foo()"
+$ git grep v2.6.15 "foo()"  # search old tree for "foo()"
+$ git show v2.6.15:a.txt    # look at old version of a.txt
+-----------------------------------------------
+
+Search for regressions:
+
+-----------------------------------------------
+$ git bisect start
+$ git bisect bad               # current version is bad
+$ git bisect good v2.6.13-rc2  # last known good revision
+Bisecting: 675 revisions left to test after this
+                               # test here, then:
+$ git bisect good              # if this revision is good, or
+$ git bisect bad               # if this revision is bad.
+                               # repeat until done.
+-----------------------------------------------
+
+Making changes
+--------------
+
+Make sure git knows who to blame:
+
+------------------------------------------------
+$ cat >~/.gitconfig <<\EOF
+[user]
+name = Your Name Comes Here
+email = you@yourdomain.example.com
+EOF
+------------------------------------------------
+
+Select file contents to include in the next commit, then make the
+commit:
+
+-----------------------------------------------
+$ git add a.txt    # updated file
+$ git add b.txt    # new file
+$ git rm c.txt     # old file
+$ git commit
+-----------------------------------------------
+
+Or, prepare and create the commit in one step:
+
+-----------------------------------------------
+$ git commit d.txt # use latest content only of d.txt
+$ git commit -a           # use latest content of all tracked files
+-----------------------------------------------
+
+Merging
+-------
+
+-----------------------------------------------
+$ git merge test   # merge branch "test" into the current branch
+$ git pull git://example.com/project.git master
+                  # fetch and merge in remote branch
+$ git pull . test  # equivalent to git merge test
+-----------------------------------------------
+
+Sharing your changes
+--------------------
+
+Importing or exporting patches:
+
+-----------------------------------------------
+$ git format-patch origin..HEAD # format a patch for each commit
+                               # in HEAD but not in origin
+$ git-am mbox # import patches from the mailbox "mbox"
+-----------------------------------------------
+
+Fetch a branch in a different git repository, then merge into the
+current branch:
+
+-----------------------------------------------
+$ git pull git://example.com/project.git theirbranch
+-----------------------------------------------
+
+Store the fetched branch into a local branch before merging into the
+current branch:
+
+-----------------------------------------------
+$ git pull git://example.com/project.git theirbranch:mybranch
+-----------------------------------------------
+
+After creating commits on a local branch, update the remote
+branch with your commits:
+
+-----------------------------------------------
+$ git push ssh://example.com/project.git mybranch:theirbranch
+-----------------------------------------------
+
+When remote and local branch are both named "test":
+
+-----------------------------------------------
+$ git push ssh://example.com/project.git test
+-----------------------------------------------
+
+Shortcut version for a frequently used remote repository:
+
+-----------------------------------------------
+$ git remote add example ssh://example.com/project.git
+$ git push example test
+-----------------------------------------------
+
+Repository maintenance
+----------------------
+
+Check for corruption:
+
+-----------------------------------------------
+$ git fsck
+-----------------------------------------------
+
+Recompress, remove unused cruft:
+
+-----------------------------------------------
+$ git gc
+-----------------------------------------------
+
+Repositories and Branches
+=========================
+
+How to get a git repository
+---------------------------
+
+It will be useful to have a git repository to experiment with as you
+read this manual.
+
+The best way to get one is by using the gitlink:git-clone[1] command
+to download a copy of an existing repository for a project that you
+are interested in.  If you don't already have a project in mind, here
+are some interesting examples:
+
+------------------------------------------------
+       # git itself (approx. 10MB download):
+$ git clone git://git.kernel.org/pub/scm/git/git.git
+       # the linux kernel (approx. 150MB download):
+$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
+------------------------------------------------
+
+The initial clone may be time-consuming for a large project, but you
+will only need to clone once.
+
+The clone command creates a new directory named after the project
+("git" or "linux-2.6" in the examples above).  After you cd into this
+directory, you will see that it contains a copy of the project files,
+together with a special top-level directory named ".git", which
+contains all the information about the history of the project.
+
+In most of the following, examples will be taken from one of the two
+repositories above.
+
+How to check out a different version of a project
+-------------------------------------------------
+
+Git is best thought of as a tool for storing the history of a
+collection of files.  It stores the history as a compressed
+collection of interrelated snapshots (versions) of the project's
+contents.
+
+A single git repository may contain multiple branches.  Each branch
+is a bookmark referencing a particular point in the project history.
+The gitlink:git-branch[1] command shows you the list of branches:
+
+------------------------------------------------
+$ git branch
+* master
+------------------------------------------------
+
+A freshly cloned repository contains a single branch, named "master",
+and the working directory contains the version of the project
+referred to by the master branch.
+
+Most projects also use tags.  Tags, like branches, are references
+into the project's history, and can be listed using the
+gitlink:git-tag[1] command:
+
+------------------------------------------------
+$ git tag -l
+v2.6.11
+v2.6.11-tree
+v2.6.12
+v2.6.12-rc2
+v2.6.12-rc3
+v2.6.12-rc4
+v2.6.12-rc5
+v2.6.12-rc6
+v2.6.13
+...
+------------------------------------------------
+
+Tags are expected to always point at the same version of a project,
+while branches are expected to advance as development progresses.
+
+Create a new branch pointing to one of these versions and check it
+out using gitlink:git-checkout[1]:
+
+------------------------------------------------
+$ git checkout -b new v2.6.13
+------------------------------------------------
+
+The working directory then reflects the contents that the project had
+when it was tagged v2.6.13, and gitlink:git-branch[1] shows two
+branches, with an asterisk marking the currently checked-out branch:
+
+------------------------------------------------
+$ git branch
+  master
+* new
+------------------------------------------------
+
+If you decide that you'd rather see version 2.6.17, you can modify
+the current branch to point at v2.6.17 instead, with
+
+------------------------------------------------
+$ git reset --hard v2.6.17
+------------------------------------------------
+
+Note that if the current branch was your only reference to a
+particular point in history, then resetting that branch may leave you
+with no way to find the history it used to point to; so use this
+command carefully.
+
+Understanding History: Commits
+------------------------------
+
+Every change in the history of a project is represented by a commit.
+The gitlink:git-show[1] command shows the most recent commit on the
+current branch:
+
+------------------------------------------------
+$ git show
+commit 2b5f6dcce5bf94b9b119e9ed8d537098ec61c3d2
+Author: Jamal Hadi Salim <hadi@cyberus.ca>
+Date:   Sat Dec 2 22:22:25 2006 -0800
+
+    [XFRM]: Fix aevent structuring to be more complete.
+    
+    aevents can not uniquely identify an SA. We break the ABI with this
+    patch, but consensus is that since it is not yet utilized by any
+    (known) application then it is fine (better do it now than later).
+    
+    Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
+    Signed-off-by: David S. Miller <davem@davemloft.net>
+
+diff --git a/Documentation/networking/xfrm_sync.txt b/Documentation/networking/xfrm_sync.txt
+index 8be626f..d7aac9d 100644
+--- a/Documentation/networking/xfrm_sync.txt
++++ b/Documentation/networking/xfrm_sync.txt
+@@ -47,10 +47,13 @@ aevent_id structure looks like:
+    struct xfrm_aevent_id {
+              struct xfrm_usersa_id           sa_id;
++             xfrm_address_t                  saddr;
+              __u32                           flags;
++             __u32                           reqid;
+    };
+...
+------------------------------------------------
+
+As you can see, a commit shows who made the latest change, what they
+did, and why.
+
+Every commit has a 40-hexdigit id, sometimes called the "object name"
+or the "SHA1 id", shown on the first line of the "git show" output.
+You can usually refer to a commit by a shorter name, such as a tag or a
+branch name, but this longer name can also be useful.  Most
+importantly, it is a globally unique name for this commit: so if you
+tell somebody else the object name (for example in email), then you are
+guaranteed that name will refer to the same commit in their repository
+that it does in yours (assuming their repository has that commit at
+all).
+
+Understanding history: commits, parents, and reachability
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Every commit (except the very first commit in a project) also has a
+parent commit which shows what happened before this commit.
+Following the chain of parents will eventually take you back to the
+beginning of the project.
+
+However, the commits do not form a simple list; git allows lines of
+development to diverge and then reconverge, and the point where two
+lines of development reconverge is called a "merge".  The commit
+representing a merge can therefore have more than one parent, with
+each parent representing the most recent commit on one of the lines
+of development leading to that point.
+
+The best way to see how this works is using the gitlink:gitk[1]
+command; running gitk now on a git repository and looking for merge
+commits will help understand how the git organizes history.
+
+In the following, we say that commit X is "reachable" from commit Y
+if commit X is an ancestor of commit Y.  Equivalently, you could say
+that Y is a descendent of X, or that there is a chain of parents
+leading from commit Y to commit X.
+
+Understanding history: History diagrams
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+We will sometimes represent git history using diagrams like the one
+below.  Commits are shown as "o", and the links between them with
+lines drawn with - / and \.  Time goes left to right:
+
+         o--o--o <-- Branch A
+        /
+ o--o--o <-- master
+        \
+         o--o--o <-- Branch B
+
+If we need to talk about a particular commit, the character "o" may
+be replaced with another letter or number.
+
+Understanding history: What is a branch?
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Though we've been using the word "branch" to mean a kind of reference
+to a particular commit, the word branch is also commonly used to
+refer to the line of commits leading up to that point.  In the
+example above, git may think of the branch named "A" as just a
+pointer to one particular commit, but we may refer informally to the
+line of three commits leading up to that point as all being part of
+"branch A".
+
+If we need to make it clear that we're just talking about the most
+recent commit on the branch, we may refer to that commit as the
+"head" of the branch.
+
+Manipulating branches
+---------------------
+
+Creating, deleting, and modifying branches is quick and easy; here's
+a summary of the commands:
+
+git branch::
+       list all branches
+git branch <branch>::
+       create a new branch named <branch>, referencing the same
+       point in history as the current branch
+git branch <branch> <start-point>::
+       create a new branch named <branch>, referencing
+       <start-point>, which may be specified any way you like,
+       including using a branch name or a tag name
+git branch -d <branch>::
+       delete the branch <branch>; if the branch you are deleting
+       points to a commit which is not reachable from this branch,
+       this command will fail with a warning.
+git branch -D <branch>::
+       even if the branch points to a commit not reachable
+       from the current branch, you may know that that commit
+       is still reachable from some other branch or tag.  In that
+       case it is safe to use this command to force git to delete
+       the branch.
+git checkout <branch>::
+       make the current branch <branch>, updating the working
+       directory to reflect the version referenced by <branch>
+git checkout -b <new> <start-point>::
+       create a new branch <new> referencing <start-point>, and
+       check it out.
+
+It is also useful to know that the special symbol "HEAD" can always
+be used to refer to the current branch.
+
+Examining branches from a remote repository
+-------------------------------------------
+
+The "master" branch that was created at the time you cloned is a copy
+of the HEAD in the repository that you cloned from.  That repository
+may also have had other branches, though, and your local repository
+keeps branches which track each of those remote branches, which you
+can view using the "-r" option to gitlink:git-branch[1]:
+
+------------------------------------------------
+$ git branch -r
+  origin/HEAD
+  origin/html
+  origin/maint
+  origin/man
+  origin/master
+  origin/next
+  origin/pu
+  origin/todo
+------------------------------------------------
+
+You cannot check out these remote-tracking branches, but you can
+examine them on a branch of your own, just as you would a tag:
+
+------------------------------------------------
+$ git checkout -b my-todo-copy origin/todo
+------------------------------------------------
+
+Note that the name "origin" is just the name that git uses by default
+to refer to the repository that you cloned from.
+
+[[how-git-stores-references]]
+Naming branches, tags, and other references
+-------------------------------------------
+
+Branches, remote-tracking branches, and tags are all references to
+commits.  All references are named with a slash-separated path name
+starting with "refs"; the names we've been using so far are actually
+shorthand:
+
+       - The branch "test" is short for "refs/heads/test".
+       - The tag "v2.6.18" is short for "refs/tags/v2.6.18".
+       - "origin/master" is short for "refs/remotes/origin/master".
+
+The full name is occasionally useful if, for example, there ever
+exists a tag and a branch with the same name.
+
+As another useful shortcut, if the repository "origin" posesses only
+a single branch, you can refer to that branch as just "origin".
+
+More generally, if you have defined a remote repository named
+"example", you can refer to the branch in that repository as
+"example".  And for a repository with multiple branches, this will
+refer to the branch designated as the "HEAD" branch.
+
+For the complete list of paths which git checks for references, and
+the order it uses to decide which to choose when there are multiple
+references with the same shorthand name, see the "SPECIFYING
+REVISIONS" section of gitlink:git-rev-parse[1].
+
+[[Updating-a-repository-with-git-fetch]]
+Updating a repository with git fetch
+------------------------------------
+
+Eventually the developer cloned from will do additional work in her
+repository, creating new commits and advancing the branches to point
+at the new commits.
+
+The command "git fetch", with no arguments, will update all of the
+remote-tracking branches to the latest version found in her
+repository.  It will not touch any of your own branches--not even the
+"master" branch that was created for you on clone.
+
+Fetching branches from other repositories
+-----------------------------------------
+
+You can also track branches from repositories other than the one you
+cloned from, using gitlink:git-remote[1]:
+
+-------------------------------------------------
+$ git remote add linux-nfs git://linux-nfs.org/pub/nfs-2.6.git
+$ git fetch
+* refs/remotes/linux-nfs/master: storing branch 'master' ...
+  commit: bf81b46
+-------------------------------------------------
+
+New remote-tracking branches will be stored under the shorthand name
+that you gave "git remote add", in this case linux-nfs:
+
+-------------------------------------------------
+$ git branch -r
+linux-nfs/master
+origin/master
+-------------------------------------------------
+
+If you run "git fetch <remote>" later, the tracking branches for the
+named <remote> will be updated.
+
+If you examine the file .git/config, you will see that git has added
+a new stanza:
+
+-------------------------------------------------
+$ cat .git/config
+...
+[remote "linux-nfs"]
+        url = git://linux-nfs.org/~bfields/git.git
+       fetch = +refs/heads/*:refs/remotes/linux-nfs-read/*
+...
+-------------------------------------------------
+
+This is what causes git to track the remote's branches; you may modify
+or delete these configuration options by editing .git/config with a
+text editor.  (See the "CONFIGURATION FILE" section of
+gitlink:git-config[1] for details.)
+
+Exploring git history
+=====================
+
+Git is best thought of as a tool for storing the history of a
+collection of files.  It does this by storing compressed snapshots of
+the contents of a file heirarchy, together with "commits" which show
+the relationships between these snapshots.
+
+Git provides extremely flexible and fast tools for exploring the
+history of a project.
+
+We start with one specialized tool that is useful for finding the
+commit that introduced a bug into a project.
+
+How to use bisect to find a regression
+--------------------------------------
+
+Suppose version 2.6.18 of your project worked, but the version at
+"master" crashes.  Sometimes the best way to find the cause of such a
+regression is to perform a brute-force search through the project's
+history to find the particular commit that caused the problem.  The
+gitlink:git-bisect[1] command can help you do this:
+
+-------------------------------------------------
+$ git bisect start
+$ git bisect good v2.6.18
+$ git bisect bad master
+Bisecting: 3537 revisions left to test after this
+[65934a9a028b88e83e2b0f8b36618fe503349f8e] BLOCK: Make USB storage depend on SCSI rather than selecting it [try #6]
+-------------------------------------------------
+
+If you run "git branch" at this point, you'll see that git has
+temporarily moved you to a new branch named "bisect".  This branch
+points to a commit (with commit id 65934...) that is reachable from
+v2.6.19 but not from v2.6.18.  Compile and test it, and see whether
+it crashes.  Assume it does crash.  Then:
+
+-------------------------------------------------
+$ git bisect bad
+Bisecting: 1769 revisions left to test after this
+[7eff82c8b1511017ae605f0c99ac275a7e21b867] i2c-core: Drop useless bitmaskings
+-------------------------------------------------
+
+checks out an older version.  Continue like this, telling git at each
+stage whether the version it gives you is good or bad, and notice
+that the number of revisions left to test is cut approximately in
+half each time.
+
+After about 13 tests (in this case), it will output the commit id of
+the guilty commit.  You can then examine the commit with
+gitlink:git-show[1], find out who wrote it, and mail them your bug
+report with the commit id.  Finally, run
+
+-------------------------------------------------
+$ git bisect reset
+-------------------------------------------------
+
+to return you to the branch you were on before and delete the
+temporary "bisect" branch.
+
+Note that the version which git-bisect checks out for you at each
+point is just a suggestion, and you're free to try a different
+version if you think it would be a good idea.  For example,
+occasionally you may land on a commit that broke something unrelated;
+run
+
+-------------------------------------------------
+$ git bisect-visualize
+-------------------------------------------------
+
+which will run gitk and label the commit it chose with a marker that
+says "bisect".  Chose a safe-looking commit nearby, note its commit
+id, and check it out with:
+
+-------------------------------------------------
+$ git reset --hard fb47ddb2db...
+-------------------------------------------------
+
+then test, run "bisect good" or "bisect bad" as appropriate, and
+continue.
+
+Naming commits
+--------------
+
+We have seen several ways of naming commits already:
+
+       - 40-hexdigit object name
+       - branch name: refers to the commit at the head of the given
+         branch
+       - tag name: refers to the commit pointed to by the given tag
+         (we've seen branches and tags are special cases of
+         <<how-git-stores-references,references>>).
+       - HEAD: refers to the head of the current branch
+
+There are many more; see the "SPECIFYING REVISIONS" section of the
+gitlink:git-rev-parse[1] man page for the complete list of ways to
+name revisions.  Some examples:
+
+-------------------------------------------------
+$ git show fb47ddb2 # the first few characters of the object name
+                   # are usually enough to specify it uniquely
+$ git show HEAD^    # the parent of the HEAD commit
+$ git show HEAD^^   # the grandparent
+$ git show HEAD~4   # the great-great-grandparent
+-------------------------------------------------
+
+Recall that merge commits may have more than one parent; by default,
+^ and ~ follow the first parent listed in the commit, but you can
+also choose:
+
+-------------------------------------------------
+$ git show HEAD^1   # show the first parent of HEAD
+$ git show HEAD^2   # show the second parent of HEAD
+-------------------------------------------------
+
+In addition to HEAD, there are several other special names for
+commits:
+
+Merges (to be discussed later), as well as operations such as
+git-reset, which change the currently checked-out commit, generally
+set ORIG_HEAD to the value HEAD had before the current operation.
+
+The git-fetch operation always stores the head of the last fetched
+branch in FETCH_HEAD.  For example, if you run git fetch without
+specifying a local branch as the target of the operation
+
+-------------------------------------------------
+$ git fetch git://example.com/proj.git theirbranch
+-------------------------------------------------
+
+the fetched commits will still be available from FETCH_HEAD.
+
+When we discuss merges we'll also see the special name MERGE_HEAD,
+which refers to the other branch that we're merging in to the current
+branch.
+
+The gitlink:git-rev-parse[1] command is a low-level command that is
+occasionally useful for translating some name for a commit to the object
+name for that commit:
+
+-------------------------------------------------
+$ git rev-parse origin
+e05db0fd4f31dde7005f075a84f96b360d05984b
+-------------------------------------------------
+
+Creating tags
+-------------
+
+We can also create a tag to refer to a particular commit; after
+running
+
+-------------------------------------------------
+$ git-tag stable-1 1b2e1d63ff
+-------------------------------------------------
+
+You can use stable-1 to refer to the commit 1b2e1d63ff.
+
+This creates a "lightweight" tag.  If the tag is a tag you wish to
+share with others, and possibly sign cryptographically, then you
+should create a tag object instead; see the gitlink:git-tag[1] man
+page for details.
+
+Browsing revisions
+------------------
+
+The gitlink:git-log[1] command can show lists of commits.  On its
+own, it shows all commits reachable from the parent commit; but you
+can also make more specific requests:
+
+-------------------------------------------------
+$ git log v2.5..       # commits since (not reachable from) v2.5
+$ git log test..master # commits reachable from master but not test
+$ git log master..test # ...reachable from test but not master
+$ git log master...test        # ...reachable from either test or master,
+                       #    but not both
+$ git log --since="2 weeks ago" # commits from the last 2 weeks
+$ git log Makefile      # commits which modify Makefile
+$ git log fs/          # ... which modify any file under fs/
+$ git log -S'foo()'    # commits which add or remove any file data
+                       # matching the string 'foo()'
+-------------------------------------------------
+
+And of course you can combine all of these; the following finds
+commits since v2.5 which touch the Makefile or any file under fs:
+
+-------------------------------------------------
+$ git log v2.5.. Makefile fs/
+-------------------------------------------------
+
+You can also ask git log to show patches:
+
+-------------------------------------------------
+$ git log -p
+-------------------------------------------------
+
+See the "--pretty" option in the gitlink:git-log[1] man page for more
+display options.
+
+Note that git log starts with the most recent commit and works
+backwards through the parents; however, since git history can contain
+multiple independent lines of development, the particular order that
+commits are listed in may be somewhat arbitrary.
+
+Generating diffs
+----------------
+
+You can generate diffs between any two versions using
+gitlink:git-diff[1]:
+
+-------------------------------------------------
+$ git diff master..test
+-------------------------------------------------
+
+Sometimes what you want instead is a set of patches:
+
+-------------------------------------------------
+$ git format-patch master..test
+-------------------------------------------------
+
+will generate a file with a patch for each commit reachable from test
+but not from master.  Note that if master also has commits which are
+not reachable from test, then the combined result of these patches
+will not be the same as the diff produced by the git-diff example.
+
+Viewing old file versions
+-------------------------
+
+You can always view an old version of a file by just checking out the
+correct revision first.  But sometimes it is more convenient to be
+able to view an old version of a single file without checking
+anything out; this command does that:
+
+-------------------------------------------------
+$ git show v2.5:fs/locks.c
+-------------------------------------------------
+
+Before the colon may be anything that names a commit, and after it
+may be any path to a file tracked by git.
+
+Examples
+--------
+
+Check whether two branches point at the same history
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Suppose you want to check whether two branches point at the same point
+in history.
+
+-------------------------------------------------
+$ git diff origin..master
+-------------------------------------------------
+
+will tell you whether the contents of the project are the same at the
+two branches; in theory, however, it's possible that the same project
+contents could have been arrived at by two different historical
+routes.  You could compare the object names:
+
+-------------------------------------------------
+$ git rev-list origin
+e05db0fd4f31dde7005f075a84f96b360d05984b
+$ git rev-list master
+e05db0fd4f31dde7005f075a84f96b360d05984b
+-------------------------------------------------
+
+Or you could recall that the ... operator selects all commits
+contained reachable from either one reference or the other but not
+both: so
+
+-------------------------------------------------
+$ git log origin...master
+-------------------------------------------------
+
+will return no commits when the two branches are equal.
+
+Find first tagged version including a given fix
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Suppose you know that the commit e05db0fd fixed a certain problem.
+You'd like to find the earliest tagged release that contains that
+fix.
+
+Of course, there may be more than one answer--if the history branched
+after commit e05db0fd, then there could be multiple "earliest" tagged
+releases.
+
+You could just visually inspect the commits since e05db0fd:
+
+-------------------------------------------------
+$ gitk e05db0fd..
+-------------------------------------------------
+
+Or you can use gitlink:git-name-rev[1], which will give the commit a
+name based on any tag it finds pointing to one of the commit's
+descendants:
+
+-------------------------------------------------
+$ git name-rev e05db0fd
+e05db0fd tags/v1.5.0-rc1^0~23
+-------------------------------------------------
+
+The gitlink:git-describe[1] command does the opposite, naming the
+revision using a tag on which the given commit is based:
+
+-------------------------------------------------
+$ git describe e05db0fd
+v1.5.0-rc0-ge05db0f
+-------------------------------------------------
+
+but that may sometimes help you guess which tags might come after the
+given commit.
+
+If you just want to verify whether a given tagged version contains a
+given commit, you could use gitlink:git-merge-base[1]:
+
+-------------------------------------------------
+$ git merge-base e05db0fd v1.5.0-rc1
+e05db0fd4f31dde7005f075a84f96b360d05984b
+-------------------------------------------------
+
+The merge-base command finds a common ancestor of the given commits,
+and always returns one or the other in the case where one is a
+descendant of the other; so the above output shows that e05db0fd
+actually is an ancestor of v1.5.0-rc1.
+
+Alternatively, note that
+
+-------------------------------------------------
+$ git log v1.5.0-rc1..e05db0fd
+-------------------------------------------------
+
+will produce empty output if and only if v1.5.0-rc1 includes e05db0fd,
+because it outputs only commits that are not reachable from v1.5.0-rc1.
+
+As yet another alternative, the gitlink:git-show-branch[1] command lists
+the commits reachable from its arguments with a display on the left-hand
+side that indicates which arguments that commit is reachable from.  So,
+you can run something like
+
+-------------------------------------------------
+$ git show-branch e05db0fd v1.5.0-rc0 v1.5.0-rc1 v1.5.0-rc2
+! [e05db0fd] Fix warnings in sha1_file.c - use C99 printf format if
+available
+ ! [v1.5.0-rc0] GIT v1.5.0 preview
+  ! [v1.5.0-rc1] GIT v1.5.0-rc1
+   ! [v1.5.0-rc2] GIT v1.5.0-rc2
+...
+-------------------------------------------------
+
+then search for a line that looks like
+
+-------------------------------------------------
++ ++ [e05db0fd] Fix warnings in sha1_file.c - use C99 printf format if
+available
+-------------------------------------------------
+
+Which shows that e05db0fd is reachable from itself, from v1.5.0-rc1, and
+from v1.5.0-rc2, but not from v1.5.0-rc0.
+
+
+Developing with git
+===================
+
+Telling git your name
+---------------------
+
+Before creating any commits, you should introduce yourself to git.  The
+easiest way to do so is:
+
+------------------------------------------------
+$ cat >~/.gitconfig <<\EOF
+[user]
+       name = Your Name Comes Here
+       email = you@yourdomain.example.com
+EOF
+------------------------------------------------
+
+(See the "CONFIGURATION FILE" section of gitlink:git-config[1] for
+details on the configuration file.)
+
+
+Creating a new repository
+-------------------------
+
+Creating a new repository from scratch is very easy:
+
+-------------------------------------------------
+$ mkdir project
+$ cd project
+$ git init
+-------------------------------------------------
+
+If you have some initial content (say, a tarball):
+
+-------------------------------------------------
+$ tar -xzvf project.tar.gz
+$ cd project
+$ git init
+$ git add . # include everything below ./ in the first commit:
+$ git commit
+-------------------------------------------------
+
+[[how-to-make-a-commit]]
+how to make a commit
+--------------------
+
+Creating a new commit takes three steps:
+
+       1. Making some changes to the working directory using your
+          favorite editor.
+       2. Telling git about your changes.
+       3. Creating the commit using the content you told git about
+          in step 2.
+
+In practice, you can interleave and repeat steps 1 and 2 as many
+times as you want: in order to keep track of what you want committed
+at step 3, git maintains a snapshot of the tree's contents in a
+special staging area called "the index."
+
+At the beginning, the content of the index will be identical to
+that of the HEAD.  The command "git diff --cached", which shows
+the difference between the HEAD and the index, should therefore
+produce no output at that point.
+
+Modifying the index is easy:
+
+To update the index with the new contents of a modified file, use
+
+-------------------------------------------------
+$ git add path/to/file
+-------------------------------------------------
+
+To add the contents of a new file to the index, use
+
+-------------------------------------------------
+$ git add path/to/file
+-------------------------------------------------
+
+To remove a file from the index and from the working tree,
+
+-------------------------------------------------
+$ git rm path/to/file
+-------------------------------------------------
+
+After each step you can verify that
+
+-------------------------------------------------
+$ git diff --cached
+-------------------------------------------------
+
+always shows the difference between the HEAD and the index file--this
+is what you'd commit if you created the commit now--and that
+
+-------------------------------------------------
+$ git diff
+-------------------------------------------------
+
+shows the difference between the working tree and the index file.
+
+Note that "git add" always adds just the current contents of a file
+to the index; further changes to the same file will be ignored unless
+you run git-add on the file again.
+
+When you're ready, just run
+
+-------------------------------------------------
+$ git commit
+-------------------------------------------------
+
+and git will prompt you for a commit message and then create the new
+commit.  Check to make sure it looks like what you expected with
+
+-------------------------------------------------
+$ git show
+-------------------------------------------------
+
+As a special shortcut,
+               
+-------------------------------------------------
+$ git commit -a
+-------------------------------------------------
+
+will update the index with any files that you've modified or removed
+and create a commit, all in one step.
+
+A number of commands are useful for keeping track of what you're
+about to commit:
+
+-------------------------------------------------
+$ git diff --cached # difference between HEAD and the index; what
+                   # would be commited if you ran "commit" now.
+$ git diff         # difference between the index file and your
+                   # working directory; changes that would not
+                   # be included if you ran "commit" now.
+$ git status       # a brief per-file summary of the above.
+-------------------------------------------------
+
+creating good commit messages
+-----------------------------
+
+Though not required, it's a good idea to begin the commit message
+with a single short (less than 50 character) line summarizing the
+change, followed by a blank line and then a more thorough
+description.  Tools that turn commits into email, for example, use
+the first line on the Subject line and the rest of the commit in the
+body.
+
+how to merge
+------------
+
+You can rejoin two diverging branches of development using
+gitlink:git-merge[1]:
+
+-------------------------------------------------
+$ git merge branchname
+-------------------------------------------------
+
+merges the development in the branch "branchname" into the current
+branch.  If there are conflicts--for example, if the same file is
+modified in two different ways in the remote branch and the local
+branch--then you are warned; the output may look something like this:
+
+-------------------------------------------------
+$ git pull . next
+Trying really trivial in-index merge...
+fatal: Merge requires file-level merging
+Nope.
+Merging HEAD with 77976da35a11db4580b80ae27e8d65caf5208086
+Merging:
+15e2162 world
+77976da goodbye
+found 1 common ancestor(s):
+d122ed4 initial
+Auto-merging file.txt
+CONFLICT (content): Merge conflict in file.txt
+Automatic merge failed; fix conflicts and then commit the result.
+-------------------------------------------------
+
+Conflict markers are left in the problematic files, and after
+you resolve the conflicts manually, you can update the index
+with the contents and run git commit, as you normally would when
+creating a new file.
+
+If you examine the resulting commit using gitk, you will see that it
+has two parents, one pointing to the top of the current branch, and
+one to the top of the other branch.
+
+In more detail:
+
+[[resolving-a-merge]]
+Resolving a merge
+-----------------
+
+When a merge isn't resolved automatically, git leaves the index and
+the working tree in a special state that gives you all the
+information you need to help resolve the merge.
+
+Files with conflicts are marked specially in the index, so until you
+resolve the problem and update the index, git commit will fail:
+
+-------------------------------------------------
+$ git commit
+file.txt: needs merge
+-------------------------------------------------
+
+Also, git status will list those files as "unmerged".
+
+All of the changes that git was able to merge automatically are
+already added to the index file, so gitlink:git-diff[1] shows only
+the conflicts.  Also, it uses a somewhat unusual syntax:
+
+-------------------------------------------------
+$ git diff
+diff --cc file.txt
+index 802992c,2b60207..0000000
+--- a/file.txt
++++ b/file.txt
+@@@ -1,1 -1,1 +1,5 @@@
+++<<<<<<< HEAD:file.txt
+ +Hello world
+++=======
++ Goodbye
+++>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt
+-------------------------------------------------
+
+Recall that the commit which will be commited after we resolve this
+conflict will have two parents instead of the usual one: one parent
+will be HEAD, the tip of the current branch; the other will be the
+tip of the other branch, which is stored temporarily in MERGE_HEAD.
+
+The diff above shows the differences between the working-tree version
+of file.txt and two previous version: one version from HEAD, and one
+from MERGE_HEAD.  So instead of preceding each line by a single "+"
+or "-", it now uses two columns: the first column is used for
+differences between the first parent and the working directory copy,
+and the second for differences between the second parent and the
+working directory copy.  Thus after resolving the conflict in the
+obvious way, the diff will look like:
+
+-------------------------------------------------
+$ git diff
+diff --cc file.txt
+index 802992c,2b60207..0000000
+--- a/file.txt
++++ b/file.txt
+@@@ -1,1 -1,1 +1,1 @@@
+- Hello world
+ -Goodbye
+++Goodbye world
+-------------------------------------------------
+
+This shows that our resolved version deleted "Hello world" from the
+first parent, deleted "Goodbye" from the second parent, and added
+"Goodbye world", which was previously absent from both.
+
+The gitlink:git-log[1] command also provides special help for merges:
+
+-------------------------------------------------
+$ git log --merge
+-------------------------------------------------
+
+This will list all commits which exist only on HEAD or on MERGE_HEAD,
+and which touch an unmerged file.
+
+We can now add the resolved version to the index and commit:
+
+-------------------------------------------------
+$ git add file.txt
+$ git commit
+-------------------------------------------------
+
+Note that the commit message will already be filled in for you with
+some information about the merge.  Normally you can just use this
+default message unchanged, but you may add additional commentary of
+your own if desired.
+
+[[undoing-a-merge]]
+undoing a merge
+---------------
+
+If you get stuck and decide to just give up and throw the whole mess
+away, you can always return to the pre-merge state with
+
+-------------------------------------------------
+$ git reset --hard HEAD
+-------------------------------------------------
+
+Or, if you've already commited the merge that you want to throw away,
+
+-------------------------------------------------
+$ git reset --hard HEAD^
+-------------------------------------------------
+
+However, this last command can be dangerous in some cases--never
+throw away a commit you have already committed if that commit may
+itself have been merged into another branch, as doing so may confuse
+further merges.
+
+Fast-forward merges
+-------------------
+
+There is one special case not mentioned above, which is treated
+differently.  Normally, a merge results in a merge commit, with two
+parents, one pointing at each of the two lines of development that
+were merged.
+
+However, if one of the two lines of development is completely
+contained within the other--so every commit present in the one is
+already contained in the other--then git just performs a
+<<fast-forwards,fast forward>>; the head of the current branch is
+moved forward to point at the head of the merged-in branch, without
+any new commits being created.
+
+Fixing mistakes
+---------------
+
+If you've messed up the working tree, but haven't yet committed your
+mistake, you can return the entire working tree to the last committed
+state with
+
+-------------------------------------------------
+$ git reset --hard HEAD
+-------------------------------------------------
+
+If you make a commit that you later wish you hadn't, there are two
+fundamentally different ways to fix the problem:
+
+       1. You can create a new commit that undoes whatever was done
+       by the previous commit.  This is the correct thing if your
+       mistake has already been made public.
+
+       2. You can go back and modify the old commit.  You should
+       never do this if you have already made the history public;
+       git does not normally expect the "history" of a project to
+       change, and cannot correctly perform repeated merges from
+       a branch that has had its history changed.
+
+Fixing a mistake with a new commit
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Creating a new commit that reverts an earlier change is very easy;
+just pass the gitlink:git-revert[1] command a reference to the bad
+commit; for example, to revert the most recent commit:
+
+-------------------------------------------------
+$ git revert HEAD
+-------------------------------------------------
+
+This will create a new commit which undoes the change in HEAD.  You
+will be given a chance to edit the commit message for the new commit.
+
+You can also revert an earlier change, for example, the next-to-last:
+
+-------------------------------------------------
+$ git revert HEAD^
+-------------------------------------------------
+
+In this case git will attempt to undo the old change while leaving
+intact any changes made since then.  If more recent changes overlap
+with the changes to be reverted, then you will be asked to fix
+conflicts manually, just as in the case of <<resolving-a-merge,
+resolving a merge>>.
+
+Fixing a mistake by editing history
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If the problematic commit is the most recent commit, and you have not
+yet made that commit public, then you may just
+<<undoing-a-merge,destroy it using git-reset>>.
+
+Alternatively, you
+can edit the working directory and update the index to fix your
+mistake, just as if you were going to <<how-to-make-a-commit,create a
+new commit>>, then run
+
+-------------------------------------------------
+$ git commit --amend
+-------------------------------------------------
+
+which will replace the old commit by a new commit incorporating your
+changes, giving you a chance to edit the old commit message first.
+
+Again, you should never do this to a commit that may already have
+been merged into another branch; use gitlink:git-revert[1] instead in
+that case.
+
+It is also possible to edit commits further back in the history, but
+this is an advanced topic to be left for
+<<cleaning-up-history,another chapter>>.
+
+Checking out an old version of a file
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In the process of undoing a previous bad change, you may find it
+useful to check out an older version of a particular file using
+gitlink:git-checkout[1].  We've used git checkout before to switch
+branches, but it has quite different behavior if it is given a path
+name: the command
+
+-------------------------------------------------
+$ git checkout HEAD^ path/to/file
+-------------------------------------------------
+
+replaces path/to/file by the contents it had in the commit HEAD^, and
+also updates the index to match.  It does not change branches.
+
+If you just want to look at an old version of the file, without
+modifying the working directory, you can do that with
+gitlink:git-show[1]:
+
+-------------------------------------------------
+$ git show HEAD^ path/to/file
+-------------------------------------------------
+
+which will display the given version of the file.
+
+Ensuring good performance
+-------------------------
+
+On large repositories, git depends on compression to keep the history
+information from taking up to much space on disk or in memory.
+
+This compression is not performed automatically.  Therefore you
+should occasionally run gitlink:git-gc[1]:
+
+-------------------------------------------------
+$ git gc
+-------------------------------------------------
+
+to recompress the archive.  This can be very time-consuming, so
+you may prefer to run git-gc when you are not doing other work.
+
+Ensuring reliability
+--------------------
+
+Checking the repository for corruption
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The gitlink:git-fsck[1] command runs a number of self-consistency checks
+on the repository, and reports on any problems.  This may take some
+time.  The most common warning by far is about "dangling" objects:
+
+-------------------------------------------------
+$ git fsck
+dangling commit 7281251ddd2a61e38657c827739c57015671a6b3
+dangling commit 2706a059f258c6b245f298dc4ff2ccd30ec21a63
+dangling commit 13472b7c4b80851a1bc551779171dcb03655e9b5
+dangling blob 218761f9d90712d37a9c5e36f406f92202db07eb
+dangling commit bf093535a34a4d35731aa2bd90fe6b176302f14f
+dangling commit 8e4bec7f2ddaa268bef999853c25755452100f8e
+dangling tree d50bb86186bf27b681d25af89d3b5b68382e4085
+dangling tree b24c2473f1fd3d91352a624795be026d64c8841f
+...
+-------------------------------------------------
+
+Dangling objects are objects that are harmless, but also unnecessary;
+you can remove them at any time with gitlink:git-prune[1] or the --prune
+option to gitlink:git-gc[1]:
+
+-------------------------------------------------
+$ git gc --prune
+-------------------------------------------------
+
+This may be time-consuming.  Unlike most other git operations (including
+git-gc when run without any options), it is not safe to prune while
+other git operations are in progress in the same repository.
+
+For more about dangling objects, see <<dangling-objects>>.
+
+
+Recovering lost changes
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Reflogs
+^^^^^^^
+
+Say you modify a branch with gitlink:git-reset[1] --hard, and then
+realize that the branch was the only reference you had to that point in
+history.
+
+Fortunately, git also keeps a log, called a "reflog", of all the
+previous values of each branch.  So in this case you can still find the
+old history using, for example, 
+
+-------------------------------------------------
+$ git log master@{1}
+-------------------------------------------------
+
+This lists the commits reachable from the previous version of the head.
+This syntax can be used to with any git command that accepts a commit,
+not just with git log.  Some other examples:
+
+-------------------------------------------------
+$ git show master@{2}          # See where the branch pointed 2,
+$ git show master@{3}          # 3, ... changes ago.
+$ gitk master@{yesterday}      # See where it pointed yesterday,
+$ gitk master@{"1 week ago"}   # ... or last week
+-------------------------------------------------
+
+The reflogs are kept by default for 30 days, after which they may be
+pruned.  See gitlink:git-reflog[1] and gitlink:git-gc[1] to learn
+how to control this pruning, and see the "SPECIFYING REVISIONS"
+section of gitlink:git-rev-parse[1] for details.
+
+Note that the reflog history is very different from normal git history.
+While normal history is shared by every repository that works on the
+same project, the reflog history is not shared: it tells you only about
+how the branches in your local repository have changed over time.
+
+Examining dangling objects
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+In some situations the reflog may not be able to save you.  For
+example, suppose you delete a branch, then realize you need the history
+it pointed you.  The reflog is also deleted; however, if you have not
+yet pruned the repository, then you may still be able to find
+the lost commits; run git-fsck and watch for output that mentions
+"dangling commits":
+
+-------------------------------------------------
+$ git fsck
+dangling commit 7281251ddd2a61e38657c827739c57015671a6b3
+dangling commit 2706a059f258c6b245f298dc4ff2ccd30ec21a63
+dangling commit 13472b7c4b80851a1bc551779171dcb03655e9b5
+...
+-------------------------------------------------
+
+You can examine
+one of those dangling commits with, for example,
+
+------------------------------------------------
+$ gitk 7281251ddd --not --all
+------------------------------------------------
+
+which does what it sounds like: it says that you want to see the commit
+history that is described by the dangling commit(s), but not the
+history that is described by all your existing branches and tags.  Thus
+you get exactly the history reachable from that commit that is lost.
+(And notice that it might not be just one commit: we only report the
+"tip of the line" as being dangling, but there might be a whole deep
+and complex commit history that was gotten dropped.)
+
+If you decide you want the history back, you can always create a new
+reference pointing to it, for example, a new branch:
+
+------------------------------------------------
+$ git branch recovered-branch 7281251ddd 
+------------------------------------------------
+
+
+Sharing development with others
+===============================
+
+[[getting-updates-with-git-pull]]
+Getting updates with git pull
+-----------------------------
+
+After you clone a repository and make a few changes of your own, you
+may wish to check the original repository for updates and merge them
+into your own work.
+
+We have already seen <<Updating-a-repository-with-git-fetch,how to
+keep remote tracking branches up to date>> with gitlink:git-fetch[1],
+and how to merge two branches.  So you can merge in changes from the
+original repository's master branch with:
+
+-------------------------------------------------
+$ git fetch
+$ git merge origin/master
+-------------------------------------------------
+
+However, the gitlink:git-pull[1] command provides a way to do this in
+one step:
+
+-------------------------------------------------
+$ git pull origin master
+-------------------------------------------------
+
+In fact, "origin" is normally the default repository to pull from,
+and the default branch is normally the HEAD of the remote repository,
+so often you can accomplish the above with just
+
+-------------------------------------------------
+$ git pull
+-------------------------------------------------
+
+See the descriptions of the branch.<name>.remote and
+branch.<name>.merge options in gitlink:git-config[1] to learn
+how to control these defaults depending on the current branch.
+
+In addition to saving you keystrokes, "git pull" also helps you by
+producing a default commit message documenting the branch and
+repository that you pulled from.
+
+(But note that no such commit will be created in the case of a
+<<fast-forwards,fast forward>>; instead, your branch will just be
+updated to point to the latest commit from the upstream branch).
+
+The git-pull command can also be given "." as the "remote" repository,
+in which case it just merges in a branch from the current repository; so
+the commands
+
+-------------------------------------------------
+$ git pull . branch
+$ git merge branch
+-------------------------------------------------
+
+are roughly equivalent.  The former is actually very commonly used.
+
+Submitting patches to a project
+-------------------------------
+
+If you just have a few changes, the simplest way to submit them may
+just be to send them as patches in email:
+
+First, use gitlink:git-format-patch[1]; for example:
+
+-------------------------------------------------
+$ git format-patch origin
+-------------------------------------------------
+
+will produce a numbered series of files in the current directory, one
+for each patch in the current branch but not in origin/HEAD.
+
+You can then import these into your mail client and send them by
+hand.  However, if you have a lot to send at once, you may prefer to
+use the gitlink:git-send-email[1] script to automate the process.
+Consult the mailing list for your project first to determine how they
+prefer such patches be handled.
+
+Importing patches to a project
+------------------------------
+
+Git also provides a tool called gitlink:git-am[1] (am stands for
+"apply mailbox"), for importing such an emailed series of patches.
+Just save all of the patch-containing messages, in order, into a
+single mailbox file, say "patches.mbox", then run
+
+-------------------------------------------------
+$ git am -3 patches.mbox
+-------------------------------------------------
+
+Git will apply each patch in order; if any conflicts are found, it
+will stop, and you can fix the conflicts as described in
+"<<resolving-a-merge,Resolving a merge>>".  (The "-3" option tells
+git to perform a merge; if you would prefer it just to abort and
+leave your tree and index untouched, you may omit that option.)
+
+Once the index is updated with the results of the conflict
+resolution, instead of creating a new commit, just run
+
+-------------------------------------------------
+$ git am --resolved
+-------------------------------------------------
+
+and git will create the commit for you and continue applying the
+remaining patches from the mailbox.
+
+The final result will be a series of commits, one for each patch in
+the original mailbox, with authorship and commit log message each
+taken from the message containing each patch.
+
+[[setting-up-a-public-repository]]
+Setting up a public repository
+------------------------------
+
+Another way to submit changes to a project is to simply tell the
+maintainer of that project to pull from your repository, exactly as
+you did in the section "<<getting-updates-with-git-pull, Getting
+updates with git pull>>".
+
+If you and maintainer both have accounts on the same machine, then
+then you can just pull changes from each other's repositories
+directly; note that all of the command (gitlink:git-clone[1],
+git-fetch[1], git-pull[1], etc.) which accept a URL as an argument
+will also accept a local file patch; so, for example, you can
+use
+
+-------------------------------------------------
+$ git clone /path/to/repository
+$ git pull /path/to/other/repository
+-------------------------------------------------
+
+If this sort of setup is inconvenient or impossible, another (more
+common) option is to set up a public repository on a public server.
+This also allows you to cleanly separate private work in progress
+from publicly visible work.
+
+You will continue to do your day-to-day work in your personal
+repository, but periodically "push" changes from your personal
+repository into your public repository, allowing other developers to
+pull from that repository.  So the flow of changes, in a situation
+where there is one other developer with a public repository, looks
+like this:
+
+                        you push
+  your personal repo ------------------> your public repo
+       ^                                     |
+       |                                     |
+       | you pull                            | they pull
+       |                                     |
+       |                                     |
+        |               they push             V
+  their public repo <------------------- their repo
+
+Now, assume your personal repository is in the directory ~/proj.  We
+first create a new clone of the repository:
+
+-------------------------------------------------
+$ git clone --bare proj-clone.git
+-------------------------------------------------
+
+The resulting directory proj-clone.git will contains a "bare" git
+repository--it is just the contents of the ".git" directory, without
+a checked-out copy of a working directory.
+
+Next, copy proj-clone.git to the server where you plan to host the
+public repository.  You can use scp, rsync, or whatever is most
+convenient.
+
+If somebody else maintains the public server, they may already have
+set up a git service for you, and you may skip to the section
+"<<pushing-changes-to-a-public-repository,Pushing changes to a public
+repository>>", below.
+
+Otherwise, the following sections explain how to export your newly
+created public repository:
+
+[[exporting-via-http]]
+Exporting a git repository via http
+-----------------------------------
+
+The git protocol gives better performance and reliability, but on a
+host with a web server set up, http exports may be simpler to set up.
+
+All you need to do is place the newly created bare git repository in
+a directory that is exported by the web server, and make some
+adjustments to give web clients some extra information they need:
+
+-------------------------------------------------
+$ mv proj.git /home/you/public_html/proj.git
+$ cd proj.git
+$ git update-server-info
+$ chmod a+x hooks/post-update
+-------------------------------------------------
+
+(For an explanation of the last two lines, see
+gitlink:git-update-server-info[1], and the documentation
+link:hooks.txt[Hooks used by git].)
+
+Advertise the url of proj.git.  Anybody else should then be able to
+clone or pull from that url, for example with a commandline like:
+
+-------------------------------------------------
+$ git clone http://yourserver.com/~you/proj.git
+-------------------------------------------------
+
+(See also
+link:howto/setup-git-server-over-http.txt[setup-git-server-over-http]
+for a slightly more sophisticated setup using WebDAV which also
+allows pushing over http.)
+
+[[exporting-via-git]]
+Exporting a git repository via the git protocol
+-----------------------------------------------
+
+This is the preferred method.
+
+For now, we refer you to the gitlink:git-daemon[1] man page for
+instructions.  (See especially the examples section.)
+
+[[pushing-changes-to-a-public-repository]]
+Pushing changes to a public repository
+--------------------------------------
+
+Note that the two techniques outline above (exporting via
+<<exporting-via-http,http>> or <<exporting-via-git,git>>) allow other
+maintainers to fetch your latest changes, but they do not allow write
+access, which you will need to update the public repository with the
+latest changes created in your private repository.
+
+The simplest way to do this is using gitlink:git-push[1] and ssh; to
+update the remote branch named "master" with the latest state of your
+branch named "master", run
+
+-------------------------------------------------
+$ git push ssh://yourserver.com/~you/proj.git master:master
+-------------------------------------------------
+
+or just
+
+-------------------------------------------------
+$ git push ssh://yourserver.com/~you/proj.git master
+-------------------------------------------------
+
+As with git-fetch, git-push will complain if this does not result in
+a <<fast-forwards,fast forward>>.  Normally this is a sign of
+something wrong.  However, if you are sure you know what you're
+doing, you may force git-push to perform the update anyway by
+proceeding the branch name by a plus sign:
+
+-------------------------------------------------
+$ git push ssh://yourserver.com/~you/proj.git +master
+-------------------------------------------------
+
+As with git-fetch, you may also set up configuration options to
+save typing; so, for example, after
+
+-------------------------------------------------
+$ cat >.git/config <<EOF
+[remote "public-repo"]
+       url = ssh://yourserver.com/~you/proj.git
+EOF
+-------------------------------------------------
+
+you should be able to perform the above push with just
+
+-------------------------------------------------
+$ git push public-repo master
+-------------------------------------------------
+
+See the explanations of the remote.<name>.url, branch.<name>.remote,
+and remote.<name>.push options in gitlink:git-config[1] for
+details.
+
+Setting up a shared repository
+------------------------------
+
+Another way to collaborate is by using a model similar to that
+commonly used in CVS, where several developers with special rights
+all push to and pull from a single shared repository.  See
+link:cvs-migration.txt[git for CVS users] for instructions on how to
+set this up.
+
+Allow web browsing of a repository
+----------------------------------
+
+The gitweb cgi script provides users an easy way to browse your
+project's files and history without having to install git; see the file
+gitweb/README in the git source tree for instructions on setting it up.
+
+Examples
+--------
+
+TODO: topic branches, typical roles as in everyday.txt, ?
+
+
+[[cleaning-up-history]]
+Rewriting history and maintaining patch series
+==============================================
+
+Normally commits are only added to a project, never taken away or
+replaced.  Git is designed with this assumption, and violating it will
+cause git's merge machinery (for example) to do the wrong thing.
+
+However, there is a situation in which it can be useful to violate this
+assumption.
+
+Creating the perfect patch series
+---------------------------------
+
+Suppose you are a contributor to a large project, and you want to add a
+complicated feature, and to present it to the other developers in a way
+that makes it easy for them to read your changes, verify that they are
+correct, and understand why you made each change.
+
+If you present all of your changes as a single patch (or commit), they
+may find it is too much to digest all at once.
+
+If you present them with the entire history of your work, complete with
+mistakes, corrections, and dead ends, they may be overwhelmed.
+
+So the ideal is usually to produce a series of patches such that:
+
+       1. Each patch can be applied in order.
+
+       2. Each patch includes a single logical change, together with a
+          message explaining the change.
+
+       3. No patch introduces a regression: after applying any initial
+          part of the series, the resulting project still compiles and
+          works, and has no bugs that it didn't have before.
+
+       4. The complete series produces the same end result as your own
+          (probably much messier!) development process did.
+
+We will introduce some tools that can help you do this, explain how to
+use them, and then explain some of the problems that can arise because
+you are rewriting history.
+
+Keeping a patch series up to date using git-rebase
+--------------------------------------------------
+
+Suppose you have a series of commits in a branch "mywork", which
+originally branched off from "origin".
+
+Suppose you create a branch "mywork" on a remote-tracking branch
+"origin", and created some commits on top of it:
+
+-------------------------------------------------
+$ git checkout -b mywork origin
+$ vi file.txt
+$ git commit
+$ vi otherfile.txt
+$ git commit
+...
+-------------------------------------------------
+
+You have performed no merges into mywork, so it is just a simple linear
+sequence of patches on top of "origin":
+
+
+ o--o--o <-- origin
+        \
+         o--o--o <-- mywork
+
+Some more interesting work has been done in the upstream project, and
+"origin" has advanced:
+
+ o--o--O--o--o--o <-- origin
+        \
+         a--b--c <-- mywork
+
+At this point, you could use "pull" to merge your changes back in;
+the result would create a new merge commit, like this:
+
+
+ o--o--O--o--o--o <-- origin
+        \        \
+         a--b--c--m <-- mywork
+However, if you prefer to keep the history in mywork a simple series of
+commits without any merges, you may instead choose to use
+gitlink:git-rebase[1]:
+
+-------------------------------------------------
+$ git checkout mywork
+$ git rebase origin
+-------------------------------------------------
+
+This will remove each of your commits from mywork, temporarily saving
+them as patches (in a directory named ".dotest"), update mywork to
+point at the latest version of origin, then apply each of the saved
+patches to the new mywork.  The result will look like:
+
+
+ o--o--O--o--o--o <-- origin
+                \
+                 a'--b'--c' <-- mywork
+
+In the process, it may discover conflicts.  In that case it will stop
+and allow you to fix the conflicts; after fixing conflicts, use "git
+add" to update the index with those contents, and then, instead of
+running git-commit, just run
+
+-------------------------------------------------
+$ git rebase --continue
+-------------------------------------------------
+
+and git will continue applying the rest of the patches.
+
+At any point you may use the --abort option to abort this process and
+return mywork to the state it had before you started the rebase:
+
+-------------------------------------------------
+$ git rebase --abort
+-------------------------------------------------
+
+Reordering or selecting from a patch series
+-------------------------------------------
+
+Given one existing commit, the gitlink:git-cherry-pick[1] command
+allows you to apply the change introduced by that commit and create a
+new commit that records it.  So, for example, if "mywork" points to a
+series of patches on top of "origin", you might do something like:
+
+-------------------------------------------------
+$ git checkout -b mywork-new origin
+$ gitk origin..mywork &
+-------------------------------------------------
+
+And browse through the list of patches in the mywork branch using gitk,
+applying them (possibly in a different order) to mywork-new using
+cherry-pick, and possibly modifying them as you go using commit
+--amend.
+
+Another technique is to use git-format-patch to create a series of
+patches, then reset the state to before the patches:
+
+-------------------------------------------------
+$ git format-patch origin
+$ git reset --hard origin
+-------------------------------------------------
+
+Then modify, reorder, or eliminate patches as preferred before applying
+them again with gitlink:git-am[1].
+
+Other tools
+-----------
+
+There are numerous other tools, such as stgit, which exist for the
+purpose of maintaining a patch series.  These are out of the scope of
+this manual.
+
+Problems with rewriting history
+-------------------------------
+
+The primary problem with rewriting the history of a branch has to do
+with merging.  Suppose somebody fetches your branch and merges it into
+their branch, with a result something like this:
+
+ o--o--O--o--o--o <-- origin
+        \        \
+         t--t--t--m <-- their branch:
+
+Then suppose you modify the last three commits:
+
+        o--o--o <-- new head of origin
+       /
+ o--o--O--o--o--o <-- old head of origin
+
+If we examined all this history together in one repository, it will
+look like:
+
+        o--o--o <-- new head of origin
+       /
+ o--o--O--o--o--o <-- old head of origin
+        \        \
+         t--t--t--m <-- their branch:
+
+Git has no way of knowing that the new head is an updated version of
+the old head; it treats this situation exactly the same as it would if
+two developers had independently done the work on the old and new heads
+in parallel.  At this point, if someone attempts to merge the new head
+in to their branch, git will attempt to merge together the two (old and
+new) lines of development, instead of trying to replace the old by the
+new.  The results are likely to be unexpected.
+
+You may still choose to publish branches whose history is rewritten,
+and it may be useful for others to be able to fetch those branches in
+order to examine or test them, but they should not attempt to pull such
+branches into their own work.
+
+For true distributed development that supports proper merging,
+published branches should never be rewritten.
+
+Advanced branch management
+==========================
+
+Fetching individual branches
+----------------------------
+
+Instead of using gitlink:git-remote[1], you can also choose just
+to update one branch at a time, and to store it locally under an
+arbitrary name:
+
+-------------------------------------------------
+$ git fetch origin todo:my-todo-work
+-------------------------------------------------
+
+The first argument, "origin", just tells git to fetch from the
+repository you originally cloned from.  The second argument tells git
+to fetch the branch named "todo" from the remote repository, and to
+store it locally under the name refs/heads/my-todo-work.
+
+You can also fetch branches from other repositories; so
+
+-------------------------------------------------
+$ git fetch git://example.com/proj.git master:example-master
+-------------------------------------------------
+
+will create a new branch named "example-master" and store in it the
+branch named "master" from the repository at the given URL.  If you
+already have a branch named example-master, it will attempt to
+"fast-forward" to the commit given by example.com's master branch.  So
+next we explain what a fast-forward is:
+
+[[fast-forwards]]
+Understanding git history: fast-forwards
+----------------------------------------
+
+In the previous example, when updating an existing branch, "git
+fetch" checks to make sure that the most recent commit on the remote
+branch is a descendant of the most recent commit on your copy of the
+branch before updating your copy of the branch to point at the new
+commit.  Git calls this process a "fast forward".
+
+A fast forward looks something like this:
+
+ o--o--o--o <-- old head of the branch
+           \
+            o--o--o <-- new head of the branch
+
+
+In some cases it is possible that the new head will *not* actually be
+a descendant of the old head.  For example, the developer may have
+realized she made a serious mistake, and decided to backtrack,
+resulting in a situation like:
+
+ o--o--o--o--a--b <-- old head of the branch
+           \
+            o--o--o <-- new head of the branch
+
+
+
+In this case, "git fetch" will fail, and print out a warning.
+
+In that case, you can still force git to update to the new head, as
+described in the following section.  However, note that in the
+situation above this may mean losing the commits labeled "a" and "b",
+unless you've already created a reference of your own pointing to
+them.
+
+Forcing git fetch to do non-fast-forward updates
+------------------------------------------------
+
+If git fetch fails because the new head of a branch is not a
+descendant of the old head, you may force the update with:
+
+-------------------------------------------------
+$ git fetch git://example.com/proj.git +master:refs/remotes/example/master
+-------------------------------------------------
+
+Note the addition of the "+" sign.  Be aware that commits which the
+old version of example/master pointed at may be lost, as we saw in
+the previous section.
+
+Configuring remote branches
+---------------------------
+
+We saw above that "origin" is just a shortcut to refer to the
+repository which you originally cloned from.  This information is
+stored in git configuration variables, which you can see using
+gitlink:git-config[1]:
+
+-------------------------------------------------
+$ git config -l
+core.repositoryformatversion=0
+core.filemode=true
+core.logallrefupdates=true
+remote.origin.url=git://git.kernel.org/pub/scm/git/git.git
+remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
+branch.master.remote=origin
+branch.master.merge=refs/heads/master
+-------------------------------------------------
+
+If there are other repositories that you also use frequently, you can
+create similar configuration options to save typing; for example,
+after
+
+-------------------------------------------------
+$ git config remote.example.url git://example.com/proj.git
+-------------------------------------------------
+
+then the following two commands will do the same thing:
+
+-------------------------------------------------
+$ git fetch git://example.com/proj.git master:refs/remotes/example/master
+$ git fetch example master:refs/remotes/example/master
+-------------------------------------------------
+
+Even better, if you add one more option:
+
+-------------------------------------------------
+$ git config remote.example.fetch master:refs/remotes/example/master
+-------------------------------------------------
+
+then the following commands will all do the same thing:
+
+-------------------------------------------------
+$ git fetch git://example.com/proj.git master:ref/remotes/example/master
+$ git fetch example master:ref/remotes/example/master
+$ git fetch example example/master
+$ git fetch example
+-------------------------------------------------
+
+You can also add a "+" to force the update each time:
+
+-------------------------------------------------
+$ git config remote.example.fetch +master:ref/remotes/example/master
+-------------------------------------------------
+
+Don't do this unless you're sure you won't mind "git fetch" possibly
+throwing away commits on mybranch.
+
+Also note that all of the above configuration can be performed by
+directly editing the file .git/config instead of using
+gitlink:git-config[1].
+
+See gitlink:git-config[1] for more details on the configuration
+options mentioned above.
+
+
+Git internals
+=============
+
+There are two object abstractions: the "object database", and the
+"current directory cache" aka "index".
+
+The Object Database
+-------------------
+
+The object database is literally just a content-addressable collection
+of objects.  All objects are named by their content, which is
+approximated by the SHA1 hash of the object itself.  Objects may refer
+to other objects (by referencing their SHA1 hash), and so you can
+build up a hierarchy of objects.
+
+All objects have a statically determined "type" aka "tag", which is
+determined at object creation time, and which identifies the format of
+the object (i.e. how it is used, and how it can refer to other
+objects).  There are currently four different object types: "blob",
+"tree", "commit" and "tag".
+
+A "blob" object cannot refer to any other object, and is, like the type
+implies, a pure storage object containing some user data.  It is used to
+actually store the file data, i.e. a blob object is associated with some
+particular version of some file. 
+
+A "tree" object is an object that ties one or more "blob" objects into a
+directory structure. In addition, a tree object can refer to other tree
+objects, thus creating a directory hierarchy. 
+
+A "commit" object ties such directory hierarchies together into
+a DAG of revisions - each "commit" is associated with exactly one tree
+(the directory hierarchy at the time of the commit). In addition, a
+"commit" refers to one or more "parent" commit objects that describe the
+history of how we arrived at that directory hierarchy.
+
+As a special case, a commit object with no parents is called the "root"
+object, and is the point of an initial project commit.  Each project
+must have at least one root, and while you can tie several different
+root objects together into one project by creating a commit object which
+has two or more separate roots as its ultimate parents, that's probably
+just going to confuse people.  So aim for the notion of "one root object
+per project", even if git itself does not enforce that. 
+
+A "tag" object symbolically identifies and can be used to sign other
+objects. It contains the identifier and type of another object, a
+symbolic name (of course!) and, optionally, a signature.
+
+Regardless of object type, all objects share the following
+characteristics: they are all deflated with zlib, and have a header
+that not only specifies their type, but also provides size information
+about the data in the object.  It's worth noting that the SHA1 hash
+that is used to name the object is the hash of the original data
+plus this header, so `sha1sum` 'file' does not match the object name
+for 'file'.
+(Historical note: in the dawn of the age of git the hash
+was the sha1 of the 'compressed' object.)
+
+As a result, the general consistency of an object can always be tested
+independently of the contents or the type of the object: all objects can
+be validated by verifying that (a) their hashes match the content of the
+file and (b) the object successfully inflates to a stream of bytes that
+forms a sequence of <ascii type without space> + <space> + <ascii decimal
+size> + <byte\0> + <binary object data>. 
+
+The structured objects can further have their structure and
+connectivity to other objects verified. This is generally done with
+the `git-fsck` program, which generates a full dependency graph
+of all objects, and verifies their internal consistency (in addition
+to just verifying their superficial consistency through the hash).
+
+The object types in some more detail:
+
+Blob Object
+-----------
+
+A "blob" object is nothing but a binary blob of data, and doesn't
+refer to anything else.  There is no signature or any other
+verification of the data, so while the object is consistent (it 'is'
+indexed by its sha1 hash, so the data itself is certainly correct), it
+has absolutely no other attributes.  No name associations, no
+permissions.  It is purely a blob of data (i.e. normally "file
+contents").
+
+In particular, since the blob is entirely defined by its data, if two
+files in a directory tree (or in multiple different versions of the
+repository) have the same contents, they will share the same blob
+object. The object is totally independent of its location in the
+directory tree, and renaming a file does not change the object that
+file is associated with in any way.
+
+A blob is typically created when gitlink:git-update-index[1]
+is run, and its data can be accessed by gitlink:git-cat-file[1].
+
+Tree Object
+-----------
+
+The next hierarchical object type is the "tree" object.  A tree object
+is a list of mode/name/blob data, sorted by name.  Alternatively, the
+mode data may specify a directory mode, in which case instead of
+naming a blob, that name is associated with another TREE object.
+
+Like the "blob" object, a tree object is uniquely determined by the
+set contents, and so two separate but identical trees will always
+share the exact same object. This is true at all levels, i.e. it's
+true for a "leaf" tree (which does not refer to any other trees, only
+blobs) as well as for a whole subdirectory.
+
+For that reason a "tree" object is just a pure data abstraction: it
+has no history, no signatures, no verification of validity, except
+that since the contents are again protected by the hash itself, we can
+trust that the tree is immutable and its contents never change.
+
+So you can trust the contents of a tree to be valid, the same way you
+can trust the contents of a blob, but you don't know where those
+contents 'came' from.
+
+Side note on trees: since a "tree" object is a sorted list of
+"filename+content", you can create a diff between two trees without
+actually having to unpack two trees.  Just ignore all common parts,
+and your diff will look right.  In other words, you can effectively
+(and efficiently) tell the difference between any two random trees by
+O(n) where "n" is the size of the difference, rather than the size of
+the tree.
+
+Side note 2 on trees: since the name of a "blob" depends entirely and
+exclusively on its contents (i.e. there are no names or permissions
+involved), you can see trivial renames or permission changes by
+noticing that the blob stayed the same.  However, renames with data
+changes need a smarter "diff" implementation.
+
+A tree is created with gitlink:git-write-tree[1] and
+its data can be accessed by gitlink:git-ls-tree[1].
+Two trees can be compared with gitlink:git-diff-tree[1].
+
+Commit Object
+-------------
+
+The "commit" object is an object that introduces the notion of
+history into the picture.  In contrast to the other objects, it
+doesn't just describe the physical state of a tree, it describes how
+we got there, and why.
+
+A "commit" is defined by the tree-object that it results in, the
+parent commits (zero, one or more) that led up to that point, and a
+comment on what happened.  Again, a commit is not trusted per se:
+the contents are well-defined and "safe" due to the cryptographically
+strong signatures at all levels, but there is no reason to believe
+that the tree is "good" or that the merge information makes sense.
+The parents do not have to actually have any relationship with the
+result, for example.
+
+Note on commits: unlike real SCM's, commits do not contain
+rename information or file mode change information.  All of that is
+implicit in the trees involved (the result tree, and the result trees
+of the parents), and describing that makes no sense in this idiotic
+file manager.
+
+A commit is created with gitlink:git-commit-tree[1] and
+its data can be accessed by gitlink:git-cat-file[1].
+
+Trust
+-----
+
+An aside on the notion of "trust". Trust is really outside the scope
+of "git", but it's worth noting a few things.  First off, since
+everything is hashed with SHA1, you 'can' trust that an object is
+intact and has not been messed with by external sources.  So the name
+of an object uniquely identifies a known state - just not a state that
+you may want to trust.
+
+Furthermore, since the SHA1 signature of a commit refers to the
+SHA1 signatures of the tree it is associated with and the signatures
+of the parent, a single named commit specifies uniquely a whole set
+of history, with full contents.  You can't later fake any step of the
+way once you have the name of a commit.
+
+So to introduce some real trust in the system, the only thing you need
+to do is to digitally sign just 'one' special note, which includes the
+name of a top-level commit.  Your digital signature shows others
+that you trust that commit, and the immutability of the history of
+commits tells others that they can trust the whole history.
+
+In other words, you can easily validate a whole archive by just
+sending out a single email that tells the people the name (SHA1 hash)
+of the top commit, and digitally sign that email using something
+like GPG/PGP.
+
+To assist in this, git also provides the tag object...
+
+Tag Object
+----------
+
+Git provides the "tag" object to simplify creating, managing and
+exchanging symbolic and signed tokens.  The "tag" object at its
+simplest simply symbolically identifies another object by containing
+the sha1, type and symbolic name.
+
+However it can optionally contain additional signature information
+(which git doesn't care about as long as there's less than 8k of
+it). This can then be verified externally to git.
+
+Note that despite the tag features, "git" itself only handles content
+integrity; the trust framework (and signature provision and
+verification) has to come from outside.
+
+A tag is created with gitlink:git-mktag[1],
+its data can be accessed by gitlink:git-cat-file[1],
+and the signature can be verified by
+gitlink:git-verify-tag[1].
+
+
+The "index" aka "Current Directory Cache"
+-----------------------------------------
+
+The index is a simple binary file, which contains an efficient
+representation of a virtual directory content at some random time.  It
+does so by a simple array that associates a set of names, dates,
+permissions and content (aka "blob") objects together.  The cache is
+always kept ordered by name, and names are unique (with a few very
+specific rules) at any point in time, but the cache has no long-term
+meaning, and can be partially updated at any time.
+
+In particular, the index certainly does not need to be consistent with
+the current directory contents (in fact, most operations will depend on
+different ways to make the index 'not' be consistent with the directory
+hierarchy), but it has three very important attributes:
+
+'(a) it can re-generate the full state it caches (not just the
+directory structure: it contains pointers to the "blob" objects so
+that it can regenerate the data too)'
+
+As a special case, there is a clear and unambiguous one-way mapping
+from a current directory cache to a "tree object", which can be
+efficiently created from just the current directory cache without
+actually looking at any other data.  So a directory cache at any one
+time uniquely specifies one and only one "tree" object (but has
+additional data to make it easy to match up that tree object with what
+has happened in the directory)
+
+'(b) it has efficient methods for finding inconsistencies between that
+cached state ("tree object waiting to be instantiated") and the
+current state.'
+
+'(c) it can additionally efficiently represent information about merge
+conflicts between different tree objects, allowing each pathname to be
+associated with sufficient information about the trees involved that
+you can create a three-way merge between them.'
+
+Those are the three ONLY things that the directory cache does.  It's a
+cache, and the normal operation is to re-generate it completely from a
+known tree object, or update/compare it with a live tree that is being
+developed.  If you blow the directory cache away entirely, you generally
+haven't lost any information as long as you have the name of the tree
+that it described. 
+
+At the same time, the index is at the same time also the
+staging area for creating new trees, and creating a new tree always
+involves a controlled modification of the index file.  In particular,
+the index file can have the representation of an intermediate tree that
+has not yet been instantiated.  So the index can be thought of as a
+write-back cache, which can contain dirty information that has not yet
+been written back to the backing store.
+
+
+
+The Workflow
+------------
+
+Generally, all "git" operations work on the index file. Some operations
+work *purely* on the index file (showing the current state of the
+index), but most operations move data to and from the index file. Either
+from the database or from the working directory. Thus there are four
+main combinations: 
+
+working directory -> index
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You update the index with information from the working directory with
+the gitlink:git-update-index[1] command.  You
+generally update the index information by just specifying the filename
+you want to update, like so:
+
+-------------------------------------------------
+$ git-update-index filename
+-------------------------------------------------
+
+but to avoid common mistakes with filename globbing etc, the command
+will not normally add totally new entries or remove old entries,
+i.e. it will normally just update existing cache entries.
+
+To tell git that yes, you really do realize that certain files no
+longer exist, or that new files should be added, you
+should use the `--remove` and `--add` flags respectively.
+
+NOTE! A `--remove` flag does 'not' mean that subsequent filenames will
+necessarily be removed: if the files still exist in your directory
+structure, the index will be updated with their new status, not
+removed. The only thing `--remove` means is that update-cache will be
+considering a removed file to be a valid thing, and if the file really
+does not exist any more, it will update the index accordingly.
+
+As a special case, you can also do `git-update-index --refresh`, which
+will refresh the "stat" information of each index to match the current
+stat information. It will 'not' update the object status itself, and
+it will only update the fields that are used to quickly test whether
+an object still matches its old backing store object.
+
+index -> object database
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+You write your current index file to a "tree" object with the program
+
+-------------------------------------------------
+$ git-write-tree
+-------------------------------------------------
+
+that doesn't come with any options - it will just write out the
+current index into the set of tree objects that describe that state,
+and it will return the name of the resulting top-level tree. You can
+use that tree to re-generate the index at any time by going in the
+other direction:
+
+object database -> index
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+You read a "tree" file from the object database, and use that to
+populate (and overwrite - don't do this if your index contains any
+unsaved state that you might want to restore later!) your current
+index.  Normal operation is just
+
+-------------------------------------------------
+$ git-read-tree <sha1 of tree>
+-------------------------------------------------
+
+and your index file will now be equivalent to the tree that you saved
+earlier. However, that is only your 'index' file: your working
+directory contents have not been modified.
+
+index -> working directory
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You update your working directory from the index by "checking out"
+files. This is not a very common operation, since normally you'd just
+keep your files updated, and rather than write to your working
+directory, you'd tell the index files about the changes in your
+working directory (i.e. `git-update-index`).
+
+However, if you decide to jump to a new version, or check out somebody
+else's version, or just restore a previous tree, you'd populate your
+index file with read-tree, and then you need to check out the result
+with
+
+-------------------------------------------------
+$ git-checkout-index filename
+-------------------------------------------------
+
+or, if you want to check out all of the index, use `-a`.
+
+NOTE! git-checkout-index normally refuses to overwrite old files, so
+if you have an old version of the tree already checked out, you will
+need to use the "-f" flag ('before' the "-a" flag or the filename) to
+'force' the checkout.
+
+
+Finally, there are a few odds and ends which are not purely moving
+from one representation to the other:
+
+Tying it all together
+~~~~~~~~~~~~~~~~~~~~~
+
+To commit a tree you have instantiated with "git-write-tree", you'd
+create a "commit" object that refers to that tree and the history
+behind it - most notably the "parent" commits that preceded it in
+history.
+
+Normally a "commit" has one parent: the previous state of the tree
+before a certain change was made. However, sometimes it can have two
+or more parent commits, in which case we call it a "merge", due to the
+fact that such a commit brings together ("merges") two or more
+previous states represented by other commits.
+
+In other words, while a "tree" represents a particular directory state
+of a working directory, a "commit" represents that state in "time",
+and explains how we got there.
+
+You create a commit object by giving it the tree that describes the
+state at the time of the commit, and a list of parents:
+
+-------------------------------------------------
+$ git-commit-tree <tree> -p <parent> [-p <parent2> ..]
+-------------------------------------------------
+
+and then giving the reason for the commit on stdin (either through
+redirection from a pipe or file, or by just typing it at the tty).
+
+git-commit-tree will return the name of the object that represents
+that commit, and you should save it away for later use. Normally,
+you'd commit a new `HEAD` state, and while git doesn't care where you
+save the note about that state, in practice we tend to just write the
+result to the file pointed at by `.git/HEAD`, so that we can always see
+what the last committed state was.
+
+Here is an ASCII art by Jon Loeliger that illustrates how
+various pieces fit together.
+
+------------
+
+                     commit-tree
+                      commit obj
+                       +----+
+                       |    |
+                       |    |
+                       V    V
+                    +-----------+
+                    | Object DB |
+                    |  Backing  |
+                    |   Store   |
+                    +-----------+
+                       ^
+           write-tree  |     |
+             tree obj  |     |
+                       |     |  read-tree
+                       |     |  tree obj
+                             V
+                    +-----------+
+                    |   Index   |
+                    |  "cache"  |
+                    +-----------+
+         update-index  ^
+             blob obj  |     |
+                       |     |
+    checkout-index -u  |     |  checkout-index
+             stat      |     |  blob obj
+                             V
+                    +-----------+
+                    |  Working  |
+                    | Directory |
+                    +-----------+
+
+------------
+
+
+Examining the data
+------------------
+
+You can examine the data represented in the object database and the
+index with various helper tools. For every object, you can use
+gitlink:git-cat-file[1] to examine details about the
+object:
+
+-------------------------------------------------
+$ git-cat-file -t <objectname>
+-------------------------------------------------
+
+shows the type of the object, and once you have the type (which is
+usually implicit in where you find the object), you can use
+
+-------------------------------------------------
+$ git-cat-file blob|tree|commit|tag <objectname>
+-------------------------------------------------
+
+to show its contents. NOTE! Trees have binary content, and as a result
+there is a special helper for showing that content, called
+`git-ls-tree`, which turns the binary content into a more easily
+readable form.
+
+It's especially instructive to look at "commit" objects, since those
+tend to be small and fairly self-explanatory. In particular, if you
+follow the convention of having the top commit name in `.git/HEAD`,
+you can do
+
+-------------------------------------------------
+$ git-cat-file commit HEAD
+-------------------------------------------------
+
+to see what the top commit was.
+
+Merging multiple trees
+----------------------
+
+Git helps you do a three-way merge, which you can expand to n-way by
+repeating the merge procedure arbitrary times until you finally
+"commit" the state.  The normal situation is that you'd only do one
+three-way merge (two parents), and commit it, but if you like to, you
+can do multiple parents in one go.
+
+To do a three-way merge, you need the two sets of "commit" objects
+that you want to merge, use those to find the closest common parent (a
+third "commit" object), and then use those commit objects to find the
+state of the directory ("tree" object) at these points.
+
+To get the "base" for the merge, you first look up the common parent
+of two commits with
+
+-------------------------------------------------
+$ git-merge-base <commit1> <commit2>
+-------------------------------------------------
+
+which will return you the commit they are both based on.  You should
+now look up the "tree" objects of those commits, which you can easily
+do with (for example)
+
+-------------------------------------------------
+$ git-cat-file commit <commitname> | head -1
+-------------------------------------------------
+
+since the tree object information is always the first line in a commit
+object.
+
+Once you know the three trees you are going to merge (the one "original"
+tree, aka the common case, and the two "result" trees, aka the branches
+you want to merge), you do a "merge" read into the index. This will
+complain if it has to throw away your old index contents, so you should
+make sure that you've committed those - in fact you would normally
+always do a merge against your last commit (which should thus match what
+you have in your current index anyway).
+
+To do the merge, do
+
+-------------------------------------------------
+$ git-read-tree -m -u <origtree> <yourtree> <targettree>
+-------------------------------------------------
+
+which will do all trivial merge operations for you directly in the
+index file, and you can just write the result out with
+`git-write-tree`.
+
+
+Merging multiple trees, continued
+---------------------------------
+
+Sadly, many merges aren't trivial. If there are files that have
+been added.moved or removed, or if both branches have modified the
+same file, you will be left with an index tree that contains "merge
+entries" in it. Such an index tree can 'NOT' be written out to a tree
+object, and you will have to resolve any such merge clashes using
+other tools before you can write out the result.
+
+You can examine such index state with `git-ls-files --unmerged`
+command.  An example:
+
+------------------------------------------------
+$ git-read-tree -m $orig HEAD $target
+$ git-ls-files --unmerged
+100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1      hello.c
+100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2      hello.c
+100644 cc44c73eb783565da5831b4d820c962954019b69 3      hello.c
+------------------------------------------------
+
+Each line of the `git-ls-files --unmerged` output begins with
+the blob mode bits, blob SHA1, 'stage number', and the
+filename.  The 'stage number' is git's way to say which tree it
+came from: stage 1 corresponds to `$orig` tree, stage 2 `HEAD`
+tree, and stage3 `$target` tree.
+
+Earlier we said that trivial merges are done inside
+`git-read-tree -m`.  For example, if the file did not change
+from `$orig` to `HEAD` nor `$target`, or if the file changed
+from `$orig` to `HEAD` and `$orig` to `$target` the same way,
+obviously the final outcome is what is in `HEAD`.  What the
+above example shows is that file `hello.c` was changed from
+`$orig` to `HEAD` and `$orig` to `$target` in a different way.
+You could resolve this by running your favorite 3-way merge
+program, e.g.  `diff3` or `merge`, on the blob objects from
+these three stages yourself, like this:
+
+------------------------------------------------
+$ git-cat-file blob 263414f... >hello.c~1
+$ git-cat-file blob 06fa6a2... >hello.c~2
+$ git-cat-file blob cc44c73... >hello.c~3
+$ merge hello.c~2 hello.c~1 hello.c~3
+------------------------------------------------
+
+This would leave the merge result in `hello.c~2` file, along
+with conflict markers if there are conflicts.  After verifying
+the merge result makes sense, you can tell git what the final
+merge result for this file is by:
+
+-------------------------------------------------
+$ mv -f hello.c~2 hello.c
+$ git-update-index hello.c
+-------------------------------------------------
+
+When a path is in unmerged state, running `git-update-index` for
+that path tells git to mark the path resolved.
+
+The above is the description of a git merge at the lowest level,
+to help you understand what conceptually happens under the hood.
+In practice, nobody, not even git itself, uses three `git-cat-file`
+for this.  There is `git-merge-index` program that extracts the
+stages to temporary files and calls a "merge" script on it:
+
+-------------------------------------------------
+$ git-merge-index git-merge-one-file hello.c
+-------------------------------------------------
+
+and that is what higher level `git resolve` is implemented with.
+
+How git stores objects efficiently: pack files
+----------------------------------------------
+
+We've seen how git stores each object in a file named after the
+object's SHA1 hash.
+
+Unfortunately this system becomes inefficient once a project has a
+lot of objects.  Try this on an old project:
+
+------------------------------------------------
+$ git count-objects
+6930 objects, 47620 kilobytes
+------------------------------------------------
+
+The first number is the number of objects which are kept in
+individual files.  The second is the amount of space taken up by
+those "loose" objects.
+
+You can save space and make git faster by moving these loose objects in
+to a "pack file", which stores a group of objects in an efficient
+compressed format; the details of how pack files are formatted can be
+found in link:technical/pack-format.txt[technical/pack-format.txt].
+
+To put the loose objects into a pack, just run git repack:
+
+------------------------------------------------
+$ git repack
+Generating pack...
+Done counting 6020 objects.
+Deltifying 6020 objects.
+ 100% (6020/6020) done
+Writing 6020 objects.
+ 100% (6020/6020) done
+Total 6020, written 6020 (delta 4070), reused 0 (delta 0)
+Pack pack-3e54ad29d5b2e05838c75df582c65257b8d08e1c created.
+------------------------------------------------
+
+You can then run
+
+------------------------------------------------
+$ git prune
+------------------------------------------------
+
+to remove any of the "loose" objects that are now contained in the
+pack.  This will also remove any unreferenced objects (which may be
+created when, for example, you use "git reset" to remove a commit).
+You can verify that the loose objects are gone by looking at the
+.git/objects directory or by running
+
+------------------------------------------------
+$ git count-objects
+0 objects, 0 kilobytes
+------------------------------------------------
+
+Although the object files are gone, any commands that refer to those
+objects will work exactly as they did before.
+
+The gitlink:git-gc[1] command performs packing, pruning, and more for
+you, so is normally the only high-level command you need.
+
+[[dangling-objects]]
+Dangling objects
+----------------
+
+The gitlink:git-fsck[1] command will sometimes complain about dangling
+objects.  They are not a problem.
+
+The most common cause of dangling objects is that you've rebased a
+branch, or you have pulled from somebody else who rebased a branch--see
+<<cleaning-up-history>>.  In that case, the old head of the original
+branch still exists, as does obviously everything it pointed to. The
+branch pointer itself just doesn't, since you replaced it with another
+one.
+
+There are also other situations too that cause dangling objects. For
+example, a "dangling blob" may arise because you did a "git add" of a
+file, but then, before you actually committed it and made it part of the
+bigger picture, you changed something else in that file and committed
+that *updated* thing - the old state that you added originally ends up
+not being pointed to by any commit or tree, so it's now a dangling blob
+object.
+
+Similarly, when the "recursive" merge strategy runs, and finds that
+there are criss-cross merges and thus more than one merge base (which is
+fairly unusual, but it does happen), it will generate one temporary
+midway tree (or possibly even more, if you had lots of criss-crossing
+merges and more than two merge bases) as a temporary internal merge
+base, and again, those are real objects, but the end result will not end
+up pointing to them, so they end up "dangling" in your repository.
+
+Generally, dangling objects aren't anything to worry about. They can
+even be very useful: if you screw something up, the dangling objects can
+be how you recover your old tree (say, you did a rebase, and realized
+that you really didn't want to - you can look at what dangling objects
+you have, and decide to reset your head to some old dangling state).
+
+For commits, the most useful thing to do with dangling objects tends to
+be to do a simple
+
+------------------------------------------------
+$ gitk <dangling-commit-sha-goes-here> --not --all
+------------------------------------------------
+
+For blobs and trees, you can't do the same, but you can examine them.
+You can just do
+
+------------------------------------------------
+$ git show <dangling-blob/tree-sha-goes-here>
+------------------------------------------------
+
+to show what the contents of the blob were (or, for a tree, basically
+what the "ls" for that directory was), and that may give you some idea
+of what the operation was that left that dangling object.
+
+Usually, dangling blobs and trees aren't very interesting. They're
+almost always the result of either being a half-way mergebase (the blob
+will often even have the conflict markers from a merge in it, if you
+have had conflicting merges that you fixed up by hand), or simply
+because you interrupted a "git fetch" with ^C or something like that,
+leaving _some_ of the new objects in the object database, but just
+dangling and useless.
+
+Anyway, once you are sure that you're not interested in any dangling 
+state, you can just prune all unreachable objects:
+
+------------------------------------------------
+$ git prune
+------------------------------------------------
+
+and they'll be gone. But you should only run "git prune" on a quiescent
+repository - it's kind of like doing a filesystem fsck recovery: you
+don't want to do that while the filesystem is mounted.
+
+(The same is true of "git-fsck" itself, btw - but since 
+git-fsck never actually *changes* the repository, it just reports 
+on what it found, git-fsck itself is never "dangerous" to run. 
+Running it while somebody is actually changing the repository can cause 
+confusing and scary messages, but it won't actually do anything bad. In 
+contrast, running "git prune" while somebody is actively changing the 
+repository is a *BAD* idea).
+
+Glossary of git terms
+=====================
+
+include::glossary.txt[]
+
+Notes and todo list for this manual
+===================================
+
+This is a work in progress.
+
+The basic requirements:
+       - It must be readable in order, from beginning to end, by
+         someone intelligent with a basic grasp of the unix
+         commandline, but without any special knowledge of git.  If
+         necessary, any other prerequisites should be specifically
+         mentioned as they arise.
+       - Whenever possible, section headings should clearly describe
+         the task they explain how to do, in language that requires
+         no more knowledge than necessary: for example, "importing
+         patches into a project" rather than "the git-am command"
+
+Think about how to create a clear chapter dependency graph that will
+allow people to get to important topics without necessarily reading
+everything in between.
+
+Say something about .gitignore.
+
+Scan Documentation/ for other stuff left out; in particular:
+       howto's
+       some of technical/?
+       hooks
+       list of commands in gitlink:git[1]
+
+Scan email archives for other stuff left out
+
+Scan man pages to see if any assume more background than this manual
+provides.
+
+Simplify beginning by suggesting disconnected head instead of
+temporary branch creation?
+
+Explain how to refer to file stages in the "how to resolve a merge"
+section: diff -1, -2, -3, --ours, --theirs :1:/path notation.  The
+"git ls-files --unmerged --stage" thing is sorta useful too,
+actually.  And note gitk --merge.
+
+Add more good examples.  Entire sections of just cookbook examples
+might be a good idea; maybe make an "advanced examples" section a
+standard end-of-chapter section?
+
+Include cross-references to the glossary, where appropriate.
+
+Document shallow clones?  See draft 1.5.0 release notes for some
+documentation.
+
+Add a section on working with other version control systems, including
+CVS, Subversion, and just imports of series of release tarballs.
+
+More details on gitweb?
+
+Write a chapter on using plumbing and writing scripts.
index e0adc340d3116cb1dfe8741a17d6b1b1cc2d7c97..8f266d0859133002ebca5c923fb2ed925d5639b3 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v1.5.0-rc2.GIT
+DEF_VER=v1.5.0-rc3.GIT
 
 LF='
 '
index a00c5ab42690aebff8d15d3391928f42d24d852d..5d31e6d46dc6d879713c63fce39fcbb05194ee55 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -219,8 +219,7 @@ BUILT_INS = \
        $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
 
 # what 'all' will build and 'install' will install, in gitexecdir
-ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) \
-       git-merge-recur$X
+ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
 
 # Backward compatibility -- to be removed after 1.0
 PROGRAMS += git-ssh-pull$X git-ssh-push$X
@@ -505,7 +504,7 @@ ifdef NO_D_INO_IN_DIRENT
        BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
 endif
 ifdef NO_C99_FORMAT
-       ALL_CFLAGS += -DNO_C99_FORMAT
+       BASIC_CFLAGS += -DNO_C99_FORMAT
 endif
 ifdef NO_SYMLINK_HEAD
        BASIC_CFLAGS += -DNO_SYMLINK_HEAD
@@ -627,9 +626,6 @@ git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS
 
 help.o: common-cmds.h
 
-git-merge-recur$X: git-merge-recursive$X
-       rm -f $@ && ln git-merge-recursive$X $@
-
 $(BUILT_INS): git$X
        rm -f $@ && ln git$X $@
 
@@ -936,7 +932,7 @@ check-docs::
        do \
                case "$$v" in \
                git-merge-octopus | git-merge-ours | git-merge-recursive | \
-               git-merge-resolve | git-merge-stupid | git-merge-recur | \
+               git-merge-resolve | git-merge-stupid | \
                git-ssh-pull | git-ssh-push ) continue ;; \
                esac ; \
                test -f "Documentation/$$v.txt" || \
index 57c46840d542f31dd4e42455140fc901f1eeb671..9db7cfe74c7a8583995e6c20c4eedebf58391fbc 100644 (file)
@@ -12,7 +12,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix)
        int i;
        nargv = xmalloc(sizeof(char *) * (argc + 2));
 
-       nargv[0] = "blame";
+       nargv[0] = "annotate";
        nargv[1] = "-c";
 
        for (i = 1; i < argc; i++) {
index 3033e9bdad55bdccc560a10996620654fe2c9b7e..69fc145a38090488e8da4b60a56154fc999b6fe5 100644 (file)
 #include "revision.h"
 #include "quote.h"
 #include "xdiff-interface.h"
+#include "cache-tree.h"
 
 static char blame_usage[] =
-"git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [commit] [--] file\n"
+"git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [--contents <filename>] [--incremental] [commit] [--] file\n"
 "  -c, --compatibility Use the same output mode as git-annotate (Default: off)\n"
 "  -b                  Show blank SHA-1 for boundary commits (Default: off)\n"
 "  -l, --long          Show long commit SHA1 (Default: off)\n"
@@ -29,6 +30,7 @@ static char blame_usage[] =
 "  -L n,m              Process only line range n,m, counting from 1\n"
 "  -M, -C              Find line movements within and across files\n"
 "  --incremental       Show blame entries as we find them, incrementally\n"
+"  --contents file     Use <file>'s contents as the final image\n"
 "  -S revs-file        Use revisions from revs-file instead of calling git-rev-list\n";
 
 static int longest_file;
@@ -39,6 +41,7 @@ static int max_score_digits;
 static int show_root;
 static int blank_boundary;
 static int incremental;
+static int cmd_is_annotate;
 
 #ifndef DEBUG
 #define DEBUG 0
@@ -333,9 +336,13 @@ static struct origin *find_origin(struct scoreboard *sb,
        diff_tree_setup_paths(paths, &diff_opts);
        if (diff_setup_done(&diff_opts) < 0)
                die("diff-setup");
-       diff_tree_sha1(parent->tree->object.sha1,
-                      origin->commit->tree->object.sha1,
-                      "", &diff_opts);
+
+       if (is_null_sha1(origin->commit->object.sha1))
+               do_diff_cache(parent->tree->object.sha1, &diff_opts);
+       else
+               diff_tree_sha1(parent->tree->object.sha1,
+                              origin->commit->tree->object.sha1,
+                              "", &diff_opts);
        diffcore_std(&diff_opts);
 
        /* It is either one entry that says "modified", or "created",
@@ -402,9 +409,13 @@ static struct origin *find_rename(struct scoreboard *sb,
        diff_tree_setup_paths(paths, &diff_opts);
        if (diff_setup_done(&diff_opts) < 0)
                die("diff-setup");
-       diff_tree_sha1(parent->tree->object.sha1,
-                      origin->commit->tree->object.sha1,
-                      "", &diff_opts);
+
+       if (is_null_sha1(origin->commit->object.sha1))
+               do_diff_cache(parent->tree->object.sha1, &diff_opts);
+       else
+               diff_tree_sha1(parent->tree->object.sha1,
+                              origin->commit->tree->object.sha1,
+                              "", &diff_opts);
        diffcore_std(&diff_opts);
 
        for (i = 0; i < diff_queued_diff.nr; i++) {
@@ -550,7 +561,7 @@ static void free_patch(struct patch *p)
 }
 
 /*
- * Link in a new blame entry to the scorebord.  Entries that cover the
+ * Link in a new blame entry to the scoreboard.  Entries that cover the
  * same line range have been removed from the scoreboard previously.
  */
 static void add_blame_entry(struct scoreboard *sb, struct blame_entry *e)
@@ -1047,9 +1058,12 @@ static int find_copy_in_parent(struct scoreboard *sb,
            (!porigin || strcmp(target->path, porigin->path)))
                diff_opts.find_copies_harder = 1;
 
-       diff_tree_sha1(parent->tree->object.sha1,
-                      target->commit->tree->object.sha1,
-                      "", &diff_opts);
+       if (is_null_sha1(target->commit->object.sha1))
+               do_diff_cache(parent->tree->object.sha1, &diff_opts);
+       else
+               diff_tree_sha1(parent->tree->object.sha1,
+                              target->commit->tree->object.sha1,
+                              "", &diff_opts);
 
        if (!diff_opts.find_copies_harder)
                diffcore_std(&diff_opts);
@@ -1336,9 +1350,9 @@ static void get_commit_info(struct commit *commit,
        tmp += 2;
        endp = strchr(tmp, '\n');
        if (!endp)
-               goto error_out;
+               endp = tmp + strlen(tmp);
        len = endp - tmp;
-       if (len >= sizeof(summary_buf))
+       if (len >= sizeof(summary_buf) || len == 0)
                goto error_out;
        memcpy(summary_buf, tmp, len);
        summary_buf[len] = 0;
@@ -1392,7 +1406,7 @@ static void found_guilty_entry(struct blame_entry *ent)
 
 /*
  * The main loop -- while the scoreboard has lines whose true origin
- * is still unknown, pick one brame_entry, and allow its current
+ * is still unknown, pick one blame_entry, and allow its current
  * suspect to pass blames to its parents.
  */
 static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
@@ -1541,12 +1555,12 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
                int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? 40 : 8;
 
                if (suspect->commit->object.flags & UNINTERESTING) {
-                       if (!blank_boundary) {
+                       if (blank_boundary)
+                               memset(hex, ' ', length);
+                       else if (!cmd_is_annotate) {
                                length--;
                                putchar('^');
                        }
-                       else
-                               memset(hex, ' ', length);
                }
 
                printf("%.*s", length, hex);
@@ -1910,6 +1924,137 @@ static int git_blame_config(const char *var, const char *value)
        return git_default_config(var, value);
 }
 
+static struct commit *fake_working_tree_commit(const char *path, const char *contents_from)
+{
+       struct commit *commit;
+       struct origin *origin;
+       unsigned char head_sha1[20];
+       char *buf;
+       const char *ident;
+       int fd;
+       time_t now;
+       unsigned long fin_size;
+       int size, len;
+       struct cache_entry *ce;
+       unsigned mode;
+
+       if (get_sha1("HEAD", head_sha1))
+               die("No such ref: HEAD");
+
+       time(&now);
+       commit = xcalloc(1, sizeof(*commit));
+       commit->parents = xcalloc(1, sizeof(*commit->parents));
+       commit->parents->item = lookup_commit_reference(head_sha1);
+       commit->object.parsed = 1;
+       commit->date = now;
+       commit->object.type = OBJ_COMMIT;
+
+       origin = make_origin(commit, path);
+
+       if (!contents_from || strcmp("-", contents_from)) {
+               struct stat st;
+               const char *read_from;
+
+               if (contents_from) {
+                       if (stat(contents_from, &st) < 0)
+                               die("Cannot stat %s", contents_from);
+                       read_from = contents_from;
+               }
+               else {
+                       if (lstat(path, &st) < 0)
+                               die("Cannot lstat %s", path);
+                       read_from = path;
+               }
+               fin_size = st.st_size;
+               buf = xmalloc(fin_size+1);
+               mode = canon_mode(st.st_mode);
+               switch (st.st_mode & S_IFMT) {
+               case S_IFREG:
+                       fd = open(read_from, O_RDONLY);
+                       if (fd < 0)
+                               die("cannot open %s", read_from);
+                       if (read_in_full(fd, buf, fin_size) != fin_size)
+                               die("cannot read %s", read_from);
+                       break;
+               case S_IFLNK:
+                       if (readlink(read_from, buf, fin_size+1) != fin_size)
+                               die("cannot readlink %s", read_from);
+                       break;
+               default:
+                       die("unsupported file type %s", read_from);
+               }
+       }
+       else {
+               /* Reading from stdin */
+               contents_from = "standard input";
+               buf = NULL;
+               fin_size = 0;
+               mode = 0;
+               while (1) {
+                       ssize_t cnt = 8192;
+                       buf = xrealloc(buf, fin_size + cnt);
+                       cnt = xread(0, buf + fin_size, cnt);
+                       if (cnt < 0)
+                               die("read error %s from stdin",
+                                   strerror(errno));
+                       if (!cnt)
+                               break;
+                       fin_size += cnt;
+               }
+               buf = xrealloc(buf, fin_size + 1);
+       }
+       buf[fin_size] = 0;
+       origin->file.ptr = buf;
+       origin->file.size = fin_size;
+       pretend_sha1_file(buf, fin_size, blob_type, origin->blob_sha1);
+       commit->util = origin;
+
+       /*
+        * Read the current index, replace the path entry with
+        * origin->blob_sha1 without mucking with its mode or type
+        * bits; we are not going to write this index out -- we just
+        * want to run "diff-index --cached".
+        */
+       discard_cache();
+       read_cache();
+
+       len = strlen(path);
+       if (!mode) {
+               int pos = cache_name_pos(path, len);
+               if (0 <= pos)
+                       mode = ntohl(active_cache[pos]->ce_mode);
+               else
+                       /* Let's not bother reading from HEAD tree */
+                       mode = S_IFREG | 0644;
+       }
+       size = cache_entry_size(len);
+       ce = xcalloc(1, size);
+       hashcpy(ce->sha1, origin->blob_sha1);
+       memcpy(ce->name, path, len);
+       ce->ce_flags = create_ce_flags(len, 0);
+       ce->ce_mode = create_ce_mode(mode);
+       add_cache_entry(ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
+
+       /*
+        * We are not going to write this out, so this does not matter
+        * right now, but someday we might optimize diff-index --cached
+        * with cache-tree information.
+        */
+       cache_tree_invalidate_path(active_cache_tree, path);
+
+       commit->buffer = xmalloc(400);
+       ident = fmt_ident("Not Committed Yet", "not.committed.yet", NULL, 0);
+       sprintf(commit->buffer,
+               "tree 0000000000000000000000000000000000000000\n"
+               "parent %s\n"
+               "author %s\n"
+               "committer %s\n\n"
+               "Version of %s from %s\n",
+               sha1_to_hex(head_sha1),
+               ident, ident, path, contents_from ? contents_from : path);
+       return commit;
+}
+
 int cmd_blame(int argc, const char **argv, const char *prefix)
 {
        struct rev_info revs;
@@ -1924,6 +2069,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
        const char *final_commit_name = NULL;
        char type[10];
        const char *bottomtop = NULL;
+       const char *contents_from = NULL;
+
+       cmd_is_annotate = !strcmp(argv[0], "annotate");
 
        git_config(git_blame_config);
        save_commit_buffer = 0;
@@ -1968,6 +2116,11 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
                                die("More than one '-L n,m' option given");
                        bottomtop = arg;
                }
+               else if (!strcmp("--contents", arg)) {
+                       if (++i >= argc)
+                               usage(blame_usage);
+                       contents_from = argv[i];
+               }
                else if (!strcmp("--incremental", arg))
                        incremental = 1;
                else if (!strcmp("--score-debug", arg))
@@ -2001,7 +2154,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
        /*
         * We have collected options unknown to us in argv[1..unk]
         * which are to be passed to revision machinery if we are
-        * going to do the "bottom" procesing.
+        * going to do the "bottom" processing.
         *
         * The remaining are:
         *
@@ -2087,7 +2240,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
        argv[unk] = NULL;
 
        init_revisions(&revs, NULL);
-       setup_revisions(unk, argv, &revs, "HEAD");
+       setup_revisions(unk, argv, &revs, NULL);
        memset(&sb, 0, sizeof(sb));
 
        /*
@@ -2114,16 +2267,14 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
        if (!sb.final) {
                /*
                 * "--not A B -- path" without anything positive;
-                * default to HEAD.
+                * do not default to HEAD, but use the working tree
+                * or "--contents".
                 */
-               unsigned char head_sha1[20];
-
-               final_commit_name = "HEAD";
-               if (get_sha1(final_commit_name, head_sha1))
-                       die("No such ref: HEAD");
-               sb.final = lookup_commit_reference(head_sha1);
-               add_pending_object(&revs, &(sb.final->object), "HEAD");
+               sb.final = fake_working_tree_commit(path, contents_from);
+               add_pending_object(&revs, &(sb.final->object), ":");
        }
+       else if (contents_from)
+               die("Cannot use --contents with final commit object name");
 
        /*
         * If we have bottom, this will mark the ancestors of the
@@ -2132,11 +2283,22 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
         */
        prepare_revision_walk(&revs);
 
-       o = get_origin(&sb, sb.final, path);
-       if (fill_blob_sha1(o))
-               die("no such path %s in %s", path, final_commit_name);
+       if (is_null_sha1(sb.final->object.sha1)) {
+               char *buf;
+               o = sb.final->util;
+               buf = xmalloc(o->file.size + 1);
+               memcpy(buf, o->file.ptr, o->file.size + 1);
+               sb.final_buf = buf;
+               sb.final_buf_size = o->file.size;
+       }
+       else {
+               o = get_origin(&sb, sb.final, path);
+               if (fill_blob_sha1(o))
+                       die("no such path %s in %s", path, final_commit_name);
 
-       sb.final_buf = read_sha1_file(o->blob_sha1, type, &sb.final_buf_size);
+               sb.final_buf = read_sha1_file(o->blob_sha1, type,
+                                             &sb.final_buf_size);
+       }
        num_read_blob++;
        lno = prepare_lines(&sb);
 
index d60690bb084ef83ce99a56453ae9dfa56da12807..2d8d61b453ede72b8d0319cb192f9f06a024d8c0 100644 (file)
@@ -316,6 +316,7 @@ static void create_branch(const char *name, const char *start_name,
        struct commit *commit;
        unsigned char sha1[20];
        char ref[PATH_MAX], msg[PATH_MAX + 20];
+       int forcing = 0;
 
        snprintf(ref, sizeof ref, "refs/heads/%s", name);
        if (check_ref_format(ref))
@@ -326,6 +327,7 @@ static void create_branch(const char *name, const char *start_name,
                        die("A branch named '%s' already exists.", name);
                else if (!is_bare_repository() && !strcmp(head, name))
                        die("Cannot force update the current branch.");
+               forcing = 1;
        }
 
        if (start_sha1)
@@ -342,11 +344,15 @@ static void create_branch(const char *name, const char *start_name,
        if (!lock)
                die("Failed to lock ref for update: %s.", strerror(errno));
 
-       if (reflog) {
+       if (reflog)
                log_all_ref_updates = 1;
+
+       if (forcing)
+               snprintf(msg, sizeof msg, "branch: Reset from %s",
+                        start_name);
+       else
                snprintf(msg, sizeof msg, "branch: Created from %s",
                         start_name);
-       }
 
        if (write_ref_sha1(lock, sha1, msg) < 0)
                die("Failed to write ref: %s.", strerror(errno));
@@ -358,7 +364,7 @@ static void rename_branch(const char *oldname, const char *newname, int force)
        unsigned char sha1[20];
 
        if (!oldname)
-               die("cannot rename the curren branch while not on any.");
+               die("cannot rename the current branch while not on any.");
 
        if (snprintf(oldref, sizeof(oldref), "refs/heads/%s", oldname) > sizeof(oldref))
                die("Old branchname too long");
@@ -381,7 +387,8 @@ static void rename_branch(const char *oldname, const char *newname, int force)
        if (rename_ref(oldref, newref, logmsg))
                die("Branch rename failed");
 
-       if (!strcmp(oldname, head) && create_symref("HEAD", newref))
+       /* no need to pass logmsg here as HEAD didn't really move */
+       if (!strcmp(oldname, head) && create_symref("HEAD", newref, NULL))
                die("Branch renamed to %s, but HEAD is not updated!", newname);
 }
 
index 9d5f266dc4e06de99aa998c2ed3d220b246db812..16c785f0477f2688632f3b67e39083f60e48b2db 100644 (file)
@@ -135,7 +135,7 @@ static const char *find_next(const char *cp)
        while (*cp) {
                if (*cp == '%') {
                        /* %( is the start of an atom;
-                        * %% is a quoteed per-cent.
+                        * %% is a quoted per-cent.
                         */
                        if (cp[1] == '(')
                                return cp;
index fec1cbd784f598342eb44f385a55dba25a0b9021..6da3814d59a2c04cbcc9853035f5d72c0a3a4928 100644 (file)
@@ -117,7 +117,7 @@ static void check_unreachable_object(struct object *obj)
 
        /*
         * "!used" means that nothing at all points to it, including
-        * other unreacahble objects. In other words, it's the "tip"
+        * other unreachable objects. In other words, it's the "tip"
         * of some set of unreachable objects, usually a commit that
         * got dropped.
         *
@@ -477,6 +477,12 @@ static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
        return 0;
 }
 
+static int fsck_handle_reflog(const char *logname, const unsigned char *sha1, int flag, void *cb_data)
+{
+       for_each_reflog_ent(logname, fsck_handle_reflog_ent, NULL);
+       return 0;
+}
+
 static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
 {
        struct object *obj;
@@ -495,14 +501,13 @@ static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int f
        obj->used = 1;
        mark_reachable(obj, REACHABLE);
 
-       for_each_reflog_ent(refname, fsck_handle_reflog_ent, NULL);
-
        return 0;
 }
 
 static void get_default_heads(void)
 {
        for_each_ref(fsck_handle_ref, NULL);
+       for_each_reflog(fsck_handle_reflog, NULL);
 
        /*
         * Not having any default heads isn't really fatal, but
index 186548938193ac125d9d9f89080cec640d0a46e0..12e43d0db4df0c40fe6375b38691684efcddad18 100644 (file)
@@ -231,7 +231,7 @@ static int create_default_files(const char *git_dir, const char *template_path)
        strcpy(path + len, "HEAD");
        reinit = !read_ref("HEAD", sha1);
        if (!reinit) {
-               if (create_symref("HEAD", "refs/heads/master") < 0)
+               if (create_symref("HEAD", "refs/heads/master", NULL) < 0)
                        exit(1);
        }
 
index 21c2a6e2d9b68c0c3bcfac824e85c7b392c72486..ac89eb2f770d3b8dbc35ee2c24d9d6c82b8fb6fe 100644 (file)
@@ -323,7 +323,7 @@ static const char ls_files_usage[] =
 int cmd_ls_files(int argc, const char **argv, const char *prefix)
 {
        int i;
-       int exc_given = 0;
+       int exc_given = 0, require_work_tree = 0;
        struct dir_struct dir;
 
        memset(&dir, 0, sizeof(dir));
@@ -363,14 +363,17 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
                }
                if (!strcmp(arg, "-m") || !strcmp(arg, "--modified")) {
                        show_modified = 1;
+                       require_work_tree = 1;
                        continue;
                }
                if (!strcmp(arg, "-o") || !strcmp(arg, "--others")) {
                        show_others = 1;
+                       require_work_tree = 1;
                        continue;
                }
                if (!strcmp(arg, "-i") || !strcmp(arg, "--ignored")) {
                        dir.show_ignored = 1;
+                       require_work_tree = 1;
                        continue;
                }
                if (!strcmp(arg, "-s") || !strcmp(arg, "--stage")) {
@@ -379,6 +382,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
                }
                if (!strcmp(arg, "-k") || !strcmp(arg, "--killed")) {
                        show_killed = 1;
+                       require_work_tree = 1;
                        continue;
                }
                if (!strcmp(arg, "--directory")) {
@@ -447,6 +451,10 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
                break;
        }
 
+       if (require_work_tree &&
+                       (is_bare_repository() || is_inside_git_dir()))
+               die("This operation must be run in a work tree");
+
        pathspec = get_pathspec(prefix, argv + i);
 
        /* Verify that the pathspec matches the prefix */
index 5f4d7d34d35da35f0c843962f1ca1ae61a575456..c45649e26cf5284323aa80a5fe73b5842346eb14 100644 (file)
@@ -54,38 +54,84 @@ static void expand_refspecs(void)
        for_each_ref(expand_one_ref, NULL);
 }
 
+struct wildcard_cb {
+       const char *from_prefix;
+       int from_prefix_len;
+       const char *to_prefix;
+       int to_prefix_len;
+       int force;
+};
+
+static int expand_wildcard_ref(const char *ref, const unsigned char *sha1, int flag, void *cb_data)
+{
+       struct wildcard_cb *cb = cb_data;
+       int len = strlen(ref);
+       char *expanded, *newref;
+
+       if (len < cb->from_prefix_len ||
+           memcmp(cb->from_prefix, ref, cb->from_prefix_len))
+               return 0;
+       expanded = xmalloc(len * 2 + cb->force +
+                          (cb->to_prefix_len - cb->from_prefix_len) + 2);
+       newref = expanded + cb->force;
+       if (cb->force)
+               expanded[0] = '+';
+       memcpy(newref, ref, len);
+       newref[len] = ':';
+       memcpy(newref + len + 1, cb->to_prefix, cb->to_prefix_len);
+       strcpy(newref + len + 1 + cb->to_prefix_len,
+              ref + cb->from_prefix_len);
+       add_refspec(expanded);
+       return 0;
+}
+
+static int wildcard_ref(const char *ref)
+{
+       int len;
+       const char *colon;
+       struct wildcard_cb cb;
+
+       memset(&cb, 0, sizeof(cb));
+       if (ref[0] == '+') {
+               cb.force = 1;
+               ref++;
+       }
+       len = strlen(ref);
+       colon = strchr(ref, ':');
+       if (! (colon && ref < colon &&
+              colon[-2] == '/' && colon[-1] == '*' &&
+              /* "<mine>/<asterisk>:<yours>/<asterisk>" is at least 7 bytes */
+              7 <= len &&
+              ref[len-2] == '/' && ref[len-1] == '*') )
+               return 0 ;
+       cb.from_prefix = ref;
+       cb.from_prefix_len = colon - ref - 1;
+       cb.to_prefix = colon + 1;
+       cb.to_prefix_len = len - (colon - ref) - 2;
+       for_each_ref(expand_wildcard_ref, &cb);
+       return 1;
+}
+
 static void set_refspecs(const char **refs, int nr)
 {
        if (nr) {
-               int pass;
-               for (pass = 0; pass < 2; pass++) {
-                       /* pass 0 counts and allocates, pass 1 fills */
-                       int i, cnt;
-                       for (i = cnt = 0; i < nr; i++) {
-                               if (!strcmp("tag", refs[i])) {
-                                       int len;
-                                       char *tag;
-                                       if (nr <= ++i)
-                                               die("tag <tag> shorthand without <tag>");
-                                       if (pass) {
-                                               len = strlen(refs[i]) + 11;
-                                               tag = xmalloc(len);
-                                               strcpy(tag, "refs/tags/");
-                                               strcat(tag, refs[i]);
-                                               refspec[cnt] = tag;
-                                       }
-                                       cnt++;
-                                       continue;
-                               }
-                               if (pass)
-                                       refspec[cnt] = refs[i];
-                               cnt++;
-                       }
-                       if (!pass) {
-                               size_t bytes = cnt * sizeof(char *);
-                               refspec_nr = cnt;
-                               refspec = xrealloc(refspec, bytes);
+               int i;
+               for (i = 0; i < nr; i++) {
+                       const char *ref = refs[i];
+                       if (!strcmp("tag", ref)) {
+                               char *tag;
+                               int len;
+                               if (nr <= ++i)
+                                       die("tag shorthand without <tag>");
+                               len = strlen(refs[i]) + 11;
+                               tag = xmalloc(len);
+                               strcpy(tag, "refs/tags/");
+                               strcat(tag, refs[i]);
+                               ref = tag;
                        }
+                       else if (wildcard_ref(ref))
+                               continue;
+                       add_refspec(ref);
                }
        }
        expand_refspecs();
@@ -129,8 +175,10 @@ static int get_remotes_uri(const char *repo, const char *uri[MAX_URI])
                        else
                                error("more than %d URL's specified, ignoring the rest", MAX_URI);
                }
-               else if (is_refspec && !has_explicit_refspec)
-                       add_refspec(xstrdup(s));
+               else if (is_refspec && !has_explicit_refspec) {
+                       if (!wildcard_ref(s))
+                               add_refspec(xstrdup(s));
+               }
        }
        fclose(f);
        if (!n)
@@ -156,8 +204,10 @@ static int get_remote_config(const char* key, const char* value)
                                error("more than %d URL's specified, ignoring the rest", MAX_URI);
                }
                else if (config_get_refspecs &&
-                        !strcmp(key + 7 + config_repo_len, ".push"))
-                       add_refspec(xstrdup(value));
+                        !strcmp(key + 7 + config_repo_len, ".push")) {
+                       if (!wildcard_ref(value))
+                               add_refspec(xstrdup(value));
+               }
                else if (config_get_receivepack &&
                         !strcmp(key + 7 + config_repo_len, ".receivepack")) {
                        if (!receivepack) {
index b443ed9ef6936294e827a2700af80484f8a98506..bfb169ac04a3bddbe7afe79efc25e5ef3de59319 100644 (file)
@@ -242,20 +242,18 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
        struct cmd_reflog_expire_cb *cmd = cb_data;
        struct expire_reflog_cb cb;
        struct ref_lock *lock;
-       char *newlog_path = NULL;
+       char *log_file, *newlog_path = NULL;
        int status = 0;
 
-       if (strncmp(ref, "refs/", 5))
-               return error("not a ref '%s'", ref);
-
        memset(&cb, 0, sizeof(cb));
        /* we take the lock for the ref itself to prevent it from
         * getting updated.
         */
-       lock = lock_ref_sha1(ref + 5, sha1);
+       lock = lock_any_ref_for_update(ref, sha1);
        if (!lock)
                return error("cannot lock ref '%s'", ref);
-       if (!file_exists(lock->log_file))
+       log_file = xstrdup(git_path("logs/%s", ref));
+       if (!file_exists(log_file))
                goto finish;
        if (!cmd->dry_run) {
                newlog_path = xstrdup(git_path("logs/%s.lock", ref));
@@ -271,13 +269,14 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
                if (fclose(cb.newlog))
                        status |= error("%s: %s", strerror(errno),
                                        newlog_path);
-               if (rename(newlog_path, lock->log_file)) {
+               if (rename(newlog_path, log_file)) {
                        status |= error("cannot rename %s to %s",
-                                       newlog_path, lock->log_file);
+                                       newlog_path, log_file);
                        unlink(newlog_path);
                }
        }
        free(newlog_path);
+       free(log_file);
        unlock_ref(lock);
        return status;
 }
@@ -351,7 +350,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
        }
 
        if (do_all)
-               status |= for_each_ref(expire_reflog, &cb);
+               status |= for_each_reflog(expire_reflog, &cb);
        while (i < argc) {
                const char *ref = argv[i++];
                unsigned char sha1[20];
index 3b716fba133ae2f0375ef73d6a50a4d93112b5e4..d53deaa3691c7b57e215f3f33c44881c4f397527 100644 (file)
@@ -347,6 +347,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                printf("%s/.git\n", cwd);
                                continue;
                        }
+                       if (!strcmp(arg, "--is-inside-git-dir")) {
+                               printf("%s\n", is_inside_git_dir() ? "true"
+                                               : "false");
+                               continue;
+                       }
                        if (!strncmp(arg, "--since=", 8)) {
                                show_datestring("--max-age=", arg+8);
                                continue;
index fa62e487b186adc72ac41aacca31b4f4c8baefa9..0d94e40df893ee6ecf146e8987c0696cb4874a36 100644 (file)
@@ -690,7 +690,10 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 
                if (ac == 0) {
                        static const char *fake_av[2];
-                       fake_av[0] = "HEAD";
+                       const char *refname;
+
+                       refname = resolve_ref("HEAD", sha1, 1, NULL);
+                       fake_av[0] = xstrdup(refname);
                        fake_av[1] = NULL;
                        av = fake_av;
                        ac = 1;
index 227c9d4a6274871b52420221d9d088bb3ac5554f..d41b40640b96e7d5568174c7d16088c29d361d42 100644 (file)
@@ -3,7 +3,7 @@
 #include "refs.h"
 
 static const char git_symbolic_ref_usage[] =
-"git-symbolic-ref [-q] name [ref]";
+"git-symbolic-ref [-q] [-m <reason>] name [ref]";
 
 static void check_symref(const char *HEAD, int quiet)
 {
@@ -25,6 +25,7 @@ static void check_symref(const char *HEAD, int quiet)
 int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
 {
        int quiet = 0;
+       const char *msg = NULL;
 
        git_config(git_default_config);
 
@@ -34,6 +35,17 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
                        break;
                else if (!strcmp("-q", arg))
                        quiet = 1;
+               else if (!strcmp("-m", arg)) {
+                       argc--;
+                       argv++;
+                       if (argc <= 1)
+                               break;
+                       msg = argv[1];
+                       if (!*msg)
+                               die("Refusing to perform update with empty message");
+                       if (strchr(msg, '\n'))
+                               die("Refusing to perform update with \\n in message");
+               }
                else if (!strcmp("--", arg)) {
                        argc--;
                        argv++;
@@ -50,7 +62,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
                check_symref(argv[1], quiet);
                break;
        case 3:
-               create_symref(argv[1], argv[2]);
+               create_symref(argv[1], argv[2], msg);
                break;
        default:
                usage(git_symbolic_ref_usage);
index 182331d34156dd6b88d16a068efad591e07ae6b3..1ac613a78869e5b0a2ac45ca6ab72adc18a55575 100644 (file)
@@ -501,6 +501,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 
        for (i = 1 ; i < argc; i++) {
                const char *path = argv[i];
+               const char *p;
 
                if (allow_options && *path == '-') {
                        if (!strcmp(path, "--")) {
@@ -616,9 +617,12 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
                                usage(update_index_usage);
                        die("unknown option %s", path);
                }
-               update_one(path, prefix, prefix_length);
+               p = prefix_path(prefix, prefix_length, path);
+               update_one(p, NULL, 0);
                if (set_executable_bit)
-                       chmod_path(set_executable_bit, path);
+                       chmod_path(set_executable_bit, p);
+               if (p < path || p > path + strlen(path))
+                       free((char*)p);
        }
        if (read_from_stdin) {
                struct strbuf buf;
diff --git a/cache.h b/cache.h
index 9873ee97d93f7e4b6809262469f228c53339d080..87142571b3a7abe7772386afebad73e69ac9540e 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -257,6 +257,7 @@ extern void * unpack_sha1_file(void *map, unsigned long mapsize, char *type, uns
 extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size);
 extern int hash_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *sha1);
 extern int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
+extern int pretend_sha1_file(void *, unsigned long, const char *, unsigned char *);
 
 extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
 
@@ -302,7 +303,7 @@ extern int read_ref(const char *filename, unsigned char *sha1);
 extern const char *resolve_ref(const char *path, unsigned char *sha1, int, int *);
 extern int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref);
 
-extern int create_symref(const char *ref, const char *refs_heads_master);
+extern int create_symref(const char *ref, const char *refs_heads_master, const char *logmsg);
 extern int validate_headref(const char *ref);
 
 extern int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);
@@ -321,6 +322,7 @@ unsigned long approxidate(const char *);
 
 extern const char *git_author_info(int);
 extern const char *git_committer_info(int);
+extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int);
 
 struct checkout {
        const char *base_dir;
index 29d0c9cf953fdc13bd44bef451d242c762e1c611..a5f2c8dd4a414e513d0421f9a499d06c73ecaf5a 100644 (file)
@@ -482,11 +482,11 @@ static int make_hunks(struct sline *sline, unsigned long cnt,
        return has_interesting;
 }
 
-static void show_parent_lno(struct sline *sline, unsigned long l0, unsigned long l1, int n)
+static void show_parent_lno(struct sline *sline, unsigned long l0, unsigned long l1, int n, unsigned long null_context)
 {
        l0 = sline[l0].p_lno[n];
        l1 = sline[l1].p_lno[n];
-       printf(" -%lu,%lu", l0, l1-l0);
+       printf(" -%lu,%lu", l0, l1-l0-null_context);
 }
 
 static int hunk_comment_line(const char *bol)
@@ -519,6 +519,7 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
                unsigned long hunk_end;
                unsigned long rlines;
                const char *hunk_comment = NULL;
+               unsigned long null_context = 0;
 
                while (lno <= cnt && !(sline[lno].flag & mark)) {
                        if (hunk_comment_line(sline[lno].bol))
@@ -535,10 +536,28 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
                rlines = hunk_end - lno;
                if (cnt < hunk_end)
                        rlines--; /* pointing at the last delete hunk */
+
+               if (!context) {
+                       /*
+                        * Even when running with --unified=0, all
+                        * lines in the hunk needs to be processed in
+                        * the loop below in order to show the
+                        * deletion recorded in lost_head.  However,
+                        * we do not want to show the resulting line
+                        * with all blank context markers in such a
+                        * case.  Compensate.
+                        */
+                       unsigned long j;
+                       for (j = lno; j < hunk_end; j++)
+                               if (!(sline[j].flag & (mark-1)))
+                                       null_context++;
+                       rlines -= null_context;
+               }
+
                fputs(c_frag, stdout);
                for (i = 0; i <= num_parent; i++) putchar(combine_marker);
                for (i = 0; i < num_parent; i++)
-                       show_parent_lno(sline, lno, hunk_end, i);
+                       show_parent_lno(sline, lno, hunk_end, i, null_context);
                printf(" +%lu,%lu ", lno+1, rlines);
                for (i = 0; i <= num_parent; i++) putchar(combine_marker);
 
@@ -578,8 +597,15 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
                        if (cnt < lno)
                                break;
                        p_mask = 1;
-                       if (!(sl->flag & (mark-1)))
+                       if (!(sl->flag & (mark-1))) {
+                               /*
+                                * This sline was here to hang the
+                                * lost lines in front of it.
+                                */
+                               if (!context)
+                                       continue;
                                fputs(c_plain, stdout);
+                       }
                        else
                                fputs(c_new, stdout);
                        for (j = 0; j < num_parent; j++) {
index 9b2b842e7dcc153a12b35394a2e3f88f146b6225..3e8c87294bc9e0cdbab40d485f75e3980ae4ff10 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -47,7 +47,8 @@ enum cmit_fmt get_commit_format(const char *arg)
        if (*arg == '=')
                arg++;
        for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
-               if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len))
+               if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
+                   !strncmp(arg, cmt_fmts[i].n, strlen(arg)))
                        return cmt_fmts[i].v;
        }
 
index c08c66890f0162fe69452927c48d6835178ed12d..d82107124a53bca99ee65ea31dceb3871bf6796f 100644 (file)
--- a/config.c
+++ b/config.c
@@ -896,7 +896,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
                                if (buf[i] != old_name[j++])
                                        break;
                        }
-                       if (buf[i] == ']') {
+                       if (buf[i] == ']' && old_name[j] == 0) {
                                /* old_name matches */
                                ret++;
                                store.baselen = strlen(new_name);
index 5e9a67c1235cd04cb51f2166b1dd2cf9fdada8eb..807d01fe3d6e7768f82c2b76e0203ed4b71f36fa 100755 (executable)
@@ -3,7 +3,17 @@
 use Gtk2 -init;
 use Gtk2::SimpleList;
 
-my $fn = shift or die "require filename to blame";
+my $hash;
+my $fn;
+if ( @ARGV == 1 ) {
+       $hash = "HEAD";
+       $fn = shift;
+} elsif ( @ARGV == 2 ) {
+       $hash = shift;
+       $fn = shift;
+} else {
+       die "Usage blameview [<rev>] <filename>";
+}
 
 Gtk2::Rc->parse_string(<<'EOS');
 style "treeview_style"
 $fileview->get_column(0)->set_spacing(0);
 $fileview->set_size_request(1024, 768);
 $fileview->set_rules_hint(1);
+$fileview->signal_connect (row_activated => sub {
+               my ($sl, $path, $column) = @_;
+               my $row_ref = $sl->get_row_data_from_path ($path);
+               system("blameview @$row_ref[0] $fn");
+               # $row_ref is now an array ref to the double-clicked row's data.
+               });
 
 my $fh;
-open($fh, '-|', "git cat-file blob HEAD:$fn")
+open($fh, '-|', "git cat-file blob $hash:$fn")
   or die "unable to open $fn: $!";
+
 while(<$fh>) {
   chomp;
   $fileview->{data}->[$.] = ['HEAD', '?', "$fn:$.", $_];
 }
 
 my $blame;
-open($blame, '-|', qw(git blame --incremental --), $fn)
+open($blame, '-|', qw(git blame --incremental --), $fn, $hash)
     or die "cannot start git-blame $fn";
 
 Glib::IO->add_watch(fileno($blame), 'in', \&read_blame_line);
diff --git a/contrib/colordiff/README b/contrib/colordiff/README
deleted file mode 100644 (file)
index 2678fdf..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-This is "colordiff" (http://colordiff.sourceforge.net/) by Dave
-Ewart <davee@sungate.co.uk>, modified specifically for git.
diff --git a/contrib/colordiff/colordiff.perl b/contrib/colordiff/colordiff.perl
deleted file mode 100755 (executable)
index 9566a76..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-#!/usr/bin/perl -w
-#
-# $Id: colordiff.pl,v 1.4.2.10 2004/01/04 15:02:59 daveewart Exp $
-
-########################################################################
-#                                                                      #
-# ColorDiff - a wrapper/replacment for 'diff' producing                #
-#             colourful output                                         #
-#                                                                      #
-# Copyright (C)2002-2004 Dave Ewart (davee@sungate.co.uk)              #
-#                                                                      #
-########################################################################
-#                                                                      #
-# This program is free software; you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation; either version 2 of the License, or    #
-# (at your option) any later version.                                  #
-#                                                                      #
-# This program is distributed in the hope that it will be useful,      #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of       #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        #
-# GNU General Public License for more details.                         #
-#                                                                      #
-# You should have received a copy of the GNU General Public License    #
-# along with this program; if not, write to the Free Software          #
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.            #
-#                                                                      #
-########################################################################
-
-use strict;
-use Getopt::Long qw(:config pass_through);
-use IPC::Open2;
-
-my $app_name     = 'colordiff';
-my $version      = '1.0.4';
-my $author       = 'Dave Ewart';
-my $author_email = 'davee@sungate.co.uk';
-my $app_www      = 'http://colordiff.sourceforge.net/';
-my $copyright    = '(C)2002-2004';
-my $show_banner  = 1;
-
-# ANSI sequences for colours
-my %colour;
-$colour{white}       = "\033[1;37m";
-$colour{yellow}      = "\033[1;33m";
-$colour{green}       = "\033[1;32m";
-$colour{blue}        = "\033[1;34m";
-$colour{cyan}        = "\033[1;36m";
-$colour{red}         = "\033[1;31m";
-$colour{magenta}     = "\033[1;35m";
-$colour{black}       = "\033[1;30m";
-$colour{darkwhite}   = "\033[0;37m";
-$colour{darkyellow}  = "\033[0;33m";
-$colour{darkgreen}   = "\033[0;32m";
-$colour{darkblue}    = "\033[0;34m";
-$colour{darkcyan}    = "\033[0;36m";
-$colour{darkred}     = "\033[0;31m";
-$colour{darkmagenta} = "\033[0;35m";
-$colour{darkblack}   = "\033[0;30m";
-$colour{OFF}         = "\033[0;0m";
-
-# Default colours if /etc/colordiffrc or ~/.colordiffrc do not exist
-my $plain_text = $colour{OFF};
-my $file_old   = $colour{red};
-my $file_new   = $colour{blue};
-my $diff_stuff = $colour{magenta};
-
-# Locations for personal and system-wide colour configurations
-my $HOME   = $ENV{HOME};
-my $etcdir = '/etc';
-
-my ($setting, $value);
-my @config_files = ("$etcdir/colordiffrc", "$HOME/.colordiffrc");
-my $config_file;
-
-foreach $config_file (@config_files) {
-    if (open(COLORDIFFRC, "<$config_file")) {
-        while (<COLORDIFFRC>) {
-            chop;
-            next if (/^#/ || /^$/);
-            s/\s+//g;
-            ($setting, $value) = split ('=');
-            if ($setting eq 'banner') {
-                if ($value eq 'no') {
-                    $show_banner = 0;
-                }
-                next;
-            }
-            if (!defined $colour{$value}) {
-                print "Invalid colour specification ($value) in $config_file\n";
-                next;
-            }
-            if ($setting eq 'plain') {
-                $plain_text = $colour{$value};
-            }
-            elsif ($setting eq 'oldtext') {
-                $file_old = $colour{$value};
-            }
-            elsif ($setting eq 'newtext') {
-                $file_new = $colour{$value};
-            }
-            elsif ($setting eq 'diffstuff') {
-                $diff_stuff = $colour{$value};
-            }
-            else {
-                print "Unknown option in $etcdir/colordiffrc: $setting\n";
-            }
-        }
-        close COLORDIFFRC;
-    }
-}
-
-# colordiff specific options here.  Need to pre-declare if using variables
-GetOptions(
-    "no-banner" => sub { $show_banner = 0 },
-    "plain-text=s" => \&set_color,
-    "file-old=s"   => \&set_color,
-    "file-new=s"   => \&set_color,
-    "diff-stuff=s" => \&set_color
-);
-
-if ($show_banner == 1) {
-    print STDERR "$app_name $version ($app_www)\n";
-    print STDERR "$copyright $author, $author_email\n\n";
-}
-
-if (defined $ARGV[0]) {
-    # More reliable way of pulling in arguments
-    open2(\*INPUTSTREAM, undef, "git", "diff", @ARGV);
-}
-else {
-    *INPUTSTREAM = \*STDIN;
-}
-
-my $record;
-my $nrecs           = 0;
-my $inside_file_old = 1;
-my $nparents        = undef;
-
-while (<INPUTSTREAM>) {
-    $nrecs++;
-    if (/^(\@\@+) -[-+0-9, ]+ \1/) {
-           print "$diff_stuff";
-           $nparents = length($1) - 1;
-    }
-    elsif (/^diff -/ || /^index / ||
-          /^old mode / || /^new mode / ||
-          /^deleted file mode / || /^new file mode / ||
-          /^similarity index / || /^dissimilarity index / ||
-          /^copy from / || /^copy to / ||
-          /^rename from / || /^rename to /) {
-           $nparents = undef;
-           print "$diff_stuff";
-    }
-    elsif (defined $nparents) {
-           if ($nparents == 1) {
-                   if (/^\+/) {
-                           print $file_new;
-                   }
-                   elsif (/^-/) {
-                           print $file_old;
-                   }
-                   else {
-                           print $plain_text;
-                   }
-           }
-           elsif (/^ {$nparents}/) {
-                   print "$plain_text";
-           }
-           elsif (/^[+ ]{$nparents}/) {
-                   print "$file_new";
-           }
-           elsif (/^[- ]{$nparents}/) {
-                   print "$file_old";
-           }
-           else {
-                   print $plain_text;
-           }
-    }
-    elsif (/^--- / || /^\+\+\+ /) {
-           print $diff_stuff;
-    }
-    else {
-           print "$plain_text";
-    }
-    s/$/$colour{OFF}/;
-    print "$_";
-}
-close INPUTSTREAM;
-
-sub set_color {
-    my ($type, $color) = @_;
-
-    $type =~ s/-/_/;
-    eval "\$$type = \$colour{$color}";
-}
index 83c69ecf489d4730ccb24a6340c1bdb548daf9db..eecdaa0e75a1873ca08dcfb8e57426cb73bd293a 100755 (executable)
@@ -1,7 +1,7 @@
 #
 # bash completion support for core Git.
 #
-# Copyright (C) 2006 Shawn Pearce
+# Copyright (C) 2006,2007 Shawn Pearce
 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
 #
 # The contained completion routines provide support for completing:
@@ -61,6 +61,25 @@ __git_ps1 ()
        fi
 }
 
+__gitcomp ()
+{
+       local all c s=$'\n' IFS=' '$'\t'$'\n'
+       local cur="${COMP_WORDS[COMP_CWORD]}"
+       if [ $# -gt 2 ]; then
+               cur="$3"
+       fi
+       for c in $1; do
+               case "$c$4" in
+               --*=*) all="$all$c$4$s" ;;
+               *.)    all="$all$c$4$s" ;;
+               *)     all="$all$c$4 $s" ;;
+               esac
+       done
+       IFS=$s
+       COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
+       return
+}
+
 __git_heads ()
 {
        local cmd i is_hash=y dir="$(__gitdir "$1")"
@@ -200,7 +219,7 @@ __git_complete_file ()
                        -- "$cur"))
                ;;
        *)
-               COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+               __gitcomp "$(__git_refs)"
                ;;
        esac
 }
@@ -212,15 +231,18 @@ __git_complete_revlist ()
        *...*)
                pfx="${cur%...*}..."
                cur="${cur#*...}"
-               COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs)" -- "$cur"))
+               __gitcomp "$(__git_refs)" "$pfx" "$cur"
                ;;
        *..*)
                pfx="${cur%..*}.."
                cur="${cur#*..}"
-               COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs)" -- "$cur"))
+               __gitcomp "$(__git_refs)" "$pfx" "$cur"
+               ;;
+       *.)
+               __gitcomp "$cur."
                ;;
        *)
-               COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+               __gitcomp "$(__git_refs)"
                ;;
        esac
 }
@@ -235,15 +257,26 @@ __git_commands ()
        for i in $(git help -a|egrep '^ ')
        do
                case $i in
+               add--interactive) : plumbing;;
+               applymbox)        : ask gittus;;
+               applypatch)       : ask gittus;;
+               archimport)       : import;;
+               cat-file)         : plumbing;;
                check-ref-format) : plumbing;;
                commit-tree)      : plumbing;;
                convert-objects)  : plumbing;;
+               cvsexportcommit)  : export;;
+               cvsimport)        : import;;
                cvsserver)        : daemon;;
                daemon)           : daemon;;
+               diff-stages)      : nobody uses it;;
+               fsck-objects)     : plumbing;;
                fetch-pack)       : plumbing;;
+               fmt-merge-msg)    : plumbing;;
                hash-object)      : plumbing;;
                http-*)           : transport;;
                index-pack)       : plumbing;;
+               init-db)          : deprecated;;
                local-fetch)      : plumbing;;
                mailinfo)         : plumbing;;
                mailsplit)        : plumbing;;
@@ -256,9 +289,15 @@ __git_commands ()
                parse-remote)     : plumbing;;
                patch-id)         : plumbing;;
                peek-remote)      : plumbing;;
+               prune)            : plumbing;;
+               prune-packed)     : plumbing;;
+               quiltimport)      : import;;
                read-tree)        : plumbing;;
                receive-pack)     : plumbing;;
+               reflog)           : plumbing;;
+               repo-config)      : plumbing;;
                rerere)           : plumbing;;
+               resolve)          : dead dont use;;
                rev-list)         : plumbing;;
                rev-parse)        : plumbing;;
                runstatus)        : plumbing;;
@@ -268,14 +307,19 @@ __git_commands ()
                show-index)       : plumbing;;
                ssh-*)            : transport;;
                stripspace)       : plumbing;;
+               svn)              : import export;;
+               svnimport)        : import;;
                symbolic-ref)     : plumbing;;
+               tar-tree)         : deprecated;;
                unpack-file)      : plumbing;;
                unpack-objects)   : plumbing;;
+               update-index)     : plumbing;;
                update-ref)       : plumbing;;
                update-server-info) : daemon;;
                upload-archive)   : plumbing;;
                upload-pack)      : plumbing;;
                write-tree)       : plumbing;;
+               verify-tag)       : plumbing;;
                *) echo $i;;
                esac
        done
@@ -314,22 +358,19 @@ _git_am ()
 {
        local cur="${COMP_WORDS[COMP_CWORD]}"
        if [ -d .dotest ]; then
-               COMPREPLY=($(compgen -W "
-                       --skip --resolved
-                       " -- "$cur"))
+               __gitcomp "--skip --resolved"
                return
        fi
        case "$cur" in
        --whitespace=*)
-               COMPREPLY=($(compgen -W "$__git_whitespacelist" \
-                       -- "${cur##--whitespace=}"))
+               __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
                return
                ;;
        --*)
-               COMPREPLY=($(compgen -W "
+               __gitcomp "
                        --signoff --utf8 --binary --3way --interactive
                        --whitespace=
-                       " -- "$cur"))
+                       "
                return
        esac
        COMPREPLY=()
@@ -340,48 +381,74 @@ _git_apply ()
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
        --whitespace=*)
-               COMPREPLY=($(compgen -W "$__git_whitespacelist" \
-                       -- "${cur##--whitespace=}"))
+               __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
                return
                ;;
        --*)
-               COMPREPLY=($(compgen -W "
+               __gitcomp "
                        --stat --numstat --summary --check --index
                        --cached --index-info --reverse --reject --unidiff-zero
                        --apply --no-add --exclude=
                        --whitespace= --inaccurate-eof --verbose
-                       " -- "$cur"))
+                       "
                return
        esac
        COMPREPLY=()
 }
 
-_git_branch ()
+_git_add ()
 {
        local cur="${COMP_WORDS[COMP_CWORD]}"
-       COMPREPLY=($(compgen -W "-l -f -d -D $(__git_refs)" -- "$cur"))
+       case "$cur" in
+       --*)
+               __gitcomp "--interactive"
+               return
+       esac
+       COMPREPLY=()
 }
 
-_git_cat_file ()
+_git_bisect ()
 {
-       local cur="${COMP_WORDS[COMP_CWORD]}"
-       case "${COMP_WORDS[0]},$COMP_CWORD" in
-       git-cat-file*,1)
-               COMPREPLY=($(compgen -W "-p -t blob tree commit tag" -- "$cur"))
-               ;;
-       git,2)
-               COMPREPLY=($(compgen -W "-p -t blob tree commit tag" -- "$cur"))
+       local i c=1 command
+       while [ $c -lt $COMP_CWORD ]; do
+               i="${COMP_WORDS[c]}"
+               case "$i" in
+               start|bad|good|reset|visualize|replay|log)
+                       command="$i"
+                       break
+                       ;;
+               esac
+               c=$((++c))
+       done
+
+       if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+               __gitcomp "start bad good reset visualize replay log"
+               return
+       fi
+
+       case "$command" in
+       bad|good|reset)
+               __gitcomp "$(__git_refs)"
                ;;
        *)
-               __git_complete_file
+               COMPREPLY=()
                ;;
        esac
 }
 
+_git_branch ()
+{
+       __gitcomp "$(__git_refs)"
+}
+
 _git_checkout ()
 {
-       local cur="${COMP_WORDS[COMP_CWORD]}"
-       COMPREPLY=($(compgen -W "-l -b $(__git_refs)" -- "$cur"))
+       __gitcomp "$(__git_refs)"
+}
+
+_git_cherry ()
+{
+       __gitcomp "$(__git_refs)"
 }
 
 _git_cherry_pick ()
@@ -389,12 +456,10 @@ _git_cherry_pick ()
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
        --*)
-               COMPREPLY=($(compgen -W "
-                       --edit --no-commit
-                       " -- "$cur"))
+               __gitcomp "--edit --no-commit"
                ;;
        *)
-               COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+               __gitcomp "$(__git_refs)"
                ;;
        esac
 }
@@ -404,10 +469,10 @@ _git_commit ()
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
        --*)
-               COMPREPLY=($(compgen -W "
+               __gitcomp "
                        --all --author= --signoff --verify --no-verify
                        --edit --amend --include --only
-                       " -- "$cur"))
+                       "
                return
        esac
        COMPREPLY=()
@@ -420,8 +485,7 @@ _git_diff ()
 
 _git_diff_tree ()
 {
-       local cur="${COMP_WORDS[COMP_CWORD]}"
-       COMPREPLY=($(compgen -W "-r -p -M $(__git_refs)" -- "$cur"))
+       __gitcomp "$(__git_refs)"
 }
 
 _git_fetch ()
@@ -430,16 +494,15 @@ _git_fetch ()
 
        case "${COMP_WORDS[0]},$COMP_CWORD" in
        git-fetch*,1)
-               COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+               __gitcomp "$(__git_remotes)"
                ;;
        git,2)
-               COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+               __gitcomp "$(__git_remotes)"
                ;;
        *)
                case "$cur" in
                *:*)
-                       cur="${cur#*:}"
-                       COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+                       __gitcomp "$(__git_refs)" "" "${cur#*:}"
                        ;;
                *)
                        local remote
@@ -447,7 +510,7 @@ _git_fetch ()
                        git-fetch) remote="${COMP_WORDS[1]}" ;;
                        git)       remote="${COMP_WORDS[2]}" ;;
                        esac
-                       COMPREPLY=($(compgen -W "$(__git_refs2 "$remote")" -- "$cur"))
+                       __gitcomp "$(__git_refs2 "$remote")"
                        ;;
                esac
                ;;
@@ -459,7 +522,7 @@ _git_format_patch ()
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
        --*)
-               COMPREPLY=($(compgen -W "
+               __gitcomp "
                        --stdout --attach --thread
                        --output-directory
                        --numbered --start-number
@@ -467,17 +530,29 @@ _git_format_patch ()
                        --signoff
                        --in-reply-to=
                        --full-index --binary
-                       " -- "$cur"))
+                       --not --all
+                       "
                return
                ;;
        esac
        __git_complete_revlist
 }
 
-_git_ls_remote ()
+_git_gc ()
 {
        local cur="${COMP_WORDS[COMP_CWORD]}"
-       COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+       case "$cur" in
+       --*)
+               __gitcomp "--prune"
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
+_git_ls_remote ()
+{
+       __gitcomp "$(__git_remotes)"
 }
 
 _git_ls_tree ()
@@ -490,13 +565,13 @@ _git_log ()
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
        --pretty=*)
-               COMPREPLY=($(compgen -W "
+               __gitcomp "
                        oneline short medium full fuller email raw
-                       " -- "${cur##--pretty=}"))
+                       " "" "${cur##--pretty=}"
                return
                ;;
        --*)
-               COMPREPLY=($(compgen -W "
+               __gitcomp "
                        --max-count= --max-age= --since= --after=
                        --min-age= --before= --until=
                        --root --not --topo-order --date-order
@@ -506,7 +581,8 @@ _git_log ()
                        --author= --committer= --grep=
                        --all-match
                        --pretty= --name-status --name-only
-                       " -- "$cur"))
+                       --not --all
+                       "
                return
                ;;
        esac
@@ -518,34 +594,31 @@ _git_merge ()
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "${COMP_WORDS[COMP_CWORD-1]}" in
        -s|--strategy)
-               COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
+               __gitcomp "$(__git_merge_strategies)"
                return
        esac
        case "$cur" in
        --strategy=*)
-               COMPREPLY=($(compgen -W "$(__git_merge_strategies)" \
-                       -- "${cur##--strategy=}"))
+               __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
                return
                ;;
        --*)
-               COMPREPLY=($(compgen -W "
+               __gitcomp "
                        --no-commit --no-summary --squash --strategy
-                       " -- "$cur"))
+                       "
                return
        esac
-       COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+       __gitcomp "$(__git_refs)"
 }
 
 _git_merge_base ()
 {
-       local cur="${COMP_WORDS[COMP_CWORD]}"
-       COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+       __gitcomp "$(__git_refs)"
 }
 
 _git_name_rev ()
 {
-       local cur="${COMP_WORDS[COMP_CWORD]}"
-       COMPREPLY=($(compgen -W "--tags --all --stdin" -- "$cur"))
+       __gitcomp "--tags --all --stdin"
 }
 
 _git_pull ()
@@ -554,10 +627,10 @@ _git_pull ()
 
        case "${COMP_WORDS[0]},$COMP_CWORD" in
        git-pull*,1)
-               COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+               __gitcomp "$(__git_remotes)"
                ;;
        git,2)
-               COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+               __gitcomp "$(__git_remotes)"
                ;;
        *)
                local remote
@@ -565,7 +638,7 @@ _git_pull ()
                git-pull)  remote="${COMP_WORDS[1]}" ;;
                git)       remote="${COMP_WORDS[2]}" ;;
                esac
-               COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur"))
+               __gitcomp "$(__git_refs "$remote")"
                ;;
        esac
 }
@@ -576,10 +649,10 @@ _git_push ()
 
        case "${COMP_WORDS[0]},$COMP_CWORD" in
        git-push*,1)
-               COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+               __gitcomp "$(__git_remotes)"
                ;;
        git,2)
-               COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+               __gitcomp "$(__git_remotes)"
                ;;
        *)
                case "$cur" in
@@ -589,11 +662,10 @@ _git_push ()
                        git-push)  remote="${COMP_WORDS[1]}" ;;
                        git)       remote="${COMP_WORDS[2]}" ;;
                        esac
-                       cur="${cur#*:}"
-                       COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur"))
+                       __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
                        ;;
                *)
-                       COMPREPLY=($(compgen -W "$(__git_refs2)" -- "$cur"))
+                       __gitcomp "$(__git_refs2)"
                        ;;
                esac
                ;;
@@ -603,30 +675,25 @@ _git_push ()
 _git_rebase ()
 {
        local cur="${COMP_WORDS[COMP_CWORD]}"
-       if [ -d .dotest ]; then
-               COMPREPLY=($(compgen -W "
-                       --continue --skip --abort
-                       " -- "$cur"))
+       if [ -d .dotest ] || [ -d .git/.dotest-merge ]; then
+               __gitcomp "--continue --skip --abort"
                return
        fi
        case "${COMP_WORDS[COMP_CWORD-1]}" in
        -s|--strategy)
-               COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
+               __gitcomp "$(__git_merge_strategies)"
                return
        esac
        case "$cur" in
        --strategy=*)
-               COMPREPLY=($(compgen -W "$(__git_merge_strategies)" \
-                       -- "${cur##--strategy=}"))
+               __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
                return
                ;;
        --*)
-               COMPREPLY=($(compgen -W "
-                       --onto --merge --strategy
-                       " -- "$cur"))
+               __gitcomp "--onto --merge --strategy"
                return
        esac
-       COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+       __gitcomp "$(__git_refs)"
 }
 
 _git_config ()
@@ -635,26 +702,40 @@ _git_config ()
        local prv="${COMP_WORDS[COMP_CWORD-1]}"
        case "$prv" in
        branch.*.remote)
-               COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+               __gitcomp "$(__git_remotes)"
                return
                ;;
        branch.*.merge)
-               COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+               __gitcomp "$(__git_refs)"
                return
                ;;
        remote.*.fetch)
                local remote="${prv#remote.}"
                remote="${remote%.fetch}"
-               COMPREPLY=($(compgen -W "$(__git_refs_remotes "$remote")" \
-                       -- "$cur"))
+               __gitcomp "$(__git_refs_remotes "$remote")"
                return
                ;;
        remote.*.push)
                local remote="${prv#remote.}"
                remote="${remote%.push}"
-               COMPREPLY=($(compgen -W "$(git --git-dir="$(__gitdir)" \
+               __gitcomp "$(git --git-dir="$(__gitdir)" \
                        for-each-ref --format='%(refname):%(refname)' \
-                       refs/heads)" -- "$cur"))
+                       refs/heads)"
+               return
+               ;;
+       pull.twohead|pull.octopus)
+               __gitcomp "$(__git_merge_strategies)"
+               return
+               ;;
+       color.branch|color.diff|color.status)
+               __gitcomp "always never auto"
+               return
+               ;;
+       color.*.*)
+               __gitcomp "
+                       black red green yellow blue magenta cyan white
+                       bold dim ul blink reverse
+                       "
                return
                ;;
        *.*)
@@ -664,41 +745,39 @@ _git_config ()
        esac
        case "$cur" in
        --*)
-               COMPREPLY=($(compgen -W "
+               __gitcomp "
                        --global --list --replace-all
                        --get --get-all --get-regexp
-                       --unset --unset-all
-                       " -- "$cur"))
+                       --add --unset --unset-all
+                       "
                return
                ;;
        branch.*.*)
                local pfx="${cur%.*}."
                cur="${cur##*.}"
-               COMPREPLY=($(compgen -P "$pfx" -W "remote merge" -- "$cur"))
+               __gitcomp "remote merge" "$pfx" "$cur"
                return
                ;;
        branch.*)
                local pfx="${cur%.*}."
                cur="${cur#*.}"
-               COMPREPLY=($(compgen -P "$pfx" -S . \
-                       -W "$(__git_heads)" -- "$cur"))
+               __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
                return
                ;;
        remote.*.*)
                local pfx="${cur%.*}."
                cur="${cur##*.}"
-               COMPREPLY=($(compgen -P "$pfx" -W "url fetch push" -- "$cur"))
+               __gitcomp "url fetch push" "$pfx" "$cur"
                return
                ;;
        remote.*)
                local pfx="${cur%.*}."
                cur="${cur#*.}"
-               COMPREPLY=($(compgen -P "$pfx" -S . \
-                       -W "$(__git_remotes)" -- "$cur"))
+               __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
                return
                ;;
        esac
-       COMPREPLY=($(compgen -W "
+       __gitcomp "
                apply.whitespace
                core.fileMode
                core.gitProxy
@@ -710,47 +789,105 @@ _git_config ()
                core.warnAmbiguousRefs
                core.compression
                core.legacyHeaders
-               i18n.commitEncoding
-               i18n.logOutputEncoding
-               diff.color
+               core.packedGitWindowSize
+               core.packedGitLimit
+               color.branch
+               color.branch.current
+               color.branch.local
+               color.branch.remote
+               color.branch.plain
                color.diff
-               diff.renameLimit
-               diff.renames
-               pager.color
+               color.diff.plain
+               color.diff.meta
+               color.diff.frag
+               color.diff.old
+               color.diff.new
+               color.diff.commit
+               color.diff.whitespace
                color.pager
-               status.color
                color.status
-               log.showroot
-               show.difftree
-               showbranch.default
-               whatchanged.difftree
+               color.status.header
+               color.status.added
+               color.status.changed
+               color.status.untracked
+               diff.renameLimit
+               diff.renames
+               fetch.unpackLimit
+               format.headers
+               gitcvs.enabled
+               gitcvs.logfile
+               gc.reflogexpire
+               gc.reflogexpireunreachable
+               gc.rerereresolved
+               gc.rerereunresolved
                http.sslVerify
                http.sslCert
                http.sslKey
                http.sslCAInfo
                http.sslCAPath
                http.maxRequests
-               http.lowSpeedLimit http.lowSpeedTime
+               http.lowSpeedLimit
+               http.lowSpeedTime
                http.noEPSV
+               i18n.commitEncoding
+               i18n.logOutputEncoding
+               log.showroot
+               merge.summary
+               merge.verbosity
                pack.window
+               pull.octopus
+               pull.twohead
                repack.useDeltaBaseOffset
-               pull.octopus pull.twohead
-               merge.summary
+               show.difftree
+               showbranch.default
+               tar.umask
+               transfer.unpackLimit
                receive.unpackLimit
                receive.denyNonFastForwards
-               user.name user.email
-               tar.umask
-               gitcvs.enabled
-               gitcvs.logfile
+               user.name
+               user.email
+               user.signingkey
+               whatchanged.difftree
                branch. remote.
-       " -- "$cur"))
+       "
+}
+
+_git_remote ()
+{
+       local i c=1 command
+       while [ $c -lt $COMP_CWORD ]; do
+               i="${COMP_WORDS[c]}"
+               case "$i" in
+               add|show|prune) command="$i"; break ;;
+               esac
+               c=$((++c))
+       done
+
+       if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+               __gitcomp "add show prune"
+               return
+       fi
+
+       case "$command" in
+       show|prune)
+               __gitcomp "$(__git_remotes)"
+               ;;
+       *)
+               COMPREPLY=()
+               ;;
+       esac
 }
 
 _git_reset ()
 {
        local cur="${COMP_WORDS[COMP_CWORD]}"
-       local opt="--mixed --hard --soft"
-       COMPREPLY=($(compgen -W "$opt $(__git_refs)" -- "$cur"))
+       case "$cur" in
+       --*)
+               __gitcomp "--mixed --hard --soft"
+               return
+               ;;
+       esac
+       __gitcomp "$(__git_refs)"
 }
 
 _git_show ()
@@ -758,13 +895,13 @@ _git_show ()
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
        --pretty=*)
-               COMPREPLY=($(compgen -W "
+               __gitcomp "
                        oneline short medium full fuller email raw
-                       " -- "${cur##--pretty=}"))
+                       " "" "${cur##--pretty=}"
                return
                ;;
        --*)
-               COMPREPLY=($(compgen -W "--pretty=" -- "$cur"))
+               __gitcomp "--pretty="
                return
                ;;
        esac
@@ -787,12 +924,12 @@ _git ()
        done
 
        if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
-               COMPREPLY=($(compgen -W "
-                       --git-dir= --version --exec-path
-                       $(__git_commands)
-                       $(__git_aliases)
-                       " -- "${COMP_WORDS[COMP_CWORD]}"))
-               return;
+               case "${COMP_WORDS[COMP_CWORD]}" in
+               --*=*) COMPREPLY=() ;;
+               --*)   __gitcomp "--git-dir= --bare --version --exec-path" ;;
+               *)     __gitcomp "$(__git_commands) $(__git_aliases)" ;;
+               esac
+               return
        fi
 
        local expansion=$(__git_aliased_command "$command")
@@ -800,10 +937,12 @@ _git ()
 
        case "$command" in
        am)          _git_am ;;
+       add)         _git_add ;;
        apply)       _git_apply ;;
+       bisect)      _git_bisect ;;
        branch)      _git_branch ;;
-       cat-file)    _git_cat_file ;;
        checkout)    _git_checkout ;;
+       cherry)      _git_cherry ;;
        cherry-pick) _git_cherry_pick ;;
        commit)      _git_commit ;;
        config)      _git_config ;;
@@ -811,6 +950,7 @@ _git ()
        diff-tree)   _git_diff_tree ;;
        fetch)       _git_fetch ;;
        format-patch) _git_format_patch ;;
+       gc)          _git_gc ;;
        log)         _git_log ;;
        ls-remote)   _git_ls_remote ;;
        ls-tree)     _git_ls_tree ;;
@@ -820,7 +960,7 @@ _git ()
        pull)        _git_pull ;;
        push)        _git_push ;;
        rebase)      _git_rebase ;;
-       repo-config) _git_config ;;
+       remote)      _git_remote ;;
        reset)       _git_reset ;;
        show)        _git_show ;;
        show-branch) _git_log ;;
@@ -832,33 +972,42 @@ _git ()
 _gitk ()
 {
        local cur="${COMP_WORDS[COMP_CWORD]}"
-       COMPREPLY=($(compgen -W "--all $(__git_refs)" -- "$cur"))
+       case "$cur" in
+       --*)
+               __gitcomp "--not --all"
+               return
+               ;;
+       esac
+       __git_complete_revlist
 }
 
 complete -o default -o nospace -F _git git
-complete -o default            -F _gitk gitk
-complete -o default            -F _git_am git-am
-complete -o default            -F _git_apply git-apply
-complete -o default            -F _git_branch git-branch
-complete -o default -o nospace -F _git_cat_file git-cat-file
-complete -o default            -F _git_checkout git-checkout
-complete -o default            -F _git_cherry_pick git-cherry-pick
-complete -o default            -F _git_commit git-commit
+complete -o default -o nospace -F _gitk gitk
+complete -o default -o nospace -F _git_am git-am
+complete -o default -o nospace -F _git_apply git-apply
+complete -o default -o nospace -F _git_bisect git-bisect
+complete -o default -o nospace -F _git_branch git-branch
+complete -o default -o nospace -F _git_checkout git-checkout
+complete -o default -o nospace -F _git_cherry git-cherry
+complete -o default -o nospace -F _git_cherry_pick git-cherry-pick
+complete -o default -o nospace -F _git_commit git-commit
 complete -o default -o nospace -F _git_diff git-diff
-complete -o default            -F _git_diff_tree git-diff-tree
+complete -o default -o nospace -F _git_diff_tree git-diff-tree
 complete -o default -o nospace -F _git_fetch git-fetch
 complete -o default -o nospace -F _git_format_patch git-format-patch
+complete -o default -o nospace -F _git_gc git-gc
 complete -o default -o nospace -F _git_log git-log
-complete -o default            -F _git_ls_remote git-ls-remote
+complete -o default -o nospace -F _git_ls_remote git-ls-remote
 complete -o default -o nospace -F _git_ls_tree git-ls-tree
-complete -o default            -F _git_merge git-merge
-complete -o default            -F _git_merge_base git-merge-base
-complete -o default            -F _git_name_rev git-name-rev
+complete -o default -o nospace -F _git_merge git-merge
+complete -o default -o nospace -F _git_merge_base git-merge-base
+complete -o default -o nospace -F _git_name_rev git-name-rev
 complete -o default -o nospace -F _git_pull git-pull
 complete -o default -o nospace -F _git_push git-push
-complete -o default            -F _git_rebase git-rebase
-complete -o default            -F _git_config git-config
-complete -o default            -F _git_reset git-reset
+complete -o default -o nospace -F _git_rebase git-rebase
+complete -o default -o nospace -F _git_config git-config
+complete -o default -o nospace -F _git_remote git-remote
+complete -o default -o nospace -F _git_reset git-reset
 complete -o default -o nospace -F _git_show git-show
 complete -o default -o nospace -F _git_log git-show-branch
 complete -o default -o nospace -F _git_log git-whatchanged
@@ -868,19 +1017,20 @@ complete -o default -o nospace -F _git_log git-whatchanged
 # included the '.exe' suffix.
 #
 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
-complete -o default            -F _git_apply git-apply.exe
+complete -o default -o nospace -F _git_add git-add.exe
+complete -o default -o nospace -F _git_apply git-apply.exe
 complete -o default -o nospace -F _git git.exe
-complete -o default            -F _git_branch git-branch.exe
-complete -o default -o nospace -F _git_cat_file git-cat-file.exe
+complete -o default -o nospace -F _git_branch git-branch.exe
+complete -o default -o nospace -F _git_cherry git-cherry.exe
 complete -o default -o nospace -F _git_diff git-diff.exe
 complete -o default -o nospace -F _git_diff_tree git-diff-tree.exe
 complete -o default -o nospace -F _git_format_patch git-format-patch.exe
 complete -o default -o nospace -F _git_log git-log.exe
 complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
-complete -o default            -F _git_merge_base git-merge-base.exe
-complete -o default            -F _git_name_rev git-name-rev.exe
+complete -o default -o nospace -F _git_merge_base git-merge-base.exe
+complete -o default -o nospace -F _git_name_rev git-name-rev.exe
 complete -o default -o nospace -F _git_push git-push.exe
-complete -o default            -F _git_config git-config
+complete -o default -o nospace -F _git_config git-config
 complete -o default -o nospace -F _git_show git-show.exe
 complete -o default -o nospace -F _git_log git-show-branch.exe
 complete -o default -o nospace -F _git_log git-whatchanged.exe
diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el
new file mode 100644 (file)
index 0000000..62cf24c
--- /dev/null
@@ -0,0 +1,180 @@
+;;; git-blame.el
+;; David Kågedal <davidk@lysator.liu.se>
+;; Message-ID: <87iren2vqx.fsf@morpheus.local>
+
+(require 'cl)
+(defun color-scale (l)
+  (let* ((colors ())
+         r g b)
+    (setq r l)
+    (while r
+      (setq g l)
+      (while g
+        (setq b l)
+        (while b
+          (push (concat "#" (car r) (car g) (car b)) colors)
+          (pop b))
+        (pop g))
+      (pop r))
+    colors))
+
+(defvar git-blame-dark-colors
+  (color-scale '("00" "04" "08" "0c"
+                 "10" "14" "18" "1c"
+                 "20" "24" "28" "2c"
+                 "30" "34" "38" "3c")))
+
+(defvar git-blame-light-colors
+  (color-scale '("c0" "c4" "c8" "cc"
+                 "d0" "d4" "d8" "dc"
+                 "e0" "e4" "e8" "ec"
+                 "f0" "f4" "f8" "fc")))
+
+(defvar git-blame-ancient-color "dark green")
+
+(defvar git-blame-overlays nil)
+(defvar git-blame-cache nil)
+
+(defvar git-blame-mode nil)
+(make-variable-buffer-local 'git-blame-mode)
+(push (list 'git-blame-mode " blame") minor-mode-alist)
+
+(defun git-blame-mode (&optional arg)
+  (interactive "P")
+  (if arg
+      (setq git-blame-mode (eq arg 1))
+    (setq git-blame-mode (not git-blame-mode)))
+  (make-local-variable 'git-blame-overlays)
+  (make-local-variable 'git-blame-colors)
+  (make-local-variable 'git-blame-cache)
+  (let ((bgmode (cdr (assoc 'background-mode (frame-parameters)))))
+    (if (eq bgmode 'dark)
+        (setq git-blame-colors git-blame-dark-colors)
+      (setq git-blame-colors git-blame-light-colors)))
+  (if git-blame-mode
+      (git-blame-run)
+    (git-blame-cleanup)))
+
+(defun git-blame-run ()
+  (let* ((display-buf (current-buffer))
+         (blame-buf (get-buffer-create
+                     (concat " git blame for " (buffer-name))))
+         (proc (start-process "git-blame" blame-buf
+                             "git" "blame" "--incremental"
+                             (file-name-nondirectory buffer-file-name))))
+    (mapcar 'delete-overlay git-blame-overlays)
+    (setq git-blame-overlays nil)
+    (setq git-blame-cache (make-hash-table :test 'equal))
+    (with-current-buffer blame-buf
+      (erase-buffer)
+      (make-local-variable 'git-blame-file)
+      (make-local-variable 'git-blame-current)
+      (setq git-blame-file display-buf)
+      (setq git-blame-current nil))
+    (set-process-filter proc 'git-blame-filter)
+    (set-process-sentinel proc 'git-blame-sentinel)))
+
+(defun git-blame-cleanup ()
+  "Remove all blame properties"
+    (mapcar 'delete-overlay git-blame-overlays)
+    (setq git-blame-overlays nil)
+    (let ((modified (buffer-modified-p)))
+      (remove-text-properties (point-min) (point-max) '(point-entered nil))
+      (set-buffer-modified-p modified)))
+
+(defun git-blame-sentinel (proc status)
+  ;;(kill-buffer (process-buffer proc))
+  (message "git blame finished"))
+
+(defvar in-blame-filter nil)
+
+(defun git-blame-filter (proc str)
+  (save-excursion
+    (set-buffer (process-buffer proc))
+    (goto-char (process-mark proc))
+    (insert-before-markers str)
+    (goto-char 0)
+    (unless in-blame-filter
+      (let ((more t)
+            (in-blame-filter t))
+        (while more
+          (setq more (git-blame-parse)))))))
+
+(defun git-blame-parse ()
+  (cond ((looking-at "\\([0-9a-f]\\{40\\}\\) \\([0-9]+\\) \\([0-9]+\\) \\([0-9]+\\)\n")
+         (let ((hash (match-string 1))
+               (src-line (string-to-number (match-string 2)))
+               (res-line (string-to-number (match-string 3)))
+               (num-lines (string-to-number (match-string 4))))
+           (setq git-blame-current
+                 (git-blame-new-commit
+                  hash src-line res-line num-lines)))
+         (delete-region (point) (match-end 0))
+         t)
+        ((looking-at "filename \\(.+\\)\n")
+         (let ((filename (match-string 1)))
+           (git-blame-add-info "filename" filename))
+         (delete-region (point) (match-end 0))
+         t)
+        ((looking-at "\\([a-z-]+\\) \\(.+\\)\n")
+         (let ((key (match-string 1))
+               (value (match-string 2)))
+           (git-blame-add-info key value))
+         (delete-region (point) (match-end 0))
+         t)
+        ((looking-at "boundary\n")
+         (setq git-blame-current nil)
+         (delete-region (point) (match-end 0))
+         t)
+        (t
+         nil)))
+
+
+(defun git-blame-new-commit (hash src-line res-line num-lines)
+  (save-excursion
+    (set-buffer git-blame-file)
+    (let ((info (gethash hash git-blame-cache))
+          (inhibit-point-motion-hooks t))
+      (when (not info)
+        (let ((color (pop git-blame-colors)))
+          (unless color
+            (setq color git-blame-ancient-color))
+          (setq info (list hash src-line res-line num-lines
+                           (cons 'color color))))
+        (puthash hash info git-blame-cache))
+      (goto-line res-line)
+      (while (> num-lines 0)
+        (if (get-text-property (point) 'git-blame)
+            (forward-line)
+          (let* ((start (point))
+                 (end (progn (forward-line 1) (point)))
+                 (ovl (make-overlay start end)))
+            (push ovl git-blame-overlays)
+            (overlay-put ovl 'git-blame info)
+            (overlay-put ovl 'help-echo hash)
+            (overlay-put ovl 'face (list :background
+                                         (cdr (assq 'color (cddddr info)))))
+            ;;(overlay-put ovl 'point-entered
+            ;;             `(lambda (x y) (git-blame-identify ,hash)))
+            (let ((modified (buffer-modified-p)))
+              (put-text-property (if (= start 1) start (1- start)) (1- end)
+                                 'point-entered
+                                 `(lambda (x y) (git-blame-identify ,hash)))
+              (set-buffer-modified-p modified))))
+        (setq num-lines (1- num-lines))))))
+
+(defun git-blame-add-info (key value)
+  (if git-blame-current
+      (nconc git-blame-current (list (cons (intern key) value)))))
+
+(defun git-blame-current-commit ()
+  (let ((info (get-char-property (point) 'git-blame)))
+    (if info
+        (car info)
+      (error "No commit info"))))
+
+(defun git-blame-identify (&optional hash)
+  (interactive)
+  (shell-command
+   (format "git log -1 --pretty=oneline %s" (or hash
+                                                (git-blame-current-commit)))))
diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py
new file mode 100755 (executable)
index 0000000..37337ff
--- /dev/null
@@ -0,0 +1,233 @@
+#! /usr/bin/python
+
+""" hg-to-svn.py - A Mercurial to GIT converter
+
+    Copyright (C)2007 Stelian Pop <stelian@popies.net>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2, or (at your option)
+    any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+"""
+
+import os, os.path, sys
+import tempfile, popen2, pickle, getopt
+import re
+
+# Maps hg version -> git version
+hgvers = {}
+# List of children for each hg revision
+hgchildren = {}
+# Current branch for each hg revision
+hgbranch = {}
+
+#------------------------------------------------------------------------------
+
+def usage():
+
+        print """\
+%s: [OPTIONS] <hgprj>
+
+options:
+    -s, --gitstate=FILE: name of the state to be saved/read
+                         for incrementals
+
+required:
+    hgprj:  name of the HG project to import (directory)
+""" % sys.argv[0]
+
+#------------------------------------------------------------------------------
+
+def getgitenv(user, date):
+    env = ''
+    elems = re.compile('(.*?)\s+<(.*)>').match(user)
+    if elems:
+        env += 'export GIT_AUTHOR_NAME="%s" ;' % elems.group(1)
+        env += 'export GIT_COMMITER_NAME="%s" ;' % elems.group(1)
+        env += 'export GIT_AUTHOR_EMAIL="%s" ;' % elems.group(2)
+        env += 'export GIT_COMMITER_EMAIL="%s" ;' % elems.group(2)
+    else:
+        env += 'export GIT_AUTHOR_NAME="%s" ;' % user
+        env += 'export GIT_COMMITER_NAME="%s" ;' % user
+        env += 'export GIT_AUTHOR_EMAIL= ;'
+        env += 'export GIT_COMMITER_EMAIL= ;'
+
+    env += 'export GIT_AUTHOR_DATE="%s" ;' % date
+    env += 'export GIT_COMMITTER_DATE="%s" ;' % date
+    return env
+
+#------------------------------------------------------------------------------
+
+state = ''
+
+try:
+    opts, args = getopt.getopt(sys.argv[1:], 's:t:', ['gitstate=', 'tempdir='])
+    for o, a in opts:
+        if o in ('-s', '--gitstate'):
+            state = a
+            state = os.path.abspath(state)
+
+    if len(args) != 1:
+        raise('params')
+except:
+    usage()
+    sys.exit(1)
+
+hgprj = args[0]
+os.chdir(hgprj)
+
+if state:
+    if os.path.exists(state):
+        print 'State does exist, reading'
+        f = open(state, 'r')
+        hgvers = pickle.load(f)
+    else:
+        print 'State does not exist, first run'
+
+tip = os.popen('hg tip | head -1 | cut -f 2 -d :').read().strip()
+print 'tip is', tip
+
+# Calculate the branches
+print 'analysing the branches...'
+hgchildren["0"] = ()
+hgbranch["0"] = "master"
+for cset in range(1, int(tip) + 1):
+    hgchildren[str(cset)] = ()
+    prnts = os.popen('hg log -r %d | grep ^parent: | cut -f 2 -d :' % cset).readlines()
+    if len(prnts) > 0:
+        parent = prnts[0].strip()
+    else:
+        parent = str(cset - 1)
+    hgchildren[parent] += ( str(cset), )
+    if len(prnts) > 1:
+        mparent = prnts[1].strip()
+        hgchildren[mparent] += ( str(cset), )
+    else:
+        mparent = None
+
+    if mparent:
+        # For merge changesets, take either one, preferably the 'master' branch
+        if hgbranch[mparent] == 'master':
+            hgbranch[str(cset)] = 'master'
+        else:
+            hgbranch[str(cset)] = hgbranch[parent]
+    else:
+        # Normal changesets
+        # For first children, take the parent branch, for the others create a new branch
+        if hgchildren[parent][0] == str(cset):
+            hgbranch[str(cset)] = hgbranch[parent]
+        else:
+            hgbranch[str(cset)] = "branch-" + str(cset)
+
+if not hgvers.has_key("0"):
+    print 'creating repository'
+    os.system('git-init-db')
+
+# loop through every hg changeset
+for cset in range(int(tip) + 1):
+
+    # incremental, already seen
+    if hgvers.has_key(str(cset)):
+        continue
+
+    # get info
+    prnts = os.popen('hg log -r %d | grep ^parent: | cut -f 2 -d :' % cset).readlines()
+    if len(prnts) > 0:
+        parent = prnts[0].strip()
+    else:
+        parent = str(cset - 1)
+    if len(prnts) > 1:
+        mparent = prnts[1].strip()
+    else:
+        mparent = None
+
+    (fdcomment, filecomment) = tempfile.mkstemp()
+    csetcomment = os.popen('hg log -r %d -v | grep -v ^changeset: | grep -v ^parent: | grep -v ^user: | grep -v ^date | grep -v ^files: | grep -v ^description: | grep -v ^tag:' % cset).read().strip()
+    os.write(fdcomment, csetcomment)
+    os.close(fdcomment)
+
+    date = os.popen('hg log -r %d | grep ^date: | cut -f 2- -d :' % cset).read().strip()
+
+    tag = os.popen('hg log -r %d | grep ^tag: | cut -f 2- -d :' % cset).read().strip()
+
+    user = os.popen('hg log -r %d | grep ^user: | cut -f 2- -d :' % cset).read().strip()
+
+    print '-----------------------------------------'
+    print 'cset:', cset
+    print 'branch:', hgbranch[str(cset)]
+    print 'user:', user
+    print 'date:', date
+    print 'comment:', csetcomment
+    print 'parent:', parent
+    if mparent:
+        print 'mparent:', mparent
+    if tag:
+        print 'tag:', tag
+    print '-----------------------------------------'
+
+    # checkout the parent if necessary
+    if cset != 0:
+        if hgbranch[str(cset)] == "branch-" + str(cset):
+            print 'creating new branch', hgbranch[str(cset)]
+            os.system('git-checkout -b %s %s' % (hgbranch[str(cset)], hgvers[parent]))
+        else:
+            print 'checking out branch', hgbranch[str(cset)]
+            os.system('git-checkout %s' % hgbranch[str(cset)])
+
+    # merge
+    if mparent:
+        if hgbranch[parent] == hgbranch[str(cset)]:
+            otherbranch = hgbranch[mparent]
+        else:
+            otherbranch = hgbranch[parent]
+        print 'merging', otherbranch, 'into', hgbranch[str(cset)]
+        os.system(getgitenv(user, date) + 'git-merge --no-commit -s ours "" %s %s' % (hgbranch[str(cset)], otherbranch))
+
+    # remove everything except .git and .hg directories
+    os.system('find . \( -path "./.hg" -o -path "./.git" \) -prune -o ! -name "." -print | xargs rm -rf')
+
+    # repopulate with checkouted files
+    os.system('hg update -C %d' % cset)
+
+    # add new files
+    os.system('git-ls-files -x .hg --others | git-update-index --add --stdin')
+    # delete removed files
+    os.system('git-ls-files -x .hg --deleted | git-update-index --remove --stdin')
+
+    # commit
+    os.system(getgitenv(user, date) + 'git-commit -a -F %s' % filecomment)
+    os.unlink(filecomment)
+
+    # tag
+    if tag and tag != 'tip':
+        os.system(getgitenv(user, date) + 'git-tag %s' % tag)
+
+    # delete branch if not used anymore...
+    if mparent and len(hgchildren[str(cset)]):
+        print "Deleting unused branch:", otherbranch
+        os.system('git-branch -d %s' % otherbranch)
+
+    # retrieve and record the version
+    vvv = os.popen('git-show | head -1').read()
+    vvv = vvv[vvv.index(' ') + 1 : ].strip()
+    print 'record', cset, '->', vvv
+    hgvers[str(cset)] = vvv
+
+os.system('git-repack -a -d')
+
+# write the state for incrementals
+if state:
+    print 'Writing state'
+    f = open(state, 'w')
+    pickle.dump(hgvers, f)
+
+# vim: et ts=8 sw=4 sts=4
diff --git a/contrib/hg-to-git/hg-to-git.txt b/contrib/hg-to-git/hg-to-git.txt
new file mode 100644 (file)
index 0000000..91f8fe6
--- /dev/null
@@ -0,0 +1,21 @@
+hg-to-git.py is able to convert a Mercurial repository into a git one,
+and preserves the branches in the process (unlike tailor)
+
+hg-to-git.py can probably be greatly improved (it's a rather crude
+combination of shell and python) but it does already work quite well for
+me. Features:
+       - supports incremental conversion
+         (for keeping a git repo in sync with a hg one)
+        - supports hg branches
+        - converts hg tags
+
+Note that the git repository will be created 'in place' (at the same
+location as the source hg repo). You will have to manually remove the
+'.hg' directory after the conversion.
+
+Also note that the incremental conversion uses 'simple' hg changesets
+identifiers (ordinals, as opposed to SHA-1 ids), and since these ids
+are not stable across different repositories the hg-to-git.py state file
+is forever tied to one hg repository.
+
+Stelian Pop <stelian@popies.net>
index 95903722142870219e01030f69e574ab20b3a4f2..2a20ca55cbe912a8ddd4bea8b2476ae30215903a 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -408,7 +408,7 @@ static void make_service_overridable(const char *name, int ena) {
 
 /*
  * Separate the "extra args" information as supplied by the client connection.
- * Any resulting data is squirrelled away in the given interpolation table.
+ * Any resulting data is squirreled away in the given interpolation table.
  */
 static void parse_extra_args(struct interp *table, char *extra_args, int buflen)
 {
index 2c9be60ed9b47c2e563f69e6c8b60195fd51a917..91cd87742f9efd2c0fcf878c179bc6ed989cb50a 100644 (file)
@@ -7,6 +7,7 @@
 #include "diff.h"
 #include "diffcore.h"
 #include "revision.h"
+#include "cache-tree.h"
 
 /*
  * diff-files
@@ -271,7 +272,7 @@ static int diff_cache(struct rev_info *revs,
                                break;
                        }
                        /* Show difference between old and new */
-                       show_modified(revs,ac[1], ce, 1,
+                       show_modified(revs, ac[1], ce, 1,
                                      cached, match_missing);
                        break;
                case 1:
@@ -372,3 +373,44 @@ int run_diff_index(struct rev_info *revs, int cached)
        diff_flush(&revs->diffopt);
        return ret;
 }
+
+int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
+{
+       struct tree *tree;
+       struct rev_info revs;
+       int i;
+       struct cache_entry **dst;
+       struct cache_entry *last = NULL;
+
+       /*
+        * This is used by git-blame to run diff-cache internally;
+        * it potentially needs to repeatedly run this, so we will
+        * start by removing the higher order entries the last round
+        * left behind.
+        */
+       dst = active_cache;
+       for (i = 0; i < active_nr; i++) {
+               struct cache_entry *ce = active_cache[i];
+               if (ce_stage(ce)) {
+                       if (last && !strcmp(ce->name, last->name))
+                               continue;
+                       cache_tree_invalidate_path(active_cache_tree,
+                                                  ce->name);
+                       last = ce;
+                       ce->ce_mode = 0;
+                       ce->ce_flags &= ~htons(CE_STAGEMASK);
+               }
+               *dst++ = ce;
+       }
+       active_nr = dst - active_cache;
+
+       init_revisions(&revs, NULL);
+       revs.prune_data = opt->paths;
+       tree = parse_tree_indirect(tree_sha1);
+       if (!tree)
+               die("bad tree object %s", sha1_to_hex(tree_sha1));
+       if (read_tree(tree, 1, opt->paths))
+               return error("unable to read tree %s", sha1_to_hex(tree_sha1));
+       return diff_cache(&revs, active_cache, active_nr, revs.prune_data,
+                         1, 0);
+}
diff --git a/diff.h b/diff.h
index 7a347cf77d448817014ceeaed2d3cd99b5894ac6..eece65ddccdb7bd8bf51af80af92e29b4eb76f37 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -222,6 +222,7 @@ extern int run_diff_files(struct rev_info *revs, int silent_on_removed);
 
 extern int run_diff_index(struct rev_info *revs, int cached);
 
+extern int do_diff_cache(const unsigned char *, struct diff_options *);
 extern int diff_flush_patch_id(struct diff_options *, unsigned char *);
 
 #endif /* DIFF_H */
index 2e15781246c4a5997eb595885801fe7c6e741495..66aaeae1021eb3c791815f927e95a87e7afa557c 100755 (executable)
@@ -95,6 +95,15 @@ END
 my $tmp = tempdir('git-archimport-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 $opt_v && print "+ Using $tmp as temporary directory\n";
 
+unless (-d $git_dir) { # initial import needs empty directory
+    opendir DIR, '.' or die "Unable to open current directory: $!\n";
+    while (my $entry = readdir DIR) {
+        $entry =~ /^\.\.?$/ or
+            die "Initial import needs an empty current working directory.\n"
+    }
+    closedir DIR
+}
+
 my %reachable = ();             # Arch repositories we can access
 my %unreachable = ();           # Arch repositories we can't access :<
 my @psets  = ();                # the collection
index 6da31e87a01af9b883958b3b0bae4304bfa94520..b1c3a6b1c1af9815db473595f4eb3e9593425f10 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-USAGE='[start|bad|good|next|reset|visualize]'
+USAGE='[start|bad|good|next|reset|visualize|replay|log]'
 LONG_USAGE='git bisect start [<pathspec>]      reset bisect state and start bisection.
 git bisect bad [<rev>]         mark <rev> a known-bad revision.
 git bisect good [<rev>...]     mark <rev>... known-good revisions.
@@ -11,6 +11,7 @@ git bisect replay <logfile>   replay bisection log
 git bisect log                 show bisect log.'
 
 . git-sh-setup
+require_work_tree
 
 sq() {
        @@PERL@@ -e '
@@ -152,7 +153,7 @@ bisect_next() {
        nr=$(eval "git-rev-list $rev $good -- $(cat $GIT_DIR/BISECT_NAMES)" | wc -l) || exit
        echo "Bisecting: $nr revisions left to test after this"
        echo "$rev" > "$GIT_DIR/refs/heads/new-bisect"
-       git checkout new-bisect || exit
+       git checkout -q new-bisect || exit
        mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" &&
        GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD refs/heads/bisect
        git-show-branch "$rev"
index 8500f51ea27054d328be6e7e53c9f14d0d9c1979..14835a4aa982af88d758ea014afacf7b2fb1bb1e 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-USAGE='[-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]'
+USAGE='[-q] [-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]'
 SUBDIRECTORY_OK=Sometimes
 . git-sh-setup
 require_work_tree
@@ -15,6 +15,7 @@ branch=
 newbranch=
 newbranch_log=
 merge=
+quiet=
 LF='
 '
 while [ "$#" != "0" ]; do
@@ -40,6 +41,9 @@ while [ "$#" != "0" ]; do
        -m)
                merge=1
                ;;
+       "-q")
+               quiet=1
+               ;;
        --)
                break
                ;;
@@ -153,35 +157,25 @@ detach_warn=
 if test -z "$branch$newbranch" && test "$new" != "$old"
 then
        detached="$new"
-       if test -n "$oldbranch"
+       if test -n "$oldbranch" && test -z "$quiet"
        then
-               detach_warn="warning: you are not on ANY branch anymore.
-If you meant to create a new branch from this checkout, you may still do
-so (now or later) by using -b with the checkout command again.  Example:
+               detach_warn="Note: moving to \"$new_name\" which isn't a local branch
+If you want to create a new branch from this checkout, you may do so
+(now or later) by using -b with the checkout command again. Example:
   git checkout -b <new_branch_name>"
        fi
-elif test -z "$oldbranch" && test -n "$branch"
+elif test -z "$oldbranch" && test -z "$quiet"
 then
-       # Coming back...
-       if test -z "$force"
-       then
-               git show-ref -d -s | grep "$old" >/dev/null || {
-                       echo >&2 \
-"You are not on any branch and switching to branch '$new_name'
-may lose your changes.  At this point, you can do one of two things:
- (1) Decide it is Ok and say 'git checkout -f $new_name';
- (2) Start a new branch from the current commit, by saying
-     'git checkout -b <branch-name>'.
-Leaving your HEAD detached; not switching to branch '$new_name'."
-                       exit 1;
-               }
-       fi
+       echo >&2 "Previous HEAD position was $old"
 fi
 
 if [ "X$old" = X ]
 then
-       echo >&2 "warning: You appear to be on a branch yet to be born."
-       echo >&2 "warning: Forcing checkout of $new_name."
+       if test -z "$quiet"
+       then
+               echo >&2 "warning: You appear to be on a branch yet to be born."
+               echo >&2 "warning: Forcing checkout of $new_name."
+       fi
        force=1
 fi
 
@@ -226,9 +220,9 @@ else
        exit 0
     )
     saved_err=$?
-    if test "$saved_err" = 0
+    if test "$saved_err" = 0 && test -z "$quiet"
     then
-       test "$new" = "$old" || git diff-index --name-status "$new"
+       git diff-index --name-status "$new"
     fi
     (exit $saved_err)
 fi
@@ -250,7 +244,11 @@ if [ "$?" -eq 0 ]; then
        fi
        if test -n "$branch"
        then
-               GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD "refs/heads/$branch"
+               GIT_DIR="$GIT_DIR" git-symbolic-ref -m "checkout: moving to $branch" HEAD "refs/heads/$branch"
+               if test -z "$quiet"
+               then
+                       echo >&2 "Switched to${newbranch:+ a new} branch \"$branch\""
+               fi
        elif test -n "$detached"
        then
                # NEEDSWORK: we would want a command to detach the HEAD
@@ -259,8 +257,9 @@ if [ "$?" -eq 0 ]; then
                #       git update-ref --detach HEAD $new
                # or something like that...
                #
-               echo "$detached" >"$GIT_DIR/HEAD.new" &&
-               mv "$GIT_DIR/HEAD.new" "$GIT_DIR/HEAD" ||
+               git-rev-parse HEAD >"$GIT_DIR/HEAD.new" &&
+               mv "$GIT_DIR/HEAD.new" "$GIT_DIR/HEAD" &&
+               git-update-ref -m "checkout: moving to $arg" HEAD "$detached" ||
                        die "Cannot detach HEAD"
                if test -n "$detach_warn"
                then
index 3d83acbfc8908cf5f17ea50f19fa4cde3ef43e59..1bd54ded3c424db30ca46b00b3ed42b4d774d21d 100755 (executable)
@@ -123,7 +123,7 @@ while
                shift
                upload_pack="--upload-pack=$1" ;;
        *,--upload-pack=*)
-               upload_pack=--upload-pack=$(expr "$1" : '-[^=]*=\(.*\)') ;;
+               upload_pack=--upload-pack=$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
        1,--depth) usage;;
        *,--depth)
                shift
@@ -178,19 +178,32 @@ esac && export GIT_DIR && git-init ${template+"$template"} || usage
 
 if test -n "$reference"
 then
+       ref_git=
        if test -d "$reference"
        then
                if test -d "$reference/.git/objects"
                then
-                       reference="$reference/.git"
+                       ref_git="$reference/.git"
+               elif test -d "$reference/objects"
+               then
+                       ref_git="$reference"
                fi
-               reference=$(cd "$reference" && pwd)
-               echo "$reference/objects" >"$GIT_DIR/objects/info/alternates"
-               (cd "$reference" && tar cf - refs) |
-               (cd "$GIT_DIR/refs" &&
-                mkdir reference-tmp &&
-                cd reference-tmp &&
-                tar xf -)
+       fi
+       if test -n "$ref_git"
+       then
+               ref_git=$(cd "$ref_git" && pwd)
+               echo "$ref_git/objects" >"$GIT_DIR/objects/info/alternates"
+               (
+                       GIT_DIR="$ref_git" git for-each-ref \
+                               --format='%(objectname) %(*objectname)'
+               ) |
+               while read a b
+               do
+                       test -z "$a" ||
+                       git update-ref "refs/reference-tmp/$a" "$a"
+                       test -z "$b" ||
+                       git update-ref "refs/reference-tmp/$b" "$b"
+               done
        else
                die "reference repository '$reference' is not a local directory."
        fi
index dc0fc3b679c78f2a1884658d556cc888a6d3e441..ec506d956fa2858897c53b35d28db8083b7fdcec 100755 (executable)
@@ -528,6 +528,7 @@ else
        rloga='commit (initial)'
        current=''
 fi
+set_reflog_action "$rloga"
 
 if test -z "$no_edit"
 then
@@ -602,7 +603,7 @@ then
        fi &&
        commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&
        rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) &&
-       git-update-ref -m "$rloga: $rlogm" HEAD $commit "$current" &&
+       git-update-ref -m "$GIT_REFLOG_ACTION: $rlogm" HEAD $commit "$current" &&
        rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" &&
        if test -f "$NEXT_INDEX"
        then
index 4863c91fe3c713c9e1b05d78b9bd22583ff4a4c0..870554eade66d1744c561d4cba33c41dd7701e55 100755 (executable)
@@ -15,9 +15,9 @@
     die "GIT_DIR is not defined or is unreadable";
 }
 
-our ($opt_h, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m );
+our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m );
 
-getopts('hpvcfam:');
+getopts('hPpvcfam:');
 
 $opt_h && usage();
 
@@ -89,7 +89,7 @@
            last;
        }; # found it
     }
-    die "Did not find $parent in the parents for this commit!" if !$found;
+    die "Did not find $parent in the parents for this commit!" if !$found and !$opt_P;
 } else { # we don't have a parent from the cmdline...
     if (@parents == 1) { # it's safe to get it from the commit
        $parent = $parents[0];
index c1f6e1e84147d7bedd32e4534a5bb9cdb83a52e5..357cac28b2e44abb8356368761be78b378e5ae2e 100755 (executable)
@@ -37,7 +37,7 @@ do
                ;;
        --upl=*|--uplo=*|--uploa=*|--upload=*|\
        --upload-=*|--upload-p=*|--upload-pa=*|--upload-pac=*|--upload-pack=*)
-               exec=--upload-pack=$(expr "$1" : '-[^=]*=\(.*\)')
+               exec=--upload-pack=$(expr "z$1" : 'z-[^=]*=\(.*\)')
                shift
                ;;
        -f|--f|--fo|--for|--forc|--force)
index e6f574b99b56648e277d128911eb875380f279db..8ea5c5e816c067db88f04bc5a0613ca1dbb13456 100755 (executable)
@@ -27,7 +27,7 @@ do
        shift;;
   -u=*|--u=*|--up=*|--upl=*|--uplo=*|--uploa=*|--upload=*|\
   --upload-=*|--upload-p=*|--upload-pa=*|--upload-pac=*|--upload-pack=*)
-       exec=--upload-pack=$(expr "$1" : '-[^=]*=\(.*\)')
+       exec=--upload-pack=$(expr "z$1" : 'z-[^=]*=\(.*\)')
        shift;;
   --)
   shift; break ;;
index 0a8ef216cb8a45df7f900a0c9698bec3e4bb47bb..75e1de49ac9adb443e6065c93ac691c27f0f5518 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Linus Torvalds
 # Copyright (c) 2005 Junio C Hamano
 #
-# Resolve two trees, using enhancd multi-base read-tree.
+# Resolve two trees, using enhanced multi-base read-tree.
 
 # The first parameters up to -- are merge bases; the rest are heads.
 bases= head= remotes= sep_seen=
index 3e783b7b056de113584e526835a23fb05dfdcfce..5208ee6ce0bb07dd22ad5ca63ee469cb03011164 100755 (executable)
@@ -174,12 +174,8 @@ canon_refs_list_for_fetch () {
                else
                        for merge_branch in $merge_branches
                        do
-                           if  test "$remote" = "$merge_branch" ||
-                               test "$local" = "$merge_branch"
-                           then
-                                   dot_prefix=
-                                   break
-                           fi
+                           [ "$remote" = "$merge_branch" ] &&
+                           dot_prefix= && break
                        done
                fi
                case "$remote" in
index 2ae1f20c2e90a34ee9c1c37ffa239ff9fa0798c8..671a5ff865b6ab891da4251ee3dd90892b13cbad 100755 (executable)
@@ -59,7 +59,7 @@ if ! [ -d "$QUILT_PATCHES" ] ; then
        exit 1
 fi
 
-# Temporay directories
+# Temporary directories
 tmp_dir=.dotest
 tmp_msg="$tmp_dir/msg"
 tmp_patch="$tmp_dir/patch"
index 99cedadda1da1ba2f62c22acfbd6477b1b2b38cb..9d2f71d15c47ae69eed57a7301d47c93d5bb070a 100755 (executable)
@@ -249,7 +249,8 @@ fi
 git-update-index --refresh || exit
 diff=$(git-diff-index --cached --name-status -r HEAD)
 case "$diff" in
-?*)    echo "$diff"
+?*)    echo "cannot rebase: your index is not up-to-date"
+       echo "$diff"
        exit 1
        ;;
 esac
index c813fe14518fc12cb8260d053d0b87d834eed47d..c56c5a84a4ac67648efd3c5ccf690e9cb21dd54f 100755 (executable)
@@ -130,7 +130,7 @@ sub update_ls_remote {
        $info->{'LS_REMOTE'} = \@ref;
 }
 
-sub show_wildcard_mapping {
+sub list_wildcard_mapping {
        my ($forced, $ours, $ls) = @_;
        my %refs;
        for (@$ls) {
@@ -156,25 +156,14 @@ sub show_wildcard_mapping {
                        push @tracked, $_;
                }
        }
-       if (@new) {
-               print "  New remote branches (next fetch will store in remotes/$ours)\n";
-               print "    @new\n";
-       }
-       if (@stale) {
-               print "  Stale tracking branches in remotes/$ours (you'd better remove them)\n";
-               print "    @stale\n";
-       }
-       if (@tracked) {
-               print "  Tracked remote branches\n";
-               print "    @tracked\n";
-       }
+       return \@new, \@stale, \@tracked;
 }
 
-sub show_mapping {
+sub list_mapping {
        my ($name, $info) = @_;
        my $fetch = $info->{'FETCH'};
        my $ls = $info->{'LS_REMOTE'};
-       my (@stale, @tracked);
+       my (@new, @stale, @tracked);
 
        for (@$fetch) {
                next unless (/(\+)?([^:]+):(.*)/);
@@ -182,7 +171,11 @@ sub show_mapping {
                if ($theirs eq 'refs/heads/*' &&
                    $ours =~ /^refs\/remotes\/(.*)\/\*$/) {
                        # wildcard mapping
-                       show_wildcard_mapping($forced, $1, $ls);
+                       my ($w_new, $w_stale, $w_tracked)
+                               = list_wildcard_mapping($forced, $1, $ls);
+                       push @new, @$w_new;
+                       push @stale, @$w_stale;
+                       push @tracked, @$w_tracked;
                }
                elsif ($theirs =~ /\*/ || $ours =~ /\*/) {
                        print STDERR "Warning: unrecognized mapping in remotes.$name.fetch: $_\n";
@@ -196,13 +189,40 @@ sub show_mapping {
                        }
                }
        }
-       if (@stale) {
-               print "  Stale tracking branches in remotes/$name (you'd better remove them)\n";
-               print "    @stale\n";
+       return \@new, \@stale, \@tracked;
+}
+
+sub show_mapping {
+       my ($name, $info) = @_;
+       my ($new, $stale, $tracked) = list_mapping($name, $info);
+       if (@$new) {
+               print "  New remote branches (next fetch will store in remotes/$name)\n";
+               print "    @$new\n";
        }
-       if (@tracked) {
+       if (@$stale) {
+               print "  Stale tracking branches in remotes/$name (use 'git remote prune')\n";
+               print "    @$stale\n";
+       }
+       if (@$tracked) {
                print "  Tracked remote branches\n";
-               print "    @tracked\n";
+               print "    @$tracked\n";
+       }
+}
+
+sub prune_remote {
+       my ($name, $ls_remote) = @_;
+       if (!exists $remote->{$name}) {
+               print STDERR "No such remote $name\n";
+               return;
+       }
+       my $info = $remote->{$name};
+       update_ls_remote($ls_remote, $info);
+
+       my ($new, $stale, $tracked) = list_mapping($name, $info);
+       my $prefix = "refs/remotes/$name";
+       foreach my $to_prune (@$stale) {
+               my @v = $git->command(qw(rev-parse --verify), "$prefix/$to_prune");
+               $git->command(qw(update-ref -d), "$prefix/$to_prune", $v[0]);
        }
 }
 
@@ -233,14 +253,30 @@ sub show_remote {
 }
 
 sub add_remote {
-       my ($name, $url) = @_;
+       my ($name, $url, $opts) = @_;
        if (exists $remote->{$name}) {
                print STDERR "remote $name already exists.\n";
                exit(1);
        }
        $git->command('config', "remote.$name.url", $url);
-       $git->command('config', "remote.$name.fetch",
-                     "+refs/heads/*:refs/remotes/$name/*");
+       my $track = $opts->{'track'} || ["*"];
+
+       for (@$track) {
+               $git->command('config', '--add', "remote.$name.fetch",
+                             "+refs/heads/$_:refs/remotes/$name/$_");
+       }
+       if ($opts->{'fetch'}) {
+               $git->command('fetch', $name);
+       }
+       if (exists $opts->{'master'}) {
+               $git->command('symbolic-ref', "refs/remotes/$name/HEAD",
+                             "refs/remotes/$name/$opts->{'master'}");
+       }
+}
+
+sub add_usage {
+       print STDERR "Usage: git remote add [-f] [-t track]* [-m master] <name> <url>\n";
+       exit(1);
 }
 
 if (!@ARGV) {
@@ -267,16 +303,62 @@ sub add_remote {
                show_remote($ARGV[$i], $ls_remote);
        }
 }
+elsif ($ARGV[0] eq 'prune') {
+       my $ls_remote = 1;
+       my $i;
+       for ($i = 1; $i < @ARGV; $i++) {
+               if ($ARGV[$i] eq '-n') {
+                       $ls_remote = 0;
+               }
+               else {
+                       last;
+               }
+       }
+       if ($i >= @ARGV) {
+               print STDERR "Usage: git remote prune <remote>\n";
+               exit(1);
+       }
+       for (; $i < @ARGV; $i++) {
+               prune_remote($ARGV[$i], $ls_remote);
+       }
+}
 elsif ($ARGV[0] eq 'add') {
+       my %opts = ();
+       while (1 < @ARGV && $ARGV[1] =~ /^-/) {
+               my $opt = $ARGV[1];
+               shift @ARGV;
+               if ($opt eq '-f' || $opt eq '--fetch') {
+                       $opts{'fetch'} = 1;
+                       next;
+               }
+               if ($opt eq '-t' || $opt eq '--track') {
+                       if (@ARGV < 1) {
+                               add_usage();
+                       }
+                       $opts{'track'} ||= [];
+                       push @{$opts{'track'}}, $ARGV[1];
+                       shift @ARGV;
+                       next;
+               }
+               if ($opt eq '-m' || $opt eq '--master') {
+                       if ((@ARGV < 1) || exists $opts{'master'}) {
+                               add_usage();
+                       }
+                       $opts{'master'} = $ARGV[1];
+                       shift @ARGV;
+                       next;
+               }
+               add_usage();
+       }
        if (@ARGV != 3) {
-               print STDERR "Usage: git remote add <name> <url>\n";
-               exit(1);
+               add_usage();
        }
-       add_remote($ARGV[1], $ARGV[2]);
+       add_remote($ARGV[1], $ARGV[2], \%opts);
 }
 else {
        print STDERR "Usage: git remote\n";
        print STDERR "       git remote add <name> <url>\n";
        print STDERR "       git remote show <name>\n";
+       print STDERR "       git remote prune <name>\n";
        exit(1);
 }
index 866d622d2344a4bd1fea579fd5d1d6aee6615eee..49f00321b28833c24ebb78ea2104f34091d43017 100755 (executable)
@@ -54,6 +54,8 @@ do
        shift
 done
 
+set_reflog_action "$me"
+
 test "$me,$replay" = "revert,t" && usage
 
 case "$no_commit" in
index b4aa4b2f4e6b53388ea9ec0ac13316ae0d0d4458..f24c7f2d23c13e9874308a019f3c0f93225de3c0 100755 (executable)
@@ -48,7 +48,8 @@ cd_to_toplevel () {
 }
 
 require_work_tree () {
-       test $(is_bare_repository) = false ||
+       test $(is_bare_repository) = false &&
+       test $(git-rev-parse --is-inside-git-dir) = false ||
        die "fatal: $0 cannot be used without a working tree."
 }
 
index 68156fc8a5d3e886fae61dae531f647e35b4899d..8ebaae9ff8865ab638f7a2db8c64f2d22f227470 100755 (executable)
@@ -681,7 +681,7 @@ sub show_log {
                process_commit($_, $r_min, $r_max) foreach reverse @k;
        }
 out:
-       eval { command_close_pipe($log) };
+       close $log;
        print '-' x72,"\n" unless $_incremental || $_oneline;
 }
 
@@ -1475,7 +1475,7 @@ sub map_tree_joins {
                                $seen{$commit} = 1;
                        }
                }
-               eval { command_close_pipe($pipe) };
+               close $pipe;
        }
 }
 
@@ -1669,7 +1669,7 @@ sub write_grafts {
                                last unless /^\S/;
                        }
                }
-               eval { command_close_pipe($ch) }; # breaking the pipe
+               close $ch; # breaking the pipe
 
                # if real parents are the only ones in the grafts, drop it
                next if join(' ',sort keys %$p) eq join(' ',sort keys %x);
@@ -1766,7 +1766,7 @@ sub get_commit_time {
                } elsif ($tz =~ s/^\-//) {
                        $s -= tz_to_s_offset($tz);
                }
-               eval { command_close_pipe($fh) };
+               close $fh;
                return $s;
        }
        die "Can't get commit time for commit: $cmt\n";
@@ -2846,7 +2846,7 @@ sub rmdirs {
                        delete $rm->{join '/', @dn};
                }
                unless (%$rm) {
-                       eval { command_close_pipe($fh) };
+                       close $fh;
                        return;
                }
        }
index 988bf4c6a6b52af4d4a1b792090c317b9d799755..4a0a7b660780b7c377ce80ac49dc99cea3e8137d 100755 (executable)
@@ -113,8 +113,9 @@ object=$(git-rev-parse --verify --default HEAD "$@") || exit 1
 type=$(git-cat-file -t $object) || exit 1
 tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
 
-keyid=$(git-repo-config user.signingkey) ||
-       keyid=$(expr "z$tagger" : 'z\(.*>\)')
+test -n "$username" ||
+       username=$(git-repo-config user.signingkey) ||
+       username=$(expr "z$tagger" : 'z\(.*>\)')
 
 trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
 
@@ -141,7 +142,7 @@ if [ "$annotate" ]; then
       cat "$GIT_DIR"/TAG_FINALMSG ) >"$GIT_DIR"/TAG_TMP
     rm -f "$GIT_DIR"/TAG_TMP.asc "$GIT_DIR"/TAG_FINALMSG
     if [ "$signed" ]; then
-       gpg -bsa -u "$keyid" "$GIT_DIR"/TAG_TMP &&
+       gpg -bsa -u "$username" "$GIT_DIR"/TAG_TMP &&
        cat "$GIT_DIR"/TAG_TMP.asc >>"$GIT_DIR"/TAG_TMP ||
        die "failed to sign the tag with GPG."
     fi
diff --git a/git.c b/git.c
index fb03a547de16af8d9201dc41e9a6f2e37680688b..82a8357272bee1ad6d452a19bf9270f94d94a6cc 100644 (file)
--- a/git.c
+++ b/git.c
@@ -299,8 +299,9 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
                        prefix = setup_git_directory();
                if (p->option & USE_PAGER)
                        setup_pager();
-               if ((p->option & NOT_BARE) && is_bare_repository())
-                       die("%s cannot be used in a bare git directory", cmd);
+               if ((p->option & NOT_BARE) &&
+                               (is_bare_repository() || is_inside_git_dir()))
+                       die("%s must be run in a work tree", cmd);
                trace_argv_printf(argv, argc, "trace: built-in: git");
 
                exit(p->fn(argc, argv, prefix));
index fb95e375948ed84abd9c433294692b12e2ff1b8d..1213325e5706e9ea0165b5df0a096e410ac4dbf0 100644 (file)
@@ -89,7 +89,8 @@ make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" WITH_OWN_SUBPROCESS_PY=YesPlease \
 
 %install
 rm -rf $RPM_BUILD_ROOT
-make %{_smp_mflags} DESTDIR=$RPM_BUILD_ROOT WITH_OWN_SUBPROCESS_PY=YesPlease \
+make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" DESTDIR=$RPM_BUILD_ROOT \
+     WITH_OWN_SUBPROCESS_PY=YesPlease \
      prefix=%{_prefix} mandir=%{_mandir} INSTALLDIRS=vendor \
      install %{!?_without_docs: install-doc}
 find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} ';'
index b606c1d3e7d36f432965bfffd808b127f2cf1887..653ca3cc60ef161f06bd3a6652eba7ad3453cc2e 100755 (executable)
@@ -834,7 +834,7 @@ sub file_type_long {
 
 ## ----------------------------------------------------------------------
 ## functions returning short HTML fragments, or transforming HTML fragments
-## which don't beling to other sections
+## which don't belong to other sections
 
 # format line of commit message.
 sub format_log_line_html {
@@ -1690,7 +1690,7 @@ sub git_header_html {
 
        my $title = "$site_name";
        if (defined $project) {
-               $title .= " - $project";
+               $title .= " - " . to_utf8($project);
                if (defined $action) {
                        $title .= "/$action";
                        if (defined $file_name) {
@@ -1963,7 +1963,7 @@ sub git_print_page_path {
 
        print "<div class=\"page_path\">";
        print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
-                     -title => 'tree root'}, "[$project]");
+                     -title => 'tree root'}, to_utf8("[$project]"));
        print " / ";
        if (defined $name) {
                my @dirname = split '/', $name;
@@ -3610,7 +3610,7 @@ sub git_snapshot {
                $hash = git_get_head_hash($project);
        }
 
-       my $filename = basename($project) . "-$hash.tar.$suffix";
+       my $filename = to_utf8(basename($project)) . "-$hash.tar.$suffix";
 
        print $cgi->header(
                -type => "application/$ctype",
diff --git a/ident.c b/ident.c
index a6fc7b5e11e3f232a7becd62223cc23c5eb68ccc..bb03bddd34f2471ed130c499affc369758d4bfd9 100644 (file)
--- a/ident.c
+++ b/ident.c
@@ -185,8 +185,8 @@ static const char *env_hint =
 "Add --global to set your account\'s default\n"
 "\n";
 
-static const char *get_ident(const char *name, const char *email,
-                            const char *date_str, int error_on_no_name)
+const char *fmt_ident(const char *name, const char *email,
+                     const char *date_str, int error_on_no_name)
 {
        static char buffer[1000];
        char date[50];
@@ -233,7 +233,7 @@ static const char *get_ident(const char *name, const char *email,
 
 const char *git_author_info(int error_on_no_name)
 {
-       return get_ident(getenv("GIT_AUTHOR_NAME"),
+       return fmt_ident(getenv("GIT_AUTHOR_NAME"),
                         getenv("GIT_AUTHOR_EMAIL"),
                         getenv("GIT_AUTHOR_DATE"),
                         error_on_no_name);
@@ -241,7 +241,7 @@ const char *git_author_info(int error_on_no_name)
 
 const char *git_committer_info(int error_on_no_name)
 {
-       return get_ident(getenv("GIT_COMMITTER_NAME"),
+       return fmt_ident(getenv("GIT_COMMITTER_NAME"),
                         getenv("GIT_COMMITTER_EMAIL"),
                         getenv("GIT_COMMITTER_DATE"),
                         error_on_no_name);
index fa320eb6b1a9e257167e7f843fe36cbdfd908726..58989424d77467da018e7daf5761f1f85040d2f6 100644 (file)
@@ -386,7 +386,7 @@ struct rename
 };
 
 /*
- * Get information of all renames which occured between 'o_tree' and
+ * Get information of all renames which occurred between 'o_tree' and
  * 'tree'. We need the three trees in the merge ('o_tree', 'a_tree' and
  * 'b_tree') to be able to associate the correct cache entries with
  * the rename information. 'tree' is always equal to either a_tree or b_tree.
@@ -891,7 +891,7 @@ static int process_renames(struct path_list *a_renames,
                        struct diff_filespec src_other, dst_other;
                        int try_merge, stage = a_renames == renames1 ? 3: 2;
 
-                       remove_file(1, ren1_src, index_only);
+                       remove_file(1, ren1_src, index_only || stage == 3);
 
                        hashcpy(src_other.sha1, ren1->src_entry->stages[stage].sha);
                        src_other.mode = ren1->src_entry->stages[stage].mode;
@@ -1175,7 +1175,7 @@ static struct commit_list *reverse_commit_list(struct commit_list *list)
 
 /*
  * Merge the commits h1 and h2, return the resulting virtual
- * commit object and a flag indicating the cleaness of the merge.
+ * commit object and a flag indicating the cleanness of the merge.
  */
 static int merge(struct commit *h1,
                 struct commit *h2,
@@ -1213,7 +1213,7 @@ static int merge(struct commit *h1,
 
                tree->object.parsed = 1;
                tree->object.type = OBJ_TREE;
-               write_sha1_file(NULL, 0, tree_type, tree->object.sha1);
+               pretend_sha1_file(NULL, 0, tree_type, tree->object.sha1);
                merged_common_ancestors = make_virtual_commit(tree, "ancestor");
        }
 
@@ -1222,8 +1222,8 @@ static int merge(struct commit *h1,
                /*
                 * When the merge fails, the result contains files
                 * with conflict markers. The cleanness flag is
-                * ignored, it was never acutally used, as result of
-                * merge_trees has always overwritten it: the commited
+                * ignored, it was never actually used, as result of
+                * merge_trees has always overwritten it: the committed
                 * "conflicts" were already resolved.
                 */
                discard_cache();
diff --git a/pager.c b/pager.c
index 4587fbbdb51e50c1e3e6e4c3476cdccd4ac59cee..5f280ab52720772905cacbcba522ecc9c81bb529 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -1,5 +1,7 @@
 #include "cache.h"
 
+#include <sys/select.h>
+
 /*
  * This is split up from the rest of git so that we might do
  * something different on Windows, for example.
@@ -7,6 +9,16 @@
 
 static void run_pager(const char *pager)
 {
+       /*
+        * Work around bug in "less" by not starting it until we
+        * have real input
+        */
+       fd_set in;
+
+       FD_ZERO(&in);
+       FD_SET(0, &in);
+       select(1, &in, NULL, &in, NULL);
+
        execlp(pager, pager, NULL);
        execl("/bin/sh", "sh", "-c", pager, NULL);
 }
index 5d1ccaa125e8322b687a70af5da98798034bc971..f2c156cde9c1ae62af12d2c213ac8b3a2cc71f21 100644 (file)
@@ -354,7 +354,7 @@ sub command_input_pipe {
 =item command_close_pipe ( PIPE [, CTX ] )
 
 Close the C<PIPE> as returned from C<command_*_pipe()>, checking
-whether the command finished successfuly. The optional C<CTX> argument
+whether the command finished successfully. The optional C<CTX> argument
 is required if you want to see the command name in the error message,
 and it is the second value returned by C<command_*_pipe()> when
 called in array context. The call idiom is:
index 8fff86699fc4585ef9378150d3a60edf911ecc8c..11e9cd9a02eb3f85a9150c6fb06d1fc76abd9b09 100644 (file)
@@ -781,7 +781,7 @@ =head1 $Error::ObjectifyCallback
 
 This variable holds a reference to a subroutine that converts errors that
 are plain strings to objects. It is used by Error.pm to convert textual
-errors to objects, and can be overrided by the user.
+errors to objects, and can be overridden by the user.
 
 It accepts a single argument which is a hash reference to named parameters.
 Currently the only named parameter passed is C<'text'> which is the text
index 140cb53370fb23eb56b1872a2f328a0840e2820f..f132696ee72bf4a2e3d608a24322a6839f9a03a8 100644 (file)
@@ -18,7 +18,7 @@
  * %r0 - temp
  * %r3 - argument (pointer to 5 words of SHA state)
  * %r4 - argument (pointer to data to hash)
- * %r5 - Contant K in SHA round (initially number of blocks to hash)
+ * %r5 - Constant K in SHA round (initially number of blocks to hash)
  * %r6-%r10 - Working copies of SHA variables A..E (actually E..A order)
  * %r11-%r26 - Data being hashed W[].
  * %r27-%r31 - Previous copies of A..E, for final add back.
@@ -48,7 +48,7 @@
  * E += ROTL(A,5) + F(B,C,D) + W[i] + K;  B = ROTL(B,30)
  * Then the variables are renamed: (A,B,C,D,E) = (E,A,B,C,D).
  *
- * Every 20 rounds, the function F() and the contant K changes:
+ * Every 20 rounds, the function F() and the constant K changes:
  * - 20 rounds of f0(b,c,d) = "bit wise b ? c : d" =  (^b & d) + (b & c)
  * - 20 rounds of f1(b,c,d) = b^c^d = (b^d)^c
  * - 20 rounds of f2(b,c,d) = majority(b,c,d) = (b&d) + ((b^d)&c)
@@ -57,7 +57,7 @@
  * These are all scheduled for near-optimal performance on a G4.
  * The G4 is a 3-issue out-of-order machine with 3 ALUs, but it can only
  * *consider* starting the oldest 3 instructions per cycle.  So to get
- * maximum performace out of it, you have to treat it as an in-order
+ * maximum performance out of it, you have to treat it as an in-order
  * machine.  Which means interleaving the computation round t with the
  * computation of W[t+4].
  *
index a6a334822a91f7325399740b0aa05e95f6fb4a70..01760d70462927ad33c7976a50e31372863a45f9 100644 (file)
@@ -188,9 +188,9 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog)
        /* Add all external refs */
        for_each_ref(add_one_ref, revs);
 
-       /* Add all reflog info from refs */
+       /* Add all reflog info */
        if (mark_reflog)
-               for_each_ref(add_one_reflog, revs);
+               for_each_reflog(add_one_reflog, revs);
 
        /*
         * Set up the revision walk - this will move all commits
index 82621601d63fff25c46d96b0ade5058fe4e16a28..653ec956f08141b3e15f52665cef7a260f8ed6a4 100644 (file)
@@ -165,6 +165,14 @@ void add_reflog_for_walk(struct reflog_walk_info *info,
        if (item)
                reflogs = item->util;
        else {
+               if (*branch == '\0') {
+                       unsigned char sha1[20];
+                       const char *head = resolve_ref("HEAD", sha1, 0, NULL);
+                       if (!head)
+                               die ("No current branch");
+                       free(branch);
+                       branch = xstrdup(head);
+               }
                reflogs = read_complete_reflog(branch);
                if (!reflogs || reflogs->nr == 0)
                        die("No reflogs found for '%s'", branch);
diff --git a/refs.c b/refs.c
index 3db444cad2b24a1b44ff8a2dae1aa6818b61cbea..03e8dfec9fcb2c9fffc7c809048fa90a0e02b0af 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -309,53 +309,6 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
        return ref;
 }
 
-int create_symref(const char *ref_target, const char *refs_heads_master)
-{
-       const char *lockpath;
-       char ref[1000];
-       int fd, len, written;
-       const char *git_HEAD = git_path("%s", ref_target);
-
-#ifndef NO_SYMLINK_HEAD
-       if (prefer_symlink_refs) {
-               unlink(git_HEAD);
-               if (!symlink(refs_heads_master, git_HEAD))
-                       return 0;
-               fprintf(stderr, "no symlink - falling back to symbolic ref\n");
-       }
-#endif
-
-       len = snprintf(ref, sizeof(ref), "ref: %s\n", refs_heads_master);
-       if (sizeof(ref) <= len) {
-               error("refname too long: %s", refs_heads_master);
-               return -1;
-       }
-       lockpath = mkpath("%s.lock", git_HEAD);
-       fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666);
-       if (fd < 0) {
-               error("Unable to open %s for writing", lockpath);
-               return -5;
-       }
-       written = write_in_full(fd, ref, len);
-       close(fd);
-       if (written != len) {
-               unlink(lockpath);
-               error("Unable to write to %s", lockpath);
-               return -2;
-       }
-       if (rename(lockpath, git_HEAD) < 0) {
-               unlink(lockpath);
-               error("Unable to create %s", git_HEAD);
-               return -3;
-       }
-       if (adjust_shared_perm(git_HEAD)) {
-               unlink(lockpath);
-               error("Unable to fix permissions on %s", lockpath);
-               return -4;
-       }
-       return 0;
-}
-
 int read_ref(const char *ref, unsigned char *sha1)
 {
        if (resolve_ref(ref, sha1, 1, NULL))
@@ -680,7 +633,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
        lock->lk = xcalloc(1, sizeof(struct lock_file));
 
        lock->ref_name = xstrdup(ref);
-       lock->log_file = xstrdup(git_path("logs/%s", ref));
+       lock->orig_ref_name = xstrdup(orig_ref);
        ref_file = git_path("%s", ref);
        lock->force_write = lstat(ref_file, &st) && errno == ENOENT;
 
@@ -778,10 +731,10 @@ int delete_ref(const char *refname, unsigned char *sha1)
         */
        ret |= repack_without_ref(refname);
 
-       err = unlink(lock->log_file);
+       err = unlink(git_path("logs/%s", lock->ref_name));
        if (err && errno != ENOENT)
                fprintf(stderr, "warning: unlink(%s) failed: %s",
-                       lock->log_file, strerror(errno));
+                       git_path("logs/%s", lock->ref_name), strerror(errno));
        invalidate_cached_refs();
        unlock_ref(lock);
        return ret;
@@ -922,47 +875,50 @@ void unlock_ref(struct ref_lock *lock)
                        rollback_lock_file(lock->lk);
        }
        free(lock->ref_name);
-       free(lock->log_file);
+       free(lock->orig_ref_name);
        free(lock);
 }
 
-static int log_ref_write(struct ref_lock *lock,
-       const unsigned char *sha1, const char *msg)
+static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
+                        const unsigned char *new_sha1, const char *msg)
 {
        int logfd, written, oflags = O_APPEND | O_WRONLY;
        unsigned maxlen, len;
        int msglen;
-       char *logrec;
+       char *log_file, *logrec;
        const char *committer;
 
        if (log_all_ref_updates < 0)
                log_all_ref_updates = !is_bare_repository();
 
+       log_file = git_path("logs/%s", ref_name);
+
        if (log_all_ref_updates &&
-           (!strncmp(lock->ref_name, "refs/heads/", 11) ||
-            !strncmp(lock->ref_name, "refs/remotes/", 13))) {
-               if (safe_create_leading_directories(lock->log_file) < 0)
+           (!strncmp(ref_name, "refs/heads/", 11) ||
+            !strncmp(ref_name, "refs/remotes/", 13) ||
+            !strcmp(ref_name, "HEAD"))) {
+               if (safe_create_leading_directories(log_file) < 0)
                        return error("unable to create directory for %s",
-                               lock->log_file);
+                                    log_file);
                oflags |= O_CREAT;
        }
 
-       logfd = open(lock->log_file, oflags, 0666);
+       logfd = open(log_file, oflags, 0666);
        if (logfd < 0) {
                if (!(oflags & O_CREAT) && errno == ENOENT)
                        return 0;
 
                if ((oflags & O_CREAT) && errno == EISDIR) {
-                       if (remove_empty_directories(lock->log_file)) {
+                       if (remove_empty_directories(log_file)) {
                                return error("There are still logs under '%s'",
-                                            lock->log_file);
+                                            log_file);
                        }
-                       logfd = open(lock->log_file, oflags, 0666);
+                       logfd = open(log_file, oflags, 0666);
                }
 
                if (logfd < 0)
                        return error("Unable to append to %s: %s",
-                                    lock->log_file, strerror(errno));
+                                    log_file, strerror(errno));
        }
 
        msglen = 0;
@@ -984,8 +940,8 @@ static int log_ref_write(struct ref_lock *lock,
        maxlen = strlen(committer) + msglen + 100;
        logrec = xmalloc(maxlen);
        len = sprintf(logrec, "%s %s %s\n",
-                     sha1_to_hex(lock->old_sha1),
-                     sha1_to_hex(sha1),
+                     sha1_to_hex(old_sha1),
+                     sha1_to_hex(new_sha1),
                      committer);
        if (msglen)
                len += sprintf(logrec + len - 1, "\t%.*s\n", msglen, msg) - 1;
@@ -993,7 +949,7 @@ static int log_ref_write(struct ref_lock *lock,
        free(logrec);
        close(logfd);
        if (written != len)
-               return error("Unable to append to %s", lock->log_file);
+               return error("Unable to append to %s", log_file);
        return 0;
 }
 
@@ -1016,7 +972,9 @@ int write_ref_sha1(struct ref_lock *lock,
                return -1;
        }
        invalidate_cached_refs();
-       if (log_ref_write(lock, sha1, logmsg) < 0) {
+       if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0 ||
+           (strcmp(lock->ref_name, lock->orig_ref_name) &&
+            log_ref_write(lock->orig_ref_name, lock->old_sha1, sha1, logmsg) < 0)) {
                unlock_ref(lock);
                return -1;
        }
@@ -1030,6 +988,65 @@ int write_ref_sha1(struct ref_lock *lock,
        return 0;
 }
 
+int create_symref(const char *ref_target, const char *refs_heads_master,
+                 const char *logmsg)
+{
+       const char *lockpath;
+       char ref[1000];
+       int fd, len, written;
+       char *git_HEAD = xstrdup(git_path("%s", ref_target));
+       unsigned char old_sha1[20], new_sha1[20];
+
+       if (logmsg && read_ref(ref_target, old_sha1))
+               hashclr(old_sha1);
+
+#ifndef NO_SYMLINK_HEAD
+       if (prefer_symlink_refs) {
+               unlink(git_HEAD);
+               if (!symlink(refs_heads_master, git_HEAD))
+                       goto done;
+               fprintf(stderr, "no symlink - falling back to symbolic ref\n");
+       }
+#endif
+
+       len = snprintf(ref, sizeof(ref), "ref: %s\n", refs_heads_master);
+       if (sizeof(ref) <= len) {
+               error("refname too long: %s", refs_heads_master);
+               goto error_free_return;
+       }
+       lockpath = mkpath("%s.lock", git_HEAD);
+       fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666);
+       if (fd < 0) {
+               error("Unable to open %s for writing", lockpath);
+               goto error_free_return;
+       }
+       written = write_in_full(fd, ref, len);
+       close(fd);
+       if (written != len) {
+               error("Unable to write to %s", lockpath);
+               goto error_unlink_return;
+       }
+       if (rename(lockpath, git_HEAD) < 0) {
+               error("Unable to create %s", git_HEAD);
+               goto error_unlink_return;
+       }
+       if (adjust_shared_perm(git_HEAD)) {
+               error("Unable to fix permissions on %s", lockpath);
+       error_unlink_return:
+               unlink(lockpath);
+       error_free_return:
+               free(git_HEAD);
+               return -1;
+       }
+
+       done:
+       if (logmsg && !read_ref(refs_heads_master, new_sha1))
+               log_ref_write(ref_target, old_sha1, new_sha1, logmsg);
+
+       free(git_HEAD);
+       return 0;
+}
+
 static char *ref_msg(const char *line, const char *endp)
 {
        const char *ep;
@@ -1186,3 +1203,53 @@ int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)
        return ret;
 }
 
+static int do_for_each_reflog(const char *base, each_ref_fn fn, void *cb_data)
+{
+       DIR *dir = opendir(git_path("logs/%s", base));
+       int retval = errno;
+
+       if (dir) {
+               struct dirent *de;
+               int baselen = strlen(base);
+               char *log = xmalloc(baselen + 257);
+
+               memcpy(log, base, baselen);
+               if (baselen && base[baselen-1] != '/')
+                       log[baselen++] = '/';
+
+               while ((de = readdir(dir)) != NULL) {
+                       struct stat st;
+                       int namelen;
+
+                       if (de->d_name[0] == '.')
+                               continue;
+                       namelen = strlen(de->d_name);
+                       if (namelen > 255)
+                               continue;
+                       if (has_extension(de->d_name, ".lock"))
+                               continue;
+                       memcpy(log + baselen, de->d_name, namelen+1);
+                       if (stat(git_path("logs/%s", log), &st) < 0)
+                               continue;
+                       if (S_ISDIR(st.st_mode)) {
+                               retval = do_for_each_reflog(log, fn, cb_data);
+                       } else {
+                               unsigned char sha1[20];
+                               if (!resolve_ref(log, sha1, 0, NULL))
+                                       retval = error("bad ref for %s", log);
+                               else
+                                       retval = fn(log, sha1, 0, cb_data);
+                       }
+                       if (retval)
+                               break;
+               }
+               free(log);
+               closedir(dir);
+       }
+       return retval;
+}
+
+int for_each_reflog(each_ref_fn fn, void *cb_data)
+{
+       return do_for_each_reflog("", fn, cb_data);
+}
diff --git a/refs.h b/refs.h
index 33450f13e781b5ab60956082c7d8b2dc31f64286..acedffc0e412e1de6137d665a7c6b32f58b1c20b 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -3,7 +3,7 @@
 
 struct ref_lock {
        char *ref_name;
-       char *log_file;
+       char *orig_ref_name;
        struct lock_file *lk;
        unsigned char old_sha1[20];
        int lock_fd;
@@ -48,6 +48,12 @@ extern int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned
 typedef int each_reflog_ent_fn(unsigned char *osha1, unsigned char *nsha1, const char *, unsigned long, int, const char *, void *);
 int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data);
 
+/*
+ * Calls the specified function for each reflog file until it returns nonzero,
+ * and returns the value
+ */
+extern int for_each_reflog(each_ref_fn, void *);
+
 /** Returns 0 if target has the right format for a ref. **/
 extern int check_ref_format(const char *target);
 
index 6cd38be3291e95e75a7d2348e825d49c8f7ad2af..f9be5a7f60c1cc5208e7c91367ecb28014106f18 100644 (file)
@@ -10,6 +10,8 @@ static FILE *info_ref_fp;
 static int add_info_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
 {
        struct object *o = parse_object(sha1);
+       if (!o)
+               return -1;
 
        fprintf(info_ref_fp, "%s        %s\n", sha1_to_hex(sha1), path);
        if (o->type == OBJ_TAG) {
index 498665e50c1a5053e29a80c37ad95b800bb0f86d..0d4bf80e74b16aa089acd06c24ad1b1a039e65b5 100644 (file)
@@ -552,7 +552,11 @@ void unuse_pack(struct pack_window **w_cursor)
        }
 }
 
-static void open_packed_git(struct packed_git *p)
+/*
+ * Do not call this directly as this leaks p->pack_fd on error return;
+ * call open_packed_git() instead.
+ */
+static int open_packed_git_1(struct packed_git *p)
 {
        struct stat st;
        struct pack_header hdr;
@@ -562,49 +566,61 @@ static void open_packed_git(struct packed_git *p)
 
        p->pack_fd = open(p->pack_name, O_RDONLY);
        if (p->pack_fd < 0 || fstat(p->pack_fd, &st))
-               die("packfile %s cannot be opened", p->pack_name);
+               return -1;
 
        /* If we created the struct before we had the pack we lack size. */
        if (!p->pack_size) {
                if (!S_ISREG(st.st_mode))
-                       die("packfile %s not a regular file", p->pack_name);
+                       return error("packfile %s not a regular file", p->pack_name);
                p->pack_size = st.st_size;
        } else if (p->pack_size != st.st_size)
-               die("packfile %s size changed", p->pack_name);
+               return error("packfile %s size changed", p->pack_name);
 
        /* We leave these file descriptors open with sliding mmap;
         * there is no point keeping them open across exec(), though.
         */
        fd_flag = fcntl(p->pack_fd, F_GETFD, 0);
        if (fd_flag < 0)
-               die("cannot determine file descriptor flags");
+               return error("cannot determine file descriptor flags");
        fd_flag |= FD_CLOEXEC;
        if (fcntl(p->pack_fd, F_SETFD, fd_flag) == -1)
-               die("cannot set FD_CLOEXEC");
+               return error("cannot set FD_CLOEXEC");
 
        /* Verify we recognize this pack file format. */
        if (read_in_full(p->pack_fd, &hdr, sizeof(hdr)) != sizeof(hdr))
-               die("file %s is far too short to be a packfile", p->pack_name);
+               return error("file %s is far too short to be a packfile", p->pack_name);
        if (hdr.hdr_signature != htonl(PACK_SIGNATURE))
-               die("file %s is not a GIT packfile", p->pack_name);
+               return error("file %s is not a GIT packfile", p->pack_name);
        if (!pack_version_ok(hdr.hdr_version))
-               die("packfile %s is version %u and not supported"
+               return error("packfile %s is version %u and not supported"
                        " (try upgrading GIT to a newer version)",
                        p->pack_name, ntohl(hdr.hdr_version));
 
        /* Verify the pack matches its index. */
        if (num_packed_objects(p) != ntohl(hdr.hdr_entries))
-               die("packfile %s claims to have %u objects"
+               return error("packfile %s claims to have %u objects"
                        " while index size indicates %u objects",
                        p->pack_name, ntohl(hdr.hdr_entries),
                        num_packed_objects(p));
        if (lseek(p->pack_fd, p->pack_size - sizeof(sha1), SEEK_SET) == -1)
-               die("end of packfile %s is unavailable", p->pack_name);
+               return error("end of packfile %s is unavailable", p->pack_name);
        if (read_in_full(p->pack_fd, sha1, sizeof(sha1)) != sizeof(sha1))
-               die("packfile %s signature is unavailable", p->pack_name);
+               return error("packfile %s signature is unavailable", p->pack_name);
        idx_sha1 = ((unsigned char *)p->index_base) + p->index_size - 40;
        if (hashcmp(sha1, idx_sha1))
-               die("packfile %s does not match index", p->pack_name);
+               return error("packfile %s does not match index", p->pack_name);
+       return 0;
+}
+
+static int open_packed_git(struct packed_git *p)
+{
+       if (!open_packed_git_1(p))
+               return 0;
+       if (p->pack_fd != -1) {
+               close(p->pack_fd);
+               p->pack_fd = -1;
+       }
+       return -1;
 }
 
 static int in_window(struct pack_window *win, unsigned long offset)
@@ -627,8 +643,8 @@ unsigned char* use_pack(struct packed_git *p,
 {
        struct pack_window *win = *w_cursor;
 
-       if (p->pack_fd == -1)
-               open_packed_git(p);
+       if (p->pack_fd == -1 && open_packed_git(p))
+               die("packfile %s cannot be accessed", p->pack_name);
 
        /* Since packfiles end in a hash of their content and its
         * pointless to ask for an offset into the middle of that
@@ -779,7 +795,7 @@ static void prepare_packed_git_one(char *objdir, int local)
                if (!has_extension(de->d_name, ".idx"))
                        continue;
 
-               /* we have .idx.  Is it a file we can map? */
+               /* Don't reopen a pack we already have. */
                strcpy(path + len, de->d_name);
                for (p = packed_git; p; p = p->next) {
                        if (!memcmp(path, p->pack_name, len + namelen - 4))
@@ -787,11 +803,13 @@ static void prepare_packed_git_one(char *objdir, int local)
                }
                if (p)
                        continue;
+               /* See if it really is a valid .idx file with corresponding
+                * .pack file that we can map.
+                */
                p = add_packed_git(path, len + namelen, local);
                if (!p)
                        continue;
-               p->next = packed_git;
-               packed_git = p;
+               install_packed_git(p);
        }
        closedir(dir);
 }
@@ -1145,7 +1163,7 @@ static unsigned long unpack_object_header(struct packed_git *p,
 
        /* use_pack() assures us we have [base, base + 20) available
         * as a range that we can look at at.  (Its actually the hash
-        * size that is assurred.)  With our object header encoding
+        * size that is assured.)  With our object header encoding
         * the maximum deflated object size is 2^137, which is just
         * insane, so we know won't exceed what we have been given.
         */
@@ -1405,6 +1423,18 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons
                }
                offset = find_pack_entry_one(sha1, p);
                if (offset) {
+                       /*
+                        * We are about to tell the caller where they can
+                        * locate the requested object.  We better make
+                        * sure the packfile is still here and can be
+                        * accessed before supplying that answer, as
+                        * it may have been deleted since the index
+                        * was loaded!
+                        */
+                       if (p->pack_fd == -1 && open_packed_git(p)) {
+                               error("packfile %s cannot be accessed", p->pack_name);
+                               continue;
+                       }
                        e->offset = offset;
                        e->p = p;
                        hashcpy(e->sha1, sha1);
@@ -1475,10 +1505,67 @@ static void *read_packed_sha1(const unsigned char *sha1, char *type, unsigned lo
                return unpack_entry(e.p, e.offset, type, size);
 }
 
+/*
+ * This is meant to hold a *small* number of objects that you would
+ * want read_sha1_file() to be able to return, but yet you do not want
+ * to write them into the object store (e.g. a browse-only
+ * application).
+ */
+static struct cached_object {
+       unsigned char sha1[20];
+       const char *type;
+       void *buf;
+       unsigned long size;
+} *cached_objects;
+static int cached_object_nr, cached_object_alloc;
+
+static struct cached_object *find_cached_object(const unsigned char *sha1)
+{
+       int i;
+       struct cached_object *co = cached_objects;
+
+       for (i = 0; i < cached_object_nr; i++, co++) {
+               if (!hashcmp(co->sha1, sha1))
+                       return co;
+       }
+       return NULL;
+}
+
+int pretend_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *sha1)
+{
+       struct cached_object *co;
+
+       hash_sha1_file(buf, len, type, sha1);
+       if (has_sha1_file(sha1) || find_cached_object(sha1))
+               return 0;
+       if (cached_object_alloc <= cached_object_nr) {
+               cached_object_alloc = alloc_nr(cached_object_alloc);
+               cached_objects = xrealloc(cached_objects,
+                                         sizeof(*cached_objects) *
+                                         cached_object_alloc);
+       }
+       co = &cached_objects[cached_object_nr++];
+       co->size = len;
+       co->type = strdup(type);
+       hashcpy(co->sha1, sha1);
+       return 0;
+}
+
 void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size)
 {
        unsigned long mapsize;
        void *map, *buf;
+       struct cached_object *co;
+
+       co = find_cached_object(sha1);
+       if (co) {
+               buf = xmalloc(co->size + 1);
+               memcpy(buf, co->buf, co->size);
+               ((char*)buf)[co->size] = 0;
+               strcpy(type, co->type);
+               *size = co->size;
+               return buf;
+       }
 
        buf = read_packed_sha1(sha1, type, size);
        if (buf)
index 9dfb3ac57403793e6c6f78f2f75fb61c0a56c4bc..d77f77097f6e00615732c5e6d50a2c594bef4311 100644 (file)
@@ -235,22 +235,23 @@ static int ambiguous_path(const char *path, int len)
        return slash;
 }
 
+static const char *ref_fmt[] = {
+       "%.*s",
+       "refs/%.*s",
+       "refs/tags/%.*s",
+       "refs/heads/%.*s",
+       "refs/remotes/%.*s",
+       "refs/remotes/%.*s/HEAD",
+       NULL
+};
+
 int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
 {
-       static const char *fmt[] = {
-               "%.*s",
-               "refs/%.*s",
-               "refs/tags/%.*s",
-               "refs/heads/%.*s",
-               "refs/remotes/%.*s",
-               "refs/remotes/%.*s/HEAD",
-               NULL
-       };
        const char **p, *r;
        int refs_found = 0;
 
        *ref = NULL;
-       for (p = fmt; *p; p++) {
+       for (p = ref_fmt; *p; p++) {
                unsigned char sha1_from_ref[20];
                unsigned char *this_result;
 
@@ -266,6 +267,28 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
        return refs_found;
 }
 
+static int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
+{
+       const char **p;
+       int logs_found = 0;
+
+       *log = NULL;
+       for (p = ref_fmt; *p; p++) {
+               struct stat st;
+               char *path = mkpath(*p, len, str);
+               if (!stat(git_path("logs/%s", path), &st) &&
+                   S_ISREG(st.st_mode)) {
+                       if (!logs_found++) {
+                               *log = xstrdup(path);
+                               resolve_ref(path, sha1, 0, NULL);
+                       }
+                       if (!warn_ambiguous_refs)
+                               break;
+               }
+       }
+       return logs_found;
+}
+
 static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
 {
        static const char *warning = "warning: refname '%.*s' is ambiguous.\n";
@@ -279,7 +302,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
        /* basic@{time or number} format to query ref-log */
        reflog_len = at = 0;
        if (str[len-1] == '}') {
-               for (at = 1; at < len - 1; at++) {
+               for (at = 0; at < len - 1; at++) {
                        if (str[at] == '@' && str[at+1] == '{') {
                                reflog_len = (len-1) - (at+2);
                                len = at;
@@ -289,10 +312,16 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
        }
 
        /* Accept only unambiguous ref paths. */
-       if (ambiguous_path(str, len))
+       if (len && ambiguous_path(str, len))
                return -1;
 
-       refs_found = dwim_ref(str, len, sha1, &real_ref);
+       if (!len && reflog_len) {
+               /* allow "@{...}" to mean the current branch reflog */
+               refs_found = dwim_ref("HEAD", 4, sha1, &real_ref);
+       } else if (reflog_len)
+               refs_found = dwim_log(str, len, sha1, &real_ref);
+       else
+               refs_found = dwim_ref(str, len, sha1, &real_ref);
 
        if (!refs_found)
                return -1;
@@ -301,12 +330,12 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
                fprintf(stderr, warning, len, str);
 
        if (reflog_len) {
-               /* Is it asking for N-th entry, or approxidate? */
                int nth, i;
                unsigned long at_time;
                unsigned long co_time;
                int co_tz, co_cnt;
 
+               /* Is it asking for N-th entry, or approxidate? */
                for (i = nth = 0; 0 <= nth && i < reflog_len; i++) {
                        char ch = str[at+2+i];
                        if ('0' <= ch && ch <= '9')
index b5ceba4acfd8e862cfc5a77672241e07205f70ea..87403da780814787f6c4ea15a790381a5b2395d3 100644 (file)
@@ -113,7 +113,8 @@ test_expect_success \
 
 test_expect_success \
     'some edit' \
-    'perl -p -i.orig -e "s/^1A.*\n$//; s/^3A/99/" file &&
+    'mv file file.orig &&
+    sed -e "s/^3A/99/" -e "/^1A/d" < file.orig > file &&
     GIT_AUTHOR_NAME="D" git commit -a -m "edit"'
 
 test_expect_success \
index 4f664f6adfb6153058848d3a3016c34e08b9425c..c11420a8b6ce9104f1c2ca3b4b2a23aef4f265ff 100755 (executable)
@@ -87,7 +87,7 @@ test_expect_success 'three-way not complaining on an untracked path in both' '
        git-read-tree -m -u branch-point master side
 '
 
-test_expect_success 'three-way not cloberring a working tree file' '
+test_expect_success 'three-way not clobbering a working tree file' '
 
        git reset --hard &&
        rm -f file2 subdir/file2 file3 subdir/file3 &&
index c090c96185c9826a752b87ce81af8d82056ede79..1e8f9e59dfe7e63177dea0a2e4b5c018a4756994 100755 (executable)
@@ -106,21 +106,21 @@ test_expect_success 'read-tree' '
        cmp ../one ../original.one
 '
 
-test_expect_success 'no file/rev ambuguity check inside .git' '
+test_expect_success 'no file/rev ambiguity check inside .git' '
        cd $HERE &&
        git commit -a -m 1 &&
        cd $HERE/.git &&
        git show -s HEAD
 '
 
-test_expect_success 'no file/rev ambuguity check inside a bare repo' '
+test_expect_success 'no file/rev ambiguity check inside a bare repo' '
        cd $HERE &&
        git clone -s --bare .git foo.git &&
        cd foo.git && GIT_DIR=. git show -s HEAD
 '
 
 # This still does not work as it should...
-: test_expect_success 'no file/rev ambuguity check inside a bare repo' '
+: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
        cd $HERE &&
        git clone -s --bare .git foo.git &&
        cd foo.git && git show -s HEAD
index ede4d42495bd5fd4f0ec7f03c41505864e5bb91e..7c7e4335d6e941a79d85c11502178b36331785a2 100755 (executable)
@@ -172,7 +172,7 @@ EOF
 check_verify_failure 'verify tag-name check'
 
 ############################################################
-# 11. tagger line lable check #1
+# 11. tagger line label check #1
 
 cat >tag.sig <<EOF
 object $head
@@ -187,7 +187,7 @@ EOF
 check_verify_failure '"tagger" line label check #1'
 
 ############################################################
-# 12. tagger line lable check #2
+# 12. tagger line label check #2
 
 cat >tag.sig <<EOF
 object $head
index cf08e9279c1b2dc61cb53cf1e4940143cb3bf05c..ac835fe4317b7a37d77205487066d8f10bd71422 100755 (executable)
@@ -10,7 +10,7 @@ commit id embedding:
 
   The contents of the repository is compared to the extracted tar
   archive.  The repository contains simple text files, symlinks and a
-  binary file (/bin/sh).  Only pathes shorter than 99 characters are
+  binary file (/bin/sh).  Only paths shorter than 99 characters are
   used.
 
   git-tar-tree applies the commit date to every file in the archive it
index 041be04f5ceed683f2b4959b119cde4e055ed6e4..1776b377f3c787977b145980f05aa74da5038657 100755 (executable)
@@ -36,7 +36,7 @@ test_expect_success \
     'git-clone foo bar'
 
 test_expect_success \
-    'successfull clone must leave the directory' \
+    'successful clone must leave the directory' \
     'cd bar'
 
 test_done
index dd9caad1c2a34a6721aafa1840916a5a7471ece8..6d432525934980050f5c0d1683a1bc5e220b6e18 100755 (executable)
@@ -26,7 +26,7 @@ git prune'
 
 cd "$base_dir"
 
-test_expect_success 'cloning with reference' \
+test_expect_success 'cloning with reference (-l -s)' \
 'git clone -l -s --reference B A C'
 
 cd "$base_dir"
@@ -50,6 +50,28 @@ diff expected current'
 
 cd "$base_dir"
 
+test_expect_success 'cloning with reference (no -l -s)' \
+'git clone --reference B A D'
+
+cd "$base_dir"
+
+test_expect_success 'existence of info/alternates' \
+'test `wc -l <D/.git/objects/info/alternates` = 1'
+
+cd "$base_dir"
+
+test_expect_success 'pulling from reference' \
+'cd D && git pull ../B'
+
+cd "$base_dir"
+
+test_expect_success 'that reference gets used' \
+'cd D && echo "0 objects, 0 kilobytes" > expected &&
+git count-objects > current &&
+diff expected current'
+
+cd "$base_dir"
+
 test_expect_success 'updating origin' \
 'cd A &&
 echo third > file3 &&
@@ -75,4 +97,20 @@ diff expected current'
 
 cd "$base_dir"
 
+test_expect_success 'pulling changes from origin' \
+'cd D &&
+git pull origin'
+
+cd "$base_dir"
+
+# the 5 local objects are expected; file3 blob, commit in A to add it
+# and its tree, and 2 are our tree and the merge commit.
+test_expect_success 'check objects expected to exist locally' \
+'cd D &&
+echo "5 objects" > expected &&
+git count-objects | cut -d, -f1 > current &&
+diff expected current'
+
+cd "$base_dir"
+
 test_done
index 69c66cf6faf6c14f4e4a33310871d56ede439457..65be95fbaaef4861189a7fc6b3a25bb6d7feb0a7 100755 (executable)
@@ -45,6 +45,7 @@ git add A M &&
 git commit -m "initial has A and M" &&
 git branch white &&
 git branch red &&
+git branch blue &&
 
 git checkout white &&
 sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
@@ -58,6 +59,13 @@ echo created by red >R &&
 git update-index --add R &&
 git commit -m "red creates R" &&
 
+git checkout blue &&
+sed -e "/^o /s/.*/g : blue changes a line/" <A >B &&
+rm -f A &&
+mv B A &&
+git update-index A &&
+git commit -m "blue modify A" &&
+
 git checkout master'
 
 # This test broke in 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae
@@ -94,4 +102,38 @@ test_expect_success 'merge white into red (A->B,M->N)' \
        return 0
 '
 
+# This test broke in 8371234ecaaf6e14fe3f2082a855eff1bbd79ae9
+test_expect_success 'merge blue into white (A->B, mod A, A untracked)' \
+'
+       git checkout -b white-blue white &&
+       echo dirty >A &&
+       git merge blue &&
+       git write-tree >/dev/null || {
+               echo "BAD: merge did not complete"
+               return 1
+       }
+
+       test -f A || {
+               echo "BAD: A does not exist in working directory"
+               return 1
+       }
+       test `cat A` = dirty || {
+               echo "BAD: A content is wrong"
+               return 1
+       }
+       test -f B || {
+               echo "BAD: B does not exist in working directory"
+               return 1
+       }
+       test -f N || {
+               echo "BAD: N does not exist in working directory"
+               return 1
+       }
+       test -f M && {
+               echo "BAD: M still exists in working directory"
+               return 1
+       }
+       return 0
+'
+
 test_done
index 46fcec50a5271d80464d7f37e5d402b1a3c0b6d0..a2c4dc324aed983e3036eaf8efe3b98a63a745c1 100755 (executable)
@@ -70,7 +70,7 @@ name='test svn:keywords ignoring'
 test_expect_success "$name" \
        'git checkout -b mybranch remotes/git-svn &&
        echo Hi again >> kw.c &&
-       git commit -a -m "test keywoards ignoring" &&
+       git commit -a -m "test keywords ignoring" &&
        git-svn set-tree remotes/git-svn..mybranch &&
        git pull . remotes/git-svn'
 
index fd0a5549fe31510ae33fc86d2aa79051f1b1f6da..4efa0c926c45befa92be90f746f03807a591a893 100755 (executable)
@@ -169,21 +169,35 @@ test_expect_success \
       test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.2/-kb with spaces.txt/1.2/"
       )'
 
-# This test contains ISO-8859-1 characters
+# Some filesystems mangle pathnames with UTF-8 characters --
+# check and skip
+if p="Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" &&
+       mkdir -p "tst/$p" &&
+       date >"tst/$p/day" &&
+       found=$(find tst -type f -print) &&
+       test "z$found" = "ztst/$p/day" &&
+       rm -fr tst
+then
+
+# This test contains UTF-8 characters
 test_expect_success \
      'File with non-ascii file name' \
-     'mkdir -p Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö &&
-      echo Foo >Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
-      git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
-      cp ../test9200a.png Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
-      git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
-      git commit -a -m "Går det så går det" && \
+     'mkdir -p Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö &&
+      echo Foo >Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
+      git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
+      cp ../test9200a.png Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
+      git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
+      git commit -a -m "Går det så går det" && \
       id=$(git rev-list --max-count=1 HEAD) &&
       (cd "$CVSWORK" &&
       git-cvsexportcommit -v -c $id &&
-      test "$(echo $(sort Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/CVS/Entries|cut -d/ -f2,3,5))" = "gårdetsågårdet.png/1.1/-kb gårdetsågårdet.txt/1.1/"
+      test "$(echo $(sort Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/CVS/Entries|cut -d/ -f2,3,5))" = "gårdetsågårdet.png/1.1/-kb gårdetsågårdet.txt/1.1/"
       )'
 
+fi
+
+rm -fr tst
+
 test_expect_success \
      'Mismatching patch should fail' \
      'date >>"E/newfile5.txt" &&
@@ -197,6 +211,10 @@ test_expect_success \
       ! git-cvsexportcommit -c $id
       )'
 
+case "$(git repo-config --bool core.filemode)" in
+false)
+       ;;
+*)
 test_expect_success \
      'Retain execute bit' \
      'mkdir G &&
@@ -211,5 +229,7 @@ test_expect_success \
       test -x G/on &&
       ! test -x G/off
       )'
+       ;;
+esac
 
 test_done
index 8e3ee6cd7b38e07d3fd39904066c8e64f1d3642f..37822fc13df73a8cb53428acc767947bb5844c9e 100755 (executable)
@@ -30,6 +30,8 @@ unset GIT_INDEX_FILE
 unset GIT_OBJECT_DIRECTORY
 unset SHA1_FILE_DIRECTORIES
 unset SHA1_FILE_DIRECTORY
+GIT_MERGE_VERBOSITY=5
+export GIT_MERGE_VERBOSITY
 export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
 export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
 export EDITOR VISUAL
index 9e1ae1a4e0322a37b494177474a964caf05ca4dd..0eeee43feb97ac79406d196c735e4027c4e9cdfd 100644 (file)
@@ -6,7 +6,7 @@ prefix ?= $(HOME)
 template_dir ?= $(prefix)/share/git-core/templates/
 # DESTDIR=
 
-# Shell quote (do not use $(call) to accomodate ancient setups);
+# Shell quote (do not use $(call) to accommodate ancient setups);
 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
 template_dir_SQ = $(subst ','\'',$(template_dir))
 
index 4bd9d96ff9a105cf41ba1859e243d3d6b63376ad..d4253cbcfb5888fa1ed4935310b677f1e6b3cf17 100644 (file)
@@ -61,7 +61,7 @@ newrev_type=$(git-cat-file -t "$newrev")
 
 case "$refname","$newrev_type" in
        refs/tags/*,commit)
-               # un-annoted tag
+               # un-annotated tag
                refname_type="tag"
                short_refname=${refname##refs/tags/}
                if [ $allowunannotated != "true" ]; then