Code

Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Sun, 10 Jun 2007 23:45:08 +0000 (16:45 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 10 Jun 2007 23:45:08 +0000 (16:45 -0700)
* maint:
  tutorial: use "project history" instead of "changelog" in header
  Documentation: user-manual todo
  user-manual: add a missing section ID
  Fix typo in remote branch example in git user manual
  user-manual: quick-start updates

348 files changed:
.gitignore
.mailmap
Documentation/RelNotes-1.5.0.4.txt
Documentation/RelNotes-1.5.0.5.txt
Documentation/RelNotes-1.5.0.6.txt
Documentation/RelNotes-1.5.1.3.txt
Documentation/RelNotes-1.5.3.txt [new file with mode: 0644]
Documentation/SubmittingPatches
Documentation/asciidoc.conf
Documentation/cmd-list.perl
Documentation/config.txt
Documentation/core-tutorial.txt
Documentation/diff-format.txt
Documentation/diff-options.txt
Documentation/diffcore.txt
Documentation/docbook-xsl.css
Documentation/fetch-options.txt
Documentation/git-add.txt
Documentation/git-am.txt
Documentation/git-apply.txt
Documentation/git-applymbox.txt [deleted file]
Documentation/git-applypatch.txt [deleted file]
Documentation/git-archimport.txt
Documentation/git-bisect.txt
Documentation/git-branch.txt
Documentation/git-cat-file.txt
Documentation/git-check-attr.txt
Documentation/git-checkout-index.txt
Documentation/git-checkout.txt
Documentation/git-cherry-pick.txt
Documentation/git-cherry.txt
Documentation/git-clone.txt
Documentation/git-commit-tree.txt
Documentation/git-config.txt
Documentation/git-convert-objects.txt
Documentation/git-count-objects.txt
Documentation/git-cvsexportcommit.txt
Documentation/git-cvsimport.txt
Documentation/git-daemon.txt
Documentation/git-describe.txt
Documentation/git-diff-files.txt
Documentation/git-diff-index.txt
Documentation/git-diff-tree.txt
Documentation/git-diff.txt
Documentation/git-fast-import.txt
Documentation/git-fmt-merge-msg.txt
Documentation/git-format-patch.txt
Documentation/git-fsck.txt
Documentation/git-gc.txt
Documentation/git-get-tar-commit-id.txt
Documentation/git-grep.txt
Documentation/git-hash-object.txt
Documentation/git-http-fetch.txt
Documentation/git-http-push.txt
Documentation/git-index-pack.txt
Documentation/git-init-db.txt
Documentation/git-init.txt
Documentation/git-instaweb.txt
Documentation/git-local-fetch.txt
Documentation/git-log.txt
Documentation/git-ls-files.txt
Documentation/git-ls-remote.txt
Documentation/git-ls-tree.txt
Documentation/git-mailinfo.txt
Documentation/git-mailsplit.txt
Documentation/git-merge-base.txt
Documentation/git-merge-index.txt
Documentation/git-merge-one-file.txt
Documentation/git-merge-tree.txt
Documentation/git-merge.txt
Documentation/git-mergetool.txt
Documentation/git-mktag.txt
Documentation/git-mktree.txt
Documentation/git-mv.txt
Documentation/git-name-rev.txt
Documentation/git-p4import.txt
Documentation/git-pack-objects.txt
Documentation/git-pack-redundant.txt
Documentation/git-patch-id.txt
Documentation/git-peek-remote.txt
Documentation/git-prune-packed.txt
Documentation/git-prune.txt
Documentation/git-pull.txt
Documentation/git-push.txt
Documentation/git-quiltimport.txt
Documentation/git-read-tree.txt
Documentation/git-rebase.txt
Documentation/git-reflog.txt
Documentation/git-relink.txt
Documentation/git-remote.txt
Documentation/git-repack.txt
Documentation/git-request-pull.txt
Documentation/git-rev-list.txt
Documentation/git-rev-parse.txt
Documentation/git-revert.txt
Documentation/git-rm.txt
Documentation/git-runstatus.txt
Documentation/git-send-email.txt
Documentation/git-sh-setup.txt
Documentation/git-shell.txt
Documentation/git-shortlog.txt
Documentation/git-show-index.txt
Documentation/git-show.txt
Documentation/git-ssh-fetch.txt
Documentation/git-ssh-upload.txt
Documentation/git-status.txt
Documentation/git-stripspace.txt
Documentation/git-submodule.txt [new file with mode: 0644]
Documentation/git-svnimport.txt
Documentation/git-tag.txt
Documentation/git-tar-tree.txt
Documentation/git-unpack-file.txt
Documentation/git-unpack-objects.txt
Documentation/git-update-index.txt
Documentation/git-update-ref.txt
Documentation/git-update-server-info.txt
Documentation/git-var.txt
Documentation/git-verify-pack.txt
Documentation/git-verify-tag.txt
Documentation/git-whatchanged.txt
Documentation/git-write-tree.txt
Documentation/git.txt
Documentation/gitk.txt
Documentation/hooks.txt
Documentation/howto/rebase-and-edit.txt
Documentation/howto/rebase-from-internal-branch.txt
Documentation/howto/rebuild-from-update-hook.txt
Documentation/howto/revert-branch-rebase.txt
Documentation/howto/separating-topic-branches.txt
Documentation/howto/use-git-daemon.txt
Documentation/merge-options.txt
Documentation/pretty-formats.txt
Documentation/pretty-options.txt
Documentation/pull-fetch-param.txt
Documentation/repository-layout.txt
Documentation/technical/pack-format.txt
Documentation/user-manual.txt
GIT-VERSION-GEN
INSTALL
Makefile
RelNotes
archive-tar.c
archive-zip.c
arm/sha1.c
arm/sha1_arm.S
builtin-annotate.c
builtin-apply.c
builtin-archive.c
builtin-branch.c
builtin-count-objects.c
builtin-describe.c
builtin-diff-index.c
builtin-fetch--tool.c
builtin-fmt-merge-msg.c
builtin-fsck.c
builtin-gc.c
builtin-log.c
builtin-ls-files.c
builtin-ls-tree.c
builtin-mailinfo.c
builtin-mailsplit.c
builtin-merge-file.c
builtin-name-rev.c
builtin-pack-objects.c
builtin-pack-refs.c
builtin-push.c
builtin-reflog.c
builtin-rerere.c
builtin-revert.c
builtin-shortlog.c
builtin-stripspace.c
builtin-update-index.c
builtin-update-ref.c
builtin.h
cache-tree.c
cache.h
commit.c
commit.h
compat/mmap.c
config.c
config.mak.in
connect.c
contrib/README
contrib/blameview/README
contrib/gitview/gitview
contrib/hooks/post-receive-email
contrib/remotes2config.sh
contrib/workdir/git-new-workdir
convert-objects.c
copy.c
csum-file.c
csum-file.h
ctype.c
daemon.c
date.c
diff-delta.c
diff-lib.c
diff.c
diff.h
diffcore-pickaxe.c
dir.c
dir.h
entry.c
environment.c
fast-import.c
fetch-pack.c
fetch.c
git-applymbox.sh [deleted file]
git-applypatch.sh [deleted file]
git-archimport.perl
git-checkout.sh
git-clone.sh
git-commit.sh
git-cvsexportcommit.perl
git-cvsimport.perl
git-cvsserver.perl
git-fetch.sh
git-gui/GIT-VERSION-GEN
git-gui/lib/class.tcl
git-merge-one-file.sh
git-merge.sh
git-mergetool.sh
git-p4import.py
git-pull.sh
git-rebase.sh
git-repack.sh
git-submodule.sh [new file with mode: 0755]
git-svnimport.perl
git-tag.sh
git-verify-tag.sh
git.spec.in
gitk
gitweb/README
gitweb/gitweb.perl
grep.c
help.c
http-fetch.c
http-push.c
http.c
ident.c
imap-send.c
index-pack.c
list-objects.c
local-fetch.c
lockfile.c
mailmap.c
match-trees.c
merge-index.c
merge-recursive.c
mktag.c
mozilla-sha1/sha1.c
mozilla-sha1/sha1.h
object-refs.c
object.c
object.h
pack-check.c
pack-redundant.c
pack-write.c
pack.h
patch-id.c
path-list.c
peek-remote.c
perl/Makefile
pkt-line.c
ppc/sha1.c
progress.c
progress.h
quote.c
quote.h
read-cache.c
receive-pack.c
refs.c
refs.h
remote.c [new file with mode: 0644]
remote.h [new file with mode: 0644]
revision.c
revision.h
rsh.h
run-command.c
run-command.h
send-pack.c
setup.c
sha1_file.c
sha1_name.c
shallow.c
ssh-upload.c
strbuf.c
t/Makefile
t/lib-read-tree-m-3way.sh
t/t0000-basic.sh
t/t1200-tutorial.sh
t/t1300-repo-config.sh
t/t2000-checkout-cache-clash.sh
t/t2001-checkout-cache-clash.sh
t/t3030-merge-recursive.sh
t/t3200-branch.sh
t/t3403-rebase-skip.sh
t/t4006-diff-mode.sh
t/t4100-apply-stat.sh
t/t4110-apply-scan.sh
t/t4112-apply-renames.sh
t/t4118-apply-empty-context.sh
t/t4119-apply-config.sh
t/t4121-apply-diffs.sh
t/t4122-apply-symlink-inside.sh
t/t4200-rerere.sh
t/t5000-tar-tree.sh
t/t5400-send-pack.sh
t/t5516-fetch-push.sh [new file with mode: 0755]
t/t5520-pull.sh
t/t5701-clone-local.sh [new file with mode: 0755]
t/t5710-info-alternate.sh
t/t6000lib.sh
t/t6002-rev-list-bisect.sh
t/t6021-merge-criss-cross.sh
t/t6023-merge-file.sh
t/t6024-recursive-merge.sh
t/t6030-bisect-porcelain.sh
t/t6101-rev-parse-parents.sh
t/t7400-submodule-basic.sh [new file with mode: 0755]
t/t9107-git-svn-migrate.sh
t/t9111/svnsync.dump
t/t9400-git-cvsserver-server.sh
t/t9500-gitweb-standalone-no-errors.sh [new file with mode: 0755]
t/test-lib.sh
templates/hooks--commit-msg
templates/hooks--post-receive
templates/hooks--pre-applypatch
templates/hooks--pre-commit
tree-walk.c
tree.c
upload-pack.c
var.c
wt-status.c
xdiff-interface.c
xdiff-interface.h
xdiff/xdiff.h
xdiff/xdiffi.c
xdiff/xdiffi.h
xdiff/xemit.c
xdiff/xemit.h
xdiff/xinclude.h
xdiff/xmacros.h
xdiff/xprepare.c
xdiff/xprepare.h
xdiff/xtypes.h
xdiff/xutils.c
xdiff/xutils.h

index 4dc0c395fa7d6e7cff7588ee66c928c954cc014d..bd49cd4627a786d6dbcd7f0d17f0fddc2add7014 100644 (file)
@@ -7,8 +7,6 @@ git-add--interactive
 git-am
 git-annotate
 git-apply
-git-applymbox
-git-applypatch
 git-archimport
 git-archive
 git-bisect
@@ -42,6 +40,7 @@ git-fast-import
 git-fetch
 git-fetch--tool
 git-fetch-pack
+git-filter-branch
 git-findtags
 git-fmt-merge-msg
 git-for-each-ref
@@ -126,6 +125,7 @@ git-ssh-push
 git-ssh-upload
 git-status
 git-stripspace
+git-submodule
 git-svn
 git-svnimport
 git-symbolic-ref
@@ -152,13 +152,14 @@ test-delta
 test-dump-cache-tree
 test-genrandom
 test-match-trees
+test-sha1
 common-cmds.h
 *.tar.gz
 *.dsc
 *.deb
 git-core.spec
 *.exe
-*.[ao]
+*.[aos]
 *.py[co]
 config.mak
 autom4te.cache
index 4e0615e9beb06928e9440e3dd60014cc265f9ee5..aa8ee6b3f1671bbc3a07af7be544c4f83d0d7b1b 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -7,6 +7,8 @@
 
 Aneesh Kumar K.V <aneesh.kumar@gmail.com>
 Chris Shoemaker <c.shoemaker@cox.net>
+Dana L. How <danahow@gmail.com>
+Dana L. How <how@deathvalley.cswitch.com>
 Daniel Barkalow <barkalow@iabervon.org>
 David KÃ¥gedal <davidk@lysator.liu.se>
 Fredrik Kuivinen <freku045@student.liu.se>
@@ -19,8 +21,8 @@ Jon Loeliger <jdl@freescale.com>
 Jon Seymour <jon@blackcubes.dyndns.org>
 Karl Hasselström <kha@treskal.com>
 Kent Engstrom <kent@lysator.liu.se>
-Lars Doelle <lars.doelle@on-line.de>
 Lars Doelle <lars.doelle@on-line ! de>
+Lars Doelle <lars.doelle@on-line.de>
 Lukas Sandström <lukass@etek.chalmers.se>
 Martin Langhoff <martin@catalyst.net.nz>
 Michele Ballabio <barra_cuda@katamail.com>
@@ -34,12 +36,11 @@ Sean Estabrooks <seanlkml@sympatico.ca>
 Shawn O. Pearce <spearce@spearce.org>
 Theodore Ts'o <tytso@mit.edu>
 Tony Luck <tony.luck@intel.com>
-Uwe Kleine-König <zeisberg@informatik.uni-freiburg.de>
 Uwe Kleine-König <Uwe_Zeisberger@digi.com>
-Uwe Kleine-König <uzeisberger@io.fsforth.de>
 Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
+Uwe Kleine-König <uzeisberger@io.fsforth.de>
+Uwe Kleine-König <zeisberg@informatik.uni-freiburg.de>
 Ville Skyttä <scop@xemacs.org>
 YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
 anonymous <linux@horizon.com>
 anonymous <linux@horizon.net>
-Dana L. How <how@deathvalley.cswitch.com>
index b727a8d1e57cf8fb5a6c591a5f35ceddbbd3f6af..feefa5dfd4eee5f493fcf3091ec0de116d414fc1 100644 (file)
@@ -20,5 +20,3 @@ Fixes since v1.5.0.3
 * Documentation updates
 
 * User manual updates
-
-
index aa86149d4f3649721f206b94c26854ce30dfc101..eeec3d73d01a0e9f61df666bad8a48a4f423438a 100644 (file)
@@ -24,5 +24,3 @@ Fixes since v1.5.0.3
 * Documentation updates
 
 * User manual updates
-
-
index e15447ffdba41ec082e249b13bc31248b6d2dbbe..c02015ad5fdb1953ad1a8cf5b0edd7ef7c04fbac 100644 (file)
@@ -19,4 +19,3 @@ Fixes since v1.5.0.5
   - user-manual has better cross references.
 
   - gitweb installation/deployment procedure is now documented.
-
index 2ddeabd0296848eeb6344b5487f85e9c484eaf0a..876408b65a0e0841567a2c9b97c6f6e62cb86b81 100644 (file)
@@ -43,4 +43,3 @@ Fixes since v1.5.1.2
     description was given by the caller.
 
 Also contains various documentation updates.
-
diff --git a/Documentation/RelNotes-1.5.3.txt b/Documentation/RelNotes-1.5.3.txt
new file mode 100644 (file)
index 0000000..d111661
--- /dev/null
@@ -0,0 +1,109 @@
+GIT v1.5.3 Release Notes (draft)
+========================
+
+Updates since v1.5.2
+--------------------
+
+* An initial interation of Porcelain level superproject support
+  started to take shape.
+
+* Thee are a handful pack-objects changes to help you cope better with
+  repositories with pathologically large blobs in them.
+
+* New commands and options.
+
+  - "git-submodule" command helps you manage the projects from
+    the superproject that contain them.
+
+  - In addition to core.compression configuration option,
+    core.loosecompression and pack.compression options can
+    independently tweak zlib compression levels used for loose
+    and packed objects.
+
+  - "git-ls-tree -l" shows size of blobs pointed at by the
+    tree entries, similar to "/bin/ls -l".
+
+  - "git-rev-list" learned --regexp-ignore-case and
+    --extended-regexp options to tweak its matching logic used
+    for --grep fitering.
+
+  - "git-describe --contains" is a handier way to call more
+    obscure command "git-name-rev --tags".
+
+  - "git gc --aggressive" tells the command to spend more cycles
+    to optimize the repository harder.
+
+  - "git repack" can be told to split resulting packs to avoid
+    exceeding limit specified with "--max-pack-size".
+
+* Updated behavior of existing commands.
+
+  - "git push" pretends that you immediately fetched back from
+    the remote by updating corresponding remote tracking
+    branches if you have any.
+
+  - The diffstat given after a merge (or a pull) honors the
+    color.diff configuration.
+
+  - "git-apply --whitespace=strip" removes blank lines added at
+    the end of the file.
+
+  - fetch over git native protocols with -v shows connection
+    status, and the IP address of the other end, to help
+    diagnosing problems.
+
+  - core.legacyheaders is no more, although we still can read
+    objects created in a new loose object format.
+
+  - "git-mailsplit" (hence "git-am") can read from Maildir
+    formatted mailboxes.
+
+  - "git cvsserver" does not barf upon seeing "cvs login"
+    request.
+
+  - "pack-objects" honors "delta" attribute set in
+    .gitattributes.  It does not attempt to deltify blobs that
+    come from paths with delta attribute set to false.
+
+  - new-workdir script (in contrib) can now be used with a bare
+    repository.
+
+
+* Builds
+
+  -
+
+* Performance Tweaks
+
+  - git-pack-objects avoids re-deltification cost by caching
+    small enough delta results it creates while looking for the
+    best delta candidates.
+
+  - diff-delta code that is used for packing has been improved
+    to work better on big files.
+
+  - when there are more than one pack files in the repository,
+    the runtime used to try finding an object always from the
+    newest packfile; it now tries the same packfile as we found
+    the object requested the last time, which exploits the
+    locality of references.
+
+Fixes since v1.5.2
+------------------
+
+All of the fixes in v1.5.2 maintenance series are included in
+this release, unless otherwise noted.
+
+* Bugfixes
+
+  - ....  This has not
+    been backported to 1.5.2.x series, as it is rather an
+    intrusive change.
+
+
+--
+exec >/var/tmp/1
+O=v1.5.2-45-ged82edc
+O=v1.5.2-172-g1a8b769
+echo O=`git describe refs/heads/master`
+git shortlog --no-merges $O..refs/heads/master ^refs/heads/maint
index b94d9a816664333e0b1767c22d1639b8839cee24..01354c2bb5da56181de3b88052e1d921986f1f95 100644 (file)
@@ -14,6 +14,8 @@ Checklist (and a short version for the impatient):
          commit message (or just use the option "-s" when
          committing) to confirm that you agree to the Developer's
          Certificate of Origin
+       - make sure that you have tests for the bug you are fixing
+       - make sure that the test suite passes after your commit
 
        Patch:
 
@@ -33,6 +35,8 @@ Checklist (and a short version for the impatient):
        - if you change, add, or remove a command line option or
          make some other user interface change, the associated
          documentation should be updated as well.
+       - if your name is not writable in ASCII, make sure that
+         you send off a message in the correct encoding.
 
 Long version:
 
@@ -239,7 +243,7 @@ One test you could do yourself if your MUA is set up correctly is:
     $ git fetch http://kernel.org/pub/scm/git/git.git master:test-apply
     $ git checkout test-apply
     $ git reset --hard
-    $ git applymbox a.patch
+    $ git am a.patch
 
 If it does not apply correctly, there can be various reasons.
 
@@ -247,7 +251,7 @@ If it does not apply correctly, there can be various reasons.
   does not have much to do with your MUA.  Please rebase the
   patch appropriately.
 
-* Your MUA corrupted your patch; applymbox would complain that
+* Your MUA corrupted your patch; "am" would complain that
   the patch does not apply.  Look at .dotest/ subdirectory and
   see what 'patch' file contains and check for the common
   corruption patterns mentioned above.
@@ -292,15 +296,15 @@ diff --git a/pico/pico.c b/pico/pico.c
 --- a/pico/pico.c
 +++ b/pico/pico.c
 @@ -219,7 +219,9 @@ PICO *pm;
-           switch(pico_all_done){      /* prepare for/handle final events */
-             case COMP_EXIT :          /* already confirmed */
-               packheader();
+           switch(pico_all_done){      /* prepare for/handle final events */
+             case COMP_EXIT :          /* already confirmed */
+               packheader();
 +#if 0
-               stripwhitespace();
+               stripwhitespace();
 +#endif
-               c |= COMP_EXIT;
-               break;
+               c |= COMP_EXIT;
+               break;
+
 
 (Daniel Barkalow)
 
index 60e15ba3494b93f2c956356d3d5fd905385d0c1f..99302c5bebb6017e34371bf12dafeab97447bda5 100644 (file)
@@ -54,5 +54,3 @@ ifdef::backend-xhtml11[]
 [gitlink-inlinemacro]
 <a href="{target}.html">{target}{0?({0})}</a>
 endif::backend-xhtml11[]
-
-
index 443802a9a3e4982c33f831217602ea600f0f2775..a181f753e0fefdeb036a826b8c0d0a5b54d0ae25 100755 (executable)
@@ -72,8 +72,6 @@ __DATA__
 git-add                                 mainporcelain
 git-am                                  mainporcelain
 git-annotate                            ancillaryinterrogators
-git-applymbox                           ancillaryinterrogators
-git-applypatch                          purehelpers
 git-apply                               plumbingmanipulators
 git-archimport                          foreignscminterface
 git-archive                             mainporcelain
@@ -180,6 +178,7 @@ git-ssh-fetch                           synchingrepositories
 git-ssh-upload                          synchingrepositories
 git-status                              mainporcelain
 git-stripspace                          purehelpers
+git-submodule                           mainporcelain
 git-svn                                 foreignscminterface
 git-svnimport                           foreignscminterface
 git-symbolic-ref                        plumbingmanipulators
index 7d9afe20f91c3922b909ef5e217c1b7640e2c600..a2057d9d24432c6092fa875454f2ebdd6b5dec89 100644 (file)
@@ -204,23 +204,16 @@ core.warnAmbiguousRefs::
        and might match multiple refs in the .git/refs/ tree. True by default.
 
 core.compression::
+       An integer -1..9, indicating a default compression level.
+       -1 is the zlib default. 0 means no compression,
+       and 1..9 are various speed/size tradeoffs, 9 being slowest.
+
+core.loosecompression::
        An integer -1..9, indicating the compression level for objects that
-       are not in a pack file. -1 is the zlib and git default. 0 means no
+       are not in a pack file. -1 is the zlib default. 0 means no
        compression, and 1..9 are various speed/size tradeoffs, 9 being
-       slowest.
-
-core.legacyheaders::
-       A boolean which
-       changes the format of loose objects so that they are more
-       efficient to pack and to send out of the repository over git
-       native protocol, since v1.4.2.  However, loose objects
-       written in the new format cannot be read by git older than
-       that version; people fetching from your repository using
-       older versions of git over dumb transports (e.g. http)
-       will also be affected.
-+
-To let git use the new loose object format, you have to
-set core.legacyheaders to false.
+       slowest.  If not set,  defaults to core.compression.  If that is
+       not set,  defaults to 0 (best speed).
 
 core.packedGitWindowSize::
        Number of bytes of a pack file to map into memory in a
@@ -397,6 +390,11 @@ format.suffix::
        `.patch`. Use this variable to change that suffix (make sure to
        include the dot if you want it).
 
+gc.aggressiveWindow::
+       The window size parameter used in the delta compression
+       algorithm used by 'git gc --aggressive'.  This defaults
+       to 10.
+
 gc.packrefs::
        `git gc` does not run `git pack-refs` in a bare repository by
        default so that older dumb-transport clients can still fetch
@@ -533,7 +531,7 @@ merge.summary::
 merge.tool::
        Controls which merge resolution program is used by
        gitlink:git-mergetool[l].  Valid values are: "kdiff3", "tkdiff",
-       "meld", "xxdiff", "emerge", "vimdiff", and "opendiff"
+       "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and "opendiff".
 
 merge.verbosity::
        Controls the amount of output shown by the recursive merge
@@ -563,6 +561,22 @@ pack.depth::
        The maximum delta depth used by gitlink:git-pack-objects[1] when no
        maximum depth is given on the command line. Defaults to 50.
 
+pack.compression::
+       An integer -1..9, indicating the compression level for objects
+       in a pack file. -1 is the zlib default. 0 means no
+       compression, and 1..9 are various speed/size tradeoffs, 9 being
+       slowest.  If not set,  defaults to core.compression.  If that is
+       not set,  defaults to -1.
+
+pack.deltaCacheSize::
+       The maxium memory in bytes used for caching deltas in
+       gitlink:git-pack-objects[1].
+       A value of 0 means no limit. Defaults to 0.
+
+pack.deltaCacheLimit::
+       The maxium size of a delta, that is cached in
+       gitlink:git-pack-objects[1]. Defaults to 1000.
+
 pull.octopus::
        The default merge strategy to use when pulling multiple branches
        at once.
@@ -668,5 +682,3 @@ receive.denyNonFastForwards::
 transfer.unpackLimit::
        When `fetch.unpackLimit` or `receive.unpackLimit` are
        not set, the value of this variable is used instead.
-
-
index 6b9b9ad7d1083ee09955ddaf46db4fad1a37834b..4fb6f4143cd849fc81f3ee5d2b8e4ee77e21137d 100644 (file)
@@ -9,11 +9,11 @@ repository, mainly because being hands-on and using explicit examples is
 often the best way of explaining what is going on.
 
 In normal life, most people wouldn't use the "core" git programs
-directly, but rather script around them to make them more palatable. 
+directly, but rather script around them to make them more palatable.
 Understanding the core git stuff may help some people get those scripts
 done, though, and it may also be instructive in helping people
 understand what it is that the higher-level helper scripts are actually
-doing. 
+doing.
 
 The core git is often called "plumbing", with the prettier user
 interfaces on top of it called "porcelain". You may not want to use the
@@ -41,7 +41,7 @@ Creating a new git repository couldn't be easier: all git repositories start
 out empty, and the only thing you need to do is find yourself a
 subdirectory that you want to use as a working tree - either an empty
 one for a totally new project, or an existing working tree that you want
-to import into git. 
+to import into git.
 
 For our first example, we're going to start a totally new repository from
 scratch, with no pre-existing files, and we'll call it `git-tutorial`.
@@ -169,7 +169,7 @@ $ ls .git/objects/??/*
 and see two files:
 
 ----------------
-.git/objects/55/7db03de997c86a4a028e1ebd3a1ceb225be238 
+.git/objects/55/7db03de997c86a4a028e1ebd3a1ceb225be238
 .git/objects/f2/4c74a2e500f5ee1332c86b94199f52b1d1d962
 ----------------
 
@@ -220,7 +220,7 @@ you have not actually really "checked in" your files into git so far,
 you've only *told* git about them.
 
 However, since git knows about them, you can now start using some of the
-most basic git commands to manipulate the files or look at their status. 
+most basic git commands to manipulate the files or look at their status.
 
 In particular, let's not even check in the two files into git yet, we'll
 start off by adding another line to `hello` first:
@@ -350,7 +350,7 @@ Making a change
 
 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? 
+state we saved in the index file?
 
 Further, remember how I said that `git-write-tree` writes the contents
 of the *index* file to the tree, and thus what we just committed was in
@@ -370,7 +370,7 @@ 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-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. 
+didn't have anything to diff against.
 
 But now we can do
 
@@ -379,7 +379,7 @@ $ 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. 
+will show us the same difference, but for a totally different reason.
 Now we're comparing the working tree not against the index file,
 but against the tree we just wrote. It just so happens that those two
 are obviously the same, so we get the same result.
@@ -398,7 +398,7 @@ 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-index \--cached -p HEAD` should thus return
-an empty set of differences, and that's exactly what it does. 
+an empty set of differences, and that's exactly what it does.
 
 [NOTE]
 ================
@@ -549,7 +549,7 @@ $ git-whatchanged -p --root
 ----------------
 
 and you will see exactly what has changed in the repository over its
-short history. 
+short history.
 
 [NOTE]
 The `\--root` flag is a flag to `git-diff-tree` to tell it to
@@ -637,7 +637,7 @@ So the mental model of "the git information is always tied directly to
 the working tree that it describes" may not be technically 100%
 accurate, but it's a good model for all normal use.
 
-This has two implications: 
+This has two implications:
 
  - if you grow bored with the tutorial repository you created (or you've
    made a mistake and want to start all over), you can just do simple
@@ -705,7 +705,7 @@ Many (most?) public remote repositories will not contain any of
 the checked out files or even an index file, and will *only* contain the
 actual core git files. Such a repository usually doesn't even have the
 `.git` subdirectory, but has all the git files directly in the
-repository. 
+repository.
 
 To create your own local live copy of such a "raw" git repository, you'd
 first create your own subdirectory for the project, and then copy the
@@ -718,7 +718,7 @@ $ cd my-git
 $ rsync -rL rsync://rsync.kernel.org/pub/scm/git/git.git/ .git
 ----------------
 
-followed by 
+followed by
 
 ----------------
 $ git-read-tree HEAD
@@ -738,7 +738,7 @@ 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-index to *force* overwriting of any old
-files). 
+files).
 
 Again, this can all be simplified with
 
@@ -751,7 +751,7 @@ $ git checkout
 which will end up doing all of the above for you.
 
 You have now successfully copied somebody else's (mine) remote
-repository, and checked it out. 
+repository, and checked it out.
 
 
 Creating a new branch
@@ -760,14 +760,14 @@ Creating a new branch
 Branches in git are really nothing more than pointers into the git
 object database from within the `.git/refs/` subdirectory, and as we
 already discussed, the `HEAD` branch is nothing but a symlink to one of
-these object pointers. 
+these object pointers.
 
 You can at any time create a new branch by just picking an arbitrary
 point in the project history, and just writing the SHA1 name of that
 object into a file under `.git/refs/heads/`. You can use any filename you
 want (and indeed, subdirectories), but the convention is that the
 "normal" branch is called `master`. That's just a convention, though,
-and nothing enforces it. 
+and nothing enforces it.
 
 To show that as an example, let's go back to the git-tutorial repository we
 used earlier, and create a branch in it. You do that by simply just
@@ -778,7 +778,7 @@ $ git checkout -b mybranch
 ------------
 
 will create a new branch based at the current `HEAD` position, and switch
-to it. 
+to it.
 
 [NOTE]
 ================================================
@@ -825,7 +825,7 @@ checking it out and switching to it. If so, just use the command
 $ git branch <branchname> [startingpoint]
 ------------
 
-which will simply _create_ the branch, but will not do anything further. 
+which will simply _create_ the branch, but will not do anything further.
 You can then later -- once you decide that you want to actually develop
 on that branch -- switch to that branch with a regular `git checkout`
 with the branchname as the argument.
@@ -884,7 +884,7 @@ $ gitk --all
 will show you graphically both of your branches (that's what the `\--all`
 means: normally it will just show you your current `HEAD`) and their
 histories. You can also see exactly how they came to be from a common
-source. 
+source.
 
 Anyway, let's exit `gitk` (`^Q` or the File menu), and decide that we want
 to merge the work we did on the `mybranch` branch into the `master`
@@ -905,8 +905,8 @@ of it as it can automatically (which in this case is just merge the `example`
 file, which had no differences in the `mybranch` branch), and say:
 
 ----------------
-       Auto-merging hello 
-       CONFLICT (content): Merge conflict in hello 
+       Auto-merging hello
+       CONFLICT (content): Merge conflict in hello
        Automatic merge failed; fix up by hand
 ----------------
 
@@ -1387,7 +1387,7 @@ repository. Kernel.org mirror network takes care of the
 propagation to other publicly visible machines:
 
 ------------
-$ git push master.kernel.org:/pub/scm/git/git.git/ 
+$ git push master.kernel.org:/pub/scm/git/git.git/
 ------------
 
 
index e38a1f14056b2e3cfe3c281eb7df7e5b44d520db..18d49d2c3baa81983b19a938598eb091fb7809ef 100644 (file)
@@ -1,7 +1,7 @@
 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 is 
+These commands all compare two sets of things; what is
 compared differs:
 
 git-diff-index <tree-ish>::
@@ -139,28 +139,28 @@ index fabadb8,cc95eb0..4866510
 --- a/describe.c
 +++ b/describe.c
 @@@ -98,20 -98,12 +98,20 @@@
-       return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
+       return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
   }
-  
+
 - static void describe(char *arg)
  -static void describe(struct commit *cmit, int last_one)
 ++static void describe(char *arg, int last_one)
   {
  +     unsigned char sha1[20];
  +     struct commit *cmit;
-       struct commit_list *list;
-       static int initialized = 0;
-       struct commit_name *n;
-  
+       struct commit_list *list;
+       static int initialized = 0;
+       struct commit_name *n;
+
  +     if (get_sha1(arg, sha1) < 0)
  +             usage(describe_usage);
  +     cmit = lookup_commit_reference(sha1);
  +     if (!cmit)
  +             usage(describe_usage);
  +
-       if (!initialized) {
-               initialized = 1;
-               for_each_ref(get_name);
+       if (!initialized) {
+               initialized = 1;
+               for_each_ref(get_name);
 ------------
 
 1.   It is preceded with a "git diff" header, that looks like
@@ -233,4 +233,3 @@ parents).  When shown by `git diff-files -c`, it compares the
 two unresolved merge parents with the working tree file
 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
 "their version").
-
index 1689c748171a8ff48395cf432aabe0130fc6b8d2..b2a05937f9c57e3a6ec70849fcc7aeca277b103b 100644 (file)
        that matches other criteria, nothing is selected.
 
 --find-copies-harder::
-       For performance reasons, by default, -C option finds copies only 
-       if the original file of the copy was modified in the same 
+       For performance reasons, by default, -C option finds copies only
+       if the original file of the copy was modified in the same
        changeset.  This flag makes the command
        inspect unmodified files as candidates for the source of
        copy.  This is a very expensive operation for large
index 34cd306bb1ee6ac73986cf3371114381b4165a0d..c6a983a5d54abe2b18d155b6cba520c257da6f59 100644 (file)
@@ -71,7 +71,7 @@ The first transformation in the chain is diffcore-pathspec, and
 is controlled by giving the pathname parameters to the
 git-diff-* commands on the command line.  The pathspec is used
 to limit the world diff operates in.  It removes the filepairs
-outside the specified set of pathnames.  E.g. If the input set 
+outside the specified set of pathnames.  E.g. If the input set
 of filepairs included:
 
 ------------------------------------------------
@@ -269,4 +269,3 @@ Documentation
 *.c
 t
 ------------------------------------------------
-
index 8821e305dd6d5df919e376d2d9c3d0d5716cc074..b878b385c6967f4c64ba30bdfe8f9bd24bef91e3 100644 (file)
-/*\r
-  CSS stylesheet for XHTML produced by DocBook XSL stylesheets.\r
-  Tested with XSL stylesheets 1.61.2, 1.67.2\r
-*/\r
-\r
-span.strong {\r
-  font-weight: bold;\r
-}\r
-\r
-body blockquote {\r
-  margin-top: .75em;\r
-  line-height: 1.5;\r
-  margin-bottom: .75em;\r
-}\r
-\r
-html body {\r
-  margin: 1em 5% 1em 5%;\r
-  line-height: 1.2;\r
-}\r
-\r
-body div {\r
-  margin: 0;\r
-}\r
-\r
-h1, h2, h3, h4, h5, h6,\r
-div.toc p b,\r
-div.list-of-figures p b,\r
-div.list-of-tables p b,\r
-div.abstract p.title\r
-{\r
-  color: #527bbd;\r
-  font-family: tahoma, verdana, sans-serif;\r
-}\r
-\r
-div.toc p:first-child,\r
-div.list-of-figures p:first-child,\r
-div.list-of-tables p:first-child,\r
-div.example p.title\r
-{\r
-  margin-bottom: 0.2em;\r
-}\r
-\r
-body h1 {\r
-  margin: .0em 0 0 -4%;\r
-  line-height: 1.3;\r
-  border-bottom: 2px solid silver;\r
-}\r
-\r
-body h2 {\r
-  margin: 0.5em 0 0 -4%;\r
-  line-height: 1.3;\r
-  border-bottom: 2px solid silver;\r
-}\r
-\r
-body h3 {\r
-  margin: .8em 0 0 -3%;\r
-  line-height: 1.3;\r
-}\r
-\r
-body h4 {\r
-  margin: .8em 0 0 -3%;\r
-  line-height: 1.3;\r
-}\r
-\r
-body h5 {\r
-  margin: .8em 0 0 -2%;\r
-  line-height: 1.3;\r
-}\r
-\r
-body h6 {\r
-  margin: .8em 0 0 -1%;\r
-  line-height: 1.3;\r
-}\r
-\r
-body hr {\r
-  border: none; /* Broken on IE6 */\r
-}\r
-div.footnotes hr {\r
-  border: 1px solid silver;\r
-}\r
-\r
-div.navheader th, div.navheader td, div.navfooter td {\r
-  font-family: sans-serif;\r
-  font-size: 0.9em;\r
-  font-weight: bold;\r
-  color: #527bbd;\r
-}\r
-div.navheader img, div.navfooter img {\r
-  border-style: none;\r
-}\r
-div.navheader a, div.navfooter a {\r
-  font-weight: normal;\r
-}\r
-div.navfooter hr {\r
-  border: 1px solid silver;\r
-}\r
-\r
-body td {\r
-  line-height: 1.2\r
-}\r
-\r
-body th {\r
-  line-height: 1.2;\r
-}\r
-\r
-ol {\r
-  line-height: 1.2;\r
-}\r
-\r
-ul, body dir, body menu {\r
-  line-height: 1.2;\r
-}\r
-\r
-html {\r
-  margin: 0; \r
-  padding: 0;\r
-}\r
-\r
-body h1, body h2, body h3, body h4, body h5, body h6 {\r
-  margin-left: 0\r
-} \r
-\r
-body pre {\r
-  margin: 0.5em 10% 0.5em 1em;\r
-  line-height: 1.0;\r
-  color: navy;\r
-}\r
-\r
-tt.literal, code.literal {\r
-  color: navy;\r
-}\r
-\r
-div.literallayout p {\r
-  padding: 0em;\r
-  margin: 0em;\r
-}\r
-\r
-div.literallayout {\r
-  font-family: monospace;\r
-#  margin: 0.5em 10% 0.5em 1em;\r
-  margin: 0em;\r
-  color: navy;\r
-  border: 1px solid silver;\r
-  background: #f4f4f4;\r
-  padding: 0.5em;\r
-}\r
-\r
-.programlisting, .screen {\r
-  border: 1px solid silver;\r
-  background: #f4f4f4;\r
-  margin: 0.5em 10% 0.5em 0;\r
-  padding: 0.5em 1em;\r
-}\r
-\r
-div.sidebar {\r
-  background: #ffffee;\r
-  margin: 1.0em 10% 0.5em 0;\r
-  padding: 0.5em 1em;\r
-  border: 1px solid silver;\r
-}\r
-div.sidebar * { padding: 0; }\r
-div.sidebar div { margin: 0; }\r
-div.sidebar p.title {\r
-  font-family: sans-serif;\r
-  margin-top: 0.5em;\r
-  margin-bottom: 0.2em;\r
-}\r
-\r
-div.bibliomixed {\r
-  margin: 0.5em 5% 0.5em 1em;\r
-}\r
-\r
-div.glossary dt {\r
-  font-weight: bold;\r
-}\r
-div.glossary dd p {\r
-  margin-top: 0.2em;\r
-}\r
-\r
-dl {\r
-  margin: .8em 0;\r
-  line-height: 1.2;\r
-}\r
-\r
-dt {\r
-  margin-top: 0.5em;\r
-}\r
-\r
-dt span.term {\r
-  font-style: italic;\r
-}\r
-\r
-div.variablelist dd p {\r
-  margin-top: 0;\r
-}\r
-\r
-div.itemizedlist li, div.orderedlist li {\r
-  margin-left: -0.8em;\r
-  margin-top: 0.5em;\r
-}\r
-\r
-ul, ol {\r
-    list-style-position: outside;\r
-}\r
-\r
-div.sidebar ul, div.sidebar ol {\r
-    margin-left: 2.8em;\r
-}\r
-\r
-div.itemizedlist p.title,\r
-div.orderedlist p.title,\r
-div.variablelist p.title\r
-{\r
-  margin-bottom: -0.8em;\r
-}\r
-\r
-div.revhistory table {\r
-  border-collapse: collapse;\r
-  border: none;\r
-}\r
-div.revhistory th {\r
-  border: none;\r
-  color: #527bbd;\r
-  font-family: tahoma, verdana, sans-serif;\r
-}\r
-div.revhistory td {\r
-  border: 1px solid silver;\r
-}\r
-\r
-/* Keep TOC and index lines close together. */\r
-div.toc dl, div.toc dt,\r
-div.list-of-figures dl, div.list-of-figures dt,\r
-div.list-of-tables dl, div.list-of-tables dt,\r
-div.indexdiv dl, div.indexdiv dt\r
-{\r
-  line-height: normal;\r
-  margin-top: 0;\r
-  margin-bottom: 0;\r
-}\r
-\r
-/*\r
-  Table styling does not work because of overriding attributes in\r
-  generated HTML.\r
-*/\r
-div.table table,\r
-div.informaltable table\r
-{\r
-    margin-left: 0;\r
-    margin-right: 5%;\r
-    margin-bottom: 0.8em;\r
-}\r
-div.informaltable table\r
-{\r
-    margin-top: 0.4em\r
-}\r
-div.table thead,\r
-div.table tfoot,\r
-div.table tbody,\r
-div.informaltable thead,\r
-div.informaltable tfoot,\r
-div.informaltable tbody\r
-{\r
-    /* No effect in IE6. */\r
-    border-top: 2px solid #527bbd;\r
-    border-bottom: 2px solid #527bbd;\r
-}\r
-div.table thead, div.table tfoot,\r
-div.informaltable thead, div.informaltable tfoot\r
-{\r
-    font-weight: bold;\r
-}\r
-\r
-div.mediaobject img {\r
-    border: 1px solid silver;\r
-    margin-bottom: 0.8em;\r
-}\r
-div.figure p.title,\r
-div.table p.title\r
-{\r
-  margin-top: 1em;\r
-  margin-bottom: 0.4em;\r
-}\r
-\r
-@media print {\r
-  div.navheader, div.navfooter { display: none; }\r
-}\r
+/*
+  CSS stylesheet for XHTML produced by DocBook XSL stylesheets.
+  Tested with XSL stylesheets 1.61.2, 1.67.2
+*/
+
+span.strong {
+  font-weight: bold;
+}
+
+body blockquote {
+  margin-top: .75em;
+  line-height: 1.5;
+  margin-bottom: .75em;
+}
+
+html body {
+  margin: 1em 5% 1em 5%;
+  line-height: 1.2;
+}
+
+body div {
+  margin: 0;
+}
+
+h1, h2, h3, h4, h5, h6,
+div.toc p b,
+div.list-of-figures p b,
+div.list-of-tables p b,
+div.abstract p.title
+{
+  color: #527bbd;
+  font-family: tahoma, verdana, sans-serif;
+}
+
+div.toc p:first-child,
+div.list-of-figures p:first-child,
+div.list-of-tables p:first-child,
+div.example p.title
+{
+  margin-bottom: 0.2em;
+}
+
+body h1 {
+  margin: .0em 0 0 -4%;
+  line-height: 1.3;
+  border-bottom: 2px solid silver;
+}
+
+body h2 {
+  margin: 0.5em 0 0 -4%;
+  line-height: 1.3;
+  border-bottom: 2px solid silver;
+}
+
+body h3 {
+  margin: .8em 0 0 -3%;
+  line-height: 1.3;
+}
+
+body h4 {
+  margin: .8em 0 0 -3%;
+  line-height: 1.3;
+}
+
+body h5 {
+  margin: .8em 0 0 -2%;
+  line-height: 1.3;
+}
+
+body h6 {
+  margin: .8em 0 0 -1%;
+  line-height: 1.3;
+}
+
+body hr {
+  border: none; /* Broken on IE6 */
+}
+div.footnotes hr {
+  border: 1px solid silver;
+}
+
+div.navheader th, div.navheader td, div.navfooter td {
+  font-family: sans-serif;
+  font-size: 0.9em;
+  font-weight: bold;
+  color: #527bbd;
+}
+div.navheader img, div.navfooter img {
+  border-style: none;
+}
+div.navheader a, div.navfooter a {
+  font-weight: normal;
+}
+div.navfooter hr {
+  border: 1px solid silver;
+}
+
+body td {
+  line-height: 1.2
+}
+
+body th {
+  line-height: 1.2;
+}
+
+ol {
+  line-height: 1.2;
+}
+
+ul, body dir, body menu {
+  line-height: 1.2;
+}
+
+html {
+  margin: 0;
+  padding: 0;
+}
+
+body h1, body h2, body h3, body h4, body h5, body h6 {
+  margin-left: 0
+}
+
+body pre {
+  margin: 0.5em 10% 0.5em 1em;
+  line-height: 1.0;
+  color: navy;
+}
+
+tt.literal, code.literal {
+  color: navy;
+}
+
+div.literallayout p {
+  padding: 0em;
+  margin: 0em;
+}
+
+div.literallayout {
+  font-family: monospace;
+#  margin: 0.5em 10% 0.5em 1em;
+  margin: 0em;
+  color: navy;
+  border: 1px solid silver;
+  background: #f4f4f4;
+  padding: 0.5em;
+}
+
+.programlisting, .screen {
+  border: 1px solid silver;
+  background: #f4f4f4;
+  margin: 0.5em 10% 0.5em 0;
+  padding: 0.5em 1em;
+}
+
+div.sidebar {
+  background: #ffffee;
+  margin: 1.0em 10% 0.5em 0;
+  padding: 0.5em 1em;
+  border: 1px solid silver;
+}
+div.sidebar * { padding: 0; }
+div.sidebar div { margin: 0; }
+div.sidebar p.title {
+  font-family: sans-serif;
+  margin-top: 0.5em;
+  margin-bottom: 0.2em;
+}
+
+div.bibliomixed {
+  margin: 0.5em 5% 0.5em 1em;
+}
+
+div.glossary dt {
+  font-weight: bold;
+}
+div.glossary dd p {
+  margin-top: 0.2em;
+}
+
+dl {
+  margin: .8em 0;
+  line-height: 1.2;
+}
+
+dt {
+  margin-top: 0.5em;
+}
+
+dt span.term {
+  font-style: italic;
+}
+
+div.variablelist dd p {
+  margin-top: 0;
+}
+
+div.itemizedlist li, div.orderedlist li {
+  margin-left: -0.8em;
+  margin-top: 0.5em;
+}
+
+ul, ol {
+    list-style-position: outside;
+}
+
+div.sidebar ul, div.sidebar ol {
+    margin-left: 2.8em;
+}
+
+div.itemizedlist p.title,
+div.orderedlist p.title,
+div.variablelist p.title
+{
+  margin-bottom: -0.8em;
+}
+
+div.revhistory table {
+  border-collapse: collapse;
+  border: none;
+}
+div.revhistory th {
+  border: none;
+  color: #527bbd;
+  font-family: tahoma, verdana, sans-serif;
+}
+div.revhistory td {
+  border: 1px solid silver;
+}
+
+/* Keep TOC and index lines close together. */
+div.toc dl, div.toc dt,
+div.list-of-figures dl, div.list-of-figures dt,
+div.list-of-tables dl, div.list-of-tables dt,
+div.indexdiv dl, div.indexdiv dt
+{
+  line-height: normal;
+  margin-top: 0;
+  margin-bottom: 0;
+}
+
+/*
+  Table styling does not work because of overriding attributes in
+  generated HTML.
+*/
+div.table table,
+div.informaltable table
+{
+    margin-left: 0;
+    margin-right: 5%;
+    margin-bottom: 0.8em;
+}
+div.informaltable table
+{
+    margin-top: 0.4em
+}
+div.table thead,
+div.table tfoot,
+div.table tbody,
+div.informaltable thead,
+div.informaltable tfoot,
+div.informaltable tbody
+{
+    /* No effect in IE6. */
+    border-top: 2px solid #527bbd;
+    border-bottom: 2px solid #527bbd;
+}
+div.table thead, div.table tfoot,
+div.informaltable thead, div.informaltable tfoot
+{
+    font-weight: bold;
+}
+
+div.mediaobject img {
+    border: 1px solid silver;
+    margin-bottom: 0.8em;
+}
+div.figure p.title,
+div.table p.title
+{
+  margin-top: 1em;
+  margin-bottom: 0.4em;
+}
+
+@media print {
+  div.navheader, div.navfooter { display: none; }
+}
index bdc7332c7b11c25957ee170b0582f9fe182755eb..da034223f3a0c07bc3451814ae8d087423f1e2f5 100644 (file)
@@ -52,4 +52,3 @@
        Deepen the history of a 'shallow' repository created by
        `git clone` with `--depth=<depth>` option (see gitlink:git-clone[1])
        by the specified number of commits.
-
index a0c9f68580594f785aaec0472ca8404701d4d86d..76d2b05854ccc742105c374fae33c676795d29f1 100644 (file)
@@ -228,4 +228,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index ba79773f79fc8823f1c611e51b163866ada26306..e4a6b3a6f0fc258e8a2052d1d56a71fb57667d39 100644 (file)
@@ -12,7 +12,7 @@ SYNOPSIS
 'git-am' [--signoff] [--dotest=<dir>] [--keep] [--utf8 | --no-utf8]
          [--3way] [--interactive] [--binary]
          [--whitespace=<option>] [-C<n>] [-p<n>]
-         <mbox>...
+         <mbox>|<Maildir>...
 'git-am' [--skip | --resolved]
 
 DESCRIPTION
@@ -23,9 +23,10 @@ current branch.
 
 OPTIONS
 -------
-<mbox>...::
+<mbox>|<Maildir>...::
        The list of mailbox files to read patches from. If you do not
-       supply this argument, reads from the standard input.
+       supply this argument, reads from the standard input. If you supply
+       directories, they'll be treated as Maildirs.
 
 -s, --signoff::
        Add `Signed-off-by:` line to the commit message, using
@@ -126,8 +127,7 @@ is terminated before the first occurrence of such a line.
 
 When initially invoking it, you give it names of the mailboxes
 to crunch.  Upon seeing the first patch that does not apply, it
-aborts in the middle, just like 'git-applymbox' does.  You can
-recover from this in one of two ways:
+aborts in the middle,.  You can recover from this in one of two ways:
 
 . skip the current patch by re-running the command with '--skip'
   option.
@@ -144,7 +144,7 @@ names.
 
 SEE ALSO
 --------
-gitlink:git-applymbox[1], gitlink:git-applypatch[1], gitlink:git-apply[1].
+gitlink:git-apply[1].
 
 
 Author
@@ -158,4 +158,3 @@ Documentation by Petr Baudis, Junio C Hamano and the git-list <git@vger.kernel.o
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 3bd2c995da7d65977481837486dc15e5e96baf91..f03f661652814d0900f3564c1914b217dc465a01 100644 (file)
@@ -183,4 +183,3 @@ Documentation by Junio C Hamano
 GIT
 ---
 Part of the gitlink:git[7] suite
-
diff --git a/Documentation/git-applymbox.txt b/Documentation/git-applymbox.txt
deleted file mode 100644 (file)
index ea919ba..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-git-applymbox(1)
-================
-
-NAME
-----
-git-applymbox - Apply a series of patches in a mailbox
-
-
-SYNOPSIS
---------
-'git-applymbox' [-u] [-k] [-q] [-m] ( -c .dotest/<num> | <mbox> ) [ <signoff> ]
-
-DESCRIPTION
------------
-Splits mail messages in a mailbox into commit log message,
-authorship information and patches, and applies them to the
-current branch.
-
-
-OPTIONS
--------
--q::
-       Apply patches interactively.  The user will be given
-       opportunity to edit the log message and the patch before
-       attempting to apply it.
-
--k::
-       Usually the program 'cleans up' the Subject: header line
-       to extract the title line for the commit log message,
-       among which (1) remove 'Re:' or 're:', (2) leading
-       whitespaces, (3) '[' up to ']', typically '[PATCH]', and
-       then prepends "[PATCH] ".  This flag forbids this
-       munging, and is most useful when used to read back 'git
-       format-patch -k' output.
-
--m::
-       Patches are applied with `git-apply` command, and unless
-       it cleanly applies without fuzz, the processing fails.
-       With this flag, if a tree that the patch applies cleanly
-       is found in a repository, the patch is applied to the
-       tree and then a 3-way merge between the resulting tree
-       and the current tree.
-
--u::
-       Pass `-u` flag to `git-mailinfo` (see gitlink:git-mailinfo[1]).
-       The proposed commit log message taken from the e-mail
-       are re-coded into UTF-8 encoding (configuration variable
-       `i18n.commitencoding` can be used to specify project's
-       preferred encoding if it is not UTF-8).  This used to be
-       optional but now it is the default.
-+
-Note that the patch is always used as-is without charset
-conversion, even with this flag.
-
--n::
-       Pass `-n` flag to `git-mailinfo` (see
-       gitlink:git-mailinfo[1]).
-
--c .dotest/<num>::
-       When the patch contained in an e-mail does not cleanly
-       apply, the command exits with an error message. The
-       patch and extracted message are found in .dotest/, and
-       you could re-run 'git applymbox' with '-c .dotest/<num>'
-       flag to restart the process after inspecting and fixing
-       them.
-
-<mbox>::
-       The name of the file that contains the e-mail messages
-       with patches.  This file should be in the UNIX mailbox
-       format.  See 'SubmittingPatches' document to learn about
-       the formatting convention for e-mail submission.
-
-<signoff>::
-       The name of the file that contains your "Signed-off-by"
-       line.  See 'SubmittingPatches' document to learn what
-       "Signed-off-by" line means.  You can also just say
-       'yes', 'true', 'me', or 'please' to use an automatically
-       generated "Signed-off-by" line based on your committer
-       identity.
-
-
-SEE ALSO
---------
-gitlink:git-am[1], gitlink:git-applypatch[1].
-
-
-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 gitlink:git[7] suite
-
diff --git a/Documentation/git-applypatch.txt b/Documentation/git-applypatch.txt
deleted file mode 100644 (file)
index 451434a..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-git-applypatch(1)
-=================
-
-NAME
-----
-git-applypatch - Apply one patch extracted from an e-mail
-
-
-SYNOPSIS
---------
-'git-applypatch' <msg> <patch> <info> [<signoff>]
-
-DESCRIPTION
------------
-This is usually not what an end user wants to run directly.  See
-gitlink:git-am[1] instead.
-
-Takes three files <msg>, <patch>, and <info> prepared from an
-e-mail message by 'git-mailinfo', and creates a commit.  It is
-usually not necessary to use this command directly.
-
-This command can run `applypatch-msg`, `pre-applypatch`, and
-`post-applypatch` hooks.  See link:hooks.html[hooks] for more
-information.
-
-
-OPTIONS
--------
-<msg>::
-       Commit log message (sans the first line, which comes
-       from e-mail Subject stored in <info>).
-
-<patch>::
-       The patch to apply.
-
-<info>::
-       Author and subject information extracted from e-mail,
-       used on "author" line and as the first line of the
-       commit log message.
-
-
-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 gitlink:git[7] suite
-
index 82cb41d2791abbd32bd8209660e9879b9f2b8f32..7091b8d61cf4871e2cecc7b18bc6997ea42b4ef9 100644 (file)
@@ -17,26 +17,26 @@ DESCRIPTION
 Imports a project from one or more Arch repositories. It will follow branches
 and repositories within the namespaces defined by the <archive/branch>
 parameters supplied. If it cannot find the remote branch a merge comes from
-it will just import it as a regular commit. If it can find it, it will mark it 
-as a merge whenever possible (see discussion below). 
+it will just import it as a regular commit. If it can find it, it will mark it
+as a merge whenever possible (see discussion below).
 
-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 follow and 
-import new branches within the provided roots. 
+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 follow and
+import new branches within the provided roots.
 
-It expects to be dealing with one project only. If it sees 
-branches that have different roots, it will refuse to run. In that case, 
-edit your <archive/branch> parameters to define clearly the scope of the 
-import. 
+It expects to be dealing with one project only. If it sees
+branches that have different roots, it will refuse to run. In that case,
+edit your <archive/branch> parameters to define clearly the scope of the
+import.
 
-`git-archimport` uses `tla` extensively in the background to access the 
+`git-archimport` uses `tla` extensively in the background to access the
 Arch repository.
 Make sure you have a recent version of `tla` available in the path. `tla` must
-know about the repositories you pass to `git-archimport`. 
+know about the repositories you pass to `git-archimport`.
 
-For the initial import `git-archimport` expects to find itself in an empty 
-directory. To follow the development of a project that uses Arch, rerun 
-`git-archimport` with the same parameters as the initial import to perform 
+For the initial import `git-archimport` expects to find itself in an empty
+directory. To follow the development of a project that uses Arch, rerun
+`git-archimport` with the same parameters as the initial import to perform
 incremental imports.
 
 While git-archimport will try to create sensible branch names for the
@@ -54,15 +54,15 @@ convert Arch repositories that had been rotated periodically.
 
 MERGES
 ------
-Patch merge data from Arch is used to mark merges in git as well. git 
+Patch merge data from Arch is used to mark merges in git as well. git
 does not care much about tracking patches, and only considers a merge when a
 branch incorporates all the commits since the point they forked. The end result
-is that git will have a good idea of how far branches have diverged. So the 
+is that git will have a good idea of how far branches have diverged. So the
 import process does lose some patch-trading metadata.
 
-Fortunately, when you try and merge branches imported from Arch, 
-git will find a good merge base, and it has a good chance of identifying 
-patches that have been traded out-of-sequence between the branches. 
+Fortunately, when you try and merge branches imported from Arch,
+git will find a good merge base, and it has a good chance of identifying
+patches that have been traded out-of-sequence between the branches.
 
 OPTIONS
 -------
@@ -71,10 +71,10 @@ OPTIONS
        Display usage.
 
 -v::
-       Verbose output. 
+       Verbose output.
 
 -T::
-       Many tags. Will create a tag for every commit, reflecting the commit 
+       Many tags. Will create a tag for every commit, reflecting the commit
        name in the Arch repository.
 
 -f::
@@ -104,7 +104,7 @@ OPTIONS
 
 
 <archive/branch>::
-       Archive/branch identifier in a format that `tla log` understands. 
+       Archive/branch identifier in a format that `tla log` understands.
 
 
 Author
@@ -118,4 +118,3 @@ Documentation by Junio C Hamano, Martin Langhoff and the git-list <git@vger.kern
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 5f68ee1584b294a9395f2a3d4f29e0b1208f5913..1072fb87d1fe38a74dc38e2d6886acfb44d9262b 100644 (file)
@@ -8,7 +8,7 @@ git-bisect - Find the change that introduced a bug by binary search
 
 SYNOPSIS
 --------
-'git bisect' <subcommand> <options> 
+'git bisect' <subcommand> <options>
 
 DESCRIPTION
 -----------
@@ -200,4 +200,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 8dc5171f5e685ab18d466751710f44e8aba104b7..8d72bb93680332da560b5b1e55a3d42c4755247c 100644 (file)
@@ -158,4 +158,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 075c0d05efca85c2357e09aa640aa4b7f0305419..afa095c79529dc92d5db6c54effd435c57f5eb7a 100644 (file)
@@ -71,4 +71,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index ceb51959b1d28a7298ddd42b0e3e968c568195a7..856d2af2ed9c1ccfcd819191060447b62e49b8b6 100644 (file)
@@ -34,4 +34,3 @@ Documentation by James Bowes.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 6dd6db04bb91ae97472ce40d6b76ff8d409b99f7..b1a8ce110cd3caa641a53e7944479bb8f84bec44 100644 (file)
@@ -182,4 +182,3 @@ Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 918d8ee720a573f91ec6efa654da5c2cdc05d7b0..ea26da8e21030883e3655dcbc28ad06a4e3816f5 100644 (file)
@@ -215,4 +215,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 68bba982606b5e17b730f0e5d4d201923231c235..47b1e8c2fcd567b7e9d673f2d3ff30c9c32a1b83 100644 (file)
@@ -68,4 +68,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 27b67b81a58956c48452b7aee46b9742ca02e31a..b62c97097f1d66a26767a304a59b83bca7b727ee 100644 (file)
@@ -64,4 +64,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index ac938d39df7a4b5b5ea3e4ca8cb2cf505fc49752..4a5bab510eb9346d815522f9c9df9af6b0a850a3 100644 (file)
@@ -175,4 +175,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 504a3aa1b460ffac9308bec4ff72cf657f8fec30..9586b9729151efd64b3cf5f5d511dd39b664e08e 100644 (file)
@@ -40,7 +40,7 @@ OPTIONS
 
 -p <parent commit>::
        Each '-p' indicates the id of a parent commit object.
-       
+
 
 Commit Information
 ------------------
@@ -107,4 +107,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 056b14724c4058ce7443264303713bbdc899f04c..f2c67176f451483abdbe862fd5d1cc8fe6b67aac 100644 (file)
@@ -291,4 +291,3 @@ Documentation by Johannes Schindelin, Petr Baudis and the git-list <git@vger.ker
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index b1220c06e193ddf3942da6e5e0faf91368d0886a..9718abf86d8cd36ddae1eae8cf2337e35b927959 100644 (file)
@@ -26,4 +26,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 91c8c92c76648ed5bfdaab6b991e7cb1ce519733..81614111a4bb3bf8ab62650876189ceee5bd6c9e 100644 (file)
@@ -35,4 +35,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index fd7f54093fc3d0a85126a0826affb712096aa144..827711c3c9b8ad8c7ecb074c5ec1a9b887992526 100644 (file)
@@ -8,25 +8,25 @@ git-cvsexportcommit - Export a single commit to a CVS checkout
 
 SYNOPSIS
 --------
-'git-cvsexportcommit' [-h] [-v] [-c] [-P] [-p] [-a] [-d cvsroot] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
+'git-cvsexportcommit' [-h] [-u] [-v] [-c] [-P] [-p] [-a] [-d cvsroot] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
 
 
 DESCRIPTION
 -----------
 Exports a commit from GIT to a CVS checkout, making it easier
-to merge patches from a git repository into a CVS repository. 
+to merge patches from a git repository into a CVS repository.
 
-Execute it from the root of the CVS working copy. GIT_DIR must be defined. 
+Execute it from the root of the CVS working copy. GIT_DIR must be defined.
 See examples below.
 
-It does its best to do the safe thing, it will check that the files are 
-unchanged and up to date in the CVS checkout, and it will not autocommit 
+It does its best to do the safe thing, it will check that the files are
+unchanged and up to date in the CVS checkout, and it will not autocommit
 by default.
 
 Supports file additions, removals, and commits that affect binary files.
 
 If the commit is a merge commit, you must tell git-cvsexportcommit what parent
-should the changeset be done against. 
+should the changeset be done against.
 
 OPTIONS
 -------
@@ -55,9 +55,12 @@ OPTIONS
        Force the parent commit, even if it is not a direct parent.
 
 -m::
-       Prepend the commit message with the provided prefix. 
+       Prepend the commit message with the provided prefix.
        Useful for patch series and the like.
 
+-u::
+       Update affected files from cvs repository before attempting export.
+
 -v::
        Verbose.
 
@@ -70,7 +73,7 @@ Merge one patch into CVS::
 $ export GIT_DIR=~/project/.git
 $ cd ~/project_cvs_checkout
 $ git-cvsexportcommit -v <commit-sha1>
-$ cvs commit -F .mgs <files> 
+$ cvs commit -F .mgs <files>
 ------------
 
 Merge pending patches into CVS automatically -- only if you really know what you are doing ::
@@ -92,4 +95,3 @@ Documentation by Martin Langhoff <martin@catalyst.net.nz>
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index e0be8565468c0b278147abc3e83eb7d19f481a40..3985e0164b3f320258a5f6b2699a9145a30e5e43 100644 (file)
@@ -37,7 +37,7 @@ 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 
+       currently, only the :local:, :ext: and :pserver: access methods
        are supported. If not given, git-cvsimport will try to read it
        from `CVS/Root`. If no such file exists, it checks for the
        `CVSROOT` environment variable.
@@ -67,7 +67,7 @@ the old cvs2git tool.
 -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. 
+       to preserve compatibility with early imported trees.
 
 -u::
        Convert underscores in tag and branch names to dots.
@@ -89,15 +89,15 @@ If you need to pass multiple options, separate them with a comma.
        Instead of calling cvsps, read the provided cvsps output file. Useful
        for debugging or when cvsps is being handled outside cvsimport.
 
--m::    
+-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. 
+       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. 
+       You must escape forward slashes.
 
 -S <regex>::
        Skip paths matching the regex.
@@ -156,4 +156,3 @@ Documentation by Matthias Urlichs <smurf@smurf.noris.de>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 9ddab712031cc2b71ccfc83dd5b6b475b5bfc809..4b30b18b427c6f4922ce44eee68042c036a6e806 100644 (file)
@@ -235,4 +235,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 47a583d3a605d95fb860e6ea7142cebf374ec5aa..ac23e28f2759222bb67fcf2445c229e918d96211 100644 (file)
@@ -8,7 +8,7 @@ git-describe - Show the most recent tag that is reachable from a commit
 
 SYNOPSIS
 --------
-'git-describe' [--all] [--tags] [--abbrev=<n>] <committish>...
+'git-describe' [--all] [--tags] [--contains] [--abbrev=<n>] <committish>...
 
 DESCRIPTION
 -----------
@@ -31,6 +31,11 @@ OPTIONS
        Instead of using only the annotated tags, use any tag
        found in `.git/refs/tags`.
 
+--contains::
+       Instead of finding the tag that predates the commit, find
+       the tag that comes after the commit, and thus contains it.
+       Automatically implies --tags.
+
 --abbrev=<n>::
        Instead of using the default 8 hexadecimal digits as the
        abbreviated object name, use <n> digits.
@@ -119,4 +124,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 2e1e29ef5ae633a005e35f656f30ce66e343de7a..d8a0a86022b805eabe3516fe980d6c626abfa68e 100644 (file)
@@ -26,7 +26,7 @@ include::diff-options.txt[]
        branch" respectively.  With these options, diffs for
        merged entries are not shown.
 +
-The default is to diff against our branch (-2) and the 
+The default is to diff against our branch (-2) and the
 cleanly resolved paths.  The option -0 can be given to
 omit diff output for unmerged entries and just show "Unmerged".
 
@@ -58,4 +58,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 2df581c2c9e598c676fcb95c35c91209d15562ca..7bd262cefd68efe84ff0c405af5eabcdc6f01be8 100644 (file)
@@ -75,7 +75,7 @@ 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 
+asking yourself "what have I already marked for being committed, and
 what's the difference to a previous tree".
 
 Non-cached Mode
@@ -130,4 +130,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 6e660e2d08c2d9d795b5ccfb91f755160cf58930..6b3f74efe7405b2b1c2d92a975aadb4363a67be0 100644 (file)
@@ -166,4 +166,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 044cee9b425bedc7addd9a4418b553557902711b..639b969315d4c9c6ece95cdeb10c2f92bd17adab 100644 (file)
@@ -138,4 +138,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 8d06775a6bd5f4ac8bd5a20fba67f76c121380ee..5eacab08dc2141360209534bc38a5fc8b7a05b75 100644 (file)
@@ -908,4 +908,3 @@ Documentation by Shawn O. Pearce <spearce@spearce.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 4913c2552f9a092dbd982b55c7e7cb2ffc986570..6affc5bb4d1730805e1704af1045bb71ca896dbb 100644 (file)
@@ -60,4 +60,3 @@ Documentation by Petr Baudis, Junio C Hamano and the git-list <git@vger.kernel.o
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index a33d157b970740aa7d056ebb459350de89513a8b..647de90361b30aeb39b4b2707a295e21863510ee 100644 (file)
@@ -11,7 +11,8 @@ SYNOPSIS
 [verse]
 'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--thread]
                    [--attach[=<boundary>] | --inline[=<boundary>]]
-                   [-s | --signoff] [<common diff options>] [--start-number <n>]
+                   [-s | --signoff] [<common diff options>]
+                   [--start-number <n>] [--numbered-files]
                    [--in-reply-to=Message-Id] [--suffix=.<sfx>]
                    [--ignore-if-in-upstream]
                    [--subject-prefix=Subject-Prefix]
@@ -30,9 +31,11 @@ gitlink:git-rev-parse[1].
 The output of this command is convenient for e-mail submission or
 for use with gitlink:git-am[1].
 
-Each output file is numbered sequentially from 1, and uses the
+By default, each output file is numbered sequentially from 1, and uses the
 first line of the commit message (massaged for pathname safety) as
-the filename. The names of the output files are printed to standard
+the filename. With the --numbered-files option, the output file names
+will only be numbers, without the first line of the commit appended.
+The names of the output files are printed to standard
 output, unless the --stdout option is specified.
 
 If -o is specified, output files are created in <dir>.  Otherwise
@@ -60,6 +63,11 @@ include::diff-options.txt[]
 --start-number <n>::
        Start numbering the patches at <n> instead of 1.
 
+--numbered-files::
+       Output file names will be a simple number sequence
+       without the default first line of the commit appended.
+       Mutually exclusive with the --stdout option.
+
 -k|--keep-subject::
        Do not strip/add '[PATCH]' from the first line of the
        commit log message.
@@ -170,4 +178,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 8c68cf037259b3abc7ea16952d232b2fb2f07a25..234c22f57f49181e847d5ccc4f0d71998ce29787 100644 (file)
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git-fsck' [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]
-                [--full] [--strict] [<object>*]
+                [--full] [--strict] [--verbose] [<object>*]
 
 DESCRIPTION
 -----------
@@ -61,6 +61,9 @@ index file and all SHA1 references in .git/refs/* as heads.
        objects that triggers this check, but it is recommended
        to check new projects with this flag.
 
+--verbose::
+       Be chatty.
+
 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
@@ -142,4 +145,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index bc1658434a61bdba41699859f103a3c8e0802d95..c7742ca9630b13d1eeef16d175f8ca840ddff4b0 100644 (file)
@@ -8,7 +8,7 @@ git-gc - Cleanup unnecessary files and optimize the local repository
 
 SYNOPSIS
 --------
-'git-gc' [--prune]
+'git-gc' [--prune] [--aggressive]
 
 DESCRIPTION
 -----------
@@ -35,6 +35,13 @@ OPTIONS
        repository at the same time (e.g. never use this option
        in a cron script).
 
+--aggressive::
+       Usually 'git-gc' runs very quickly while providing good disk
+       space utilization and performance.  This option will cause
+       git-gc to more aggressively optimize the repository at the expense
+       of taking much more time.  The effects of this optimization are
+       persistent, so this option only needs to be used occasionally; every
+       few hundred changesets or so.
 
 Configuration
 -------------
@@ -67,6 +74,13 @@ The optional configuration variable 'gc.packrefs' determines if
 is not run in bare repositories by default, to allow older dumb-transport
 clients fetch from the repository,  but this will change in the future.
 
+The optional configuration variable 'gc.aggressiveWindow' controls how
+much time is spent optimizing the delta compression of the objects in
+the repository when the --aggressive option is specified.  The larger
+the value, the more time is spent optimizing the delta compression.  See
+the documentation for the --window' option in gitlink:git-repack[1] for
+more details.  This defaults to 10.
+
 See Also
 --------
 gitlink:git-prune[1]
index 48805b651ca8161a87448f307b45c9e9d4df3c0f..9b5f86fc30aecc5e1183e514d5d0f81d14a751c3 100644 (file)
@@ -34,4 +34,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index c5a5dad1ce27dde6c3846beaf7ab2f7aa8ed81c8..97faaa1d3a9d8c7025ab33c3126ba10e4c5ed708 100644 (file)
@@ -144,4 +144,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 5edc36f060f7cf6444dd016cbb7e073af923f5db..616f196d81ca54595dc67f4846bace5880b9b90d 100644 (file)
@@ -18,7 +18,7 @@ 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" to update the index
 without modifying files in the work tree.  When <type> is not
-specified, it defaults to "blob". 
+specified, it defaults to "blob".
 
 OPTIONS
 -------
@@ -43,4 +43,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 4deabc376c6698408bee032409434bd7e32740a4..45e48453a17d70c559cbc65477cad6610abc5928 100644 (file)
@@ -54,4 +54,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index a15cf5b2a30a6ed2c207622c767d131346936a06..9afb860381369767a0a3f5295f588b75f559ff22 100644 (file)
@@ -52,7 +52,7 @@ Specifying the Refs
 
 A '<ref>' specification can be either a single pattern, or a pair
 of such patterns separated by a colon ":" (this means that a ref name
-cannot have a colon in it).  A single pattern '<name>' is just a 
+cannot have a colon in it).  A single pattern '<name>' is just a
 shorthand for '<name>:<name>'.
 
 Each pattern pair consists of the source side (before the colon)
index 226926964e5f3e6620f20b23b74c0299a168d07f..a8a7f6f04bf5b95a5b325dc2df0adf9d94532bc5 100644 (file)
@@ -98,4 +98,3 @@ Documentation by Sergey Vlasov
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 5412135d763af3a8c68e18441b774654f07eadfd..ab0201aec2131d48b535cf6307fc446dffd89a9b 100644 (file)
@@ -16,4 +16,3 @@ DESCRIPTION
 
 This is a synonym for gitlink:git-init[1].  Please refer to the
 documentation of that command.
-
index 1b64d3ab03c2e13807e24833823193021559d947..413ed65143d90b32a9b77301953f45bc26465e7d 100644 (file)
@@ -108,4 +108,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 9df0ab2d76f6f024a138a84a7fd3c442342c1b88..cec60ee78075aa4411cd637aece93fc38080b0c5 100644 (file)
@@ -82,4 +82,3 @@ Documentation by Eric Wong <normalperson@yhbt.net>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 51389ef37da443c981f3bb5d46f819e90c3d2980..19b5f8895c329877167a4f625f33971d498185ae 100644 (file)
@@ -62,4 +62,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 0f353f6558e5843b1534f4cb9acd75746c313510..6157edb404db3ff0db0bb21e826e140037acb6af 100644 (file)
@@ -101,4 +101,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index a78a9ff1b85d1c8cf003ddab63b8412cf3083657..997594549fbf5a1e50a7d187c3cebcbe93461455 100644 (file)
@@ -180,4 +180,3 @@ Documentation by David Greaves, Junio C Hamano, Josh Triplett, and the git-list
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index c254005ca39e6872b8ec7b729246d18757df31d1..93e9a60330797070fc50c0df6c0767b7b81f79c0 100644 (file)
@@ -70,4 +70,3 @@ Written by Junio C Hamano <junkio@cox.net>
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 78993940811c96752e87f7b9e7c1381066056950..7b7859967326acaff157eab01da16b83c1342fcc 100644 (file)
@@ -9,7 +9,7 @@ git-ls-tree - List the contents of a tree object
 SYNOPSIS
 --------
 [verse]
-'git-ls-tree' [-d] [-r] [-t] [-z]
+'git-ls-tree' [-d] [-r] [-t] [-l] [-z]
            [--name-only] [--name-status] [--full-name] [--abbrev=[<n>]]
            <tree-ish> [paths...]
 
@@ -36,6 +36,10 @@ OPTIONS
        Show tree entries even when going to recurse them. Has no effect
        if '-r' was not passed. '-d' implies '-t'.
 
+-l::
+--long::
+       Show object size of blob (file) entries.
+
 -z::
        \0 line termination on output.
 
@@ -65,6 +69,14 @@ Output Format
 When the `-z` option is not used, TAB, LF, and backslash characters
 in pathnames are represented as `\t`, `\n`, and `\\`, respectively.
 
+When the `-l` option is used, format changes to
+
+        <mode> SP <type> SP <object> SP <object size> TAB <file>
+
+Object size identified by <object> is given in bytes, and right-justified
+with minimum width of 7 characters.  Object size is given only for blobs
+(file) entries; for other entries `-` character is used in place of size.
+
 
 Author
 ------
@@ -80,4 +92,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 8eadcebfcf5c26c599cde0d939d1046de69f2335..64aa6a1ea6bca248e7078efcecb3d582cf8a0f5f 100644 (file)
@@ -16,7 +16,7 @@ DESCRIPTION
 Reading a single e-mail message from the standard input, and
 writes the commit log message in <msg> file, and the patches in
 <patch> file.  The author name, e-mail and e-mail subject are
-written out to the standard output to be used by git-applypatch
+written out to the standard output to be used by git-am
 to create a commit.  It is usually not necessary to use this
 command directly.  See gitlink:git-am[1] instead.
 
@@ -67,4 +67,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index c11d6a530f67857bb28a5b3cee48bc5b01f5cb92..c4f4cabbdcdaae18491c301d44fd68ae89b18352 100644 (file)
@@ -7,12 +7,15 @@ git-mailsplit - Simple UNIX mbox splitter program
 
 SYNOPSIS
 --------
-'git-mailsplit' [-b] [-f<nn>] [-d<prec>] -o<directory> [--] [<mbox>...]
+'git-mailsplit' [-b] [-f<nn>] [-d<prec>] -o<directory> [--] [<mbox>|<Maildir>...]
 
 DESCRIPTION
 -----------
-Splits a mbox file into a list of files: "0001" "0002" ..  in the specified
-directory so you can process them further from there.
+Splits a mbox file or a Maildir into a list of files: "0001" "0002" ..  in the
+specified directory so you can process them further from there.
+
+IMPORTANT: Maildir splitting relies upon filenames being sorted to output
+patches in the correct order.
 
 OPTIONS
 -------
@@ -20,6 +23,10 @@ OPTIONS
        Mbox file to split.  If not given, the mbox is read from
        the standard input.
 
+<Maildir>::
+       Root of the Maildir to split. This directory should contain the cur, tmp
+       and new subdirectories.
+
 <directory>::
        Directory in which to place the individual messages.
 
@@ -49,4 +56,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 3190aed10885b5f3471dfc30922c141835d6c4f1..6b71880ec45455b1e62c3e1582d4cf78f2ed4852 100644 (file)
@@ -40,4 +40,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index b8ee1ff2b0681ea9fbc83618b1d09d95f3a902ff..17e9f10c659844e55e56b0d3a005e5f250f43c20 100644 (file)
@@ -59,7 +59,7 @@ Examples:
   This is modified MM in the branch B.                 # merge2
   This is modified MM in the branch B.                 # current contents
 
-or 
+or
 
   torvalds@ppc970:~/merge-test> git-merge-index cat AA MM
   cat: : No such file or directory
@@ -85,4 +85,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index f80ab3b8c479d787e116298f5446d1ff57ff2774..f35d0e1b4560a4970e7423011b585e1ff7d538c1 100644 (file)
@@ -27,4 +27,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 35fb4fb713bac225c665b6d7701efc9f105b9c16..6892fdac3df054e87019318c524185109ea16200 100644 (file)
@@ -34,4 +34,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 9c08efa53abc2797a7b7ca0e589d83b9a4387987..d285cba033325f8652996ea71a06d53c22424dae 100644 (file)
@@ -9,7 +9,7 @@ git-merge - Join two or more development histories together
 SYNOPSIS
 --------
 [verse]
-'git-merge' [-n] [--no-commit] [--squash] [-s <strategy>]...
+'git-merge' [-n] [--summary] [--no-commit] [--squash] [-s <strategy>]...
        [-m <msg>] <remote> <remote>...
 
 DESCRIPTION
@@ -95,7 +95,7 @@ When things cleanly merge, these things happen:
 1. the results are updated both in the index file and in your
    working tree,
 2. index file is written out as a tree,
-3. the tree gets committed, and 
+3. the tree gets committed, and
 4. the `HEAD` pointer gets advanced.
 
 Because of 2., we require that the original state of the index
index add01e855a09c34b6aa9c83af6efcd17f24f3c9d..6c32c6d18ead2047ce590e2853bbc1a5a2dd1e7c 100644 (file)
@@ -25,7 +25,7 @@ OPTIONS
 -t or --tool=<tool>::
        Use the merge resolution program specified by <tool>.
        Valid merge tools are:
-       kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, and opendiff
+       kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, and opendiff
 +
 If a merge resolution program is not specified, 'git mergetool'
 will use the configuration variable merge.tool.  If the
@@ -43,4 +43,3 @@ Documentation by Theodore Y Ts'o.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 2860a3d1ba54c712bb30febfa37693f3efbdb7bf..ea7a75234a91b0dade03b8e19d4ba7d0d1a82f63 100644 (file)
@@ -19,18 +19,18 @@ The output is the new tag's <object> identifier.
 
 Tag Format
 ----------
-A tag signature file has a very simple fixed format: three lines of
+A tag signature file has a very simple fixed format: four lines of
 
   object <sha1>
   type <typename>
   tag <tagname>
+  tagger <tagger>
 
-followed by some 'optional' free-form signature that git itself
-doesn't care about, but that can be verified with gpg or similar.
-
-The size of the full object is artificially limited to 8kB.  (Just
-because I'm a lazy bastard, and if you can't fit a signature in that
-size, you're doing something wrong)
+followed by some 'optional' free-form message (some tags created
+by older git may not have `tagger` line).  The message, when
+exists, is separated by a blank line from the header.  The
+message part may contain a signature that git itself doesn't
+care about, but that can be verified with gpg.
 
 
 Author
@@ -44,4 +44,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 5f9ee603b758ea251a438399a642fa60d364aca2..638abc7d0f7425749339b1519cab5c0586e96138 100644 (file)
@@ -32,4 +32,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 6756b76bb11bc17279c3f20c16d7b4ba131f5832..2c9cf743c7a097ab955938d023e347e866fbc13e 100644 (file)
@@ -51,4 +51,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index d6c8bf800f4456ea63ff7d9b0c01b2d4f0d9d179..91eede120e5e192ac8ce3a483dd6a88dce414333 100644 (file)
@@ -34,6 +34,13 @@ OPTIONS
        Read from stdin, append "(<rev_name>)" to all sha1's of nameable
        commits, and pass to stdout
 
+--name-only::
+       Instead of printing both the SHA-1 and the name, print only
+       the name.  If given with --tags the usual tag prefix of
+       "tags/" is also ommitted from the name, matching the output
+       of gitlink::git-describe[1] more closely.  This option
+       cannot be combined with --stdin.
+
 EXAMPLE
 -------
 
@@ -69,4 +76,3 @@ Documentation by Johannes Schindelin.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 714abbe28ecfef592d0a7892dccbe88c8f66967c..9967587fe6bef0cf7cc3e93467bd179f6f58b032 100644 (file)
@@ -165,4 +165,3 @@ Written by Sean Estabrooks <seanlkml@sympatico.ca>
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index bd3ee456e336add5d880d6a1192646220e7c34d7..e3549b50442bea1734812ec40331adb7e3d41ef7 100644 (file)
@@ -85,6 +85,11 @@ base-name::
        times to get to the necessary object.
        The default value for --window is 10 and --depth is 50.
 
+--max-pack-size=<n>::
+       Maximum size of each output packfile, expressed in MiB.
+       If specified,  multiple packfiles may be created.
+       The default is unlimited.
+
 --incremental::
        This flag causes an object already in a pack ignored
        even if it appears in the standard input.
@@ -127,6 +132,25 @@ base-name::
        This flag tells the command not to reuse existing deltas
        but compute them from scratch.
 
+--no-reuse-object::
+       This flag tells the command not to reuse existing object data at all,
+       including non deltified object, forcing recompression of everything.
+       This implies --no-reuse-delta. Useful only in the obscure case where
+       wholesale enforcement of a different compression level on the
+       packed data is desired.
+
+--compression=[N]::
+       Specifies compression level for newly-compressed data in the
+       generated pack.  If not specified,  pack compression level is
+       determined first by pack.compression,  then by core.compression,
+       and defaults to -1,  the zlib default,  if neither is set.
+       Data copied from loose objects will be recompressed
+       if core.legacyheaders was true when they were created or if
+       the loose compression level (see core.loosecompression and
+       core.compression) is now a different value than the pack
+       compression level.  Add --no-reuse-object if you want to force
+       a uniform compression level on all data no matter the source.
+
 --delta-base-offset::
        A packed archive can express base object of a delta as
        either 20-byte object name or as an offset in the
@@ -161,4 +185,3 @@ gitlink:git-prune-packed[1]
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 94bbea0db2caf32635cfa8fc199e8150b1cd05f2..f2ceebac4ba57a07d2d9bf2ae1e9f54d003b2d7f 100644 (file)
@@ -17,7 +17,7 @@ are redundant. The output is suitable for piping to
 'xargs rm' if you are in the root of the repository.
 
 git-pack-redundant accepts a list of objects on standard input. Any objects
-given will be ignored when checking which packs are required. This makes the 
+given will be ignored when checking which packs are required. This makes the
 following command useful when wanting to remove packs which contain unreachable
 objects.
 
@@ -55,4 +55,3 @@ gitlink:git-prune-packed[1]
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index a7e9fd021a4cc1e467b2df7dd7e06d79a5182c7a..ad528a922487be06207bdcc38a03fe55fd0f2a5d 100644 (file)
@@ -40,4 +40,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 74f37bd9040200c0dbc82c67b45540e873d4649e..abc171266a35299159308d0653bb0c659b8bdc77 100644 (file)
@@ -52,4 +52,3 @@ Documentation by Junio C Hamano.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 310033e4605d20b99c21a769e79b25b64abbb618..3800edb7bb7d9062dddb3393eaf1a80e5a44596d 100644 (file)
@@ -50,4 +50,3 @@ gitlink:git-repack[1]
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index b8166a210fe5f0a6c5ade480640146684d2517cb..0ace233d18383f53ca4d31baaa8e3c230ddb874b 100644 (file)
@@ -58,4 +58,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 94478ed94d70c597c8a024afe79b456a66d40a35..84693f8b10619dca8b615d30fbbcd950c9319d16 100644 (file)
@@ -165,4 +165,3 @@ Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index e9ad10672a7f045f25937ca85caec548fcb4327f..366c5dbdce69854e7cc1e085cdf53e0e88f7bcb2 100644 (file)
@@ -110,4 +110,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 296937a4167dc2e4c93cfcafca9fea14090cb108..1c3ef4c59362a1ccc8e44a54738c788f710201be 100644 (file)
@@ -58,4 +58,3 @@ Documentation by Eric Biederman <ebiederm@lnxi.com>
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index acb57447a864a54b3b531b7ef7403563fd20f886..84184d6294df83c3229a8035d934b23c598578d1 100644 (file)
@@ -356,4 +356,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 753b275a0f79d88ef439a4c235452bd17f81ce2e..0c00090a6b95662fff38baafaaa892ab65e25609 100644 (file)
@@ -237,4 +237,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 1e343bcdcdd4c1998b9887866507639bb31d030c..f717e1e30c1b2a99d1d32b86d7d3eedfe6d88d40 100644 (file)
@@ -65,4 +65,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index aca60120c8a671465bb83127bde080b94c0bb782..fe631bb3dd9096e831087511202e2771ebb85df4 100644 (file)
@@ -34,4 +34,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 3dde7134a5cedc6d58a934e1dd61db26d5e459ae..ab232c2f68e1c4bf47977ea3be4fc2ae525fb67b 100644 (file)
@@ -128,4 +128,3 @@ Documentation by J. Bruce Fields and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index cc3b0b21c727349eb3a51d9837bc006b987537c3..c33a512ffb0bfaef8c920ecff7c2630d2eabf0b9 100644 (file)
@@ -65,6 +65,11 @@ OPTIONS
        to be applied that many times to get to the necessary object.
        The default value for --window is 10 and --depth is 50.
 
+--max-pack-size=<n>::
+       Maximum size of each output packfile, expressed in MiB.
+       If specified,  multiple packfiles may be created.
+       The default is unlimited.
+
 
 Configuration
 -------------
@@ -96,4 +101,3 @@ gitlink:git-prune-packed[1]
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 478a5fd6b74ddbcbf279339a5c3ae5eefb039cb4..087eeb7cc22552b8903e54fc52f08eeb56fb1a0d 100644 (file)
@@ -37,4 +37,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index c3c2043d183e0e6c7292f5af7c28af57958c4dcd..0dba73f27607560d3e868306af78bad83dc3bfff 100644 (file)
@@ -25,6 +25,7 @@ SYNOPSIS
             [ \--cherry-pick ]
             [ \--encoding[=<encoding>] ]
             [ \--(author|committer|grep)=<pattern> ]
+            [ \--regexp-ignore-case ] [ \--extended-regexp ]
             [ \--date={local|relative|default} ]
             [ [\--objects | \--objects-edge] [ \--unpacked ] ]
             [ \--pretty | \--header ]
@@ -214,6 +215,15 @@ limiting may be applied.
        Limit the commits output to ones with log message that
        matches the specified pattern (regular expression).
 
+--regexp-ignore-case::
+
+       Match the regexp limiting patterns without regard to letters case.
+
+--extended-regexp::
+
+       Consider the limiting patterns to be extended regular expressions
+       instead of the default basic regular expressions.
+
 --remove-empty::
 
        Stop when a given path disappears from the tree.
index 7757abe62190a066b6ad8b57214b70ff3fa0f12a..e1cb4ef8568d05ad7bacfb391227bb88560fd448 100644 (file)
@@ -286,4 +286,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 8081bbaffa8d3710b644c744b9f81d459938a20e..69db4984473fae7928797bcfb13baf1f0e39d851 100644 (file)
@@ -56,4 +56,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index a65f24a0f698eb801ac43bba5aa7dc746e96edc0..78f45dca2e37415cbeafb02db559edc6ca511d51 100644 (file)
@@ -95,4 +95,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 8bb52f46872194783148851ca2fe81dfb9d13bf7..dee5d0da9db0e8e88f7f2f237fcfe3ca7f5c28ec 100644 (file)
@@ -66,4 +66,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 7ae39fd5a20a869db8c2be101d7001c1c48ff198..946bd76afc5bf9de22917bb4f4c1d8b44c745503 100644 (file)
@@ -78,7 +78,7 @@ The --cc option must be repeated for each user you want on the cc list.
        `localhost` otherwise.
 
 --subject::
-       Specify the initial subject of the email thread.
+       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.
 
@@ -137,4 +137,3 @@ Documentation by Ryan Anderson
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 2b2abebd608be337db35a3de4b83d37d43061acb..1ea1faa1b57adecea4269fa6d0c2c4afdee9b3da 100644 (file)
@@ -69,4 +69,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 228b9f14f3530b9ec28e603a3ef2327c7039c440..48f2d57b7b48fa9c8fb0cbc5fcb547d6aed32cbb 100644 (file)
@@ -32,4 +32,3 @@ Documentation by Petr Baudis and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 15cc6f77c1e9b8a77c8396fab99cf9d9fda98ef3..2220ef6ea8d3bfa58f3c1279dfcf4f735c2dae0a 100644 (file)
@@ -56,4 +56,3 @@ Documentation by Junio C Hamano.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index be09b62bebb2b98fa8b0f39e47d29267126fa2a6..764d99356bcefb40a16d3c27bc41e881f87b396a 100644 (file)
@@ -32,4 +32,3 @@ Documentation by Junio C Hamano
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 34c5caf2d08324cc1595013cbdcd40d89d7a1968..a42e1211500a6a6ecdf1d9e1ddbf6712869ceb79 100644 (file)
@@ -84,4 +84,3 @@ This manual page is a stub. You can help the git documentation by expanding it.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 192b1f15a9ca75351623d32e4373d65c6501b465..aaf3db06dacfacfc093672c44cfe265b6de36c24 100644 (file)
@@ -48,4 +48,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index a9b7e9f974c13252456309c7053537853dc7ea9b..4796224244d6025554a8f1f2cf47b92529f7898c 100644 (file)
@@ -44,4 +44,3 @@ Documentation by Daniel Barkalow
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 1fd1af102ae948ca008bbd35675d859340e46dbd..6f16eb0328f754b5f5019ff5dac51604de7d535f 100644 (file)
@@ -58,4 +58,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 3a03dd04106d45cc3c233230d1773874f3ca1cef..1306d7bab70efb57cba62a98ebd2d67b06677c97 100644 (file)
@@ -30,4 +30,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
new file mode 100644 (file)
index 0000000..cb0424f
--- /dev/null
@@ -0,0 +1,65 @@
+git-submodule(1)
+================
+
+NAME
+----
+git-submodule - Initialize, update or inspect submodules
+
+
+SYNOPSIS
+--------
+'git-submodule' [--quiet] [--cached] [status|init|update] [--] [<path>...]
+
+
+COMMANDS
+--------
+status::
+       Show the status of the submodules. This will print the SHA-1 of the
+       currently checked out commit for each submodule, along with the
+       submodule path and the output of gitlink:git-describe[1] for the
+       SHA-1. Each SHA-1 will be prefixed with `-` if the submodule is not
+       initialized and `+` if the currently checked out submodule commit
+       does not match the SHA-1 found in the index of the containing
+       repository. This command is the default command for git-submodule.
+
+init::
+       Initialize the submodules, i.e. clone the git repositories specified
+       in the .gitmodules file and checkout the submodule commits specified
+       in the index of the containing repository. This will make the
+       submodules HEAD be detached.
+
+update::
+       Update the initialized submodules, i.e. checkout the submodule commits
+       specified in the index of the containing repository. This will make
+       the submodules HEAD be detached.
+
+
+OPTIONS
+-------
+-q, --quiet::
+       Only print error messages.
+
+--cached::
+       Display the SHA-1 stored in the index, not the SHA-1 of the currently
+       checked out submodule commit. This option is only valid for the
+       status command.
+
+<path>::
+       Path to submodule(s). When specified this will restrict the command
+       to only operate on the submodules found at the specified paths.
+
+FILES
+-----
+When cloning submodules, a .gitmodules file in the top-level directory
+of the containing repository is used to find the url of each submodule.
+This file should be formatted in the same way as $GIR_DIR/config. The key
+to each submodule url is "module.$path.url".
+
+
+AUTHOR
+------
+Written by Lars Hjemli <hjemli@gmail.com>
+
+GIT
+---
+Part of the gitlink:git[7] suite
index bdae7d87dce5d07d0d31b45f127fa43a239a6632..e97d15e8f237e969b76cdda9a90f6740aab77f13 100644 (file)
@@ -174,4 +174,3 @@ Documentation by Matthias Urlichs <smurf@smurf.noris.de>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 4e3e02756c8863dbc6fe1d745e1a8c9a97c18919..aee2c1bdc785259c3f587323b557f5c575f3c797 100644 (file)
@@ -11,7 +11,7 @@ SYNOPSIS
 [verse]
 'git-tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>]  <name> [<head>]
 'git-tag' -d <name>...
-'git-tag' -l [<pattern>]
+'git-tag' [-n [<num>]] -l [<pattern>]
 'git-tag' -v <name>
 
 DESCRIPTION
@@ -38,8 +38,8 @@ GnuPG key for signing.
 
 `-v <tag>` verifies the gpg signature of the tag.
 
-`-l <pattern>` lists tags that match the given pattern (or all
-if no pattern is given).
+`-l <pattern>` lists tags with names that match the given pattern
+(or all if no pattern is given).
 
 OPTIONS
 -------
@@ -61,8 +61,13 @@ OPTIONS
 -v::
        Verify the gpg signature of given the tag
 
+-n <num>::
+       <num> specifies how many lines from the annotation, if any,
+       are printed when using -l.
+       The default is not to print any annotation lines.
+
 -l <pattern>::
-       List tags that match the given pattern (or all if no pattern is given).
+       List tags with names that match the given pattern (or all if no pattern is given).
 
 -m <msg>::
        Use the given tag message (instead of prompting)
index 7bde73b1b85df03893fa15b99b17c5aff09ae574..2d01d9666fd2ab5f53ab2265ca701d56ea370f8b 100644 (file)
@@ -90,4 +90,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 213dc8196b90170cc14e35f7c637815b39a7ff8d..20bb6a7800c43c6613aaeda2a86cd3311213bfbe 100644 (file)
@@ -33,4 +33,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index b1b3ec9772b7e689a4a3d42e78be68df34de40ac..d529a43f55ed6356f88fc6410f3fe00dfc01359d 100644 (file)
@@ -52,4 +52,3 @@ Documentation by Junio C Hamano
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 6cfbd9a842f0601cf81f8780ecf6b7939b25dccb..0a1953803e48947f6eeae385550ac2cd4e838411 100644 (file)
@@ -56,7 +56,7 @@ OPTIONS
 
 --unmerged::
         If --refresh finds unmerged changes in the index, the default
-        behavior is to error out.  This option makes git-update-index 
+        behavior is to error out.  This option makes git-update-index
         continue anyway.
 
 --ignore-missing::
@@ -64,12 +64,12 @@ OPTIONS
 
 --cacheinfo <mode> <object> <path>::
        Directly insert the specified info into the index.
-       
+
 --index-info::
         Read index information from stdin.
 
 --chmod=(+|-)x::
-        Set the execute permissions on the updated files.        
+        Set the execute permissions on the updated files.
 
 --assume-unchanged, --no-assume-unchanged::
        When these flags are specified, the object name recorded
@@ -126,7 +126,7 @@ OPTIONS
 <file>::
        Files to act on.
        Note that files beginning with '.' are discarded. This includes
-       `./file` and `dir/./file`. If you don't want this, then use     
+       `./file` and `dir/./file`. If you don't want this, then use
        cleaner names.
        The same applies to directories ending '/' and paths with '//'
 
@@ -324,4 +324,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 9424feab320afcaa5a44bd2c2c6c86728bd8d004..f222616591f157beada3c5355ee0e56d68171761 100644 (file)
@@ -7,7 +7,7 @@ git-update-ref - Update the object name stored in a ref safely
 
 SYNOPSIS
 --------
-'git-update-ref' [-m <reason>] (-d <ref> <oldvalue> | <ref> <newvalue> [<oldvalue>])
+'git-update-ref' [-m <reason>] (-d <ref> <oldvalue> | [--no-deref] <ref> <newvalue> [<oldvalue>])
 
 DESCRIPTION
 -----------
@@ -36,6 +36,9 @@ them and update them as a regular file (i.e. it will allow the
 filesystem to follow them, but will overwrite such a symlink to
 somewhere else with a regular filename).
 
+If --no-deref is given, <ref> itself is overwritten, rather than
+the result of following the symbolic pointers.
+
 In general, using
 
        git-update-ref HEAD "$head"
index 88a03c7c5ed4935fc10764d0f56326f0436a6f26..e7e82a31ea58a0515ed3a294140fd361577c07ce 100644 (file)
@@ -55,4 +55,3 @@ Documentation by Junio C Hamano.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 9b0de1c111d7b58cb8d431d90814d1f1530f5e0d..813942368b31a9eccb1c06b67e1a4303d3b62ede 100644 (file)
@@ -62,4 +62,3 @@ Documentation by Eric Biederman and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 7a6132b016903801fd1070e062381a41ec52536a..f4c540f39bffe5bda536445dc1556ff4c6bfa60a 100644 (file)
@@ -51,4 +51,3 @@ Documentation by Junio C Hamano
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 0f9bdb58dcc3cf7ee549f483164a708f536d2bd5..48d17fd9c44acc3192987d818f3505c56d2eddb4 100644 (file)
@@ -29,4 +29,3 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 399bff3bbcab89be96039c373cf1120dcab0efe1..607df48f09254f2c93ad41e75ed976b092711dff 100644 (file)
@@ -78,4 +78,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 96d5e07b112aa2a87eb6433f7cbeb8ce5f10205a..cb8d6aadeb3fc3b55c58bd40b96461a07a124260 100644 (file)
@@ -47,4 +47,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 98860af0455ebb5290e7225e6ac677dc7ab3268c..ba077c39c6a34584da306cce51da34537b0d1e0f 100644 (file)
@@ -428,4 +428,3 @@ contributors on the git-list <git@vger.kernel.org>.
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index 48c5894736ac3065e80a36e1a5230d86004bee2e..e9f82b97b91b92785b76a224e176b695593cdbe7 100644 (file)
@@ -99,4 +99,3 @@ Documentation by Junio C Hamano, Jonas Fonseca, and the git-list
 GIT
 ---
 Part of the gitlink:git[7] suite
-
index aabb9750fddbc28091c46780ccf7b835b62b04c7..6836477ca816a6caa860960c3456cfbbf5cd32f1 100644 (file)
@@ -12,11 +12,10 @@ This document describes the currently defined hooks.
 applypatch-msg
 --------------
 
-This hook is invoked by `git-applypatch` script, which is
-typically invoked by `git-applymbox`.  It takes a single
+This hook is invoked by `git-am` script.  It takes a single
 parameter, the name of the file that holds the proposed commit
 log message.  Exiting with non-zero status causes
-`git-applypatch` to abort before applying the patch.
+`git-am` to abort before applying the patch.
 
 The hook is allowed to edit the message file in place, and can
 be used to normalize the message into some project standard
@@ -29,8 +28,7 @@ The default 'applypatch-msg' hook, when enabled, runs the
 pre-applypatch
 --------------
 
-This hook is invoked by `git-applypatch` script, which is
-typically invoked by `git-applymbox`.  It takes no parameter,
+This hook is invoked by `git-am`.  It takes no parameter,
 and is invoked after the patch is applied, but before a commit
 is made.  Exiting with non-zero status causes the working tree
 after application of the patch not committed.
@@ -44,12 +42,11 @@ The default 'pre-applypatch' hook, when enabled, runs the
 post-applypatch
 ---------------
 
-This hook is invoked by `git-applypatch` script, which is
-typically invoked by `git-applymbox`.  It takes no parameter,
+This hook is invoked by `git-am`.  It takes no parameter,
 and is invoked after the patch is applied and a commit is made.
 
 This hook is meant primarily for notification, and cannot affect
-the outcome of `git-applypatch`.
+the outcome of `git-am`.
 
 pre-commit
 ----------
index 646c55cc6954fbf36a11fbe22cb2c1acb64dfd43..554909fe08de380aa02f2bf37f0f3b43b0233f4b 100644 (file)
@@ -9,16 +9,16 @@ Abstract: In this article, Linus demonstrates how a broken commit
 
 On Sat, 13 Aug 2005, Linus Torvalds wrote:
 
-> That's correct. Same things apply: you can move a patch over, and create a 
-> new one with a modified comment, but basically the _old_ commit will be 
+> That's correct. Same things apply: you can move a patch over, and create a
+> new one with a modified comment, but basically the _old_ commit will be
 > immutable.
 
 Let me clarify.
 
 You can entirely _drop_ old branches, so commits may be immutable, but
-nothing forces you to keep them. Of course, when you drop a commit, you'll 
-always end up dropping all the commits that depended on it, and if you 
-actually got somebody else to pull that commit you can't drop it from 
+nothing forces you to keep them. Of course, when you drop a commit, you'll
+always end up dropping all the commits that depended on it, and if you
+actually got somebody else to pull that commit you can't drop it from
 _their_ repository, but undoing things is not impossible.
 
 For example, let's say that you've made a mess of things: you've committed
@@ -29,7 +29,7 @@ want to save "b" and "c". What you can do is
        # for reference
        git branch broken
 
-       # Reset the main branch to three parents back: this 
+       # Reset the main branch to three parents back: this
        # effectively undoes the three top commits
        git reset HEAD^^^
        git checkout -f
@@ -59,7 +59,7 @@ Finally, check out the end result again:
 
 to see that everything looks sensible.
 
-And then, you can just remove the broken branch if you decide you really 
+And then, you can just remove the broken branch if you decide you really
 don't want it:
 
        # remove 'broken' branch
@@ -68,8 +68,8 @@ don't want it:
        # Prune old objects if you're really really sure
        git prune
 
-And yeah, I'm sure there are other ways of doing this. And as usual, the 
-above is totally untested, and I just wrote it down in this email, so if 
+And yeah, I'm sure there are other ways of doing this. And as usual, the
+above is totally untested, and I just wrote it down in this email, so if
 I've done something wrong, you'll have to figure it out on your own ;)
 
                        Linus
@@ -77,5 +77,3 @@ I've done something wrong, you'll have to figure it out on your own ;)
 To unsubscribe from this list: send the line "unsubscribe git" in
 the body of a message to majordomo@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
-
-
index 3b3a5c2e69e59d4708171ba745d7d4009788102b..7a76045eb742b38e726e15491db2bf4315cb8f6a 100644 (file)
@@ -14,10 +14,10 @@ Petr Baudis <pasky@suse.cz> writes:
 > Dear diary, on Sun, Aug 14, 2005 at 09:57:13AM CEST, I got a letter
 > where Junio C Hamano <junkio@cox.net> told me that...
 >> Linus Torvalds <torvalds@osdl.org> writes:
->> 
->> > Junio, maybe you want to talk about how you move patches from your "pu" 
+>>
+>> > Junio, maybe you want to talk about how you move patches from your "pu"
 >> > branch to the real branches.
->> 
+>>
 > Actually, wouldn't this be also precisely for what StGIT is intended to?
 
 Exactly my feeling.  I was sort of waiting for Catalin to speak
@@ -118,7 +118,7 @@ up your changes, along with other changes.
 
    where                      *your "master" head
   upstream --> #1 --> #2 --> #3
-    used   \ 
+    used   \
    to be     \--> #A --> #2' --> #3' --> #B --> #C
                                                 *upstream head
 
@@ -133,7 +133,7 @@ You fetch from upstream, but not merge.
     $ git fetch upstream
 
 This leaves the updated upstream head in .git/FETCH_HEAD but
-does not touch your .git/HEAD nor .git/refs/heads/master.  
+does not touch your .git/HEAD nor .git/refs/heads/master.
 You run "git rebase" now.
 
     $ git rebase FETCH_HEAD master
@@ -161,5 +161,3 @@ the #1' commit.
 To unsubscribe from this list: send the line "unsubscribe git" in
 the body of a message to majordomo@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
-
-
index 02621b54a03ce5771eab1c49d121a07ba31cbf16..8d55dfbfaef7ef6bb30b65ea52c7825b099b50d8 100644 (file)
@@ -84,4 +84,3 @@ There are four things worth mentioning:
  - This is still crude and does not protect against simultaneous
    make invocations stomping on each other.  I would need to add
    some locking mechanism for this.
-
index d88ec23a97bc59f29a5f9734fc5ba0ef5a9ae6cf..865a6663240f744d448b0a125ebc123afb72ede2 100644 (file)
@@ -146,7 +146,7 @@ Everything is in the good order.  I do not need the temporary branch
 nor tag anymore, so remove them:
 
 ------------------------------------------------
-$ rm -f .git/refs/tags/pu-anchor 
+$ rm -f .git/refs/tags/pu-anchor
 $ git branch -d revert-c99
 ------------------------------------------------
 
index 090e2c9b018c7ea16b98094746d4e005abd27eec..0d73b31224c881eb83f30ec3c5421a81288f6502 100644 (file)
@@ -12,7 +12,7 @@ up with a history like this:
 
             "master"
         o---o
-             \                    "topic" 
+             \                    "topic"
               o---o---o---o---o---o
 
 At this point, "topic" contains something I know I want, but it
@@ -29,11 +29,11 @@ start building on top of "master":
         $ git checkout -b topicA master
         ... pick and apply pieces from P.diff to build
         ... commits on topicA branch.
-                      
+
               o---o---o
              /        "topicA"
         o---o"master"
-             \                    "topic" 
+             \                    "topic"
               o---o---o---o---o---o
 
 Before doing each commit on "topicA" HEAD, I run "diff HEAD"
@@ -59,7 +59,7 @@ other topic:
              /o---o---o
             |/        "topicA"
         o---o"master"
-             \                    "topic" 
+             \                    "topic"
               o---o---o---o---o---o
 
 After I am done, I'd try a pretend-merge between "topicA" and
@@ -73,7 +73,7 @@ After I am done, I'd try a pretend-merge between "topicA" and
              /o---o---o----------'
             |/        "topicA"
         o---o"master"
-             \                    "topic" 
+             \                    "topic"
               o---o---o---o---o---o
 
 The last diff better not to show anything other than cleanups
@@ -84,8 +84,7 @@ for crufts.  Then I can finally clean things up:
 
                                 "topicB"
                o---o---o---o---o
-              / 
+              /
              /o---o---o
             |/        "topicA"
         o---o"master"
-
index 1a1eb246bf5b5ff5f67edea306371604159762ae..4e2f75cb6167633c97ec1981d2b6659368cc0170 100644 (file)
@@ -49,4 +49,3 @@ Now, test your daemon with
        $ git ls-remote git://127.0.0.1/rule-the-world.git
 
 If this does not work, find out why, and submit a patch to this document.
-
index 182cef54be5963ff0f32a24329ca195607413e29..d64c259bb35d3140b371e8717a2553146d3f92f5 100644 (file)
@@ -1,3 +1,7 @@
+--summary::
+       Show a diffstat at the end of the merge. The diffstat is also
+       controlled by the configuration option merge.diffstat.
+
 -n, \--no-summary::
        Do not show diffstat at the end of the merge.
 
@@ -21,4 +25,3 @@
        If there is no `-s` option, a built-in list of strategies
        is used instead (`git-merge-recursive` when merging a single
        head, `git-merge-octopus` otherwise).
-
index d922e8e86c173491fc492d3060bf92f4ee7b6c2d..c551ea61d2870e6e4d5471ec4fcbca4fbd802b09 100644 (file)
@@ -121,4 +121,3 @@ The placeholders are:
 - '%Creset': reset color
 - '%m': left, right or boundary mark
 - '%n': newline
-
index 7d515be0fd3b89d602ac2919fd2ea3dd4bc84131..6338def5a795a8171286626752a96f8ac88842c8 100644 (file)
@@ -11,4 +11,3 @@
        command to re-code the commit log message in the encoding
        preferred by the user.  For non plumbing commands this
        defaults to UTF-8.
-
index 8d4e950abc65c233268d785dcbfee67ab0522f4c..b6eb7fc6189daece1a200293dc767b6bc064620a 100644 (file)
@@ -58,7 +58,7 @@ is often useful.
 +
 Some short-cut notations are also supported.
 +
-* `tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`; 
+* `tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`;
   it requests fetching everything up to the given tag.
 * A parameter <ref> without a colon is equivalent to
   <ref>: when pulling/fetching, so it merges <ref> into the current
index 15221b53206eb65072f147ac72f556d0a1ee55e4..4c92e375fed4592f7190086dd40ef6dd1241d238 100644 (file)
@@ -177,4 +177,3 @@ shallow::
        This is similar to `info/grafts` but is internally used
        and maintained by shallow clone mechanism.  See `--depth`
        option to gitlink:git-clone[1] and gitlink:git-fetch[1].
-
index 9ce3c473ae1a9b5fd0b3a909fb264d8e0fff27a5..e5b31c81fa3b5268c6d1bc0afcaec967f401ac28 100644 (file)
@@ -80,7 +80,7 @@ Pack Idx file:
            +--------------------------------+ |
 main       | offset                         | |
 index      | object name 00XXXXXXXXXXXXXXXX | |
-table      +--------------------------------+ | 
+table      +--------------------------------+ |
            | offset                         | |
            | object name 00XXXXXXXXXXXXXXXX | |
            +--------------------------------+ |
@@ -97,14 +97,14 @@ trailer       | | packfile checksum              |
          | +--------------------------------+
          | | idxfile checksum               |
          | +--------------------------------+
-          .-------.      
+          .-------.
                   |
 Pack file entry: <+
 
      packed object header:
        1-byte size extension bit (MSB)
               type (next 3 bit)
-              size0 (lower 4-bit) 
+              size0 (lower 4-bit)
         n-byte sizeN (as long as MSB is set, each 7-bit)
                size0..sizeN form 4+7+7+..+7 bit integer, size0
                is the least significant part, and sizeN is the
@@ -114,5 +114,5 @@ Pack file entry: <+
                is the size before compression).
        If it is DELTA, then
          20-byte base object name SHA1 (the size above is the
-               size of the delta data that follows).
+               size of the delta data that follows).
           delta data, deflated.
index 780f0f0ee64f8ea20e0a4eafe2db039194819fed..0bfa21b3d2eddf2783890d880e3d5abc951b62fa 100644 (file)
@@ -154,11 +154,11 @@ Author: Jamal Hadi Salim <hadi@cyberus.ca>
 Date:   Sat Dec 2 22:22:25 2006 -0800
 
     [XFRM]: Fix aevent structuring to be more complete.
-    
+
     aevents can not uniquely identify an SA. We break the ABI with this
     patch, but consensus is that since it is not yet utilized by any
     (known) application then it is fine (better do it now than later).
-    
+
     Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
     Signed-off-by: David S. Miller <davem@davemloft.net>
 
@@ -167,7 +167,7 @@ index 8be626f..d7aac9d 100644
 --- a/Documentation/networking/xfrm_sync.txt
 +++ b/Documentation/networking/xfrm_sync.txt
 @@ -47,10 +47,13 @@ aevent_id structure looks like:
+
     struct xfrm_aevent_id {
               struct xfrm_usersa_id           sa_id;
 +             xfrm_address_t                  saddr;
@@ -1057,7 +1057,7 @@ $ git show
 -------------------------------------------------
 
 As a special shortcut,
-               
+
 -------------------------------------------------
 $ git commit -a
 -------------------------------------------------
@@ -1555,7 +1555,7 @@ history.
 
 Fortunately, git also keeps a log, called a "reflog", of all the
 previous values of each branch.  So in this case you can still find the
-old history using, for example, 
+old history using, for example,
 
 -------------------------------------------------
 $ git log master@{1}
@@ -1631,7 +1631,7 @@ If you decide you want the history back, you can always create a new
 reference pointing to it, for example, a new branch:
 
 ------------------------------------------------
-$ git branch recovered-branch 7281251ddd 
+$ git branch recovered-branch 7281251ddd
 ------------------------------------------------
 
 Other types of dangling objects (blobs and trees) are also possible, and
@@ -1794,7 +1794,7 @@ like this:
 
                         you push
   your personal repo ------------------> your public repo
-       ^                                     |
+       ^                                     |
        |                                     |
        | you pull                            | they pull
        |                                     |
@@ -2360,7 +2360,7 @@ the result would create a new merge commit, like this:
         \        \
          a--b--c--m <-- mywork
 ................................................
+
 However, if you prefer to keep the history in mywork a simple series of
 commits without any merges, you may instead choose to use
 gitlink:git-rebase[1]:
@@ -2736,7 +2736,7 @@ must have at least one root, and while you can tie several different
 root objects together into one project by creating a commit object which
 has two or more separate roots as its ultimate parents, that's probably
 just going to confuse people.  So aim for the notion of "one root object
-per project", even if git itself does not enforce that. 
+per project", even if git itself does not enforce that.
 
 A <<def_tag_object,"tag" object>> symbolically identifies and can be
 used to sign other objects. It contains the identifier and type of
@@ -2758,7 +2758,7 @@ independently of the contents or the type of the object: all objects can
 be validated by verifying that (a) their hashes match the content of the
 file and (b) the object successfully inflates to a stream of bytes that
 forms a sequence of <ascii type without space> + <space> + <ascii decimal
-size> + <byte\0> + <binary object data>. 
+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
@@ -2955,7 +2955,7 @@ cache, and the normal operation is to re-generate it completely from a
 known tree object, or update/compare it with a live tree that is being
 developed.  If you blow the directory cache away entirely, you generally
 haven't lost any information as long as you have the name of the tree
-that it described. 
+that it described.
 
 At the same time, the index is at the same time also the
 staging area for creating new trees, and creating a new tree always
@@ -2975,7 +2975,7 @@ Generally, all "git" operations work on the index file. Some operations
 work *purely* on the index file (showing the current state of the
 index), but most operations move data to and from the index file. Either
 from the database or from the working directory. Thus there are four
-main combinations: 
+main combinations:
 
 [[working-directory-to-index]]
 working directory -> index
@@ -3438,7 +3438,7 @@ because you interrupted a "git fetch" with ^C or something like that,
 leaving _some_ of the new objects in the object database, but just
 dangling and useless.
 
-Anyway, once you are sure that you're not interested in any dangling 
+Anyway, once you are sure that you're not interested in any dangling
 state, you can just prune all unreachable objects:
 
 ------------------------------------------------
@@ -3449,12 +3449,12 @@ and they'll be gone. But you should only run "git prune" on a quiescent
 repository - it's kind of like doing a filesystem fsck recovery: you
 don't want to do that while the filesystem is mounted.
 
-(The same is true of "git-fsck" itself, btw - but since 
-git-fsck never actually *changes* the repository, it just reports 
-on what it found, git-fsck itself is never "dangerous" to run. 
-Running it while somebody is actually changing the repository can cause 
-confusing and scary messages, but it won't actually do anything bad. In 
-contrast, running "git prune" while somebody is actively changing the 
+(The same is true of "git-fsck" itself, btw - but since
+git-fsck never actually *changes* the repository, it just reports
+on what it found, git-fsck itself is never "dangerous" to run.
+Running it while somebody is actually changing the repository can cause
+confusing and scary messages, but it won't actually do anything bad. In
+contrast, running "git prune" while somebody is actively changing the
 repository is a *BAD* idea).
 
 [[birdview-on-the-source-code]]
index bd30398dd3bb83cf9b91f465c3ae67c365d8e9a6..289c8067b507095b18fc7be60772756ff740385d 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v1.5.2.1.GIT
+DEF_VER=v1.5.2.GIT
 
 LF='
 '
@@ -43,5 +43,3 @@ test "$VN" = "$VC" || {
        echo >&2 "GIT_VERSION = $VN"
        echo "GIT_VERSION = $VN" >$GVF
 }
-
-
diff --git a/INSTALL b/INSTALL
index 361c65bacc50b4038cb9a32bab07c275a1ecdc76..95269cc513fab071d96a044b32aec7abb8b3fe7c 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -31,7 +31,7 @@ Issues of note:
    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"
-   instead. 
+   instead.
 
    But let's face it, most of us don't have GNU interactive tools, and
    even if we had it, we wouldn't know what it does.  I don't think it
@@ -111,4 +111,3 @@ Issues of note:
    would instead give you a copy of what you see at:
 
        http://www.kernel.org/pub/software/scm/git/docs/
-
index fb11fa1987e162c13a9fba492da41e26fdad7195..30a405292215acc4a4520e87a8c10bd7a9284a98 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -206,10 +206,10 @@ SCRIPT_SH = \
        git-repack.sh git-request-pull.sh git-reset.sh \
        git-sh-setup.sh \
        git-tag.sh git-verify-tag.sh \
-       git-applymbox.sh git-applypatch.sh git-am.sh \
+       git-am.sh \
        git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
        git-merge-resolve.sh git-merge-ours.sh \
-       git-lost-found.sh git-quiltimport.sh
+       git-lost-found.sh git-quiltimport.sh git-submodule.sh
 
 SCRIPT_PERL = \
        git-add--interactive.perl \
@@ -238,7 +238,6 @@ PROGRAMS = \
        git-convert-objects$X git-fetch-pack$X \
        git-hash-object$X git-index-pack$X git-local-fetch$X \
        git-fast-import$X \
-       git-merge-base$X \
        git-daemon$X \
        git-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \
        git-peek-remote$X git-receive-pack$X \
@@ -296,7 +295,8 @@ LIB_H = \
        diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h sideband.h \
        run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
        tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \
-       utf8.h reflog-walk.h patch-ids.h attr.h decorate.h progress.h mailmap.h
+       utf8.h reflog-walk.h patch-ids.h attr.h decorate.h progress.h \
+       mailmap.h remote.h
 
 DIFF_OBJS = \
        diff.o diff-lib.o diffcore-break.o diffcore-order.o \
@@ -318,7 +318,7 @@ LIB_OBJS = \
        write_or_die.o trace.o list-objects.o grep.o match-trees.o \
        alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
        color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \
-       convert.o attr.o decorate.o progress.o mailmap.o symlinks.o
+       convert.o attr.o decorate.o progress.o mailmap.o symlinks.o remote.o
 
 BUILTIN_OBJS = \
        builtin-add.o \
@@ -845,6 +845,8 @@ git$X git.spec \
 
 %.o: %.c GIT-CFLAGS
        $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
+%.s: %.c GIT-CFLAGS
+       $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
 %.o: %.S
        $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 
@@ -941,7 +943,7 @@ endif
 
 ### Testing rules
 
-TEST_PROGRAMS = test-chmtime$X test-genrandom$X
+TEST_PROGRAMS = test-chmtime$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X
 
 all:: $(TEST_PROGRAMS)
 
@@ -954,26 +956,12 @@ export NO_SVN_TESTS
 test: all
        $(MAKE) -C t/ all
 
-test-date$X: test-date.c date.o ctype.o
-       $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
+test-date$X: date.o ctype.o
 
-test-delta$X: test-delta.o diff-delta.o patch-delta.o $(GITLIBS)
-       $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
+test-delta$X: diff-delta.o patch-delta.o
 
-test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS)
-       $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
-
-test-sha1$X: test-sha1.o $(GITLIBS)
-       $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
-
-test-match-trees$X: test-match-trees.o $(GITLIBS)
-       $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
-
-test-chmtime$X: test-chmtime.c
-       $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $<
-
-test-genrandom$X: test-genrandom.c
-       $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $<
+test-%$X: test-%.o $(GITLIBS)
+       $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 
 check-sha1:: test-sha1$X
        ./test-sha1.sh
@@ -1064,8 +1052,9 @@ dist-doc:
 
 clean:
        rm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
-               test-chmtime$X test-genrandom$X $(LIB_FILE) $(XDIFF_LIB)
+               $(LIB_FILE) $(XDIFF_LIB)
        rm -f $(ALL_PROGRAMS) $(BUILT_INS) git$X
+       rm -f $(TEST_PROGRAMS)
        rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags
        rm -rf autom4te.cache
        rm -f configure config.log config.mak.autogen config.mak.append config.status config.cache
index 403fb970379c478ed49c50488a39705afe11d188..0de5e663a2ba03a15eb6711079c6bff0cba023cb 120000 (symlink)
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes-1.5.2.1.txt
\ No newline at end of file
+Documentation/RelNotes-1.5.3.txt
\ No newline at end of file
index 33e76576f149d89922deda1de5548be7bc42d0eb..66fe3e375b545613faba4e051dc41c1acb5d8cee 100644 (file)
@@ -167,7 +167,7 @@ static void write_entry(const unsigned char *sha1, struct strbuf *path,
        } else {
                if (verbose)
                        fprintf(stderr, "%.*s\n", path->len, path->buf);
-               if (S_ISDIR(mode) || S_ISDIRLNK(mode)) {
+               if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
                        *header.typeflag = TYPEFLAG_DIR;
                        mode = (mode | 0777) & ~tar_umask;
                } else if (S_ISLNK(mode)) {
@@ -280,7 +280,7 @@ static int write_tar_entry(const unsigned char *sha1,
        memcpy(path.buf + baselen, filename, filenamelen);
        path.len = baselen + filenamelen;
        path.buf[path.len] = '\0';
-       if (S_ISDIR(mode) || S_ISDIRLNK(mode)) {
+       if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
                strbuf_append_string(&path, "/");
                buffer = NULL;
                size = 0;
index 3cbf6bb8ac4045803140ca5019126015e817155e..444e1623db66fe4f5d8983e1e9e2cf4083b005b4 100644 (file)
@@ -182,7 +182,7 @@ static int write_zip_entry(const unsigned char *sha1,
                goto out;
        }
 
-       if (S_ISDIR(mode) || S_ISDIRLNK(mode)) {
+       if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
                method = 0;
                attr2 = 16;
                result = (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
index 11b1a048b489fa2bb15e4b723e5fe36920f48eee..9e3ae038e818f4e21bc50f864fc5204f6fa44daa 100644 (file)
@@ -49,7 +49,7 @@ void SHA1_Update(SHA_CTX *c, const void *p, unsigned long n)
 void SHA1_Final(unsigned char *hash, SHA_CTX *c)
 {
        uint64_t bitlen;
-       uint32_t bitlen_hi, bitlen_lo; 
+       uint32_t bitlen_hi, bitlen_lo;
        unsigned int i, offset, padlen;
        unsigned char bits[8];
        static const unsigned char padding[64] = { 0x80, };
@@ -69,7 +69,7 @@ void SHA1_Final(unsigned char *hash, SHA_CTX *c)
        bits[5] = bitlen_lo >> 16;
        bits[6] = bitlen_lo >> 8;
        bits[7] = bitlen_lo;
-       SHA1_Update(c, bits, 8); 
+       SHA1_Update(c, bits, 8);
 
        for (i = 0; i < 5; i++) {
                uint32_t v = c->hash[i];
index a328b73375a318228e309419c524c8de0860ed89..8c1cb99fb403875af85e4d1524d21f7eb818f59b 100644 (file)
@@ -181,4 +181,3 @@ sha_transform:
 
 .L_sha_K:
        .word   0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6
-
index 9db7cfe74c7a8583995e6c20c4eedebf58391fbc..fc43eed36b55e4966796490b8c0a02fae790229c 100644 (file)
@@ -22,4 +22,3 @@ int cmd_annotate(int argc, const char **argv, const char *prefix)
 
        return cmd_blame(argc + 1, nargv, prefix);
 }
-
index 0399743c4e2288a0812faeea92c07a5f6a13fccc..c6f736c14e4840bde2efd204e7f88a3556e9eed9 100644 (file)
@@ -55,7 +55,7 @@ static enum whitespace_eol {
 } new_whitespace = warn_on_whitespace;
 static int whitespace_error;
 static int squelch_whitespace_errors = 5;
-static int applied_after_stripping;
+static int applied_after_fixing_ws;
 static const char *patch_input_file;
 
 static void parse_whitespace_option(const char *option)
@@ -1657,7 +1657,7 @@ static int apply_line(char *output, const char *patch, int plen)
        if (add_nl_to_tail)
                output[plen++] = '\n';
        if (fixed)
-               applied_after_stripping++;
+               applied_after_fixing_ws++;
        return output + plen - buf;
 }
 
@@ -1671,6 +1671,7 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag, i
        char *new = xmalloc(size);
        const char *oldlines, *newlines;
        int oldsize = 0, newsize = 0;
+       int new_blank_lines_at_end = 0;
        unsigned long leading, trailing;
        int pos, lines;
 
@@ -1678,6 +1679,7 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag, i
                char first;
                int len = linelen(patch, size);
                int plen;
+               int added_blank_line = 0;
 
                if (!len)
                        break;
@@ -1699,6 +1701,7 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag, i
                        else if (first == '+')
                                first = '-';
                }
+
                switch (first) {
                case '\n':
                        /* Newer GNU diff, empty context line */
@@ -1716,9 +1719,14 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag, i
                                break;
                /* Fall-through for ' ' */
                case '+':
-                       if (first != '+' || !no_add)
-                               newsize += apply_line(new + newsize, patch,
-                                                     plen);
+                       if (first != '+' || !no_add) {
+                               int added = apply_line(new + newsize, patch,
+                                                      plen);
+                               newsize += added;
+                               if (first == '+' &&
+                                   added == 1 && new[newsize-1] == '\n')
+                                       added_blank_line = 1;
+                       }
                        break;
                case '@': case '\\':
                        /* Ignore it, we already handled it */
@@ -1728,6 +1736,10 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag, i
                                error("invalid start of line: '%c'", first);
                        return -1;
                }
+               if (added_blank_line)
+                       new_blank_lines_at_end++;
+               else
+                       new_blank_lines_at_end = 0;
                patch += len;
                size -= len;
        }
@@ -1770,9 +1782,16 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag, i
                if (match_beginning && offset)
                        offset = -1;
                if (offset >= 0) {
-                       int diff = newsize - oldsize;
-                       unsigned long size = desc->size + diff;
-                       unsigned long alloc = desc->alloc;
+                       int diff;
+                       unsigned long size, alloc;
+
+                       if (new_whitespace == strip_whitespace &&
+                           (desc->size - oldsize - offset == 0)) /* end of file? */
+                               newsize -= new_blank_lines_at_end;
+
+                       diff = newsize - oldsize;
+                       size = desc->size + diff;
+                       alloc = desc->alloc;
 
                        /* Warn if it was necessary to reduce the number
                         * of context lines.
@@ -2865,18 +2884,17 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
                                squelched == 1 ? "" : "s");
                }
                if (new_whitespace == error_on_whitespace)
-                       die("%d line%s add%s trailing whitespaces.",
+                       die("%d line%s add%s whitespace errors.",
                            whitespace_error,
                            whitespace_error == 1 ? "" : "s",
                            whitespace_error == 1 ? "s" : "");
-               if (applied_after_stripping)
+               if (applied_after_fixing_ws)
                        fprintf(stderr, "warning: %d line%s applied after"
-                               " stripping trailing whitespaces.\n",
-                               applied_after_stripping,
-                               applied_after_stripping == 1 ? "" : "s");
+                               " fixing whitespace errors.\n",
+                               applied_after_fixing_ws,
+                               applied_after_fixing_ws == 1 ? "" : "s");
                else if (whitespace_error)
-                       fprintf(stderr, "warning: %d line%s add%s trailing"
-                               " whitespaces.\n",
+                       fprintf(stderr, "warning: %d line%s add%s whitespace errors.\n",
                                whitespace_error,
                                whitespace_error == 1 ? "" : "s",
                                whitespace_error == 1 ? "s" : "");
index 7f4e409c998ba4a864bd39032556d71693ff6793..187491bc172571b783a0be4f4dfa3d94d58bb0fe 100644 (file)
@@ -45,7 +45,7 @@ static int run_remote_archiver(const char *remote, int argc,
        }
 
        url = xstrdup(remote);
-       pid = git_connect(fd, url, exec);
+       pid = git_connect(fd, url, exec, 0);
        if (pid < 0)
                return pid;
 
index 8956d0f84213afbd0e53e39bc863c05960f524f0..da480519d7a1e7fb51d94c393ded3fe64840ee8b 100644 (file)
@@ -55,7 +55,7 @@ static int parse_branch_color_slot(const char *var, int ofs)
        die("bad config variable '%s'", var);
 }
 
-int git_branch_config(const char *var, const char *value)
+static int git_branch_config(const char *var, const char *value)
 {
        if (!strcmp(var, "color.branch")) {
                branch_use_color = git_config_colorbool(var, value);
@@ -72,7 +72,7 @@ int git_branch_config(const char *var, const char *value)
        return git_default_config(var, value);
 }
 
-const char *branch_get_color(enum color_branch ix)
+static const char *branch_get_color(enum color_branch ix)
 {
        if (branch_use_color)
                return branch_colors[ix];
@@ -317,8 +317,6 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev)
 static char *config_repo;
 static char *config_remote;
 static const char *start_ref;
-static int start_len;
-static int base_len;
 
 static int get_remote_branch_name(const char *value)
 {
@@ -334,26 +332,41 @@ static int get_remote_branch_name(const char *value)
 
        end = value + strlen(value);
 
-       /* Try an exact match first.  */
+       /*
+        * Try an exact match first.  I.e. handle the case where the
+        * value is "$anything:refs/foo/bar/baz" and start_ref is exactly
+        * "refs/foo/bar/baz". Then the name at the remote is $anything.
+        */
        if (!strcmp(colon + 1, start_ref)) {
-               /* Truncate the value before the colon.  */
+               /* Truncate the value before the colon. */
                nfasprintf(&config_repo, "%.*s", colon - value, value);
                return 1;
        }
 
-       /* Try with a wildcard match now.  */
-       if (end - value > 2 && end[-2] == '/' && end[-1] == '*' &&
-           colon - value > 2 && colon[-2] == '/' && colon[-1] == '*' &&
-           (end - 2) - (colon + 1) == base_len &&
-           !strncmp(colon + 1, start_ref, base_len)) {
-               /* Replace the star with the remote branch name.  */
-               nfasprintf(&config_repo, "%.*s%s",
-                          (colon - 2) - value, value,
-                          start_ref + base_len);
-               return 1;
-       }
+       /*
+        * Is this a wildcard match?
+        */
+       if ((end - 2 <= value) || end[-2] != '/' || end[-1] != '*' ||
+           (colon - 2 <= value) || colon[-2] != '/' || colon[-1] != '*')
+               return 0;
 
-       return 0;
+       /*
+        * Value is "refs/foo/bar/<asterisk>:refs/baz/boa/<asterisk>"
+        * and start_ref begins with "refs/baz/boa/"; the name at the
+        * remote is refs/foo/bar/ with the remaining part of the
+        * start_ref.  The length of the prefix on the RHS is (end -
+        * colon - 2), including the slash immediately before the
+        * asterisk.
+        */
+       if ((strlen(start_ref) < end - colon - 2) ||
+           memcmp(start_ref, colon + 1, end - colon - 2))
+               return 0; /* does not match prefix */
+
+       /* Replace the asterisk with the remote branch name.  */
+       nfasprintf(&config_repo, "%.*s%s",
+                  (colon - 1) - value, value,
+                  start_ref + (end - colon - 2));
+       return 1;
 }
 
 static int get_remote_config(const char *key, const char *value)
@@ -363,10 +376,12 @@ static int get_remote_config(const char *key, const char *value)
                return 0;
 
        var = strrchr(key, '.');
-       if (var == key + 6)
+       if (var == key + 6 || strcmp(var, ".fetch"))
                return 0;
-
-       if (!strcmp(var, ".fetch") && get_remote_branch_name(value))
+       /*
+        * Ok, we are looking at key == "remote.$foo.fetch";
+        */
+       if (get_remote_branch_name(value))
                nfasprintf(&config_remote, "%.*s", var - (key + 7), key + 7);
 
        return 0;
@@ -392,14 +407,14 @@ static void set_branch_merge(const char *name, const char *config_remote,
 
 static void set_branch_defaults(const char *name, const char *real_ref)
 {
-       const char *slash = strrchr(real_ref, '/');
-
-       if (!slash)
-               return;
-
+       /*
+        * name is the name of new branch under refs/heads;
+        * real_ref is typically refs/remotes/$foo/$bar, where
+        * $foo is the remote name (there typically are no slashes)
+        * and $bar is the branch name we map from the remote
+        * (it could have slashes).
+        */
        start_ref = real_ref;
-       start_len = strlen(real_ref);
-       base_len = slash - real_ref;
        git_config(get_remote_config);
        if (!config_repo && !config_remote &&
            !prefixcmp(real_ref, "refs/heads/")) {
@@ -462,7 +477,7 @@ static void create_branch(const char *name, const char *start_name,
                die("Not a valid branch point: '%s'.", start_name);
        hashcpy(sha1, commit->object.sha1);
 
-       lock = lock_any_ref_for_update(ref, NULL);
+       lock = lock_any_ref_for_update(ref, NULL, 0);
        if (!lock)
                die("Failed to lock ref for update: %s.", strerror(errno));
 
index ff90ebd465002882781507ecfcfc33cab2f759fc..4274ec19500953bd7b6775e6d66271e9e116fa86 100644 (file)
@@ -111,6 +111,8 @@ int cmd_count_objects(int ac, const char **av, const char *prefix)
                for (p = packed_git; p; p = p->next) {
                        if (!p->pack_local)
                                continue;
+                       if (open_pack_index(p))
+                               continue;
                        packed += p->num_objects;
                        num_pack++;
                }
index 165917e40db78e7105a16d6e7a1653862a29fdc5..669110cb0645629ca5b152d8328aa91d63be1550 100644 (file)
@@ -3,6 +3,7 @@
 #include "tag.h"
 #include "refs.h"
 #include "builtin.h"
+#include "exec_cmd.h"
 
 #define SEEN           (1u<<0)
 #define MAX_TAGS       (FLAG_BITS - 1)
@@ -242,12 +243,15 @@ static void describe(const char *arg, int last_one)
 int cmd_describe(int argc, const char **argv, const char *prefix)
 {
        int i;
+       int contains = 0;
 
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
 
                if (*arg != '-')
                        break;
+               else if (!strcmp(arg, "--contains"))
+                       contains = 1;
                else if (!strcmp(arg, "--debug"))
                        debug = 1;
                else if (!strcmp(arg, "--all"))
@@ -272,6 +276,16 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 
        save_commit_buffer = 0;
 
+       if (contains) {
+               const char **args = xmalloc((4 + argc - i) * sizeof(char*));
+               args[0] = "name-rev";
+               args[1] = "--name-only";
+               args[2] = "--tags";
+               memcpy(args + 3, argv + i, (argc - i) * sizeof(char*));
+               args[3 + argc - i] = NULL;
+               return cmd_name_rev(3 + argc - i, args, prefix);
+       }
+
        if (argc <= i)
                describe("HEAD", 1);
        else
index d90eba95a6be17bd0486e0311c2657b1f69ab7d9..81e7167438ecfc25a6f9a317af663034d653588e 100644 (file)
@@ -23,7 +23,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
        argc = setup_revisions(argc, argv, &rev, NULL);
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
-                       
+
                if (!strcmp(arg, "--cached"))
                        cached = 1;
                else
index 12adb3833cd60771f8e63b2ebaecff3769fa74e2..ed4d5de5d5e6d0bef5b29f3d21a3e58ff7778c8b 100644 (file)
@@ -42,7 +42,7 @@ static int update_ref(const char *action,
        if (!rla)
                rla = "(reflog update)";
        snprintf(msg, sizeof(msg), "%s: %s", rla, action);
-       lock = lock_any_ref_for_update(refname, oldval);
+       lock = lock_any_ref_for_update(refname, oldval, 0);
        if (!lock)
                return 1;
        if (write_ref_sha1(lock, sha1, msg) < 0)
index 5c145d2165027adc5e5d44c6dda969e1ed86be57..ae60fccea74077b4d2456919d2f911f8a257c5b4 100644 (file)
@@ -357,4 +357,3 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 
        return 0;
 }
-
index 44ce629a498f986f239e008a61d32e10968907e0..944a496650b6e13d2684bb221ee8bc7aadd78d6f 100644 (file)
@@ -20,6 +20,7 @@ static int check_strict;
 static int keep_cache_objects;
 static unsigned char head_sha1[20];
 static int errors_found;
+static int verbose;
 #define ERROR_OBJECT 01
 #define ERROR_REACHABLE 02
 
@@ -149,6 +150,9 @@ static void check_unreachable_object(struct object *obj)
 
 static void check_object(struct object *obj)
 {
+       if (verbose)
+               fprintf(stderr, "Checking %s\n", sha1_to_hex(obj->sha1));
+
        if (obj->flags & REACHABLE)
                check_reachable_object(obj);
        else
@@ -161,6 +165,9 @@ static void check_connectivity(void)
 
        /* Look up all the requirements, warn about missing objects.. */
        max = get_max_object_index();
+       if (verbose)
+               fprintf(stderr, "Checking connectivity (%d objects)\n", max);
+
        for (i = 0; i < max; i++) {
                struct object *obj = get_indexed_object(i);
 
@@ -229,6 +236,10 @@ static int fsck_tree(struct tree *item)
        const char *o_name;
        const unsigned char *o_sha1;
 
+       if (verbose)
+               fprintf(stderr, "Checking tree %s\n",
+                               sha1_to_hex(item->object.sha1));
+
        init_tree_desc(&desc, item->buffer, item->size);
 
        o_mode = 0;
@@ -256,7 +267,7 @@ static int fsck_tree(struct tree *item)
                case S_IFREG | 0644:
                case S_IFLNK:
                case S_IFDIR:
-               case S_IFDIRLNK:
+               case S_IFGITLINK:
                        break;
                /*
                 * This is nonstandard, but we had a few of these
@@ -317,6 +328,10 @@ static int fsck_commit(struct commit *commit)
        char *buffer = commit->buffer;
        unsigned char tree_sha1[20], sha1[20];
 
+       if (verbose)
+               fprintf(stderr, "Checking commit %s\n",
+                       sha1_to_hex(commit->object.sha1));
+
        if (memcmp(buffer, "tree ", 5))
                return objerror(&commit->object, "invalid format - expected 'tree' line");
        if (get_sha1_hex(buffer+5, tree_sha1) || buffer[45] != '\n')
@@ -336,7 +351,7 @@ static int fsck_commit(struct commit *commit)
        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", 
+               printf("bad commit date in %s\n",
                       sha1_to_hex(commit->object.sha1));
        return 0;
 }
@@ -345,6 +360,10 @@ static int fsck_tag(struct tag *tag)
 {
        struct object *tagged = tag->tagged;
 
+       if (verbose)
+               fprintf(stderr, "Checking tag %s\n",
+                       sha1_to_hex(tag->object.sha1));
+
        if (!tagged) {
                return objerror(&tag->object, "could not load tagged object");
        }
@@ -446,6 +465,9 @@ static void fsck_dir(int i, char *path)
        if (!dir)
                return;
 
+       if (verbose)
+               fprintf(stderr, "Checking directory %s\n", path);
+
        while ((de = readdir(dir)) != NULL) {
                char name[100];
                unsigned char sha1[20];
@@ -480,6 +502,10 @@ static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
 {
        struct object *obj;
 
+       if (verbose)
+               fprintf(stderr, "Checking reflog %s->%s\n",
+                       sha1_to_hex(osha1), sha1_to_hex(nsha1));
+
        if (!is_null_sha1(osha1)) {
                obj = lookup_object(osha1);
                if (obj) {
@@ -549,6 +575,10 @@ static void get_default_heads(void)
 static void fsck_object_dir(const char *path)
 {
        int i;
+
+       if (verbose)
+               fprintf(stderr, "Checking object directory\n");
+
        for (i = 0; i < 256; i++) {
                static char dir[4096];
                sprintf(dir, "%s/%02x", path, i);
@@ -564,6 +594,9 @@ static int fsck_head_link(void)
        int null_is_error = 0;
        const char *head_points_at = resolve_ref("HEAD", sha1, 0, &flag);
 
+       if (verbose)
+               fprintf(stderr, "Checking HEAD link\n");
+
        if (!head_points_at)
                return error("Invalid HEAD");
        if (!strcmp(head_points_at, "HEAD"))
@@ -586,6 +619,9 @@ static int fsck_cache_tree(struct cache_tree *it)
        int i;
        int err = 0;
 
+       if (verbose)
+               fprintf(stderr, "Checking cache tree\n");
+
        if (0 <= it->entry_count) {
                struct object *obj = parse_object(it->sha1);
                if (!obj) {
@@ -605,7 +641,7 @@ static int fsck_cache_tree(struct cache_tree *it)
 
 static const char fsck_usage[] =
 "git-fsck [--tags] [--root] [[--unreachable] [--cache] [--full] "
-"[--strict] <head-sha1>*]";
+"[--strict] [--verbose] <head-sha1>*]";
 
 int cmd_fsck(int argc, char **argv, const char *prefix)
 {
@@ -645,6 +681,10 @@ int cmd_fsck(int argc, char **argv, const char *prefix)
                        check_strict = 1;
                        continue;
                }
+               if (!strcmp(arg, "--verbose")) {
+                       verbose = 1;
+                       continue;
+               }
                if (*arg == '-')
                        usage(fsck_usage);
        }
@@ -668,7 +708,10 @@ int cmd_fsck(int argc, char **argv, const char *prefix)
                        verify_pack(p, 0);
 
                for (p = packed_git; p; p = p->next) {
-                       uint32_t i, num = p->num_objects;
+                       uint32_t i, num;
+                       if (open_pack_index(p))
+                               continue;
+                       num = p->num_objects;
                        for (i = 0; i < num; i++)
                                fsck_sha1(nth_packed_object_sha1(p, i));
                }
@@ -676,7 +719,7 @@ int cmd_fsck(int argc, char **argv, const char *prefix)
 
        heads = 0;
        for (i = 1; i < argc; i++) {
-               const char *arg = argv[i]; 
+               const char *arg = argv[i];
 
                if (*arg == '-')
                        continue;
@@ -715,7 +758,7 @@ int cmd_fsck(int argc, char **argv, const char *prefix)
                        struct object *obj;
 
                        mode = ntohl(active_cache[i]->ce_mode);
-                       if (S_ISDIRLNK(mode))
+                       if (S_ISGITLINK(mode))
                                continue;
                        blob = lookup_blob(active_cache[i]->sha1);
                        if (!blob)
index 3b1f8c2f3e6d352b43c671a409898c43cf1119ec..45025fba30c1fb594a696c26a7eac11862cfd8f9 100644 (file)
 
 #define FAILED_RUN "failed to run %s"
 
-static const char builtin_gc_usage[] = "git-gc [--prune]";
+static const char builtin_gc_usage[] = "git-gc [--prune] [--aggressive]";
 
-static int pack_refs = -1;
+static int pack_refs = 1;
+static int aggressive_window = -1;
 
-static const char *argv_pack_refs[] = {"pack-refs", "--prune", NULL};
+#define MAX_ADD 10
+static const char *argv_pack_refs[] = {"pack-refs", "--all", "--prune", NULL};
 static const char *argv_reflog[] = {"reflog", "expire", "--all", NULL};
-static const char *argv_repack[] = {"repack", "-a", "-d", "-l", NULL};
+static const char *argv_repack[MAX_ADD] = {"repack", "-a", "-d", "-l", NULL};
 static const char *argv_prune[] = {"prune", NULL};
 static const char *argv_rerere[] = {"rerere", "gc", NULL};
 
@@ -34,13 +36,31 @@ static int gc_config(const char *var, const char *value)
                        pack_refs = git_config_bool(var, value);
                return 0;
        }
+       if (!strcmp(var, "gc.aggressivewindow")) {
+               aggressive_window = git_config_int(var, value);
+               return 0;
+       }
        return git_default_config(var, value);
 }
 
+static void append_option(const char **cmd, const char *opt, int max_length)
+{
+       int i;
+
+       for (i = 0; cmd[i]; i++)
+               ;
+
+       if (i + 2 >= max_length)
+               die("Too many options specified");
+       cmd[i++] = opt;
+       cmd[i] = NULL;
+}
+
 int cmd_gc(int argc, const char **argv, const char *prefix)
 {
        int i;
        int prune = 0;
+       char buf[80];
 
        git_config(gc_config);
 
@@ -53,6 +73,14 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
                        prune = 1;
                        continue;
                }
+               if (!strcmp(arg, "--aggressive")) {
+                       append_option(argv_repack, "-f", MAX_ADD);
+                       if (aggressive_window > 0) {
+                               sprintf(buf, "--window=%d", aggressive_window);
+                               append_option(argv_repack, buf, MAX_ADD);
+                       }
+                       continue;
+               }
                /* perhaps other parameters later... */
                break;
        }
index 37447123f924149f012a298eaf31dacb0c87b724..0aede7683986aff131f9278a968c84622c01181b 100644 (file)
@@ -60,13 +60,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
                rev->always_show_header = 0;
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
-               if (!prefixcmp(arg, "--encoding=")) {
-                       arg += 11;
-                       if (strcmp(arg, "none"))
-                               git_log_output_encoding = xstrdup(arg);
-                       else
-                               git_log_output_encoding = "";
-               } else if (!strcmp(arg, "--decorate")) {
+               if (!strcmp(arg, "--decorate")) {
                        if (!decorate)
                                for_each_ref(add_ref_decoration, NULL);
                        decorate = 1;
@@ -298,7 +292,8 @@ static int git_format_config(const char *var, const char *value)
 static FILE *realstdout = NULL;
 static const char *output_directory = NULL;
 
-static int reopen_stdout(struct commit *commit, int nr, int keep_subject)
+static int reopen_stdout(struct commit *commit, int nr, int keep_subject,
+                        int numbered_files)
 {
        char filename[PATH_MAX];
        char *sol;
@@ -315,53 +310,61 @@ static int reopen_stdout(struct commit *commit, int nr, int keep_subject)
                        filename[len++] = '/';
        }
 
-       sprintf(filename + len, "%04d", nr);
-       len = strlen(filename);
-
-       sol = strstr(commit->buffer, "\n\n");
-       if (sol) {
-               int j, space = 1;
-
-               sol += 2;
-               /* strip [PATCH] or [PATCH blabla] */
-               if (!keep_subject && !prefixcmp(sol, "[PATCH")) {
-                       char *eos = strchr(sol + 6, ']');
-                       if (eos) {
-                               while (isspace(*eos))
-                                       eos++;
-                               sol = eos;
-                       }
-               }
+       if (numbered_files) {
+               sprintf(filename + len, "%d", nr);
+               len = strlen(filename);
+
+       } else {
+               sprintf(filename + len, "%04d", nr);
+               len = strlen(filename);
 
-               for (j = 0;
-                    j < FORMAT_PATCH_NAME_MAX - suffix_len - 5 &&
-                            len < sizeof(filename) - suffix_len &&
-                            sol[j] && sol[j] != '\n';
-                    j++) {
-                       if (istitlechar(sol[j])) {
-                               if (space) {
-                                       filename[len++] = '-';
-                                       space = 0;
+               sol = strstr(commit->buffer, "\n\n");
+               if (sol) {
+                       int j, space = 1;
+
+                       sol += 2;
+                       /* strip [PATCH] or [PATCH blabla] */
+                       if (!keep_subject && !prefixcmp(sol, "[PATCH")) {
+                               char *eos = strchr(sol + 6, ']');
+                               if (eos) {
+                                       while (isspace(*eos))
+                                               eos++;
+                                       sol = eos;
                                }
-                               filename[len++] = sol[j];
-                               if (sol[j] == '.')
-                                       while (sol[j + 1] == '.')
-                                               j++;
-                       } else
-                               space = 1;
+                       }
+
+                       for (j = 0;
+                            j < FORMAT_PATCH_NAME_MAX - suffix_len - 5 &&
+                                    len < sizeof(filename) - suffix_len &&
+                                    sol[j] && sol[j] != '\n';
+                            j++) {
+                               if (istitlechar(sol[j])) {
+                                       if (space) {
+                                               filename[len++] = '-';
+                                               space = 0;
+                                       }
+                                       filename[len++] = sol[j];
+                                       if (sol[j] == '.')
+                                               while (sol[j + 1] == '.')
+                                                       j++;
+                               } else
+                                       space = 1;
+                       }
+                       while (filename[len - 1] == '.'
+                              || filename[len - 1] == '-')
+                               len--;
+                       filename[len] = 0;
                }
-               while (filename[len - 1] == '.' || filename[len - 1] == '-')
-                       len--;
-               filename[len] = 0;
+               if (len + suffix_len >= sizeof(filename))
+                       return error("Patch pathname too long");
+               strcpy(filename + len, fmt_patch_suffix);
        }
-       if (len + suffix_len >= sizeof(filename))
-               return error("Patch pathname too long");
-       strcpy(filename + len, fmt_patch_suffix);
+
        fprintf(realstdout, "%s\n", filename);
        if (freopen(filename, "w", stdout) == NULL)
                return error("Cannot open patch file %s",filename);
-       return 0;
 
+       return 0;
 }
 
 static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const char *prefix)
@@ -431,6 +434,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        int numbered = 0;
        int start_number = -1;
        int keep_subject = 0;
+       int numbered_files = 0;         /* _just_ numbers */
        int subject_prefix = 0;
        int ignore_if_in_upstream = 0;
        int thread = 0;
@@ -465,6 +469,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                        numbered = 1;
                else if (!prefixcmp(argv[i], "--start-number="))
                        start_number = strtol(argv[i] + 15, NULL, 10);
+               else if (!strcmp(argv[i], "--numbered-files"))
+                       numbered_files = 1;
                else if (!strcmp(argv[i], "--start-number")) {
                        i++;
                        if (i == argc)
@@ -540,6 +546,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                die ("-n and -k are mutually exclusive.");
        if (keep_subject && subject_prefix)
                die ("--subject-prefix and -k are mutually exclusive.");
+       if (numbered_files && use_stdout)
+               die ("--numbered-files and --stdout are mutually exclusive.");
 
        argc = setup_revisions(argc, argv, &rev, "HEAD");
        if (argc > 1)
@@ -614,7 +622,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                        rev.message_id = message_id;
                }
                if (!use_stdout)
-                       if (reopen_stdout(commit, rev.nr, keep_subject))
+                       if (reopen_stdout(commit, rev.nr, keep_subject,
+                                         numbered_files))
                                die("Failed to create output files");
                shown = log_tree_commit(&rev, commit);
                free(commit->buffer);
index f7c066b24b7a6a728fd2f0bf4a92a31fb4a695dd..5398a41415372b07fa1fdb43c26b5570e9d990b8 100644 (file)
@@ -117,7 +117,7 @@ static void show_other_files(struct dir_struct *dir)
                if (0 <= pos)
                        continue;       /* exact match */
                pos = -pos - 1;
-               if (pos < active_nr) { 
+               if (pos < active_nr) {
                        ce = active_cache[pos];
                        if (ce_namelen(ce) == len &&
                            !memcmp(ce->name, ent->name, len))
index 1cb4dca277b511315d3b914239c57621fc60bcf3..cb4be4fabb84bafd5518e81d2fd0ed6ee191641c 100644 (file)
@@ -15,6 +15,7 @@ static int line_termination = '\n';
 #define LS_TREE_ONLY 2
 #define LS_SHOW_TREES 4
 #define LS_NAME_ONLY 8
+#define LS_SHOW_SIZE 16
 static int abbrev;
 static int ls_options;
 static const char **pathspec;
@@ -22,7 +23,7 @@ static int chomp_prefix;
 static const char *ls_tree_prefix;
 
 static const char ls_tree_usage[] =
-       "git-ls-tree [-d] [-r] [-t] [-z] [--name-only] [--name-status] [--full-name] [--abbrev[=<n>]] <tree-ish> [path...]";
+       "git-ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--abbrev[=<n>]] <tree-ish> [path...]";
 
 static int show_recursive(const char *base, int baselen, const char *pathname)
 {
@@ -59,8 +60,9 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
 {
        int retval = 0;
        const char *type = blob_type;
+       unsigned long size;
 
-       if (S_ISDIRLNK(mode)) {
+       if (S_ISGITLINK(mode)) {
                /*
                 * Maybe we want to have some recursive version here?
                 *
@@ -92,10 +94,24 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
            (baselen < chomp_prefix || memcmp(ls_tree_prefix, base, chomp_prefix)))
                return 0;
 
-       if (!(ls_options & LS_NAME_ONLY))
-               printf("%06o %s %s\t", mode, type,
-                               abbrev ? find_unique_abbrev(sha1,abbrev)
-                                       : sha1_to_hex(sha1));
+       if (!(ls_options & LS_NAME_ONLY)) {
+               if (ls_options & LS_SHOW_SIZE) {
+                       if (!strcmp(type, blob_type)) {
+                               sha1_object_info(sha1, &size);
+                               printf("%06o %s %s %7lu\t", mode, type,
+                                      abbrev ? find_unique_abbrev(sha1, abbrev)
+                                             : sha1_to_hex(sha1),
+                                      size);
+                       } else
+                               printf("%06o %s %s %7c\t", mode, type,
+                                      abbrev ? find_unique_abbrev(sha1, abbrev)
+                                             : sha1_to_hex(sha1),
+                                      '-');
+               } else
+                       printf("%06o %s %s\t", mode, type,
+                              abbrev ? find_unique_abbrev(sha1, abbrev)
+                                     : sha1_to_hex(sha1));
+       }
        write_name_quoted(base + chomp_prefix, baselen - chomp_prefix,
                          pathname,
                          line_termination, stdout);
@@ -126,12 +142,19 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
                case 't':
                        ls_options |= LS_SHOW_TREES;
                        break;
+               case 'l':
+                       ls_options |= LS_SHOW_SIZE;
+                       break;
                case '-':
                        if (!strcmp(argv[1]+2, "name-only") ||
                            !strcmp(argv[1]+2, "name-status")) {
                                ls_options |= LS_NAME_ONLY;
                                break;
                        }
+                       if (!strcmp(argv[1]+2, "long")) {
+                               ls_options |= LS_SHOW_SIZE;
+                               break;
+                       }
                        if (!strcmp(argv[1]+2, "full-name")) {
                                chomp_prefix = 0;
                                break;
index c95e477e831dd436f074bbca9b2b9ca5ad5a5eb1..489c2c58c01514ac3d967d1c3f46f1243f853580 100644 (file)
@@ -851,8 +851,8 @@ static void handle_info(void)
        fprintf(fout, "\n");
 }
 
-int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
-            const char *msg, const char *patch)
+static int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
+                   const char *msg, const char *patch)
 {
        keep_subject = ks;
        metainfo_charset = encoding;
index 3bca855aae857cde15f2a249f8e0a5c30b3e7d82..43fc373a15cbe935054b47f9bd67c04ecf216e4e 100644 (file)
@@ -6,9 +6,10 @@
  */
 #include "cache.h"
 #include "builtin.h"
+#include "path-list.h"
 
 static const char git_mailsplit_usage[] =
-"git-mailsplit [-d<prec>] [-f<n>] [-b] -o<directory> <mbox>...";
+"git-mailsplit [-d<prec>] [-f<n>] [-b] -o<directory> <mbox>|<Maildir>...";
 
 static int is_from_line(const char *line, int len)
 {
@@ -96,44 +97,107 @@ static int split_one(FILE *mbox, const char *name, int allow_bare)
        exit(1);
 }
 
-int split_mbox(const char **mbox, const char *dir, int allow_bare, int nr_prec, int skip)
+static int populate_maildir_list(struct path_list *list, const char *path)
 {
-       char *name = xmalloc(strlen(dir) + 2 + 3 * sizeof(skip));
+       DIR *dir;
+       struct dirent *dent;
+
+       if ((dir = opendir(path)) == NULL) {
+               error("cannot opendir %s (%s)", path, strerror(errno));
+               return -1;
+       }
+
+       while ((dent = readdir(dir)) != NULL) {
+               if (dent->d_name[0] == '.')
+                       continue;
+               path_list_insert(dent->d_name, list);
+       }
+
+       closedir(dir);
+
+       return 0;
+}
+
+static int split_maildir(const char *maildir, const char *dir,
+       int nr_prec, int skip)
+{
+       char file[PATH_MAX];
+       char curdir[PATH_MAX];
+       char name[PATH_MAX];
        int ret = -1;
+       int i;
+       struct path_list list = {NULL, 0, 0, 1};
 
-       while (*mbox) {
-               const char *file = *mbox++;
-               FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r");
-               int file_done = 0;
+       snprintf(curdir, sizeof(curdir), "%s/cur", maildir);
+       if (populate_maildir_list(&list, curdir) < 0)
+               goto out;
 
-               if ( !f ) {
-                       error("cannot open mbox %s", file);
+       for (i = 0; i < list.nr; i++) {
+               FILE *f;
+               snprintf(file, sizeof(file), "%s/%s", curdir, list.items[i].path);
+               f = fopen(file, "r");
+               if (!f) {
+                       error("cannot open mail %s (%s)", file, strerror(errno));
                        goto out;
                }
 
                if (fgets(buf, sizeof(buf), f) == NULL) {
-                       if (f == stdin)
-                               break; /* empty stdin is OK */
-                       error("cannot read mbox %s", file);
+                       error("cannot read mail %s (%s)", file, strerror(errno));
                        goto out;
                }
 
-               while (!file_done) {
-                       sprintf(name, "%s/%0*d", dir, nr_prec, ++skip);
-                       file_done = split_one(f, name, allow_bare);
+               sprintf(name, "%s/%0*d", dir, nr_prec, ++skip);
+               split_one(f, name, 1);
+
+               fclose(f);
+       }
+
+       path_list_clear(&list, 1);
+
+       ret = skip;
+out:
+       return ret;
+}
+
+static int split_mbox(const char *file, const char *dir, int allow_bare,
+                     int nr_prec, int skip)
+{
+       char name[PATH_MAX];
+       int ret = -1;
+
+       FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r");
+       int file_done = 0;
+
+       if (!f) {
+               error("cannot open mbox %s", file);
+               goto out;
+       }
+
+       if (fgets(buf, sizeof(buf), f) == NULL) {
+               /* empty stdin is OK */
+               if (f != stdin) {
+                       error("cannot read mbox %s", file);
+                       goto out;
                }
+               file_done = 1;
+       }
 
-               if (f != stdin)
-                       fclose(f);
+       while (!file_done) {
+               sprintf(name, "%s/%0*d", dir, nr_prec, ++skip);
+               file_done = split_one(f, name, allow_bare);
        }
+
+       if (f != stdin)
+               fclose(f);
+
        ret = skip;
 out:
-       free(name);
        return ret;
 }
+
 int cmd_mailsplit(int argc, const char **argv, const char *prefix)
 {
-       int nr = 0, nr_prec = 4, ret;
+       int nr = 0, nr_prec = 4, num = 0;
        int allow_bare = 0;
        const char *dir = NULL;
        const char **argp;
@@ -186,9 +250,41 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)
                        argp = stdin_only;
        }
 
-       ret = split_mbox(argp, dir, allow_bare, nr_prec, nr);
-       if (ret != -1)
-               printf("%d\n", ret);
+       while (*argp) {
+               const char *arg = *argp++;
+               struct stat argstat;
+               int ret = 0;
+
+               if (arg[0] == '-' && arg[1] == 0) {
+                       ret = split_mbox(arg, dir, allow_bare, nr_prec, nr);
+                       if (ret < 0) {
+                               error("cannot split patches from stdin");
+                               return 1;
+                       }
+                       num += (ret - nr);
+                       nr = ret;
+                       continue;
+               }
+
+               if (stat(arg, &argstat) == -1) {
+                       error("cannot stat %s (%s)", arg, strerror(errno));
+                       return 1;
+               }
+
+               if (S_ISDIR(argstat.st_mode))
+                       ret = split_maildir(arg, dir, nr_prec, nr);
+               else
+                       ret = split_mbox(arg, dir, allow_bare, nr_prec, nr);
+
+               if (ret < 0) {
+                       error("cannot split patches from %s", arg);
+                       return 1;
+               }
+               num += (ret - nr);
+               nr = ret;
+       }
+
+       printf("%d\n", num);
 
-       return ret == -1;
+       return 0;
 }
index 913577390862a847857a650516740059072b60ad..10ec63b17e6b16382f2b39e5c01cc6cf1dce448e 100644 (file)
@@ -36,9 +36,13 @@ int cmd_merge_file(int argc, char **argv, char **envp)
        for (; i < 3; i++)
                names[i] = argv[i + 1];
 
-       for (i = 0; i < 3; i++)
+       for (i = 0; i < 3; i++) {
                if (read_mmfile(mmfs + i, argv[i + 1]))
                        return -1;
+               if (buffer_is_binary(mmfs[i].ptr, mmfs[i].size))
+                       return error("Cannot merge binary files: %s\n",
+                                       argv[i + 1]);
+       }
 
        ret = xdl_merge(mmfs + 1, mmfs + 0, names[0], mmfs + 2, names[2],
                        &xpp, XDL_MERGE_ZEALOUS, &result);
index 2d94eaaa6a90f2efe4401873930533b12b85522f..61eba343ab781341a0baf127b323508a0c2af332 100644 (file)
@@ -85,6 +85,7 @@ copy_data:
 
 struct name_ref_data {
        int tags_only;
+       int name_only;
        const char *ref_filter;
 };
 
@@ -112,6 +113,10 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void
 
                if (!prefixcmp(path, "refs/heads/"))
                        path = path + 11;
+               else if (data->tags_only
+                   && data->name_only
+                   && !prefixcmp(path, "refs/tags/"))
+                       path = path + 10;
                else if (!prefixcmp(path, "refs/"))
                        path = path + 5;
 
@@ -151,7 +156,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
 {
        struct object_array revs = { 0, 0, NULL };
        int as_is = 0, all = 0, transform_stdin = 0;
-       struct name_ref_data data = { 0, NULL };
+       struct name_ref_data data = { 0, 0, NULL };
 
        git_config(git_default_config);
 
@@ -167,6 +172,9 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
                        if (!strcmp(*argv, "--")) {
                                as_is = 1;
                                continue;
+                       } else if (!strcmp(*argv, "--name-only")) {
+                               data.name_only = 1;
+                               continue;
                        } else if (!strcmp(*argv, "--tags")) {
                                data.tags_only = 1;
                                continue;
@@ -267,16 +275,18 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
                        struct object * obj = get_indexed_object(i);
                        if (!obj)
                                continue;
-                       printf("%s %s\n", sha1_to_hex(obj->sha1), get_rev_name(obj));
+                       if (!data.name_only)
+                               printf("%s ", sha1_to_hex(obj->sha1));
+                       printf("%s\n", get_rev_name(obj));
                }
        } else {
                int i;
-               for (i = 0; i < revs.nr; i++)
-                       printf("%s %s\n",
-                               revs.objects[i].name,
-                               get_rev_name(revs.objects[i].item));
+               for (i = 0; i < revs.nr; i++) {
+                       if (!data.name_only)
+                               printf("%s ", revs.objects[i].name);
+                       printf("%s\n", get_rev_name(revs.objects[i].item));
+               }
        }
 
        return 0;
 }
-
index 966f843e4357d45b8c9acf96617bdacd8dc1b133..3d396ca37ac1356c7974aaaf34af39bcd0cf6bae 100644 (file)
@@ -1,5 +1,6 @@
 #include "builtin.h"
 #include "cache.h"
+#include "attr.h"
 #include "object.h"
 #include "blob.h"
 #include "commit.h"
 #include "progress.h"
 
 static const char pack_usage[] = "\
-git-pack-objects [{ -q | --progress | --all-progress }] \n\
+git-pack-objects [{ -q | --progress | --all-progress }] [--max-pack-size=N] \n\
        [--local] [--incremental] [--window=N] [--depth=N] \n\
-       [--no-reuse-delta] [--delta-base-offset] [--non-empty] \n\
-       [--revs [--unpacked | --all]*] [--reflog] [--stdout | base-name] \n\
-       [<ref-list | <object-list]";
+       [--no-reuse-delta] [--no-reuse-object] [--delta-base-offset] \n\
+       [--non-empty] [--revs [--unpacked | --all]*] [--reflog] \n\
+       [--stdout | base-name] [<ref-list | <object-list]";
 
 struct object_entry {
-       unsigned char sha1[20];
-       uint32_t crc32;         /* crc of raw pack data for this object */
-       off_t offset;           /* offset into the final pack file */
+       struct pack_idx_entry idx;
        unsigned long size;     /* uncompressed size */
+
        unsigned int hash;      /* name hint hash */
        unsigned int depth;     /* delta depth */
        struct packed_git *in_pack;     /* already in pack */
@@ -35,14 +35,16 @@ struct object_entry {
        struct object_entry *delta_sibling; /* other deltified objects who
                                             * uses the same base as me
                                             */
+       void *delta_data;       /* cached delta (uncompressed) */
        unsigned long delta_size;       /* delta data size (uncompressed) */
        enum object_type type;
        enum object_type in_pack_type;  /* could be delta */
        unsigned char in_pack_header_size;
        unsigned char preferred_base; /* we do not pack this, but is available
-                                      * to be used as the base objectto delta
+                                      * to be used as the base object to delta
                                       * objects against.
                                       */
+       unsigned char no_try_delta;
 };
 
 /*
@@ -52,22 +54,30 @@ struct object_entry {
  * nice "minimum seek" order.
  */
 static struct object_entry *objects;
-static uint32_t nr_objects, nr_alloc, nr_result;
+static struct object_entry **written_list;
+static uint32_t nr_objects, nr_alloc, nr_result, nr_written;
 
 static int non_empty;
-static int no_reuse_delta;
+static int no_reuse_delta, no_reuse_object;
 static int local;
 static int incremental;
 static int allow_ofs_delta;
 static const char *pack_tmp_name, *idx_tmp_name;
 static char tmpname[PATH_MAX];
-static unsigned char pack_file_sha1[20];
+static const char *base_name;
 static int progress = 1;
 static int window = 10;
+static uint32_t pack_size_limit;
 static int depth = 50;
 static int pack_to_stdout;
 static int num_preferred_base;
 static struct progress progress_state;
+static int pack_compression_level = Z_DEFAULT_COMPRESSION;
+static int pack_compression_seen;
+
+static unsigned long delta_cache_size = 0;
+static unsigned long max_delta_cache_size = 0;
+static unsigned long cache_max_small_delta_size = 1000;
 
 /*
  * The object names in objects array are hashed with this hashtable,
@@ -234,15 +244,15 @@ static void *delta_against(void *buf, unsigned long size, struct object_entry *e
 {
        unsigned long othersize, delta_size;
        enum object_type type;
-       void *otherbuf = read_sha1_file(entry->delta->sha1, &type, &othersize);
+       void *otherbuf = read_sha1_file(entry->delta->idx.sha1, &type, &othersize);
        void *delta_buf;
 
        if (!otherbuf)
-               die("unable to read %s", sha1_to_hex(entry->delta->sha1));
+               die("unable to read %s", sha1_to_hex(entry->delta->idx.sha1));
         delta_buf = diff_delta(otherbuf, othersize,
                               buf, size, &delta_size, 0);
         if (!delta_buf || delta_size != entry->delta_size)
-               die("delta size changed");
+               die("delta size changed");
         free(buf);
         free(otherbuf);
        return delta_buf;
@@ -346,76 +356,45 @@ static void copy_pack_data(struct sha1file *f,
        }
 }
 
-static int check_loose_inflate(unsigned char *data, unsigned long len, unsigned long expect)
-{
-       z_stream stream;
-       unsigned char fakebuf[4096];
-       int st;
-
-       memset(&stream, 0, sizeof(stream));
-       stream.next_in = data;
-       stream.avail_in = len;
-       stream.next_out = fakebuf;
-       stream.avail_out = sizeof(fakebuf);
-       inflateInit(&stream);
-
-       while (1) {
-               st = inflate(&stream, Z_FINISH);
-               if (st == Z_STREAM_END || st == Z_OK) {
-                       st = (stream.total_out == expect &&
-                             stream.total_in == len) ? 0 : -1;
-                       break;
-               }
-               if (st != Z_BUF_ERROR) {
-                       st = -1;
-                       break;
-               }
-               stream.next_out = fakebuf;
-               stream.avail_out = sizeof(fakebuf);
-       }
-       inflateEnd(&stream);
-       return st;
-}
-
-static int revalidate_loose_object(struct object_entry *entry,
-                                  unsigned char *map,
-                                  unsigned long mapsize)
-{
-       /* we already know this is a loose object with new type header. */
-       enum object_type type;
-       unsigned long size, used;
-
-       if (pack_to_stdout)
-               return 0;
-
-       used = unpack_object_header_gently(map, mapsize, &type, &size);
-       if (!used)
-               return -1;
-       map += used;
-       mapsize -= used;
-       return check_loose_inflate(map, mapsize, size);
-}
-
 static unsigned long write_object(struct sha1file *f,
-                                 struct object_entry *entry)
+                                 struct object_entry *entry,
+                                 off_t write_offset)
 {
        unsigned long size;
        enum object_type type;
        void *buf;
        unsigned char header[10];
+       unsigned char dheader[10];
        unsigned hdrlen;
        off_t datalen;
        enum object_type obj_type;
        int to_reuse = 0;
+       /* write limit if limited packsize and not first object */
+       unsigned long limit = pack_size_limit && nr_written ?
+                               pack_size_limit - write_offset : 0;
+                               /* no if no delta */
+       int usable_delta =      !entry->delta ? 0 :
+                               /* yes if unlimited packfile */
+                               !pack_size_limit ? 1 :
+                               /* no if base written to previous pack */
+                               entry->delta->idx.offset == (off_t)-1 ? 0 :
+                               /* otherwise double-check written to this
+                                * pack,  like we do below
+                                */
+                               entry->delta->idx.offset ? 1 : 0;
 
        if (!pack_to_stdout)
                crc32_begin(f);
 
        obj_type = entry->type;
-       if (! entry->in_pack)
+       if (no_reuse_object)
+               to_reuse = 0;   /* explicit */
+       else if (!entry->in_pack)
                to_reuse = 0;   /* can't reuse what we don't have */
        else if (obj_type == OBJ_REF_DELTA || obj_type == OBJ_OFS_DELTA)
-               to_reuse = 1;   /* check_object() decided it for us */
+                               /* check_object() decided it for us ... */
+               to_reuse = usable_delta;
+                               /* ... but pack split may override that */
        else if (obj_type != entry->in_pack_type)
                to_reuse = 0;   /* pack has delta which is unusable */
        else if (entry->delta)
@@ -425,44 +404,49 @@ static unsigned long write_object(struct sha1file *f,
                                 * and we do not need to deltify it.
                                 */
 
-       if (!entry->in_pack && !entry->delta) {
-               unsigned char *map;
-               unsigned long mapsize;
-               map = map_sha1_file(entry->sha1, &mapsize);
-               if (map && !legacy_loose_object(map)) {
-                       /* We can copy straight into the pack file */
-                       if (revalidate_loose_object(entry, map, mapsize))
-                               die("corrupt loose object %s",
-                                   sha1_to_hex(entry->sha1));
-                       sha1write(f, map, mapsize);
-                       munmap(map, mapsize);
-                       written++;
-                       reused++;
-                       return mapsize;
-               }
-               if (map)
-                       munmap(map, mapsize);
-       }
-
        if (!to_reuse) {
-               buf = read_sha1_file(entry->sha1, &type, &size);
-               if (!buf)
-                       die("unable to read %s", sha1_to_hex(entry->sha1));
-               if (size != entry->size)
-                       die("object %s size inconsistency (%lu vs %lu)",
-                           sha1_to_hex(entry->sha1), size, entry->size);
-               if (entry->delta) {
+               z_stream stream;
+               unsigned long maxsize;
+               void *out;
+               if (!usable_delta) {
+                       buf = read_sha1_file(entry->idx.sha1, &obj_type, &size);
+                       if (!buf)
+                               die("unable to read %s", sha1_to_hex(entry->idx.sha1));
+               } else if (entry->delta_data) {
+                       size = entry->delta_size;
+                       buf = entry->delta_data;
+                       entry->delta_data = NULL;
+                       obj_type = (allow_ofs_delta && entry->delta->idx.offset) ?
+                               OBJ_OFS_DELTA : OBJ_REF_DELTA;
+               } else {
+                       buf = read_sha1_file(entry->idx.sha1, &type, &size);
+                       if (!buf)
+                               die("unable to read %s", sha1_to_hex(entry->idx.sha1));
                        buf = delta_against(buf, size, entry);
                        size = entry->delta_size;
-                       obj_type = (allow_ofs_delta && entry->delta->offset) ?
+                       obj_type = (allow_ofs_delta && entry->delta->idx.offset) ?
                                OBJ_OFS_DELTA : OBJ_REF_DELTA;
                }
+               /* compress the data to store and put compressed length in datalen */
+               memset(&stream, 0, sizeof(stream));
+               deflateInit(&stream, pack_compression_level);
+               maxsize = deflateBound(&stream, size);
+               out = xmalloc(maxsize);
+               /* Compress it */
+               stream.next_in = buf;
+               stream.avail_in = size;
+               stream.next_out = out;
+               stream.avail_out = maxsize;
+               while (deflate(&stream, Z_FINISH) == Z_OK)
+                       /* nothing */;
+               deflateEnd(&stream);
+               datalen = stream.total_out;
+               deflateEnd(&stream);
                /*
                 * The object header is a byte of 'type' followed by zero or
                 * more bytes of length.
                 */
                hdrlen = encode_header(obj_type, size, header);
-               sha1write(f, header, hdrlen);
 
                if (obj_type == OBJ_OFS_DELTA) {
                        /*
@@ -470,22 +454,42 @@ static unsigned long write_object(struct sha1file *f,
                         * encoding of the relative offset for the delta
                         * base from this object's position in the pack.
                         */
-                       off_t ofs = entry->offset - entry->delta->offset;
-                       unsigned pos = sizeof(header) - 1;
-                       header[pos] = ofs & 127;
+                       off_t ofs = entry->idx.offset - entry->delta->idx.offset;
+                       unsigned pos = sizeof(dheader) - 1;
+                       dheader[pos] = ofs & 127;
                        while (ofs >>= 7)
-                               header[--pos] = 128 | (--ofs & 127);
-                       sha1write(f, header + pos, sizeof(header) - pos);
-                       hdrlen += sizeof(header) - pos;
+                               dheader[--pos] = 128 | (--ofs & 127);
+                       if (limit && hdrlen + sizeof(dheader) - pos + datalen + 20 >= limit) {
+                               free(out);
+                               free(buf);
+                               return 0;
+                       }
+                       sha1write(f, header, hdrlen);
+                       sha1write(f, dheader + pos, sizeof(dheader) - pos);
+                       hdrlen += sizeof(dheader) - pos;
                } else if (obj_type == OBJ_REF_DELTA) {
                        /*
                         * Deltas with a base reference contain
                         * an additional 20 bytes for the base sha1.
                         */
-                       sha1write(f, entry->delta->sha1, 20);
+                       if (limit && hdrlen + 20 + datalen + 20 >= limit) {
+                               free(out);
+                               free(buf);
+                               return 0;
+                       }
+                       sha1write(f, header, hdrlen);
+                       sha1write(f, entry->delta->idx.sha1, 20);
                        hdrlen += 20;
+               } else {
+                       if (limit && hdrlen + datalen + 20 >= limit) {
+                               free(out);
+                               free(buf);
+                               return 0;
+                       }
+                       sha1write(f, header, hdrlen);
                }
-               datalen = sha1write_compressed(f, buf, size);
+               sha1write(f, out, datalen);
+               free(out);
                free(buf);
        }
        else {
@@ -495,45 +499,54 @@ static unsigned long write_object(struct sha1file *f,
                off_t offset;
 
                if (entry->delta) {
-                       obj_type = (allow_ofs_delta && entry->delta->offset) ?
+                       obj_type = (allow_ofs_delta && entry->delta->idx.offset) ?
                                OBJ_OFS_DELTA : OBJ_REF_DELTA;
                        reused_delta++;
                }
                hdrlen = encode_header(obj_type, entry->size, header);
-               sha1write(f, header, hdrlen);
-               if (obj_type == OBJ_OFS_DELTA) {
-                       off_t ofs = entry->offset - entry->delta->offset;
-                       unsigned pos = sizeof(header) - 1;
-                       header[pos] = ofs & 127;
-                       while (ofs >>= 7)
-                               header[--pos] = 128 | (--ofs & 127);
-                       sha1write(f, header + pos, sizeof(header) - pos);
-                       hdrlen += sizeof(header) - pos;
-               } else if (obj_type == OBJ_REF_DELTA) {
-                       sha1write(f, entry->delta->sha1, 20);
-                       hdrlen += 20;
-               }
-
                offset = entry->in_pack_offset;
                revidx = find_packed_object(p, offset);
                datalen = revidx[1].offset - offset;
                if (!pack_to_stdout && p->index_version > 1 &&
                    check_pack_crc(p, &w_curs, offset, datalen, revidx->nr))
-                       die("bad packed object CRC for %s", sha1_to_hex(entry->sha1));
+                       die("bad packed object CRC for %s", sha1_to_hex(entry->idx.sha1));
                offset += entry->in_pack_header_size;
                datalen -= entry->in_pack_header_size;
+               if (obj_type == OBJ_OFS_DELTA) {
+                       off_t ofs = entry->idx.offset - entry->delta->idx.offset;
+                       unsigned pos = sizeof(dheader) - 1;
+                       dheader[pos] = ofs & 127;
+                       while (ofs >>= 7)
+                               dheader[--pos] = 128 | (--ofs & 127);
+                       if (limit && hdrlen + sizeof(dheader) - pos + datalen + 20 >= limit)
+                               return 0;
+                       sha1write(f, header, hdrlen);
+                       sha1write(f, dheader + pos, sizeof(dheader) - pos);
+                       hdrlen += sizeof(dheader) - pos;
+               } else if (obj_type == OBJ_REF_DELTA) {
+                       if (limit && hdrlen + 20 + datalen + 20 >= limit)
+                               return 0;
+                       sha1write(f, header, hdrlen);
+                       sha1write(f, entry->delta->idx.sha1, 20);
+                       hdrlen += 20;
+               } else {
+                       if (limit && hdrlen + datalen + 20 >= limit)
+                               return 0;
+                       sha1write(f, header, hdrlen);
+               }
+
                if (!pack_to_stdout && p->index_version == 1 &&
                    check_pack_inflate(p, &w_curs, offset, datalen, entry->size))
-                       die("corrupt packed object for %s", sha1_to_hex(entry->sha1));
+                       die("corrupt packed object for %s", sha1_to_hex(entry->idx.sha1));
                copy_pack_data(f, p, &w_curs, offset, datalen);
                unuse_pack(&w_curs);
                reused++;
        }
-       if (entry->delta)
+       if (usable_delta)
                written_delta++;
        written++;
        if (!pack_to_stdout)
-               entry->crc32 = crc32_end(f);
+               entry->idx.crc32 = crc32_end(f);
        return hdrlen + datalen;
 }
 
@@ -544,15 +557,23 @@ static off_t write_one(struct sha1file *f,
        unsigned long size;
 
        /* offset is non zero if object is written already. */
-       if (e->offset || e->preferred_base)
+       if (e->idx.offset || e->preferred_base)
                return offset;
 
        /* if we are deltified, write out base object first. */
-       if (e->delta)
+       if (e->delta) {
                offset = write_one(f, e->delta, offset);
+               if (!offset)
+                       return 0;
+       }
 
-       e->offset = offset;
-       size = write_object(f, e);
+       e->idx.offset = offset;
+       size = write_object(f, e, offset);
+       if (!size) {
+               e->idx.offset = 0;
+               return 0;
+       }
+       written_list[nr_written++] = e;
 
        /* make sure off_t is sufficiently large not to wrap */
        if (offset > offset + size)
@@ -566,174 +587,114 @@ static int open_object_dir_tmp(const char *path)
     return mkstemp(tmpname);
 }
 
-static off_t write_pack_file(void)
+/* forward declaration for write_pack_file */
+static int adjust_perm(const char *path, mode_t mode);
+
+static void write_pack_file(void)
 {
-       uint32_t i;
+       uint32_t i = 0, j;
        struct sha1file *f;
-       off_t offset, last_obj_offset = 0;
+       off_t offset, offset_one, last_obj_offset = 0;
        struct pack_header hdr;
-       int do_progress = progress;
-
-       if (pack_to_stdout) {
-               f = sha1fd(1, "<stdout>");
-               do_progress >>= 1;
-       } else {
-               int fd = open_object_dir_tmp("tmp_pack_XXXXXX");
-               if (fd < 0)
-                       die("unable to create %s: %s\n", tmpname, strerror(errno));
-               pack_tmp_name = xstrdup(tmpname);
-               f = sha1fd(fd, pack_tmp_name);
-       }
+       int do_progress = progress >> pack_to_stdout;
+       uint32_t nr_remaining = nr_result;
 
        if (do_progress)
                start_progress(&progress_state, "Writing %u objects...", "", nr_result);
+       written_list = xmalloc(nr_objects * sizeof(struct object_entry *));
 
-       hdr.hdr_signature = htonl(PACK_SIGNATURE);
-       hdr.hdr_version = htonl(PACK_VERSION);
-       hdr.hdr_entries = htonl(nr_result);
-       sha1write(f, &hdr, sizeof(hdr));
-       offset = sizeof(hdr);
-       if (!nr_result)
-               goto done;
-       for (i = 0; i < nr_objects; i++) {
-               last_obj_offset = offset;
-               offset = write_one(f, objects + i, offset);
-               if (do_progress)
-                       display_progress(&progress_state, written);
-       }
-       if (do_progress)
-               stop_progress(&progress_state);
- done:
-       if (written != nr_result)
-               die("wrote %u objects while expecting %u", written, nr_result);
-       sha1close(f, pack_file_sha1, 1);
-
-       return last_obj_offset;
-}
-
-static int sha1_sort(const void *_a, const void *_b)
-{
-       const struct object_entry *a = *(struct object_entry **)_a;
-       const struct object_entry *b = *(struct object_entry **)_b;
-       return hashcmp(a->sha1, b->sha1);
-}
-
-static uint32_t index_default_version = 1;
-static uint32_t index_off32_limit = 0x7fffffff;
-
-static void write_index_file(off_t last_obj_offset, unsigned char *sha1)
-{
-       struct sha1file *f;
-       struct object_entry **sorted_by_sha, **list, **last;
-       uint32_t array[256];
-       uint32_t i, index_version;
-       SHA_CTX ctx;
-
-       int fd = open_object_dir_tmp("tmp_idx_XXXXXX");
-       if (fd < 0)
-               die("unable to create %s: %s\n", tmpname, strerror(errno));
-       idx_tmp_name = xstrdup(tmpname);
-       f = sha1fd(fd, idx_tmp_name);
-
-       if (nr_result) {
-               uint32_t j = 0;
-               sorted_by_sha =
-                       xcalloc(nr_result, sizeof(struct object_entry *));
-               for (i = 0; i < nr_objects; i++)
-                       if (!objects[i].preferred_base)
-                               sorted_by_sha[j++] = objects + i;
-               if (j != nr_result)
-                       die("listed %u objects while expecting %u", j, nr_result);
-               qsort(sorted_by_sha, nr_result, sizeof(*sorted_by_sha), sha1_sort);
-               list = sorted_by_sha;
-               last = sorted_by_sha + nr_result;
-       } else
-               sorted_by_sha = list = last = NULL;
-
-       /* if last object's offset is >= 2^31 we should use index V2 */
-       index_version = (last_obj_offset >> 31) ? 2 : index_default_version;
+       do {
+               unsigned char sha1[20];
+
+               if (pack_to_stdout) {
+                       f = sha1fd(1, "<stdout>");
+               } else {
+                       int fd = open_object_dir_tmp("tmp_pack_XXXXXX");
+                       if (fd < 0)
+                               die("unable to create %s: %s\n", tmpname, strerror(errno));
+                       pack_tmp_name = xstrdup(tmpname);
+                       f = sha1fd(fd, pack_tmp_name);
+               }
 
-       /* index versions 2 and above need a header */
-       if (index_version >= 2) {
-               struct pack_idx_header hdr;
-               hdr.idx_signature = htonl(PACK_IDX_SIGNATURE);
-               hdr.idx_version = htonl(index_version);
+               hdr.hdr_signature = htonl(PACK_SIGNATURE);
+               hdr.hdr_version = htonl(PACK_VERSION);
+               hdr.hdr_entries = htonl(nr_remaining);
                sha1write(f, &hdr, sizeof(hdr));
-       }
-
-       /*
-        * Write the first-level table (the list is sorted,
-        * but we use a 256-entry lookup to be able to avoid
-        * having to do eight extra binary search iterations).
-        */
-       for (i = 0; i < 256; i++) {
-               struct object_entry **next = list;
-               while (next < last) {
-                       struct object_entry *entry = *next;
-                       if (entry->sha1[0] != i)
+               offset = sizeof(hdr);
+               nr_written = 0;
+               for (; i < nr_objects; i++) {
+                       last_obj_offset = offset;
+                       offset_one = write_one(f, objects + i, offset);
+                       if (!offset_one)
                                break;
-                       next++;
+                       offset = offset_one;
+                       if (do_progress)
+                               display_progress(&progress_state, written);
                }
-               array[i] = htonl(next - sorted_by_sha);
-               list = next;
-       }
-       sha1write(f, array, 256 * 4);
-
-       /* Compute the SHA1 hash of sorted object names. */
-       SHA1_Init(&ctx);
-
-       /* Write the actual SHA1 entries. */
-       list = sorted_by_sha;
-       for (i = 0; i < nr_result; i++) {
-               struct object_entry *entry = *list++;
-               if (index_version < 2) {
-                       uint32_t offset = htonl(entry->offset);
-                       sha1write(f, &offset, 4);
-               }
-               sha1write(f, entry->sha1, 20);
-               SHA1_Update(&ctx, entry->sha1, 20);
-       }
 
-       if (index_version >= 2) {
-               unsigned int nr_large_offset = 0;
-
-               /* write the crc32 table */
-               list = sorted_by_sha;
-               for (i = 0; i < nr_objects; i++) {
-                       struct object_entry *entry = *list++;
-                       uint32_t crc32_val = htonl(entry->crc32);
-                       sha1write(f, &crc32_val, 4);
+               /*
+                * Did we write the wrong # entries in the header?
+                * If so, rewrite it like in fast-import
+                */
+               if (pack_to_stdout || nr_written == nr_remaining) {
+                       sha1close(f, sha1, 1);
+               } else {
+                       sha1close(f, sha1, 0);
+                       fixup_pack_header_footer(f->fd, sha1, pack_tmp_name, nr_written);
+                       close(f->fd);
                }
 
-               /* write the 32-bit offset table */
-               list = sorted_by_sha;
-               for (i = 0; i < nr_objects; i++) {
-                       struct object_entry *entry = *list++;
-                       uint32_t offset = (entry->offset <= index_off32_limit) ?
-                               entry->offset : (0x80000000 | nr_large_offset++);
-                       offset = htonl(offset);
-                       sha1write(f, &offset, 4);
+               if (!pack_to_stdout) {
+                       mode_t mode = umask(0);
+
+                       umask(mode);
+                       mode = 0444 & ~mode;
+
+                       idx_tmp_name = write_idx_file(NULL,
+                               (struct pack_idx_entry **) written_list, nr_written, sha1);
+                       snprintf(tmpname, sizeof(tmpname), "%s-%s.pack",
+                                base_name, sha1_to_hex(sha1));
+                       if (adjust_perm(pack_tmp_name, mode))
+                               die("unable to make temporary pack file readable: %s",
+                                   strerror(errno));
+                       if (rename(pack_tmp_name, tmpname))
+                               die("unable to rename temporary pack file: %s",
+                                   strerror(errno));
+                       snprintf(tmpname, sizeof(tmpname), "%s-%s.idx",
+                                base_name, sha1_to_hex(sha1));
+                       if (adjust_perm(idx_tmp_name, mode))
+                               die("unable to make temporary index file readable: %s",
+                                   strerror(errno));
+                       if (rename(idx_tmp_name, tmpname))
+                               die("unable to rename temporary index file: %s",
+                                   strerror(errno));
+                       puts(sha1_to_hex(sha1));
                }
 
-               /* write the large offset table */
-               list = sorted_by_sha;
-               while (nr_large_offset) {
-                       struct object_entry *entry = *list++;
-                       uint64_t offset = entry->offset;
-                       if (offset > index_off32_limit) {
-                               uint32_t split[2];
-                               split[0]        = htonl(offset >> 32);
-                               split[1] = htonl(offset & 0xffffffff);
-                               sha1write(f, split, 8);
-                               nr_large_offset--;
-                       }
+               /* mark written objects as written to previous pack */
+               for (j = 0; j < nr_written; j++) {
+                       written_list[j]->idx.offset = (off_t)-1;
                }
-       }
+               nr_remaining -= nr_written;
+       } while (nr_remaining && i < nr_objects);
 
-       sha1write(f, pack_file_sha1, 20);
-       sha1close(f, NULL, 1);
-       free(sorted_by_sha);
-       SHA1_Final(sha1, &ctx);
+       free(written_list);
+       if (do_progress)
+               stop_progress(&progress_state);
+       if (written != nr_result)
+               die("wrote %u objects while expecting %u", written, nr_result);
+       /*
+        * We have scanned through [0 ... i).  Since we have written
+        * the correct number of objects,  the remaining [i ... nr_objects)
+        * items must be either already written (due to out-of-order delta base)
+        * or a preferred base.  Count those which are neither and complain if any.
+        */
+       for (j = 0; i < nr_objects; i++) {
+               struct object_entry *e = objects + i;
+               j += !e->idx.offset && !e->preferred_base;
+       }
+       if (j)
+               die("wrote %u objects as expected but %u unwritten", written, j);
 }
 
 static int locate_object_entry_hash(const unsigned char *sha1)
@@ -743,7 +704,7 @@ static int locate_object_entry_hash(const unsigned char *sha1)
        memcpy(&ui, sha1, sizeof(unsigned int));
        i = ui % object_ix_hashsz;
        while (0 < object_ix[i]) {
-               if (!hashcmp(sha1, objects[object_ix[i] - 1].sha1))
+               if (!hashcmp(sha1, objects[object_ix[i] - 1].idx.sha1))
                        return i;
                if (++i == object_ix_hashsz)
                        i = 0;
@@ -775,7 +736,7 @@ static void rehash_objects(void)
        object_ix = xrealloc(object_ix, sizeof(int) * object_ix_hashsz);
        memset(object_ix, 0, sizeof(int) * object_ix_hashsz);
        for (i = 0, oe = objects; i < nr_objects; i++, oe++) {
-               int ix = locate_object_entry_hash(oe->sha1);
+               int ix = locate_object_entry_hash(oe->idx.sha1);
                if (0 <= ix)
                        continue;
                ix = -1 - ix;
@@ -788,6 +749,9 @@ static unsigned name_hash(const char *name)
        unsigned char c;
        unsigned hash = 0;
 
+       if (!name)
+               return 0;
+
        /*
         * This effectively just creates a sortable number from the
         * last sixteen non-whitespace characters. Last characters
@@ -801,13 +765,36 @@ static unsigned name_hash(const char *name)
        return hash;
 }
 
+static void setup_delta_attr_check(struct git_attr_check *check)
+{
+       static struct git_attr *attr_delta;
+
+       if (!attr_delta)
+               attr_delta = git_attr("delta", 5);
+
+       check[0].attr = attr_delta;
+}
+
+static int no_try_delta(const char *path)
+{
+       struct git_attr_check check[1];
+
+       setup_delta_attr_check(check);
+       if (git_checkattr(path, ARRAY_SIZE(check), check))
+               return 0;
+       if (ATTR_FALSE(check->value))
+               return 1;
+       return 0;
+}
+
 static int add_object_entry(const unsigned char *sha1, enum object_type type,
-                           unsigned hash, int exclude)
+                           const char *name, int exclude)
 {
        struct object_entry *entry;
        struct packed_git *p, *found_pack = NULL;
        off_t found_offset = 0;
        int ix;
+       unsigned hash = name_hash(name);
 
        ix = nr_objects ? locate_object_entry_hash(sha1) : -1;
        if (ix >= 0) {
@@ -843,7 +830,7 @@ static int add_object_entry(const unsigned char *sha1, enum object_type type,
 
        entry = objects + nr_objects++;
        memset(entry, 0, sizeof(*entry));
-       hashcpy(entry->sha1, sha1);
+       hashcpy(entry->idx.sha1, sha1);
        entry->hash = hash;
        if (type)
                entry->type = type;
@@ -864,6 +851,9 @@ static int add_object_entry(const unsigned char *sha1, enum object_type type,
        if (progress)
                display_progress(&progress_state, nr_objects);
 
+       if (name && no_try_delta(name))
+               entry->no_try_delta = 1;
+
        return 1;
 }
 
@@ -996,10 +986,9 @@ static void add_pbase_object(struct tree_desc *tree,
                if (cmp < 0)
                        return;
                if (name[cmplen] != '/') {
-                       unsigned hash = name_hash(fullname);
                        add_object_entry(entry.sha1,
                                         S_ISDIR(entry.mode) ? OBJ_TREE : OBJ_BLOB,
-                                        hash, 1);
+                                        fullname, 1);
                        return;
                }
                if (S_ISDIR(entry.mode)) {
@@ -1059,10 +1048,11 @@ static int check_pbase_path(unsigned hash)
        return 0;
 }
 
-static void add_preferred_base_object(const char *name, unsigned hash)
+static void add_preferred_base_object(const char *name)
 {
        struct pbase_tree *it;
        int cmplen;
+       unsigned hash = name_hash(name);
 
        if (!num_preferred_base || check_pbase_path(hash))
                return;
@@ -1070,7 +1060,7 @@ static void add_preferred_base_object(const char *name, unsigned hash)
        cmplen = name_cmp_len(name);
        for (it = pbase_tree; it; it = it->next) {
                if (cmplen == 0) {
-                       add_object_entry(it->pcache.sha1, OBJ_TREE, 0, 1);
+                       add_object_entry(it->pcache.sha1, OBJ_TREE, NULL, 1);
                }
                else {
                        struct tree_desc tree;
@@ -1125,8 +1115,8 @@ static void check_object(struct object_entry *entry)
                buf = use_pack(p, &w_curs, entry->in_pack_offset, &avail);
 
                /*
-                * We want in_pack_type even if we do not reuse delta.
-                * There is no point not reusing non-delta representations.
+                * We want in_pack_type even if we do not reuse delta
+                * since non-delta representations could still be reused.
                 */
                used = unpack_object_header_gently(buf, avail,
                                                   &entry->in_pack_type,
@@ -1160,13 +1150,13 @@ static void check_object(struct object_entry *entry)
                                ofs += 1;
                                if (!ofs || MSB(ofs, 7))
                                        die("delta base offset overflow in pack for %s",
-                                           sha1_to_hex(entry->sha1));
+                                           sha1_to_hex(entry->idx.sha1));
                                c = buf[used_0++];
                                ofs = (ofs << 7) + (c & 127);
                        }
                        if (ofs >= entry->in_pack_offset)
                                die("delta base offset out of bound for %s",
-                                   sha1_to_hex(entry->sha1));
+                                   sha1_to_hex(entry->idx.sha1));
                        ofs = entry->in_pack_offset - ofs;
                        if (!no_reuse_delta && !entry->preferred_base)
                                base_ref = find_packed_object_name(p, ofs);
@@ -1213,10 +1203,10 @@ static void check_object(struct object_entry *entry)
                unuse_pack(&w_curs);
        }
 
-       entry->type = sha1_object_info(entry->sha1, &entry->size);
+       entry->type = sha1_object_info(entry->idx.sha1, &entry->size);
        if (entry->type < 0)
                die("unable to get type of object %s",
-                   sha1_to_hex(entry->sha1));
+                   sha1_to_hex(entry->idx.sha1));
 }
 
 static int pack_offset_sort(const void *_a, const void *_b)
@@ -1226,7 +1216,7 @@ static int pack_offset_sort(const void *_a, const void *_b)
 
        /* avoid filesystem trashing with loose objects */
        if (!a->in_pack && !b->in_pack)
-               return hashcmp(a->sha1, b->sha1);
+               return hashcmp(a->idx.sha1, b->idx.sha1);
 
        if (a->in_pack < b->in_pack)
                return -1;
@@ -1282,6 +1272,23 @@ struct unpacked {
        struct delta_index *index;
 };
 
+static int delta_cacheable(struct unpacked *trg, struct unpacked *src,
+                           unsigned long src_size, unsigned long trg_size,
+                           unsigned long delta_size)
+{
+       if (max_delta_cache_size && delta_cache_size + delta_size > max_delta_cache_size)
+               return 0;
+
+       if (delta_size < cache_max_small_delta_size)
+               return 1;
+
+       /* cache delta, if objects are large enough compared to delta size */
+       if ((src_size >> 20) + (trg_size >> 21) > (delta_size >> 10))
+               return 1;
+
+       return 0;
+}
+
 /*
  * We search for deltas _backwards_ in a list sorted by type and
  * by size, so that we see progressively smaller and smaller files.
@@ -1338,31 +1345,45 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
 
        /* Load data if not already done */
        if (!trg->data) {
-               trg->data = read_sha1_file(trg_entry->sha1, &type, &sz);
+               trg->data = read_sha1_file(trg_entry->idx.sha1, &type, &sz);
                if (sz != trg_size)
                        die("object %s inconsistent object length (%lu vs %lu)",
-                           sha1_to_hex(trg_entry->sha1), sz, trg_size);
+                           sha1_to_hex(trg_entry->idx.sha1), sz, trg_size);
        }
        if (!src->data) {
-               src->data = read_sha1_file(src_entry->sha1, &type, &sz);
+               src->data = read_sha1_file(src_entry->idx.sha1, &type, &sz);
                if (sz != src_size)
                        die("object %s inconsistent object length (%lu vs %lu)",
-                           sha1_to_hex(src_entry->sha1), sz, src_size);
+                           sha1_to_hex(src_entry->idx.sha1), sz, src_size);
        }
        if (!src->index) {
                src->index = create_delta_index(src->data, src_size);
-               if (!src->index)
-                       die("out of memory");
+               if (!src->index) {
+                       static int warned = 0;
+                       if (!warned++)
+                               warning("suboptimal pack - out of memory");
+                       return 0;
+               }
        }
 
        delta_buf = create_delta(src->index, trg->data, trg_size, &delta_size, max_size);
        if (!delta_buf)
                return 0;
 
+       if (trg_entry->delta_data) {
+               delta_cache_size -= trg_entry->delta_size;
+               free(trg_entry->delta_data);
+       }
+       trg_entry->delta_data = 0;
        trg_entry->delta = src_entry;
        trg_entry->delta_size = delta_size;
        trg_entry->depth = src_entry->depth + 1;
-       free(delta_buf);
+
+       if (delta_cacheable(src, trg, src_size, trg_size, delta_size)) {
+               trg_entry->delta_data = xrealloc(delta_buf, delta_size);
+               delta_cache_size += trg_entry->delta_size;
+       } else
+               free(delta_buf);
        return 1;
 }
 
@@ -1412,6 +1433,10 @@ static void find_deltas(struct object_entry **list, int window, int depth)
 
                if (entry->size < 50)
                        continue;
+
+               if (entry->no_try_delta)
+                       continue;
+
                free_delta_index(n->index);
                n->index = NULL;
                free(n->data);
@@ -1494,6 +1519,24 @@ static int git_pack_config(const char *k, const char *v)
                depth = git_config_int(k, v);
                return 0;
        }
+       if (!strcmp(k, "pack.compression")) {
+               int level = git_config_int(k, v);
+               if (level == -1)
+                       level = Z_DEFAULT_COMPRESSION;
+               else if (level < 0 || level > Z_BEST_COMPRESSION)
+                       die("bad pack compression level %d", level);
+               pack_compression_level = level;
+               pack_compression_seen = 1;
+               return 0;
+       }
+       if (!strcmp(k, "pack.deltacachesize")) {
+               max_delta_cache_size = git_config_int(k, v);
+               return 0;
+       }
+       if (!strcmp(k, "pack.deltacachelimit")) {
+               cache_max_small_delta_size = git_config_int(k, v);
+               return 0;
+       }
        return git_default_config(k, v);
 }
 
@@ -1501,7 +1544,6 @@ static void read_object_list_from_stdin(void)
 {
        char line[40 + 1 + PATH_MAX + 2];
        unsigned char sha1[20];
-       unsigned hash;
 
        for (;;) {
                if (!fgets(line, sizeof(line), stdin)) {
@@ -1524,22 +1566,20 @@ static void read_object_list_from_stdin(void)
                if (get_sha1_hex(line, sha1))
                        die("expected sha1, got garbage:\n %s", line);
 
-               hash = name_hash(line+41);
-               add_preferred_base_object(line+41, hash);
-               add_object_entry(sha1, 0, hash, 0);
+               add_preferred_base_object(line+41);
+               add_object_entry(sha1, 0, line+41, 0);
        }
 }
 
 static void show_commit(struct commit *commit)
 {
-       add_object_entry(commit->object.sha1, OBJ_COMMIT, 0, 0);
+       add_object_entry(commit->object.sha1, OBJ_COMMIT, NULL, 0);
 }
 
 static void show_object(struct object_array_entry *p)
 {
-       unsigned hash = name_hash(p->name);
-       add_preferred_base_object(p->name, hash);
-       add_object_entry(p->item->sha1, p->item->type, hash, 0);
+       add_preferred_base_object(p->name);
+       add_object_entry(p->item->sha1, p->item->type, p->name, 0);
 }
 
 static void show_edge(struct commit *commit)
@@ -1592,8 +1632,6 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
        int use_internal_rev_list = 0;
        int thin = 0;
        uint32_t i;
-       off_t last_obj_offset;
-       const char *base_name = NULL;
        const char **rp_av;
        int rp_ac_alloc = 64;
        int rp_ac;
@@ -1605,6 +1643,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
        rp_ac = 2;
 
        git_config(git_pack_config);
+       if (!pack_compression_seen && core_compression_seen)
+               pack_compression_level = core_compression_level;
 
        progress = isatty(2);
        for (i = 1; i < argc; i++) {
@@ -1625,6 +1665,25 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                        incremental = 1;
                        continue;
                }
+               if (!prefixcmp(arg, "--compression=")) {
+                       char *end;
+                       int level = strtoul(arg+14, &end, 0);
+                       if (!arg[14] || *end)
+                               usage(pack_usage);
+                       if (level == -1)
+                               level = Z_DEFAULT_COMPRESSION;
+                       else if (level < 0 || level > Z_BEST_COMPRESSION)
+                               die("bad pack compression level %d", level);
+                       pack_compression_level = level;
+                       continue;
+               }
+               if (!prefixcmp(arg, "--max-pack-size=")) {
+                       char *end;
+                       pack_size_limit = strtoul(arg+16, &end, 0) * 1024 * 1024;
+                       if (!arg[16] || *end)
+                               usage(pack_usage);
+                       continue;
+               }
                if (!prefixcmp(arg, "--window=")) {
                        char *end;
                        window = strtoul(arg+9, &end, 0);
@@ -1655,6 +1714,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                        no_reuse_delta = 1;
                        continue;
                }
+               if (!strcmp("--no-reuse-object", arg)) {
+                       no_reuse_object = no_reuse_delta = 1;
+                       continue;
+               }
                if (!strcmp("--delta-base-offset", arg)) {
                        allow_ofs_delta = 1;
                        continue;
@@ -1688,12 +1751,12 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                }
                if (!prefixcmp(arg, "--index-version=")) {
                        char *c;
-                       index_default_version = strtoul(arg + 16, &c, 10);
-                       if (index_default_version > 2)
+                       pack_idx_default_version = strtoul(arg + 16, &c, 10);
+                       if (pack_idx_default_version > 2)
                                die("bad %s", arg);
                        if (*c == ',')
-                               index_off32_limit = strtoul(c+1, &c, 0);
-                       if (*c || index_off32_limit & 0x80000000)
+                               pack_idx_off32_limit = strtoul(c+1, &c, 0);
+                       if (*c || pack_idx_off32_limit & 0x80000000)
                                die("bad %s", arg);
                        continue;
                }
@@ -1719,6 +1782,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
        if (pack_to_stdout != !base_name)
                usage(pack_usage);
 
+       if (pack_to_stdout && pack_size_limit)
+               die("--max-pack-size cannot be used to build a pack for transfer.");
+
        if (!pack_to_stdout && thin)
                die("--thin cannot be used to build an indexable pack.");
 
@@ -1744,33 +1810,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                fprintf(stderr, "Result has %u objects.\n", nr_result);
        if (nr_result)
                prepare_pack(window, depth);
-       last_obj_offset = write_pack_file();
-       if (!pack_to_stdout) {
-               unsigned char object_list_sha1[20];
-               mode_t mode = umask(0);
-
-               umask(mode);
-               mode = 0444 & ~mode;
-
-               write_index_file(last_obj_offset, object_list_sha1);
-               snprintf(tmpname, sizeof(tmpname), "%s-%s.pack",
-                        base_name, sha1_to_hex(object_list_sha1));
-               if (adjust_perm(pack_tmp_name, mode))
-                       die("unable to make temporary pack file readable: %s",
-                           strerror(errno));
-               if (rename(pack_tmp_name, tmpname))
-                       die("unable to rename temporary pack file: %s",
-                           strerror(errno));
-               snprintf(tmpname, sizeof(tmpname), "%s-%s.idx",
-                        base_name, sha1_to_hex(object_list_sha1));
-               if (adjust_perm(idx_tmp_name, mode))
-                       die("unable to make temporary index file readable: %s",
-                           strerror(errno));
-               if (rename(idx_tmp_name, tmpname))
-                       die("unable to rename temporary index file: %s",
-                           strerror(errno));
-               puts(sha1_to_hex(object_list_sha1));
-       }
+       write_pack_file();
        if (progress)
                fprintf(stderr, "Total %u (delta %u), reused %u (delta %u)\n",
                        written, written_delta, reused, reused_delta);
index d080e30d67a913529d46e0da169faa4b0be75580..1952950c9a4bf13dc728bb8d6a79493dad36df06 100644 (file)
@@ -12,9 +12,11 @@ struct ref_to_prune {
        char name[FLEX_ARRAY];
 };
 
+#define PACK_REFS_PRUNE        0x0001
+#define PACK_REFS_ALL  0x0002
+
 struct pack_refs_cb_data {
-       int prune;
-       int all;
+       unsigned int flags;
        struct ref_to_prune *ref_to_prune;
        FILE *refs_file;
 };
@@ -39,7 +41,7 @@ static int handle_one_ref(const char *path, const unsigned char *sha1,
        is_tag_ref = !prefixcmp(path, "refs/tags/");
 
        /* ALWAYS pack refs that were already packed or are tags */
-       if (!cb->all && !is_tag_ref && !(flags & REF_ISPACKED))
+       if (!(cb->flags & PACK_REFS_ALL) && !is_tag_ref && !(flags & REF_ISPACKED))
                return 0;
 
        fprintf(cb->refs_file, "%s %s\n", sha1_to_hex(sha1), path);
@@ -53,7 +55,7 @@ static int handle_one_ref(const char *path, const unsigned char *sha1,
                }
        }
 
-       if (cb->prune && !do_not_prune(flags)) {
+       if ((cb->flags & PACK_REFS_PRUNE) && !do_not_prune(flags)) {
                int namelen = strlen(path) + 1;
                struct ref_to_prune *n = xcalloc(1, sizeof(*n) + namelen);
                hashcpy(n->sha1, sha1);
@@ -85,26 +87,51 @@ static void prune_refs(struct ref_to_prune *r)
 
 static struct lock_file packed;
 
-int cmd_pack_refs(int argc, const char **argv, const char *prefix)
+static int pack_refs(unsigned int flags)
 {
-       int fd, i;
+       int fd;
        struct pack_refs_cb_data cbdata;
 
        memset(&cbdata, 0, sizeof(cbdata));
+       cbdata.flags = flags;
+
+       fd = hold_lock_file_for_update(&packed, git_path("packed-refs"), 1);
+       cbdata.refs_file = fdopen(fd, "w");
+       if (!cbdata.refs_file)
+               die("unable to create ref-pack file structure (%s)",
+                   strerror(errno));
+
+       /* perhaps other traits later as well */
+       fprintf(cbdata.refs_file, "# pack-refs with: peeled \n");
+
+       for_each_ref(handle_one_ref, &cbdata);
+       if (fflush(cbdata.refs_file) || fsync(fd) || fclose(cbdata.refs_file))
+               die("failed to write ref-pack file (%s)", strerror(errno));
+       if (commit_lock_file(&packed) < 0)
+               die("unable to overwrite old ref-pack file (%s)", strerror(errno));
+       if (cbdata.flags & PACK_REFS_PRUNE)
+               prune_refs(cbdata.ref_to_prune);
+       return 0;
+}
 
-       cbdata.prune = 1;
+int cmd_pack_refs(int argc, const char **argv, const char *prefix)
+{
+       int i;
+       unsigned int flags;
+
+       flags = PACK_REFS_PRUNE;
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
                if (!strcmp(arg, "--prune")) {
-                       cbdata.prune = 1; /* now the default */
+                       flags |= PACK_REFS_PRUNE; /* now the default */
                        continue;
                }
                if (!strcmp(arg, "--no-prune")) {
-                       cbdata.prune = 0;
+                       flags &= ~PACK_REFS_PRUNE;
                        continue;
                }
                if (!strcmp(arg, "--all")) {
-                       cbdata.all = 1;
+                       flags |= PACK_REFS_ALL;
                        continue;
                }
                /* perhaps other parameters later... */
@@ -113,22 +140,5 @@ int cmd_pack_refs(int argc, const char **argv, const char *prefix)
        if (i != argc)
                usage(builtin_pack_refs_usage);
 
-       fd = hold_lock_file_for_update(&packed, git_path("packed-refs"), 1);
-       cbdata.refs_file = fdopen(fd, "w");
-       if (!cbdata.refs_file)
-               die("unable to create ref-pack file structure (%s)",
-                   strerror(errno));
-
-       /* perhaps other traits later as well */
-       fprintf(cbdata.refs_file, "# pack-refs with: peeled \n");
-
-       for_each_ref(handle_one_ref, &cbdata);
-       fflush(cbdata.refs_file);
-       fsync(fd);
-       fclose(cbdata.refs_file);
-       if (commit_lock_file(&packed) < 0)
-               die("unable to overwrite old ref-pack file (%s)", strerror(errno));
-       if (cbdata.prune)
-               prune_refs(cbdata.ref_to_prune);
-       return 0;
+       return pack_refs(flags);
 }
index cb78401c946eac9019c2e4e953c3b87ef9e214f3..2612f07f74855ad6dec8ccd605279ab3a502e5e2 100644 (file)
@@ -5,17 +5,13 @@
 #include "refs.h"
 #include "run-command.h"
 #include "builtin.h"
-
-#define MAX_URI (16)
+#include "remote.h"
 
 static const char push_usage[] = "git-push [--all] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]";
 
-static int all, tags, force, thin = 1, verbose;
+static int all, force, thin = 1, verbose;
 static const char *receivepack;
 
-#define BUF_SIZE (2084)
-static char buffer[BUF_SIZE];
-
 static const char **refspec;
 static int refspec_nr;
 
@@ -27,285 +23,47 @@ static void add_refspec(const char *ref)
        refspec_nr = nr;
 }
 
-static int expand_one_ref(const char *ref, const unsigned char *sha1, int flag, void *cb_data)
-{
-       /* Ignore the "refs/" at the beginning of the refname */
-       ref += 5;
-
-       if (!prefixcmp(ref, "tags/"))
-               add_refspec(xstrdup(ref));
-       return 0;
-}
-
-static void expand_refspecs(void)
-{
-       if (all) {
-               if (refspec_nr)
-                       die("cannot mix '--all' and a refspec");
-
-               /*
-                * No need to expand "--all" - we'll just use
-                * the "--all" flag to send-pack
-                */
-               return;
-       }
-       if (!tags)
-               return;
-       for_each_ref(expand_one_ref, NULL);
-}
-
-struct wildcard_cb {
-       const char *from_prefix;
-       int from_prefix_len;
-       const char *to_prefix;
-       int to_prefix_len;
-       int force;
-};
-
-static int expand_wildcard_ref(const char *ref, const unsigned char *sha1, int flag, void *cb_data)
-{
-       struct wildcard_cb *cb = cb_data;
-       int len = strlen(ref);
-       char *expanded, *newref;
-
-       if (len < cb->from_prefix_len ||
-           memcmp(cb->from_prefix, ref, cb->from_prefix_len))
-               return 0;
-       expanded = xmalloc(len * 2 + cb->force +
-                          (cb->to_prefix_len - cb->from_prefix_len) + 2);
-       newref = expanded + cb->force;
-       if (cb->force)
-               expanded[0] = '+';
-       memcpy(newref, ref, len);
-       newref[len] = ':';
-       memcpy(newref + len + 1, cb->to_prefix, cb->to_prefix_len);
-       strcpy(newref + len + 1 + cb->to_prefix_len,
-              ref + cb->from_prefix_len);
-       add_refspec(expanded);
-       return 0;
-}
-
-static int wildcard_ref(const char *ref)
-{
-       int len;
-       const char *colon;
-       struct wildcard_cb cb;
-
-       memset(&cb, 0, sizeof(cb));
-       if (ref[0] == '+') {
-               cb.force = 1;
-               ref++;
-       }
-       len = strlen(ref);
-       colon = strchr(ref, ':');
-       if (! (colon && ref < colon &&
-              colon[-2] == '/' && colon[-1] == '*' &&
-              /* "<mine>/<asterisk>:<yours>/<asterisk>" is at least 7 bytes */
-              7 <= len &&
-              ref[len-2] == '/' && ref[len-1] == '*') )
-               return 0 ;
-       cb.from_prefix = ref;
-       cb.from_prefix_len = colon - ref - 1;
-       cb.to_prefix = colon + 1;
-       cb.to_prefix_len = len - (colon - ref) - 2;
-       for_each_ref(expand_wildcard_ref, &cb);
-       return 1;
-}
-
 static void set_refspecs(const char **refs, int nr)
 {
-       if (nr) {
-               int i;
-               for (i = 0; i < nr; i++) {
-                       const char *ref = refs[i];
-                       if (!strcmp("tag", ref)) {
-                               char *tag;
-                               int len;
-                               if (nr <= ++i)
-                                       die("tag shorthand without <tag>");
-                               len = strlen(refs[i]) + 11;
-                               tag = xmalloc(len);
-                               strcpy(tag, "refs/tags/");
-                               strcat(tag, refs[i]);
-                               ref = tag;
-                       }
-                       else if (wildcard_ref(ref))
-                               continue;
-                       add_refspec(ref);
-               }
-       }
-       expand_refspecs();
-}
-
-static int get_remotes_uri(const char *repo, const char *uri[MAX_URI])
-{
-       int n = 0;
-       FILE *f = fopen(git_path("remotes/%s", repo), "r");
-       int has_explicit_refspec = refspec_nr || all || tags;
-
-       if (!f)
-               return -1;
-       while (fgets(buffer, BUF_SIZE, f)) {
-               int is_refspec;
-               char *s, *p;
-
-               if (!prefixcmp(buffer, "URL:")) {
-                       is_refspec = 0;
-                       s = buffer + 4;
-               } else if (!prefixcmp(buffer, "Push:")) {
-                       is_refspec = 1;
-                       s = buffer + 5;
-               } else
-                       continue;
-
-               /* Remove whitespace at the head.. */
-               while (isspace(*s))
-                       s++;
-               if (!*s)
-                       continue;
-
-               /* ..and at the end */
-               p = s + strlen(s);
-               while (isspace(p[-1]))
-                       *--p = 0;
-
-               if (!is_refspec) {
-                       if (n < MAX_URI)
-                               uri[n++] = xstrdup(s);
-                       else
-                               error("more than %d URL's specified, ignoring the rest", MAX_URI);
-               }
-               else if (is_refspec && !has_explicit_refspec) {
-                       if (!wildcard_ref(s))
-                               add_refspec(xstrdup(s));
-               }
-       }
-       fclose(f);
-       if (!n)
-               die("remote '%s' has no URL", repo);
-       return n;
-}
-
-static const char **config_uri;
-static const char *config_repo;
-static int config_repo_len;
-static int config_current_uri;
-static int config_get_refspecs;
-static int config_get_receivepack;
-
-static int get_remote_config(const char* key, const char* value)
-{
-       if (!prefixcmp(key, "remote.") &&
-           !strncmp(key + 7, config_repo, config_repo_len)) {
-               if (!strcmp(key + 7 + config_repo_len, ".url")) {
-                       if (config_current_uri < MAX_URI)
-                               config_uri[config_current_uri++] = xstrdup(value);
-                       else
-                               error("more than %d URL's specified, ignoring the rest", MAX_URI);
-               }
-               else if (config_get_refspecs &&
-                        !strcmp(key + 7 + config_repo_len, ".push")) {
-                       if (!wildcard_ref(value))
-                               add_refspec(xstrdup(value));
-               }
-               else if (config_get_receivepack &&
-                        !strcmp(key + 7 + config_repo_len, ".receivepack")) {
-                       if (!receivepack) {
-                               char *rp = xmalloc(strlen(value) + 16);
-                               sprintf(rp, "--receive-pack=%s", value);
-                               receivepack = rp;
-                       } else
-                               error("more than one receivepack given, using the first");
-               }
-       }
-       return 0;
-}
-
-static int get_config_remotes_uri(const char *repo, const char *uri[MAX_URI])
-{
-       config_repo_len = strlen(repo);
-       config_repo = repo;
-       config_current_uri = 0;
-       config_uri = uri;
-       config_get_refspecs = !(refspec_nr || all || tags);
-       config_get_receivepack = (receivepack == NULL);
-
-       git_config(get_remote_config);
-       return config_current_uri;
-}
-
-static int get_branches_uri(const char *repo, const char *uri[MAX_URI])
-{
-       const char *slash = strchr(repo, '/');
-       int n = slash ? slash - repo : 1000;
-       FILE *f = fopen(git_path("branches/%.*s", n, repo), "r");
-       char *s, *p;
-       int len;
-
-       if (!f)
-               return 0;
-       s = fgets(buffer, BUF_SIZE, f);
-       fclose(f);
-       if (!s)
-               return 0;
-       while (isspace(*s))
-               s++;
-       if (!*s)
-               return 0;
-       p = s + strlen(s);
-       while (isspace(p[-1]))
-               *--p = 0;
-       len = p - s;
-       if (slash)
-               len += strlen(slash);
-       p = xmalloc(len + 1);
-       strcpy(p, s);
-       if (slash)
-               strcat(p, slash);
-       uri[0] = p;
-       return 1;
-}
-
-/*
- * Read remotes and branches file, fill the push target URI
- * list.  If there is no command line refspecs, read Push: lines
- * to set up the *refspec list as well.
- * return the number of push target URIs
- */
-static int read_config(const char *repo, const char *uri[MAX_URI])
-{
-       int n;
-
-       if (*repo != '/') {
-               n = get_remotes_uri(repo, uri);
-               if (n > 0)
-                       return n;
-
-               n = get_config_remotes_uri(repo, uri);
-               if (n > 0)
-                       return n;
-
-               n = get_branches_uri(repo, uri);
-               if (n > 0)
-                       return n;
+       int i;
+       for (i = 0; i < nr; i++) {
+               const char *ref = refs[i];
+               if (!strcmp("tag", ref)) {
+                       char *tag;
+                       int len;
+                       if (nr <= ++i)
+                               die("tag shorthand without <tag>");
+                       len = strlen(refs[i]) + 11;
+                       tag = xmalloc(len);
+                       strcpy(tag, "refs/tags/");
+                       strcat(tag, refs[i]);
+                       ref = tag;
+               }
+               add_refspec(ref);
        }
-
-       uri[0] = repo;
-       return 1;
 }
 
 static int do_push(const char *repo)
 {
-       const char *uri[MAX_URI];
-       int i, n, errs;
+       int i, errs;
        int common_argc;
        const char **argv;
        int argc;
+       struct remote *remote = remote_get(repo);
 
-       n = read_config(repo, uri);
-       if (n <= 0)
+       if (!remote)
                die("bad repository '%s'", repo);
 
+       if (remote->receivepack) {
+               char *rp = xmalloc(strlen(remote->receivepack) + 16);
+               sprintf(rp, "--receive-pack=%s", remote->receivepack);
+               receivepack = rp;
+       }
+       if (!refspec && !all && remote->push_refspec_nr) {
+               refspec = remote->push_refspec;
+               refspec_nr = remote->push_refspec_nr;
+       }
+
        argv = xmalloc((refspec_nr + 10) * sizeof(char *));
        argv[0] = "dummy-send-pack";
        argc = 1;
@@ -318,18 +76,23 @@ static int do_push(const char *repo)
        common_argc = argc;
 
        errs = 0;
-       for (i = 0; i < n; i++) {
+       for (i = 0; i < remote->uri_nr; i++) {
                int err;
                int dest_argc = common_argc;
                int dest_refspec_nr = refspec_nr;
                const char **dest_refspec = refspec;
-               const char *dest = uri[i];
+               const char *dest = remote->uri[i];
                const char *sender = "send-pack";
                if (!prefixcmp(dest, "http://") ||
                    !prefixcmp(dest, "https://"))
                        sender = "http-push";
-               else if (thin)
-                       argv[dest_argc++] = "--thin";
+               else {
+                       char *rem = xmalloc(strlen(remote->name) + 10);
+                       sprintf(rem, "--remote=%s", remote->name);
+                       argv[dest_argc++] = rem;
+                       if (thin)
+                               argv[dest_argc++] = "--thin";
+               }
                argv[0] = sender;
                argv[dest_argc++] = dest;
                while (dest_refspec_nr--)
@@ -341,7 +104,7 @@ static int do_push(const char *repo)
                if (!err)
                        continue;
 
-               error("failed to push to '%s'", uri[i]);
+               error("failed to push to '%s'", remote->uri[i]);
                switch (err) {
                case -ERR_RUN_COMMAND_FORK:
                        error("unable to fork for %s", sender);
@@ -362,7 +125,7 @@ static int do_push(const char *repo)
 int cmd_push(int argc, const char **argv, const char *prefix)
 {
        int i;
-       const char *repo = "origin";    /* default repository */
+       const char *repo = NULL;        /* default repository */
 
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
@@ -385,7 +148,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
                        continue;
                }
                if (!strcmp(arg, "--tags")) {
-                       tags = 1;
+                       add_refspec("refs/tags/*");
                        continue;
                }
                if (!strcmp(arg, "--force") || !strcmp(arg, "-f")) {
@@ -411,5 +174,8 @@ int cmd_push(int argc, const char **argv, const char *prefix)
                usage(push_usage);
        }
        set_refspecs(argv + i, argc - i);
+       if (all && refspec)
+               usage(push_usage);
+
        return do_push(repo);
 }
index 4c39f1da98e5e690f28f5145a1ab5dba790da68d..ce093cad78ce8008cd8a60d3ab6be5663a712a9d 100644 (file)
@@ -249,7 +249,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
        /* we take the lock for the ref itself to prevent it from
         * getting updated.
         */
-       lock = lock_any_ref_for_update(ref, sha1);
+       lock = lock_any_ref_for_update(ref, sha1, 0);
        if (!lock)
                return error("cannot lock ref '%s'", ref);
        log_file = xstrdup(git_path("logs/%s", ref));
index 8c2c8bdc18a69e4dff7386548e5f7ea78a133f7b..f6409b93c19aff7f8d820e52e39f45d717e31996 100644 (file)
@@ -434,4 +434,3 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
        path_list_clear(&merge_rr, 1);
        return 0;
 }
-
index ea2f15b977a8b62189755ae89e3ee704b45afae8..8f02ed7bd1b7d4aecb8611ac1c0ebf3978b34ca5 100644 (file)
@@ -45,8 +45,10 @@ static void parse_options(int argc, const char **argv)
        if (argc < 2)
                usage(usage_str);
 
-       for (i = 1; i < argc - 1; i++) {
+       for (i = 1; i < argc; i++) {
                arg = argv[i];
+               if (arg[0] != '-')
+                       break;
                if (!strcmp(arg, "-n") || !strcmp(arg, "--no-commit"))
                        no_commit = 1;
                else if (!strcmp(arg, "-e") || !strcmp(arg, "--edit"))
@@ -59,7 +61,8 @@ static void parse_options(int argc, const char **argv)
                else if (strcmp(arg, "-r"))
                        usage(usage_str);
        }
-
+       if (i != argc - 1)
+               usage(usage_str);
        arg = argv[argc - 1];
        if (get_sha1(arg, sha1))
                die ("Cannot find '%s'", arg);
@@ -104,7 +107,7 @@ static char *get_oneline(const char *message)
        return result;
 }
 
-char *get_encoding(const char *message)
+static char *get_encoding(const char *message)
 {
        const char *p = message, *eol;
 
index 8d3f742d432c966e5afe03e8d0628eb92a73920c..16af6199ab2bc8a663d16f78a5d461a5bee05bc7 100644 (file)
@@ -331,4 +331,3 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
 
        return 0;
 }
-
index f0d4d9e2d10446a229094c991363f5a17ce4c666..62bd4b547b8c7efaa982cef61edf365466089eb6 100644 (file)
@@ -26,7 +26,7 @@ static int cleanup(char *line)
        return 1;
 }
 
-void stripspace(FILE *in, FILE *out)
+static void stripspace(FILE *in, FILE *out)
 {
        int empties = -1;
        int incomplete = 0;
index 8f9899178b1755ee0acd4a34ee185a4f54fb4219..509369e9e7b1719e53ba2dd2d976066fb9513353 100644 (file)
@@ -134,7 +134,7 @@ static int process_directory(const char *path, int len, struct stat *st)
        /* Exact match: file or existing gitlink */
        if (pos >= 0) {
                struct cache_entry *ce = active_cache[pos];
-               if (S_ISDIRLNK(ntohl(ce->ce_mode))) {
+               if (S_ISGITLINK(ntohl(ce->ce_mode))) {
 
                        /* Do nothing to the index if there is no HEAD! */
                        if (resolve_gitlink_ref(path, "HEAD", sha1) < 0)
@@ -178,7 +178,7 @@ static int process_file(const char *path, int len, struct stat *st)
        int pos = cache_name_pos(path, len);
        struct cache_entry *ce = pos < 0 ? NULL : active_cache[pos];
 
-       if (ce && S_ISDIRLNK(ntohl(ce->ce_mode)))
+       if (ce && S_ISGITLINK(ntohl(ce->ce_mode)))
                return error("%s is already a gitlink, not replacing", path);
 
        return add_one_path(ce, path, len, st);
index 5ee960bf41c4518b6c5530acb123a7ed668538fc..feac2ed12d22dcd23db5823cd32a0f9f1c1c974a 100644 (file)
@@ -3,16 +3,17 @@
 #include "builtin.h"
 
 static const char git_update_ref_usage[] =
-"git-update-ref [-m <reason>] (-d <refname> <value> | <refname> <value> [<oldval>])";
+"git-update-ref [-m <reason>] (-d <refname> <value> | [--no-deref] <refname> <value> [<oldval>])";
 
 int cmd_update_ref(int argc, const char **argv, const char *prefix)
 {
        const char *refname=NULL, *value=NULL, *oldval=NULL, *msg=NULL;
        struct ref_lock *lock;
        unsigned char sha1[20], oldsha1[20];
-       int i, delete;
+       int i, delete, ref_flags;
 
        delete = 0;
+       ref_flags = 0;
        git_config(git_default_config);
 
        for (i = 1; i < argc; i++) {
@@ -30,6 +31,10 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
                        delete = 1;
                        continue;
                }
+               if (!strcmp("--no-deref", argv[i])) {
+                       ref_flags |= REF_NODEREF;
+                       continue;
+               }
                if (!refname) {
                        refname = argv[i];
                        continue;
@@ -59,7 +64,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
        if (oldval && *oldval && get_sha1(oldval, oldsha1))
                die("%s: not a valid old SHA1", oldval);
 
-       lock = lock_any_ref_for_update(refname, oldval ? oldsha1 : NULL);
+       lock = lock_any_ref_for_update(refname, oldval ? oldsha1 : NULL, ref_flags);
        if (!lock)
                die("%s: cannot lock the ref", refname);
        if (write_ref_sha1(lock, sha1, msg) < 0)
index d3f3a7496e1c1adbe3f8bae36603fafee374c8c5..da4834c312445ae2b987000eba9891b7c3b265b5 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -7,9 +7,6 @@ extern const char git_version_string[];
 extern const char git_usage_string[];
 
 extern void help_unknown_cmd(const char *cmd);
-extern int mailinfo(FILE *in, FILE *out, int ks, const char *encoding, const char *msg, const char *patch);
-extern int split_mbox(const char **mbox, const char *dir, int allow_bare, int nr_prec, int skip);
-extern void stripspace(FILE *in, FILE *out);
 extern int write_tree(unsigned char *sha1, int missing_ok, const char *prefix);
 extern void prune_packed_objects(int);
 
index 6369cc7c536ba7b82a6afcb191628beefe889b72..350a79b768e7c032e1b4815f7201c9ce5f88bc8d 100644 (file)
@@ -326,7 +326,7 @@ static int update_one(struct cache_tree *it,
                        mode = ntohl(ce->ce_mode);
                        entlen = pathlen - baselen;
                }
-               if (mode != S_IFDIRLNK && !missing_ok && !has_sha1_file(sha1))
+               if (mode != S_IFGITLINK && !missing_ok && !has_sha1_file(sha1))
                        return error("invalid object %s", sha1_to_hex(sha1));
 
                if (!ce->ce_mode)
diff --git a/cache.h b/cache.h
index 5dff2f1d73eb1a41f664d959d18e6f2c0e102e64..5e7381eb1ea5f5fa8f4e70b15bc50f45ca616d39 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -40,8 +40,8 @@
  * happens that everybody shares the same bit representation
  * in the UNIX world (and apparently wider too..)
  */
-#define S_IFDIRLNK     0160000
-#define S_ISDIRLNK(m)  (((m) & S_IFMT) == S_IFDIRLNK)
+#define S_IFGITLINK    0160000
+#define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK)
 
 /*
  * Intensive research over the course of many years has shown that
@@ -123,8 +123,8 @@ static inline unsigned int create_ce_mode(unsigned int mode)
 {
        if (S_ISLNK(mode))
                return htonl(S_IFLNK);
-       if (S_ISDIR(mode) || S_ISDIRLNK(mode))
-               return htonl(S_IFDIRLNK);
+       if (S_ISDIR(mode) || S_ISGITLINK(mode))
+               return htonl(S_IFGITLINK);
        return htonl(S_IFREG | ce_permissions(mode));
 }
 static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned int mode)
@@ -142,7 +142,7 @@ static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned in
 }
 #define canon_mode(mode) \
        (S_ISREG(mode) ? (S_IFREG | ce_permissions(mode)) : \
-       S_ISLNK(mode) ? S_IFLNK : S_ISDIR(mode) ? S_IFDIR : S_IFDIRLNK)
+       S_ISLNK(mode) ? S_IFLNK : S_ISDIR(mode) ? S_IFDIR : S_IFGITLINK)
 
 #define cache_entry_size(len) ((offsetof(struct cache_entry,name) + (len) + 8) & ~7)
 
@@ -273,7 +273,6 @@ extern void rollback_lock_file(struct lock_file *);
 extern int delete_ref(const char *, const unsigned char *sha1);
 
 /* Environment bits from configuration mechanism */
-extern int use_legacy_headers;
 extern int trust_executable_bit;
 extern int has_symlinks;
 extern int assume_unchanged;
@@ -283,6 +282,8 @@ extern int warn_ambiguous_refs;
 extern int shared_repository;
 extern const char *apply_default_whitespace;
 extern int zlib_compression_level;
+extern int core_compression_level;
+extern int core_compression_seen;
 extern size_t packed_git_window_size;
 extern size_t packed_git_limit;
 extern size_t delta_base_cache_limit;
@@ -354,7 +355,6 @@ extern int move_temp_to_file(const char *tmpfile, const char *filename);
 extern int has_sha1_pack(const unsigned char *sha1, const char **ignore);
 extern int has_sha1_file(const unsigned char *sha1);
 extern void *map_sha1_file(const unsigned char *sha1, unsigned long *);
-extern int legacy_loose_object(unsigned char *);
 
 extern int has_pack_file(const unsigned char *sha1);
 extern int has_pack_index(const unsigned char *sha1);
@@ -463,11 +463,10 @@ struct ref {
 #define REF_HEADS      (1u << 1)
 #define REF_TAGS       (1u << 2)
 
-extern pid_t git_connect(int fd[2], char *url, const char *prog);
+#define CONNECT_VERBOSE       (1u << 0)
+extern pid_t git_connect(int fd[2], char *url, const char *prog, int flags);
 extern int finish_connect(pid_t pid);
 extern int path_match(const char *path, int nr, char **match);
-extern int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
-                     int nr_refspec, char **refspec, int all);
 extern int get_ack(int fd, unsigned char *result_sha1);
 extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match, unsigned int flags);
 extern int server_supports(const char *feature);
@@ -480,14 +479,15 @@ extern void prepare_packed_git(void);
 extern void reprepare_packed_git(void);
 extern void install_packed_git(struct packed_git *pack);
 
-extern struct packed_git *find_sha1_pack(const unsigned char *sha1, 
+extern struct packed_git *find_sha1_pack(const unsigned char *sha1,
                                         struct packed_git *packs);
 
 extern void pack_report(void);
+extern int open_pack_index(struct packed_git *);
 extern unsigned char* use_pack(struct packed_git *, struct pack_window **, off_t, unsigned int *);
 extern void unuse_pack(struct pack_window **);
 extern struct packed_git *add_packed_git(const char *, int, int);
-extern const unsigned char *nth_packed_object_sha1(const struct packed_git *, uint32_t);
+extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t);
 extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);
 extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
 extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
index 5632e32685478dcce34e479e8e916b0ccd3a3b13..4ca4d44ba0d648c6c102ac17160b69f6f0f02836 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -148,7 +148,7 @@ static int commit_graft_pos(const unsigned char *sha1)
 int register_commit_graft(struct commit_graft *graft, int ignore_dups)
 {
        int pos = commit_graft_pos(graft->sha1);
-       
+
        if (0 <= pos) {
                if (ignore_dups)
                        free(graft);
@@ -406,7 +406,7 @@ struct commit_list * insert_by_date(struct commit *item, struct commit_list **li
        return commit_list_insert(item, pp);
 }
 
-       
+
 void sort_by_date(struct commit_list **list)
 {
        struct commit_list *ret = NULL;
@@ -1116,15 +1116,6 @@ struct commit *pop_commit(struct commit_list **stack)
        return item;
 }
 
-int count_parents(struct commit * commit)
-{
-        int count;
-        struct commit_list * parents = commit->parents;
-        for (count = 0; parents; parents = parents->next,count++)
-               ;
-        return count;
-}
-
 void topo_sort_default_setter(struct commit *c, void *data)
 {
        c->util = data;
@@ -1160,7 +1151,7 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo,
                next = next->next;
                count++;
        }
-       
+
        if (!count)
                return;
        /* allocate an array to help sort the list */
@@ -1188,11 +1179,11 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo,
                }
                next=next->next;
        }
-       /* 
+       /*
          * find the tips
          *
-         * tips are nodes not reachable from any other node in the list 
-         * 
+         * tips are nodes not reachable from any other node in the list
+         *
          * the tips serve as a starting set for the work queue.
          */
        next=*list;
@@ -1220,7 +1211,7 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo,
 
                        if (pn) {
                                /*
-                                * parents are only enqueued for emission 
+                                * parents are only enqueued for emission
                                  * when all their children have been emitted thereby
                                  * guaranteeing topological order.
                                  */
index 86e8dca0c9dbac4d990d959296145805319b477a..a313b53c3106c6f2502bf02c86db47a0df5b0f6c 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -66,15 +66,13 @@ extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit
 /** Removes the first commit from a list sorted by date, and adds all
  * of its parents.
  **/
-struct commit *pop_most_recent_commit(struct commit_list **list, 
+struct commit *pop_most_recent_commit(struct commit_list **list,
                                      unsigned int mark);
 
 struct commit *pop_commit(struct commit_list **stack);
 
 void clear_commit_marks(struct commit *commit, unsigned int mark);
 
-int count_parents(struct commit * commit);
-
 /*
  * Performs an in-place topological sort of list supplied.
  *
index 4cfaee31361d98d2c8f68d250609b09130335baa..c9d46d174259f42a3e2a2eb073475aba517044be 100644 (file)
@@ -40,4 +40,3 @@ int git_munmap(void *start, size_t length)
        free(start);
        return 0;
 }
-
index 7b655fdb78350bf9a8320075bef6cf4f1e87c50c..58d3ed5d371b6d7548f6677e65135bd3f01851d0 100644 (file)
--- a/config.c
+++ b/config.c
@@ -12,6 +12,8 @@
 static FILE *config_file;
 static const char *config_file_name;
 static int config_linenr;
+static int zlib_compression_seen;
+
 static int get_next_char(void)
 {
        int c;
@@ -299,8 +301,14 @@ int git_default_config(const char *var, const char *value)
                return 0;
        }
 
-       if (!strcmp(var, "core.legacyheaders")) {
-               use_legacy_headers = git_config_bool(var, value);
+       if (!strcmp(var, "core.loosecompression")) {
+               int level = git_config_int(var, value);
+               if (level == -1)
+                       level = Z_DEFAULT_COMPRESSION;
+               else if (level < 0 || level > Z_BEST_COMPRESSION)
+                       die("bad zlib compression level %d", level);
+               zlib_compression_level = level;
+               zlib_compression_seen = 1;
                return 0;
        }
 
@@ -310,7 +318,10 @@ int git_default_config(const char *var, const char *value)
                        level = Z_DEFAULT_COMPRESSION;
                else if (level < 0 || level > Z_BEST_COMPRESSION)
                        die("bad zlib compression level %d", level);
-               zlib_compression_level = level;
+               core_compression_level = level;
+               core_compression_seen = 1;
+               if (!zlib_compression_seen)
+                       zlib_compression_level = level;
                return 0;
        }
 
@@ -610,7 +621,7 @@ static ssize_t find_beginning_of_line(const char* contents, size_t size,
        size_t equal_offset = size, bracket_offset = size;
        ssize_t offset;
 
-       for (offset = offset_-2; offset > 0 
+       for (offset = offset_-2; offset > 0
                        && contents[offset] != '\n'; offset--)
                switch (contents[offset]) {
                        case '=': equal_offset = offset; break;
@@ -978,4 +989,3 @@ int git_config_rename_section(const char *old_name, const char *new_name)
        free(config_filename);
        return ret;
 }
-
index eb9d7a55496492fa021e8262f052c7f46b60ea20..a3032e389f6bf63cd46a3aa23e59b6a6cd537132 100644 (file)
@@ -38,4 +38,3 @@ NO_STRCASESTR=@NO_STRCASESTR@
 NO_STRLCPY=@NO_STRLCPY@
 NO_SETENV=@NO_SETENV@
 NO_ICONV=@NO_ICONV@
-
index da89c9cfcf3469dfab789f2644f953ea46666e90..7fab9c0fd961af54a5758e8452391ff7a5e2e9bd 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -4,6 +4,7 @@
 #include "quote.h"
 #include "refs.h"
 #include "run-command.h"
+#include "remote.h"
 
 static char *server_capabilities;
 
@@ -128,245 +129,6 @@ int path_match(const char *path, int nr, char **match)
        return 0;
 }
 
-struct refspec {
-       char *src;
-       char *dst;
-       char force;
-};
-
-/*
- * A:B means fast forward remote B with local A.
- * +A:B means overwrite remote B with local A.
- * +A is a shorthand for +A:A.
- * A is a shorthand for A:A.
- * :B means delete remote B.
- */
-static struct refspec *parse_ref_spec(int nr_refspec, char **refspec)
-{
-       int i;
-       struct refspec *rs = xcalloc(sizeof(*rs), (nr_refspec + 1));
-       for (i = 0; i < nr_refspec; i++) {
-               char *sp, *dp, *ep;
-               sp = refspec[i];
-               if (*sp == '+') {
-                       rs[i].force = 1;
-                       sp++;
-               }
-               ep = strchr(sp, ':');
-               if (ep) {
-                       dp = ep + 1;
-                       *ep = 0;
-               }
-               else
-                       dp = sp;
-               rs[i].src = sp;
-               rs[i].dst = dp;
-       }
-       rs[nr_refspec].src = rs[nr_refspec].dst = NULL;
-       return rs;
-}
-
-static int count_refspec_match(const char *pattern,
-                              struct ref *refs,
-                              struct ref **matched_ref)
-{
-       int patlen = strlen(pattern);
-       struct ref *matched_weak = NULL;
-       struct ref *matched = NULL;
-       int weak_match = 0;
-       int match = 0;
-
-       for (weak_match = match = 0; refs; refs = refs->next) {
-               char *name = refs->name;
-               int namelen = strlen(name);
-               int weak_match;
-
-               if (namelen < patlen ||
-                   memcmp(name + namelen - patlen, pattern, patlen))
-                       continue;
-               if (namelen != patlen && name[namelen - patlen - 1] != '/')
-                       continue;
-
-               /* A match is "weak" if it is with refs outside
-                * heads or tags, and did not specify the pattern
-                * in full (e.g. "refs/remotes/origin/master") or at
-                * least from the toplevel (e.g. "remotes/origin/master");
-                * otherwise "git push $URL master" would result in
-                * ambiguity between remotes/origin/master and heads/master
-                * at the remote site.
-                */
-               if (namelen != patlen &&
-                   patlen != namelen - 5 &&
-                   prefixcmp(name, "refs/heads/") &&
-                   prefixcmp(name, "refs/tags/")) {
-                       /* We want to catch the case where only weak
-                        * matches are found and there are multiple
-                        * matches, and where more than one strong
-                        * matches are found, as ambiguous.  One
-                        * strong match with zero or more weak matches
-                        * are acceptable as a unique match.
-                        */
-                       matched_weak = refs;
-                       weak_match++;
-               }
-               else {
-                       matched = refs;
-                       match++;
-               }
-       }
-       if (!matched) {
-               *matched_ref = matched_weak;
-               return weak_match;
-       }
-       else {
-               *matched_ref = matched;
-               return match;
-       }
-}
-
-static void link_dst_tail(struct ref *ref, struct ref ***tail)
-{
-       **tail = ref;
-       *tail = &ref->next;
-       **tail = NULL;
-}
-
-static struct ref *try_explicit_object_name(const char *name)
-{
-       unsigned char sha1[20];
-       struct ref *ref;
-       int len;
-
-       if (!*name) {
-               ref = xcalloc(1, sizeof(*ref) + 20);
-               strcpy(ref->name, "(delete)");
-               hashclr(ref->new_sha1);
-               return ref;
-       }
-       if (get_sha1(name, sha1))
-               return NULL;
-       len = strlen(name) + 1;
-       ref = xcalloc(1, sizeof(*ref) + len);
-       memcpy(ref->name, name, len);
-       hashcpy(ref->new_sha1, sha1);
-       return ref;
-}
-
-static int match_explicit_refs(struct ref *src, struct ref *dst,
-                              struct ref ***dst_tail, struct refspec *rs)
-{
-       int i, errs;
-       for (i = errs = 0; rs[i].src; i++) {
-               struct ref *matched_src, *matched_dst;
-
-               matched_src = matched_dst = NULL;
-               switch (count_refspec_match(rs[i].src, src, &matched_src)) {
-               case 1:
-                       break;
-               case 0:
-                       /* The source could be in the get_sha1() format
-                        * not a reference name.  :refs/other is a
-                        * way to delete 'other' ref at the remote end.
-                        */
-                       matched_src = try_explicit_object_name(rs[i].src);
-                       if (matched_src)
-                               break;
-                       errs = 1;
-                       error("src refspec %s does not match any.",
-                             rs[i].src);
-                       break;
-               default:
-                       errs = 1;
-                       error("src refspec %s matches more than one.",
-                             rs[i].src);
-                       break;
-               }
-               switch (count_refspec_match(rs[i].dst, dst, &matched_dst)) {
-               case 1:
-                       break;
-               case 0:
-                       if (!memcmp(rs[i].dst, "refs/", 5)) {
-                               int len = strlen(rs[i].dst) + 1;
-                               matched_dst = xcalloc(1, sizeof(*dst) + len);
-                               memcpy(matched_dst->name, rs[i].dst, len);
-                               link_dst_tail(matched_dst, dst_tail);
-                       }
-                       else if (!strcmp(rs[i].src, rs[i].dst) &&
-                                matched_src) {
-                               /* pushing "master:master" when
-                                * remote does not have master yet.
-                                */
-                               int len = strlen(matched_src->name) + 1;
-                               matched_dst = xcalloc(1, sizeof(*dst) + len);
-                               memcpy(matched_dst->name, matched_src->name,
-                                      len);
-                               link_dst_tail(matched_dst, dst_tail);
-                       }
-                       else {
-                               errs = 1;
-                               error("dst refspec %s does not match any "
-                                     "existing ref on the remote and does "
-                                     "not start with refs/.", rs[i].dst);
-                       }
-                       break;
-               default:
-                       errs = 1;
-                       error("dst refspec %s matches more than one.",
-                             rs[i].dst);
-                       break;
-               }
-               if (errs)
-                       continue;
-               if (matched_dst->peer_ref) {
-                       errs = 1;
-                       error("dst ref %s receives from more than one src.",
-                             matched_dst->name);
-               }
-               else {
-                       matched_dst->peer_ref = matched_src;
-                       matched_dst->force = rs[i].force;
-               }
-       }
-       return -errs;
-}
-
-static struct ref *find_ref_by_name(struct ref *list, const char *name)
-{
-       for ( ; list; list = list->next)
-               if (!strcmp(list->name, name))
-                       return list;
-       return NULL;
-}
-
-int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
-              int nr_refspec, char **refspec, int all)
-{
-       struct refspec *rs = parse_ref_spec(nr_refspec, refspec);
-
-       if (nr_refspec)
-               return match_explicit_refs(src, dst, dst_tail, rs);
-
-       /* pick the remainder */
-       for ( ; src; src = src->next) {
-               struct ref *dst_peer;
-               if (src->peer_ref)
-                       continue;
-               dst_peer = find_ref_by_name(dst, src->name);
-               if ((dst_peer && dst_peer->peer_ref) || (!dst_peer && !all))
-                       continue;
-               if (!dst_peer) {
-                       /* Create a new one and link it */
-                       int len = strlen(src->name) + 1;
-                       dst_peer = xcalloc(1, sizeof(*dst_peer) + len);
-                       memcpy(dst_peer->name, src->name, len);
-                       hashcpy(dst_peer->new_sha1, src->new_sha1);
-                       link_dst_tail(dst_peer, dst_tail);
-               }
-               dst_peer->peer_ref = src;
-       }
-       return 0;
-}
-
 enum protocol {
        PROTO_LOCAL = 1,
        PROTO_SSH,
@@ -391,16 +153,34 @@ static enum protocol get_protocol(const char *name)
 
 #ifndef NO_IPV6
 
+static const char *ai_name(const struct addrinfo *ai)
+{
+       static char addr[INET_ADDRSTRLEN];
+       if ( AF_INET == ai->ai_family ) {
+               struct sockaddr_in *in;
+               in = (struct sockaddr_in *)ai->ai_addr;
+               inet_ntop(ai->ai_family, &in->sin_addr, addr, sizeof(addr));
+       } else if ( AF_INET6 == ai->ai_family ) {
+               struct sockaddr_in6 *in;
+               in = (struct sockaddr_in6 *)ai->ai_addr;
+               inet_ntop(ai->ai_family, &in->sin6_addr, addr, sizeof(addr));
+       } else {
+               strcpy(addr, "(unknown)");
+       }
+       return addr;
+}
+
 /*
  * Returns a connected socket() fd, or else die()s.
  */
-static int git_tcp_connect_sock(char *host)
+static int git_tcp_connect_sock(char *host, int flags)
 {
        int sockfd = -1, saved_errno = 0;
        char *colon, *end;
        const char *port = STR(DEFAULT_GIT_PORT);
        struct addrinfo hints, *ai0, *ai;
        int gai;
+       int cnt = 0;
 
        if (host[0] == '[') {
                end = strchr(host + 1, ']');
@@ -425,10 +205,16 @@ static int git_tcp_connect_sock(char *host)
        hints.ai_socktype = SOCK_STREAM;
        hints.ai_protocol = IPPROTO_TCP;
 
+       if (flags & CONNECT_VERBOSE)
+               fprintf(stderr, "Looking up %s ... ", host);
+
        gai = getaddrinfo(host, port, &hints, &ai);
        if (gai)
                die("Unable to look up %s (port %s) (%s)", host, port, gai_strerror(gai));
 
+       if (flags & CONNECT_VERBOSE)
+               fprintf(stderr, "done.\nConnecting to %s (port %s) ... ", host, port);
+
        for (ai0 = ai; ai; ai = ai->ai_next) {
                sockfd = socket(ai->ai_family,
                                ai->ai_socktype, ai->ai_protocol);
@@ -438,10 +224,18 @@ static int git_tcp_connect_sock(char *host)
                }
                if (connect(sockfd, ai->ai_addr, ai->ai_addrlen) < 0) {
                        saved_errno = errno;
+                       fprintf(stderr, "%s[%d: %s]: net=%s, errno=%s\n",
+                               host,
+                               cnt,
+                               ai_name(ai),
+                               hstrerror(h_errno),
+                               strerror(saved_errno));
                        close(sockfd);
                        sockfd = -1;
                        continue;
                }
+               if (flags & CONNECT_VERBOSE)
+                       fprintf(stderr, "%s ", ai_name(ai));
                break;
        }
 
@@ -450,6 +244,9 @@ static int git_tcp_connect_sock(char *host)
        if (sockfd < 0)
                die("unable to connect a socket (%s)", strerror(saved_errno));
 
+       if (flags & CONNECT_VERBOSE)
+               fprintf(stderr, "done.\n");
+
        return sockfd;
 }
 
@@ -458,7 +255,7 @@ static int git_tcp_connect_sock(char *host)
 /*
  * Returns a connected socket() fd, or else die()s.
  */
-static int git_tcp_connect_sock(char *host)
+static int git_tcp_connect_sock(char *host, int flags)
 {
        int sockfd = -1, saved_errno = 0;
        char *colon, *end;
@@ -467,6 +264,7 @@ static int git_tcp_connect_sock(char *host)
        struct sockaddr_in sa;
        char **ap;
        unsigned int nport;
+       int cnt;
 
        if (host[0] == '[') {
                end = strchr(host + 1, ']');
@@ -485,6 +283,9 @@ static int git_tcp_connect_sock(char *host)
                port = colon + 1;
        }
 
+       if (flags & CONNECT_VERBOSE)
+               fprintf(stderr, "Looking up %s ... ", host);
+
        he = gethostbyname(host);
        if (!he)
                die("Unable to look up %s (%s)", host, hstrerror(h_errno));
@@ -497,7 +298,10 @@ static int git_tcp_connect_sock(char *host)
                nport = se->s_port;
        }
 
-       for (ap = he->h_addr_list; *ap; ap++) {
+       if (flags & CONNECT_VERBOSE)
+               fprintf(stderr, "done.\nConnecting to %s (port %s) ... ", host, port);
+
+       for (cnt = 0, ap = he->h_addr_list; *ap; ap++, cnt++) {
                sockfd = socket(he->h_addrtype, SOCK_STREAM, 0);
                if (sockfd < 0) {
                        saved_errno = errno;
@@ -511,25 +315,37 @@ static int git_tcp_connect_sock(char *host)
 
                if (connect(sockfd, (struct sockaddr *)&sa, sizeof sa) < 0) {
                        saved_errno = errno;
+                       fprintf(stderr, "%s[%d: %s]: net=%s, errno=%s\n",
+                               host,
+                               cnt,
+                               inet_ntoa(*(struct in_addr *)&sa.sin_addr),
+                               hstrerror(h_errno),
+                               strerror(saved_errno));
                        close(sockfd);
                        sockfd = -1;
                        continue;
                }
+               if (flags & CONNECT_VERBOSE)
+                       fprintf(stderr, "%s ",
+                               inet_ntoa(*(struct in_addr *)&sa.sin_addr));
                break;
        }
 
        if (sockfd < 0)
                die("unable to connect a socket (%s)", strerror(saved_errno));
 
+       if (flags & CONNECT_VERBOSE)
+               fprintf(stderr, "done.\n");
+
        return sockfd;
 }
 
 #endif /* NO_IPV6 */
 
 
-static void git_tcp_connect(int fd[2], char *host)
+static void git_tcp_connect(int fd[2], char *host, int flags)
 {
-       int sockfd = git_tcp_connect_sock(host);
+       int sockfd = git_tcp_connect_sock(host, flags);
 
        fd[0] = sockfd;
        fd[1] = dup(sockfd);
@@ -574,7 +390,7 @@ static int git_proxy_command_options(const char *var, const char *value)
                }
                if (0 <= matchlen) {
                        /* core.gitproxy = none for kernel.org */
-                       if (matchlen == 4 && 
+                       if (matchlen == 4 &&
                            !memcmp(value, "none", 4))
                                matchlen = 0;
                        git_proxy_command = xmalloc(matchlen + 1);
@@ -646,7 +462,7 @@ static void git_proxy_connect(int fd[2], char *host)
  *
  * Does not return a negative value on error; it just dies.
  */
-pid_t git_connect(int fd[2], char *url, const char *prog)
+pid_t git_connect(int fd[2], char *url, const char *prog, int flags)
 {
        char *host, *path = url;
        char *end;
@@ -719,7 +535,7 @@ pid_t git_connect(int fd[2], char *url, const char *prog)
                if (git_use_proxy(host))
                        git_proxy_connect(fd, host);
                else
-                       git_tcp_connect(fd, host);
+                       git_tcp_connect(fd, host, flags);
                /*
                 * Separate original protocol components prog and path
                 * from extended components with a NUL byte.
index e1c0a01ff30d3756d547781f783a37c96e9b7eb9..05f291c1f1d3d1018f390618816f94d0cd58951b 100644 (file)
@@ -41,4 +41,3 @@ submit a patch to create a subdirectory of contrib/ and put your
 stuff there.
 
 -jc
-
index 50a6f67fd6df5c37a0e244ff5c5997131f3f0f52..fada5ce909876168f68a85c8ca9a8bc269048acb 100644 (file)
@@ -7,4 +7,3 @@ To: Linus Torvalds <torvalds@linux-foundation.org>
 Cc: git@vger.kernel.org
 Date: Sat, 27 Jan 2007 18:52:38 -0500
 Message-ID: <20070127235238.GA28706@coredump.intra.peff.net>
-
index 2d80e2bad2e6f322d7ff7e9f03a6897a11f74231..098cb01353d4adbfd32bdd4f70183b4b474f2158 100755 (executable)
@@ -259,10 +259,13 @@ class CellRendererGraph(gtk.GenericCellRenderer):
                                self.set_colour(ctx, colour, 0.0, 0.5)
                        ctx.show_text(name)
 
-class Commit:
+class Commit(object):
        """ This represent a commit object obtained after parsing the git-rev-list
        output """
 
+       __slots__ = ['children_sha1', 'message', 'author', 'date', 'committer',
+                                'commit_date', 'commit_sha1', 'parent_sha1']
+
        children_sha1 = {}
 
        def __init__(self, commit_lines):
@@ -339,7 +342,7 @@ class Commit:
                fp.close()
                return diff
 
-class AnnotateWindow:
+class AnnotateWindow(object):
        """Annotate window.
        This object represents and manages a single window containing the
        annotate information of the file
@@ -519,7 +522,7 @@ class AnnotateWindow:
                self.io_watch_tag = gobject.io_add_watch(fp, gobject.IO_IN, self.data_ready)
 
 
-class DiffWindow:
+class DiffWindow(object):
        """Diff window.
        This object represents and manages a single window containing the
        differences between two revisions on a branch.
@@ -674,7 +677,7 @@ class DiffWindow:
                        fp.close()
                dialog.destroy()
 
-class GitView:
+class GitView(object):
        """ This is the main class
        """
        version = "0.9"
@@ -1277,5 +1280,3 @@ if __name__ == "__main__":
 
        view = GitView( without_diff != 1)
        view.run(sys.argv[without_diff:])
-
-
index d1bef9125bca0997e0e714b3f89e9c2df307d598..c589a39a0c81818150575c74866a57619e1adf2a 100644 (file)
@@ -199,7 +199,7 @@ generate_email_footer()
 
 
        hooks/post-receive
-       -- 
+       --
        $projectdesc
        EOF
 }
index dc09eae972711496aa390cb99b3017a936ce1afc..0c8b9544908ad90c1731cbac14f9f78910abc8f8 100644 (file)
@@ -31,5 +31,3 @@ if [ -d "$GIT_DIR"/remotes ]; then
                esac
        done
 fi
-
-
index 9877b98508497c9377876bd08e8f130660b9ba05..f2a3615bbc44ed4edbee4014683621a91c1a7ab9 100755 (executable)
@@ -20,17 +20,19 @@ new_workdir=$2
 branch=$3
 
 # want to make sure that what is pointed to has a .git directory ...
-test -d "$orig_git/.git" || die "\"$orig_git\" is not a git repository!"
+git_dir=$(cd "$orig_git" 2>/dev/null &&
+  git rev-parse --git-dir 2>/dev/null) ||
+  die "\"$orig_git\" is not a git repository!"
 
 # don't link to a workdir
-if test -L "$orig_git/.git/config"
+if test -L "$git_dir/config"
 then
        die "\"$orig_git\" is a working directory only, please specify" \
                "a complete repository."
 fi
 
 # make sure the the links use full paths
-orig_git=$(cd "$orig_git"; pwd)
+git_dir=$(cd "$git_dir"; pwd)
 
 # create the workdir
 mkdir -p "$new_workdir/.git" || die "unable to create \"$new_workdir\"!"
@@ -45,13 +47,13 @@ do
                mkdir -p "$(dirname "$new_workdir/.git/$x")"
                ;;
        esac
-       ln -s "$orig_git/.git/$x" "$new_workdir/.git/$x"
+       ln -s "$git_dir/$x" "$new_workdir/.git/$x"
 done
 
 # now setup the workdir
 cd "$new_workdir"
 # copy the HEAD from the original repository as a default branch
-cp "$orig_git/.git/HEAD" .git/HEAD
+cp "$git_dir/HEAD" .git/HEAD
 # checkout the branch (either the same as HEAD from the original repository, or
 # the one that was asked for)
 git checkout -f $branch
index cefbcebdcaa0a085745c81b2ed1103e9575cb635..90e7900e6d7aff2fadf9ba04f8d982733493411c 100644 (file)
@@ -194,7 +194,7 @@ static unsigned long parse_oldstyle_date(const char *buf)
                fmt++;
        } while (*buf && *fmt);
        printf("left: %s\n", buf);
-       return mktime(&tm);                             
+       return mktime(&tm);
 }
 
 static int convert_date_line(char *dst, void **buf, unsigned long *sp)
diff --git a/copy.c b/copy.c
index d340bb253ec35af379c29e71f384e15d6822fb9a..c225d1b0ff0a67e637f7200ab5c2a917b550af4f 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -34,4 +34,3 @@ int copy_fd(int ifd, int ofd)
        close(ifd);
        return 0;
 }
-
index 7c806ada48d0fd58c091f9415fc8bb2f61bdd2e6..510934262437cf48c2b732bc2a392dd8167bee45 100644 (file)
@@ -29,18 +29,20 @@ static void sha1flush(struct sha1file *f, unsigned int count)
        }
 }
 
-int sha1close(struct sha1file *f, unsigned char *result, int update)
+int sha1close(struct sha1file *f, unsigned char *result, int final)
 {
        unsigned offset = f->offset;
        if (offset) {
                SHA1_Update(&f->ctx, f->buffer, offset);
                sha1flush(f, offset);
+               f->offset = 0;
        }
+       if (!final)
+               return 0;       /* only want to flush (no checksum write, no close) */
        SHA1_Final(f->buffer, &f->ctx);
        if (result)
                hashcpy(result, f->buffer);
-       if (update)
-               sha1flush(f, 20);
+       sha1flush(f, 20);
        if (close(f->fd))
                die("%s: sha1 file error on close (%s)", f->name, strerror(errno));
        free(f);
@@ -119,14 +121,14 @@ struct sha1file *sha1fd(int fd, const char *name)
        return f;
 }
 
-int sha1write_compressed(struct sha1file *f, void *in, unsigned int size)
+int sha1write_compressed(struct sha1file *f, void *in, unsigned int size, int level)
 {
        z_stream stream;
        unsigned long maxsize;
        void *out;
 
        memset(&stream, 0, sizeof(stream));
-       deflateInit(&stream, zlib_compression_level);
+       deflateInit(&stream, level);
        maxsize = deflateBound(&stream, size);
        out = xmalloc(maxsize);
 
index 7e1339189dcdc6e271fad5df7ad427954642ae9e..4e8b83e0936f255e0fff57127da56288a988a5fe 100644 (file)
@@ -16,7 +16,7 @@ extern struct sha1file *sha1fd(int fd, const char *name);
 extern struct sha1file *sha1create(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
 extern int sha1close(struct sha1file *, unsigned char *, int);
 extern int sha1write(struct sha1file *, void *, unsigned int);
-extern int sha1write_compressed(struct sha1file *, void *, unsigned int);
+extern int sha1write_compressed(struct sha1file *, void *, unsigned int, int);
 extern void crc32_begin(struct sha1file *);
 extern uint32_t crc32_end(struct sha1file *);
 
diff --git a/ctype.c b/ctype.c
index 56bdffa636e6b4465ab8451de0351ff394182885..ee06eb7f48f1d3e818b3037369b4e056fe7e5be7 100644 (file)
--- a/ctype.c
+++ b/ctype.c
@@ -20,4 +20,3 @@ unsigned char sane_ctype[256] = {
        AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA,  0,  0,  0,  0,  0,         /* 112-15 */
        /* Nothing in the 128.. range */
 };
-
index 674e30dca3d05cabc5a72e7bb0a40e64eaa4b2eb..a3f2ac1d81a21883c5ec7e9f1270c9109c675f12 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -133,7 +133,7 @@ static int avoid_alias(char *p)
 {
        int sl, ndot;
 
-       /* 
+       /*
         * This resurrects the belts and suspenders paranoia check by HPA
         * done in <435560F7.4080006@zytor.com> thread, now enter_repo()
         * does not do getcwd() based path canonicalizations.
@@ -247,7 +247,7 @@ static char *path_ok(struct interp *itable)
                int pathlen = strlen(path);
 
                /* The validation is done on the paths after enter_repo
-                * appends optional {.git,.git/.git} and friends, but 
+                * appends optional {.git,.git/.git} and friends, but
                 * it does not use getcwd().  So if your /pub is
                 * a symlink to /mnt/pub, you can whitelist /pub and
                 * do not have to say /mnt/pub.
@@ -439,7 +439,7 @@ static void parse_extra_args(struct interp *table, char *extra_args, int buflen)
        }
 }
 
-void fill_in_extra_table_entries(struct interp *itable)
+static void fill_in_extra_table_entries(struct interp *itable)
 {
        char *hp;
 
diff --git a/date.c b/date.c
index 4690371e5559f72b7755b3cc92ae85843098d285..316841e8ad3705559fddb0ca4aff969fdf91b011 100644 (file)
--- a/date.c
+++ b/date.c
@@ -403,7 +403,7 @@ static int match_multi_number(unsigned long num, char c, const char *date, char
 }
 
 /*
- * We've seen a digit. Time? Year? Date? 
+ * We've seen a digit. Time? Year? Date?
  */
 static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt)
 {
@@ -495,7 +495,7 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt
        } else if (num > 0 && num < 13) {
                tm->tm_mon = num-1;
        }
-               
+
        return n;
 }
 
@@ -569,13 +569,13 @@ int parse_date(const char *date, char *result, int maxlen)
                if (!match) {
                        /* BAD CRAP */
                        match = 1;
-               }       
+               }
 
                date += match;
        }
 
        /* mktime uses local timezone */
-       then = my_mktime(&tm); 
+       then = my_mktime(&tm);
        if (offset == -1)
                offset = (then - mktime(&tm)) / 60;
 
@@ -691,7 +691,7 @@ static const struct typelen {
        { "days", 24*60*60 },
        { "weeks", 7*24*60*60 },
        { NULL }
-};     
+};
 
 static const char *approxidate_alpha(const char *date, struct tm *tm, int *num)
 {
index 9f998d0a73e0127d3a68a7caecb3727569149871..faf96e47130e3a2af26f55fc1173874f078617fc 100644 (file)
@@ -1,21 +1,14 @@
 /*
  * diff-delta.c: generate a delta between two buffers
  *
- *  Many parts of this file have been lifted from LibXDiff version 0.10.
- *  http://www.xmailserver.org/xdiff-lib.html
+ * This code was greatly inspired by parts of LibXDiff from Davide Libenzi
+ * http://www.xmailserver.org/xdiff-lib.html
  *
- *  LibXDiff was written by Davide Libenzi <davidel@xmailserver.org>
- *  Copyright (C) 2003 Davide Libenzi
+ * Rewritten for GIT by Nicolas Pitre <nico@cam.org>, (C) 2005-2007
  *
- *  Many mods for GIT usage by Nicolas Pitre <nico@cam.org>, (C) 2005.
- *
- *  This file is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2.1 of the License, or (at your option) any later version.
- *
- *  Use of this within git automatically means that the LGPL
- *  licensing gets turned into GPLv2 within this project.
+ * This code is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
  */
 
 #include "git-compat-util.h"
@@ -246,7 +239,7 @@ create_delta(const struct delta_index *index,
             const void *trg_buf, unsigned long trg_size,
             unsigned long *delta_size, unsigned long max_size)
 {
-       unsigned int i, outpos, outsize, val;
+       unsigned int i, outpos, outsize, moff, msize, val;
        int inscnt;
        const unsigned char *ref_data, *ref_top, *data, *top;
        unsigned char *out;
@@ -291,30 +284,33 @@ create_delta(const struct delta_index *index,
        }
        inscnt = i;
 
+       moff = 0;
+       msize = 0;
        while (data < top) {
-               unsigned int moff = 0, msize = 0;
-               struct index_entry *entry;
-               val ^= U[data[-RABIN_WINDOW]];
-               val = ((val << 8) | *data) ^ T[val >> RABIN_SHIFT];
-               i = val & index->hash_mask;
-               for (entry = index->hash[i]; entry; entry = entry->next) {
-                       const unsigned char *ref = entry->ptr;
-                       const unsigned char *src = data;
-                       unsigned int ref_size = ref_top - ref;
-                       if (entry->val != val)
-                               continue;
-                       if (ref_size > top - src)
-                               ref_size = top - src;
-                       if (ref_size > 0x10000)
-                               ref_size = 0x10000;
-                       if (ref_size <= msize)
-                               break;
-                       while (ref_size-- && *src++ == *ref)
-                               ref++;
-                       if (msize < ref - entry->ptr) {
-                               /* this is our best match so far */
-                               msize = ref - entry->ptr;
-                               moff = entry->ptr - ref_data;
+               if (msize < 4096) {
+                       struct index_entry *entry;
+                       val ^= U[data[-RABIN_WINDOW]];
+                       val = ((val << 8) | *data) ^ T[val >> RABIN_SHIFT];
+                       i = val & index->hash_mask;
+                       for (entry = index->hash[i]; entry; entry = entry->next) {
+                               const unsigned char *ref = entry->ptr;
+                               const unsigned char *src = data;
+                               unsigned int ref_size = ref_top - ref;
+                               if (entry->val != val)
+                                       continue;
+                               if (ref_size > top - src)
+                                       ref_size = top - src;
+                               if (ref_size <= msize)
+                                       break;
+                               while (ref_size-- && *src++ == *ref)
+                                       ref++;
+                               if (msize < ref - entry->ptr) {
+                                       /* this is our best match so far */
+                                       msize = ref - entry->ptr;
+                                       moff = entry->ptr - ref_data;
+                                       if (msize >= 4096) /* good enough */
+                                               break;
+                               }
                        }
                }
 
@@ -327,27 +323,13 @@ create_delta(const struct delta_index *index,
                                out[outpos - inscnt - 1] = inscnt;
                                inscnt = 0;
                        }
+                       msize = 0;
                } else {
+                       unsigned int left;
                        unsigned char *op;
 
-                       if (msize >= RABIN_WINDOW) {
-                               const unsigned char *sk;
-                               sk = data + msize - RABIN_WINDOW;
-                               val = 0;
-                               for (i = 0; i < RABIN_WINDOW; i++)
-                                       val = ((val << 8) | *sk++) ^ T[val >> RABIN_SHIFT];
-                       } else {
-                               const unsigned char *sk = data + 1;
-                               for (i = 1; i < msize; i++) {
-                                       val ^= U[sk[-RABIN_WINDOW]];
-                                       val = ((val << 8) | *sk++) ^ T[val >> RABIN_SHIFT];
-                               }
-                       }
-
                        if (inscnt) {
                                while (moff && ref_data[moff-1] == data[-1]) {
-                                       if (msize == 0x10000)
-                                               break;
                                        /* we can match one byte back */
                                        msize++;
                                        moff--;
@@ -363,23 +345,40 @@ create_delta(const struct delta_index *index,
                                inscnt = 0;
                        }
 
-                       data += msize;
+                       /* A copy op is currently limited to 64KB (pack v2) */
+                       left = (msize < 0x10000) ? 0 : (msize - 0x10000);
+                       msize -= left;
+
                        op = out + outpos++;
                        i = 0x80;
 
-                       if (moff & 0xff) { out[outpos++] = moff; i |= 0x01; }
-                       moff >>= 8;
-                       if (moff & 0xff) { out[outpos++] = moff; i |= 0x02; }
-                       moff >>= 8;
-                       if (moff & 0xff) { out[outpos++] = moff; i |= 0x04; }
-                       moff >>= 8;
-                       if (moff & 0xff) { out[outpos++] = moff; i |= 0x08; }
+                       if (moff & 0x000000ff)
+                               out[outpos++] = moff >> 0,  i |= 0x01;
+                       if (moff & 0x0000ff00)
+                               out[outpos++] = moff >> 8,  i |= 0x02;
+                       if (moff & 0x00ff0000)
+                               out[outpos++] = moff >> 16, i |= 0x04;
+                       if (moff & 0xff000000)
+                               out[outpos++] = moff >> 24, i |= 0x08;
 
-                       if (msize & 0xff) { out[outpos++] = msize; i |= 0x10; }
-                       msize >>= 8;
-                       if (msize & 0xff) { out[outpos++] = msize; i |= 0x20; }
+                       if (msize & 0x00ff)
+                               out[outpos++] = msize >> 0, i |= 0x10;
+                       if (msize & 0xff00)
+                               out[outpos++] = msize >> 8, i |= 0x20;
 
                        *op = i;
+
+                       data += msize;
+                       moff += msize;
+                       msize = left;
+
+                       if (msize < 4096) {
+                               int j;
+                               val = 0;
+                               for (j = -RABIN_WINDOW; j < 0; j++)
+                                       val = ((val << 8) | data[j])
+                                             ^ T[val >> RABIN_SHIFT];
+                       }
                }
 
                if (outpos >= outsize - MAX_OP_SIZE) {
@@ -389,7 +388,7 @@ create_delta(const struct delta_index *index,
                                outsize = max_size + MAX_OP_SIZE + 1;
                        if (max_size && outpos > max_size)
                                break;
-                       out = xrealloc(out, outsize);
+                       out = realloc(out, outsize);
                        if (!out) {
                                free(tmp);
                                return NULL;
index 07f4e8106a51384d2236b182438472884c300da6..7fb19c7b87fc39cc4515628e8623ccb92fbaa60e 100644 (file)
@@ -664,7 +664,7 @@ int run_diff_index(struct rev_info *revs, int cached)
        const char *tree_name;
        int match_missing = 0;
 
-       /* 
+       /*
         * Backward compatibility wart - "diff-index -m" does
         * not mean "do not ignore merges", but totally different.
         */
diff --git a/diff.c b/diff.c
index af282ddd8818aacdc516ff6f9dff4d84097cbab0..1d234d361d29605c49da8fa177ebb563cf3066c1 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1107,10 +1107,8 @@ static void setup_diff_attr_check(struct git_attr_check *check)
        check->attr = attr_diff;
 }
 
-#define FIRST_FEW_BYTES 8000
 static int file_is_binary(struct diff_filespec *one)
 {
-       unsigned long sz;
        struct git_attr_check attr_diff_check;
 
        setup_diff_attr_check(&attr_diff_check);
@@ -1127,10 +1125,7 @@ static int file_is_binary(struct diff_filespec *one)
                        return 0;
                diff_populate_filespec(one, 0);
        }
-       sz = one->size;
-       if (FIRST_FEW_BYTES < sz)
-               sz = FIRST_FEW_BYTES;
-       return !!memchr(one->data, 0, sz);
+       return buffer_is_binary(one->data, one->size);
 }
 
 static void builtin_diff(const char *name_a,
@@ -1465,7 +1460,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
        if (size_only && 0 < s->size)
                return 0;
 
-       if (S_ISDIRLNK(s->mode))
+       if (S_ISGITLINK(s->mode))
                return diff_populate_gitlink(s, size_only);
 
        if (!s->sha1_valid ||
@@ -2108,6 +2103,8 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va
        return 1;
 }
 
+static int diff_scoreopt_parse(const char *opt);
+
 int diff_opt_parse(struct diff_options *options, const char **av, int ac)
 {
        const char *arg = av[0];
@@ -2279,7 +2276,7 @@ static int parse_num(const char **cp_p)
        return (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale));
 }
 
-int diff_scoreopt_parse(const char *opt)
+static int diff_scoreopt_parse(const char *opt)
 {
        int opt1, opt2, cmd;
 
@@ -3036,7 +3033,7 @@ void diff_addremove(struct diff_options *options,
         * entries to the diff-core.  They will be prefixed
         * with something like '=' or '*' (I haven't decided
         * which but should not make any difference).
-        * Feeding the same new and old to diff_change() 
+        * Feeding the same new and old to diff_change()
         * also has the same effect.
         * Before the final output happens, they are pruned after
         * merged into rename/copy pairs as appropriate.
@@ -3063,7 +3060,7 @@ void diff_change(struct diff_options *options,
                 unsigned old_mode, unsigned new_mode,
                 const unsigned char *old_sha1,
                 const unsigned char *new_sha1,
-                const char *base, const char *path) 
+                const char *base, const char *path)
 {
        char concatpath[PATH_MAX];
        struct diff_filespec *one, *two;
diff --git a/diff.h b/diff.h
index 63738c1dd4c71cb1beacaffea40bf51377a137ea..a7ee6d8c87887b111ef84b95266e1ff43496e7c3 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -155,8 +155,6 @@ extern void diff_unmerge(struct diff_options *,
                         unsigned mode,
                         const unsigned char *sha1);
 
-extern int diff_scoreopt_parse(const char *opt);
-
 #define DIFF_SETUP_REVERSE             1
 #define DIFF_SETUP_USE_CACHE           2
 #define DIFF_SETUP_USE_SIZE_CACHE      4
index c4a77d71da5602b68c541c2487fcbecfdfff2944..af9fffe6e8e145b066157da8791c749257e7c8e9 100644 (file)
@@ -102,7 +102,7 @@ void diffcore_pickaxe(const char *needle, int opts)
                for (i = 0; i < q->nr; i++)
                        diff_free_filepair(q->queue[i]);
        }
-       else 
+       else
                /* Showing only the filepairs that has the needle */
                for (i = 0; i < q->nr; i++) {
                        struct diff_filepair *p = q->queue[i];
diff --git a/dir.c b/dir.c
index 11fab7f4bf9b93be33795dfd5c1a3c55c8a8079d..f543f50f42d5bca1a6a6f981e8bb1b3cafd352ea 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -321,7 +321,7 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
                        break;
                if (endchar == '/')
                        return index_directory;
-               if (!endchar && S_ISDIRLNK(ntohl(ce->ce_mode)))
+               if (!endchar && S_ISGITLINK(ntohl(ce->ce_mode)))
                        return index_gitdir;
        }
        return index_nonexistent;
@@ -356,7 +356,7 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
  *      also true and the directory is empty, in which case
  *      we just ignore it entirely.
  *  (b) if it looks like a git directory, and we don't have
- *      'no_dirlinks' set we treat it as a gitlink, and show it
+ *      'no_gitlinks' set we treat it as a gitlink, and show it
  *      as a directory.
  *  (c) otherwise, we recurse into it.
  */
@@ -383,7 +383,7 @@ static enum directory_treatment treat_directory(struct dir_struct *dir,
        case index_nonexistent:
                if (dir->show_other_directories)
                        break;
-               if (!dir->no_dirlinks) {
+               if (!dir->no_gitlinks) {
                        unsigned char sha1[20];
                        if (resolve_gitlink_ref(dirname, "HEAD", sha1) == 0)
                                return show_directory;
diff --git a/dir.h b/dir.h
index 817c674da1e017cffea9dddae672f9125aca8475..172147fd3d4711c9ea95cd76048b7188bf9a1e2c 100644 (file)
--- a/dir.h
+++ b/dir.h
@@ -34,7 +34,7 @@ struct dir_struct {
        unsigned int show_ignored:1,
                     show_other_directories:1,
                     hide_empty_directories:1,
-                    no_dirlinks:1;
+                    no_gitlinks:1;
        struct dir_entry **entries;
 
        /* Exclude info */
diff --git a/entry.c b/entry.c
index 82bf7259a7d1d34a92a9bf214bccd9771748c582..c540ae13e858685faa8dbbada5b064074235ae6d 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -31,7 +31,7 @@ static void remove_subtree(const char *path)
        struct dirent *de;
        char pathbuf[PATH_MAX];
        char *name;
-       
+
        if (!dir)
                die("cannot opendir %s (%s)", path, strerror(errno));
        strcpy(pathbuf, path);
@@ -145,7 +145,7 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
                                                 "symlink %s (%s)", path, strerror(errno));
                }
                break;
-       case S_IFDIRLNK:
+       case S_IFGITLINK:
                if (to_tempfile)
                        return error("git-checkout-index: cannot create temporary subproject %s", path);
                if (mkdir(path, 0777) < 0)
@@ -194,7 +194,7 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *t
                unlink(path);
                if (S_ISDIR(st.st_mode)) {
                        /* If it is a gitlink, leave it alone! */
-                       if (S_ISDIRLNK(ntohl(ce->ce_mode)))
+                       if (S_ISGITLINK(ntohl(ce->ce_mode)))
                                return 0;
                        if (!state->force)
                                return error("%s is a directory", path);
index 22316597df60648c850001e068938eaf39d57f6d..8b9b89d0a0c93683b522383ed56d7f464a6962cb 100644 (file)
@@ -11,7 +11,6 @@
 
 char git_default_email[MAX_GITNAME];
 char git_default_name[MAX_GITNAME];
-int use_legacy_headers = 1;
 int trust_executable_bit = 1;
 int has_symlinks = 1;
 int assume_unchanged;
@@ -24,7 +23,9 @@ const char *git_commit_encoding;
 const char *git_log_output_encoding;
 int shared_repository = PERM_UMASK;
 const char *apply_default_whitespace;
-int zlib_compression_level = Z_DEFAULT_COMPRESSION;
+int zlib_compression_level = Z_BEST_SPEED;
+int core_compression_level;
+int core_compression_seen;
 size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
 size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
 size_t delta_base_cache_limit = 16 * 1024 * 1024;
@@ -104,5 +105,3 @@ char *get_graft_file(void)
                setup_git_env();
        return git_graft_file;
 }
-
-
index 17554f68493a8409c64b47334a94e622d47d8133..f9bfcc72c87bf79fcb7a5faef01bc0d12aa15420 100644 (file)
@@ -1272,7 +1272,7 @@ static int update_branch(struct branch *b)
 
        if (read_ref(b->name, old_sha1))
                hashclr(old_sha1);
-       lock = lock_any_ref_for_update(b->name, old_sha1);
+       lock = lock_any_ref_for_update(b->name, old_sha1, 0);
        if (!lock)
                return error("Unable to lock %s", b->name);
        if (!force_update && !is_null_sha1(old_sha1)) {
index 06f4aeced439312c43f2736a1684f9e22218899b..9c81305be5f4c1a78794c9d5397bd828ba705fcc 100644 (file)
@@ -114,7 +114,7 @@ static const unsigned char* get_rev(void)
                commit->object.flags |= POPPED;
                if (!(commit->object.flags & COMMON))
                        non_common_revs--;
-       
+
                parents = commit->parents;
 
                if (commit->object.flags & COMMON) {
@@ -733,7 +733,7 @@ int main(int argc, char **argv)
        }
        if (!dest)
                usage(fetch_pack_usage);
-       pid = git_connect(fd, dest, uploadpack);
+       pid = git_connect(fd, dest, uploadpack, verbose ? CONNECT_VERBOSE : 0);
        if (pid < 0)
                return 1;
        if (heads && nr_heads)
diff --git a/fetch.c b/fetch.c
index 8e29d313f817981a29ebb65f2f579c9f1bd8e9b6..dda33e548b65e79e22de8a84ab4d67ef13387a05 100644 (file)
--- a/fetch.c
+++ b/fetch.c
@@ -15,7 +15,7 @@ int get_verbosely = 0;
 int get_recover = 0;
 static unsigned char current_commit_sha1[20];
 
-void pull_say(const char *fmt, const char *hex) 
+void pull_say(const char *fmt, const char *hex)
 {
        if (get_verbosely)
                fprintf(stderr, fmt, hex);
@@ -153,7 +153,7 @@ static int process(struct object *obj)
                        return 0;
                prefetch(obj->sha1);
        }
-               
+
        object_list_insert(obj, process_queue_end);
        process_queue_end = &(*process_queue_end)->next;
        return 0;
diff --git a/git-applymbox.sh b/git-applymbox.sh
deleted file mode 100755 (executable)
index c18e80f..0000000
+++ /dev/null
@@ -1,121 +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"
-##
-## 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-am is supposed to be the newer and better tool for this job.
-
-USAGE='[-u] [-k] [-q] [-m] (-c .dotest/<num> | mbox) [signoff]'
-. git-sh-setup
-
-git var GIT_COMMITTER_IDENT >/dev/null || exit
-
-keep_subject= query_apply= continue= utf8=-u resume=t
-while case "$#" in 0) break ;; esac
-do
-       case "$1" in
-       -u)     utf8=-u ;;
-       -n)     utf8=-n ;;
-       -k)     keep_subject=-k ;;
-       -q)     query_apply=t ;;
-       -c)     continue="$2"; resume=f; shift ;;
-       -m)     fall_back_3way=t ;;
-       -*)     usage ;;
-       *)      break ;;
-       esac
-       shift
-done
-
-case "$continue" in
-'')
-       rm -rf .dotest
-       mkdir .dotest
-       num_msgs=$(git-mailsplit "$1" .dotest) || exit 1
-       echo "$num_msgs patch(es) to process."
-       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 "$fall_back_3way" in
-t)     : >.dotest/.3way
-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
-           test -s .dotest/patch || {
-               echo "Patch is empty.  Was it split wrong?"
-               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)
-               # Remove the cleanly applied one to reduce clutter.
-               rm -f .dotest/$i
-               ;;
-       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.sh b/git-applypatch.sh
deleted file mode 100755 (executable)
index 8df2aee..0000000
+++ /dev/null
@@ -1,212 +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
-##
-
-USAGE='<msg> <patch> <info> [<signoff>]'
-. git-sh-setup
-
-case "$#" in 3|4) ;; *) usage ;; esac
-
-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
-
-## We do not attempt the 3-way merge fallback unless this file exists.
-fall_back_3way=.dotest/.3way
-
-MSGFILE=$1
-PATCHFILE=$2
-INFO=$3
-SIGNOFF=$4
-EDIT=${VISUAL:-${EDITOR:-vi}}
-
-export GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$INFO")"
-export GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$INFO")"
-export GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$INFO")"
-export SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$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" || {
-                   test '' = "$LAST_SIGNED_OFF_BY" && echo
-                   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 "--------------------------"
-       printf "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" || {
-
-       # git-apply exits with status 1 when the patch does not apply,
-       # but it die()s with other failures, most notably upon corrupt
-       # patch.  In the latter case, there is no point to try applying
-       # it to another tree and do 3-way merge.
-       test $? = 1 || exit 1
-
-       test -f "$fall_back_3way" || exit 1
-
-       # Here if we know which revision the patch applies to,
-       # we create a temporary working tree and index, apply the
-       # patch, and attempt 3-way merge with the resulting tree.
-
-       O_OBJECT=`cd "$GIT_OBJECT_DIRECTORY" && pwd`
-       rm -fr .patch-merge-*
-
-       if git-apply -z --index-info "$PATCHFILE" \
-               >.patch-merge-index-info 2>/dev/null &&
-               GIT_INDEX_FILE=.patch-merge-tmp-index \
-               git-update-index -z --index-info <.patch-merge-index-info &&
-               GIT_INDEX_FILE=.patch-merge-tmp-index \
-               git-write-tree >.patch-merge-tmp-base &&
-               (
-                       mkdir .patch-merge-tmp-dir &&
-                       cd .patch-merge-tmp-dir &&
-                       GIT_INDEX_FILE="../.patch-merge-tmp-index" \
-                       GIT_OBJECT_DIRECTORY="$O_OBJECT" \
-                       git-apply $binary --index
-               ) <"$PATCHFILE"
-       then
-               echo Using index info to reconstruct a base tree...
-               mv .patch-merge-tmp-base .patch-merge-base
-               mv .patch-merge-tmp-index .patch-merge-index
-       else
-       (
-               N=10
-
-               # Otherwise, try nearby trees that can be used to apply the
-               # patch.
-               git-rev-list --max-count=$N HEAD
-
-               # or hoping the patch is against known tags...
-               git-ls-remote --tags .
-       ) |
-           while read base junk
-           do
-               # Try it if we have it as a tree.
-               git-cat-file tree "$base" >/dev/null 2>&1 || continue
-
-               rm -fr .patch-merge-tmp-* &&
-               mkdir .patch-merge-tmp-dir || break
-               (
-                       cd .patch-merge-tmp-dir &&
-                       GIT_INDEX_FILE=../.patch-merge-tmp-index &&
-                       GIT_OBJECT_DIRECTORY="$O_OBJECT" &&
-                       export GIT_INDEX_FILE GIT_OBJECT_DIRECTORY &&
-                       git-read-tree "$base" &&
-                       git-apply --index &&
-                       mv ../.patch-merge-tmp-index ../.patch-merge-index &&
-                       echo "$base" >../.patch-merge-base
-               ) <"$PATCHFILE"  2>/dev/null && break
-           done
-       fi
-
-       test -f .patch-merge-index &&
-       his_tree=$(GIT_INDEX_FILE=.patch-merge-index git-write-tree) &&
-       orig_tree=$(cat .patch-merge-base) &&
-       rm -fr .patch-merge-* || exit 1
-
-       echo Falling back to patching base and 3-way merge using $orig_tree...
-
-       # This is not so wrong.  Depending on which base we picked,
-       # orig_tree may be wildly different from ours, but his_tree
-       # has the same set of wildly different changes in parts the
-       # patch did not touch, so resolve ends up canceling them,
-       # saying that we reverted all those changes.
-
-       if git-merge-resolve $orig_tree -- HEAD $his_tree
-       then
-               echo Done.
-       else
-               echo Failed to merge in the changes.
-               exit 1
-       fi
-}
-
-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
-parent=$(git-rev-parse --verify HEAD) &&
-commit=$(git-commit-tree $tree -p $parent <"$final") || exit 1
-echo Committed: $commit
-git-update-ref -m "applypatch: $SUBJECT" HEAD $commit $parent || exit
-
-if test -x "$GIT_DIR"/hooks/post-applypatch
-then
-       "$GIT_DIR"/hooks/post-applypatch
-fi
index c1e7c1ddcbbf45995b53785a0f39314f6d499d2c..b21077206a93139fd8652d5174817e18c89ba22e 100755 (executable)
@@ -3,19 +3,19 @@
 # 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. 
+# The basic idea is to walk the output of tla abrowse,
+# fetch the changesets and apply them.
 #
 
 =head1 Invocation
 
-    git-archimport [ -h ] [ -v ] [ -o ] [ -a ] [ -f ] [ -T ] 
-       [ -D depth] [ -t tempdir ] <archive>/<branch> [ <archive>/<branch> ]
+    git-archimport [ -h ] [ -v ] [ -o ] [ -a ] [ -f ] [ -T ]
+       [ -D depth] [ -t tempdir ] <archive>/<branch> [ <archive>/<branch> ]
 
 Imports a project from one or more Arch repositories. It will follow branches
 and repositories within the namespaces defined by the <archive/branch>
 parameters supplied. If it cannot find the remote branch a merge comes from
-it will just import it as a regular commit. If it can find it, it will mark it 
+it will just import it as a regular commit. If it can find it, it will mark it
 as a merge whenever possible.
 
 See man (1) git-archimport for more details.
@@ -25,14 +25,14 @@ See man (1) git-archimport for more details.
  - create tag objects instead of ref tags
  - audit shell-escaping of filenames
  - hide our private tags somewhere smarter
- - find a way to make "cat *patches | patch" safe even when patchfiles are missing newlines  
+ - find a way to make "cat *patches | patch" safe even when patchfiles are missing newlines
  - sort and apply patches by graphing ancestry relations instead of just
    relying in dates supplied in the changeset itself.
    tla ancestry-graph -m could be helpful here...
 
 =head1 Devel tricks
 
-Add print in front of the shell commands invoked via backticks. 
+Add print in front of the shell commands invoked via backticks.
 
 =head1 Devel Notes
 
@@ -126,16 +126,16 @@ sub do_abrowse {
     my $stage = shift;
     while (my ($limit, $level) = each %arch_branches) {
         next unless $level == $stage;
-        
-       open ABROWSE, "$TLA abrowse -fkD --merges $limit |" 
+
+       open ABROWSE, "$TLA abrowse -fkD --merges $limit |"
                                 or die "Problems with tla abrowse: $!";
-    
+
         my %ps        = ();         # the current one
         my $lastseen  = '';
-    
+
         while (<ABROWSE>) {
             chomp;
-            
+
             # first record padded w 8 spaces
             if (s/^\s{8}\b//) {
                 my ($id, $type) = split(m/\s+/, $_, 2);
@@ -147,13 +147,13 @@ sub do_abrowse {
                     push (@psets, \%last_ps);
                     $psets{ $last_ps{id} } = \%last_ps;
                 }
-                
+
                 my $branch = extract_versionname($id);
                 %ps = ( id => $id, branch => $branch );
                 if (%last_ps && ($last_ps{branch} eq $branch)) {
                     $ps{parent_id} = $last_ps{id};
                 }
-                
+
                 $arch_branches{$branch} = 1;
                 $lastseen = 'id';
 
@@ -166,16 +166,16 @@ sub do_abrowse {
                     $ps{type} = 't';
                     # read which revision we've tagged when we parse the log
                     $ps{tag}  = $1;
-                } else { 
+                } else {
                     warn "Unknown type $type";
                 }
 
                 $arch_branches{$branch} = 1;
                 $lastseen = 'id';
-            } elsif (s/^\s{10}//) { 
-                # 10 leading spaces or more 
+            } elsif (s/^\s{10}//) {
+                # 10 leading spaces or more
                 # indicate commit metadata
-                
+
                 # date
                 if ($lastseen eq 'id' && m/^(\d{4}-\d\d-\d\d \d\d:\d\d:\d\d)/){
                     $ps{date}   = $1;
@@ -186,12 +186,12 @@ sub do_abrowse {
                 } elsif ($lastseen eq 'merges' && s/^\s{2}//) {
                     my $id = $_;
                     push (@{$ps{merges}}, $id);
-                   
+
                     # aggressive branch finding:
                     if ($opt_D) {
                         my $branch = extract_versionname($id);
                         my $repo = extract_reponame($branch);
-                        
+
                         if (archive_reachable($repo) &&
                                 !defined $arch_branches{$branch}) {
                             $arch_branches{$branch} = $stage + 1;
@@ -208,10 +208,10 @@ sub do_abrowse {
             if (@psets && $psets[$#psets]{branch} eq $ps{branch}) {
                 $temp{parent_id} = $psets[$#psets]{id};
             }
-            push (@psets, \%temp);  
+            push (@psets, \%temp);
             $psets{ $temp{id} } = \%temp;
-        }    
-        
+        }
+
         close ABROWSE or die "$TLA abrowse failed on $limit\n";
     }
 }                               # end foreach $root
@@ -253,7 +253,7 @@ unless (-d $git_dir) { # initial import
     while (my $file = readdir(DIR)) {
         # skip non-interesting-files
         next unless -f "$ptag_dir/$file";
-   
+
         # convert first '--' to '/' from old git-archimport to use
         # as an archivename/c--b--v private tag
         if ($file !~ m!,!) {
@@ -275,7 +275,7 @@ sub extract_reponame {
     my $fq_cvbr = shift; # archivename/[[[[category]branch]version]revision]
     return (split(/\//, $fq_cvbr))[0];
 }
+
 sub extract_versionname {
     my $name = shift;
     $name =~ s/--(?:patch|version(?:fix)?|base)-\d+$//;
@@ -283,7 +283,7 @@ sub extract_versionname {
 }
 
 # convert a fully-qualified revision or version to a unique dirname:
-#   normalperson@yhbt.net-05/mpd--uclinux--1--patch-2 
+#   normalperson@yhbt.net-05/mpd--uclinux--1--patch-2
 # becomes: normalperson@yhbt.net-05,mpd--uclinux--1
 #
 # the git notion of a branch is closer to
@@ -339,7 +339,7 @@ sub git_branchname {
 
 sub process_patchset_accurate {
     my $ps = shift;
-    
+
     # switch to that branch if we're not already in that branch:
     if (-e "$git_dir/refs/heads/$ps->{branch}") {
        system('git-checkout','-f',$ps->{branch}) == 0 or die "$! $?\n";
@@ -348,7 +348,7 @@ sub process_patchset_accurate {
        my $rm = safe_pipe_capture('git-ls-files','--others','-z');
        rmtree(split(/\0/,$rm)) if $rm;
     }
-    
+
     # Apply the import/changeset/merge into the working tree
     my $dir = sync_to_ps($ps);
     # read the new log entry:
@@ -361,9 +361,9 @@ sub process_patchset_accurate {
     parselog($ps, \@commitlog);
 
     if ($ps->{id} =~ /--base-0$/ && $ps->{id} ne $psets[0]{id}) {
-        # this should work when importing continuations 
+        # this should work when importing continuations
         if ($ps->{tag} && (my $branchpoint = eval { ptag($ps->{tag}) })) {
-            
+
             # find where we are supposed to branch from
            if (! -e "$git_dir/refs/heads/$ps->{branch}") {
                system('git-branch',$ps->{branch},$branchpoint) == 0 or die "$! $?\n";
@@ -388,8 +388,8 @@ sub process_patchset_accurate {
         }
         # allow multiple bases/imports here since Arch supports cherry-picks
         # from unrelated trees
-    } 
-    
+    }
+
     # update the index with all the changes we got
     system('git-diff-files --name-only -z | '.
             'git-update-index --remove -z --stdin') == 0 or die "$! $?\n";
@@ -402,7 +402,7 @@ sub process_patchset_accurate {
 # does not handle permissions or any renames involving directories
 sub process_patchset_fast {
     my $ps = shift;
-    # 
+    #
     # create the branch if needed
     #
     if ($ps->{type} eq 'i' && !$import) {
@@ -417,9 +417,9 @@ sub process_patchset_fast {
             # 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}" 
+            die "Tagging from unknown id unsupported: $ps->{tag}"
                 unless $branchpoint;
-            
+
             # find where we are supposed to branch from
            if (! -e "$git_dir/refs/heads/$ps->{branch}") {
                system('git-branch',$ps->{branch},$branchpoint) == 0 or die "$! $?\n";
@@ -435,13 +435,13 @@ sub process_patchset_fast {
             }
             system('git-checkout',$ps->{branch}) == 0 or die "$! $?\n";
             return 0;
-        } 
+        }
         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 $!;
         $stats{import_or_tag}++;
@@ -455,10 +455,10 @@ sub process_patchset_fast {
     # prepare update git's index, based on what arch knows
     # about the pset, resolve parents, etc
     #
-    
-    my @commitlog = safe_pipe_capture($TLA,'cat-archive-log',$ps->{id}); 
+
+    my @commitlog = safe_pipe_capture($TLA,'cat-archive-log',$ps->{id});
     die "Error in cat-archive-log: $!" if $?;
-        
+
     parselog($ps,\@commitlog);
 
     # imports don't give us good info
@@ -485,10 +485,10 @@ sub process_patchset_fast {
         if (@$ren % 2) {
             die "Odd number of entries in rename!?";
         }
-        
+
         while (@$ren) {
             my $from = shift @$ren;
-            my $to   = shift @$ren;           
+            my $to   = shift @$ren;
 
             unless (-d dirname($to)) {
                 mkpath(dirname($to)); # will die on err
@@ -529,20 +529,20 @@ if ($opt_f) {
             "Things may be a bit slow\n";
     *process_patchset = *process_patchset_accurate;
 }
-    
+
 foreach my $ps (@psets) {
     # process patchsets
     $ps->{branch} = git_branchname($ps->{id});
 
     #
-    # ensure we have a clean state 
-    # 
+    # ensure we have a clean state
+    #
     if (my $dirty = `git-diff-files`) {
         die "Unclean tree when about to process $ps->{id} " .
             " - did we fail to commit cleanly before?\n$dirty";
     }
     die $! if $?;
-    
+
     #
     # skip commits already in repo
     #
@@ -559,7 +559,7 @@ foreach my $ps (@psets) {
     my $tree = `git-write-tree`;
     die "cannot write tree $!" if $?;
     chomp $tree;
-    
+
     #
     # Who's your daddy?
     #
@@ -570,18 +570,18 @@ foreach my $ps (@psets) {
             close HEAD;
             chomp $p;
             push @par, '-p', $p;
-        } else { 
+        } else {
             if ($ps->{type} eq 's') {
                 warn "Could not find the right head for the branch $ps->{branch}";
             }
         }
     }
-    
+
     if ($ps->{merges}) {
         push @par, find_parents($ps);
     }
 
-    #    
+    #
     # Commit, tag and clean state
     #
     $ENV{TZ}                  = 'GMT';
@@ -592,14 +592,14 @@ foreach my $ps (@psets) {
     $ENV{GIT_COMMITTER_EMAIL} = $ps->{email};
     $ENV{GIT_COMMITTER_DATE}  = $ps->{date};
 
-    my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) 
+    my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par)
         or die $!;
     print WRITER $ps->{summary},"\n\n";
     print WRITER $ps->{message},"\n";
-    
+
     # make it easy to backtrack and figure out which Arch revision this was:
     print WRITER 'git-archimport-id: ',$ps->{id},"\n";
-    
+
     close WRITER;
     my $commitid = <READER>;    # read
     chomp $commitid;
@@ -611,7 +611,7 @@ foreach my $ps (@psets) {
     }
     #
     # Update the branch
-    # 
+    #
     open  HEAD, ">","$git_dir/refs/heads/$ps->{branch}";
     print HEAD $commitid;
     close HEAD;
@@ -640,7 +640,7 @@ exit 0;
 sub sync_to_ps {
     my $ps = shift;
     my $tree_dir = $tmp.'/'.tree_dirname($ps->{id});
-    
+
     $opt_v && print "sync_to_ps($ps->{id}) method: ";
 
     if (-d $tree_dir) {
@@ -674,7 +674,7 @@ sub sync_to_ps {
         safe_pipe_capture($TLA,'get','--no-pristine',$ps->{id},$tree_dir);
         $stats{get_new}++;
     }
-   
+
     # added -I flag to rsync since we're going to fast! AIEEEEE!!!!
     system('rsync','-aI','--delete','--exclude',$git_dir,
 #               '--exclude','.arch-inventory',
@@ -691,15 +691,15 @@ sub apply_import {
     mkpath($tmp);
 
     safe_pipe_capture($TLA,'get','-s','--no-pristine',$ps->{id},"$tmp/import");
-    die "Cannot get import: $!" if $?;    
+    die "Cannot get import: $!" if $?;
     system('rsync','-aI','--delete', '--exclude',$git_dir,
                '--exclude','.arch-ids','--exclude','{arch}',
                "$tmp/import/", './');
     die "Cannot rsync import:$!" if $?;
-    
+
     rmtree("$tmp/import");
     die "Cannot remove tempdir: $!" if $?;
-    
+
 
     return 1;
 }
@@ -712,13 +712,13 @@ sub apply_cset {
     # get the changeset
     safe_pipe_capture($TLA,'get-changeset',$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 can get mucked up by patches
-        # with missing trailing newlines or the standard 
+        # 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
@@ -741,7 +741,7 @@ sub apply_cset {
 
     # bring in new files
     system('rsync','-aI','--exclude',$git_dir,
-               '--exclude','.arch-ids',
+               '--exclude','.arch-ids',
                '--exclude', '{arch}',
                "$tmp/changeset/new-files-archive/",'./');
 
@@ -789,7 +789,7 @@ sub parselog {
         removed_files => 1,
         removed_directories => 1,
     );
-    
+
     chomp (@$log);
     while ($_ = shift @$log) {
         if (/^Continuation-of:\s*(.*)/) {
@@ -828,7 +828,7 @@ sub parselog {
             }
         }
     }
-   
+
     # drop leading empty lines from the log message
     while (@$log && $log->[0] eq '') {
        shift @$log;
@@ -842,7 +842,7 @@ sub parselog {
        $ps->{summary} = $log->[0] . '...';
     }
     $ps->{message} = join("\n",@$log);
-    
+
     # skip Arch control files, unescape pika-escaped files
     foreach my $k (keys %want_headers) {
         next unless (defined $ps->{$k});
@@ -867,7 +867,7 @@ sub parselog {
 # write/read a tag
 sub tag {
     my ($tag, $commit) = @_;
+
     if ($opt_o) {
         $tag =~ s|/|--|g;
     } else {
@@ -875,7 +875,7 @@ sub tag {
        $patchname =~ s/.*--//;
         $tag = git_branchname ($tag) . '--' . $patchname;
     }
-    
+
     if ($commit) {
         open(C,">","$git_dir/refs/tags/$tag")
             or die "Cannot create tag $tag: $!\n";
@@ -902,8 +902,8 @@ sub ptag {
     my ($tag, $commit) = @_;
 
     # don't use subdirs for tags yet, it could screw up other porcelains
-    $tag =~ s|/|,|g; 
-    
+    $tag =~ s|/|,|g;
+
     my $tag_file = "$ptag_dir/$tag";
     my $tag_branch_dir = dirname($tag_file);
     mkpath($tag_branch_dir) unless (-d $tag_branch_dir);
@@ -915,7 +915,7 @@ sub ptag {
             or die "Cannot write tag $tag: $!\n";
         close(C)
             or die "Cannot write tag $tag: $!\n";
-       $rptags{$commit} = $tag 
+       $rptags{$commit} = $tag
            unless $tag =~ m/--base-0$/;
     } else {                    # read
         # if the tag isn't there, return 0
@@ -941,7 +941,7 @@ sub find_parents {
     # Identify what branches are merging into me
     # and whether we are fully merged
     # git-merge-base <headsha> <headsha> should tell
-    # me what the base of the merge should be 
+    # me what the base of the merge should be
     #
     my $ps = shift;
 
@@ -963,14 +963,14 @@ sub find_parents {
     }
 
     #
-    # foreach branch find a merge base and walk it to the 
+    # foreach branch find a merge base and walk it to the
     # head where we are, collecting the merged patchsets that
     # Arch has recorded. Keep that in @have
     # Compare that with the commits on the other branch
     # between merge-base and the tip of the branch (@need)
     # and see if we have a series of consecutive patches
     # starting from the merge base. The tip of the series
-    # of consecutive patches merged is our new parent for 
+    # of consecutive patches merged is our new parent for
     # that branch.
     #
     foreach my $branch (keys %branches) {
@@ -979,13 +979,13 @@ sub find_parents {
        next unless -e "$git_dir/refs/heads/$branch";
 
        my $mergebase = `git-merge-base $branch $ps->{branch}`;
-       if ($?) { 
-           # Don't die here, Arch supports one-way cherry-picking
-           # between branches with no common base (or any relationship
-           # at all beforehand)
-           warn "Cannot find merge base for $branch and $ps->{branch}";
-           next;
-       }
+       if ($?) {
+           # Don't die here, Arch supports one-way cherry-picking
+           # between branches with no common base (or any relationship
+           # at all beforehand)
+           warn "Cannot find merge base for $branch and $ps->{branch}";
+           next;
+       }
        chomp $mergebase;
 
        # now walk up to the mergepoint collecting what patches we have
@@ -1010,7 +1010,7 @@ sub find_parents {
        # merge what we have with what ancestors have
        %have = (%have, %ancestorshave);
 
-       # see what the remote branch has - these are the merges we 
+       # see what the remote branch has - these are the merges we
        # will want to have in a consecutive series from the mergebase
        my $otherbranchtip = git_rev_parse($branch);
        my @needraw = `git-rev-list --topo-order $otherbranchtip ^$mergebase`;
@@ -1018,7 +1018,7 @@ sub find_parents {
        foreach my $needps (@needraw) {         # get the psets
            $needps = commitid2pset($needps);
            # git-rev-list will also
-           # list commits merged in via earlier 
+           # list commits merged in via earlier
            # merges. we are only interested in commits
            # from the branch we're looking at
            if ($branch eq $needps->{branch}) {
@@ -1054,7 +1054,7 @@ sub find_parents {
        next unless ref    $psets{$p}{merges};
        my @merges = @{$psets{$p}{merges}};
        foreach my $merge (@merges) {
-           if ($parents{$merge}) { 
+           if ($parents{$merge}) {
                delete $parents{$merge};
            }
        }
@@ -1079,10 +1079,10 @@ sub git_rev_parse {
 sub commitid2pset {
     my $commitid = shift;
     chomp $commitid;
-    my $name = $rptags{$commitid} 
+    my $name = $rptags{$commitid}
        || die "Cannot find reverse tag mapping for $commitid";
     $name =~ s|,|/|;
-    my $ps   = $psets{$name} 
+    my $ps   = $psets{$name}
        || (print Dumper(sort keys %psets)) && die "Cannot find patchset for $name";
     return $ps;
 }
@@ -1112,7 +1112,7 @@ sub archive_reachable {
     my $archive = shift;
     return 1 if $reachable{$archive};
     return 0 if $unreachable{$archive};
-    
+
     if (system "$TLA whereis-archive $archive >/dev/null") {
         if ($opt_a && (system($TLA,'register-archive',
                       "http://mirrors.sourcecontrol.net/$archive") == 0)) {
@@ -1127,4 +1127,3 @@ sub archive_reachable {
         return 1;
     }
 }
-
index 7c5ca3d62f85b78ec82f02c2045435d889c32cdd..33f1e87c0c209b89eb785381db62d826818b602d 100755 (executable)
@@ -211,7 +211,7 @@ else
        esac
 
        # Match the index to the working tree, and do a three-way.
-       git diff-files --name-only | git update-index --remove --stdin &&
+       git diff-files --name-only | git update-index --remove --stdin &&
        work=`git write-tree` &&
        git read-tree $v --reset -u $new || exit
 
@@ -246,7 +246,7 @@ else
     (exit $saved_err)
 fi
 
-# 
+#
 # Switch the HEAD pointer to the new branch if we
 # checked out a branch head, and remove any potential
 # old MERGE_HEAD's (subsequent commits will clearly not
@@ -271,15 +271,7 @@ if [ "$?" -eq 0 ]; then
                fi
        elif test -n "$detached"
        then
-               # NEEDSWORK: we would want a command to detach the HEAD
-               # atomically, instead of this handcrafted command sequence.
-               # Perhaps:
-               #       git update-ref --detach HEAD $new
-               # or something like that...
-               #
-               git-rev-parse HEAD >"$GIT_DIR/HEAD.new" &&
-               mv "$GIT_DIR/HEAD.new" "$GIT_DIR/HEAD" &&
-               git-update-ref -m "checkout: moving to $arg" HEAD "$detached" ||
+               git-update-ref --no-deref -m "checkout: moving to $arg" HEAD "$detached" ||
                        die "Cannot detach HEAD"
                if test -n "$detach_warn"
                then
index fdd354f2da1978241a3e79a47a067496150cc1bc..3a410624d374e9d02b305a25469176e4d4e725e6 100755 (executable)
@@ -2,7 +2,7 @@
 #
 # Copyright (c) 2005, Linus Torvalds
 # Copyright (c) 2005, Junio C Hamano
-# 
+#
 # Clone a repository into a different directory that does not yet exist.
 
 # See git-sh-setup why.
@@ -20,7 +20,7 @@ usage() {
 get_repo_base() {
        (
                cd "`/bin/pwd`" &&
-               cd "$1" &&
+               cd "$1" || cd "$1.git" &&
                {
                        cd .git
                        pwd
@@ -98,7 +98,7 @@ while
        *,--na|*,--nak|*,--nake|*,--naked|\
        *,-b|*,--b|*,--ba|*,--bar|*,--bare) bare=yes ;;
        *,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;;
-        *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) 
+        *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared)
           local_shared=yes; use_local=yes ;;
        1,--template) usage ;;
        *,--template)
@@ -410,4 +410,3 @@ fi
 rm -f "$GIT_DIR/CLONE_HEAD" "$GIT_DIR/REMOTE_HEAD"
 
 trap - 0
-
index e8b60f70497c71bd66b96115b9bba78cee523a8c..5547a02954b23425e644d0b30ae6047afa393ac0 100755 (executable)
@@ -557,7 +557,7 @@ then
        } >>"$GIT_DIR"/COMMIT_EDITMSG
 else
        # we need to check if there is anything to commit
-       run_status >/dev/null 
+       run_status >/dev/null
 fi
 if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" -a -z "$amend" ]
 then
index d6ae99b8c00c278f6e4b0190dfb892b857f27103..e9832d2bb913d61ce8a92ddf32e009ad59659d53 100755 (executable)
@@ -15,9 +15,9 @@ unless ($ENV{GIT_DIR} && -r $ENV{GIT_DIR}){
     die "GIT_DIR is not defined or is unreadable";
 }
 
-our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d);
+our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d, $opt_u);
 
-getopts('hPpvcfam:d:');
+getopts('uhPpvcfam:d:');
 
 $opt_h && usage();
 
@@ -178,6 +178,10 @@ foreach my $f (@files) {
 
 my %cvsstat;
 if (@canstatusfiles) {
+    if ($opt_u) {
+      my @updated = safe_pipe_capture(@cvs, 'update', @canstatusfiles);
+      print @updated;
+    }
     my @cvsoutput;
     @cvsoutput= safe_pipe_capture(@cvs, 'status', @canstatusfiles);
     my $matchcount = 0;
@@ -193,7 +197,7 @@ if (@canstatusfiles) {
 # ... validate new files,
 foreach my $f (@afiles) {
     if (defined ($cvsstat{$f}) and $cvsstat{$f} ne "Unknown") {
-       $dirty = 1;
+       $dirty = 1;
        warn "File $f is already known in your CVS checkout -- perhaps it has been added by another user. Or this may indicate that it exists on a different branch. If this is the case, use -f to force the merge.\n";
        warn "Status was: $cvsstat{$f}\n";
     }
index 4e6c9c6cc7c1fbbf69c455d6095cc8d18c81de16..3225a2a25dcaabbae64754e99a550f5b210f3765 100755 (executable)
@@ -145,7 +145,7 @@ my $cvs_tree;
 if ($#ARGV == 0) {
        $cvs_tree = $ARGV[0];
 } elsif (-f 'CVS/Repository') {
-       open my $f, '<', 'CVS/Repository' or 
+       open my $f, '<', 'CVS/Repository' or
            die 'Failed to open CVS/Repository';
        $cvs_tree = <$f>;
        chomp $cvs_tree;
@@ -434,7 +434,7 @@ sub file {
        my ($self,$fn,$rev) = @_;
        my $res;
 
-       my ($fh, $name) = tempfile('gitcvs.XXXXXX', 
+       my ($fh, $name) = tempfile('gitcvs.XXXXXX',
                    DIR => File::Spec->tmpdir(), UNLINK => 1);
 
        $self->_file($fn,$rev) and $res = $self->_line($fh);
@@ -520,8 +520,8 @@ sub is_sha1 {
 
 sub get_headref ($$) {
     my $name    = shift;
-    my $git_dir = shift; 
-    
+    my $git_dir = shift;
+
     my $f = "$git_dir/refs/heads/$name";
     if (open(my $fh, $f)) {
            chomp(my $r = <$fh>);
@@ -771,7 +771,7 @@ sub commit {
                $xtag =~ s/\s+\*\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **
                $xtag =~ tr/_/\./ if ( $opt_u );
                $xtag =~ s/[\/]/$opt_s/g;
-               
+
                my $pid = open2($in, $out, 'git-mktag');
                print $out "object $cid\n".
                    "type commit\n".
@@ -788,7 +788,7 @@ sub commit {
                     $? != 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";
index 1de517791f8a293a9c770f6260ff48f9719845ad..d41b29f30b6f07429b227fc4e07fffdcb292bbee 100755 (executable)
@@ -95,9 +95,10 @@ $state->{method} = 'ext';
 if (@ARGV && $ARGV[0] eq 'pserver') {
     $state->{method} = 'pserver';
     my $line = <STDIN>; chomp $line;
-    unless( $line eq 'BEGIN AUTH REQUEST') {
+    unless( $line =~ /^BEGIN (AUTH|VERIFICATION) REQUEST$/) {
        die "E Do not understand $line - expecting BEGIN AUTH REQUEST\n";
     }
+    my $request = $1;
     $line = <STDIN>; chomp $line;
     req_Root('root', $line) # reuse Root
        or die "E Invalid root $line \n";
@@ -109,10 +110,11 @@ if (@ARGV && $ARGV[0] eq 'pserver') {
     }
     $line = <STDIN>; chomp $line;    # validate the password?
     $line = <STDIN>; chomp $line;
-    unless ($line eq 'END AUTH REQUEST') {
-       die "E Do not understand $line -- expecting END AUTH REQUEST\n";
+    unless ($line eq "END $request REQUEST") {
+       die "E Do not understand $line -- expecting END $request REQUEST\n";
     }
     print "I LOVE YOU\n";
+    exit if $request eq 'VERIFICATION'; # cvs login
     # and now back to our regular programme...
 }
 
@@ -165,6 +167,17 @@ sub req_Root
     my ( $cmd, $data ) = @_;
     $log->debug("req_Root : $data");
 
+    unless ($data =~ m#^/#) {
+       print "error 1 Root must be an absolute pathname\n";
+       return 0;
+    }
+
+    if ($state->{CVSROOT}
+       && ($state->{CVSROOT} ne $data)) {
+       print "error 1 Conflicting roots specified\n";
+       return 0;
+    }
+
     $state->{CVSROOT} = $data;
 
     $ENV{GIT_DIR} = $state->{CVSROOT} . "/";
index 0e05cf1195737d2c7afc4b9447d7b4105908bf77..6d3a3468b3f22d8eeb1a2ba568a6c8ed48606dbd 100755 (executable)
@@ -61,7 +61,7 @@ do
                quiet=--quiet
                ;;
        -v|--verbose)
-               verbose=Yes
+               verbose="$verbose"Yes
                ;;
        -k|--k|--ke|--kee|--keep)
                keep='-k -k'
@@ -201,8 +201,14 @@ fetch_all_at_once () {
                        echo "$ls_remote_result" | \
                                git-fetch--tool pick-rref "$rref" "-"
                else
+                       flags=
+                       case $verbose in
+                       YesYes*)
+                           flags="-v"
+                           ;;
+                       esac
                        git-fetch-pack --thin $exec $keep $shallow_depth \
-                               $quiet $no_progress "$remote" $rref ||
+                               $quiet $no_progress $flags "$remote" $rref ||
                        echo failed "$remote"
                fi
        fi
index 25647c8060d8e30ef48d972e487dc9b280266b88..eee495a98666094415233a7023c03db9852dfe53 100755 (executable)
@@ -78,5 +78,3 @@ test "$VN" = "$VC" || {
        echo >&2 "GITGUI_VERSION = $VN"
        echo "GITGUI_VERSION = $VN" >$GVF
 }
-
-
index 88b056522a866b3acc9620218ec8dfae042d62a2..72494c1a1ea51ec004a63f08f2c62db9096c2318 100644 (file)
@@ -151,4 +151,3 @@ auto_mkindex_parser::command constructor {name args} {
                [format { [list source [file join $dir %s]]} \
                [file split $scriptFile]] "\n"
 }
-
index 7d62d7902cb1d7cd2749091b86d532306bea89b3..254d210bdca128089da453988175e2324b837a85 100755 (executable)
@@ -88,7 +88,7 @@ case "${1:-.}${2:-.}${3:-.}" in
                # remove lines that are unique to ours.
                orig=`git-unpack-file $2`
                sz0=`wc -c <"$orig"`
-               diff -u -La/$orig -Lb/$orig $orig $src2 | git-apply --no-add 
+               diff -u -La/$orig -Lb/$orig $orig $src2 | git-apply --no-add
                sz1=`wc -c <"$orig"`
 
                # If we do not have enough common material, it is not
index b2f8a2acd398b7c61b68a59c6d3631ca84be0727..981d69d35f4e6349d99192996af3b793071a6172 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Junio C Hamano
 #
 
-USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+'
+USAGE='[-n] [--summary] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+'
 
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
@@ -88,11 +88,11 @@ finish () {
        '')
                ;;
        ?*)
-               case "$no_summary" in
-               '')
-                       git-diff-tree --stat --summary -M "$head" "$1"
-                       ;;
-               esac
+               if test "$show_diffstat" = t
+               then
+                       # We want color (if set), but no pager
+                       GIT_PAGER='' git-diff --stat --summary -M "$head" "$1"
+               fi
                ;;
        esac
 }
@@ -125,7 +125,9 @@ do
        case "$1" in
        -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
                --no-summa|--no-summar|--no-summary)
-               no_summary=t ;;
+               show_diffstat=false ;;
+       --summary)
+               show_diffstat=t ;;
        --sq|--squ|--squa|--squas|--squash)
                squash=t no_commit=t ;;
        --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
@@ -167,6 +169,11 @@ do
        shift
 done
 
+if test -z "$show_diffstat"; then
+    test "$(git-config --bool merge.diffstat)" = false && show_diffstat=false
+    test -z "$show_diffstat" && show_diffstat=t
+fi
+
 # This could be traditional "merge <msg> HEAD <commit>..."  and the
 # way we can tell it is to see if the second token is HEAD, but some
 # people might have misused the interface and used a committish that
index e62351bcbabc00a3d89ddf1c8dd936cea400501f..7b663091935fd83e5985e5d8b9763cafecc0947d 100755 (executable)
@@ -5,7 +5,7 @@
 # Copyright (c) 2006 Theodore Y. Ts'o
 #
 # This file is licensed under the GPL v2, or a later version
-# at the discretion of Junio C Hammano.
+# at the discretion of Junio C Hamano.
 #
 
 USAGE='[--tool=tool] [file to merge] ...'
@@ -215,6 +215,12 @@ merge_file () {
            check_unchanged
            save_backup
            ;;
+       gvimdiff)
+               touch "$BACKUP"
+               gvimdiff -f -- "$LOCAL" "$path" "$REMOTE"
+               check_unchanged
+               save_backup
+               ;;
        xxdiff)
            touch "$BACKUP"
            if base_present ; then
@@ -293,7 +299,7 @@ done
 if test -z "$merge_tool"; then
     merge_tool=`git-config merge.tool`
     case "$merge_tool" in
-       kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | "")
+       kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | "")
            ;; # happy
        *)
            echo >&2 "git config option merge.tool set to unknown tool: $merge_tool"
@@ -304,28 +310,42 @@ if test -z "$merge_tool"; then
 fi
 
 if test -z "$merge_tool" ; then
-    if type kdiff3 >/dev/null 2>&1 && test -n "$DISPLAY"; then
-       merge_tool="kdiff3";
-    elif type tkdiff >/dev/null 2>&1 && test -n "$DISPLAY"; then
-       merge_tool=tkdiff
-    elif type xxdiff >/dev/null 2>&1 && test -n "$DISPLAY"; then
-       merge_tool=xxdiff
-    elif type meld >/dev/null 2>&1 && test -n "$DISPLAY"; then
-       merge_tool=meld
-    elif type opendiff >/dev/null 2>&1; then
-       merge_tool=opendiff
-    elif type emacs >/dev/null 2>&1; then
-       merge_tool=emerge
-    elif type vimdiff >/dev/null 2>&1; then
-       merge_tool=vimdiff
-    else
+    if test -n "$DISPLAY"; then
+        merge_tool_candidates="kdiff3 tkdiff xxdiff meld gvimdiff"
+        if test -n "$GNOME_DESKTOP_SESSION_ID" ; then
+            merge_tool_candidates="meld $merge_tool_candidates"
+        fi
+        if test "$KDE_FULL_SESSION" = "true"; then
+            merge_tool_candidates="kdiff3 $merge_tool_candidates"
+        fi
+    fi
+    if echo "${VISUAL:-$EDITOR}" | grep 'emacs' > /dev/null 2>&1; then
+        merge_tool_candidates="$merge_tool_candidates emerge"
+    fi
+    if echo "${VISUAL:-$EDITOR}" | grep 'vim' > /dev/null 2>&1; then
+        merge_tool_candidates="$merge_tool_candidates vimdiff"
+    fi
+    merge_tool_candidates="$merge_tool_candidates opendiff emerge vimdiff"
+    echo "merge tool candidates: $merge_tool_candidates"
+    for i in $merge_tool_candidates; do
+        if test $i = emerge ; then
+            cmd=emacs
+        else
+            cmd=$i
+        fi
+        if type $cmd > /dev/null 2>&1; then
+            merge_tool=$i
+            break
+        fi
+    done
+    if test -z "$merge_tool" ; then
        echo "No available merge resolution programs available."
        exit 1
     fi
 fi
 
 case "$merge_tool" in
-    kdiff3|tkdiff|meld|xxdiff|vimdiff|opendiff)
+    kdiff3|tkdiff|meld|xxdiff|vimdiff|gvimdiff|opendiff)
        if ! type "$merge_tool" > /dev/null 2>&1; then
            echo "The merge tool $merge_tool is not available"
            exit 1
index 60a758bfe3bf535733612d4a0843fb42055f4c80..0f3d97b67eef3108728265e26f5d79c4526d11ac 100644 (file)
@@ -358,4 +358,3 @@ for id in changes:
     if stitch == 1:
         git.clean_directories()
         stitch = 0
-
index a3665d7751cc836dc669390df7b972c29575037b..ba0ca079e204a464ee05b6c000ed891ed3c08b33 100755 (executable)
@@ -22,6 +22,9 @@ do
        -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
                --no-summa|--no-summar|--no-summary)
                no_summary=-n ;;
+       --summary)
+               no_summary=$1
+               ;;
        --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
                no_commit=--no-commit ;;
        --sq|--squ|--squa|--squas|--squash)
index 2dc2c4fe9b4d4a7ff10398938efbed28fa6f43f7..2aa3a011dbe31e5167534a8bf443ff27dd96b38f 100755 (executable)
@@ -55,7 +55,7 @@ continue_merge () {
        if test -n "$unmerged"
        then
                echo "You still have unmerged paths in your index"
-               echo "did you forget update-index?"
+               echo "did you forget to use git add?"
                die "$RESOLVEMSG"
        fi
 
@@ -126,7 +126,7 @@ do
        --continue)
                git-diff-files --quiet || {
                        echo "You must edit all merge conflicts and then"
-                       echo "mark them as resolved using git update-index"
+                       echo "mark them as resolved using git add"
                        exit 1
                }
                if test -d "$dotest"
@@ -307,7 +307,8 @@ fi
 if test -n "$verbose"
 then
        echo "Changes from $mb to $onto:"
-       git-diff-tree --stat --summary "$mb" "$onto"
+       # We want color (if set), but no pager
+       GIT_PAGER='' git-diff --stat --summary "$mb" "$onto"
 fi
 
 # Rewind the head to "$onto"; this saves our current head in ORIG_HEAD.
index ddfa8b44a17f1ea7ff039bca1d6132ba07e5cf12..8c32724be75b77f145106f96257afccb56cfc1ef 100755 (executable)
@@ -3,12 +3,12 @@
 # Copyright (c) 2005 Linus Torvalds
 #
 
-USAGE='[-a] [-d] [-f] [-l] [-n] [-q] [--window=N] [--depth=N]'
+USAGE='[-a] [-d] [-f] [-l] [-n] [-q] [--max-pack-size=N] [--window=N] [--depth=N]'
 SUBDIRECTORY_OK='Yes'
 . git-sh-setup
 
 no_update_info= all_into_one= remove_redundant=
-local= quiet= no_reuse_delta= extra=
+local= quiet= no_reuse= extra=
 while case "$#" in 0) break ;; esac
 do
        case "$1" in
@@ -16,8 +16,9 @@ do
        -a)     all_into_one=t ;;
        -d)     remove_redundant=t ;;
        -q)     quiet=-q ;;
-       -f)     no_reuse_delta=--no-reuse-delta ;;
+       -f)     no_reuse=--no-reuse-object ;;
        -l)     local=--local ;;
+       --max-pack-size=*) extra="$extra $1" ;;
        --window=*) extra="$extra $1" ;;
        --depth=*) extra="$extra $1" ;;
        *)      usage ;;
@@ -35,7 +36,7 @@ true)
 esac
 
 PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
-PACKTMP="$GIT_DIR/.tmp-$$-pack"
+PACKTMP="$GIT_OBJECT_DIRECTORY/.tmp-$$-pack"
 rm -f "$PACKTMP"-*
 trap 'rm -f "$PACKTMP"-*' 0 1 2 3 15
 
@@ -61,12 +62,14 @@ case ",$all_into_one," in
        ;;
 esac
 
-args="$args $local $quiet $no_reuse_delta$extra"
-name=$(git-pack-objects --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
+args="$args $local $quiet $no_reuse$extra"
+names=$(git-pack-objects --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
        exit 1
-if [ -z "$name" ]; then
+if [ -z "$names" ]; then
        echo Nothing new to pack.
-else
+fi
+for name in $names ; do
+       fullbases="$fullbases pack-$name"
        chmod a-w "$PACKTMP-$name.pack"
        chmod a-w "$PACKTMP-$name.idx"
        if test "$quiet" != '-q'; then
@@ -92,7 +95,7 @@ else
                exit 1
        }
        rm -f "$PACKDIR/old-pack-$name.pack" "$PACKDIR/old-pack-$name.idx"
-fi
+done
 
 if test "$remove_redundant" = t
 then
@@ -103,8 +106,8 @@ then
                ( cd "$PACKDIR" &&
                  for e in $existing
                  do
-                       case "$e" in
-                       pack-$name) ;;
+                       case " $fullbases " in
+                       *" $e "*) ;;
                        *)      rm -f "$e.pack" "$e.idx" "$e.keep" ;;
                        esac
                  done
diff --git a/git-submodule.sh b/git-submodule.sh
new file mode 100755 (executable)
index 0000000..6ed5a6c
--- /dev/null
@@ -0,0 +1,194 @@
+#!/bin/sh
+#
+# git-submodules.sh: init, update or list git submodules
+#
+# Copyright (c) 2007 Lars Hjemli
+
+USAGE='[--quiet] [--cached] [status|init|update] [--] [<path>...]'
+. git-sh-setup
+require_work_tree
+
+init=
+update=
+status=
+quiet=
+cached=
+
+#
+# print stuff on stdout unless -q was specified
+#
+say()
+{
+       if test -z "$quiet"
+       then
+               echo "$@"
+       fi
+}
+
+#
+# Run clone + checkout on missing submodules
+#
+# $@ = requested paths (default to all)
+#
+modules_init()
+{
+       git ls-files --stage -- "$@" | grep -e '^160000 ' |
+       while read mode sha1 stage path
+       do
+               # Skip submodule paths that already contain a .git directory.
+               # This will also trigger if $path is a symlink to a git
+               # repository
+               test -d "$path"/.git && continue
+
+               # If there already is a directory at the submodule path,
+               # expect it to be empty (since that is the default checkout
+               # action) and try to remove it.
+               # Note: if $path is a symlink to a directory the test will
+               # succeed but the rmdir will fail. We might want to fix this.
+               if test -d "$path"
+               then
+                       rmdir "$path" 2>/dev/null ||
+                       die "Directory '$path' exist, but is neither empty nor a git repository"
+               fi
+
+               test -e "$path" &&
+               die "A file already exist at path '$path'"
+
+               url=$(GIT_CONFIG=.gitmodules git-config module."$path".url)
+               test -z "$url" &&
+               die "No url found for submodule '$path' in .gitmodules"
+
+               # MAYBE FIXME: this would be the place to check GIT_CONFIG
+               # for a preferred url for this submodule, possibly like this:
+               #
+               # modname=$(GIT_CONFIG=.gitmodules git-config module."$path".name)
+               # alturl=$(git-config module."$modname".url)
+               #
+               # This would let the versioned .gitmodules file use the submodule
+               # path as key, while the unversioned GIT_CONFIG would use the
+               # logical modulename (if present) as key. But this would need
+               # another fallback mechanism if the module wasn't named.
+
+               git-clone -n "$url" "$path" ||
+               die "Clone of submodule '$path' failed"
+
+               (unset GIT_DIR && cd "$path" && git-checkout -q "$sha1") ||
+               die "Checkout of submodule '$path' failed"
+
+               say "Submodule '$path' initialized"
+       done
+}
+
+#
+# Checkout correct revision of each initialized submodule
+#
+# $@ = requested paths (default to all)
+#
+modules_update()
+{
+       git ls-files --stage -- "$@" | grep -e '^160000 ' |
+       while read mode sha1 stage path
+       do
+               if ! test -d "$path"/.git
+               then
+                       # Only mention uninitialized submodules when its
+                       # path have been specified
+                       test "$#" != "0" &&
+                       say "Submodule '$path' not initialized"
+                       continue;
+               fi
+               subsha1=$(unset GIT_DIR && cd "$path" &&
+                       git-rev-parse --verify HEAD) ||
+               die "Unable to find current revision of submodule '$path'"
+
+               if test "$subsha1" != "$sha1"
+               then
+                       (unset GIT_DIR && cd "$path" && git-fetch &&
+                               git-checkout -q "$sha1") ||
+                       die "Unable to checkout '$sha1' in submodule '$path'"
+
+                       say "Submodule '$path': checked out '$sha1'"
+               fi
+       done
+}
+
+#
+# List all registered submodules, prefixed with:
+#  - submodule not initialized
+#  + different revision checked out
+#
+# If --cached was specified the revision in the index will be printed
+# instead of the currently checked out revision.
+#
+# $@ = requested paths (default to all)
+#
+modules_list()
+{
+       git ls-files --stage -- "$@" | grep -e '^160000 ' |
+       while read mode sha1 stage path
+       do
+               if ! test -d "$path"/.git
+               then
+                       say "-$sha1 $path"
+                       continue;
+               fi
+               revname=$(unset GIT_DIR && cd "$path" && git-describe $sha1)
+               if git diff-files --quiet -- "$path"
+               then
+                       say " $sha1 $path ($revname)"
+               else
+                       if test -z "$cached"
+                       then
+                               sha1=$(unset GIT_DIR && cd "$path" && git-rev-parse --verify HEAD)
+                               revname=$(unset GIT_DIR && cd "$path" && git-describe $sha1)
+                       fi
+                       say "+$sha1 $path ($revname)"
+               fi
+       done
+}
+
+while case "$#" in 0) break ;; esac
+do
+       case "$1" in
+       init)
+               init=1
+               ;;
+       update)
+               update=1
+               ;;
+       status)
+               status=1
+               ;;
+       -q|--quiet)
+               quiet=1
+               ;;
+       --cached)
+               cached=1
+               ;;
+       --)
+               break
+               ;;
+       -*)
+               usage
+               ;;
+       *)
+               break
+               ;;
+       esac
+       shift
+done
+
+case "$init,$update,$status,$cached" in
+1,,,)
+       modules_init "$@"
+       ;;
+,1,,)
+       modules_update "$@"
+       ;;
+,,*,*)
+       modules_list "$@"
+       ;;
+*)
+       usage
+       ;;
+esac
index 3af8c7e1106d755b1589750ff5673ff6a6cd3b14..f4597626b955252fa7cfc092d8bb041cc3887345 100755 (executable)
@@ -542,7 +542,7 @@ sub copy_path($$$$$$$$) {
        if ($node_kind eq $SVN::Node::dir) {
                $srcpath =~ s#/*$#/#;
        }
-       
+
        my $pid = open my $f,'-|';
        die $! unless defined $pid;
        if (!$pid) {
@@ -560,7 +560,7 @@ sub copy_path($$$$$$$$) {
                } else {
                        $p = $path;
                }
-               push(@$new,[$mode,$sha1,$p]);   
+               push(@$new,[$mode,$sha1,$p]);
        }
        close($f) or
                print STDERR "$newrev:$newbranch: could not list files in $oldpath \@ $rev\n";
index 6f0b7a72192bbeb7ca4693f40f80e2bd20d5eb03..c84043902f9fcaf7c09846b9fd68986bd7fc5108 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Copyright (c) 2005 Linus Torvalds
 
-USAGE='-l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'
+USAGE='[-n [<num>]] -l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'
 SUBDIRECTORY_OK='Yes'
 . git-sh-setup
 
@@ -13,6 +13,7 @@ message=
 username=
 list=
 verify=
+LINES=0
 while case "$#" in 0) break ;; esac
 do
     case "$1" in
@@ -26,17 +27,44 @@ do
     -f)
        force=1
        ;;
-    -l)
-       case "$#" in
-       1)
-               set x . ;;
+    -n)
+        case $2 in
+       -*)     LINES=1         # no argument
+               ;;
+       *)      shift
+               LINES=$(expr "$1" : '\([0-9]*\)')
+               [ -z "$LINES" ] && LINES=1 # 1 line is default when -n is used
+               ;;
        esac
+       ;;
+    -l)
+       list=1
        shift
-       git rev-parse --symbolic --tags | sort | grep "$@"
-       exit $?
+       PATTERN="$1"    # select tags by shell pattern, not re
+       git rev-parse --symbolic --tags | sort |
+           while read TAG
+           do
+               case "$TAG" in
+               *$PATTERN*) ;;
+               *)          continue ;;
+               esac
+               [ "$LINES" -le 0 ] && { echo "$TAG"; continue ;}
+               OBJTYPE=$(git cat-file -t "$TAG")
+               case $OBJTYPE in
+               tag)    ANNOTATION=$(git cat-file tag "$TAG" |
+                                      sed -e '1,/^$/d' \
+                                          -e '/^-----BEGIN PGP SIGNATURE-----$/Q' )
+                       printf "%-15s %s\n" "$TAG" "$ANNOTATION" |
+                         sed -e '2,$s/^/    /' \
+                             -e "${LINES}q"
+                       ;;
+               *)      echo "$TAG"
+                       ;;
+               esac
+           done
        ;;
     -m)
-       annotate=1
+       annotate=1
        shift
        message="$1"
        if test "$#" = "0"; then
@@ -62,7 +90,7 @@ do
        username="$1"
        ;;
     -d)
-       shift
+       shift
        had_error=0
        for tag
        do
@@ -97,6 +125,8 @@ do
     shift
 done
 
+[ -n "$list" ] && exit 0
+
 name="$1"
 [ "$name" ] || usage
 prev=0000000000000000000000000000000000000000
@@ -150,4 +180,3 @@ if [ "$annotate" ]; then
 fi
 
 git update-ref "refs/tags/$name" "$object" "$prev"
-
index 8db7dd0b7d371cfeec84e70ff2a51ccf53a994e7..f2d5597dba8921c6381dfd018a97733252cc457d 100755 (executable)
@@ -42,4 +42,3 @@ cat "$GIT_DIR/.tmp-vtag" |
 sed '/-----BEGIN PGP/Q' |
 gpg --verify "$GIT_DIR/.tmp-vtag" - || exit 1
 rm -f "$GIT_DIR/.tmp-vtag"
-
index 3a45eb876157d9979f51fe88ecc5d5ae4a93ff1c..b9dc1d59ebc14e94d2b81bdfaf68c10d97820e83 100644 (file)
@@ -63,7 +63,7 @@ Git tools for importing Perforce repositories.
 %package email
 Summary:        Git tools for sending email
 Group:          Development/Tools
-Requires:      git-core = %{version}-%{release} 
+Requires:      git-core = %{version}-%{release}
 %description email
 Git tools for sending email.
 
diff --git a/gitk b/gitk
index a57e84cef7143839af954e2aa1fcb3d633befe41..87c3690ff3f742984ea91dcd45fb8475ae988f1e 100755 (executable)
--- a/gitk
+++ b/gitk
@@ -337,7 +337,7 @@ proc readrefs {} {
                    set tagids($name) $commit
                    lappend idtags($commit) $name
                }
-           }           
+           }
            catch {
                set tagcontents($name) [exec git cat-file tag $id]
            }
index e02e90f0429be0d2a69b76571101f20b8f75530f..7186cede2fad816ef4d497ac2c863869d5db76a0 100644 (file)
@@ -79,4 +79,3 @@ Originally written by:
 
 Any comment/question/concern to:
   Git mailing list <git@vger.kernel.org>
-
index 5c7011a37b2e4dab8c38de54a3e531d2fa16ddbe..e92596c295576d20d76eef23c004e7d2a5db6a3a 100755 (executable)
@@ -94,6 +94,13 @@ our $default_text_plain_charset  = undef;
 # (relative to the current git repository)
 our $mimetypes_file = undef;
 
+# assume this charset if line contains non-UTF-8 characters;
+# it should be valid encoding (see Encoding::Supported(3pm) for list),
+# for which encoding all byte sequences are valid, for example
+# 'iso-8859-1' aka 'latin1' (it is decoded without checking, so it
+# could be even 'utf-8' for the old behavior)
+our $fallback_encoding = 'latin1';
+
 # You define site-wide feature defaults here; override them with
 # $GITWEB_CONFIG as necessary.
 our %feature = (
@@ -132,7 +139,7 @@ our %feature = (
        # $feature{'snapshot'}{'default'} = [undef];
        # To have project specific config enable override in $GITWEB_CONFIG
        # $feature{'snapshot'}{'override'} = 1;
-       # and in project config gitweb.snapshot = none|gzip|bzip2;
+       # and in project config gitweb.snapshot = none|gzip|bzip2|zip;
        'snapshot' => {
                'sub' => \&feature_snapshot,
                'override' => 0,
@@ -244,6 +251,8 @@ sub feature_snapshot {
                return ('x-gzip', 'gz', 'gzip');
        } elsif ($val eq 'bzip2') {
                return ('x-bzip2', 'bz2', 'bzip2');
+       } elsif ($val eq 'zip') {
+               return ('x-zip', 'zip', '');
        } elsif ($val eq 'none') {
                return ();
        }
@@ -600,6 +609,20 @@ sub validate_refname {
        return $input;
 }
 
+# decode sequences of octets in utf8 into Perl's internal form,
+# which is utf-8 with utf8 flag set if needed.  gitweb writes out
+# in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning
+sub to_utf8 {
+       my $str = shift;
+       my $res;
+       eval { $res = decode_utf8($str, Encode::FB_CROAK); };
+       if (defined $res) {
+               return $res;
+       } else {
+               return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
+       }
+}
+
 # quote unsafe chars, but keep the slash, even when it's not
 # correct, but quoted slashes look too horrible in bookmarks
 sub esc_param {
@@ -624,7 +647,7 @@ sub esc_html ($;%) {
        my $str = shift;
        my %opts = @_;
 
-       $str = decode_utf8($str);
+       $str = to_utf8($str);
        $str = $cgi->escapeHTML($str);
        if ($opts{'-nbsp'}) {
                $str =~ s/ /&nbsp;/g;
@@ -638,7 +661,7 @@ sub esc_path {
        my $str = shift;
        my %opts = @_;
 
-       $str = decode_utf8($str);
+       $str = to_utf8($str);
        $str = $cgi->escapeHTML($str);
        if ($opts{'-nbsp'}) {
                $str =~ s/ /&nbsp;/g;
@@ -923,7 +946,7 @@ sub format_subject_html {
 
        if (length($short) < length($long)) {
                return $cgi->a({-href => $href, -class => "list subject",
-                               -title => decode_utf8($long)},
+                               -title => to_utf8($long)},
                       esc_html($short) . $extra);
        } else {
                return $cgi->a({-href => $href, -class => "list subject"},
@@ -1237,7 +1260,7 @@ sub git_get_projects_list {
                        if (check_export_ok("$projectroot/$path")) {
                                my $pr = {
                                        path => $path,
-                                       owner => decode_utf8($owner),
+                                       owner => to_utf8($owner),
                                };
                                push @list, $pr;
                                (my $forks_path = $path) =~ s/\.git$//;
@@ -1267,7 +1290,7 @@ sub git_get_project_owner {
                        $pr = unescape($pr);
                        $ow = unescape($ow);
                        if ($pr eq $project) {
-                               $owner = decode_utf8($ow);
+                               $owner = to_utf8($ow);
                                last;
                        }
                }
@@ -1757,7 +1780,7 @@ sub get_file_owner {
        }
        my $owner = $gcos;
        $owner =~ s/[,;].*$//;
-       return decode_utf8($owner);
+       return to_utf8($owner);
 }
 
 ## ......................................................................
@@ -1840,7 +1863,7 @@ sub git_header_html {
 
        my $title = "$site_name";
        if (defined $project) {
-               $title .= " - " . decode_utf8($project);
+               $title .= " - " . to_utf8($project);
                if (defined $action) {
                        $title .= "/$action";
                        if (defined $file_name) {
@@ -2114,7 +2137,7 @@ sub git_print_page_path {
 
        print "<div class=\"page_path\">";
        print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
-                     -title => 'tree root'}, decode_utf8("[$project]"));
+                     -title => 'tree root'}, to_utf8("[$project]"));
        print " / ";
        if (defined $name) {
                my @dirname = split '/', $name;
@@ -2934,7 +2957,7 @@ sub git_project_list_body {
                ($pr->{'age'}, $pr->{'age_string'}) = @aa;
                if (!defined $pr->{'descr'}) {
                        my $descr = git_get_project_description($pr->{'path'}) || "";
-                       $pr->{'descr_long'} = decode_utf8($descr);
+                       $pr->{'descr_long'} = to_utf8($descr);
                        $pr->{'descr'} = chop_str($descr, 25, 5);
                }
                if (!defined $pr->{'owner'}) {
@@ -3976,19 +3999,26 @@ sub git_snapshot {
                $hash = git_get_head_hash($project);
        }
 
-       my $filename = decode_utf8(basename($project)) . "-$hash.tar.$suffix";
+       my $git = git_cmd_str();
+       my $name = $project;
+       $name =~ s/\047/\047\\\047\047/g;
+       my $filename = to_utf8(basename($project));
+       my $cmd;
+       if ($suffix eq 'zip') {
+               $filename .= "-$hash.$suffix";
+               $cmd = "$git archive --format=zip --prefix=\'$name\'/ $hash";
+       } else {
+               $filename .= "-$hash.tar.$suffix";
+               $cmd = "$git archive --format=tar --prefix=\'$name\'/ $hash | $command";
+       }
 
        print $cgi->header(
                -type => "application/$ctype",
                -content_disposition => 'inline; filename="' . "$filename" . '"',
                -status => '200 OK');
 
-       my $git = git_cmd_str();
-       my $name = $project;
-       $name =~ s/\047/\047\\\047\047/g;
-       open my $fd, "-|",
-               "$git archive --format=tar --prefix=\'$name\'/ $hash | $command"
-               or die_error(undef, "Execute git-tar-tree failed");
+       open my $fd, "-|", $cmd
+               or die_error(undef, "Execute git-archive failed");
        binmode STDOUT, ':raw';
        print <$fd>;
        binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
diff --git a/grep.c b/grep.c
index fcc676230282e4c5bda4f9f97c5ae65c1a6beb30..f67d6716ea5f42c3384a7a4cb2eb973b02785fba 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "grep.h"
+#include "xdiff-interface.h"
 
 void append_grep_pattern(struct grep_opt *opt, const char *pat,
                         const char *origin, int no, enum grep_pat_token t)
@@ -232,17 +233,6 @@ static void show_line(struct grep_opt *opt, const char *bol, const char *eol,
        printf("%.*s\n", (int)(eol-bol), bol);
 }
 
-/*
- * NEEDSWORK: share code with diff.c
- */
-#define FIRST_FEW_BYTES 8000
-static int buffer_is_binary(const char *ptr, unsigned long size)
-{
-       if (FIRST_FEW_BYTES < size)
-               size = FIRST_FEW_BYTES;
-       return !!memchr(ptr, 0, size);
-}
-
 static int fixmatch(const char *pattern, char *line, regmatch_t *match)
 {
        char *hit = strstr(line, pattern);
diff --git a/help.c b/help.c
index 6a9af4d175f2fe9724a2844df63e4011ba91f1b3..1cd33ece6bcec6f71c6749205c18c0f413034d89 100644 (file)
--- a/help.c
+++ b/help.c
@@ -219,5 +219,3 @@ int cmd_help(int argc, const char **argv, const char *prefix)
 
        return 0;
 }
-
-
index 09baedc18ae320a2f09fa61d9065bedb69c02a41..202fae0ba8b348aeca6ec6c61045f39aa0d1fa66 100644 (file)
@@ -828,7 +828,7 @@ static void abort_object_request(struct object_request *obj_req)
        }
        unlink(obj_req->tmpfile);
        if (obj_req->slot) {
-               release_active_slot(obj_req->slot);
+               release_active_slot(obj_req->slot);
                obj_req->slot = NULL;
        }
        release_object_request(obj_req);
index e3f767582bfc71fc3d1b90be8fa76ab3ad7e1664..7c3720f602bb8f50ed54a4f7e7a85c7e08d1c07b 100644 (file)
@@ -9,6 +9,7 @@
 #include "diff.h"
 #include "revision.h"
 #include "exec_cmd.h"
+#include "remote.h"
 
 #include <expat.h>
 
@@ -517,7 +518,7 @@ static void start_put(struct transfer_request *request)
        request->buffer.size = stream.total_out;
        request->buffer.posn = 0;
 
-       request->url = xmalloc(strlen(remote->url) + 
+       request->url = xmalloc(strlen(remote->url) +
                               strlen(request->lock->token) + 51);
        strcpy(request->url, remote->url);
        posn = request->url + strlen(remote->url);
diff --git a/http.c b/http.c
index ae27e0c9409b93558e50318f2dd0a4fe758293b5..c6fb8ace9f9f43935f4128fc223b01e6cb9fa605 100644 (file)
--- a/http.c
+++ b/http.c
@@ -137,7 +137,7 @@ static int http_options(const char *var, const char *value)
                return 0;
        }
 
-#ifdef USE_CURL_MULTI  
+#ifdef USE_CURL_MULTI
        if (!strcmp("http.maxrequests", var)) {
                if (max_requests == -1)
                        max_requests = git_config_int(var, value);
diff --git a/ident.c b/ident.c
index 69a04b827d7805d9b29153e31e5489edb587690a..3d49608e6f9afe22f24a2faf70f2d6cee50b8919 100644 (file)
--- a/ident.c
+++ b/ident.c
@@ -195,10 +195,10 @@ const char *fmt_ident(const char *name, const char *email,
        setup_ident();
        if (!name)
                name = git_default_name;
-       if (!email)
-               email = getenv("EMAIL");
        if (!email)
                email = git_default_email;
+       if (!email)
+               email = getenv("EMAIL");
 
        if (!*name) {
                struct passwd *pw;
index 4283a4acdaf28a8edc2f595e6137cc396f4988dc..a5a069608419a8ecc42be63eb7998efd262f0ddc 100644 (file)
@@ -1239,7 +1239,7 @@ split_msg( msg_data_t *all_msgs, msg_data_t *msg, int *ofs )
        msg->data[ msg->len ] = 0;
 
        *ofs += msg->len;
-       return 1;
+       return 1;
 }
 
 static imap_server_conf_t server =
index 58c4a9c41dd7a05b86d40e6eeee33ba0a3fb6c4f..82c8da3683bbda15a5f7476d93c14737617d3e49 100644 (file)
@@ -13,13 +13,11 @@ static const char index_pack_usage[] =
 
 struct object_entry
 {
-       off_t offset;
+       struct pack_idx_entry idx;
        unsigned long size;
        unsigned int hdr_size;
-       uint32_t crc32;
        enum object_type type;
        enum object_type real_type;
-       unsigned char sha1[20];
 };
 
 union delta_base {
@@ -197,7 +195,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
        unsigned shift;
        void *data;
 
-       obj->offset = consumed_bytes;
+       obj->idx.offset = consumed_bytes;
        input_crc32 = crc32(0, Z_NULL, 0);
 
        p = fill(1);
@@ -229,15 +227,15 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
                while (c & 128) {
                        base_offset += 1;
                        if (!base_offset || MSB(base_offset, 7))
-                               bad_object(obj->offset, "offset value overflow for delta base object");
+                               bad_object(obj->idx.offset, "offset value overflow for delta base object");
                        p = fill(1);
                        c = *p;
                        use(1);
                        base_offset = (base_offset << 7) + (c & 127);
                }
-               delta_base->offset = obj->offset - base_offset;
-               if (delta_base->offset >= obj->offset)
-                       bad_object(obj->offset, "delta base offset is out of bound");
+               delta_base->offset = obj->idx.offset - base_offset;
+               if (delta_base->offset >= obj->idx.offset)
+                       bad_object(obj->idx.offset, "delta base offset is out of bound");
                break;
        case OBJ_COMMIT:
        case OBJ_TREE:
@@ -245,19 +243,19 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
        case OBJ_TAG:
                break;
        default:
-               bad_object(obj->offset, "unknown object type %d", obj->type);
+               bad_object(obj->idx.offset, "unknown object type %d", obj->type);
        }
-       obj->hdr_size = consumed_bytes - obj->offset;
+       obj->hdr_size = consumed_bytes - obj->idx.offset;
 
-       data = unpack_entry_data(obj->offset, obj->size);
-       obj->crc32 = input_crc32;
+       data = unpack_entry_data(obj->idx.offset, obj->size);
+       obj->idx.crc32 = input_crc32;
        return data;
 }
 
 static void *get_data_from_pack(struct object_entry *obj)
 {
-       unsigned long from = obj[0].offset + obj[0].hdr_size;
-       unsigned long len = obj[1].offset - from;
+       unsigned long from = obj[0].idx.offset + obj[0].hdr_size;
+       unsigned long len = obj[1].idx.offset - from;
        unsigned long rdy = 0;
        unsigned char *src, *data;
        z_stream stream;
@@ -360,11 +358,11 @@ static void resolve_delta(struct object_entry *delta_obj, void *base_data,
                             &result_size);
        free(delta_data);
        if (!result)
-               bad_object(delta_obj->offset, "failed to apply delta");
-       sha1_object(result, result_size, type, delta_obj->sha1);
+               bad_object(delta_obj->idx.offset, "failed to apply delta");
+       sha1_object(result, result_size, type, delta_obj->idx.sha1);
        nr_resolved_deltas++;
 
-       hashcpy(delta_base.sha1, delta_obj->sha1);
+       hashcpy(delta_base.sha1, delta_obj->idx.sha1);
        if (!find_delta_children(&delta_base, &first, &last)) {
                for (j = first; j <= last; j++) {
                        struct object_entry *child = objects + deltas[j].obj_no;
@@ -374,7 +372,7 @@ static void resolve_delta(struct object_entry *delta_obj, void *base_data,
        }
 
        memset(&delta_base, 0, sizeof(delta_base));
-       delta_base.offset = delta_obj->offset;
+       delta_base.offset = delta_obj->idx.offset;
        if (!find_delta_children(&delta_base, &first, &last)) {
                for (j = first; j <= last; j++) {
                        struct object_entry *child = objects + deltas[j].obj_no;
@@ -418,12 +416,12 @@ static void parse_pack_objects(unsigned char *sha1)
                        delta->obj_no = i;
                        delta++;
                } else
-                       sha1_object(data, obj->size, obj->type, obj->sha1);
+                       sha1_object(data, obj->size, obj->type, obj->idx.sha1);
                free(data);
                if (verbose)
                        display_progress(&progress, i+1);
        }
-       objects[i].offset = consumed_bytes;
+       objects[i].idx.offset = consumed_bytes;
        if (verbose)
                stop_progress(&progress);
 
@@ -465,10 +463,10 @@ static void parse_pack_objects(unsigned char *sha1)
 
                if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA)
                        continue;
-               hashcpy(base.sha1, obj->sha1);
+               hashcpy(base.sha1, obj->idx.sha1);
                ref = !find_delta_children(&base, &ref_first, &ref_last);
                memset(&base, 0, sizeof(base));
-               base.offset = obj->offset;
+               base.offset = obj->idx.offset;
                ofs = !find_delta_children(&base, &ofs_first, &ofs_last);
                if (!ref && !ofs)
                        continue;
@@ -535,11 +533,11 @@ static void append_obj_to_pack(const unsigned char *sha1, void *buf,
        }
        header[n++] = c;
        write_or_die(output_fd, header, n);
-       obj[0].crc32 = crc32(0, Z_NULL, 0);
-       obj[0].crc32 = crc32(obj[0].crc32, header, n);
-       obj[1].offset = obj[0].offset + n;
-       obj[1].offset += write_compressed(output_fd, buf, size, &obj[0].crc32);
-       hashcpy(obj->sha1, sha1);
+       obj[0].idx.crc32 = crc32(0, Z_NULL, 0);
+       obj[0].idx.crc32 = crc32(obj[0].idx.crc32, header, n);
+       obj[1].idx.offset = obj[0].idx.offset + n;
+       obj[1].idx.offset += write_compressed(output_fd, buf, size, &obj[0].idx.crc32);
+       hashcpy(obj->idx.sha1, sha1);
 }
 
 static int delta_pos_compare(const void *_a, const void *_b)
@@ -602,145 +600,6 @@ static void fix_unresolved_deltas(int nr_unresolved)
        free(sorted_by_pos);
 }
 
-static uint32_t index_default_version = 1;
-static uint32_t index_off32_limit = 0x7fffffff;
-
-static int sha1_compare(const void *_a, const void *_b)
-{
-       struct object_entry *a = *(struct object_entry **)_a;
-       struct object_entry *b = *(struct object_entry **)_b;
-       return hashcmp(a->sha1, b->sha1);
-}
-
-/*
- * On entry *sha1 contains the pack content SHA1 hash, on exit it is
- * the SHA1 hash of sorted object names.
- */
-static const char *write_index_file(const char *index_name, unsigned char *sha1)
-{
-       struct sha1file *f;
-       struct object_entry **sorted_by_sha, **list, **last;
-       uint32_t array[256];
-       int i, fd;
-       SHA_CTX ctx;
-       uint32_t index_version;
-
-       if (nr_objects) {
-               sorted_by_sha =
-                       xcalloc(nr_objects, sizeof(struct object_entry *));
-               list = sorted_by_sha;
-               last = sorted_by_sha + nr_objects;
-               for (i = 0; i < nr_objects; ++i)
-                       sorted_by_sha[i] = &objects[i];
-               qsort(sorted_by_sha, nr_objects, sizeof(sorted_by_sha[0]),
-                     sha1_compare);
-       }
-       else
-               sorted_by_sha = list = last = NULL;
-
-       if (!index_name) {
-               static char tmpfile[PATH_MAX];
-               snprintf(tmpfile, sizeof(tmpfile),
-                        "%s/tmp_idx_XXXXXX", get_object_directory());
-               fd = mkstemp(tmpfile);
-               index_name = xstrdup(tmpfile);
-       } else {
-               unlink(index_name);
-               fd = open(index_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
-       }
-       if (fd < 0)
-               die("unable to create %s: %s", index_name, strerror(errno));
-       f = sha1fd(fd, index_name);
-
-       /* if last object's offset is >= 2^31 we should use index V2 */
-       index_version = (objects[nr_objects-1].offset >> 31) ? 2 : index_default_version;
-
-       /* index versions 2 and above need a header */
-       if (index_version >= 2) {
-               struct pack_idx_header hdr;
-               hdr.idx_signature = htonl(PACK_IDX_SIGNATURE);
-               hdr.idx_version = htonl(index_version);
-               sha1write(f, &hdr, sizeof(hdr));
-       }
-
-       /*
-        * Write the first-level table (the list is sorted,
-        * but we use a 256-entry lookup to be able to avoid
-        * having to do eight extra binary search iterations).
-        */
-       for (i = 0; i < 256; i++) {
-               struct object_entry **next = list;
-               while (next < last) {
-                       struct object_entry *obj = *next;
-                       if (obj->sha1[0] != i)
-                               break;
-                       next++;
-               }
-               array[i] = htonl(next - sorted_by_sha);
-               list = next;
-       }
-       sha1write(f, array, 256 * 4);
-
-       /* compute the SHA1 hash of sorted object names. */
-       SHA1_Init(&ctx);
-
-       /*
-        * Write the actual SHA1 entries..
-        */
-       list = sorted_by_sha;
-       for (i = 0; i < nr_objects; i++) {
-               struct object_entry *obj = *list++;
-               if (index_version < 2) {
-                       uint32_t offset = htonl(obj->offset);
-                       sha1write(f, &offset, 4);
-               }
-               sha1write(f, obj->sha1, 20);
-               SHA1_Update(&ctx, obj->sha1, 20);
-       }
-
-       if (index_version >= 2) {
-               unsigned int nr_large_offset = 0;
-
-               /* write the crc32 table */
-               list = sorted_by_sha;
-               for (i = 0; i < nr_objects; i++) {
-                       struct object_entry *obj = *list++;
-                       uint32_t crc32_val = htonl(obj->crc32);
-                       sha1write(f, &crc32_val, 4);
-               }
-
-               /* write the 32-bit offset table */
-               list = sorted_by_sha;
-               for (i = 0; i < nr_objects; i++) {
-                       struct object_entry *obj = *list++;
-                       uint32_t offset = (obj->offset <= index_off32_limit) ?
-                               obj->offset : (0x80000000 | nr_large_offset++);
-                       offset = htonl(offset);
-                       sha1write(f, &offset, 4);
-               }
-
-               /* write the large offset table */
-               list = sorted_by_sha;
-               while (nr_large_offset) {
-                       struct object_entry *obj = *list++;
-                       uint64_t offset = obj->offset;
-                       if (offset > index_off32_limit) {
-                               uint32_t split[2];
-                               split[0]        = htonl(offset >> 32);
-                               split[1] = htonl(offset & 0xffffffff);
-                               sha1write(f, split, 8);
-                               nr_large_offset--;
-                       }
-               }
-       }
-
-       sha1write(f, sha1, 20);
-       sha1close(f, NULL, 1);
-       free(sorted_by_sha);
-       SHA1_Final(sha1, &ctx);
-       return index_name;
-}
-
 static void final(const char *final_pack_name, const char *curr_pack_name,
                  const char *final_index_name, const char *curr_index_name,
                  const char *keep_name, const char *keep_msg,
@@ -830,6 +689,7 @@ int main(int argc, char **argv)
        const char *curr_index, *index_name = NULL;
        const char *keep_name = NULL, *keep_msg = NULL;
        char *index_name_buf = NULL, *keep_name_buf = NULL;
+       struct pack_idx_entry **idx_objects;
        unsigned char sha1[20];
 
        for (i = 1; i < argc; i++) {
@@ -865,12 +725,12 @@ int main(int argc, char **argv)
                                index_name = argv[++i];
                        } else if (!prefixcmp(arg, "--index-version=")) {
                                char *c;
-                               index_default_version = strtoul(arg + 16, &c, 10);
-                               if (index_default_version > 2)
+                               pack_idx_default_version = strtoul(arg + 16, &c, 10);
+                               if (pack_idx_default_version > 2)
                                        die("bad %s", arg);
                                if (*c == ',')
-                                       index_off32_limit = strtoul(c+1, &c, 0);
-                               if (*c || index_off32_limit & 0x80000000)
+                                       pack_idx_off32_limit = strtoul(c+1, &c, 0);
+                               if (*c || pack_idx_off32_limit & 0x80000000)
                                        die("bad %s", arg);
                        } else
                                usage(index_pack_usage);
@@ -940,7 +800,13 @@ int main(int argc, char **argv)
                            nr_deltas - nr_resolved_deltas);
        }
        free(deltas);
-       curr_index = write_index_file(index_name, sha1);
+
+       idx_objects = xmalloc((nr_objects) * sizeof(struct pack_idx_entry *));
+       for (i = 0; i < nr_objects; i++)
+               idx_objects[i] = &objects[i].idx;
+       curr_index = write_idx_file(index_name, idx_objects, nr_objects, sha1);
+       free(idx_objects);
+
        final(pack_name, curr_pack,
                index_name, curr_index,
                keep_name, keep_msg,
index 310f8d39082a12d2c3daddd1fca454686e7425c3..e5c88c278fe23eefbf4cb4dd0c66251b208e48bd 100644 (file)
@@ -87,7 +87,7 @@ static void process_tree(struct rev_info *revs,
                        process_tree(revs,
                                     lookup_tree(entry.sha1),
                                     p, &me, entry.path);
-               else if (S_ISDIRLNK(entry.mode))
+               else if (S_ISGITLINK(entry.mode))
                        process_gitlink(revs, entry.sha1,
                                        p, &me, entry.path);
                else
index 4b650efa8b19424a61566b7ec87e7808874a6721..bf7ec6c2a3e25d09d3a43047d0cf3e1e6f883178 100644 (file)
@@ -114,7 +114,7 @@ static int fetch_pack(const unsigned char *sha1)
                return -1;
        target = find_sha1_pack(sha1, packs);
        if (!target)
-               return error("Couldn't find %s: not separate or in any pack", 
+               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",
@@ -122,11 +122,11 @@ static int fetch_pack(const unsigned char *sha1)
                fprintf(stderr, " which contains %s\n",
                        sha1_to_hex(sha1));
        }
-       sprintf(filename, "%s/objects/pack/pack-%s.pack", 
+       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), 1);
-       sprintf(filename, "%s/objects/pack/pack-%s.idx", 
+       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), 1);
@@ -141,7 +141,7 @@ static int fetch_file(const unsigned char *sha1)
        char *hex = sha1_to_hex(sha1);
        char *dest_filename = sha1_file_name(sha1);
 
-       if (object_name_start < 0) {
+       if (object_name_start < 0) {
                strcpy(filename, path); /* e.g. git.git */
                strcat(filename, "/objects/");
                object_name_start = strlen(filename);
index 23db35aff21d7c33197726128e2f120291e6e9f0..5ad2858b4885022141d915fa0555c51f80d11c1c 100644 (file)
@@ -97,4 +97,3 @@ void rollback_lock_file(struct lock_file *lk)
                unlink(lk->filename);
        lk->filename[0] = 0;
 }
-
index cb567a2832d9f8c784aea388af9144c12eddc7d5..87141670595c50a4fa7b87a12b85ff0e2b7da8af 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -89,4 +89,3 @@ int map_email(struct path_list *map, const char *email, char *name, int maxlen)
        }
        return 0;
 }
-
index 23cafe47b495ba40fbdd46eb35943be5f722a1d7..d7e29c4d1d3e44c85e0eeb28040e8ea945090594 100644 (file)
@@ -301,4 +301,3 @@ void shift_tree(const unsigned char *hash1,
 
        splice_tree(hash1, add_prefix, hash2, shifted);
 }
-
index 5599fd321bb4c09c1c0ce4fc62dfb9ecf5531c2b..fa719cb0b1bd227423587c9e41eed77c755465a4 100644 (file)
@@ -25,7 +25,7 @@ static void run_program(void)
 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;
index 8f72b2c079a68ac5cb9d1c90bb7b72fa779efb5f..4a82b741ae020376ac67b34d5fce86e8a87a3b5d 100644 (file)
@@ -680,6 +680,12 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
 {
        xpparam_t xpp;
 
+       if (buffer_is_binary(orig->ptr, orig->size) ||
+                       buffer_is_binary(src1->ptr, src1->size) ||
+                       buffer_is_binary(src2->ptr, src2->size))
+               return error("Cannot merge binary files: %s vs. %s\n",
+                       name1, name2);
+
        memset(&xpp, 0, sizeof(xpp));
        return xdl_merge(orig,
                         src1, name1,
diff --git a/mktag.c b/mktag.c
index 931011121e7276513b55fc41691c65a0d924119d..b82e377bd826617810488ea8c92a4135bceebda6 100644 (file)
--- a/mktag.c
+++ b/mktag.c
  * The first three lines are guaranteed to be at least 63 bytes:
  * "object <sha1>\n" is 48 bytes, "type tag\n" at 9 bytes is the
  * shortest possible type-line, and "tag .\n" at 6 bytes is the
- * shortest single-character-tag line. 
- *
- * We also artificially limit the size of the full object to 8kB.
- * Just because I'm a lazy bastard, and if you can't fit a signature
- * in that size, you're doing something wrong.
+ * shortest single-character-tag line.
  */
 
-/* Some random size */
-#define MAXSIZE (8192)
-
 /*
  * We refuse to tag something we can't verify. Just because.
  */
index 847531d19f88e420ad68f95f11ab2f1f77876d08..3f06b835675206912777a774d91c3ba611fa5a06 100644 (file)
@@ -1,29 +1,29 @@
-/* 
+/*
  * The contents of this file are subject to the Mozilla Public
  * License Version 1.1 (the "License"); you may not use this file
  * except in compliance with the License. You may obtain a copy of
  * the License at http://www.mozilla.org/MPL/
- * 
+ *
  * Software distributed under the License is distributed on an "AS
  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  * implied. See the License for the specific language governing
  * rights and limitations under the License.
- * 
+ *
  * The Original Code is SHA 180-1 Reference Implementation (Compact version)
- * 
+ *
  * The Initial Developer of the Original Code is Paul Kocher of
- * Cryptography Research.  Portions created by Paul Kocher are 
+ * Cryptography Research.  Portions created by Paul Kocher are
  * Copyright (C) 1995-9 by Cryptography Research, Inc.  All
  * Rights Reserved.
- * 
+ *
  * Contributor(s):
  *
  *     Paul Kocher
- * 
+ *
  * Alternatively, the contents of this file may be used under the
  * terms of the GNU General Public License Version 2 or later (the
- * "GPL"), in which case the provisions of the GPL are applicable 
- * instead of those above.  If you wish to allow use of your 
+ * "GPL"), in which case the provisions of the GPL are applicable
+ * instead of those above.  If you wish to allow use of your
  * version of this file only under the terms of the GPL and not to
  * allow others to use your version of this file under the MPL,
  * indicate your decision by deleting the provisions above and
@@ -149,4 +149,3 @@ static void shaHashBlock(SHA_CTX *ctx) {
   ctx->H[3] += D;
   ctx->H[4] += E;
 }
-
index 5d82afa3bdd21a2855c569a73cf3277b5c6a41bc..16f2d3d43ca8bee1eeb306308277bef8c707a972 100644 (file)
@@ -1,29 +1,29 @@
-/* 
+/*
  * The contents of this file are subject to the Mozilla Public
  * License Version 1.1 (the "License"); you may not use this file
  * except in compliance with the License. You may obtain a copy of
  * the License at http://www.mozilla.org/MPL/
- * 
+ *
  * Software distributed under the License is distributed on an "AS
  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  * implied. See the License for the specific language governing
  * rights and limitations under the License.
- * 
+ *
  * The Original Code is SHA 180-1 Header File
- * 
+ *
  * The Initial Developer of the Original Code is Paul Kocher of
- * Cryptography Research.  Portions created by Paul Kocher are 
+ * Cryptography Research.  Portions created by Paul Kocher are
  * Copyright (C) 1995-9 by Cryptography Research, Inc.  All
  * Rights Reserved.
- * 
+ *
  * Contributor(s):
  *
  *     Paul Kocher
- * 
+ *
  * Alternatively, the contents of this file may be used under the
  * terms of the GNU General Public License Version 2 or later (the
- * "GPL"), in which case the provisions of the GPL are applicable 
- * instead of those above.  If you wish to allow use of your 
+ * "GPL"), in which case the provisions of the GPL are applicable
+ * instead of those above.  If you wish to allow use of your
  * version of this file only under the terms of the GPL and not to
  * allow others to use your version of this file under the MPL,
  * indicate your decision by deleting the provisions above and
index 022e8d841c7f5498b6f008647ed37c430826b443..5345671569e9500ad31124dacf9525739687d9be 100644 (file)
@@ -85,5 +85,3 @@ void mark_reachable(struct object *obj, unsigned int mask)
                        mark_reachable(refs->ref[i], mask);
        }
 }
-
-
index cfc4969ed9ba0ccfdba8f97637bac20be31d1eba..16793d9958a57664233b9e4468e112dfa1a8a915 100644 (file)
--- a/object.c
+++ b/object.c
@@ -160,8 +160,11 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
                parse_tag_buffer(tag, buffer, size);
                obj = &tag->object;
        } else {
+               warning("object %s has unknown type id %d\n", sha1_to_hex(sha1), type);
                obj = NULL;
        }
+       if (obj && obj->type == OBJ_NONE)
+               obj->type = type;
        *eaten_p = eaten;
        return obj;
 }
index 94f19eed86ceebcc85770a379faf7b1270d1fad4..397bbfa090cd281214013c42a5f0b1de6063a861 100644 (file)
--- a/object.h
+++ b/object.h
@@ -66,7 +66,7 @@ void set_object_refs(struct object *obj, struct object_refs *refs);
 
 void mark_reachable(struct object *obj, unsigned int mask);
 
-struct object_list *object_list_insert(struct object *item, 
+struct object_list *object_list_insert(struct object *item,
                                       struct object_list **list_p);
 
 void object_list_append(struct object *item,
index d04536bbff7cba22ca67521d45e690dfa5aa8675..d7dd62bb8346c4cac8dbd7334e999a450c21c5ab 100644 (file)
@@ -1,6 +1,23 @@
 #include "cache.h"
 #include "pack.h"
 
+struct idx_entry
+{
+       const unsigned char *sha1;
+       off_t                offset;
+};
+
+static int compare_entries(const void *e1, const void *e2)
+{
+       const struct idx_entry *entry1 = e1;
+       const struct idx_entry *entry2 = e2;
+       if (entry1->offset < entry2->offset)
+               return -1;
+       if (entry1->offset > entry2->offset)
+               return 1;
+       return 0;
+}
+
 static int verify_packfile(struct packed_git *p,
                struct pack_window **w_curs)
 {
@@ -11,6 +28,7 @@ static int verify_packfile(struct packed_git *p,
        off_t offset = 0, pack_sig = p->pack_size - 20;
        uint32_t nr_objects, i;
        int err;
+       struct idx_entry *entries;
 
        /* Note that the pack header checks are actually performed by
         * use_pack when it first opens the pack file.  If anything
@@ -41,44 +59,48 @@ static int verify_packfile(struct packed_git *p,
         * we do not do scan-streaming check on the pack file.
         */
        nr_objects = p->num_objects;
+       entries = xmalloc(nr_objects * sizeof(*entries));
+       /* first sort entries by pack offset, since unpacking them is more efficient that way */
+       for (i = 0; i < nr_objects; i++) {
+               entries[i].sha1 = nth_packed_object_sha1(p, i);
+               if (!entries[i].sha1)
+                       die("internal error pack-check nth-packed-object");
+               entries[i].offset = find_pack_entry_one(entries[i].sha1, p);
+               if (!entries[i].offset)
+                       die("internal error pack-check find-pack-entry-one");
+       }
+       qsort(entries, nr_objects, sizeof(*entries), compare_entries);
+
        for (i = 0, err = 0; i < nr_objects; i++) {
-               const unsigned char *sha1;
                void *data;
                enum object_type type;
                unsigned long size;
-               off_t offset;
 
-               sha1 = nth_packed_object_sha1(p, i);
-               if (!sha1)
-                       die("internal error pack-check nth-packed-object");
-               offset = find_pack_entry_one(sha1, p);
-               if (!offset)
-                       die("internal error pack-check find-pack-entry-one");
-               data = unpack_entry(p, offset, &type, &size);
+               data = unpack_entry(p, entries[i].offset, &type, &size);
                if (!data) {
                        err = error("cannot unpack %s from %s",
-                                   sha1_to_hex(sha1), p->pack_name);
+                                   sha1_to_hex(entries[i].sha1), p->pack_name);
                        continue;
                }
-               if (check_sha1_signature(sha1, data, size, typename(type))) {
+               if (check_sha1_signature(entries[i].sha1, data, size, typename(type))) {
                        err = error("packed %s from %s is corrupt",
-                                   sha1_to_hex(sha1), p->pack_name);
+                                   sha1_to_hex(entries[i].sha1), p->pack_name);
                        free(data);
                        continue;
                }
                free(data);
        }
+       free(entries);
 
        return err;
 }
 
 
-#define MAX_CHAIN 40
+#define MAX_CHAIN 50
 
 static void show_pack_info(struct packed_git *p)
 {
-       uint32_t nr_objects, i, chain_histogram[MAX_CHAIN];
-
+       uint32_t nr_objects, i, chain_histogram[MAX_CHAIN+1];
        nr_objects = p->num_objects;
        memset(chain_histogram, 0, sizeof(chain_histogram));
 
@@ -109,32 +131,37 @@ static void show_pack_info(struct packed_git *p)
                        printf("%-6s %lu %"PRIuMAX" %u %s\n",
                               type, size, (uintmax_t)offset,
                               delta_chain_length, sha1_to_hex(base_sha1));
-                       if (delta_chain_length < MAX_CHAIN)
+                       if (delta_chain_length <= MAX_CHAIN)
                                chain_histogram[delta_chain_length]++;
                        else
                                chain_histogram[0]++;
                }
        }
 
-       for (i = 0; i < MAX_CHAIN; i++) {
+       for (i = 0; i <= MAX_CHAIN; i++) {
                if (!chain_histogram[i])
                        continue;
-               printf("chain length %s %d: %d object%s\n",
-                      i ? "=" : ">=",
-                      i ? i : MAX_CHAIN,
-                      chain_histogram[i],
-                      1 < chain_histogram[i] ? "s" : "");
+               printf("chain length = %d: %d object%s\n", i,
+                      chain_histogram[i], chain_histogram[i] > 1 ? "s" : "");
        }
+       if (chain_histogram[0])
+               printf("chain length > %d: %d object%s\n", MAX_CHAIN,
+                      chain_histogram[0], chain_histogram[0] > 1 ? "s" : "");
 }
 
 int verify_pack(struct packed_git *p, int verbose)
 {
-       off_t index_size = p->index_size;
-       const unsigned char *index_base = p->index_data;
+       off_t index_size;
+       const unsigned char *index_base;
        SHA_CTX ctx;
        unsigned char sha1[20];
        int ret;
 
+       if (open_pack_index(p))
+               return error("packfile %s index not opened", p->pack_name);
+       index_size = p->index_size;
+       index_base = p->index_data;
+
        ret = 0;
        /* Verify SHA1 sum of the index file */
        SHA1_Init(&ctx);
index 87077e150c1b53a26464089a2cabafafb32e6636..f5cd0ac59e5794a375172b998399a546eaef4ab1 100644 (file)
@@ -81,7 +81,7 @@ static struct llist * llist_copy(struct llist *list)
 {
        struct llist *ret;
        struct llist_item *new, *old, *prev;
-       
+
        llist_init(&ret);
 
        if ((ret->size = list->size) == 0)
@@ -100,7 +100,7 @@ static struct llist * llist_copy(struct llist *list)
        }
        new->next = NULL;
        ret->back = new;
-       
+
        return ret;
 }
 
@@ -550,6 +550,9 @@ static struct pack_list * add_pack(struct packed_git *p)
        l.pack = p;
        llist_init(&l.all_objects);
 
+       if (open_pack_index(p))
+               return NULL;
+
        base = p->index_data;
        base += 256 * 4 + ((p->index_version < 2) ? 4 : 8);
        step = (p->index_version < 2) ? 24 : 20;
index ae2e481e5554cfa66cf137d38c38f961b9aa8ec7..1cf5f7c9f0956a457de03c64238d298a9d996984 100644 (file)
@@ -1,5 +1,147 @@
 #include "cache.h"
 #include "pack.h"
+#include "csum-file.h"
+
+uint32_t pack_idx_default_version = 1;
+uint32_t pack_idx_off32_limit = 0x7fffffff;
+
+static int sha1_compare(const void *_a, const void *_b)
+{
+       struct pack_idx_entry *a = *(struct pack_idx_entry **)_a;
+       struct pack_idx_entry *b = *(struct pack_idx_entry **)_b;
+       return hashcmp(a->sha1, b->sha1);
+}
+
+/*
+ * On entry *sha1 contains the pack content SHA1 hash, on exit it is
+ * the SHA1 hash of sorted object names. The objects array passed in
+ * will be sorted by SHA1 on exit.
+ */
+const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1)
+{
+       struct sha1file *f;
+       struct pack_idx_entry **sorted_by_sha, **list, **last;
+       off_t last_obj_offset = 0;
+       uint32_t array[256];
+       int i, fd;
+       SHA_CTX ctx;
+       uint32_t index_version;
+
+       if (nr_objects) {
+               sorted_by_sha = objects;
+               list = sorted_by_sha;
+               last = sorted_by_sha + nr_objects;
+               for (i = 0; i < nr_objects; ++i) {
+                       if (objects[i]->offset > last_obj_offset)
+                               last_obj_offset = objects[i]->offset;
+               }
+               qsort(sorted_by_sha, nr_objects, sizeof(sorted_by_sha[0]),
+                     sha1_compare);
+       }
+       else
+               sorted_by_sha = list = last = NULL;
+
+       if (!index_name) {
+               static char tmpfile[PATH_MAX];
+               snprintf(tmpfile, sizeof(tmpfile),
+                        "%s/tmp_idx_XXXXXX", get_object_directory());
+               fd = mkstemp(tmpfile);
+               index_name = xstrdup(tmpfile);
+       } else {
+               unlink(index_name);
+               fd = open(index_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
+       }
+       if (fd < 0)
+               die("unable to create %s: %s", index_name, strerror(errno));
+       f = sha1fd(fd, index_name);
+
+       /* if last object's offset is >= 2^31 we should use index V2 */
+       index_version = (last_obj_offset >> 31) ? 2 : pack_idx_default_version;
+
+       /* index versions 2 and above need a header */
+       if (index_version >= 2) {
+               struct pack_idx_header hdr;
+               hdr.idx_signature = htonl(PACK_IDX_SIGNATURE);
+               hdr.idx_version = htonl(index_version);
+               sha1write(f, &hdr, sizeof(hdr));
+       }
+
+       /*
+        * Write the first-level table (the list is sorted,
+        * but we use a 256-entry lookup to be able to avoid
+        * having to do eight extra binary search iterations).
+        */
+       for (i = 0; i < 256; i++) {
+               struct pack_idx_entry **next = list;
+               while (next < last) {
+                       struct pack_idx_entry *obj = *next;
+                       if (obj->sha1[0] != i)
+                               break;
+                       next++;
+               }
+               array[i] = htonl(next - sorted_by_sha);
+               list = next;
+       }
+       sha1write(f, array, 256 * 4);
+
+       /* compute the SHA1 hash of sorted object names. */
+       SHA1_Init(&ctx);
+
+       /*
+        * Write the actual SHA1 entries..
+        */
+       list = sorted_by_sha;
+       for (i = 0; i < nr_objects; i++) {
+               struct pack_idx_entry *obj = *list++;
+               if (index_version < 2) {
+                       uint32_t offset = htonl(obj->offset);
+                       sha1write(f, &offset, 4);
+               }
+               sha1write(f, obj->sha1, 20);
+               SHA1_Update(&ctx, obj->sha1, 20);
+       }
+
+       if (index_version >= 2) {
+               unsigned int nr_large_offset = 0;
+
+               /* write the crc32 table */
+               list = sorted_by_sha;
+               for (i = 0; i < nr_objects; i++) {
+                       struct pack_idx_entry *obj = *list++;
+                       uint32_t crc32_val = htonl(obj->crc32);
+                       sha1write(f, &crc32_val, 4);
+               }
+
+               /* write the 32-bit offset table */
+               list = sorted_by_sha;
+               for (i = 0; i < nr_objects; i++) {
+                       struct pack_idx_entry *obj = *list++;
+                       uint32_t offset = (obj->offset <= pack_idx_off32_limit) ?
+                               obj->offset : (0x80000000 | nr_large_offset++);
+                       offset = htonl(offset);
+                       sha1write(f, &offset, 4);
+               }
+
+               /* write the large offset table */
+               list = sorted_by_sha;
+               while (nr_large_offset) {
+                       struct pack_idx_entry *obj = *list++;
+                       uint64_t offset = obj->offset;
+                       if (offset > pack_idx_off32_limit) {
+                               uint32_t split[2];
+                               split[0] = htonl(offset >> 32);
+                               split[1] = htonl(offset & 0xffffffff);
+                               sha1write(f, split, 8);
+                               nr_large_offset--;
+                       }
+               }
+       }
+
+       sha1write(f, sha1, 20);
+       sha1close(f, NULL, 1);
+       SHA1_Final(sha1, &ctx);
+       return index_name;
+}
 
 void fixup_pack_header_footer(int pack_fd,
                         unsigned char *pack_file_sha1,
diff --git a/pack.h b/pack.h
index d667fb8d5a49b4480beaa6f384f1f6f86b035806..f357c9f4282d5bc8bbcff6f3a44b9812415745a6 100644 (file)
--- a/pack.h
+++ b/pack.h
@@ -34,6 +34,10 @@ struct pack_header {
  */
 #define PACK_IDX_SIGNATURE 0xff744f63  /* "\377tOc" */
 
+/* These may be overridden by command-line parameters */
+extern uint32_t pack_idx_default_version;
+extern uint32_t pack_idx_off32_limit;
+
 /*
  * Packed object index header
  */
@@ -42,6 +46,16 @@ struct pack_idx_header {
        uint32_t idx_version;
 };
 
+/*
+ * Common part of object structure used for write_idx_file
+ */
+struct pack_idx_entry {
+       unsigned char sha1[20];
+       uint32_t crc32;
+       off_t offset;
+};
+
+extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1);
 
 extern int verify_pack(struct packed_git *, int);
 extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t);
index 086d2d9c68835c6a7434932f6e3b430e0906578d..9349bc5580456b378d41da7cc2518e4fa9a7e81a 100644 (file)
@@ -81,4 +81,4 @@ int main(int argc, char **argv)
 
        generate_id_list();
        return 0;
-}      
+}
index caaa5cc57b05e1a27bb4fd8f49bb74e06b9936e3..dcb4b3ac139a5a264df04d91cee17679efe55aa6 100644 (file)
@@ -100,4 +100,3 @@ void print_path_list(const char *text, const struct path_list *p)
        for (i = 0; i < p->nr; i++)
                printf("%s:%p\n", p->items[i].path, p->items[i].util);
 }
-
index 96bfac498bdc58c90c9bc136a1df7bac9bfa0d92..ceb787170e17df130e26658e5a189bb63684ab3e 100644 (file)
@@ -64,7 +64,7 @@ int main(int argc, char **argv)
        if (!dest || i != argc - 1)
                usage(peek_remote_usage);
 
-       pid = git_connect(fd, dest, uploadpack);
+       pid = git_connect(fd, dest, uploadpack, 0);
        if (pid < 0)
                return 1;
        ret = peek_remote(fd, flags);
index 0d695fd2f35f91b47455dc382d86b52bb51088d2..5e079ad01126845c39fd9583fa742f54d5658b49 100644 (file)
@@ -40,4 +40,3 @@ endif
 # (even though GIT-CFLAGS aren't used yet. If ever)
 ../GIT-CFLAGS:
        $(MAKE) -C .. GIT-CFLAGS
-
index b60526869a38bd20f800c275f7b42390c8bea1ee..355546a1ad844492234dc7ee91528c525af5610a 100644 (file)
@@ -5,7 +5,7 @@
  * Write a packetized stream, where each line is preceded by
  * its length (including the header) as a 4-byte hex number.
  * A length of 'zero' means end of stream (and a length of 1-3
- * would be an error). 
+ * would be an error).
  *
  * This is all pretty stupid, but we use this packetized line
  * format to make a streaming format possible without ever
index 0820398b004dd8af93a25e7fa26be60cf4dda410..738e36c1e81def4822ccc2a66bc2761402a07f26 100644 (file)
@@ -50,7 +50,7 @@ int SHA1_Update(SHA_CTX *c, const void *ptr, unsigned long n)
                p += nb;
        }
        return 0;
-}      
+}
 
 int SHA1_Final(unsigned char *hash, SHA_CTX *c)
 {
index 05f7890314e0bd596eb2e4110cdb98eeea61c9da..4344f4eed5e46c4e013018af8ef9ab062f740d8f 100644 (file)
@@ -62,11 +62,13 @@ int display_progress(struct progress *progress, unsigned n)
                        fprintf(stderr, "%s%4u%% (%u/%u) done\r",
                                progress->prefix, percent, n, progress->total);
                        progress_update = 0;
+                       progress->need_lf = 1;
                        return 1;
                }
        } else if (progress_update) {
                fprintf(stderr, "%s%u\r", progress->prefix, n);
                progress_update = 0;
+               progress->need_lf = 1;
                return 1;
        }
        return 0;
@@ -80,6 +82,7 @@ void start_progress(struct progress *progress, const char *title,
        progress->total = total;
        progress->last_percent = -1;
        progress->delay = 0;
+       progress->need_lf = 0;
        if (snprintf(buf, sizeof(buf), title, total))
                fprintf(stderr, "%s\n", buf);
        set_progress_signal();
@@ -95,12 +98,13 @@ void start_progress_delay(struct progress *progress, const char *title,
        progress->delayed_percent_treshold = percent_treshold;
        progress->delayed_title = title;
        progress->delay = delay;
+       progress->need_lf = 0;
        set_progress_signal();
 }
 
 void stop_progress(struct progress *progress)
 {
        clear_progress_signal();
-       if (progress->total)
+       if (progress->need_lf)
                fputc('\n', stderr);
 }
index 5ae1a89e5a4669553e44d5bd0cc339c308c60c0f..a7c17ca7c4bdad953508d03c20e73022b03bd25a 100644 (file)
@@ -8,6 +8,7 @@ struct progress {
        unsigned delay;
        unsigned delayed_percent_treshold;
        const char *delayed_title;
+       int need_lf;
 };
 
 int display_progress(struct progress *progress, unsigned n);
diff --git a/quote.c b/quote.c
index fb9e4ca253ea9bcadbcb55dcdd62be614c66758f..aa440098e1d8a771aa2d9d2e17355fd560f3c253 100644 (file)
--- a/quote.c
+++ b/quote.c
@@ -20,7 +20,7 @@ static inline int need_bs_quote(char c)
        return (c == '\'' || c == '!');
 }
 
-size_t sq_quote_buf(char *dst, size_t n, const char *src)
+static size_t sq_quote_buf(char *dst, size_t n, const char *src)
 {
        char c;
        char *bp = dst;
@@ -62,18 +62,6 @@ void sq_quote_print(FILE *stream, const char *src)
        fputc('\'', stream);
 }
 
-char *sq_quote(const char *src)
-{
-       char *buf;
-       size_t cnt;
-
-       cnt = sq_quote_buf(NULL, 0, src) + 1;
-       buf = xmalloc(cnt);
-       sq_quote_buf(buf, cnt, src);
-
-       return buf;
-}
-
 char *sq_quote_argv(const char** argv, int count)
 {
        char *buf, *to;
diff --git a/quote.h b/quote.h
index bdc3610df51000baeda49da1eeaec20ccb2682fb..8a59cc55d1dcfba728614b2d6494272ceafbf3a1 100644 (file)
--- a/quote.h
+++ b/quote.h
@@ -28,9 +28,7 @@
  * excluding the final null regardless of the buffer size.
  */
 
-extern char *sq_quote(const char *src);
 extern void sq_quote_print(FILE *stream, const char *src);
-extern size_t sq_quote_buf(char *dst, size_t n, const char *src);
 extern char *sq_quote_argv(const char** argv, int count);
 
 /*
index d9f46da5cc547d8cfaa34c901be50a13995b120e..4362b11f475748e89e9deaf6257fb0c411948105 100644 (file)
@@ -92,7 +92,7 @@ static int ce_compare_gitlink(struct cache_entry *ce)
 
        /*
         * We don't actually require that the .git directory
-        * under DIRLNK directory be a valid git directory. It
+        * under GITLINK directory be a valid git directory. It
         * might even be missing (in case nobody populated that
         * sub-project).
         *
@@ -115,7 +115,7 @@ static int ce_modified_check_fs(struct cache_entry *ce, struct stat *st)
                        return DATA_CHANGED;
                break;
        case S_IFDIR:
-               if (S_ISDIRLNK(ntohl(ce->ce_mode)))
+               if (S_ISGITLINK(ntohl(ce->ce_mode)))
                        return 0;
        default:
                return TYPE_CHANGED;
@@ -142,7 +142,7 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
                    (has_symlinks || !S_ISREG(st->st_mode)))
                        changed |= TYPE_CHANGED;
                break;
-       case S_IFDIRLNK:
+       case S_IFGITLINK:
                if (!S_ISDIR(st->st_mode))
                        changed |= TYPE_CHANGED;
                else if (ce_compare_gitlink(ce))
@@ -166,7 +166,7 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
                changed |= MTIME_CHANGED;
        if (ce->ce_ctime.nsec != htonl(st->st_ctim.tv_nsec))
                changed |= CTIME_CHANGED;
-#endif 
+#endif
 
        if (ce->ce_uid != htonl(st->st_uid) ||
            ce->ce_gid != htonl(st->st_gid))
@@ -597,7 +597,7 @@ static int has_dir_name(struct index_state *istate,
  * is being added, or we already have path and path/file is being
  * added.  Either one would result in a nonsense tree that has path
  * twice when git-write-tree tries to write it out.  Prevent it.
- * 
+ *
  * If ok-to-replace is specified, we remove the conflicting entries
  * from the cache so the caller should recompute the insert position.
  * When this happens, we return non-zero.
@@ -970,8 +970,8 @@ static int ce_write(SHA_CTX *context, int fd, void *data, unsigned int len)
                write_buffer_len = buffered;
                len -= partial;
                data = (char *) data + partial;
-       }
-       return 0;
+       }
+       return 0;
 }
 
 static int write_index_ext_header(SHA_CTX *context, int fd,
@@ -1037,7 +1037,7 @@ static void ce_smudge_racily_clean_entry(struct cache_entry *ce)
                 * size to zero here, then the object name recorded
                 * in index is the 6-byte file but the cached stat information
                 * becomes zero --- which would then match what we would
-                * obtain from the filesystem next time we stat("frotz"). 
+                * obtain from the filesystem next time we stat("frotz").
                 *
                 * However, the second update-index, before calling
                 * this function, notices that the cached size is 6
index 26aa26bcb5089adcf400d12b673519e328b49a23..d3c422be58c5ee1af7e75cf4186bc9bbfb19ec30 100644 (file)
@@ -209,7 +209,7 @@ static const char *update(struct command *cmd)
                return NULL; /* good */
        }
        else {
-               lock = lock_any_ref_for_update(name, old_sha1);
+               lock = lock_any_ref_for_update(name, old_sha1, 0);
                if (!lock) {
                        error("failed to lock %s", name);
                        return "failed to lock";
diff --git a/refs.c b/refs.c
index 89876bff871d007a6675f5790ce8cb34fe21fb39..ef4484d2937727b131eade1c6b62180cd9722976 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -603,15 +603,20 @@ int get_ref_sha1(const char *ref, unsigned char *sha1)
 
 static inline int bad_ref_char(int ch)
 {
-       return (((unsigned) ch) <= ' ' ||
-               ch == '~' || ch == '^' || ch == ':' ||
-               /* 2.13 Pattern Matching Notation */
-               ch == '?' || ch == '*' || ch == '[');
+       if (((unsigned) ch) <= ' ' ||
+           ch == '~' || ch == '^' || ch == ':')
+               return 1;
+       /* 2.13 Pattern Matching Notation */
+       if (ch == '?' || ch == '[') /* Unsupported */
+               return 1;
+       if (ch == '*') /* Supported at the end */
+               return 2;
+       return 0;
 }
 
 int check_ref_format(const char *ref)
 {
-       int ch, level;
+       int ch, level, bad_type;
        const char *cp = ref;
 
        level = 0;
@@ -622,13 +627,19 @@ int check_ref_format(const char *ref)
                        return -1; /* should not end with slashes */
 
                /* we are at the beginning of the path component */
-               if (ch == '.' || bad_ref_char(ch))
+               if (ch == '.')
                        return -1;
+               bad_type = bad_ref_char(ch);
+               if (bad_type) {
+                       return (bad_type == 2 && !*cp) ? -3 : -1;
+               }
 
                /* scan the rest of the path component */
                while ((ch = *cp++) != 0) {
-                       if (bad_ref_char(ch))
-                               return -1;
+                       bad_type = bad_ref_char(ch);
+                       if (bad_type) {
+                               return (bad_type == 2 && !*cp) ? -3 : -1;
+                       }
                        if (ch == '/')
                                break;
                        if (ch == '.' && *cp == '.')
@@ -736,19 +747,20 @@ static int is_refname_available(const char *ref, const char *oldref,
        return 1;
 }
 
-static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char *old_sha1, int *flag)
+static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char *old_sha1, int flags, int *type_p)
 {
        char *ref_file;
        const char *orig_ref = ref;
        struct ref_lock *lock;
        struct stat st;
        int last_errno = 0;
+       int type;
        int mustexist = (old_sha1 && !is_null_sha1(old_sha1));
 
        lock = xcalloc(1, sizeof(struct ref_lock));
        lock->lock_fd = -1;
 
-       ref = resolve_ref(ref, lock->old_sha1, mustexist, flag);
+       ref = resolve_ref(ref, lock->old_sha1, mustexist, &type);
        if (!ref && errno == EISDIR) {
                /* we are trying to lock foo but we used to
                 * have foo/bar which now does not exist;
@@ -761,8 +773,10 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
                        error("there are still refs under '%s'", orig_ref);
                        goto error_return;
                }
-               ref = resolve_ref(orig_ref, lock->old_sha1, mustexist, flag);
+               ref = resolve_ref(orig_ref, lock->old_sha1, mustexist, &type);
        }
+       if (type_p)
+           *type_p = type;
        if (!ref) {
                last_errno = errno;
                error("unable to resolve reference %s: %s",
@@ -780,10 +794,15 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
 
        lock->lk = xcalloc(1, sizeof(struct lock_file));
 
+       if (flags & REF_NODEREF)
+               ref = orig_ref;
        lock->ref_name = xstrdup(ref);
        lock->orig_ref_name = xstrdup(orig_ref);
        ref_file = git_path("%s", ref);
-       lock->force_write = lstat(ref_file, &st) && errno == ENOENT;
+       if (lstat(ref_file, &st) && errno == ENOENT)
+               lock->force_write = 1;
+       if ((flags & REF_NODEREF) && (type & REF_ISSYMREF))
+               lock->force_write = 1;
 
        if (safe_create_leading_directories(ref_file)) {
                last_errno = errno;
@@ -806,14 +825,14 @@ struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1)
        if (check_ref_format(ref))
                return NULL;
        strcpy(refpath, mkpath("refs/%s", ref));
-       return lock_ref_sha1_basic(refpath, old_sha1, NULL);
+       return lock_ref_sha1_basic(refpath, old_sha1, 0, NULL);
 }
 
-struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1)
+struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int flags)
 {
        if (check_ref_format(ref) == -1)
                return NULL;
-       return lock_ref_sha1_basic(ref, old_sha1, NULL);
+       return lock_ref_sha1_basic(ref, old_sha1, flags, NULL);
 }
 
 static struct lock_file packlock;
@@ -858,7 +877,7 @@ int delete_ref(const char *refname, const unsigned char *sha1)
        struct ref_lock *lock;
        int err, i, ret = 0, flag = 0;
 
-       lock = lock_ref_sha1_basic(refname, sha1, &flag);
+       lock = lock_ref_sha1_basic(refname, sha1, 0, &flag);
        if (!lock)
                return 1;
        if (!(flag & REF_ISPACKED)) {
@@ -909,7 +928,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
        if (!is_refname_available(newref, oldref, get_loose_refs(), 0))
                return 1;
 
-       lock = lock_ref_sha1_basic(renamed_ref, NULL, NULL);
+       lock = lock_ref_sha1_basic(renamed_ref, NULL, 0, NULL);
        if (!lock)
                return error("unable to lock %s", renamed_ref);
        lock->force_write = 1;
@@ -963,7 +982,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
        }
        logmoved = log;
 
-       lock = lock_ref_sha1_basic(newref, NULL, NULL);
+       lock = lock_ref_sha1_basic(newref, NULL, 0, NULL);
        if (!lock) {
                error("unable to lock %s for update", newref);
                goto rollback;
@@ -979,7 +998,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
        return 0;
 
  rollback:
-       lock = lock_ref_sha1_basic(oldref, NULL, NULL);
+       lock = lock_ref_sha1_basic(oldref, NULL, 0, NULL);
        if (!lock) {
                error("unable to lock %s for rollback", oldref);
                goto rollbacklog;
diff --git a/refs.h b/refs.h
index f61f6d934e80b21432f93cd3b9f138770a9d2b86..f234eb76ba5d6aba03f484fe58d11ba81a90ff5a 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -33,7 +33,8 @@ extern int get_ref_sha1(const char *ref, unsigned char *sha1);
 extern struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1);
 
 /** Locks any ref (for 'HEAD' type refs). */
-extern struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1);
+#define REF_NODEREF    0x01
+extern struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int flags);
 
 /** Release any lock taken but not written. **/
 extern void unlock_ref(struct ref_lock *lock);
diff --git a/remote.c b/remote.c
new file mode 100644 (file)
index 0000000..33c8e50
--- /dev/null
+++ b/remote.c
@@ -0,0 +1,568 @@
+#include "cache.h"
+#include "remote.h"
+#include "refs.h"
+
+static struct remote **remotes;
+static int allocated_remotes;
+
+#define BUF_SIZE (2048)
+static char buffer[BUF_SIZE];
+
+static void add_push_refspec(struct remote *remote, const char *ref)
+{
+       int nr = remote->push_refspec_nr + 1;
+       remote->push_refspec =
+               xrealloc(remote->push_refspec, nr * sizeof(char *));
+       remote->push_refspec[nr-1] = ref;
+       remote->push_refspec_nr = nr;
+}
+
+static void add_fetch_refspec(struct remote *remote, const char *ref)
+{
+       int nr = remote->fetch_refspec_nr + 1;
+       remote->fetch_refspec =
+               xrealloc(remote->fetch_refspec, nr * sizeof(char *));
+       remote->fetch_refspec[nr-1] = ref;
+       remote->fetch_refspec_nr = nr;
+}
+
+static void add_uri(struct remote *remote, const char *uri)
+{
+       int nr = remote->uri_nr + 1;
+       remote->uri =
+               xrealloc(remote->uri, nr * sizeof(char *));
+       remote->uri[nr-1] = uri;
+       remote->uri_nr = nr;
+}
+
+static struct remote *make_remote(const char *name, int len)
+{
+       int i, empty = -1;
+
+       for (i = 0; i < allocated_remotes; i++) {
+               if (!remotes[i]) {
+                       if (empty < 0)
+                               empty = i;
+               } else {
+                       if (len ? (!strncmp(name, remotes[i]->name, len) &&
+                                  !remotes[i]->name[len]) :
+                           !strcmp(name, remotes[i]->name))
+                               return remotes[i];
+               }
+       }
+
+       if (empty < 0) {
+               empty = allocated_remotes;
+               allocated_remotes += allocated_remotes ? allocated_remotes : 1;
+               remotes = xrealloc(remotes,
+                                  sizeof(*remotes) * allocated_remotes);
+               memset(remotes + empty, 0,
+                      (allocated_remotes - empty) * sizeof(*remotes));
+       }
+       remotes[empty] = xcalloc(1, sizeof(struct remote));
+       if (len)
+               remotes[empty]->name = xstrndup(name, len);
+       else
+               remotes[empty]->name = xstrdup(name);
+       return remotes[empty];
+}
+
+static void read_remotes_file(struct remote *remote)
+{
+       FILE *f = fopen(git_path("remotes/%s", remote->name), "r");
+
+       if (!f)
+               return;
+       while (fgets(buffer, BUF_SIZE, f)) {
+               int value_list;
+               char *s, *p;
+
+               if (!prefixcmp(buffer, "URL:")) {
+                       value_list = 0;
+                       s = buffer + 4;
+               } else if (!prefixcmp(buffer, "Push:")) {
+                       value_list = 1;
+                       s = buffer + 5;
+               } else if (!prefixcmp(buffer, "Pull:")) {
+                       value_list = 2;
+                       s = buffer + 5;
+               } else
+                       continue;
+
+               while (isspace(*s))
+                       s++;
+               if (!*s)
+                       continue;
+
+               p = s + strlen(s);
+               while (isspace(p[-1]))
+                       *--p = 0;
+
+               switch (value_list) {
+               case 0:
+                       add_uri(remote, xstrdup(s));
+                       break;
+               case 1:
+                       add_push_refspec(remote, xstrdup(s));
+                       break;
+               case 2:
+                       add_fetch_refspec(remote, xstrdup(s));
+                       break;
+               }
+       }
+       fclose(f);
+}
+
+static void read_branches_file(struct remote *remote)
+{
+       const char *slash = strchr(remote->name, '/');
+       int n = slash ? slash - remote->name : 1000;
+       FILE *f = fopen(git_path("branches/%.*s", n, remote->name), "r");
+       char *s, *p;
+       int len;
+
+       if (!f)
+               return;
+       s = fgets(buffer, BUF_SIZE, f);
+       fclose(f);
+       if (!s)
+               return;
+       while (isspace(*s))
+               s++;
+       if (!*s)
+               return;
+       p = s + strlen(s);
+       while (isspace(p[-1]))
+               *--p = 0;
+       len = p - s;
+       if (slash)
+               len += strlen(slash);
+       p = xmalloc(len + 1);
+       strcpy(p, s);
+       if (slash)
+               strcat(p, slash);
+       add_uri(remote, p);
+}
+
+static char *default_remote_name = NULL;
+static const char *current_branch = NULL;
+static int current_branch_len = 0;
+
+static int handle_config(const char *key, const char *value)
+{
+       const char *name;
+       const char *subkey;
+       struct remote *remote;
+       if (!prefixcmp(key, "branch.") && current_branch &&
+           !strncmp(key + 7, current_branch, current_branch_len) &&
+           !strcmp(key + 7 + current_branch_len, ".remote")) {
+               free(default_remote_name);
+               default_remote_name = xstrdup(value);
+       }
+       if (prefixcmp(key,  "remote."))
+               return 0;
+       name = key + 7;
+       subkey = strrchr(name, '.');
+       if (!subkey)
+               return error("Config with no key for remote %s", name);
+       if (*subkey == '/') {
+               warning("Config remote shorthand cannot begin with '/': %s", name);
+               return 0;
+       }
+       remote = make_remote(name, subkey - name);
+       if (!value) {
+               /* if we ever have a boolean variable, e.g. "remote.*.disabled"
+                * [remote "frotz"]
+                *      disabled
+                * is a valid way to set it to true; we get NULL in value so
+                * we need to handle it here.
+                *
+                * if (!strcmp(subkey, ".disabled")) {
+                *      val = git_config_bool(key, value);
+                *      return 0;
+                * } else
+                *
+                */
+               return 0; /* ignore unknown booleans */
+       }
+       if (!strcmp(subkey, ".url")) {
+               add_uri(remote, xstrdup(value));
+       } else if (!strcmp(subkey, ".push")) {
+               add_push_refspec(remote, xstrdup(value));
+       } else if (!strcmp(subkey, ".fetch")) {
+               add_fetch_refspec(remote, xstrdup(value));
+       } else if (!strcmp(subkey, ".receivepack")) {
+               if (!remote->receivepack)
+                       remote->receivepack = xstrdup(value);
+               else
+                       error("more than one receivepack given, using the first");
+       }
+       return 0;
+}
+
+static void read_config(void)
+{
+       unsigned char sha1[20];
+       const char *head_ref;
+       int flag;
+       if (default_remote_name) // did this already
+               return;
+       default_remote_name = xstrdup("origin");
+       current_branch = NULL;
+       head_ref = resolve_ref("HEAD", sha1, 0, &flag);
+       if (head_ref && (flag & REF_ISSYMREF) &&
+           !prefixcmp(head_ref, "refs/heads/")) {
+               current_branch = head_ref + strlen("refs/heads/");
+               current_branch_len = strlen(current_branch);
+       }
+       git_config(handle_config);
+}
+
+static struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)
+{
+       int i;
+       struct refspec *rs = xcalloc(sizeof(*rs), nr_refspec);
+       for (i = 0; i < nr_refspec; i++) {
+               const char *sp, *ep, *gp;
+               sp = refspec[i];
+               if (*sp == '+') {
+                       rs[i].force = 1;
+                       sp++;
+               }
+               gp = strchr(sp, '*');
+               ep = strchr(sp, ':');
+               if (gp && ep && gp > ep)
+                       gp = NULL;
+               if (ep) {
+                       if (ep[1]) {
+                               const char *glob = strchr(ep + 1, '*');
+                               if (!glob)
+                                       gp = NULL;
+                               if (gp)
+                                       rs[i].dst = xstrndup(ep + 1,
+                                                            glob - ep - 1);
+                               else
+                                       rs[i].dst = xstrdup(ep + 1);
+                       }
+               } else {
+                       ep = sp + strlen(sp);
+               }
+               if (gp) {
+                       rs[i].pattern = 1;
+                       ep = gp;
+               }
+               rs[i].src = xstrndup(sp, ep - sp);
+       }
+       return rs;
+}
+
+struct remote *remote_get(const char *name)
+{
+       struct remote *ret;
+
+       read_config();
+       if (!name)
+               name = default_remote_name;
+       ret = make_remote(name, 0);
+       if (name[0] != '/') {
+               if (!ret->uri)
+                       read_remotes_file(ret);
+               if (!ret->uri)
+                       read_branches_file(ret);
+       }
+       if (!ret->uri)
+               add_uri(ret, name);
+       if (!ret->uri)
+               return NULL;
+       ret->fetch = parse_ref_spec(ret->fetch_refspec_nr, ret->fetch_refspec);
+       ret->push = parse_ref_spec(ret->push_refspec_nr, ret->push_refspec);
+       return ret;
+}
+
+int remote_has_uri(struct remote *remote, const char *uri)
+{
+       int i;
+       for (i = 0; i < remote->uri_nr; i++) {
+               if (!strcmp(remote->uri[i], uri))
+                       return 1;
+       }
+       return 0;
+}
+
+int remote_find_tracking(struct remote *remote, struct refspec *refspec)
+{
+       int i;
+       for (i = 0; i < remote->fetch_refspec_nr; i++) {
+               struct refspec *fetch = &remote->fetch[i];
+               if (!fetch->dst)
+                       continue;
+               if (fetch->pattern) {
+                       if (!prefixcmp(refspec->src, fetch->src)) {
+                               refspec->dst =
+                                       xmalloc(strlen(fetch->dst) +
+                                               strlen(refspec->src) -
+                                               strlen(fetch->src) + 1);
+                               strcpy(refspec->dst, fetch->dst);
+                               strcpy(refspec->dst + strlen(fetch->dst),
+                                      refspec->src + strlen(fetch->src));
+                               refspec->force = fetch->force;
+                               return 0;
+                       }
+               } else {
+                       if (!strcmp(refspec->src, fetch->src)) {
+                               refspec->dst = xstrdup(fetch->dst);
+                               refspec->force = fetch->force;
+                               return 0;
+                       }
+               }
+       }
+       refspec->dst = NULL;
+       return -1;
+}
+
+static int count_refspec_match(const char *pattern,
+                              struct ref *refs,
+                              struct ref **matched_ref)
+{
+       int patlen = strlen(pattern);
+       struct ref *matched_weak = NULL;
+       struct ref *matched = NULL;
+       int weak_match = 0;
+       int match = 0;
+
+       for (weak_match = match = 0; refs; refs = refs->next) {
+               char *name = refs->name;
+               int namelen = strlen(name);
+               int weak_match;
+
+               if (namelen < patlen ||
+                   memcmp(name + namelen - patlen, pattern, patlen))
+                       continue;
+               if (namelen != patlen && name[namelen - patlen - 1] != '/')
+                       continue;
+
+               /* A match is "weak" if it is with refs outside
+                * heads or tags, and did not specify the pattern
+                * in full (e.g. "refs/remotes/origin/master") or at
+                * least from the toplevel (e.g. "remotes/origin/master");
+                * otherwise "git push $URL master" would result in
+                * ambiguity between remotes/origin/master and heads/master
+                * at the remote site.
+                */
+               if (namelen != patlen &&
+                   patlen != namelen - 5 &&
+                   prefixcmp(name, "refs/heads/") &&
+                   prefixcmp(name, "refs/tags/")) {
+                       /* We want to catch the case where only weak
+                        * matches are found and there are multiple
+                        * matches, and where more than one strong
+                        * matches are found, as ambiguous.  One
+                        * strong match with zero or more weak matches
+                        * are acceptable as a unique match.
+                        */
+                       matched_weak = refs;
+                       weak_match++;
+               }
+               else {
+                       matched = refs;
+                       match++;
+               }
+       }
+       if (!matched) {
+               *matched_ref = matched_weak;
+               return weak_match;
+       }
+       else {
+               *matched_ref = matched;
+               return match;
+       }
+}
+
+static void link_dst_tail(struct ref *ref, struct ref ***tail)
+{
+       **tail = ref;
+       *tail = &ref->next;
+       **tail = NULL;
+}
+
+static struct ref *try_explicit_object_name(const char *name)
+{
+       unsigned char sha1[20];
+       struct ref *ref;
+       int len;
+
+       if (!*name) {
+               ref = xcalloc(1, sizeof(*ref) + 20);
+               strcpy(ref->name, "(delete)");
+               hashclr(ref->new_sha1);
+               return ref;
+       }
+       if (get_sha1(name, sha1))
+               return NULL;
+       len = strlen(name) + 1;
+       ref = xcalloc(1, sizeof(*ref) + len);
+       memcpy(ref->name, name, len);
+       hashcpy(ref->new_sha1, sha1);
+       return ref;
+}
+
+static int match_explicit_refs(struct ref *src, struct ref *dst,
+                              struct ref ***dst_tail, struct refspec *rs,
+                              int rs_nr)
+{
+       int i, errs;
+       for (i = errs = 0; i < rs_nr; i++) {
+               struct ref *matched_src, *matched_dst;
+
+               const char *dst_value = rs[i].dst;
+
+               if (rs[i].pattern)
+                       continue;
+
+               if (dst_value == NULL)
+                       dst_value = rs[i].src;
+
+               matched_src = matched_dst = NULL;
+               switch (count_refspec_match(rs[i].src, src, &matched_src)) {
+               case 1:
+                       break;
+               case 0:
+                       /* The source could be in the get_sha1() format
+                        * not a reference name.  :refs/other is a
+                        * way to delete 'other' ref at the remote end.
+                        */
+                       matched_src = try_explicit_object_name(rs[i].src);
+                       if (matched_src)
+                               break;
+                       errs = 1;
+                       error("src refspec %s does not match any.",
+                             rs[i].src);
+                       break;
+               default:
+                       errs = 1;
+                       error("src refspec %s matches more than one.",
+                             rs[i].src);
+                       break;
+               }
+               switch (count_refspec_match(dst_value, dst, &matched_dst)) {
+               case 1:
+                       break;
+               case 0:
+                       if (!memcmp(dst_value, "refs/", 5)) {
+                               int len = strlen(dst_value) + 1;
+                               matched_dst = xcalloc(1, sizeof(*dst) + len);
+                               memcpy(matched_dst->name, dst_value, len);
+                               link_dst_tail(matched_dst, dst_tail);
+                       }
+                       else if (!strcmp(rs[i].src, dst_value) &&
+                                matched_src) {
+                               /* pushing "master:master" when
+                                * remote does not have master yet.
+                                */
+                               int len = strlen(matched_src->name) + 1;
+                               matched_dst = xcalloc(1, sizeof(*dst) + len);
+                               memcpy(matched_dst->name, matched_src->name,
+                                      len);
+                               link_dst_tail(matched_dst, dst_tail);
+                       }
+                       else {
+                               errs = 1;
+                               error("dst refspec %s does not match any "
+                                     "existing ref on the remote and does "
+                                     "not start with refs/.", dst_value);
+                       }
+                       break;
+               default:
+                       errs = 1;
+                       error("dst refspec %s matches more than one.",
+                             dst_value);
+                       break;
+               }
+               if (errs)
+                       continue;
+               if (matched_dst->peer_ref) {
+                       errs = 1;
+                       error("dst ref %s receives from more than one src.",
+                             matched_dst->name);
+               }
+               else {
+                       matched_dst->peer_ref = matched_src;
+                       matched_dst->force = rs[i].force;
+               }
+       }
+       return -errs;
+}
+
+static struct ref *find_ref_by_name(struct ref *list, const char *name)
+{
+       for ( ; list; list = list->next)
+               if (!strcmp(list->name, name))
+                       return list;
+       return NULL;
+}
+
+static const struct refspec *check_pattern_match(const struct refspec *rs,
+                                                int rs_nr,
+                                                const struct ref *src)
+{
+       int i;
+       for (i = 0; i < rs_nr; i++) {
+               if (rs[i].pattern && !prefixcmp(src->name, rs[i].src))
+                       return rs + i;
+       }
+       return NULL;
+}
+
+int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
+              int nr_refspec, char **refspec, int all)
+{
+       struct refspec *rs =
+               parse_ref_spec(nr_refspec, (const char **) refspec);
+
+       if (match_explicit_refs(src, dst, dst_tail, rs, nr_refspec))
+               return -1;
+
+       /* pick the remainder */
+       for ( ; src; src = src->next) {
+               struct ref *dst_peer;
+               const struct refspec *pat = NULL;
+               char *dst_name;
+               if (src->peer_ref)
+                       continue;
+               if (nr_refspec) {
+                       pat = check_pattern_match(rs, nr_refspec, src);
+                       if (!pat)
+                               continue;
+               }
+
+               if (pat) {
+                       dst_name = xmalloc(strlen(pat->dst) +
+                                          strlen(src->name) -
+                                          strlen(pat->src) + 2);
+                       strcpy(dst_name, pat->dst);
+                       strcat(dst_name, src->name + strlen(pat->src));
+               } else
+                       dst_name = strdup(src->name);
+               dst_peer = find_ref_by_name(dst, dst_name);
+               if (dst_peer && dst_peer->peer_ref)
+                       /* We're already sending something to this ref. */
+                       goto free_name;
+               if (!dst_peer && !nr_refspec && !all)
+                       /* Remote doesn't have it, and we have no
+                        * explicit pattern, and we don't have
+                        * --all. */
+                       goto free_name;
+               if (!dst_peer) {
+                       /* Create a new one and link it */
+                       int len = strlen(dst_name) + 1;
+                       dst_peer = xcalloc(1, sizeof(*dst_peer) + len);
+                       memcpy(dst_peer->name, dst_name, len);
+                       hashcpy(dst_peer->new_sha1, src->new_sha1);
+                       link_dst_tail(dst_peer, dst_tail);
+               }
+               dst_peer->peer_ref = src;
+       free_name:
+               free(dst_name);
+       }
+       return 0;
+}
diff --git a/remote.h b/remote.h
new file mode 100644 (file)
index 0000000..01dbcef
--- /dev/null
+++ b/remote.h
@@ -0,0 +1,41 @@
+#ifndef REMOTE_H
+#define REMOTE_H
+
+struct remote {
+       const char *name;
+
+       const char **uri;
+       int uri_nr;
+
+       const char **push_refspec;
+       struct refspec *push;
+       int push_refspec_nr;
+
+       const char **fetch_refspec;
+       struct refspec *fetch;
+       int fetch_refspec_nr;
+
+       const char *receivepack;
+};
+
+struct remote *remote_get(const char *name);
+
+int remote_has_uri(struct remote *remote, const char *uri);
+
+struct refspec {
+       unsigned force : 1;
+       unsigned pattern : 1;
+
+       const char *src;
+       char *dst;
+};
+
+int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
+              int nr_refspec, char **refspec, int all);
+
+/*
+ * For the given remote, reads the refspec's src and sets the other fields.
+ */
+int remote_find_tracking(struct remote *remote, struct refspec *refspec);
+
+#endif
index 0125d41136871ad2cd07daaaabf40bd2f902a44f..b12c25e2b0c8e2c1d3bb097739f3c132a296c964 100644 (file)
@@ -114,12 +114,7 @@ void mark_parents_uninteresting(struct commit *commit)
        }
 }
 
-void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
-{
-       add_pending_object_with_mode(revs, obj, name, S_IFINVALID);
-}
-
-void add_pending_object_with_mode(struct rev_info *revs, struct object *obj, const char *name, unsigned mode)
+static void add_pending_object_with_mode(struct rev_info *revs, struct object *obj, const char *name, unsigned mode)
 {
        if (revs->no_walk && (obj->flags & UNINTERESTING))
                die("object ranges do not make sense when not walking revisions");
@@ -129,6 +124,11 @@ void add_pending_object_with_mode(struct rev_info *revs, struct object *obj, con
                                (struct commit *)obj, name);
 }
 
+void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
+{
+       add_pending_object_with_mode(revs, obj, name, S_IFINVALID);
+}
+
 static struct object *get_reference(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags)
 {
        struct object *object;
@@ -262,7 +262,7 @@ static void file_change(struct diff_options *options,
        options->has_changes = 1;
 }
 
-int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)
+static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)
 {
        if (!t1)
                return REV_TREE_NEW;
@@ -276,7 +276,7 @@ int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)
        return tree_difference;
 }
 
-int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)
+static int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)
 {
        int retval;
        void *tree;
@@ -881,6 +881,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
        const char **unrecognized = argv + 1;
        int left = 1;
        int all_match = 0;
+       int regflags = 0;
 
        /* First, search for "--" */
        seen_dashdash = 0;
@@ -1152,6 +1153,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                                add_message_grep(revs, arg+7);
                                continue;
                        }
+                       if (!prefixcmp(arg, "--extended-regexp")) {
+                               regflags |= REG_EXTENDED;
+                               continue;
+                       }
+                       if (!prefixcmp(arg, "--regexp-ignore-case")) {
+                               regflags |= REG_ICASE;
+                               continue;
+                       }
                        if (!strcmp(arg, "--all-match")) {
                                all_match = 1;
                                continue;
@@ -1200,6 +1209,9 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                }
        }
 
+       if (revs->grep_filter)
+               revs->grep_filter->regflags |= regflags;
+
        if (show_merge)
                prepare_show_merge(revs);
        if (def && !revs->pending.nr) {
index 2845167746ce4632894fce88e840df60513933aa..f46b4d55a2c75e201b37dda8edd6d353722a96cb 100644 (file)
@@ -106,8 +106,6 @@ struct rev_info {
 #define REV_TREE_DIFFERENT     2
 
 /* revision.c */
-extern int rev_same_tree_as_empty(struct rev_info *, struct tree *t1);
-extern int rev_compare_tree(struct rev_info *, struct tree *t1, struct tree *t2);
 
 extern void init_revisions(struct rev_info *revs, const char *prefix);
 extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def);
@@ -131,6 +129,5 @@ extern void add_object(struct object *obj,
                       const char *name);
 
 extern void add_pending_object(struct rev_info *revs, struct object *obj, const char *name);
-extern void add_pending_object_with_mode(struct rev_info *revs, struct object *obj, const char *name, unsigned mode);
 
 #endif
diff --git a/rsh.h b/rsh.h
index 3b4194239dc419c38910012b129c4c92b72ef8ad..ee2f49929131c684bcffa3e95a1ee29521e8818b 100644 (file)
--- a/rsh.h
+++ b/rsh.h
@@ -1,7 +1,7 @@
 #ifndef RSH_H
 #define RSH_H
 
-int setup_connection(int *fd_in, int *fd_out, const char *remote_prog, 
+int setup_connection(int *fd_in, int *fd_out, const char *remote_prog,
                     char *url, int rmt_argc, char **rmt_argv);
 
 #endif
index eff523e191b35385895f6b077fc76c7c21819012..7e779d33ee9ea5f7d2e6aedc8c3a0a0476e87135 100644 (file)
@@ -73,6 +73,17 @@ int start_command(struct child_process *cmd)
                        close(cmd->out);
                }
 
+               if (cmd->dir && chdir(cmd->dir))
+                       die("exec %s: cd to %s failed (%s)", cmd->argv[0],
+                           cmd->dir, strerror(errno));
+               if (cmd->env) {
+                       for (; *cmd->env; cmd->env++) {
+                               if (strchr(*cmd->env, '='))
+                                       putenv((char*)*cmd->env);
+                               else
+                                       unsetenv(*cmd->env);
+                       }
+               }
                if (cmd->git_cmd) {
                        execv_git_cmd(cmd->argv);
                } else {
@@ -133,13 +144,37 @@ int run_command(struct child_process *cmd)
        return finish_command(cmd);
 }
 
+static void prepare_run_command_v_opt(struct child_process *cmd,
+                                     const char **argv,
+                                     int opt)
+{
+       memset(cmd, 0, sizeof(*cmd));
+       cmd->argv = argv;
+       cmd->no_stdin = opt & RUN_COMMAND_NO_STDIN ? 1 : 0;
+       cmd->git_cmd = opt & RUN_GIT_CMD ? 1 : 0;
+       cmd->stdout_to_stderr = opt & RUN_COMMAND_STDOUT_TO_STDERR ? 1 : 0;
+}
+
 int run_command_v_opt(const char **argv, int opt)
 {
        struct child_process cmd;
-       memset(&cmd, 0, sizeof(cmd));
-       cmd.argv = argv;
-       cmd.no_stdin = opt & RUN_COMMAND_NO_STDIN ? 1 : 0;
-       cmd.git_cmd = opt & RUN_GIT_CMD ? 1 : 0;
-       cmd.stdout_to_stderr = opt & RUN_COMMAND_STDOUT_TO_STDERR ? 1 : 0;
+       prepare_run_command_v_opt(&cmd, argv, opt);
+       return run_command(&cmd);
+}
+
+int run_command_v_opt_cd(const char **argv, int opt, const char *dir)
+{
+       struct child_process cmd;
+       prepare_run_command_v_opt(&cmd, argv, opt);
+       cmd.dir = dir;
+       return run_command(&cmd);
+}
+
+int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env)
+{
+       struct child_process cmd;
+       prepare_run_command_v_opt(&cmd, argv, opt);
+       cmd.dir = dir;
+       cmd.env = env;
        return run_command(&cmd);
 }
index 3680ef9d452490c67788b0ab027839a8383ed855..7958eb1e0b7a927019460e06d7a01622eddf81df 100644 (file)
@@ -16,6 +16,8 @@ struct child_process {
        pid_t pid;
        int in;
        int out;
+       const char *dir;
+       const char *const *env;
        unsigned close_in:1;
        unsigned close_out:1;
        unsigned no_stdin:1;
@@ -32,5 +34,12 @@ int run_command(struct child_process *);
 #define RUN_GIT_CMD         2  /*If this is to be git sub-command */
 #define RUN_COMMAND_STDOUT_TO_STDERR 4
 int run_command_v_opt(const char **argv, int opt);
+int run_command_v_opt_cd(const char **argv, int opt, const char *dir);
+
+/*
+ * env (the environment) is to be formatted like environ: "VAR=VALUE".
+ * To unset an environment variable use just "VAR".
+ */
+int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env);
 
 #endif
index d5b51628dfbcc44b22b5069df19eeac67dda1e57..fecbda981b7c6c2504abdd7afb94e35e73e18cce 100644 (file)
@@ -4,6 +4,7 @@
 #include "refs.h"
 #include "pkt-line.h"
 #include "run-command.h"
+#include "remote.h"
 
 static const char send_pack_usage[] =
 "git-send-pack [--all] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
@@ -176,7 +177,7 @@ static int receive_status(int in)
        return ret;
 }
 
-static int send_pack(int in, int out, int nr_refspec, char **refspec)
+static int send_pack(int in, int out, struct remote *remote, int nr_refspec, char **refspec)
 {
        struct ref *ref;
        int new_refs;
@@ -213,18 +214,19 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
        new_refs = 0;
        for (ref = remote_refs; ref; ref = ref->next) {
                char old_hex[60], *new_hex;
-               int delete_ref;
+               int will_delete_ref;
 
                if (!ref->peer_ref)
                        continue;
 
-               delete_ref = is_null_sha1(ref->peer_ref->new_sha1);
-               if (delete_ref && !allow_deleting_refs) {
+
+               will_delete_ref = is_null_sha1(ref->peer_ref->new_sha1);
+               if (will_delete_ref && !allow_deleting_refs) {
                        error("remote does not support deleting refs");
                        ret = -2;
                        continue;
                }
-               if (!delete_ref &&
+               if (!will_delete_ref &&
                    !hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {
                        if (verbose)
                                fprintf(stderr, "'%s': up-to-date\n", ref->name);
@@ -251,7 +253,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
                 */
 
                if (!force_update &&
-                   !delete_ref &&
+                   !will_delete_ref &&
                    !is_null_sha1(ref->old_sha1) &&
                    !ref->force) {
                        if (!has_sha1_file(ref->old_sha1) ||
@@ -275,7 +277,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
                        }
                }
                hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
-               if (!delete_ref)
+               if (!will_delete_ref)
                        new_refs++;
                strcpy(old_hex, sha1_to_hex(ref->old_sha1));
                new_hex = sha1_to_hex(ref->new_sha1);
@@ -290,7 +292,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
                else
                        packet_write(out, "%s %s %s",
                                     old_hex, new_hex, ref->name);
-               if (delete_ref)
+               if (will_delete_ref)
                        fprintf(stderr, "deleting '%s'\n", ref->name);
                else {
                        fprintf(stderr, "updating '%s'", ref->name);
@@ -300,6 +302,28 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
                        fprintf(stderr, "\n  from %s\n  to   %s\n",
                                old_hex, new_hex);
                }
+               if (remote) {
+                       struct refspec rs;
+                       rs.src = ref->name;
+                       remote_find_tracking(remote, &rs);
+                       if (rs.dst) {
+                               struct ref_lock *lock;
+                               fprintf(stderr, " Also local %s\n", rs.dst);
+                               if (will_delete_ref) {
+                                       if (delete_ref(rs.dst, NULL)) {
+                                               error("Failed to delete");
+                                       }
+                               } else {
+                                       lock = lock_any_ref_for_update(rs.dst, NULL, 0);
+                                       if (!lock)
+                                               error("Failed to lock");
+                                       else
+                                               write_ref_sha1(lock, ref->new_sha1,
+                                                              "update by push");
+                               }
+                               free(rs.dst);
+                       }
+               }
        }
 
        packet_flush(out);
@@ -330,6 +354,7 @@ static void verify_remote_names(int nr_heads, char **heads)
                case -2: /* ok but a single level -- that is fine for
                          * a match pattern.
                          */
+               case -3: /* ok but ends with a pattern-match character */
                        continue;
                }
                die("remote part of refspec is not a valid name in %s",
@@ -344,6 +369,8 @@ int main(int argc, char **argv)
        char **heads = NULL;
        int fd[2], ret;
        pid_t pid;
+       char *remote_name = NULL;
+       struct remote *remote = NULL;
 
        setup_git_directory();
        git_config(git_default_config);
@@ -361,6 +388,10 @@ int main(int argc, char **argv)
                                receivepack = arg + 7;
                                continue;
                        }
+                       if (!prefixcmp(arg, "--remote=")) {
+                               remote_name = arg + 9;
+                               continue;
+                       }
                        if (!strcmp(arg, "--all")) {
                                send_all = 1;
                                continue;
@@ -393,10 +424,18 @@ int main(int argc, char **argv)
                usage(send_pack_usage);
        verify_remote_names(nr_heads, heads);
 
-       pid = git_connect(fd, dest, receivepack);
+       if (remote_name) {
+               remote = remote_get(remote_name);
+               if (!remote_has_uri(remote, dest)) {
+                       die("Destination %s is not a uri for %s",
+                           dest, remote_name);
+               }
+       }
+
+       pid = git_connect(fd, dest, receivepack, verbose ? CONNECT_VERBOSE : 0);
        if (pid < 0)
                return 1;
-       ret = send_pack(fd[0], fd[1], nr_heads, heads);
+       ret = send_pack(fd[0], fd[1], remote, nr_heads, heads);
        close(fd[0]);
        close(fd[1]);
        ret |= finish_connect(pid);
diff --git a/setup.c b/setup.c
index a45ea8309a9773160597f142f1208a6129885499..14f62c42e3ac6ead75d4963ee705b9a110da3de0 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -39,7 +39,7 @@ const char *prefix_path(const char *prefix, int len, const char *path)
        if (len) {
                int speclen = strlen(path);
                char *n = xmalloc(speclen + len + 1);
-       
+
                memcpy(n, prefix, len);
                memcpy(n + len, path, speclen+1);
                path = n;
@@ -47,7 +47,7 @@ const char *prefix_path(const char *prefix, int len, const char *path)
        return path;
 }
 
-/* 
+/*
  * Unlike prefix_path, this should be used if the named file does
  * not have to interact with index entry; i.e. name of a random file
  * on the filesystem.
index c2f807f4c282b99fe063e999ecf61a3dc12fb86d..2b860868f55a83ed599f39d7820a9fb227946912 100644 (file)
@@ -193,7 +193,7 @@ char *sha1_pack_name(const unsigned char *sha1)
                *buf++ = hex[val >> 4];
                *buf++ = hex[val & 0xf];
        }
-       
+
        return base;
 }
 
@@ -218,7 +218,7 @@ char *sha1_pack_index_name(const unsigned char *sha1)
                *buf++ = hex[val >> 4];
                *buf++ = hex[val & 0xf];
        }
-       
+
        return base;
 }
 
@@ -376,11 +376,12 @@ void prepare_alt_odb(void)
 {
        const char *alt;
 
+       if (alt_odb_tail)
+               return;
+
        alt = getenv(ALTERNATE_DB_ENVIRONMENT);
        if (!alt) alt = "";
 
-       if (alt_odb_tail)
-               return;
        alt_odb_tail = &alt_odb_list;
        link_alt_odb_entries(alt, alt + strlen(alt), ':', NULL, 0);
 
@@ -530,6 +531,21 @@ static int check_packed_git_idx(const char *path,  struct packed_git *p)
        return 0;
 }
 
+int open_pack_index(struct packed_git *p)
+{
+       char *idx_name;
+       int ret;
+
+       if (p->index_data)
+               return 0;
+
+       idx_name = xstrdup(p->pack_name);
+       strcpy(idx_name + strlen(idx_name) - strlen(".pack"), ".idx");
+       ret = check_packed_git_idx(idx_name, p);
+       free(idx_name);
+       return ret;
+}
+
 static void scan_windows(struct packed_git *p,
        struct packed_git **lru_p,
        struct pack_window **lru_w,
@@ -605,6 +621,9 @@ static int open_packed_git_1(struct packed_git *p)
        unsigned char *idx_sha1;
        long fd_flag;
 
+       if (!p->index_data && open_pack_index(p))
+               return error("packfile %s index unavailable", p->pack_name);
+
        p->pack_fd = open(p->pack_name, O_RDONLY);
        if (p->pack_fd < 0 || fstat(p->pack_fd, &st))
                return -1;
@@ -757,8 +776,7 @@ struct packed_git *add_packed_git(const char *path, int path_len, int local)
                return NULL;
        memcpy(p->pack_name, path, path_len);
        strcpy(p->pack_name + path_len, ".pack");
-       if (stat(p->pack_name, &st) || !S_ISREG(st.st_mode) ||
-           check_packed_git_idx(path, p)) {
+       if (stat(p->pack_name, &st) || !S_ISREG(st.st_mode)) {
                free(p);
                return NULL;
        }
@@ -766,6 +784,10 @@ struct packed_git *add_packed_git(const char *path, int path_len, int local)
        /* ok, it looks sane as far as we can check without
         * actually mapping the pack file.
         */
+       p->index_version = 0;
+       p->index_data = NULL;
+       p->index_size = 0;
+       p->num_objects = 0;
        p->pack_size = st.st_size;
        p->next = NULL;
        p->windows = NULL;
@@ -972,7 +994,7 @@ void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
        return map;
 }
 
-int legacy_loose_object(unsigned char *map)
+static int legacy_loose_object(unsigned char *map)
 {
        unsigned int word;
 
@@ -1034,6 +1056,14 @@ static int unpack_sha1_header(z_stream *stream, unsigned char *map, unsigned lon
                return inflate(stream, 0);
        }
 
+
+       /*
+        * There used to be a second loose object header format which
+        * was meant to mimic the in-pack format, allowing for direct
+        * copy of the object data.  This format turned up not to be
+        * really worth it and we don't write it any longer.  But we
+        * can still read it.
+        */
        used = unpack_object_header_gently(map, mapsize, &type, &size);
        if (!used || !valid_loose_object_type[type])
                return -1;
@@ -1109,7 +1139,7 @@ static int parse_sha1_header(const char *hdr, unsigned long *sizep)
        unsigned long size;
 
        /*
-        * The type can be at most ten bytes (including the 
+        * The type can be at most ten bytes (including the
         * terminating '\0' that we add), and is followed by
         * a space.
         */
@@ -1564,10 +1594,15 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
        return data;
 }
 
-const unsigned char *nth_packed_object_sha1(const struct packed_git *p,
+const unsigned char *nth_packed_object_sha1(struct packed_git *p,
                                            uint32_t n)
 {
        const unsigned char *index = p->index_data;
+       if (!index) {
+               if (open_pack_index(p))
+                       return NULL;
+               index = p->index_data;
+       }
        if (n >= p->num_objects)
                return NULL;
        index += 4 * 256;
@@ -1604,6 +1639,12 @@ off_t find_pack_entry_one(const unsigned char *sha1,
        const unsigned char *index = p->index_data;
        unsigned hi, lo;
 
+       if (!index) {
+               if (open_pack_index(p))
+                       return 0;
+               level1_ofs = p->index_data;
+               index = p->index_data;
+       }
        if (p->index_version > 1) {
                level1_ofs += 2;
                index += 8;
@@ -1646,20 +1687,25 @@ static int matches_pack_name(struct packed_git *p, const char *ig)
 
 static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed)
 {
+       static struct packed_git *last_found = (void *)1;
        struct packed_git *p;
        off_t offset;
 
        prepare_packed_git();
+       if (!packed_git)
+               return 0;
+       p = (last_found == (void *)1) ? packed_git : last_found;
 
-       for (p = packed_git; p; p = p->next) {
+       do {
                if (ignore_packed) {
                        const char **ig;
                        for (ig = ignore_packed; *ig; ig++)
                                if (!matches_pack_name(p, *ig))
                                        break;
                        if (*ig)
-                               continue;
+                               goto next;
                }
+
                offset = find_pack_entry_one(sha1, p);
                if (offset) {
                        /*
@@ -1672,18 +1718,27 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons
                         */
                        if (p->pack_fd == -1 && open_packed_git(p)) {
                                error("packfile %s cannot be accessed", p->pack_name);
-                               continue;
+                               goto next;
                        }
                        e->offset = offset;
                        e->p = p;
                        hashcpy(e->sha1, sha1);
+                       last_found = p;
                        return 1;
                }
-       }
+
+               next:
+               if (p == last_found)
+                       p = packed_git;
+               else
+                       p = p->next;
+               if (p == last_found)
+                       p = p->next;
+       } while (p);
        return 0;
 }
 
-struct packed_git *find_sha1_pack(const unsigned char *sha1, 
+struct packed_git *find_sha1_pack(const unsigned char *sha1,
                                  struct packed_git *packs)
 {
        struct packed_git *p;
@@ -1962,40 +2017,6 @@ static int write_buffer(int fd, const void *buf, size_t len)
        return 0;
 }
 
-static int write_binary_header(unsigned char *hdr, enum object_type type, unsigned long len)
-{
-       int hdr_len;
-       unsigned char c;
-
-       c = (type << 4) | (len & 15);
-       len >>= 4;
-       hdr_len = 1;
-       while (len) {
-               *hdr++ = c | 0x80;
-               hdr_len++;
-               c = (len & 0x7f);
-               len >>= 7;
-       }
-       *hdr = c;
-       return hdr_len;
-}
-
-static void setup_object_header(z_stream *stream, const char *type, unsigned long len)
-{
-       int obj_type, hdrlen;
-
-       if (use_legacy_headers) {
-               while (deflate(stream, 0) == Z_OK)
-                       /* nothing */;
-               return;
-       }
-       obj_type = type_from_string(type);
-       hdrlen = write_binary_header(stream->next_out, obj_type, len);
-       stream->total_out = hdrlen;
-       stream->next_out += hdrlen;
-       stream->avail_out -= hdrlen;
-}
-
 int hash_sha1_file(const void *buf, unsigned long len, const char *type,
                    unsigned char *sha1)
 {
@@ -2062,7 +2083,8 @@ int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned cha
        /* First header.. */
        stream.next_in = (unsigned char *)hdr;
        stream.avail_in = hdrlen;
-       setup_object_header(&stream, type, len);
+       while (deflate(&stream, 0) == Z_OK)
+               /* nothing */;
 
        /* Then the data itself.. */
        stream.next_in = buf;
index 55f25a2d3b49b1d565a9840b7dcfb2e22687cdd3..858f08c34a2de917b630d02974a839d626d23e7f 100644 (file)
@@ -76,8 +76,11 @@ static int find_short_packed_object(int len, const unsigned char *match, unsigne
 
        prepare_packed_git();
        for (p = packed_git; p && found < 2; p = p->next) {
-               uint32_t num = p->num_objects;
-               uint32_t first = 0, last = num;
+               uint32_t num, last;
+               uint32_t first = 0;
+               open_pack_index(p);
+               num = p->num_objects;
+               last = num;
                while (first < last) {
                        uint32_t mid = (first + last) / 2;
                        const unsigned char *now;
@@ -133,6 +136,7 @@ static int find_unique_short_object(int len, char *canonical,
        int has_unpacked, has_packed;
        unsigned char unpacked_sha1[20], packed_sha1[20];
 
+       prepare_alt_odb();
        has_unpacked = find_short_object_filename(len, canonical, unpacked_sha1);
        has_packed = find_short_packed_object(len, res, packed_sha1);
        if (!has_unpacked && !has_packed)
@@ -654,7 +658,6 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
        const char *cp;
 
        *mode = S_IFINVALID;
-       prepare_alt_odb();
        ret = get_sha1_1(name, namelen, sha1);
        if (!ret)
                return ret;
@@ -679,8 +682,6 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
                namelen = namelen - (cp - name);
                if (!active_cache)
                        read_cache();
-               if (active_nr < 0)
-                       return -1;
                pos = cache_name_pos(cp, namelen);
                if (pos < 0)
                        pos = -pos - 1;
index d17868929ceadbd2565549a60cb738a95c90a4bb..dbd9f5ad0ac21e70fc3a095d8e2938f245c238d3 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -101,4 +101,3 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
 
        return result;
 }
-
index 498d41e19b5756c82ef8e0ead779f40812f84227..20c35f03dd1fb468c7cecc71f91951657f229f5e 100644 (file)
@@ -29,24 +29,24 @@ static int serve_object(int fd_in, int fd_out) {
        }
        if (!size)
                return -1;
-       
+
        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;
        }
-       
+
        if (write_in_full(fd_out, &remote, 1) != 1)
                return 0;
-       
+
        if (remote < 0)
                return 0;
-       
+
        return write_sha1_to_fd(fd_out, sha1);
 }
 
index 7f14b0fb59bd7e14979b002f441ae84ff5b0e9a2..e33d06b87c978ad7484c9d6bf972681c3d6cdeb0 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -39,4 +39,3 @@ void read_line(struct strbuf *sb, FILE *fp, int term) {
                sb->eof = 1;
        strbuf_end(sb);
 }
-
index 19e38508a70708b78de6467df71ed36373999d6a..b25caca887103d81d406d2e8696e28e598ec8f7b 100644 (file)
@@ -28,4 +28,3 @@ full-svn-test:
 
 .PHONY: $(T) clean
 .NOTPARALLEL:
-
index d195603dfa9dc0328f1fcfd6c79c6c6cbe424f0c..586df2113f81aed913769bf977924ec7851207fe 100644 (file)
@@ -87,7 +87,7 @@ test_expect_success \
 test_expect_success \
     'recording branch A tree' \
     'tree_A=$(git-write-tree)'
-          
+
 ################################################################
 # Branch B
 # Start from O
index 186de7024336ca98bd5dcea6f675e1fc221d0ce0..8bfe8320ea99f50c6e6c748d0b9e6b5be1a7e3d3 100755 (executable)
@@ -37,7 +37,7 @@ fi
 find .git/objects -type f -print >should-be-empty
 test_expect_success \
     '.git/objects should be empty after git-init in an empty repo.' \
-    'cmp -s /dev/null should-be-empty' 
+    'cmp -s /dev/null should-be-empty'
 
 # also it should have 2 subdirectories; no fan-out anymore, pack, and info.
 # 3 is counting "objects" itself
index ca2c30f7aff5beda97ea598e272750c23e34296e..d3f83584856acd83bd37550579fe5d450061ce60 100755 (executable)
@@ -159,4 +159,3 @@ test_expect_success 'git prune-packed' 'git prune-packed'
 test_expect_failure '-> only packed objects' 'find -type f .git/objects/[0-9a-f][0-9a-f]'
 
 test_done
-
index 3f3fd2d7f7cc148948a20e47cccd06751b9a2241..7731fa72ceef16ba85b3ce4dcf1c21630f81f634 100755 (executable)
@@ -514,4 +514,3 @@ git config --list > result
 test_expect_success 'value continued on next line' 'cmp result expect'
 
 test_done
-
index 03ea4dece4b7fd3849269a0af3e960572ab5618d..d556b41f130f96b3043892e81a3dad7d66c9bff1 100755 (executable)
@@ -49,5 +49,3 @@ test_expect_success \
     'test -f path0 && test -d path1 && test -f path1/file1'
 
 test_done
-
-
index 0dcab8f1dea0d3d5e4bcebbc0b571fe46c2265e0..b895a0fe36c1508b754d6ec78bdf0efe085abd70 100755 (executable)
@@ -84,4 +84,3 @@ test_expect_success \
      test ! -h path1/file1 && test -f path1/file1'
 
 test_done
-
index 86ee2b0bd3737f94ebab32a344a6b1c5afc5ea92..607f57ff941b7da5296ab58cbf5e30db66087669 100755 (executable)
@@ -525,4 +525,3 @@ test_expect_success 'reset and bind merge' '
 '
 
 test_done
-
index 828d553a4b53210e9bd15c522e2a798901b2ac35..6f6d8844e8628d006b1d4c11eb02a5ee14a8fd35 100755 (executable)
@@ -136,8 +136,8 @@ test_expect_success 'test tracking setup (non-wildcard, not matching)' \
      git-config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
      (git-show-ref -q refs/remotes/local/master || git-fetch local) &&
      git-branch --track my5 local/master &&
-     ! test $(git-config branch.my5.remote) = local &&
-     ! test $(git-config branch.my5.merge) = refs/heads/master'
+     ! test "$(git-config branch.my5.remote)" = local &&
+     ! test "$(git-config branch.my5.merge)" = refs/heads/master'
 
 test_expect_success 'test tracking setup via config' \
     'git-config branch.autosetupmerge true &&
@@ -155,14 +155,22 @@ test_expect_success 'test overriding tracking setup via --no-track' \
      (git-show-ref -q refs/remotes/local/master || git-fetch local) &&
      git-branch --no-track my2 local/master &&
      git-config branch.autosetupmerge false &&
-     ! test $(git-config branch.my2.remote) = local &&
-     ! test $(git-config branch.my2.merge) = refs/heads/master'
+     ! test "$(git-config branch.my2.remote)" = local &&
+     ! test "$(git-config branch.my2.merge)" = refs/heads/master'
 
 test_expect_success 'test local tracking setup' \
     'git branch --track my6 s &&
      test $(git-config branch.my6.remote) = . &&
      test $(git-config branch.my6.merge) = refs/heads/s'
 
+test_expect_success 'test tracking setup via --track but deeper' \
+    'git-config remote.local.url . &&
+     git-config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+     (git-show-ref -q refs/remotes/local/o/o || git-fetch local) &&
+     git-branch --track my7 local/o/o &&
+     test "$(git-config branch.my7.remote)" = local &&
+     test "$(git-config branch.my7.merge)" = refs/heads/o/o'
+
 # Keep this test last, as it changes the current branch
 cat >expect <<EOF
 0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000     branch: Created from master
index 977c498f00f2d8e2066bd586130ee84fe1a196a3..9e11ed295d02f760f01a5b4fcb371b17a5b710cf 100755 (executable)
@@ -54,4 +54,3 @@ test_expect_success 'merge and reference trees equal' \
 test_debug 'gitk --all & sleep 1'
 
 test_done
-
index e72c6fd1b4fa294e3e52fe55ab68c672bfc57e15..b8acca1813955ca0034f7b2c0b9a12e3e2a4926f 100755 (executable)
@@ -41,4 +41,3 @@ test_expect_success \
     'git diff expected check'
 
 test_done
-
index 7b81c32e57f502f2c6d952bd9b7e6b432e092372..c23341feb55e2404533b94fdf627de13c01b4ada 100755 (executable)
@@ -44,4 +44,3 @@ test_expect_success \
     git diff ../t4100/t-apply-7.expect current'
 
 test_done
-
index 005f74481625e88a4f36bd5f17d339c1924778c4..9faef0d66e49b61826d4602e13206445bdb1b319 100755 (executable)
@@ -98,4 +98,3 @@ test_expect_success "S = cmp" \
     'cmp apply.txt patch.txt'
 
 test_done
-
index 69e9603c784b580ff143e4249c72aea79f64f471..9baf810beeb513e5a86b822c5a23354e948ef5c4 100755 (executable)
@@ -49,10 +49,10 @@ copy to include/arch/cris/klibc/archsetjmp.h
 - * arch/x86_64/include/klibc/archsetjmp.h
 + * arch/cris/include/klibc/archsetjmp.h
   */
+
  #ifndef _KLIBC_ARCHSETJMP_H
  #define _KLIBC_ARCHSETJMP_H
+
  struct __jmp_buf {
 -  unsigned long __rbx;
 -  unsigned long __rsp;
@@ -74,9 +74,9 @@ copy to include/arch/cris/klibc/archsetjmp.h
 +  unsigned long __sp;
 +  unsigned long __srp;
  };
+
  typedef struct __jmp_buf jmp_buf[1];
+
 -#endif /* _SETJMP_H */
 +#endif /* _KLIBC_ARCHSETJMP_H */
 diff --git a/klibc/arch/x86_64/include/klibc/archsetjmp.h b/include/arch/m32r/klibc/archsetjmp.h
@@ -90,10 +90,10 @@ rename to include/arch/m32r/klibc/archsetjmp.h
 - * arch/x86_64/include/klibc/archsetjmp.h
 + * arch/m32r/include/klibc/archsetjmp.h
   */
+
  #ifndef _KLIBC_ARCHSETJMP_H
  #define _KLIBC_ARCHSETJMP_H
+
  struct __jmp_buf {
 -  unsigned long __rbx;
 -  unsigned long __rsp;
@@ -108,9 +108,9 @@ rename to include/arch/m32r/klibc/archsetjmp.h
    unsigned long __r15;
 -  unsigned long __rip;
  };
+
  typedef struct __jmp_buf jmp_buf[1];
+
 -#endif /* _SETJMP_H */
 +#endif /* _KLIBC_ARCHSETJMP_H */
 EOF
index 27cc6f2b88974051cd521755800342e375d84af7..dd88e81e04beaa0e0a703efa3e4130c474ef0b69 100755 (executable)
@@ -53,4 +53,3 @@ test_expect_success 'apply --apply' '
 '
 
 test_done
-
index 620a9207bf14f5a7e2506742f1e7d0ddb91d0a78..edae7056e409fb2314bd1db1b4689f55ed08248b 100755 (executable)
@@ -24,7 +24,7 @@ cat >gpatch.file <<\EOF &&
 +++ file1+     2007-02-21 01:07:44.000000000 -0800
 @@ -1 +1 @@
 -A
-+B 
++B
 EOF
 
 sed -e 's|file1|sub/&|' gpatch.file >gpatch-sub.file &&
index 2b2f1eda21c647c5c8aa0f0d2b41cecf8d90f6c4..b95b89c341d3da9bb6f22c68cbb1144380396155 100755 (executable)
@@ -30,4 +30,3 @@ test_expect_success \
        '( git diff test~2 test~1; git diff test~1 test~0 )| git apply'
 
 test_done
-
index 3ddfe64b02490c2fa2e8cf7445aa518e0de8bf1b..841773f75fc085d07836b39b3775f49bde5d8d19 100755 (executable)
@@ -53,4 +53,3 @@ test_expect_success 'check result' '
 '
 
 test_done
-
index c64ebbb2e9e9eaf3fbb792a4f119cd9a1c2b4352..a46d7f74bedb105297a9015af9f9098c84365100 100755 (executable)
@@ -148,5 +148,3 @@ test_expect_success 'old records rest in peace' \
        "test ! -f $rr/preimage && test ! -f $rr2/preimage"
 
 test_done
-
-
index e223c074f043571ff868a2f4783c7cc155185004..a6c5bf6ab4c32b123bd7d678d7bd3c5cef6f5cb0 100755 (executable)
@@ -108,6 +108,13 @@ test_expect_success \
     'git-archive --format=zip' \
     'git-archive --format=zip HEAD >d.zip'
 
+$UNZIP -v >/dev/null 2>&1
+if [ $? -eq 127 ]; then
+       echo "Skipping ZIP tests, because unzip was not found"
+       test_done
+       exit
+fi
+
 test_expect_success \
     'extract ZIP archive' \
     '(mkdir d && cd d && $UNZIP ../d.zip)'
index 477b267599512fee5a5a3cf86687c3708ff967b8..4eaea8f3364343385227b38ac279a603f7ca025b 100755 (executable)
@@ -66,7 +66,7 @@ test_expect_success 'pack the destination repository' '
 '
 
 test_expect_success \
-        'pushing rewound head should not barf but require --force' ' 
+        'pushing rewound head should not barf but require --force' '
        # should not fail but refuse to update.
        if git-send-pack ./victim/.git/ master
        then
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
new file mode 100755 (executable)
index 0000000..dba018f
--- /dev/null
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+test_description='fetching and pushing, with or without wildcard'
+
+. ./test-lib.sh
+
+D=`pwd`
+
+mk_empty () {
+       rm -fr testrepo &&
+       mkdir testrepo &&
+       (
+               cd testrepo &&
+               git init
+       )
+}
+
+test_expect_success setup '
+
+       : >path1 &&
+       git add path1 &&
+       test_tick &&
+       git commit -a -m repo &&
+       the_commit=$(git show-ref -s --verify refs/heads/master)
+
+'
+
+test_expect_success 'fetch without wildcard' '
+       mk_empty &&
+       (
+               cd testrepo &&
+               git fetch .. refs/heads/master:refs/remotes/origin/master &&
+
+               r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+               test "z$r" = "z$the_commit" &&
+
+               test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+       )
+'
+
+test_expect_success 'fetch with wildcard' '
+       mk_empty &&
+       (
+               cd testrepo &&
+               git config remote.up.url .. &&
+               git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
+               git fetch up &&
+
+               r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+               test "z$r" = "z$the_commit" &&
+
+               test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+       )
+'
+
+test_expect_success 'push without wildcard' '
+       mk_empty &&
+
+       git push testrepo refs/heads/master:refs/remotes/origin/master &&
+       (
+               cd testrepo &&
+               r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+               test "z$r" = "z$the_commit" &&
+
+               test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+       )
+'
+
+test_expect_success 'push with wildcard' '
+       mk_empty &&
+
+       git push testrepo "refs/heads/*:refs/remotes/origin/*" &&
+       (
+               cd testrepo &&
+               r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+               test "z$r" = "z$the_commit" &&
+
+               test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+       )
+'
+
+test_done
index 243212d3dac03c19db18e9c8fcfc3b9049137cdd..93eaf2c1544b5374dbe8043c66478a0a80b0bb82 100755 (executable)
@@ -54,4 +54,3 @@ test_expect_success 'the default remote . should not break explicit pull' '
 '
 
 test_done
-
diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh
new file mode 100755 (executable)
index 0000000..b093327
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+test_description='test local clone'
+. ./test-lib.sh
+
+D=`pwd`
+
+test_expect_success 'preparing origin repository' '
+       : >file && git add . && git commit -m1 &&
+       git clone --bare . a.git &&
+       git clone --bare . x
+'
+
+test_expect_success 'local clone without .git suffix' '
+       cd "$D" &&
+       git clone -l -s a b &&
+       cd b &&
+       git fetch
+'
+
+test_expect_success 'local clone with .git suffix' '
+       cd "$D" &&
+       git clone -l -s a.git c &&
+       cd c &&
+       git fetch
+'
+
+test_expect_success 'local clone from x' '
+       cd "$D" &&
+       git clone -l -s x y &&
+       cd y &&
+       git fetch
+'
+
+test_expect_success 'local clone from x.git that does not exist' '
+       cd "$D" &&
+       if git clone -l -s x.git z
+       then
+               echo "Oops, should have failed"
+               false
+       else
+               echo happy
+       fi
+'
+
+test_done
index 2f8e97cb7ea4b8bdf56d5795d512534d504d25c0..699df6ebd8b6e76f95b255783c892de23610e504 100755 (executable)
@@ -104,4 +104,3 @@ test_valid_repo'
 cd "$base_dir"
 
 test_done
-
index d40262159bce36e78dd56d931eaf1d007ef77da8..d548bf8026289f1d590ecd0e0b7ec883650c4d78 100755 (executable)
@@ -17,17 +17,17 @@ unique_commit()
        _text=$1
         _tree=$2
        shift 2
-       echo $_text | git-commit-tree $(tag $_tree) "$@"
+       echo $_text | git-commit-tree $(tag $_tree) "$@"
 }
 
 # Save the output of a command into the tag specified. Prepend
 # a substitution script for the tag onto the front of sed.script
 save_tag()
 {
-       _tag=$1 
+       _tag=$1
        [ -n "$_tag" ] || error "usage: save_tag tag commit-args ..."
        shift 1
-       "$@" >.git/refs/tags/$_tag
+       "$@" >.git/refs/tags/$_tag
 
         echo "s/$(tag $_tag)/$_tag/g" > sed.script.tmp
        cat sed.script >> sed.script.tmp
@@ -35,7 +35,7 @@ save_tag()
        mv sed.script.tmp sed.script
 }
 
-# Replace unhelpful sha1 hashses with their symbolic equivalents 
+# Replace unhelpful sha1 hashses with their symbolic equivalents
 entag()
 {
        sed -f sed.script
@@ -62,7 +62,7 @@ as_author()
 commit_date()
 {
         _commit=$1
-       git-cat-file commit $_commit | sed -n "s/^committer .*> \([0-9]*\) .*/\1/p" 
+       git-cat-file commit $_commit | sed -n "s/^committer .*> \([0-9]*\) .*/\1/p"
 }
 
 on_committer_date()
@@ -103,14 +103,14 @@ name_from_description()
 
 # Execute the test described by the first argument, by eval'ing
 # command line specified in the 2nd argument. Check the status code
-# is zero and that the output matches the stream read from 
+# is zero and that the output matches the stream read from
 # stdin.
 test_output_expect_success()
-{      
+{
        _description=$1
         _test=$2
         [ $# -eq 2 ] || error "usage: test_output_expect_success description test <<EOF ... EOF"
         _name=$(echo $_description | name_from_description)
        cat > $_name.expected
-       test_expect_success "$_description" "check_output $_name \"$_test\"" 
+       test_expect_success "$_description" "check_output $_name \"$_test\""
 }
index fcb33027648b8449cba5869cbe808a4e26ff7f2d..71cbb72e1bc2e8b11c248c01cb7559e43ddabe04 100755 (executable)
@@ -26,7 +26,7 @@ test_bisection_diff()
 
        # Test if bisection size is close to half of list size within
        # tolerance.
-       # 
+       #
        _bisect_err=`expr $_list_size - $_bisection_size \* 2`
        test "$_bisect_err" -lt 0 && _bisect_err=`expr 0 - $_bisect_err`
        _bisect_err=`expr $_bisect_err / 2` ; # floor
@@ -116,8 +116,8 @@ on_committer_date "1971-08-16 00:00:06" save_tag V unique_commit V tree -p u1 -p
 
 test_sequence()
 {
-       _bisect_option=$1       
-       
+       _bisect_option=$1
+
        test_bisection_diff 0 $_bisect_option l0 ^root
        test_bisection_diff 0 $_bisect_option l1 ^root
        test_bisection_diff 0 $_bisect_option l2 ^root
@@ -152,7 +152,7 @@ test_sequence()
        test_bisection_diff 0 $_bisect_option u3 ^U
        test_bisection_diff 0 $_bisect_option u4 ^U
        test_bisection_diff 0 $_bisect_option u5 ^U
-       
+
 #
 # the following illustrates Linus' binary bug blatt idea.
 #
index 499cafb882b83b780171c8601b9f4c54b294ed43..0ab14a6e81302db6a1239d68270ab909cb2fd216 100755 (executable)
@@ -20,7 +20,7 @@ test_expect_success 'prepare repository' \
 7
 8
 9" > file &&
-git add file && 
+git add file &&
 git commit -m "Initial commit" file &&
 git branch A &&
 git branch B &&
index c76fccfb5a0811aca3bb5af67f8558745935148f..ecc11c1a8448d7a5825e8ade7d7aaa7c43efef9f 100755 (executable)
@@ -134,5 +134,9 @@ EOF
 
 test_expect_success "expected conflict markers" "git diff expect out"
 
-test_done
+test_expect_success 'binary files cannot be merged' '
+       ! git merge-file -p orig.txt ../test4012.png new1.txt 2> merge.err &&
+       grep "Cannot merge binary files" merge.err
+'
 
+test_done
index a398556137205d9fb561746335a13330a5aeda54..058db9cc52521a9ba9e408c9455645d8adc4ba79 100755 (executable)
@@ -81,4 +81,18 @@ EOF
 
 test_expect_success "virtual trees were processed" "git diff expect out"
 
+git reset --hard
+test_expect_success 'refuse to merge binary files' '
+       printf "\0" > binary-file &&
+       git add binary-file &&
+       git commit -m binary &&
+       git checkout G &&
+       printf "\0\0" > binary-file &&
+       git add binary-file &&
+       git commit -m binary2 &&
+       ! git merge F > merge.out 2> merge.err &&
+       grep "Cannot merge binary files: HEAD:binary-file vs. F:binary-file" \
+               merge.err
+'
+
 test_done
index 30f6ade13f088df1ce6c7e3649c2afb343649d65..03cdba5808aef6fbec2d95f771e6551396ff94cf 100755 (executable)
@@ -102,4 +102,3 @@ test_expect_success \
 #
 #
 test_done
-
index 7d354a1fae774ca0e77e554dad827f1a9b781818..dd6cc3a55c54a04d9bf83ba618d81fdeeed82e69 100755 (executable)
@@ -29,5 +29,14 @@ test_expect_success 'final^1^3 not valid' "if git-rev-parse --verify final^1^3;
 test_expect_failure '--verify start2^1' 'git-rev-parse --verify start2^1'
 test_expect_success '--verify start2^0' 'git-rev-parse --verify start2^0'
 
-test_done
+test_expect_success 'repack for next test' 'git repack -a -d'
+test_expect_success 'short SHA-1 works' '
+       start=`git rev-parse --verify start` &&
+       echo $start &&
+       abbrv=`echo $start | sed s/.\$//` &&
+       echo $abbrv &&
+       abbrv=`git rev-parse --verify $abbrv` &&
+       echo $abbrv &&
+       test $start = $abbrv'
 
+test_done
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
new file mode 100755 (executable)
index 0000000..6274729
--- /dev/null
@@ -0,0 +1,143 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Lars Hjemli
+#
+
+test_description='Basic porcelain support for submodules
+
+This test tries to verify basic sanity of the init, update and status
+subcommands of git-submodule.
+'
+
+. ./test-lib.sh
+
+#
+# Test setup:
+#  -create a repository in directory lib
+#  -add a couple of files
+#  -add directory lib to 'superproject', this creates a DIRLINK entry
+#  -add a couple of regular files to enable testing of submodule filtering
+#  -mv lib subrepo
+#  -add an entry to .gitmodules for path 'lib'
+#
+test_expect_success 'Prepare submodule testing' '
+       mkdir lib &&
+       cd lib &&
+       git-init &&
+       echo a >a &&
+       git-add a &&
+       git-commit -m "submodule commit 1" &&
+       git-tag -a -m "rev-1" rev-1 &&
+       rev1=$(git-rev-parse HEAD) &&
+       if test -z "$rev1"
+       then
+               echo "[OOPS] submodule git-rev-parse returned nothing"
+               false
+       fi &&
+       cd .. &&
+       echo a >a &&
+       echo z >z &&
+       git-add a lib z &&
+       git-commit -m "super commit 1" &&
+       mv lib .subrepo &&
+       GIT_CONFIG=.gitmodules git-config module.lib.url ./.subrepo
+'
+
+test_expect_success 'status should only print one line' '
+       lines=$(git-submodule status | wc -l) &&
+       test $lines = 1
+'
+
+test_expect_success 'status should initially be "missing"' '
+       git-submodule status | grep "^-$rev1"
+'
+
+test_expect_success 'init should fail when path is used by a file' '
+       echo "hello" >lib &&
+       if git-submodule init
+       then
+               echo "[OOPS] init should have failed"
+               false
+       elif test -f lib && test "$(cat lib)" != "hello"
+       then
+               echo "[OOPS] init failed but lib file was molested"
+               false
+       else
+               rm lib
+       fi
+'
+
+test_expect_success 'init should fail when path is used by a nonempty directory' '
+       mkdir lib &&
+       echo "hello" >lib/a &&
+       if git-submodule init
+       then
+               echo "[OOPS] init should have failed"
+               false
+       elif test "$(cat lib/a)" != "hello"
+       then
+               echo "[OOPS] init failed but lib/a was molested"
+               false
+       else
+               rm lib/a
+       fi
+'
+
+test_expect_success 'init should work when path is an empty dir' '
+       rm -rf lib &&
+       mkdir lib &&
+       git-submodule init &&
+       head=$(cd lib && git-rev-parse HEAD) &&
+       if test -z "$head"
+       then
+               echo "[OOPS] Failed to obtain submodule head"
+               false
+       elif test "$head" != "$rev1"
+       then
+               echo "[OOPS] Submodule head is $head but should have been $rev1"
+               false
+       fi
+'
+
+test_expect_success 'status should be "up-to-date" after init' '
+       git-submodule status | grep "^ $rev1"
+'
+
+test_expect_success 'status should be "modified" after submodule commit' '
+       cd lib &&
+       echo b >b &&
+       git-add b &&
+       git-commit -m "submodule commit 2" &&
+       rev2=$(git-rev-parse HEAD) &&
+       cd .. &&
+       if test -z "$rev2"
+       then
+               echo "[OOPS] submodule git-rev-parse returned nothing"
+               false
+       fi &&
+       git-submodule status | grep "^+$rev2"
+'
+
+test_expect_success 'the --cached sha1 should be rev1' '
+       git-submodule --cached status | grep "^+$rev1"
+'
+
+test_expect_success 'update should checkout rev1' '
+       git-submodule update &&
+       head=$(cd lib && git-rev-parse HEAD) &&
+       if test -z "$head"
+       then
+               echo "[OOPS] submodule git-rev-parse returned nothing"
+               false
+       elif test "$head" != "$rev1"
+       then
+               echo "[OOPS] init did not checkout correct head"
+               false
+       fi
+'
+
+test_expect_success 'status should be "up-to-date" after update' '
+       git-submodule status | grep "^ $rev1"
+'
+
+test_done
index dc2afdaa4561ce037239907297718dba1fa33ce6..d549665400a2eccffec0689865a1e9fdcc034985 100755 (executable)
@@ -109,4 +109,3 @@ test_expect_success  ".rev_db auto-converted to .rev_db.UUID" "
        "
 
 test_done
-
index a9a46eeb2978071e44db85405b62c515e0b6c278..499fa9594fafe5d45a32005c189634b6a3048777 100644 (file)
@@ -558,5 +558,3 @@ Text-content-md5: 7abb78de7f2756ca8b511cbc879fd5e7
 Content-length: 4
 
 cba
-
-
index d406a8824a382433cbc8c6f499ef3bc1f00301b2..41dcf646d132e35ca37ab6cc75fc2a7e70cc765e 100755 (executable)
@@ -47,6 +47,172 @@ test_expect_success 'basic checkout' \
   'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master &&
    test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"'
 
+#------------------------
+# PSERVER AUTHENTICATION
+#------------------------
+
+cat >request-anonymous  <<EOF
+BEGIN AUTH REQUEST
+$SERVERDIR
+anonymous
+
+END AUTH REQUEST
+EOF
+
+cat >request-git  <<EOF
+BEGIN AUTH REQUEST
+$SERVERDIR
+git
+
+END AUTH REQUEST
+EOF
+
+cat >login-anonymous <<EOF
+BEGIN VERIFICATION REQUEST
+$SERVERDIR
+anonymous
+
+END VERIFICATION REQUEST
+EOF
+
+cat >login-git <<EOF
+BEGIN VERIFICATION REQUEST
+$SERVERDIR
+git
+
+END VERIFICATION REQUEST
+EOF
+
+test_expect_success 'pserver authentication' \
+  'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
+   tail -n1 log | grep -q "^I LOVE YOU$"'
+
+test_expect_success 'pserver authentication failure (non-anonymous user)' \
+  'if cat request-git | git-cvsserver pserver >log 2>&1
+   then
+       false
+   else
+       true
+   fi &&
+   tail -n1 log | grep -q "^I HATE YOU$"'
+
+test_expect_success 'pserver authentication (login)' \
+  'cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
+   tail -n1 log | grep -q "^I LOVE YOU$"'
+
+test_expect_success 'pserver authentication failure (login/non-anonymous user)' \
+  'if cat login-git | git-cvsserver pserver >log 2>&1
+   then
+       false
+   else
+       true
+   fi &&
+   tail -n1 log | grep -q "^I HATE YOU$"'
+
+
+# misuse pserver authentication for testing of req_Root
+
+cat >request-relative  <<EOF
+BEGIN AUTH REQUEST
+gitcvs.git
+anonymous
+
+END AUTH REQUEST
+EOF
+
+cat >request-conflict  <<EOF
+BEGIN AUTH REQUEST
+$SERVERDIR
+anonymous
+
+END AUTH REQUEST
+Root $WORKDIR
+EOF
+
+test_expect_success 'req_Root failure (relative pathname)' \
+  'if cat request-relative | git-cvsserver pserver >log 2>&1
+   then
+       echo unexpected success
+       false
+   else
+       true
+   fi &&
+   tail log | grep -q "^error 1 Root must be an absolute pathname$"'
+
+test_expect_success 'req_Root failure (conflicting roots)' \
+  'cat request-conflict | git-cvsserver pserver >log 2>&1 &&
+   tail log | grep -q "^error 1 Conflicting roots specified$"'
+
+
+#--------------
+# CONFIG TESTS
+#--------------
+
+test_expect_success 'gitcvs.enabled = false' \
+  'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
+   if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
+   then
+     echo unexpected cvs success
+     false
+   else
+     true
+   fi &&
+   cat cvs.log | grep -q "GITCVS emulation disabled" &&
+   test ! -d cvswork2'
+
+rm -fr cvswork2
+test_expect_success 'gitcvs.ext.enabled = true' \
+  'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
+   GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
+   GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
+   diff -q cvswork cvswork2'
+
+rm -fr cvswork2
+test_expect_success 'gitcvs.ext.enabled = false' \
+  'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false &&
+   GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
+   if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
+   then
+     echo unexpected cvs success
+     false
+   else
+     true
+   fi &&
+   cat cvs.log | grep -q "GITCVS emulation disabled" &&
+   test ! -d cvswork2'
+
+rm -fr cvswork2
+test_expect_success 'gitcvs.dbname' \
+  'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
+   GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite &&
+   GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
+   diff -q cvswork cvswork2 &&
+   test -f "$SERVERDIR/gitcvs.ext.master.sqlite" &&
+   cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs.ext.master.sqlite"'
+
+rm -fr cvswork2
+test_expect_success 'gitcvs.ext.dbname' \
+  'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
+   GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
+   GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
+   GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
+   diff -q cvswork cvswork2 &&
+   test -f "$SERVERDIR/gitcvs1.ext.master.sqlite" &&
+   test ! -f "$SERVERDIR/gitcvs2.ext.master.sqlite" &&
+   cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs1.ext.master.sqlite"'
+
+
+#------------
+# CVS UPDATE
+#------------
+
+rm -fr "$SERVERDIR"
+cd "$WORKDIR" &&
+git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
+GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
+GIT_DIR="$SERVERDIR" git config --bool gitcvs.logfile "$SERVERDIR/gitcvs.log" ||
+exit 1
+
 test_expect_success 'cvs update (create new file)' \
   'echo testfile1 >testfile1 &&
    git add testfile1 &&
@@ -123,4 +289,75 @@ test_expect_success 'cvs update (re-add deleted file)' \
    test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" &&
    diff -q testfile1 ../testfile1'
 
+cd "$WORKDIR"
+test_expect_success 'cvs update (merge)' \
+  'echo Line 0 >expected &&
+   for i in 1 2 3 4 5 6 7
+   do
+     echo Line $i >>merge
+     echo Line $i >>expected
+   done &&
+   echo Line 8 >>expected &&
+   git add merge &&
+   git commit -q -m "Merge test (pre-merge)" &&
+   git push gitcvs.git >/dev/null &&
+   cd cvswork &&
+   GIT_CONFIG="$git_config" cvs -Q update &&
+   test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" &&
+   diff -q merge ../merge &&
+   ( echo Line 0; cat merge ) >merge.tmp &&
+   mv merge.tmp merge &&
+   cd "$WORKDIR" &&
+   echo Line 8 >>merge &&
+   git add merge &&
+   git commit -q -m "Merge test (merge)" &&
+   git push gitcvs.git >/dev/null &&
+   cd cvswork &&
+   sleep 1 && touch merge &&
+   GIT_CONFIG="$git_config" cvs -Q update &&
+   diff -q merge ../expected'
+
+cd "$WORKDIR"
+
+cat >expected.C <<EOF
+<<<<<<< merge.mine
+Line 0
+=======
+LINE 0
+>>>>>>> merge.3
+EOF
+
+for i in 1 2 3 4 5 6 7 8
+do
+  echo Line $i >>expected.C
+done
+
+test_expect_success 'cvs update (conflict merge)' \
+  '( echo LINE 0; cat merge ) >merge.tmp &&
+   mv merge.tmp merge &&
+   git add merge &&
+   git commit -q -m "Merge test (conflict)" &&
+   git push gitcvs.git >/dev/null &&
+   cd cvswork &&
+   GIT_CONFIG="$git_config" cvs -Q update &&
+   diff -q merge ../expected.C'
+
+cd "$WORKDIR"
+test_expect_success 'cvs update (-C)' \
+  'cd cvswork &&
+   GIT_CONFIG="$git_config" cvs -Q update -C &&
+   diff -q merge ../merge'
+
+cd "$WORKDIR"
+test_expect_success 'cvs update (merge no-op)' \
+   'echo Line 9 >>merge &&
+    cp merge cvswork/merge &&
+    git add merge &&
+    git commit -q -m "Merge test (no-op)" &&
+    git push gitcvs.git >/dev/null &&
+    cd cvswork &&
+    sleep 1 && touch merge &&
+    GIT_CONFIG="$git_config" cvs -Q update &&
+    diff -q merge ../merge'
+
 test_done
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
new file mode 100755 (executable)
index 0000000..44ae503
--- /dev/null
@@ -0,0 +1,518 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Jakub Narebski
+#
+
+test_description='gitweb as standalone script (basic tests).
+
+This test runs gitweb (git web interface) as CGI script from
+commandline, and checks that it would not write any errors
+or warnings to log.'
+
+gitweb_init () {
+       cat >gitweb_config.perl <<EOF
+#!/usr/bin/perl
+
+# gitweb configuration for tests
+
+our \$version = "current";
+our \$GIT = "git";
+our \$projectroot = "$(pwd)";
+our \$home_link_str = "projects";
+our \$site_name = "[localhost]";
+our \$site_header = "";
+our \$site_footer = "";
+our \$home_text = "indextext.html";
+our @stylesheets = ("file:///$(pwd)/../../gitweb/gitweb.css");
+our \$logo = "file:///$(pwd)/../../gitweb/git-logo.png";
+our \$favicon = "file:///$(pwd)/../../gitweb/git-favicon.png";
+our \$projects_list = "";
+our \$export_ok = "";
+our \$strict_export = "";
+
+CGI::Carp::set_programname("gitweb/gitweb.cgi");
+EOF
+
+       cat >.git/description <<EOF
+$0 test repository
+EOF
+}
+
+gitweb_run () {
+       export GATEWAY_INTERFACE="CGI/1.1"
+       export HTTP_ACCEPT="*/*"
+       export REQUEST_METHOD="GET"
+       export QUERY_STRING=""$1""
+       export PATH_INFO=""$2""
+
+       export GITWEB_CONFIG=$(pwd)/gitweb_config.perl
+
+       # some of git commands write to STDERR on error, but this is not
+       # written to web server logs, so we are not interested in that:
+       # we are interested only in properly formatted errors/warnings
+       rm -f gitweb.log &&
+       perl -- $(pwd)/../../gitweb/gitweb.perl \
+               >/dev/null 2>gitweb.log &&
+       if grep -q -s "^[[]" gitweb.log >/dev/null; then false; else true; fi
+
+       # gitweb.log is left for debugging
+}
+
+. ./test-lib.sh
+
+gitweb_init
+
+# ----------------------------------------------------------------------
+# no commits (empty, just initialized repository)
+
+test_expect_success \
+       'no commits: projects_list (implicit)' \
+       'gitweb_run'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'no commits: projects_index' \
+       'gitweb_run "a=project_index"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'no commits: .git summary (implicit)' \
+       'gitweb_run "p=.git"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'no commits: .git commit (implicit HEAD)' \
+       'gitweb_run "p=.git;a=commit"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'no commits: .git commitdiff (implicit HEAD)' \
+       'gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'no commits: .git tree (implicit HEAD)' \
+       'gitweb_run "p=.git;a=tree"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'no commits: .git heads' \
+       'gitweb_run "p=.git;a=heads"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'no commits: .git tags' \
+       'gitweb_run "p=.git;a=tags"'
+test_debug 'cat gitweb.log'
+
+
+# ----------------------------------------------------------------------
+# initial commit
+
+test_expect_success \
+       'Make initial commit' \
+       'echo "Not an empty file." > file &&
+        git add file &&
+        git commit -a -m "Initial commit." &&
+        git branch b'
+
+test_expect_success \
+       'projects_list (implicit)' \
+       'gitweb_run'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'projects_index' \
+       'gitweb_run "a=project_index"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git summary (implicit)' \
+       'gitweb_run "p=.git"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git commit (implicit HEAD)' \
+       'gitweb_run "p=.git;a=commit"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git commitdiff (implicit HEAD, root commit)' \
+       'gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git commitdiff_plain (implicit HEAD, root commit)' \
+       'gitweb_run "p=.git;a=commitdiff_plain"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git commit (HEAD)' \
+       'gitweb_run "p=.git;a=commit;h=HEAD"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git tree (implicit HEAD)' \
+       'gitweb_run "p=.git;a=tree"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git blob (file)' \
+       'gitweb_run "p=.git;a=blob;f=file"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git blob_plain (file)' \
+       'gitweb_run "p=.git;a=blob_plain;f=file"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# nonexistent objects
+
+test_expect_success \
+       '.git commit (non-existent)' \
+       'gitweb_run "p=.git;a=commit;h=non-existent"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git commitdiff (non-existent)' \
+       'gitweb_run "p=.git;a=commitdiff;h=non-existent"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git commitdiff (non-existent vs HEAD)' \
+       'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git tree (0000000000000000000000000000000000000000)' \
+       'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git tag (0000000000000000000000000000000000000000)' \
+       'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git blob (non-existent)' \
+       'gitweb_run "p=.git;a=blob;f=non-existent"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       '.git blob_plain (non-existent)' \
+       'gitweb_run "p=.git;a=blob_plain;f=non-existent"'
+test_debug 'cat gitweb.log'
+
+
+# ----------------------------------------------------------------------
+# commitdiff testing (implicit, one implicit tree-ish)
+
+test_expect_success \
+       'commitdiff(0): root' \
+       'gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(0): file added' \
+       'echo "New file" > new_file &&
+        git add new_file &&
+        git commit -a -m "File added." &&
+        gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(0): mode change' \
+       'chmod a+x new_file &&
+        git commit -a -m "Mode changed." &&
+        gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(0): file renamed' \
+       'git mv new_file renamed_file &&
+        git commit -a -m "File renamed." &&
+        gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(0): file to symlink' \
+       'rm renamed_file &&
+        ln -s file renamed_file &&
+        git commit -a -m "File to symlink." &&
+        gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(0): file deleted' \
+       'git rm renamed_file &&
+        rm -f renamed_file &&
+        git commit -a -m "File removed." &&
+        gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(0): file copied / new file' \
+       'cp file file2 &&
+        git add file2 &&
+        git commit -a -m "File copied." &&
+        gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(0): mode change and modified' \
+       'echo "New line" >> file2 &&
+        chmod a+x file2 &&
+        git commit -a -m "Mode change and modification." &&
+        gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(0): renamed and modified' \
+       'cat >file2<<EOF &&
+Dominus regit me,
+et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+EOF
+        git commit -a -m "File added." &&
+        git mv file2 file3 &&
+        echo "Propter nomen suum." >> file3 &&
+        git commit -a -m "File rename and modification." &&
+        gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(0): renamed, mode change and modified' \
+       'git mv file3 file2 &&
+        echo "Propter nomen suum." >> file2 &&
+        chmod a+x file2 &&
+        git commit -a -m "File rename, mode change and modification." &&
+        gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# commitdiff testing (taken from t4114-apply-typechange.sh)
+
+test_expect_success 'setup typechange commits' '
+       echo "hello world" > foo &&
+       echo "hi planet" > bar &&
+       git update-index --add foo bar &&
+       git commit -m initial &&
+       git branch initial &&
+       rm -f foo &&
+       ln -s bar foo &&
+       git update-index foo &&
+       git commit -m "foo symlinked to bar" &&
+       git branch foo-symlinked-to-bar &&
+       rm -f foo &&
+       echo "how far is the sun?" > foo &&
+       git update-index foo &&
+       git commit -m "foo back to file" &&
+       git branch foo-back-to-file &&
+       rm -f foo &&
+       git update-index --remove foo &&
+       mkdir foo &&
+       echo "if only I knew" > foo/baz &&
+       git update-index --add foo/baz &&
+       git commit -m "foo becomes a directory" &&
+       git branch "foo-becomes-a-directory" &&
+       echo "hello world" > foo/baz &&
+       git update-index foo/baz &&
+       git commit -m "foo/baz is the original foo" &&
+       git branch foo-baz-renamed-from-foo
+       '
+
+test_expect_success \
+       'commitdiff(2): file renamed from foo to foo/baz' \
+       'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(2): file renamed from foo/baz to foo' \
+       'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(2): directory becomes file' \
+       'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(2): file becomes directory' \
+       'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(2): file becomes symlink' \
+       'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(2): symlink becomes file' \
+       'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(2): symlink becomes directory' \
+       'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(2): directory becomes symlink' \
+       'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# commit, commitdiff: merge, large
+test_expect_success \
+       'Create a merge' \
+       'git checkout b &&
+        echo "Branch" >> b &&
+        git add b &&
+        git commit -a -m "On branch" &&
+        git checkout master &&
+        git pull . b'
+
+test_expect_success \
+       'commit(0): merge commit' \
+       'gitweb_run "p=.git;a=commit"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(0): merge commit' \
+       'gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'Prepare large commit' \
+       'git checkout b &&
+        echo "To be changed" > 01-change &&
+        echo "To be renamed" > 02-pure-rename-from &&
+        echo "To be deleted" > 03-delete &&
+        echo "To be renamed and changed" > 04-rename-from &&
+        echo "To have mode changed" > 05-mode-change &&
+        echo "File to symlink" > 06-file-or-symlink &&
+        echo "To be changed and have mode changed" > 07-change-mode-change     &&
+        git add 0* &&
+        git commit -a -m "Prepare large commit" &&
+        echo "Changed" > 01-change &&
+        git mv 02-pure-rename-from 02-pure-rename-to &&
+        git rm 03-delete && rm -f 03-delete &&
+        echo "A new file" > 03-new &&
+        git add 03-new &&
+        git mv 04-rename-from 04-rename-to &&
+        echo "Changed" >> 04-rename-to &&
+        chmod a+x 05-mode-change &&
+        rm -f 06-file-or-symlink && ln -s 01-change 06-file-or-symlink &&
+        echo "Changed and have mode changed" > 07-change-mode-change   &&
+        chmod a+x 07-change-mode-change &&
+        git commit -a -m "Large commit" &&
+        git checkout master'
+
+test_expect_success \
+       'commit(1): large commit' \
+       'gitweb_run "p=.git;a=commit;h=b"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'commitdiff(1): large commit' \
+       'gitweb_run "p=.git;a=commitdiff;h=b"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# tags testing
+
+test_expect_success \
+       'tags: list of different types of tags' \
+       'git checkout master &&
+        git tag -a -m "Tag commit object" tag-commit HEAD &&
+        git tag -a -m "" tag-commit-nomessage HEAD &&
+        git tag -a -m "Tag tag object" tag-tag tag-commit &&
+        git tag -a -m "Tag tree object" tag-tree HEAD^{tree} &&
+        git tag -a -m "Tag blob object" tag-blob HEAD:file &&
+        git tag lightweight/tag-commit HEAD &&
+        git tag lightweight/tag-tag tag-commit &&
+        git tag lightweight/tag-tree HEAD^{tree} &&
+        git tag lightweight/tag-blob HEAD:file &&
+        gitweb_run "p=.git;a=tags"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'tag: Tag to commit object' \
+       'gitweb_run "p=.git;a=tag;h=tag-commit"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'tag: on lightweight tag (invalid)' \
+       'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# logs
+
+test_expect_success \
+       'logs: log (implicit HEAD)' \
+       'gitweb_run "p=.git;a=log"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'logs: shortlog (implicit HEAD)' \
+       'gitweb_run "p=.git;a=shortlog"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'logs: history (implicit HEAD, file)' \
+       'gitweb_run "p=.git;a=history;f=file"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# feed generation
+
+test_expect_success \
+       'feeds: OPML' \
+       'gitweb_run "a=opml"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'feed: RSS' \
+       'gitweb_run "p=.git;a=rss"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'feed: Atom' \
+       'gitweb_run "p=.git;a=atom"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# encoding/decoding
+
+test_expect_success \
+       'encode(commit): utf8' \
+       '. ../t3901-utf8.txt &&
+        echo "UTF-8" >> file &&
+        git add file &&
+        git commit -F ../t3900/1-UTF-8.txt &&
+        gitweb_run "p=.git;a=commit"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'encode(commit): iso-8859-1' \
+       '. ../t3901-8859-1.txt &&
+        echo "ISO-8859-1" >> file &&
+        git add file &&
+        git config i18n.commitencoding ISO-8859-1 &&
+        git commit -F ../t3900/ISO-8859-1.txt &&
+        git config --unset i18n.commitencoding &&
+        gitweb_run "p=.git;a=commit"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'encode(log): utf-8 and iso-8859-1' \
+       'gitweb_run "p=.git;a=log"'
+test_debug 'cat gitweb.log'
+
+test_done
index dee3ad76212ea95c75c8287c8d8c0f312125bd06..8bf4cf49a207132d0f517468b6ca1182cca61aeb 100644 (file)
@@ -232,7 +232,7 @@ test_create_repo () {
        mv .git/hooks .git/hooks-disabled
        cd "$owd"
 }
-       
+
 test_done () {
        trap - exit
        case "$test_failure" in
index 9b04f2d69c6dc054e8e5403062fb7ef5d2117328..c5cdb9d7eeebab7edf048e77eb92437de24751bf 100644 (file)
@@ -19,4 +19,3 @@ test "" = "$(grep '^Signed-off-by: ' "$1" |
        echo >&2 Duplicate Signed-off-by lines.
        exit 1
 }
-
index 190de2688cd2ef82525a0998e0c5133f8cd45a83..b70c8fd36430fb1e0b02119d7f802c2144fa2a41 100644 (file)
@@ -14,4 +14,3 @@
 
 
 #. /usr/share/doc/git-core/contrib/hooks/post-receive-email
-
index 5f56ce8053a40919cbf02010e29f185b6f9d8784..eeccc934cad8bb74624ed388988fe79c26e6900d 100644 (file)
@@ -12,4 +12,3 @@
 test -x "$GIT_DIR/hooks/pre-commit" &&
        exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
 :
-
index 723a9ef210bb84c217026c2cdf9d30661f64447b..18b87309f65be23794b87260e08c547f5deeefce 100644 (file)
@@ -68,4 +68,3 @@ perl -e '
     }
     exit($found_bad);
 '
-
index cbb24eb3f663cd0370f528d983a2266a55b91c4f..8d4b67317f21508a105175686c7ec98a090ed9b5 100644 (file)
@@ -206,4 +206,3 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch
        free(tree);
        return retval;
 }
-
diff --git a/tree.c b/tree.c
index e4a39aa3c36964c9034d2393a8b9cb483d1543da..04fe653a8e25feb0fc15f76ba487d0f8dbd52f82 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -157,7 +157,7 @@ static void track_tree_refs(struct tree *item)
        /* Count how many entries there are.. */
        init_tree_desc(&desc, item->buffer, item->size);
        while (tree_entry(&desc, &entry)) {
-               if (S_ISDIRLNK(entry.mode))
+               if (S_ISGITLINK(entry.mode))
                        continue;
                n_refs++;
        }
@@ -169,12 +169,17 @@ static void track_tree_refs(struct tree *item)
        while (tree_entry(&desc, &entry)) {
                struct object *obj;
 
-               if (S_ISDIRLNK(entry.mode))
+               if (S_ISGITLINK(entry.mode))
                        continue;
                if (S_ISDIR(entry.mode))
                        obj = &lookup_tree(entry.sha1)->object;
-               else
+               else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode))
                        obj = &lookup_blob(entry.sha1)->object;
+               else {
+                       warning("in tree %s: entry %s has bad mode %.6o\n",
+                            sha1_to_hex(item->object.sha1), entry.path, entry.mode);
+                       obj = lookup_unknown_object(entry.sha1);
+               }
                refs->ref[i++] = obj;
        }
        set_object_refs(&item->object, refs);
index d3a09e78d56642db9b1fb1b1ead34ff60dd8c923..fe96ef15c43fa6e3f8f947f84ddce3c498e82859 100644 (file)
@@ -62,7 +62,7 @@ static ssize_t send_client_data(int fd, const char *data, ssize_t sz)
        return safe_write(fd, data, sz);
 }
 
-FILE *pack_pipe = NULL;
+static FILE *pack_pipe = NULL;
 static void show_commit(struct commit *commit)
 {
        if (commit->object.flags & BOUNDARY)
@@ -678,7 +678,7 @@ int main(int argc, char **argv)
                        break;
                }
        }
-       
+
        if (i != argc-1)
                usage(upload_pack_usage);
        dir = argv[i];
diff --git a/var.c b/var.c
index e585e59d315061e2e82ea8a23843c128bcce2555..4127031910c83987c8ef394e3711942e2db8a8f9 100644 (file)
--- a/var.c
+++ b/var.c
@@ -67,8 +67,8 @@ int main(int argc, char **argv)
        val = read_var(argv[1]);
        if (!val)
                usage(var_usage);
-       
+
        printf("%s\n", val);
-       
+
        return 0;
 }
index 4bfe8f15d8a0e275f1ed2d2458cda4d592f7c630..52054201c2a8729e036a5d97337a5f85bcafc782 100644 (file)
@@ -198,7 +198,7 @@ static void wt_read_cache(struct wt_status *s)
        read_cache();
 }
 
-void wt_status_print_initial(struct wt_status *s)
+static void wt_status_print_initial(struct wt_status *s)
 {
        int i;
        char buf[PATH_MAX];
index 10816e95a07c23dda7554c102c306d7e9beca606..e407cf11b1d8ba28be64eda7bcb505d9edb4d253 100644 (file)
@@ -122,4 +122,10 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
        return 0;
 }
 
-
+#define FIRST_FEW_BYTES 8000
+int buffer_is_binary(const char *ptr, unsigned long size)
+{
+       if (FIRST_FEW_BYTES < size)
+               size = FIRST_FEW_BYTES;
+       return !!memchr(ptr, 0, size);
+}
index 1918808081c00daf20a16a1592c0ed9be6d79be4..536f4e4d9784e0e5ffdc108a5be4bf758d1578ba 100644 (file)
@@ -18,5 +18,6 @@ int parse_hunk_header(char *line, int len,
                      int *ob, int *on,
                      int *nb, int *nn);
 int read_mmfile(mmfile_t *ptr, const char *filename);
+int buffer_is_binary(const char *ptr, unsigned long size);
 
 #endif
index e874a7c46a90104ebf586d0fc48964634f356763..9402bb0799978e181ba972a749a0ad849d2bd706 100644 (file)
@@ -103,4 +103,3 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
 #endif /* #ifdef __cplusplus */
 
 #endif /* #if !defined(XDIFF_H) */
-
index 9aeebc473b11a3dbfa5b52930b4a8e5a35f22215..5cb7171a8f528881c6171defa5b102e87d7aa522 100644 (file)
@@ -565,4 +565,3 @@ int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
 
        return 0;
 }
-
index 472aeaecfab85e7276baaceb446d2095eeab01fd..3e099dc445d6130f6a0ce2c6270a3b06d6ee119f 100644 (file)
@@ -57,4 +57,3 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
                  xdemitconf_t const *xecfg);
 
 #endif /* #if !defined(XDIFFI_H) */
-
index e291dc7608c4ab9b54a5d049bf3b555704e37fe8..4b6e6391123ed92470f8cbaf8b87286e498dfe00 100644 (file)
@@ -99,8 +99,8 @@ static void xdl_find_func(xdfile_t *xf, long i, char *buf, long sz, long *ll) {
 }
 
 
-int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
-                   xdemitconf_t const *xecfg) {
+static int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
+                           xdemitconf_t const *xecfg) {
        xdfile_t *xdf = &xe->xdf1;
        const char *rchg = xdf->rchg;
        long ix;
@@ -194,4 +194,3 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
 
        return 0;
 }
-
index e629417dd2028be30e661fe9059a9a3af30b482d..440a7390fa4abb0411c336cfba616e3229484e86 100644 (file)
@@ -31,4 +31,3 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
 
 
 #endif /* #if !defined(XEMIT_H) */
-
index 04a9da82c9cb7a2ab24d86efb0e6c6aafdd55f3b..526ccb344d231fb978f53b80deb17ec6c8fed368 100644 (file)
@@ -40,4 +40,3 @@
 
 
 #endif /* #if !defined(XINCLUDE_H) */
-
index e2cd2023b31e794bc0c5ba28f64ae4ce4e128184..8ef232cfad12d706aaafe705bf16c546f3597182 100644 (file)
@@ -51,4 +51,3 @@ do { \
 
 
 #endif /* #if !defined(XMACROS_H) */
-
index 1be7b3195059bebffe83d17301f3ff0fb261799e..e87ab57c652b56b1a684e2a0a56885c1d1b27ef7 100644 (file)
@@ -466,4 +466,3 @@ static int xdl_optimize_ctxs(xdfile_t *xdf1, xdfile_t *xdf2) {
 
        return 0;
 }
-
index 344c569e8b4ebeec2f1e6130184a424ae1341bf6..8fb06a537451cbf3335ab4bdacb0f992e9744338 100644 (file)
@@ -32,4 +32,3 @@ void xdl_free_env(xdfenv_t *xe);
 
 
 #endif /* #if !defined(XPREPARE_H) */
-
index 3593a664fc2e58a6cdd2a5f3bdee46dd5ffdaa8e..2511aef8d89ab52be5ec6a5e46236b4b6bcd07ea 100644 (file)
@@ -65,4 +65,3 @@ typedef struct s_xdfenv {
 
 
 #endif /* #if !defined(XTYPES_H) */
-
index bf91c0f73c658637d078ac93226148faa3bb0dc4..2ade97b2574a9f77e7ae4002a4e07a6a38e46d07 100644 (file)
@@ -380,4 +380,3 @@ int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2,
 
        return 0;
 }
-
index 70d8b9838a7333bc5a1edb93cf0e9abdbcf146cc..d5de8292e05e7c36c4b68857c1cf9855e3d2f70a 100644 (file)
@@ -45,4 +45,3 @@ int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2,
 
 
 #endif /* #if !defined(XUTILS_H) */
-