Big tool rename.
authorJunio C Hamano <junkio@cox.net>
Thu, 8 Sep 2005 00:26:23 +0000 (17:26 -0700)
committerJunio C Hamano <junkio@cox.net>
Thu, 8 Sep 2005 00:45:20 +0000 (17:45 -0700)
As promised, this is the "big tool rename" patch.  The primary differences
since 0.99.6 are:

  (1) git-*-script are no more.  The commands installed do not
      have any such suffix so users do not have to remember if
      something is implemented as a shell script or not.

  (2) Many command names with 'cache' in them are renamed with
      'index' if that is what they mean.

There are backward compatibility symblic links so that you and
Porcelains can keep using the old names, but the backward
compatibility support  is expected to be removed in the near
future.

Signed-off-by: Junio C Hamano <junkio@cox.net>
253 files changed:
.gitignore
Documentation/diff-format.txt
Documentation/diffcore.txt
Documentation/git-add-script.txt [deleted file]
Documentation/git-add.txt [new file with mode: 0644]
Documentation/git-archimport-script.txt [deleted file]
Documentation/git-archimport.txt [new file with mode: 0644]
Documentation/git-bisect-script.txt [deleted file]
Documentation/git-bisect.txt [new file with mode: 0644]
Documentation/git-branch-script.txt [deleted file]
Documentation/git-branch.txt [new file with mode: 0644]
Documentation/git-checkout-cache.txt [deleted file]
Documentation/git-checkout-index.txt [new file with mode: 0644]
Documentation/git-checkout-script.txt [deleted file]
Documentation/git-checkout.txt [new file with mode: 0644]
Documentation/git-cherry-pick-script.txt [deleted file]
Documentation/git-cherry-pick.txt [new file with mode: 0644]
Documentation/git-clone-script.txt [deleted file]
Documentation/git-clone.txt [new file with mode: 0644]
Documentation/git-commit-script.txt [deleted file]
Documentation/git-commit.txt [new file with mode: 0644]
Documentation/git-convert-cache.txt [deleted file]
Documentation/git-convert-objects.txt [new file with mode: 0644]
Documentation/git-count-objects-script.txt [deleted file]
Documentation/git-count-objects.txt [new file with mode: 0644]
Documentation/git-cvsimport-script.txt [deleted file]
Documentation/git-cvsimport.txt [new file with mode: 0644]
Documentation/git-diff-cache.txt [deleted file]
Documentation/git-diff-files.txt
Documentation/git-diff-helper.txt
Documentation/git-diff-index.txt [new file with mode: 0644]
Documentation/git-diff-script.txt [deleted file]
Documentation/git-diff-tree.txt
Documentation/git-diff.txt [new file with mode: 0644]
Documentation/git-fetch-script.txt [deleted file]
Documentation/git-fetch.txt [new file with mode: 0644]
Documentation/git-format-patch-script.txt [deleted file]
Documentation/git-format-patch.txt [new file with mode: 0644]
Documentation/git-fsck-cache.txt [deleted file]
Documentation/git-fsck-objects.txt [new file with mode: 0644]
Documentation/git-hash-object.txt
Documentation/git-http-fetch.txt [new file with mode: 0644]
Documentation/git-http-pull.txt [deleted file]
Documentation/git-local-fetch.txt [new file with mode: 0644]
Documentation/git-local-pull.txt [deleted file]
Documentation/git-log-script.txt [deleted file]
Documentation/git-log.txt [new file with mode: 0644]
Documentation/git-ls-remote-script.txt [deleted file]
Documentation/git-ls-remote.txt [new file with mode: 0644]
Documentation/git-merge-cache.txt [deleted file]
Documentation/git-merge-index.txt [new file with mode: 0644]
Documentation/git-merge-one-file-script.txt [deleted file]
Documentation/git-merge-one-file.txt [new file with mode: 0644]
Documentation/git-octopus-script.txt [deleted file]
Documentation/git-octopus.txt [new file with mode: 0644]
Documentation/git-pack-objects.txt
Documentation/git-parse-remote-script.txt [deleted file]
Documentation/git-parse-remote.txt [new file with mode: 0644]
Documentation/git-prune-packed.txt
Documentation/git-prune-script.txt [deleted file]
Documentation/git-prune.txt [new file with mode: 0644]
Documentation/git-pull-script.txt [deleted file]
Documentation/git-pull.txt [new file with mode: 0644]
Documentation/git-push-script.txt [deleted file]
Documentation/git-push.txt [new file with mode: 0644]
Documentation/git-read-tree.txt
Documentation/git-rebase-script.txt [deleted file]
Documentation/git-rebase.txt [new file with mode: 0644]
Documentation/git-relink-script.txt [deleted file]
Documentation/git-relink.txt [new file with mode: 0644]
Documentation/git-rename-script.txt [deleted file]
Documentation/git-rename.txt [new file with mode: 0644]
Documentation/git-repack-script.txt [deleted file]
Documentation/git-repack.txt [new file with mode: 0644]
Documentation/git-request-pull-script.txt [deleted file]
Documentation/git-request-pull.txt [new file with mode: 0644]
Documentation/git-reset-script.txt [deleted file]
Documentation/git-reset.txt [new file with mode: 0644]
Documentation/git-resolve-script.txt [deleted file]
Documentation/git-resolve.txt [new file with mode: 0644]
Documentation/git-revert-script.txt [deleted file]
Documentation/git-revert.txt [new file with mode: 0644]
Documentation/git-send-email-script.txt [deleted file]
Documentation/git-send-email.txt [new file with mode: 0644]
Documentation/git-sh-setup-script.txt [deleted file]
Documentation/git-sh-setup.txt [new file with mode: 0644]
Documentation/git-show-branch.txt
Documentation/git-ssh-fetch.txt [new file with mode: 0644]
Documentation/git-ssh-pull.txt [deleted file]
Documentation/git-ssh-push.txt [deleted file]
Documentation/git-ssh-upload.txt [new file with mode: 0644]
Documentation/git-status-script.txt [deleted file]
Documentation/git-status.txt [new file with mode: 0644]
Documentation/git-tag-script.txt [deleted file]
Documentation/git-tag.txt [new file with mode: 0644]
Documentation/git-update-cache.txt [deleted file]
Documentation/git-update-index.txt [new file with mode: 0644]
Documentation/git-var.txt
Documentation/git-verify-tag-script.txt [deleted file]
Documentation/git-verify-tag.txt [new file with mode: 0644]
Documentation/git-write-tree.txt
Documentation/git.txt
Documentation/hooks.txt
Documentation/howto/make-dist.txt
Documentation/howto/rebase-from-internal-branch.txt
Documentation/howto/revert-branch-rebase.txt
Documentation/tutorial.txt
INSTALL
Makefile
README
checkout-cache.c [deleted file]
checkout-index.c [new file with mode: 0644]
cmd-rename.sh [new file with mode: 0755]
convert-cache.c [deleted file]
convert-objects.c [new file with mode: 0644]
debian/changelog
diff-cache.c [deleted file]
diff-index.c [new file with mode: 0644]
entry.c
fetch.c [new file with mode: 0644]
fetch.h [new file with mode: 0644]
fsck-cache.c [deleted file]
fsck-objects.c [new file with mode: 0644]
git [deleted file]
git-add-script [deleted file]
git-add.sh [new file with mode: 0755]
git-applymbox [deleted file]
git-applymbox.sh [new file with mode: 0755]
git-applypatch [deleted file]
git-applypatch.sh [new file with mode: 0755]
git-archimport-script [deleted file]
git-archimport.perl [new file with mode: 0755]
git-bisect-script [deleted file]
git-bisect.sh [new file with mode: 0755]
git-branch-script [deleted file]
git-branch.sh [new file with mode: 0755]
git-checkout-script [deleted file]
git-checkout.sh [new file with mode: 0755]
git-cherry [deleted file]
git-cherry.sh [new file with mode: 0755]
git-clone-script [deleted file]
git-clone.sh [new file with mode: 0755]
git-commit-script [deleted file]
git-commit.sh [new file with mode: 0755]
git-count-objects-script [deleted file]
git-count-objects.sh [new file with mode: 0755]
git-cvsimport-script [deleted file]
git-cvsimport.perl [new file with mode: 0755]
git-diff-script [deleted file]
git-diff.sh [new file with mode: 0755]
git-fetch-script [deleted file]
git-fetch.sh [new file with mode: 0755]
git-format-patch-script [deleted file]
git-format-patch.sh [new file with mode: 0755]
git-log-script [deleted file]
git-log.sh [new file with mode: 0755]
git-ls-remote-script [deleted file]
git-ls-remote.sh [new file with mode: 0755]
git-merge-one-file-script [deleted file]
git-merge-one-file.sh [new file with mode: 0755]
git-octopus-script [deleted file]
git-octopus.sh [new file with mode: 0755]
git-parse-remote-script [deleted file]
git-parse-remote.sh [new file with mode: 0755]
git-prune-script [deleted file]
git-prune.sh [new file with mode: 0755]
git-pull-script [deleted file]
git-pull.sh [new file with mode: 0755]
git-push-script [deleted file]
git-push.sh [new file with mode: 0755]
git-rebase-script [deleted file]
git-rebase.sh [new file with mode: 0755]
git-relink-script [deleted file]
git-relink.perl [new file with mode: 0755]
git-rename-script [deleted file]
git-rename.perl [new file with mode: 0755]
git-repack-script [deleted file]
git-repack.sh [new file with mode: 0755]
git-request-pull-script [deleted file]
git-request-pull.sh [new file with mode: 0755]
git-reset-script [deleted file]
git-reset.sh [new file with mode: 0755]
git-resolve-script [deleted file]
git-resolve.sh [new file with mode: 0755]
git-revert-script [deleted file]
git-revert.sh [new file with mode: 0755]
git-send-email-script [deleted file]
git-send-email.perl [new file with mode: 0755]
git-sh-setup-script [deleted file]
git-sh-setup.sh [new file with mode: 0755]
git-shortlog [deleted file]
git-shortlog.perl [new file with mode: 0755]
git-status-script [deleted file]
git-status.sh [new file with mode: 0755]
git-tag-script [deleted file]
git-tag.sh [new file with mode: 0755]
git-verify-tag-script [deleted file]
git-verify-tag.sh [new file with mode: 0755]
git-whatchanged [deleted file]
git-whatchanged.sh [new file with mode: 0755]
git.sh [new file with mode: 0755]
http-fetch.c [new file with mode: 0644]
http-pull.c [deleted file]
local-fetch.c [new file with mode: 0644]
local-pull.c [deleted file]
merge-cache.c [deleted file]
merge-index.c [new file with mode: 0644]
pull.c [deleted file]
pull.h [deleted file]
ssh-fetch.c [new file with mode: 0644]
ssh-pull.c [deleted file]
ssh-push.c [deleted file]
ssh-upload.c [new file with mode: 0644]
t/README
t/lib-read-tree-m-3way.sh
t/t0000-basic.sh
t/t0100-environment-names.sh
t/t0110-environment-names-old.sh
t/t1000-read-tree-m-3way.sh
t/t1001-read-tree-m-2way.sh
t/t1002-read-tree-m-u-2way.sh
t/t1005-read-tree-m-2way-emu23.sh
t/t2000-checkout-cache-clash.sh
t/t2001-checkout-cache-clash.sh
t/t2002-checkout-cache-u.sh
t/t2003-checkout-cache-mkdir.sh
t/t2100-update-cache-badpath.sh
t/t3010-ls-files-killed.sh
t/t3100-ls-tree-restrict.sh
t/t4000-diff-format.sh
t/t4001-diff-rename.sh
t/t4002-diff-basic.sh
t/t4003-diff-rename-1.sh
t/t4004-diff-rename-symlink.sh
t/t4005-diff-rename-2.sh
t/t4006-diff-mode.sh
t/t4007-rename-3.sh
t/t4008-diff-break-rewrite.sh
t/t4009-diff-rename-4.sh
t/t4010-diff-pathspec.sh
t/t4102-apply-rename.sh
t/t4112-apply-renames.sh
t/t5000-tar-tree.sh
t/t5300-pack-object.sh
t/t5400-send-pack.sh
t/t6001-rev-list-merge-order.sh
t/t6002-rev-list-bisect.sh
t/t6003-rev-list-topo-order.sh
t/t6101-rev-parse-parents.sh
templates/hooks--commit-msg
templates/hooks--pre-commit
update-cache.c [deleted file]
update-index.c [new file with mode: 0644]

index 245f54e..12b0137 100644 (file)
@@ -1,28 +1,28 @@
 git-apply
 git-build-rev-cache
 git-cat-file
-git-checkout-cache
+git-checkout-index
 git-clone-pack
 git-commit-tree
-git-convert-cache
+git-convert-objects
 git-daemon
-git-diff-cache
+git-diff-index
 git-diff-files
 git-diff-helper
 git-diff-stages
 git-diff-tree
 git-export
 git-fetch-pack
-git-fsck-cache
+git-fsck-objects
 git-get-tar-commit-id
 git-hash-object
-git-http-pull
+git-http-fetch
 git-init-db
-git-local-pull
+git-local-fetch
 git-ls-files
 git-ls-tree
 git-merge-base
-git-merge-cache
+git-merge-index
 git-mktag
 git-pack-objects
 git-patch-id
@@ -37,13 +37,13 @@ git-send-pack
 git-show-branch
 git-show-index
 git-show-rev-cache
-git-ssh-pull
-git-ssh-push
+git-ssh-fetch
+git-ssh-upload
 git-stripspace
 git-tar-tree
 git-unpack-file
 git-unpack-objects
-git-update-cache
+git-update-index
 git-update-server-info
 git-upload-pack
 git-var
index 811d143..424e75a 100644 (file)
@@ -1,13 +1,13 @@
-The output format from "git-diff-cache", "git-diff-tree" and
+The output format from "git-diff-index", "git-diff-tree" and
 "git-diff-files" are very similar.
 
 These commands all compare two sets of things; what are
 compared are different:
 
-git-diff-cache <tree-ish>::
+git-diff-index <tree-ish>::
         compares the <tree-ish> and the files on the filesystem.
 
-git-diff-cache --cached <tree-ish>::
+git-diff-index --cached <tree-ish>::
         compares the <tree-ish> and the cache.
 
 git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]::
@@ -58,7 +58,7 @@ Example:
 Generating patches with -p
 --------------------------
 
-When "git-diff-cache", "git-diff-tree", or "git-diff-files" are run
+When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
 with a '-p' option, they do not produce the output described above;
 instead they produce a patch file.
 
@@ -77,7 +77,7 @@ The "diff" formatting options can be customized via the
 environment variable 'GIT_DIFF_OPTS'.  For example, if you
 prefer context diff:
 
-      GIT_DIFF_OPTS=-c git-diff-cache -p $(cat .git/HEAD)
+      GIT_DIFF_OPTS=-c git-diff-index -p $(cat .git/HEAD)
 
 
 2. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the
index 1a6e725..a0ffe85 100644 (file)
@@ -6,7 +6,7 @@ June 2005
 Introduction
 ------------
 
-The diff commands git-diff-cache, git-diff-files, and
+The diff commands git-diff-index, git-diff-files, and
 git-diff-tree can be told to manipulate differences they find
 in unconventional ways before showing diff(1) output.  The
 manipulation is collectively called "diffcore transformation".
@@ -21,7 +21,7 @@ The chain of operation
 The git-diff-* family works by first comparing two sets of
 files:
 
- - git-diff-cache compares contents of a "tree" object and the
+ - git-diff-index compares contents of a "tree" object and the
    working directory (when '--cached' flag is not used) or a
    "tree" object and the index file (when '--cached' flag is
    used);
diff --git a/Documentation/git-add-script.txt b/Documentation/git-add-script.txt
deleted file mode 100644 (file)
index 3001143..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-git-add-script(1)
-=================
-
-NAME
-----
-git-add-script - Add files to the cache.
-
-SYNOPSIS
---------
-'git-add-script' <file>...
-
-DESCRIPTION
------------
-A simple wrapper to git-update-cache to add files to the cache for people used
-to do "cvs add".
-
-OPTIONS
--------
-<file>...::
-       Files to add to the cache.
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
new file mode 100644 (file)
index 0000000..beb4500
--- /dev/null
@@ -0,0 +1,33 @@
+git-add(1)
+==========
+
+NAME
+----
+git-add - Add files to the cache.
+
+SYNOPSIS
+--------
+'git-add' <file>...
+
+DESCRIPTION
+-----------
+A simple wrapper to git-update-index to add files to the cache for people used
+to do "cvs add".
+
+OPTIONS
+-------
+<file>...::
+       Files to add to the cache.
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-archimport-script.txt b/Documentation/git-archimport-script.txt
deleted file mode 100644 (file)
index 134fbed..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-git-archimport-script(1)
-========================
-
-NAME
-----
-git-archimport-script - Import an arch repository into git
-
-
-SYNOPSIS
---------
-`git-archimport-script` [--option...] <args>
-
-DESCRIPTION
------------
-The script expects you to provide the key roots where it can start the
-import from an 'initial import' or 'tag' type of Arch commit. It will
-then follow all the branching and tagging within the provided roots.
-
-It will die if it sees branches that have different roots.
-
-
-OPTIONS
--------
---option::
-       Some option not yet documented.
-
-<args>...::
-       Some argument not yet documented.
-
-
-Author
-------
-Written by Martin Langhoff <martin@catalyst.net.nz>.
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-archimport.txt b/Documentation/git-archimport.txt
new file mode 100644 (file)
index 0000000..8ce5f0a
--- /dev/null
@@ -0,0 +1,42 @@
+git-archimport(1)
+=================
+
+NAME
+----
+git-archimport - Import an arch repository into git
+
+
+SYNOPSIS
+--------
+`git-archimport` [--option...] <args>
+
+DESCRIPTION
+-----------
+The script expects you to provide the key roots where it can start the
+import from an 'initial import' or 'tag' type of Arch commit. It will
+then follow all the branching and tagging within the provided roots.
+
+It will die if it sees branches that have different roots.
+
+
+OPTIONS
+-------
+--option::
+       Some option not yet documented.
+
+<args>...::
+       Some argument not yet documented.
+
+
+Author
+------
+Written by Martin Langhoff <martin@catalyst.net.nz>.
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-bisect-script.txt b/Documentation/git-bisect-script.txt
deleted file mode 100644 (file)
index b4531c6..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-git-bisect-script(1)
-====================
-
-NAME
-----
-git-bisect-script - Find the change that introduced a bug
-
-
-SYNOPSIS
---------
-'git bisect' start
-'git bisect' bad <rev>
-'git bisect' good <rev>
-'git bisect' reset [<branch>]
-'git bisect' visualize
-
-
-DESCRIPTION
------------
-This command uses 'git-rev-list --bisect' option to help drive
-the binary search process to find which change introduced a bug,
-given an old "good" commit object name and a later "bad" commit
-object name.
-
-The way you use it is:
-
-------------------------------------------------
-git bisect start
-git bisect bad                 # Current version is bad
-git bisect good v2.6.13-rc2    # v2.6.13-rc2 was the last version
-                               # tested that was good
-------------------------------------------------
-
-When you give at least one bad and one good versions, it will
-bisect the revision tree and say something like:
-
-------------------------------------------------
-Bisecting: 675 revisions left to test after this
-------------------------------------------------
-
-and check out the state in the middle. Now, compile that kernel, and boot
-it. Now, let's say that this booted kernel works fine, then just do
-
-------------------------------------------------
-git bisect good                        # this one is good
-------------------------------------------------
-
-which will now say
-
-------------------------------------------------
-Bisecting: 337 revisions left to test after this
-------------------------------------------------
-
-and you continue along, compiling that one, testing it, and depending on
-whether it is good or bad, you say "git bisect good" or "git bisect bad",
-and ask for the next bisection.
-
-Until you have no more left, and you'll have been left with the first bad
-kernel rev in "refs/bisect/bad".
-
-Oh, and then after you want to reset to the original head, do a
-
-------------------------------------------------
-git bisect reset
-------------------------------------------------
-
-to get back to the master branch, instead of being in one of the bisection
-branches ("git bisect start" will do that for you too, actually: it will
-reset the bisection state, and before it does that it checks that you're
-not using some old bisection branch).
-
-During the bisection process, you can say
-
-       git bisect visualize
-
-to see the currently remaining suspects in `gitk`.
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
new file mode 100644 (file)
index 0000000..ae43876
--- /dev/null
@@ -0,0 +1,90 @@
+git-bisect(1)
+=============
+
+NAME
+----
+git-bisect - Find the change that introduced a bug
+
+
+SYNOPSIS
+--------
+'git bisect' start
+'git bisect' bad <rev>
+'git bisect' good <rev>
+'git bisect' reset [<branch>]
+'git bisect' visualize
+
+
+DESCRIPTION
+-----------
+This command uses 'git-rev-list --bisect' option to help drive
+the binary search process to find which change introduced a bug,
+given an old "good" commit object name and a later "bad" commit
+object name.
+
+The way you use it is:
+
+------------------------------------------------
+git bisect start
+git bisect bad                 # Current version is bad
+git bisect good v2.6.13-rc2    # v2.6.13-rc2 was the last version
+                               # tested that was good
+------------------------------------------------
+
+When you give at least one bad and one good versions, it will
+bisect the revision tree and say something like:
+
+------------------------------------------------
+Bisecting: 675 revisions left to test after this
+------------------------------------------------
+
+and check out the state in the middle. Now, compile that kernel, and boot
+it. Now, let's say that this booted kernel works fine, then just do
+
+------------------------------------------------
+git bisect good                        # this one is good
+------------------------------------------------
+
+which will now say
+
+------------------------------------------------
+Bisecting: 337 revisions left to test after this
+------------------------------------------------
+
+and you continue along, compiling that one, testing it, and depending on
+whether it is good or bad, you say "git bisect good" or "git bisect bad",
+and ask for the next bisection.
+
+Until you have no more left, and you'll have been left with the first bad
+kernel rev in "refs/bisect/bad".
+
+Oh, and then after you want to reset to the original head, do a
+
+------------------------------------------------
+git bisect reset
+------------------------------------------------
+
+to get back to the master branch, instead of being in one of the bisection
+branches ("git bisect start" will do that for you too, actually: it will
+reset the bisection state, and before it does that it checks that you're
+not using some old bisection branch).
+
+During the bisection process, you can say
+
+       git bisect visualize
+
+to see the currently remaining suspects in `gitk`.
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-branch-script.txt b/Documentation/git-branch-script.txt
deleted file mode 100644 (file)
index 3ace8ad..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-git-branch-script(1)
-====================
-
-NAME
-----
-git-branch-script - Create a new branch.
-
-SYNOPSIS
---------
-'git-branch-script' [<branchname> [start-point]]
-
-DESCRIPTION
------------
-If no argument is provided, show available branches and mark current
-branch with star. Otherwise, create a new branch of name <branchname>.
-
-If a starting point is also specified, that will be where the branch is
-created, otherwise it will be created at the current HEAD.
-
-OPTIONS
--------
-<branchname>::
-       The name of the branch to create.
-
-start-point::
-       Where to make the branch; defaults to HEAD.
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org> and Junio C Hamano <junkio@cox.net>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
new file mode 100644 (file)
index 0000000..914c0e6
--- /dev/null
@@ -0,0 +1,39 @@
+git-branch(1)
+=============
+
+NAME
+----
+git-branch - Create a new branch.
+
+SYNOPSIS
+--------
+'git-branch' [<branchname> [start-point]]
+
+DESCRIPTION
+-----------
+If no argument is provided, show available branches and mark current
+branch with star. Otherwise, create a new branch of name <branchname>.
+
+If a starting point is also specified, that will be where the branch is
+created, otherwise it will be created at the current HEAD.
+
+OPTIONS
+-------
+<branchname>::
+       The name of the branch to create.
+
+start-point::
+       Where to make the branch; defaults to HEAD.
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org> and Junio C Hamano <junkio@cox.net>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-checkout-cache.txt b/Documentation/git-checkout-cache.txt
deleted file mode 100644 (file)
index 321a00c..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-git-checkout-cache(1)
-=====================
-v0.1, May 2005
-
-NAME
-----
-git-checkout-cache - Copy files from the cache to the working directory
-
-
-SYNOPSIS
---------
-'git-checkout-cache' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
-                  [--] <file>...
-
-DESCRIPTION
------------
-Will copy all files listed from the cache to the working directory
-(not overwriting existing files).
-
-OPTIONS
--------
--u::
-       update stat information for the checked out entries in
-       the cache file.
-
--q::
-       be quiet if files exist or are not in the cache
-
--f::
-       forces overwrite of existing files
-
--a::
-       checks out all files in the cache (will then continue to
-       process listed files).
-
--n::
-       Don't checkout new files, only refresh files already checked
-       out.
-
---prefix=<string>::
-       When creating files, prepend <string> (usually a directory
-       including a trailing /)
-
---::
-       Do not interpret any more arguments as options.
-
-Note that the order of the flags matters:
-
-     git-checkout-cache -a -f file.c
-
-will first check out all files listed in the cache (but not overwrite
-any old ones), and then force-checkout `file.c` a second time (ie that
-one *will* overwrite any old contents with the same filename).
-
-Also, just doing "git-checkout-cache" does nothing. You probably meant
-"git-checkout-cache -a". And if you want to force it, you want
-"git-checkout-cache -f -a".
-
-Intuitiveness is not the goal here. Repeatability is. The reason for
-the "no arguments means no work" thing is that from scripts you are
-supposed to be able to do things like:
-
-       find . -name '*.h' -print0 | xargs -0 git-checkout-cache -f --
-
-which will force all existing `*.h` files to be replaced with their
-cached copies. If an empty command line implied "all", then this would
-force-refresh everything in the cache, which was not the point.
-
-To update and refresh only the files already checked out:
-
-        git-checkout-cache -n -f -a && git-update-cache --ignore-missing --refresh
-
-Oh, and the "--" is just a good idea when you know the rest will be
-filenames. Just so that you wouldn't have a filename of "-a" causing
-problems (not possible in the above example, but get used to it in
-scripting!).
-
-The prefix ability basically makes it trivial to use
-git-checkout-cache as an "export as tree" function. Just read the
-desired tree into the index, and do a
-  
-        git-checkout-cache --prefix=git-export-dir/ -a
-  
-and git-checkout-cache will "export" the cache into the specified
-directory.
-  
-NOTE The final "/" is important. The exported name is literally just
-prefixed with the specified string, so you can also do something like
-
-    git-checkout-cache --prefix=.merged- Makefile
-
-to check out the currently cached copy of `Makefile` into the file
-`.merged-Makefile`
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-checkout-index.txt b/Documentation/git-checkout-index.txt
new file mode 100644 (file)
index 0000000..bb15214
--- /dev/null
@@ -0,0 +1,106 @@
+git-checkout-index(1)
+=====================
+v0.1, May 2005
+
+NAME
+----
+git-checkout-index - Copy files from the cache to the working directory
+
+
+SYNOPSIS
+--------
+'git-checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
+                  [--] <file>...
+
+DESCRIPTION
+-----------
+Will copy all files listed from the cache to the working directory
+(not overwriting existing files).
+
+OPTIONS
+-------
+-u::
+       update stat information for the checked out entries in
+       the cache file.
+
+-q::
+       be quiet if files exist or are not in the cache
+
+-f::
+       forces overwrite of existing files
+
+-a::
+       checks out all files in the cache (will then continue to
+       process listed files).
+
+-n::
+       Don't checkout new files, only refresh files already checked
+       out.
+
+--prefix=<string>::
+       When creating files, prepend <string> (usually a directory
+       including a trailing /)
+
+--::
+       Do not interpret any more arguments as options.
+
+Note that the order of the flags matters:
+
+     git-checkout-index -a -f file.c
+
+will first check out all files listed in the cache (but not overwrite
+any old ones), and then force-checkout `file.c` a second time (ie that
+one *will* overwrite any old contents with the same filename).
+
+Also, just doing "git-checkout-index" does nothing. You probably meant
+"git-checkout-index -a". And if you want to force it, you want
+"git-checkout-index -f -a".
+
+Intuitiveness is not the goal here. Repeatability is. The reason for
+the "no arguments means no work" thing is that from scripts you are
+supposed to be able to do things like:
+
+       find . -name '*.h' -print0 | xargs -0 git-checkout-index -f --
+
+which will force all existing `*.h` files to be replaced with their
+cached copies. If an empty command line implied "all", then this would
+force-refresh everything in the cache, which was not the point.
+
+To update and refresh only the files already checked out:
+
+        git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh
+
+Oh, and the "--" is just a good idea when you know the rest will be
+filenames. Just so that you wouldn't have a filename of "-a" causing
+problems (not possible in the above example, but get used to it in
+scripting!).
+
+The prefix ability basically makes it trivial to use
+git-checkout-index as an "export as tree" function. Just read the
+desired tree into the index, and do a
+  
+        git-checkout-index --prefix=git-export-dir/ -a
+  
+and git-checkout-index will "export" the cache into the specified
+directory.
+  
+NOTE The final "/" is important. The exported name is literally just
+prefixed with the specified string, so you can also do something like
+
+    git-checkout-index --prefix=.merged- Makefile
+
+to check out the currently cached copy of `Makefile` into the file
+`.merged-Makefile`
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-checkout-script.txt b/Documentation/git-checkout-script.txt
deleted file mode 100644 (file)
index 52831ab..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-git-checkout-script(1)
-======================
-
-NAME
-----
-git-checkout-script - Checkout and switch to a branch.
-
-SYNOPSIS
---------
-'git-checkout-script' [-f] [-b <new_branch>] [<branch>]
-
-DESCRIPTION
------------
-Updates the index and working tree to reflect the specified branch,
-<branch>. Updates HEAD to be <branch> or, if specified, <new_branch>.
-
-OPTIONS
--------
--f::
-       Force an re-read of everything.
-
--b::
-       Create a new branch and start it at <branch>.
-
-<new_branch>::
-       Name for the new branch.
-
-<branch>::
-       Branch to checkout; may be any object ID that resolves to a
-       commit. Defaults to HEAD.
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
new file mode 100644 (file)
index 0000000..3bc7743
--- /dev/null
@@ -0,0 +1,43 @@
+git-checkout(1)
+===============
+
+NAME
+----
+git-checkout - Checkout and switch to a branch.
+
+SYNOPSIS
+--------
+'git-checkout' [-f] [-b <new_branch>] [<branch>]
+
+DESCRIPTION
+-----------
+Updates the index and working tree to reflect the specified branch,
+<branch>. Updates HEAD to be <branch> or, if specified, <new_branch>.
+
+OPTIONS
+-------
+-f::
+       Force an re-read of everything.
+
+-b::
+       Create a new branch and start it at <branch>.
+
+<new_branch>::
+       Name for the new branch.
+
+<branch>::
+       Branch to checkout; may be any object ID that resolves to a
+       commit. Defaults to HEAD.
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-cherry-pick-script.txt b/Documentation/git-cherry-pick-script.txt
deleted file mode 100644 (file)
index ab9fb22..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-git-cherry-pick-script(1)
-=========================
-v0.99.5 Aug 2005
-
-NAME
-----
-git-cherry-pick-script - Apply the change introduced by an existing commit.
-
-SYNOPSIS
---------
-'git-cherry-pick-script' [-n] [-r] <commit>
-
-DESCRIPTION
------------
-Given one existing commit, apply the change the patch introduces, and record a
-new commit that records it.  This requires your working tree to be clean (no
-modifications from the HEAD commit).
-
-OPTIONS
--------
-<commit>::
-       Commit to cherry-pick.
-
--r::
-       Usuall the command appends which commit was
-       cherry-picked after the original commit message when
-       making a commit.  This option, '--replay', causes it to
-       use the original commit message intact.  This is useful
-       when you are reordering the patches in your private tree
-       before publishing, and is used by 'git rebase'.
-
--n::
-       Usually the command automatically creates a commit with
-       a commit log message stating which commit was
-       cherry-picked.  This flag applies the change necessary
-       to cherry-pick the named commit to your working tree,
-       but does not make the commit.  In addition, when this
-       option is used, your working tree does not have to match
-       the HEAD commit.  The cherry-pick is done against the
-       beginning state of your working tree.
-
-       This is useful when cherry-picking more than one commits'
-       effect to your working tree in a row.
-
-
-Author
-------
-Written by Junio C Hamano <junkio@cox.net>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
new file mode 100644 (file)
index 0000000..38a4875
--- /dev/null
@@ -0,0 +1,57 @@
+git-cherry-pick(1)
+==================
+v0.99.5 Aug 2005
+
+NAME
+----
+git-cherry-pick - Apply the change introduced by an existing commit.
+
+SYNOPSIS
+--------
+'git-cherry-pick' [-n] [-r] <commit>
+
+DESCRIPTION
+-----------
+Given one existing commit, apply the change the patch introduces, and record a
+new commit that records it.  This requires your working tree to be clean (no
+modifications from the HEAD commit).
+
+OPTIONS
+-------
+<commit>::
+       Commit to cherry-pick.
+
+-r::
+       Usuall the command appends which commit was
+       cherry-picked after the original commit message when
+       making a commit.  This option, '--replay', causes it to
+       use the original commit message intact.  This is useful
+       when you are reordering the patches in your private tree
+       before publishing, and is used by 'git rebase'.
+
+-n::
+       Usually the command automatically creates a commit with
+       a commit log message stating which commit was
+       cherry-picked.  This flag applies the change necessary
+       to cherry-pick the named commit to your working tree,
+       but does not make the commit.  In addition, when this
+       option is used, your working tree does not have to match
+       the HEAD commit.  The cherry-pick is done against the
+       beginning state of your working tree.
+
+       This is useful when cherry-picking more than one commits'
+       effect to your working tree in a row.
+
+
+Author
+------
+Written by Junio C Hamano <junkio@cox.net>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-clone-script.txt b/Documentation/git-clone-script.txt
deleted file mode 100644 (file)
index afb25bd..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-git-clone-script(1)
-===================
-v0.1, July 2005
-
-NAME
-----
-git-clone-script - Clones a repository.
-
-
-SYNOPSIS
---------
-'git clone' [-l] [-u <upload-pack>] [-q] <repository> <directory>
-
-DESCRIPTION
------------
-Clones a repository into a newly created directory.
-
-OPTIONS
--------
--l::
-       When the repository to clone from is on a local machine,
-       this flag bypasses normal "git aware" transport
-       mechanism and clones the repository by making a copy of
-       HEAD and everything under objects and refs directories.
-       The files under .git/objects/ directory are hardlinked
-       to save space when possible.
-
--q::
-       Operate quietly.  This flag is passed to "rsync" and
-       "git-clone-pack" commands when given.
-
--u <upload-pack>::
-       When given, and the repository to clone from is handled
-       by 'git-clone-pack', '--exec=<upload-pack>' is passed to
-       the command to specify non-default path for the command
-       run on the other end.
-
-<repository>::
-       The (possibly remote) repository to clone from.  It can
-       be an "rsync://host/dir" URL, an "http://host/dir" URL,
-       or [<host>:]/dir notation that is used by 'git-clone-pack'.
-       Currently http transport is not supported.
-
-<directory>::
-       The name of a new directory to be cloned into.  It is an
-       error to specify an existing directory.
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by Junio C Hamano.
-
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
new file mode 100644 (file)
index 0000000..cff87ea
--- /dev/null
@@ -0,0 +1,60 @@
+git-clone(1)
+============
+v0.1, July 2005
+
+NAME
+----
+git-clone - Clones a repository.
+
+
+SYNOPSIS
+--------
+'git clone' [-l] [-u <upload-pack>] [-q] <repository> <directory>
+
+DESCRIPTION
+-----------
+Clones a repository into a newly created directory.
+
+OPTIONS
+-------
+-l::
+       When the repository to clone from is on a local machine,
+       this flag bypasses normal "git aware" transport
+       mechanism and clones the repository by making a copy of
+       HEAD and everything under objects and refs directories.
+       The files under .git/objects/ directory are hardlinked
+       to save space when possible.
+
+-q::
+       Operate quietly.  This flag is passed to "rsync" and
+       "git-clone-pack" commands when given.
+
+-u <upload-pack>::
+       When given, and the repository to clone from is handled
+       by 'git-clone-pack', '--exec=<upload-pack>' is passed to
+       the command to specify non-default path for the command
+       run on the other end.
+
+<repository>::
+       The (possibly remote) repository to clone from.  It can
+       be an "rsync://host/dir" URL, an "http://host/dir" URL,
+       or [<host>:]/dir notation that is used by 'git-clone-pack'.
+       Currently http transport is not supported.
+
+<directory>::
+       The name of a new directory to be cloned into.  It is an
+       error to specify an existing directory.
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by Junio C Hamano.
+
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-commit-script.txt b/Documentation/git-commit-script.txt
deleted file mode 100644 (file)
index faa1870..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-git-commit-script(1)
-====================
-v0.99.4, Aug 2005
-
-NAME
-----
-git-commit-script - Record your changes
-
-SYNOPSIS
---------
-'git commit' [-a] [-s] [-v] [(-c | -C) <commit> | -F <file> | -m <msg>] [-e] <file>...
-
-DESCRIPTION
------------
-Updates the index file for given paths, or all modified files if
-'-a' is specified, and makes a commit object.  The command
-VISUAL and EDITOR environment variables to edit the commit log
-message.
-
-This command can run `commit-msg`, `pre-commit`, and
-`post-commit` hooks.  See link:hooks.html[hooks] for more
-information.
-
-OPTIONS
--------
--a::
-       Update all paths in the index file.
-
--c or -C <commit>::
-       Take existing commit object, and reuse the log message
-       and the authorship information (including the timestamp)
-       when creating the commit.  With '-C', the editor is not
-       invoked; with '-c' the user can further edit the commit
-       message.
-
--F <file>::
-       Take the commit message from the given file.  Use '-' to
-       read the message from the standard input.
-
--m <msg>::
-       Use the given <msg> as the commit message.
-
--s::
-       Add Signed-off-by line at the end of the commit message.
-
--v::
-       Look for suspicious lines the commit introduces, and
-       abort committing if there is one.  The definition of
-       'suspicious lines' is currently the lines that has
-       trailing whitespaces, and the lines whose indentation
-       has a SP character immediately followed by a TAB
-       character.
-
--e::
-       The message taken from file with `-F`, command line with
-       `-m`, and from file with `-C` are usually used as the
-       commit log message unmodified.  This option lets you
-       further edit the message taken from these sources.
-
-<file>...::
-       Update specified paths in the index file before committing.
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org> and
-Junio C Hamano <junkio@cox.net>
-
-
-GIT
----
-Part of the link:git.html[git] suite
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
new file mode 100644 (file)
index 0000000..afcf6ef
--- /dev/null
@@ -0,0 +1,72 @@
+git-commit(1)
+=============
+v0.99.4, Aug 2005
+
+NAME
+----
+git-commit - Record your changes
+
+SYNOPSIS
+--------
+'git commit' [-a] [-s] [-v] [(-c | -C) <commit> | -F <file> | -m <msg>] [-e] <file>...
+
+DESCRIPTION
+-----------
+Updates the index file for given paths, or all modified files if
+'-a' is specified, and makes a commit object.  The command
+VISUAL and EDITOR environment variables to edit the commit log
+message.
+
+This command can run `commit-msg`, `pre-commit`, and
+`post-commit` hooks.  See link:hooks.html[hooks] for more
+information.
+
+OPTIONS
+-------
+-a::
+       Update all paths in the index file.
+
+-c or -C <commit>::
+       Take existing commit object, and reuse the log message
+       and the authorship information (including the timestamp)
+       when creating the commit.  With '-C', the editor is not
+       invoked; with '-c' the user can further edit the commit
+       message.
+
+-F <file>::
+       Take the commit message from the given file.  Use '-' to
+       read the message from the standard input.
+
+-m <msg>::
+       Use the given <msg> as the commit message.
+
+-s::
+       Add Signed-off-by line at the end of the commit message.
+
+-v::
+       Look for suspicious lines the commit introduces, and
+       abort committing if there is one.  The definition of
+       'suspicious lines' is currently the lines that has
+       trailing whitespaces, and the lines whose indentation
+       has a SP character immediately followed by a TAB
+       character.
+
+-e::
+       The message taken from file with `-F`, command line with
+       `-m`, and from file with `-C` are usually used as the
+       commit log message unmodified.  This option lets you
+       further edit the message taken from these sources.
+
+<file>...::
+       Update specified paths in the index file before committing.
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org> and
+Junio C Hamano <junkio@cox.net>
+
+
+GIT
+---
+Part of the link:git.html[git] suite
diff --git a/Documentation/git-convert-cache.txt b/Documentation/git-convert-cache.txt
deleted file mode 100644 (file)
index 66d7fe7..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-git-convert-cache(1)
-====================
-v0.1, May 2005
-
-NAME
-----
-git-convert-cache - Converts old-style GIT repository
-
-
-SYNOPSIS
---------
-'git-convert-cache'
-
-DESCRIPTION
------------
-Converts old-style GIT repository to the latest format
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-convert-objects.txt b/Documentation/git-convert-objects.txt
new file mode 100644 (file)
index 0000000..b1bc1c5
--- /dev/null
@@ -0,0 +1,30 @@
+git-convert-objects(1)
+======================
+v0.1, May 2005
+
+NAME
+----
+git-convert-objects - Converts old-style GIT repository
+
+
+SYNOPSIS
+--------
+'git-convert-objects'
+
+DESCRIPTION
+-----------
+Converts old-style GIT repository to the latest format
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-count-objects-script.txt b/Documentation/git-count-objects-script.txt
deleted file mode 100644 (file)
index 8a3cedf..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-git-count-objects-script(1)
-===========================
-
-NAME
-----
-git-count-objects-script - Reports on unpacked objects.
-
-SYNOPSIS
---------
-'git-count-objects-script'
-
-DESCRIPTION
------------
-This counts the number of unpacked object files and disk space consumed by
-them, to help you decide when it is a good time to repack.
-
-Author
-------
-Written by Junio C Hamano <junkio@cox.net>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-count-objects.txt b/Documentation/git-count-objects.txt
new file mode 100644 (file)
index 0000000..824852c
--- /dev/null
@@ -0,0 +1,28 @@
+git-count-objects(1)
+====================
+
+NAME
+----
+git-count-objects - Reports on unpacked objects.
+
+SYNOPSIS
+--------
+'git-count-objects'
+
+DESCRIPTION
+-----------
+This counts the number of unpacked object files and disk space consumed by
+them, to help you decide when it is a good time to repack.
+
+Author
+------
+Written by Junio C Hamano <junkio@cox.net>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-cvsimport-script.txt b/Documentation/git-cvsimport-script.txt
deleted file mode 100644 (file)
index 9d8acfc..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-git-cvsimport-script(1)
-=======================
-v0.1, July 2005
-
-NAME
-----
-git-cvsimport-script - Import a CVS repository into git
-
-
-SYNOPSIS
---------
-'git-cvsimport-script' [ -o <branch-for-HEAD> ] [ -h ] [ -v ]
-                       [ -d <CVSROOT> ] [ -p <options-for-cvsps> ]
-                       [ -C <GIT_repository> ] [ -i ] [ -k ]
-                       [ -s <subst> ] [ -m ] [ -M regex ] [ <CVS_module> ]
-
-
-DESCRIPTION
------------
-Imports a CVS repository into git. It will either create a new
-repository, or incrementally import into an existing one.
-
-Splitting the CVS log into patch sets is done by 'cvsps'.
-At least version 2.1 is required.
-
-OPTIONS
--------
--d <CVSROOT>::
-       The root of the CVS archive. May be local (a simple path) or remote;
-       currently, only the :local:, :ext: and :pserver: access methods 
-       are supported.
-
--C <target-dir>::
-        The GIT repository to import to.  If the directory doesn't
-        exist, it will be created.  Default is the current directory.
-
--i::
-       Import-only: don't perform a checkout after importing.  This option
-       ensures the working directory and cache remain untouched and will
-       not create them if they do not exist.
-
--k::
-       Kill keywords: will extract files with -kk from the CVS archive
-       to avoid noisy changesets. Highly recommended, but off by default
-       to preserve compatibility with early imported trees. 
-
--u::
-       Convert underscores in tag and branch names to dots.
-
--o <branch-for-HEAD>::
-       The 'HEAD' branch from CVS is imported to the 'origin' branch within
-       the git repository, as 'HEAD' already has a special meaning for git.
-       Use this option if you want to import into a different branch.
-
-       Use '-o master' for continuing an import that was initially done by
-       the old cvs2git tool.
-
--p <options-for-cvsps>::
-       Additional options for cvsps.
-       The options '-u' and '-A' are implicit and should not be used here.
-
-       If you need to pass multiple options, separate them with a comma.
-
--m::    
-       Attempt to detect merges based on the commit message. This option
-       will enable default regexes that try to capture the name source 
-       branch name from the commit message. 
-
--M <regex>::
-       Attempt to detect merges based on the commit message with a custom
-       regex. It can be used with -m to also see the default regexes. 
-       You must escape forward slashes. 
-
--v::
-       Verbosity: let 'cvsimport' report what it is doing.
-
-<CVS_module>::
-       The CVS module you want to import. Relative to <CVSROOT>.
-
--h::
-       Print a short usage message and exit.
-
--z <fuzz>::
-        Pass the timestamp fuzz factor to cvsps.
-
--s <subst>::
-       Substitute the character "/" in branch names with <subst>
-
-OUTPUT
-------
-If '-v' is specified, the script reports what it is doing.
-
-Otherwise, success is indicated the Unix way, i.e. by simply exiting with
-a zero exit status.
-
-
-Author
-------
-Written by Matthias Urlichs <smurf@smurf.noris.de>, with help from
-various participants of the git-list <git@vger.kernel.org>.
-
-Documentation
---------------
-Documentation by Matthias Urlichs <smurf@smurf.noris.de>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt
new file mode 100644 (file)
index 0000000..edf9521
--- /dev/null
@@ -0,0 +1,109 @@
+git-cvsimport(1)
+================
+v0.1, July 2005
+
+NAME
+----
+git-cvsimport - Import a CVS repository into git
+
+
+SYNOPSIS
+--------
+'git-cvsimport' [ -o <branch-for-HEAD> ] [ -h ] [ -v ]
+                       [ -d <CVSROOT> ] [ -p <options-for-cvsps> ]
+                       [ -C <GIT_repository> ] [ -i ] [ -k ]
+                       [ -s <subst> ] [ -m ] [ -M regex ] [ <CVS_module> ]
+
+
+DESCRIPTION
+-----------
+Imports a CVS repository into git. It will either create a new
+repository, or incrementally import into an existing one.
+
+Splitting the CVS log into patch sets is done by 'cvsps'.
+At least version 2.1 is required.
+
+OPTIONS
+-------
+-d <CVSROOT>::
+       The root of the CVS archive. May be local (a simple path) or remote;
+       currently, only the :local:, :ext: and :pserver: access methods 
+       are supported.
+
+-C <target-dir>::
+        The GIT repository to import to.  If the directory doesn't
+        exist, it will be created.  Default is the current directory.
+
+-i::
+       Import-only: don't perform a checkout after importing.  This option
+       ensures the working directory and cache remain untouched and will
+       not create them if they do not exist.
+
+-k::
+       Kill keywords: will extract files with -kk from the CVS archive
+       to avoid noisy changesets. Highly recommended, but off by default
+       to preserve compatibility with early imported trees. 
+
+-u::
+       Convert underscores in tag and branch names to dots.
+
+-o <branch-for-HEAD>::
+       The 'HEAD' branch from CVS is imported to the 'origin' branch within
+       the git repository, as 'HEAD' already has a special meaning for git.
+       Use this option if you want to import into a different branch.
+
+       Use '-o master' for continuing an import that was initially done by
+       the old cvs2git tool.
+
+-p <options-for-cvsps>::
+       Additional options for cvsps.
+       The options '-u' and '-A' are implicit and should not be used here.
+
+       If you need to pass multiple options, separate them with a comma.
+
+-m::    
+       Attempt to detect merges based on the commit message. This option
+       will enable default regexes that try to capture the name source 
+       branch name from the commit message. 
+
+-M <regex>::
+       Attempt to detect merges based on the commit message with a custom
+       regex. It can be used with -m to also see the default regexes. 
+       You must escape forward slashes. 
+
+-v::
+       Verbosity: let 'cvsimport' report what it is doing.
+
+<CVS_module>::
+       The CVS module you want to import. Relative to <CVSROOT>.
+
+-h::
+       Print a short usage message and exit.
+
+-z <fuzz>::
+        Pass the timestamp fuzz factor to cvsps.
+
+-s <subst>::
+       Substitute the character "/" in branch names with <subst>
+
+OUTPUT
+------
+If '-v' is specified, the script reports what it is doing.
+
+Otherwise, success is indicated the Unix way, i.e. by simply exiting with
+a zero exit status.
+
+
+Author
+------
+Written by Matthias Urlichs <smurf@smurf.noris.de>, with help from
+various participants of the git-list <git@vger.kernel.org>.
+
+Documentation
+--------------
+Documentation by Matthias Urlichs <smurf@smurf.noris.de>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-diff-cache.txt b/Documentation/git-diff-cache.txt
deleted file mode 100644 (file)
index a353d12..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-git-diff-cache(1)
-=================
-v0.1, May 2005
-
-NAME
-----
-git-diff-cache - Compares content and mode of blobs between the cache and repository
-
-
-SYNOPSIS
---------
-'git-diff-cache' [-m] [--cached] [<common diff options>] <tree-ish> [<path>...]
-
-DESCRIPTION
------------
-Compares the content and mode of the blobs found via a tree
-object with the content of the current cache and, optionally
-ignoring the stat state of the file on disk.  When paths are
-specified, compares only those named paths.  Otherwise all
-entries in the cache are compared.
-
-OPTIONS
--------
-include::diff-options.txt[]
-
-<tree-ish>::
-       The id of a tree object to diff against.
-
---cached::
-       do not consider the on-disk file at all
-
--m::
-       By default, files recorded in the index but not checked
-       out are reported as deleted.  This flag makes
-       "git-diff-cache" say that all non-checked-out files are up
-       to date.
-
-Output format
--------------
-include::diff-format.txt[]
-
-Operating Modes
----------------
-You can choose whether you want to trust the index file entirely
-(using the '--cached' flag) or ask the diff logic to show any files
-that don't match the stat state as being "tentatively changed".  Both
-of these operations are very useful indeed.
-
-Cached Mode
------------
-If '--cached' is specified, it allows you to ask:
-
-       show me the differences between HEAD and the current cache
-       contents (the ones I'd write with a "git-write-tree")
-
-For example, let's say that you have worked on your working directory, updated
-some files in the cache and are ready to commit. You want to see eactly
-*what* you are going to commit is without having to write a new tree
-object and compare it that way, and to do that, you just do
-
-       git-diff-cache --cached $(cat .git/HEAD)
-
-Example: let's say I had renamed `commit.c` to `git-commit.c`, and I had
-done an "git-update-cache" to make that effective in the index file.
-"git-diff-files" wouldn't show anything at all, since the index file
-matches my working directory. But doing a "git-diff-cache" does:
-
-  torvalds@ppc970:~/git> git-diff-cache --cached $(cat .git/HEAD)
-  -100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        commit.c
-  +100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        git-commit.c
-
-You can trivially see that the above is a rename.
-
-In fact, "git-diff-cache --cached" *should* always be entirely equivalent to
-actually doing a "git-write-tree" and comparing that. Except this one is much
-nicer for the case where you just want to check where you are.
-
-So doing a "git-diff-cache --cached" is basically very useful when you are 
-asking yourself "what have I already marked for being committed, and 
-what's the difference to a previous tree".
-
-Non-cached Mode
----------------
-The "non-cached" mode takes a different approach, and is potentially
-the more useful of the two in that what it does can't be emulated with
-a "git-write-tree" + "git-diff-tree". Thus that's the default mode.
-The non-cached version asks the question:
-
-   show me the differences between HEAD and the currently checked out
-   tree - index contents _and_ files that aren't up-to-date
-
-which is obviously a very useful question too, since that tells you what
-you *could* commit. Again, the output matches the "git-diff-tree -r"
-output to a tee, but with a twist.
-
-The twist is that if some file doesn't match the cache, we don't have
-a backing store thing for it, and we use the magic "all-zero" sha1 to
-show that. So let's say that you have edited `kernel/sched.c`, but
-have not actually done a "git-update-cache" on it yet - there is no
-"object" associated with the new state, and you get:
-
-  torvalds@ppc970:~/v2.6/linux> git-diff-cache $(cat .git/HEAD )
-  *100644->100664 blob    7476bb......->000000......      kernel/sched.c
-
-ie it shows that the tree has changed, and that `kernel/sched.c` has is
-not up-to-date and may contain new stuff. The all-zero sha1 means that to
-get the real diff, you need to look at the object in the working directory
-directly rather than do an object-to-object diff.
-
-NOTE! As with other commands of this type, "git-diff-cache" does not
-actually look at the contents of the file at all. So maybe
-`kernel/sched.c` hasn't actually changed, and it's just that you
-touched it. In either case, it's a note that you need to
-"git-upate-cache" it to make the cache be in sync.
-
-NOTE 2! You can have a mixture of files show up as "has been updated"
-and "is still dirty in the working directory" together. You can always
-tell which file is in which state, since the "has been updated" ones
-show a valid sha1, and the "not in sync with the index" ones will
-always have the special all-zero sha1.
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
index 3e1244f..72c7a71 100644 (file)
@@ -16,7 +16,7 @@ DESCRIPTION
 Compares the files in the working tree and the cache.  When paths
 are specified, compares only those named paths.  Otherwise all
 entries in the cache are compared.  The output format is the
-same as "git-diff-cache" and "git-diff-tree".
+same as "git-diff-index" and "git-diff-tree".
 
 OPTIONS
 -------
index d826deb..26f5f39 100644 (file)
@@ -13,7 +13,7 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-Reads output from "git-diff-cache", "git-diff-tree" and "git-diff-files" and
+Reads output from "git-diff-index", "git-diff-tree" and "git-diff-files" and
 generates patch format output.
 
 OPTIONS
@@ -35,7 +35,7 @@ OPTIONS
 
 See Also
 --------
-The section on generating patches in link:git-diff-cache.html[git-diff-cache]
+The section on generating patches in link:git-diff-index.html[git-diff-index]
 
 
 Author
diff --git a/Documentation/git-diff-index.txt b/Documentation/git-diff-index.txt
new file mode 100644 (file)
index 0000000..12bfcb3
--- /dev/null
@@ -0,0 +1,134 @@
+git-diff-index(1)
+=================
+v0.1, May 2005
+
+NAME
+----
+git-diff-index - Compares content and mode of blobs between the cache and repository
+
+
+SYNOPSIS
+--------
+'git-diff-index' [-m] [--cached] [<common diff options>] <tree-ish> [<path>...]
+
+DESCRIPTION
+-----------
+Compares the content and mode of the blobs found via a tree
+object with the content of the current cache and, optionally
+ignoring the stat state of the file on disk.  When paths are
+specified, compares only those named paths.  Otherwise all
+entries in the cache are compared.
+
+OPTIONS
+-------
+include::diff-options.txt[]
+
+<tree-ish>::
+       The id of a tree object to diff against.
+
+--cached::
+       do not consider the on-disk file at all
+
+-m::
+       By default, files recorded in the index but not checked
+       out are reported as deleted.  This flag makes
+       "git-diff-index" say that all non-checked-out files are up
+       to date.
+
+Output format
+-------------
+include::diff-format.txt[]
+
+Operating Modes
+---------------
+You can choose whether you want to trust the index file entirely
+(using the '--cached' flag) or ask the diff logic to show any files
+that don't match the stat state as being "tentatively changed".  Both
+of these operations are very useful indeed.
+
+Cached Mode
+-----------
+If '--cached' is specified, it allows you to ask:
+
+       show me the differences between HEAD and the current cache
+       contents (the ones I'd write with a "git-write-tree")
+
+For example, let's say that you have worked on your working directory, updated
+some files in the cache and are ready to commit. You want to see eactly
+*what* you are going to commit is without having to write a new tree
+object and compare it that way, and to do that, you just do
+
+       git-diff-index --cached $(cat .git/HEAD)
+
+Example: let's say I had renamed `commit.c` to `git-commit.c`, and I had
+done an "git-update-index" to make that effective in the index file.
+"git-diff-files" wouldn't show anything at all, since the index file
+matches my working directory. But doing a "git-diff-index" does:
+
+  torvalds@ppc970:~/git> git-diff-index --cached $(cat .git/HEAD)
+  -100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        commit.c
+  +100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        git-commit.c
+
+You can trivially see that the above is a rename.
+
+In fact, "git-diff-index --cached" *should* always be entirely equivalent to
+actually doing a "git-write-tree" and comparing that. Except this one is much
+nicer for the case where you just want to check where you are.
+
+So doing a "git-diff-index --cached" is basically very useful when you are
+asking yourself "what have I already marked for being committed, and 
+what's the difference to a previous tree".
+
+Non-cached Mode
+---------------
+The "non-cached" mode takes a different approach, and is potentially
+the more useful of the two in that what it does can't be emulated with
+a "git-write-tree" + "git-diff-tree". Thus that's the default mode.
+The non-cached version asks the question:
+
+   show me the differences between HEAD and the currently checked out
+   tree - index contents _and_ files that aren't up-to-date
+
+which is obviously a very useful question too, since that tells you what
+you *could* commit. Again, the output matches the "git-diff-tree -r"
+output to a tee, but with a twist.
+
+The twist is that if some file doesn't match the cache, we don't have
+a backing store thing for it, and we use the magic "all-zero" sha1 to
+show that. So let's say that you have edited `kernel/sched.c`, but
+have not actually done a "git-update-index" on it yet - there is no
+"object" associated with the new state, and you get:
+
+  torvalds@ppc970:~/v2.6/linux> git-diff-index $(cat .git/HEAD )
+  *100644->100664 blob    7476bb......->000000......      kernel/sched.c
+
+ie it shows that the tree has changed, and that `kernel/sched.c` has is
+not up-to-date and may contain new stuff. The all-zero sha1 means that to
+get the real diff, you need to look at the object in the working directory
+directly rather than do an object-to-object diff.
+
+NOTE! As with other commands of this type, "git-diff-index" does not
+actually look at the contents of the file at all. So maybe
+`kernel/sched.c` hasn't actually changed, and it's just that you
+touched it. In either case, it's a note that you need to
+"git-upate-cache" it to make the cache be in sync.
+
+NOTE 2! You can have a mixture of files show up as "has been updated"
+and "is still dirty in the working directory" together. You can always
+tell which file is in which state, since the "has been updated" ones
+show a valid sha1, and the "not in sync with the index" ones will
+always have the special all-zero sha1.
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-diff-script.txt b/Documentation/git-diff-script.txt
deleted file mode 100644 (file)
index 64acdc0..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-git-diff-script(1)
-==================
-
-NAME
-----
-git-diff-script - Some git command not yet documented.
-
-
-SYNOPSIS
---------
-'git-diff-script' [ --option ] <args>...
-
-DESCRIPTION
------------
-Does something not yet documented.
-
-
-OPTIONS
--------
---option::
-       Some option not yet documented.
-
-<args>...::
-       Some argument not yet documented.
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
index 5ccf0ba..9ec4b29 100644 (file)
@@ -93,7 +93,7 @@ so it can be used to name subdirectories.
 An example of normal usage is:
 
   torvalds@ppc970:~/git> git-diff-tree 5319e4......
-  *100664->100664 blob    ac348b.......->a01513.......      git-fsck-cache.c
+  *100664->100664 blob    ac348b.......->a01513.......      git-fsck-objects.c
 
 which tells you that the last commit changed just one file (it's from
 this one:
@@ -104,7 +104,7 @@ this one:
   author Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005
   committer Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005
 
-  Make "git-fsck-cache" print out all the root commits it finds.
+  Make "git-fsck-objects" print out all the root commits it finds.
 
   Once I do the reference tracking, I'll also make it print out all the
   HEAD commits it finds, which is even more interesting.
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
new file mode 100644 (file)
index 0000000..f43a60f
--- /dev/null
@@ -0,0 +1,38 @@
+git-diff(1)
+===========
+
+NAME
+----
+git-diff - Some git command not yet documented.
+
+
+SYNOPSIS
+--------
+'git-diff' [ --option ] <args>...
+
+DESCRIPTION
+-----------
+Does something not yet documented.
+
+
+OPTIONS
+-------
+--option::
+       Some option not yet documented.
+
+<args>...::
+       Some argument not yet documented.
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-fetch-script.txt b/Documentation/git-fetch-script.txt
deleted file mode 100644 (file)
index d15222b..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-git-fetch-script(1)
-===================
-v0.99.5, Aug 2005
-
-NAME
-----
-git-fetch-script - Download objects and a head from another repository.
-
-
-SYNOPSIS
---------
-'git-fetch-script' <repository> <refspec>...
-
-
-DESCRIPTION
------------
-Fetches named heads or tags from another repository, along with
-the objects necessary to complete them.
-
-The ref names and their object names of fetched refs are stored
-in $GIT_DIR/FETCH_HEAD.  This information is left for a later merge
-operation done by "git resolve" or "git octopus".
-
-
-OPTIONS
--------
-include::pull-fetch-param.txt[]
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org> and
-Junio C Hamano <junkio@cox.net>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
diff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt
new file mode 100644 (file)
index 0000000..017f646
--- /dev/null
@@ -0,0 +1,41 @@
+git-fetch(1)
+============
+v0.99.5, Aug 2005
+
+NAME
+----
+git-fetch - Download objects and a head from another repository.
+
+
+SYNOPSIS
+--------
+'git-fetch' <repository> <refspec>...
+
+
+DESCRIPTION
+-----------
+Fetches named heads or tags from another repository, along with
+the objects necessary to complete them.
+
+The ref names and their object names of fetched refs are stored
+in $GIT_DIR/FETCH_HEAD.  This information is left for a later merge
+operation done by "git resolve" or "git octopus".
+
+
+OPTIONS
+-------
+include::pull-fetch-param.txt[]
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org> and
+Junio C Hamano <junkio@cox.net>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
diff --git a/Documentation/git-format-patch-script.txt b/Documentation/git-format-patch-script.txt
deleted file mode 100644 (file)
index ae3b8a1..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-git-format-patch-script(1)
-==========================
-
-NAME
-----
-git-format-patch-script - Some git command not yet documented.
-
-
-SYNOPSIS
---------
-'git-format-patch-script' [ --option ] <args>...
-
-DESCRIPTION
------------
-Does something not yet documented.
-
-
-OPTIONS
--------
---option::
-       Some option not yet documented.
-
-<args>...::
-       Some argument not yet documented.
-
-
-Author
-------
-Written by Junio C Hamano <junkio@cox.net>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
new file mode 100644 (file)
index 0000000..1788a97
--- /dev/null
@@ -0,0 +1,38 @@
+git-format-patch(1)
+===================
+
+NAME
+----
+git-format-patch - Some git command not yet documented.
+
+
+SYNOPSIS
+--------
+'git-format-patch' [ --option ] <args>...
+
+DESCRIPTION
+-----------
+Does something not yet documented.
+
+
+OPTIONS
+-------
+--option::
+       Some option not yet documented.
+
+<args>...::
+       Some argument not yet documented.
+
+
+Author
+------
+Written by Junio C Hamano <junkio@cox.net>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-fsck-cache.txt b/Documentation/git-fsck-cache.txt
deleted file mode 100644 (file)
index 13f1965..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-git-fsck-cache(1)
-=================
-v0.1, May 2005
-
-NAME
-----
-git-fsck-cache - Verifies the connectivity and validity of the objects in the database
-
-
-SYNOPSIS
---------
-'git-fsck-cache' [--tags] [--root] [--unreachable] [--cache] [--standalone | --full] [--strict] [<object>*]
-
-DESCRIPTION
------------
-Verifies the connectivity and validity of the objects in the database.
-
-OPTIONS
--------
-<object>::
-       An object to treat as the head of an unreachability trace.
-
-       If no objects are given, git-fsck-cache defaults to using the
-       index file and all SHA1 references in .git/refs/* as heads.
-
---unreachable::
-       Print out objects that exist but that aren't readable from any
-       of the reference nodes.
-
---root::
-       Report root nodes.
-
---tags::
-       Report tags.
-
---cache::
-       Consider any object recorded in the cache also as a head node for
-       an unreachability trace.
-
---standalone::
-       Limit checks to the contents of GIT_OBJECT_DIRECTORY
-       ($GIT_DIR/objects), making sure that it is consistent and
-       complete without referring to objects found in alternate
-       object pools listed in GIT_ALTERNATE_OBJECT_DIRECTORIES,
-       nor packed GIT archives found in $GIT_DIR/objects/pack;
-       cannot be used with --full.
-
---full::
-       Check not just objects in GIT_OBJECT_DIRECTORY
-       ($GIT_DIR/objects), but also the ones found in alternate
-       object pools listed in GIT_ALTERNATE_OBJECT_DIRECTORIES,
-       and in packed GIT archives found in $GIT_DIR/objects/pack
-       and corresponding pack subdirectories in alternate
-       object pools; cannot be used with --standalone.
-
---strict::
-       Enable more strict checking, namely to catch a file mode
-       recorded with g+w bit set, which was created by older
-       versions of GIT.  Existing repositories, including the
-       Linux kernel, GIT itself, and sparse repository have old
-       objects that triggers this check, but it is recommended
-       to check new projects with this flag.
-
-It tests SHA1 and general object sanity, and it does full tracking of
-the resulting reachability and everything else. It prints out any
-corruption it finds (missing or bad objects), and if you use the
-'--unreachable' flag it will also print out objects that exist but
-that aren't readable from any of the specified head nodes.
-
-So for example
-
-       git-fsck-cache --unreachable $(cat .git/HEAD .git/refs/heads/*)
-
-will do quite a _lot_ of verification on the tree. There are a few
-extra validity tests to be added (make sure that tree objects are
-sorted properly etc), but on the whole if "git-fsck-cache" is happy, you
-do have a valid tree.
-
-Any corrupt objects you will have to find in backups or other archives
-(ie you can just remove them and do an "rsync" with some other site in
-the hopes that somebody else has the object you have corrupted).
-
-Of course, "valid tree" doesn't mean that it wasn't generated by some
-evil person, and the end result might be crap. Git is a revision
-tracking system, not a quality assurance system ;)
-
-Extracted Diagnostics
----------------------
-
-expect dangling commits - potential heads - due to lack of head information::
-       You haven't specified any nodes as heads so it won't be
-       possible to differentiate between un-parented commits and
-       root nodes.
-
-missing sha1 directory '<dir>'::
-       The directory holding the sha1 objects is missing.
-
-unreachable <type> <object>::
-       The <type> object <object>, isn't actually referred to directly
-       or indirectly in any of the trees or commits seen. This can
-       mean that there's another root node that you're not specifying
-       or that the tree is corrupt. If you haven't missed a root node
-       then you might as well delete unreachable nodes since they
-       can't be used.
-
-missing <type> <object>::
-       The <type> object <object>, is referred to but isn't present in
-       the database.
-
-dangling <type> <object>::
-       The <type> object <object>, is present in the database but never
-       'directly' used. A dangling commit could be a root node.
-
-warning: git-fsck-cache: tree <tree> has full pathnames in it::
-       And it shouldn't...
-
-sha1 mismatch <object>::
-       The database has an object who's sha1 doesn't match the
-       database value.
-       This indicates a serious data integrity problem.
-
-Environment Variables
----------------------
-
-GIT_OBJECT_DIRECTORY::
-       used to specify the object database root (usually $GIT_DIR/objects)
-
-GIT_INDEX_FILE::
-       used to specify the index file of the cache
-
-GIT_ALTERNATE_OBJECT_DIRECTORIES:
-       used to specify additional object database roots (usually unset)
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-fsck-objects.txt b/Documentation/git-fsck-objects.txt
new file mode 100644 (file)
index 0000000..2b86404
--- /dev/null
@@ -0,0 +1,145 @@
+git-fsck-objects(1)
+===================
+v0.1, May 2005
+
+NAME
+----
+git-fsck-objects - Verifies the connectivity and validity of the objects in the database
+
+
+SYNOPSIS
+--------
+'git-fsck-objects' [--tags] [--root] [--unreachable] [--cache] [--standalone | --full] [--strict] [<object>*]
+
+DESCRIPTION
+-----------
+Verifies the connectivity and validity of the objects in the database.
+
+OPTIONS
+-------
+<object>::
+       An object to treat as the head of an unreachability trace.
+
+       If no objects are given, git-fsck-objects defaults to using the
+       index file and all SHA1 references in .git/refs/* as heads.
+
+--unreachable::
+       Print out objects that exist but that aren't readable from any
+       of the reference nodes.
+
+--root::
+       Report root nodes.
+
+--tags::
+       Report tags.
+
+--cache::
+       Consider any object recorded in the cache also as a head node for
+       an unreachability trace.
+
+--standalone::
+       Limit checks to the contents of GIT_OBJECT_DIRECTORY
+       ($GIT_DIR/objects), making sure that it is consistent and
+       complete without referring to objects found in alternate
+       object pools listed in GIT_ALTERNATE_OBJECT_DIRECTORIES,
+       nor packed GIT archives found in $GIT_DIR/objects/pack;
+       cannot be used with --full.
+
+--full::
+       Check not just objects in GIT_OBJECT_DIRECTORY
+       ($GIT_DIR/objects), but also the ones found in alternate
+       object pools listed in GIT_ALTERNATE_OBJECT_DIRECTORIES,
+       and in packed GIT archives found in $GIT_DIR/objects/pack
+       and corresponding pack subdirectories in alternate
+       object pools; cannot be used with --standalone.
+
+--strict::
+       Enable more strict checking, namely to catch a file mode
+       recorded with g+w bit set, which was created by older
+       versions of GIT.  Existing repositories, including the
+       Linux kernel, GIT itself, and sparse repository have old
+       objects that triggers this check, but it is recommended
+       to check new projects with this flag.
+
+It tests SHA1 and general object sanity, and it does full tracking of
+the resulting reachability and everything else. It prints out any
+corruption it finds (missing or bad objects), and if you use the
+'--unreachable' flag it will also print out objects that exist but
+that aren't readable from any of the specified head nodes.
+
+So for example
+
+       git-fsck-objects --unreachable $(cat .git/HEAD .git/refs/heads/*)
+
+will do quite a _lot_ of verification on the tree. There are a few
+extra validity tests to be added (make sure that tree objects are
+sorted properly etc), but on the whole if "git-fsck-objects" is happy, you
+do have a valid tree.
+
+Any corrupt objects you will have to find in backups or other archives
+(ie you can just remove them and do an "rsync" with some other site in
+the hopes that somebody else has the object you have corrupted).
+
+Of course, "valid tree" doesn't mean that it wasn't generated by some
+evil person, and the end result might be crap. Git is a revision
+tracking system, not a quality assurance system ;)
+
+Extracted Diagnostics
+---------------------
+
+expect dangling commits - potential heads - due to lack of head information::
+       You haven't specified any nodes as heads so it won't be
+       possible to differentiate between un-parented commits and
+       root nodes.
+
+missing sha1 directory '<dir>'::
+       The directory holding the sha1 objects is missing.
+
+unreachable <type> <object>::
+       The <type> object <object>, isn't actually referred to directly
+       or indirectly in any of the trees or commits seen. This can
+       mean that there's another root node that you're not specifying
+       or that the tree is corrupt. If you haven't missed a root node
+       then you might as well delete unreachable nodes since they
+       can't be used.
+
+missing <type> <object>::
+       The <type> object <object>, is referred to but isn't present in
+       the database.
+
+dangling <type> <object>::
+       The <type> object <object>, is present in the database but never
+       'directly' used. A dangling commit could be a root node.
+
+warning: git-fsck-objects: tree <tree> has full pathnames in it::
+       And it shouldn't...
+
+sha1 mismatch <object>::
+       The database has an object who's sha1 doesn't match the
+       database value.
+       This indicates a serious data integrity problem.
+
+Environment Variables
+---------------------
+
+GIT_OBJECT_DIRECTORY::
+       used to specify the object database root (usually $GIT_DIR/objects)
+
+GIT_INDEX_FILE::
+       used to specify the index file of the cache
+
+GIT_ALTERNATE_OBJECT_DIRECTORIES:
+       used to specify additional object database roots (usually unset)
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
index a77adab..4dd06f7 100644 (file)
@@ -17,7 +17,7 @@ Computes the object ID value for an object with specified type
 with the contents of the named file (which can be outside of the
 work tree), and optionally writes the resulting object into the
 object database.  Reports its object ID to its standard output.
-This is used by "git-cvsimport-script" to update the cache
+This is used by "git-cvsimport" to update the cache
 without modifying files in the work tree.  When <type> is not
 specified, it defaults to "blob". 
 
diff --git a/Documentation/git-http-fetch.txt b/Documentation/git-http-fetch.txt
new file mode 100644 (file)
index 0000000..9cd862e
--- /dev/null
@@ -0,0 +1,42 @@
+git-http-fetch(1)
+=================
+v0.1, May 2005
+
+NAME
+----
+git-http-fetch - Downloads a remote GIT repository via HTTP
+
+
+SYNOPSIS
+--------
+'git-http-fetch' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] commit-id url
+
+DESCRIPTION
+-----------
+Downloads a remote GIT repository via HTTP.
+
+-c::
+       Get the commit objects.
+-t::
+       Get trees associated with the commit objects.
+-a::
+       Get all the objects.
+-v::
+       Report what is downloaded.
+
+-w <filename>::
+        Writes the commit-id into the filename under $GIT_DIR/refs/<filename> on
+        the local end after the transfer is complete.
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-http-pull.txt b/Documentation/git-http-pull.txt
deleted file mode 100644 (file)
index edc5ceb..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-git-http-pull(1)
-================
-v0.1, May 2005
-
-NAME
-----
-git-http-pull - Downloads a remote GIT repository via HTTP
-
-
-SYNOPSIS
---------
-'git-http-pull' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] commit-id url
-
-DESCRIPTION
------------
-Downloads a remote GIT repository via HTTP.
-
--c::
-       Get the commit objects.
--t::
-       Get trees associated with the commit objects.
--a::
-       Get all the objects.
--v::
-       Report what is downloaded.
-
--w <filename>::
-        Writes the commit-id into the filename under $GIT_DIR/refs/<filename> on
-        the local end after the transfer is complete.
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-local-fetch.txt b/Documentation/git-local-fetch.txt
new file mode 100644 (file)
index 0000000..aad7d99
--- /dev/null
@@ -0,0 +1,44 @@
+git-local-fetch(1)
+==================
+v0.1, May 2005
+
+NAME
+----
+git-local-fetch - Duplicates another GIT repository on a local system
+
+
+SYNOPSIS
+--------
+'git-local-fetch' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] [-l] [-s] [-n] commit-id path
+
+DESCRIPTION
+-----------
+Duplicates another GIT repository on a local system.
+
+OPTIONS
+-------
+-c::
+       Get the commit objects.
+-t::
+       Get trees associated with the commit objects.
+-a::
+       Get all the objects.
+-v::
+       Report what is downloaded.
+
+-w <filename>::
+        Writes the commit-id into the filename under $GIT_DIR/refs/<filename> on
+        the local end after the transfer is complete.
+
+Author
+------
+Written by Junio C Hamano <junkio@cox.net>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-local-pull.txt b/Documentation/git-local-pull.txt
deleted file mode 100644 (file)
index 4651e81..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-git-local-pull(1)
-=================
-v0.1, May 2005
-
-NAME
-----
-git-local-pull - Duplicates another GIT repository on a local system
-
-
-SYNOPSIS
---------
-'git-local-pull' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] [-l] [-s] [-n] commit-id path
-
-DESCRIPTION
------------
-Duplicates another GIT repository on a local system.
-
-OPTIONS
--------
--c::
-       Get the commit objects.
--t::
-       Get trees associated with the commit objects.
--a::
-       Get all the objects.
--v::
-       Report what is downloaded.
-
--w <filename>::
-        Writes the commit-id into the filename under $GIT_DIR/refs/<filename> on
-        the local end after the transfer is complete.
-
-Author
-------
-Written by Junio C Hamano <junkio@cox.net>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-log-script.txt b/Documentation/git-log-script.txt
deleted file mode 100644 (file)
index ed359be..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-git-log-script(1)
-=================
-v0.99.4, Aug 2005
-
-NAME
-----
-git-log-script - Show commit logs
-
-
-SYNOPSIS
---------
-'git log' <option>...
-
-DESCRIPTION
------------
-Shows the commit logs.  This command internally invokes
-'git-rev-list', and the command line options are passed to that
-command.
-
-This manual page describes only the most frequently used options.
-
-OPTIONS
--------
---pretty=<format>:
-       Controls the way the commit log is formatted.
-
---max-count=<n>::
-       Limits the number of commits to show.
-
-<since>..<until>::
-       Show only commits between the named two commits.
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
new file mode 100644 (file)
index 0000000..d1c24f7
--- /dev/null
@@ -0,0 +1,45 @@
+git-log(1)
+==========
+v0.99.4, Aug 2005
+
+NAME
+----
+git-log - Show commit logs
+
+
+SYNOPSIS
+--------
+'git log' <option>...
+
+DESCRIPTION
+-----------
+Shows the commit logs.  This command internally invokes
+'git-rev-list', and the command line options are passed to that
+command.
+
+This manual page describes only the most frequently used options.
+
+OPTIONS
+-------
+--pretty=<format>:
+       Controls the way the commit log is formatted.
+
+--max-count=<n>::
+       Limits the number of commits to show.
+
+<since>..<until>::
+       Show only commits between the named two commits.
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-ls-remote-script.txt b/Documentation/git-ls-remote-script.txt
deleted file mode 100644 (file)
index 0b98e6a..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-git-ls-remote-script(1)
-=======================
-v0.1, May 2005
-
-NAME
-----
-git-ls-remote-script - Look at references other repository has.
-
-
-SYNOPSIS
---------
-'git-ls-remote' [--heads] [--tags] <repository> <refs>...
-
-DESCRIPTION
------------
-Displays the references other repository has.
-
-
-OPTIONS
--------
---heads --tags::
-       Limit to only refs/heads and refs/tags, respectively.
-       These options are _not_ mutually exclusive; when given
-       both, references stored in refs/heads and refs/tags are
-       displayed.
-
-<repository>::
-       Location of the repository.  The shorthand defined in
-       $GIT_DIR/branches/ can be used.
-
-<refs>...::
-       When unspecified, all references, after filtering done
-       with --heads and --tags, are shown.  When <refs>... are
-       specified, only references matching the given patterns
-       are displayed.
-
-EXAMPLES
---------
-
-       $ git ls-remote --tags ./.
-       d6602ec5194c87b0fc87103ca4d67251c76f233a        refs/tags/v0.99
-       f25a265a342aed6041ab0cc484224d9ca54b6f41        refs/tags/v0.99.1
-       7ceca275d047c90c0c7d5afb13ab97efdf51bd6e        refs/tags/v0.99.3
-       c5db5456ae3b0873fc659c19fafdde22313cc441        refs/tags/v0.99.2
-       0918385dbd9656cab0d1d81ba7453d49bbc16250        refs/tags/junio-gpg-pub
-       $ git ls-remote http://www.kernel.org/pub/scm/git/git.git master pu rc
-       5fe978a5381f1fbad26a80e682ddd2a401966740        refs/heads/master
-       c781a84b5204fb294c9ccc79f8b3baceeb32c061        refs/heads/pu
-       b1d096f2926c4e37c9c0b6a7bf2119bedaa277cb        refs/heads/rc
-       $ echo http://www.kernel.org/pub/scm/git/git.git >.git/branches/public
-       $ git ls-remote --tags public v\*
-       d6602ec5194c87b0fc87103ca4d67251c76f233a        refs/tags/v0.99
-       f25a265a342aed6041ab0cc484224d9ca54b6f41        refs/tags/v0.99.1
-       c5db5456ae3b0873fc659c19fafdde22313cc441        refs/tags/v0.99.2
-       7ceca275d047c90c0c7d5afb13ab97efdf51bd6e        refs/tags/v0.99.3
-
-Author
-------
-Written by Junio C Hamano <junkio@cox.net>
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt
new file mode 100644 (file)
index 0000000..c3152b1
--- /dev/null
@@ -0,0 +1,64 @@
+git-ls-remote(1)
+================
+v0.1, May 2005
+
+NAME
+----
+git-ls-remote - Look at references other repository has.
+
+
+SYNOPSIS
+--------
+'git-ls-remote' [--heads] [--tags] <repository> <refs>...
+
+DESCRIPTION
+-----------
+Displays the references other repository has.
+
+
+OPTIONS
+-------
+--heads --tags::
+       Limit to only refs/heads and refs/tags, respectively.
+       These options are _not_ mutually exclusive; when given
+       both, references stored in refs/heads and refs/tags are
+       displayed.
+
+<repository>::
+       Location of the repository.  The shorthand defined in
+       $GIT_DIR/branches/ can be used.
+
+<refs>...::
+       When unspecified, all references, after filtering done
+       with --heads and --tags, are shown.  When <refs>... are
+       specified, only references matching the given patterns
+       are displayed.
+
+EXAMPLES
+--------
+
+       $ git ls-remote --tags ./.
+       d6602ec5194c87b0fc87103ca4d67251c76f233a        refs/tags/v0.99
+       f25a265a342aed6041ab0cc484224d9ca54b6f41        refs/tags/v0.99.1
+       7ceca275d047c90c0c7d5afb13ab97efdf51bd6e        refs/tags/v0.99.3
+       c5db5456ae3b0873fc659c19fafdde22313cc441        refs/tags/v0.99.2
+       0918385dbd9656cab0d1d81ba7453d49bbc16250        refs/tags/junio-gpg-pub
+       $ git ls-remote http://www.kernel.org/pub/scm/git/git.git master pu rc
+       5fe978a5381f1fbad26a80e682ddd2a401966740        refs/heads/master
+       c781a84b5204fb294c9ccc79f8b3baceeb32c061        refs/heads/pu
+       b1d096f2926c4e37c9c0b6a7bf2119bedaa277cb        refs/heads/rc
+       $ echo http://www.kernel.org/pub/scm/git/git.git >.git/branches/public
+       $ git ls-remote --tags public v\*
+       d6602ec5194c87b0fc87103ca4d67251c76f233a        refs/tags/v0.99
+       f25a265a342aed6041ab0cc484224d9ca54b6f41        refs/tags/v0.99.1
+       c5db5456ae3b0873fc659c19fafdde22313cc441        refs/tags/v0.99.2
+       7ceca275d047c90c0c7d5afb13ab97efdf51bd6e        refs/tags/v0.99.3
+
+Author
+------
+Written by Junio C Hamano <junkio@cox.net>
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-merge-cache.txt b/Documentation/git-merge-cache.txt
deleted file mode 100644 (file)
index bd3c9ca..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-git-merge-cache(1)
-==================
-v0.1, May 2005
-
-NAME
-----
-git-merge-cache - Runs a merge for files needing merging
-
-
-SYNOPSIS
---------
-'git-merge-cache' [-o] [-q] <merge-program> (-a | -- | <file>\*) 
-
-DESCRIPTION
------------
-This looks up the <file>(s) in the cache and, if there are any merge
-entries, passes the SHA1 hash for those files as arguments 1, 2, 3 (empty
-argument if no file), and <file> as argument 4.  File modes for the three
-files are passed as arguments 5, 6 and 7.
-
-OPTIONS
--------
---::
-       Interpret all following arguments as filenames.
-
--a::
-       Run merge against all files in the cache that need merging.
-
--o::
-       Instead of stopping at the first failed merge, do all of them
-       in one shot - continue with merging even when previous merges
-       returned errors, and only return the error code after all the
-       merges are over.
-
--q::
-       Do not complain about failed merge program (the merge program
-       failure usually indicates conflicts during merge). This is for
-       porcelains which might want to emit custom messages.
-
-If "git-merge-cache" is called with multiple <file>s (or -a) then it
-processes them in turn only stopping if merge returns a non-zero exit
-code.
-
-Typically this is run with the a script calling the merge command from
-the RCS package.
-
-A sample script called "git-merge-one-file-script" is included in the
-distribution.
-
-ALERT ALERT ALERT! The git "merge object order" is different from the
-RCS "merge" program merge object order. In the above ordering, the
-original is first. But the argument order to the 3-way merge program
-"merge" is to have the original in the middle. Don't ask me why.
-
-Examples:
-
-  torvalds@ppc970:~/merge-test> git-merge-cache cat MM
-  This is MM from the original tree.                   # original
-  This is modified MM in the branch A.                 # merge1
-  This is modified MM in the branch B.                 # merge2
-  This is modified MM in the branch B.                 # current contents
-
-or 
-
-  torvalds@ppc970:~/merge-test> git-merge-cache cat AA MM
-  cat: : No such file or directory
-  This is added AA in the branch A.
-  This is added AA in the branch B.
-  This is added AA in the branch B.
-  fatal: merge program failed
-
-where the latter example shows how "git-merge-cache" will stop trying to
-merge once anything has returned an error (ie "cat" returned an error
-for the AA file, because it didn't exist in the original, and thus
-"git-merge-cache" didn't even try to merge the MM thing).
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-One-shot merge by Petr Baudis <pasky@ucw.cz>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-merge-index.txt b/Documentation/git-merge-index.txt
new file mode 100644 (file)
index 0000000..1b99f2b
--- /dev/null
@@ -0,0 +1,89 @@
+git-merge-index(1)
+==================
+v0.1, May 2005
+
+NAME
+----
+git-merge-index - Runs a merge for files needing merging
+
+
+SYNOPSIS
+--------
+'git-merge-index' [-o] [-q] <merge-program> (-a | -- | <file>\*)
+
+DESCRIPTION
+-----------
+This looks up the <file>(s) in the cache and, if there are any merge
+entries, passes the SHA1 hash for those files as arguments 1, 2, 3 (empty
+argument if no file), and <file> as argument 4.  File modes for the three
+files are passed as arguments 5, 6 and 7.
+
+OPTIONS
+-------
+--::
+       Interpret all following arguments as filenames.
+
+-a::
+       Run merge against all files in the cache that need merging.
+
+-o::
+       Instead of stopping at the first failed merge, do all of them
+       in one shot - continue with merging even when previous merges
+       returned errors, and only return the error code after all the
+       merges are over.
+
+-q::
+       Do not complain about failed merge program (the merge program
+       failure usually indicates conflicts during merge). This is for
+       porcelains which might want to emit custom messages.
+
+If "git-merge-index" is called with multiple <file>s (or -a) then it
+processes them in turn only stopping if merge returns a non-zero exit
+code.
+
+Typically this is run with the a script calling the merge command from
+the RCS package.
+
+A sample script called "git-merge-one-file" is included in the
+distribution.
+
+ALERT ALERT ALERT! The git "merge object order" is different from the
+RCS "merge" program merge object order. In the above ordering, the
+original is first. But the argument order to the 3-way merge program
+"merge" is to have the original in the middle. Don't ask me why.
+
+Examples:
+
+  torvalds@ppc970:~/merge-test> git-merge-index cat MM
+  This is MM from the original tree.                   # original
+  This is modified MM in the branch A.                 # merge1
+  This is modified MM in the branch B.                 # merge2
+  This is modified MM in the branch B.                 # current contents
+
+or 
+
+  torvalds@ppc970:~/merge-test> git-merge-index cat AA MM
+  cat: : No such file or directory
+  This is added AA in the branch A.
+  This is added AA in the branch B.
+  This is added AA in the branch B.
+  fatal: merge program failed
+
+where the latter example shows how "git-merge-index" will stop trying to
+merge once anything has returned an error (ie "cat" returned an error
+for the AA file, because it didn't exist in the original, and thus
+"git-merge-index" didn't even try to merge the MM thing).
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+One-shot merge by Petr Baudis <pasky@ucw.cz>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-merge-one-file-script.txt b/Documentation/git-merge-one-file-script.txt
deleted file mode 100644 (file)
index 1cfe954..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-git-merge-one-file-script(1)
-============================
-v0.99.4, Aug 2005
-
-NAME
-----
-git-merge-one-file-script - The standard helper program to use with "git-merge-cache"
-
-
-SYNOPSIS
---------
-'git-merge-one-file-script'
-
-DESCRIPTION
------------
-This is the standard helper program to use with "git-merge-cache"
-to resolve a merge after the trivial merge done with "git-read-tree -m".
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>,
-Junio C Hamano <junkio@cox.net> and Petr Baudis <pasky@suse.cz>.
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-merge-one-file.txt b/Documentation/git-merge-one-file.txt
new file mode 100644 (file)
index 0000000..b84d14d
--- /dev/null
@@ -0,0 +1,31 @@
+git-merge-one-file(1)
+=====================
+v0.99.4, Aug 2005
+
+NAME
+----
+git-merge-one-file - The standard helper program to use with "git-merge-index"
+
+
+SYNOPSIS
+--------
+'git-merge-one-file'
+
+DESCRIPTION
+-----------
+This is the standard helper program to use with "git-merge-index"
+to resolve a merge after the trivial merge done with "git-read-tree -m".
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>,
+Junio C Hamano <junkio@cox.net> and Petr Baudis <pasky@suse.cz>.
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-octopus-script.txt b/Documentation/git-octopus-script.txt
deleted file mode 100644 (file)
index f7a073d..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-git-octopus-script(1)
-=====================
-v0.99.5, Aug 2005
-
-NAME
-----
-git-octopus-script - Merge more than two commits.
-
-
-SYNOPSIS
---------
-'git-octopus'
-
-DESCRIPTION
------------
-After running 'git fetch', $GIT_DIR/FETCH_HEAD contains the
-following information, one line per remote ref:
-
-------------------------------------------------
-<object name>  <ref name> from <repository>
-------------------------------------------------
-
-Using this information, create and commit an Octopus merge on
-top of the current HEAD.
-
-
-Author
-------
-Written by Junio C Hamano <junkio@cox.net>
-
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-octopus.txt b/Documentation/git-octopus.txt
new file mode 100644 (file)
index 0000000..7a9cc54
--- /dev/null
@@ -0,0 +1,39 @@
+git-octopus(1)
+==============
+v0.99.5, Aug 2005
+
+NAME
+----
+git-octopus - Merge more than two commits.
+
+
+SYNOPSIS
+--------
+'git-octopus'
+
+DESCRIPTION
+-----------
+After running 'git fetch', $GIT_DIR/FETCH_HEAD contains the
+following information, one line per remote ref:
+
+------------------------------------------------
+<object name>  <ref name> from <repository>
+------------------------------------------------
+
+Using this information, create and commit an Octopus merge on
+top of the current HEAD.
+
+
+Author
+------
+Written by Junio C Hamano <junkio@cox.net>
+
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
index 7710be0..5ce195c 100644 (file)
@@ -76,7 +76,7 @@ Documentation by Junio C Hamano
 
 See-Also
 --------
-git-repack-script(1) git-prune-packed(1)
+git-repack(1) git-prune-packed(1)
 
 GIT
 ---
diff --git a/Documentation/git-parse-remote-script.txt b/Documentation/git-parse-remote-script.txt
deleted file mode 100644 (file)
index d6e551f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-git-parse-remote-script(1)
-==========================
-
-NAME
-----
-git-parse-remote-script - Routines to help parsing $GIT_DIR/remotes/
-
-
-SYNOPSIS
---------
-'. git-parse-remote-script'
-
-DESCRIPTION
------------
-This script is included in various scripts to supply
-routines to parse files under $GIT_DIR/remotes/ and
-$GIT_DIR/branches/.
-
-The primary entry points are:
-
-get_remote_refs_for_fetch::
-       Given the list of user-supplied `<repo> <refspec>...`,
-       return the list of refs to fetch after canonicalizing
-       them into `$GIT_DIR` relative paths
-       (e.g. `refs/heads/foo`).  When `<refspec>...` is empty
-       the returned list of refs consists of the defaults
-       for the given `<repo>`, if specified in
-       `$GIT_DIR/remotes/` or `$GIT_DIR/branches/`.
-
-get_remote_refs_for_push::
-       Given the list of user-supplied `<repo> <refspec>...`,
-       return the list of refs to push in a form suitable to be
-       fed to the `git-send-pack` command.  When `<refspec>...`
-       is empty the returned list of refs consists of the
-       defaults for the given `<repo>`, if specified in
-       `$GIT_DIR/remotes/`.
-
-Author
-------
-Written by Junio C Hamano.
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
diff --git a/Documentation/git-parse-remote.txt b/Documentation/git-parse-remote.txt
new file mode 100644 (file)
index 0000000..7ee0145
--- /dev/null
@@ -0,0 +1,48 @@
+git-parse-remote(1)
+===================
+
+NAME
+----
+git-parse-remote - Routines to help parsing $GIT_DIR/remotes/
+
+
+SYNOPSIS
+--------
+'. git-parse-remote'
+
+DESCRIPTION
+-----------
+This script is included in various scripts to supply
+routines to parse files under $GIT_DIR/remotes/ and
+$GIT_DIR/branches/.
+
+The primary entry points are:
+
+get_remote_refs_for_fetch::
+       Given the list of user-supplied `<repo> <refspec>...`,
+       return the list of refs to fetch after canonicalizing
+       them into `$GIT_DIR` relative paths
+       (e.g. `refs/heads/foo`).  When `<refspec>...` is empty
+       the returned list of refs consists of the defaults
+       for the given `<repo>`, if specified in
+       `$GIT_DIR/remotes/` or `$GIT_DIR/branches/`.
+
+get_remote_refs_for_push::
+       Given the list of user-supplied `<repo> <refspec>...`,
+       return the list of refs to push in a form suitable to be
+       fed to the `git-send-pack` command.  When `<refspec>...`
+       is empty the returned list of refs consists of the
+       defaults for the given `<repo>`, if specified in
+       `$GIT_DIR/remotes/`.
+
+Author
+------
+Written by Junio C Hamano.
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
index 893c1df..3fca275 100644 (file)
@@ -34,7 +34,7 @@ Documentation by Ryan Anderson <ryan@michonline.com>
 
 See-Also
 --------
-git-pack-objects(1) git-repack-script(1)
+git-pack-objects(1) git-repack(1)
 
 GIT
 ---
diff --git a/Documentation/git-prune-script.txt b/Documentation/git-prune-script.txt
deleted file mode 100644 (file)
index 0f76e8f..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-git-prune-script(1)
-===================
-v0.99.5, Aug 2005
-
-NAME
-----
-git-prune-script - Prunes all unreachable objects from the object database
-
-
-SYNOPSIS
---------
-'git-prune-script' [-n]
-
-DESCRIPTION
------------
-
-This runs `git-fsck-cache --unreachable` using the heads
-specified on the command line (or `$GIT_DIR/refs/heads/\*` and
-`$GIT_DIR/refs/tags/\*` if none is specified), and prunes all
-unreachable objects from the object database.  In addition, it
-prunes the unpacked objects that are also found in packs by
-running `git prune-packed`.
-
-OPTIONS
--------
-
--n::
-       Do not remove anything; just report what it would
-       remove.
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-prune.txt b/Documentation/git-prune.txt
new file mode 100644 (file)
index 0000000..f368427
--- /dev/null
@@ -0,0 +1,43 @@
+git-prune(1)
+============
+v0.99.5, Aug 2005
+
+NAME
+----
+git-prune - Prunes all unreachable objects from the object database
+
+
+SYNOPSIS
+--------
+'git-prune' [-n]
+
+DESCRIPTION
+-----------
+
+This runs `git-fsck-objects --unreachable` using the heads
+specified on the command line (or `$GIT_DIR/refs/heads/\*` and
+`$GIT_DIR/refs/tags/\*` if none is specified), and prunes all
+unreachable objects from the object database.  In addition, it
+prunes the unpacked objects that are also found in packs by
+running `git prune-packed`.
+
+OPTIONS
+-------
+
+-n::
+       Do not remove anything; just report what it would
+       remove.
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-pull-script.txt b/Documentation/git-pull-script.txt
deleted file mode 100644 (file)
index 8111813..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-git-pull-script(1)
-==================
-v0.99.4, Aug 2005
-
-NAME
-----
-git-pull-script - Pull and merge from another repository.
-
-
-SYNOPSIS
---------
-'git-pull-script' <repository> <refspec>...
-
-
-DESCRIPTION
------------
-Runs 'git-fetch-script' with the given parameters.
-
-When only one ref is downloaded, runs 'git resolve' to merge it
-into the local HEAD.  Otherwise uses 'git octopus' to merge them
-into the local HEAD.
-
-
-OPTIONS
--------
-include::pull-fetch-param.txt[]
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-and Junio C Hamano <junkio@cox.net>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
new file mode 100644 (file)
index 0000000..235a036
--- /dev/null
@@ -0,0 +1,41 @@
+git-pull(1)
+===========
+v0.99.4, Aug 2005
+
+NAME
+----
+git-pull - Pull and merge from another repository.
+
+
+SYNOPSIS
+--------
+'git-pull' <repository> <refspec>...
+
+
+DESCRIPTION
+-----------
+Runs 'git-fetch' with the given parameters.
+
+When only one ref is downloaded, runs 'git resolve' to merge it
+into the local HEAD.  Otherwise uses 'git octopus' to merge them
+into the local HEAD.
+
+
+OPTIONS
+-------
+include::pull-fetch-param.txt[]
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+and Junio C Hamano <junkio@cox.net>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-push-script.txt b/Documentation/git-push-script.txt
deleted file mode 100644 (file)
index 556682f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-git-push-script(1)
-==================
-
-NAME
-----
-git-push-script - Update remote refs along with associated objects.
-
-
-SYNOPSIS
---------
-'git-push-script' [--all] [--force] <repository> <refspec>...
-
-DESCRIPTION
------------
-
-Updates remote refs using local refs, while sending objects
-necessary to complete the given refs.
-
-
-OPTIONS
--------
-include::pull-fetch-param.txt[]
-
-
-Author
-------
-Written by Junio C Hamano <junkio@cox.net>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
new file mode 100644 (file)
index 0000000..b8993eb
--- /dev/null
@@ -0,0 +1,36 @@
+git-push(1)
+===========
+
+NAME
+----
+git-push - Update remote refs along with associated objects.
+
+
+SYNOPSIS
+--------
+'git-push' [--all] [--force] <repository> <refspec>...
+
+DESCRIPTION
+-----------
+
+Updates remote refs using local refs, while sending objects
+necessary to complete the given refs.
+
+
+OPTIONS
+-------
+include::pull-fetch-param.txt[]
+
+
+Author
+------
+Written by Junio C Hamano <junkio@cox.net>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
index e1be6cc..d9c5a13 100644 (file)
@@ -16,7 +16,7 @@ DESCRIPTION
 -----------
 Reads the tree information given by <tree-ish> into the directory cache,
 but does not actually *update* any of the files it "caches". (see:
-git-checkout-cache)
+git-checkout-index)
 
 Optionally, it can merge a tree into the cache, perform a
 fast-forward (i.e. 2-way) merge, or a 3-way merge, with the -m
@@ -56,7 +56,7 @@ being read, the stat info from the cache is used. (In other words, the
 cache's stat()s take precedence over the merged tree's).
 
 That means that if you do a "git-read-tree -m <newtree>" followed by a
-"git-checkout-cache -f -u -a", the "git-checkout-cache" only checks out
+"git-checkout-index -f -u -a", the "git-checkout-index" only checks out
 the stuff that really changed.
 
 This is used to avoid unnecessary false hits when "git-diff-files" is
@@ -126,13 +126,13 @@ operating under the -u flag.
 
 When this form of git-read-tree returns successfully, you can
 see what "local changes" you made are carried forward by running
-"git-diff-cache --cached $M".  Note that this does not
-necessarily match "git-diff-cache --cached $H" would have
+"git-diff-index --cached $M".  Note that this does not
+necessarily match "git-diff-index --cached $H" would have
 produced before such a two tree merge.  This is because of cases
 18 and 19 --- if you already had the changes in $M (e.g. maybe
-you picked it up via e-mail in a patch form), "git-diff-cache
+you picked it up via e-mail in a patch form), "git-diff-index
 --cached $H" would have told you about the change before this
-merge, but it would not show in "git-diff-cache --cached $M"
+merge, but it would not show in "git-diff-index --cached $M"
 output after two-tree merge.
 
 
@@ -205,8 +205,8 @@ populated.  Here is an outline of how the algorithm works:
     matching "stage1" entry if it exists too.  .. all the normal
     trivial rules ..
 
-You would normally use "git-merge-cache" with supplied
-"git-merge-one-file-script" to do this last step.  The script
+You would normally use "git-merge-index" with supplied
+"git-merge-one-file" to do this last step.  The script
 does not touch the files in the work tree, and the entire merge
 happens in the index file.  In other words, there is no need to
 worry about what is in the working directory, since it is never
@@ -225,13 +225,13 @@ changes.  To illustrate, suppose you start from what has been
 commited last to your repository:
 
     $ JC=`cat .git/HEAD`
-    $ git-checkout-cache -f -u -a $JC
+    $ git-checkout-index -f -u -a $JC
 
-You do random edits, without running git-update-cache.  And then
+You do random edits, without running git-update-index.  And then
 you notice that the tip of your "upstream" tree has advanced
 since you pulled from him:
 
-    $ git-fetch-script rsync://.... linus
+    $ git-fetch rsync://.... linus
     $ LT=`cat .git/MERGE_HEAD`
 
 Your work tree is still based on your HEAD ($JC), but you have
@@ -240,7 +240,7 @@ added or modified cache entries since $JC, and if you haven't,
 then does the right thing.  So with the following sequence:
 
     $ git-read-tree -m -u `git-merge-base $JC $LT` $JC $LT
-    $ git-merge-cache git-merge-one-file-script -a
+    $ git-merge-index git-merge-one-file -a
     $ echo "Merge with Linus" | \
       git-commit-tree `git-write-tree` -p $JC -p $LT
 
diff --git a/Documentation/git-rebase-script.txt b/Documentation/git-rebase-script.txt
deleted file mode 100644 (file)
index 8f14186..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-git-rebase-script(1)
-====================
-
-NAME
-----
-git-rebase-script - Rebase local commits to new upstream head.
-
-SYNOPSIS
---------
-'git-rebase-script' <upstream> [<head>]
-
-DESCRIPTION
------------
-Rebases local commits to the new head of the upstream tree.
-
-OPTIONS
--------
-<upstream>::
-       Upstream branch to compare against.
-
-<head>::
-       Working branch; defaults to HEAD.
-
-Author
-------
-Written by Junio C Hamano <junkio@cox.net>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
new file mode 100644 (file)
index 0000000..09bd328
--- /dev/null
@@ -0,0 +1,35 @@
+git-rebase(1)
+=============
+
+NAME
+----
+git-rebase - Rebase local commits to new upstream head.
+
+SYNOPSIS
+--------
+'git-rebase' <upstream> [<head>]
+
+DESCRIPTION
+-----------
+Rebases local commits to the new head of the upstream tree.
+
+OPTIONS
+-------
+<upstream>::
+       Upstream branch to compare against.
+
+<head>::
+       Working branch; defaults to HEAD.
+
+Author
+------
+Written by Junio C Hamano <junkio@cox.net>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-relink-script.txt b/Documentation/git-relink-script.txt
deleted file mode 100644 (file)
index 99c05d4..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-git-relink-script(1)
-====================
-
-NAME
-----
-git-relink-script - Hardlink common objects in local repositories.
-
-SYNOPSIS
---------
-'git-relink-script' [--safe] <dir> <dir> [<dir>]\*
-
-DESCRIPTION
------------
-This will scan 2 or more object repositories and look for common objects, check
-if they are hardlinked, and replace one with a hardlink to the other if not.
-
-OPTIONS
--------
---safe::
-       Stops if two objects with the same hash exist but have different sizes.
-       Default is to warn and continue.
-
-<dir>::
-       Directories containing a .git/objects/ subdirectory.
-
-Author
-------
-Written by Ryan Anderson <ryan@michonline.com>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-relink.txt b/Documentation/git-relink.txt
new file mode 100644 (file)
index 0000000..25975ae
--- /dev/null
@@ -0,0 +1,37 @@
+git-relink(1)
+=============
+
+NAME
+----
+git-relink - Hardlink common objects in local repositories.
+
+SYNOPSIS
+--------
+'git-relink' [--safe] <dir> <dir> [<dir>]\*
+
+DESCRIPTION
+-----------
+This will scan 2 or more object repositories and look for common objects, check
+if they are hardlinked, and replace one with a hardlink to the other if not.
+
+OPTIONS
+-------
+--safe::
+       Stops if two objects with the same hash exist but have different sizes.
+       Default is to warn and continue.
+
+<dir>::
+       Directories containing a .git/objects/ subdirectory.
+
+Author
+------
+Written by Ryan Anderson <ryan@michonline.com>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-rename-script.txt b/Documentation/git-rename-script.txt
deleted file mode 100644 (file)
index b110525..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-git-rename-script(1)
-====================
-v0.1, May 2005
-
-NAME
-----
-git-rename-script - Script used to rename a file, directory or symlink.
-
-
-SYNOPSIS
---------
-'git-rename-script' <source> <destination>
-
-DESCRIPTION
------------
-This script is used to rename a file, directory or symlink.
-
-The index is updated after successful completion, but the change must still be
-committed.
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-Rewritten by Ryan Anderson <ryan@michonline.com>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-rename.txt b/Documentation/git-rename.txt
new file mode 100644 (file)
index 0000000..2c24bfa
--- /dev/null
@@ -0,0 +1,33 @@
+git-rename(1)
+=============
+v0.1, May 2005
+
+NAME
+----
+git-rename - Script used to rename a file, directory or symlink.
+
+
+SYNOPSIS
+--------
+'git-rename' <source> <destination>
+
+DESCRIPTION
+-----------
+This script is used to rename a file, directory or symlink.
+
+The index is updated after successful completion, but the change must still be
+committed.
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+Rewritten by Ryan Anderson <ryan@michonline.com>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-repack-script.txt b/Documentation/git-repack-script.txt
deleted file mode 100644 (file)
index df94ec1..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-git-repack-script(1)
-====================
-v0.99.5, August 2005
-
-NAME
-----
-git-repack-script - Script used to pack a repository from a collection of
-objects into pack files.
-
-
-SYNOPSIS
---------
-'git-repack-script' [-a] [-d]
-
-DESCRIPTION
------------
-
-This script is used to combine all objects that do not currently
-reside in a "pack", into a pack.
-
-A pack is a collection of objects, individually compressed, with
-delta compression applied, stored in a single file, with an
-associated index file.
-
-Packs are used to reduce the load on mirror systems, backup
-engines, disk storage, etc.
-
-OPTIONS
--------
-
--a::
-       Instead of incrementally packing the unpacked objects,
-       pack everything available into a single pack.
-       Especially useful when packing a repository that is used
-       for a private development and there no need to worry
-       about people fetching via dumb protocols from it.  Use
-       with '-d'.
-
--d::
-       After packing, if the newly created packs make some
-       existing packs redundant, remove the redundant packs.
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by Ryan Anderson <ryan@michonline.com>
-
-See-Also
---------
-git-pack-objects(1) git-prune-packed(1)
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
new file mode 100644 (file)
index 0000000..d8e3ad0
--- /dev/null
@@ -0,0 +1,59 @@
+git-repack(1)
+=============
+v0.99.5, August 2005
+
+NAME
+----
+git-repack - Script used to pack a repository from a collection of
+objects into pack files.
+
+
+SYNOPSIS
+--------
+'git-repack' [-a] [-d]
+
+DESCRIPTION
+-----------
+
+This script is used to combine all objects that do not currently
+reside in a "pack", into a pack.
+
+A pack is a collection of objects, individually compressed, with
+delta compression applied, stored in a single file, with an
+associated index file.
+
+Packs are used to reduce the load on mirror systems, backup
+engines, disk storage, etc.
+
+OPTIONS
+-------
+
+-a::
+       Instead of incrementally packing the unpacked objects,
+       pack everything available into a single pack.
+       Especially useful when packing a repository that is used
+       for a private development and there no need to worry
+       about people fetching via dumb protocols from it.  Use
+       with '-d'.
+
+-d::
+       After packing, if the newly created packs make some
+       existing packs redundant, remove the redundant packs.
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by Ryan Anderson <ryan@michonline.com>
+
+See-Also
+--------
+git-pack-objects(1) git-prune-packed(1)
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-request-pull-script.txt b/Documentation/git-request-pull-script.txt
deleted file mode 100644 (file)
index 1ebf726..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-git-request-pull-script(1)
-==========================
-
-NAME
-----
-git-request-pull-script - Generates a summary of pending changes.
-
-SYNOPSIS
---------
-'git-request-pull-script' <start> <url> [<end>]
-
-DESCRIPTION
------------
-
-Summarizes the changes between two commits to the standard output, and includes
-the given URL in the generated summary.
-
-OPTIONS
--------
-<start>::
-       Commit to start at.
-
-<url>::
-       URL to include in the summary.
-
-<end>::
-       Commit to send at; defaults to HEAD.
-
-Author
-------
-Written by Ryan Anderson <ryan@michonline.com> and Junio C Hamano <junkio@cox.net>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-request-pull.txt b/Documentation/git-request-pull.txt
new file mode 100644 (file)
index 0000000..27a66ac
--- /dev/null
@@ -0,0 +1,40 @@
+git-request-pull(1)
+===================
+
+NAME
+----
+git-request-pull - Generates a summary of pending changes.
+
+SYNOPSIS
+--------
+'git-request-pull' <start> <url> [<end>]
+
+DESCRIPTION
+-----------
+
+Summarizes the changes between two commits to the standard output, and includes
+the given URL in the generated summary.
+
+OPTIONS
+-------
+<start>::
+       Commit to start at.
+
+<url>::
+       URL to include in the summary.
+
+<end>::
+       Commit to send at; defaults to HEAD.
+
+Author
+------
+Written by Ryan Anderson <ryan@michonline.com> and Junio C Hamano <junkio@cox.net>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-reset-script.txt b/Documentation/git-reset-script.txt
deleted file mode 100644 (file)
index 18bd9e9..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-git-reset-script(1)
-===================
-
-NAME
-----
-git-reset-script - Reset current HEAD to the specified state.
-
-SYNOPSIS
---------
-'git-reset-script' [--mixed | --soft | --hard] [<commit-ish>]
-
-DESCRIPTION
------------
-Sets the current head to the specified commit and optionally resets the
-index and working tree to match.
-
-OPTIONS
--------
---mixed::
-       Like --soft but reports what has not been updated. This is the
-       default action.
-
---soft::
-       Does not touch the index file nor the working tree at all, but
-       requires them in a good order.
-
---hard::
-       Matches the working tree and index to that of the tree being
-       switched to.
-
-<commit-ish>::
-       Commit to make the current HEAD.
-
-Author
-------
-Written by Junio C Hamano <junkio@cox.net> and Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
new file mode 100644 (file)
index 0000000..a6567c4
--- /dev/null
@@ -0,0 +1,45 @@
+git-reset(1)
+============
+
+NAME
+----
+git-reset - Reset current HEAD to the specified state.
+
+SYNOPSIS
+--------
+'git-reset' [--mixed | --soft | --hard] [<commit-ish>]
+
+DESCRIPTION
+-----------
+Sets the current head to the specified commit and optionally resets the
+index and working tree to match.
+
+OPTIONS
+-------
+--mixed::
+       Like --soft but reports what has not been updated. This is the
+       default action.
+
+--soft::
+       Does not touch the index file nor the working tree at all, but
+       requires them in a good order.
+
+--hard::
+       Matches the working tree and index to that of the tree being
+       switched to.
+
+<commit-ish>::
+       Commit to make the current HEAD.
+
+Author
+------
+Written by Junio C Hamano <junkio@cox.net> and Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-resolve-script.txt b/Documentation/git-resolve-script.txt
deleted file mode 100644 (file)
index 77076aa..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-git-resolve-script(1)
-=====================
-v0.99.5, Aug 2005
-
-NAME
-----
-git-resolve-script - Merge two commits
-
-
-SYNOPSIS
---------
-'git resolve' <current> <merged> <message>
-
-DESCRIPTION
------------
-Given two commits and a merge message, merge the <merged> commit
-into <current> commit, with the commit log message <message>.
-
-When <current> is a descendant of <merged>, or <current> is an
-ancestor of <merged>, no new commit is created and the <message>
-is ignored.  The former is informally called "already up to
-date", and the latter is often called "fast forward".
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org> and
-Dan Holmsand <holmsand@gmail.com>.
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-resolve.txt b/Documentation/git-resolve.txt
new file mode 100644 (file)
index 0000000..d058318
--- /dev/null
@@ -0,0 +1,37 @@
+git-resolve(1)
+==============
+v0.99.5, Aug 2005
+
+NAME
+----
+git-resolve - Merge two commits
+
+
+SYNOPSIS
+--------
+'git resolve' <current> <merged> <message>
+
+DESCRIPTION
+-----------
+Given two commits and a merge message, merge the <merged> commit
+into <current> commit, with the commit log message <message>.
+
+When <current> is a descendant of <merged>, or <current> is an
+ancestor of <merged>, no new commit is created and the <message>
+is ignored.  The former is informally called "already up to
+date", and the latter is often called "fast forward".
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org> and
+Dan Holmsand <holmsand@gmail.com>.
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-revert-script.txt b/Documentation/git-revert-script.txt
deleted file mode 100644 (file)
index 9609dcd..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-git-revert-script(1)
-====================
-
-NAME
-----
-git-revert-script - Revert an existing commit.
-
-SYNOPSIS
---------
-'git-revert-script' [-n] <commit>
-
-DESCRIPTION
------------
-Given one existing commit, revert the change the patch introduces, and record a
-new commit that records it.  This requires your working tree to be clean (no
-modifications from the HEAD commit).
-
-OPTIONS
--------
-<commit>::
-       Commit to revert.
-
--n::
-       Usually the command automatically creates a commit with
-       a commit log message stating which commit was reverted.
-       This flag applies the change necessary to revert the
-       named commit to your working tree, but does not make the
-       commit.  In addition, when this option is used, your
-       working tree does not have to match the HEAD commit.
-       The revert is done against the beginning state of your
-       working tree.
-
-       This is useful when reverting more than one commits'
-       effect to your working tree in a row.
-
-
-Author
-------
-Written by Junio C Hamano <junkio@cox.net>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt
new file mode 100644 (file)
index 0000000..a3f9a56
--- /dev/null
@@ -0,0 +1,48 @@
+git-revert(1)
+=============
+
+NAME
+----
+git-revert - Revert an existing commit.
+
+SYNOPSIS
+--------
+'git-revert' [-n] <commit>
+
+DESCRIPTION
+-----------
+Given one existing commit, revert the change the patch introduces, and record a
+new commit that records it.  This requires your working tree to be clean (no
+modifications from the HEAD commit).
+
+OPTIONS
+-------
+<commit>::
+       Commit to revert.
+
+-n::
+       Usually the command automatically creates a commit with
+       a commit log message stating which commit was reverted.
+       This flag applies the change necessary to revert the
+       named commit to your working tree, but does not make the
+       commit.  In addition, when this option is used, your
+       working tree does not have to match the HEAD commit.
+       The revert is done against the beginning state of your
+       working tree.
+
+       This is useful when reverting more than one commits'
+       effect to your working tree in a row.
+
+
+Author
+------
+Written by Junio C Hamano <junkio@cox.net>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-send-email-script.txt b/Documentation/git-send-email-script.txt
deleted file mode 100644 (file)
index f79ad19..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-git-send-email-script(1)
-========================
-v0.1, July 2005
-
-NAME
-----
-git-send-email-script - Send a collection of patches as emails
-
-
-SYNOPSIS
---------
-'git-send-email-script' [options] <file|directory> [... file|directory]
-
-
-
-DESCRIPTION
------------
-Takes the patches given on the command line and emails them out.
-
-The header of the email is configurable by command line options.  If not
-specified on the command line, the user will be prompted with a ReadLine
-enabled interface to provide the necessary information.
-
-The options available are:
-
-  --to
-       Specify the primary recipient of the emails generated.
-       Generally, this will be the upstream maintainer of the
-       project involved.
-
-   --from
-       Specify the sender of the emails.  This will default to
-       the value GIT_COMMITTER_IDENT, as returned by "git-var -l".
-       The user will still be prompted to confirm this entry.
-
-   --compose
-       Use \$EDITOR to edit an introductory message for the
-       patch series.
-
-   --subject
-       Specify the initial subject of the email thread.
-       Only necessary if --compose is also set.  If --compose
-       is not set, this will be prompted for.
-
-   --in-reply-to
-       Specify the contents of the first In-Reply-To header.
-       Subsequent emails will refer to the previous email 
-       instead of this if --chain-reply-to is set (the default)
-       Only necessary if --compose is also set.  If --compose
-       is not set, this will be prompted for.
-
-   --chain-reply-to, --no-chain-reply-to
-       If this is set, each email will be sent as a reply to the previous
-       email sent.  If disabled with "--no-chain-reply-to", all emails after
-       the first will be sent as replies to the first email sent.  When using
-       this, it is recommended that the first file given be an overview of the
-       entire patch series.
-       Default is --chain-reply-to
-
-   --smtp-server
-       If set, specifies the outgoing SMTP server to use.  Defaults to
-       localhost.
-
-
-Author
-------
-Written by Ryan Anderson <ryan@michonline.com>
-
-git-send-email-script is originally based upon
-send_lots_of_email.pl by Greg Kroah-Hartman.
-
-Documentation
---------------
-Documentation by Ryan Anderson
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
new file mode 100644 (file)
index 0000000..fa11efc
--- /dev/null
@@ -0,0 +1,79 @@
+git-send-email(1)
+=================
+v0.1, July 2005
+
+NAME
+----
+git-send-email - Send a collection of patches as emails
+
+
+SYNOPSIS
+--------
+'git-send-email' [options] <file|directory> [... file|directory]
+
+
+
+DESCRIPTION
+-----------
+Takes the patches given on the command line and emails them out.
+
+The header of the email is configurable by command line options.  If not
+specified on the command line, the user will be prompted with a ReadLine
+enabled interface to provide the necessary information.
+
+The options available are:
+
+  --to
+       Specify the primary recipient of the emails generated.
+       Generally, this will be the upstream maintainer of the
+       project involved.
+
+   --from
+       Specify the sender of the emails.  This will default to
+       the value GIT_COMMITTER_IDENT, as returned by "git-var -l".
+       The user will still be prompted to confirm this entry.
+
+   --compose
+       Use \$EDITOR to edit an introductory message for the
+       patch series.
+
+   --subject
+       Specify the initial subject of the email thread.
+       Only necessary if --compose is also set.  If --compose
+       is not set, this will be prompted for.
+
+   --in-reply-to
+       Specify the contents of the first In-Reply-To header.
+       Subsequent emails will refer to the previous email 
+       instead of this if --chain-reply-to is set (the default)
+       Only necessary if --compose is also set.  If --compose
+       is not set, this will be prompted for.
+
+   --chain-reply-to, --no-chain-reply-to
+       If this is set, each email will be sent as a reply to the previous
+       email sent.  If disabled with "--no-chain-reply-to", all emails after
+       the first will be sent as replies to the first email sent.  When using
+       this, it is recommended that the first file given be an overview of the
+       entire patch series.
+       Default is --chain-reply-to
+
+   --smtp-server
+       If set, specifies the outgoing SMTP server to use.  Defaults to
+       localhost.
+
+
+Author
+------
+Written by Ryan Anderson <ryan@michonline.com>
+
+git-send-email is originally based upon
+send_lots_of_email.pl by Greg Kroah-Hartman.
+
+Documentation
+--------------
+Documentation by Ryan Anderson
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-sh-setup-script.txt b/Documentation/git-sh-setup-script.txt
deleted file mode 100644 (file)
index 5ac613a..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-git-sh-setup-script(1)
-======================
-
-NAME
-----
-git-sh-setup-script - Common git shell script setup code.
-
-SYNOPSIS
---------
-'git-sh-setup-script'
-
-DESCRIPTION
------------
-
-Sets up the normal git environment variables and a few helper functions
-(currently just "die()"), and returns ok if it all looks like a git archive.
-So use it something like
-
-       . git-sh-setup-script || die "Not a git archive"
-
-to make the rest of the git scripts more careful and readable.
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt
new file mode 100644 (file)
index 0000000..fcf2cdf
--- /dev/null
@@ -0,0 +1,34 @@
+git-sh-setup(1)
+===============
+
+NAME
+----
+git-sh-setup - Common git shell script setup code.
+
+SYNOPSIS
+--------
+'git-sh-setup'
+
+DESCRIPTION
+-----------
+
+Sets up the normal git environment variables and a few helper functions
+(currently just "die()"), and returns ok if it all looks like a git archive.
+So use it something like
+
+       . git-sh-setup || die "Not a git archive"
+
+to make the rest of the git scripts more careful and readable.
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
index 5103c0c..c947fce 100644 (file)
@@ -88,7 +88,7 @@ the name of the branch because it is obvious.
 $ git show-branch --more=4 master
 [master] Add 'git show-branch'.
 [~1] Add a new extended SHA1 syntax <name>~<num>
-[~2] Fix "git-diff-script A B"
+[~2] Fix "git-diff A B"
 [~3] git-ls-files: generalized pathspecs
 [~4] Make "git-ls-files" work in subdirectories
 ------------------------------------------------
diff --git a/Documentation/git-ssh-fetch.txt b/Documentation/git-ssh-fetch.txt
new file mode 100644 (file)
index 0000000..4ef03f6
--- /dev/null
@@ -0,0 +1,52 @@
+git-ssh-fetch(1)
+================
+v0.1, May 2005
+
+NAME
+----
+git-ssh-fetch - Pulls from a remote repository over ssh connection
+
+
+
+SYNOPSIS
+--------
+'git-ssh-fetch' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] commit-id url
+
+DESCRIPTION
+-----------
+Pulls from a remote repository over ssh connection, invoking
+git-ssh-upload on the other end. It functions identically to
+git-ssh-upload, aside from which end you run it on.
+
+
+OPTIONS
+-------
+commit-id::
+        Either the hash or the filename under [URL]/refs/ to
+        pull.
+
+-c::
+       Get the commit objects.
+-t::
+       Get trees associated with the commit objects.
+-a::
+       Get all the objects.
+-v::
+       Report what is downloaded.
+-w::
+        Writes the commit-id into the filename under $GIT_DIR/refs/ on
+        the local end after the transfer is complete.
+
+
+Author
+------
+Written by Daniel Barkalow <barkalow@iabervon.org>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-ssh-pull.txt b/Documentation/git-ssh-pull.txt
deleted file mode 100644 (file)
index ac3fb34..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-git-ssh-pull(1)
-===============
-v0.1, May 2005
-
-NAME
-----
-git-ssh-pull - Pulls from a remote repository over ssh connection
-
-
-
-SYNOPSIS
---------
-'git-ssh-pull' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] commit-id url
-
-DESCRIPTION
------------
-Pulls from a remote repository over ssh connection, invoking
-git-ssh-push on the other end. It functions identically to
-git-ssh-push, aside from which end you run it on.
-
-
-OPTIONS
--------
-commit-id::
-        Either the hash or the filename under [URL]/refs/ to
-        pull.
-
--c::
-       Get the commit objects.
--t::
-       Get trees associated with the commit objects.
--a::
-       Get all the objects.
--v::
-       Report what is downloaded.
--w::
-        Writes the commit-id into the filename under $GIT_DIR/refs/ on
-        the local end after the transfer is complete.
-
-
-Author
-------
-Written by Daniel Barkalow <barkalow@iabervon.org>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-ssh-push.txt b/Documentation/git-ssh-push.txt
deleted file mode 100644 (file)
index e38679d..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-git-ssh-push(1)
-===============
-v0.1, Jun 2005
-
-NAME
-----
-git-ssh-push - Pushes to a remote repository over ssh connection
-
-
-SYNOPSIS
---------
-'git-ssh-push' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] commit-id url
-
-DESCRIPTION
------------
-Pushes from a remote repository over ssh connection, invoking
-git-ssh-pull on the other end. It functions identically to
-git-ssh-pull, aside from which end you run it on.
-
-OPTIONS
--------
-commit-id::
-        Id of commit to push.
-
--c::
-        Get the commit objects.
--t::
-        Get tree associated with the requested commit object.
--a::
-        Get all the objects.
--v::
-        Report what is uploaded.
--w::
-        Writes the commit-id into the filename under [URL]/refs/ on
-        the remote end after the transfer is complete.
-
-Author
-------
-Written by Daniel Barkalow <barkalow@iabervon.org>
-
-Documentation
---------------
-Documentation by Daniel Barkalow
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-ssh-upload.txt b/Documentation/git-ssh-upload.txt
new file mode 100644 (file)
index 0000000..f1aa0df
--- /dev/null
@@ -0,0 +1,48 @@
+git-ssh-upload(1)
+=================
+v0.1, Jun 2005
+
+NAME
+----
+git-ssh-upload - Pushes to a remote repository over ssh connection
+
+
+SYNOPSIS
+--------
+'git-ssh-upload' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] commit-id url
+
+DESCRIPTION
+-----------
+Pushes from a remote repository over ssh connection, invoking
+git-ssh-fetch on the other end. It functions identically to
+git-ssh-fetch, aside from which end you run it on.
+
+OPTIONS
+-------
+commit-id::
+        Id of commit to push.
+
+-c::
+        Get the commit objects.
+-t::
+        Get tree associated with the requested commit object.
+-a::
+        Get all the objects.
+-v::
+        Report what is uploaded.
+-w::
+        Writes the commit-id into the filename under [URL]/refs/ on
+        the remote end after the transfer is complete.
+
+Author
+------
+Written by Daniel Barkalow <barkalow@iabervon.org>
+
+Documentation
+--------------
+Documentation by Daniel Barkalow
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-status-script.txt b/Documentation/git-status-script.txt
deleted file mode 100644 (file)
index 2fb7f74..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-git-status-script(1)
-====================
-v0.99.4, Aug 2005
-
-NAME
-----
-git-status-script - Show working tree status.
-
-
-SYNOPSIS
---------
-'git status'
-
-DESCRIPTION
------------
-Examines paths in the working tree that has changes unrecorded
-to the index file, and changes between the index file and the
-current HEAD commit.  The former paths are what you _could_
-commit by running 'git-update-cache' before running 'git
-commit', and the latter paths are what you _would_ commit by
-running 'git commit'.
-
-If there is no path that is different between the index file and
-the current HEAD commit, the command exits with non-zero
-status.
-
-
-OUTPUT
-------
-The output from this command is designed to be used as a commit
-template comments, and all the output lines are prefixed with '#'.
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org> and
-Junio C Hamano <junkio@cox.net>.
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
new file mode 100644 (file)
index 0000000..886fb7c
--- /dev/null
@@ -0,0 +1,46 @@
+git-status(1)
+=============
+v0.99.4, Aug 2005
+
+NAME
+----
+git-status - Show working tree status.
+
+
+SYNOPSIS
+--------
+'git status'
+
+DESCRIPTION
+-----------
+Examines paths in the working tree that has changes unrecorded
+to the index file, and changes between the index file and the
+current HEAD commit.  The former paths are what you _could_
+commit by running 'git-update-index' before running 'git
+commit', and the latter paths are what you _would_ commit by
+running 'git commit'.
+
+If there is no path that is different between the index file and
+the current HEAD commit, the command exits with non-zero
+status.
+
+
+OUTPUT
+------
+The output from this command is designed to be used as a commit
+template comments, and all the output lines are prefixed with '#'.
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org> and
+Junio C Hamano <junkio@cox.net>.
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
diff --git a/Documentation/git-tag-script.txt b/Documentation/git-tag-script.txt
deleted file mode 100644 (file)
index 5032acb..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-git-tag-script(1)
-=================
-v0.99.4, Aug 2005
-
-NAME
-----
-git-tag-script -  Create a tag object signed with GPG
-
-
-
-SYNOPSIS
---------
-'git-tag-script' [-s | -a] [-f] <name>
-
-DESCRIPTION
------------
-Adds a "tag" reference in .git/refs/tags/
-
-Unless "-f" is given, the tag must not yet exist in ".git/refs/tags"
-
-If "-s" or "-a" is passed, the user will be prompted for a tag message.
-and a tag object is created.  Otherwise just the SHA1 object
-name of the commit object is written.
-
-A GnuPG signed tag object will be created when "-s" is used.
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>,
-Junio C Hamano <junkio@cox.net> and Chris Wright <chrisw@osdl.org>.
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt
new file mode 100644 (file)
index 0000000..0e1be72
--- /dev/null
@@ -0,0 +1,39 @@
+git-tag(1)
+==========
+v0.99.4, Aug 2005
+
+NAME
+----
+git-tag -  Create a tag object signed with GPG
+
+
+
+SYNOPSIS
+--------
+'git-tag' [-s | -a] [-f] <name>
+
+DESCRIPTION
+-----------
+Adds a "tag" reference in .git/refs/tags/
+
+Unless "-f" is given, the tag must not yet exist in ".git/refs/tags"
+
+If "-s" or "-a" is passed, the user will be prompted for a tag message.
+and a tag object is created.  Otherwise just the SHA1 object
+name of the commit object is written.
+
+A GnuPG signed tag object will be created when "-s" is used.
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>,
+Junio C Hamano <junkio@cox.net> and Chris Wright <chrisw@osdl.org>.
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
diff --git a/Documentation/git-update-cache.txt b/Documentation/git-update-cache.txt
deleted file mode 100644 (file)
index 7340e89..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-git-update-cache(1)
-===================
-v0.1, May 2005
-
-NAME
-----
-git-update-cache - Modifies the index or directory cache
-
-
-SYNOPSIS
---------
-'git-update-cache'
-            [--add] [--remove] [--refresh] [--replace]
-            [--ignore-missing]
-            [--force-remove]
-            [--cacheinfo <mode> <object> <file>]\*
-            [--info-only]
-            [--] [<file>]\*
-
-DESCRIPTION
------------
-Modifies the index or directory cache. Each file mentioned is updated
-into the cache and any 'unmerged' or 'needs updating' state is
-cleared.
-
-The way "git-update-cache" handles files it is told about can be modified
-using the various options:
-
-OPTIONS
--------
---add::
-       If a specified file isn't in the cache already then it's
-       added.
-       Default behaviour is to ignore new files.
-
---remove::
-       If a specified file is in the cache but is missing then it's
-       removed.
-       Default behaviour is to ignore removed file.
-
---refresh::
-       Looks at the current cache and checks to see if merges or
-       updates are needed by checking stat() information.
-
---ignore-missing::
-       Ignores missing files during a --refresh
-
---cacheinfo <mode> <object> <path>::
-       Directly insert the specified info into the cache.
-       
---info-only::
-       Do not create objects in the object database for all
-       <file> arguments that follow this flag; just insert
-       their object IDs into the cache.
-
---force-remove::
-       Remove the file from the index even when the working directory
-       still has such a file. (Implies --remove.)
-
---replace::
-       By default, when a file `path` exists in the index,
-       git-update-cache refuses an attempt to add `path/file`.
-       Similarly if a file `path/file` exists, a file `path`
-       cannot be added.  With --replace flag, existing entries
-       that conflicts with the entry being added are
-       automatically removed with warning messages.
-
---::
-       Do not interpret any more arguments as options.
-
-<file>::
-       Files to act on.
-       Note that files begining with '.' are discarded. This includes
-       `./file` and `dir/./file`. If you don't want this, then use     
-       cleaner names.
-       The same applies to directories ending '/' and paths with '//'
-
-Using --refresh
----------------
-'--refresh' does not calculate a new sha1 file or bring the cache
-up-to-date for mode/content changes. But what it *does* do is to
-"re-match" the stat information of a file with the cache, so that you
-can refresh the cache for a file that hasn't been changed but where
-the stat entry is out of date.
-
-For example, you'd want to do this after doing a "git-read-tree", to link
-up the stat cache details with the proper files.
-
-Using --cacheinfo or --info-only
---------------------------------
-'--cacheinfo' is used to register a file that is not in the
-current working directory.  This is useful for minimum-checkout
-merging.
-
-  To pretend you have a file with mode and sha1 at path, say:
-
-   $ git-update-cache --cacheinfo mode sha1 path
-
-'--info-only' is used to register files without placing them in the object
-database.  This is useful for status-only repositories.
-
-Both '--cacheinfo' and '--info-only' behave similarly: the index is updated
-but the object database isn't.  '--cacheinfo' is useful when the object is
-in the database but the file isn't available locally.  '--info-only' is
-useful when the file is available, but you do not wish to update the
-object database.
-
-Examples
---------
-To update and refresh only the files already checked out:
-
-   git-checkout-cache -n -f -a && git-update-cache --ignore-missing --refresh
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
new file mode 100644 (file)
index 0000000..54b5f24
--- /dev/null
@@ -0,0 +1,126 @@
+git-update-index(1)
+===================
+v0.1, May 2005
+
+NAME
+----
+git-update-index - Modifies the index or directory cache
+
+
+SYNOPSIS
+--------
+'git-update-index'
+            [--add] [--remove] [--refresh] [--replace]
+            [--ignore-missing]
+            [--force-remove]
+            [--cacheinfo <mode> <object> <file>]\*
+            [--info-only]
+            [--] [<file>]\*
+
+DESCRIPTION
+-----------
+Modifies the index or directory cache. Each file mentioned is updated
+into the cache and any 'unmerged' or 'needs updating' state is
+cleared.
+
+The way "git-update-index" handles files it is told about can be modified
+using the various options:
+
+OPTIONS
+-------
+--add::
+       If a specified file isn't in the cache already then it's
+       added.
+       Default behaviour is to ignore new files.
+
+--remove::
+       If a specified file is in the cache but is missing then it's
+       removed.
+       Default behaviour is to ignore removed file.
+
+--refresh::
+       Looks at the current cache and checks to see if merges or
+       updates are needed by checking stat() information.
+
+--ignore-missing::
+       Ignores missing files during a --refresh
+
+--cacheinfo <mode> <object> <path>::
+       Directly insert the specified info into the cache.
+       
+--info-only::
+       Do not create objects in the object database for all
+       <file> arguments that follow this flag; just insert
+       their object IDs into the cache.
+
+--force-remove::
+       Remove the file from the index even when the working directory
+       still has such a file. (Implies --remove.)
+
+--replace::
+       By default, when a file `path` exists in the index,
+       git-update-index refuses an attempt to add `path/file`.
+       Similarly if a file `path/file` exists, a file `path`
+       cannot be added.  With --replace flag, existing entries
+       that conflicts with the entry being added are
+       automatically removed with warning messages.
+
+--::
+       Do not interpret any more arguments as options.
+
+<file>::
+       Files to act on.
+       Note that files begining with '.' are discarded. This includes
+       `./file` and `dir/./file`. If you don't want this, then use     
+       cleaner names.
+       The same applies to directories ending '/' and paths with '//'
+
+Using --refresh
+---------------
+'--refresh' does not calculate a new sha1 file or bring the cache
+up-to-date for mode/content changes. But what it *does* do is to
+"re-match" the stat information of a file with the cache, so that you
+can refresh the cache for a file that hasn't been changed but where
+the stat entry is out of date.
+
+For example, you'd want to do this after doing a "git-read-tree", to link
+up the stat cache details with the proper files.
+
+Using --cacheinfo or --info-only
+--------------------------------
+'--cacheinfo' is used to register a file that is not in the
+current working directory.  This is useful for minimum-checkout
+merging.
+
+  To pretend you have a file with mode and sha1 at path, say:
+
+   $ git-update-index --cacheinfo mode sha1 path
+
+'--info-only' is used to register files without placing them in the object
+database.  This is useful for status-only repositories.
+
+Both '--cacheinfo' and '--info-only' behave similarly: the index is updated
+but the object database isn't.  '--cacheinfo' is useful when the object is
+in the database but the file isn't available locally.  '--info-only' is
+useful when the file is available, but you do not wish to update the
+object database.
+
+Examples
+--------
+To update and refresh only the files already checked out:
+
+   git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
index 45b1006..ebe87d6 100644 (file)
@@ -44,7 +44,7 @@ Your sysadmin must hate you!::
 See Also
 --------
 link:git-commit-tree.html[git-commit-tree]
-link:git-tag-script.html[git-tag-script]
+link:git-tag.html[git-tag]
 
 Author
 ------
diff --git a/Documentation/git-verify-tag-script.txt b/Documentation/git-verify-tag-script.txt
deleted file mode 100644 (file)
index d5d747c..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-git-verify-tag-script(1)
-========================
-
-NAME
-----
-git-verify-tag-script - Check the GPG signature of tag.
-
-SYNOPSIS
---------
-'git-verify-tag-script' <tag>
-
-DESCRIPTION
------------
-Validates the gpg signature created by git-tag-script.
-
-OPTIONS
--------
-<tag>::
-       SHA1 identifier of a git tag object.
-
-Author
-------
-Written by Jan Harkes <jaharkes@cs.cmu.edu> and Eric W. Biederman <ebiederm@xmission.com>
-
-Documentation
---------------
-Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git-verify-tag.txt b/Documentation/git-verify-tag.txt
new file mode 100644 (file)
index 0000000..98db1b3
--- /dev/null
@@ -0,0 +1,32 @@
+git-verify-tag(1)
+=================
+
+NAME
+----
+git-verify-tag - Check the GPG signature of tag.
+
+SYNOPSIS
+--------
+'git-verify-tag' <tag>
+
+DESCRIPTION
+-----------
+Validates the gpg signature created by git-tag.
+
+OPTIONS
+-------
+<tag>::
+       SHA1 identifier of a git tag object.
+
+Author
+------
+Written by Jan Harkes <jaharkes@cs.cmu.edu> and Eric W. Biederman <ebiederm@xmission.com>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
index 3cf8c93..5cd54ab 100644 (file)
@@ -20,7 +20,7 @@ The cache must be merged.
 Conceptually, "git-write-tree" sync()s the current directory cache contents
 into a set of tree files.
 In order to have that match what is actually in your directory right
-now, you need to have done a "git-update-cache" phase before you did the
+now, you need to have done a "git-update-index" phase before you did the
 "git-write-tree".
 
 OPTIONS
index fd5108c..617f416 100644 (file)
@@ -21,7 +21,7 @@ at the link:tutorial.html[tutorial] document.
 
 The <<Discussion>> section below contains much useful definition and
 clarification info - read that first.  And of the commands, I suggest
-reading link:git-update-cache.html[git-update-cache] and
+reading link:git-update-index.html[git-update-index] and
 link:git-read-tree.html[git-read-tree] first - I wish I had!
 
 If you are migrating from CVS, link:cvs-migration.html[cvs migration]
@@ -59,8 +59,9 @@ link:git-apply.html[git-apply]::
        Reads a "diff -up1" or git generated patch file and
        applies it to the working tree.
 
-link:git-checkout-cache.html[git-checkout-cache]::
+link:git-checkout-index.html[git-checkout-index]::
        Copy files from the cache to the working directory
+       Previously this command was known as git-checkout-cache.
 
 link:git-commit-tree.html[git-commit-tree]::
        Creates a new commit object
@@ -71,8 +72,9 @@ link:git-hash-object.html[git-hash-object]::
 link:git-init-db.html[git-init-db]::
        Creates an empty git object database
 
-link:git-merge-cache.html[git-merge-cache]::
+link:git-merge-index.html[git-merge-index]::
        Runs a merge for files needing merging
+       Previously this command was known as git-merge-cache.
 
 link:git-mktag.html[git-mktag]::
        Creates a tag object
@@ -89,8 +91,9 @@ link:git-read-tree.html[git-read-tree]::
 link:git-unpack-objects.html[git-unpack-objects]::
        Unpacks objects out of a packed archive.
 
-link:git-update-cache.html[git-update-cache]::
+link:git-update-index.html[git-update-index]::
        Modifies the index or directory cache
+       Previously this command was known as git-update-cache.
 
 link:git-write-tree.html[git-write-tree]::
        Creates a tree from the current cache
@@ -102,8 +105,9 @@ Interrogation commands
 link:git-cat-file.html[git-cat-file]::
        Provide content or type information for repository objects
 
-link:git-diff-cache.html[git-diff-cache]::
+link:git-diff-index.html[git-diff-index]::
        Compares content and mode of blobs between the cache and repository
+       Previously this command was known as git-diff-cache.
 
 link:git-diff-files.html[git-diff-files]::
        Compares files in the working tree and the cache
@@ -117,8 +121,9 @@ link:git-diff-tree.html[git-diff-tree]::
 link:git-export.html[git-export]::
        Exports each commit and a diff against each of its parents
 
-link:git-fsck-cache.html[git-fsck-cache]::
+link:git-fsck-objects.html[git-fsck-objects]::
        Verifies the connectivity and validity of the objects in the database
+       Previously this command was known as git-fsck-cache.
 
 link:git-ls-files.html[git-ls-files]::
        Information about files in the cache/working directory
@@ -164,11 +169,13 @@ link:git-clone-pack.html[git-clone-pack]::
 link:git-fetch-pack.html[git-fetch-pack]::
        Updates from a remote repository.
 
-link:git-http-pull.html[git-http-pull]::
+link:git-http-fetch.html[git-http-fetch]::
        Downloads a remote GIT repository via HTTP
+       Previously this command was known as git-http-pull.
 
-link:git-local-pull.html[git-local-pull]::
+link:git-local-fetch.html[git-local-fetch]::
        Duplicates another GIT repository on a local system
+       Previously this command was known as git-local-pull.
 
 link:git-peek-remote.html[git-peek-remote]::
        Lists references on a remote repository using upload-pack protocol.
@@ -179,11 +186,13 @@ link:git-receive-pack.html[git-receive-pack]::
 link:git-send-pack.html[git-send-pack]::
        Pushes to a remote repository, intelligently.
 
-link:git-ssh-pull.html[git-ssh-pull]::
+link:git-ssh-fetch.html[git-ssh-fetch]::
        Pulls from a remote repository over ssh connection
+       Previously this command was known as git-ssh-pull.
 
-link:git-ssh-push.html[git-ssh-push]::
-       Helper "server-side" program used by git-ssh-pull
+link:git-ssh-upload.html[git-ssh-upload]::
+       Helper "server-side" program used by git-ssh-fetch
+       Previously this command was known as git-ssh-push.
 
 link:git-update-server-info.html[git-update-server-info]::
        Updates auxiliary information on a dumb server to help
@@ -197,65 +206,84 @@ link:git-upload-pack.html[git-upload-pack]::
 Porcelain-ish Commands
 ----------------------
 
-link:git-add-script.html[git-add-script]::
+link:git-add.html[git-add]::
        Add paths to the index file.
+       Previously this command was known as git-add-script.
 
 link:git-applymbox.html[git-applymbox]::
        Apply patches from a mailbox.
 
-link:git-bisect-script.html[git-bisect-script]::
+link:git-bisect.html[git-bisect]::
        Find the change that introduced a bug.
+       Previously this command was known as git-bisect-script.
 
-link:git-branch-script.html[git-branch-script]::
+link:git-branch.html[git-branch]::
        Create and Show branches.
+       Previously this command was known as git-branch-script.
 
-link:git-checkout-script.html[git-checkout-script]::
+link:git-checkout.html[git-checkout]::
        Checkout and switch to a branch.
+       Previously this command was known as git-checkout-script.
 
-link:git-cherry-pick-script.html[git-cherry-pick-script]::
+link:git-cherry-pick.html[git-cherry-pick]::
        Cherry-pick the effect of an existing commit.
+       Previously this command was known as git-cherry-pick-script.
 
-link:git-clone-script.html[git-clone-script]::
+link:git-clone.html[git-clone]::
        Clones a repository into a new directory.
+       Previously this command was known as git-clone-script.
 
-link:git-commit-script.html[git-commit-script]::
+link:git-commit.html[git-commit]::
        Record changes to the repository.
+       Previously this command was known as git-commit-script.
 
-link:git-fetch-script.html[git-fetch-script]::
+link:git-fetch.html[git-fetch]::
        Download from a remote repository via various protocols.
+       Previously this command was known as git-fetch-script.
 
-link:git-log-script.html[git-log-script]::
+link:git-log.html[git-log]::
        Shows commit logs.
+       Previously this command was known as git-log-script.
 
-link:git-ls-remote-script.html[git-ls-remote-script]::
+link:git-ls-remote.html[git-ls-remote]::
        Shows references in a remote or local repository.
+       Previously this command was known as git-ls-remote-script.
 
-link:git-octopus-script.html[git-octopus-script]::
+link:git-octopus.html[git-octopus]::
        Merge more than two commits.
+       Previously this command was known as git-octopus-script.
 
-link:git-pull-script.html[git-pull-script]::
+link:git-pull.html[git-pull]::
        Fetch from and merge with a remote repository.
+       Previously this command was known as git-pull-script.
 
-link:git-push-script.html[git-push-script]::
+link:git-push.html[git-push]::
        Update remote refs along with associated objects.
+       Previously this command was known as git-push-script.
 
-link:git-rebase-script.html[git-rebase-script]::
+link:git-rebase.html[git-rebase]::
        Rebase local commits to new upstream head.
+       Previously this command was known as git-rebase-script.
 
-link:git-rename-script.html[git-rename]::
+link:git-rename.html[git-rename]::
        Rename files and directories.
+       Previously this command was known as git-rename-script.
 
-link:git-repack-script.html[git-repack-script]::
+link:git-repack.html[git-repack]::
        Pack unpacked objects in a repository.
+       Previously this command was known as git-repack-script.
 
-link:git-reset-script.html[git-reset-script]::
+link:git-reset.html[git-reset]::
        Reset current HEAD to the specified state.
+       Previously this command was known as git-reset-script.
 
-link:git-resolve-script.html[git-resolve-script]::
+link:git-resolve.html[git-resolve]::
        Merge two commits.
+       Previously this command was known as git-resolve-script.
 
-link:git-revert-script.html[git-revert-script]::
+link:git-revert.html[git-revert]::
        Revert an existing commit.
+       Previously this command was known as git-revert-script.
 
 link:git-shortlog.html[git-shortlog]::
        Summarizes 'git log' output.
@@ -263,11 +291,13 @@ link:git-shortlog.html[git-shortlog]::
 link:git-show-branch.html[git-show-branch]::
        Show branches and their commits.
 
-link:git-status-script.html[git-status-script]::
+link:git-status.html[git-status]::
        Shows the working tree status.
+       Previously this command was known as git-status-script.
 
-link:git-verify-tag-script.html[git-verify-tag-script]::
+link:git-verify-tag.html[git-verify-tag]::
        Check the GPG signature of tag.
+       Previously this command was known as git-verify-tag-script.
 
 link:git-whatchanged.html[git-whatchanged]::
        Shows commit logs and differences they introduce.
@@ -280,29 +310,37 @@ Manipulators:
 link:git-applypatch.html[git-applypatch]::
        Apply one patch extracted from an e-mail.
 
-link:git-archimport-script.html[git-archimport-script]::
+link:git-archimport.html[git-archimport]::
        Import an arch repository into git.
+       Previously this command was known as git-archimport-script.
 
-link:git-convert-cache.html[git-convert-cache]::
+link:git-convert-objects.html[git-convert-objects]::
        Converts old-style GIT repository
+       Previously this command was known as git-convert-cache.
 
-link:git-cvsimport-script.html[git-cvsimport-script]::
+link:git-cvsimport.html[git-cvsimport]::
        Salvage your data out of another SCM people love to hate.
+       Previously this command was known as git-cvsimport-script.
 
-link:git-merge-one-file-script.html[git-merge-one-file-script]::
-       The standard helper program to use with "git-merge-cache"
+link:git-merge-one-file.html[git-merge-one-file]::
+       The standard helper program to use with "git-merge-index"
+       Previously this command was known as git-merge-one-file-script.
 
-link:git-prune-script.html[git-prune-script]::
+link:git-prune.html[git-prune]::
        Prunes all unreachable objects from the object database
+       Previously this command was known as git-prune-script.
 
-link:git-relink-script.html[git-relink-script]::
+link:git-relink.html[git-relink]::
        Hardlink common objects in local repositories.
+       Previously this command was known as git-relink-script.
 
-link:git-sh-setup-script.html[git-sh-setup-script]::
+link:git-sh-setup.html[git-sh-setup]::
        Common git shell script setup code.
+       Previously this command was known as git-sh-setup-script.
 
-link:git-tag-script.html[git-tag-script]::
+link:git-tag.html[git-tag]::
        An example script to create a tag object signed with GPG
+       Previously this command was known as git-tag-script.
 
 
 Interrogators:
@@ -313,8 +351,9 @@ link:git-build-rev-cache.html[git-build-rev-cache]::
 link:git-cherry.html[git-cherry]::
        Find commits not merged upstream.
 
-link:git-count-objects-script.html[git-count-objects-script]::
+link:git-count-objects.html[git-count-objects]::
        Count unpacked number of objects and their disk consumption.
+       Previously this command was known as git-count-objects-script.
 
 link:git-daemon.html[git-daemon]::
        A really simple server for GIT repositories.
@@ -334,17 +373,20 @@ link:git-mailsplit.html[git-mailsplit]::
 link:git-patch-id.html[git-patch-id]::
        Compute unique ID for a patch.
 
-link:git-parse-remote-script.html[git-parse-remote-script]::
+link:git-parse-remote.html[git-parse-remote]::
        Routines to help parsing $GIT_DIR/remotes/
+       Previously this command was known as git-parse-remote-script.
 
-link:git-request-pull-script.html[git-request-pull-script]::
-       git-request-pull-script.
+link:git-request-pull.html[git-request-pull]::
+       git-request-pull.
+       Previously this command was known as git-request-pull-script.
 
 link:git-rev-parse.html[git-rev-parse]::
        Pick out and massage parameters.
 
-link:git-send-email-script.html[git-send-email]::
+link:git-send-email.html[git-send-email]::
        Send patch e-mails out of "format-patch --mbox" output.
+       Previously this command was known as git-send-email-script.
 
 link:git-show-rev-cache.html[git-show-rev-cache]::
        Show the contents of a rev-cache file.
@@ -352,11 +394,13 @@ link:git-show-rev-cache.html[git-show-rev-cache]::
 Commands not yet documented
 ---------------------------
 
-link:git-diff-script.html[git-diff-script]::
-       git-diff-script.
+link:git-diff.html[git-diff]::
+       git-diff.
+       Previously this command was known as git-diff-script.
 
-link:git-format-patch-script.html[git-format-patch-script]::
-       git-format-patch-script.
+link:git-format-patch.html[git-format-patch]::
+       git-format-patch.
+       Previously this command was known as git-format-patch-script.
 
 link:git-stripspace.html[git-stripspace]::
        git-stripspace.
@@ -473,7 +517,7 @@ git Diffs
 'GIT_DIFF_OPTS'::
 'GIT_EXTERNAL_DIFF'::
        see the "generating patches" section in :
-       link:git-diff-cache.html[git-diff-cache];
+       link:git-diff-index.html[git-diff-index];
        link:git-diff-files.html[git-diff-files];
        link:git-diff-tree.html[git-diff-tree]
 
index 45809ba..ca0efee 100644 (file)
@@ -56,11 +56,11 @@ the outcome of `git-applypatch`.
 pre-commit
 ----------
 
-This hook is invoked by `git-commit-script`, and can be bypassed
+This hook is invoked by `git-commit`, and can be bypassed
 with `--no-verify` option.  It takes no parameter, and is
 invoked before obtaining the proposed commit log message and
 making a commit.  Exiting with non-zero status from this script
-causes the `git-commit-script` to abort.
+causes the `git-commit` to abort.
 
 The default pre-commit hook, when enabled, catches introduction
 of lines with trailing whitespaces and aborts the commit when
@@ -69,10 +69,10 @@ a such line is found.
 commit-msg
 ----------
 
-This hook is invoked by `git-commit-script`, and can be bypassed
+This hook is invoked by `git-commit`, and can be bypassed
 with `--no-verify` option.  It takes a single parameter, the
 name of the file that holds the proposed commit log message.
-Exiting with non-zero status causes the `git-commit-script` to
+Exiting with non-zero status causes the `git-commit` to
 abort.
 
 The hook is allowed to edit the message file in place, and can
@@ -86,11 +86,11 @@ Signed-off-by: lines, and aborts the commit when one is found.
 post-commit
 -----------
 
-This hook is invoked by `git-commit-script`.  It takes no
+This hook is invoked by `git-commit`.  It takes no
 parameter, and is invoked after a commit is made.
 
 This hook is meant primarily for notification, and cannot affect
-the outcome of `git-commit-script`.
+the outcome of `git-commit`.
 
 The default post-commit hook, when enabled, demonstrates how to
 send out a commit notification e-mail.
index 132d5ec..00e330b 100644 (file)
@@ -32,7 +32,7 @@ This is my crappy "release-script":
         stable="$1"
         last="$2"
         new="$3"
-        echo "# git-tag-script v$new"
+        echo "# git-tag v$new"
         echo "git-tar-tree v$new linux-$new | gzip -9 > ../linux-$new.tar.gz"
         echo "git-diff-tree -p v$stable v$new | gzip -9 > ../patch-$new.gz"
         echo "git-rev-list --pretty v$new ^v$last > ../ChangeLog-$new"
index 4523b69..b2c021d 100644 (file)
@@ -111,7 +111,7 @@ prepare #2 and #3 for e-mail submission.
 
 This creates two files, 0001-XXXX.txt and 0002-XXXX.txt.  Send
 them out "To: " your project maintainer and "Cc: " your mailing
-list.  You could use contributed script git-send-email-script if
+list.  You could use contributed script git-send-email if
 your host has necessary perl modules for this, but your usual
 MUA would do as long as it does not corrupt whitespaces in the
 patch.
index 1c9a368..e4cce5b 100644 (file)
@@ -182,10 +182,10 @@ And the final repository status looks like this:
 ------------------------------------------------
 $ git show-branch --more=1 master pu rc
 ! [master] Revert "Replace zero-length array decls with []."
- ! [pu] git-repack-script: Add option to repack all objects.
+ ! [pu] git-repack: Add option to repack all objects.
   * [rc] Merge refs/heads/master from .
 ---
- +  [pu] git-repack-script: Add option to repack all objects.
+ +  [pu] git-repack: Add option to repack all objects.
  +  [pu~1] More documentation updates.
  +  [pu~2] Show commits in topo order and name all commits.
  +  [pu~3] mailinfo and applymbox updates
index 8d999b0..c938bbc 100644 (file)
@@ -126,7 +126,7 @@ actually check in your hard work, you will have to go through two steps:
  - commit that index file as an object.
 
 The first step is trivial: when you want to tell git about any changes
-to your working tree, you use the `git-update-cache` program. That
+to your working tree, you use the `git-update-index` program. That
 program normally just takes a list of filenames you want to update, but
 to avoid trivial mistakes, it refuses to add new entries to the cache
 (or remove existing ones) unless you explicitly tell it that you're
@@ -136,7 +136,7 @@ adding a new entry with the `\--add` flag (or removing an entry with the
 So to populate the index with the two files you just created, you can do
 
 ------------------------------------------------
-git-update-cache --add hello example
+git-update-index --add hello example
 ------------------------------------------------
 
 and you have now told git to track those two files.
@@ -183,7 +183,7 @@ hexadecimal digits in most places.
 Anyway, as we mentioned previously, you normally never actually take a
 look at the objects themselves, and typing long 40-character hex
 names is not something you'd normally want to do. The above digression
-was just to show that `git-update-cache` did something magical, and
+was just to show that `git-update-index` did something magical, and
 actually saved away the contents of your files into the git object
 database.
 
@@ -318,7 +318,7 @@ instead, and it would have done the above magic scripting for you.
 Making a change
 ---------------
 
-Remember how we did the `git-update-cache` on file `hello` and then we
+Remember how we did the `git-update-index` on file `hello` and then we
 changed `hello` afterward, and could compare the new state of `hello` with the
 state we saved in the index file? 
 
@@ -333,18 +333,18 @@ As before, if we do `git-diff-files -p` in our git-tutorial project,
 we'll still see the same difference we saw last time: the index file
 hasn't changed by the act of committing anything. However, now that we
 have committed something, we can also learn to use a new command:
-`git-diff-cache`.
+`git-diff-index`.
 
 Unlike `git-diff-files`, which showed the difference between the index
-file and the working tree, `git-diff-cache` shows the differences
+file and the working tree, `git-diff-index` shows the differences
 between a committed *tree* and either the index file or the working
-tree. In other words, `git-diff-cache` wants a tree to be diffed
+tree. In other words, `git-diff-index` wants a tree to be diffed
 against, and before we did the commit, we couldn't do that, because we
 didn't have anything to diff against. 
 
 But now we can do
 
-       git-diff-cache -p HEAD
+       git-diff-index -p HEAD
 
 (where `-p` has the same meaning as it did in `git-diff-files`), and it
 will show us the same difference, but for a totally different reason. 
@@ -359,16 +359,16 @@ it with
 
 which ends up doing the above for you.
 
-In other words, `git-diff-cache` normally compares a tree against the
+In other words, `git-diff-index` normally compares a tree against the
 working tree, but when given the `\--cached` flag, it is told to
 instead compare against just the index cache contents, and ignore the
 current working tree state entirely. Since we just wrote the index
-file to HEAD, doing `git-diff-cache \--cached -p HEAD` should thus return
+file to HEAD, doing `git-diff-index \--cached -p HEAD` should thus return
 an empty set of differences, and that's exactly what it does. 
 
 [NOTE]
 ================
-`git-diff-cache` really always uses the index for its
+`git-diff-index` really always uses the index for its
 comparisons, and saying that it compares a tree against the working
 tree is thus not strictly accurate. In particular, the list of
 files to compare (the "meta-data") *always* comes from the index file,
@@ -391,7 +391,7 @@ work through the index file, so the first thing we need to do is to
 update the index cache:
 
 ------------------------------------------------
-git-update-cache hello
+git-update-index hello
 ------------------------------------------------
 
 (note how we didn't need the `\--add` flag this time, since git knew
@@ -399,9 +399,9 @@ about the file already).
 
 Note what happens to the different `git-diff-\*` versions here. After
 we've updated `hello` in the index, `git-diff-files -p` now shows no
-differences, but `git-diff-cache -p HEAD` still *does* show that the
+differences, but `git-diff-index -p HEAD` still *does* show that the
 current state is different from the state we committed. In fact, now
-`git-diff-cache` shows the same difference whether we use the `--cached`
+`git-diff-index` shows the same difference whether we use the `--cached`
 flag or not, since now the index is coherent with the working tree.
 
 Now, since we've updated `hello` in the index, we can commit the new
@@ -429,7 +429,7 @@ You've now made your first real git commit. And if you're interested in
 looking at what `git commit` really does, feel free to investigate:
 it's a few very simple shell scripts to generate the helpful (?) commit
 message headers, and a few one-liners that actually do the
-commit itself (`git-commit-script`).
+commit itself (`git-commit`).
 
 
 Checking it out
@@ -490,11 +490,11 @@ can explore on your own.
 Most likely, you are not directly using the core
 git Plumbing commands, but using Porcelain like Cogito on top
 of it. Cogito works a bit differently and you usually do not
-have to run `git-update-cache` yourself for changed files (you
+have to run `git-update-index` yourself for changed files (you
 do tell underlying git about additions and removals via
 `cg-add` and `cg-rm` commands). Just before you make a commit
 with `cg-commit`, Cogito figures out which files you modified,
-and runs `git-update-cache` on them for you.
+and runs `git-update-index` on them for you.
 
 
 Tagging a version
@@ -579,7 +579,7 @@ file (which caches various information, notably some of the "stat"
 information for the files involved) will likely need to be refreshed.
 So after you do a `cp -a` to create a new copy, you'll want to do
 
-       git-update-cache --refresh
+       git-update-index --refresh
 +
 in the new repository to make sure that the index file is up-to-date.
 
@@ -591,16 +591,16 @@ When copying a remote repository, you'll want to at a minimum update the
 index cache when you do this, and especially with other peoples'
 repositories you often want to make sure that the index cache is in some
 known state (you don't know *what* they've done and not yet checked in),
-so usually you'll precede the `git-update-cache` with a
+so usually you'll precede the `git-update-index` with a
 
        git-read-tree --reset HEAD
-       git-update-cache --refresh
+       git-update-index --refresh
 
 which will force a total index re-build from the tree pointed to by `HEAD`.
-It resets the index contents to `HEAD`, and then the `git-update-cache`
+It resets the index contents to `HEAD`, and then the `git-update-index`
 makes sure to match up all index entries with the checked-out files.
 If the original repository had uncommitted changes in its
-working tree, `git-update-cache --refresh` notices them and
+working tree, `git-update-index --refresh` notices them and
 tells you they need to be updated.
 
 The above can also be written as simply
@@ -610,7 +610,7 @@ The above can also be written as simply
 and in fact a lot of the common git command combinations can be scripted
 with the `git xyz` interfaces, and you can learn things by just looking
 at what the `git-*-script` scripts do (`git reset` is the above two lines
-implemented in `git-reset-script`, but some things like `git status` and
+implemented in `git-reset`, but some things like `git status` and
 `git commit` are slightly more complex scripts around the basic git
 commands). 
 
@@ -638,13 +638,13 @@ you have all the git internal files, but you will notice that you don't
 actually have any of the working tree files to work on. To get
 those, you'd check them out with
 
-       git-checkout-cache -u -a
+       git-checkout-index -u -a
 
 where the `-u` flag means that you want the checkout to keep the index
 up-to-date (so that you don't have to refresh it afterward), and the
 `-a` flag means "check out all files" (if you have a stale copy or an
 older version of a checked out tree you may also need to add the `-f`
-flag first, to tell git-checkout-cache to *force* overwriting of any old
+flag first, to tell git-checkout-index to *force* overwriting of any old
 files). 
 
 Again, this can all be simplified with
@@ -742,7 +742,7 @@ git commit -m 'Some work.' hello
 ------------------------------------------------
 
 Here, we just added another line to `hello`, and we used a shorthand for
-both going a `git-update-cache hello` and `git commit` by just giving the
+both going a `git-update-index hello` and `git commit` by just giving the
 filename directly to `git commit`. The `-m` flag is to give the
 commit log message from the command line.
 
@@ -971,7 +971,7 @@ transports', because they do not require any GIT aware smart
 server like GIT Native transport does.  Any stock HTTP server
 would suffice.
 +
-There are (confusingly enough) `git-ssh-pull` and `git-ssh-push`
+There are (confusingly enough) `git-ssh-fetch` and `git-ssh-upload`
 programs, which are 'commit walkers'; they outlived their
 usefulness when GIT Native and SSH transports were introduced,
 and not used by `git pull` or `git push` scripts.
diff --git a/INSTALL b/INSTALL
index 43f2bb9..14580cc 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -18,7 +18,7 @@ Issues of note:
    Tough.  Either don't use the wrapper script, or delete the old GNU
    interactive tools.  None of the core git stuff needs the wrapper,
    it's just a convenient shorthand and while it is documented in some
-   places, you can always replace "git commit" with "git-commit-script"
+   places, you can always replace "git commit" with "git-commit"
    instead. 
 
    But let's face it, most of us don't have GNU interactive tools, and
@@ -41,8 +41,8 @@ Issues of note:
          can avoid the bignum support by excising git-rev-list support
          for "--merge-order" (by hand).
 
-       - "libcurl" and "curl" executable.  git-http-pull and
-         git-fetch-script use them.  If you do not use http
+       - "libcurl" and "curl" executable.  git-http-fetch and
+         git-fetch use them.  If you do not use http
          transfer, you are probabaly OK if you do not have
          them.
 
index 6dbffc2..18696fa 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -57,24 +57,21 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
 
 ### --- END CONFIGURATION SECTION ---
 
-
-
-SCRIPTS=git git-merge-one-file-script git-prune-script \
-       git-pull-script git-tag-script git-resolve-script git-whatchanged \
-       git-fetch-script git-status-script git-commit-script \
-       git-log-script git-shortlog git-cvsimport-script git-diff-script \
-       git-reset-script git-add-script git-checkout-script git-clone-script \
-       gitk git-cherry git-rebase-script git-relink-script git-repack-script \
-       git-format-patch-script git-sh-setup-script git-push-script \
-       git-branch-script git-parse-remote-script git-verify-tag-script \
-       git-ls-remote-script git-rename-script \
-       git-request-pull-script git-bisect-script \
-       git-applymbox git-applypatch
-
-SCRIPTS += git-count-objects-script
-SCRIPTS += git-revert-script
-SCRIPTS += git-octopus-script
-SCRIPTS += git-archimport-script
+SCRIPT_SH = \
+       git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
+       git-cherry.sh git-clone.sh git-commit.sh \
+       git-count-objects.sh git-diff.sh git-fetch.sh \
+       git-format-patch.sh git-log.sh git-ls-remote.sh \
+       git-merge-one-file.sh git-octopus.sh git-parse-remote.sh \
+       git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
+       git-repack.sh git-request-pull.sh git-reset.sh \
+       git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
+       git-tag.sh git-verify-tag.sh git-whatchanged.sh git.sh \
+       git-applymbox.sh git-applypatch.sh
+
+SCRIPT_PERL = \
+       git-archimport.perl git-cvsimport.perl git-relink.perl \
+       git-rename.perl git-send-email.perl git-shortlog.perl
 
 # The ones that do not have to link with lcrypto nor lz.
 SIMPLE_PROGRAMS = \
@@ -82,56 +79,50 @@ SIMPLE_PROGRAMS = \
        git-daemon git-var
 
 # ... and all the rest
-PROG=   git-update-cache git-diff-files git-init-db git-write-tree \
-       git-read-tree git-commit-tree git-cat-file git-fsck-cache \
-       git-checkout-cache git-diff-tree git-rev-tree git-ls-files \
-       git-ls-tree git-merge-base git-merge-cache \
-       git-unpack-file git-export git-diff-cache git-convert-cache \
-       git-ssh-push git-ssh-pull git-rev-list git-mktag \
-       git-diff-helper git-tar-tree git-local-pull git-hash-object \
-       git-apply \
-       git-diff-stages git-rev-parse git-patch-id git-pack-objects \
-       git-unpack-objects git-verify-pack git-receive-pack git-send-pack \
-       git-prune-packed git-fetch-pack git-upload-pack git-clone-pack \
-       git-show-index git-peek-remote git-show-branch \
-       git-update-server-info git-show-rev-cache git-build-rev-cache \
+PROGRAMS = \
+       git-apply git-build-rev-cache git-cat-file \
+       git-checkout-index git-clone-pack git-commit-tree \
+       git-convert-objects git-diff-files \
+       git-diff-helper git-diff-index git-diff-stages \
+       git-diff-tree git-export git-fetch-pack git-fsck-objects \
+       git-hash-object git-init-db \
+       git-local-fetch git-ls-files git-ls-tree git-merge-base \
+       git-merge-index git-mktag git-pack-objects git-patch-id \
+       git-peek-remote git-prune-packed git-read-tree \
+       git-receive-pack git-rev-list git-rev-parse \
+       git-rev-tree git-send-pack git-show-branch \
+       git-show-index git-show-rev-cache git-ssh-fetch \
+       git-ssh-upload git-tar-tree git-unpack-file \
+       git-unpack-objects git-update-index git-update-server-info \
+       git-upload-pack git-verify-pack git-write-tree \
        $(SIMPLE_PROGRAMS)
 
 ifdef WITH_SEND_EMAIL
-SCRIPTS += git-send-email-script
+       SCRIPT_PERL += git-send-email.perl
 endif
 
 ifndef NO_CURL
-       PROG+= git-http-pull
+       PROGRAMS += git-http-fetch
 endif
 
 LIB_FILE=libgit.a
-LIB_H=cache.h object.h blob.h tree.h commit.h tag.h delta.h epoch.h csum-file.h \
-       pack.h pkt-line.h refs.h
-LIB_OBJS=read-cache.o sha1_file.o usage.o object.o commit.o tree.o blob.o \
-        tag.o date.o index.o diff-delta.o patch-delta.o entry.o path.o \
-        refs.o csum-file.o pack-check.o pkt-line.o connect.o ident.o \
-        sha1_name.o setup.o
-
-LIB_H += rev-cache.h
-LIB_OBJS += rev-cache.o
 
-LIB_H += run-command.h
-LIB_OBJS += run-command.o
+LIB_H = \
+       blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
+       diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
+       rev-cache.h run-command.h strbuf.h tag.h tree.h
 
-LIB_H += strbuf.h
-LIB_OBJS += strbuf.o
+DIFF_OBJS = \
+       diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
+       diffcore-pickaxe.o diffcore-rename.o
 
-LIB_H += quote.h
-LIB_OBJS += quote.o 
-
-LIB_H += diff.h count-delta.h
-DIFF_OBJS = diff.o diffcore-rename.o diffcore-pickaxe.o diffcore-pathspec.o \
-       diffcore-break.o diffcore-order.o
-LIB_OBJS += $(DIFF_OBJS) count-delta.o
-
-LIB_OBJS += gitenv.o
-LIB_OBJS += server-info.o
+LIB_OBJS = \
+       blob.o commit.o connect.o count-delta.o csum-file.o \
+       date.o diff-delta.o entry.o gitenv.o ident.o index.o \
+       object.o pack-check.o patch-delta.o path.o pkt-line.o \
+       quote.o read-cache.o refs.o rev-cache.o run-command.o \
+       server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
+       tag.o tree.o usage.o $(DIFF_OBJS)
 
 LIBS = $(LIB_FILE)
 LIBS += -lz
@@ -143,11 +134,11 @@ endif
 
 ifndef NO_OPENSSL
        LIB_OBJS += epoch.o
-       OPENSSL_LIBSSL=-lssl
+       OPENSSL_LIBSSL = -lssl
 else
        DEFINES += '-DNO_OPENSSL'
-       MOZILLA_SHA1=1
-       OPENSSL_LIBSSL=
+       MOZILLA_SHA1 = 1
+       OPENSSL_LIBSSL =
 endif
 ifdef NEEDS_SSL_WITH_CRYPTO
        LIB_4_CRYPTO = -lcrypto -lssl
@@ -160,25 +151,25 @@ else
        LIB_4_ICONV =
 endif
 ifdef MOZILLA_SHA1
-       SHA1_HEADER="mozilla-sha1/sha1.h"
+       SHA1_HEADER = "mozilla-sha1/sha1.h"
        LIB_OBJS += mozilla-sha1/sha1.o
 else
        ifdef PPC_SHA1
-               SHA1_HEADER="ppc/sha1.h"
+               SHA1_HEADER = "ppc/sha1.h"
                LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
        else
-               SHA1_HEADER=<openssl/sha.h>
+               SHA1_HEADER = <openssl/sha.h>
                LIBS += $(LIB_4_CRYPTO)
        endif
 endif
 
 DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
 
-
+SCRIPTS = $(SCRIPT_SH) $(SCRIPT_PERL) gitk
 
 ### Build rules
 
-all: $(PROG)
+all: $(PROGRAMS)
 
 all:
        $(MAKE) -C templates
@@ -196,12 +187,12 @@ $(SIMPLE_PROGRAMS) : $(LIB_FILE)
 $(SIMPLE_PROGRAMS) : git-% : %.o
        $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIB_FILE) $(SIMPLE_LIB)
 
-git-http-pull: pull.o
-git-local-pull: pull.o
-git-ssh-pull: rsh.o pull.o
-git-ssh-push: rsh.o
+git-http-fetch: fetch.o
+git-local-fetch: fetch.o
+git-ssh-fetch: rsh.o fetch.o
+git-ssh-upload: rsh.o
 
-git-http-pull: LIBS += -lcurl
+git-http-fetch: LIBS += -lcurl
 git-rev-list: LIBS += $(OPENSSL_LIBSSL)
 
 init-db.o: init-db.c
@@ -209,7 +200,7 @@ init-db.o: init-db.c
                -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
 
 $(LIB_OBJS): $(LIB_H)
-$(patsubst git-%,%.o,$(PROG)): $(LIB_H)
+$(patsubst git-%,%.o,$(PROGRAMS)): $(LIB_H)
 $(DIFF_OBJS): diffcore.h
 
 $(LIB_FILE): $(LIB_OBJS)
@@ -219,7 +210,6 @@ doc:
        $(MAKE) -C Documentation all
 
 
-
 ### Testing rules
 
 test: all
@@ -238,10 +228,22 @@ check:
 
 ### Installation rules
 
-install: $(PROG) $(SCRIPTS)
+install: $(PROGRAMS) $(SCRIPTS)
        $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
-       $(INSTALL) $(PROG) $(SCRIPTS) $(DESTDIR)$(bindir)
-       $(INSTALL) git-revert-script $(DESTDIR)$(bindir)/git-cherry-pick-script
+       $(INSTALL) $(PROGRAMS) $(DESTDIR)$(bindir)
+       @for s in $(SCRIPTS); \
+       do \
+               case "$$s" in \
+               *.*) \
+                       e=`expr "$$s" : '\(.*\)\.[^.]*$$'` ;; \
+               *) \
+                       e="$$s" ;; \
+               esac && \
+               echo ": install $$s $(DESTDIR)$(bindir)/$$e" && \
+               $(INSTALL) $$s $(DESTDIR)$(bindir)/$$e || exit; \
+       done
+       $(INSTALL) git-revert.sh $(DESTDIR)$(bindir)/git-cherry-pick
+       sh ./cmd-rename.sh $(DESTDIR)$(bindir)
        $(MAKE) -C templates install
 
 install-doc:
@@ -276,7 +278,7 @@ deb: dist
 ### Cleaning rules
 
 clean:
-       rm -f *.o mozilla-sha1/*.o ppc/*.o $(PROG) $(LIB_FILE)
+       rm -f *.o mozilla-sha1/*.o ppc/*.o $(PROGRAMS) $(LIB_FILE)
        rm -f git-core.spec
        rm -rf $(GIT_TARNAME)
        rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
diff --git a/README b/README
index 62c3b0c..6b38a7a 100644 (file)
--- a/README
+++ b/README
@@ -81,7 +81,7 @@ 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-cache` program, which generates a full dependency graph
+the `git-fsck-objects` 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).
 
@@ -104,7 +104,7 @@ 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 link:git-update-cache.html[git-update-cache]
+A blob is typically created when link:git-update-index.html[git-update-index]
 is run, and its data can be accessed by link:git-cat-file.html[git-cat-file].
 
 Tree Object
@@ -218,7 +218,7 @@ verification) has to come from outside.
 A tag is created with link:git-mktag.html[git-mktag],
 its data can be accessed by link:git-cat-file.html[git-cat-file],
 and the signature can be verified by
-link:git-verify-tag-script.html[git-verify-tag].
+link:git-verify-tag.html[git-verify-tag].
 
 
 The "index" aka "Current Directory Cache"
@@ -286,11 +286,11 @@ main combinations:
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 You update the index with information from the working directory with
-the link:git-update-cache.html[git-update-cache] command.  You
+the link:git-update-index.html[git-update-index] command.  You
 generally update the index information by just specifying the filename
 you want to update, like so:
 
-       git-update-cache filename
+       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,
@@ -307,7 +307,7 @@ 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-cache --refresh`, which
+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
@@ -347,18 +347,18 @@ 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-cache`).
+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-cache filename
+               git-checkout-index filename
 
 or, if you want to check out all of the index, use `-a`.
 
-NOTE! git-checkout-cache normally refuses to overwrite old files, so
+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.
@@ -530,17 +530,17 @@ 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-cache hello.c
+       git-update-index hello.c
 
-When a path is in unmerged state, running `git-update-cache` for
+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-cache` program that extracts the
+for this.  There is `git-merge-index` program that extracts the
 stages to temporary files and calls a `merge` script on it
 
-       git-merge-cache git-merge-one-file-script hello.c
+       git-merge-index git-merge-one-file hello.c
 
 and that is what higher level `git resolve` is implemented with.
diff --git a/checkout-cache.c b/checkout-cache.c
deleted file mode 100644 (file)
index 31ff577..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Check-out files from the "current cache directory"
- *
- * Copyright (C) 2005 Linus Torvalds
- *
- * Careful: order of argument flags does matter. For example,
- *
- *     git-checkout-cache -a -f file.c
- *
- * Will first check out all files listed in the cache (but not
- * overwrite any old ones), and then force-checkout "file.c" a
- * second time (ie that one _will_ overwrite any old contents
- * with the same filename).
- *
- * Also, just doing "git-checkout-cache" does nothing. You probably
- * meant "git-checkout-cache -a". And if you want to force it, you
- * want "git-checkout-cache -f -a".
- *
- * Intuitiveness is not the goal here. Repeatability is. The
- * reason for the "no arguments means no work" thing is that
- * from scripts you are supposed to be able to do things like
- *
- *     find . -name '*.h' -print0 | xargs -0 git-checkout-cache -f --
- *
- * which will force all existing *.h files to be replaced with
- * their cached copies. If an empty command line implied "all",
- * then this would force-refresh everything in the cache, which
- * was not the point.
- *
- * Oh, and the "--" is just a good idea when you know the rest
- * will be filenames. Just so that you wouldn't have a filename
- * of "-a" causing problems (not possible in the above example,
- * but get used to it in scripting!).
- */
-#include "cache.h"
-
-static struct checkout state = {
-       .base_dir = "",
-       .base_dir_len = 0,
-       .force = 0,
-       .quiet = 0,
-       .not_new = 0,
-       .refresh_cache = 0,
-};
-
-static int checkout_file(const char *name)
-{
-       int pos = cache_name_pos(name, strlen(name));
-       if (pos < 0) {
-               if (!state.quiet) {
-                       pos = -pos - 1;
-                       fprintf(stderr,
-                               "git-checkout-cache: %s is %s.\n",
-                               name,
-                               (pos < active_nr &&
-                                !strcmp(active_cache[pos]->name, name)) ?
-                               "unmerged" : "not in the cache");
-               }
-               return -1;
-       }
-       return checkout_entry(active_cache[pos], &state);
-}
-
-static int checkout_all(void)
-{
-       int i;
-
-       for (i = 0; i < active_nr ; i++) {
-               struct cache_entry *ce = active_cache[i];
-               if (ce_stage(ce))
-                       continue;
-               if (checkout_entry(ce, &state) < 0)
-                       return -1;
-       }
-       return 0;
-}
-
-static const char checkout_cache_usage[] =
-"git-checkout-cache [-u] [-q] [-a] [-f] [-n] [--prefix=<string>] [--] <file>...";
-
-static struct cache_file cache_file;
-
-int main(int argc, char **argv)
-{
-       int i, force_filename = 0;
-       int newfd = -1;
-
-       if (read_cache() < 0) {
-               die("invalid cache");
-       }
-
-       for (i = 1; i < argc; i++) {
-               const char *arg = argv[i];
-               if (!force_filename) {
-                       if (!strcmp(arg, "-a")) {
-                               checkout_all();
-                               continue;
-                       }
-                       if (!strcmp(arg, "--")) {
-                               force_filename = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "-f")) {
-                               state.force = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "-q")) {
-                               state.quiet = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "-n")) {
-                               state.not_new = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "-u")) {
-                               state.refresh_cache = 1;
-                               if (newfd < 0)
-                                       newfd = hold_index_file_for_update
-                                               (&cache_file,
-                                                get_index_file());
-                               if (newfd < 0)
-                                       die("cannot open index.lock file.");
-                               continue;
-                       }
-                       if (!memcmp(arg, "--prefix=", 9)) {
-                               state.base_dir = arg+9;
-                               state.base_dir_len = strlen(state.base_dir);
-                               continue;
-                       }
-                       if (arg[0] == '-')
-                               usage(checkout_cache_usage);
-               }
-               if (state.base_dir_len) {
-                       /* when --prefix is specified we do not
-                        * want to update cache.
-                        */
-                       if (state.refresh_cache) {
-                               close(newfd); newfd = -1;
-                               rollback_index_file(&cache_file);
-                       }
-                       state.refresh_cache = 0;
-               }
-               checkout_file(arg);
-       }
-
-       if (0 <= newfd &&
-           (write_cache(newfd, active_cache, active_nr) ||
-            commit_index_file(&cache_file)))
-               die("Unable to write new cachefile");
-       return 0;
-}
diff --git a/checkout-index.c b/checkout-index.c
new file mode 100644 (file)
index 0000000..f32513c
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Check-out files from the "current cache directory"
+ *
+ * Copyright (C) 2005 Linus Torvalds
+ *
+ * Careful: order of argument flags does matter. For example,
+ *
+ *     git-checkout-index -a -f file.c
+ *
+ * Will first check out all files listed in the cache (but not
+ * overwrite any old ones), and then force-checkout "file.c" a
+ * second time (ie that one _will_ overwrite any old contents
+ * with the same filename).
+ *
+ * Also, just doing "git-checkout-index" does nothing. You probably
+ * meant "git-checkout-index -a". And if you want to force it, you
+ * want "git-checkout-index -f -a".
+ *
+ * Intuitiveness is not the goal here. Repeatability is. The
+ * reason for the "no arguments means no work" thing is that
+ * from scripts you are supposed to be able to do things like
+ *
+ *     find . -name '*.h' -print0 | xargs -0 git-checkout-index -f --
+ *
+ * which will force all existing *.h files to be replaced with
+ * their cached copies. If an empty command line implied "all",
+ * then this would force-refresh everything in the cache, which
+ * was not the point.
+ *
+ * Oh, and the "--" is just a good idea when you know the rest
+ * will be filenames. Just so that you wouldn't have a filename
+ * of "-a" causing problems (not possible in the above example,
+ * but get used to it in scripting!).
+ */
+#include "cache.h"
+
+static struct checkout state = {
+       .base_dir = "",
+       .base_dir_len = 0,
+       .force = 0,
+       .quiet = 0,
+       .not_new = 0,
+       .refresh_cache = 0,
+};
+
+static int checkout_file(const char *name)
+{
+       int pos = cache_name_pos(name, strlen(name));
+       if (pos < 0) {
+               if (!state.quiet) {
+                       pos = -pos - 1;
+                       fprintf(stderr,
+                               "git-checkout-index: %s is %s.\n",
+                               name,
+                               (pos < active_nr &&
+                                !strcmp(active_cache[pos]->name, name)) ?
+                               "unmerged" : "not in the cache");
+               }
+               return -1;
+       }
+       return checkout_entry(active_cache[pos], &state);
+}
+
+static int checkout_all(void)
+{
+       int i;
+
+       for (i = 0; i < active_nr ; i++) {
+               struct cache_entry *ce = active_cache[i];
+               if (ce_stage(ce))
+                       continue;
+               if (checkout_entry(ce, &state) < 0)
+                       return -1;
+       }
+       return 0;
+}
+
+static const char checkout_cache_usage[] =
+"git-checkout-index [-u] [-q] [-a] [-f] [-n] [--prefix=<string>] [--] <file>...";
+
+static struct cache_file cache_file;
+
+int main(int argc, char **argv)
+{
+       int i, force_filename = 0;
+       int newfd = -1;
+
+       if (read_cache() < 0) {
+               die("invalid cache");
+       }
+
+       for (i = 1; i < argc; i++) {
+               const char *arg = argv[i];
+               if (!force_filename) {
+                       if (!strcmp(arg, "-a")) {
+                               checkout_all();
+                               continue;
+                       }
+                       if (!strcmp(arg, "--")) {
+                               force_filename = 1;
+                               continue;
+                       }
+                       if (!strcmp(arg, "-f")) {
+                               state.force = 1;
+                               continue;
+                       }
+                       if (!strcmp(arg, "-q")) {
+                               state.quiet = 1;
+                               continue;
+                       }
+                       if (!strcmp(arg, "-n")) {
+                               state.not_new = 1;
+                               continue;
+                       }
+                       if (!strcmp(arg, "-u")) {
+                               state.refresh_cache = 1;
+                               if (newfd < 0)
+                                       newfd = hold_index_file_for_update
+                                               (&cache_file,
+                                                get_index_file());
+                               if (newfd < 0)
+                                       die("cannot open index.lock file.");
+                               continue;
+                       }
+                       if (!memcmp(arg, "--prefix=", 9)) {
+                               state.base_dir = arg+9;
+                               state.base_dir_len = strlen(state.base_dir);
+                               continue;
+                       }
+                       if (arg[0] == '-')
+                               usage(checkout_cache_usage);
+               }
+               if (state.base_dir_len) {
+                       /* when --prefix is specified we do not
+                        * want to update cache.
+                        */
+                       if (state.refresh_cache) {
+                               close(newfd); newfd = -1;
+                               rollback_index_file(&cache_file);
+                       }
+                       state.refresh_cache = 0;
+               }
+               checkout_file(arg);
+       }
+
+       if (0 <= newfd &&
+           (write_cache(newfd, active_cache, active_nr) ||
+            commit_index_file(&cache_file)))
+               die("Unable to write new cachefile");
+       return 0;
+}
diff --git a/cmd-rename.sh b/cmd-rename.sh
new file mode 100755 (executable)
index 0000000..1edb037
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/sh
+d="$1"
+test -d "$d" || exit
+while read old new
+do
+       rm -f "$d/$old"
+       ln -s "$new" "$d/$old"
+done <<\EOF
+git-add-script git-add
+git-archimport-script  git-archimport
+git-bisect-script      git-bisect
+git-branch-script      git-branch
+git-checkout-script    git-checkout
+git-cherry-pick-script git-cherry-pick
+git-clone-script       git-clone
+git-commit-script      git-commit
+git-count-objects-script       git-count-objects
+git-cvsimport-script   git-cvsimport
+git-diff-script        git-diff
+git-send-email-script  git-send-email
+git-fetch-script       git-fetch
+git-format-patch-script        git-format-patch
+git-log-script git-log
+git-ls-remote-script   git-ls-remote
+git-merge-one-file-script      git-merge-one-file
+git-octopus-script     git-octopus
+git-parse-remote-script        git-parse-remote
+git-prune-script       git-prune
+git-pull-script        git-pull
+git-push-script        git-push
+git-rebase-script      git-rebase
+git-relink-script      git-relink
+git-rename-script      git-rename
+git-repack-script      git-repack
+git-request-pull-script        git-request-pull
+git-reset-script       git-reset
+git-resolve-script     git-resolve
+git-revert-script      git-revert
+git-sh-setup-script    git-sh-setup
+git-status-script      git-status
+git-tag-script git-tag
+git-verify-tag-script  git-verify-tag
+git-http-pull  git-http-fetch
+git-local-pull git-local-fetch
+git-ssh-pull   git-ssh-fetch
+git-checkout-cache     git-checkout-index
+git-diff-cache git-diff-index
+git-merge-cache        git-merge-index
+git-update-cache       git-update-index
+git-ssh-push   git-ssh-upload
+git-convert-cache      git-convert-objects
+git-fsck-cache git-fsck-objects
+EOF
diff --git a/convert-cache.c b/convert-cache.c
deleted file mode 100644 (file)
index 95f0302..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-#define _XOPEN_SOURCE /* glibc2 needs this */
-#include <time.h>
-#include <ctype.h>
-#include "cache.h"
-
-struct entry {
-       unsigned char old_sha1[20];
-       unsigned char new_sha1[20];
-       int converted;
-};
-
-#define MAXOBJECTS (1000000)
-
-static struct entry *convert[MAXOBJECTS];
-static int nr_convert;
-
-static struct entry * convert_entry(unsigned char *sha1);
-
-static struct entry *insert_new(unsigned char *sha1, int pos)
-{
-       struct entry *new = xmalloc(sizeof(struct entry));
-       memset(new, 0, sizeof(*new));
-       memcpy(new->old_sha1, sha1, 20);
-       memmove(convert + pos + 1, convert + pos, (nr_convert - pos) * sizeof(struct entry *));
-       convert[pos] = new;
-       nr_convert++;
-       if (nr_convert == MAXOBJECTS)
-               die("you're kidding me - hit maximum object limit");
-       return new;
-}
-
-static struct entry *lookup_entry(unsigned char *sha1)
-{
-       int low = 0, high = nr_convert;
-
-       while (low < high) {
-               int next = (low + high) / 2;
-               struct entry *n = convert[next];
-               int cmp = memcmp(sha1, n->old_sha1, 20);
-               if (!cmp)
-                       return n;
-               if (cmp < 0) {
-                       high = next;
-                       continue;
-               }
-               low = next+1;
-       }
-       return insert_new(sha1, low);
-}
-
-static void convert_binary_sha1(void *buffer)
-{
-       struct entry *entry = convert_entry(buffer);
-       memcpy(buffer, entry->new_sha1, 20);
-}
-
-static void convert_ascii_sha1(void *buffer)
-{
-       unsigned char sha1[20];
-       struct entry *entry;
-
-       if (get_sha1_hex(buffer, sha1))
-               die("expected sha1, got '%s'", (char*) buffer);
-       entry = convert_entry(sha1);
-       memcpy(buffer, sha1_to_hex(entry->new_sha1), 40);
-}
-
-static unsigned int convert_mode(unsigned int mode)
-{
-       unsigned int newmode;
-
-       newmode = mode & S_IFMT;
-       if (S_ISREG(mode))
-               newmode |= (mode & 0100) ? 0755 : 0644;
-       return newmode;
-}
-
-static int write_subdirectory(void *buffer, unsigned long size, const char *base, int baselen, unsigned char *result_sha1)
-{
-       char *new = xmalloc(size);
-       unsigned long newlen = 0;
-       unsigned long used;
-
-       used = 0;
-       while (size) {
-               int len = 21 + strlen(buffer);
-               char *path = strchr(buffer, ' ');
-               unsigned char *sha1;
-               unsigned int mode;
-               char *slash, *origpath;
-
-               if (!path || sscanf(buffer, "%o", &mode) != 1)
-                       die("bad tree conversion");
-               mode = convert_mode(mode);
-               path++;
-               if (memcmp(path, base, baselen))
-                       break;
-               origpath = path;
-               path += baselen;
-               slash = strchr(path, '/');
-               if (!slash) {
-                       newlen += sprintf(new + newlen, "%o %s", mode, path);
-                       new[newlen++] = '\0';
-                       memcpy(new + newlen, buffer + len - 20, 20);
-                       newlen += 20;
-
-                       used += len;
-                       size -= len;
-                       buffer += len;
-                       continue;
-               }
-
-               newlen += sprintf(new + newlen, "%o %.*s", S_IFDIR, (int)(slash - path), path);
-               new[newlen++] = 0;
-               sha1 = (unsigned char *)(new + newlen);
-               newlen += 20;
-
-               len = write_subdirectory(buffer, size, origpath, slash-origpath+1, sha1);
-
-               used += len;
-               size -= len;
-               buffer += len;
-       }
-
-       write_sha1_file(new, newlen, "tree", result_sha1);
-       free(new);
-       return used;
-}
-
-static void convert_tree(void *buffer, unsigned long size, unsigned char *result_sha1)
-{
-       void *orig_buffer = buffer;
-       unsigned long orig_size = size;
-
-       while (size) {
-               int len = 1+strlen(buffer);
-
-               convert_binary_sha1(buffer + len);
-
-               len += 20;
-               if (len > size)
-                       die("corrupt tree object");
-               size -= len;
-               buffer += len;
-       }
-
-       write_subdirectory(orig_buffer, orig_size, "", 0, result_sha1);
-}
-
-static unsigned long parse_oldstyle_date(const char *buf)
-{
-       char c, *p;
-       char buffer[100];
-       struct tm tm;
-       const char *formats[] = {
-               "%c",
-               "%a %b %d %T",
-               "%Z",
-               "%Y",
-               " %Y",
-               NULL
-       };
-       /* We only ever did two timezones in the bad old format .. */
-       const char *timezones[] = {
-               "PDT", "PST", "CEST", NULL
-       };
-       const char **fmt = formats;
-
-       p = buffer;
-       while (isspace(c = *buf))
-               buf++;
-       while ((c = *buf++) != '\n')
-               *p++ = c;
-       *p++ = 0;
-       buf = buffer;
-       memset(&tm, 0, sizeof(tm));
-       do {
-               const char *next = strptime(buf, *fmt, &tm);
-               if (next) {
-                       if (!*next)
-                               return mktime(&tm);
-                       buf = next;
-               } else {
-                       const char **p = timezones;
-                       while (isspace(*buf))
-                               buf++;
-                       while (*p) {
-                               if (!memcmp(buf, *p, strlen(*p))) {
-                                       buf += strlen(*p);
-                                       break;
-                               }
-                               p++;
-                       }
-               }
-               fmt++;
-       } while (*buf && *fmt);
-       printf("left: %s\n", buf);
-       return mktime(&tm);                             
-}
-
-static int convert_date_line(char *dst, void **buf, unsigned long *sp)
-{
-       unsigned long size = *sp;
-       char *line = *buf;
-       char *next = strchr(line, '\n');
-       char *date = strchr(line, '>');
-       int len;
-
-       if (!next || !date)
-               die("missing or bad author/committer line %s", line);
-       next++; date += 2;
-
-       *buf = next;
-       *sp = size - (next - line);
-
-       len = date - line;
-       memcpy(dst, line, len);
-       dst += len;
-
-       /* Is it already in new format? */
-       if (isdigit(*date)) {
-               int datelen = next - date;
-               memcpy(dst, date, datelen);
-               return len + datelen;
-       }
-
-       /*
-        * Hacky hacky: one of the sparse old-style commits does not have
-        * any date at all, but we can fake it by using the committer date.
-        */
-       if (*date == '\n' && strchr(next, '>'))
-               date = strchr(next, '>')+2;
-
-       return len + sprintf(dst, "%lu -0700\n", parse_oldstyle_date(date));
-}
-
-static void convert_date(void *buffer, unsigned long size, unsigned char *result_sha1)
-{
-       char *new = xmalloc(size + 100);
-       unsigned long newlen = 0;
-       
-       // "tree <sha1>\n"
-       memcpy(new + newlen, buffer, 46);
-       newlen += 46;
-       buffer += 46;
-       size -= 46;
-
-       // "parent <sha1>\n"
-       while (!memcmp(buffer, "parent ", 7)) {
-               memcpy(new + newlen, buffer, 48);
-               newlen += 48;
-               buffer += 48;
-               size -= 48;
-       }
-
-       // "author xyz <xyz> date"
-       newlen += convert_date_line(new + newlen, &buffer, &size);
-       // "committer xyz <xyz> date"
-       newlen += convert_date_line(new + newlen, &buffer, &size);
-
-       // Rest
-       memcpy(new + newlen, buffer, size);
-       newlen += size;
-
-       write_sha1_file(new, newlen, "commit", result_sha1);
-       free(new);      
-}
-
-static void convert_commit(void *buffer, unsigned long size, unsigned char *result_sha1)
-{
-       void *orig_buffer = buffer;
-       unsigned long orig_size = size;
-
-       if (memcmp(buffer, "tree ", 5))
-               die("Bad commit '%s'", (char*) buffer);
-       convert_ascii_sha1(buffer+5);
-       buffer += 46;    /* "tree " + "hex sha1" + "\n" */
-       while (!memcmp(buffer, "parent ", 7)) {
-               convert_ascii_sha1(buffer+7);
-               buffer += 48;
-       }
-       convert_date(orig_buffer, orig_size, result_sha1);
-}
-
-static struct entry * convert_entry(unsigned char *sha1)
-{
-       struct entry *entry = lookup_entry(sha1);
-       char type[20];
-       void *buffer, *data;
-       unsigned long size;
-
-       if (entry->converted)
-               return entry;
-       data = read_sha1_file(sha1, type, &size);
-       if (!data)
-               die("unable to read object %s", sha1_to_hex(sha1));
-
-       buffer = xmalloc(size);
-       memcpy(buffer, data, size);
-       
-       if (!strcmp(type, "blob")) {
-               write_sha1_file(buffer, size, "blob", entry->new_sha1);
-       } else if (!strcmp(type, "tree"))
-               convert_tree(buffer, size, entry->new_sha1);
-       else if (!strcmp(type, "commit"))
-               convert_commit(buffer, size, entry->new_sha1);
-       else
-               die("unknown object type '%s' in %s", type, sha1_to_hex(sha1));
-       entry->converted = 1;
-       free(buffer);
-       free(data);
-       return entry;
-}
-
-int main(int argc, char **argv)
-{
-       unsigned char sha1[20];
-       struct entry *entry;
-
-       if (argc != 2 || get_sha1(argv[1], sha1))
-               usage("git-convert-cache <sha1>");
-
-       entry = convert_entry(sha1);
-       printf("new sha1: %s\n", sha1_to_hex(entry->new_sha1));
-       return 0;
-}
diff --git a/convert-objects.c b/convert-objects.c
new file mode 100644 (file)
index 0000000..9ad0c77
--- /dev/null
@@ -0,0 +1,326 @@
+#define _XOPEN_SOURCE /* glibc2 needs this */
+#include <time.h>
+#include <ctype.h>
+#include "cache.h"
+
+struct entry {
+       unsigned char old_sha1[20];
+       unsigned char new_sha1[20];
+       int converted;
+};
+
+#define MAXOBJECTS (1000000)
+
+static struct entry *convert[MAXOBJECTS];
+static int nr_convert;
+
+static struct entry * convert_entry(unsigned char *sha1);
+
+static struct entry *insert_new(unsigned char *sha1, int pos)
+{
+       struct entry *new = xmalloc(sizeof(struct entry));
+       memset(new, 0, sizeof(*new));
+       memcpy(new->old_sha1, sha1, 20);
+       memmove(convert + pos + 1, convert + pos, (nr_convert - pos) * sizeof(struct entry *));
+       convert[pos] = new;
+       nr_convert++;
+       if (nr_convert == MAXOBJECTS)
+               die("you're kidding me - hit maximum object limit");
+       return new;
+}
+
+static struct entry *lookup_entry(unsigned char *sha1)
+{
+       int low = 0, high = nr_convert;
+
+       while (low < high) {
+               int next = (low + high) / 2;
+               struct entry *n = convert[next];
+               int cmp = memcmp(sha1, n->old_sha1, 20);
+               if (!cmp)
+                       return n;
+               if (cmp < 0) {
+                       high = next;
+                       continue;
+               }
+               low = next+1;
+       }
+       return insert_new(sha1, low);
+}
+
+static void convert_binary_sha1(void *buffer)
+{
+       struct entry *entry = convert_entry(buffer);
+       memcpy(buffer, entry->new_sha1, 20);
+}
+
+static void convert_ascii_sha1(void *buffer)
+{
+       unsigned char sha1[20];
+       struct entry *entry;
+
+       if (get_sha1_hex(buffer, sha1))
+               die("expected sha1, got '%s'", (char*) buffer);
+       entry = convert_entry(sha1);
+       memcpy(buffer, sha1_to_hex(entry->new_sha1), 40);
+}
+
+static unsigned int convert_mode(unsigned int mode)
+{
+       unsigned int newmode;
+
+       newmode = mode & S_IFMT;
+       if (S_ISREG(mode))
+               newmode |= (mode & 0100) ? 0755 : 0644;
+       return newmode;
+}
+
+static int write_subdirectory(void *buffer, unsigned long size, const char *base, int baselen, unsigned char *result_sha1)
+{
+       char *new = xmalloc(size);
+       unsigned long newlen = 0;
+       unsigned long used;
+
+       used = 0;
+       while (size) {
+               int len = 21 + strlen(buffer);
+               char *path = strchr(buffer, ' ');
+               unsigned char *sha1;
+               unsigned int mode;
+               char *slash, *origpath;
+
+               if (!path || sscanf(buffer, "%o", &mode) != 1)
+                       die("bad tree conversion");
+               mode = convert_mode(mode);
+               path++;
+               if (memcmp(path, base, baselen))
+                       break;
+               origpath = path;
+               path += baselen;
+               slash = strchr(path, '/');
+               if (!slash) {
+                       newlen += sprintf(new + newlen, "%o %s", mode, path);
+                       new[newlen++] = '\0';
+                       memcpy(new + newlen, buffer + len - 20, 20);
+                       newlen += 20;
+
+                       used += len;
+                       size -= len;
+                       buffer += len;
+                       continue;
+               }
+
+               newlen += sprintf(new + newlen, "%o %.*s", S_IFDIR, (int)(slash - path), path);
+               new[newlen++] = 0;
+               sha1 = (unsigned char *)(new + newlen);
+               newlen += 20;
+
+               len = write_subdirectory(buffer, size, origpath, slash-origpath+1, sha1);
+
+               used += len;
+               size -= len;
+               buffer += len;
+       }
+
+       write_sha1_file(new, newlen, "tree", result_sha1);
+       free(new);
+       return used;
+}
+
+static void convert_tree(void *buffer, unsigned long size, unsigned char *result_sha1)
+{
+       void *orig_buffer = buffer;
+       unsigned long orig_size = size;
+
+       while (size) {
+               int len = 1+strlen(buffer);
+
+               convert_binary_sha1(buffer + len);
+
+               len += 20;
+               if (len > size)
+                       die("corrupt tree object");
+               size -= len;
+               buffer += len;
+       }
+
+       write_subdirectory(orig_buffer, orig_size, "", 0, result_sha1);
+}
+
+static unsigned long parse_oldstyle_date(const char *buf)
+{
+       char c, *p;
+       char buffer[100];
+       struct tm tm;
+       const char *formats[] = {
+               "%c",
+               "%a %b %d %T",
+               "%Z",
+               "%Y",
+               " %Y",
+               NULL
+       };
+       /* We only ever did two timezones in the bad old format .. */
+       const char *timezones[] = {
+               "PDT", "PST", "CEST", NULL
+       };
+       const char **fmt = formats;
+
+       p = buffer;
+       while (isspace(c = *buf))
+               buf++;
+       while ((c = *buf++) != '\n')
+               *p++ = c;
+       *p++ = 0;
+       buf = buffer;
+       memset(&tm, 0, sizeof(tm));
+       do {
+               const char *next = strptime(buf, *fmt, &tm);
+               if (next) {
+                       if (!*next)
+                               return mktime(&tm);
+                       buf = next;
+               } else {
+                       const char **p = timezones;
+                       while (isspace(*buf))
+                               buf++;
+                       while (*p) {
+                               if (!memcmp(buf, *p, strlen(*p))) {
+                                       buf += strlen(*p);
+                                       break;
+                               }
+                               p++;
+                       }
+               }
+               fmt++;
+       } while (*buf && *fmt);
+       printf("left: %s\n", buf);
+       return mktime(&tm);                             
+}
+
+static int convert_date_line(char *dst, void **buf, unsigned long *sp)
+{
+       unsigned long size = *sp;
+       char *line = *buf;
+       char *next = strchr(line, '\n');
+       char *date = strchr(line, '>');
+       int len;
+
+       if (!next || !date)
+               die("missing or bad author/committer line %s", line);
+       next++; date += 2;
+
+       *buf = next;
+       *sp = size - (next - line);
+
+       len = date - line;
+       memcpy(dst, line, len);
+       dst += len;
+
+       /* Is it already in new format? */
+       if (isdigit(*date)) {
+               int datelen = next - date;
+               memcpy(dst, date, datelen);
+               return len + datelen;
+       }
+
+       /*
+        * Hacky hacky: one of the sparse old-style commits does not have
+        * any date at all, but we can fake it by using the committer date.
+        */
+       if (*date == '\n' && strchr(next, '>'))
+               date = strchr(next, '>')+2;
+
+       return len + sprintf(dst, "%lu -0700\n", parse_oldstyle_date(date));
+}
+
+static void convert_date(void *buffer, unsigned long size, unsigned char *result_sha1)
+{
+       char *new = xmalloc(size + 100);
+       unsigned long newlen = 0;
+       
+       // "tree <sha1>\n"
+       memcpy(new + newlen, buffer, 46);
+       newlen += 46;
+       buffer += 46;
+       size -= 46;
+
+       // "parent <sha1>\n"
+       while (!memcmp(buffer, "parent ", 7)) {
+               memcpy(new + newlen, buffer, 48);
+               newlen += 48;
+               buffer += 48;
+               size -= 48;
+       }
+
+       // "author xyz <xyz> date"
+       newlen += convert_date_line(new + newlen, &buffer, &size);
+       // "committer xyz <xyz> date"
+       newlen += convert_date_line(new + newlen, &buffer, &size);
+
+       // Rest
+       memcpy(new + newlen, buffer, size);
+       newlen += size;
+
+       write_sha1_file(new, newlen, "commit", result_sha1);
+       free(new);      
+}
+
+static void convert_commit(void *buffer, unsigned long size, unsigned char *result_sha1)
+{
+       void *orig_buffer = buffer;
+       unsigned long orig_size = size;
+
+       if (memcmp(buffer, "tree ", 5))
+               die("Bad commit '%s'", (char*) buffer);
+       convert_ascii_sha1(buffer+5);
+       buffer += 46;    /* "tree " + "hex sha1" + "\n" */
+       while (!memcmp(buffer, "parent ", 7)) {
+               convert_ascii_sha1(buffer+7);
+               buffer += 48;
+       }
+       convert_date(orig_buffer, orig_size, result_sha1);
+}
+
+static struct entry * convert_entry(unsigned char *sha1)
+{
+       struct entry *entry = lookup_entry(sha1);
+       char type[20];
+       void *buffer, *data;
+       unsigned long size;
+
+       if (entry->converted)
+               return entry;
+       data = read_sha1_file(sha1, type, &size);
+       if (!data)
+               die("unable to read object %s", sha1_to_hex(sha1));
+
+       buffer = xmalloc(size);
+       memcpy(buffer, data, size);
+       
+       if (!strcmp(type, "blob")) {
+               write_sha1_file(buffer, size, "blob", entry->new_sha1);
+       } else if (!strcmp(type, "tree"))
+               convert_tree(buffer, size, entry->new_sha1);
+       else if (!strcmp(type, "commit"))
+               convert_commit(buffer, size, entry->new_sha1);
+       else
+               die("unknown object type '%s' in %s", type, sha1_to_hex(sha1));
+       entry->converted = 1;
+       free(buffer);
+       free(data);
+       return entry;
+}
+
+int main(int argc, char **argv)
+{
+       unsigned char sha1[20];
+       struct entry *entry;
+
+       if (argc != 2 || get_sha1(argv[1], sha1))
+               usage("git-convert-objects <sha1>");
+
+       entry = convert_entry(sha1);
+       printf("new sha1: %s\n", sha1_to_hex(entry->new_sha1));
+       return 0;
+}
index f3cf358..9ea9e52 100644 (file)
@@ -6,7 +6,7 @@ git-core (0.99.6-0) unstable; urgency=low
 
 git-core (0.99.5-1) unstable; urgency=low
 
-  * Enable git-send-email-script on Debian.  There is no reason to shy
+  * Enable git-send-email on Debian.  There is no reason to shy
     away from it, since we have the necessary Perl modules available.
 
  -- Junio C Hamano <junkio@cox.net>  Thu, 25 Aug 2005 14:16:59 -0700
diff --git a/diff-cache.c b/diff-cache.c
deleted file mode 100644 (file)
index 400a4cb..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
-#include "cache.h"
-#include "diff.h"
-
-static int cached_only = 0;
-static int diff_output_format = DIFF_FORMAT_RAW;
-static int diff_line_termination = '\n';
-static int match_nonexisting = 0;
-static int detect_rename = 0;
-static int find_copies_harder = 0;
-static int diff_setup_opt = 0;
-static int diff_score_opt = 0;
-static const char *pickaxe = NULL;
-static int pickaxe_opts = 0;
-static int diff_break_opt = -1;
-static const char *orderfile = NULL;
-static const char *diff_filter = NULL;
-
-/* A file entry went away or appeared */
-static void show_file(const char *prefix, struct cache_entry *ce, unsigned char *sha1, unsigned int mode)
-{
-       diff_addremove(prefix[0], ntohl(mode), sha1, ce->name, NULL);
-}
-
-static int get_stat_data(struct cache_entry *ce, unsigned char **sha1p, unsigned int *modep)
-{
-       unsigned char *sha1 = ce->sha1;
-       unsigned int mode = ce->ce_mode;
-
-       if (!cached_only) {
-               static unsigned char no_sha1[20];
-               int changed;
-               struct stat st;
-               if (lstat(ce->name, &st) < 0) {
-                       if (errno == ENOENT && match_nonexisting) {
-                               *sha1p = sha1;
-                               *modep = mode;
-                               return 0;
-                       }
-                       return -1;
-               }
-               changed = ce_match_stat(ce, &st);
-               if (changed) {
-                       mode = create_ce_mode(st.st_mode);
-                       sha1 = no_sha1;
-               }
-       }
-
-       *sha1p = sha1;
-       *modep = mode;
-       return 0;
-}
-
-static void show_new_file(struct cache_entry *new)
-{
-       unsigned char *sha1;
-       unsigned int mode;
-
-       /* New file in the index: it might actually be different in the working copy */
-       if (get_stat_data(new, &sha1, &mode) < 0)
-               return;
-
-       show_file("+", new, sha1, mode);
-}
-
-static int show_modified(struct cache_entry *old,
-                        struct cache_entry *new,
-                        int report_missing)
-{
-       unsigned int mode, oldmode;
-       unsigned char *sha1;
-
-       if (get_stat_data(new, &sha1, &mode) < 0) {
-               if (report_missing)
-                       show_file("-", old, old->sha1, old->ce_mode);
-               return -1;
-       }
-
-       oldmode = old->ce_mode;
-       if (mode == oldmode && !memcmp(sha1, old->sha1, 20) &&
-           !find_copies_harder)
-               return 0;
-
-       mode = ntohl(mode);
-       oldmode = ntohl(oldmode);
-
-       diff_change(oldmode, mode,
-                   old->sha1, sha1, old->name, NULL);
-       return 0;
-}
-
-static int diff_cache(struct cache_entry **ac, int entries, const char **pathspec)
-{
-       while (entries) {
-               struct cache_entry *ce = *ac;
-               int same = (entries > 1) && ce_same_name(ce, ac[1]);
-
-               if (!ce_path_match(ce, pathspec))
-                       goto skip_entry;
-
-               switch (ce_stage(ce)) {
-               case 0:
-                       /* No stage 1 entry? That means it's a new file */
-                       if (!same) {
-                               show_new_file(ce);
-                               break;
-                       }
-                       /* Show difference between old and new */
-                       show_modified(ac[1], ce, 1);
-                       break;
-               case 1:
-                       /* No stage 3 (merge) entry? That means it's been deleted */
-                       if (!same) {
-                               show_file("-", ce, ce->sha1, ce->ce_mode);
-                               break;
-                       }
-                       /* We come here with ce pointing at stage 1
-                        * (original tree) and ac[1] pointing at stage
-                        * 3 (unmerged).  show-modified with
-                        * report-mising set to false does not say the
-                        * file is deleted but reports true if work
-                        * tree does not have it, in which case we
-                        * fall through to report the unmerged state.
-                        * Otherwise, we show the differences between
-                        * the original tree and the work tree.
-                        */
-                       if (!cached_only && !show_modified(ce, ac[1], 0))
-                               break;
-                       /* fallthru */
-               case 3:
-                       diff_unmerge(ce->name);
-                       break;
-
-               default:
-                       die("impossible cache entry stage");
-               }
-
-skip_entry:
-               /*
-                * Ignore all the different stages for this file,
-                * we've handled the relevant cases now.
-                */
-               do {
-                       ac++;
-                       entries--;
-               } while (entries && ce_same_name(ce, ac[0]));
-       }
-       return 0;
-}
-
-/*
- * This turns all merge entries into "stage 3". That guarantees that
- * when we read in the new tree (into "stage 1"), we won't lose sight
- * of the fact that we had unmerged entries.
- */
-static void mark_merge_entries(void)
-{
-       int i;
-       for (i = 0; i < active_nr; i++) {
-               struct cache_entry *ce = active_cache[i];
-               if (!ce_stage(ce))
-                       continue;
-               ce->ce_flags |= htons(CE_STAGEMASK);
-       }
-}
-
-static const char diff_cache_usage[] =
-"git-diff-cache [-m] [--cached] "
-"[<common diff options>] <tree-ish> [<path>...]"
-COMMON_DIFF_OPTIONS_HELP;
-
-int main(int argc, char **argv)
-{
-       const char *tree_name = NULL;
-       unsigned char sha1[20];
-       const char *prefix = setup_git_directory();
-       const char **pathspec = NULL;
-       void *tree;
-       unsigned long size;
-       int ret;
-       int allow_options = 1;
-       int i;
-
-       for (i = 1; i < argc; i++) {
-               const char *arg = argv[i];
-
-               if (!allow_options || *arg != '-') {
-                       if (tree_name)
-                               break;
-                       tree_name = arg;
-                       continue;
-               }
-                       
-               if (!strcmp(arg, "--")) {
-                       allow_options = 0;
-                       continue;
-               }
-               if (!strcmp(arg, "-r")) {
-                       /* We accept the -r flag just to look like git-diff-tree */
-                       continue;
-               }
-               /* We accept the -u flag as a synonym for "-p" */
-               if (!strcmp(arg, "-p") || !strcmp(arg, "-u")) {
-                       diff_output_format = DIFF_FORMAT_PATCH;
-                       continue;
-               }
-               if (!strncmp(arg, "-B", 2)) {
-                       if ((diff_break_opt = diff_scoreopt_parse(arg)) == -1)
-                               usage(diff_cache_usage);
-                       continue;
-               }
-               if (!strncmp(arg, "-M", 2)) {
-                       detect_rename = DIFF_DETECT_RENAME;
-                       if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1)
-                               usage(diff_cache_usage);
-                       continue;
-               }
-               if (!strncmp(arg, "-C", 2)) {
-                       detect_rename = DIFF_DETECT_COPY;
-                       if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1)
-                               usage(diff_cache_usage);
-                       continue;
-               }
-               if (!strcmp(arg, "--find-copies-harder")) {
-                       find_copies_harder = 1;
-                       continue;
-               }
-               if (!strcmp(arg, "-z")) {
-                       diff_line_termination = 0;
-                       continue;
-               }
-               if (!strcmp(arg, "--name-only")) {
-                       diff_output_format = DIFF_FORMAT_NAME;
-                       continue;
-               }
-               if (!strcmp(arg, "-R")) {
-                       diff_setup_opt |= DIFF_SETUP_REVERSE;
-                       continue;
-               }
-               if (!strncmp(arg, "-S", 2)) {
-                       pickaxe = arg + 2;
-                       continue;
-               }
-               if (!strncmp(arg, "--diff-filter=", 14)) {
-                       diff_filter = arg + 14;
-                       continue;
-               }
-               if (!strncmp(arg, "-O", 2)) {
-                       orderfile = arg + 2;
-                       continue;
-               }
-               if (!strcmp(arg, "--pickaxe-all")) {
-                       pickaxe_opts = DIFF_PICKAXE_ALL;
-                       continue;
-               }
-               if (!strcmp(arg, "-m")) {
-                       match_nonexisting = 1;
-                       continue;
-               }
-               if (!strcmp(arg, "--cached")) {
-                       cached_only = 1;
-                       continue;
-               }
-               usage(diff_cache_usage);
-       }
-
-       pathspec = get_pathspec(prefix, argv + i);
-
-       if (find_copies_harder && detect_rename != DIFF_DETECT_COPY)
-               usage(diff_cache_usage);
-
-       if (!tree_name || get_sha1(tree_name, sha1))
-               usage(diff_cache_usage);
-
-       read_cache();
-
-       /* The rest is for paths restriction. */
-       diff_setup(diff_setup_opt);
-
-       mark_merge_entries();
-
-       tree = read_object_with_reference(sha1, "tree", &size, NULL);
-       if (!tree)
-               die("bad tree object %s", tree_name);
-       if (read_tree(tree, size, 1, pathspec))
-               die("unable to read tree object %s", tree_name);
-
-       ret = diff_cache(active_cache, active_nr, pathspec);
-
-       diffcore_std(pathspec,
-                    detect_rename, diff_score_opt,
-                    pickaxe, pickaxe_opts,
-                    diff_break_opt,
-                    orderfile, diff_filter);
-       diff_flush(diff_output_format, diff_line_termination);
-       return ret;
-}
diff --git a/diff-index.c b/diff-index.c
new file mode 100644 (file)
index 0000000..bc41d54
--- /dev/null
@@ -0,0 +1,296 @@
+#include "cache.h"
+#include "diff.h"
+
+static int cached_only = 0;
+static int diff_output_format = DIFF_FORMAT_RAW;
+static int diff_line_termination = '\n';
+static int match_nonexisting = 0;
+static int detect_rename = 0;
+static int find_copies_harder = 0;
+static int diff_setup_opt = 0;
+static int diff_score_opt = 0;
+static const char *pickaxe = NULL;
+static int pickaxe_opts = 0;
+static int diff_break_opt = -1;
+static const char *orderfile = NULL;
+static const char *diff_filter = NULL;
+
+/* A file entry went away or appeared */
+static void show_file(const char *prefix, struct cache_entry *ce, unsigned char *sha1, unsigned int mode)
+{
+       diff_addremove(prefix[0], ntohl(mode), sha1, ce->name, NULL);
+}
+
+static int get_stat_data(struct cache_entry *ce, unsigned char **sha1p, unsigned int *modep)
+{
+       unsigned char *sha1 = ce->sha1;
+       unsigned int mode = ce->ce_mode;
+
+       if (!cached_only) {
+               static unsigned char no_sha1[20];
+               int changed;
+               struct stat st;
+               if (lstat(ce->name, &st) < 0) {
+                       if (errno == ENOENT && match_nonexisting) {
+                               *sha1p = sha1;
+                               *modep = mode;
+                               return 0;
+                       }
+                       return -1;
+               }
+               changed = ce_match_stat(ce, &st);
+               if (changed) {
+                       mode = create_ce_mode(st.st_mode);
+                       sha1 = no_sha1;
+               }
+       }
+
+       *sha1p = sha1;
+       *modep = mode;
+       return 0;
+}
+
+static void show_new_file(struct cache_entry *new)
+{
+       unsigned char *sha1;
+       unsigned int mode;
+
+       /* New file in the index: it might actually be different in the working copy */
+       if (get_stat_data(new, &sha1, &mode) < 0)
+               return;
+
+       show_file("+", new, sha1, mode);
+}
+
+static int show_modified(struct cache_entry *old,
+                        struct cache_entry *new,
+                        int report_missing)
+{
+       unsigned int mode, oldmode;
+       unsigned char *sha1;
+
+       if (get_stat_data(new, &sha1, &mode) < 0) {
+               if (report_missing)
+                       show_file("-", old, old->sha1, old->ce_mode);
+               return -1;
+       }
+
+       oldmode = old->ce_mode;
+       if (mode == oldmode && !memcmp(sha1, old->sha1, 20) &&
+           !find_copies_harder)
+               return 0;
+
+       mode = ntohl(mode);
+       oldmode = ntohl(oldmode);
+
+       diff_change(oldmode, mode,
+                   old->sha1, sha1, old->name, NULL);
+       return 0;
+}
+
+static int diff_cache(struct cache_entry **ac, int entries, const char **pathspec)
+{
+       while (entries) {
+               struct cache_entry *ce = *ac;
+               int same = (entries > 1) && ce_same_name(ce, ac[1]);
+
+               if (!ce_path_match(ce, pathspec))
+                       goto skip_entry;
+
+               switch (ce_stage(ce)) {
+               case 0:
+                       /* No stage 1 entry? That means it's a new file */
+                       if (!same) {
+                               show_new_file(ce);
+                               break;
+                       }
+                       /* Show difference between old and new */
+                       show_modified(ac[1], ce, 1);
+                       break;
+               case 1:
+                       /* No stage 3 (merge) entry? That means it's been deleted */
+                       if (!same) {
+                               show_file("-", ce, ce->sha1, ce->ce_mode);
+                               break;
+                       }
+                       /* We come here with ce pointing at stage 1
+                        * (original tree) and ac[1] pointing at stage
+                        * 3 (unmerged).  show-modified with
+                        * report-mising set to false does not say the
+                        * file is deleted but reports true if work
+                        * tree does not have it, in which case we
+                        * fall through to report the unmerged state.
+                        * Otherwise, we show the differences between
+                        * the original tree and the work tree.
+                        */
+                       if (!cached_only && !show_modified(ce, ac[1], 0))
+                               break;
+                       /* fallthru */
+               case 3:
+                       diff_unmerge(ce->name);
+                       break;
+
+               default:
+                       die("impossible cache entry stage");
+               }
+
+skip_entry:
+               /*
+                * Ignore all the different stages for this file,
+                * we've handled the relevant cases now.
+                */
+               do {
+                       ac++;
+                       entries--;
+               } while (entries && ce_same_name(ce, ac[0]));
+       }
+       return 0;
+}
+
+/*
+ * This turns all merge entries into "stage 3". That guarantees that
+ * when we read in the new tree (into "stage 1"), we won't lose sight
+ * of the fact that we had unmerged entries.
+ */
+static void mark_merge_entries(void)
+{
+       int i;
+       for (i = 0; i < active_nr; i++) {
+               struct cache_entry *ce = active_cache[i];
+               if (!ce_stage(ce))
+                       continue;
+               ce->ce_flags |= htons(CE_STAGEMASK);
+       }
+}
+
+static const char diff_cache_usage[] =
+"git-diff-index [-m] [--cached] "
+"[<common diff options>] <tree-ish> [<path>...]"
+COMMON_DIFF_OPTIONS_HELP;
+
+int main(int argc, char **argv)
+{
+       const char *tree_name = NULL;
+       unsigned char sha1[20];
+       const char *prefix = setup_git_directory();
+       const char **pathspec = NULL;
+       void *tree;
+       unsigned long size;
+       int ret;
+       int allow_options = 1;
+       int i;
+
+       for (i = 1; i < argc; i++) {
+               const char *arg = argv[i];
+
+               if (!allow_options || *arg != '-') {
+                       if (tree_name)
+                               break;
+                       tree_name = arg;
+                       continue;
+               }
+                       
+               if (!strcmp(arg, "--")) {
+                       allow_options = 0;
+                       continue;
+               }
+               if (!strcmp(arg, "-r")) {
+                       /* We accept the -r flag just to look like git-diff-tree */
+                       continue;
+               }
+               /* We accept the -u flag as a synonym for "-p" */
+               if (!strcmp(arg, "-p") || !strcmp(arg, "-u")) {
+                       diff_output_format = DIFF_FORMAT_PATCH;
+                       continue;
+               }
+               if (!strncmp(arg, "-B", 2)) {
+                       if ((diff_break_opt = diff_scoreopt_parse(arg)) == -1)
+                               usage(diff_cache_usage);
+                       continue;
+               }
+               if (!strncmp(arg, "-M", 2)) {
+                       detect_rename = DIFF_DETECT_RENAME;
+                       if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1)
+                               usage(diff_cache_usage);
+                       continue;
+               }
+               if (!strncmp(arg, "-C", 2)) {
+                       detect_rename = DIFF_DETECT_COPY;
+                       if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1)
+                               usage(diff_cache_usage);
+                       continue;
+               }
+               if (!strcmp(arg, "--find-copies-harder")) {
+                       find_copies_harder = 1;
+                       continue;
+               }
+               if (!strcmp(arg, "-z")) {
+                       diff_line_termination = 0;
+                       continue;
+               }
+               if (!strcmp(arg, "--name-only")) {
+                       diff_output_format = DIFF_FORMAT_NAME;
+                       continue;
+               }
+               if (!strcmp(arg, "-R")) {
+                       diff_setup_opt |= DIFF_SETUP_REVERSE;
+                       continue;
+               }
+               if (!strncmp(arg, "-S", 2)) {
+                       pickaxe = arg + 2;
+                       continue;
+               }
+               if (!strncmp(arg, "--diff-filter=", 14)) {
+                       diff_filter = arg + 14;
+                       continue;
+               }
+               if (!strncmp(arg, "-O", 2)) {
+                       orderfile = arg + 2;
+                       continue;
+               }
+               if (!strcmp(arg, "--pickaxe-all")) {
+                       pickaxe_opts = DIFF_PICKAXE_ALL;
+                       continue;
+               }
+               if (!strcmp(arg, "-m")) {
+                       match_nonexisting = 1;
+                       continue;
+               }
+               if (!strcmp(arg, "--cached")) {
+                       cached_only = 1;
+                       continue;
+               }
+               usage(diff_cache_usage);
+       }
+
+       pathspec = get_pathspec(prefix, argv + i);
+
+       if (find_copies_harder && detect_rename != DIFF_DETECT_COPY)
+               usage(diff_cache_usage);
+
+       if (!tree_name || get_sha1(tree_name, sha1))
+               usage(diff_cache_usage);
+
+       read_cache();
+
+       /* The rest is for paths restriction. */
+       diff_setup(diff_setup_opt);
+
+       mark_merge_entries();
+
+       tree = read_object_with_reference(sha1, "tree", &size, NULL);
+       if (!tree)
+               die("bad tree object %s", tree_name);
+       if (read_tree(tree, size, 1, pathspec))
+               die("unable to read tree object %s", tree_name);
+
+       ret = diff_cache(active_cache, active_nr, pathspec);
+
+       diffcore_std(pathspec,
+                    detect_rename, diff_score_opt,
+                    pickaxe, pickaxe_opts,
+                    diff_break_opt,
+                    orderfile, diff_filter);
+       diff_flush(diff_output_format, diff_line_termination);
+       return ret;
+}
diff --git a/entry.c b/entry.c
index 15b8fda..b8426db 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -76,7 +76,7 @@ static int write_entry(struct cache_entry *ce, const char *path, struct checkout
        if (!new || strcmp(type, "blob")) {
                if (new)
                        free(new);
-               return error("git-checkout-cache: unable to read sha1 file of %s (%s)",
+               return error("git-checkout-index: unable to read sha1 file of %s (%s)",
                        path, sha1_to_hex(ce->sha1));
        }
        switch (ntohl(ce->ce_mode) & S_IFMT) {
@@ -84,28 +84,28 @@ static int write_entry(struct cache_entry *ce, const char *path, struct checkout
                fd = create_file(path, ntohl(ce->ce_mode));
                if (fd < 0) {
                        free(new);
-                       return error("git-checkout-cache: unable to create file %s (%s)",
+                       return error("git-checkout-index: unable to create file %s (%s)",
                                path, strerror(errno));
                }
                wrote = write(fd, new, size);
                close(fd);
                free(new);
                if (wrote != size)
-                       return error("git-checkout-cache: unable to write file %s", path);
+                       return error("git-checkout-index: unable to write file %s", path);
                break;
        case S_IFLNK:
                memcpy(target, new, size);
                target[size] = '\0';
                if (symlink(target, path)) {
                        free(new);
-                       return error("git-checkout-cache: unable to create symlink %s (%s)",
+                       return error("git-checkout-index: unable to create symlink %s (%s)",
                                path, strerror(errno));
                }
                free(new);
                break;
        default:
                free(new);
-               return error("git-checkout-cache: unknown file mode for %s", path);
+               return error("git-checkout-index: unknown file mode for %s", path);
        }
 
        if (state->refresh_cache) {
@@ -131,7 +131,7 @@ int checkout_entry(struct cache_entry *ce, struct checkout *state)
                        return 0;
                if (!state->force) {
                        if (!state->quiet)
-                               fprintf(stderr, "git-checkout-cache: %s already exists\n", path);
+                               fprintf(stderr, "git-checkout-index: %s already exists\n", path);
                        return 0;
                }
 
diff --git a/fetch.c b/fetch.c
new file mode 100644 (file)
index 0000000..e874538
--- /dev/null
+++ b/fetch.c
@@ -0,0 +1,210 @@
+#include "fetch.h"
+
+#include "cache.h"
+#include "commit.h"
+#include "tree.h"
+#include "tag.h"
+#include "blob.h"
+#include "refs.h"
+
+const char *write_ref = NULL;
+
+const unsigned char *current_ref = NULL;
+
+int get_tree = 0;
+int get_history = 0;
+int get_all = 0;
+int get_verbosely = 0;
+static unsigned char current_commit_sha1[20];
+
+void pull_say(const char *fmt, const char *hex) 
+{
+       if (get_verbosely)
+               fprintf(stderr, fmt, hex);
+}
+
+static void report_missing(const char *what, const unsigned char *missing)
+{
+       char missing_hex[41];
+
+       strcpy(missing_hex, sha1_to_hex(missing));;
+       fprintf(stderr,
+               "Cannot obtain needed %s %s\nwhile processing commit %s.\n",
+               what, missing_hex, sha1_to_hex(current_commit_sha1));
+}
+
+static int make_sure_we_have_it(const char *what, unsigned char *sha1)
+{
+       int status = 0;
+
+       if (!has_sha1_file(sha1)) {
+               status = fetch(sha1);
+               if (status && what)
+                       report_missing(what, sha1);
+       }
+       return status;
+}
+
+static int process(unsigned char *sha1, const char *type);
+
+static int process_tree(struct tree *tree)
+{
+       struct tree_entry_list *entries;
+
+       if (parse_tree(tree))
+               return -1;
+
+       for (entries = tree->entries; entries; entries = entries->next) {
+               if (process(entries->item.any->sha1,
+                           entries->directory ? tree_type : blob_type))
+                       return -1;
+       }
+       return 0;
+}
+
+static int process_commit(struct commit *commit)
+{
+       if (parse_commit(commit))
+               return -1;
+
+       memcpy(current_commit_sha1, commit->object.sha1, 20);
+
+       if (get_tree) {
+               if (process(commit->tree->object.sha1, tree_type))
+                       return -1;
+               if (!get_all)
+                       get_tree = 0;
+       }
+       if (get_history) {
+               struct commit_list *parents = commit->parents;
+               for (; parents; parents = parents->next) {
+                       if (has_sha1_file(parents->item->object.sha1))
+                               continue;
+                       if (process(parents->item->object.sha1,
+                                   commit_type))
+                               return -1;
+               }
+       }
+       return 0;
+}
+
+static int process_tag(struct tag *tag)
+{
+       if (parse_tag(tag))
+               return -1;
+       return process(tag->tagged->sha1, NULL);
+}
+
+static struct object_list *process_queue = NULL;
+static struct object_list **process_queue_end = &process_queue;
+
+static int process_object(struct object *obj)
+{
+       if (obj->type == commit_type) {
+               if (process_commit((struct commit *)obj))
+                       return -1;
+               return 0;
+       }
+       if (obj->type == tree_type) {
+               if (process_tree((struct tree *)obj))
+                       return -1;
+               return 0;
+       }
+       if (obj->type == blob_type) {
+               return 0;
+       }
+       if (obj->type == tag_type) {
+               if (process_tag((struct tag *)obj))
+                       return -1;
+               return 0;
+       }
+       return error("Unable to determine requirements "
+                    "of type %s for %s",
+                    obj->type, sha1_to_hex(obj->sha1));
+}
+
+static int process(unsigned char *sha1, const char *type)
+{
+       struct object *obj = lookup_object_type(sha1, type);
+       if (has_sha1_file(sha1)) {
+               parse_object(sha1);
+               /* We already have it, so we should scan it now. */
+               return process_object(obj);
+       }
+       if (object_list_contains(process_queue, obj))
+               return 0;
+       object_list_insert(obj, process_queue_end);
+       process_queue_end = &(*process_queue_end)->next;
+
+       //fprintf(stderr, "prefetch %s\n", sha1_to_hex(sha1));
+       prefetch(sha1);
+               
+       return 0;
+}
+
+static int loop(void)
+{
+       while (process_queue) {
+               struct object *obj = process_queue->item;
+               /*
+               fprintf(stderr, "%d objects to pull\n", 
+                       object_list_length(process_queue));
+               */
+               process_queue = process_queue->next;
+               if (!process_queue)
+                       process_queue_end = &process_queue;
+
+               //fprintf(stderr, "fetch %s\n", sha1_to_hex(obj->sha1));
+               
+               if (make_sure_we_have_it(obj->type ? obj->type : "object", 
+                                        obj->sha1))
+                       return -1;
+               if (!obj->type)
+                       parse_object(obj->sha1);
+               if (process_object(obj))
+                       return -1;
+       }
+       return 0;
+}
+
+static int interpret_target(char *target, unsigned char *sha1)
+{
+       if (!get_sha1_hex(target, sha1))
+               return 0;
+       if (!check_ref_format(target)) {
+               if (!fetch_ref(target, sha1)) {
+                       return 0;
+               }
+       }
+       return -1;
+}
+
+
+int pull(char *target)
+{
+       unsigned char sha1[20];
+       int fd = -1;
+
+       if (write_ref && current_ref) {
+               fd = lock_ref_sha1(write_ref, current_ref);
+               if (fd < 0)
+                       return -1;
+       }
+
+       if (interpret_target(target, sha1))
+               return error("Could not interpret %s as something to pull",
+                            target);
+       if (process(sha1, NULL))
+               return -1;
+       if (loop())
+               return -1;
+       
+       if (write_ref) {
+               if (current_ref) {
+                       write_ref_sha1(write_ref, fd, sha1);
+               } else {
+                       write_ref_sha1_unlocked(write_ref, sha1);
+               }
+       }
+       return 0;
+}
diff --git a/fetch.h b/fetch.h
new file mode 100644 (file)
index 0000000..e7710e8
--- /dev/null
+++ b/fetch.h
@@ -0,0 +1,48 @@
+#ifndef PULL_H
+#define PULL_H
+
+/*
+ * Fetch object given SHA1 from the remote, and store it locally under
+ * GIT_OBJECT_DIRECTORY.  Return 0 on success, -1 on failure.  To be
+ * provided by the particular implementation.
+ */
+extern int fetch(unsigned char *sha1);
+
+/*
+ * Fetch the specified object and store it locally; fetch() will be
+ * called later to determine success. To be provided by the particular
+ * implementation.
+ */
+extern void prefetch(unsigned char *sha1);
+
+/*
+ * Fetch ref (relative to $GIT_DIR/refs) from the remote, and store
+ * the 20-byte SHA1 in sha1.  Return 0 on success, -1 on failure.  To
+ * be provided by the particular implementation.
+ */
+extern int fetch_ref(char *ref, unsigned char *sha1);
+
+/* If set, the ref filename to write the target value to. */
+extern const char *write_ref;
+
+/* If set, the hash that the current value of write_ref must be. */
+extern const unsigned char *current_ref;
+
+/* Set to fetch the target tree. */
+extern int get_tree;
+
+/* Set to fetch the commit history. */
+extern int get_history;
+
+/* Set to fetch the trees in the commit history. */
+extern int get_all;
+
+/* Set to be verbose */
+extern int get_verbosely;
+
+/* Report what we got under get_verbosely */
+extern void pull_say(const char *, const char *);
+
+extern int pull(char *target);
+
+#endif /* PULL_H */
diff --git a/fsck-cache.c b/fsck-cache.c
deleted file mode 100644 (file)
index e53d01a..0000000
+++ /dev/null
@@ -1,537 +0,0 @@
-#include <sys/types.h>
-#include <dirent.h>
-
-#include "cache.h"
-#include "commit.h"
-#include "tree.h"
-#include "blob.h"
-#include "tag.h"
-#include "refs.h"
-#include "pack.h"
-
-#define REACHABLE 0x0001
-
-static int show_root = 0;
-static int show_tags = 0;
-static int show_unreachable = 0;
-static int standalone = 0;
-static int check_full = 0;
-static int check_strict = 0;
-static int keep_cache_objects = 0; 
-static unsigned char head_sha1[20];
-
-static void check_connectivity(void)
-{
-       int i;
-
-       /* Look up all the requirements, warn about missing objects.. */
-       for (i = 0; i < nr_objs; i++) {
-               struct object *obj = objs[i];
-               struct object_list *refs;
-
-               if (!obj->parsed) {
-                       if (!standalone && has_sha1_file(obj->sha1))
-                               ; /* it is in pack */
-                       else
-                               printf("missing %s %s\n",
-                                      obj->type, sha1_to_hex(obj->sha1));
-                       continue;
-               }
-
-               for (refs = obj->refs; refs; refs = refs->next) {
-                       if (refs->item->parsed ||
-                           (!standalone && has_sha1_file(refs->item->sha1)))
-                               continue;
-                       printf("broken link from %7s %s\n",
-                              obj->type, sha1_to_hex(obj->sha1));
-                       printf("              to %7s %s\n",
-                              refs->item->type, sha1_to_hex(refs->item->sha1));
-               }
-
-               if (show_unreachable && !(obj->flags & REACHABLE)) {
-                       printf("unreachable %s %s\n",
-                              obj->type, sha1_to_hex(obj->sha1));
-                       continue;
-               }
-
-               if (!obj->used) {
-                       printf("dangling %s %s\n", obj->type, 
-                              sha1_to_hex(obj->sha1));
-               }
-       }
-}
-
-/*
- * The entries in a tree are ordered in the _path_ order,
- * which means that a directory entry is ordered by adding
- * a slash to the end of it.
- *
- * So a directory called "a" is ordered _after_ a file
- * called "a.c", because "a/" sorts after "a.c".
- */
-#define TREE_UNORDERED (-1)
-#define TREE_HAS_DUPS  (-2)
-
-static int verify_ordered(struct tree_entry_list *a, struct tree_entry_list *b)
-{
-       int len1 = strlen(a->name);
-       int len2 = strlen(b->name);
-       int len = len1 < len2 ? len1 : len2;
-       unsigned char c1, c2;
-       int cmp;
-
-       cmp = memcmp(a->name, b->name, len);
-       if (cmp < 0)
-               return 0;
-       if (cmp > 0)
-               return TREE_UNORDERED;
-
-       /*
-        * Ok, the first <len> characters are the same.
-        * Now we need to order the next one, but turn
-        * a '\0' into a '/' for a directory entry.
-        */
-       c1 = a->name[len];
-       c2 = b->name[len];
-       if (!c1 && !c2)
-               /*
-                * git-write-tree used to write out a nonsense tree that has
-                * entries with the same name, one blob and one tree.  Make
-                * sure we do not have duplicate entries.
-                */
-               return TREE_HAS_DUPS;
-       if (!c1 && a->directory)
-               c1 = '/';
-       if (!c2 && b->directory)
-               c2 = '/';
-       return c1 < c2 ? 0 : TREE_UNORDERED;
-}
-
-static int fsck_tree(struct tree *item)
-{
-       int retval;
-       int has_full_path = 0;
-       int has_zero_pad = 0;
-       int has_bad_modes = 0;
-       int has_dup_entries = 0;
-       int not_properly_sorted = 0;
-       struct tree_entry_list *entry, *last;
-
-       last = NULL;
-       for (entry = item->entries; entry; entry = entry->next) {
-               if (strchr(entry->name, '/'))
-                       has_full_path = 1;
-               has_zero_pad |= entry->zeropad;
-
-               switch (entry->mode) {
-               /*
-                * Standard modes.. 
-                */
-               case S_IFREG | 0755:
-               case S_IFREG | 0644:
-               case S_IFLNK:
-               case S_IFDIR:
-                       break;
-               /*
-                * This is nonstandard, but we had a few of these
-                * early on when we honored the full set of mode
-                * bits..
-                */
-               case S_IFREG | 0664:
-                       if (!check_strict)
-                               break;
-               default:
-                       has_bad_modes = 1;
-               }
-
-               if (last) {
-                       switch (verify_ordered(last, entry)) {
-                       case TREE_UNORDERED:
-                               not_properly_sorted = 1;
-                               break;
-                       case TREE_HAS_DUPS:
-                               has_dup_entries = 1;
-                               break;
-                       default:
-                               break;
-                       }
-               }
-
-               last = entry;
-       }
-
-       retval = 0;
-       if (has_full_path) {
-               fprintf(stderr, "warning: git-fsck-cache: tree %s "
-                       "has full pathnames in it\n", 
-                       sha1_to_hex(item->object.sha1));
-       }
-       if (has_zero_pad) {
-               fprintf(stderr, "warning: git-fsck-cache: tree %s "
-                       "has zero-padded file modes in it\n",
-                       sha1_to_hex(item->object.sha1));
-       }
-       if (has_bad_modes) {
-               fprintf(stderr, "warning: git-fsck-cache: tree %s "
-                       "has bad file modes in it\n",
-                       sha1_to_hex(item->object.sha1));
-       }
-       if (has_dup_entries) {
-               fprintf(stderr, "error: git-fsck-cache: tree %s "
-                       "has duplicate file entries\n",
-                       sha1_to_hex(item->object.sha1));
-               retval = -1;
-       }
-       if (not_properly_sorted) {
-               fprintf(stderr, "error: git-fsck-cache: tree %s "
-                       "is not properly sorted\n",
-                       sha1_to_hex(item->object.sha1));
-               retval = -1;
-       }
-       return retval;
-}
-
-static int fsck_commit(struct commit *commit)
-{
-       char *buffer = commit->buffer;
-       unsigned char sha1[20];
-
-       if (memcmp(buffer, "tree ", 5))
-               return -1;
-       if (get_sha1_hex(buffer+5, sha1) || buffer[45] != '\n')
-               return -1;
-       buffer += 46;
-       while (!memcmp(buffer, "parent ", 7)) {
-               if (get_sha1_hex(buffer+7, sha1) || buffer[47] != '\n')
-                       return -1;
-               buffer += 48;
-       }
-       if (memcmp(buffer, "author ", 7))
-               return -1;
-       free(commit->buffer);
-       commit->buffer = NULL;
-       if (!commit->tree)
-               return -1;
-       if (!commit->parents && show_root)
-               printf("root %s\n", sha1_to_hex(commit->object.sha1));
-       if (!commit->date)
-               printf("bad commit date in %s\n", 
-                      sha1_to_hex(commit->object.sha1));
-       return 0;
-}
-
-static int fsck_tag(struct tag *tag)
-{
-       struct object *tagged = tag->tagged;
-
-       if (!tagged) {
-               printf("bad object in tag %s\n", sha1_to_hex(tag->object.sha1));
-               return -1;
-       }
-       if (!show_tags)
-               return 0;
-
-       printf("tagged %s %s", tagged->type, sha1_to_hex(tagged->sha1));
-       printf(" (%s) in %s\n", tag->tag, sha1_to_hex(tag->object.sha1));
-       return 0;
-}
-
-static int fsck_sha1(unsigned char *sha1)
-{
-       struct object *obj = parse_object(sha1);
-       if (!obj)
-               return -1;
-       if (obj->type == blob_type)
-               return 0;
-       if (obj->type == tree_type)
-               return fsck_tree((struct tree *) obj);
-       if (obj->type == commit_type)
-               return fsck_commit((struct commit *) obj);
-       if (obj->type == tag_type)
-               return fsck_tag((struct tag *) obj);
-       return -1;
-}
-
-/*
- * This is the sorting chunk size: make it reasonably
- * big so that we can sort well..
- */
-#define MAX_SHA1_ENTRIES (1024)
-
-struct sha1_entry {
-       unsigned long ino;
-       unsigned char sha1[20];
-};
-
-static struct {
-       unsigned long nr;
-       struct sha1_entry *entry[MAX_SHA1_ENTRIES];
-} sha1_list;
-
-static int ino_compare(const void *_a, const void *_b)
-{
-       const struct sha1_entry *a = _a, *b = _b;
-       unsigned long ino1 = a->ino, ino2 = b->ino;
-       return ino1 < ino2 ? -1 : ino1 > ino2 ? 1 : 0;
-}
-
-static void fsck_sha1_list(void)
-{
-       int i, nr = sha1_list.nr;
-
-       qsort(sha1_list.entry, nr, sizeof(struct sha1_entry *), ino_compare);
-       for (i = 0; i < nr; i++) {
-               struct sha1_entry *entry = sha1_list.entry[i];
-               unsigned char *sha1 = entry->sha1;
-
-               sha1_list.entry[i] = NULL;
-               if (fsck_sha1(sha1) < 0)
-                       fprintf(stderr, "bad sha1 entry '%s'\n", sha1_to_hex(sha1));
-               free(entry);
-       }
-       sha1_list.nr = 0;
-}
-
-static void add_sha1_list(unsigned char *sha1, unsigned long ino)
-{
-       struct sha1_entry *entry = xmalloc(sizeof(*entry));
-       int nr;
-
-       entry->ino = ino;
-       memcpy(entry->sha1, sha1, 20);
-       nr = sha1_list.nr;
-       if (nr == MAX_SHA1_ENTRIES) {
-               fsck_sha1_list();
-               nr = 0;
-       }
-       sha1_list.entry[nr] = entry;
-       sha1_list.nr = ++nr;
-}
-
-static int fsck_dir(int i, char *path)
-{
-       DIR *dir = opendir(path);
-       struct dirent *de;
-
-       if (!dir) {
-               return error("missing sha1 directory '%s'", path);
-       }
-
-       while ((de = readdir(dir)) != NULL) {
-               char name[100];
-               unsigned char sha1[20];
-               int len = strlen(de->d_name);
-
-               switch (len) {
-               case 2:
-                       if (de->d_name[1] != '.')
-                               break;
-               case 1:
-                       if (de->d_name[0] != '.')
-                               break;
-                       continue;
-               case 38:
-                       sprintf(name, "%02x", i);
-                       memcpy(name+2, de->d_name, len+1);
-                       if (get_sha1_hex(name, sha1) < 0)
-                               break;
-                       add_sha1_list(sha1, de->d_ino);
-                       continue;
-               }
-               fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);
-       }
-       closedir(dir);
-       return 0;
-}
-
-static int default_refs = 0;
-
-static int fsck_handle_ref(const char *refname, const unsigned char *sha1)
-{
-       struct object *obj;
-
-       obj = lookup_object(sha1);
-       if (!obj) {
-               if (!standalone && has_sha1_file(sha1)) {
-                       default_refs++;
-                       return 0; /* it is in a pack */
-               }
-               error("%s: invalid sha1 pointer %s", refname, sha1_to_hex(sha1));
-               /* We'll continue with the rest despite the error.. */
-               return 0;
-       }
-       default_refs++;
-       obj->used = 1;
-       mark_reachable(obj, REACHABLE);
-       return 0;
-}
-
-static void get_default_heads(void)
-{
-       for_each_ref(fsck_handle_ref);
-       if (!default_refs)
-               die("No default references");
-}
-
-static void fsck_object_dir(const char *path)
-{
-       int i;
-       for (i = 0; i < 256; i++) {
-               static char dir[4096];
-               sprintf(dir, "%s/%02x", path, i);
-               fsck_dir(i, dir);
-       }
-       fsck_sha1_list();
-}
-
-static int fsck_head_link(void)
-{
-       int fd, count;
-       char hex[40];
-       unsigned char sha1[20];
-       static char path[PATH_MAX], link[PATH_MAX];
-       const char *git_dir;
-
-       git_dir = gitenv(GIT_DIR_ENVIRONMENT);
-       if (!git_dir) git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
-
-       snprintf(path, sizeof(path), "%s/HEAD", git_dir);
-       if (readlink(path, link, sizeof(link)) < 0)
-               return error("HEAD is not a symlink");
-       if (strncmp("refs/heads/", link, 11))
-               return error("HEAD points to something strange (%s)", link);
-       fd = open(path, O_RDONLY);
-       if (fd < 0)
-               return error("HEAD: %s", strerror(errno));
-       count = read(fd, hex, sizeof(hex));
-       close(fd);
-       if (count < 0)
-               return error("HEAD: %s", strerror(errno));
-       if (count < 40 || get_sha1_hex(hex, sha1))
-               return error("HEAD: not a valid git pointer");
-       return 0;
-}
-
-int main(int argc, char **argv)
-{
-       int i, heads;
-
-       for (i = 1; i < argc; i++) {
-               const char *arg = argv[i];
-
-               if (!strcmp(arg, "--unreachable")) {
-                       show_unreachable = 1;
-                       continue;
-               }
-               if (!strcmp(arg, "--tags")) {
-                       show_tags = 1;
-                       continue;
-               }
-               if (!strcmp(arg, "--root")) {
-                       show_root = 1;
-                       continue;
-               }
-               if (!strcmp(arg, "--cache")) {
-                       keep_cache_objects = 1;
-                       continue;
-               }
-               if (!strcmp(arg, "--standalone")) {
-                       standalone = 1;
-                       continue;
-               }
-               if (!strcmp(arg, "--full")) {
-                       check_full = 1;
-                       continue;
-               }
-               if (!strcmp(arg, "--strict")) {
-                       check_strict = 1;
-                       continue;
-               }
-               if (*arg == '-')
-                       usage("git-fsck-cache [--tags] [--root] [[--unreachable] [--cache] [--standalone | --full] [--strict] <head-sha1>*]");
-       }
-
-       if (standalone && check_full)
-               die("Only one of --standalone or --full can be used.");
-       if (standalone)
-               putenv("GIT_ALTERNATE_OBJECT_DIRECTORIES=");
-
-       fsck_head_link();
-       fsck_object_dir(get_object_directory());
-       if (check_full) {
-               struct alternate_object_database *alt;
-               struct packed_git *p;
-               prepare_alt_odb();
-               for (alt = alt_odb_list; alt; alt = alt->next) {
-                       char namebuf[PATH_MAX];
-                       int namelen = alt->name - alt->base;
-                       memcpy(namebuf, alt->base, namelen);
-                       namebuf[namelen - 1] = 0;
-                       fsck_object_dir(namebuf);
-               }
-               prepare_packed_git();
-               for (p = packed_git; p; p = p->next)
-                       /* verify gives error messages itself */
-                       verify_pack(p, 0);
-
-               for (p = packed_git; p; p = p->next) {
-                       int num = num_packed_objects(p);
-                       for (i = 0; i < num; i++) {
-                               unsigned char sha1[20];
-                               nth_packed_object_sha1(p, i, sha1);
-                               if (fsck_sha1(sha1) < 0)
-                                       fprintf(stderr, "bad sha1 entry '%s'\n", sha1_to_hex(sha1));
-
-                       }
-               }
-       }
-
-       heads = 0;
-       for (i = 1; i < argc; i++) {
-               const char *arg = argv[i]; 
-
-               if (*arg == '-')
-                       continue;
-
-               if (!get_sha1(arg, head_sha1)) {
-                       struct object *obj = lookup_object(head_sha1);
-
-                       /* Error is printed by lookup_object(). */
-                       if (!obj)
-                               continue;
-
-                       obj->used = 1;
-                       mark_reachable(obj, REACHABLE);
-                       heads++;
-                       continue;
-               }
-               error("expected sha1, got %s", arg);
-       }
-
-       /*
-        * If we've not been given any explicit head information, do the
-        * default ones from .git/refs. We also consider the index file
-        * in this case (ie this implies --cache).
-        */
-       if (!heads) {
-               get_default_heads();
-               keep_cache_objects = 1;
-       }
-
-       if (keep_cache_objects) {
-               int i;
-               read_cache();
-               for (i = 0; i < active_nr; i++) {
-                       struct blob *blob = lookup_blob(active_cache[i]->sha1);
-                       struct object *obj;
-                       if (!blob)
-                               continue;
-                       obj = &blob->object;
-                       obj->used = 1;
-                       mark_reachable(obj, REACHABLE);
-               }
-       }
-
-       check_connectivity();
-       return 0;
-}
diff --git a/fsck-objects.c b/fsck-objects.c
new file mode 100644 (file)
index 0000000..43d188a
--- /dev/null
@@ -0,0 +1,537 @@
+#include <sys/types.h>
+#include <dirent.h>
+
+#include "cache.h"
+#include "commit.h"
+#include "tree.h"
+#include "blob.h"
+#include "tag.h"
+#include "refs.h"
+#include "pack.h"
+
+#define REACHABLE 0x0001
+
+static int show_root = 0;
+static int show_tags = 0;
+static int show_unreachable = 0;
+static int standalone = 0;
+static int check_full = 0;
+static int check_strict = 0;
+static int keep_cache_objects = 0; 
+static unsigned char head_sha1[20];
+
+static void check_connectivity(void)
+{
+       int i;
+
+       /* Look up all the requirements, warn about missing objects.. */
+       for (i = 0; i < nr_objs; i++) {
+               struct object *obj = objs[i];
+               struct object_list *refs;
+
+               if (!obj->parsed) {
+                       if (!standalone && has_sha1_file(obj->sha1))
+                               ; /* it is in pack */
+                       else
+                               printf("missing %s %s\n",
+                                      obj->type, sha1_to_hex(obj->sha1));
+                       continue;
+               }
+
+               for (refs = obj->refs; refs; refs = refs->next) {
+                       if (refs->item->parsed ||
+                           (!standalone && has_sha1_file(refs->item->sha1)))
+                               continue;
+                       printf("broken link from %7s %s\n",
+                              obj->type, sha1_to_hex(obj->sha1));
+                       printf("              to %7s %s\n",
+                              refs->item->type, sha1_to_hex(refs->item->sha1));
+               }
+
+               if (show_unreachable && !(obj->flags & REACHABLE)) {
+                       printf("unreachable %s %s\n",
+                              obj->type, sha1_to_hex(obj->sha1));
+                       continue;
+               }
+
+               if (!obj->used) {
+                       printf("dangling %s %s\n", obj->type, 
+                              sha1_to_hex(obj->sha1));
+               }
+       }
+}
+
+/*
+ * The entries in a tree are ordered in the _path_ order,
+ * which means that a directory entry is ordered by adding
+ * a slash to the end of it.
+ *
+ * So a directory called "a" is ordered _after_ a file
+ * called "a.c", because "a/" sorts after "a.c".
+ */
+#define TREE_UNORDERED (-1)
+#define TREE_HAS_DUPS  (-2)
+
+static int verify_ordered(struct tree_entry_list *a, struct tree_entry_list *b)
+{
+       int len1 = strlen(a->name);
+       int len2 = strlen(b->name);
+       int len = len1 < len2 ? len1 : len2;
+       unsigned char c1, c2;
+       int cmp;
+
+       cmp = memcmp(a->name, b->name, len);
+       if (cmp < 0)
+               return 0;
+       if (cmp > 0)
+               return TREE_UNORDERED;
+
+       /*
+        * Ok, the first <len> characters are the same.
+        * Now we need to order the next one, but turn
+        * a '\0' into a '/' for a directory entry.
+        */
+       c1 = a->name[len];
+       c2 = b->name[len];
+       if (!c1 && !c2)
+               /*
+                * git-write-tree used to write out a nonsense tree that has
+                * entries with the same name, one blob and one tree.  Make
+                * sure we do not have duplicate entries.
+                */
+               return TREE_HAS_DUPS;
+       if (!c1 && a->directory)
+               c1 = '/';
+       if (!c2 && b->directory)
+               c2 = '/';
+       return c1 < c2 ? 0 : TREE_UNORDERED;
+}
+
+static int fsck_tree(struct tree *item)
+{
+       int retval;
+       int has_full_path = 0;
+       int has_zero_pad = 0;
+       int has_bad_modes = 0;
+       int has_dup_entries = 0;
+       int not_properly_sorted = 0;
+       struct tree_entry_list *entry, *last;
+
+       last = NULL;
+       for (entry = item->entries; entry; entry = entry->next) {
+               if (strchr(entry->name, '/'))
+                       has_full_path = 1;
+               has_zero_pad |= entry->zeropad;
+
+               switch (entry->mode) {
+               /*
+                * Standard modes.. 
+                */
+               case S_IFREG | 0755:
+               case S_IFREG | 0644:
+               case S_IFLNK:
+               case S_IFDIR:
+                       break;
+               /*
+                * This is nonstandard, but we had a few of these
+                * early on when we honored the full set of mode
+                * bits..
+                */
+               case S_IFREG | 0664:
+                       if (!check_strict)
+                               break;
+               default:
+                       has_bad_modes = 1;
+               }
+
+               if (last) {
+                       switch (verify_ordered(last, entry)) {
+                       case TREE_UNORDERED:
+                               not_properly_sorted = 1;
+                               break;
+                       case TREE_HAS_DUPS:
+                               has_dup_entries = 1;
+                               break;
+                       default:
+                               break;
+                       }
+               }
+
+               last = entry;
+       }
+
+       retval = 0;
+       if (has_full_path) {
+               fprintf(stderr, "warning: git-fsck-objects: tree %s "
+                       "has full pathnames in it\n", 
+                       sha1_to_hex(item->object.sha1));
+       }
+       if (has_zero_pad) {
+               fprintf(stderr, "warning: git-fsck-objects: tree %s "
+                       "has zero-padded file modes in it\n",
+                       sha1_to_hex(item->object.sha1));
+       }
+       if (has_bad_modes) {
+               fprintf(stderr, "warning: git-fsck-objects: tree %s "
+                       "has bad file modes in it\n",
+                       sha1_to_hex(item->object.sha1));
+       }
+       if (has_dup_entries) {
+               fprintf(stderr, "error: git-fsck-objects: tree %s "
+                       "has duplicate file entries\n",
+                       sha1_to_hex(item->object.sha1));
+               retval = -1;
+       }
+       if (not_properly_sorted) {
+               fprintf(stderr, "error: git-fsck-objects: tree %s "
+                       "is not properly sorted\n",
+                       sha1_to_hex(item->object.sha1));
+               retval = -1;
+       }
+       return retval;
+}
+
+static int fsck_commit(struct commit *commit)
+{
+       char *buffer = commit->buffer;
+       unsigned char sha1[20];
+
+       if (memcmp(buffer, "tree ", 5))
+               return -1;
+       if (get_sha1_hex(buffer+5, sha1) || buffer[45] != '\n')
+               return -1;
+       buffer += 46;
+       while (!memcmp(buffer, "parent ", 7)) {
+               if (get_sha1_hex(buffer+7, sha1) || buffer[47] != '\n')
+                       return -1;
+               buffer += 48;
+       }
+       if (memcmp(buffer, "author ", 7))
+               return -1;
+       free(commit->buffer);
+       commit->buffer = NULL;
+       if (!commit->tree)
+               return -1;
+       if (!commit->parents && show_root)
+               printf("root %s\n", sha1_to_hex(commit->object.sha1));
+       if (!commit->date)
+               printf("bad commit date in %s\n", 
+                      sha1_to_hex(commit->object.sha1));
+       return 0;
+}
+
+static int fsck_tag(struct tag *tag)
+{
+       struct object *tagged = tag->tagged;
+
+       if (!tagged) {
+               printf("bad object in tag %s\n", sha1_to_hex(tag->object.sha1));
+               return -1;
+       }
+       if (!show_tags)
+               return 0;
+
+       printf("tagged %s %s", tagged->type, sha1_to_hex(tagged->sha1));
+       printf(" (%s) in %s\n", tag->tag, sha1_to_hex(tag->object.sha1));
+       return 0;
+}
+
+static int fsck_sha1(unsigned char *sha1)
+{
+       struct object *obj = parse_object(sha1);
+       if (!obj)
+               return -1;
+       if (obj->type == blob_type)
+               return 0;
+       if (obj->type == tree_type)
+               return fsck_tree((struct tree *) obj);
+       if (obj->type == commit_type)
+               return fsck_commit((struct commit *) obj);
+       if (obj->type == tag_type)
+               return fsck_tag((struct tag *) obj);
+       return -1;
+}
+
+/*
+ * This is the sorting chunk size: make it reasonably
+ * big so that we can sort well..
+ */
+#define MAX_SHA1_ENTRIES (1024)
+
+struct sha1_entry {
+       unsigned long ino;
+       unsigned char sha1[20];
+};
+
+static struct {
+       unsigned long nr;
+       struct sha1_entry *entry[MAX_SHA1_ENTRIES];
+} sha1_list;
+
+static int ino_compare(const void *_a, const void *_b)
+{
+       const struct sha1_entry *a = _a, *b = _b;
+       unsigned long ino1 = a->ino, ino2 = b->ino;
+       return ino1 < ino2 ? -1 : ino1 > ino2 ? 1 : 0;
+}
+
+static void fsck_sha1_list(void)
+{
+       int i, nr = sha1_list.nr;
+
+       qsort(sha1_list.entry, nr, sizeof(struct sha1_entry *), ino_compare);
+       for (i = 0; i < nr; i++) {
+               struct sha1_entry *entry = sha1_list.entry[i];
+               unsigned char *sha1 = entry->sha1;
+
+               sha1_list.entry[i] = NULL;
+               if (fsck_sha1(sha1) < 0)
+                       fprintf(stderr, "bad sha1 entry '%s'\n", sha1_to_hex(sha1));
+               free(entry);
+       }
+       sha1_list.nr = 0;
+}
+
+static void add_sha1_list(unsigned char *sha1, unsigned long ino)
+{
+       struct sha1_entry *entry = xmalloc(sizeof(*entry));
+       int nr;
+
+       entry->ino = ino;
+       memcpy(entry->sha1, sha1, 20);
+       nr = sha1_list.nr;
+       if (nr == MAX_SHA1_ENTRIES) {
+               fsck_sha1_list();
+               nr = 0;
+       }
+       sha1_list.entry[nr] = entry;
+       sha1_list.nr = ++nr;
+}
+
+static int fsck_dir(int i, char *path)
+{
+       DIR *dir = opendir(path);
+       struct dirent *de;
+
+       if (!dir) {
+               return error("missing sha1 directory '%s'", path);
+       }
+
+       while ((de = readdir(dir)) != NULL) {
+               char name[100];
+               unsigned char sha1[20];
+               int len = strlen(de->d_name);
+
+               switch (len) {
+               case 2:
+                       if (de->d_name[1] != '.')
+                               break;
+               case 1:
+                       if (de->d_name[0] != '.')
+                               break;
+                       continue;
+               case 38:
+                       sprintf(name, "%02x", i);
+                       memcpy(name+2, de->d_name, len+1);
+                       if (get_sha1_hex(name, sha1) < 0)
+                               break;
+                       add_sha1_list(sha1, de->d_ino);
+                       continue;
+               }
+               fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);
+       }
+       closedir(dir);
+       return 0;
+}
+
+static int default_refs = 0;
+
+static int fsck_handle_ref(const char *refname, const unsigned char *sha1)
+{
+       struct object *obj;
+
+       obj = lookup_object(sha1);
+       if (!obj) {
+               if (!standalone && has_sha1_file(sha1)) {
+                       default_refs++;
+                       return 0; /* it is in a pack */
+               }
+               error("%s: invalid sha1 pointer %s", refname, sha1_to_hex(sha1));
+               /* We'll continue with the rest despite the error.. */
+               return 0;
+       }
+       default_refs++;
+       obj->used = 1;
+       mark_reachable(obj, REACHABLE);
+       return 0;
+}
+
+static void get_default_heads(void)
+{
+       for_each_ref(fsck_handle_ref);
+       if (!default_refs)
+               die("No default references");
+}
+
+static void fsck_object_dir(const char *path)
+{
+       int i;
+       for (i = 0; i < 256; i++) {
+               static char dir[4096];
+               sprintf(dir, "%s/%02x", path, i);
+               fsck_dir(i, dir);
+       }
+       fsck_sha1_list();
+}
+
+static int fsck_head_link(void)
+{
+       int fd, count;
+       char hex[40];
+       unsigned char sha1[20];
+       static char path[PATH_MAX], link[PATH_MAX];
+       const char *git_dir;
+
+       git_dir = gitenv(GIT_DIR_ENVIRONMENT);
+       if (!git_dir) git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
+
+       snprintf(path, sizeof(path), "%s/HEAD", git_dir);
+       if (readlink(path, link, sizeof(link)) < 0)
+               return error("HEAD is not a symlink");
+       if (strncmp("refs/heads/", link, 11))
+               return error("HEAD points to something strange (%s)", link);
+       fd = open(path, O_RDONLY);
+       if (fd < 0)
+               return error("HEAD: %s", strerror(errno));
+       count = read(fd, hex, sizeof(hex));
+       close(fd);
+       if (count < 0)
+               return error("HEAD: %s", strerror(errno));
+       if (count < 40 || get_sha1_hex(hex, sha1))
+               return error("HEAD: not a valid git pointer");
+       return 0;
+}
+
+int main(int argc, char **argv)
+{
+       int i, heads;
+
+       for (i = 1; i < argc; i++) {
+               const char *arg = argv[i];
+
+               if (!strcmp(arg, "--unreachable")) {
+                       show_unreachable = 1;
+                       continue;
+               }
+               if (!strcmp(arg, "--tags")) {
+                       show_tags = 1;
+                       continue;
+               }
+               if (!strcmp(arg, "--root")) {
+                       show_root = 1;
+                       continue;
+               }
+               if (!strcmp(arg, "--cache")) {
+                       keep_cache_objects = 1;
+                       continue;
+               }
+               if (!strcmp(arg, "--standalone")) {
+                       standalone = 1;
+                       continue;
+               }
+               if (!strcmp(arg, "--full")) {
+                       check_full = 1;
+                       continue;
+               }
+               if (!strcmp(arg, "--strict")) {
+                       check_strict = 1;
+                       continue;
+               }
+               if (*arg == '-')
+                       usage("git-fsck-objects [--tags] [--root] [[--unreachable] [--cache] [--standalone | --full] [--strict] <head-sha1>*]");
+       }
+
+       if (standalone && check_full)
+               die("Only one of --standalone or --full can be used.");
+       if (standalone)
+               putenv("GIT_ALTERNATE_OBJECT_DIRECTORIES=");
+
+       fsck_head_link();
+       fsck_object_dir(get_object_directory());
+       if (check_full) {
+               struct alternate_object_database *alt;
+               struct packed_git *p;
+               prepare_alt_odb();
+               for (alt = alt_odb_list; alt; alt = alt->next) {
+                       char namebuf[PATH_MAX];
+                       int namelen = alt->name - alt->base;
+                       memcpy(namebuf, alt->base, namelen);
+                       namebuf[namelen - 1] = 0;
+                       fsck_object_dir(namebuf);
+               }
+               prepare_packed_git();
+               for (p = packed_git; p; p = p->next)
+                       /* verify gives error messages itself */
+                       verify_pack(p, 0);
+
+               for (p = packed_git; p; p = p->next) {
+                       int num = num_packed_objects(p);
+                       for (i = 0; i < num; i++) {
+                               unsigned char sha1[20];
+                               nth_packed_object_sha1(p, i, sha1);
+                               if (fsck_sha1(sha1) < 0)
+                                       fprintf(stderr, "bad sha1 entry '%s'\n", sha1_to_hex(sha1));
+
+                       }
+               }
+       }
+
+       heads = 0;
+       for (i = 1; i < argc; i++) {
+               const char *arg = argv[i]; 
+
+               if (*arg == '-')
+                       continue;
+
+               if (!get_sha1(arg, head_sha1)) {
+                       struct object *obj = lookup_object(head_sha1);
+
+                       /* Error is printed by lookup_object(). */
+                       if (!obj)
+                               continue;
+
+                       obj->used = 1;
+                       mark_reachable(obj, REACHABLE);
+                       heads++;
+                       continue;
+               }
+               error("expected sha1, got %s", arg);
+       }
+
+       /*
+        * If we've not been given any explicit head information, do the
+        * default ones from .git/refs. We also consider the index file
+        * in this case (ie this implies --cache).
+        */
+       if (!heads) {
+               get_default_heads();
+               keep_cache_objects = 1;
+       }
+
+       if (keep_cache_objects) {
+               int i;
+               read_cache();
+               for (i = 0; i < active_nr; i++) {
+                       struct blob *blob = lookup_blob(active_cache[i]->sha1);
+                       struct object *obj;
+                       if (!blob)
+                               continue;
+                       obj = &blob->object;
+                       obj->used = 1;
+                       mark_reachable(obj, REACHABLE);
+               }
+       }
+
+       check_connectivity();
+       return 0;
+}
diff --git a/git b/git
deleted file mode 100755 (executable)
index 476aeec..0000000
--- a/git
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-cmd=
-path=$(dirname $0)
-case "$#" in
-0)     ;;
-*)     cmd="$1"
-       shift
-       test -x $path/git-$cmd-script && exec $path/git-$cmd-script "$@"
-       test -x $path/git-$cmd && exec $path/git-$cmd "$@" ;;
-esac
-
-echo "Usage: git COMMAND [OPTIONS] [TARGET]"
-if [ -n "$cmd" ]; then
-    echo " git command '$cmd' not found: commands are:"
-else
-    echo " git commands are:"
-fi
-
-ls $path | sed -ne 's/^git-\(.*\)-script/  \1/p' | fmt
diff --git a/git-add-script b/git-add-script
deleted file mode 100755 (executable)
index 61ec040..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-git-update-cache --add -- "$@"
diff --git a/git-add.sh b/git-add.sh
new file mode 100755 (executable)
index 0000000..7d91eeb
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+git-update-index --add -- "$@"
diff --git a/git-applymbox b/git-applymbox
deleted file mode 100755 (executable)
index e58bb21..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/bin/sh
-##
-## "dotest" is my stupid name for my patch-application script, which
-## I never got around to renaming after I tested it. We're now on the
-## second generation of scripts, still called "dotest".
-##
-## Update: Ryan Anderson finally shamed me into naming this "applymbox".
-##
-## You give it a mbox-format collection of emails, and it will try to
-## apply them to the kernel using "applypatch"
-##
-## applymbox [-u] [-k] [-q] (-c .dotest/msg-number | mail_archive) [Signoff_file]"
-##
-## The patch application may fail in the middle.  In which case:
-## (1) look at .dotest/patch and fix it up to apply
-## (2) re-run applymbox with -c .dotest/msg-number for the current one.
-## Pay a special attention to the commit log message if you do this and
-## use a Signoff_file, because applypatch wants to append the sign-off
-## message to msg-clean every time it is run.
-
-. git-sh-setup-script || die "Not a git archive"
-
-usage () {
-    echo >&2 "applymbox [-u] [-k] [-q] (-c .dotest/<num> | mbox) [signoff]"
-    exit 1
-}
-
-keep_subject= query_apply= continue= utf8= resume=t
-while case "$#" in 0) break ;; esac
-do
-       case "$1" in
-       -u)     utf8=-u ;;
-       -k)     keep_subject=-k ;;
-       -q)     query_apply=t ;;
-       -c)     continue="$2"; resume=f; shift ;;
-       -*)     usage ;;
-       *)      break ;;
-       esac
-       shift
-done
-
-case "$continue" in
-'')
-       rm -rf .dotest
-       mkdir .dotest
-       git-mailsplit "$1" .dotest || exit 1
-       shift
-esac
-
-files=$(git-diff-cache --cached --name-only HEAD) || exit
-if [ "$files" ]; then
-   echo "Dirty index: cannot apply patches (dirty: $files)" >&2
-   exit 1
-fi
-
-case "$query_apply" in
-t)     touch .dotest/.query_apply
-esac
-case "$keep_subject" in
--k)    : >.dotest/.keep_subject
-esac
-
-signoff="$1"
-set x .dotest/0*
-shift
-while case "$#" in 0) break;; esac
-do
-    i="$1" 
-    case "$resume,$continue" in
-    f,$i)      resume=t;;
-    f,*)       shift
-               continue;;
-    *)
-           git-mailinfo $keep_subject $utf8 \
-               .dotest/msg .dotest/patch <$i >.dotest/info || exit 1
-           git-stripspace < .dotest/msg > .dotest/msg-clean
-           ;;
-    esac
-    while :; # for fixing up and retry
-    do
-       git-applypatch .dotest/msg-clean .dotest/patch .dotest/info "$signoff"
-       case "$?" in
-       0 | 2 )
-               # 2 is a special exit code from applypatch to indicate that
-               # the patch wasn't applied, but continue anyway 
-               ;;
-       *)
-               ret=$?
-               if test -f .dotest/.query_apply
-               then
-                       echo >&2 "* Patch failed."
-                       echo >&2 "* You could fix it up in your editor and"
-                       echo >&2 "  retry.  If you want to do so, say yes here"
-                       echo >&2 "  AFTER fixing .dotest/patch up."
-                       echo >&2 -n "Retry [y/N]? "
-                       read yesno
-                       case "$yesno" in
-                       [Yy]*)
-                               continue ;;
-                       esac
-               fi
-               exit $ret
-       esac
-       break
-    done
-    shift
-done
-# return to pristine
-rm -fr .dotest
diff --git a/git-applymbox.sh b/git-applymbox.sh
new file mode 100755 (executable)
index 0000000..e2bfd02
--- /dev/null
@@ -0,0 +1,109 @@
+#!/bin/sh
+##
+## "dotest" is my stupid name for my patch-application script, which
+## I never got around to renaming after I tested it. We're now on the
+## second generation of scripts, still called "dotest".
+##
+## Update: Ryan Anderson finally shamed me into naming this "applymbox".
+##
+## You give it a mbox-format collection of emails, and it will try to
+## apply them to the kernel using "applypatch"
+##
+## applymbox [-u] [-k] [-q] (-c .dotest/msg-number | mail_archive) [Signoff_file]"
+##
+## The patch application may fail in the middle.  In which case:
+## (1) look at .dotest/patch and fix it up to apply
+## (2) re-run applymbox with -c .dotest/msg-number for the current one.
+## Pay a special attention to the commit log message if you do this and
+## use a Signoff_file, because applypatch wants to append the sign-off
+## message to msg-clean every time it is run.
+
+. git-sh-setup || die "Not a git archive"
+
+usage () {
+    echo >&2 "applymbox [-u] [-k] [-q] (-c .dotest/<num> | mbox) [signoff]"
+    exit 1
+}
+
+keep_subject= query_apply= continue= utf8= resume=t
+while case "$#" in 0) break ;; esac
+do
+       case "$1" in
+       -u)     utf8=-u ;;
+       -k)     keep_subject=-k ;;
+       -q)     query_apply=t ;;
+       -c)     continue="$2"; resume=f; shift ;;
+       -*)     usage ;;
+       *)      break ;;
+       esac
+       shift
+done
+
+case "$continue" in
+'')
+       rm -rf .dotest
+       mkdir .dotest
+       git-mailsplit "$1" .dotest || exit 1
+       shift
+esac
+
+files=$(git-diff-index --cached --name-only HEAD) || exit
+if [ "$files" ]; then
+   echo "Dirty index: cannot apply patches (dirty: $files)" >&2
+   exit 1
+fi
+
+case "$query_apply" in
+t)     touch .dotest/.query_apply
+esac
+case "$keep_subject" in
+-k)    : >.dotest/.keep_subject
+esac
+
+signoff="$1"
+set x .dotest/0*
+shift
+while case "$#" in 0) break;; esac
+do
+    i="$1" 
+    case "$resume,$continue" in
+    f,$i)      resume=t;;
+    f,*)       shift
+               continue;;
+    *)
+           git-mailinfo $keep_subject $utf8 \
+               .dotest/msg .dotest/patch <$i >.dotest/info || exit 1
+           git-stripspace < .dotest/msg > .dotest/msg-clean
+           ;;
+    esac
+    while :; # for fixing up and retry
+    do
+       git-applypatch .dotest/msg-clean .dotest/patch .dotest/info "$signoff"
+       case "$?" in
+       0 | 2 )
+               # 2 is a special exit code from applypatch to indicate that
+               # the patch wasn't applied, but continue anyway 
+               ;;
+       *)
+               ret=$?
+               if test -f .dotest/.query_apply
+               then
+                       echo >&2 "* Patch failed."
+                       echo >&2 "* You could fix it up in your editor and"
+                       echo >&2 "  retry.  If you want to do so, say yes here"
+                       echo >&2 "  AFTER fixing .dotest/patch up."
+                       echo >&2 -n "Retry [y/N]? "
+                       read yesno
+                       case "$yesno" in
+                       [Yy]*)
+                               continue ;;
+                       esac
+               fi
+               exit $ret
+       esac
+       break
+    done
+    shift
+done
+# return to pristine
+rm -fr .dotest
diff --git a/git-applypatch b/git-applypatch
deleted file mode 100755 (executable)
index e5bc3c0..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/bin/sh
-##
-## applypatch takes four file arguments, and uses those to
-## apply the unpacked patch (surprise surprise) that they
-## represent to the current tree.
-##
-## The arguments are:
-##     $1 - file with commit message
-##     $2 - file with the actual patch
-##     $3 - "info" file with Author, email and subject
-##     $4 - optional file containing signoff to add
-##
-. git-sh-setup-script || die "Not a git archive."
-
-final=.dotest/final-commit
-##
-## If this file exists, we ask before applying
-##
-query_apply=.dotest/.query_apply
-
-## We do not munge the first line of the commit message too much
-## if this file exists.
-keep_subject=.dotest/.keep_subject
-
-
-MSGFILE=$1
-PATCHFILE=$2
-INFO=$3
-SIGNOFF=$4
-EDIT=${VISUAL:-${EDITOR:-vi}}
-
-export GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' .dotest/info)"
-export GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' .dotest/info)"
-export GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' .dotest/info)"
-export SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' .dotest/info)"
-
-if test '' != "$SIGNOFF"
-then
-       if test -f "$SIGNOFF"
-       then
-               SIGNOFF=`cat "$SIGNOFF"` || exit
-       elif case "$SIGNOFF" in yes | true | me | please) : ;; *) false ;; esac
-       then
-               SIGNOFF=`git-var GIT_COMMITTER_IDENT | sed -e '
-                               s/>.*/>/
-                               s/^/Signed-off-by: /'
-               `
-       else
-               SIGNOFF=
-       fi
-       if test '' != "$SIGNOFF"
-       then
-               LAST_SIGNED_OFF_BY=`
-                       sed -ne '/^Signed-off-by: /p' "$MSGFILE" |
-                       tail -n 1
-               `
-               test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" ||
-               echo "$SIGNOFF" >>"$MSGFILE"
-       fi
-fi
-
-patch_header=
-test -f "$keep_subject" || patch_header='[PATCH] '
-
-{
-       echo "$patch_header$SUBJECT"
-       if test -s "$MSGFILE"
-       then
-               echo
-               cat "$MSGFILE"
-       fi
-} >"$final"
-
-interactive=yes
-test -f "$query_apply" || interactive=no
-
-while [ "$interactive" = yes ]; do
-       echo "Commit Body is:"
-       echo "--------------------------"
-       cat "$final"
-       echo "--------------------------"
-       echo -n "Apply? [y]es/[n]o/[e]dit/[a]ccept all "
-       read reply
-       case "$reply" in
-               y|Y) interactive=no;;
-               n|N) exit 2;;   # special value to tell dotest to keep going
-               e|E) "$EDIT" "$final";;
-               a|A) rm -f "$query_apply"
-                    interactive=no ;;
-       esac
-done
-
-if test -x "$GIT_DIR"/hooks/applypatch-msg
-then
-       "$GIT_DIR"/hooks/applypatch-msg "$final" || exit
-fi
-
-echo
-echo Applying "'$SUBJECT'"
-echo
-
-git-apply --index "$PATCHFILE" || exit 1
-
-if test -x "$GIT_DIR"/hooks/pre-applypatch
-then
-       "$GIT_DIR"/hooks/pre-applypatch || exit
-fi
-
-tree=$(git-write-tree) || exit 1
-echo Wrote tree $tree
-commit=$(git-commit-tree $tree -p $(cat "$GIT_DIR"/HEAD) < "$final") || exit 1
-echo Committed: $commit
-echo $commit > "$GIT_DIR"/HEAD
-
-if test -x "$GIT_DIR"/hooks/post-applypatch
-then
-       "$GIT_DIR"/hooks/post-applypatch
-fi
diff --git a/git-applypatch.sh b/git-applypatch.sh
new file mode 100755 (executable)
index 0000000..fd594ed
--- /dev/null
@@ -0,0 +1,118 @@
+#!/bin/sh
+##
+## applypatch takes four file arguments, and uses those to
+## apply the unpacked patch (surprise surprise) that they
+## represent to the current tree.
+##
+## The arguments are:
+##     $1 - file with commit message
+##     $2 - file with the actual patch
+##     $3 - "info" file with Author, email and subject
+##     $4 - optional file containing signoff to add
+##
+. git-sh-setup || die "Not a git archive."
+
+final=.dotest/final-commit
+##
+## If this file exists, we ask before applying
+##
+query_apply=.dotest/.query_apply
+
+## We do not munge the first line of the commit message too much
+## if this file exists.
+keep_subject=.dotest/.keep_subject
+
+
+MSGFILE=$1
+PATCHFILE=$2
+INFO=$3
+SIGNOFF=$4
+EDIT=${VISUAL:-${EDITOR:-vi}}
+
+export GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' .dotest/info)"
+export GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' .dotest/info)"
+export GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' .dotest/info)"
+export SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' .dotest/info)"
+
+if test '' != "$SIGNOFF"
+then
+       if test -f "$SIGNOFF"
+       then
+               SIGNOFF=`cat "$SIGNOFF"` || exit
+       elif case "$SIGNOFF" in yes | true | me | please) : ;; *) false ;; esac
+       then
+               SIGNOFF=`git-var GIT_COMMITTER_IDENT | sed -e '
+                               s/>.*/>/
+                               s/^/Signed-off-by: /'
+               `
+       else
+               SIGNOFF=
+       fi
+       if test '' != "$SIGNOFF"
+       then
+               LAST_SIGNED_OFF_BY=`
+                       sed -ne '/^Signed-off-by: /p' "$MSGFILE" |
+                       tail -n 1
+               `
+               test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" ||
+               echo "$SIGNOFF" >>"$MSGFILE"
+       fi
+fi
+
+patch_header=
+test -f "$keep_subject" || patch_header='[PATCH] '
+
+{
+       echo "$patch_header$SUBJECT"
+       if test -s "$MSGFILE"
+       then
+               echo
+               cat "$MSGFILE"
+       fi
+} >"$final"
+
+interactive=yes
+test -f "$query_apply" || interactive=no
+
+while [ "$interactive" = yes ]; do
+       echo "Commit Body is:"
+       echo "--------------------------"
+       cat "$final"
+       echo "--------------------------"
+       echo -n "Apply? [y]es/[n]o/[e]dit/[a]ccept all "
+       read reply
+       case "$reply" in
+               y|Y) interactive=no;;
+               n|N) exit 2;;   # special value to tell dotest to keep going
+               e|E) "$EDIT" "$final";;
+               a|A) rm -f "$query_apply"
+                    interactive=no ;;
+       esac
+done
+
+if test -x "$GIT_DIR"/hooks/applypatch-msg
+then
+       "$GIT_DIR"/hooks/applypatch-msg "$final" || exit
+fi
+
+echo
+echo Applying "'$SUBJECT'"
+echo
+
+git-apply --index "$PATCHFILE" || exit 1
+
+if test -x "$GIT_DIR"/hooks/pre-applypatch
+then
+       "$GIT_DIR"/hooks/pre-applypatch || exit
+fi
+
+tree=$(git-write-tree) || exit 1
+echo Wrote tree $tree
+commit=$(git-commit-tree $tree -p $(cat "$GIT_DIR"/HEAD) < "$final") || exit 1
+echo Committed: $commit
+echo $commit > "$GIT_DIR"/HEAD
+
+if test -x "$GIT_DIR"/hooks/post-applypatch
+then
+       "$GIT_DIR"/hooks/post-applypatch
+fi
diff --git a/git-archimport-script b/git-archimport-script
deleted file mode 100755 (executable)
index 8f475fd..0000000
+++ /dev/null
@@ -1,604 +0,0 @@
-#!/usr/bin/perl -w
-#
-# This tool is copyright (c) 2005, Martin Langhoff.
-# It is released under the Gnu Public License, version 2.
-#
-# The basic idea is to walk the output of tla abrowse, 
-# fetch the changesets and apply them. 
-#
-=head1 Invocation
-
-    git-archimport-script -i <archive>/<branch> [<archive>/<branch>]
-    [ <archive>/<branch> ]
-
-    The script expects you to provide the key roots where it can start the
-    import from an 'initial import' or 'tag' type of Arch commit. It will
-    then follow all the branching and tagging within the provided roots.
-
-    It will die if it sees branches that have different roots. 
-
-=head2 TODO
-
- - keep track of merged patches, and mark a git merge when it happens
- - smarter rules to parse the archive history "up" and "down"
- - be able to continue an import where we left off
- - audit shell-escaping of filenames
-
-=head1 Devel tricks
-
-Add print in front of the shell commands invoked via backticks. 
-
-=cut
-
-use strict;
-use warnings;
-use Getopt::Std;
-use File::Spec;
-use File::Temp qw(tempfile);
-use File::Path qw(mkpath);
-use File::Basename qw(basename dirname);
-use String::ShellQuote;
-use Time::Local;
-use IO::Socket;
-use IO::Pipe;
-use POSIX qw(strftime dup2);
-use Data::Dumper qw/ Dumper /;
-use IPC::Open2;
-
-$SIG{'PIPE'}="IGNORE";
-$ENV{'TZ'}="UTC";
-
-our($opt_h,$opt_v, $opt_T,
-    $opt_C,$opt_t);
-
-sub usage() {
-    print STDERR <<END;
-Usage: ${\basename $0}     # fetch/update GIT from Arch
-       [ -h ] [ -v ] [ -T ] 
-       [ -C GIT_repository ] [ -t tempdir ] 
-       repository/arch-branch [ repository/arch-branch] ...
-END
-    exit(1);
-}
-
-getopts("hviC:t:") or usage();
-usage if $opt_h;
-
-@ARGV >= 1 or usage();
-my @arch_roots = @ARGV;
-
-my $tmp = $opt_t;
-$tmp ||= '/tmp';
-$tmp .= '/git-archimport/';
-
-my $git_tree = $opt_C;
-$git_tree ||= ".";
-
-
-my @psets  = ();                # the collection
-
-foreach my $root (@arch_roots) {
-    my ($arepo, $abranch) = split(m!/!, $root);
-    open ABROWSE, "tla abrowse -f -A $arepo --desc --merges $abranch |" 
-        or die "Problems with tla abrowse: $!";
-    
-    my %ps        = ();         # the current one
-    my $mode      = '';
-    my $lastseen  = '';
-    
-    while (<ABROWSE>) {
-        chomp;
-        
-        # first record padded w 8 spaces
-        if (s/^\s{8}\b//) {
-            
-            # store the record we just captured
-            if (%ps) {
-                my %temp = %ps; # break references
-                push (@psets, \%temp);
-                %ps = ();
-            }
-            
-            my ($id, $type) = split(m/\s{3}/, $_);
-            $ps{id}   = $id;
-            $ps{repo} = $arepo;
-
-            # deal with types
-            if ($type =~ m/^\(simple changeset\)/) {
-                $ps{type} = 's';
-            } elsif ($type eq '(initial import)') {
-                $ps{type} = 'i';
-            } elsif ($type =~ m/^\(tag revision of (.+)\)/) {
-                $ps{type} = 't';
-                $ps{tag}  = $1;
-            } else { 
-                warn "Unknown type $type";
-            }
-            $lastseen = 'id';
-        }
-        
-        if (s/^\s{10}//) { 
-            # 10 leading spaces or more 
-            # indicate commit metadata
-            
-            # date & author 
-            if ($lastseen eq 'id' && m/^\d{4}-\d{2}-\d{2}/) {
-                
-                my ($date, $authoremail) = split(m/\s{2,}/, $_);
-                $ps{date}   = $date;
-                $ps{date}   =~ s/\bGMT$//; # strip off trailign GMT
-                if ($ps{date} =~ m/\b\w+$/) {
-                    warn 'Arch dates not in GMT?! - imported dates will be wrong';
-                }
-            
-                $authoremail =~ m/^(.+)\s(\S+)$/;
-                $ps{author} = $1;
-                $ps{email}  = $2;
-            
-                $lastseen = 'date';
-            
-            } elsif ($lastseen eq 'date') {
-                # the only hint is position
-                # subject is after date
-                $ps{subj} = $_;
-                $lastseen = 'subj';
-            
-            } elsif ($lastseen eq 'subj' && $_ eq 'merges in:') {
-                $ps{merges} = [];
-                $lastseen = 'merges';
-            
-            } elsif ($lastseen eq 'merges' && s/^\s{2}//) {
-                push (@{$ps{merges}}, $_);
-            } else {
-                warn 'more metadata after merges!?';
-            }
-            
-        }
-    }
-
-    if (%ps) {
-        my %temp = %ps;         # break references
-        push (@psets, \%temp);
-        %ps = ();
-    }    
-    close ABROWSE;
-}                               # end foreach $root
-
-## Order patches by time
-@psets = sort {$a->{date}.$b->{id} cmp $b->{date}.$b->{id}} @psets;
-
-#print Dumper \@psets;
-
-##
-## TODO cleanup irrelevant patches
-##      and put an initial import
-##      or a full tag
-my $import = 0;
-unless (-d '.git') { # initial import
-    if ($psets[0]{type} eq 'i' || $psets[0]{type} eq 't') {
-        print "Starting import from $psets[0]{id}\n";
-       `git-init-db`;
-       die $! if $?;
-       $import = 1;
-    } else {
-        die "Need to start from an import or a tag -- cannot use $psets[0]{id}";
-    }
-}
-
-# process patchsets
-foreach my $ps (@psets) {
-
-    $ps->{branch} =  branchname($ps->{id});
-
-    #
-    # ensure we have a clean state 
-    # 
-    if (`git diff-files`) {
-        die "Unclean tree when about to process $ps->{id} " .
-            " - did we fail to commit cleanly before?";
-    }
-    die $! if $?;
-
-    #
-    # skip commits already in repo
-    #
-    if (ptag($ps->{id})) {
-      $opt_v && print "Skipping already imported: $ps->{id}\n";
-      next;
-    }
-
-    # 
-    # create the branch if needed
-    #
-    if ($ps->{type} eq 'i' && !$import) {
-        die "Should not have more than one 'Initial import' per GIT import: $ps->{id}";
-    }
-
-    unless ($import) { # skip for import
-        if ( -e ".git/refs/heads/$ps->{branch}") {
-            # we know about this branch
-            `git checkout    $ps->{branch}`;
-        } else {
-            # new branch! we need to verify a few things
-            die "Branch on a non-tag!" unless $ps->{type} eq 't';
-            my $branchpoint = ptag($ps->{tag});
-            die "Tagging from unknown id unsupported: $ps->{tag}" 
-                unless $branchpoint;
-            
-            # find where we are supposed to branch from
-            `git checkout -b $ps->{branch} $branchpoint`;
-
-            # If we trust Arch with the fact that this is just 
-            # a tag, and it does not affect the state of the tree
-            # then we just tag and move on
-            tag($ps->{id}, $branchpoint);
-            ptag($ps->{id}, $branchpoint);
-            print " * Tagged $ps->{id} at $branchpoint\n";
-            next;
-        } 
-        die $! if $?;
-    } 
-
-    #
-    # Apply the import/changeset/merge into the working tree
-    # 
-    if ($ps->{type} eq 'i' || $ps->{type} eq 't') {
-        apply_import($ps) or die $!;
-        $import=0;
-    } elsif ($ps->{type} eq 's') {
-        apply_cset($ps);
-    }
-
-    #
-    # prepare update git's index, based on what arch knows
-    # about the pset, resolve parents, etc
-    #
-    my $tree;
-    
-    my $commitlog = `tla cat-archive-log -A $ps->{repo} $ps->{id}`; 
-    die "Error in cat-archive-log: $!" if $?;
-        
-    # parselog will git-add/rm files
-    # and generally prepare things for the commit
-    # NOTE: parselog will shell-quote filenames! 
-    my ($sum, $msg, $add, $del, $mod, $ren) = parselog($commitlog);
-    my $logmessage = "$sum\n$msg";
-
-
-    # imports don't give us good info
-    # on added files. Shame on them
-    if ($ps->{type} eq 'i' || $ps->{type} eq 't') { 
-        `find . -type f -print0 | grep -zv '^./.git' | xargs -0 -l100 git-update-cache --add`;
-        `git-ls-files --deleted -z | xargs --no-run-if-empty -0 -l100 git-update-cache --remove`; 
-    }
-
-    if (@$add) {
-        while (@$add) {
-            my @slice = splice(@$add, 0, 100);
-            my $slice = join(' ', @slice);          
-            `git-update-cache --add $slice`;
-            die "Error in git-update-cache --add: $!" if $?;
-        }
-    }
-    if (@$del) {
-        foreach my $file (@$del) {
-            unlink $file or die "Problems deleting $file : $!";
-        }
-        while (@$del) {
-            my @slice = splice(@$del, 0, 100);
-            my $slice = join(' ', @slice);
-            `git-update-cache --remove $slice`;
-            die "Error in git-update-cache --remove: $!" if $?;
-        }
-    }
-    if (@$ren) {                # renamed
-        if (@$ren % 2) {
-            die "Odd number of entries in rename!?";
-        }
-        ;
-        while (@$ren) {
-            my $from = pop @$ren;
-            my $to   = pop @$ren;           
-
-            unless (-d dirname($to)) {
-                mkpath(dirname($to)); # will die on err
-            }
-            #print "moving $from $to";
-            `mv $from $to`;
-            die "Error renaming $from $to : $!" if $?;
-            `git-update-cache --remove $from`;
-            die "Error in git-update-cache --remove: $!" if $?;
-            `git-update-cache --add $to`;
-            die "Error in git-update-cache --add: $!" if $?;
-        }
-
-    }
-    if (@$mod) {                # must be _after_ renames
-        while (@$mod) {
-            my @slice = splice(@$mod, 0, 100);
-            my $slice = join(' ', @slice);
-            `git-update-cache $slice`;
-            die "Error in git-update-cache: $!" if $?;
-        }
-    }
-
-    # warn "errors when running git-update-cache! $!";
-    $tree = `git-write-tree`;
-    die "cannot write tree $!" if $?;
-    chomp $tree;
-        
-    
-    #
-    # Who's your daddy?
-    #
-    my @par;
-    if ( -e ".git/refs/heads/$ps->{branch}") {
-        if (open HEAD, "<.git/refs/heads/$ps->{branch}") {
-            my $p = <HEAD>;
-            close HEAD;
-            chomp $p;
-            push @par, '-p', $p;
-        } else { 
-            if ($ps->{type} eq 's') {
-                warn "Could not find the right head for the branch $ps->{branch}";
-            }
-        }
-    }
-    
-    my $par = join (' ', @par);
-
-    #    
-    # Commit, tag and clean state
-    #
-    $ENV{TZ}                  = 'GMT';
-    $ENV{GIT_AUTHOR_NAME}     = $ps->{author};
-    $ENV{GIT_AUTHOR_EMAIL}    = $ps->{email};
-    $ENV{GIT_AUTHOR_DATE}     = $ps->{date};
-    $ENV{GIT_COMMITTER_NAME}  = $ps->{author};
-    $ENV{GIT_COMMITTER_EMAIL} = $ps->{email};
-    $ENV{GIT_COMMITTER_DATE}  = $ps->{date};
-
-    my ($pid, $commit_rh, $commit_wh);
-    $commit_rh = 'commit_rh';
-    $commit_wh = 'commit_wh';
-    
-    $pid = open2(*READER, *WRITER, "git-commit-tree $tree $par") 
-        or die $!;
-    print WRITER $logmessage;   # write
-    close WRITER;
-    my $commitid = <READER>;    # read
-    chomp $commitid;
-    close READER;
-    waitpid $pid,0;             # close;
-
-    if (length $commitid != 40) {
-        die "Something went wrong with the commit! $! $commitid";
-    }
-    #
-    # Update the branch
-    # 
-    open  HEAD, ">.git/refs/heads/$ps->{branch}";
-    print HEAD $commitid;
-    close HEAD;
-    unlink ('.git/HEAD');
-    symlink("refs/heads/$ps->{branch}",".git/HEAD");
-
-    # tag accordingly
-    ptag($ps->{id}, $commitid); # private tag
-    if ($opt_T || $ps->{type} eq 't' || $ps->{type} eq 'i') {
-        tag($ps->{id}, $commitid);
-    }
-    print " * Committed $ps->{id}\n";
-    print "   + tree   $tree\n";
-    print "   + commit $commitid\n";
-    # print "   + commit date is  $ps->{date} \n";
-}
-
-sub branchname {
-    my $id = shift;
-    $id =~ s#^.+?/##;
-    my @parts = split(m/--/, $id);
-    return join('--', @parts[0..1]);
-}
-
-sub apply_import {
-    my $ps = shift;
-    my $bname = branchname($ps->{id});
-
-    `mkdir -p $tmp`;
-
-    `tla get -s --no-pristine -A $ps->{repo} $ps->{id} $tmp/import`;
-    die "Cannot get import: $!" if $?;    
-    `rsync -v --archive --delete --exclude '.git' --exclude '.arch-ids' --exclude '{arch}' $tmp/import/* ./`;
-    die "Cannot rsync import:$!" if $?;
-    
-    `rm -fr $tmp/import`;
-    die "Cannot remove tempdir: $!" if $?;
-    
-
-    return 1;
-}
-
-sub apply_cset {
-    my $ps = shift;
-
-    `mkdir -p $tmp`;
-
-    # get the changeset
-    `tla get-changeset  -A $ps->{repo} $ps->{id} $tmp/changeset`;
-    die "Cannot get changeset: $!" if $?;
-    
-    # apply patches
-    if (`find $tmp/changeset/patches -type f -name '*.patch'`) {
-        # this can be sped up considerably by doing
-        #    (find | xargs cat) | patch
-        # but that cna get mucked up by patches
-        # with missing trailing newlines or the standard 
-        # 'missing newline' flag in the patch - possibly
-        # produced with an old/buggy diff.
-        # slow and safe, we invoke patch once per patchfile
-        `find $tmp/changeset/patches -type f -name '*.patch' -print0 | grep -zv '{arch}' | xargs -iFILE -0 --no-run-if-empty patch -p1 --forward -iFILE`;
-        die "Problem applying patches! $!" if $?;
-    }
-
-    # apply changed binary files
-    if (my @modified = `find $tmp/changeset/patches -type f -name '*.modified'`) {
-        foreach my $mod (@modified) {
-            chomp $mod;
-            my $orig = $mod;
-            $orig =~ s/\.modified$//; # lazy
-            $orig =~ s!^\Q$tmp\E/changeset/patches/!!;
-            #print "rsync -p '$mod' '$orig'";
-            `rsync -p $mod ./$orig`;
-            die "Problem applying binary changes! $!" if $?;
-        }
-    }
-
-    # bring in new files
-    `rsync --archive --exclude '.git' --exclude '.arch-ids' --exclude '{arch}' $tmp/changeset/new-files-archive/* ./`;
-
-    # deleted files are hinted from the commitlog processing
-
-    `rm -fr $tmp/changeset`;
-}
-
-
-# =for reference
-# A log entry looks like 
-# Revision: moodle-org--moodle--1.3.3--patch-15
-# Archive: arch-eduforge@catalyst.net.nz--2004
-# Creator: Penny Leach <penny@catalyst.net.nz>
-# Date: Wed May 25 14:15:34 NZST 2005
-# Standard-date: 2005-05-25 02:15:34 GMT
-# New-files: lang/de/.arch-ids/block_glossary_random.php.id
-#     lang/de/.arch-ids/block_html.php.id
-# New-directories: lang/de/help/questionnaire
-#     lang/de/help/questionnaire/.arch-ids
-# Renamed-files: .arch-ids/db_sears.sql.id db/.arch-ids/db_sears.sql.id
-#    db_sears.sql db/db_sears.sql
-# Removed-files: lang/be/docs/.arch-ids/release.html.id
-#     lang/be/docs/.arch-ids/releaseold.html.id
-# Modified-files: admin/cron.php admin/delete.php
-#     admin/editor.html backup/lib.php backup/restore.php
-# New-patches: arch-eduforge@catalyst.net.nz--2004/moodle-org--moodle--1.3.3--patch-15
-# Summary: Updating to latest from MOODLE_14_STABLE (1.4.5+)
-# Keywords:
-#
-# Updating yadda tadda tadda madda
-sub parselog {
-    my $log = shift;
-    #print $log;
-
-    my (@add, @del, @mod, @ren, @kw, $sum, $msg );
-
-    if ($log =~ m/(?:\n|^)New-files:(.*?)(?=\n\w)/s ) {
-        my $files = $1;
-        @add = split(m/\s+/s, $files);
-    }
-       
-    if ($log =~ m/(?:\n|^)Removed-files:(.*?)(?=\n\w)/s ) {
-        my $files = $1;
-        @del = split(m/\s+/s, $files);
-    }
-    
-    if ($log =~ m/(?:\n|^)Modified-files:(.*?)(?=\n\w)/s ) {
-        my $files = $1;
-        @mod = split(m/\s+/s, $files);
-    }
-    
-    if ($log =~ m/(?:\n|^)Renamed-files:(.*?)(?=\n\w)/s ) {
-        my $files = $1;
-        @ren = split(m/\s+/s, $files);
-    }
-
-    $sum ='';
-    if ($log =~ m/^Summary:(.+?)$/m ) {
-        $sum = $1;
-        $sum =~ s/^\s+//;
-        $sum =~ s/\s+$//;
-    }
-
-    $msg = '';
-    if ($log =~ m/\n\n(.+)$/s) {
-        $msg = $1;
-        $msg =~ s/^\s+//;
-        $msg =~ s/\s+$//;
-    }
-
-
-    # cleanup the arrays
-    foreach my $ref ( (\@add, \@del, \@mod, \@ren) ) {
-        my @tmp = ();
-        while (my $t = pop @$ref) {
-            next unless length ($t);
-            next if $t =~ m!\{arch\}/!;
-            next if $t =~ m!\.arch-ids/!;
-            next if $t =~ m!\.arch-inventory$!;
-            push (@tmp, shell_quote($t));
-        }
-        @$ref = @tmp;
-    }
-    
-    #print Dumper [$sum, $msg, \@add, \@del, \@mod, \@ren]; 
-    return       ($sum, $msg, \@add, \@del, \@mod, \@ren); 
-}
-
-# write/read a tag
-sub tag {
-    my ($tag, $commit) = @_;
-    $tag =~ s|/|--|g; 
-    $tag = shell_quote($tag);
-    
-    if ($commit) {
-        open(C,">.git/refs/tags/$tag")
-            or die "Cannot create tag $tag: $!\n";
-        print C "$commit\n"
-            or die "Cannot write tag $tag: $!\n";
-        close(C)
-            or die "Cannot write tag $tag: $!\n";
-        print "Created tag '$tag' on '$commit'\n" if $opt_v;
-    } else {                    # read
-        open(C,"<.git/refs/tags/$tag")
-            or die "Cannot read tag $tag: $!\n";
-        $commit = <C>;
-        chomp $commit;
-        die "Error reading tag $tag: $!\n" unless length $commit == 40;
-        close(C)
-            or die "Cannot read tag $tag: $!\n";
-        return $commit;
-    }
-}
-
-# write/read a private tag
-# reads fail softly if the tag isn't there
-sub ptag {
-    my ($tag, $commit) = @_;
-    $tag =~ s|/|--|g; 
-    $tag = shell_quote($tag);
-    
-    unless (-d '.git/archimport/tags') {
-        mkpath('.git/archimport/tags');
-    }
-
-    if ($commit) {              # write
-        open(C,">.git/archimport/tags/$tag")
-            or die "Cannot create tag $tag: $!\n";
-        print C "$commit\n"
-            or die "Cannot write tag $tag: $!\n";
-        close(C)
-            or die "Cannot write tag $tag: $!\n";
-    } else {                    # read
-        # if the tag isn't there, return 0
-        unless ( -s ".git/archimport/tags/$tag") {
-            return 0;
-        }
-        open(C,"<.git/archimport/tags/$tag")
-            or die "Cannot read tag $tag: $!\n";
-        $commit = <C>;
-        chomp $commit;
-        die "Error reading tag $tag: $!\n" unless length $commit == 40;
-        close(C)
-            or die "Cannot read tag $tag: $!\n";
-        return $commit;
-    }
-}
diff --git a/git-archimport.perl b/git-archimport.perl
new file mode 100755 (executable)
index 0000000..e9e6f1b
--- /dev/null
@@ -0,0 +1,604 @@
+#!/usr/bin/perl -w
+#
+# This tool is copyright (c) 2005, Martin Langhoff.
+# It is released under the Gnu Public License, version 2.
+#
+# The basic idea is to walk the output of tla abrowse, 
+# fetch the changesets and apply them. 
+#
+=head1 Invocation
+
+    git-archimport -i <archive>/<branch> [<archive>/<branch>]
+    [ <archive>/<branch> ]
+
+    The script expects you to provide the key roots where it can start the
+    import from an 'initial import' or 'tag' type of Arch commit. It will
+    then follow all the branching and tagging within the provided roots.
+
+    It will die if it sees branches that have different roots. 
+
+=head2 TODO
+
+ - keep track of merged patches, and mark a git merge when it happens
+ - smarter rules to parse the archive history "up" and "down"
+ - be able to continue an import where we left off
+ - audit shell-escaping of filenames
+
+=head1 Devel tricks
+
+Add print in front of the shell commands invoked via backticks. 
+
+=cut
+
+use strict;
+use warnings;
+use Getopt::Std;
+use File::Spec;
+use File::Temp qw(tempfile);
+use File::Path qw(mkpath);
+use File::Basename qw(basename dirname);
+use String::ShellQuote;
+use Time::Local;
+use IO::Socket;
+use IO::Pipe;
+use POSIX qw(strftime dup2);
+use Data::Dumper qw/ Dumper /;
+use IPC::Open2;
+
+$SIG{'PIPE'}="IGNORE";
+$ENV{'TZ'}="UTC";
+
+our($opt_h,$opt_v, $opt_T,
+    $opt_C,$opt_t);
+
+sub usage() {
+    print STDERR <<END;
+Usage: ${\basename $0}     # fetch/update GIT from Arch
+       [ -h ] [ -v ] [ -T ] 
+       [ -C GIT_repository ] [ -t tempdir ] 
+       repository/arch-branch [ repository/arch-branch] ...
+END
+    exit(1);
+}
+
+getopts("hviC:t:") or usage();
+usage if $opt_h;
+
+@ARGV >= 1 or usage();
+my @arch_roots = @ARGV;
+
+my $tmp = $opt_t;
+$tmp ||= '/tmp';
+$tmp .= '/git-archimport/';
+
+my $git_tree = $opt_C;
+$git_tree ||= ".";
+
+
+my @psets  = ();                # the collection
+
+foreach my $root (@arch_roots) {
+    my ($arepo, $abranch) = split(m!/!, $root);
+    open ABROWSE, "tla abrowse -f -A $arepo --desc --merges $abranch |" 
+        or die "Problems with tla abrowse: $!";
+    
+    my %ps        = ();         # the current one
+    my $mode      = '';
+    my $lastseen  = '';
+    
+    while (<ABROWSE>) {
+        chomp;
+        
+        # first record padded w 8 spaces
+        if (s/^\s{8}\b//) {
+            
+            # store the record we just captured
+            if (%ps) {
+                my %temp = %ps; # break references
+                push (@psets, \%temp);
+                %ps = ();
+            }
+            
+            my ($id, $type) = split(m/\s{3}/, $_);
+            $ps{id}   = $id;
+            $ps{repo} = $arepo;
+
+            # deal with types
+            if ($type =~ m/^\(simple changeset\)/) {
+                $ps{type} = 's';
+            } elsif ($type eq '(initial import)') {
+                $ps{type} = 'i';
+            } elsif ($type =~ m/^\(tag revision of (.+)\)/) {
+                $ps{type} = 't';
+                $ps{tag}  = $1;
+            } else { 
+                warn "Unknown type $type";
+            }
+            $lastseen = 'id';
+        }
+        
+        if (s/^\s{10}//) { 
+            # 10 leading spaces or more 
+            # indicate commit metadata
+            
+            # date & author 
+            if ($lastseen eq 'id' && m/^\d{4}-\d{2}-\d{2}/) {
+                
+                my ($date, $authoremail) = split(m/\s{2,}/, $_);
+                $ps{date}   = $date;
+                $ps{date}   =~ s/\bGMT$//; # strip off trailign GMT
+                if ($ps{date} =~ m/\b\w+$/) {
+                    warn 'Arch dates not in GMT?! - imported dates will be wrong';
+                }
+            
+                $authoremail =~ m/^(.+)\s(\S+)$/;
+                $ps{author} = $1;
+                $ps{email}  = $2;
+            
+                $lastseen = 'date';
+            
+            } elsif ($lastseen eq 'date') {
+                # the only hint is position
+                # subject is after date
+                $ps{subj} = $_;
+                $lastseen = 'subj';
+            
+            } elsif ($lastseen eq 'subj' && $_ eq 'merges in:') {
+                $ps{merges} = [];
+                $lastseen = 'merges';
+            
+            } elsif ($lastseen eq 'merges' && s/^\s{2}//) {
+                push (@{$ps{merges}}, $_);
+            } else {
+                warn 'more metadata after merges!?';
+            }
+            
+        }
+    }
+
+    if (%ps) {
+        my %temp = %ps;         # break references
+        push (@psets, \%temp);
+        %ps = ();
+    }    
+    close ABROWSE;
+}                               # end foreach $root
+
+## Order patches by time
+@psets = sort {$a->{date}.$b->{id} cmp $b->{date}.$b->{id}} @psets;
+
+#print Dumper \@psets;
+
+##
+## TODO cleanup irrelevant patches
+##      and put an initial import
+##      or a full tag
+my $import = 0;
+unless (-d '.git') { # initial import
+    if ($psets[0]{type} eq 'i' || $psets[0]{type} eq 't') {
+        print "Starting import from $psets[0]{id}\n";
+       `git-init-db`;
+       die $! if $?;
+       $import = 1;
+    } else {
+        die "Need to start from an import or a tag -- cannot use $psets[0]{id}";
+    }
+}
+
+# process patchsets
+foreach my $ps (@psets) {
+
+    $ps->{branch} =  branchname($ps->{id});
+
+    #
+    # ensure we have a clean state 
+    # 
+    if (`git diff-files`) {
+        die "Unclean tree when about to process $ps->{id} " .
+            " - did we fail to commit cleanly before?";
+    }
+    die $! if $?;
+
+    #
+    # skip commits already in repo
+    #
+    if (ptag($ps->{id})) {
+      $opt_v && print "Skipping already imported: $ps->{id}\n";
+      next;
+    }
+
+    # 
+    # create the branch if needed
+    #
+    if ($ps->{type} eq 'i' && !$import) {
+        die "Should not have more than one 'Initial import' per GIT import: $ps->{id}";
+    }
+
+    unless ($import) { # skip for import
+        if ( -e ".git/refs/heads/$ps->{branch}") {
+            # we know about this branch
+            `git checkout    $ps->{branch}`;
+        } else {
+            # new branch! we need to verify a few things
+            die "Branch on a non-tag!" unless $ps->{type} eq 't';
+            my $branchpoint = ptag($ps->{tag});
+            die "Tagging from unknown id unsupported: $ps->{tag}" 
+                unless $branchpoint;
+            
+            # find where we are supposed to branch from
+            `git checkout -b $ps->{branch} $branchpoint`;
+
+            # If we trust Arch with the fact that this is just 
+            # a tag, and it does not affect the state of the tree
+            # then we just tag and move on
+            tag($ps->{id}, $branchpoint);
+            ptag($ps->{id}, $branchpoint);
+            print " * Tagged $ps->{id} at $branchpoint\n";
+            next;
+        } 
+        die $! if $?;
+    } 
+
+    #
+    # Apply the import/changeset/merge into the working tree
+    # 
+    if ($ps->{type} eq 'i' || $ps->{type} eq 't') {
+        apply_import($ps) or die $!;
+        $import=0;
+    } elsif ($ps->{type} eq 's') {
+        apply_cset($ps);
+    }
+
+    #
+    # prepare update git's index, based on what arch knows
+    # about the pset, resolve parents, etc
+    #
+    my $tree;
+    
+    my $commitlog = `tla cat-archive-log -A $ps->{repo} $ps->{id}`; 
+    die "Error in cat-archive-log: $!" if $?;
+        
+    # parselog will git-add/rm files
+    # and generally prepare things for the commit
+    # NOTE: parselog will shell-quote filenames! 
+    my ($sum, $msg, $add, $del, $mod, $ren) = parselog($commitlog);
+    my $logmessage = "$sum\n$msg";
+
+
+    # imports don't give us good info
+    # on added files. Shame on them
+    if ($ps->{type} eq 'i' || $ps->{type} eq 't') { 
+        `find . -type f -print0 | grep -zv '^./.git' | xargs -0 -l100 git-update-index --add`;
+        `git-ls-files --deleted -z | xargs --no-run-if-empty -0 -l100 git-update-index --remove`;
+    }
+
+    if (@$add) {
+        while (@$add) {
+            my @slice = splice(@$add, 0, 100);
+            my $slice = join(' ', @slice);          
+            `git-update-index --add $slice`;
+            die "Error in git-update-index --add: $!" if $?;
+        }
+    }
+    if (@$del) {
+        foreach my $file (@$del) {
+            unlink $file or die "Problems deleting $file : $!";
+        }
+        while (@$del) {
+            my @slice = splice(@$del, 0, 100);
+            my $slice = join(' ', @slice);
+            `git-update-index --remove $slice`;
+            die "Error in git-update-index --remove: $!" if $?;
+        }
+    }
+    if (@$ren) {                # renamed
+        if (@$ren % 2) {
+            die "Odd number of entries in rename!?";
+        }
+        ;
+        while (@$ren) {
+            my $from = pop @$ren;
+            my $to   = pop @$ren;           
+
+            unless (-d dirname($to)) {
+                mkpath(dirname($to)); # will die on err
+            }
+            #print "moving $from $to";
+            `mv $from $to`;
+            die "Error renaming $from $to : $!" if $?;
+            `git-update-index --remove $from`;
+            die "Error in git-update-index --remove: $!" if $?;
+            `git-update-index --add $to`;
+            die "Error in git-update-index --add: $!" if $?;
+        }
+
+    }
+    if (@$mod) {                # must be _after_ renames
+        while (@$mod) {
+            my @slice = splice(@$mod, 0, 100);
+            my $slice = join(' ', @slice);
+            `git-update-index $slice`;
+            die "Error in git-update-index: $!" if $?;
+        }
+    }
+
+    # warn "errors when running git-update-index! $!";
+    $tree = `git-write-tree`;
+    die "cannot write tree $!" if $?;
+    chomp $tree;
+        
+    
+    #
+    # Who's your daddy?
+    #
+    my @par;
+    if ( -e ".git/refs/heads/$ps->{branch}") {
+        if (open HEAD, "<.git/refs/heads/$ps->{branch}") {
+            my $p = <HEAD>;
+            close HEAD;
+            chomp $p;
+            push @par, '-p', $p;
+        } else { 
+            if ($ps->{type} eq 's') {
+                warn "Could not find the right head for the branch $ps->{branch}";
+            }
+        }
+    }
+    
+    my $par = join (' ', @par);
+
+    #    
+    # Commit, tag and clean state
+    #
+    $ENV{TZ}                  = 'GMT';
+    $ENV{GIT_AUTHOR_NAME}     = $ps->{author};
+    $ENV{GIT_AUTHOR_EMAIL}    = $ps->{email};
+    $ENV{GIT_AUTHOR_DATE}     = $ps->{date};
+    $ENV{GIT_COMMITTER_NAME}  = $ps->{author};
+    $ENV{GIT_COMMITTER_EMAIL} = $ps->{email};
+    $ENV{GIT_COMMITTER_DATE}  = $ps->{date};
+
+    my ($pid, $commit_rh, $commit_wh);
+    $commit_rh = 'commit_rh';
+    $commit_wh = 'commit_wh';
+    
+    $pid = open2(*READER, *WRITER, "git-commit-tree $tree $par") 
+        or die $!;
+    print WRITER $logmessage;   # write
+    close WRITER;
+    my $commitid = <READER>;    # read
+    chomp $commitid;
+    close READER;
+    waitpid $pid,0;             # close;
+
+    if (length $commitid != 40) {
+        die "Something went wrong with the commit! $! $commitid";
+    }
+    #
+    # Update the branch
+    # 
+    open  HEAD, ">.git/refs/heads/$ps->{branch}";
+    print HEAD $commitid;
+    close HEAD;
+    unlink ('.git/HEAD');
+    symlink("refs/heads/$ps->{branch}",".git/HEAD");
+
+    # tag accordingly
+    ptag($ps->{id}, $commitid); # private tag
+    if ($opt_T || $ps->{type} eq 't' || $ps->{type} eq 'i') {
+        tag($ps->{id}, $commitid);
+    }
+    print " * Committed $ps->{id}\n";
+    print "   + tree   $tree\n";
+    print "   + commit $commitid\n";
+    # print "   + commit date is  $ps->{date} \n";
+}
+
+sub branchname {
+    my $id = shift;
+    $id =~ s#^.+?/##;
+    my @parts = split(m/--/, $id);
+    return join('--', @parts[0..1]);
+}
+
+sub apply_import {
+    my $ps = shift;
+    my $bname = branchname($ps->{id});
+
+    `mkdir -p $tmp`;
+
+    `tla get -s --no-pristine -A $ps->{repo} $ps->{id} $tmp/import`;
+    die "Cannot get import: $!" if $?;    
+    `rsync -v --archive --delete --exclude '.git' --exclude '.arch-ids' --exclude '{arch}' $tmp/import/* ./`;
+    die "Cannot rsync import:$!" if $?;
+    
+    `rm -fr $tmp/import`;
+    die "Cannot remove tempdir: $!" if $?;
+    
+
+    return 1;
+}
+
+sub apply_cset {
+    my $ps = shift;
+
+    `mkdir -p $tmp`;
+
+    # get the changeset
+    `tla get-changeset  -A $ps->{repo} $ps->{id} $tmp/changeset`;
+    die "Cannot get changeset: $!" if $?;
+    
+    # apply patches
+    if (`find $tmp/changeset/patches -type f -name '*.patch'`) {
+        # this can be sped up considerably by doing
+        #    (find | xargs cat) | patch
+        # but that cna get mucked up by patches
+        # with missing trailing newlines or the standard 
+        # 'missing newline' flag in the patch - possibly
+        # produced with an old/buggy diff.
+        # slow and safe, we invoke patch once per patchfile
+        `find $tmp/changeset/patches -type f -name '*.patch' -print0 | grep -zv '{arch}' | xargs -iFILE -0 --no-run-if-empty patch -p1 --forward -iFILE`;
+        die "Problem applying patches! $!" if $?;
+    }
+
+    # apply changed binary files
+    if (my @modified = `find $tmp/changeset/patches -type f -name '*.modified'`) {
+        foreach my $mod (@modified) {
+            chomp $mod;
+            my $orig = $mod;
+            $orig =~ s/\.modified$//; # lazy
+            $orig =~ s!^\Q$tmp\E/changeset/patches/!!;
+            #print "rsync -p '$mod' '$orig'";
+            `rsync -p $mod ./$orig`;
+            die "Problem applying binary changes! $!" if $?;
+        }
+    }
+
+    # bring in new files
+    `rsync --archive --exclude '.git' --exclude '.arch-ids' --exclude '{arch}' $tmp/changeset/new-files-archive/* ./`;
+
+    # deleted files are hinted from the commitlog processing
+
+    `rm -fr $tmp/changeset`;
+}
+
+
+# =for reference
+# A log entry looks like 
+# Revision: moodle-org--moodle--1.3.3--patch-15
+# Archive: arch-eduforge@catalyst.net.nz--2004
+# Creator: Penny Leach <penny@catalyst.net.nz>
+# Date: Wed May 25 14:15:34 NZST 2005
+# Standard-date: 2005-05-25 02:15:34 GMT
+# New-files: lang/de/.arch-ids/block_glossary_random.php.id
+#     lang/de/.arch-ids/block_html.php.id
+# New-directories: lang/de/help/questionnaire
+#     lang/de/help/questionnaire/.arch-ids
+# Renamed-files: .arch-ids/db_sears.sql.id db/.arch-ids/db_sears.sql.id
+#    db_sears.sql db/db_sears.sql
+# Removed-files: lang/be/docs/.arch-ids/release.html.id
+#     lang/be/docs/.arch-ids/releaseold.html.id
+# Modified-files: admin/cron.php admin/delete.php
+#     admin/editor.html backup/lib.php backup/restore.php
+# New-patches: arch-eduforge@catalyst.net.nz--2004/moodle-org--moodle--1.3.3--patch-15
+# Summary: Updating to latest from MOODLE_14_STABLE (1.4.5+)
+# Keywords:
+#
+# Updating yadda tadda tadda madda
+sub parselog {
+    my $log = shift;
+    #print $log;
+
+    my (@add, @del, @mod, @ren, @kw, $sum, $msg );
+
+    if ($log =~ m/(?:\n|^)New-files:(.*?)(?=\n\w)/s ) {
+        my $files = $1;
+        @add = split(m/\s+/s, $files);
+    }
+       
+    if ($log =~ m/(?:\n|^)Removed-files:(.*?)(?=\n\w)/s ) {
+        my $files = $1;
+        @del = split(m/\s+/s, $files);
+    }
+    
+    if ($log =~ m/(?:\n|^)Modified-files:(.*?)(?=\n\w)/s ) {
+        my $files = $1;
+        @mod = split(m/\s+/s, $files);
+    }
+    
+    if ($log =~ m/(?:\n|^)Renamed-files:(.*?)(?=\n\w)/s ) {
+        my $files = $1;
+        @ren = split(m/\s+/s, $files);
+    }
+
+    $sum ='';
+    if ($log =~ m/^Summary:(.+?)$/m ) {
+        $sum = $1;
+        $sum =~ s/^\s+//;
+        $sum =~ s/\s+$//;
+    }
+
+    $msg = '';
+    if ($log =~ m/\n\n(.+)$/s) {
+        $msg = $1;
+        $msg =~ s/^\s+//;
+        $msg =~ s/\s+$//;
+    }
+
+
+    # cleanup the arrays
+    foreach my $ref ( (\@add, \@del, \@mod, \@ren) ) {
+        my @tmp = ();
+        while (my $t = pop @$ref) {
+            next unless length ($t);
+            next if $t =~ m!\{arch\}/!;
+            next if $t =~ m!\.arch-ids/!;
+            next if $t =~ m!\.arch-inventory$!;
+            push (@tmp, shell_quote($t));
+        }
+        @$ref = @tmp;
+    }
+    
+    #print Dumper [$sum, $msg, \@add, \@del, \@mod, \@ren]; 
+    return       ($sum, $msg, \@add, \@del, \@mod, \@ren); 
+}
+
+# write/read a tag
+sub tag {
+    my ($tag, $commit) = @_;
+    $tag =~ s|/|--|g; 
+    $tag = shell_quote($tag);
+    
+    if ($commit) {
+        open(C,">.git/refs/tags/$tag")
+            or die "Cannot create tag $tag: $!\n";
+        print C "$commit\n"
+            or die "Cannot write tag $tag: $!\n";
+        close(C)
+            or die "Cannot write tag $tag: $!\n";
+        print "Created tag '$tag' on '$commit'\n" if $opt_v;
+    } else {                    # read
+        open(C,"<.git/refs/tags/$tag")
+            or die "Cannot read tag $tag: $!\n";
+        $commit = <C>;
+        chomp $commit;
+        die "Error reading tag $tag: $!\n" unless length $commit == 40;
+        close(C)
+            or die "Cannot read tag $tag: $!\n";
+        return $commit;
+    }
+}
+
+# write/read a private tag
+# reads fail softly if the tag isn't there
+sub ptag {
+    my ($tag, $commit) = @_;
+    $tag =~ s|/|--|g; 
+    $tag = shell_quote($tag);
+    
+    unless (-d '.git/archimport/tags') {
+        mkpath('.git/archimport/tags');
+    }
+
+    if ($commit) {              # write
+        open(C,">.git/archimport/tags/$tag")
+            or die "Cannot create tag $tag: $!\n";
+        print C "$commit\n"
+            or die "Cannot write tag $tag: $!\n";
+        close(C)
+            or die "Cannot write tag $tag: $!\n";
+    } else {                    # read
+        # if the tag isn't there, return 0
+        unless ( -s ".git/archimport/tags/$tag") {
+            return 0;
+        }
+        open(C,"<.git/archimport/tags/$tag")
+            or die "Cannot read tag $tag: $!\n";
+        $commit = <C>;
+        chomp $commit;
+        die "Error reading tag $tag: $!\n" unless length $commit == 40;
+        close(C)
+            or die "Cannot read tag $tag: $!\n";
+        return $commit;
+    }
+}
diff --git a/git-bisect-script b/git-bisect-script
deleted file mode 100755 (executable)
index e5a4670..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-#!/bin/sh
-. git-sh-setup-script || dir "Not a git archive"
-
-usage() {
-    echo >&2 'usage: git bisect [start|bad|good|next|reset|visualize]
-git bisect start               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.
-git bisect next                        find next bisection to test and check it out.
-git bisect reset [<branch>]    finish bisection search and go back to branch.
-git bisect visualize            show bisect status in gitk.'
-    exit 1
-}
-
-bisect_autostart() {
-       test -d "$GIT_DIR/refs/bisect" || {
-               echo >&2 'You need to start by "git bisect start"'
-               if test -t 0
-               then
-                       echo >&2 -n 'Do you want me to do it for you [Y/n]? '
-                       read yesno
-                       case "$yesno" in
-                       [Nn]*)
-                               exit ;;
-                       esac
-                       bisect_start
-               else
-                       exit 1
-               fi
-       }
-}
-
-bisect_start() {
-        case "$#" in 0) ;; *) usage ;; esac
-       #
-       # Verify HEAD. If we were bisecting before this, reset to the
-       # top-of-line master first!
-       #
-       head=$(readlink $GIT_DIR/HEAD) || die "Bad HEAD - I need a symlink"
-       case "$head" in
-       refs/heads/bisect*)
-               git checkout master || exit
-               ;;
-       refs/heads/*)
-               ;;
-       *)
-               die "Bad HEAD - strange symlink"
-               ;;
-       esac
-
-       #
-       # Get rid of any old bisect state
-       #
-       rm -f "$GIT_DIR/refs/heads/bisect"
-       rm -rf "$GIT_DIR/refs/bisect/"
-       mkdir "$GIT_DIR/refs/bisect"
-}
-
-bisect_bad() {
-       bisect_autostart
-       case "$#" in
-       0)
-               rev=$(git-rev-parse --verify HEAD) ;;
-       1)
-               rev=$(git-rev-parse --verify "$1") ;;
-       *)
-               usage ;;
-       esac || exit
-       echo "$rev" > "$GIT_DIR/refs/bisect/bad"
-       bisect_auto_next
-}
-
-bisect_good() {
-       bisect_autostart
-        case "$#" in
-       0)    revs=$(git-rev-parse --verify HEAD) || exit ;;
-       *)    revs=$(git-rev-parse --revs-only --no-flags "$@") &&
-               test '' != "$revs" || die "Bad rev input: $@" ;;
-       esac
-       for rev in $revs
-       do
-               rev=$(git-rev-parse --verify "$rev") || exit
-               echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev"
-       done
-       bisect_auto_next
-}
-
-bisect_next_check() {
-       next_ok=no
-        test -f "$GIT_DIR/refs/bisect/bad" &&
-       case "$(cd "$GIT_DIR" && echo refs/bisect/good-*)" in
-       refs/bisect/good-\*) ;;
-       *) next_ok=yes ;;
-       esac
-       case "$next_ok,$1" in
-       no,) false ;;
-       no,fail)
-           echo >&2 'You need to give me at least one good and one bad revisions.'
-           exit 1 ;;
-       *)
-           true ;;
-       esac
-}
-
-bisect_auto_next() {
-       bisect_next_check && bisect_next
-}
-
-bisect_next() {
-        case "$#" in 0) ;; *) usage ;; esac
-       bisect_autostart
-       bisect_next_check fail
-       bad=$(git-rev-parse --verify refs/bisect/bad) &&
-       good=$(git-rev-parse --sq --revs-only --not \
-               $(cd "$GIT_DIR" && ls refs/bisect/good-*)) &&
-       rev=$(eval "git-rev-list --bisect $good $bad") || exit
-       if [ -z "$rev" ]; then
-           echo "$bad was both good and bad"
-           exit 1
-       fi
-       if [ "$rev" = "$bad" ]; then
-           echo "$rev is first bad commit"
-           git-diff-tree --pretty $rev
-           exit 0
-       fi
-       nr=$(eval "git-rev-list $rev $good" | 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
-       mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" &&
-       ln -sf refs/heads/bisect "$GIT_DIR/HEAD"
-}
-
-bisect_visualize() {
-       bisect_next_check fail
-       gitk bisect/bad --not `cd "$GIT_DIR/refs" && echo bisect/good-*`
-}
-
-bisect_reset() {
-       case "$#" in
-       0) branch=master ;;
-       1) test -f "$GIT_DIR/refs/heads/$1" || {
-              echo >&2 "$1 does not seem to be a valid branch"
-              exit 1
-          }
-          branch="$1" ;;
-        *)
-           usage ;;
-       esac
-       git checkout "$branch" &&
-       rm -fr "$GIT_DIR/refs/bisect"
-       rm -f "$GIT_DIR/refs/reads/bisect"
-}
-
-case "$#" in
-0)
-    usage ;;
-*)
-    cmd="$1"
-    shift
-    case "$cmd" in
-    start)
-        bisect_start "$@" ;;
-    bad)
-        bisect_bad "$@" ;;
-    good)
-        bisect_good "$@" ;;
-    next)
-        # Not sure we want "next" at the UI level anymore.
-        bisect_next "$@" ;;
-    visualize)
-       bisect_visualize "$@" ;;
-    reset)
-        bisect_reset "$@" ;;
-    *)
-        usage ;;
-    esac
-esac
diff --git a/git-bisect.sh b/git-bisect.sh
new file mode 100755 (executable)
index 0000000..605d58a
--- /dev/null
@@ -0,0 +1,178 @@
+#!/bin/sh
+. git-sh-setup || dir "Not a git archive"
+
+usage() {
+    echo >&2 'usage: git bisect [start|bad|good|next|reset|visualize]
+git bisect start               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.
+git bisect next                        find next bisection to test and check it out.
+git bisect reset [<branch>]    finish bisection search and go back to branch.
+git bisect visualize            show bisect status in gitk.'
+    exit 1
+}
+
+bisect_autostart() {
+       test -d "$GIT_DIR/refs/bisect" || {
+               echo >&2 'You need to start by "git bisect start"'
+               if test -t 0
+               then
+                       echo >&2 -n 'Do you want me to do it for you [Y/n]? '
+                       read yesno
+                       case "$yesno" in
+                       [Nn]*)
+                               exit ;;
+                       esac
+                       bisect_start
+               else
+                       exit 1
+               fi
+       }
+}
+
+bisect_start() {
+        case "$#" in 0) ;; *) usage ;; esac
+       #
+       # Verify HEAD. If we were bisecting before this, reset to the
+       # top-of-line master first!
+       #
+       head=$(readlink $GIT_DIR/HEAD) || die "Bad HEAD - I need a symlink"
+       case "$head" in
+       refs/heads/bisect*)
+               git checkout master || exit
+               ;;
+       refs/heads/*)
+               ;;
+       *)
+               die "Bad HEAD - strange symlink"
+               ;;
+       esac
+
+       #
+       # Get rid of any old bisect state
+       #
+       rm -f "$GIT_DIR/refs/heads/bisect"
+       rm -rf "$GIT_DIR/refs/bisect/"
+       mkdir "$GIT_DIR/refs/bisect"
+}
+
+bisect_bad() {
+       bisect_autostart
+       case "$#" in
+       0)
+               rev=$(git-rev-parse --verify HEAD) ;;
+       1)
+               rev=$(git-rev-parse --verify "$1") ;;
+       *)
+               usage ;;
+       esac || exit
+       echo "$rev" > "$GIT_DIR/refs/bisect/bad"
+       bisect_auto_next
+}
+
+bisect_good() {
+       bisect_autostart
+        case "$#" in
+       0)    revs=$(git-rev-parse --verify HEAD) || exit ;;
+       *)    revs=$(git-rev-parse --revs-only --no-flags "$@") &&
+               test '' != "$revs" || die "Bad rev input: $@" ;;
+       esac
+       for rev in $revs
+       do
+               rev=$(git-rev-parse --verify "$rev") || exit
+               echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev"
+       done
+       bisect_auto_next
+}
+
+bisect_next_check() {
+       next_ok=no
+        test -f "$GIT_DIR/refs/bisect/bad" &&
+       case "$(cd "$GIT_DIR" && echo refs/bisect/good-*)" in
+       refs/bisect/good-\*) ;;
+       *) next_ok=yes ;;
+       esac
+       case "$next_ok,$1" in
+       no,) false ;;
+       no,fail)
+           echo >&2 'You need to give me at least one good and one bad revisions.'
+           exit 1 ;;
+       *)
+           true ;;
+       esac
+}
+
+bisect_auto_next() {
+       bisect_next_check && bisect_next
+}
+
+bisect_next() {
+        case "$#" in 0) ;; *) usage ;; esac
+       bisect_autostart
+       bisect_next_check fail
+       bad=$(git-rev-parse --verify refs/bisect/bad) &&
+       good=$(git-rev-parse --sq --revs-only --not \
+               $(cd "$GIT_DIR" && ls refs/bisect/good-*)) &&
+       rev=$(eval "git-rev-list --bisect $good $bad") || exit
+       if [ -z "$rev" ]; then
+           echo "$bad was both good and bad"
+           exit 1
+       fi
+       if [ "$rev" = "$bad" ]; then
+           echo "$rev is first bad commit"
+           git-diff-tree --pretty $rev
+           exit 0
+       fi
+       nr=$(eval "git-rev-list $rev $good" | 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
+       mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" &&
+       ln -sf refs/heads/bisect "$GIT_DIR/HEAD"
+}
+
+bisect_visualize() {
+       bisect_next_check fail
+       gitk bisect/bad --not `cd "$GIT_DIR/refs" && echo bisect/good-*`
+}
+
+bisect_reset() {
+       case "$#" in
+       0) branch=master ;;
+       1) test -f "$GIT_DIR/refs/heads/$1" || {
+              echo >&2 "$1 does not seem to be a valid branch"
+              exit 1
+          }
+          branch="$1" ;;
+        *)
+           usage ;;
+       esac
+       git checkout "$branch" &&
+       rm -fr "$GIT_DIR/refs/bisect"
+       rm -f "$GIT_DIR/refs/reads/bisect"
+}
+
+case "$#" in
+0)
+    usage ;;
+*)
+    cmd="$1"
+    shift
+    case "$cmd" in
+    start)
+        bisect_start "$@" ;;
+    bad)
+        bisect_bad "$@" ;;
+    good)
+        bisect_good "$@" ;;
+    next)
+        # Not sure we want "next" at the UI level anymore.
+        bisect_next "$@" ;;
+    visualize)
+       bisect_visualize "$@" ;;
+    reset)
+        bisect_reset "$@" ;;
+    *)
+        usage ;;
+    esac
+esac
diff --git a/git-branch-script b/git-branch-script
deleted file mode 100755 (executable)
index 0ecbd23..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-. git-sh-setup-script || die "Not a git archive"
-
-case "$#" in
-0)
-       headref=$(readlink "$GIT_DIR/HEAD" | sed -e 's|^refs/heads/||')
-       git-rev-parse --symbolic --all |
-       sed -ne 's|^refs/heads/||p' |
-       sort |
-       while read ref
-       do
-               if test "$headref" = "$ref"
-               then
-                       pfx='*'
-               else
-                       pfx=' '
-               fi
-               echo "$pfx $ref"
-       done
-       exit 0 ;;
-1)
-       head=HEAD ;;
-2)
-       head="$2^0" ;;
-esac
-branchname="$1"
-rev=$(git-rev-parse --verify "$head") || exit
-
-[ -e "$GIT_DIR/refs/heads/$branchname" ] && die "$branchname already exists"
-
-echo $rev > "$GIT_DIR/refs/heads/$branchname"
diff --git a/git-branch.sh b/git-branch.sh
new file mode 100755 (executable)
index 0000000..145a7b7
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+. git-sh-setup || die "Not a git archive"
+
+case "$#" in
+0)
+       headref=$(readlink "$GIT_DIR/HEAD" | sed -e 's|^refs/heads/||')
+       git-rev-parse --symbolic --all |
+       sed -ne 's|^refs/heads/||p' |
+       sort |
+       while read ref
+       do
+               if test "$headref" = "$ref"
+               then
+                       pfx='*'
+               else
+                       pfx=' '
+               fi
+               echo "$pfx $ref"
+       done
+       exit 0 ;;
+1)
+       head=HEAD ;;
+2)
+       head="$2^0" ;;
+esac
+branchname="$1"
+rev=$(git-rev-parse --verify "$head") || exit
+
+[ -e "$GIT_DIR/refs/heads/$branchname" ] && die "$branchname already exists"
+
+echo $rev > "$GIT_DIR/refs/heads/$branchname"
diff --git a/git-checkout-script b/git-checkout-script
deleted file mode 100755 (executable)
index b31ded7..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/sh
-. git-sh-setup-script || die "Not a git archive"
-
-old=$(git-rev-parse HEAD)
-new=
-force=
-branch=
-newbranch=
-while [ "$#" != "0" ]; do
-    arg="$1"
-    shift
-    case "$arg" in
-       "-b")
-               newbranch="$1"
-               shift
-               [ -z "$newbranch" ] &&
-                       die "git checkout: -b needs a branch name"
-               [ -e "$GIT_DIR/refs/heads/$newbranch" ] &&
-                       die "git checkout: branch $newbranch already exists"
-               ;;
-       "-f")
-               force=1
-               ;;
-       *)
-               rev=$(git-rev-parse --verify "$arg^0") || exit
-               if [ -z "$rev" ]; then
-                       echo "unknown flag $arg"
-                       exit 1
-               fi
-               if [ "$new" ]; then
-                       echo "Multiple revisions?"
-                       exit 1
-               fi
-               new="$rev"
-               if [ -f "$GIT_DIR/refs/heads/$arg" ]; then
-                       branch="$arg"
-               fi
-               ;;
-    esac
-done
-[ -z "$new" ] && new=$old
-
-#
-# If we don't have an old branch that we're switching to,
-# and we don't have a new branch name for the target we
-# are switching to, then we'd better just be checking out
-# what we already had
-#
-[ -z "$branch$newbranch" ] &&
-       [ "$new" != "$old" ] &&
-       die "git checkout: you need to specify a new branch name"
-
-if [ "$force" ]
-then
-    git-read-tree --reset $new &&
-       git-checkout-cache -q -f -u -a
-else
-    git-read-tree -m -u $old $new
-fi
-
-# 
-# Switch the HEAD pointer to the new branch if it we
-# checked out a branch head, and remove any potential
-# old MERGE_HEAD's (subsequent commits will clearly not
-# be based on them, since we re-set the index)
-#
-if [ "$?" -eq 0 ]; then
-       if [ "$newbranch" ]; then
-               echo $new > "$GIT_DIR/refs/heads/$newbranch"
-               branch="$newbranch"
-       fi
-       [ "$branch" ] && ln -sf "refs/heads/$branch" "$GIT_DIR/HEAD"
-       rm -f "$GIT_DIR/MERGE_HEAD"
-else
-       exit 1
-fi
diff --git a/git-checkout.sh b/git-checkout.sh
new file mode 100755 (executable)
index 0000000..4e7c57a
--- /dev/null
@@ -0,0 +1,76 @@
+#!/bin/sh
+. git-sh-setup || die "Not a git archive"
+
+old=$(git-rev-parse HEAD)
+new=
+force=
+branch=
+newbranch=
+while [ "$#" != "0" ]; do
+    arg="$1"
+    shift
+    case "$arg" in
+       "-b")
+               newbranch="$1"
+               shift
+               [ -z "$newbranch" ] &&
+                       die "git checkout: -b needs a branch name"
+               [ -e "$GIT_DIR/refs/heads/$newbranch" ] &&
+                       die "git checkout: branch $newbranch already exists"
+               ;;
+       "-f")
+               force=1
+               ;;
+       *)
+               rev=$(git-rev-parse --verify "$arg^0") || exit
+               if [ -z "$rev" ]; then
+                       echo "unknown flag $arg"
+                       exit 1
+               fi
+               if [ "$new" ]; then
+                       echo "Multiple revisions?"
+                       exit 1
+               fi
+               new="$rev"
+               if [ -f "$GIT_DIR/refs/heads/$arg" ]; then
+                       branch="$arg"
+               fi
+               ;;
+    esac
+done
+[ -z "$new" ] && new=$old
+
+#
+# If we don't have an old branch that we're switching to,
+# and we don't have a new branch name for the target we
+# are switching to, then we'd better just be checking out
+# what we already had
+#
+[ -z "$branch$newbranch" ] &&
+       [ "$new" != "$old" ] &&
+       die "git checkout: you need to specify a new branch name"
+
+if [ "$force" ]
+then
+    git-read-tree --reset $new &&
+       git-checkout-index -q -f -u -a
+else
+    git-read-tree -m -u $old $new
+fi
+
+# 
+# Switch the HEAD pointer to the new branch if it we
+# checked out a branch head, and remove any potential
+# old MERGE_HEAD's (subsequent commits will clearly not
+# be based on them, since we re-set the index)
+#
+if [ "$?" -eq 0 ]; then
+       if [ "$newbranch" ]; then
+               echo $new > "$GIT_DIR/refs/heads/$newbranch"
+               branch="$newbranch"
+       fi
+       [ "$branch" ] && ln -sf "refs/heads/$branch" "$GIT_DIR/HEAD"
+       rm -f "$GIT_DIR/MERGE_HEAD"
+else
+       exit 1
+fi
diff --git a/git-cherry b/git-cherry
deleted file mode 100755 (executable)
index fe8c109..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Junio C Hamano.
-#
-
-. git-sh-setup-script || die "Not a git archive."
-
-usage="usage: $0 "'[-v] <upstream> [<head>]
-
-             __*__*__*__*__> <upstream>
-            /
-  fork-point
-            \__+__+__+__+__+__+__+__> <head>
-
-Each commit between the fork-point and <head> is examined, and
-compared against the change each commit between the fork-point and
-<upstream> introduces.  If the change seems to be in the upstream,
-it is shown on the standard output with prefix "+".  Otherwise
-it is shown with prefix "-".
-'
-
-case "$1" in -v) verbose=t; shift ;; esac 
-
-case "$#,$1" in
-1,*..*)
-    upstream=$(expr "$1" : '\(.*\)\.\.') ours=$(expr "$1" : '.*\.\.\(.*\)$')
-    set x "$upstream" "$ours"
-    shift ;;
-esac
-
-case "$#" in
-1) upstream=`git-rev-parse --verify "$1"` &&
-   ours=`git-rev-parse --verify HEAD` || exit
-   ;;
-2) upstream=`git-rev-parse --verify "$1"` &&
-   ours=`git-rev-parse --verify "$2"` || exit
-   ;;
-*) echo >&2 "$usage"; exit 1 ;;
-esac
-
-# Note that these list commits in reverse order;
-# not that the order in inup matters...
-inup=`git-rev-list ^$ours $upstream` &&
-ours=`git-rev-list $ours ^$upstream` || exit
-
-tmp=.cherry-tmp$$
-patch=$tmp-patch
-mkdir $patch
-trap "rm -rf $tmp-*" 0 1 2 3 15
-
-_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
-_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
-
-for c in $inup
-do
-       git-diff-tree -p $c
-done | git-patch-id |
-while read id name
-do
-       echo $name >>$patch/$id
-done
-
-LF='
-'
-
-O=
-for c in $ours
-do
-       set x `git-diff-tree -p $c | git-patch-id`
-       if test "$2" != ""
-       then
-               if test -f "$patch/$2"
-               then
-                       sign=-
-               else
-                       sign=+
-               fi
-               case "$verbose" in
-               t)
-                       c=$(git-rev-list --pretty=oneline --max-count=1 $c)
-               esac
-               case "$O" in
-               '')     O="$sign $c" ;;
-               *)      O="$sign $c$LF$O" ;;
-               esac
-       fi
-done
-case "$O" in
-'') ;;
-*)  echo "$O" ;;
-esac
diff --git a/git-cherry.sh b/git-cherry.sh
new file mode 100755 (executable)
index 0000000..aad2e61
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano.
+#
+
+. git-sh-setup || die "Not a git archive."
+
+usage="usage: $0 "'[-v] <upstream> [<head>]
+
+             __*__*__*__*__> <upstream>
+            /
+  fork-point
+            \__+__+__+__+__+__+__+__> <head>
+
+Each commit between the fork-point and <head> is examined, and
+compared against the change each commit between the fork-point and
+<upstream> introduces.  If the change seems to be in the upstream,
+it is shown on the standard output with prefix "+".  Otherwise
+it is shown with prefix "-".
+'
+
+case "$1" in -v) verbose=t; shift ;; esac 
+
+case "$#,$1" in
+1,*..*)
+    upstream=$(expr "$1" : '\(.*\)\.\.') ours=$(expr "$1" : '.*\.\.\(.*\)$')
+    set x "$upstream" "$ours"
+    shift ;;
+esac
+
+case "$#" in
+1) upstream=`git-rev-parse --verify "$1"` &&
+   ours=`git-rev-parse --verify HEAD` || exit
+   ;;
+2) upstream=`git-rev-parse --verify "$1"` &&
+   ours=`git-rev-parse --verify "$2"` || exit
+   ;;
+*) echo >&2 "$usage"; exit 1 ;;
+esac
+
+# Note that these list commits in reverse order;
+# not that the order in inup matters...
+inup=`git-rev-list ^$ours $upstream` &&
+ours=`git-rev-list $ours ^$upstream` || exit
+
+tmp=.cherry-tmp$$
+patch=$tmp-patch
+mkdir $patch
+trap "rm -rf $tmp-*" 0 1 2 3 15
+
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+
+for c in $inup
+do
+       git-diff-tree -p $c
+done | git-patch-id |
+while read id name
+do
+       echo $name >>$patch/$id
+done
+
+LF='
+'
+
+O=
+for c in $ours
+do
+       set x `git-diff-tree -p $c | git-patch-id`
+       if test "$2" != ""
+       then
+               if test -f "$patch/$2"
+               then
+                       sign=-
+               else
+                       sign=+
+               fi
+               case "$verbose" in
+               t)
+                       c=$(git-rev-list --pretty=oneline --max-count=1 $c)
+               esac
+               case "$O" in
+               '')     O="$sign $c" ;;
+               *)      O="$sign $c$LF$O" ;;
+               esac
+       fi
+done
+case "$O" in
+'') ;;
+*)  echo "$O" ;;
+esac
diff --git a/git-clone-script b/git-clone-script
deleted file mode 100755 (executable)
index 0848a5d..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005, Linus Torvalds
-# Copyright (c) 2005, Junio C Hamano
-# 
-# Clone a repository into a different directory that does not yet exist.
-
-usage() {
-       echo >&2 "* git clone [-l [-s]] [-q] [-u <upload-pack>] <repo> <dir>"
-       exit 1
-}
-
-get_repo_base() {
-       (cd "$1" && (cd .git ; pwd)) 2> /dev/null
-}
-
-if [ -n "$GIT_SSL_NO_VERIFY" ]; then
-    curl_extra_args="-k"
-fi
-
-http_fetch () {
-       # $1 = Remote, $2 = Local
-       curl -nsf $curl_extra_args "$1" >"$2"
-}
-
-clone_dumb_http () {
-       # $1 - remote, $2 - local
-       cd "$2" &&
-       clone_tmp='.git/clone-tmp' &&
-       mkdir -p "$clone_tmp" || exit 1
-       http_fetch "$1/info/refs" "$clone_tmp/refs" &&
-       http_fetch "$1/objects/info/packs" "$clone_tmp/packs" || {
-               echo >&2 "Cannot get remote repository information.
-Perhaps git-update-server-info needs to be run there?"
-               exit 1;
-       }
-       while read type name
-       do
-               case "$type" in
-               P) ;;
-               *) continue ;;
-               esac &&
-
-               idx=`expr "$name" : '\(.*\)\.pack'`.idx
-               http_fetch "$1/objects/pack/$name" ".git/objects/pack/$name" &&
-               http_fetch "$1/objects/pack/$idx" ".git/objects/pack/$idx" &&
-               git-verify-pack ".git/objects/pack/$idx" || exit 1
-       done <"$clone_tmp/packs"
-
-       while read sha1 refname
-       do
-               name=`expr "$refname" : 'refs/\(.*\)'` &&
-               git-http-pull -v -a -w "$name" "$name" "$1/" || exit 1
-       done <"$clone_tmp/refs"
-       rm -fr "$clone_tmp"
-}
-
-quiet=
-use_local=no
-local_shared=no
-upload_pack=
-while
-       case "$#,$1" in
-       0,*) break ;;
-       *,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;;
-        *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) 
-          local_shared=yes ;;
-       *,-q|*,--quiet) quiet=-q ;;
-       1,-u|1,--upload-pack) usage ;;
-       *,-u|*,--upload-pack)
-               shift
-               upload_pack="--exec=$1" ;;
-       *,-*) usage ;;
-       *) break ;;
-       esac
-do
-       shift
-done
-
-# Turn the source into an absolute path if
-# it is local
-repo="$1"
-local=no
-if base=$(get_repo_base "$repo"); then
-       repo="$base"
-       local=yes
-fi
-
-dir="$2"
-mkdir "$dir" &&
-D=$(
-       (cd "$dir" && git-init-db && pwd)
-) &&
-test -d "$D" || usage
-
-# We do local magic only when the user tells us to.
-case "$local,$use_local" in
-yes,yes)
-       ( cd "$repo/objects" ) || {
-               echo >&2 "-l flag seen but $repo is not local."
-               exit 1
-       }
-
-       case "$local_shared" in
-       no)
-           # See if we can hardlink and drop "l" if not.
-           sample_file=$(cd "$repo" && \
-                         find objects -type f -print | sed -e 1q)
-
-           # objects directory should not be empty since we are cloning!
-           test -f "$repo/$sample_file" || exit
-
-           l=
-           if ln "$repo/$sample_file" "$D/.git/objects/sample" 2>/dev/null
-           then
-                   l=l
-           fi &&
-           rm -f "$D/.git/objects/sample" &&
-           cd "$repo" &&
-           find objects -type f -print |
-           cpio -puamd$l "$D/.git/" || exit 1
-           ;;
-       yes)
-           mkdir -p "$D/.git/objects/info"
-           {
-               test -f "$repo/objects/info/alternates" &&
-               cat "$repo/objects/info/alternates";
-               echo "$repo/objects"
-           } >"$D/.git/objects/info/alternates"
-           ;;
-       esac
-
-       # Make a duplicate of refs and HEAD pointer
-       HEAD=
-       if test -f "$repo/HEAD"
-       then
-               HEAD=HEAD
-       fi
-       tar Ccf "$repo" - refs $HEAD | tar Cxf "$D/.git" - || exit 1
-       ;;
-*)
-       case "$repo" in
-       rsync://*)
-               rsync $quiet -avz --ignore-existing "$repo/objects/" "$D/.git/objects/" &&
-               rsync $quiet -avz --ignore-existing "$repo/refs/" "$D/.git/refs/"
-               ;;
-       http://*)
-               clone_dumb_http "$repo" "$D"
-               ;;
-       *)
-               cd "$D" && case "$upload_pack" in
-               '') git-clone-pack $quiet "$repo" ;;
-               *) git-clone-pack $quiet "$upload_pack" "$repo" ;;
-               esac
-               ;;
-       esac
-       ;;
-esac
-
-# Update origin.
-mkdir -p "$D/.git/remotes/" &&
-rm -f "$D/.git/remotes/origin" &&
-echo >"$D/.git/remotes/origin" \
-"URL: $repo
-Pull: master:origin"
diff --git a/git-clone.sh b/git-clone.sh
new file mode 100755 (executable)
index 0000000..c076292
--- /dev/null
@@ -0,0 +1,165 @@
+#!/bin/sh
+#
+# Copyright (c) 2005, Linus Torvalds
+# Copyright (c) 2005, Junio C Hamano
+# 
+# Clone a repository into a different directory that does not yet exist.
+
+usage() {
+       echo >&2 "* git clone [-l [-s]] [-q] [-u <upload-pack>] <repo> <dir>"
+       exit 1
+}
+
+get_repo_base() {
+       (cd "$1" && (cd .git ; pwd)) 2> /dev/null
+}
+
+if [ -n "$GIT_SSL_NO_VERIFY" ]; then
+    curl_extra_args="-k"
+fi
+
+http_fetch () {
+       # $1 = Remote, $2 = Local
+       curl -nsf $curl_extra_args "$1" >"$2"
+}
+
+clone_dumb_http () {
+       # $1 - remote, $2 - local
+       cd "$2" &&
+       clone_tmp='.git/clone-tmp' &&
+       mkdir -p "$clone_tmp" || exit 1
+       http_fetch "$1/info/refs" "$clone_tmp/refs" &&
+       http_fetch "$1/objects/info/packs" "$clone_tmp/packs" || {
+               echo >&2 "Cannot get remote repository information.
+Perhaps git-update-server-info needs to be run there?"
+               exit 1;
+       }
+       while read type name
+       do
+               case "$type" in
+               P) ;;
+               *) continue ;;
+               esac &&
+
+               idx=`expr "$name" : '\(.*\)\.pack'`.idx
+               http_fetch "$1/objects/pack/$name" ".git/objects/pack/$name" &&
+               http_fetch "$1/objects/pack/$idx" ".git/objects/pack/$idx" &&
+               git-verify-pack ".git/objects/pack/$idx" || exit 1
+       done <"$clone_tmp/packs"
+
+       while read sha1 refname
+       do
+               name=`expr "$refname" : 'refs/\(.*\)'` &&
+               git-http-fetch -v -a -w "$name" "$name" "$1/" || exit 1
+       done <"$clone_tmp/refs"
+       rm -fr "$clone_tmp"
+}
+
+quiet=
+use_local=no
+local_shared=no
+upload_pack=
+while
+       case "$#,$1" in
+       0,*) break ;;
+       *,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;;
+        *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) 
+          local_shared=yes ;;
+       *,-q|*,--quiet) quiet=-q ;;
+       1,-u|1,--upload-pack) usage ;;
+       *,-u|*,--upload-pack)
+               shift
+               upload_pack="--exec=$1" ;;
+       *,-*) usage ;;
+       *) break ;;
+       esac
+do
+       shift
+done
+
+# Turn the source into an absolute path if
+# it is local
+repo="$1"
+local=no
+if base=$(get_repo_base "$repo"); then
+       repo="$base"
+       local=yes
+fi
+
+dir="$2"
+mkdir "$dir" &&
+D=$(
+       (cd "$dir" && git-init-db && pwd)
+) &&
+test -d "$D" || usage
+
+# We do local magic only when the user tells us to.
+case "$local,$use_local" in
+yes,yes)
+       ( cd "$repo/objects" ) || {
+               echo >&2 "-l flag seen but $repo is not local."
+               exit 1
+       }
+
+       case "$local_shared" in
+       no)
+           # See if we can hardlink and drop "l" if not.
+           sample_file=$(cd "$repo" && \
+                         find objects -type f -print | sed -e 1q)
+
+           # objects directory should not be empty since we are cloning!
+           test -f "$repo/$sample_file" || exit
+
+           l=
+           if ln "$repo/$sample_file" "$D/.git/objects/sample" 2>/dev/null
+           then
+                   l=l
+           fi &&
+           rm -f "$D/.git/objects/sample" &&
+           cd "$repo" &&
+           find objects -type f -print |
+           cpio -puamd$l "$D/.git/" || exit 1
+           ;;
+       yes)
+           mkdir -p "$D/.git/objects/info"
+           {
+               test -f "$repo/objects/info/alternates" &&
+               cat "$repo/objects/info/alternates";
+               echo "$repo/objects"
+           } >"$D/.git/objects/info/alternates"
+           ;;
+       esac
+
+       # Make a duplicate of refs and HEAD pointer
+       HEAD=
+       if test -f "$repo/HEAD"
+       then
+               HEAD=HEAD
+       fi
+       tar Ccf "$repo" - refs $HEAD | tar Cxf "$D/.git" - || exit 1
+       ;;
+*)
+       case "$repo" in
+       rsync://*)
+               rsync $quiet -avz --ignore-existing "$repo/objects/" "$D/.git/objects/" &&
+               rsync $quiet -avz --ignore-existing "$repo/refs/" "$D/.git/refs/"
+               ;;
+       http://*)
+               clone_dumb_http "$repo" "$D"
+               ;;
+       *)
+               cd "$D" && case "$upload_pack" in
+               '') git-clone-pack $quiet "$repo" ;;
+               *) git-clone-pack $quiet "$upload_pack" "$repo" ;;
+               esac
+               ;;
+       esac
+       ;;
+esac
+
+# Update origin.
+mkdir -p "$D/.git/remotes/" &&
+rm -f "$D/.git/remotes/origin" &&
+echo >"$D/.git/remotes/origin" \
+"URL: $repo
+Pull: master:origin"
diff --git a/git-commit-script b/git-commit-script
deleted file mode 100755 (executable)
index a2455b0..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Linus Torvalds
-#
-
-. git-sh-setup-script || die "Not a git archive"
-
-usage () {
-       die 'git commit [-a] [-v | --no-verify]  [-m <message>] [-F <logfile>] [(-C|-c) <commit>] [<path>...]'
-}
-
-all= logfile= use_commit= no_edit= log_given= log_message= verify=t signoff=
-while case "$#" in 0) break;; esac
-do
-  case "$1" in
-  -a|--a|--al|--all)
-    all=t
-    shift ;;
-  -F=*|--f=*|--fi=*|--fil=*|--file=*)
-    log_given=t$log_given
-    logfile=`expr "$1" : '-[^=]*=\(.*\)'`
-    no_edit=t
-    shift ;;
-  -F|--f|--fi|--fil|--file)
-    case "$#" in 1) usage ;; esac; shift
-    log_given=t$log_given
-    logfile="$1"
-    no_edit=t
-    shift ;;
-  -m=*|--m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*)
-    log_given=t$log_given
-    log_message=`expr "$1" : '-[^=]*=\(.*\)'`
-    no_edit=t
-    shift ;;
-  -m|--m|--me|--mes|--mess|--messa|--messag|--message)
-    case "$#" in 1) usage ;; esac; shift
-    log_given=t$log_given
-    log_message="$1"
-    no_edit=t
-    shift ;;
-  -c=*|--ree=*|--reed=*|--reedi=*|--reedit=*|--reedit-=*|--reedit-m=*|\
-  --reedit-me=*|--reedit-mes=*|--reedit-mess=*|--reedit-messa=*|\
-  --reedit-messag=*|--reedit-message=*)
-    log_given=t$log_given
-    use_commit=`expr "$1" : '-[^=]*=\(.*\)'`
-    shift ;;
-  -c|--ree|--reed|--reedi|--reedit|--reedit-|--reedit-m|--reedit-me|\
-  --reedit-mes|--reedit-mess|--reedit-messa|--reedit-messag|--reedit-message)
-    case "$#" in 1) usage ;; esac; shift
-    log_given=t$log_given
-    use_commit="$1"
-    shift ;;
-  -C=*|--reu=*|--reus=*|--reuse=*|--reuse-=*|--reuse-m=*|--reuse-me=*|\
-  --reuse-mes=*|--reuse-mess=*|--reuse-messa=*|--reuse-messag=*|\
-  --reuse-message=*)
-    log_given=t$log_given
-    use_commit=`expr "$1" : '-[^=]*=\(.*\)'`
-    no_edit=t
-    shift ;;
-  -C|--reu|--reus|--reuse|--reuse-|--reuse-m|--reuse-me|--reuse-mes|\
-  --reuse-mess|--reuse-messa|--reuse-messag|--reuse-message)
-    case "$#" in 1) usage ;; esac; shift
-    log_given=t$log_given
-    use_commit="$1"
-    no_edit=t
-    shift ;;
-  -e|--e|--ed|--edi|--edit)
-    no_edit=
-    shift ;;
-  -s|--s|--si|--sig|--sign|--signo|--signof|--signoff)
-    signoff=t
-    shift ;;
-  -n|--n|--no|--no-|--no-v|--no-ve|--no-ver|--no-veri|--no-verif|--no-verify)
-    verify=
-    shift ;;
-  -v|--v|--ve|--ver|--veri|--verif|--verify)
-    verify=t
-    shift ;;
-  --)
-    shift
-    break ;;
-  -*)
-     usage ;;
-  *)
-    break ;;
-  esac
-done
-
-case "$log_given" in
-tt*)
-  die "Only one of -c/-C/-F/-m can be used." ;;
-esac
-
-case "$all,$#" in
-t,*)
-       git-diff-files --name-only -z |
-       xargs -0 git-update-cache -q --remove --
-       ;;
-,0)
-       ;;
-*)
-       git-diff-files --name-only -z "$@" |
-       xargs -0 git-update-cache -q --remove --
-       ;;
-esac || exit 1
-git-update-cache -q --refresh || exit 1
-
-case "$verify" in
-t)
-       if test -x "$GIT_DIR"/hooks/pre-commit
-       then
-               "$GIT_DIR"/hooks/pre-commit || exit
-       fi
-esac
-
-if test "$log_message" != ''
-then
-       echo "$log_message"
-elif test "$logfile" != ""
-then
-       if test "$logfile" = -
-       then
-               test -t 0 &&
-               echo >&2 "(reading log message from standard input)"
-               cat
-       else
-               cat <"$logfile"
-       fi
-elif test "$use_commit" != ""
-then
-       git-cat-file commit "$use_commit" | sed -e '1,/^$/d'
-fi | git-stripspace >.editmsg
-
-case "$signoff" in
-t)
-       git-var GIT_COMMITTER_IDENT | sed -e '
-               s/>.*/>/
-               s/^/Signed-off-by: /
-       ' >>.editmsg
-       ;;
-esac
-
-if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
-       echo "#"
-       echo "# It looks like your may be committing a MERGE."
-       echo "# If this is not correct, please remove the file"
-       echo "# $GIT_DIR/MERGE_HEAD"
-       echo "# and try again"
-       echo "#"
-fi >>.editmsg
-
-PARENTS="-p HEAD"
-if [ ! -r "$GIT_DIR/HEAD" ]; then
-       if [ -z "$(git-ls-files)" ]; then
-               echo Nothing to commit 1>&2
-               exit 1
-       fi
-       PARENTS=""
-else
-       if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
-               PARENTS="-p HEAD -p MERGE_HEAD"
-       fi
-       if test "$use_commit" != ""
-       then
-               pick_author_script='
-               /^author /{
-                       h
-                       s/^author \([^<]*\) <[^>]*> .*$/\1/
-                       s/'\''/'\''\'\'\''/g
-                       s/.*/GIT_AUTHOR_NAME='\''&'\''/p
-
-                       g
-                       s/^author [^<]* <\([^>]*\)> .*$/\1/
-                       s/'\''/'\''\'\'\''/g
-                       s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
-
-                       g
-                       s/^author [^<]* <[^>]*> \(.*\)$/\1/
-                       s/'\''/'\''\'\'\''/g
-                       s/.*/GIT_AUTHOR_DATE='\''&'\''/p
-
-                       q
-               }
-               '
-               set_author_env=`git-cat-file commit "$use_commit" |
-               sed -ne "$pick_author_script"`
-               eval "$set_author_env"
-               export GIT_AUTHOR_NAME
-               export GIT_AUTHOR_EMAIL
-               export GIT_AUTHOR_DATE
-       fi
-fi
-git-status-script >>.editmsg
-if [ "$?" != "0" -a ! -f $GIT_DIR/MERGE_HEAD ]
-then
-       rm -f .editmsg
-       git-status-script
-       exit 1
-fi
-case "$no_edit" in
-'')
-       ${VISUAL:-${EDITOR:-vi}} .editmsg
-       ;;
-esac
-
-case "$verify" in
-t)
-       if test -x "$GIT_DIR"/hooks/commit-msg
-       then
-               "$GIT_DIR"/hooks/commit-msg .editmsg || exit
-       fi
-esac
-
-grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
-grep -v -i '^Signed-off-by' .cmitmsg >.cmitchk
-if test -s .cmitchk
-then
-       tree=$(git-write-tree) &&
-       commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) &&
-       echo $commit > "$GIT_DIR/HEAD" &&
-       rm -f -- "$GIT_DIR/MERGE_HEAD"
-else
-       echo >&2 "* no commit message?  aborting commit."
-       false
-fi
-ret="$?"
-rm -f .cmitmsg .editmsg .cmitchk
-
-if test -x "$GIT_DIR"/hooks/post-commit && test "$ret" = 0
-then
-       "$GIT_DIR"/hooks/post-commit
-fi
-exit "$ret"
diff --git a/git-commit.sh b/git-commit.sh
new file mode 100755 (executable)
index 0000000..741444a
--- /dev/null
@@ -0,0 +1,233 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Linus Torvalds
+#
+
+. git-sh-setup || die "Not a git archive"
+
+usage () {
+       die 'git commit [-a] [-v | --no-verify]  [-m <message>] [-F <logfile>] [(-C|-c) <commit>] [<path>...]'
+}
+
+all= logfile= use_commit= no_edit= log_given= log_message= verify=t signoff=
+while case "$#" in 0) break;; esac
+do
+  case "$1" in
+  -a|--a|--al|--all)
+    all=t
+    shift ;;
+  -F=*|--f=*|--fi=*|--fil=*|--file=*)
+    log_given=t$log_given
+    logfile=`expr "$1" : '-[^=]*=\(.*\)'`
+    no_edit=t
+    shift ;;
+  -F|--f|--fi|--fil|--file)
+    case "$#" in 1) usage ;; esac; shift
+    log_given=t$log_given
+    logfile="$1"
+    no_edit=t
+    shift ;;
+  -m=*|--m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*)
+    log_given=t$log_given
+    log_message=`expr "$1" : '-[^=]*=\(.*\)'`
+    no_edit=t
+    shift ;;
+  -m|--m|--me|--mes|--mess|--messa|--messag|--message)
+    case "$#" in 1) usage ;; esac; shift
+    log_given=t$log_given
+    log_message="$1"
+    no_edit=t
+    shift ;;
+  -c=*|--ree=*|--reed=*|--reedi=*|--reedit=*|--reedit-=*|--reedit-m=*|\
+  --reedit-me=*|--reedit-mes=*|--reedit-mess=*|--reedit-messa=*|\
+  --reedit-messag=*|--reedit-message=*)
+    log_given=t$log_given
+    use_commit=`expr "$1" : '-[^=]*=\(.*\)'`
+    shift ;;
+  -c|--ree|--reed|--reedi|--reedit|--reedit-|--reedit-m|--reedit-me|\
+  --reedit-mes|--reedit-mess|--reedit-messa|--reedit-messag|--reedit-message)
+    case "$#" in 1) usage ;; esac; shift
+    log_given=t$log_given
+    use_commit="$1"
+    shift ;;
+  -C=*|--reu=*|--reus=*|--reuse=*|--reuse-=*|--reuse-m=*|--reuse-me=*|\
+  --reuse-mes=*|--reuse-mess=*|--reuse-messa=*|--reuse-messag=*|\
+  --reuse-message=*)
+    log_given=t$log_given
+    use_commit=`expr "$1" : '-[^=]*=\(.*\)'`
+    no_edit=t
+    shift ;;
+  -C|--reu|--reus|--reuse|--reuse-|--reuse-m|--reuse-me|--reuse-mes|\
+  --reuse-mess|--reuse-messa|--reuse-messag|--reuse-message)
+    case "$#" in 1) usage ;; esac; shift
+    log_given=t$log_given
+    use_commit="$1"
+    no_edit=t
+    shift ;;
+  -e|--e|--ed|--edi|--edit)
+    no_edit=
+    shift ;;
+  -s|--s|--si|--sig|--sign|--signo|--signof|--signoff)
+    signoff=t
+    shift ;;
+  -n|--n|--no|--no-|--no-v|--no-ve|--no-ver|--no-veri|--no-verif|--no-verify)
+    verify=
+    shift ;;
+  -v|--v|--ve|--ver|--veri|--verif|--verify)
+    verify=t
+    shift ;;
+  --)
+    shift
+    break ;;
+  -*)
+     usage ;;
+  *)
+    break ;;
+  esac
+done
+
+case "$log_given" in
+tt*)
+  die "Only one of -c/-C/-F/-m can be used." ;;
+esac
+
+case "$all,$#" in
+t,*)
+       git-diff-files --name-only -z |
+       xargs -0 git-update-index -q --remove --
+       ;;
+,0)
+       ;;
+*)
+       git-diff-files --name-only -z "$@" |
+       xargs -0 git-update-index -q --remove --
+       ;;
+esac || exit 1
+git-update-index -q --refresh || exit 1
+
+case "$verify" in
+t)
+       if test -x "$GIT_DIR"/hooks/pre-commit
+       then
+               "$GIT_DIR"/hooks/pre-commit || exit
+       fi
+esac
+
+if test "$log_message" != ''
+then
+       echo "$log_message"
+elif test "$logfile" != ""
+then
+       if test "$logfile" = -
+       then
+               test -t 0 &&
+               echo >&2 "(reading log message from standard input)"
+               cat
+       else
+               cat <"$logfile"
+       fi
+elif test "$use_commit" != ""
+then
+       git-cat-file commit "$use_commit" | sed -e '1,/^$/d'
+fi | git-stripspace >.editmsg
+
+case "$signoff" in
+t)
+       git-var GIT_COMMITTER_IDENT | sed -e '
+               s/>.*/>/
+               s/^/Signed-off-by: /
+       ' >>.editmsg
+       ;;
+esac
+
+if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
+       echo "#"
+       echo "# It looks like your may be committing a MERGE."
+       echo "# If this is not correct, please remove the file"
+       echo "# $GIT_DIR/MERGE_HEAD"
+       echo "# and try again"
+       echo "#"
+fi >>.editmsg
+
+PARENTS="-p HEAD"
+if [ ! -r "$GIT_DIR/HEAD" ]; then
+       if [ -z "$(git-ls-files)" ]; then
+               echo Nothing to commit 1>&2
+               exit 1
+       fi
+       PARENTS=""
+else
+       if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
+               PARENTS="-p HEAD -p MERGE_HEAD"
+       fi
+       if test "$use_commit" != ""
+       then
+               pick_author_script='
+               /^author /{
+                       h
+                       s/^author \([^<]*\) <[^>]*> .*$/\1/
+                       s/'\''/'\''\'\'\''/g
+                       s/.*/GIT_AUTHOR_NAME='\''&'\''/p
+
+                       g
+                       s/^author [^<]* <\([^>]*\)> .*$/\1/
+                       s/'\''/'\''\'\'\''/g
+                       s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
+
+                       g
+                       s/^author [^<]* <[^>]*> \(.*\)$/\1/
+                       s/'\''/'\''\'\'\''/g
+                       s/.*/GIT_AUTHOR_DATE='\''&'\''/p
+
+                       q
+               }
+               '
+               set_author_env=`git-cat-file commit "$use_commit" |
+               sed -ne "$pick_author_script"`
+               eval "$set_author_env"
+               export GIT_AUTHOR_NAME
+               export GIT_AUTHOR_EMAIL
+               export GIT_AUTHOR_DATE
+       fi
+fi
+git-status >>.editmsg
+if [ "$?" != "0" -a ! -f $GIT_DIR/MERGE_HEAD ]
+then
+       rm -f .editmsg
+       git-status
+       exit 1
+fi
+case "$no_edit" in
+'')
+       ${VISUAL:-${EDITOR:-vi}} .editmsg
+       ;;
+esac
+
+case "$verify" in
+t)
+       if test -x "$GIT_DIR"/hooks/commit-msg
+       then
+               "$GIT_DIR"/hooks/commit-msg .editmsg || exit
+       fi
+esac
+
+grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
+grep -v -i '^Signed-off-by' .cmitmsg >.cmitchk
+if test -s .cmitchk
+then
+       tree=$(git-write-tree) &&
+       commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) &&
+       echo $commit > "$GIT_DIR/HEAD" &&
+       rm -f -- "$GIT_DIR/MERGE_HEAD"
+else
+       echo >&2 "* no commit message?  aborting commit."
+       false
+fi
+ret="$?"
+rm -f .cmitmsg .editmsg .cmitchk
+
+if test -x "$GIT_DIR"/hooks/post-commit && test "$ret" = 0
+then
+       "$GIT_DIR"/hooks/post-commit
+fi
+exit "$ret"
diff --git a/git-count-objects-script b/git-count-objects-script
deleted file mode 100755 (executable)
index 86432db..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-. git-sh-setup-script
-
-echo $(find "$GIT_DIR/objects"/?? -type f -print | wc -l) objects, \
-$({
-    echo 0
-    # "no-such" is to help Darwin folks by not using xargs -r.
-    find "$GIT_DIR/objects"/?? -type f -print 2>/dev/null |
-    xargs du -k "$GIT_DIR/objects/no-such" 2>/dev/null |
-    sed -e 's/[        ].*/ +/'
-    echo p
-} | dc) kilobytes
diff --git a/git-count-objects.sh b/git-count-objects.sh
new file mode 100755 (executable)
index 0000000..74ee4f3
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+. git-sh-setup
+
+echo $(find "$GIT_DIR/objects"/?? -type f -print | wc -l) objects, \
+$({
+    echo 0
+    # "no-such" is to help Darwin folks by not using xargs -r.
+    find "$GIT_DIR/objects"/?? -type f -print 2>/dev/null |
+    xargs du -k "$GIT_DIR/objects/no-such" 2>/dev/null |
+    sed -e 's/[        ].*/ +/'
+    echo p
+} | dc) kilobytes
diff --git a/git-cvsimport-script b/git-cvsimport-script
deleted file mode 100755 (executable)
index 5079c79..0000000
+++ /dev/null
@@ -1,823 +0,0 @@
-#!/usr/bin/perl -w
-
-# This tool is copyright (c) 2005, Matthias Urlichs.
-# It is released under the Gnu Public License, version 2.
-#
-# The basic idea is to aggregate CVS check-ins into related changes.
-# Fortunately, "cvsps" does that for us; all we have to do is to parse
-# its output.
-#
-# Checking out the files is done by a single long-running CVS connection
-# / server process.
-#
-# The head revision is on branch "origin" by default.
-# You can change that with the '-o' option.
-
-use strict;
-use warnings;
-use Getopt::Std;
-use File::Spec;
-use File::Temp qw(tempfile);
-use File::Path qw(mkpath);
-use File::Basename qw(basename dirname);
-use Time::Local;
-use IO::Socket;
-use IO::Pipe;
-use POSIX qw(strftime dup2);
-use IPC::Open2;
-
-$SIG{'PIPE'}="IGNORE";
-$ENV{'TZ'}="UTC";
-
-our($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_s,$opt_m,$opt_M);
-
-sub usage() {
-       print STDERR <<END;
-Usage: ${\basename $0}     # fetch/update GIT from CVS
-       [-o branch-for-HEAD] [-h] [-v] [-d CVSROOT]
-       [-p opts-for-cvsps] [-C GIT_repository] [-z fuzz]
-       [-i] [-k] [-u] [-s subst] [-m] [-M regex] [CVS_module]
-END
-       exit(1);
-}
-
-getopts("hivmkuo:d:p:C:z:s:M:") or usage();
-usage if $opt_h;
-
-@ARGV <= 1 or usage();
-
-if($opt_d) {
-       $ENV{"CVSROOT"} = $opt_d;
-} elsif(-f 'CVS/Root') {
-       open my $f, '<', 'CVS/Root' or die 'Failed to open CVS/Root';
-       $opt_d = <$f>;
-       chomp $opt_d;
-       close $f;
-       $ENV{"CVSROOT"} = $opt_d;
-} elsif($ENV{"CVSROOT"}) {
-       $opt_d = $ENV{"CVSROOT"};
-} else {
-       die "CVSROOT needs to be set";
-}
-$opt_o ||= "origin";
-$opt_s ||= "-";
-my $git_tree = $opt_C;
-$git_tree ||= ".";
-
-my $cvs_tree;
-if ($#ARGV == 0) {
-       $cvs_tree = $ARGV[0];
-} elsif (-f 'CVS/Repository') {
-       open my $f, '<', 'CVS/Repository' or 
-           die 'Failed to open CVS/Repository';
-       $cvs_tree = <$f>;
-       chomp $cvs_tree;
-       close $f;
-} else {
-       usage();
-}
-
-our @mergerx = ();
-if ($opt_m) {
-       @mergerx = ( qr/\W(?:from|of|merge|merging|merged) (\w+)/i );
-}
-if ($opt_M) {
-       push (@mergerx, qr/$opt_M/);
-}
-
-select(STDERR); $|=1; select(STDOUT);
-
-
-package CVSconn;
-# Basic CVS dialog.
-# We're only interested in connecting and downloading, so ...
-
-use File::Spec;
-use File::Temp qw(tempfile);
-use POSIX qw(strftime dup2);
-
-sub new {
-       my($what,$repo,$subdir) = @_;
-       $what=ref($what) if ref($what);
-
-       my $self = {};
-       $self->{'buffer'} = "";
-       bless($self,$what);
-
-       $repo =~ s#/+$##;
-       $self->{'fullrep'} = $repo;
-       $self->conn();
-
-       $self->{'subdir'} = $subdir;
-       $self->{'lines'} = undef;
-
-       return $self;
-}
-
-sub conn {
-       my $self = shift;
-       my $repo = $self->{'fullrep'};
-       if($repo =~ s/^:pserver:(?:(.*?)(?::(.*?))?@)?([^:\/]*)(?::(\d*))?//) {
-               my($user,$pass,$serv,$port) = ($1,$2,$3,$4);
-               $user="anonymous" unless defined $user;
-               my $rr2 = "-";
-               unless($port) {
-                       $rr2 = ":pserver:$user\@$serv:$repo";
-                       $port=2401;
-               }
-               my $rr = ":pserver:$user\@$serv:$port$repo";
-
-               unless($pass) {
-                       open(H,$ENV{'HOME'}."/.cvspass") and do {
-                               # :pserver:cvs@mea.tmt.tele.fi:/cvsroot/zmailer Ah<Z
-                               while(<H>) {
-                                       chomp;
-                                       s/^\/\d+\s+//;
-                                       my ($w,$p) = split(/\s/,$_,2);
-                                       if($w eq $rr or $w eq $rr2) {
-                                               $pass = $p;
-                                               last;
-                                       }
-                               }
-                       };
-               }
-               $pass="A" unless $pass;
-
-               my $s = IO::Socket::INET->new(PeerHost => $serv, PeerPort => $port);
-               die "Socket to $serv: $!\n" unless defined $s;
-               $s->write("BEGIN AUTH REQUEST\n$repo\n$user\n$pass\nEND AUTH REQUEST\n")
-                       or die "Write to $serv: $!\n";
-               $s->flush();
-
-               my $rep = <$s>;
-
-               if($rep ne "I LOVE YOU\n") {
-                       $rep="<unknown>" unless $rep;
-                       die "AuthReply: $rep\n";
-               }
-               $self->{'socketo'} = $s;
-               $self->{'socketi'} = $s;
-       } else { # local or ext: Fork off our own cvs server.
-               my $pr = IO::Pipe->new();
-               my $pw = IO::Pipe->new();
-               my $pid = fork();
-               die "Fork: $!\n" unless defined $pid;
-               my $cvs = 'cvs';
-               $cvs = $ENV{CVS_SERVER} if exists $ENV{CVS_SERVER};
-               my $rsh = 'rsh';
-               $rsh = $ENV{CVS_RSH} if exists $ENV{CVS_RSH};
-
-               my @cvs = ($cvs, 'server');
-               my ($local, $user, $host);
-               $local = $repo =~ s/:local://;
-               if (!$local) {
-                   $repo =~ s/:ext://;
-                   $local = !($repo =~ s/^(?:([^\@:]+)\@)?([^:]+)://);
-                   ($user, $host) = ($1, $2);
-               }
-               if (!$local) {
-                   if ($user) {
-                       unshift @cvs, $rsh, '-l', $user, $host;
-                   } else {
-                       unshift @cvs, $rsh, $host;
-                   }
-               }
-
-               unless($pid) {
-                       $pr->writer();
-                       $pw->reader();
-                       dup2($pw->fileno(),0);
-                       dup2($pr->fileno(),1);
-                       $pr->close();
-                       $pw->close();
-                       exec(@cvs);
-               }
-               $pw->writer();
-               $pr->reader();
-               $self->{'socketo'} = $pw;
-               $self->{'socketi'} = $pr;
-       }
-       $self->{'socketo'}->write("Root $repo\n");
-
-       # Trial and error says that this probably is the minimum set
-       $self->{'socketo'}->write("Valid-responses ok error Valid-requests Mode M Mbinary E Checked-in Created Updated Merged Removed\n");
-
-       $self->{'socketo'}->write("valid-requests\n");
-       $self->{'socketo'}->flush();
-
-       chomp(my $rep=$self->readline());
-       if($rep !~ s/^Valid-requests\s*//) {
-               $rep="<unknown>" unless $rep;
-               die "Expected Valid-requests from server, but got: $rep\n";
-       }
-       chomp(my $res=$self->readline());
-       die "validReply: $res\n" if $res ne "ok";
-
-       $self->{'socketo'}->write("UseUnchanged\n") if $rep =~ /\bUseUnchanged\b/;
-       $self->{'repo'} = $repo;
-}
-
-sub readline {
-       my($self) = @_;
-       return $self->{'socketi'}->getline();
-}
-
-sub _file {
-       # Request a file with a given revision.
-       # Trial and error says this is a good way to do it. :-/
-       my($self,$fn,$rev) = @_;
-       $self->{'socketo'}->write("Argument -N\n") or return undef;
-       $self->{'socketo'}->write("Argument -P\n") or return undef;
-       # -kk: Linus' version doesn't use it - defaults to off
-       if ($opt_k) {
-           $self->{'socketo'}->write("Argument -kk\n") or return undef;
-       }
-       $self->{'socketo'}->write("Argument -r\n") or return undef;
-       $self->{'socketo'}->write("Argument $rev\n") or return undef;
-       $self->{'socketo'}->write("Argument --\n") or return undef;
-       $self->{'socketo'}->write("Argument $self->{'subdir'}/$fn\n") or return undef;
-       $self->{'socketo'}->write("Directory .\n") or return undef;
-       $self->{'socketo'}->write("$self->{'repo'}\n") or return undef;
-       # $self->{'socketo'}->write("Sticky T1.0\n") or return undef;
-       $self->{'socketo'}->write("co\n") or return undef;
-       $self->{'socketo'}->flush() or return undef;
-       $self->{'lines'} = 0;
-       return 1;
-}
-sub _line {
-       # Read a line from the server.
-       # ... except that 'line' may be an entire file. ;-)
-       my($self, $fh) = @_;
-       die "Not in lines" unless defined $self->{'lines'};
-
-       my $line;
-       my $res=0;
-       while(defined($line = $self->readline())) {
-               # M U gnupg-cvs-rep/AUTHORS
-               # Updated gnupg-cvs-rep/
-               # /daten/src/rsync/gnupg-cvs-rep/AUTHORS
-               # /AUTHORS/1.1///T1.1
-               # u=rw,g=rw,o=rw
-               # 0
-               # ok
-
-               if($line =~ s/^(?:Created|Updated) //) {
-                       $line = $self->readline(); # path
-                       $line = $self->readline(); # Entries line
-                       my $mode = $self->readline(); chomp $mode;
-                       $self->{'mode'} = $mode;
-                       defined (my $cnt = $self->readline())
-                               or die "EOF from server after 'Changed'\n";
-                       chomp $cnt;
-                       die "Duh: Filesize $cnt" if $cnt !~ /^\d+$/;
-                       $line="";
-                       $res=0;
-                       while($cnt) {
-                               my $buf;
-                               my $num = $self->{'socketi'}->read($buf,$cnt);
-                               die "Server: Filesize $cnt: $num: $!\n" if not defined $num or $num<=0;
-                               print $fh $buf;
-                               $res += $num;
-                               $cnt -= $num;
-                       }
-               } elsif($line =~ s/^ //) {
-                       print $fh $line;
-                       $res += length($line);
-               } elsif($line =~ /^M\b/) {
-                       # output, do nothing
-               } elsif($line =~ /^Mbinary\b/) {
-                       my $cnt;
-                       die "EOF from server after 'Mbinary'" unless defined ($cnt = $self->readline());
-                       chomp $cnt;
-                       die "Duh: Mbinary $cnt" if $cnt !~ /^\d+$/ or $cnt<1;
-                       $line="";
-                       while($cnt) {
-                               my $buf;
-                               my $num = $self->{'socketi'}->read($buf,$cnt);
-                               die "S: Mbinary $cnt: $num: $!\n" if not defined $num or $num<=0;
-                               print $fh $buf;
-                               $res += $num;
-                               $cnt -= $num;
-                       }
-               } else {
-                       chomp $line;
-                       if($line eq "ok") {
-                               # print STDERR "S: ok (".length($res).")\n";
-                               return $res;
-                       } elsif($line =~ s/^E //) {
-                               # print STDERR "S: $line\n";
-                       } elsif($line =~ /^Remove-entry /i) {
-                               $line = $self->readline(); # filename
-                               $line = $self->readline(); # OK
-                               chomp $line;
-                               die "Unknown: $line" if $line ne "ok";
-                               return -1;
-                       } else {
-                               die "Unknown: $line\n";
-                       }
-               }
-       }
-}
-sub file {
-       my($self,$fn,$rev) = @_;
-       my $res;
-
-       my ($fh, $name) = tempfile('gitcvs.XXXXXX', 
-                   DIR => File::Spec->tmpdir(), UNLINK => 1);
-
-       $self->_file($fn,$rev) and $res = $self->_line($fh);
-
-       if (!defined $res) {
-           # retry
-           $self->conn();
-           $self->_file($fn,$rev)
-                   or die "No file command send\n";
-           $res = $self->_line($fh);
-           die "No input: $fn $rev\n" unless defined $res;
-       }
-       close ($fh);
-
-       return ($name, $res);
-}
-
-
-package main;
-
-my $cvs = CVSconn->new($opt_d, $cvs_tree);
-
-
-sub pdate($) {
-       my($d) = @_;
-       m#(\d{2,4})/(\d\d)/(\d\d)\s(\d\d):(\d\d)(?::(\d\d))?#
-               or die "Unparseable date: $d\n";
-       my $y=$1; $y-=1900 if $y>1900;
-       return timegm($6||0,$5,$4,$3,$2-1,$y);
-}
-
-sub pmode($) {
-       my($mode) = @_;
-       my $m = 0;
-       my $mm = 0;
-       my $um = 0;
-       for my $x(split(//,$mode)) {
-               if($x eq ",") {
-                       $m |= $mm&$um;
-                       $mm = 0;
-                       $um = 0;
-               } elsif($x eq "u") { $um |= 0700;
-               } elsif($x eq "g") { $um |= 0070;
-               } elsif($x eq "o") { $um |= 0007;
-               } elsif($x eq "r") { $mm |= 0444;
-               } elsif($x eq "w") { $mm |= 0222;
-               } elsif($x eq "x") { $mm |= 0111;
-               } elsif($x eq "=") { # do nothing
-               } else { die "Unknown mode: $mode\n";
-               }
-       }
-       $m |= $mm&$um;
-       return $m;
-}
-
-sub getwd() {
-       my $pwd = `pwd`;
-       chomp $pwd;
-       return $pwd;
-}
-
-
-sub get_headref($$) {
-    my $name    = shift;
-    my $git_dir = shift; 
-    my $sha;
-    
-    if (open(C,"$git_dir/refs/heads/$name")) {
-       chomp($sha = <C>);
-       close(C);
-       length($sha) == 40
-           or die "Cannot get head id for $name ($sha): $!\n";
-    }
-    return $sha;
-}
-
-
--d $git_tree
-       or mkdir($git_tree,0777)
-       or die "Could not create $git_tree: $!";
-chdir($git_tree);
-
-my $last_branch = "";
-my $orig_branch = "";
-my $forward_master = 0;
-my %branch_date;
-
-my $git_dir = $ENV{"GIT_DIR"} || ".git";
-$git_dir = getwd()."/".$git_dir unless $git_dir =~ m#^/#;
-$ENV{"GIT_DIR"} = $git_dir;
-my $orig_git_index;
-$orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE};
-my ($git_ih, $git_index) = tempfile('gitXXXXXX', SUFFIX => '.idx',
-                                   DIR => File::Spec->tmpdir());
-close ($git_ih);
-$ENV{GIT_INDEX_FILE} = $git_index;
-unless(-d $git_dir) {
-       system("git-init-db");
-       die "Cannot init the GIT db at $git_tree: $?\n" if $?;
-       system("git-read-tree");
-       die "Cannot init an empty tree: $?\n" if $?;
-
-       $last_branch = $opt_o;
-       $orig_branch = "";
-} else {
-       -f "$git_dir/refs/heads/$opt_o"
-               or die "Branch '$opt_o' does not exist.\n".
-                      "Either use the correct '-o branch' option,\n".
-                      "or import to a new repository.\n";
-
-       $last_branch = basename(readlink("$git_dir/HEAD"));
-       unless($last_branch) {
-               warn "Cannot read the last branch name: $! -- assuming 'master'\n";
-               $last_branch = "master";
-       }
-       $orig_branch = $last_branch;
-       if (-f "$git_dir/CVS2GIT_HEAD") {
-               die <<EOM;
-CVS2GIT_HEAD exists.
-Make sure your working directory corresponds to HEAD and remove CVS2GIT_HEAD.
-You may need to run
-
-    git-read-tree -m -u CVS2GIT_HEAD HEAD
-EOM
-       }
-       system('cp', "$git_dir/HEAD", "$git_dir/CVS2GIT_HEAD");
-
-       $forward_master =
-           $opt_o ne 'master' && -f "$git_dir/refs/heads/master" &&
-           system('cmp', '-s', "$git_dir/refs/heads/master", 
-                               "$git_dir/refs/heads/$opt_o") == 0;
-
-       # populate index
-       system('git-read-tree', $last_branch);
-       die "read-tree failed: $?\n" if $?;
-
-       # Get the last import timestamps
-       opendir(D,"$git_dir/refs/heads");
-       while(defined(my $head = readdir(D))) {
-               next if $head =~ /^\./;
-               open(F,"$git_dir/refs/heads/$head")
-                       or die "Bad head branch: $head: $!\n";
-               chomp(my $ftag = <F>);
-               close(F);
-               open(F,"git-cat-file commit $ftag |");
-               while(<F>) {
-                       next unless /^author\s.*\s(\d+)\s[-+]\d{4}$/;
-                       $branch_date{$head} = $1;
-                       last;
-               }
-               close(F);
-       }
-       closedir(D);
-}
-
--d $git_dir
-       or die "Could not create git subdir ($git_dir).\n";
-
-my $pid = open(CVS,"-|");
-die "Cannot fork: $!\n" unless defined $pid;
-unless($pid) {
-       my @opt;
-       @opt = split(/,/,$opt_p) if defined $opt_p;
-       unshift @opt, '-z', $opt_z if defined $opt_z;
-       exec("cvsps",@opt,"-u","-A","--cvs-direct",'--root',$opt_d,$cvs_tree);
-       die "Could not start cvsps: $!\n";
-}
-
-
-## cvsps output:
-#---------------------
-#PatchSet 314
-#Date: 1999/09/18 13:03:59
-#Author: wkoch
-#Branch: STABLE-BRANCH-1-0
-#Ancestor branch: HEAD
-#Tag: (none)
-#Log:
-#    See ChangeLog: Sat Sep 18 13:03:28 CEST 1999  Werner Koch
-#Members:
-#      README:1.57->1.57.2.1
-#      VERSION:1.96->1.96.2.1
-#
-#---------------------
-
-my $state = 0;
-
-my($patchset,$date,$author,$branch,$ancestor,$tag,$logmsg);
-my(@old,@new);
-my $commit = sub {
-       my $pid;
-       while(@old) {
-               my @o2;
-               if(@old > 55) {
-                       @o2 = splice(@old,0,50);
-               } else {
-                       @o2 = @old;
-                       @old = ();
-               }
-               system("git-update-cache","--force-remove","--",@o2);
-               die "Cannot remove files: $?\n" if $?;
-       }
-       while(@new) {
-               my @n2;
-               if(@new > 12) {
-                       @n2 = splice(@new,0,10);
-               } else {
-                       @n2 = @new;
-                       @new = ();
-               }
-               system("git-update-cache","--add",
-                       (map { ('--cacheinfo', @$_) } @n2));
-               die "Cannot add files: $?\n" if $?;
-       }
-
-       $pid = open(C,"-|");
-       die "Cannot fork: $!" unless defined $pid;
-       unless($pid) {
-               exec("git-write-tree");
-               die "Cannot exec git-write-tree: $!\n";
-       }
-       chomp(my $tree = <C>);
-       length($tree) == 40
-               or die "Cannot get tree id ($tree): $!\n";
-       close(C)
-               or die "Error running git-write-tree: $?\n";
-       print "Tree ID $tree\n" if $opt_v;
-
-       my $parent = "";
-       if(open(C,"$git_dir/refs/heads/$last_branch")) {
-               chomp($parent = <C>);
-               close(C);
-               length($parent) == 40
-                       or die "Cannot get parent id ($parent): $!\n";
-               print "Parent ID $parent\n" if $opt_v;
-       }
-
-       my $pr = IO::Pipe->new() or die "Cannot open pipe: $!\n";
-       my $pw = IO::Pipe->new() or die "Cannot open pipe: $!\n";
-       $pid = fork();
-       die "Fork: $!\n" unless defined $pid;
-       unless($pid) {
-               $pr->writer();
-               $pw->reader();
-               dup2($pw->fileno(),0);
-               dup2($pr->fileno(),1);
-               $pr->close();
-               $pw->close();
-
-               my @par = ();
-               @par = ("-p",$parent) if $parent;
-
-               # loose detection of merges
-               # based on the commit msg
-               foreach my $rx (@mergerx) {
-                       if ($logmsg =~ $rx) {
-                               my $mparent = $1;
-                               if ($mparent eq 'HEAD') { $mparent = $opt_o };
-                               if ( -e "$git_dir/refs/heads/$mparent") {
-                                       $mparent = get_headref($mparent, $git_dir);
-                                       push @par, '-p', $mparent;
-                                       # printing here breaks import # 
-                                       # # print "Merge parent branch: $mparent\n" if $opt_v;
-                               }
-                       } 
-               }
-
-               exec("env",
-                       "GIT_AUTHOR_NAME=$author",
-                       "GIT_AUTHOR_EMAIL=$author",
-                       "GIT_AUTHOR_DATE=".strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)),
-                       "GIT_COMMITTER_NAME=$author",
-                       "GIT_COMMITTER_EMAIL=$author",
-                       "GIT_COMMITTER_DATE=".strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)),
-                       "git-commit-tree", $tree,@par);
-               die "Cannot exec git-commit-tree: $!\n";
-       }
-       $pw->writer();
-       $pr->reader();
-
-       # compatibility with git2cvs
-       substr($logmsg,32767) = "" if length($logmsg) > 32767;
-       $logmsg =~ s/[\s\n]+\z//;
-
-       print $pw "$logmsg\n"
-               or die "Error writing to git-commit-tree: $!\n";
-       $pw->close();
-
-       print "Committed patch $patchset ($branch ".strftime("%Y-%m-%d %H:%M:%S",gmtime($date)).")\n" if $opt_v;
-       chomp(my $cid = <$pr>);
-       length($cid) == 40
-               or die "Cannot get commit id ($cid): $!\n";
-       print "Commit ID $cid\n" if $opt_v;
-       $pr->close();
-
-       waitpid($pid,0);
-       die "Error running git-commit-tree: $?\n" if $?;
-
-       open(C,">$git_dir/refs/heads/$branch")
-               or die "Cannot open branch $branch for update: $!\n";
-       print C "$cid\n"
-               or die "Cannot write branch $branch for update: $!\n";
-       close(C)
-               or die "Cannot write branch $branch for update: $!\n";
-
-       if($tag) {
-               my($in, $out) = ('','');
-               my($xtag) = $tag;
-               $xtag =~ s/\s+\*\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **
-               $xtag =~ tr/_/\./ if ( $opt_u );
-               
-               my $pid = open2($in, $out, 'git-mktag');
-               print $out "object $cid\n".
-                   "type commit\n".
-                   "tag $xtag\n".
-                   "tagger $author <$author>\n"
-                   or die "Cannot create tag object $xtag: $!\n";
-               close($out)
-                   or die "Cannot create tag object $xtag: $!\n";
-
-               my $tagobj = <$in>;
-               chomp $tagobj;
-
-               if ( !close($in) or waitpid($pid, 0) != $pid or
-                    $? != 0 or $tagobj !~ /^[0123456789abcdef]{40}$/ ) {
-                   die "Cannot create tag object $xtag: $!\n";
-               }
-               
-
-               open(C,">$git_dir/refs/tags/$xtag")
-                       or die "Cannot create tag $xtag: $!\n";
-               print C "$tagobj\n"
-                       or die "Cannot write tag $xtag: $!\n";
-               close(C)
-                       or die "Cannot write tag $xtag: $!\n";
-
-               print "Created tag '$xtag' on '$branch'\n" if $opt_v;
-       }
-};
-
-while(<CVS>) {
-       chomp;
-       if($state == 0 and /^-+$/) {
-               $state = 1;
-       } elsif($state == 0) {
-               $state = 1;
-               redo;
-       } elsif(($state==0 or $state==1) and s/^PatchSet\s+//) {
-               $patchset = 0+$_;
-               $state=2;
-       } elsif($state == 2 and s/^Date:\s+//) {
-               $date = pdate($_);
-               unless($date) {
-                       print STDERR "Could not parse date: $_\n";
-                       $state=0;
-                       next;
-               }
-               $state=3;
-       } elsif($state == 3 and s/^Author:\s+//) {
-               s/\s+$//;
-               $author = $_;
-               $state = 4;
-       } elsif($state == 4 and s/^Branch:\s+//) {
-               s/\s+$//;
-               s/[\/]/$opt_s/g;
-               $branch = $_;
-               $state = 5;
-       } elsif($state == 5 and s/^Ancestor branch:\s+//) {
-               s/\s+$//;
-               $ancestor = $_;
-               $ancestor = $opt_o if $ancestor eq "HEAD";
-               $state = 6;
-       } elsif($state == 5) {
-               $ancestor = undef;
-               $state = 6;
-               redo;
-       } elsif($state == 6 and s/^Tag:\s+//) {
-               s/\s+$//;
-               if($_ eq "(none)") {
-                       $tag = undef;
-               } else {
-                       $tag = $_;
-               }
-               $state = 7;
-       } elsif($state == 7 and /^Log:/) {
-               $logmsg = "";
-               $state = 8;
-       } elsif($state == 8 and /^Members:/) {
-               $branch = $opt_o if $branch eq "HEAD";
-               if(defined $branch_date{$branch} and $branch_date{$branch} >= $date) {
-                       # skip
-                       print "skip patchset $patchset: $date before $branch_date{$branch}\n" if $opt_v;
-                       $state = 11;
-                       next;
-               }
-               if($ancestor) {
-                       if(-f "$git_dir/refs/heads/$branch") {
-                               print STDERR "Branch $branch already exists!\n";
-                               $state=11;
-                               next;
-                       }
-                       unless(open(H,"$git_dir/refs/heads/$ancestor")) {
-                               print STDERR "Branch $ancestor does not exist!\n";
-                               $state=11;
-                               next;
-                       }
-                       chomp(my $id = <H>);
-                       close(H);
-                       unless(open(H,"> $git_dir/refs/heads/$branch")) {
-                               print STDERR "Could not create branch $branch: $!\n";
-                               $state=11;
-                               next;
-                       }
-                       print H "$id\n"
-                               or die "Could not write branch $branch: $!";
-                       close(H)
-                               or die "Could not write branch $branch: $!";
-               }
-               if(($ancestor || $branch) ne $last_branch) {
-                       print "Switching from $last_branch to $branch\n" if $opt_v;
-                       system("git-read-tree", $branch);
-                       die "read-tree failed: $?\n" if $?;
-               }
-               $last_branch = $branch if $branch ne $last_branch;
-               $state = 9;
-       } elsif($state == 8) {
-               $logmsg .= "$_\n";
-       } elsif($state == 9 and /^\s+(.+?):(INITIAL|\d+(?:\.\d+)+)->(\d+(?:\.\d+)+)\s*$/) {
-#      VERSION:1.96->1.96.2.1
-               my $init = ($2 eq "INITIAL");
-               my $fn = $1;
-               my $rev = $3;
-               $fn =~ s#^/+##;
-               my ($tmpname, $size) = $cvs->file($fn,$rev);
-               if($size == -1) {
-                       push(@old,$fn);
-                       print "Drop $fn\n" if $opt_v;
-               } else {
-                       print "".($init ? "New" : "Update")." $fn: $size bytes\n" if $opt_v;
-                       open my $F, '-|', "git-hash-object -w $tmpname"
-                               or die "Cannot create object: $!\n";
-                       my $sha = <$F>;
-                       chomp $sha;
-                       close $F;
-                       my $mode = pmode($cvs->{'mode'});
-                       push(@new,[$mode, $sha, $fn]); # may be resurrected!
-               }
-               unlink($tmpname);
-       } elsif($state == 9 and /^\s+(.+?):\d+(?:\.\d+)+->(\d+(?:\.\d+)+)\(DEAD\)\s*$/) {
-               my $fn = $1;
-               $fn =~ s#^/+##;
-               push(@old,$fn);
-               print "Delete $fn\n" if $opt_v;
-       } elsif($state == 9 and /^\s*$/) {
-               $state = 10;
-       } elsif(($state == 9 or $state == 10) and /^-+$/) {
-               &$commit();
-               $state = 1;
-       } elsif($state == 11 and /^-+$/) {
-               $state = 1;
-       } elsif(/^-+$/) { # end of unknown-line processing
-               $state = 1;
-       } elsif($state != 11) { # ignore stuff when skipping
-               print "* UNKNOWN LINE * $_\n";
-       }
-}
-&$commit() if $branch and $state != 11;
-
-unlink($git_index);
-
-if (defined $orig_git_index) {
-       $ENV{GIT_INDEX_FILE} = $orig_git_index;
-} else {
-       delete $ENV{GIT_INDEX_FILE};
-}
-
-# Now switch back to the branch we were in before all of this happened
-if($orig_branch) {
-       print "DONE\n" if $opt_v;
-       system("cp","$git_dir/refs/heads/$opt_o","$git_dir/refs/heads/master")
-               if $forward_master;
-       unless ($opt_i) {
-               system('git-read-tree', '-m', '-u', 'CVS2GIT_HEAD', 'HEAD');
-               die "read-tree failed: $?\n" if $?;
-       }
-} else {
-       $orig_branch = "master";
-       print "DONE; creating $orig_branch branch\n" if $opt_v;
-       system("cp","$git_dir/refs/heads/$opt_o","$git_dir/refs/heads/master")
-               unless -f "$git_dir/refs/heads/master";
-       unlink("$git_dir/HEAD");
-       symlink("refs/heads/$orig_branch","$git_dir/HEAD");
-       unless ($opt_i) {
-               system('git checkout');
-               die "checkout failed: $?\n" if $?;
-       }
-}
-unlink("$git_dir/CVS2GIT_HEAD");
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
new file mode 100755 (executable)
index 0000000..565f4f1
--- /dev/null
@@ -0,0 +1,823 @@
+#!/usr/bin/perl -w
+
+# This tool is copyright (c) 2005, Matthias Urlichs.
+# It is released under the Gnu Public License, version 2.
+#
+# The basic idea is to aggregate CVS check-ins into related changes.
+# Fortunately, "cvsps" does that for us; all we have to do is to parse
+# its output.
+#
+# Checking out the files is done by a single long-running CVS connection
+# / server process.
+#
+# The head revision is on branch "origin" by default.
+# You can change that with the '-o' option.
+
+use strict;
+use warnings;
+use Getopt::Std;
+use File::Spec;
+use File::Temp qw(tempfile);
+use File::Path qw(mkpath);
+use File::Basename qw(basename dirname);
+use Time::Local;
+use IO::Socket;
+use IO::Pipe;
+use POSIX qw(strftime dup2);
+use IPC::Open2;
+
+$SIG{'PIPE'}="IGNORE";
+$ENV{'TZ'}="UTC";
+
+our($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_s,$opt_m,$opt_M);
+
+sub usage() {
+       print STDERR <<END;
+Usage: ${\basename $0}     # fetch/update GIT from CVS
+       [-o branch-for-HEAD] [-h] [-v] [-d CVSROOT]
+       [-p opts-for-cvsps] [-C GIT_repository] [-z fuzz]
+       [-i] [-k] [-u] [-s subst] [-m] [-M regex] [CVS_module]
+END
+       exit(1);
+}
+
+getopts("hivmkuo:d:p:C:z:s:M:") or usage();
+usage if $opt_h;
+
+@ARGV <= 1 or usage();
+
+if($opt_d) {
+       $ENV{"CVSROOT"} = $opt_d;
+} elsif(-f 'CVS/Root') {
+       open my $f, '<', 'CVS/Root' or die 'Failed to open CVS/Root';
+       $opt_d = <$f>;
+       chomp $opt_d;
+       close $f;
+       $ENV{"CVSROOT"} = $opt_d;
+} elsif($ENV{"CVSROOT"}) {
+       $opt_d = $ENV{"CVSROOT"};
+} else {
+       die "CVSROOT needs to be set";
+}
+$opt_o ||= "origin";
+$opt_s ||= "-";
+my $git_tree = $opt_C;
+$git_tree ||= ".";
+
+my $cvs_tree;
+if ($#ARGV == 0) {
+       $cvs_tree = $ARGV[0];
+} elsif (-f 'CVS/Repository') {
+       open my $f, '<', 'CVS/Repository' or 
+           die 'Failed to open CVS/Repository';
+       $cvs_tree = <$f>;
+       chomp $cvs_tree;
+       close $f;
+} else {
+       usage();
+}
+
+our @mergerx = ();
+if ($opt_m) {
+       @mergerx = ( qr/\W(?:from|of|merge|merging|merged) (\w+)/i );
+}
+if ($opt_M) {
+       push (@mergerx, qr/$opt_M/);
+}
+
+select(STDERR); $|=1; select(STDOUT);
+
+
+package CVSconn;
+# Basic CVS dialog.
+# We're only interested in connecting and downloading, so ...
+
+use File::Spec;
+use File::Temp qw(tempfile);
+use POSIX qw(strftime dup2);
+
+sub new {
+       my($what,$repo,$subdir) = @_;
+       $what=ref($what) if ref($what);
+
+       my $self = {};
+       $self->{'buffer'} = "";
+       bless($self,$what);
+
+       $repo =~ s#/+$##;
+       $self->{'fullrep'} = $repo;
+       $self->conn();
+
+       $self->{'subdir'} = $subdir;
+       $self->{'lines'} = undef;
+
+       return $self;
+}
+
+sub conn {
+       my $self = shift;
+       my $repo = $self->{'fullrep'};
+       if($repo =~ s/^:pserver:(?:(.*?)(?::(.*?))?@)?([^:\/]*)(?::(\d*))?//) {
+               my($user,$pass,$serv,$port) = ($1,$2,$3,$4);
+               $user="anonymous" unless defined $user;
+               my $rr2 = "-";
+               unless($port) {
+                       $rr2 = ":pserver:$user\@$serv:$repo";
+                       $port=2401;
+               }
+               my $rr = ":pserver:$user\@$serv:$port$repo";
+
+               unless($pass) {
+                       open(H,$ENV{'HOME'}."/.cvspass") and do {
+                               # :pserver:cvs@mea.tmt.tele.fi:/cvsroot/zmailer Ah<Z
+                               while(<H>) {
+                                       chomp;
+                                       s/^\/\d+\s+//;
+                                       my ($w,$p) = split(/\s/,$_,2);
+                                       if($w eq $rr or $w eq $rr2) {
+                                               $pass = $p;
+                                               last;
+                                       }
+                               }
+                       };
+               }
+               $pass="A" unless $pass;
+
+               my $s = IO::Socket::INET->new(PeerHost => $serv, PeerPort => $port);
+               die "Socket to $serv: $!\n" unless defined $s;
+               $s->write("BEGIN AUTH REQUEST\n$repo\n$user\n$pass\nEND AUTH REQUEST\n")
+                       or die "Write to $serv: $!\n";
+               $s->flush();
+
+               my $rep = <$s>;
+
+               if($rep ne "I LOVE YOU\n") {
+                       $rep="<unknown>" unless $rep;
+                       die "AuthReply: $rep\n";
+               }
+               $self->{'socketo'} = $s;
+               $self->{'socketi'} = $s;
+       } else { # local or ext: Fork off our own cvs server.
+               my $pr = IO::Pipe->new();
+               my $pw = IO::Pipe->new();
+               my $pid = fork();
+               die "Fork: $!\n" unless defined $pid;
+               my $cvs = 'cvs';
+               $cvs = $ENV{CVS_SERVER} if exists $ENV{CVS_SERVER};
+               my $rsh = 'rsh';
+               $rsh = $ENV{CVS_RSH} if exists $ENV{CVS_RSH};
+
+               my @cvs = ($cvs, 'server');
+               my ($local, $user, $host);
+               $local = $repo =~ s/:local://;
+               if (!$local) {
+                   $repo =~ s/:ext://;
+                   $local = !($repo =~ s/^(?:([^\@:]+)\@)?([^:]+)://);
+                   ($user, $host) = ($1, $2);
+               }
+               if (!$local) {
+                   if ($user) {
+                       unshift @cvs, $rsh, '-l', $user, $host;
+                   } else {
+                       unshift @cvs, $rsh, $host;
+                   }
+               }
+
+               unless($pid) {
+                       $pr->writer();
+                       $pw->reader();
+                       dup2($pw->fileno(),0);
+                       dup2($pr->fileno(),1);
+                       $pr->close();
+                       $pw->close();
+                       exec(@cvs);
+               }
+               $pw->writer();
+               $pr->reader();
+               $self->{'socketo'} = $pw;
+               $self->{'socketi'} = $pr;
+       }
+       $self->{'socketo'}->write("Root $repo\n");
+
+       # Trial and error says that this probably is the minimum set
+       $self->{'socketo'}->write("Valid-responses ok error Valid-requests Mode M Mbinary E Checked-in Created Updated Merged Removed\n");
+
+       $self->{'socketo'}->write("valid-requests\n");
+       $self->{'socketo'}->flush();
+
+       chomp(my $rep=$self->readline());
+       if($rep !~ s/^Valid-requests\s*//) {
+               $rep="<unknown>" unless $rep;
+               die "Expected Valid-requests from server, but got: $rep\n";
+       }
+       chomp(my $res=$self->readline());
+       die "validReply: $res\n" if $res ne "ok";
+
+       $self->{'socketo'}->write("UseUnchanged\n") if $rep =~ /\bUseUnchanged\b/;
+       $self->{'repo'} = $repo;
+}
+
+sub readline {
+       my($self) = @_;
+       return $self->{'socketi'}->getline();
+}
+
+sub _file {
+       # Request a file with a given revision.
+       # Trial and error says this is a good way to do it. :-/
+       my($self,$fn,$rev) = @_;
+       $self->{'socketo'}->write("Argument -N\n") or return undef;
+       $self->{'socketo'}->write("Argument -P\n") or return undef;
+       # -kk: Linus' version doesn't use it - defaults to off
+       if ($opt_k) {
+           $self->{'socketo'}->write("Argument -kk\n") or return undef;
+       }
+       $self->{'socketo'}->write("Argument -r\n") or return undef;
+       $self->{'socketo'}->write("Argument $rev\n") or return undef;
+       $self->{'socketo'}->write("Argument --\n") or return undef;
+       $self->{'socketo'}->write("Argument $self->{'subdir'}/$fn\n") or return undef;
+       $self->{'socketo'}->write("Directory .\n") or return undef;
+       $self->{'socketo'}->write("$self->{'repo'}\n") or return undef;
+       # $self->{'socketo'}->write("Sticky T1.0\n") or return undef;
+       $self->{'socketo'}->write("co\n") or return undef;
+       $self->{'socketo'}->flush() or return undef;
+       $self->{'lines'} = 0;
+       return 1;
+}
+sub _line {
+       # Read a line from the server.
+       # ... except that 'line' may be an entire file. ;-)
+       my($self, $fh) = @_;
+       die "Not in lines" unless defined $self->{'lines'};
+
+       my $line;
+       my $res=0;
+       while(defined($line = $self->readline())) {
+               # M U gnupg-cvs-rep/AUTHORS
+               # Updated gnupg-cvs-rep/
+               # /daten/src/rsync/gnupg-cvs-rep/AUTHORS
+               # /AUTHORS/1.1///T1.1
+               # u=rw,g=rw,o=rw
+               # 0
+               # ok
+
+               if($line =~ s/^(?:Created|Updated) //) {
+                       $line = $self->readline(); # path
+                       $line = $self->readline(); # Entries line
+                       my $mode = $self->readline(); chomp $mode;
+                       $self->{'mode'} = $mode;
+                       defined (my $cnt = $self->readline())
+                               or die "EOF from server after 'Changed'\n";
+                       chomp $cnt;
+                       die "Duh: Filesize $cnt" if $cnt !~ /^\d+$/;
+                       $line="";
+                       $res=0;
+                       while($cnt) {
+                               my $buf;
+                               my $num = $self->{'socketi'}->read($buf,$cnt);
+                               die "Server: Filesize $cnt: $num: $!\n" if not defined $num or $num<=0;
+                               print $fh $buf;
+                               $res += $num;
+                               $cnt -= $num;
+                       }
+               } elsif($line =~ s/^ //) {
+                       print $fh $line;
+                       $res += length($line);
+               } elsif($line =~ /^M\b/) {
+                       # output, do nothing
+               } elsif($line =~ /^Mbinary\b/) {
+                       my $cnt;
+                       die "EOF from server after 'Mbinary'" unless defined ($cnt = $self->readline());
+                       chomp $cnt;
+                       die "Duh: Mbinary $cnt" if $cnt !~ /^\d+$/ or $cnt<1;
+                       $line="";
+                       while($cnt) {
+                               my $buf;
+                               my $num = $self->{'socketi'}->read($buf,$cnt);
+                               die "S: Mbinary $cnt: $num: $!\n" if not defined $num or $num<=0;
+                               print $fh $buf;
+                               $res += $num;
+                               $cnt -= $num;
+                       }
+               } else {
+                       chomp $line;
+                       if($line eq "ok") {
+                               # print STDERR "S: ok (".length($res).")\n";
+                               return $res;
+                       } elsif($line =~ s/^E //) {
+                               # print STDERR "S: $line\n";
+                       } elsif($line =~ /^Remove-entry /i) {
+                               $line = $self->readline(); # filename
+                               $line = $self->readline(); # OK
+                               chomp $line;
+                               die "Unknown: $line" if $line ne "ok";
+                               return -1;
+                       } else {
+                               die "Unknown: $line\n";
+                       }
+               }
+       }
+}
+sub file {
+       my($self,$fn,$rev) = @_;
+       my $res;
+
+       my ($fh, $name) = tempfile('gitcvs.XXXXXX', 
+                   DIR => File::Spec->tmpdir(), UNLINK => 1);
+
+       $self->_file($fn,$rev) and $res = $self->_line($fh);
+
+       if (!defined $res) {
+           # retry
+           $self->conn();
+           $self->_file($fn,$rev)
+                   or die "No file command send\n";
+           $res = $self->_line($fh);
+           die "No input: $fn $rev\n" unless defined $res;
+       }
+       close ($fh);
+
+       return ($name, $res);
+}
+
+
+package main;
+
+my $cvs = CVSconn->new($opt_d, $cvs_tree);
+
+
+sub pdate($) {
+       my($d) = @_;
+       m#(\d{2,4})/(\d\d)/(\d\d)\s(\d\d):(\d\d)(?::(\d\d))?#
+               or die "Unparseable date: $d\n";
+       my $y=$1; $y-=1900 if $y>1900;
+       return timegm($6||0,$5,$4,$3,$2-1,$y);
+}
+
+sub pmode($) {
+       my($mode) = @_;
+       my $m = 0;
+       my $mm = 0;
+       my $um = 0;
+       for my $x(split(//,$mode)) {
+               if($x eq ",") {
+                       $m |= $mm&$um;
+                       $mm = 0;
+                       $um = 0;
+               } elsif($x eq "u") { $um |= 0700;
+               } elsif($x eq "g") { $um |= 0070;
+               } elsif($x eq "o") { $um |= 0007;
+               } elsif($x eq "r") { $mm |= 0444;
+               } elsif($x eq "w") { $mm |= 0222;
+               } elsif($x eq "x") { $mm |= 0111;
+               } elsif($x eq "=") { # do nothing
+               } else { die "Unknown mode: $mode\n";
+               }
+       }
+       $m |= $mm&$um;
+       return $m;
+}
+
+sub getwd() {
+       my $pwd = `pwd`;
+       chomp $pwd;
+       return $pwd;
+}
+
+
+sub get_headref($$) {
+    my $name    = shift;
+    my $git_dir = shift; 
+    my $sha;
+    
+    if (open(C,"$git_dir/refs/heads/$name")) {
+       chomp($sha = <C>);
+       close(C);
+       length($sha) == 40
+           or die "Cannot get head id for $name ($sha): $!\n";
+    }
+    return $sha;
+}
+
+
+-d $git_tree
+       or mkdir($git_tree,0777)
+       or die "Could not create $git_tree: $!";
+chdir($git_tree);
+
+my $last_branch = "";
+my $orig_branch = "";
+my $forward_master = 0;
+my %branch_date;
+
+my $git_dir = $ENV{"GIT_DIR"} || ".git";
+$git_dir = getwd()."/".$git_dir unless $git_dir =~ m#^/#;
+$ENV{"GIT_DIR"} = $git_dir;
+my $orig_git_index;
+$orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE};
+my ($git_ih, $git_index) = tempfile('gitXXXXXX', SUFFIX => '.idx',
+                                   DIR => File::Spec->tmpdir());
+close ($git_ih);
+$ENV{GIT_INDEX_FILE} = $git_index;
+unless(-d $git_dir) {
+       system("git-init-db");
+       die "Cannot init the GIT db at $git_tree: $?\n" if $?;
+       system("git-read-tree");
+       die "Cannot init an empty tree: $?\n" if $?;
+
+       $last_branch = $opt_o;
+       $orig_branch = "";
+} else {
+       -f "$git_dir/refs/heads/$opt_o"
+               or die "Branch '$opt_o' does not exist.\n".
+                      "Either use the correct '-o branch' option,\n".
+                      "or import to a new repository.\n";
+
+       $last_branch = basename(readlink("$git_dir/HEAD"));
+       unless($last_branch) {
+               warn "Cannot read the last branch name: $! -- assuming 'master'\n";
+               $last_branch = "master";
+       }
+       $orig_branch = $last_branch;
+       if (-f "$git_dir/CVS2GIT_HEAD") {
+               die <<EOM;
+CVS2GIT_HEAD exists.
+Make sure your working directory corresponds to HEAD and remove CVS2GIT_HEAD.
+You may need to run
+
+    git-read-tree -m -u CVS2GIT_HEAD HEAD
+EOM
+       }
+       system('cp', "$git_dir/HEAD", "$git_dir/CVS2GIT_HEAD");
+
+       $forward_master =
+           $opt_o ne 'master' && -f "$git_dir/refs/heads/master" &&
+           system('cmp', '-s', "$git_dir/refs/heads/master", 
+                               "$git_dir/refs/heads/$opt_o") == 0;
+
+       # populate index
+       system('git-read-tree', $last_branch);
+       die "read-tree failed: $?\n" if $?;
+
+       # Get the last import timestamps
+       opendir(D,"$git_dir/refs/heads");
+       while(defined(my $head = readdir(D))) {
+               next if $head =~ /^\./;
+               open(F,"$git_dir/refs/heads/$head")
+                       or die "Bad head branch: $head: $!\n";
+               chomp(my $ftag = <F>);
+               close(F);
+               open(F,"git-cat-file commit $ftag |");
+               while(<F>) {
+                       next unless /^author\s.*\s(\d+)\s[-+]\d{4}$/;
+                       $branch_date{$head} = $1;
+                       last;
+               }
+               close(F);
+       }
+       closedir(D);
+}
+
+-d $git_dir
+       or die "Could not create git subdir ($git_dir).\n";
+
+my $pid = open(CVS,"-|");
+die "Cannot fork: $!\n" unless defined $pid;
+unless($pid) {
+       my @opt;
+       @opt = split(/,/,$opt_p) if defined $opt_p;
+       unshift @opt, '-z', $opt_z if defined $opt_z;
+       exec("cvsps",@opt,"-u","-A","--cvs-direct",'--root',$opt_d,$cvs_tree);
+       die "Could not start cvsps: $!\n";
+}
+
+
+## cvsps output:
+#---------------------
+#PatchSet 314
+#Date: 1999/09/18 13:03:59
+#Author: wkoch
+#Branch: STABLE-BRANCH-1-0
+#Ancestor branch: HEAD
+#Tag: (none)
+#Log:
+#    See ChangeLog: Sat Sep 18 13:03:28 CEST 1999  Werner Koch
+#Members:
+#      README:1.57->1.57.2.1
+#      VERSION:1.96->1.96.2.1
+#
+#---------------------
+
+my $state = 0;
+
+my($patchset,$date,$author,$branch,$ancestor,$tag,$logmsg);
+my(@old,@new);
+my $commit = sub {
+       my $pid;
+       while(@old) {
+               my @o2;
+               if(@old > 55) {
+                       @o2 = splice(@old,0,50);
+               } else {
+                       @o2 = @old;
+                       @old = ();
+               }
+               system("git-update-index","--force-remove","--",@o2);
+               die "Cannot remove files: $?\n" if $?;
+       }
+       while(@new) {
+               my @n2;
+               if(@new > 12) {
+                       @n2 = splice(@new,0,10);
+               } else {
+                       @n2 = @new;
+                       @new = ();
+               }
+               system("git-update-index","--add",
+                       (map { ('--cacheinfo', @$_) } @n2));
+               die "Cannot add files: $?\n" if $?;
+       }
+
+       $pid = open(C,"-|");
+       die "Cannot fork: $!" unless defined $pid;
+       unless($pid) {
+               exec("git-write-tree");
+               die "Cannot exec git-write-tree: $!\n";
+       }
+       chomp(my $tree = <C>);
+       length($tree) == 40
+               or die "Cannot get tree id ($tree): $!\n";
+       close(C)
+               or die "Error running git-write-tree: $?\n";
+       print "Tree ID $tree\n" if $opt_v;
+
+       my $parent = "";
+       if(open(C,"$git_dir/refs/heads/$last_branch")) {
+               chomp($parent = <C>);
+               close(C);
+               length($parent) == 40
+                       or die "Cannot get parent id ($parent): $!\n";
+               print "Parent ID $parent\n" if $opt_v;
+       }
+
+       my $pr = IO::Pipe->new() or die "Cannot open pipe: $!\n";
+       my $pw = IO::Pipe->new() or die "Cannot open pipe: $!\n";
+       $pid = fork();
+       die "Fork: $!\n" unless defined $pid;
+       unless($pid) {
+               $pr->writer();
+               $pw->reader();
+               dup2($pw->fileno(),0);
+               dup2($pr->fileno(),1);
+               $pr->close();
+               $pw->close();
+
+               my @par = ();
+               @par = ("-p",$parent) if $parent;
+
+               # loose detection of merges
+               # based on the commit msg
+               foreach my $rx (@mergerx) {
+                       if ($logmsg =~ $rx) {
+                               my $mparent = $1;
+                               if ($mparent eq 'HEAD') { $mparent = $opt_o };
+                               if ( -e "$git_dir/refs/heads/$mparent") {
+                                       $mparent = get_headref($mparent, $git_dir);
+                                       push @par, '-p', $mparent;
+                                       # printing here breaks import # 
+                                       # # print "Merge parent branch: $mparent\n" if $opt_v;
+                               }
+                       } 
+               }
+
+               exec("env",
+                       "GIT_AUTHOR_NAME=$author",
+                       "GIT_AUTHOR_EMAIL=$author",
+                       "GIT_AUTHOR_DATE=".strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)),
+                       "GIT_COMMITTER_NAME=$author",
+                       "GIT_COMMITTER_EMAIL=$author",
+                       "GIT_COMMITTER_DATE=".strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)),
+                       "git-commit-tree", $tree,@par);
+               die "Cannot exec git-commit-tree: $!\n";
+       }
+       $pw->writer();
+       $pr->reader();
+
+       # compatibility with git2cvs
+       substr($logmsg,32767) = "" if length($logmsg) > 32767;
+       $logmsg =~ s/[\s\n]+\z//;
+
+       print $pw "$logmsg\n"
+               or die "Error writing to git-commit-tree: $!\n";
+       $pw->close();
+
+       print "Committed patch $patchset ($branch ".strftime("%Y-%m-%d %H:%M:%S",gmtime($date)).")\n" if $opt_v;
+       chomp(my $cid = <$pr>);
+       length($cid) == 40
+               or die "Cannot get commit id ($cid): $!\n";
+       print "Commit ID $cid\n" if $opt_v;
+       $pr->close();
+
+       waitpid($pid,0);
+       die "Error running git-commit-tree: $?\n" if $?;
+
+       open(C,">$git_dir/refs/heads/$branch")
+               or die "Cannot open branch $branch for update: $!\n";
+       print C "$cid\n"
+               or die "Cannot write branch $branch for update: $!\n";
+       close(C)
+               or die "Cannot write branch $branch for update: $!\n";
+
+       if($tag) {
+               my($in, $out) = ('','');
+               my($xtag) = $tag;
+               $xtag =~ s/\s+\*\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **
+               $xtag =~ tr/_/\./ if ( $opt_u );
+               
+               my $pid = open2($in, $out, 'git-mktag');
+               print $out "object $cid\n".
+                   "type commit\n".
+                   "tag $xtag\n".
+                   "tagger $author <$author>\n"
+                   or die "Cannot create tag object $xtag: $!\n";
+               close($out)
+                   or die "Cannot create tag object $xtag: $!\n";
+
+               my $tagobj = <$in>;
+               chomp $tagobj;
+
+               if ( !close($in) or waitpid($pid, 0) != $pid or
+                    $? != 0 or $tagobj !~ /^[0123456789abcdef]{40}$/ ) {
+                   die "Cannot create tag object $xtag: $!\n";
+               }
+               
+
+               open(C,">$git_dir/refs/tags/$xtag")
+                       or die "Cannot create tag $xtag: $!\n";
+               print C "$tagobj\n"
+                       or die "Cannot write tag $xtag: $!\n";
+               close(C)
+                       or die "Cannot write tag $xtag: $!\n";
+
+               print "Created tag '$xtag' on '$branch'\n" if $opt_v;
+       }
+};
+
+while(<CVS>) {
+       chomp;
+       if($state == 0 and /^-+$/) {
+               $state = 1;
+       } elsif($state == 0) {
+               $state = 1;
+               redo;
+       } elsif(($state==0 or $state==1) and s/^PatchSet\s+//) {
+               $patchset = 0+$_;
+               $state=2;
+       } elsif($state == 2 and s/^Date:\s+//) {
+               $date = pdate($_);
+               unless($date) {
+                       print STDERR "Could not parse date: $_\n";
+                       $state=0;
+                       next;
+               }
+               $state=3;
+       } elsif($state == 3 and s/^Author:\s+//) {
+               s/\s+$//;
+               $author = $_;
+               $state = 4;
+       } elsif($state == 4 and s/^Branch:\s+//) {
+               s/\s+$//;
+               s/[\/]/$opt_s/g;
+               $branch = $_;
+               $state = 5;
+       } elsif($state == 5 and s/^Ancestor branch:\s+//) {
+               s/\s+$//;
+               $ancestor = $_;
+               $ancestor = $opt_o if $ancestor eq "HEAD";
+               $state = 6;
+       } elsif($state == 5) {
+               $ancestor = undef;
+               $state = 6;
+               redo;
+       } elsif($state == 6 and s/^Tag:\s+//) {
+               s/\s+$//;
+               if($_ eq "(none)") {
+                       $tag = undef;
+               } else {
+                       $tag = $_;
+               }
+               $state = 7;
+       } elsif($state == 7 and /^Log:/) {
+               $logmsg = "";
+               $state = 8;
+       } elsif($state == 8 and /^Members:/) {
+               $branch = $opt_o if $branch eq "HEAD";
+               if(defined $branch_date{$branch} and $branch_date{$branch} >= $date) {
+                       # skip
+                       print "skip patchset $patchset: $date before $branch_date{$branch}\n" if $opt_v;
+                       $state = 11;
+                       next;
+               }
+               if($ancestor) {
+                       if(-f "$git_dir/refs/heads/$branch") {
+                               print STDERR "Branch $branch already exists!\n";
+                               $state=11;
+                               next;
+                       }
+                       unless(open(H,"$git_dir/refs/heads/$ancestor")) {
+                               print STDERR "Branch $ancestor does not exist!\n";
+                               $state=11;
+                               next;
+                       }
+                       chomp(my $id = <H>);
+                       close(H);
+                       unless(open(H,"> $git_dir/refs/heads/$branch")) {
+                               print STDERR "Could not create branch $branch: $!\n";
+                               $state=11;
+                               next;
+                       }
+                       print H "$id\n"
+                               or die "Could not write branch $branch: $!";
+                       close(H)
+                               or die "Could not write branch $branch: $!";
+               }
+               if(($ancestor || $branch) ne $last_branch) {
+                       print "Switching from $last_branch to $branch\n" if $opt_v;
+                       system("git-read-tree", $branch);
+                       die "read-tree failed: $?\n" if $?;
+               }
+               $last_branch = $branch if $branch ne $last_branch;
+               $state = 9;
+       } elsif($state == 8) {
+               $logmsg .= "$_\n";
+       } elsif($state == 9 and /^\s+(.+?):(INITIAL|\d+(?:\.\d+)+)->(\d+(?:\.\d+)+)\s*$/) {
+#      VERSION:1.96->1.96.2.1
+               my $init = ($2 eq "INITIAL");
+               my $fn = $1;
+               my $rev = $3;
+               $fn =~ s#^/+##;
+               my ($tmpname, $size) = $cvs->file($fn,$rev);
+               if($size == -1) {
+                       push(@old,$fn);
+                       print "Drop $fn\n" if $opt_v;
+               } else {
+                       print "".($init ? "New" : "Update")." $fn: $size bytes\n" if $opt_v;
+                       open my $F, '-|', "git-hash-object -w $tmpname"
+                               or die "Cannot create object: $!\n";
+                       my $sha = <$F>;
+                       chomp $sha;
+                       close $F;
+                       my $mode = pmode($cvs->{'mode'});
+                       push(@new,[$mode, $sha, $fn]); # may be resurrected!
+               }
+               unlink($tmpname);
+       } elsif($state == 9 and /^\s+(.+?):\d+(?:\.\d+)+->(\d+(?:\.\d+)+)\(DEAD\)\s*$/) {
+               my $fn = $1;
+               $fn =~ s#^/+##;
+               push(@old,$fn);
+               print "Delete $fn\n" if $opt_v;
+       } elsif($state == 9 and /^\s*$/) {
+               $state = 10;
+       } elsif(($state == 9 or $state == 10) and /^-+$/) {
+               &$commit();
+               $state = 1;
+       } elsif($state == 11 and /^-+$/) {
+               $state = 1;
+       } elsif(/^-+$/) { # end of unknown-line processing
+               $state = 1;
+       } elsif($state != 11) { # ignore stuff when skipping
+               print "* UNKNOWN LINE * $_\n";
+       }
+}
+&$commit() if $branch and $state != 11;
+
+unlink($git_index);
+
+if (defined $orig_git_index) {
+       $ENV{GIT_INDEX_FILE} = $orig_git_index;
+} else {
+       delete $ENV{GIT_INDEX_FILE};
+}
+
+# Now switch back to the branch we were in before all of this happened
+if($orig_branch) {
+       print "DONE\n" if $opt_v;
+       system("cp","$git_dir/refs/heads/$opt_o","$git_dir/refs/heads/master")
+               if $forward_master;
+       unless ($opt_i) {
+               system('git-read-tree', '-m', '-u', 'CVS2GIT_HEAD', 'HEAD');
+               die "read-tree failed: $?\n" if $?;
+       }
+} else {
+       $orig_branch = "master";
+       print "DONE; creating $orig_branch branch\n" if $opt_v;
+       system("cp","$git_dir/refs/heads/$opt_o","$git_dir/refs/heads/master")
+               unless -f "$git_dir/refs/heads/master";
+       unlink("$git_dir/HEAD");
+       symlink("refs/heads/$orig_branch","$git_dir/HEAD");
+       unless ($opt_i) {
+               system('git checkout');
+               die "checkout failed: $?\n" if $?;
+       }
+}
+unlink("$git_dir/CVS2GIT_HEAD");
diff --git a/git-diff-script b/git-diff-script
deleted file mode 100755 (executable)
index a285a2a..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Linus Torvalds
-# Copyright (c) 2005 Junio C Hamano
-
-rev=$(git-rev-parse --revs-only --no-flags --sq "$@") || exit
-flags=$(git-rev-parse --no-revs --flags --sq "$@")
-files=$(git-rev-parse --no-revs --no-flags --sq "$@")
-
-: ${flags:="'-M' '-p'"}
-
-case "$rev" in
-?*' '?*' '?*)
-       die "I don't understand"
-       ;;
-?*' '^?*)
-       begin=$(expr "$rev" : '.*^.\([0-9a-f]*\).*') &&
-       end=$(expr "$rev" : '.\([0-9a-f]*\). .*') || exit
-       cmd="git-diff-tree $flags $begin $end $files"
-       ;;
-?*' '?*)
-       cmd="git-diff-tree $flags $rev $files"
-       ;;
-?*' ')
-       cmd="git-diff-cache $flags $rev $files"
-       ;;
-'')
-       cmd="git-diff-files $flags $files"
-       ;;
-*)
-       die "I don't understand $*"
-       ;;
-esac
-
-eval "$cmd"
diff --git a/git-diff.sh b/git-diff.sh
new file mode 100755 (executable)
index 0000000..9732c8a
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Linus Torvalds
+# Copyright (c) 2005 Junio C Hamano
+
+rev=$(git-rev-parse --revs-only --no-flags --sq "$@") || exit
+flags=$(git-rev-parse --no-revs --flags --sq "$@")
+files=$(git-rev-parse --no-revs --no-flags --sq "$@")
+
+: ${flags:="'-M' '-p'"}
+
+case "$rev" in
+?*' '?*' '?*)
+       die "I don't understand"
+       ;;
+?*' '^?*)
+       begin=$(expr "$rev" : '.*^.\([0-9a-f]*\).*') &&
+       end=$(expr "$rev" : '.\([0-9a-f]*\). .*') || exit
+       cmd="git-diff-tree $flags $begin $end $files"
+       ;;
+?*' '?*)
+       cmd="git-diff-tree $flags $rev $files"
+       ;;
+?*' ')
+       cmd="git-diff-index $flags $rev $files"
+       ;;
+'')
+       cmd="git-diff-files $flags $files"
+       ;;
+*)
+       die "I don't understand $*"
+       ;;
+esac
+
+eval "$cmd"
diff --git a/git-fetch-script b/git-fetch-script
deleted file mode 100755 (executable)
index f9f90b6..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-#!/bin/sh
-#
-. git-sh-setup-script || die "Not a git archive"
-. git-parse-remote-script
-_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
-_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
-
-append=
-force=
-update_head_ok=
-while case "$#" in 0) break ;; esac
-do
-       case "$1" in
-       -a|--a|--ap|--app|--appe|--appen|--append)
-               append=t
-               ;;
-       -f|--f|--fo|--for|--forc|--force)
-               force=t
-               ;;
-       -u|--u|--up|--upd|--upda|--updat|--update|--update-|--update-h|\
-       --update-he|--update-hea|--update-head|--update-head-|\
-       --update-head-o|--update-head-ok)
-               update_head_ok=t
-               ;;
-       *)
-               break
-               ;;
-       esac
-       shift
-done
-
-case "$#" in
-0)
-       test -f "$GIT_DIR/branches/origin" ||
-               test -f "$GIT_DIR/remotes/origin" ||
-                       die "Where do you want to fetch from today?"
-       set origin ;;
-esac
-
-remote_nick="$1"
-remote=$(get_remote_url "$@")
-refs=
-rref=
-rsync_slurped_objects=
-
-if test "" = "$append"
-then
-       : >$GIT_DIR/FETCH_HEAD
-fi
-
-append_fetch_head () {
-    head_="$1"
-    remote_="$2"
-    remote_name_="$3"
-    remote_nick_="$4"
-    local_name_="$5"
-
-    # remote-nick is the URL given on the command line (or a shorthand)
-    # remote-name is the $GIT_DIR relative refs/ path we computed
-    # for this refspec.
-    case "$remote_name_" in
-    HEAD)
-       note_= ;;
-    refs/heads/*)
-       note_="$(expr "$remote_name_" : 'refs/heads/\(.*\)')"
-       note_="branch '$note_' of " ;;
-    refs/tags/*)
-       note_="$(expr "$remote_name_" : 'refs/tags/\(.*\)')"
-       note_="tag '$note_' of " ;;
-    *)
-       note_="$remote_name of " ;;
-    esac
-    remote_1_=$(expr "$remote_" : '\(.*\)\.git/*$') &&
-       remote_="$remote_1_"
-    note_="$note_$remote_"
-
-    # 2.6.11-tree tag would not be happy to be fed to resolve.
-    if git-cat-file commit "$head_" >/dev/null 2>&1
-    then
-       headc_=$(git-rev-parse --verify "$head_^0") || exit
-       echo "$headc_   $note_" >>$GIT_DIR/FETCH_HEAD
-       echo >&2 "* committish: $head_"
-       echo >&2 "  $note_"
-    else
-       echo >&2 "* non-commit: $head_"
-       echo >&2 "  $note_"
-    fi
-    if test "$local_name_" != ""
-    then
-       # We are storing the head locally.  Make sure that it is
-       # a fast forward (aka "reverse push").
-       fast_forward_local "$local_name_" "$head_" "$note_"
-    fi
-}
-
-fast_forward_local () {
-    case "$1" in
-    refs/tags/*)
-       # Tags need not be pointing at commits so there
-       # is no way to guarantee "fast-forward" anyway.
-       if test -f "$GIT_DIR/$1"
-       then
-               echo >&2 "* $1: updating with $3"
-       else
-               echo >&2 "* $1: storing $3"
-       fi
-       echo "$2" >"$GIT_DIR/$1" ;;
-
-    refs/heads/*)
-       # NEEDSWORK: use the same cmpxchg protocol here.
-       echo "$2" >"$GIT_DIR/$1.lock"
-       if test -f "$GIT_DIR/$1"
-       then
-           local=$(git-rev-parse --verify "$1^0") &&
-           mb=$(git-merge-base "$local" "$2") &&
-           case "$2,$mb" in
-           $local,*)
-               echo >&2 "* $1: same as $3"
-               ;;
-           *,$local)
-               echo >&2 "* $1: fast forward to $3"
-               ;;
-           *)
-               false
-               ;;
-           esac || {
-               echo >&2 "* $1: does not fast forward to $3;"
-               case "$force,$single_force" in
-               t,* | *,t)
-                       echo >&2 "  forcing update."
-                       ;;
-               *)
-                       mv "$GIT_DIR/$1.lock" "$GIT_DIR/$1.remote"
-                       echo >&2 "  leaving it in '$1.remote'"
-                       ;;
-               esac
-           }
-       else
-               echo >&2 "* $1: storing $3"
-       fi
-       test -f "$GIT_DIR/$1.lock" &&
-           mv "$GIT_DIR/$1.lock" "$GIT_DIR/$1"
-       ;;
-    esac
-}
-
-case "$update_head_ok" in
-'')
-       orig_head=$(cat "$GIT_DIR/HEAD" 2>/dev/null)
-       ;;
-esac
-
-for ref in $(get_remote_refs_for_fetch "$@")
-do
-    refs="$refs $ref"
-
-    # These are relative path from $GIT_DIR, typically starting at refs/
-    # but may be HEAD
-    if expr "$ref" : '\+' >/dev/null
-    then
-       single_force=t
-       ref=$(expr "$ref" : '\+\(.*\)')
-    else
-       single_force=
-    fi
-    remote_name=$(expr "$ref" : '\([^:]*\):')
-    local_name=$(expr "$ref" : '[^:]*:\(.*\)')
-
-    rref="$rref $remote_name"
-
-    # There are transports that can fetch only one head at a time...
-    case "$remote" in
-    http://* | https://*)
-       if [ -n "$GIT_SSL_NO_VERIFY" ]; then
-           curl_extra_args="-k"
-       fi
-       head=$(curl -nsf $curl_extra_args "$remote/$remote_name") &&
-       expr "$head" : "$_x40\$" >/dev/null ||
-               die "Failed to fetch $remote_name from $remote"
-       echo Fetching "$remote_name from $remote" using http
-       git-http-pull -v -a "$head" "$remote/" || exit
-       ;;
-    rsync://*)
-       TMP_HEAD="$GIT_DIR/TMP_HEAD"
-       rsync -L "$remote/$remote_name" "$TMP_HEAD" || exit 1
-       head=$(git-rev-parse TMP_HEAD)
-       rm -f "$TMP_HEAD"
-       test "$rsync_slurped_objects" || {
-           rsync -avz --ignore-existing "$remote/objects/" \
-               "$GIT_OBJECT_DIRECTORY/" || exit
-           rsync_slurped_objects=t
-       }
-       ;;
-    *)
-       # We will do git native transport with just one call later.
-       continue ;;
-    esac
-
-    append_fetch_head "$head" "$remote" "$remote_name" "$remote_nick" "$local_name"
-
-done
-
-case "$remote" in
-http://* | https://* | rsync://* )
-    ;; # we are already done.
-*)
-    git-fetch-pack "$remote" $rref |
-    while read sha1 remote_name
-    do
-       found=
-       single_force=
-       for ref in $refs
-       do
-           case "$ref" in
-           +$remote_name:*)
-               single_force=t
-               found="$ref"
-               break ;;
-           $remote_name:*)
-               found="$ref"
-               break ;;
-           esac
-       done
-
-       local_name=$(expr "$found" : '[^:]*:\(.*\)')
-       append_fetch_head "$sha1" "$remote" "$remote_name" "$remote_nick" "$local_name"
-    done
-    ;;
-esac
-
-# If the original head was empty (i.e. no "master" yet), or
-# if we were told not to worry, we do not have to check.
-case ",$update_head_ok,$orig_head," in
-*,, | t,* )
-       ;;
-*)
-       curr_head=$(cat "$GIT_DIR/HEAD" 2>/dev/null)
-       if test "$curr_head" != "$orig_head"
-       then
-               echo "$orig_head" >$GIT_DIR/HEAD
-               die "Cannot fetch into the current branch."
-       fi
-       ;;
-esac
diff --git a/git-fetch.sh b/git-fetch.sh
new file mode 100755 (executable)
index 0000000..4928cd5
--- /dev/null
@@ -0,0 +1,244 @@
+#!/bin/sh
+#
+. git-sh-setup || die "Not a git archive"
+. git-parse-remote
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+
+append=
+force=
+update_head_ok=
+while case "$#" in 0) break ;; esac
+do
+       case "$1" in
+       -a|--a|--ap|--app|--appe|--appen|--append)
+               append=t
+               ;;
+       -f|--f|--fo|--for|--forc|--force)
+               force=t
+               ;;
+       -u|--u|--up|--upd|--upda|--updat|--update|--update-|--update-h|\
+       --update-he|--update-hea|--update-head|--update-head-|\
+       --update-head-o|--update-head-ok)
+               update_head_ok=t
+               ;;
+       *)
+               break
+               ;;
+       esac
+       shift
+done
+
+case "$#" in
+0)
+       test -f "$GIT_DIR/branches/origin" ||
+               test -f "$GIT_DIR/remotes/origin" ||
+                       die "Where do you want to fetch from today?"
+       set origin ;;
+esac
+
+remote_nick="$1"
+remote=$(get_remote_url "$@")
+refs=
+rref=
+rsync_slurped_objects=
+
+if test "" = "$append"
+then
+       : >$GIT_DIR/FETCH_HEAD
+fi
+
+append_fetch_head () {
+    head_="$1"
+    remote_="$2"
+    remote_name_="$3"
+    remote_nick_="$4"
+    local_name_="$5"
+
+    # remote-nick is the URL given on the command line (or a shorthand)
+    # remote-name is the $GIT_DIR relative refs/ path we computed
+    # for this refspec.
+    case "$remote_name_" in
+    HEAD)
+       note_= ;;
+    refs/heads/*)
+       note_="$(expr "$remote_name_" : 'refs/heads/\(.*\)')"
+       note_="branch '$note_' of " ;;
+    refs/tags/*)
+       note_="$(expr "$remote_name_" : 'refs/tags/\(.*\)')"
+       note_="tag '$note_' of " ;;
+    *)
+       note_="$remote_name of " ;;
+    esac
+    remote_1_=$(expr "$remote_" : '\(.*\)\.git/*$') &&
+       remote_="$remote_1_"
+    note_="$note_$remote_"
+
+    # 2.6.11-tree tag would not be happy to be fed to resolve.
+    if git-cat-file commit "$head_" >/dev/null 2>&1
+    then
+       headc_=$(git-rev-parse --verify "$head_^0") || exit
+       echo "$headc_   $note_" >>$GIT_DIR/FETCH_HEAD
+       echo >&2 "* committish: $head_"
+       echo >&2 "  $note_"
+    else
+       echo >&2 "* non-commit: $head_"
+       echo >&2 "  $note_"
+    fi
+    if test "$local_name_" != ""
+    then
+       # We are storing the head locally.  Make sure that it is
+       # a fast forward (aka "reverse push").
+       fast_forward_local "$local_name_" "$head_" "$note_"
+    fi
+}
+
+fast_forward_local () {
+    case "$1" in
+    refs/tags/*)
+       # Tags need not be pointing at commits so there
+       # is no way to guarantee "fast-forward" anyway.
+       if test -f "$GIT_DIR/$1"
+       then
+               echo >&2 "* $1: updating with $3"
+       else
+               echo >&2 "* $1: storing $3"
+       fi
+       echo "$2" >"$GIT_DIR/$1" ;;
+
+    refs/heads/*)
+       # NEEDSWORK: use the same cmpxchg protocol here.
+       echo "$2" >"$GIT_DIR/$1.lock"
+       if test -f "$GIT_DIR/$1"
+       then
+           local=$(git-rev-parse --verify "$1^0") &&
+           mb=$(git-merge-base "$local" "$2") &&
+           case "$2,$mb" in
+           $local,*)
+               echo >&2 "* $1: same as $3"
+               ;;
+           *,$local)
+               echo >&2 "* $1: fast forward to $3"
+               ;;
+           *)
+               false
+               ;;
+           esac || {
+               echo >&2 "* $1: does not fast forward to $3;"
+               case "$force,$single_force" in
+               t,* | *,t)
+                       echo >&2 "  forcing update."
+                       ;;
+               *)
+                       mv "$GIT_DIR/$1.lock" "$GIT_DIR/$1.remote"
+                       echo >&2 "  leaving it in '$1.remote'"
+                       ;;
+               esac
+           }
+       else
+               echo >&2 "* $1: storing $3"
+       fi
+       test -f "$GIT_DIR/$1.lock" &&
+           mv "$GIT_DIR/$1.lock" "$GIT_DIR/$1"
+       ;;
+    esac
+}
+
+case "$update_head_ok" in
+'')
+       orig_head=$(cat "$GIT_DIR/HEAD" 2>/dev/null)
+       ;;
+esac
+
+for ref in $(get_remote_refs_for_fetch "$@")
+do
+    refs="$refs $ref"
+
+    # These are relative path from $GIT_DIR, typically starting at refs/
+    # but may be HEAD
+    if expr "$ref" : '\+' >/dev/null
+    then
+       single_force=t
+       ref=$(expr "$ref" : '\+\(.*\)')
+    else
+       single_force=
+    fi
+    remote_name=$(expr "$ref" : '\([^:]*\):')
+    local_name=$(expr "$ref" : '[^:]*:\(.*\)')
+
+    rref="$rref $remote_name"
+
+    # There are transports that can fetch only one head at a time...
+    case "$remote" in
+    http://* | https://*)
+       if [ -n "$GIT_SSL_NO_VERIFY" ]; then
+           curl_extra_args="-k"
+       fi
+       head=$(curl -nsf $curl_extra_args "$remote/$remote_name") &&
+       expr "$head" : "$_x40\$" >/dev/null ||
+               die "Failed to fetch $remote_name from $remote"
+       echo Fetching "$remote_name from $remote" using http
+       git-http-fetch -v -a "$head" "$remote/" || exit
+       ;;
+    rsync://*)
+       TMP_HEAD="$GIT_DIR/TMP_HEAD"
+       rsync -L "$remote/$remote_name" "$TMP_HEAD" || exit 1
+       head=$(git-rev-parse TMP_HEAD)
+       rm -f "$TMP_HEAD"
+       test "$rsync_slurped_objects" || {
+           rsync -avz --ignore-existing "$remote/objects/" \
+               "$GIT_OBJECT_DIRECTORY/" || exit
+           rsync_slurped_objects=t
+       }
+       ;;
+    *)
+       # We will do git native transport with just one call later.
+       continue ;;
+    esac
+
+    append_fetch_head "$head" "$remote" "$remote_name" "$remote_nick" "$local_name"
+
+done
+
+case "$remote" in
+http://* | https://* | rsync://* )
+    ;; # we are already done.
+*)
+    git-fetch-pack "$remote" $rref |
+    while read sha1 remote_name
+    do
+       found=
+       single_force=
+       for ref in $refs
+       do
+           case "$ref" in
+           +$remote_name:*)
+               single_force=t
+               found="$ref"
+               break ;;
+           $remote_name:*)
+               found="$ref"
+               break ;;
+           esac
+       done
+
+       local_name=$(expr "$found" : '[^:]*:\(.*\)')
+       append_fetch_head "$sha1" "$remote" "$remote_name" "$remote_nick" "$local_name"
+    done
+    ;;
+esac
+
+# If the original head was empty (i.e. no "master" yet), or
+# if we were told not to worry, we do not have to check.
+case ",$update_head_ok,$orig_head," in
+*,, | t,* )
+       ;;
+*)
+       curr_head=$(cat "$GIT_DIR/HEAD" 2>/dev/null)
+       if test "$curr_head" != "$orig_head"
+       then
+               echo "$orig_head" >$GIT_DIR/HEAD
+               die "Cannot fetch into the current branch."
+       fi
+       ;;
+esac
diff --git a/git-format-patch-script b/git-format-patch-script
deleted file mode 100755 (executable)
index 9b13b88..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Junio C Hamano
-#
-
-. git-sh-setup-script || die "Not a git archive."
-
-usage () {
-    echo >&2 "usage: $0"' [-n] [-o dir] [--keep-subject] [--mbox] [--check] [--signoff] [-<diff options>...] upstream [ our-head ]
-
-Prepare each commit with its patch since our-head forked from upstream,
-one file per patch, for e-mail submission.  Each output file is
-numbered sequentially from 1, and uses the first line of the commit
-message (massaged for pathname safety) as the filename.
-
-When -o is specified, output files are created in that directory; otherwise in
-the current working directory.
-
-When -n is specified, instead of "[PATCH] Subject", the first line is formatted
-as "[PATCH N/M] Subject", unless you have only one patch.
-
-When --mbox is specified, the output is formatted to resemble
-UNIX mailbox format, and can be concatenated together for processing
-with applymbox.
-'
-    exit 1
-}
-
-diff_opts=
-IFS='
-'
-LF='
-'
-
-outdir=./
-while case "$#" in 0) break;; esac
-do
-    case "$1" in
-    -a|--a|--au|--aut|--auth|--autho|--author)
-    author=t ;;
-    -c|--c|--ch|--che|--chec|--check)
-    check=t ;;
-    -d|--d|--da|--dat|--date)
-    date=t ;;
-    -m|--m|--mb|--mbo|--mbox)
-    date=t author=t mbox=t ;;
-    -k|--k|--ke|--kee|--keep|--keep-|--keep-s|--keep-su|--keep-sub|\
-    --keep-subj|--keep-subje|--keep-subjec|--keep-subject)
-    keep_subject=t ;;
-    -n|--n|--nu|--num|--numb|--numbe|--number|--numbere|--numbered)
-    numbered=t ;;
-    -s|--s|--si|--sig|--sign|--signo|--signof|--signoff)
-    signoff=t ;;
-    -o=*|--o=*|--ou=*|--out=*|--outp=*|--outpu=*|--output=*|--output-=*|\
-    --output-d=*|--output-di=*|--output-dir=*|--output-dire=*|\
-    --output-direc=*|--output-direct=*|--output-directo=*|\
-    --output-director=*|--output-directory=*)
-    outdir=`expr "$1" : '-[^=]*=\(.*\)'` ;;
-    -o|--o|--ou|--out|--outp|--outpu|--output|--output-|--output-d|\
-    --output-di|--output-dir|--output-dire|--output-direc|--output-direct|\
-    --output-directo|--output-director|--output-directory)
-    case "$#" in 1) usage ;; esac; shift
-    outdir="$1" ;;
-    -*)        diff_opts="$diff_opts$LF$1" ;;
-    *) break ;;
-    esac
-    shift
-done
-
-case "$keep_subject$numbered" in
-tt)
-       die '--keep-subject and --numbered are incompatible.' ;;
-esac
-
-revpair=
-case "$#" in
-2)
-    revpair="$1..$2" ;;
-1)
-    case "$1" in
-    *..*)
-       revpair="$1";;
-    *)
-       revpair="$1..HEAD";;
-    esac ;;
-*)
-    usage ;;
-esac
-
-me=`git-var GIT_AUTHOR_IDENT | sed -e 's/>.*/>/'`
-
-case "$outdir" in
-*/) ;;
-*) outdir="$outdir/" ;;
-esac
-test -d "$outdir" || mkdir -p "$outdir" || exit
-
-tmp=.tmp-series$$
-trap 'rm -f $tmp-*' 0 1 2 3 15
-
-series=$tmp-series
-commsg=$tmp-commsg
-filelist=$tmp-files
-
-titleScript='
-       /./d
-       /^$/n
-       s/^\[PATCH[^]]*\] *//
-       s/[^-a-z.A-Z_0-9]/-/g
-        s/\.\.\.*/\./g
-       s/\.*$//
-       s/--*/-/g
-       s/^-//
-       s/-$//
-       s/$/./
-       p
-       q
-'
-
-whosepatchScript='
-/^author /{
-       s/author \(.*>\) \(.*\)$/au='\''\1'\'' ad='\''\2'\''/p
-       q
-}'
-
-_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
-_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
-stripCommitHead='/^'"$_x40"' (from '"$_x40"')$/d'
-
-git-rev-list --no-merges --merge-order \
-       $(git-rev-parse --revs-only "$revpair") >$series
-total=`wc -l <$series | tr -dc "[0-9]"`
-i=$total
-while read commit
-do
-    git-cat-file commit "$commit" | git-stripspace >$commsg
-    title=`sed -ne "$titleScript" <$commsg`
-    case "$numbered" in
-    '') num= ;;
-    *)
-       case $total in
-       1) num= ;;
-       *) num=' '`printf "%d/%d" $i $total` ;;
-       esac
-    esac
-
-    file=`printf '%04d-%stxt' $i "$title"`
-    i=`expr "$i" - 1`
-    echo "* $file"
-    {
-       mailScript='
-       /./d
-       /^$/n'
-       case "$keep_subject" in
-       t)  ;;
-       *)
-           mailScript="$mailScript"'
-           s|^\[PATCH[^]]*\] *||
-           s|^|[PATCH'"$num"'] |'
-           ;;
-       esac
-       mailScript="$mailScript"'
-       s|^|Subject: |'
-       case "$mbox" in
-       t)
-           echo 'From nobody Mon Sep 17 00:00:00 2001' ;# UNIX "From" line
-           ;;
-       esac
-       eval "$(sed -ne "$whosepatchScript" $commsg)"
-       test "$author,$au" = ",$me" || {
-               mailScript="$mailScript"'
-       a\
-From: '"$au"
-       }
-       test "$date,$au" = ",$me" || {
-               mailScript="$mailScript"'
-       a\
-Date: '"$ad"
-       }
-
-       mailScript="$mailScript"'
-       : body
-       p
-       n
-       b body'
-
-       sed -ne "$mailScript" <$commsg
-
-       test "$signoff" = "t" && {
-               offsigner=`git-var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/'`
-               line="Signed-off-by: $offsigner"
-               grep -q "^$line\$" $commsg || {
-                       echo
-                       echo "$line"
-                       echo
-               }
-       }
-       echo
-       echo '---'
-       echo
-       git-diff-tree -p $diff_opts "$commit" | git-apply --stat --summary
-       echo
-       git-diff-tree -p $diff_opts "$commit" | sed -e "$stripCommitHead"
-
-       case "$mbox" in
-       t)
-               echo
-               ;;
-       esac
-    } >"$outdir$file"
-    case "$check" in
-    t)
-       # This is slightly modified from Andrew Morton's Perfect Patch.
-       # Lines you introduce should not have trailing whitespace.
-       # Also check for an indentation that has SP before a TAB.
-        grep -n '^+\([         ]*      .*\|.*[         ]\)$' "$outdir$file"
-
-       : do not exit with non-zero because we saw no problem in the last one.
-    esac
-done <$series
diff --git a/git-format-patch.sh b/git-format-patch.sh
new file mode 100755 (executable)
index 0000000..cfba1de
--- /dev/null
@@ -0,0 +1,220 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+. git-sh-setup || die "Not a git archive."
+
+usage () {
+    echo >&2 "usage: $0"' [-n] [-o dir] [--keep-subject] [--mbox] [--check] [--signoff] [-<diff options>...] upstream [ our-head ]
+
+Prepare each commit with its patch since our-head forked from upstream,
+one file per patch, for e-mail submission.  Each output file is
+numbered sequentially from 1, and uses the first line of the commit
+message (massaged for pathname safety) as the filename.
+
+When -o is specified, output files are created in that directory; otherwise in
+the current working directory.
+
+When -n is specified, instead of "[PATCH] Subject", the first line is formatted
+as "[PATCH N/M] Subject", unless you have only one patch.
+
+When --mbox is specified, the output is formatted to resemble
+UNIX mailbox format, and can be concatenated together for processing
+with applymbox.
+'
+    exit 1
+}
+
+diff_opts=
+IFS='
+'
+LF='
+'
+
+outdir=./
+while case "$#" in 0) break;; esac
+do
+    case "$1" in
+    -a|--a|--au|--aut|--auth|--autho|--author)
+    author=t ;;
+    -c|--c|--ch|--che|--chec|--check)
+    check=t ;;
+    -d|--d|--da|--dat|--date)
+    date=t ;;
+    -m|--m|--mb|--mbo|--mbox)
+    date=t author=t mbox=t ;;
+    -k|--k|--ke|--kee|--keep|--keep-|--keep-s|--keep-su|--keep-sub|\
+    --keep-subj|--keep-subje|--keep-subjec|--keep-subject)
+    keep_subject=t ;;
+    -n|--n|--nu|--num|--numb|--numbe|--number|--numbere|--numbered)
+    numbered=t ;;
+    -s|--s|--si|--sig|--sign|--signo|--signof|--signoff)
+    signoff=t ;;
+    -o=*|--o=*|--ou=*|--out=*|--outp=*|--outpu=*|--output=*|--output-=*|\
+    --output-d=*|--output-di=*|--output-dir=*|--output-dire=*|\
+    --output-direc=*|--output-direct=*|--output-directo=*|\
+    --output-director=*|--output-directory=*)
+    outdir=`expr "$1" : '-[^=]*=\(.*\)'` ;;
+    -o|--o|--ou|--out|--outp|--outpu|--output|--output-|--output-d|\
+    --output-di|--output-dir|--output-dire|--output-direc|--output-direct|\
+    --output-directo|--output-director|--output-directory)
+    case "$#" in 1) usage ;; esac; shift
+    outdir="$1" ;;
+    -*)        diff_opts="$diff_opts$LF$1" ;;
+    *) break ;;
+    esac
+    shift
+done
+
+case "$keep_subject$numbered" in
+tt)
+       die '--keep-subject and --numbered are incompatible.' ;;
+esac
+
+revpair=
+case "$#" in
+2)
+    revpair="$1..$2" ;;
+1)
+    case "$1" in
+    *..*)
+       revpair="$1";;
+    *)
+       revpair="$1..HEAD";;
+    esac ;;
+*)
+    usage ;;
+esac
+
+me=`git-var GIT_AUTHOR_IDENT | sed -e 's/>.*/>/'`
+
+case "$outdir" in
+*/) ;;
+*) outdir="$outdir/" ;;
+esac
+test -d "$outdir" || mkdir -p "$outdir" || exit
+
+tmp=.tmp-series$$
+trap 'rm -f $tmp-*' 0 1 2 3 15
+
+series=$tmp-series
+commsg=$tmp-commsg
+filelist=$tmp-files
+
+titleScript='
+       /./d
+       /^$/n
+       s/^\[PATCH[^]]*\] *//
+       s/[^-a-z.A-Z_0-9]/-/g
+        s/\.\.\.*/\./g
+       s/\.*$//
+       s/--*/-/g
+       s/^-//
+       s/-$//
+       s/$/./
+       p
+       q
+'
+
+whosepatchScript='
+/^author /{
+       s/author \(.*>\) \(.*\)$/au='\''\1'\'' ad='\''\2'\''/p
+       q
+}'
+
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+stripCommitHead='/^'"$_x40"' (from '"$_x40"')$/d'
+
+git-rev-list --no-merges --merge-order \
+       $(git-rev-parse --revs-only "$revpair") >$series
+total=`wc -l <$series | tr -dc "[0-9]"`
+i=$total
+while read commit
+do
+    git-cat-file commit "$commit" | git-stripspace >$commsg
+    title=`sed -ne "$titleScript" <$commsg`
+    case "$numbered" in
+    '') num= ;;
+    *)
+       case $total in
+       1) num= ;;
+       *) num=' '`printf "%d/%d" $i $total` ;;
+       esac
+    esac
+
+    file=`printf '%04d-%stxt' $i "$title"`
+    i=`expr "$i" - 1`
+    echo "* $file"
+    {
+       mailScript='
+       /./d
+       /^$/n'
+       case "$keep_subject" in
+       t)  ;;
+       *)
+           mailScript="$mailScript"'
+           s|^\[PATCH[^]]*\] *||
+           s|^|[PATCH'"$num"'] |'
+           ;;
+       esac
+       mailScript="$mailScript"'
+       s|^|Subject: |'
+       case "$mbox" in
+       t)
+           echo 'From nobody Mon Sep 17 00:00:00 2001' ;# UNIX "From" line
+           ;;
+       esac
+       eval "$(sed -ne "$whosepatchScript" $commsg)"
+       test "$author,$au" = ",$me" || {
+               mailScript="$mailScript"'
+       a\
+From: '"$au"
+       }
+       test "$date,$au" = ",$me" || {
+               mailScript="$mailScript"'
+       a\
+Date: '"$ad"
+       }
+
+       mailScript="$mailScript"'
+       : body
+       p
+       n
+       b body'
+
+       sed -ne "$mailScript" <$commsg
+
+       test "$signoff" = "t" && {
+               offsigner=`git-var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/'`
+               line="Signed-off-by: $offsigner"
+               grep -q "^$line\$" $commsg || {
+                       echo
+                       echo "$line"
+                       echo
+               }
+       }
+       echo
+       echo '---'
+       echo
+       git-diff-tree -p $diff_opts "$commit" | git-apply --stat --summary
+       echo
+       git-diff-tree -p $diff_opts "$commit" | sed -e "$stripCommitHead"
+
+       case "$mbox" in
+       t)
+               echo
+               ;;
+       esac
+    } >"$outdir$file"
+    case "$check" in
+    t)
+       # This is slightly modified from Andrew Morton's Perfect Patch.
+       # Lines you introduce should not have trailing whitespace.
+       # Also check for an indentation that has SP before a TAB.
+        grep -n '^+\([         ]*      .*\|.*[         ]\)$' "$outdir$file"
+
+       : do not exit with non-zero because we saw no problem in the last one.
+    esac
+done <$series
diff --git a/git-log-script b/git-log-script
deleted file mode 100755 (executable)
index b36c4e9..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Linus Torvalds
-#
-
-# This one uses only subdirectory-aware commands, so no need to
-# include sh-setup-script.
-
-revs=$(git-rev-parse --revs-only --no-flags --default HEAD "$@") || exit
-[ "$revs" ] || {
-       echo >&2 "No HEAD ref"
-       exit 1
-}
-git-rev-list --pretty $(git-rev-parse --default HEAD "$@") |
-LESS=-S ${PAGER:-less}
diff --git a/git-log.sh b/git-log.sh
new file mode 100755 (executable)
index 0000000..b36c4e9
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Linus Torvalds
+#
+
+# This one uses only subdirectory-aware commands, so no need to
+# include sh-setup-script.
+
+revs=$(git-rev-parse --revs-only --no-flags --default HEAD "$@") || exit
+[ "$revs" ] || {
+       echo >&2 "No HEAD ref"
+       exit 1
+}
+git-rev-list --pretty $(git-rev-parse --default HEAD "$@") |
+LESS=-S ${PAGER:-less}
diff --git a/git-ls-remote-script b/git-ls-remote-script
deleted file mode 100755 (executable)
index 061a231..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/bin/sh
-#
-. git-sh-setup-script || die "Not a git archive"
-
-usage () {
-    echo >&2 "usage: $0 [--heads] [--tags] <repository> <refs>..."
-    exit 1;
-}
-
-while case "$#" in 0) break;; esac
-do
-  case "$1" in
-  -h|--h|--he|--hea|--head|--heads)
-  heads=heads; shift ;;
-  -t|--t|--ta|--tag|--tags)
-  tags=tags; shift ;;
-  --)
-  shift; break ;;
-  -*)
-  usage ;;
-  *)
-  break ;;
-  esac
-done
-
-case "$#" in 0) usage ;; esac
-
-case ",$heads,$tags," in
-,,,) heads=heads tags=tags other=other ;;
-esac
-
-. git-parse-remote-script
-peek_repo="$(get_remote_url "$@")"
-shift
-
-tmp=.ls-remote-$$
-trap "rm -fr $tmp-*" 0 1 2 3 15
-tmpdir=$tmp-d
-
-case "$peek_repo" in
-http://* | https://* )
-        if [ -n "$GIT_SSL_NO_VERIFY" ]; then
-            curl_extra_args="-k"
-        fi
-       curl -nsf $curl_extra_args "$peek_repo/info/refs" || exit 1
-       ;;
-
-rsync://* )
-       mkdir $tmpdir
-       rsync -rq "$peek_repo/refs" $tmpdir || exit 1
-       (cd $tmpdir && find refs -type f) |
-       while read path
-       do
-               cat "$tmpdir/$path" | tr -d '\012'
-               echo "  $path"
-       done &&
-       rm -fr $tmpdir
-       ;;
-
-* )
-       git-peek-remote "$peek_repo"
-       ;;
-esac |
-sort -t '      ' -k 2 |
-while read sha1 path
-do
-       case "$path" in
-       refs/heads/*)
-               group=heads ;;
-       refs/tags/*)
-               group=tags ;;
-       *)
-               group=other ;;
-       esac
-       case ",$heads,$tags,$other," in
-       *,$group,*)
-               ;;
-       *)
-               continue;;
-       esac
-       case "$#" in
-       0)
-               match=yes ;;
-       *)
-               match=no
-               for pat
-               do
-                       case "/$path" in
-                       */$pat )
-                               match=yes
-                               break ;;
-                       esac
-               done
-       esac
-       case "$match" in
-       no)
-               continue ;;
-       esac
-       echo "$sha1     $path"
-done
diff --git a/git-ls-remote.sh b/git-ls-remote.sh
new file mode 100755 (executable)
index 0000000..604c5f5
--- /dev/null
@@ -0,0 +1,100 @@
+#!/bin/sh
+#
+. git-sh-setup || die "Not a git archive"
+
+usage () {
+    echo >&2 "usage: $0 [--heads] [--tags] <repository> <refs>..."
+    exit 1;
+}
+
+while case "$#" in 0) break;; esac
+do
+  case "$1" in
+  -h|--h|--he|--hea|--head|--heads)
+  heads=heads; shift ;;
+  -t|--t|--ta|--tag|--tags)
+  tags=tags; shift ;;
+  --)
+  shift; break ;;
+  -*)
+  usage ;;
+  *)
+  break ;;
+  esac
+done
+
+case "$#" in 0) usage ;; esac
+
+case ",$heads,$tags," in
+,,,) heads=heads tags=tags other=other ;;
+esac
+
+. git-parse-remote
+peek_repo="$(get_remote_url "$@")"
+shift
+
+tmp=.ls-remote-$$
+trap "rm -fr $tmp-*" 0 1 2 3 15
+tmpdir=$tmp-d
+
+case "$peek_repo" in
+http://* | https://* )
+        if [ -n "$GIT_SSL_NO_VERIFY" ]; then
+            curl_extra_args="-k"
+        fi
+       curl -nsf $curl_extra_args "$peek_repo/info/refs" || exit 1
+       ;;
+
+rsync://* )
+       mkdir $tmpdir
+       rsync -rq "$peek_repo/refs" $tmpdir || exit 1
+       (cd $tmpdir && find refs -type f) |
+       while read path
+       do
+               cat "$tmpdir/$path" | tr -d '\012'
+               echo "  $path"
+       done &&
+       rm -fr $tmpdir
+       ;;
+
+* )
+       git-peek-remote "$peek_repo"
+       ;;
+esac |
+sort -t '      ' -k 2 |
+while read sha1 path
+do
+       case "$path" in
+       refs/heads/*)
+               group=heads ;;
+       refs/tags/*)
+               group=tags ;;
+       *)
+               group=other ;;
+       esac
+       case ",$heads,$tags,$other," in
+       *,$group,*)
+               ;;
+       *)
+               continue;;
+       esac
+       case "$#" in
+       0)
+               match=yes ;;
+       *)
+               match=no
+               for pat
+               do
+                       case "/$path" in
+                       */$pat )
+                               match=yes
+                               break ;;
+                       esac
+               done
+       esac
+       case "$match" in
+       no)
+               continue ;;
+       esac
+       echo "$sha1     $path"
+done
diff --git a/git-merge-one-file-script b/git-merge-one-file-script
deleted file mode 100755 (executable)
index b791107..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) Linus Torvalds, 2005
-#
-# This is the git per-file merge script, called with
-#
-#   $1 - original file SHA1 (or empty)
-#   $2 - file in branch1 SHA1 (or empty)
-#   $3 - file in branch2 SHA1 (or empty)
-#   $4 - pathname in repository
-#   $5 - orignal file mode (or empty)
-#   $6 - file in branch1 mode (or empty)
-#   $7 - file in branch2 mode (or empty)
-#
-# Handle some trivial cases.. The _really_ trivial cases have
-# been handled already by git-read-tree, but that one doesn't
-# do any merges that might change the tree layout.
-
-case "${1:-.}${2:-.}${3:-.}" in
-#
-# Deleted in both or deleted in one and unchanged in the other
-#
-"$1.." | "$1.$1" | "$1$1.")
-       if [ "$2" ]; then
-               echo "Removing $4"
-       fi
-       if test -f "$4"; then
-               rm -f -- "$4"
-       fi &&
-               exec git-update-cache --remove -- "$4"
-       ;;
-
-#
-# Added in one.
-#
-".$2." | "..$3" )
-       echo "Adding $4"
-       git-update-cache --add --cacheinfo "$6$7" "$2$3" "$4" &&
-               exec git-checkout-cache -u -f -- "$4"
-       ;;
-
-#
-# Added in both (check for same permissions).
-#
-".$3$2")
-       if [ "$6" != "$7" ]; then
-               echo "ERROR: File $4 added identically in both branches,"
-               echo "ERROR: but permissions conflict $6->$7."
-               exit 1
-       fi
-       echo "Adding $4"
-       git-update-cache --add --cacheinfo "$6" "$2" "$4" &&
-               exec git-checkout-cache -u -f -- "$4"
-       ;;
-
-#
-# Modified in both, but differently.
-#
-"$1$2$3")
-       echo "Auto-merging $4."
-       orig=`git-unpack-file $1`
-       src2=`git-unpack-file $3`
-
-       # We reset the index to the first branch, making
-       # git-diff-file useful
-       git-update-cache --add --cacheinfo "$6" "$2" "$4"
-               git-checkout-cache -u -f -- "$4" &&
-               merge "$4" "$orig" "$src2"
-       ret=$?
-       rm -f -- "$orig" "$src2"
-
-       if [ "$6" != "$7" ]; then
-               echo "ERROR: Permissions conflict: $5->$6,$7."
-               ret=1
-       fi
-
-       if [ $ret -ne 0 ]; then
-               echo "ERROR: Merge conflict in $4."
-               exit 1
-       fi
-       exec git-update-cache -- "$4"
-       ;;
-
-*)
-       echo "ERROR: $4: Not handling case $1 -> $2 -> $3"
-       ;;
-esac
-exit 1
diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh
new file mode 100755 (executable)
index 0000000..5419e59
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# Copyright (c) Linus Torvalds, 2005
+#
+# This is the git per-file merge script, called with
+#
+#   $1 - original file SHA1 (or empty)
+#   $2 - file in branch1 SHA1 (or empty)
+#   $3 - file in branch2 SHA1 (or empty)
+#   $4 - pathname in repository
+#   $5 - orignal file mode (or empty)
+#   $6 - file in branch1 mode (or empty)
+#   $7 - file in branch2 mode (or empty)
+#
+# Handle some trivial cases.. The _really_ trivial cases have
+# been handled already by git-read-tree, but that one doesn't
+# do any merges that might change the tree layout.
+
+case "${1:-.}${2:-.}${3:-.}" in
+#
+# Deleted in both or deleted in one and unchanged in the other
+#
+"$1.." | "$1.$1" | "$1$1.")
+       if [ "$2" ]; then
+               echo "Removing $4"
+       fi
+       if test -f "$4"; then
+               rm -f -- "$4"
+       fi &&
+               exec git-update-index --remove -- "$4"
+       ;;
+
+#
+# Added in one.
+#
+".$2." | "..$3" )
+       echo "Adding $4"
+       git-update-index --add --cacheinfo "$6$7" "$2$3" "$4" &&
+               exec git-checkout-index -u -f -- "$4"
+       ;;
+
+#
+# Added in both (check for same permissions).
+#
+".$3$2")
+       if [ "$6" != "$7" ]; then
+               echo "ERROR: File $4 added identically in both branches,"
+               echo "ERROR: but permissions conflict $6->$7."
+               exit 1
+       fi
+       echo "Adding $4"
+       git-update-index --add --cacheinfo "$6" "$2" "$4" &&
+               exec git-checkout-index -u -f -- "$4"
+       ;;
+
+#
+# Modified in both, but differently.
+#
+"$1$2$3")
+       echo "Auto-merging $4."
+       orig=`git-unpack-file $1`
+       src2=`git-unpack-file $3`
+
+       # We reset the index to the first branch, making
+       # git-diff-file useful
+       git-update-index --add --cacheinfo "$6" "$2" "$4"
+               git-checkout-index -u -f -- "$4" &&
+               merge "$4" "$orig" "$src2"
+       ret=$?
+       rm -f -- "$orig" "$src2"
+
+       if [ "$6" != "$7" ]; then
+               echo "ERROR: Permissions conflict: $5->$6,$7."
+               ret=1
+       fi
+
+       if [ $ret -ne 0 ]; then
+               echo "ERROR: Merge conflict in $4."
+               exit 1
+       fi
+       exec git-update-index -- "$4"
+       ;;
+
+*)
+       echo "ERROR: $4: Not handling case $1 -> $2 -> $3"
+       ;;
+esac
+exit 1
diff --git a/git-octopus-script b/git-octopus-script
deleted file mode 100755 (executable)
index 80edfd4..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Junio C Hamano
-#
-# Resolve two or more trees recorded in $GIT_DIR/FETCH_HEAD.
-#
-. git-sh-setup-script || die "Not a git archive"
-
-usage () {
-    die "usage: git octopus"
-}
-
-# Sanity check the heads early.
-while read SHA1 REPO
-do
-       test $(git-cat-file -t $SHA1) = "commit" ||
-               die "$REPO given to octopus is not a commit"
-done <"$GIT_DIR/FETCH_HEAD"
-
-head=$(git-rev-parse --verify HEAD) || exit
-
-git-update-cache --refresh ||
-       die "Your working tree is dirty."
-test "$(git-diff-cache --cached "$head")" = "" ||
-       die "Your working tree does not match HEAD."
-
-# MRC is the current "merge reference commit"
-# MRT is the current "merge result tree"
-
-MRC=$head MSG= PARENT="-p $head"
-MRT=$(git-write-tree)
-CNT=1 ;# counting our head
-NON_FF_MERGE=0
-while read SHA1 REPO
-do
-       common=$(git-merge-base $MRC $SHA1) ||
-               die "Unable to find common commit with $SHA1 from $REPO"
-
-       if test "$common" = $SHA1
-       then
-               echo "Already up-to-date: $REPO"
-               continue
-       fi
-
-       CNT=`expr $CNT + 1`
-       PARENT="$PARENT -p $SHA1"
-       MSG="$MSG
-       $REPO"
-
-       if test "$common,$NON_FF_MERGE" = "$MRC,0"
-       then
-               # The first head being merged was a fast-forward.
-               # Advance MRC to the head being merged, and use that
-               # tree as the intermediate result of the merge.
-               # We still need to count this as part of the parent set.
-
-               echo "Fast forwarding to: $REPO"
-               git-read-tree -u -m $head $SHA1 || exit
-               MRC=$SHA1 MRT=$(git-write-tree)
-               continue
-       fi
-
-       NON_FF_MERGE=1
-
-       echo "Trying simple merge with $REPO"
-       git-read-tree -u -m $common $MRT $SHA1 || exit
-       next=$(git-write-tree 2>/dev/null)
-       if test $? -ne 0
-       then
-               echo "Simple merge did not work, trying automatic merge."
-               git-merge-cache -o git-merge-one-file-script -a || {
-               git-read-tree --reset "$head"
-               git-checkout-cache -f -q -u -a
-               die "Automatic merge failed; should not be doing Octopus"
-               }
-               next=$(git-write-tree 2>/dev/null)
-       fi
-       MRC=$common
-       MRT=$next
-done <"$GIT_DIR/FETCH_HEAD"
-
-# Just to be careful in case the user feeds nonsense to us.
-case "$CNT" in
-1)
-       echo "No changes."
-       exit 0 ;;
-2)
-       echo "Not an Octopus; making an ordinary commit."
-       MSG="Merge "`expr "$MSG" : '.   \(.*\)'` ; # remove LF and TAB
-       ;;
-*)
-       # In an octopus, the original head is just one of the equals,
-       # so we should list it as such.
-       HEAD_LINK=`readlink "$GIT_DIR/HEAD"`
-       MSG="Octopus merge of the following:
-
-       $HEAD_LINK from .$MSG"
-       ;;
-esac
-result_commit=$(echo "$MSG" | git-commit-tree $MRT $PARENT)
-echo "Committed merge $result_commit"
-echo $result_commit >"$GIT_DIR"/HEAD
-git-diff-tree -p $head $result_commit | git-apply --stat
diff --git a/git-octopus.sh b/git-octopus.sh
new file mode 100755 (executable)
index 0000000..521cc6f
--- /dev/null
@@ -0,0 +1,103 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+# Resolve two or more trees recorded in $GIT_DIR/FETCH_HEAD.
+#
+. git-sh-setup || die "Not a git archive"
+
+usage () {
+    die "usage: git octopus"
+}
+
+# Sanity check the heads early.
+while read SHA1 REPO
+do
+       test $(git-cat-file -t $SHA1) = "commit" ||
+               die "$REPO given to octopus is not a commit"
+done <"$GIT_DIR/FETCH_HEAD"
+
+head=$(git-rev-parse --verify HEAD) || exit
+
+git-update-index --refresh ||
+       die "Your working tree is dirty."
+test "$(git-diff-index --cached "$head")" = "" ||
+       die "Your working tree does not match HEAD."
+
+# MRC is the current "merge reference commit"
+# MRT is the current "merge result tree"
+
+MRC=$head MSG= PARENT="-p $head"
+MRT=$(git-write-tree)
+CNT=1 ;# counting our head
+NON_FF_MERGE=0
+while read SHA1 REPO
+do
+       common=$(git-merge-base $MRC $SHA1) ||
+               die "Unable to find common commit with $SHA1 from $REPO"
+
+       if test "$common" = $SHA1
+       then
+               echo "Already up-to-date: $REPO"
+               continue
+       fi
+
+       CNT=`expr $CNT + 1`
+       PARENT="$PARENT -p $SHA1"
+       MSG="$MSG
+       $REPO"
+
+       if test "$common,$NON_FF_MERGE" = "$MRC,0"
+       then
+               # The first head being merged was a fast-forward.
+               # Advance MRC to the head being merged, and use that
+               # tree as the intermediate result of the merge.
+               # We still need to count this as part of the parent set.
+
+               echo "Fast forwarding to: $REPO"
+               git-read-tree -u -m $head $SHA1 || exit
+               MRC=$SHA1 MRT=$(git-write-tree)
+               continue
+       fi
+
+       NON_FF_MERGE=1
+
+       echo "Trying simple merge with $REPO"
+       git-read-tree -u -m $common $MRT $SHA1 || exit
+       next=$(git-write-tree 2>/dev/null)
+       if test $? -ne 0
+       then
+               echo "Simple merge did not work, trying automatic merge."
+               git-merge-index -o git-merge-one-file -a || {
+               git-read-tree --reset "$head"
+               git-checkout-index -f -q -u -a
+               die "Automatic merge failed; should not be doing Octopus"
+               }
+               next=$(git-write-tree 2>/dev/null)
+       fi
+       MRC=$common
+       MRT=$next
+done <"$GIT_DIR/FETCH_HEAD"
+
+# Just to be careful in case the user feeds nonsense to us.
+case "$CNT" in
+1)
+       echo "No changes."
+       exit 0 ;;
+2)
+       echo "Not an Octopus; making an ordinary commit."
+       MSG="Merge "`expr "$MSG" : '.   \(.*\)'` ; # remove LF and TAB
+       ;;
+*)
+       # In an octopus, the original head is just one of the equals,
+       # so we should list it as such.
+       HEAD_LINK=`readlink "$GIT_DIR/HEAD"`
+       MSG="Octopus merge of the following:
+
+       $HEAD_LINK from .$MSG"
+       ;;
+esac
+result_commit=$(echo "$MSG" | git-commit-tree $MRT $PARENT)
+echo "Committed merge $result_commit"
+echo $result_commit >"$GIT_DIR"/HEAD
+git-diff-tree -p $head $result_commit | git-apply --stat
diff --git a/git-parse-remote-script b/git-parse-remote-script
deleted file mode 100755 (executable)
index 43b4368..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-#!/bin/sh
-
-. git-sh-setup-script || die "Not a git archive"
-
-get_data_source () {
-       case "$1" in
-       */*)
-               # Not so fast.  This could be the partial URL shorthand...
-               token=$(expr "$1" : '\([^/]*\)/')
-               remainder=$(expr "$1" : '[^/]*/\(.*\)')
-               if test -f "$GIT_DIR/branches/$token"
-               then
-                       echo branches-partial
-               else
-                       echo ''
-               fi
-               ;;
-       *)
-               if test -f "$GIT_DIR/remotes/$1"
-               then
-                       echo remotes
-               elif test -f "$GIT_DIR/branches/$1"
-               then
-                       echo branches
-               else
-                       echo ''
-               fi ;;
-       esac
-}
-
-get_remote_url () {
-       data_source=$(get_data_source "$1")
-       case "$data_source" in
-       '')
-               echo "$1" ;;
-       remotes)
-               sed -ne '/^URL: */{
-                       s///p
-                       q
-               }' "$GIT_DIR/remotes/$1" ;;
-       branches)
-               sed -e 's/#.*//' "$GIT_DIR/branches/$1" ;;
-       branches-partial)
-               token=$(expr "$1" : '\([^/]*\)/')
-               remainder=$(expr "$1" : '[^/]*/\(.*\)')
-               url=$(sed -e 's/#.*//' "$GIT_DIR/branches/$token")
-               echo "$url/$remainder"
-               ;;
-       *)
-               die "internal error: get-remote-url $1" ;;
-       esac
-}
-
-get_remote_default_refs_for_push () {
-       data_source=$(get_data_source "$1")
-       case "$data_source" in
-       '' | branches | branches-partial)
-               ;; # no default push mapping, just send matching refs.
-       remotes)
-               sed -ne '/^Push: */{
-                       s///p
-               }' "$GIT_DIR/remotes/$1" ;;
-       *)
-               die "internal error: get-remote-default-ref-for-push $1" ;;
-       esac
-}
-
-# Subroutine to canonicalize remote:local notation
-canon_refs_list_for_fetch () {
-       for ref
-       do
-               force=
-               case "$ref" in
-               +*)
-                       ref=$(expr "$ref" : '\+\(.*\)')
-                       force=+
-                       ;;
-               esac
-               expr "$ref" : '.*:' >/dev/null || ref="${ref}:"
-               remote=$(expr "$ref" : '\([^:]*\):')
-               local=$(expr "$ref" : '[^:]*:\(.*\)')
-               case "$remote" in
-               '') remote=HEAD ;;
-               refs/heads/* | refs/tags/*) ;;
-               heads/* | tags/* ) remote="refs/$remote" ;;
-               *) remote="refs/heads/$remote" ;;
-               esac
-               case "$local" in
-               '') local= ;;
-               refs/heads/* | refs/tags/*) ;;
-               heads/* | tags/* ) local="refs/$local" ;;
-               *) local="refs/heads/$local" ;;
-               esac
-               echo "${force}${remote}:${local}"
-       done
-}
-
-# Returns list of src: (no store), or src:dst (store)
-get_remote_default_refs_for_fetch () {
-       data_source=$(get_data_source "$1")
-       case "$data_source" in
-       '' | branches-partial)
-               echo "HEAD:" ;;
-       branches)
-               remote_branch=$(sed -ne '/#/s/.*#//p' "$GIT_DIR/branches/$1")
-               case "$remote_branch" in '') remote_branch=master ;; esac
-               echo "refs/heads/${remote_branch}:refs/heads/$1"
-               ;;
-       remotes)
-               canon_refs_list_for_fetch $(sed -ne '/^Pull: */{
-                                               s///p
-                                       }' "$GIT_DIR/remotes/$1")
-               ;;
-       *)
-               die "internal error: get-remote-default-ref-for-push $1" ;;
-       esac
-}
-
-get_remote_refs_for_push () {
-       case "$#" in
-       0) die "internal error: get-remote-refs-for-push." ;;
-       1) get_remote_default_refs_for_push "$@" ;;
-       *) shift; echo "$@" ;;
-       esac
-}
-
-get_remote_refs_for_fetch () {
-       case "$#" in
-       0)
-           die "internal error: get-remote-refs-for-fetch." ;;
-       1)
-           get_remote_default_refs_for_fetch "$@" ;;
-       *)
-           shift
-           tag_just_seen=
-           for ref
-           do
-               if test "$tag_just_seen"
-               then
-                   echo "refs/tags/${ref}:refs/tags/${ref}"
-                   tag_just_seen=
-                   continue
-               else
-                   case "$ref" in
-                   tag)
-                       tag_just_seen=yes
-                       continue
-                       ;;
-                   esac
-               fi
-               canon_refs_list_for_fetch "$ref"
-           done
-           ;;
-       esac
-}
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
new file mode 100755 (executable)
index 0000000..3c5d94b
--- /dev/null
@@ -0,0 +1,155 @@
+#!/bin/sh
+
+. git-sh-setup || die "Not a git archive"
+
+get_data_source () {
+       case "$1" in
+       */*)
+               # Not so fast.  This could be the partial URL shorthand...
+               token=$(expr "$1" : '\([^/]*\)/')
+               remainder=$(expr "$1" : '[^/]*/\(.*\)')
+               if test -f "$GIT_DIR/branches/$token"
+               then
+                       echo branches-partial
+               else
+                       echo ''
+               fi
+               ;;
+       *)
+               if test -f "$GIT_DIR/remotes/$1"
+               then
+                       echo remotes
+               elif test -f "$GIT_DIR/branches/$1"
+               then
+                       echo branches
+               else
+                       echo ''
+               fi ;;
+       esac
+}
+
+get_remote_url () {
+       data_source=$(get_data_source "$1")
+       case "$data_source" in
+       '')
+               echo "$1" ;;
+       remotes)
+               sed -ne '/^URL: */{
+                       s///p
+                       q
+               }' "$GIT_DIR/remotes/$1" ;;
+       branches)
+               sed -e 's/#.*//' "$GIT_DIR/branches/$1" ;;
+       branches-partial)
+               token=$(expr "$1" : '\([^/]*\)/')
+               remainder=$(expr "$1" : '[^/]*/\(.*\)')
+               url=$(sed -e 's/#.*//' "$GIT_DIR/branches/$token")
+               echo "$url/$remainder"
+               ;;
+       *)
+               die "internal error: get-remote-url $1" ;;
+       esac
+}
+
+get_remote_default_refs_for_push () {
+       data_source=$(get_data_source "$1")
+       case "$data_source" in
+       '' | branches | branches-partial)
+               ;; # no default push mapping, just send matching refs.
+       remotes)
+               sed -ne '/^Push: */{
+                       s///p
+               }' "$GIT_DIR/remotes/$1" ;;
+       *)
+               die "internal error: get-remote-default-ref-for-push $1" ;;
+       esac
+}
+
+# Subroutine to canonicalize remote:local notation
+canon_refs_list_for_fetch () {
+       for ref
+       do
+               force=
+               case "$ref" in
+               +*)
+                       ref=$(expr "$ref" : '\+\(.*\)')
+                       force=+
+                       ;;
+               esac
+               expr "$ref" : '.*:' >/dev/null || ref="${ref}:"
+               remote=$(expr "$ref" : '\([^:]*\):')
+               local=$(expr "$ref" : '[^:]*:\(.*\)')
+               case "$remote" in
+               '') remote=HEAD ;;
+               refs/heads/* | refs/tags/*) ;;
+               heads/* | tags/* ) remote="refs/$remote" ;;
+               *) remote="refs/heads/$remote" ;;
+               esac
+               case "$local" in
+               '') local= ;;
+               refs/heads/* | refs/tags/*) ;;
+               heads/* | tags/* ) local="refs/$local" ;;
+               *) local="refs/heads/$local" ;;
+               esac
+               echo "${force}${remote}:${local}"
+       done
+}
+
+# Returns list of src: (no store), or src:dst (store)
+get_remote_default_refs_for_fetch () {
+       data_source=$(get_data_source "$1")
+       case "$data_source" in
+       '' | branches-partial)
+               echo "HEAD:" ;;
+       branches)
+               remote_branch=$(sed -ne '/#/s/.*#//p' "$GIT_DIR/branches/$1")
+               case "$remote_branch" in '') remote_branch=master ;; esac
+               echo "refs/heads/${remote_branch}:refs/heads/$1"
+               ;;
+       remotes)
+               canon_refs_list_for_fetch $(sed -ne '/^Pull: */{
+                                               s///p
+                                       }' "$GIT_DIR/remotes/$1")
+               ;;
+       *)
+               die "internal error: get-remote-default-ref-for-push $1" ;;
+       esac
+}
+
+get_remote_refs_for_push () {
+       case "$#" in
+       0) die "internal error: get-remote-refs-for-push." ;;
+       1) get_remote_default_refs_for_push "$@" ;;
+       *) shift; echo "$@" ;;
+       esac
+}
+
+get_remote_refs_for_fetch () {
+       case "$#" in
+       0)
+           die "internal error: get-remote-refs-for-fetch." ;;
+       1)
+           get_remote_default_refs_for_fetch "$@" ;;
+       *)
+           shift
+           tag_just_seen=
+           for ref
+           do
+               if test "$tag_just_seen"
+               then
+                   echo "refs/tags/${ref}:refs/tags/${ref}"
+                   tag_just_seen=
+                   continue
+               else
+                   case "$ref" in
+                   tag)
+                       tag_just_seen=yes
+                       continue
+                       ;;
+                   esac
+               fi
+               canon_refs_list_for_fetch "$ref"
+           done
+           ;;
+       esac
+}
diff --git a/git-prune-script b/git-prune-script
deleted file mode 100755 (executable)
index 2e130c7..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-. git-sh-setup-script || die "Not a git archive"
-
-dryrun=
-echo=
-while case "$#" in 0) break ;; esac
-do
-    case "$1" in
-    -n) dryrun=-n echo=echo ;;
-    --) break ;;
-    -*) echo >&2 "usage: git-prune-script [ -n ] [ heads... ]"; exit 1 ;;
-    *)  break ;;
-    esac
-    shift;
-done
-
-git-fsck-cache --full --cache --unreachable "$@" |
-sed -ne '/unreachable /{
-    s/unreachable [^ ][^ ]* //
-    s|\(..\)|\1/|p
-}' | {
-       cd "$GIT_OBJECT_DIRECTORY" || exit
-       xargs $echo rm -f
-}
-
-git-prune-packed $dryrun
diff --git a/git-prune.sh b/git-prune.sh
new file mode 100755 (executable)
index 0000000..9657dbf
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+. git-sh-setup || die "Not a git archive"
+
+dryrun=
+echo=
+while case "$#" in 0) break ;; esac
+do
+    case "$1" in
+    -n) dryrun=-n echo=echo ;;
+    --) break ;;
+    -*) echo >&2 "usage: git-prune [ -n ] [ heads... ]"; exit 1 ;;
+    *)  break ;;
+    esac
+    shift;
+done
+
+git-fsck-objects --full --cache --unreachable "$@" |
+sed -ne '/unreachable /{
+    s/unreachable [^ ][^ ]* //
+    s|\(..\)|\1/|p
+}' | {
+       cd "$GIT_OBJECT_DIRECTORY" || exit
+       xargs $echo rm -f
+}
+
+git-prune-packed $dryrun
diff --git a/git-pull-script b/git-pull-script
deleted file mode 100755 (executable)
index c31a65c..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Junio C Hamano
-#
-# Fetch one or more remote refs and merge it/them into the current HEAD.
-
-. git-sh-setup-script || die "Not a git archive"
-
-orig_head=$(cat "$GIT_DIR/HEAD") || die "Pulling into a black hole?"
-git-fetch-script --update-head-ok "$@" || exit 1
-
-curr_head=$(cat "$GIT_DIR/HEAD")
-if test "$curr_head" != "$orig_head"
-then
-       # The fetch involved updating the current branch.
-
-       # The working tree and the index file is still based on the
-       # $orig_head commit, but we are merging into $curr_head.
-       # First update the working tree to match $curr_head.
-
-       echo >&2 "Warning: fetch updated the current branch head."
-       echo >&2 "Warning: fast forwarding your working tree."
-       git-read-tree -u -m "$orig_head" "$curr_head" ||
-               die "You need to first update your working tree."
-fi
-
-merge_head=$(sed -e 's/        .*//' "$GIT_DIR"/FETCH_HEAD | tr '\012' ' ')
-merge_name=$(sed -e 's/^[0-9a-f]*      //' "$GIT_DIR"/FETCH_HEAD |
-        tr '\012' ' ')
-
-case "$merge_head" in
-'')
-       echo >&2 "No changes."
-       exit 0
-       ;;
-*' '?*)
-       echo >&2 "Pulling more than one heads; making an Octopus."
-       exec git-octopus-script
-       ;;
-esac
-
-git-resolve-script \
-       "$(cat "$GIT_DIR"/HEAD)" \
-       $merge_head "Merge $merge_name"
diff --git a/git-pull.sh b/git-pull.sh
new file mode 100755 (executable)
index 0000000..c1b4474
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+# Fetch one or more remote refs and merge it/them into the current HEAD.
+
+. git-sh-setup || die "Not a git archive"
+
+orig_head=$(cat "$GIT_DIR/HEAD") || die "Pulling into a black hole?"
+git-fetch --update-head-ok "$@" || exit 1
+
+curr_head=$(cat "$GIT_DIR/HEAD")
+if test "$curr_head" != "$orig_head"
+then
+       # The fetch involved updating the current branch.
+
+       # The working tree and the index file is still based on the
+       # $orig_head commit, but we are merging into $curr_head.
+       # First update the working tree to match $curr_head.
+
+       echo >&2 "Warning: fetch updated the current branch head."
+       echo >&2 "Warning: fast forwarding your working tree."
+       git-read-tree -u -m "$orig_head" "$curr_head" ||
+               die "You need to first update your working tree."
+fi
+
+merge_head=$(sed -e 's/        .*//' "$GIT_DIR"/FETCH_HEAD | tr '\012' ' ')
+merge_name=$(sed -e 's/^[0-9a-f]*      //' "$GIT_DIR"/FETCH_HEAD |
+        tr '\012' ' ')
+
+case "$merge_head" in
+'')
+       echo >&2 "No changes."
+       exit 0
+       ;;
+*' '?*)
+       echo >&2 "Pulling more than one heads; making an Octopus."
+       exec git-octopus
+       ;;
+esac
+
+git-resolve \
+       "$(cat "$GIT_DIR"/HEAD)" \
+       $merge_head "Merge $merge_name"
diff --git a/git-push-script b/git-push-script
deleted file mode 100755 (executable)
index 744ee7e..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/sh
-. git-sh-setup-script || die "Not a git archive"
-
-# Parse out parameters and then stop at remote, so that we can
-# translate it using .git/branches information
-has_all=
-has_force=
-has_exec=
-remote=
-
-while case "$#" in 0) break ;; esac
-do
-       case "$1" in
-       --all)
-               has_all=--all ;;
-       --force)
-               has_force=--force ;;
-       --exec=*)
-               has_exec="$1" ;;
-       -*)
-               die "Unknown parameter $1" ;;
-        *)
-               set x "$@"
-               shift
-               break ;;
-       esac
-       shift
-done
-case "$#" in
-0)
-       die "Where would you want to push today?" ;;
-esac
-
-. git-parse-remote-script
-remote=$(get_remote_url "$@")
-case "$has_all" in
---all) set x ;;
-'')    set x $(get_remote_refs_for_push "$@") ;;
-esac
-shift
-
-case "$remote" in
-http://* | https://* | git://* | rsync://* )
-       die "Cannot push to $remote" ;;
-esac
-
-set x "$remote" "$@"; shift
-test "$has_all" && set x "$has_all" "$@" && shift
-test "$has_force" && set x "$has_force" "$@" && shift
-test "$has_exec" && set x "$has_exec" "$@" && shift
-
-exec git-send-pack "$@"
diff --git a/git-push.sh b/git-push.sh
new file mode 100755 (executable)
index 0000000..00d7150
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/sh
+. git-sh-setup || die "Not a git archive"
+
+# Parse out parameters and then stop at remote, so that we can
+# translate it using .git/branches information
+has_all=
+has_force=
+has_exec=
+remote=
+
+while case "$#" in 0) break ;; esac
+do
+       case "$1" in
+       --all)
+               has_all=--all ;;
+       --force)
+               has_force=--force ;;
+       --exec=*)
+               has_exec="$1" ;;
+       -*)
+               die "Unknown parameter $1" ;;
+        *)
+               set x "$@"
+               shift
+               break ;;
+       esac
+       shift
+done
+case "$#" in
+0)
+       die "Where would you want to push today?" ;;
+esac
+
+. git-parse-remote
+remote=$(get_remote_url "$@")
+case "$has_all" in
+--all) set x ;;
+'')    set x $(get_remote_refs_for_push "$@") ;;
+esac
+shift
+
+case "$remote" in
+http://* | https://* | git://* | rsync://* )
+       die "Cannot push to $remote" ;;
+esac
+
+set x "$remote" "$@"; shift
+test "$has_all" && set x "$has_all" "$@" && shift
+test "$has_force" && set x "$has_force" "$@" && shift
+test "$has_exec" && set x "$has_exec" "$@" && shift
+
+exec git-send-pack "$@"
diff --git a/git-rebase-script b/git-rebase-script
deleted file mode 100755 (executable)
index b0893cc..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Junio C Hamano.
-#
-
-. git-sh-setup-script || die "Not a git archive."
-
-usage="usage: $0 "'<upstream> [<head>]
-
-Uses output from git-cherry to rebase local commits to the new head of
-upstream tree.'
-
-case "$#,$1" in
-1,*..*)
-    upstream=$(expr "$1" : '\(.*\)\.\.') ours=$(expr "$1" : '.*\.\.\(.*\)$')
-    set x "$upstream" "$ours"
-    shift ;;
-esac
-
-git-update-cache --refresh || exit
-
-case "$#" in
-1) ours_symbolic=HEAD ;;
-2) ours_symbolic="$2" ;;
-*) die "$usage" ;;
-esac
-
-upstream=`git-rev-parse --verify "$1"` &&
-ours=`git-rev-parse --verify "$ours_symbolic"` || exit
-different1=$(git-diff-cache --name-only --cached "$ours") &&
-different2=$(git-diff-cache --name-only "$ours") &&
-test "$different1$different2" = "" ||
-die "Your working tree does not match $ours_symbolic."
-
-git-read-tree -m -u $ours $upstream &&
-git-rev-parse --verify "$upstream^0" >"$GIT_DIR/HEAD" || exit
-
-tmp=.rebase-tmp$$
-fail=$tmp-fail
-trap "rm -rf $tmp-*" 1 2 3 15
-
->$fail
-
-git-cherry -v $upstream $ours |
-while read sign commit msg
-do
-       case "$sign" in
-       -)
-               echo >&2 "* Already applied: $msg"
-               continue ;;
-       esac
-       echo >&2 "* Applying: $msg"
-       S=`cat "$GIT_DIR/HEAD"` &&
-       git-cherry-pick-script --replay $commit || {
-               echo >&2 "* Not applying the patch and continuing."
-               echo $commit >>$fail
-               git-reset-script --hard $S
-       }
-done
-if test -s $fail
-then
-       echo >&2 Some commits could not be rebased, check by hand:
-       cat >&2 $fail
-       echo >&2 "(the same list of commits are found in $tmp)"
-       exit 1
-else
-       rm -f $fail
-fi
diff --git a/git-rebase.sh b/git-rebase.sh
new file mode 100755 (executable)
index 0000000..49c8f12
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano.
+#
+
+. git-sh-setup || die "Not a git archive."
+
+usage="usage: $0 "'<upstream> [<head>]
+
+Uses output from git-cherry to rebase local commits to the new head of
+upstream tree.'
+
+case "$#,$1" in
+1,*..*)
+    upstream=$(expr "$1" : '\(.*\)\.\.') ours=$(expr "$1" : '.*\.\.\(.*\)$')
+    set x "$upstream" "$ours"
+    shift ;;
+esac
+
+git-update-index --refresh || exit
+
+case "$#" in
+1) ours_symbolic=HEAD ;;
+2) ours_symbolic="$2" ;;
+*) die "$usage" ;;
+esac
+
+upstream=`git-rev-parse --verify "$1"` &&
+ours=`git-rev-parse --verify "$ours_symbolic"` || exit
+different1=$(git-diff-index --name-only --cached "$ours") &&
+different2=$(git-diff-index --name-only "$ours") &&
+test "$different1$different2" = "" ||
+die "Your working tree does not match $ours_symbolic."
+
+git-read-tree -m -u $ours $upstream &&
+git-rev-parse --verify "$upstream^0" >"$GIT_DIR/HEAD" || exit
+
+tmp=.rebase-tmp$$
+fail=$tmp-fail
+trap "rm -rf $tmp-*" 1 2 3 15
+
+>$fail
+
+git-cherry -v $upstream $ours |
+while read sign commit msg
+do
+       case "$sign" in
+       -)
+               echo >&2 "* Already applied: $msg"
+               continue ;;
+       esac
+       echo >&2 "* Applying: $msg"
+       S=`cat "$GIT_DIR/HEAD"` &&
+       git-cherry-pick --replay $commit || {
+               echo >&2 "* Not applying the patch and continuing."
+               echo $commit >>$fail
+               git-reset --hard $S
+       }
+done
+if test -s $fail
+then
+       echo >&2 Some commits could not be rebased, check by hand:
+       cat >&2 $fail
+       echo >&2 "(the same list of commits are found in $tmp)"
+       exit 1
+else
+       rm -f $fail
+fi
diff --git a/git-relink-script b/git-relink-script
deleted file mode 100755 (executable)
index f6b4f6a..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-#!/usr/bin/env perl
-# Copyright 2005, Ryan Anderson <ryan@michonline.com>
-# Distribution permitted under the GPL v2, as distributed
-# by the Free Software Foundation.
-# Later versions of the GPL at the discretion of Linus Torvalds
-#
-# Scan two git object-trees, and hardlink any common objects between them.
-
-use 5.006;
-use strict;
-use warnings;
-use Getopt::Long;
-
-sub get_canonical_form($);
-sub do_scan_directory($$$);
-sub compare_two_files($$);
-sub usage();
-sub link_two_files($$);
-
-# stats
-my $total_linked = 0;
-my $total_already = 0;
-my ($linked,$already);
-
-my $fail_on_different_sizes = 0;
-my $help = 0;
-GetOptions("safe" => \$fail_on_different_sizes,
-          "help" => \$help);
-
-usage() if $help;
-
-my (@dirs) = @ARGV;
-
-usage() if (!defined $dirs[0] || !defined $dirs[1]);
-
-$_ = get_canonical_form($_) foreach (@dirs);
-
-my $master_dir = pop @dirs;
-
-opendir(D,$master_dir . "objects/")
-       or die "Failed to open $master_dir/objects/ : $!";
-
-my @hashdirs = grep !/^\.{1,2}$/, readdir(D);
-
-foreach my $repo (@dirs) {
-       $linked = 0;
-       $already = 0;
-       printf("Searching '%s' and '%s' for common objects and hardlinking them...\n",
-               $master_dir,$repo);
-
-       foreach my $hashdir (@hashdirs) {
-               do_scan_directory($master_dir, $hashdir, $repo);
-       }
-
-       printf("Linked %d files, %d were already linked.\n",$linked, $already);
-
-       $total_linked += $linked;
-       $total_already += $already;
-}
-
-printf("Totals: Linked %d files, %d were already linked.\n",
-       $total_linked, $total_already);
-
-
-sub do_scan_directory($$$) {
-       my ($srcdir, $subdir, $dstdir) = @_;
-
-       my $sfulldir = sprintf("%sobjects/%s/",$srcdir,$subdir);
-       my $dfulldir = sprintf("%sobjects/%s/",$dstdir,$subdir);
-
-       opendir(S,$sfulldir)
-               or die "Failed to opendir $sfulldir: $!";
-
-       foreach my $file (grep(!/\.{1,2}$/, readdir(S))) {
-               my $sfilename = $sfulldir . $file;
-               my $dfilename = $dfulldir . $file;
-
-               compare_two_files($sfilename,$dfilename);
-
-       }
-       closedir(S);
-}
-
-sub compare_two_files($$) {
-       my ($sfilename, $dfilename) = @_;
-
-       # Perl's stat returns relevant information as follows:
-       # 0 = dev number
-       # 1 = inode number
-       # 7 = size
-       my @sstatinfo = stat($sfilename);
-       my @dstatinfo = stat($dfilename);
-
-       if (@sstatinfo == 0 && @dstatinfo == 0) {
-               die sprintf("Stat of both %s and %s failed: %s\n",$sfilename, $dfilename, $!);
-
-       } elsif (@dstatinfo == 0) {
-               return;
-       }
-
-       if ( ($sstatinfo[0] == $dstatinfo[0]) &&
-            ($sstatinfo[1] != $dstatinfo[1])) {
-               if ($sstatinfo[7] == $dstatinfo[7]) {
-                       link_two_files($sfilename, $dfilename);
-
-               } else {
-                       my $err = sprintf("ERROR: File sizes are not the same, cannot relink %s to %s.\n",
-                               $sfilename, $dfilename);
-                       if ($fail_on_different_sizes) {
-                               die $err;
-                       } else {
-                               warn $err;
-                       }
-               }
-
-       } elsif ( ($sstatinfo[0] == $dstatinfo[0]) &&
-            ($sstatinfo[1] == $dstatinfo[1])) {
-               $already++;
-       }
-}
-
-sub get_canonical_form($) {
-       my $dir = shift;
-       my $original = $dir;
-
-       die "$dir is not a directory." unless -d $dir;
-
-       $dir .= "/" unless $dir =~ m#/$#;
-       $dir .= ".git/" unless $dir =~ m#\.git/$#;
-
-       die "$original does not have a .git/ subdirectory.\n" unless -d $dir;
-
-       return $dir;
-}
-
-sub link_two_files($$) {
-       my ($sfilename, $dfilename) = @_;
-       my $tmpdname = sprintf("%s.old",$dfilename);
-       rename($dfilename,$tmpdname)
-               or die sprintf("Failure renaming %s to %s: %s",
-                       $dfilename, $tmpdname, $!);
-
-       if (! link($sfilename,$dfilename)) {
-               my $failtxt = "";
-               unless (rename($tmpdname,$dfilename)) {
-                       $failtxt = sprintf(
-                               "Git Repository containing %s is probably corrupted, " .
-                               "please copy '%s' to '%s' to fix.\n",
-                               $tmpdname, $dfilename);
-               }
-
-               die sprintf("Failed to link %s to %s: %s\n%s" .
-                       $sfilename, $dfilename,
-                       $!, $dfilename, $failtxt);
-       }
-
-       unlink($tmpdname)
-               or die sprintf("Unlink of %s failed: %s\n",
-                       $dfilename, $!);
-
-       $linked++;
-}
-
-
-sub usage() {
-       print("Usage: $0 [--safe] <dir> [<dir> ...] <master_dir> \n");
-       print("All directories should contain a .git/objects/ subdirectory.\n");
-       print("Options\n");
-       print("\t--safe\t" .
-               "Stops if two objects with the same hash exist but " .
-               "have different sizes.  Default is to warn and continue.\n");
-       exit(1);
-}
diff --git a/git-relink.perl b/git-relink.perl
new file mode 100755 (executable)
index 0000000..f6b4f6a
--- /dev/null
@@ -0,0 +1,173 @@
+#!/usr/bin/env perl
+# Copyright 2005, Ryan Anderson <ryan@michonline.com>
+# Distribution permitted under the GPL v2, as distributed
+# by the Free Software Foundation.
+# Later versions of the GPL at the discretion of Linus Torvalds
+#
+# Scan two git object-trees, and hardlink any common objects between them.
+
+use 5.006;
+use strict;
+use warnings;
+use Getopt::Long;
+
+sub get_canonical_form($);
+sub do_scan_directory($$$);
+sub compare_two_files($$);
+sub usage();
+sub link_two_files($$);
+
+# stats
+my $total_linked = 0;
+my $total_already = 0;
+my ($linked,$already);
+
+my $fail_on_different_sizes = 0;
+my $help = 0;
+GetOptions("safe" => \$fail_on_different_sizes,
+          "help" => \$help);
+
+usage() if $help;
+
+my (@dirs) = @ARGV;
+
+usage() if (!defined $dirs[0] || !defined $dirs[1]);
+
+$_ = get_canonical_form($_) foreach (@dirs);
+
+my $master_dir = pop @dirs;
+
+opendir(D,$master_dir . "objects/")
+       or die "Failed to open $master_dir/objects/ : $!";
+
+my @hashdirs = grep !/^\.{1,2}$/, readdir(D);
+
+foreach my $repo (@dirs) {
+       $linked = 0;
+       $already = 0;
+       printf("Searching '%s' and '%s' for common objects and hardlinking them...\n",
+               $master_dir,$repo);
+
+       foreach my $hashdir (@hashdirs) {
+               do_scan_directory($master_dir, $hashdir, $repo);
+       }
+
+       printf("Linked %d files, %d were already linked.\n",$linked, $already);
+
+       $total_linked += $linked;
+       $total_already += $already;
+}
+
+printf("Totals: Linked %d files, %d were already linked.\n",
+       $total_linked, $total_already);
+
+
+sub do_scan_directory($$$) {
+       my ($srcdir, $subdir, $dstdir) = @_;
+
+       my $sfulldir = sprintf("%sobjects/%s/",$srcdir,$subdir);
+       my $dfulldir = sprintf("%sobjects/%s/",$dstdir,$subdir);
+
+       opendir(S,$sfulldir)
+               or die "Failed to opendir $sfulldir: $!";
+
+       foreach my $file (grep(!/\.{1,2}$/, readdir(S))) {
+               my $sfilename = $sfulldir . $file;
+               my $dfilename = $dfulldir . $file;
+
+               compare_two_files($sfilename,$dfilename);
+
+       }
+       closedir(S);
+}
+
+sub compare_two_files($$) {
+       my ($sfilename, $dfilename) = @_;
+
+       # Perl's stat returns relevant information as follows:
+       # 0 = dev number
+       # 1 = inode number
+       # 7 = size
+       my @sstatinfo = stat($sfilename);
+       my @dstatinfo = stat($dfilename);
+
+       if (@sstatinfo == 0 && @dstatinfo == 0) {
+               die sprintf("Stat of both %s and %s failed: %s\n",$sfilename, $dfilename, $!);
+
+       } elsif (@dstatinfo == 0) {
+               return;
+       }
+
+       if ( ($sstatinfo[0] == $dstatinfo[0]) &&
+            ($sstatinfo[1] != $dstatinfo[1])) {
+               if ($sstatinfo[7] == $dstatinfo[7]) {
+                       link_two_files($sfilename, $dfilename);
+
+               } else {
+                       my $err = sprintf("ERROR: File sizes are not the same, cannot relink %s to %s.\n",
+                               $sfilename, $dfilename);
+                       if ($fail_on_different_sizes) {
+                               die $err;
+                       } else {
+                               warn $err;
+                       }
+               }
+
+       } elsif ( ($sstatinfo[0] == $dstatinfo[0]) &&
+            ($sstatinfo[1] == $dstatinfo[1])) {
+               $already++;
+       }
+}
+
+sub get_canonical_form($) {
+       my $dir = shift;
+       my $original = $dir;
+
+       die "$dir is not a directory." unless -d $dir;
+
+       $dir .= "/" unless $dir =~ m#/$#;
+       $dir .= ".git/" unless $dir =~ m#\.git/$#;
+
+       die "$original does not have a .git/ subdirectory.\n" unless -d $dir;
+
+       return $dir;
+}
+
+sub link_two_files($$) {
+       my ($sfilename, $dfilename) = @_;
+       my $tmpdname = sprintf("%s.old",$dfilename);
+       rename($dfilename,$tmpdname)
+               or die sprintf("Failure renaming %s to %s: %s",
+                       $dfilename, $tmpdname, $!);
+
+       if (! link($sfilename,$dfilename)) {
+               my $failtxt = "";
+               unless (rename($tmpdname,$dfilename)) {
+                       $failtxt = sprintf(
+                               "Git Repository containing %s is probably corrupted, " .
+                               "please copy '%s' to '%s' to fix.\n",
+                               $tmpdname, $dfilename);
+               }
+
+               die sprintf("Failed to link %s to %s: %s\n%s" .
+                       $sfilename, $dfilename,
+                       $!, $dfilename, $failtxt);
+       }
+
+       unlink($tmpdname)
+               or die sprintf("Unlink of %s failed: %s\n",
+                       $dfilename, $!);
+
+       $linked++;
+}
+
+
+sub usage() {
+       print("Usage: $0 [--safe] <dir> [<dir> ...] <master_dir> \n");
+       print("All directories should contain a .git/objects/ subdirectory.\n");
+       print("Options\n");
+       print("\t--safe\t" .
+               "Stops if two objects with the same hash exist but " .
+               "have different sizes.  Default is to warn and continue.\n");
+       exit(1);
+}
diff --git a/git-rename-script b/git-rename-script
deleted file mode 100755 (executable)
index b4d3148..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright 2005, Ryan Anderson <ryan@michonline.com>
-#
-# This file is licensed under the GPL v2, or a later version
-# at the discretion of Linus Torvalds.
-
-
-use warnings;
-use strict;
-
-sub usage($);
-
-# Sanity checks:
-my $GIT_DIR = $ENV{'GIT_DIR'} || ".git";
-
-unless ( -d $GIT_DIR && -d $GIT_DIR . "/objects" && 
-       -d $GIT_DIR . "/objects/00" && -d $GIT_DIR . "/refs") {
-       usage("Git repository not found.");
-}
-
-usage("") if scalar @ARGV != 2;
-
-my ($src,$dst) = @ARGV;
-
-unless (-f $src || -l $src || -d $src) {
-       usage("git rename: bad source '$src'");
-}
-
-if (-e $dst) {
-       usage("git rename: destinations '$dst' already exists");
-}
-
-my (@allfiles,@srcfiles,@dstfiles);
-
-$/ = "\0";
-open(F,"-|","git-ls-files","-z")
-       or die "Failed to open pipe from git-ls-files: " . $!;
-
-@allfiles = map { chomp; $_; } <F>;
-close(F);
-
-my $safesrc = quotemeta($src);
-@srcfiles = grep /^$safesrc/, @allfiles;
-@dstfiles = @srcfiles;
-s#^$safesrc(/|$)#$dst$1# for @dstfiles;
-
-rename($src,$dst)
-       or die "rename failed: $!";
-
-my $rc = system("git-update-cache","--add","--",@dstfiles);
-die "git-update-cache failed to add new name with code $?\n" if $rc;
-
-$rc = system("git-update-cache","--remove","--",@srcfiles);
-die "git-update-cache failed to remove old name with code $?\n" if $rc;
-
-
-sub usage($) {
-       my $s = shift;
-       print $s, "\n" if (length $s != 0);
-       print <<EOT;
-$0 <source> <dest>
-source must exist and be either a file, symlink or directory.
-dest must NOT exist.
-
-Renames source to dest, and updates the git cache to reflect the change.
-Use "git commit" to make record the change permanently.
-EOT
-       exit(1);
-}
diff --git a/git-rename.perl b/git-rename.perl
new file mode 100755 (executable)
index 0000000..a28c8c8
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+#
+# Copyright 2005, Ryan Anderson <ryan@michonline.com>
+#
+# This file is licensed under the GPL v2, or a later version
+# at the discretion of Linus Torvalds.
+
+
+use warnings;
+use strict;
+
+sub usage($);
+
+# Sanity checks:
+my $GIT_DIR = $ENV{'GIT_DIR'} || ".git";
+
+unless ( -d $GIT_DIR && -d $GIT_DIR . "/objects" && 
+       -d $GIT_DIR . "/objects/00" && -d $GIT_DIR . "/refs") {
+       usage("Git repository not found.");
+}
+
+usage("") if scalar @ARGV != 2;
+
+my ($src,$dst) = @ARGV;
+
+unless (-f $src || -l $src || -d $src) {
+       usage("git rename: bad source '$src'");
+}
+
+if (-e $dst) {
+       usage("git rename: destinations '$dst' already exists");
+}
+
+my (@allfiles,@srcfiles,@dstfiles);
+
+$/ = "\0";
+open(F,"-|","git-ls-files","-z")
+       or die "Failed to open pipe from git-ls-files: " . $!;
+
+@allfiles = map { chomp; $_; } <F>;
+close(F);
+
+my $safesrc = quotemeta($src);
+@srcfiles = grep /^$safesrc/, @allfiles;
+@dstfiles = @srcfiles;
+s#^$safesrc(/|$)#$dst$1# for @dstfiles;
+
+rename($src,$dst)
+       or die "rename failed: $!";
+
+my $rc = system("git-update-index","--add","--",@dstfiles);
+die "git-update-index failed to add new name with code $?\n" if $rc;
+
+$rc = system("git-update-index","--remove","--",@srcfiles);
+die "git-update-index failed to remove old name with code $?\n" if $rc;
+
+
+sub usage($) {
+       my $s = shift;
+       print $s, "\n" if (length $s != 0);
+       print <<EOT;
+$0 <source> <dest>
+source must exist and be either a file, symlink or directory.
+dest must NOT exist.
+
+Renames source to dest, and updates the git cache to reflect the change.
+Use "git commit" to make record the change permanently.
+EOT
+       exit(1);
+}
diff --git a/git-repack-script b/git-repack-script
deleted file mode 100755 (executable)
index 80628b5..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Linus Torvalds
-#
-
-. git-sh-setup-script || die "Not a git archive"
-       
-no_update_info= all_into_one= remove_redundant=
-while case "$#" in 0) break ;; esac
-do
-       case "$1" in
-       -n)     no_update_info=t ;;
-       -a)     all_into_one=t ;;
-       -d)     remove_redandant=t ;;
-       *)      break ;;
-       esac
-       shift
-done
-
-rm -f .tmp-pack-*
-PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
-
-# There will be more repacking strategies to come...
-case ",$all_into_one," in
-,,)
-       rev_list='--unpacked'
-       rev_parse='--all'
-       pack_objects='--incremental'
-       ;;
-,t,)
-       rev_list=
-       rev_parse='--all'
-       pack_objects=
-       # This part is a stop-gap until we have proper pack redundancy
-       # checker.
-       existing=`cd "$PACKDIR" && \
-           find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
-       ;;
-esac
-name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) |
-       git-pack-objects --non-empty $pack_objects .tmp-pack) ||
-       exit 1
-if [ -z "$name" ]; then
-       echo Nothing new to pack.
-       exit 0
-fi
-echo "Pack pack-$name created."
-
-mkdir -p "$PACKDIR" || exit
-
-mv .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
-mv .tmp-pack-$name.idx  "$PACKDIR/pack-$name.idx" ||
-exit
-
-if test "$remove_redandant" = t
-then
-       # We know $existing are all redandant only when
-       # all-into-one is used.
-       if test "$all_into_one" != '' && test "$existing" != ''
-       then
-               ( cd "$PACKDIR" && rm -f $existing )
-       fi
-fi
-
-case "$no_update_info" in
-t) : ;;
-*) git-update-server-info ;;
-esac
diff --git a/git-repack.sh b/git-repack.sh
new file mode 100755 (executable)
index 0000000..064c85c
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Linus Torvalds
+#
+
+. git-sh-setup || die "Not a git archive"
+       
+no_update_info= all_into_one= remove_redundant=
+while case "$#" in 0) break ;; esac
+do
+       case "$1" in
+       -n)     no_update_info=t ;;
+       -a)     all_into_one=t ;;
+       -d)     remove_redandant=t ;;
+       *)      break ;;
+       esac
+       shift
+done
+
+rm -f .tmp-pack-*
+PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
+
+# There will be more repacking strategies to come...
+case ",$all_into_one," in
+,,)
+       rev_list='--unpacked'
+       rev_parse='--all'
+       pack_objects='--incremental'
+       ;;
+,t,)
+       rev_list=
+       rev_parse='--all'
+       pack_objects=
+       # This part is a stop-gap until we have proper pack redundancy
+       # checker.
+       existing=`cd "$PACKDIR" && \
+           find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
+       ;;
+esac
+name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) |
+       git-pack-objects --non-empty $pack_objects .tmp-pack) ||
+       exit 1
+if [ -z "$name" ]; then
+       echo Nothing new to pack.
+       exit 0
+fi
+echo "Pack pack-$name created."
+
+mkdir -p "$PACKDIR" || exit
+
+mv .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
+mv .tmp-pack-$name.idx  "$PACKDIR/pack-$name.idx" ||
+exit
+
+if test "$remove_redandant" = t
+then
+       # We know $existing are all redandant only when
+       # all-into-one is used.
+       if test "$all_into_one" != '' && test "$existing" != ''
+       then
+               ( cd "$PACKDIR" && rm -f $existing )
+       fi
+fi
+
+case "$no_update_info" in
+t) : ;;
+*) git-update-server-info ;;
+esac
diff --git a/git-request-pull-script b/git-request-pull-script
deleted file mode 100755 (executable)
index ae6cd27..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh -e
-# Copyright 2005, Ryan Anderson <ryan@michonline.com>
-#
-# This file is licensed under the GPL v2, or a later version
-# at the discretion of Linus Torvalds.
-
-usage()
-{
-       echo "$0 <commit> <url> [ <head> ]"
-       echo "  Summarizes the changes since <commit> to the standard output,"
-       echo "  and includes <url> in the message generated."
-       exit 1
-}
-
-revision=$1
-url=$2
-head=${3-HEAD}
-
-[ "$revision" ] || usage
-[ "$url" ] || usage
-
-baserev=`git-rev-parse --verify "$revision"^0` &&
-headrev=`git-rev-parse --verify "$head"^0` || exit
-
-echo "The following changes since commit $baserev:"
-git log --max-count=1 --pretty=short "$baserev" |
-git-shortlog | sed -e 's/^\(.\)/  \1/'
-
-echo "are found in the git repository at:" 
-echo
-echo "  $url"
-echo
-
-git log  $baserev..$headrev | git-shortlog ;
-git diff $baserev..$headrev | git-apply --stat --summary
diff --git a/git-request-pull.sh b/git-request-pull.sh
new file mode 100755 (executable)
index 0000000..ae6cd27
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh -e
+# Copyright 2005, Ryan Anderson <ryan@michonline.com>
+#
+# This file is licensed under the GPL v2, or a later version
+# at the discretion of Linus Torvalds.
+
+usage()
+{
+       echo "$0 <commit> <url> [ <head> ]"
+       echo "  Summarizes the changes since <commit> to the standard output,"
+       echo "  and includes <url> in the message generated."
+       exit 1
+}
+
+revision=$1
+url=$2
+head=${3-HEAD}
+
+[ "$revision" ] || usage
+[ "$url" ] || usage
+
+baserev=`git-rev-parse --verify "$revision"^0` &&
+headrev=`git-rev-parse --verify "$head"^0` || exit
+
+echo "The following changes since commit $baserev:"
+git log --max-count=1 --pretty=short "$baserev" |
+git-shortlog | sed -e 's/^\(.\)/  \1/'
+
+echo "are found in the git repository at:" 
+echo
+echo "  $url"
+echo
+
+git log  $baserev..$headrev | git-shortlog ;
+git diff $baserev..$headrev | git-apply --stat --summary
diff --git a/git-reset-script b/git-reset-script
deleted file mode 100755 (executable)
index 863e2a9..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/bin/sh
-. git-sh-setup-script || die "Not a git archive"
-
-tmp=/var/tmp/reset.$$
-trap 'rm -f $tmp-*' 0 1 2 3 15
-
-reset_type=--mixed
-case "$1" in
---mixed | --soft | --hard)
-       reset_type="$1"
-       shift
-       ;;
-esac
-
-rev=$(git-rev-parse --verify --default HEAD "$@") || exit
-rev=$(git-rev-parse --verify $rev^0) || exit
-
-# We need to remember the set of paths that _could_ be left
-# behind before a hard reset, so that we can remove them.
-if test "$reset_type" = "--hard"
-then
-       {
-               git-ls-files --stage -z
-               git-rev-parse --verify HEAD 2>/dev/null &&
-               git-ls-tree -r -z HEAD
-       } | perl -e '
-           use strict;
-           my %seen;
-           $/ = "\0";
-           while (<>) {
-               chomp;
-               my ($info, $path) = split(/\t/, $_);
-               next if ($info =~ / tree /);
-               if (!$seen{$path}) {
-                       $seen{$path} = 1;
-                       print "$path\0";
-               }
-           }
-       ' >$tmp-exists
-fi
-
-# Soft reset does not touch the index file nor the working tree
-# at all, but requires them in a good order.  Other resets reset
-# the index file to the tree object we are switching to.
-if test "$reset_type" = "--soft"
-then
-       if test -f "$GIT_DIR/MERGE_HEAD" ||
-          test "" != "$(git-ls-files --unmerged)"
-       then
-               die "Cannot do a soft reset in the middle of a merge."
-       fi
-else
-       git-read-tree --reset "$rev" || exit
-fi
-
-# Any resets update HEAD to the head being switched to.
-if orig=$(git-rev-parse --verify HEAD 2>/dev/null)
-then
-       echo "$orig" >"$GIT_DIR/ORIG_HEAD"
-else
-       rm -f "$GIT_DIR/ORIG_HEAD"
-fi
-echo "$rev" >"$GIT_DIR/HEAD"
-
-case "$reset_type" in
---hard )
-       # Hard reset matches the working tree to that of the tree
-       # being switched to.
-       git-checkout-cache -f -u -q -a
-       git-ls-files --cached -z |
-       perl -e '
-               use strict;
-               my (%keep, $fh);
-               $/ = "\0";
-               while (<STDIN>) {
-                       chomp;
-                       $keep{$_} = 1;
-               }
-               open $fh, "<", $ARGV[0]
-                       or die "cannot open $ARGV[0]";
-               while (<$fh>) {
-                       chomp;
-                       if (! exists $keep{$_}) {
-                               print "$_\0";
-                       }
-               }
-       ' $tmp-exists | xargs -0 rm -v -f --
-       ;;
---soft )
-       ;; # Nothing else to do
---mixed )
-       # Report what has not been updated.
-       git-update-cache --refresh
-       ;;
-esac
-
-rm -f "$GIT_DIR/MERGE_HEAD"
diff --git a/git-reset.sh b/git-reset.sh
new file mode 100755 (executable)
index 0000000..04c1ac0
--- /dev/null
@@ -0,0 +1,97 @@
+#!/bin/sh
+. git-sh-setup || die "Not a git archive"
+
+tmp=/var/tmp/reset.$$
+trap 'rm -f $tmp-*' 0 1 2 3 15
+
+reset_type=--mixed
+case "$1" in
+--mixed | --soft | --hard)
+       reset_type="$1"
+       shift
+       ;;
+esac
+
+rev=$(git-rev-parse --verify --default HEAD "$@") || exit
+rev=$(git-rev-parse --verify $rev^0) || exit
+
+# We need to remember the set of paths that _could_ be left
+# behind before a hard reset, so that we can remove them.
+if test "$reset_type" = "--hard"
+then
+       {
+               git-ls-files --stage -z
+               git-rev-parse --verify HEAD 2>/dev/null &&
+               git-ls-tree -r -z HEAD
+       } | perl -e '
+           use strict;
+           my %seen;
+           $/ = "\0";
+           while (<>) {
+               chomp;
+               my ($info, $path) = split(/\t/, $_);
+               next if ($info =~ / tree /);
+               if (!$seen{$path}) {
+                       $seen{$path} = 1;
+                       print "$path\0";
+               }
+           }
+       ' >$tmp-exists
+fi
+
+# Soft reset does not touch the index file nor the working tree
+# at all, but requires them in a good order.  Other resets reset
+# the index file to the tree object we are switching to.
+if test "$reset_type" = "--soft"
+then
+       if test -f "$GIT_DIR/MERGE_HEAD" ||
+          test "" != "$(git-ls-files --unmerged)"
+       then
+               die "Cannot do a soft reset in the middle of a merge."
+       fi
+else
+       git-read-tree --reset "$rev" || exit
+fi
+
+# Any resets update HEAD to the head being switched to.
+if orig=$(git-rev-parse --verify HEAD 2>/dev/null)
+then
+       echo "$orig" >"$GIT_DIR/ORIG_HEAD"
+else
+       rm -f "$GIT_DIR/ORIG_HEAD"
+fi
+echo "$rev" >"$GIT_DIR/HEAD"
+
+case "$reset_type" in
+--hard )
+       # Hard reset matches the working tree to that of the tree
+       # being switched to.
+       git-checkout-index -f -u -q -a
+       git-ls-files --cached -z |
+       perl -e '
+               use strict;
+               my (%keep, $fh);
+               $/ = "\0";
+               while (<STDIN>) {
+                       chomp;
+                       $keep{$_} = 1;
+               }
+               open $fh, "<", $ARGV[0]
+                       or die "cannot open $ARGV[0]";
+               while (<$fh>) {
+                       chomp;
+                       if (! exists $keep{$_}) {
+                               print "$_\0";
+                       }
+               }
+       ' $tmp-exists | xargs -0 rm -v -f --
+       ;;
+--soft )
+       ;; # Nothing else to do
+--mixed )
+       # Report what has not been updated.
+       git-update-index --refresh
+       ;;
+esac
+
+rm -f "$GIT_DIR/MERGE_HEAD"
diff --git a/git-resolve-script b/git-resolve-script
deleted file mode 100755 (executable)
index 000cbb8..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Linus Torvalds
-#
-# Resolve two trees.
-#
-. git-sh-setup-script || die "Not a git archive"
-
-usage () {
-       die "git-resolve-script <head> <remote> <merge-message>"
-}
-
-dropheads() {
-       rm -f -- "$GIT_DIR/MERGE_HEAD" \
-               "$GIT_DIR/LAST_MERGE" || exit 1
-}
-
-head=$(git-rev-parse --verify "$1"^0) &&
-merge=$(git-rev-parse --verify "$2"^0) &&
-merge_msg="$3" || usage
-
-#
-# The remote name is just used for the message,
-# but we do want it.
-#
-if [ -z "$head" -o -z "$merge" -o -z "$merge_msg" ]; then
-       usage
-fi
-
-dropheads
-echo $head > "$GIT_DIR"/ORIG_HEAD
-echo $merge > "$GIT_DIR"/LAST_MERGE
-
-common=$(git-merge-base $head $merge)
-if [ -z "$common" ]; then
-       die "Unable to find common commit between" $merge $head
-fi
-
-case "$common" in
-"$merge")
-       echo "Already up-to-date. Yeeah!"
-       dropheads
-       exit 0
-       ;;
-"$head")
-       echo "Updating from $head to $merge."
-       git-read-tree -u -m $head $merge || exit 1
-       echo $merge > "$GIT_DIR"/HEAD
-       git-diff-tree -p $head $merge | git-apply --stat
-       dropheads
-       exit 0
-       ;;
-esac
-
-# Find an optimum merge base if there are more than one candidates.
-LF='
-'
-common=$(git-merge-base -a $head $merge)
-case "$common" in
-?*"$LF"?*)
-       echo "Trying to find the optimum merge base."
-       G=.tmp-index$$
-       best=
-       best_cnt=-1
-       for c in $common
-       do
-               rm -f $G
-               GIT_INDEX_FILE=$G git-read-tree -m $c $head $merge \
-                       2>/dev/null || continue
-               # Count the paths that are unmerged.
-               cnt=`GIT_INDEX_FILE=$G git-ls-files --unmerged | wc -l`
-               if test $best_cnt -le 0 -o $cnt -le $best_cnt
-               then
-                       best=$c
-                       best_cnt=$cnt
-                       if test "$best_cnt" -eq 0
-                       then
-                               # Cannot do any better than all trivial merge.
-                               break
-                       fi
-               fi
-       done
-       rm -f $G
-       common="$best"
-esac
-
-echo "Trying to merge $merge into $head using $common."
-git-update-cache --refresh 2>/dev/null
-git-read-tree -u -m $common $head $merge || exit 1
-result_tree=$(git-write-tree  2> /dev/null)
-if [ $? -ne 0 ]; then
-       echo "Simple merge failed, trying Automatic merge"
-       git-merge-cache -o git-merge-one-file-script -a
-       if [ $? -ne 0 ]; then
-               echo $merge > "$GIT_DIR"/MERGE_HEAD
-               die "Automatic merge failed, fix up by hand"
-       fi
-       result_tree=$(git-write-tree) || exit 1
-fi
-result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree -p $head -p $merge)
-echo "Committed merge $result_commit"
-echo $result_commit > "$GIT_DIR"/HEAD
-git-diff-tree -p $head $result_commit | git-apply --stat
-dropheads
diff --git a/git-resolve.sh b/git-resolve.sh
new file mode 100755 (executable)
index 0000000..1f559d8
--- /dev/null
@@ -0,0 +1,104 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Linus Torvalds
+#
+# Resolve two trees.
+#
+. git-sh-setup || die "Not a git archive"
+
+usage () {
+       die "git-resolve <head> <remote> <merge-message>"
+}
+
+dropheads() {
+       rm -f -- "$GIT_DIR/MERGE_HEAD" \
+               "$GIT_DIR/LAST_MERGE" || exit 1
+}
+
+head=$(git-rev-parse --verify "$1"^0) &&
+merge=$(git-rev-parse --verify "$2"^0) &&
+merge_msg="$3" || usage
+
+#
+# The remote name is just used for the message,
+# but we do want it.
+#
+if [ -z "$head" -o -z "$merge" -o -z "$merge_msg" ]; then
+       usage
+fi
+
+dropheads
+echo $head > "$GIT_DIR"/ORIG_HEAD
+echo $merge > "$GIT_DIR"/LAST_MERGE
+
+common=$(git-merge-base $head $merge)
+if [ -z "$common" ]; then
+       die "Unable to find common commit between" $merge $head
+fi
+
+case "$common" in
+"$merge")
+       echo "Already up-to-date. Yeeah!"
+       dropheads
+       exit 0
+       ;;
+"$head")
+       echo "Updating from $head to $merge."
+       git-read-tree -u -m $head $merge || exit 1
+       echo $merge > "$GIT_DIR"/HEAD
+       git-diff-tree -p $head $merge | git-apply --stat
+       dropheads
+       exit 0
+       ;;
+esac
+
+# Find an optimum merge base if there are more than one candidates.
+LF='
+'
+common=$(git-merge-base -a $head $merge)
+case "$common" in
+?*"$LF"?*)
+       echo "Trying to find the optimum merge base."
+       G=.tmp-index$$
+       best=
+       best_cnt=-1
+       for c in $common
+       do
+               rm -f $G
+               GIT_INDEX_FILE=$G git-read-tree -m $c $head $merge \
+                       2>/dev/null || continue
+               # Count the paths that are unmerged.
+               cnt=`GIT_INDEX_FILE=$G git-ls-files --unmerged | wc -l`
+               if test $best_cnt -le 0 -o $cnt -le $best_cnt
+               then
+                       best=$c
+                       best_cnt=$cnt
+                       if test "$best_cnt" -eq 0
+                       then
+                               # Cannot do any better than all trivial merge.
+                               break
+                       fi
+               fi
+       done
+       rm -f $G
+       common="$best"
+esac
+
+echo "Trying to merge $merge into $head using $common."
+git-update-index --refresh 2>/dev/null
+git-read-tree -u -m $common $head $merge || exit 1
+result_tree=$(git-write-tree  2> /dev/null)
+if [ $? -ne 0 ]; then
+       echo "Simple merge failed, trying Automatic merge"
+       git-merge-index -o git-merge-one-file -a
+       if [ $? -ne 0 ]; then
+               echo $merge > "$GIT_DIR"/MERGE_HEAD
+               die "Automatic merge failed, fix up by hand"
+       fi
+       result_tree=$(git-write-tree) || exit 1
+fi
+result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree -p $head -p $merge)
+echo "Committed merge $result_commit"
+echo $result_commit > "$GIT_DIR"/HEAD
+git-diff-tree -p $head $result_commit | git-apply --stat
+dropheads
diff --git a/git-revert-script b/git-revert-script
deleted file mode 100755 (executable)
index 82ed093..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Linus Torvalds
-# Copyright (c) 2005 Junio C Hamano
-#
-. git-sh-setup-script || die "Not a git archive"
-
-case "$0" in
-*-revert-* )
-       me=revert ;;
-*-cherry-pick-* )
-       me=cherry-pick ;;
-esac
-
-usage () {
-       case "$me" in
-       cherry-pick)
-               die "usage git $me [-n] [-r] <commit-ish>"
-               ;;
-       revert)
-               die "usage git $me [-n] <commit-ish>"
-               ;;
-       esac
-}
-
-no_commit= replay=
-while case "$#" in 0) break ;; esac
-do
-       case "$1" in
-       -n|--n|--no|--no-|--no-c|--no-co|--no-com|--no-comm|\
-           --no-commi|--no-commit)
-               no_commit=t
-               ;;
-       -r|--r|--re|--rep|--repl|--repla|--replay)
-               replay=t
-               ;;
-       -*)
-               usage
-               ;;
-       *)
-               break
-               ;;
-       esac
-       shift
-done
-
-test "$me,$replay" = "revert,t" && usage
-
-case "$no_commit" in
-t)
-       # We do not intend to commit immediately.  We just want to
-       # merge the differences in.
-       head=$(git-write-tree) ||
-               die "Your index file is unmerged."
-       ;;
-*)
-       check_clean_tree || die "Cannot run $me from a dirty tree."
-       head=$(git-rev-parse --verify HEAD) ||
-               die "You do not have a valid HEAD"
-       ;;
-esac
-
-rev=$(git-rev-parse --verify "$@") &&
-commit=$(git-rev-parse --verify "$rev^0") ||
-       die "Not a single commit $@"
-prev=$(git-rev-parse --verify "$commit^1" 2>/dev/null) ||
-       die "Cannot run $me a root commit"
-git-rev-parse --verify "$commit^2" >/dev/null 2>&1 &&
-       die "Cannot run $me a multi-parent commit."
-
-# "commit" is an existing commit.  We would want to apply
-# the difference it introduces since its first parent "prev"
-# on top of the current HEAD if we are cherry-pick.  Or the
-# reverse of it if we are revert.
-
-case "$me" in
-revert)
-       git-rev-list --pretty=oneline --max-count=1 $commit |
-       sed -e '
-               s/^[^ ]* /Revert "/
-               s/$/"/'
-       echo
-       echo "This reverts $commit commit."
-       test "$rev" = "$commit" ||
-       echo "(original 'git revert' arguments: $@)"
-       base=$commit next=$prev
-       ;;
-
-cherry-pick)
-       pick_author_script='
-       /^author /{
-               h
-               s/^author \([^<]*\) <[^>]*> .*$/\1/
-               s/'\''/'\''\'\'\''/g
-               s/.*/GIT_AUTHOR_NAME='\''&'\''/p
-
-               g
-               s/^author [^<]* <\([^>]*\)> .*$/\1/
-               s/'\''/'\''\'\'\''/g
-               s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
-
-               g
-               s/^author [^<]* <[^>]*> \(.*\)$/\1/
-               s/'\''/'\''\'\'\''/g
-               s/.*/GIT_AUTHOR_DATE='\''&'\''/p
-
-               q
-       }'
-       set_author_env=`git-cat-file commit "$commit" |
-       sed -ne "$pick_author_script"`
-       eval "$set_author_env"
-       export GIT_AUTHOR_NAME
-       export GIT_AUTHOR_EMAIL
-       export GIT_AUTHOR_DATE
-
-       git-cat-file commit $commit | sed -e '1,/^$/d'
-       case "$replay" in
-       '')
-               echo "(cherry picked from $commit commit)"
-               test "$rev" = "$commit" ||
-               echo "(original 'git cherry-pick' arguments: $@)"
-               ;;
-       esac
-       base=$prev next=$commit
-       ;;
-
-esac >.msg
-
-# This three way merge is an interesting one.  We are at
-# $head, and would want to apply the change between $commit
-# and $prev on top of us (when reverting), or the change between
-# $prev and $commit on top of us (when cherry-picking or replaying).
-
-echo >&2 "First trying simple merge strategy to $me."
-git-read-tree -m -u $base $head $next &&
-result=$(git-write-tree 2>/dev/null) || {
-    echo >&2 "Simple $me fails; trying Automatic $me."
-    git-merge-cache -o git-merge-one-file-script -a || {
-           echo >&2 "Automatic $me failed.  After fixing it up,"
-           echo >&2 "you can use \"git commit -F .msg\""
-           case "$me" in
-           cherry-pick)
-               echo >&2 "You may choose to use the following when making"
-               echo >&2 "the commit:"
-               echo >&2 "$set_author_env"
-           esac
-           exit 1
-    }
-    result=$(git-write-tree) || exit
-}
-echo >&2 "Finished one $me."
-
-# If we are cherry-pick, and if the merge did not result in
-# hand-editing, we will hit this commit and inherit the original
-# author date and name.
-# If we are revert, or if our cherry-pick results in a hand merge,
-# we had better say that the current user is responsible for that.
-
-case "$no_commit" in
-'')
-       git-commit-script -n -F .msg
-       rm -f .msg
-       ;;
-esac
diff --git a/git-revert.sh b/git-revert.sh
new file mode 100755 (executable)
index 0000000..722c4f7
--- /dev/null
@@ -0,0 +1,166 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Linus Torvalds
+# Copyright (c) 2005 Junio C Hamano
+#
+. git-sh-setup || die "Not a git archive"
+
+case "$0" in
+*-revert* )
+       me=revert ;;
+*-cherry-pick* )
+       me=cherry-pick ;;
+* )
+       die "What are ou talking about?" ;;
+esac
+
+usage () {
+       case "$me" in
+       cherry-pick)
+               die "usage git $me [-n] [-r] <commit-ish>"
+               ;;
+       revert)
+               die "usage git $me [-n] <commit-ish>"
+               ;;
+       esac
+}
+
+no_commit= replay=
+while case "$#" in 0) break ;; esac
+do
+       case "$1" in
+       -n|--n|--no|--no-|--no-c|--no-co|--no-com|--no-comm|\
+           --no-commi|--no-commit)
+               no_commit=t
+               ;;
+       -r|--r|--re|--rep|--repl|--repla|--replay)
+               replay=t
+               ;;
+       -*)
+               usage
+               ;;
+       *)
+               break
+               ;;
+       esac
+       shift
+done
+
+test "$me,$replay" = "revert,t" && usage
+
+case "$no_commit" in
+t)
+       # We do not intend to commit immediately.  We just want to
+       # merge the differences in.
+       head=$(git-write-tree) ||
+               die "Your index file is unmerged."
+       ;;
+*)
+       check_clean_tree || die "Cannot run $me from a dirty tree."
+       head=$(git-rev-parse --verify HEAD) ||
+               die "You do not have a valid HEAD"
+       ;;
+esac
+
+rev=$(git-rev-parse --verify "$@") &&
+commit=$(git-rev-parse --verify "$rev^0") ||
+       die "Not a single commit $@"
+prev=$(git-rev-parse --verify "$commit^1" 2>/dev/null) ||
+       die "Cannot run $me a root commit"
+git-rev-parse --verify "$commit^2" >/dev/null 2>&1 &&
+       die "Cannot run $me a multi-parent commit."
+
+# "commit" is an existing commit.  We would want to apply
+# the difference it introduces since its first parent "prev"
+# on top of the current HEAD if we are cherry-pick.  Or the
+# reverse of it if we are revert.
+
+case "$me" in
+revert)
+       git-rev-list --pretty=oneline --max-count=1 $commit |
+       sed -e '
+               s/^[^ ]* /Revert "/
+               s/$/"/'
+       echo
+       echo "This reverts $commit commit."
+       test "$rev" = "$commit" ||
+       echo "(original 'git revert' arguments: $@)"
+       base=$commit next=$prev
+       ;;
+
+cherry-pick)
+       pick_author_script='
+       /^author /{
+               h
+               s/^author \([^<]*\) <[^>]*> .*$/\1/
+               s/'\''/'\''\'\'\''/g
+               s/.*/GIT_AUTHOR_NAME='\''&'\''/p
+
+               g
+               s/^author [^<]* <\([^>]*\)> .*$/\1/
+               s/'\''/'\''\'\'\''/g
+               s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
+
+               g
+               s/^author [^<]* <[^>]*> \(.*\)$/\1/
+               s/'\''/'\''\'\'\''/g
+               s/.*/GIT_AUTHOR_DATE='\''&'\''/p
+
+               q
+       }'
+       set_author_env=`git-cat-file commit "$commit" |
+       sed -ne "$pick_author_script"`
+       eval "$set_author_env"
+       export GIT_AUTHOR_NAME
+       export GIT_AUTHOR_EMAIL
+       export GIT_AUTHOR_DATE
+
+       git-cat-file commit $commit | sed -e '1,/^$/d'
+       case "$replay" in
+       '')
+               echo "(cherry picked from $commit commit)"
+               test "$rev" = "$commit" ||
+               echo "(original 'git cherry-pick' arguments: $@)"
+               ;;
+       esac
+       base=$prev next=$commit
+       ;;
+
+esac >.msg
+
+# This three way merge is an interesting one.  We are at
+# $head, and would want to apply the change between $commit
+# and $prev on top of us (when reverting), or the change between
+# $prev and $commit on top of us (when cherry-picking or replaying).
+
+echo >&2 "First trying simple merge strategy to $me."
+git-read-tree -m -u $base $head $next &&
+result=$(git-write-tree 2>/dev/null) || {
+    echo >&2 "Simple $me fails; trying Automatic $me."
+    git-merge-index -o git-merge-one-file -a || {
+           echo >&2 "Automatic $me failed.  After fixing it up,"
+           echo >&2 "you can use \"git commit -F .msg\""
+           case "$me" in
+           cherry-pick)
+               echo >&2 "You may choose to use the following when making"
+               echo >&2 "the commit:"
+               echo >&2 "$set_author_env"
+           esac
+           exit 1
+    }
+    result=$(git-write-tree) || exit
+}
+echo >&2 "Finished one $me."
+
+# If we are cherry-pick, and if the merge did not result in
+# hand-editing, we will hit this commit and inherit the original
+# author date and name.
+# If we are revert, or if our cherry-pick results in a hand merge,
+# we had better say that the current user is responsible for that.
+
+case "$no_commit" in
+'')
+       git-commit -n -F .msg
+       rm -f .msg
+       ;;
+esac
diff --git a/git-send-email-script b/git-send-email-script
deleted file mode 100755 (executable)
index 86b676a..0000000
+++ /dev/null
@@ -1,368 +0,0 @@
-#!/usr/bin/perl -w
-#
-# Copyright 2002,2005 Greg Kroah-Hartman <greg@kroah.com>
-# Copyright 2005 Ryan Anderson <ryan@michonline.com>
-#
-# GPL v2 (See COPYING)
-#
-# Ported to support git "mbox" format files by Ryan Anderson <ryan@michonline.com>
-#
-# Sends a collection of emails to the given email addresses, disturbingly fast.
-#
-# Supports two formats:
-# 1. mbox format files (ignoring most headers and MIME formatting - this is designed for sending patches)
-# 2. The original format support by Greg's script:
-#    first line of the message is who to CC,
-#    and second line is the subject of the message.
-#
-
-use strict;
-use warnings;
-use Term::ReadLine;
-use Mail::Sendmail qw(sendmail %mailcfg);
-use Getopt::Long;
-use Data::Dumper;
-use Email::Valid;
-
-sub unique_email_list(@);
-sub cleanup_compose_files();
-
-# Constants (essentially)
-my $compose_filename = ".msg.$$";
-
-# Variables we fill in automatically, or via prompting:
-my (@to,@cc,$initial_reply_to,$initial_subject,@files,$from,$compose);
-
-# Behavior modification variables
-my ($chain_reply_to, $smtp_server) = (1, "localhost");
-
-# Example reply to:
-#$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
-
-my $term = new Term::ReadLine 'git-send-email';
-
-# Begin by accumulating all the variables (defined above), that we will end up
-# needing, first, from the command line:
-
-my $rc = GetOptions("from=s" => \$from,
-                    "in-reply-to=s" => \$initial_reply_to,
-                   "subject=s" => \$initial_subject,
-                   "to=s" => \@to,
-                   "chain-reply-to!" => \$chain_reply_to,
-                   "smtp-server=s" => \$smtp_server,
-                   "compose" => \$compose,
-        );
-
-# Now, let's fill any that aren't set in with defaults:
-
-open(GITVAR,"-|","git-var","-l")
-       or die "Failed to open pipe from git-var: $!";
-
-my ($author,$committer);
-while(<GITVAR>) {
-       chomp;
-       my ($var,$data) = split /=/,$_,2;
-       my @fields = split /\s+/, $data;
-
-       my $ident = join(" ", @fields[0...(@fields-3)]);
-
-       if ($var eq 'GIT_AUTHOR_IDENT') {
-               $author = $ident;
-       } elsif ($var eq 'GIT_COMMITTER_IDENT') {
-               $committer = $ident;
-       }
-}
-close(GITVAR);
-
-my $prompting = 0;
-if (!defined $from) {
-       $from = $author || $committer;
-       do {
-               $_ = $term->readline("Who should the emails appear to be from? ",
-                       $from);
-       } while (!defined $_);
-
-       $from = $_;
-       print "Emails will be sent from: ", $from, "\n";
-       $prompting++;
-}
-
-if (!@to) {
-       do {
-               $_ = $term->readline("Who should the emails be sent to? ",
-                               "");
-       } while (!defined $_);
-       my $to = $_;
-       push @to, split /,/, $to;
-       $prompting++;
-}
-
-if (!defined $initial_subject && $compose) {
-       do {
-               $_ = $term->readline("What subject should the emails start with? ",
-                       $initial_subject);
-       } while (!defined $_);
-       $initial_subject = $_;
-       $prompting++;
-}
-
-if (!defined $initial_reply_to && $prompting) {
-       do {
-               $_= $term->readline("Message-ID to be used as In-Reply-To for the first email? ",
-                       $initial_reply_to);
-       } while (!defined $_);
-
-       $initial_reply_to = $_;
-       $initial_reply_to =~ s/(^\s+|\s+$)//g;
-}
-
-if (!defined $smtp_server) {
-       $smtp_server = "localhost";
-}
-
-if ($compose) {
-       # Note that this does not need to be secure, but we will make a small
-       # effort to have it be unique
-       open(C,">",$compose_filename)
-               or die "Failed to open for writing $compose_filename: $!";
-       print C "From \n";
-       printf C "Subject: %s\n\n", $initial_subject;
-       printf C <<EOT;
-GIT: Please enter your email below.
-GIT: Lines beginning in "GIT: " will be removed.
-GIT: Consider including an overall diffstat or table of contents
-GIT: for the patch you are writing.
-
-EOT
-       close(C);
-
-       my $editor = $ENV{EDITOR};
-       $editor = 'vi' unless defined $editor;
-       system($editor, $compose_filename);
-
-       open(C2,">",$compose_filename . ".final")
-               or die "Failed to open $compose_filename.final : " . $!;
-
-       open(C,"<",$compose_filename)
-               or die "Failed to open $compose_filename : " . $!;
-
-       while(<C>) {
-               next if m/^GIT: /;
-               print C2 $_;
-       }
-       close(C);
-       close(C2);
-
-       do {
-               $_ = $term->readline("Send this email? (y|n) ");
-       } while (!defined $_);
-
-       if (uc substr($_,0,1) ne 'Y') {
-               cleanup_compose_files();
-               exit(0);
-       }
-
-       @files = ($compose_filename . ".final");
-}
-
-
-# Now that all the defaults are set, process the rest of the command line
-# arguments and collect up the files that need to be processed.
-for my $f (@ARGV) {
-       if (-d $f) {
-               opendir(DH,$f)
-                       or die "Failed to opendir $f: $!";
-
-               push @files, grep { -f $_ } map { +$f . "/" . $_ }
-                               sort readdir(DH);
-
-       } elsif (-f $f) {
-               push @files, $f;
-
-       } else {
-               print STDERR "Skipping $f - not found.\n";
-       }
-}
-
-if (@files) {
-       print $_,"\n" for @files;
-} else {
-       print <<EOT;
-git-send-email-script [options] <file | directory> [... file | directory ]
-Options:
-   --from         Specify the "From:" line of the email to be sent.
-
-   --to           Specify the primary "To:" line of the email.
-
-   --compose      Use \$EDITOR to edit an introductory message for the
-                  patch series.
-
-   --subject      Specify the initial "Subject:" line.
-                  Only necessary if --compose is also set.  If --compose
-                 is not set, this will be prompted for.
-
-   --in-reply-to  Specify the first "In-Reply-To:" header line.
-                  Only used if --compose is also set.  If --compose is not
-                 set, this will be prompted for.
-
-   --chain-reply-to If set, the replies will all be to the previous
-                  email sent, rather than to the first email sent.
-                  Defaults to on.
-
-   --smtp-server  If set, specifies the outgoing SMTP server to use.
-                  Defaults to localhost.
-
-Error: Please specify a file or a directory on the command line.
-EOT
-       exit(1);
-}
-
-# Variables we set as part of the loop over files
-our ($message_id, $cc, %mail, $subject, $reply_to, $message);
-
-
-# Usually don't need to change anything below here.
-
-# we make a "fake" message id by taking the current number
-# of seconds since the beginning of Unix time and tacking on
-# a random number to the end, in case we are called quicker than
-# 1 second since the last time we were called.
-
-# We'll setup a template for the message id, using the "from" address:
-my $message_id_from = Email::Valid->address($from);
-my $message_id_template = "<%s-git-send-email-$message_id_from>";
-
-sub make_message_id
-{
-       my $date = `date "+\%s"`;
-       chomp($date);
-       my $pseudo_rand = int (rand(4200));
-       $message_id = sprintf $message_id_template, "$date$pseudo_rand";
-       #print "new message id = $message_id\n"; # Was useful for debugging
-}
-
-
-
-$cc = "";
-
-sub send_message
-{
-       my $to = join (", ", unique_email_list(@to));
-
-       %mail = (       To      =>      $to,
-                       From    =>      $from,
-                       CC      =>      $cc,
-                       Subject =>      $subject,
-                       Message =>      $message,
-                       'Reply-to'      =>      $from,
-                       'In-Reply-To'   =>      $reply_to,
-                       'Message-ID'    =>      $message_id,
-                       'X-Mailer'      =>      "git-send-email-script",
-               );
-
-       $mail{smtp} = $smtp_server;
-       $mailcfg{mime} = 0;
-
-       #print Data::Dumper->Dump([\%mail],[qw(*mail)]);
-
-       sendmail(%mail) or die $Mail::Sendmail::error;
-
-       print "OK. Log says:\n", $Mail::Sendmail::log;
-       print "\n\n"
-}
-
-
-$reply_to = $initial_reply_to;
-make_message_id();
-$subject = $initial_subject;
-
-foreach my $t (@files) {
-       my $F = $t;
-       open(F,"<",$t) or die "can't open file $t";
-
-       @cc = ();
-       my $found_mbox = 0;
-       my $header_done = 0;
-       $message = "";
-       while(<F>) {
-               if (!$header_done) {
-                       $found_mbox = 1, next if (/^From /);
-                       chomp;
-
-                       if ($found_mbox) {
-                               if (/^Subject:\s+(.*)$/) {
-                                       $subject = $1;
-
-                               } elsif (/^(Cc|From):\s+(.*)$/) {
-                                       printf("(mbox) Adding cc: %s from line '%s'\n",
-                                               $2, $_);
-                                       push @cc, $2;
-                               }
-
-                       } else {
-                               # In the traditional
-                               # "send lots of email" format,
-                               # line 1 = cc
-                               # line 2 = subject
-                               # So let's support that, too.
-                               if (@cc == 0) {
-                                       printf("(non-mbox) Adding cc: %s from line '%s'\n",
-                                               $_, $_);
-
-                                       push @cc, $_;
-
-                               } elsif (!defined $subject) {
-                                       $subject = $_;
-                               }
-                       }
-
-                       # A whitespace line will terminate the headers
-                       if (m/^\s*$/) {
-                               $header_done = 1;
-                       }
-               } else {
-                       $message .=  $_;
-                       if (/^Signed-off-by: (.*)$/i) {
-                               my $c = $1;
-                               chomp $c;
-                               push @cc, $c;
-                               printf("(sob) Adding cc: %s from line '%s'\n",
-                                       $c, $_);
-                       }
-               }
-       }
-       close F;
-
-       $cc = join(", ", unique_email_list(@cc));
-
-       send_message();
-
-       # set up for the next message
-       if ($chain_reply_to || length($reply_to) == 0) {
-               $reply_to = $message_id;
-       }
-       make_message_id();
-}
-
-if ($compose) {
-       cleanup_compose_files();
-}
-
-sub cleanup_compose_files() {
-       unlink($compose_filename, $compose_filename . ".final");
-
-}
-
-
-
-sub unique_email_list(@) {
-       my %seen;
-       my @emails;
-
-       foreach my $entry (@_) {
-               my $clean = Email::Valid->address($entry);
-               next if $seen{$clean}++;
-               push @emails, $entry;
-       }
-       return @emails;
-}
diff --git a/git-send-email.perl b/git-send-email.perl
new file mode 100755 (executable)
index 0000000..ec1428d
--- /dev/null
@@ -0,0 +1,368 @@
+#!/usr/bin/perl -w
+#
+# Copyright 2002,2005 Greg Kroah-Hartman <greg@kroah.com>
+# Copyright 2005 Ryan Anderson <ryan@michonline.com>
+#
+# GPL v2 (See COPYING)
+#
+# Ported to support git "mbox" format files by Ryan Anderson <ryan@michonline.com>
+#
+# Sends a collection of emails to the given email addresses, disturbingly fast.
+#
+# Supports two formats:
+# 1. mbox format files (ignoring most headers and MIME formatting - this is designed for sending patches)
+# 2. The original format support by Greg's script:
+#    first line of the message is who to CC,
+#    and second line is the subject of the message.
+#
+
+use strict;
+use warnings;
+use Term::ReadLine;
+use Mail::Sendmail qw(sendmail %mailcfg);
+use Getopt::Long;
+use Data::Dumper;
+use Email::Valid;
+
+sub unique_email_list(@);
+sub cleanup_compose_files();
+
+# Constants (essentially)
+my $compose_filename = ".msg.$$";
+
+# Variables we fill in automatically, or via prompting:
+my (@to,@cc,$initial_reply_to,$initial_subject,@files,$from,$compose);
+
+# Behavior modification variables
+my ($chain_reply_to, $smtp_server) = (1, "localhost");
+
+# Example reply to:
+#$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
+
+my $term = new Term::ReadLine 'git-send-email';
+
+# Begin by accumulating all the variables (defined above), that we will end up
+# needing, first, from the command line:
+
+my $rc = GetOptions("from=s" => \$from,
+                    "in-reply-to=s" => \$initial_reply_to,
+                   "subject=s" => \$initial_subject,
+                   "to=s" => \@to,
+                   "chain-reply-to!" => \$chain_reply_to,
+                   "smtp-server=s" => \$smtp_server,
+                   "compose" => \$compose,
+        );
+
+# Now, let's fill any that aren't set in with defaults:
+
+open(GITVAR,"-|","git-var","-l")
+       or die "Failed to open pipe from git-var: $!";
+
+my ($author,$committer);
+while(<GITVAR>) {
+       chomp;
+       my ($var,$data) = split /=/,$_,2;
+       my @fields = split /\s+/, $data;
+
+       my $ident = join(" ", @fields[0...(@fields-3)]);
+
+       if ($var eq 'GIT_AUTHOR_IDENT') {
+               $author = $ident;
+       } elsif ($var eq 'GIT_COMMITTER_IDENT') {
+               $committer = $ident;
+       }
+}
+close(GITVAR);
+
+my $prompting = 0;
+if (!defined $from) {
+       $from = $author || $committer;
+       do {
+               $_ = $term->readline("Who should the emails appear to be from? ",
+                       $from);
+       } while (!defined $_);
+
+       $from = $_;
+       print "Emails will be sent from: ", $from, "\n";
+       $prompting++;
+}
+
+if (!@to) {
+       do {
+               $_ = $term->readline("Who should the emails be sent to? ",
+                               "");
+       } while (!defined $_);
+       my $to = $_;
+       push @to, split /,/, $to;
+       $prompting++;
+}
+
+if (!defined $initial_subject && $compose) {
+       do {
+               $_ = $term->readline("What subject should the emails start with? ",
+                       $initial_subject);
+       } while (!defined $_);
+       $initial_subject = $_;
+       $prompting++;
+}
+
+if (!defined $initial_reply_to && $prompting) {
+       do {
+               $_= $term->readline("Message-ID to be used as In-Reply-To for the first email? ",
+                       $initial_reply_to);
+       } while (!defined $_);
+
+       $initial_reply_to = $_;
+       $initial_reply_to =~ s/(^\s+|\s+$)//g;
+}
+
+if (!defined $smtp_server) {
+       $smtp_server = "localhost";
+}
+
+if ($compose) {
+       # Note that this does not need to be secure, but we will make a small
+       # effort to have it be unique
+       open(C,">",$compose_filename)
+               or die "Failed to open for writing $compose_filename: $!";
+       print C "From \n";
+       printf C "Subject: %s\n\n", $initial_subject;
+       printf C <<EOT;
+GIT: Please enter your email below.
+GIT: Lines beginning in "GIT: " will be removed.
+GIT: Consider including an overall diffstat or table of contents
+GIT: for the patch you are writing.
+
+EOT
+       close(C);
+
+       my $editor = $ENV{EDITOR};
+       $editor = 'vi' unless defined $editor;
+       system($editor, $compose_filename);
+
+       open(C2,">",$compose_filename . ".final")
+               or die "Failed to open $compose_filename.final : " . $!;
+
+       open(C,"<",$compose_filename)
+               or die "Failed to open $compose_filename : " . $!;
+
+       while(<C>) {
+               next if m/^GIT: /;
+               print C2 $_;
+       }
+       close(C);
+       close(C2);
+
+       do {
+               $_ = $term->readline("Send this email? (y|n) ");
+       } while (!defined $_);
+
+       if (uc substr($_,0,1) ne 'Y') {
+               cleanup_compose_files();
+               exit(0);
+       }
+
+       @files = ($compose_filename . ".final");
+}
+
+
+# Now that all the defaults are set, process the rest of the command line
+# arguments and collect up the files that need to be processed.
+for my $f (@ARGV) {
+       if (-d $f) {
+               opendir(DH,$f)
+                       or die "Failed to opendir $f: $!";
+
+               push @files, grep { -f $_ } map { +$f . "/" . $_ }
+                               sort readdir(DH);
+
+       } elsif (-f $f) {
+               push @files, $f;
+
+       } else {
+               print STDERR "Skipping $f - not found.\n";
+       }
+}
+
+if (@files) {
+       print $_,"\n" for @files;
+} else {
+       print <<EOT;
+git-send-email [options] <file | directory> [... file | directory ]
+Options:
+   --from         Specify the "From:" line of the email to be sent.
+
+   --to           Specify the primary "To:" line of the email.
+
+   --compose      Use \$EDITOR to edit an introductory message for the
+                  patch series.
+
+   --subject      Specify the initial "Subject:" line.
+                  Only necessary if --compose is also set.  If --compose
+                 is not set, this will be prompted for.
+
+   --in-reply-to  Specify the first "In-Reply-To:" header line.
+                  Only used if --compose is also set.  If --compose is not
+                 set, this will be prompted for.
+
+   --chain-reply-to If set, the replies will all be to the previous
+                  email sent, rather than to the first email sent.
+                  Defaults to on.
+
+   --smtp-server  If set, specifies the outgoing SMTP server to use.
+                  Defaults to localhost.
+
+Error: Please specify a file or a directory on the command line.
+EOT
+       exit(1);
+}
+
+# Variables we set as part of the loop over files
+our ($message_id, $cc, %mail, $subject, $reply_to, $message);
+
+
+# Usually don't need to change anything below here.
+
+# we make a "fake" message id by taking the current number
+# of seconds since the beginning of Unix time and tacking on
+# a random number to the end, in case we are called quicker than
+# 1 second since the last time we were called.
+
+# We'll setup a template for the message id, using the "from" address:
+my $message_id_from = Email::Valid->address($from);
+my $message_id_template = "<%s-git-send-email-$message_id_from>";
+
+sub make_message_id
+{
+       my $date = `date "+\%s"`;
+       chomp($date);
+       my $pseudo_rand = int (rand(4200));
+       $message_id = sprintf $message_id_template, "$date$pseudo_rand";
+       #print "new message id = $message_id\n"; # Was useful for debugging
+}
+
+
+
+$cc = "";
+
+sub send_message
+{
+       my $to = join (", ", unique_email_list(@to));
+
+       %mail = (       To      =>      $to,
+                       From    =>      $from,
+                       CC      =>      $cc,
+                       Subject =>      $subject,
+                       Message =>      $message,
+                       'Reply-to'      =>      $from,
+                       'In-Reply-To'   =>      $reply_to,
+                       'Message-ID'    =>      $message_id,
+                       'X-Mailer'      =>      "git-send-email",
+               );
+
+       $mail{smtp} = $smtp_server;
+       $mailcfg{mime} = 0;
+
+       #print Data::Dumper->Dump([\%mail],[qw(*mail)]);
+
+       sendmail(%mail) or die $Mail::Sendmail::error;
+
+       print "OK. Log says:\n", $Mail::Sendmail::log;
+       print "\n\n"
+}
+
+
+$reply_to = $initial_reply_to;
+make_message_id();
+$subject = $initial_subject;
+
+foreach my $t (@files) {
+       my $F = $t;
+       open(F,"<",$t) or die "can't open file $t";
+
+       @cc = ();
+       my $found_mbox = 0;
+       my $header_done = 0;
+       $message = "";
+       while(<F>) {
+               if (!$header_done) {
+                       $found_mbox = 1, next if (/^From /);
+                       chomp;
+
+                       if ($found_mbox) {
+                               if (/^Subject:\s+(.*)$/) {
+                                       $subject = $1;
+
+                               } elsif (/^(Cc|From):\s+(.*)$/) {
+                                       printf("(mbox) Adding cc: %s from line '%s'\n",
+                                               $2, $_);
+                                       push @cc, $2;
+                               }
+
+                       } else {
+                               # In the traditional
+                               # "send lots of email" format,
+                               # line 1 = cc
+                               # line 2 = subject
+                               # So let's support that, too.
+                               if (@cc == 0) {
+                                       printf("(non-mbox) Adding cc: %s from line '%s'\n",
+                                               $_, $_);
+
+                                       push @cc, $_;
+
+                               } elsif (!defined $subject) {
+                                       $subject = $_;
+                               }
+                       }
+
+                       # A whitespace line will terminate the headers
+                       if (m/^\s*$/) {
+                               $header_done = 1;
+                       }
+               } else {
+                       $message .=  $_;
+                       if (/^Signed-off-by: (.*)$/i) {
+                               my $c = $1;
+                               chomp $c;
+                               push @cc, $c;
+                               printf("(sob) Adding cc: %s from line '%s'\n",
+                                       $c, $_);
+                       }
+               }
+       }
+       close F;
+
+       $cc = join(", ", unique_email_list(@cc));
+
+       send_message();
+
+       # set up for the next message
+       if ($chain_reply_to || length($reply_to) == 0) {
+               $reply_to = $message_id;
+       }
+       make_message_id();
+}
+
+if ($compose) {
+       cleanup_compose_files();
+}
+
+sub cleanup_compose_files() {
+       unlink($compose_filename, $compose_filename . ".final");
+
+}
+
+
+
+sub unique_email_list(@) {
+       my %seen;
+       my @emails;
+
+       foreach my $entry (@_) {
+               my $clean = Email::Valid->address($entry);
+               next if $seen{$clean}++;
+               push @emails, $entry;
+       }
+       return @emails;
+}
diff --git a/git-sh-setup-script b/git-sh-setup-script
deleted file mode 100755 (executable)
index 9ed5e85..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-#
-# Set up GIT_DIR and GIT_OBJECT_DIRECTORY
-# and return true if everything looks ok
-#
-: ${GIT_DIR=.git}
-: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
-
-die() {
-       echo "$@" >&2
-       exit 1
-}
-
-check_clean_tree() {
-    dirty1_=`git-update-cache -q --refresh` && {
-    dirty2_=`git-diff-cache --name-only --cached HEAD`
-    case "$dirty2_" in '') : ;; *) (exit 1) ;; esac
-    } || {
-       echo >&2 "$dirty1_"
-       echo "$dirty2_" | sed >&2 -e 's/^/modified: /'
-       (exit 1)
-    }
-}
-
-[ -h "$GIT_DIR/HEAD" ] &&
-[ -d "$GIT_DIR/refs" ] &&
-[ -d "$GIT_OBJECT_DIRECTORY/00" ]
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
new file mode 100755 (executable)
index 0000000..06d8299
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Set up GIT_DIR and GIT_OBJECT_DIRECTORY
+# and return true if everything looks ok
+#
+: ${GIT_DIR=.git}
+: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
+
+die() {
+       echo "$@" >&2
+       exit 1
+}
+
+check_clean_tree() {
+    dirty1_=`git-update-index -q --refresh` && {
+    dirty2_=`git-diff-index --name-only --cached HEAD`
+    case "$dirty2_" in '') : ;; *) (exit 1) ;; esac
+    } || {
+       echo >&2 "$dirty1_"
+       echo "$dirty2_" | sed >&2 -e 's/^/modified: /'
+       (exit 1)
+    }
+}
+
+[ -h "$GIT_DIR/HEAD" ] &&
+[ -d "$GIT_DIR/refs" ] &&
+[ -d "$GIT_OBJECT_DIRECTORY/00" ]
diff --git a/git-shortlog b/git-shortlog
deleted file mode 100755 (executable)
index 107c895..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-
-#
-# Even with git, we don't always have name translations.
-# So have an email->real name table to translate the
-# (hopefully few) missing names
-#
-my %mailmap = (
-       'R.Marek@sh.cvut.cz' => 'Rudolf Marek',
-       'Ralf.Wildenhues@gmx.de' => 'Ralf Wildenhues',
-       'aherrman@de.ibm.com' => 'Andreas Herrmann',
-       'akpm@osdl.org' => 'Andrew Morton',
-       'andrew.vasquez@qlogic.com' => 'Andrew Vasquez',
-       'aquynh@gmail.com' => 'Nguyen Anh Quynh',
-       'axboe@suse.de' => 'Jens Axboe',
-       'blaisorblade@yahoo.it' => 'Paolo \'Blaisorblade\' Giarrusso',
-       'bunk@stusta.de' => 'Adrian Bunk',
-       'domen@coderock.org' => 'Domen Puncer',
-       'dougg@torque.net' => 'Douglas Gilbert',
-       'dwmw2@shinybook.infradead.org' => 'David Woodhouse',
-       'ecashin@coraid.com' => 'Ed L Cashin',
-       'felix@derklecks.de' => 'Felix Moeller',
-       'fzago@systemfabricworks.com' => 'Frank Zago',
-       'gregkh@suse.de' => 'Greg Kroah-Hartman',
-       'hch@lst.de' => 'Christoph Hellwig',
-       'htejun@gmail.com' => 'Tejun Heo',
-       'jejb@mulgrave.(none)' => 'James Bottomley',
-       'jejb@titanic.il.steeleye.com' => 'James Bottomley',
-       'jgarzik@pretzel.yyz.us' => 'Jeff Garzik',
-       'johnpol@2ka.mipt.ru' => 'Evgeniy Polyakov',
-       'kay.sievers@vrfy.org' => 'Kay Sievers',
-       'minyard@acm.org' => 'Corey Minyard',
-       'mshah@teja.com' => 'Mitesh shah',
-       'pj@ludd.ltu.se' => 'Peter A Jonsson',
-       'rmps@joel.ist.utl.pt' => 'Rui Saraiva',
-       'santtu.hyrkko@gmail.com' => 'Santtu Hyrkkö',
-       'simon@thekelleys.org.uk' => 'Simon Kelley',
-       'ssant@in.ibm.com' => 'Sachin P Sant',
-       'terra@gnome.org' => 'Morten Welinder',
-       'tony.luck@intel.com' => 'Tony Luck',
-       'welinder@anemone.rentec.com' => 'Morten Welinder',
-       'welinder@darter.rentec.com' => 'Morten Welinder',
-       'welinder@troll.com' => 'Morten Welinder',
-);
-
-my (%map);
-my $pstate = 1;
-my $n_records = 0;
-my $n_output = 0;
-
-
-sub shortlog_entry($$) {
-       my ($name, $desc) = @_;
-       my $key = $name;
-
-       $desc =~ s#/pub/scm/linux/kernel/git/#/.../#g;
-       $desc =~ s#\[PATCH\] ##g;
-
-       # store description in array, in email->{desc list} map
-       if (exists $map{$key}) {
-               # grab ref
-               my $obj = $map{$key};
-
-               # add desc to array
-               push(@$obj, $desc);
-       } else {
-               # create new array, containing 1 item
-               my @arr = ($desc);
-
-               # store ref to array
-               $map{$key} = \@arr;
-       }
-}
-
-# sort comparison function
-sub by_name($$) {
-       my ($a, $b) = @_;
-
-       uc($a) cmp uc($b);
-}
-
-sub shortlog_output {
-       my ($obj, $key, $desc);
-
-       foreach $key (sort by_name keys %map) {
-               # output author
-               printf "%s:\n", $key;
-
-               # output author's 1-line summaries
-               $obj = $map{$key};
-               foreach $desc (reverse @$obj) {
-                       print "  $desc\n";
-                       $n_output++;
-               }
-
-               # blank line separating author from next author
-               print "\n";
-       }
-}
-
-sub changelog_input {
-       my ($author, $desc);
-
-       while (<>) {
-               # get author and email
-               if ($pstate == 1) {
-                       my ($email);
-
-                       next unless /^Author: (.*)<(.*)>.*$/;
-       
-                       $n_records++;
-       
-                       $author = $1;
-                       $email = $2;
-                       $desc = undef;
-
-                       # trim trailing whitespace.
-                       # why doesn't chomp work?
-                       while ($author && ($author =~ /\s$/)) {
-                               chop $author;
-                       }
-       
-                       # cset author fixups
-                       if (exists $mailmap{$email}) {
-                               $author = $mailmap{$email};
-                       } elsif (exists $mailmap{$author}) {
-                               $author = $mailmap{$author};
-                       } elsif ((!$author) || ($author eq "")) {
-                               $author = $email;
-                       }
-       
-                       $pstate++;
-               }
-       
-               # skip to blank line
-               elsif ($pstate == 2) {
-                       next unless /^\s*$/;
-                       $pstate++;
-               }
-       
-               # skip to non-blank line
-               elsif ($pstate == 3) {
-                       next unless /^\s*(\S.*)$/;
-
-                       # skip lines that are obviously not
-                       # a 1-line cset description
-                       next if /^\s*From: /;
-
-                       chomp;
-                       $desc = $1;
-       
-                       &shortlog_entry($author, $desc);
-       
-                       $pstate = 1;
-               }
-       
-               else {
-                       die "invalid parse state $pstate";
-               }
-       }
-}
-
-sub finalize {
-       #print "\n$n_records records parsed.\n";
-
-       if ($n_records != $n_output) {
-               die "parse error: input records != output records\n";
-       }
-}
-
-&changelog_input;
-&shortlog_output;
-&finalize;
-exit(0);
-
diff --git a/git-shortlog.perl b/git-shortlog.perl
new file mode 100755 (executable)
index 0000000..107c895
--- /dev/null
@@ -0,0 +1,177 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+#
+# Even with git, we don't always have name translations.
+# So have an email->real name table to translate the
+# (hopefully few) missing names
+#
+my %mailmap = (
+       'R.Marek@sh.cvut.cz' => 'Rudolf Marek',
+       'Ralf.Wildenhues@gmx.de' => 'Ralf Wildenhues',
+       'aherrman@de.ibm.com' => 'Andreas Herrmann',
+       'akpm@osdl.org' => 'Andrew Morton',
+       'andrew.vasquez@qlogic.com' => 'Andrew Vasquez',
+       'aquynh@gmail.com' => 'Nguyen Anh Quynh',
+       'axboe@suse.de' => 'Jens Axboe',
+       'blaisorblade@yahoo.it' => 'Paolo \'Blaisorblade\' Giarrusso',
+       'bunk@stusta.de' => 'Adrian Bunk',
+       'domen@coderock.org' => 'Domen Puncer',
+       'dougg@torque.net' => 'Douglas Gilbert',
+       'dwmw2@shinybook.infradead.org' => 'David Woodhouse',
+       'ecashin@coraid.com' => 'Ed L Cashin',
+       'felix@derklecks.de' => 'Felix Moeller',
+       'fzago@systemfabricworks.com' => 'Frank Zago',
+       'gregkh@suse.de' => 'Greg Kroah-Hartman',
+       'hch@lst.de' => 'Christoph Hellwig',
+       'htejun@gmail.com' => 'Tejun Heo',
+       'jejb@mulgrave.(none)' => 'James Bottomley',
+       'jejb@titanic.il.steeleye.com' => 'James Bottomley',
+       'jgarzik@pretzel.yyz.us' => 'Jeff Garzik',
+       'johnpol@2ka.mipt.ru' => 'Evgeniy Polyakov',
+       'kay.sievers@vrfy.org' => 'Kay Sievers',
+       'minyard@acm.org' => 'Corey Minyard',
+       'mshah@teja.com' => 'Mitesh shah',
+       'pj@ludd.ltu.se' => 'Peter A Jonsson',
+       'rmps@joel.ist.utl.pt' => 'Rui Saraiva',
+       'santtu.hyrkko@gmail.com' => 'Santtu Hyrkkö',
+       'simon@thekelleys.org.uk' => 'Simon Kelley',
+       'ssant@in.ibm.com' => 'Sachin P Sant',
+       'terra@gnome.org' => 'Morten Welinder',
+       'tony.luck@intel.com' => 'Tony Luck',
+       'welinder@anemone.rentec.com' => 'Morten Welinder',
+       'welinder@darter.rentec.com' => 'Morten Welinder',
+       'welinder@troll.com' => 'Morten Welinder',
+);
+
+my (%map);
+my $pstate = 1;
+my $n_records = 0;
+my $n_output = 0;
+
+
+sub shortlog_entry($$) {
+       my ($name, $desc) = @_;
+       my $key = $name;
+
+       $desc =~ s#/pub/scm/linux/kernel/git/#/.../#g;
+       $desc =~ s#\[PATCH\] ##g;
+
+       # store description in array, in email->{desc list} map
+       if (exists $map{$key}) {
+               # grab ref
+               my $obj = $map{$key};
+
+               # add desc to array
+               push(@$obj, $desc);
+       } else {
+               # create new array, containing 1 item
+               my @arr = ($desc);
+
+               # store ref to array
+               $map{$key} = \@arr;
+       }
+}
+
+# sort comparison function
+sub by_name($$) {
+       my ($a, $b) = @_;
+
+       uc($a) cmp uc($b);
+}
+
+sub shortlog_output {
+       my ($obj, $key, $desc);
+
+       foreach $key (sort by_name keys %map) {
+               # output author
+               printf "%s:\n", $key;
+
+               # output author's 1-line summaries
+               $obj = $map{$key};
+               foreach $desc (reverse @$obj) {
+                       print "  $desc\n";
+                       $n_output++;
+               }
+
+               # blank line separating author from next author
+               print "\n";
+       }
+}
+
+sub changelog_input {
+       my ($author, $desc);
+
+       while (<>) {
+               # get author and email
+               if ($pstate == 1) {
+                       my ($email);
+
+                       next unless /^Author: (.*)<(.*)>.*$/;
+       
+                       $n_records++;
+       
+                       $author = $1;
+                       $email = $2;
+                       $desc = undef;
+
+                       # trim trailing whitespace.
+                       # why doesn't chomp work?
+                       while ($author && ($author =~ /\s$/)) {
+                               chop $author;
+                       }
+       
+                       # cset author fixups
+                       if (exists $mailmap{$email}) {
+                               $author = $mailmap{$email};
+                       } elsif (exists $mailmap{$author}) {
+                               $author = $mailmap{$author};
+                       } elsif ((!$author) || ($author eq "")) {
+                               $author = $email;
+                       }
+       
+                       $pstate++;
+               }
+       
+               # skip to blank line
+               elsif ($pstate == 2) {
+                       next unless /^\s*$/;
+                       $pstate++;
+               }
+       
+               # skip to non-blank line
+               elsif ($pstate == 3) {
+                       next unless /^\s*(\S.*)$/;
+
+                       # skip lines that are obviously not
+                       # a 1-line cset description
+                       next if /^\s*From: /;
+
+                       chomp;
+                       $desc = $1;
+       
+                       &shortlog_entry($author, $desc);
+       
+                       $pstate = 1;
+               }
+       
+               else {
+                       die "invalid parse state $pstate";
+               }
+       }
+}
+
+sub finalize {
+       #print "\n$n_records records parsed.\n";
+
+       if ($n_records != $n_output) {
+               die "parse error: input records != output records\n";
+       }
+}
+
+&changelog_input;
+&shortlog_output;
+&finalize;
+exit(0);
+
diff --git a/git-status-script b/git-status-script
deleted file mode 100755 (executable)
index ee8f706..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Linus Torvalds
-#
-. git-sh-setup-script || die "Not a git archive"
-
-report () {
-  header="#
-# $1:
-#   ($2)
-#
-"
-  trailer=""
-  while read oldmode mode oldsha sha status name newname
-  do
-    echo -n "$header"
-    header=""
-    trailer="#
-"
-    case "$status" in
-    M ) echo "#        modified: $name";;
-    D*) echo "#        deleted:  $name";;
-    T ) echo "#        typechange: $name";;
-    C*) echo "#        copied: $name -> $newname";;
-    R*) echo "#        renamed: $name -> $newname";;
-    A*) echo "#        new file: $name";;
-    U ) echo "#        unmerged: $name";;
-    esac
-  done
-  echo -n "$trailer"
-  [ "$header" ]
-}
-
-branch=`readlink "$GIT_DIR/HEAD"`
-case "$branch" in
-refs/heads/master) ;;
-*)     echo "# On branch $branch" ;;
-esac
-
-git-update-cache --refresh >/dev/null 2>&1
-
-if test -f "$GIT_DIR/HEAD"
-then
-       git-diff-cache -M --cached HEAD |
-       sed 's/^://' |
-       report "Updated but not checked in" "will commit"
-
-       committable="$?"
-else
-       echo '#
-# Initial commit
-#'
-       git-ls-files |
-       sed 's/^/o o o o A /' |
-       report "Updated but not checked in" "will commit"
-
-       committable="$?"
-fi
-
-git-diff-files |
-sed 's/^://' |
-report "Changed but not updated" "use git-update-cache to mark for commit"
-
-if grep -v '^#' "$GIT_DIR/info/exclude" >/dev/null 2>&1
-then
-       git-ls-files --others \
-           --exclude-from="$GIT_DIR/info/exclude" \
-           --exclude-per-directory=.gitignore |
-       sed -e '
-       1i\
-#\
-# Ignored files:\
-#   (use "git add" to add to commit)\
-#
-       s/^/#   /
-       $a\
-#'
-fi
-
-case "$committable" in
-0)
-       echo "nothing to commit"
-       exit 1
-esac
-exit 0
diff --git a/git-status.sh b/git-status.sh
new file mode 100755 (executable)
index 0000000..621fa49
--- /dev/null
@@ -0,0 +1,85 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Linus Torvalds
+#
+. git-sh-setup || die "Not a git archive"
+
+report () {
+  header="#
+# $1:
+#   ($2)
+#
+"
+  trailer=""
+  while read oldmode mode oldsha sha status name newname
+  do
+    echo -n "$header"
+    header=""
+    trailer="#
+"
+    case "$status" in
+    M ) echo "#        modified: $name";;
+    D*) echo "#        deleted:  $name";;
+    T ) echo "#        typechange: $name";;
+    C*) echo "#        copied: $name -> $newname";;
+    R*) echo "#        renamed: $name -> $newname";;
+    A*) echo "#        new file: $name";;
+    U ) echo "#        unmerged: $name";;
+    esac
+  done
+  echo -n "$trailer"
+  [ "$header" ]
+}
+
+branch=`readlink "$GIT_DIR/HEAD"`
+case "$branch" in
+refs/heads/master) ;;
+*)     echo "# On branch $branch" ;;
+esac
+
+git-update-index --refresh >/dev/null 2>&1
+
+if test -f "$GIT_DIR/HEAD"
+then
+       git-diff-index -M --cached HEAD |
+       sed 's/^://' |
+       report "Updated but not checked in" "will commit"
+
+       committable="$?"
+else
+       echo '#
+# Initial commit
+#'
+       git-ls-files |
+       sed 's/^/o o o o A /' |
+       report "Updated but not checked in" "will commit"
+
+       committable="$?"
+fi
+
+git-diff-files |
+sed 's/^://' |
+report "Changed but not updated" "use git-update-index to mark for commit"
+
+if grep -v '^#' "$GIT_DIR/info/exclude" >/dev/null 2>&1
+then
+       git-ls-files --others \
+           --exclude-from="$GIT_DIR/info/exclude" \
+           --exclude-per-directory=.gitignore |
+       sed -e '
+       1i\
+#\
+# Ignored files:\
+#   (use "git add" to add to commit)\
+#
+       s/^/#   /
+       $a\
+#'
+fi
+
+case "$committable" in
+0)
+       echo "nothing to commit"
+       exit 1
+esac
+exit 0
diff --git a/git-tag-script b/git-tag-script
deleted file mode 100755 (executable)
index 39c3c53..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/sh
-# Copyright (c) 2005 Linus Torvalds
-
-. git-sh-setup-script || die "Not a git archive"
-
-usage () {
-    echo >&2 "Usage: git-tag-script [-a | -s] [-f] [-m "tag message"] tagname"
-    exit 1
-}
-
-annotate=
-signed=
-force=
-message=
-while case "$#" in 0) break ;; esac
-do
-    case "$1" in
-    -a)
-       annotate=1
-       ;;
-    -s)
-       annotate=1
-       signed=1
-       ;;
-    -f)
-       force=1
-       ;;
-    -m)
-       annotate=1
-       shift
-       message="$1"
-       ;;
-    -*)
-        usage
-       ;;
-    *)
-       break
-       ;;
-    esac
-    shift
-done
-
-name="$1"
-[ "$name" ] || usage
-if [ -e "$GIT_DIR/refs/tags/$name" -a -z "$force" ]; then
-    die "tag '$name' already exists"
-fi
-shift
-
-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
-
-trap 'rm -f .tmp-tag* .tagmsg .editmsg' 0
-
-if [ "$annotate" ]; then
-    if [ -z "$message" ]; then
-        ( echo "#"
-          echo "# Write a tag message"
-          echo "#" ) > .editmsg
-        ${VISUAL:-${EDITOR:-vi}} .editmsg || exit
-    else
-        echo "$message" > .editmsg
-    fi
-
-    grep -v '^#' < .editmsg | git-stripspace > .tagmsg
-
-    [ -s .tagmsg ] || exit
-
-    ( echo -e "object $object\ntype $type\ntag $name\ntagger $tagger\n"; cat .tagmsg ) > .tmp-tag
-    rm -f .tmp-tag.asc .tagmsg
-    if [ "$signed" ]; then
-       me=$(expr "$tagger" : '\(.*>\)') &&
-       gpg -bsa -u "$me" .tmp-tag &&
-       cat .tmp-tag.asc >>.tmp-tag ||
-       die "failed to sign the tag with GPG."
-    fi
-    object=$(git-mktag < .tmp-tag)
-fi
-
-mkdir -p "$GIT_DIR/refs/tags"
-echo $object > "$GIT_DIR/refs/tags/$name"
diff --git a/git-tag.sh b/git-tag.sh
new file mode 100755 (executable)
index 0000000..76c1bcd
--- /dev/null
@@ -0,0 +1,82 @@
+#!/bin/sh
+# Copyright (c) 2005 Linus Torvalds
+
+. git-sh-setup || die "Not a git archive"
+
+usage () {
+    echo >&2 "Usage: git-tag [-a | -s] [-f] [-m "tag message"] tagname"
+    exit 1
+}
+
+annotate=
+signed=
+force=
+message=
+while case "$#" in 0) break ;; esac
+do
+    case "$1" in
+    -a)
+       annotate=1
+       ;;
+    -s)
+       annotate=1
+       signed=1
+       ;;
+    -f)
+       force=1
+       ;;
+    -m)
+       annotate=1
+       shift
+       message="$1"
+       ;;
+    -*)
+        usage
+       ;;
+    *)
+       break
+       ;;
+    esac
+    shift
+done
+
+name="$1"
+[ "$name" ] || usage
+if [ -e "$GIT_DIR/refs/tags/$name" -a -z "$force" ]; then
+    die "tag '$name' already exists"
+fi
+shift
+
+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
+
+trap 'rm -f .tmp-tag* .tagmsg .editmsg' 0
+
+if [ "$annotate" ]; then
+    if [ -z "$message" ]; then
+        ( echo "#"
+          echo "# Write a tag message"
+          echo "#" ) > .editmsg
+        ${VISUAL:-${EDITOR:-vi}} .editmsg || exit
+    else
+        echo "$message" > .editmsg
+    fi
+
+    grep -v '^#' < .editmsg | git-stripspace > .tagmsg
+
+    [ -s .tagmsg ] || exit
+
+    ( echo -e "object $object\ntype $type\ntag $name\ntagger $tagger\n"; cat .tagmsg ) > .tmp-tag
+    rm -f .tmp-tag.asc .tagmsg
+    if [ "$signed" ]; then
+       me=$(expr "$tagger" : '\(.*>\)') &&
+       gpg -bsa -u "$me" .tmp-tag &&
+       cat .tmp-tag.asc >>.tmp-tag ||
+       die "failed to sign the tag with GPG."
+    fi
+    object=$(git-mktag < .tmp-tag)
+fi
+
+mkdir -p "$GIT_DIR/refs/tags"
+echo $object > "$GIT_DIR/refs/tags/$name"
diff --git a/git-verify-tag-script b/git-verify-tag-script
deleted file mode 100755 (executable)
index 6eb650b..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-. git-sh-setup-script || die "Not a git archive"
-
-tag=$(git-rev-parse $1) || exit 1
-
-git-cat-file tag $tag > .tmp-vtag || exit 1
-cat .tmp-vtag | sed '/-----BEGIN PGP/Q' | gpg --verify .tmp-vtag - || exit 1
-rm -f .tmp-vtag
diff --git a/git-verify-tag.sh b/git-verify-tag.sh
new file mode 100755 (executable)
index 0000000..156c75b
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+. git-sh-setup || die "Not a git archive"
+
+tag=$(git-rev-parse $1) || exit 1
+
+git-cat-file tag $tag > .tmp-vtag || exit 1
+cat .tmp-vtag | sed '/-----BEGIN PGP/Q' | gpg --verify .tmp-vtag - || exit 1
+rm -f .tmp-vtag
diff --git a/git-whatchanged b/git-whatchanged
deleted file mode 100755 (executable)
index 85a49fc..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-rev_list_args=$(git-rev-parse --sq --default HEAD --revs-only "$@") &&
-diff_tree_args=$(git-rev-parse --sq --no-revs "$@") &&
-
-eval "git-rev-list $rev_list_args" |
-eval "git-diff-tree --stdin --pretty -r $diff_tree_args" |
-LESS="$LESS -S" ${PAGER:-less}
diff --git a/git-whatchanged.sh b/git-whatchanged.sh
new file mode 100755 (executable)
index 0000000..85a49fc
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+rev_list_args=$(git-rev-parse --sq --default HEAD --revs-only "$@") &&
+diff_tree_args=$(git-rev-parse --sq --no-revs "$@") &&
+
+eval "git-rev-list $rev_list_args" |
+eval "git-diff-tree --stdin --pretty -r $diff_tree_args" |
+LESS="$LESS -S" ${PAGER:-less}
diff --git a/git.sh b/git.sh
new file mode 100755 (executable)
index 0000000..f967650
--- /dev/null
+++ b/git.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+cmd=
+path=$(dirname $0)
+case "$#" in
+0)     ;;
+*)     cmd="$1"
+       shift
+       test -x $path/git-$cmd && exec $path/git-$cmd "$@" ;;
+esac
+
+echo "Usage: git COMMAND [OPTIONS] [TARGET]"
+if [ -n "$cmd" ]; then
+    echo " git command '$cmd' not found: commands are:"
+else
+    echo " git commands are:"
+fi
+
+cat <<\EOF
+    add apply archimport bisect branch checkout cherry clone
+    commit count-objects cvsimport diff fetch format-patch
+    fsck-cache get-tar-commit-id init-db log ls-remote octopus
+    pack-objects parse-remote patch-id prune pull push rebase
+    relink rename repack request-pull reset resolve revert
+    send-email shortlog show-branch status tag verify-tag
+    whatchanged
+EOF
diff --git a/http-fetch.c b/http-fetch.c
new file mode 100644 (file)
index 0000000..df99ba7
--- /dev/null
@@ -0,0 +1,371 @@
+#include "cache.h"
+#include "commit.h"
+
+#include "fetch.h"
+
+#include <curl/curl.h>
+#include <curl/easy.h>
+
+#if LIBCURL_VERSION_NUM < 0x070704
+#define curl_global_cleanup() do { /* nothing */ } while(0)
+#endif
+#if LIBCURL_VERSION_NUM < 0x070800
+#define curl_global_init(a) do { /* nothing */ } while(0)
+#endif
+
+static CURL *curl;
+
+static char *base;
+
+static SHA_CTX c;
+static z_stream stream;
+
+static int local;
+static int zret;
+
+static int curl_ssl_verify;
+
+struct buffer
+{
+        size_t posn;
+        size_t size;
+        void *buffer;
+};
+
+static size_t fwrite_buffer(void *ptr, size_t eltsize, size_t nmemb,
+                            struct buffer *buffer)
+{
+        size_t size = eltsize * nmemb;
+        if (size > buffer->size - buffer->posn)
+                size = buffer->size - buffer->posn;
+        memcpy(buffer->buffer + buffer->posn, ptr, size);
+        buffer->posn += size;
+        return size;
+}
+
+static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,
+                              void *data)
+{
+       unsigned char expn[4096];
+       size_t size = eltsize * nmemb;
+       int posn = 0;
+       do {
+               ssize_t retval = write(local, ptr + posn, size - posn);
+               if (retval < 0)
+                       return posn;
+               posn += retval;
+       } while (posn < size);
+
+       stream.avail_in = size;
+       stream.next_in = ptr;
+       do {
+               stream.next_out = expn;
+               stream.avail_out = sizeof(expn);
+               zret = inflate(&stream, Z_SYNC_FLUSH);
+               SHA1_Update(&c, expn, sizeof(expn) - stream.avail_out);
+       } while (stream.avail_in && zret == Z_OK);
+       return size;
+}
+
+void prefetch(unsigned char *sha1)
+{
+}
+
+static int got_indices = 0;
+
+static struct packed_git *packs = NULL;
+
+static int fetch_index(unsigned char *sha1)
+{
+       char *filename;
+       char *url;
+
+       FILE *indexfile;
+
+       if (has_pack_index(sha1))
+               return 0;
+
+       if (get_verbosely)
+               fprintf(stderr, "Getting index for pack %s\n",
+                       sha1_to_hex(sha1));
+       
+       url = xmalloc(strlen(base) + 64);
+       sprintf(url, "%s/objects/pack/pack-%s.idx",
+               base, sha1_to_hex(sha1));
+       
+       filename = sha1_pack_index_name(sha1);
+       indexfile = fopen(filename, "w");
+       if (!indexfile)
+               return error("Unable to open local file %s for pack index",
+                            filename);
+
+       curl_easy_setopt(curl, CURLOPT_FILE, indexfile);
+       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
+       curl_easy_setopt(curl, CURLOPT_URL, url);
+       
+       if (curl_easy_perform(curl)) {
+               fclose(indexfile);
+               return error("Unable to get pack index %s", url);
+       }
+
+       fclose(indexfile);
+       return 0;
+}
+
+static int setup_index(unsigned char *sha1)
+{
+       struct packed_git *new_pack;
+       if (has_pack_file(sha1))
+               return 0; // don't list this as something we can get
+
+       if (fetch_index(sha1))
+               return -1;
+
+       new_pack = parse_pack_index(sha1);
+       new_pack->next = packs;
+       packs = new_pack;
+       return 0;
+}
+
+static int fetch_indices(void)
+{
+       unsigned char sha1[20];
+       char *url;
+       struct buffer buffer;
+       char *data;
+       int i = 0;
+
+       if (got_indices)
+               return 0;
+
+       data = xmalloc(4096);
+       buffer.size = 4096;
+       buffer.posn = 0;
+       buffer.buffer = data;
+
+       if (get_verbosely)
+               fprintf(stderr, "Getting pack list\n");
+       
+       url = xmalloc(strlen(base) + 21);
+       sprintf(url, "%s/objects/info/packs", base);
+
+       curl_easy_setopt(curl, CURLOPT_FILE, &buffer);
+       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
+       curl_easy_setopt(curl, CURLOPT_URL, url);
+       
+       if (curl_easy_perform(curl)) {
+               return error("Unable to get pack index %s", url);
+       }
+
+       do {
+               switch (data[i]) {
+               case 'P':
+                       i++;
+                       if (i + 52 < buffer.posn &&
+                           !strncmp(data + i, " pack-", 6) &&
+                           !strncmp(data + i + 46, ".pack\n", 6)) {
+                               get_sha1_hex(data + i + 6, sha1);
+                               setup_index(sha1);
+                               i += 51;
+                               break;
+                       }
+               default:
+                       while (data[i] != '\n')
+                               i++;
+               }
+               i++;
+       } while (i < buffer.posn);
+
+       got_indices = 1;
+       return 0;
+}
+
+static int fetch_pack(unsigned char *sha1)
+{
+       char *url;
+       struct packed_git *target;
+       struct packed_git **lst;
+       FILE *packfile;
+       char *filename;
+
+       if (fetch_indices())
+               return -1;
+       target = find_sha1_pack(sha1, packs);
+       if (!target)
+               return error("Couldn't get %s: not separate or in any pack",
+                            sha1_to_hex(sha1));
+
+       if (get_verbosely) {
+               fprintf(stderr, "Getting pack %s\n",
+                       sha1_to_hex(target->sha1));
+               fprintf(stderr, " which contains %s\n",
+                       sha1_to_hex(sha1));
+       }
+
+       url = xmalloc(strlen(base) + 65);
+       sprintf(url, "%s/objects/pack/pack-%s.pack",
+               base, sha1_to_hex(target->sha1));
+
+       filename = sha1_pack_name(target->sha1);
+       packfile = fopen(filename, "w");
+       if (!packfile)
+               return error("Unable to open local file %s for pack",
+                            filename);
+
+       curl_easy_setopt(curl, CURLOPT_FILE, packfile);
+       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
+       curl_easy_setopt(curl, CURLOPT_URL, url);
+       
+       if (curl_easy_perform(curl)) {
+               fclose(packfile);
+               return error("Unable to get pack file %s", url);
+       }
+
+       fclose(packfile);
+
+       lst = &packs;
+       while (*lst != target)
+               lst = &((*lst)->next);
+       *lst = (*lst)->next;
+
+       install_packed_git(target);
+
+       return 0;
+}
+
+int fetch(unsigned char *sha1)
+{
+       char *hex = sha1_to_hex(sha1);
+       char *filename = sha1_file_name(sha1);
+       unsigned char real_sha1[20];
+       char *url;
+       char *posn;
+
+       local = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
+
+       if (local < 0)
+               return error("Couldn't open local object %s\n", filename);
+
+       memset(&stream, 0, sizeof(stream));
+
+       inflateInit(&stream);
+
+       SHA1_Init(&c);
+
+       curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
+       curl_easy_setopt(curl, CURLOPT_FILE, NULL);
+       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);
+
+       url = xmalloc(strlen(base) + 50);
+       strcpy(url, base);
+       posn = url + strlen(base);
+       strcpy(posn, "objects/");
+       posn += 8;
+       memcpy(posn, hex, 2);
+       posn += 2;
+       *(posn++) = '/';
+       strcpy(posn, hex + 2);
+
+       curl_easy_setopt(curl, CURLOPT_URL, url);
+
+       if (curl_easy_perform(curl)) {
+               unlink(filename);
+               if (fetch_pack(sha1))
+                       return error("Tried %s", url);
+               return 0;
+       }
+
+       close(local);
+       inflateEnd(&stream);
+       SHA1_Final(real_sha1, &c);
+       if (zret != Z_STREAM_END) {
+               unlink(filename);
+               return error("File %s (%s) corrupt\n", hex, url);
+       }
+       if (memcmp(sha1, real_sha1, 20)) {
+               unlink(filename);
+               return error("File %s has bad hash\n", hex);
+       }
+       
+       pull_say("got %s\n", hex);
+       return 0;
+}
+
+int fetch_ref(char *ref, unsigned char *sha1)
+{
+        char *url, *posn;
+        char hex[42];
+        struct buffer buffer;
+        buffer.size = 41;
+        buffer.posn = 0;
+        buffer.buffer = hex;
+        hex[41] = '\0';
+        
+        curl_easy_setopt(curl, CURLOPT_FILE, &buffer);
+        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
+
+        url = xmalloc(strlen(base) + 6 + strlen(ref));
+        strcpy(url, base);
+        posn = url + strlen(base);
+        strcpy(posn, "refs/");
+        posn += 5;
+        strcpy(posn, ref);
+
+        curl_easy_setopt(curl, CURLOPT_URL, url);
+
+        if (curl_easy_perform(curl))
+                return error("Couldn't get %s for %s\n", url, ref);
+
+        hex[40] = '\0';
+        get_sha1_hex(hex, sha1);
+        return 0;
+}
+
+int main(int argc, char **argv)
+{
+       char *commit_id;
+       char *url;
+       int arg = 1;
+
+       while (arg < argc && argv[arg][0] == '-') {
+               if (argv[arg][1] == 't') {
+                       get_tree = 1;
+               } else if (argv[arg][1] == 'c') {
+                       get_history = 1;
+               } else if (argv[arg][1] == 'a') {
+                       get_all = 1;
+                       get_tree = 1;
+                       get_history = 1;
+               } else if (argv[arg][1] == 'v') {
+                       get_verbosely = 1;
+               } else if (argv[arg][1] == 'w') {
+                       write_ref = argv[arg + 1];
+                       arg++;
+               }
+               arg++;
+       }
+       if (argc < arg + 2) {
+               usage("git-http-fetch [-c] [-t] [-a] [-d] [-v] [--recover] [-w ref] commit-id url");
+               return 1;
+       }
+       commit_id = argv[arg];
+       url = argv[arg + 1];
+
+       curl_global_init(CURL_GLOBAL_ALL);
+
+       curl = curl_easy_init();
+
+       curl_ssl_verify = gitenv("GIT_SSL_NO_VERIFY") ? 0 : 1;
+       curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, curl_ssl_verify);
+#if LIBCURL_VERSION_NUM >= 0x070907
+       curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
+#endif
+
+       base = url;
+
+       if (pull(commit_id))
+               return 1;
+
+       curl_global_cleanup();
+       return 0;
+}
diff --git a/http-pull.c b/http-pull.c
deleted file mode 100644 (file)
index e70ab39..0000000
+++ /dev/null
@@ -1,371 +0,0 @@
-#include "cache.h"
-#include "commit.h"
-
-#include "pull.h"
-
-#include <curl/curl.h>
-#include <curl/easy.h>
-
-#if LIBCURL_VERSION_NUM < 0x070704
-#define curl_global_cleanup() do { /* nothing */ } while(0)
-#endif
-#if LIBCURL_VERSION_NUM < 0x070800
-#define curl_global_init(a) do { /* nothing */ } while(0)
-#endif
-
-static CURL *curl;
-
-static char *base;
-
-static SHA_CTX c;
-static z_stream stream;
-
-static int local;
-static int zret;
-
-static int curl_ssl_verify;
-
-struct buffer
-{
-        size_t posn;
-        size_t size;
-        void *buffer;
-};
-
-static size_t fwrite_buffer(void *ptr, size_t eltsize, size_t nmemb,
-                            struct buffer *buffer)
-{
-        size_t size = eltsize * nmemb;
-        if (size > buffer->size - buffer->posn)
-                size = buffer->size - buffer->posn;
-        memcpy(buffer->buffer + buffer->posn, ptr, size);
-        buffer->posn += size;
-        return size;
-}
-
-static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,
-                              void *data)
-{
-       unsigned char expn[4096];
-       size_t size = eltsize * nmemb;
-       int posn = 0;
-       do {
-               ssize_t retval = write(local, ptr + posn, size - posn);
-               if (retval < 0)
-                       return posn;
-               posn += retval;
-       } while (posn < size);
-
-       stream.avail_in = size;
-       stream.next_in = ptr;
-       do {
-               stream.next_out = expn;
-               stream.avail_out = sizeof(expn);
-               zret = inflate(&stream, Z_SYNC_FLUSH);
-               SHA1_Update(&c, expn, sizeof(expn) - stream.avail_out);
-       } while (stream.avail_in && zret == Z_OK);
-       return size;
-}
-
-void prefetch(unsigned char *sha1)
-{
-}
-
-static int got_indices = 0;
-
-static struct packed_git *packs = NULL;
-
-static int fetch_index(unsigned char *sha1)
-{
-       char *filename;
-       char *url;
-
-       FILE *indexfile;
-
-       if (has_pack_index(sha1))
-               return 0;
-
-       if (get_verbosely)
-               fprintf(stderr, "Getting index for pack %s\n",
-                       sha1_to_hex(sha1));
-       
-       url = xmalloc(strlen(base) + 64);
-       sprintf(url, "%s/objects/pack/pack-%s.idx",
-               base, sha1_to_hex(sha1));
-       
-       filename = sha1_pack_index_name(sha1);
-       indexfile = fopen(filename, "w");
-       if (!indexfile)
-               return error("Unable to open local file %s for pack index",
-                            filename);
-
-       curl_easy_setopt(curl, CURLOPT_FILE, indexfile);
-       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
-       curl_easy_setopt(curl, CURLOPT_URL, url);
-       
-       if (curl_easy_perform(curl)) {
-               fclose(indexfile);
-               return error("Unable to get pack index %s", url);
-       }
-
-       fclose(indexfile);
-       return 0;
-}
-
-static int setup_index(unsigned char *sha1)
-{
-       struct packed_git *new_pack;
-       if (has_pack_file(sha1))
-               return 0; // don't list this as something we can get
-
-       if (fetch_index(sha1))
-               return -1;
-
-       new_pack = parse_pack_index(sha1);
-       new_pack->next = packs;
-       packs = new_pack;
-       return 0;
-}
-
-static int fetch_indices(void)
-{
-       unsigned char sha1[20];
-       char *url;
-       struct buffer buffer;
-       char *data;
-       int i = 0;
-
-       if (got_indices)
-               return 0;
-
-       data = xmalloc(4096);
-       buffer.size = 4096;
-       buffer.posn = 0;
-       buffer.buffer = data;
-
-       if (get_verbosely)
-               fprintf(stderr, "Getting pack list\n");
-       
-       url = xmalloc(strlen(base) + 21);
-       sprintf(url, "%s/objects/info/packs", base);
-
-       curl_easy_setopt(curl, CURLOPT_FILE, &buffer);
-       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
-       curl_easy_setopt(curl, CURLOPT_URL, url);
-       
-       if (curl_easy_perform(curl)) {
-               return error("Unable to get pack index %s", url);
-       }
-
-       do {
-               switch (data[i]) {
-               case 'P':
-                       i++;
-                       if (i + 52 < buffer.posn &&
-                           !strncmp(data + i, " pack-", 6) &&
-                           !strncmp(data + i + 46, ".pack\n", 6)) {
-                               get_sha1_hex(data + i + 6, sha1);
-                               setup_index(sha1);
-                               i += 51;
-                               break;
-                       }
-               default:
-                       while (data[i] != '\n')
-                               i++;
-               }
-               i++;
-       } while (i < buffer.posn);
-
-       got_indices = 1;
-       return 0;
-}
-
-static int fetch_pack(unsigned char *sha1)
-{
-       char *url;
-       struct packed_git *target;
-       struct packed_git **lst;
-       FILE *packfile;
-       char *filename;
-
-       if (fetch_indices())
-               return -1;
-       target = find_sha1_pack(sha1, packs);
-       if (!target)
-               return error("Couldn't get %s: not separate or in any pack",
-                            sha1_to_hex(sha1));
-
-       if (get_verbosely) {
-               fprintf(stderr, "Getting pack %s\n",
-                       sha1_to_hex(target->sha1));
-               fprintf(stderr, " which contains %s\n",
-                       sha1_to_hex(sha1));
-       }
-
-       url = xmalloc(strlen(base) + 65);
-       sprintf(url, "%s/objects/pack/pack-%s.pack",
-               base, sha1_to_hex(target->sha1));
-
-       filename = sha1_pack_name(target->sha1);
-       packfile = fopen(filename, "w");
-       if (!packfile)
-               return error("Unable to open local file %s for pack",
-                            filename);
-
-       curl_easy_setopt(curl, CURLOPT_FILE, packfile);
-       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
-       curl_easy_setopt(curl, CURLOPT_URL, url);
-       
-       if (curl_easy_perform(curl)) {
-               fclose(packfile);
-               return error("Unable to get pack file %s", url);
-       }
-
-       fclose(packfile);
-
-       lst = &packs;
-       while (*lst != target)
-               lst = &((*lst)->next);
-       *lst = (*lst)->next;
-
-       install_packed_git(target);
-
-       return 0;
-}
-
-int fetch(unsigned char *sha1)
-{
-       char *hex = sha1_to_hex(sha1);
-       char *filename = sha1_file_name(sha1);
-       unsigned char real_sha1[20];
-       char *url;
-       char *posn;
-
-       local = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
-
-       if (local < 0)
-               return error("Couldn't open local object %s\n", filename);
-
-       memset(&stream, 0, sizeof(stream));
-
-       inflateInit(&stream);
-
-       SHA1_Init(&c);
-
-       curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
-       curl_easy_setopt(curl, CURLOPT_FILE, NULL);
-       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);
-
-       url = xmalloc(strlen(base) + 50);
-       strcpy(url, base);
-       posn = url + strlen(base);
-       strcpy(posn, "objects/");
-       posn += 8;
-       memcpy(posn, hex, 2);
-       posn += 2;
-       *(posn++) = '/';
-       strcpy(posn, hex + 2);
-
-       curl_easy_setopt(curl, CURLOPT_URL, url);
-
-       if (curl_easy_perform(curl)) {
-               unlink(filename);
-               if (fetch_pack(sha1))
-                       return error("Tried %s", url);
-               return 0;
-       }
-
-       close(local);
-       inflateEnd(&stream);
-       SHA1_Final(real_sha1, &c);
-       if (zret != Z_STREAM_END) {
-               unlink(filename);
-               return error("File %s (%s) corrupt\n", hex, url);
-       }
-       if (memcmp(sha1, real_sha1, 20)) {
-               unlink(filename);
-               return error("File %s has bad hash\n", hex);
-       }
-       
-       pull_say("got %s\n", hex);
-       return 0;
-}
-
-int fetch_ref(char *ref, unsigned char *sha1)
-{
-        char *url, *posn;
-        char hex[42];
-        struct buffer buffer;
-        buffer.size = 41;
-        buffer.posn = 0;
-        buffer.buffer = hex;
-        hex[41] = '\0';
-        
-        curl_easy_setopt(curl, CURLOPT_FILE, &buffer);
-        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
-
-        url = xmalloc(strlen(base) + 6 + strlen(ref));
-        strcpy(url, base);
-        posn = url + strlen(base);
-        strcpy(posn, "refs/");
-        posn += 5;
-        strcpy(posn, ref);
-
-        curl_easy_setopt(curl, CURLOPT_URL, url);
-
-        if (curl_easy_perform(curl))
-                return error("Couldn't get %s for %s\n", url, ref);
-
-        hex[40] = '\0';
-        get_sha1_hex(hex, sha1);
-        return 0;
-}
-
-int main(int argc, char **argv)
-{
-       char *commit_id;
-       char *url;
-       int arg = 1;
-
-       while (arg < argc && argv[arg][0] == '-') {
-               if (argv[arg][1] == 't') {
-                       get_tree = 1;
-               } else if (argv[arg][1] == 'c') {
-                       get_history = 1;
-               } else if (argv[arg][1] == 'a') {
-                       get_all = 1;
-                       get_tree = 1;
-                       get_history = 1;
-               } else if (argv[arg][1] == 'v') {
-                       get_verbosely = 1;
-               } else if (argv[arg][1] == 'w') {
-                       write_ref = argv[arg + 1];
-                       arg++;
-               }
-               arg++;
-       }
-       if (argc < arg + 2) {
-               usage("git-http-pull [-c] [-t] [-a] [-d] [-v] [--recover] [-w ref] commit-id url");
-               return 1;
-       }
-       commit_id = argv[arg];
-       url = argv[arg + 1];
-
-       curl_global_init(CURL_GLOBAL_ALL);
-
-       curl = curl_easy_init();
-
-       curl_ssl_verify = gitenv("GIT_SSL_NO_VERIFY") ? 0 : 1;
-       curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, curl_ssl_verify);
-#if LIBCURL_VERSION_NUM >= 0x070907
-       curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
-#endif
-
-       base = url;
-
-       if (pull(commit_id))
-               return 1;
-
-       curl_global_cleanup();
-       return 0;
-}
diff --git a/local-fetch.c b/local-fetch.c
new file mode 100644 (file)
index 0000000..8176532
--- /dev/null
@@ -0,0 +1,227 @@
+/*
+ * Copyright (C) 2005 Junio C Hamano
+ */
+#include "cache.h"
+#include "commit.h"
+#include "fetch.h"
+
+static int use_link = 0;
+static int use_symlink = 0;
+static int use_filecopy = 1;
+
+static char *path; /* "Remote" git repository */
+
+void prefetch(unsigned char *sha1)
+{
+}
+
+static struct packed_git *packs = NULL;
+
+static void setup_index(unsigned char *sha1)
+{
+       struct packed_git *new_pack;
+       char filename[PATH_MAX];
+       strcpy(filename, path);
+       strcat(filename, "/objects/pack/pack-");
+       strcat(filename, sha1_to_hex(sha1));
+       strcat(filename, ".idx");
+       new_pack = parse_pack_index_file(sha1, filename);
+       new_pack->next = packs;
+       packs = new_pack;
+}
+
+static int setup_indices(void)
+{
+       DIR *dir;
+       struct dirent *de;
+       char filename[PATH_MAX];
+       unsigned char sha1[20];
+       sprintf(filename, "%s/objects/pack/", path);
+       dir = opendir(filename);
+       while ((de = readdir(dir)) != NULL) {
+               int namelen = strlen(de->d_name);
+               if (namelen != 50 || 
+                   strcmp(de->d_name + namelen - 5, ".pack"))
+                       continue;
+               get_sha1_hex(de->d_name + 5, sha1);
+               setup_index(sha1);
+       }
+       return 0;
+}
+
+static int copy_file(const char *source, const char *dest, const char *hex)
+{
+       if (use_link) {
+               if (!link(source, dest)) {
+                       pull_say("link %s\n", hex);
+                       return 0;
+               }
+               /* If we got ENOENT there is no point continuing. */
+               if (errno == ENOENT) {
+                       fprintf(stderr, "does not exist %s\n", source);
+                       return -1;
+               }
+       }
+       if (use_symlink && !symlink(source, dest)) {
+               pull_say("symlink %s\n", hex);
+               return 0;
+       }
+       if (use_filecopy) {
+               int ifd, ofd, status;
+               struct stat st;
+               void *map;
+               ifd = open(source, O_RDONLY);
+               if (ifd < 0 || fstat(ifd, &st) < 0) {
+                       close(ifd);
+                       fprintf(stderr, "cannot open %s\n", source);
+                       return -1;
+               }
+               map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, ifd, 0);
+               close(ifd);
+               if (map == MAP_FAILED) {
+                       fprintf(stderr, "cannot mmap %s\n", source);
+                       return -1;
+               }
+               ofd = open(dest, O_WRONLY | O_CREAT | O_EXCL, 0666);
+               status = ((ofd < 0) ||
+                         (write(ofd, map, st.st_size) != st.st_size));
+               munmap(map, st.st_size);
+               close(ofd);
+               if (status)
+                       fprintf(stderr, "cannot write %s\n", dest);
+               else
+                       pull_say("copy %s\n", hex);
+               return status;
+       }
+       fprintf(stderr, "failed to copy %s with given copy methods.\n", hex);
+       return -1;
+}
+
+static int fetch_pack(const unsigned char *sha1)
+{
+       struct packed_git *target;
+       char filename[PATH_MAX];
+       if (setup_indices())
+               return -1;
+       target = find_sha1_pack(sha1, packs);
+       if (!target)
+               return error("Couldn't find %s: not separate or in any pack", 
+                            sha1_to_hex(sha1));
+       if (get_verbosely) {
+               fprintf(stderr, "Getting pack %s\n",
+                       sha1_to_hex(target->sha1));
+               fprintf(stderr, " which contains %s\n",
+                       sha1_to_hex(sha1));
+       }
+       sprintf(filename, "%s/objects/pack/pack-%s.pack", 
+               path, sha1_to_hex(target->sha1));
+       copy_file(filename, sha1_pack_name(target->sha1),
+                 sha1_to_hex(target->sha1));
+       sprintf(filename, "%s/objects/pack/pack-%s.idx", 
+               path, sha1_to_hex(target->sha1));
+       copy_file(filename, sha1_pack_index_name(target->sha1),
+                 sha1_to_hex(target->sha1));
+       install_packed_git(target);
+       return 0;
+}
+
+static int fetch_file(const unsigned char *sha1)
+{
+       static int object_name_start = -1;
+       static char filename[PATH_MAX];
+       char *hex = sha1_to_hex(sha1);
+       const char *dest_filename = sha1_file_name(sha1);
+
+       if (object_name_start < 0) {
+               strcpy(filename, path); /* e.g. git.git */
+               strcat(filename, "/objects/");
+               object_name_start = strlen(filename);
+       }
+       filename[object_name_start+0] = hex[0];
+       filename[object_name_start+1] = hex[1];
+       filename[object_name_start+2] = '/';
+       strcpy(filename + object_name_start + 3, hex + 2);
+       return copy_file(filename, dest_filename, hex);
+}
+
+int fetch(unsigned char *sha1)
+{
+       return fetch_file(sha1) && fetch_pack(sha1);
+}
+
+int fetch_ref(char *ref, unsigned char *sha1)
+{
+       static int ref_name_start = -1;
+       static char filename[PATH_MAX];
+       static char hex[41];
+       int ifd;
+
+       if (ref_name_start < 0) {
+               sprintf(filename, "%s/refs/", path);
+               ref_name_start = strlen(filename);
+       }
+       strcpy(filename + ref_name_start, ref);
+       ifd = open(filename, O_RDONLY);
+       if (ifd < 0) {
+               close(ifd);
+               fprintf(stderr, "cannot open %s\n", filename);
+               return -1;
+       }
+       if (read(ifd, hex, 40) != 40 || get_sha1_hex(hex, sha1)) {
+               close(ifd);
+               fprintf(stderr, "cannot read from %s\n", filename);
+               return -1;
+       }
+       close(ifd);
+       pull_say("ref %s\n", sha1_to_hex(sha1));
+       return 0;
+}
+
+static const char local_pull_usage[] =
+"git-local-fetch [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] [-l] [-s] [-n] commit-id path";
+
+/* 
+ * By default we only use file copy.
+ * If -l is specified, a hard link is attempted.
+ * If -s is specified, then a symlink is attempted.
+ * If -n is _not_ specified, then a regular file-to-file copy is done.
+ */
+int main(int argc, char **argv)
+{
+       char *commit_id;
+       int arg = 1;
+
+       while (arg < argc && argv[arg][0] == '-') {
+               if (argv[arg][1] == 't')
+                       get_tree = 1;
+               else if (argv[arg][1] == 'c')
+                       get_history = 1;
+               else if (argv[arg][1] == 'a') {
+                       get_all = 1;
+                       get_tree = 1;
+                       get_history = 1;
+               }
+               else if (argv[arg][1] == 'l')
+                       use_link = 1;
+               else if (argv[arg][1] == 's')
+                       use_symlink = 1;
+               else if (argv[arg][1] == 'n')
+                       use_filecopy = 0;
+               else if (argv[arg][1] == 'v')
+                       get_verbosely = 1;
+               else if (argv[arg][1] == 'w')
+                       write_ref = argv[++arg];
+               else
+                       usage(local_pull_usage);
+               arg++;
+       }
+       if (argc < arg + 2)
+               usage(local_pull_usage);
+       commit_id = argv[arg];
+       path = argv[arg + 1];
+
+       if (pull(commit_id))
+               return 1;
+
+       return 0;
+}
diff --git a/local-pull.c b/local-pull.c
deleted file mode 100644 (file)
index ca0003b..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright (C) 2005 Junio C Hamano
- */
-#include "cache.h"
-#include "commit.h"
-#include "pull.h"
-
-static int use_link = 0;
-static int use_symlink = 0;
-static int use_filecopy = 1;
-
-static char *path; /* "Remote" git repository */
-
-void prefetch(unsigned char *sha1)
-{
-}
-
-static struct packed_git *packs = NULL;
-
-static void setup_index(unsigned char *sha1)
-{
-       struct packed_git *new_pack;
-       char filename[PATH_MAX];
-       strcpy(filename, path);
-       strcat(filename, "/objects/pack/pack-");
-       strcat(filename, sha1_to_hex(sha1));
-       strcat(filename, ".idx");
-       new_pack = parse_pack_index_file(sha1, filename);
-       new_pack->next = packs;
-       packs = new_pack;
-}
-
-static int setup_indices(void)
-{
-       DIR *dir;
-       struct dirent *de;
-       char filename[PATH_MAX];
-       unsigned char sha1[20];
-       sprintf(filename, "%s/objects/pack/", path);
-       dir = opendir(filename);
-       while ((de = readdir(dir)) != NULL) {
-               int namelen = strlen(de->d_name);
-               if (namelen != 50 || 
-                   strcmp(de->d_name + namelen - 5, ".pack"))
-                       continue;
-               get_sha1_hex(de->d_name + 5, sha1);
-               setup_index(sha1);
-       }
-       return 0;
-}
-
-static int copy_file(const char *source, const char *dest, const char *hex)
-{
-       if (use_link) {
-               if (!link(source, dest)) {
-                       pull_say("link %s\n", hex);
-                       return 0;
-               }
-               /* If we got ENOENT there is no point continuing. */
-               if (errno == ENOENT) {
-                       fprintf(stderr, "does not exist %s\n", source);
-                       return -1;
-               }
-       }
-       if (use_symlink && !symlink(source, dest)) {
-               pull_say("symlink %s\n", hex);
-               return 0;
-       }
-       if (use_filecopy) {
-               int ifd, ofd, status;
-               struct stat st;
-               void *map;
-               ifd = open(source, O_RDONLY);
-               if (ifd < 0 || fstat(ifd, &st) < 0) {
-                       close(ifd);
-                       fprintf(stderr, "cannot open %s\n", source);
-                       return -1;
-               }
-               map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, ifd, 0);
-               close(ifd);
-               if (map == MAP_FAILED) {
-                       fprintf(stderr, "cannot mmap %s\n", source);
-                       return -1;
-               }
-               ofd = open(dest, O_WRONLY | O_CREAT | O_EXCL, 0666);
-               status = ((ofd < 0) ||
-                         (write(ofd, map, st.st_size) != st.st_size));
-               munmap(map, st.st_size);
-               close(ofd);
-               if (status)
-                       fprintf(stderr, "cannot write %s\n", dest);
-               else
-                       pull_say("copy %s\n", hex);
-               return status;
-       }
-       fprintf(stderr, "failed to copy %s with given copy methods.\n", hex);
-       return -1;
-}
-
-static int fetch_pack(const unsigned char *sha1)
-{
-       struct packed_git *target;
-       char filename[PATH_MAX];
-       if (setup_indices())
-               return -1;
-       target = find_sha1_pack(sha1, packs);
-       if (!target)
-               return error("Couldn't find %s: not separate or in any pack", 
-                            sha1_to_hex(sha1));
-       if (get_verbosely) {
-               fprintf(stderr, "Getting pack %s\n",
-                       sha1_to_hex(target->sha1));
-               fprintf(stderr, " which contains %s\n",
-                       sha1_to_hex(sha1));
-       }
-       sprintf(filename, "%s/objects/pack/pack-%s.pack", 
-               path, sha1_to_hex(target->sha1));
-       copy_file(filename, sha1_pack_name(target->sha1),
-                 sha1_to_hex(target->sha1));
-       sprintf(filename, "%s/objects/pack/pack-%s.idx", 
-               path, sha1_to_hex(target->sha1));
-       copy_file(filename, sha1_pack_index_name(target->sha1),
-                 sha1_to_hex(target->sha1));
-       install_packed_git(target);
-       return 0;
-}
-
-static int fetch_file(const unsigned char *sha1)
-{
-       static int object_name_start = -1;
-       static char filename[PATH_MAX];
-       char *hex = sha1_to_hex(sha1);
-       const char *dest_filename = sha1_file_name(sha1);
-
-       if (object_name_start < 0) {
-               strcpy(filename, path); /* e.g. git.git */
-               strcat(filename, "/objects/");
-               object_name_start = strlen(filename);
-       }
-       filename[object_name_start+0] = hex[0];
-       filename[object_name_start+1] = hex[1];
-       filename[object_name_start+2] = '/';
-       strcpy(filename + object_name_start + 3, hex + 2);
-       return copy_file(filename, dest_filename, hex);
-}
-
-int fetch(unsigned char *sha1)
-{
-       return fetch_file(sha1) && fetch_pack(sha1);
-}
-
-int fetch_ref(char *ref, unsigned char *sha1)
-{
-       static int ref_name_start = -1;
-       static char filename[PATH_MAX];
-       static char hex[41];
-       int ifd;
-
-       if (ref_name_start < 0) {
-               sprintf(filename, "%s/refs/", path);
-               ref_name_start = strlen(filename);
-       }
-       strcpy(filename + ref_name_start, ref);
-       ifd = open(filename, O_RDONLY);
-       if (ifd < 0) {
-               close(ifd);
-               fprintf(stderr, "cannot open %s\n", filename);
-               return -1;
-       }
-       if (read(ifd, hex, 40) != 40 || get_sha1_hex(hex, sha1)) {
-               close(ifd);
-               fprintf(stderr, "cannot read from %s\n", filename);
-               return -1;
-       }
-       close(ifd);
-       pull_say("ref %s\n", sha1_to_hex(sha1));
-       return 0;
-}
-
-static const char local_pull_usage[] =
-"git-local-pull [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] [-l] [-s] [-n] commit-id path";
-
-/* 
- * By default we only use file copy.
- * If -l is specified, a hard link is attempted.
- * If -s is specified, then a symlink is attempted.
- * If -n is _not_ specified, then a regular file-to-file copy is done.
- */
-int main(int argc, char **argv)
-{
-       char *commit_id;
-       int arg = 1;
-
-       while (arg < argc && argv[arg][0] == '-') {
-               if (argv[arg][1] == 't')
-                       get_tree = 1;
-               else if (argv[arg][1] == 'c')
-                       get_history = 1;
-               else if (argv[arg][1] == 'a') {
-                       get_all = 1;
-                       get_tree = 1;
-                       get_history = 1;
-               }
-               else if (argv[arg][1] == 'l')
-                       use_link = 1;
-               else if (argv[arg][1] == 's')
-                       use_symlink = 1;
-               else if (argv[arg][1] == 'n')
-                       use_filecopy = 0;
-               else if (argv[arg][1] == 'v')
-                       get_verbosely = 1;
-               else if (argv[arg][1] == 'w')
-                       write_ref = argv[++arg];
-               else
-                       usage(local_pull_usage);
-               arg++;
-       }
-       if (argc < arg + 2)
-               usage(local_pull_usage);
-       commit_id = argv[arg];
-       path = argv[arg + 1];
-
-       if (pull(commit_id))
-               return 1;
-
-       return 0;
-}
diff --git a/merge-cache.c b/merge-cache.c
deleted file mode 100644 (file)
index 744681b..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include "cache.h"
-
-static const char *pgm = NULL;
-static const char *arguments[8];
-static int one_shot, quiet;
-static int err;
-
-static void run_program(void)
-{
-       int pid = fork(), status;
-
-       if (pid < 0)
-               die("unable to fork");
-       if (!pid) {
-               execlp(pgm, arguments[0],
-                           arguments[1],
-                           arguments[2],
-                           arguments[3],
-                           arguments[4],
-                           arguments[5],
-                           arguments[6],
-                           arguments[7],
-                           NULL);
-               die("unable to execute '%s'", pgm);
-       }
-       if (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) {
-               if (one_shot) {
-                       err++;
-               } else {
-                       if (!quiet)
-                               die("merge program failed");
-                       exit(1);
-               }
-       }
-}
-
-static int merge_entry(int pos, const char *path)
-{
-       int found;
-       
-       if (pos >= active_nr)
-               die("git-merge-cache: %s not in the cache", path);
-       arguments[0] = pgm;
-       arguments[1] = "";
-       arguments[2] = "";
-       arguments[3] = "";
-       arguments[4] = path;
-       arguments[5] = "";
-       arguments[6] = "";
-       arguments[7] = "";
-       found = 0;
-       do {
-               static char hexbuf[4][60];
-               static char ownbuf[4][60];
-               struct cache_entry *ce = active_cache[pos];
-               int stage = ce_stage(ce);
-
-               if (strcmp(ce->name, path))
-                       break;
-               found++;
-               strcpy(hexbuf[stage], sha1_to_hex(ce->sha1));
-               sprintf(ownbuf[stage], "%o", ntohl(ce->ce_mode) & (~S_IFMT));
-               arguments[stage] = hexbuf[stage];
-               arguments[stage + 4] = ownbuf[stage];
-       } while (++pos < active_nr);
-       if (!found)
-               die("git-merge-cache: %s not in the cache", path);
-       run_program();
-       return found;
-}
-
-static void merge_file(const char *path)
-{
-       int pos = cache_name_pos(path, strlen(path));
-
-       /*
-        * If it already exists in the cache as stage0, it's
-        * already merged and there is nothing to do.
-        */
-       if (pos < 0)
-               merge_entry(-pos-1, path);
-}
-
-static void merge_all(void)
-{
-       int i;
-       for (i = 0; i < active_nr; i++) {
-               struct cache_entry *ce = active_cache[i];
-               if (!ce_stage(ce))
-                       continue;
-               i += merge_entry(i, ce->name)-1;
-       }
-}
-
-int main(int argc, char **argv)
-{
-       int i, force_file = 0;
-
-       if (argc < 3)
-               usage("git-merge-cache [-o] [-q] <merge-program> (-a | <filename>*)");
-
-       read_cache();
-
-       i = 1;
-       if (!strcmp(argv[i], "-o")) {
-               one_shot = 1;
-               i++;
-       }
-       if (!strcmp(argv[i], "-q")) {
-               quiet = 1;
-               i++;
-       }
-       pgm = argv[i++];
-       for (; i < argc; i++) {
-               char *arg = argv[i];
-               if (!force_file && *arg == '-') {
-                       if (!strcmp(arg, "--")) {
-                               force_file = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "-a")) {
-                               merge_all();
-                               continue;
-                       }
-                       die("git-merge-cache: unknown option %s", arg);
-               }
-               merge_file(arg);
-       }
-       if (err && !quiet)
-               die("merge program failed");
-       return err;
-}
diff --git a/merge-index.c b/merge-index.c
new file mode 100644 (file)
index 0000000..727527f
--- /dev/null
@@ -0,0 +1,135 @@
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "cache.h"
+
+static const char *pgm = NULL;
+static const char *arguments[8];
+static int one_shot, quiet;
+static int err;
+
+static void run_program(void)
+{
+       int pid = fork(), status;
+
+       if (pid < 0)
+               die("unable to fork");
+       if (!pid) {
+               execlp(pgm, arguments[0],
+                           arguments[1],
+                           arguments[2],
+                           arguments[3],
+                           arguments[4],
+                           arguments[5],
+                           arguments[6],
+                           arguments[7],
+                           NULL);
+               die("unable to execute '%s'", pgm);
+       }
+       if (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) {
+               if (one_shot) {
+                       err++;
+               } else {
+                       if (!quiet)
+                               die("merge program failed");
+                       exit(1);
+               }
+       }
+}
+
+static int merge_entry(int pos, const char *path)
+{
+       int found;
+       
+       if (pos >= active_nr)
+               die("git-merge-index: %s not in the cache", path);
+       arguments[0] = pgm;
+       arguments[1] = "";
+       arguments[2] = "";
+       arguments[3] = "";
+       arguments[4] = path;
+       arguments[5] = "";
+       arguments[6] = "";
+       arguments[7] = "";
+       found = 0;
+       do {
+               static char hexbuf[4][60];
+               static char ownbuf[4][60];
+               struct cache_entry *ce = active_cache[pos];
+               int stage = ce_stage(ce);
+
+               if (strcmp(ce->name, path))
+                       break;
+               found++;
+               strcpy(hexbuf[stage], sha1_to_hex(ce->sha1));
+               sprintf(ownbuf[stage], "%o", ntohl(ce->ce_mode) & (~S_IFMT));
+               arguments[stage] = hexbuf[stage];
+               arguments[stage + 4] = ownbuf[stage];
+       } while (++pos < active_nr);
+       if (!found)
+               die("git-merge-index: %s not in the cache", path);
+       run_program();
+       return found;
+}
+
+static void merge_file(const char *path)
+{
+       int pos = cache_name_pos(path, strlen(path));
+
+       /*
+        * If it already exists in the cache as stage0, it's
+        * already merged and there is nothing to do.
+        */
+       if (pos < 0)
+               merge_entry(-pos-1, path);
+}
+
+static void merge_all(void)
+{
+       int i;
+       for (i = 0; i < active_nr; i++) {
+               struct cache_entry *ce = active_cache[i];
+               if (!ce_stage(ce))
+                       continue;
+               i += merge_entry(i, ce->name)-1;
+       }
+}
+
+int main(int argc, char **argv)
+{
+       int i, force_file = 0;
+
+       if (argc < 3)
+               usage("git-merge-index [-o] [-q] <merge-program> (-a | <filename>*)");
+
+       read_cache();
+
+       i = 1;
+       if (!strcmp(argv[i], "-o")) {
+               one_shot = 1;
+               i++;
+       }
+       if (!strcmp(argv[i], "-q")) {
+               quiet = 1;
+               i++;
+       }
+       pgm = argv[i++];
+       for (; i < argc; i++) {
+               char *arg = argv[i];
+               if (!force_file && *arg == '-') {
+                       if (!strcmp(arg, "--")) {
+                               force_file = 1;
+                               continue;
+                       }
+                       if (!strcmp(arg, "-a")) {
+                               merge_all();
+                               continue;
+                       }
+                       die("git-merge-index: unknown option %s", arg);
+               }
+               merge_file(arg);
+       }
+       if (err && !quiet)
+               die("merge program failed");
+       return err;
+}
diff --git a/pull.c b/pull.c
deleted file mode 100644 (file)
index ff55044..0000000
--- a/pull.c
+++ /dev/null
@@ -1,210 +0,0 @@
-#include "pull.h"
-
-#include "cache.h"
-#include "commit.h"
-#include "tree.h"
-#include "tag.h"
-#include "blob.h"
-#include "refs.h"
-
-const char *write_ref = NULL;
-
-const unsigned char *current_ref = NULL;
-
-int get_tree = 0;
-int get_history = 0;
-int get_all = 0;
-int get_verbosely = 0;
-static unsigned char current_commit_sha1[20];
-
-void pull_say(const char *fmt, const char *hex) 
-{
-       if (get_verbosely)
-               fprintf(stderr, fmt, hex);
-}
-
-static void report_missing(const char *what, const unsigned char *missing)
-{
-       char missing_hex[41];
-
-       strcpy(missing_hex, sha1_to_hex(missing));;
-       fprintf(stderr,
-               "Cannot obtain needed %s %s\nwhile processing commit %s.\n",
-               what, missing_hex, sha1_to_hex(current_commit_sha1));
-}
-
-static int make_sure_we_have_it(const char *what, unsigned char *sha1)
-{
-       int status = 0;
-
-       if (!has_sha1_file(sha1)) {
-               status = fetch(sha1);
-               if (status && what)
-                       report_missing(what, sha1);
-       }
-       return status;
-}
-
-static int process(unsigned char *sha1, const char *type);
-
-static int process_tree(struct tree *tree)
-{
-       struct tree_entry_list *entries;
-
-       if (parse_tree(tree))
-               return -1;
-
-       for (entries = tree->entries; entries; entries = entries->next) {
-               if (process(entries->item.any->sha1,
-                           entries->directory ? tree_type : blob_type))
-                       return -1;
-       }
-       return 0;
-}
-
-static int process_commit(struct commit *commit)
-{
-       if (parse_commit(commit))
-               return -1;
-
-       memcpy(current_commit_sha1, commit->object.sha1, 20);
-
-       if (get_tree) {
-               if (process(commit->tree->object.sha1, tree_type))
-                       return -1;
-               if (!get_all)
-                       get_tree = 0;
-       }
-       if (get_history) {
-               struct commit_list *parents = commit->parents;
-               for (; parents; parents = parents->next) {
-                       if (has_sha1_file(parents->item->object.sha1))
-                               continue;
-                       if (process(parents->item->object.sha1,
-                                   commit_type))
-                               return -1;
-               }
-       }
-       return 0;
-}
-
-static int process_tag(struct tag *tag)
-{
-       if (parse_tag(tag))
-               return -1;
-       return process(tag->tagged->sha1, NULL);
-}
-
-static struct object_list *process_queue = NULL;
-static struct object_list **process_queue_end = &process_queue;
-
-static int process_object(struct object *obj)
-{
-       if (obj->type == commit_type) {
-               if (process_commit((struct commit *)obj))
-                       return -1;
-               return 0;
-       }
-       if (obj->type == tree_type) {
-               if (process_tree((struct tree *)obj))
-                       return -1;
-               return 0;
-       }
-       if (obj->type == blob_type) {
-               return 0;
-       }
-       if (obj->type == tag_type) {
-               if (process_tag((struct tag *)obj))
-                       return -1;
-               return 0;
-       }
-       return error("Unable to determine requirements "
-                    "of type %s for %s",
-                    obj->type, sha1_to_hex(obj->sha1));
-}
-
-static int process(unsigned char *sha1, const char *type)
-{
-       struct object *obj = lookup_object_type(sha1, type);
-       if (has_sha1_file(sha1)) {
-               parse_object(sha1);
-               /* We already have it, so we should scan it now. */
-               return process_object(obj);
-       }
-       if (object_list_contains(process_queue, obj))
-               return 0;
-       object_list_insert(obj, process_queue_end);
-       process_queue_end = &(*process_queue_end)->next;
-
-       //fprintf(stderr, "prefetch %s\n", sha1_to_hex(sha1));
-       prefetch(sha1);
-               
-       return 0;
-}
-
-static int loop(void)
-{
-       while (process_queue) {
-               struct object *obj = process_queue->item;
-               /*
-               fprintf(stderr, "%d objects to pull\n", 
-                       object_list_length(process_queue));
-               */
-               process_queue = process_queue->next;
-               if (!process_queue)
-                       process_queue_end = &process_queue;
-
-               //fprintf(stderr, "fetch %s\n", sha1_to_hex(obj->sha1));
-               
-               if (make_sure_we_have_it(obj->type ? obj->type : "object", 
-                                        obj->sha1))
-                       return -1;
-               if (!obj->type)
-                       parse_object(obj->sha1);
-               if (process_object(obj))
-                       return -1;
-       }
-       return 0;
-}
-
-static int interpret_target(char *target, unsigned char *sha1)
-{
-       if (!get_sha1_hex(target, sha1))
-               return 0;
-       if (!check_ref_format(target)) {
-               if (!fetch_ref(target, sha1)) {
-                       return 0;
-               }
-       }
-       return -1;
-}
-
-
-int pull(char *target)
-{
-       unsigned char sha1[20];
-       int fd = -1;
-
-       if (write_ref && current_ref) {
-               fd = lock_ref_sha1(write_ref, current_ref);
-               if (fd < 0)
-                       return -1;
-       }
-
-       if (interpret_target(target, sha1))
-               return error("Could not interpret %s as something to pull",
-                            target);
-       if (process(sha1, NULL))
-               return -1;
-       if (loop())
-               return -1;
-       
-       if (write_ref) {
-               if (current_ref) {
-                       write_ref_sha1(write_ref, fd, sha1);
-               } else {
-                       write_ref_sha1_unlocked(write_ref, sha1);
-               }
-       }
-       return 0;
-}
diff --git a/pull.h b/pull.h
deleted file mode 100644 (file)
index e7710e8..0000000
--- a/pull.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef PULL_H
-#define PULL_H
-
-/*
- * Fetch object given SHA1 from the remote, and store it locally under
- * GIT_OBJECT_DIRECTORY.  Return 0 on success, -1 on failure.  To be
- * provided by the particular implementation.
- */
-extern int fetch(unsigned char *sha1);
-
-/*
- * Fetch the specified object and store it locally; fetch() will be
- * called later to determine success. To be provided by the particular
- * implementation.
- */
-extern void prefetch(unsigned char *sha1);
-
-/*
- * Fetch ref (relative to $GIT_DIR/refs) from the remote, and store
- * the 20-byte SHA1 in sha1.  Return 0 on success, -1 on failure.  To
- * be provided by the particular implementation.
- */
-extern int fetch_ref(char *ref, unsigned char *sha1);
-
-/* If set, the ref filename to write the target value to. */
-extern const char *write_ref;
-
-/* If set, the hash that the current value of write_ref must be. */
-extern const unsigned char *current_ref;
-
-/* Set to fetch the target tree. */
-extern int get_tree;
-
-/* Set to fetch the commit history. */
-extern int get_history;
-
-/* Set to fetch the trees in the commit history. */
-extern int get_all;
-
-/* Set to be verbose */
-extern int get_verbosely;
-
-/* Report what we got under get_verbosely */
-extern void pull_say(const char *, const char *);
-
-extern int pull(char *target);
-
-#endif /* PULL_H */
diff --git a/ssh-fetch.c b/ssh-fetch.c
new file mode 100644 (file)
index 0000000..d8f4368
--- /dev/null
@@ -0,0 +1,129 @@
+#include "cache.h"
+#include "commit.h"
+#include "rsh.h"
+#include "fetch.h"
+#include "refs.h"
+
+static int fd_in;
+static int fd_out;
+
+static unsigned char remote_version = 0;
+static unsigned char local_version = 1;
+
+static ssize_t force_write(int fd, void *buffer, size_t length)
+{
+       ssize_t ret = 0;
+       while (ret < length) {
+               ssize_t size = write(fd, buffer + ret, length - ret);
+               if (size < 0) {
+                       return size;
+               }
+               if (size == 0) {
+                       return ret;
+               }
+               ret += size;
+       }
+       return ret;
+}
+
+void prefetch(unsigned char *sha1)
+{
+       char type = 'o';
+       force_write(fd_out, &type, 1);
+       force_write(fd_out, sha1, 20);
+       //memcpy(requested + 20 * prefetches++, sha1, 20);
+}
+
+static char conn_buf[4096];
+static size_t conn_buf_posn = 0;
+
+int fetch(unsigned char *sha1)
+{
+       int ret;
+       signed char remote;
+
+       if (conn_buf_posn) {
+               remote = conn_buf[0];
+               memmove(conn_buf, conn_buf + 1, --conn_buf_posn);
+       } else {
+               if (read(fd_in, &remote, 1) < 1)
+                       return -1;
+       }
+       //fprintf(stderr, "Got %d\n", remote);
+       if (remote < 0)
+               return remote;
+       ret = write_sha1_from_fd(sha1, fd_in, conn_buf, 4096, &conn_buf_posn);
+       if (!ret)
+               pull_say("got %s\n", sha1_to_hex(sha1));
+       return ret;
+}
+
+static int get_version(void)
+{
+       char type = 'v';
+       write(fd_out, &type, 1);
+       write(fd_out, &local_version, 1);
+       if (read(fd_in, &remote_version, 1) < 1) {
+               return error("Couldn't read version from remote end");
+       }
+       return 0;
+}
+
+int fetch_ref(char *ref, unsigned char *sha1)
+{
+       signed char remote;
+       char type = 'r';
+       write(fd_out, &type, 1);
+       write(fd_out, ref, strlen(ref) + 1);
+       read(fd_in, &remote, 1);
+       if (remote < 0)
+               return remote;
+       read(fd_in, sha1, 20);
+       return 0;
+}
+
+int main(int argc, char **argv)
+{
+       char *commit_id;
+       char *url;
+       int arg = 1;
+       const char *prog;
+
+       prog = getenv("GIT_SSH_PUSH");
+       if (!prog) prog = "git-ssh-upload";
+
+       while (arg < argc && argv[arg][0] == '-') {
+               if (argv[arg][1] == 't') {
+                       get_tree = 1;
+               } else if (argv[arg][1] == 'c') {
+                       get_history = 1;
+               } else if (argv[arg][1] == 'a') {
+                       get_all = 1;
+                       get_tree = 1;
+                       get_history = 1;
+               } else if (argv[arg][1] == 'v') {
+                       get_verbosely = 1;
+               } else if (argv[arg][1] == 'w') {
+                       write_ref = argv[arg + 1];
+                       arg++;
+               }
+               arg++;
+       }
+       if (argc < arg + 2) {
+               usage("git-ssh-fetch [-c] [-t] [-a] [-v] [-d] [--recover] [-w ref] commit-id url");
+               return 1;
+       }
+       commit_id = argv[arg];
+       url = argv[arg + 1];
+
+       if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))
+               return 1;
+
+       if (get_version())
+               return 1;
+
+       if (pull(commit_id))
+               return 1;
+
+       return 0;
+}
diff --git a/ssh-pull.c b/ssh-pull.c
deleted file mode 100644 (file)
index f1d8e70..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-#include "cache.h"
-#include "commit.h"
-#include "rsh.h"
-#include "pull.h"
-#include "refs.h"
-
-static int fd_in;
-static int fd_out;
-
-static unsigned char remote_version = 0;
-static unsigned char local_version = 1;
-
-static ssize_t force_write(int fd, void *buffer, size_t length)
-{
-       ssize_t ret = 0;
-       while (ret < length) {
-               ssize_t size = write(fd, buffer + ret, length - ret);
-               if (size < 0) {
-                       return size;
-               }
-               if (size == 0) {
-                       return ret;
-               }
-               ret += size;
-       }
-       return ret;
-}
-
-void prefetch(unsigned char *sha1)
-{
-       char type = 'o';
-       force_write(fd_out, &type, 1);
-       force_write(fd_out, sha1, 20);
-       //memcpy(requested + 20 * prefetches++, sha1, 20);
-}
-
-static char conn_buf[4096];
-static size_t conn_buf_posn = 0;
-
-int fetch(unsigned char *sha1)
-{
-       int ret;
-       signed char remote;
-
-       if (conn_buf_posn) {
-               remote = conn_buf[0];
-               memmove(conn_buf, conn_buf + 1, --conn_buf_posn);
-       } else {
-               if (read(fd_in, &remote, 1) < 1)
-                       return -1;
-       }
-       //fprintf(stderr, "Got %d\n", remote);
-       if (remote < 0)
-               return remote;
-       ret = write_sha1_from_fd(sha1, fd_in, conn_buf, 4096, &conn_buf_posn);
-       if (!ret)
-               pull_say("got %s\n", sha1_to_hex(sha1));
-       return ret;
-}
-
-static int get_version(void)
-{
-       char type = 'v';
-       write(fd_out, &type, 1);
-       write(fd_out, &local_version, 1);
-       if (read(fd_in, &remote_version, 1) < 1) {
-               return error("Couldn't read version from remote end");
-       }
-       return 0;
-}
-
-int fetch_ref(char *ref, unsigned char *sha1)
-{
-       signed char remote;
-       char type = 'r';
-       write(fd_out, &type, 1);
-       write(fd_out, ref, strlen(ref) + 1);
-       read(fd_in, &remote, 1);
-       if (remote < 0)
-               return remote;
-       read(fd_in, sha1, 20);
-       return 0;
-}
-
-int main(int argc, char **argv)
-{
-       char *commit_id;
-       char *url;
-       int arg = 1;
-       const char *prog;
-
-       prog = getenv("GIT_SSH_PUSH");
-       if (!prog) prog = "git-ssh-push";
-
-       while (arg < argc && argv[arg][0] == '-') {
-               if (argv[arg][1] == 't') {
-                       get_tree = 1;
-               } else if (argv[arg][1] == 'c') {
-                       get_history = 1;
-               } else if (argv[arg][1] == 'a') {
-                       get_all = 1;
-                       get_tree = 1;
-                       get_history = 1;
-               } else if (argv[arg][1] == 'v') {
-                       get_verbosely = 1;
-               } else if (argv[arg][1] == 'w') {
-                       write_ref = argv[arg + 1];
-                       arg++;
-               }
-               arg++;
-       }
-       if (argc < arg + 2) {
-               usage("git-ssh-pull [-c] [-t] [-a] [-v] [-d] [--recover] [-w ref] commit-id url");
-               return 1;
-       }
-       commit_id = argv[arg];
-       url = argv[arg + 1];
-
-       if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))
-               return 1;
-
-       if (get_version())
-               return 1;
-
-       if (pull(commit_id))
-               return 1;
-
-       return 0;
-}
diff --git a/ssh-push.c b/ssh-push.c
deleted file mode 100644 (file)
index 5bd4569..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-#include "cache.h"
-#include "rsh.h"
-#include "refs.h"
-
-#include <string.h>
-
-static unsigned char local_version = 1;
-static unsigned char remote_version = 0;
-
-static int verbose = 0;
-
-static int serve_object(int fd_in, int fd_out) {
-       ssize_t size;
-       unsigned char sha1[20];
-       signed char remote;
-       int posn = 0;
-       do {
-               size = read(fd_in, sha1 + posn, 20 - posn);
-               if (size < 0) {
-                       perror("git-ssh-push: read ");
-                       return -1;
-               }
-               if (!size)
-                       return -1;
-               posn += size;
-       } while (posn < 20);
-       
-       if (verbose)
-               fprintf(stderr, "Serving %s\n", sha1_to_hex(sha1));
-
-       remote = 0;
-       
-       if (!has_sha1_file(sha1)) {
-               fprintf(stderr, "git-ssh-push: could not find %s\n", 
-                       sha1_to_hex(sha1));
-               remote = -1;
-       }
-       
-       write(fd_out, &remote, 1);
-       
-       if (remote < 0)
-               return 0;
-       
-       return write_sha1_to_fd(fd_out, sha1);
-}
-
-static int serve_version(int fd_in, int fd_out)
-{
-       if (read(fd_in, &remote_version, 1) < 1)
-               return -1;
-       write(fd_out, &local_version, 1);
-       return 0;
-}
-
-static int serve_ref(int fd_in, int fd_out)
-{
-       char ref[PATH_MAX];
-       unsigned char sha1[20];
-       int posn = 0;
-       signed char remote = 0;
-       do {
-               if (read(fd_in, ref + posn, 1) < 1)
-                       return -1;
-               posn++;
-       } while (ref[posn - 1]);
-
-       if (verbose)
-               fprintf(stderr, "Serving %s\n", ref);
-
-       if (get_ref_sha1(ref, sha1))
-               remote = -1;
-       write(fd_out, &remote, 1);
-       if (remote)
-               return 0;
-       write(fd_out, sha1, 20);
-        return 0;
-}
-
-
-static void service(int fd_in, int fd_out) {
-       char type;
-       int retval;
-       do {
-               retval = read(fd_in, &type, 1);
-               if (retval < 1) {
-                       if (retval < 0)
-                               perror("git-ssh-push: read ");
-                       return;
-               }
-               if (type == 'v' && serve_version(fd_in, fd_out))
-                       return;
-               if (type == 'o' && serve_object(fd_in, fd_out))
-                       return;
-               if (type == 'r' && serve_ref(fd_in, fd_out))
-                       return;
-       } while (1);
-}
-
-static const char ssh_push_usage[] =
-       "git-ssh-push [-c] [-t] [-a] [-w ref] commit-id url";
-
-int main(int argc, char **argv)
-{
-       int arg = 1;
-        char *commit_id;
-        char *url;
-       int fd_in, fd_out;
-       const char *prog;
-       unsigned char sha1[20];
-       char hex[41];
-
-       prog = getenv("GIT_SSH_PULL");
-       if (!prog) prog = "git-ssh-pull";
-       while (arg < argc && argv[arg][0] == '-') {
-               if (argv[arg][1] == 'w')
-                       arg++;
-                arg++;
-        }
-       if (argc < arg + 2)
-               usage(ssh_push_usage);
-       commit_id = argv[arg];
-       url = argv[arg + 1];
-       if (get_sha1(commit_id, sha1))
-               usage(ssh_push_usage);
-       memcpy(hex, sha1_to_hex(sha1), sizeof(hex));
-       argv[arg] = hex;
-
-       if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))
-               return 1;
-
-       service(fd_in, fd_out);
-       return 0;
-}
diff --git a/ssh-upload.c b/ssh-upload.c
new file mode 100644 (file)
index 0000000..10a3687
--- /dev/null
@@ -0,0 +1,133 @@
+#include "cache.h"
+#include "rsh.h"
+#include "refs.h"
+
+#include <string.h>
+
+static unsigned char local_version = 1;
+static unsigned char remote_version = 0;
+
+static int verbose = 0;
+
+static int serve_object(int fd_in, int fd_out) {
+       ssize_t size;
+       unsigned char sha1[20];
+       signed char remote;
+       int posn = 0;
+       do {
+               size = read(fd_in, sha1 + posn, 20 - posn);
+               if (size < 0) {
+                       perror("git-ssh-upload: read ");
+                       return -1;
+               }
+               if (!size)
+                       return -1;
+               posn += size;
+       } while (posn < 20);
+       
+       if (verbose)
+               fprintf(stderr, "Serving %s\n", sha1_to_hex(sha1));
+
+       remote = 0;
+       
+       if (!has_sha1_file(sha1)) {
+               fprintf(stderr, "git-ssh-upload: could not find %s\n",
+                       sha1_to_hex(sha1));
+               remote = -1;
+       }
+       
+       write(fd_out, &remote, 1);
+       
+       if (remote < 0)
+               return 0;
+       
+       return write_sha1_to_fd(fd_out, sha1);
+}
+
+static int serve_version(int fd_in, int fd_out)
+{
+       if (read(fd_in, &remote_version, 1) < 1)
+               return -1;
+       write(fd_out, &local_version, 1);
+       return 0;
+}
+
+static int serve_ref(int fd_in, int fd_out)
+{
+       char ref[PATH_MAX];
+       unsigned char sha1[20];
+       int posn = 0;
+       signed char remote = 0;
+       do {
+               if (read(fd_in, ref + posn, 1) < 1)
+                       return -1;
+               posn++;
+       } while (ref[posn - 1]);
+
+       if (verbose)
+               fprintf(stderr, "Serving %s\n", ref);
+
+       if (get_ref_sha1(ref, sha1))
+               remote = -1;
+       write(fd_out, &remote, 1);
+       if (remote)
+               return 0;
+       write(fd_out, sha1, 20);
+        return 0;
+}
+
+
+static void service(int fd_in, int fd_out) {
+       char type;
+       int retval;
+       do {
+               retval = read(fd_in, &type, 1);
+               if (retval < 1) {
+                       if (retval < 0)
+                               perror("git-ssh-upload: read ");
+                       return;
+               }
+               if (type == 'v' && serve_version(fd_in, fd_out))
+                       return;
+               if (type == 'o' && serve_object(fd_in, fd_out))
+                       return;
+               if (type == 'r' && serve_ref(fd_in, fd_out))
+                       return;
+       } while (1);
+}
+
+static const char ssh_push_usage[] =
+       "git-ssh-upload [-c] [-t] [-a] [-w ref] commit-id url";
+
+int main(int argc, char **argv)
+{
+       int arg = 1;
+        char *commit_id;
+        char *url;
+       int fd_in, fd_out;
+       const char *prog;
+       unsigned char sha1[20];
+       char hex[41];
+
+       prog = getenv("GIT_SSH_PULL");
+       if (!prog) prog = "git-ssh-fetch";
+       while (arg < argc && argv[arg][0] == '-') {
+               if (argv[arg][1] == 'w')
+                       arg++;
+                arg++;
+        }
+       if (argc < arg + 2)
+               usage(ssh_push_usage);
+       commit_id = argv[arg];
+       url = argv[arg + 1];
+       if (get_sha1(commit_id, sha1))
+               usage(ssh_push_usage);
+       memcpy(hex, sha1_to_hex(sha1), sizeof(hex));
+       argv[arg] = hex;
+
+       if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))
+               return 1;
+
+       service(fd_in, fd_out);
+       return 0;
+}
index ab47ef9..ac5a3ac 100644 (file)
--- a/t/README
+++ b/t/README
@@ -20,9 +20,9 @@ the tests.
     *** t0000-basic.sh ***
     *   ok 1: .git/objects should be empty after git-init-db in an empty repo.
     *   ok 2: .git/objects should have 256 subdirectories.
-    *   ok 3: git-update-cache without --add should fail adding.
+    *   ok 3: git-update-index without --add should fail adding.
     ...
-    *   ok 23: no diff after checkout and git-update-cache --refresh.
+    *   ok 23: no diff after checkout and git-update-index --refresh.
     * passed all 23 test(s)
     *** t0100-environment-names.sh ***
     *   ok 1: using old names should issue warnings.
@@ -33,7 +33,7 @@ Or you can run each test individually from command line, like
 this:
 
     $ sh ./t3001-ls-files-killed.sh
-    *   ok 1: git-update-cache --add to add various paths.
+    *   ok 1: git-update-index --add to add various paths.
     *   ok 2: git-ls-files -k to show killed files.
     *   ok 3: validate git-ls-files -k output.
     * passed all 3 test(s)
@@ -163,8 +163,8 @@ library for your script to use.
    Example:
 
        test_expect_failure \
-           'git-update-cache without --add should fail adding.' \
-           'git-update-cache should-be-empty'
+           'git-update-index without --add should fail adding.' \
+           'git-update-index should-be-empty'
 
  - test_debug <script>
 
index d6645b4..d195603 100755 (executable)
@@ -10,14 +10,14 @@ do
        echo This is Z/$p from the original tree. >Z/$p
        test_expect_success \
            "adding test file $p and Z/$p" \
-           'git-update-cache --add $p &&
-           git-update-cache --add Z/$p'
+           'git-update-index --add $p &&
+           git-update-index --add Z/$p'
     done
 done
 echo This is SS from the original tree. >SS
 test_expect_success \
     'adding test file SS' \
-    'git-update-cache --add SS'
+    'git-update-index --add SS'
 cat >TT <<\EOF
 This is a trivial merge sample text.
 Branch A is expected to upcase this word, here.
@@ -32,7 +32,7 @@ This concludes the trivial merge sample file.
 EOF
 test_expect_success \
     'adding test file TT' \
-    'git-update-cache --add TT'
+    'git-update-index --add TT'
 test_expect_success \
     'prepare initial tree' \
     'tree_O=$(git-write-tree)'
@@ -47,14 +47,14 @@ to_remove=$(echo D? Z/D?)
 rm -f $to_remove
 test_expect_success \
     'change in branch A (removal)' \
-    'git-update-cache --remove $to_remove'
+    'git-update-index --remove $to_remove'
 
 for p in M? Z/M?
 do
     echo This is modified $p in the branch A. >$p
     test_expect_success \
        'change in branch A (modification)' \
-        "git-update-cache $p"
+        "git-update-index $p"
 done
 
 for p in AN AA Z/AN Z/AA
@@ -62,27 +62,27 @@ do
     echo This is added $p in the branch A. >$p
     test_expect_success \
        'change in branch A (addition)' \
-       "git-update-cache --add $p"
+       "git-update-index --add $p"
 done
 
 echo This is SS from the modified tree. >SS
 echo This is LL from the modified tree. >LL
 test_expect_success \
     'change in branch A (addition)' \
-    'git-update-cache --add LL &&
-     git-update-cache SS'
+    'git-update-index --add LL &&
+     git-update-index SS'
 mv TT TT-
 sed -e '/Branch A/s/word/WORD/g' <TT- >TT
 rm -f TT-
 test_expect_success \
     'change in branch A (edit)' \
-    'git-update-cache TT'
+    'git-update-index TT'
 
 mkdir DF
 echo Branch A makes a file at DF/DF, creating a directory DF. >DF/DF
 test_expect_success \
     'change in branch A (change file to directory)' \
-    'git-update-cache --add DF/DF'
+    'git-update-index --add DF/DF'
 
 test_expect_success \
     'recording branch A tree' \
@@ -97,20 +97,20 @@ mkdir Z
 test_expect_success \
     'reading original tree and checking out' \
     'git-read-tree $tree_O &&
-     git-checkout-cache -a'
+     git-checkout-index -a'
 
 to_remove=$(echo ?D Z/?D)
 rm -f $to_remove
 test_expect_success \
     'change in branch B (removal)' \
-    "git-update-cache --remove $to_remove"
+    "git-update-index --remove $to_remove"
 
 for p in ?M Z/?M
 do
     echo This is modified $p in the branch B. >$p
     test_expect_success \
        'change in branch B (modification)' \
-       "git-update-cache $p"
+       "git-update-index $p"
 done
 
 for p in NA AA Z/NA Z/AA
@@ -118,25 +118,25 @@ do
     echo This is added $p in the branch B. >$p
     test_expect_success \
        'change in branch B (addition)' \
-       "git-update-cache --add $p"
+       "git-update-index --add $p"
 done
 echo This is SS from the modified tree. >SS
 echo This is LL from the modified tree. >LL
 test_expect_success \
     'change in branch B (addition and modification)' \
-    'git-update-cache --add LL &&
-     git-update-cache SS'
+    'git-update-index --add LL &&
+     git-update-index SS'
 mv TT TT-
 sed -e '/Branch B/s/word/WORD/g' <TT- >TT
 rm -f TT-
 test_expect_success \
     'change in branch B (modification)' \
-    'git-update-cache TT'
+    'git-update-index TT'
 
 echo Branch B makes a file at DF. >DF
 test_expect_success \
     'change in branch B (addition of a file to conflict with directory)' \
-    'git-update-cache --add DF'
+    'git-update-index --add DF'
 
 test_expect_success \
     'recording branch B tree' \
@@ -147,12 +147,12 @@ test_expect_success \
     'rm -f .git/index &&
      git-read-tree $tree_O &&
      mkdir .orig-O &&
-     git-checkout-cache --prefix=.orig-O/ -f -q -a &&
+     git-checkout-index --prefix=.orig-O/ -f -q -a &&
      rm -f .git/index &&
      git-read-tree $tree_A &&
      mkdir .orig-A &&
-     git-checkout-cache --prefix=.orig-A/ -f -q -a &&
+     git-checkout-index --prefix=.orig-A/ -f -q -a &&
      rm -f .git/index &&
      git-read-tree $tree_B &&
      mkdir .orig-B &&
-     git-checkout-cache --prefix=.orig-B/ -f -q -a'
+     git-checkout-index --prefix=.orig-B/ -f -q -a'
index 142b7bf..3649f0f 100755 (executable)
@@ -40,13 +40,13 @@ test_expect_success \
 
 # updating a new file without --add should fail.
 test_expect_failure \
-    'git-update-cache without --add should fail adding.' \
-    'git-update-cache should-be-empty'
+    'git-update-index without --add should fail adding.' \
+    'git-update-index should-be-empty'
 
 # and with --add it should succeed, even if it is empty (it used to fail).
 test_expect_success \
-    'git-update-cache with --add should succeed.' \
-    'git-update-cache --add should-be-empty'
+    'git-update-index with --add should succeed.' \
+    'git-update-index --add should-be-empty'
 
 test_expect_success \
     'writing tree out with git-write-tree' \
@@ -60,12 +60,12 @@ test_expect_success \
 # Removing paths.
 rm -f should-be-empty full-of-directories
 test_expect_failure \
-    'git-update-cache without --remove should fail removing.' \
-    'git-update-cache should-be-empty'
+    'git-update-index without --remove should fail removing.' \
+    'git-update-index should-be-empty'
 
 test_expect_success \
-    'git-update-cache with --remove should be able to remove.' \
-    'git-update-cache --remove should-be-empty'
+    'git-update-index with --remove should be able to remove.' \
+    'git-update-index --remove should-be-empty'
 
 # Empty tree can be written with recent write-tree.
 test_expect_success \
@@ -84,8 +84,8 @@ do
     ln -s "hello $p" ${p}sym
 done
 test_expect_success \
-    'adding various types of objects with git-update-cache --add.' \
-    'find path* ! -type d -print0 | xargs -0 git-update-cache --add'
+    'adding various types of objects with git-update-index --add.' \
+    'find path* ! -type d -print0 | xargs -0 git-update-index --add'
 
 # Show them and see that matches what we expect.
 test_expect_success \
@@ -170,11 +170,11 @@ test_expect_success \
     'git-diff-files >current && diff >/dev/null -b current expected'
 
 test_expect_success \
-    'git-update-cache --refresh should succeed.' \
-    'git-update-cache --refresh'
+    'git-update-index --refresh should succeed.' \
+    'git-update-index --refresh'
 
 test_expect_success \
-    'no diff after checkout and git-update-cache --refresh.' \
+    'no diff after checkout and git-update-index --refresh.' \
     'git-diff-files >current && cmp -s current /dev/null'
 
 test_done
index 9f851bc..3493bd4 100755 (executable)
@@ -34,7 +34,7 @@ export_them () {
 }
 
 date >path0
-git-update-cache --add path0
+git-update-index --add path0
 tree=$(git-write-tree)
 
 AUTHOR_DATE='Wed May 11 23:55:18 2005'
index c548b9b..5d602cc 100755 (executable)
@@ -54,8 +54,8 @@ test_expect_success \
 
 date >path0
 test_expect_success \
-    'using GIT_DIR in git-update-cache' \
-    'git-update-cache --add path0 && test -f .svn/index'
+    'using GIT_DIR in git-update-index' \
+    'git-update-index --add path0 && test -f .svn/index'
 
 sedScript='s|\(..\)|.svn/objects/\1/|'
 
index 89f0e81..f1cd50c 100755 (executable)
@@ -150,7 +150,7 @@ test_expect_success \
     "rm -fr [NDMALTS][NDMALTSF] Z &&
      rm .git/index &&
      git-read-tree $tree_A &&
-     git-checkout-cache -f -u -a &&
+     git-checkout-index -f -u -a &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -230,21 +230,21 @@ test_expect_failure \
     '1 - must not have an entry not in A.' \
     "rm -f .git/index XX &&
      echo XX >XX &&
-     git-update-cache --add XX &&
+     git-update-index --add XX &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '2 - must match B in !O && !A && B case.' \
     "rm -f .git/index NA &&
      cp .orig-B/NA NA &&
-     git-update-cache --add NA &&
+     git-update-index --add NA &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '2 - matching B alone is OK in !O && !A && B case.' \
     "rm -f .git/index NA &&
      cp .orig-B/NA NA &&
-     git-update-cache --add NA &&
+     git-update-index --add NA &&
      echo extra >>NA &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
@@ -252,7 +252,7 @@ test_expect_success \
     '3 - must match A in !O && A && !B case.' \
     "rm -f .git/index AN &&
      cp .orig-A/AN AN &&
-     git-update-cache --add AN &&
+     git-update-index --add AN &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -260,7 +260,7 @@ test_expect_success \
     '3 - matching A alone is OK in !O && A && !B case.' \
     "rm -f .git/index AN &&
      cp .orig-A/AN AN &&
-     git-update-cache --add AN &&
+     git-update-index --add AN &&
      echo extra >>AN &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
@@ -269,14 +269,14 @@ test_expect_failure \
     "rm -f .git/index AN &&
      cp .orig-A/AN AN &&
      echo extra >>AN &&
-     git-update-cache --add AN &&
+     git-update-index --add AN &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '4 - must match and be up-to-date in !O && A && B && A!=B case.' \
     "rm -f .git/index AA &&
      cp .orig-A/AA AA &&
-     git-update-cache --add AA &&
+     git-update-index --add AA &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -284,7 +284,7 @@ test_expect_failure \
     '4 (fail) - must match and be up-to-date in !O && A && B && A!=B case.' \
     "rm -f .git/index AA &&
      cp .orig-A/AA AA &&
-     git-update-cache --add AA &&
+     git-update-index --add AA &&
      echo extra >>AA &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
@@ -293,14 +293,14 @@ test_expect_failure \
     "rm -f .git/index AA &&
      cp .orig-A/AA AA &&
      echo extra >>AA &&
-     git-update-cache --add AA &&
+     git-update-index --add AA &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '5 - must match in !O && A && B && A==B case.' \
     "rm -f .git/index LL &&
      cp .orig-A/LL LL &&
-     git-update-cache --add LL &&
+     git-update-index --add LL &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -308,7 +308,7 @@ test_expect_success \
     '5 - must match in !O && A && B && A==B case.' \
     "rm -f .git/index LL &&
      cp .orig-A/LL LL &&
-     git-update-cache --add LL &&
+     git-update-index --add LL &&
      echo extra >>LL &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
@@ -318,35 +318,35 @@ test_expect_failure \
     "rm -f .git/index LL &&
      cp .orig-A/LL LL &&
      echo extra >>LL &&
-     git-update-cache --add LL &&
+     git-update-index --add LL &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_failure \
     '6 - must not exist in O && !A && !B case' \
     "rm -f .git/index DD &&
      echo DD >DD
-     git-update-cache --add DD &&
+     git-update-index --add DD &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_failure \
     '7 - must not exist in O && !A && B && O!=B case' \
     "rm -f .git/index DM &&
      cp .orig-B/DM DM &&
-     git-update-cache --add DM &&
+     git-update-index --add DM &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_failure \
     '8 - must not exist in O && !A && B && O==B case' \
     "rm -f .git/index DN &&
      cp .orig-B/DN DN &&
-     git-update-cache --add DN &&
+     git-update-index --add DN &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '9 - must match and be up-to-date in O && A && !B && O!=A case' \
     "rm -f .git/index MD &&
      cp .orig-A/MD MD &&
-     git-update-cache --add MD &&
+     git-update-index --add MD &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -354,7 +354,7 @@ test_expect_failure \
     '9 (fail) - must match and be up-to-date in O && A && !B && O!=A case' \
     "rm -f .git/index MD &&
      cp .orig-A/MD MD &&
-     git-update-cache --add MD &&
+     git-update-index --add MD &&
      echo extra >>MD &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
@@ -363,14 +363,14 @@ test_expect_failure \
     "rm -f .git/index MD &&
      cp .orig-A/MD MD &&
      echo extra >>MD &&
-     git-update-cache --add MD &&
+     git-update-index --add MD &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '10 - must match and be up-to-date in O && A && !B && O==A case' \
     "rm -f .git/index ND &&
      cp .orig-A/ND ND &&
-     git-update-cache --add ND &&
+     git-update-index --add ND &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -378,7 +378,7 @@ test_expect_failure \
     '10 (fail) - must match and be up-to-date in O && A && !B && O==A case' \
     "rm -f .git/index ND &&
      cp .orig-A/ND ND &&
-     git-update-cache --add ND &&
+     git-update-index --add ND &&
      echo extra >>ND &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
@@ -387,14 +387,14 @@ test_expect_failure \
     "rm -f .git/index ND &&
      cp .orig-A/ND ND &&
      echo extra >>ND &&
-     git-update-cache --add ND &&
+     git-update-index --add ND &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '11 - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \
     "rm -f .git/index MM &&
      cp .orig-A/MM MM &&
-     git-update-cache --add MM &&
+     git-update-index --add MM &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -402,7 +402,7 @@ test_expect_failure \
     '11 (fail) - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \
     "rm -f .git/index MM &&
      cp .orig-A/MM MM &&
-     git-update-cache --add MM &&
+     git-update-index --add MM &&
      echo extra >>MM &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
@@ -411,14 +411,14 @@ test_expect_failure \
     "rm -f .git/index MM &&
      cp .orig-A/MM MM &&
      echo extra >>MM &&
-     git-update-cache --add MM &&
+     git-update-index --add MM &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '12 - must match A in O && A && B && O!=A && A==B case' \
     "rm -f .git/index SS &&
      cp .orig-A/SS SS &&
-     git-update-cache --add SS &&
+     git-update-index --add SS &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -426,7 +426,7 @@ test_expect_success \
     '12 - must match A in O && A && B && O!=A && A==B case' \
     "rm -f .git/index SS &&
      cp .orig-A/SS SS &&
-     git-update-cache --add SS &&
+     git-update-index --add SS &&
      echo extra >>SS &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
@@ -436,14 +436,14 @@ test_expect_failure \
     "rm -f .git/index SS &&
      cp .orig-A/SS SS &&
      echo extra >>SS &&
-     git-update-cache --add SS &&
+     git-update-index --add SS &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '13 - must match A in O && A && B && O!=A && O==B case' \
     "rm -f .git/index MN &&
      cp .orig-A/MN MN &&
-     git-update-cache --add MN &&
+     git-update-index --add MN &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -451,7 +451,7 @@ test_expect_success \
     '13 - must match A in O && A && B && O!=A && O==B case' \
     "rm -f .git/index MN &&
      cp .orig-A/MN MN &&
-     git-update-cache --add MN &&
+     git-update-index --add MN &&
      echo extra >>MN &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
@@ -460,7 +460,7 @@ test_expect_success \
     '14 - must match and be up-to-date in O && A && B && O==A && O!=B case' \
     "rm -f .git/index NM &&
      cp .orig-A/NM NM &&
-     git-update-cache --add NM &&
+     git-update-index --add NM &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -468,7 +468,7 @@ test_expect_success \
     '14 - may match B in O && A && B && O==A && O!=B case' \
     "rm -f .git/index NM &&
      cp .orig-B/NM NM &&
-     git-update-cache --add NM &&
+     git-update-index --add NM &&
      echo extra >>NM &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
@@ -477,7 +477,7 @@ test_expect_failure \
     '14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \
     "rm -f .git/index NM &&
      cp .orig-A/NM NM &&
-     git-update-cache --add NM &&
+     git-update-index --add NM &&
      echo extra >>NM &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
@@ -486,14 +486,14 @@ test_expect_failure \
     "rm -f .git/index NM &&
      cp .orig-A/NM NM &&
      echo extra >>NM &&
-     git-update-cache --add NM &&
+     git-update-index --add NM &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '15 - must match A in O && A && B && O==A && O==B case' \
     "rm -f .git/index NN &&
      cp .orig-A/NN NN &&
-     git-update-cache --add NN &&
+     git-update-index --add NN &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -501,7 +501,7 @@ test_expect_success \
     '15 - must match A in O && A && B && O==A && O==B case' \
     "rm -f .git/index NN &&
      cp .orig-A/NN NN &&
-     git-update-cache --add NN &&
+     git-update-index --add NN &&
      echo extra >>NN &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
@@ -511,7 +511,7 @@ test_expect_failure \
     "rm -f .git/index NN &&
      cp .orig-A/NN NN &&
      echo extra >>NN &&
-     git-update-cache --add NN &&
+     git-update-index --add NN &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_done
index 919f2b3..5b69681 100755 (executable)
@@ -68,13 +68,13 @@ test_expect_success \
      cat bozbar-old >bozbar &&
      echo rezrov >rezrov &&
      echo yomin >yomin &&
-     git-update-cache --add nitfol bozbar rezrov &&
+     git-update-index --add nitfol bozbar rezrov &&
      treeH=`git-write-tree` &&
      echo treeH $treeH &&
      git-ls-tree $treeH &&
 
      cat bozbar-new >bozbar &&
-     git-update-cache --add frotz bozbar --force-remove rezrov &&
+     git-update-index --add frotz bozbar --force-remove rezrov &&
      git-ls-files --stage >M.out &&
      treeM=`git-write-tree` &&
      echo treeM $treeM &&
@@ -97,8 +97,8 @@ test_expect_success \
     '4 - carry forward local addition.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
-     git-update-cache --add yomin &&
+     git-checkout-index -u -f -q -a &&
+     git-update-index --add yomin &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >4.out || return 1
      diff -u M.out 4.out >4diff.out
@@ -109,9 +109,9 @@ test_expect_success \
     '5 - carry forward local addition.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo yomin >yomin &&
-     git-update-cache --add yomin &&
+     git-update-index --add yomin &&
      echo yomin yomin >yomin &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >5.out || return 1
@@ -123,8 +123,8 @@ test_expect_success \
     '6 - local addition already has the same.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
-     git-update-cache --add frotz &&
+     git-checkout-index -u -f -q -a &&
+     git-update-index --add frotz &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >6.out &&
      diff -u M.out 6.out &&
@@ -134,9 +134,9 @@ test_expect_success \
     '7 - local addition already has the same.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo frotz >frotz &&
-     git-update-cache --add frotz &&
+     git-update-index --add frotz &&
      echo frotz frotz >frotz &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >7.out &&
@@ -147,18 +147,18 @@ test_expect_success \
     '8 - conflicting addition.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo frotz frotz >frotz &&
-     git-update-cache --add frotz &&
+     git-update-index --add frotz &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
 test_expect_success \
     '9 - conflicting addition.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo frotz frotz >frotz &&
-     git-update-cache --add frotz &&
+     git-update-index --add frotz &&
      echo frotz >frotz &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
@@ -166,9 +166,9 @@ test_expect_success \
     '10 - path removed.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo rezrov >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >10.out &&
      diff -u M.out 10.out'
@@ -177,9 +177,9 @@ test_expect_success \
     '11 - dirty path removed.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo rezrov >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      echo rezrov rezrov >rezrov &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
@@ -187,18 +187,18 @@ test_expect_success \
     '12 - unmatching local changes being removed.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo rezrov rezrov >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
 test_expect_success \
     '13 - unmatching local changes being removed.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo rezrov rezrov >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      echo rezrov >rezrov &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
@@ -211,9 +211,9 @@ test_expect_success \
     '14 - unchanged in two heads.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo nitfol nitfol >nitfol &&
-     git-update-cache --add nitfol &&
+     git-update-index --add nitfol &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >14.out || return 1
      diff -u M.out 14.out >14diff.out
@@ -224,9 +224,9 @@ test_expect_success \
     '15 - unchanged in two heads.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo nitfol nitfol >nitfol &&
-     git-update-cache --add nitfol &&
+     git-update-index --add nitfol &&
      echo nitfol nitfol nitfol >nitfol &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >15.out || return 1
@@ -238,18 +238,18 @@ test_expect_success \
     '16 - conflicting local change.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo bozbar bozbar >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
 test_expect_success \
     '17 - conflicting local change.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo bozbar bozbar >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      echo bozbar bozbar bozbar >bozbar &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
@@ -257,9 +257,9 @@ test_expect_success \
     '18 - local change already having a good result.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      cat bozbar-new >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >18.out &&
      diff -u M.out 18.out &&
@@ -269,9 +269,9 @@ test_expect_success \
     '19 - local change already having a good result, further modified.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      cat bozbar-new >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      echo gnusto gnusto >bozbar &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >19.out &&
@@ -282,9 +282,9 @@ test_expect_success \
     '20 - no local change, use new tree.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      cat bozbar-old >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >20.out &&
      diff -u M.out 20.out &&
@@ -294,9 +294,9 @@ test_expect_success \
     '21 - no local change, dirty cache.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      cat bozbar-old >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      echo gnusto gnusto >bozbar &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
@@ -305,9 +305,9 @@ test_expect_success \
     '22 - local change cache updated.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      sed -e "s/such as/SUCH AS/" bozbar-old >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
 # Also make sure we did not break DF vs DF/DF case.
@@ -315,7 +315,7 @@ test_expect_success \
     'DF vs DF/DF case setup.' \
     'rm -f .git/index &&
      echo DF >DF &&
-     git-update-cache --add DF &&
+     git-update-index --add DF &&
      treeDF=`git-write-tree` &&
      echo treeDF $treeDF &&
      git-ls-tree $treeDF &&
@@ -323,7 +323,7 @@ test_expect_success \
      rm -f DF &&
      mkdir DF &&
      echo DF/DF >DF/DF &&
-     git-update-cache --add --remove DF DF/DF &&
+     git-update-index --add --remove DF DF/DF &&
      treeDFDF=`git-write-tree` &&
      echo treeDFDF $treeDFDF &&
      git-ls-tree $treeDFDF &&
@@ -334,7 +334,7 @@ test_expect_success \
     'rm -f .git/index &&
      rm -fr DF &&
      echo DF >DF &&
-     git-update-cache --add DF &&
+     git-update-index --add DF &&
      read_tree_twoway $treeDF $treeDFDF &&
      git-ls-files --stage >DFDFcheck.out &&
      diff -u DFDF.out DFDFcheck.out &&
index 512d897..861ef4c 100755 (executable)
@@ -40,13 +40,13 @@ test_expect_success \
      echo bozbar >bozbar &&
      echo rezrov >rezrov &&
      echo yomin >yomin &&
-     git-update-cache --add nitfol bozbar rezrov &&
+     git-update-index --add nitfol bozbar rezrov &&
      treeH=`git-write-tree` &&
      echo treeH $treeH &&
      git-ls-tree $treeH &&
 
      echo gnusto >bozbar &&
-     git-update-cache --add frotz bozbar --force-remove rezrov &&
+     git-update-index --add frotz bozbar --force-remove rezrov &&
      git-ls-files --stage >M.out &&
      treeM=`git-write-tree` &&
      echo treeM $treeM &&
@@ -71,7 +71,7 @@ echo '+100644 X 0     yomin' >expected
 test_expect_success \
     '4 - carry forward local addition.' \
     'rm -f .git/index &&
-     git-update-cache --add yomin &&
+     git-update-index --add yomin &&
      git-read-tree -m -u $treeH $treeM &&
      git-ls-files --stage >4.out || return 1
      diff --unified=0 M.out 4.out >4diff.out
@@ -87,7 +87,7 @@ test_expect_success \
     '5 - carry forward local addition.' \
     'rm -f .git/index &&
      echo yomin >yomin &&
-     git-update-cache --add yomin &&
+     git-update-index --add yomin &&
      echo yomin yomin >yomin &&
      git-read-tree -m -u $treeH $treeM &&
      git-ls-files --stage >5.out || return 1
@@ -104,7 +104,7 @@ test_expect_success \
 test_expect_success \
     '6 - local addition already has the same.' \
     'rm -f .git/index &&
-     git-update-cache --add frotz &&
+     git-update-index --add frotz &&
      git-read-tree -m -u $treeH $treeM &&
      git-ls-files --stage >6.out &&
      diff --unified=0 M.out 6.out &&
@@ -119,7 +119,7 @@ test_expect_success \
     '7 - local addition already has the same.' \
     'rm -f .git/index &&
      echo frotz >frotz &&
-     git-update-cache --add frotz &&
+     git-update-index --add frotz &&
      echo frotz frotz >frotz &&
      git-read-tree -m -u $treeH $treeM &&
      git-ls-files --stage >7.out &&
@@ -136,14 +136,14 @@ test_expect_success \
     '8 - conflicting addition.' \
     'rm -f .git/index &&
      echo frotz frotz >frotz &&
-     git-update-cache --add frotz &&
+     git-update-index --add frotz &&
      if git-read-tree -m -u $treeH $treeM; then false; else :; fi'
 
 test_expect_success \
     '9 - conflicting addition.' \
     'rm -f .git/index &&
      echo frotz frotz >frotz &&
-     git-update-cache --add frotz &&
+     git-update-index --add frotz &&
      echo frotz >frotz &&
      if git-read-tree -m -u $treeH $treeM; then false; else :; fi'
 
@@ -151,7 +151,7 @@ test_expect_success \
     '10 - path removed.' \
     'rm -f .git/index &&
      echo rezrov >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      git-read-tree -m -u $treeH $treeM &&
      git-ls-files --stage >10.out &&
      cmp M.out 10.out &&
@@ -162,7 +162,7 @@ test_expect_success \
     '11 - dirty path removed.' \
     'rm -f .git/index &&
      echo rezrov >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      echo rezrov rezrov >rezrov &&
      if git-read-tree -m -u $treeH $treeM; then false; else :; fi'
 
@@ -170,14 +170,14 @@ test_expect_success \
     '12 - unmatching local changes being removed.' \
     'rm -f .git/index &&
      echo rezrov rezrov >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      if git-read-tree -m -u $treeH $treeM; then false; else :; fi'
 
 test_expect_success \
     '13 - unmatching local changes being removed.' \
     'rm -f .git/index &&
      echo rezrov rezrov >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      echo rezrov >rezrov &&
      if git-read-tree -m -u $treeH $treeM; then false; else :; fi'
 
@@ -190,7 +190,7 @@ test_expect_success \
     '14 - unchanged in two heads.' \
     'rm -f .git/index &&
      echo nitfol nitfol >nitfol &&
-     git-update-cache --add nitfol &&
+     git-update-index --add nitfol &&
      git-read-tree -m -u $treeH $treeM &&
      git-ls-files --stage >14.out || return 1
      diff --unified=0 M.out 14.out >14diff.out
@@ -209,7 +209,7 @@ test_expect_success \
     '15 - unchanged in two heads.' \
     'rm -f .git/index &&
      echo nitfol nitfol >nitfol &&
-     git-update-cache --add nitfol &&
+     git-update-index --add nitfol &&
      echo nitfol nitfol nitfol >nitfol &&
      git-read-tree -m -u $treeH $treeM &&
      git-ls-files --stage >15.out || return 1
@@ -229,14 +229,14 @@ test_expect_success \
     '16 - conflicting local change.' \
     'rm -f .git/index &&
      echo bozbar bozbar >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      if git-read-tree -m -u $treeH $treeM; then false; else :; fi'
 
 test_expect_success \
     '17 - conflicting local change.' \
     'rm -f .git/index &&
      echo bozbar bozbar >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      echo bozbar bozbar bozbar >bozbar &&
      if git-read-tree -m -u $treeH $treeM; then false; else :; fi'
 
@@ -244,7 +244,7 @@ test_expect_success \
     '18 - local change already having a good result.' \
     'rm -f .git/index &&
      echo gnusto >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      git-read-tree -m -u $treeH $treeM &&
      git-ls-files --stage >18.out &&
      diff --unified=0 M.out 18.out &&
@@ -256,7 +256,7 @@ test_expect_success \
     '19 - local change already having a good result, further modified.' \
     'rm -f .git/index &&
      echo gnusto >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      echo gnusto gnusto >bozbar &&
      git-read-tree -m -u $treeH $treeM &&
      git-ls-files --stage >19.out &&
@@ -275,7 +275,7 @@ test_expect_success \
     '20 - no local change, use new tree.' \
     'rm -f .git/index &&
      echo bozbar >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      git-read-tree -m -u $treeH $treeM &&
      git-ls-files --stage >20.out &&
      diff --unified=0 M.out 20.out &&
@@ -287,7 +287,7 @@ test_expect_success \
     '21 - no local change, dirty cache.' \
     'rm -f .git/index &&
      echo bozbar >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      echo gnusto gnusto >bozbar &&
      if git-read-tree -m -u $treeH $treeM; then false; else :; fi'
 
@@ -296,7 +296,7 @@ test_expect_success \
     'DF vs DF/DF case setup.' \
     'rm -f .git/index &&
      echo DF >DF &&
-     git-update-cache --add DF &&
+     git-update-index --add DF &&
      treeDF=`git-write-tree` &&
      echo treeDF $treeDF &&
      git-ls-tree $treeDF &&
@@ -304,7 +304,7 @@ test_expect_success \
      rm -f DF &&
      mkdir DF &&
      echo DF/DF >DF/DF &&
-     git-update-cache --add --remove DF DF/DF &&
+     git-update-index --add --remove DF DF/DF &&
      treeDFDF=`git-write-tree` &&
      echo treeDFDF $treeDFDF &&
      git-ls-tree $treeDFDF &&
@@ -315,7 +315,7 @@ test_expect_success \
     'rm -f .git/index &&
      rm -fr DF &&
      echo DF >DF &&
-     git-update-cache --add DF &&
+     git-update-index --add DF &&
      git-read-tree -m -u $treeDF $treeDFDF &&
      git-ls-files --stage >DFDFcheck.out &&
      diff --unified=0 DFDF.out DFDFcheck.out &&
index 9227254..00c332a 100755 (executable)
@@ -25,7 +25,7 @@ In the test, these paths are used:
 read_tree_twoway () {
     git-read-tree --emu23 "$1" "$2" &&
     git-ls-files --stage &&
-    git-merge-cache git-merge-one-file-script -a &&
+    git-merge-index ../../git-merge-one-file.sh -a &&
     git-ls-files --stage
 }
 
@@ -77,13 +77,13 @@ test_expect_success \
      cat bozbar-old >bozbar &&
      echo rezrov >rezrov &&
      echo yomin >yomin &&
-     git-update-cache --add nitfol bozbar rezrov &&
+     git-update-index --add nitfol bozbar rezrov &&
      treeH=`git-write-tree` &&
      echo treeH $treeH &&
      git-ls-tree $treeH &&
 
      cat bozbar-new >bozbar &&
-     git-update-cache --add frotz bozbar --force-remove rezrov &&
+     git-update-index --add frotz bozbar --force-remove rezrov &&
      git-ls-files --stage >M.out &&
      treeM=`git-write-tree` &&
      echo treeM $treeM &&
@@ -117,8 +117,8 @@ test_expect_success \
     '4 - carry forward local addition.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
-     git-update-cache --add yomin &&
+     git-checkout-index -u -f -q -a &&
+     git-update-index --add yomin &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >4.out || return 1
      diff -u M.out 4.out >4diff.out
@@ -131,9 +131,9 @@ test_expect_success \
     '5 - carry forward local addition.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo yomin >yomin &&
-     git-update-cache --add yomin &&
+     git-update-index --add yomin &&
      echo yomin yomin >yomin &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >5.out || return 1
@@ -147,8 +147,8 @@ test_expect_success \
     '6 - local addition already has the same.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
-     git-update-cache --add frotz &&
+     git-checkout-index -u -f -q -a &&
+     git-update-index --add frotz &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >6.out &&
      diff -u M.out 6.out &&
@@ -160,9 +160,9 @@ test_expect_success \
     '7 - local addition already has the same.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo frotz >frotz &&
-     git-update-cache --add frotz &&
+     git-update-index --add frotz &&
      echo frotz frotz >frotz &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >7.out &&
@@ -173,18 +173,18 @@ test_expect_success \
     '8 - conflicting addition.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo frotz frotz >frotz &&
-     git-update-cache --add frotz &&
+     git-update-index --add frotz &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
 test_expect_success \
     '9 - conflicting addition.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo frotz frotz >frotz &&
-     git-update-cache --add frotz &&
+     git-update-index --add frotz &&
      echo frotz >frotz &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
@@ -192,9 +192,9 @@ test_expect_success \
     '10 - path removed.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo rezrov >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >10.out &&
      diff -u M.out 10.out'
@@ -203,9 +203,9 @@ test_expect_success \
     '11 - dirty path removed.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo rezrov >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      echo rezrov rezrov >rezrov &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
@@ -213,18 +213,18 @@ test_expect_success \
     '12 - unmatching local changes being removed.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo rezrov rezrov >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
 test_expect_success \
     '13 - unmatching local changes being removed.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo rezrov rezrov >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      echo rezrov >rezrov &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
@@ -237,9 +237,9 @@ test_expect_success \
     '14 - unchanged in two heads.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo nitfol nitfol >nitfol &&
-     git-update-cache --add nitfol &&
+     git-update-index --add nitfol &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >14.out || return 1
      diff -u M.out 14.out >14diff.out
@@ -250,9 +250,9 @@ test_expect_success \
     '15 - unchanged in two heads.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo nitfol nitfol >nitfol &&
-     git-update-cache --add nitfol &&
+     git-update-index --add nitfol &&
      echo nitfol nitfol nitfol >nitfol &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >15.out || return 1
@@ -268,9 +268,9 @@ test_expect_success \
     '16 - conflicting local change.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo bozbar bozbar >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      git-read-tree --emu23 $treeH $treeM &&
      check_stages' <<\EOF
 100644 X 1     bozbar
@@ -286,9 +286,9 @@ test_expect_success \
     '17 - conflicting local change.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      echo bozbar bozbar >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      echo bozbar bozbar bozbar >bozbar &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
@@ -296,9 +296,9 @@ test_expect_success \
     '18 - local change already having a good result.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      cat bozbar-new >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >18.out &&
      diff -u M.out 18.out &&
@@ -308,9 +308,9 @@ test_expect_success \
     '19 - local change already having a good result, further modified.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      cat bozbar-new >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      echo gnusto gnusto >bozbar &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >19.out &&
@@ -321,9 +321,9 @@ test_expect_success \
     '20 - no local change, use new tree.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      cat bozbar-old >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >20.out &&
      diff -u M.out 20.out &&
@@ -333,9 +333,9 @@ test_expect_success \
     '21 - no local change, dirty cache.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      cat bozbar-old >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      echo gnusto gnusto >bozbar &&
      if read_tree_twoway $treeH $treeM; then false; else :; fi'
 
@@ -348,9 +348,9 @@ test_expect_success \
     '22 - local change cache updated.' \
     'rm -f .git/index &&
      git-read-tree $treeH &&
-     git-checkout-cache -u -f -q -a &&
+     git-checkout-index -u -f -q -a &&
      sed -e "s/such as/SUCH AS/" bozbar-old >bozbar &&
-     git-update-cache --add bozbar &&
+     git-update-index --add bozbar &&
      read_tree_twoway $treeH $treeM &&
      git-ls-files --stage >22.out || return 1
      diff -u M.out 22.out >22diff.out
@@ -362,7 +362,7 @@ test_expect_success \
     'DF vs DF/DF case setup.' \
     'rm -f .git/index &&
      echo DF >DF &&
-     git-update-cache --add DF &&
+     git-update-index --add DF &&
      treeDF=`git-write-tree` &&
      echo treeDF $treeDF &&
      git-ls-tree $treeDF &&
@@ -371,7 +371,7 @@ test_expect_success \
      rm -f DF &&
      mkdir DF &&
      echo DF/DF >DF/DF &&
-     git-update-cache --add --remove DF DF/DF &&
+     git-update-index --add --remove DF DF/DF &&
      treeDFDF=`git-write-tree` &&
      echo treeDFDF $treeDFDF &&
      git-ls-tree $treeDFDF &&
@@ -382,7 +382,7 @@ test_expect_success \
     'rm -f .git/index &&
      rm -fr DF &&
      echo DF >DF &&
-     git-update-cache --add DF &&
+     git-update-index --add DF &&
      read_tree_twoway $treeDF $treeDFDF &&
      git-ls-files --stage >DFDFcheck.out &&
      diff -u DFDF.out DFDFcheck.out &&
@@ -396,7 +396,7 @@ test_expect_success \
      rm -fr DF &&
      mkdir DF &&
      echo DF/DF >DF/DF &&
-     git-update-cache --add DF/DF &&
+     git-update-index --add DF/DF &&
      read_tree_twoway $treeDFDF $treeDF &&
      git-ls-files --stage >DFDFcheck.out &&
      diff -u DF.out DFDFcheck.out &&
@@ -411,7 +411,7 @@ test_expect_success \
      rm -fr DF &&
      mkdir DF &&
      echo DF/DF >DF/DF &&
-     git-update-cache --add DF/DF &&
+     git-update-index --add DF/DF &&
      # This should fail because I and H have a conflict
      # at DF.
      if git-read-tree --emu23 $treeDF $treeDFDF
index a2c4260..03ea4de 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Junio C Hamano
 #
 
-test_description='git-checkout-cache test.
+test_description='git-checkout-index test.
 
 This test registers the following filesystem structure in the
 cache:
@@ -16,7 +16,7 @@ And then tries to checkout in a work tree that has the following:
     path0/file0 - a file in a directory
     path1       - a file
 
-The git-checkout-cache command should fail when attempting to checkout
+The git-checkout-index command should fail when attempting to checkout
 path0, finding it is occupied by a directory, and path1/file1, finding
 path1 is occupied by a non-directory.  With "-f" flag, it should remove
 the conflicting paths and succeed.
@@ -28,8 +28,8 @@ mkdir path1
 date >path1/file1
 
 test_expect_success \
-    'git-update-cache --add various paths.' \
-    'git-update-cache --add path0 path1/file1'
+    'git-update-index --add various paths.' \
+    'git-update-index --add path0 path1/file1'
 
 rm -fr path0 path1
 mkdir path0
@@ -37,15 +37,15 @@ date >path0/file0
 date >path1
 
 test_expect_failure \
-    'git-checkout-cache without -f should fail on conflicting work tree.' \
-    'git-checkout-cache -a'
+    'git-checkout-index without -f should fail on conflicting work tree.' \
+    'git-checkout-index -a'
 
 test_expect_success \
-    'git-checkout-cache with -f should succeed.' \
-    'git-checkout-cache -f -a'
+    'git-checkout-index with -f should succeed.' \
+    'git-checkout-index -f -a'
 
 test_expect_success \
-    'git-checkout-cache conflicting paths.' \
+    'git-checkout-index conflicting paths.' \
     'test -f path0 && test -d path1 && test -f path1/file1'
 
 test_done
index f0e3d1d..b1c5263 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Junio C Hamano
 #
 
-test_description='git-checkout-cache test.
+test_description='git-checkout-index test.
 
 This test registers the following filesystem structure in the cache:
 
@@ -36,8 +36,8 @@ show_files() {
 mkdir path0
 date >path0/file0
 test_expect_success \
-    'git-update-cache --add path0/file0' \
-    'git-update-cache --add path0/file0'
+    'git-update-index --add path0/file0' \
+    'git-update-index --add path0/file0'
 test_expect_success \
     'writing tree out with git-write-tree' \
     'tree1=$(git-write-tree)'
@@ -46,8 +46,8 @@ test_debug 'show_files $tree1'
 mkdir path1
 date >path1/file1
 test_expect_success \
-    'git-update-cache --add path1/file1' \
-    'git-update-cache --add path1/file1'
+    'git-update-index --add path1/file1' \
+    'git-update-index --add path1/file1'
 test_expect_success \
     'writing tree out with git-write-tree' \
     'tree2=$(git-write-tree)'
@@ -56,13 +56,13 @@ test_debug 'show_files $tree2'
 rm -fr path1
 test_expect_success \
     'read previously written tree and checkout.' \
-    'git-read-tree -m $tree1 && git-checkout-cache -f -a'
+    'git-read-tree -m $tree1 && git-checkout-index -f -a'
 test_debug 'show_files $tree1'
 
 ln -s path0 path1
 test_expect_success \
-    'git-update-cache --add a symlink.' \
-    'git-update-cache --add path1'
+    'git-update-index --add a symlink.' \
+    'git-update-index --add path1'
 test_expect_success \
     'writing tree out with git-write-tree' \
     'tree3=$(git-write-tree)'
@@ -73,7 +73,7 @@ test_debug 'show_files $tree3'
 
 test_expect_success \
     'read previously written tree and checkout.' \
-    'git-read-tree $tree2 && git-checkout-cache -f -a'
+    'git-read-tree $tree2 && git-checkout-index -f -a'
 test_debug show_files $tree2
 
 test_expect_success \
index 69146ac..4352ddb 100755 (executable)
@@ -3,31 +3,31 @@
 # Copyright (c) 2005 Junio C Hamano
 #
 
-test_description='git-checkout-cache -u test.
+test_description='git-checkout-index -u test.
 
-With -u flag, git-checkout-cache internally runs the equivalent of
-git-update-cache --refresh on the checked out entry.'
+With -u flag, git-checkout-index internally runs the equivalent of
+git-update-index --refresh on the checked out entry.'
 
 . ./test-lib.sh
 
 test_expect_success \
 'preparation' '
 echo frotz >path0 &&
-git-update-cache --add path0 &&
+git-update-index --add path0 &&
 t=$(git-write-tree)'
 
 test_expect_failure \
-'without -u, git-checkout-cache smudges stat information.' '
+'without -u, git-checkout-index smudges stat information.' '
 rm -f path0 &&
 git-read-tree $t &&
-git-checkout-cache -f -a &&
+git-checkout-index -f -a &&
 git-diff-files | diff - /dev/null'
 
 test_expect_success \
-'with -u, git-checkout-cache picks up stat information from new files.' '
+'with -u, git-checkout-index picks up stat information from new files.' '
 rm -f path0 &&
 git-read-tree $t &&
-git-checkout-cache -u -f -a &&
+git-checkout-index -u -f -a &&
 git-diff-files | diff - /dev/null'
 
 test_done
index ed5e4ee..f9bc90a 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Junio C Hamano
 #
 
-test_description='git-checkout-cache --prefix test.
+test_description='git-checkout-index --prefix test.
 
 This test makes sure that --prefix option works as advertised, and
 also verifies that such leading path may contain symlinks, unlike
@@ -17,14 +17,14 @@ test_expect_success \
     'mkdir path1 &&
     echo frotz >path0 &&
     echo rezrov >path1/file1 &&
-    git-update-cache --add path0 path1/file1'
+    git-update-index --add path0 path1/file1'
 
 test_expect_success \
     'have symlink in place where dir is expected.' \
     'rm -fr path0 path1 &&
      mkdir path2 &&
      ln -s path2 path1 &&
-     git-checkout-cache -f -a &&
+     git-checkout-index -f -a &&
      test ! -h path1 && test -d path1 &&
      test -f path1/file1 && test ! -f path2/file1'
 
@@ -32,7 +32,7 @@ test_expect_success \
     'use --prefix=path2/' \
     'rm -fr path0 path1 path2 &&
      mkdir path2 &&
-     git-checkout-cache --prefix=path2/ -f -a &&
+     git-checkout-index --prefix=path2/ -f -a &&
      test -f path2/path0 &&
      test -f path2/path1/file1 &&
      test ! -f path0 &&
@@ -41,7 +41,7 @@ test_expect_success \
 test_expect_success \
     'use --prefix=tmp-' \
     'rm -fr path0 path1 path2 tmp* &&
-     git-checkout-cache --prefix=tmp- -f -a &&
+     git-checkout-index --prefix=tmp- -f -a &&
      test -f tmp-path0 &&
      test -f tmp-path1/file1 &&
      test ! -f path0 &&
@@ -52,7 +52,7 @@ test_expect_success \
     'rm -fr path0 path1 path2 tmp* &&
      echo nitfol >tmp-path1 &&
      mkdir tmp-path0 &&
-     git-checkout-cache --prefix=tmp- -f -a &&
+     git-checkout-index --prefix=tmp- -f -a &&
      test -f tmp-path0 &&
      test -f tmp-path1/file1 &&
      test ! -f path0 &&
@@ -64,7 +64,7 @@ test_expect_success \
     'rm -fr path0 path1 path2 tmp* &&
      mkdir tmp1 tmp1/orary &&
      ln -s tmp1 tmp &&
-     git-checkout-cache --prefix=tmp/orary/ -f -a &&
+     git-checkout-index --prefix=tmp/orary/ -f -a &&
      test -d tmp1/orary &&
      test -f tmp1/orary/path0 &&
      test -f tmp1/orary/path1/file1 &&
@@ -76,7 +76,7 @@ test_expect_success \
     'rm -fr path0 path1 path2 tmp* &&
      mkdir tmp1 &&
      ln -s tmp1 tmp &&
-     git-checkout-cache --prefix=tmp/orary- -f -a &&
+     git-checkout-index --prefix=tmp/orary- -f -a &&
      test -f tmp1/orary-path0 &&
      test -f tmp1/orary-path1/file1 &&
      test -h tmp'
@@ -87,7 +87,7 @@ test_expect_success \
     'rm -fr path0 path1 path2 tmp* &&
      mkdir tmp1 &&
      ln -s tmp1 tmp-path1 &&
-     git-checkout-cache --prefix=tmp- -f -a &&
+     git-checkout-index --prefix=tmp- -f -a &&
      test -f tmp-path0 &&
      test ! -h tmp-path1 &&
      test -d tmp-path1 &&
index 86b7375..5bc0a3b 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Junio C Hamano
 #
 
-test_description='git-update-cache nonsense-path test.
+test_description='git-update-index nonsense-path test.
 
 This test creates the following structure in the cache:
 
@@ -12,7 +12,7 @@ This test creates the following structure in the cache:
     path2/file2 - a file in a directory
     path3/file3 - a file in a directory
 
-and tries to git-update-cache --add the following:
+and tries to git-update-index --add the following:
 
     path0/file0 - a file in a directory
     path1/file1 - a file in a directory
@@ -31,8 +31,8 @@ date >path2/file2
 date >path3/file3
 
 test_expect_success \
-    'git-update-cache --add to add various paths.' \
-    'git-update-cache --add -- path0 path1 path2/file2 path3/file3'
+    'git-update-index --add to add various paths.' \
+    'git-update-index --add -- path0 path1 path2/file2 path3/file3'
 
 rm -fr path?
 
@@ -45,7 +45,7 @@ date >path1/file1
 for p in path0/file0 path1/file1 path2 path3
 do
        test_expect_failure \
-           "git-update-cache to add conflicting path $p should fail." \
-           "git-update-cache --add -- $p"
+           "git-update-index to add conflicting path $p should fail." \
+           "git-update-index --add -- $p"
 done
 test_done
index c4d6d21..2e18baa 100755 (executable)
@@ -33,8 +33,8 @@ mkdir path2 path3
 date >path2/file2
 date >path3/file3
 test_expect_success \
-    'git-update-cache --add to add various paths.' \
-    "git-update-cache --add -- path0 path1 path?/file?"
+    'git-update-index --add to add various paths.' \
+    "git-update-index --add -- path0 path1 path?/file?"
 
 rm -fr path?
 date >path2
index 61a7c7f..c6ce56c 100755 (executable)
@@ -27,7 +27,7 @@ test_expect_success \
      ln -s ../path1 path2/bazbo &&
      echo Mi >path2/baz/b &&
      find path? \( -type f -o -type l \) -print |
-     xargs git-update-cache --add &&
+     xargs git-update-index --add &&
      tree=`git-write-tree` &&
      echo $tree'
 
index 3accb14..91015d7 100755 (executable)
@@ -16,7 +16,7 @@ chmod +x path1
 
 test_expect_success \
     'update-cache --add two files with and without +x.' \
-    'git-update-cache --add path0 path1'
+    'git-update-index --add path0 path1'
 
 mv path0 path0-
 sed -e 's/line/Line/' <path0- >path0
index 80edae6..be47485 100755 (executable)
@@ -27,7 +27,7 @@ Line 15
 
 test_expect_success \
     'update-cache --add a file.' \
-    'git-update-cache --add path0'
+    'git-update-index --add path0'
 
 test_expect_success \
     'write that tree.' \
@@ -37,11 +37,11 @@ sed -e 's/line/Line/' <path0 >path1
 rm -f path0
 test_expect_success \
     'renamed and edited the file.' \
-    'git-update-cache --add --remove path0 path1'
+    'git-update-index --add --remove path0 path1'
 
 test_expect_success \
-    'git-diff-cache -p -M after rename and editing.' \
-    'git-diff-cache -p -M $tree >current'
+    'git-diff-index -p -M after rename and editing.' \
+    'git-diff-index -p -M $tree >current'
 cat >expected <<\EOF
 diff --git a/path0 b/path1
 rename from path0
index 2ec2961..769274a 100755 (executable)
@@ -171,28 +171,28 @@ test_expect_success \
 test_expect_success \
     'diff-cache O with A in cache' \
     'git-read-tree $tree_A &&
-     git-diff-cache --cached $tree_O >.test-a &&
+     git-diff-index --cached $tree_O >.test-a &&
      cmp -s .test-a .test-recursive-OA'
 
 test_expect_success \
     'diff-cache O with B in cache' \
     'git-read-tree $tree_B &&
-     git-diff-cache --cached $tree_O >.test-a &&
+     git-diff-index --cached $tree_O >.test-a &&
      cmp -s .test-a .test-recursive-OB'
 
 test_expect_success \
     'diff-cache A with B in cache' \
     'git-read-tree $tree_B &&
-     git-diff-cache --cached $tree_A >.test-a &&
+     git-diff-index --cached $tree_A >.test-a &&
      cmp -s .test-a .test-recursive-AB'
 
 test_expect_success \
     'diff-files with O in cache and A checked out' \
     'rm -fr Z [A-Z][A-Z] &&
      git-read-tree $tree_A &&
-     git-checkout-cache -f -a &&
+     git-checkout-index -f -a &&
      git-read-tree -m $tree_O || return 1
-     git-update-cache --refresh >/dev/null ;# this can exit non-zero
+     git-update-index --refresh >/dev/null ;# this can exit non-zero
      git-diff-files >.test-a &&
      cmp_diff_files_output .test-a .test-recursive-OA'
 
@@ -200,9 +200,9 @@ test_expect_success \
     'diff-files with O in cache and B checked out' \
     'rm -fr Z [A-Z][A-Z] &&
      git-read-tree $tree_B &&
-     git-checkout-cache -f -a &&
+     git-checkout-index -f -a &&
      git-read-tree -m $tree_O || return 1
-     git-update-cache --refresh >/dev/null ;# this can exit non-zero
+     git-update-index --refresh >/dev/null ;# this can exit non-zero
      git-diff-files >.test-a &&
      cmp_diff_files_output .test-a .test-recursive-OB'
 
@@ -210,9 +210,9 @@ test_expect_success \
     'diff-files with A in cache and B checked out' \
     'rm -fr Z [A-Z][A-Z] &&
      git-read-tree $tree_B &&
-     git-checkout-cache -f -a &&
+     git-checkout-index -f -a &&
      git-read-tree -m $tree_A || return 1
-     git-update-cache --refresh >/dev/null ;# this can exit non-zero
+     git-update-index --refresh >/dev/null ;# this can exit non-zero
      git-diff-files >.test-a &&
      cmp_diff_files_output .test-a .test-recursive-AB'
 
index 8e3091a..2751970 100755 (executable)
@@ -13,7 +13,7 @@ test_expect_success \
     'prepare reference tree' \
     'cat ../../COPYING >COPYING &&
      echo frotz >rezrov &&
-    git-update-cache --add COPYING rezrov &&
+    git-update-index --add COPYING rezrov &&
     tree=$(git-write-tree) &&
     echo $tree'
 
@@ -22,14 +22,14 @@ test_expect_success \
     'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
     sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
     rm -f COPYING &&
-    git-update-cache --add --remove COPYING COPYING.?'
+    git-update-index --add --remove COPYING COPYING.?'
 
 # tree has COPYING and rezrov.  work tree has COPYING.1 and COPYING.2,
 # both are slightly edited, and unchanged rezrov.  So we say you
 # copy-and-edit one, and rename-and-edit the other.  We do not say
 # anything about rezrov.
 
-GIT_DIFF_OPTS=--unified=0 git-diff-cache -M -p $tree >current
+GIT_DIFF_OPTS=--unified=0 git-diff-index -M -p $tree >current
 cat >expected <<\EOF
 diff --git a/COPYING b/COPYING.1
 copy from COPYING
@@ -62,14 +62,14 @@ test_expect_success \
 test_expect_success \
     'prepare work tree again' \
     'mv COPYING.2 COPYING &&
-     git-update-cache --add --remove COPYING COPYING.1 COPYING.2'
+     git-update-index --add --remove COPYING COPYING.1 COPYING.2'
 
 # tree has COPYING and rezrov.  work tree has COPYING and COPYING.1,
 # both are slightly edited, and unchanged rezrov.  So we say you
 # edited one, and copy-and-edit the other.  We do not say
 # anything about rezrov.
 
-GIT_DIFF_OPTS=--unified=0 git-diff-cache -C -p $tree >current
+GIT_DIFF_OPTS=--unified=0 git-diff-index -C -p $tree >current
 cat >expected <<\EOF
 diff --git a/COPYING b/COPYING
 --- a/COPYING
@@ -100,16 +100,16 @@ test_expect_success \
 test_expect_success \
     'prepare work tree once again' \
     'cat ../../COPYING >COPYING &&
-     git-update-cache --add --remove COPYING COPYING.1'
+     git-update-index --add --remove COPYING COPYING.1'
 
 # tree has COPYING and rezrov.  work tree has COPYING and COPYING.1,
 # but COPYING is not edited.  We say you copy-and-edit COPYING.1; this
 # is only possible because -C mode now reports the unmodified file to
 # the diff-core.  Unchanged rezrov, although being fed to
-# git-diff-cache as well, should not be mentioned.
+# git-diff-index as well, should not be mentioned.
 
 GIT_DIFF_OPTS=--unified=0 \
-    git-diff-cache -C --find-copies-harder -p $tree >current
+    git-diff-index -C --find-copies-harder -p $tree >current
 cat >expected <<\EOF
 diff --git a/COPYING b/COPYING.1
 copy from COPYING
index 010dd87..f59614a 100755 (executable)
@@ -15,7 +15,7 @@ test_expect_success \
     'prepare reference tree' \
     'echo xyzzy | tr -d '\\\\'012 >yomin &&
      ln -s xyzzy frotz &&
-    git-update-cache --add frotz yomin &&
+    git-update-index --add frotz yomin &&
     tree=$(git-write-tree) &&
     echo $tree'
 
@@ -25,7 +25,7 @@ test_expect_success \
      rm -f yomin &&
      ln -s xyzzy nitfol &&
      ln -s xzzzy bozbar &&
-    git-update-cache --add --remove frotz rezrov nitfol bozbar yomin'
+    git-update-index --add --remove frotz rezrov nitfol bozbar yomin'
 
 # tree has frotz pointing at xyzzy, and yomin that contains xyzzy to
 # confuse things.  work tree has rezrov (xyzzy) nitfol (xyzzy) and
@@ -33,7 +33,7 @@ test_expect_success \
 # rezrov and nitfol are rename/copy of frotz and bozbar should be
 # a new creation.
 
-GIT_DIFF_OPTS=--unified=0 git-diff-cache -M -p $tree >current
+GIT_DIFF_OPTS=--unified=0 git-diff-index -M -p $tree >current
 cat >expected <<\EOF
 diff --git a/bozbar b/bozbar
 new file mode 120000
index cee06e4..5636f4f 100755 (executable)
@@ -13,7 +13,7 @@ test_expect_success \
     'prepare reference tree' \
     'cat ../../COPYING >COPYING &&
      echo frotz >rezrov &&
-    git-update-cache --add COPYING rezrov &&
+    git-update-index --add COPYING rezrov &&
     tree=$(git-write-tree) &&
     echo $tree'
 
@@ -22,14 +22,14 @@ test_expect_success \
     'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
     sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
     rm -f COPYING &&
-    git-update-cache --add --remove COPYING COPYING.?'
+    git-update-index --add --remove COPYING COPYING.?'
 
 # tree has COPYING and rezrov.  work tree has COPYING.1 and COPYING.2,
 # both are slightly edited, and unchanged rezrov.  We say COPYING.1
 # and COPYING.2 are based on COPYING, and do not say anything about
 # rezrov.
 
-git-diff-cache -M $tree >current
+git-diff-index -M $tree >current
 
 cat >expected <<\EOF
 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
@@ -77,14 +77,14 @@ test_expect_success \
 test_expect_success \
     'prepare work tree again' \
     'mv COPYING.2 COPYING &&
-     git-update-cache --add --remove COPYING COPYING.1 COPYING.2'
+     git-update-index --add --remove COPYING COPYING.1 COPYING.2'
 
 # tree has COPYING and rezrov.  work tree has COPYING and COPYING.1,
 # both are slightly edited, and unchanged rezrov.  We say COPYING.1
 # is based on COPYING and COPYING is still there, and do not say anything
 # about rezrov.
 
-git-diff-cache -C $tree >current
+git-diff-index -C $tree >current
 cat >expected <<\EOF
 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M     COPYING
 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
@@ -134,9 +134,9 @@ test_expect_success \
 test_expect_success \
     'prepare work tree once again' \
     'cat ../../COPYING >COPYING &&
-     git-update-cache --add --remove COPYING COPYING.1'
+     git-update-index --add --remove COPYING COPYING.1'
 
-git-diff-cache -C --find-copies-harder $tree >current
+git-diff-index -C --find-copies-harder $tree >current
 cat >expected <<\EOF
 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
 EOF
index 90fd21f..e2a67e9 100755 (executable)
@@ -11,15 +11,15 @@ test_description='Test mode change diffs.
 test_expect_success \
     'setup' \
     'echo frotz >rezrov &&
-     git-update-cache --add rezrov &&
+     git-update-index --add rezrov &&
      tree=`git-write-tree` &&
      echo $tree'
 
 test_expect_success \
     'chmod' \
     'chmod +x rezrov &&
-     git-update-cache rezrov &&
-     git-diff-cache $tree >current'
+     git-update-index rezrov &&
+     git-diff-index $tree >current'
 
 _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
index 042390a..bb6ba69 100755 (executable)
@@ -13,20 +13,20 @@ test_expect_success \
     'prepare reference tree' \
     'mkdir path0 path1 &&
      cp ../../COPYING path0/COPYING &&
-     git-update-cache --add path0/COPYING &&
+     git-update-index --add path0/COPYING &&
     tree=$(git-write-tree) &&
     echo $tree'
 
 test_expect_success \
     'prepare work tree' \
     'cp path0/COPYING path1/COPYING &&
-     git-update-cache --add --remove path0/COPYING path1/COPYING'
+     git-update-index --add --remove path0/COPYING path1/COPYING'
 
 # In the tree, there is only path0/COPYING.  In the cache, path0 and
 # path1 both have COPYING and the latter is a copy of path0/COPYING.
 # Comparing the full tree with cache should tell us so.
 
-git-diff-cache -C --find-copies-harder $tree >current
+git-diff-index -C --find-copies-harder $tree >current
 
 cat >expected <<\EOF
 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100  path0/COPYING   path1/COPYING
@@ -42,7 +42,7 @@ test_expect_success \
 # path1/COPYING suddenly appearing from nowhere, not detected as
 # a copy from path0/COPYING.
 
-git-diff-cache -C $tree path1 >current
+git-diff-index -C $tree path1 >current
 
 cat >expected <<\EOF
 :000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A     path1/COPYING
@@ -55,14 +55,14 @@ test_expect_success \
 test_expect_success \
     'tweak work tree' \
     'rm -f path0/COPYING &&
-     git-update-cache --remove path0/COPYING'
+     git-update-index --remove path0/COPYING'
 
 # In the tree, there is only path0/COPYING.  In the cache, path0 does
 # not have COPYING anymore and path1 has COPYING which is a copy of
 # path0/COPYING.  Showing the full tree with cache should tell us about
 # the rename.
 
-git-diff-cache -C $tree >current
+git-diff-index -C $tree >current
 
 cat >expected <<\EOF
 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100  path0/COPYING   path1/COPYING
@@ -77,7 +77,7 @@ test_expect_success \
 # path0/COPYING.  When we say we care only about path1, we should just
 # see path1/COPYING appearing from nowhere.
 
-git-diff-cache -C $tree path1 >current
+git-diff-index -C $tree path1 >current
 
 cat >expected <<\EOF
 :000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A     path1/COPYING
index 4c971c9..263ac1e 100755 (executable)
@@ -28,7 +28,7 @@ test_expect_success \
     setup \
     'cat ../../README >file0 &&
      cat ../../COPYING >file1 &&
-    git-update-cache --add file0 file1 &&
+    git-update-index --add file0 file1 &&
     tree=$(git-write-tree) &&
     echo "$tree"'
 
@@ -36,11 +36,11 @@ test_expect_success \
     'change file1 with copy-edit of file0 and remove file0' \
     'sed -e "s/git/GIT/" file0 >file1 &&
      rm -f file0 &&
-    git-update-cache --remove file0 file1'
+    git-update-index --remove file0 file1'
 
 test_expect_success \
     'run diff with -B' \
-    'git-diff-cache -B --cached "$tree" >current'
+    'git-diff-index -B --cached "$tree" >current'
 
 cat >expected <<\EOF
 :100644 000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 0000000000000000000000000000000000000000 D     file0
@@ -53,7 +53,7 @@ test_expect_success \
 
 test_expect_success \
     'run diff with -B and -M' \
-    'git-diff-cache -B -M "$tree" >current'
+    'git-diff-index -B -M "$tree" >current'
 
 cat >expected <<\EOF
 :100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c R100  file0   file1
@@ -67,15 +67,15 @@ test_expect_success \
     'swap file0 and file1' \
     'rm -f file0 file1 &&
      git-read-tree -m $tree &&
-     git-checkout-cache -f -u -a &&
+     git-checkout-index -f -u -a &&
      mv file0 tmp &&
      mv file1 file0 &&
      mv tmp file1 &&
-     git-update-cache file0 file1'
+     git-update-index file0 file1'
 
 test_expect_success \
     'run diff with -B' \
-    'git-diff-cache -B "$tree" >current'
+    'git-diff-index -B "$tree" >current'
 
 cat >expected <<\EOF
 :100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 6ff87c4664981e4397625791c8ea3bbb5f2279a3 M100  file0
@@ -88,7 +88,7 @@ test_expect_success \
 
 test_expect_success \
     'run diff with -B and -M' \
-    'git-diff-cache -B -M "$tree" >current'
+    'git-diff-index -B -M "$tree" >current'
 
 cat >expected <<\EOF
 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100  file1   file0
@@ -103,11 +103,11 @@ test_expect_success \
     'make file0 into something completely different' \
     'rm -f file0 &&
      ln -s frotz file0 &&
-     git-update-cache file0 file1'
+     git-update-index file0 file1'
 
 test_expect_success \
     'run diff with -B' \
-    'git-diff-cache -B "$tree" >current'
+    'git-diff-index -B "$tree" >current'
 
 cat >expected <<\EOF
 :100644 120000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 67be421f88824578857624f7b3dc75e99a8a1481 T     file0
@@ -120,7 +120,7 @@ test_expect_success \
 
 test_expect_success \
     'run diff with -B' \
-    'git-diff-cache -B -M "$tree" >current'
+    'git-diff-index -B -M "$tree" >current'
 
 # This should not mistake file0 as the copy source of new file1
 # due to type differences.
@@ -135,7 +135,7 @@ test_expect_success \
 
 test_expect_success \
     'run diff with -M' \
-    'git-diff-cache -M "$tree" >current'
+    'git-diff-index -M "$tree" >current'
 
 # This should not mistake file0 as the copy source of new file1
 # due to type differences.
@@ -152,15 +152,15 @@ test_expect_success \
     'file1 edited to look like file0 and file0 rename-edited to file2' \
     'rm -f file0 file1 &&
      git-read-tree -m $tree &&
-     git-checkout-cache -f -u -a &&
+     git-checkout-index -f -u -a &&
      sed -e "s/git/GIT/" file0 >file1 &&
      sed -e "s/git/GET/" file0 >file2 &&
      rm -f file0
-     git-update-cache --add --remove file0 file1 file2'
+     git-update-index --add --remove file0 file1 file2'
 
 test_expect_success \
     'run diff with -B' \
-    'git-diff-cache -B "$tree" >current'
+    'git-diff-index -B "$tree" >current'
 
 cat >expected <<\EOF
 :100644 000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 0000000000000000000000000000000000000000 D     file0
@@ -174,7 +174,7 @@ test_expect_success \
 
 test_expect_success \
     'run diff with -B -M' \
-    'git-diff-cache -B -M "$tree" >current'
+    'git-diff-index -B -M "$tree" >current'
 
 cat >expected <<\EOF
 :100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c C095  file0   file1
index 6229a5b..ea81152 100755 (executable)
@@ -13,7 +13,7 @@ test_expect_success \
     'prepare reference tree' \
     'cat ../../COPYING >COPYING &&
      echo frotz >rezrov &&
-    git-update-cache --add COPYING rezrov &&
+    git-update-index --add COPYING rezrov &&
     tree=$(git-write-tree) &&
     echo $tree'
 
@@ -22,14 +22,14 @@ test_expect_success \
     'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
     sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
     rm -f COPYING &&
-    git-update-cache --add --remove COPYING COPYING.?'
+    git-update-index --add --remove COPYING COPYING.?'
 
 # tree has COPYING and rezrov.  work tree has COPYING.1 and COPYING.2,
 # both are slightly edited, and unchanged rezrov.  We say COPYING.1
 # and COPYING.2 are based on COPYING, and do not say anything about
 # rezrov.
 
-git-diff-cache -z -M $tree >current
+git-diff-index -z -M $tree >current
 
 cat >expected <<\EOF
 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
@@ -81,14 +81,14 @@ test_expect_success \
 test_expect_success \
     'prepare work tree again' \
     'mv COPYING.2 COPYING &&
-     git-update-cache --add --remove COPYING COPYING.1 COPYING.2'
+     git-update-index --add --remove COPYING COPYING.1 COPYING.2'
 
 # tree has COPYING and rezrov.  work tree has COPYING and COPYING.1,
 # both are slightly edited, and unchanged rezrov.  We say COPYING.1
 # is based on COPYING and COPYING is still there, and do not say anything
 # about rezrov.
 
-git-diff-cache -z -C $tree >current
+git-diff-index -z -C $tree >current
 cat >expected <<\EOF
 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M
 COPYING
@@ -141,9 +141,9 @@ test_expect_success \
 test_expect_success \
     'prepare work tree once again' \
     'cat ../../COPYING >COPYING &&
-     git-update-cache --add --remove COPYING COPYING.1'
+     git-update-index --add --remove COPYING COPYING.1'
 
-git-diff-cache -z -C --find-copies-harder $tree >current
+git-diff-index -z -C --find-copies-harder $tree >current
 cat >expected <<\EOF
 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
 COPYING
index 9f2c6f6..8db329d 100755 (executable)
@@ -17,18 +17,18 @@ test_expect_success \
     'echo frotz >file0 &&
      mkdir path1 &&
      echo rezrov >path1/file1 &&
-     git-update-cache --add file0 path1/file1 &&
+     git-update-index --add file0 path1/file1 &&
      tree=`git-write-tree` &&
      echo "$tree" &&
      echo nitfol >file0 &&
      echo yomin >path1/file1 &&
-     git-update-cache file0 path1/file1' 
+     git-update-index file0 path1/file1'
 
 cat >expected <<\EOF
 EOF
 test_expect_success \
     'limit to path should show nothing' \
-    'git-diff-cache --cached $tree path >current &&
+    'git-diff-index --cached $tree path >current &&
      compare_diff_raw current expected'
 
 cat >expected <<\EOF
@@ -36,7 +36,7 @@ cat >expected <<\EOF
 EOF
 test_expect_success \
     'limit to path1 should show path1/file1' \
-    'git-diff-cache --cached $tree path1 >current &&
+    'git-diff-index --cached $tree path1 >current &&
      compare_diff_raw current expected'
 
 cat >expected <<\EOF
@@ -44,7 +44,7 @@ cat >expected <<\EOF
 EOF
 test_expect_success \
     'limit to path1/ should show path1/file1' \
-    'git-diff-cache --cached $tree path1/ >current &&
+    'git-diff-index --cached $tree path1/ >current &&
      compare_diff_raw current expected'
 
 cat >expected <<\EOF
@@ -52,14 +52,14 @@ cat >expected <<\EOF
 EOF
 test_expect_success \
     'limit to file0 should show file0' \
-    'git-diff-cache --cached $tree file0 >current &&
+    'git-diff-index --cached $tree file0 >current &&
      compare_diff_raw current expected'
 
 cat >expected <<\EOF
 EOF
 test_expect_success \
     'limit to file0/ should emit nothing.' \
-    'git-diff-cache --cached $tree file0/ >current &&
+    'git-diff-index --cached $tree file0/ >current &&
      compare_diff_raw current expected'
 
 test_done
index f591a56..530cc4d 100755 (executable)
@@ -26,7 +26,7 @@ echo 'This is foo' >foo
 chmod +x foo
 
 test_expect_success setup \
-    'git-update-cache --add foo'
+    'git-update-index --add foo'
 
 test_expect_success apply \
     'git-apply --index --stat --summary --apply test-patch'
index 906188c..a06f695 100755 (executable)
@@ -139,7 +139,7 @@ rename to include/arch/m32r/klibc/archsetjmp.h
 +#endif /* _KLIBC_ARCHSETJMP_H */
 EOF
 
-find include klibc -type f -print | xargs git-update-cache --add --
+find include klibc -type f -print | xargs git-update-index --add --
 
 test_expect_success 'check rename/copy patch' 'git-apply --check patch'
 
index abce669..6bf3406 100755 (executable)
@@ -37,8 +37,8 @@ test_expect_success \
 
 test_expect_success \
     'add files to repository' \
-    'find a -type f | xargs git-update-cache --add &&
-     find a -type l | xargs git-update-cache --add &&
+    'find a -type f | xargs git-update-index --add &&
+     find a -type l | xargs git-update-index --add &&
      treeid=`git-write-tree` &&
      echo $treeid >treeid &&
      TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
index 0395124..bb62336 100755 (executable)
@@ -16,9 +16,9 @@ test_expect_success \
      for i in a b c
      do
             dd if=/dev/zero bs=4k count=1 | tr "\\0" $i >$i &&
-            git-update-cache --add $i || return 1
+            git-update-index --add $i || return 1
      done &&
-     cat c >d && echo foo >>d && git-update-cache --add d &&
+     cat c >d && echo foo >>d && git-update-index --add d &&
      tree=`git-write-tree` &&
      commit=`git-commit-tree $tree </dev/null` && {
         echo $tree &&
index 2c142df..fb8320d 100755 (executable)
@@ -21,9 +21,9 @@ test_expect_success setup '
            parent=$commit || return 1
        done &&
        echo "$commit" >.git/HEAD &&
-       git clone -l ./. victim &&
+       git-clone.sh -l ./. victim &&
        cd victim &&
-       git log &&
+       git-log.sh &&
        cd .. &&
        echo $zero >.git/HEAD &&
        parent=$zero &&
@@ -35,7 +35,7 @@ test_expect_success setup '
        done &&
        echo "$commit" >.git/HEAD &&
        echo Rebase &&
-       git log'
+       git-log.sh'
 
 test_expect_success \
         'pushing rewound head should not barf but require --force' ' 
index 7fe744e..0101242 100755 (executable)
@@ -45,7 +45,7 @@ grep_stderr()
 }
 
 date >path0
-git-update-cache --add path0
+git-update-index --add path0
 save_tag tree git-write-tree
 on_committer_date "1971-08-16 00:00:00" hide_error save_tag root unique_commit root tree
 on_committer_date "1971-08-16 00:00:01" save_tag l0 unique_commit l0 tree -p root
index 99d86ae..d0a4ff2 100755 (executable)
@@ -40,7 +40,7 @@ test_bisection_diff()
 }
 
 date >path0
-git-update-cache --add path0
+git-update-index --add path0
 save_tag tree git-write-tree
 on_committer_date "1971-08-16 00:00:00" hide_error save_tag root unique_commit root tree
 on_committer_date "1971-08-16 00:00:01" save_tag l0 unique_commit l0 tree -p root
index eb41f86..88d14ee 100755 (executable)
@@ -14,7 +14,7 @@ list_duplicates()
 }
 
 date >path0
-git-update-cache --add path0
+git-update-index --add path0
 save_tag tree git-write-tree
 on_committer_date "1971-08-16 00:00:00" hide_error save_tag root unique_commit root tree
 on_committer_date "1971-08-16 00:00:01" save_tag l0 unique_commit l0 tree -p root
index 4f57a28..1beab71 100644 (file)
@@ -9,7 +9,7 @@ test_description='Test git-rev-parse with different parent options'
 . ../t6000lib.sh # t6xxx specific functions
 
 date >path0
-git-update-cache --add path0
+git-update-index --add path0
 save_tag tree git-write-tree
 hide_error save_tag start unique_commit "start" tree
 save_tag second unique_commit "second" tree -p start
index 029f897..643822d 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # An example hook script to check the commit log message.
-# Called by git-commit-script with one argument, the name of the file
+# Called by git-commit with one argument, the name of the file
 # that has the commit message.  The hook should exit with non-zero
 # status after issuing an appropriate message if it wants to stop the
 # commit.  The hook is allowed to edit the commit message file.
index 075eb3c..4bb6803 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # An example hook script to verify what is about to be committed.
-# Called by git-commit-script with no arguments.  The hook should
+# Called by git-commit with no arguments.  The hook should
 # exit with non-zero status after issuing an appropriate message if
 # it wants to stop the commit.
 #
@@ -31,7 +31,7 @@ perl -e '
        print STDERR "* $why (line $lineno)\n";
        print STDERR "$filename:$lineno:$line\n";
     }
-    open $fh, "-|", qw(git-diff-cache -p -M --cached HEAD);
+    open $fh, "-|", qw(git-diff-index -p -M --cached HEAD);
     while (<$fh>) {
        if (m|^diff --git a/(.*) b/\1$|) {
            $filename = $1;
diff --git a/update-cache.c b/update-cache.c
deleted file mode 100644 (file)
index 3d1fd2b..0000000
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * GIT - The information manager from hell
- *
- * Copyright (C) Linus Torvalds, 2005
- */
-#include "cache.h"
-
-/*
- * Default to not allowing changes to the list of files. The
- * tool doesn't actually care, but this makes it harder to add
- * files to the revision control by mistake by doing something
- * like "git-update-cache *" and suddenly having all the object
- * files be revision controlled.
- */
-static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new = 0, quiet = 0, info_only = 0;
-static int force_remove;
-
-/* Three functions to allow overloaded pointer return; see linux/err.h */
-static inline void *ERR_PTR(long error)
-{
-       return (void *) error;
-}
-
-static inline long PTR_ERR(const void *ptr)
-{
-       return (long) ptr;
-}
-
-static inline long IS_ERR(const void *ptr)
-{
-       return (unsigned long)ptr > (unsigned long)-1000L;
-}
-
-static int add_file_to_cache(char *path)
-{
-       int size, namelen, option, status;
-       struct cache_entry *ce;
-       struct stat st;
-       int fd;
-       char *target;
-
-       status = lstat(path, &st);
-       if (status < 0 || S_ISDIR(st.st_mode)) {
-               /* When we used to have "path" and now we want to add
-                * "path/file", we need a way to remove "path" before
-                * being able to add "path/file".  However,
-                * "git-update-cache --remove path" would not work.
-                * --force-remove can be used but this is more user
-                * friendly, especially since we can do the opposite
-                * case just fine without --force-remove.
-                */
-               if (status == 0 || (errno == ENOENT || errno == ENOTDIR)) {
-                       if (allow_remove)
-                               return remove_file_from_cache(path);
-               }
-               if (0 == status)
-                       return error("%s: is a directory", path);
-               else
-                       return error("lstat(\"%s\"): %s", path,
-                                    strerror(errno));
-       }
-       namelen = strlen(path);
-       size = cache_entry_size(namelen);
-       ce = xmalloc(size);
-       memset(ce, 0, size);
-       memcpy(ce->name, path, namelen);
-       fill_stat_cache_info(ce, &st);
-       ce->ce_mode = create_ce_mode(st.st_mode);
-       ce->ce_flags = htons(namelen);
-       switch (st.st_mode & S_IFMT) {
-       case S_IFREG:
-               fd = open(path, O_RDONLY);
-               if (fd < 0)
-                       return -1;
-               if (index_fd(ce->sha1, fd, &st, !info_only, NULL) < 0)
-                       return -1;
-               break;
-       case S_IFLNK:
-               target = xmalloc(st.st_size+1);
-               if (readlink(path, target, st.st_size+1) != st.st_size) {
-                       free(target);
-                       return -1;
-               }
-               if (info_only) {
-                       unsigned char hdr[50];
-                       int hdrlen;
-                       write_sha1_file_prepare(target, st.st_size, "blob",
-                                               ce->sha1, hdr, &hdrlen);
-               } else if (write_sha1_file(target, st.st_size, "blob", ce->sha1))
-                       return -1;
-               free(target);
-               break;
-       default:
-               return -1;
-       }
-       option = allow_add ? ADD_CACHE_OK_TO_ADD : 0;
-       option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;
-       return add_cache_entry(ce, option);
-}
-
-static int compare_data(struct cache_entry *ce, struct stat *st)
-{
-       int match = -1;
-       int fd = open(ce->name, O_RDONLY);
-
-       if (fd >= 0) {
-               unsigned char sha1[20];
-               if (!index_fd(sha1, fd, st, 0, NULL))
-                       match = memcmp(sha1, ce->sha1, 20);
-               close(fd);
-       }
-       return match;
-}
-
-static int compare_link(struct cache_entry *ce, unsigned long expected_size)
-{
-       int match = -1;
-       char *target;
-       void *buffer;
-       unsigned long size;
-       char type[10];
-       int len;
-
-       target = xmalloc(expected_size);
-       len = readlink(ce->name, target, expected_size);
-       if (len != expected_size) {
-               free(target);
-               return -1;
-       }
-       buffer = read_sha1_file(ce->sha1, type, &size);
-       if (!buffer) {
-               free(target);
-               return -1;
-       }
-       if (size == expected_size)
-               match = memcmp(buffer, target, size);
-       free(buffer);
-       free(target);
-       return match;
-}
-
-/*
- * "refresh" does not calculate a new sha1 file or bring the
- * cache up-to-date for mode/content changes. But what it
- * _does_ do is to "re-match" the stat information of a file
- * with the cache, so that you can refresh the cache for a
- * file that hasn't been changed but where the stat entry is
- * out of date.
- *
- * For example, you'd want to do this after doing a "git-read-tree",
- * to link up the stat cache details with the proper files.
- */
-static struct cache_entry *refresh_entry(struct cache_entry *ce)
-{
-       struct stat st;
-       struct cache_entry *updated;
-       int changed, size;
-
-       if (lstat(ce->name, &st) < 0)
-               return ERR_PTR(-errno);
-
-       changed = ce_match_stat(ce, &st);
-       if (!changed)
-               return ce;
-
-       /*
-        * If the mode or type has changed, there's no point in trying
-        * to refresh the entry - it's not going to match
-        */
-       if (changed & (MODE_CHANGED | TYPE_CHANGED))
-               return ERR_PTR(-EINVAL);
-
-       switch (st.st_mode & S_IFMT) {
-       case S_IFREG:
-               if (compare_data(ce, &st))
-                       return ERR_PTR(-EINVAL);
-               break;
-       case S_IFLNK:
-               if (compare_link(ce, st.st_size))
-                       return ERR_PTR(-EINVAL);
-               break;
-       default:
-               return ERR_PTR(-EINVAL);
-       }
-
-       size = ce_size(ce);
-       updated = xmalloc(size);
-       memcpy(updated, ce, size);
-       fill_stat_cache_info(updated, &st);
-       return updated;
-}
-
-static int refresh_cache(void)
-{
-       int i;
-       int has_errors = 0;
-
-       for (i = 0; i < active_nr; i++) {
-               struct cache_entry *ce, *new;
-               ce = active_cache[i];
-               if (ce_stage(ce)) {
-                       printf("%s: needs merge\n", ce->name);
-                       has_errors = 1;
-                       while ((i < active_nr) &&
-                              ! strcmp(active_cache[i]->name, ce->name))
-                               i++;
-                       i--;
-                       continue;
-               }
-
-               new = refresh_entry(ce);
-               if (IS_ERR(new)) {
-                       if (not_new && PTR_ERR(new) == -ENOENT)
-                               continue;
-                       if (quiet)
-                               continue;
-                       printf("%s: needs update\n", ce->name);
-                       has_errors = 1;
-                       continue;
-               }
-               active_cache_changed = 1;
-               /* You can NOT just free active_cache[i] here, since it
-                * might not be necessarily malloc()ed but can also come
-                * from mmap(). */
-               active_cache[i] = new;
-       }
-       return has_errors;
-}
-
-/*
- * We fundamentally don't like some paths: we don't want
- * dot or dot-dot anywhere, and for obvious reasons don't
- * want to recurse into ".git" either.
- *
- * Also, we don't want double slashes or slashes at the
- * end that can make pathnames ambiguous.
- */
-static int verify_dotfile(const char *rest)
-{
-       /*
-        * The first character was '.', but that
-        * has already been discarded, we now test
-        * the rest.
-        */
-       switch (*rest) {
-       /* "." is not allowed */
-       case '\0': case '/':
-               return 0;
-
-       /*
-        * ".git" followed by  NUL or slash is bad. This
-        * shares the path end test with the ".." case.
-        */
-       case 'g':
-               if (rest[1] != 'i')
-                       break;
-               if (rest[2] != 't')
-                       break;
-               rest += 2;
-       /* fallthrough */
-       case '.':
-               if (rest[1] == '\0' || rest[1] == '/')
-                       return 0;
-       }
-       return 1;
-}
-
-static int verify_path(char *path)
-{
-       char c;
-
-       goto inside;
-       for (;;) {
-               if (!c)
-                       return 1;
-               if (c == '/') {
-inside:
-                       c = *path++;
-                       switch (c) {
-                       default:
-                               continue;
-                       case '/': case '\0':
-                               break;
-                       case '.':
-                               if (verify_dotfile(path))
-                                       continue;
-                       }
-                       return 0;
-               }
-               c = *path++;
-       }
-}
-
-static int add_cacheinfo(char *arg1, char *arg2, char *arg3)
-{
-       int size, len, option;
-       unsigned int mode;
-       unsigned char sha1[20];
-       struct cache_entry *ce;
-
-       if (sscanf(arg1, "%o", &mode) != 1)
-               return -1;
-       if (get_sha1_hex(arg2, sha1))
-               return -1;
-       if (!verify_path(arg3))
-               return -1;
-
-       len = strlen(arg3);
-       size = cache_entry_size(len);
-       ce = xmalloc(size);
-       memset(ce, 0, size);
-
-       memcpy(ce->sha1, sha1, 20);
-       memcpy(ce->name, arg3, len);
-       ce->ce_flags = htons(len);
-       ce->ce_mode = create_ce_mode(mode);
-       option = allow_add ? ADD_CACHE_OK_TO_ADD : 0;
-       option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;
-       return add_cache_entry(ce, option);
-}
-
-static struct cache_file cache_file;
-
-int main(int argc, char **argv)
-{
-       int i, newfd, entries, has_errors = 0;
-       int allow_options = 1;
-       const char *prefix = setup_git_directory();
-
-       newfd = hold_index_file_for_update(&cache_file, get_index_file());
-       if (newfd < 0)
-               die("unable to create new cachefile");
-
-       entries = read_cache();
-       if (entries < 0)
-               die("cache corrupted");
-
-       for (i = 1 ; i < argc; i++) {
-               char *path = argv[i];
-
-               if (allow_options && *path == '-') {
-                       if (!strcmp(path, "--")) {
-                               allow_options = 0;
-                               continue;
-                       }
-                       if (!strcmp(path, "-q")) {
-                               quiet = 1;
-                               continue;
-                       }
-                       if (!strcmp(path, "--add")) {
-                               allow_add = 1;
-                               continue;
-                       }
-                       if (!strcmp(path, "--replace")) {
-                               allow_replace = 1;
-                               continue;
-                       }
-                       if (!strcmp(path, "--remove")) {
-                               allow_remove = 1;
-                               continue;
-                       }
-                       if (!strcmp(path, "--refresh")) {
-                               has_errors |= refresh_cache();
-                               continue;
-                       }
-                       if (!strcmp(path, "--cacheinfo")) {
-                               if (i+3 >= argc)
-                                       die("git-update-cache: --cacheinfo <mode> <sha1> <path>");
-                               if (add_cacheinfo(argv[i+1], argv[i+2], argv[i+3]))
-                                       die("git-update-cache: --cacheinfo cannot add %s", argv[i+3]);
-                               i += 3;
-                               continue;
-                       }
-                       if (!strcmp(path, "--info-only")) {
-                               info_only = 1;
-                               continue;
-                       }
-                       if (!strcmp(path, "--force-remove")) {
-                               force_remove = 1;
-                               continue;
-                       }
-
-                       if (!strcmp(path, "--ignore-missing")) {
-                               not_new = 1;
-                               continue;
-                       }
-                       die("unknown option %s", path);
-               }
-               path = prefix_path(prefix, prefix ? strlen(prefix) : 0, path);
-               if (!verify_path(path)) {
-                       fprintf(stderr, "Ignoring path %s\n", argv[i]);
-                       continue;
-               }
-               if (force_remove) {
-                       if (remove_file_from_cache(path))
-                               die("git-update-cache: --force-remove cannot remove %s", path);
-                       continue;
-               }
-               if (add_file_to_cache(path))
-                       die("Unable to add %s to database; maybe you want to use --add option?", path);
-       }
-       if (write_cache(newfd, active_cache, active_nr) ||
-           commit_index_file(&cache_file))
-               die("Unable to write new cachefile");
-
-       return has_errors ? 1 : 0;
-}
diff --git a/update-index.c b/update-index.c
new file mode 100644 (file)
index 0000000..d10dfd9
--- /dev/null
@@ -0,0 +1,407 @@
+/*
+ * GIT - The information manager from hell
+ *
+ * Copyright (C) Linus Torvalds, 2005
+ */
+#include "cache.h"
+
+/*
+ * Default to not allowing changes to the list of files. The
+ * tool doesn't actually care, but this makes it harder to add
+ * files to the revision control by mistake by doing something
+ * like "git-update-index *" and suddenly having all the object
+ * files be revision controlled.
+ */
+static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new = 0, quiet = 0, info_only = 0;
+static int force_remove;
+
+/* Three functions to allow overloaded pointer return; see linux/err.h */
+static inline void *ERR_PTR(long error)
+{
+       return (void *) error;
+}
+
+static inline long PTR_ERR(const void *ptr)
+{
+       return (long) ptr;
+}
+
+static inline long IS_ERR(const void *ptr)
+{
+       return (unsigned long)ptr > (unsigned long)-1000L;
+}
+
+static int add_file_to_cache(char *path)
+{
+       int size, namelen, option, status;
+       struct cache_entry *ce;
+       struct stat st;
+       int fd;
+       char *target;
+
+       status = lstat(path, &st);
+       if (status < 0 || S_ISDIR(st.st_mode)) {
+               /* When we used to have "path" and now we want to add
+                * "path/file", we need a way to remove "path" before
+                * being able to add "path/file".  However,
+                * "git-update-index --remove path" would not work.
+                * --force-remove can be used but this is more user
+                * friendly, especially since we can do the opposite
+                * case just fine without --force-remove.
+                */
+               if (status == 0 || (errno == ENOENT || errno == ENOTDIR)) {
+                       if (allow_remove)
+                               return remove_file_from_cache(path);
+               }
+               if (0 == status)
+                       return error("%s: is a directory", path);
+               else
+                       return error("lstat(\"%s\"): %s", path,
+                                    strerror(errno));
+       }
+       namelen = strlen(path);
+       size = cache_entry_size(namelen);
+       ce = xmalloc(size);
+       memset(ce, 0, size);
+       memcpy(ce->name, path, namelen);
+       fill_stat_cache_info(ce, &st);
+       ce->ce_mode = create_ce_mode(st.st_mode);
+       ce->ce_flags = htons(namelen);
+       switch (st.st_mode & S_IFMT) {
+       case S_IFREG:
+               fd = open(path, O_RDONLY);
+               if (fd < 0)
+                       return -1;
+               if (index_fd(ce->sha1, fd, &st, !info_only, NULL) < 0)
+                       return -1;
+               break;
+       case S_IFLNK:
+               target = xmalloc(st.st_size+1);
+               if (readlink(path, target, st.st_size+1) != st.st_size) {
+                       free(target);
+                       return -1;
+               }
+               if (info_only) {
+                       unsigned char hdr[50];
+                       int hdrlen;
+                       write_sha1_file_prepare(target, st.st_size, "blob",
+                                               ce->sha1, hdr, &hdrlen);
+               } else if (write_sha1_file(target, st.st_size, "blob", ce->sha1))
+                       return -1;
+               free(target);
+               break;
+       default:
+               return -1;
+       }
+       option = allow_add ? ADD_CACHE_OK_TO_ADD : 0;
+       option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;
+       return add_cache_entry(ce, option);
+}
+
+static int compare_data(struct cache_entry *ce, struct stat *st)
+{
+       int match = -1;
+       int fd = open(ce->name, O_RDONLY);
+
+       if (fd >= 0) {
+               unsigned char sha1[20];
+               if (!index_fd(sha1, fd, st, 0, NULL))
+                       match = memcmp(sha1, ce->sha1, 20);
+               close(fd);
+       }
+       return match;
+}
+
+static int compare_link(struct cache_entry *ce, unsigned long expected_size)
+{
+       int match = -1;
+       char *target;
+       void *buffer;
+       unsigned long size;
+       char type[10];
+       int len;
+
+       target = xmalloc(expected_size);
+       len = readlink(ce->name, target, expected_size);
+       if (len != expected_size) {
+               free(target);
+               return -1;
+       }
+       buffer = read_sha1_file(ce->sha1, type, &size);
+       if (!buffer) {
+               free(target);
+               return -1;
+       }
+       if (size == expected_size)
+               match = memcmp(buffer, target, size);
+       free(buffer);
+       free(target);
+       return match;
+}
+
+/*
+ * "refresh" does not calculate a new sha1 file or bring the
+ * cache up-to-date for mode/content changes. But what it
+ * _does_ do is to "re-match" the stat information of a file
+ * with the cache, so that you can refresh the cache for a
+ * file that hasn't been changed but where the stat entry is
+ * out of date.
+ *
+ * For example, you'd want to do this after doing a "git-read-tree",
+ * to link up the stat cache details with the proper files.
+ */
+static struct cache_entry *refresh_entry(struct cache_entry *ce)
+{
+       struct stat st;
+       struct cache_entry *updated;
+       int changed, size;
+
+       if (lstat(ce->name, &st) < 0)
+               return ERR_PTR(-errno);
+
+       changed = ce_match_stat(ce, &st);
+       if (!changed)
+               return ce;
+
+       /*
+        * If the mode or type has changed, there's no point in trying
+        * to refresh the entry - it's not going to match
+        */
+       if (changed & (MODE_CHANGED | TYPE_CHANGED))
+               return ERR_PTR(-EINVAL);
+
+       switch (st.st_mode & S_IFMT) {
+       case S_IFREG:
+               if (compare_data(ce, &st))
+                       return ERR_PTR(-EINVAL);
+               break;
+       case S_IFLNK:
+               if (compare_link(ce, st.st_size))
+                       return ERR_PTR(-EINVAL);
+               break;
+       default:
+               return ERR_PTR(-EINVAL);
+       }
+
+       size = ce_size(ce);
+       updated = xmalloc(size);
+       memcpy(updated, ce, size);
+       fill_stat_cache_info(updated, &st);
+       return updated;
+}
+
+static int refresh_cache(void)
+{
+       int i;
+       int has_errors = 0;
+
+       for (i = 0; i < active_nr; i++) {
+               struct cache_entry *ce, *new;
+               ce = active_cache[i];
+               if (ce_stage(ce)) {
+                       printf("%s: needs merge\n", ce->name);
+                       has_errors = 1;
+                       while ((i < active_nr) &&
+                              ! strcmp(active_cache[i]->name, ce->name))
+                               i++;
+                       i--;
+                       continue;
+               }
+
+               new = refresh_entry(ce);
+               if (IS_ERR(new)) {
+                       if (not_new && PTR_ERR(new) == -ENOENT)
+                               continue;
+                       if (quiet)
+                               continue;
+                       printf("%s: needs update\n", ce->name);
+                       has_errors = 1;
+                       continue;
+               }
+               active_cache_changed = 1;
+               /* You can NOT just free active_cache[i] here, since it
+                * might not be necessarily malloc()ed but can also come
+                * from mmap(). */
+               active_cache[i] = new;
+       }
+       return has_errors;
+}
+
+/*
+ * We fundamentally don't like some paths: we don't want
+ * dot or dot-dot anywhere, and for obvious reasons don't
+ * want to recurse into ".git" either.
+ *
+ * Also, we don't want double slashes or slashes at the
+ * end that can make pathnames ambiguous.
+ */
+static int verify_dotfile(const char *rest)
+{
+       /*
+        * The first character was '.', but that
+        * has already been discarded, we now test
+        * the rest.
+        */
+       switch (*rest) {
+       /* "." is not allowed */
+       case '\0': case '/':
+               return 0;
+
+       /*
+        * ".git" followed by  NUL or slash is bad. This
+        * shares the path end test with the ".." case.
+        */
+       case 'g':
+               if (rest[1] != 'i')
+                       break;
+               if (rest[2] != 't')
+                       break;
+               rest += 2;
+       /* fallthrough */
+       case '.':
+               if (rest[1] == '\0' || rest[1] == '/')
+                       return 0;
+       }
+       return 1;
+}
+
+static int verify_path(char *path)
+{
+       char c;
+
+       goto inside;
+       for (;;) {
+               if (!c)
+                       return 1;
+               if (c == '/') {
+inside:
+                       c = *path++;
+                       switch (c) {
+                       default:
+                               continue;
+                       case '/': case '\0':
+                               break;
+                       case '.':
+                               if (verify_dotfile(path))
+                                       continue;
+                       }
+                       return 0;
+               }
+               c = *path++;
+       }
+}
+
+static int add_cacheinfo(char *arg1, char *arg2, char *arg3)
+{
+       int size, len, option;
+       unsigned int mode;
+       unsigned char sha1[20];
+       struct cache_entry *ce;
+
+       if (sscanf(arg1, "%o", &mode) != 1)
+               return -1;
+       if (get_sha1_hex(arg2, sha1))
+               return -1;
+       if (!verify_path(arg3))
+               return -1;
+
+       len = strlen(arg3);
+       size = cache_entry_size(len);
+       ce = xmalloc(size);
+       memset(ce, 0, size);
+
+       memcpy(ce->sha1, sha1, 20);
+       memcpy(ce->name, arg3, len);
+       ce->ce_flags = htons(len);
+       ce->ce_mode = create_ce_mode(mode);
+       option = allow_add ? ADD_CACHE_OK_TO_ADD : 0;
+       option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;
+       return add_cache_entry(ce, option);
+}
+
+static struct cache_file cache_file;
+
+int main(int argc, char **argv)
+{
+       int i, newfd, entries, has_errors = 0;
+       int allow_options = 1;
+       const char *prefix = setup_git_directory();
+
+       newfd = hold_index_file_for_update(&cache_file, get_index_file());
+       if (newfd < 0)
+               die("unable to create new cachefile");
+
+       entries = read_cache();
+       if (entries < 0)
+               die("cache corrupted");
+
+       for (i = 1 ; i < argc; i++) {
+               char *path = argv[i];
+
+               if (allow_options && *path == '-') {
+                       if (!strcmp(path, "--")) {
+                               allow_options = 0;
+                               continue;
+                       }
+                       if (!strcmp(path, "-q")) {
+                               quiet = 1;
+                               continue;
+                       }
+                       if (!strcmp(path, "--add")) {
+                               allow_add = 1;
+                               continue;
+                       }
+                       if (!strcmp(path, "--replace")) {
+                               allow_replace = 1;
+                               continue;
+                       }
+                       if (!strcmp(path, "--remove")) {
+                               allow_remove = 1;
+                               continue;
+                       }
+                       if (!strcmp(path, "--refresh")) {
+                               has_errors |= refresh_cache();
+                               continue;
+                       }
+                       if (!strcmp(path, "--cacheinfo")) {
+                               if (i+3 >= argc)
+                                       die("git-update-index: --cacheinfo <mode> <sha1> <path>");
+                               if (add_cacheinfo(argv[i+1], argv[i+2], argv[i+3]))
+                                       die("git-update-index: --cacheinfo cannot add %s", argv[i+3]);
+                               i += 3;
+                               continue;
+                       }
+                       if (!strcmp(path, "--info-only")) {
+                               info_only = 1;
+                               continue;
+                       }
+                       if (!strcmp(path, "--force-remove")) {
+                               force_remove = 1;
+                               continue;
+                       }
+
+                       if (!strcmp(path, "--ignore-missing")) {
+                               not_new = 1;
+                               continue;
+                       }
+                       die("unknown option %s", path);
+               }
+               path = prefix_path(prefix, prefix ? strlen(prefix) : 0, path);
+               if (!verify_path(path)) {
+                       fprintf(stderr, "Ignoring path %s\n", argv[i]);
+                       continue;
+               }
+               if (force_remove) {
+                       if (remove_file_from_cache(path))
+                               die("git-update-index: --force-remove cannot remove %s", path);
+                       continue;
+               }
+               if (add_file_to_cache(path))
+                       die("Unable to add %s to database; maybe you want to use --add option?", path);
+       }
+       if (write_cache(newfd, active_cache, active_nr) ||
+           commit_index_file(&cache_file))
+               die("Unable to write new cachefile");
+
+       return has_errors ? 1 : 0;
+}