Code

Merge commit 'sg/merge-options^' into jk/renamelimit
authorJunio C Hamano <gitster@pobox.com>
Sat, 3 May 2008 20:18:20 +0000 (13:18 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 3 May 2008 20:18:20 +0000 (13:18 -0700)
* commit 'sg/merge-options^':
  merge, pull: add '--(no-)log' command line option
  fmt-merge-msg: add '--(no-)log' options and 'merge.log' config variable
  add 'merge.stat' config variable
  merge, pull: introduce '--(no-)stat' option
  doc: moved merge.* config variables into separate merge-config.txt

95 files changed:
Documentation/RelNotes-1.5.5.1.txt [new file with mode: 0644]
Documentation/RelNotes-1.5.6.txt [new file with mode: 0644]
Documentation/config.txt
Documentation/cvs-migration.txt
Documentation/diff-options.txt
Documentation/everyday.txt
Documentation/git-checkout.txt
Documentation/git-clone.txt
Documentation/git-config.txt
Documentation/git-cvsserver.txt
Documentation/git-fsck.txt
Documentation/git-gc.txt
Documentation/git-init.txt
Documentation/git-prune.txt
Documentation/git-push.txt
Documentation/git-rev-parse.txt
Documentation/git-rm.txt
Documentation/git-status.txt
Documentation/git-unpack-objects.txt
Documentation/git.txt
Documentation/gitk.txt
Documentation/hooks.txt
Documentation/howto/setup-git-server-over-http.txt
Documentation/user-manual.txt
Makefile
RelNotes
archive.c
attr.c
builtin-apply.c
builtin-checkout.c
builtin-clean.c
builtin-commit.c
builtin-config.c
builtin-fetch-pack.c
builtin-fetch.c
builtin-fmt-merge-msg.c
builtin-gc.c
builtin-init-db.c
builtin-log.c
builtin-remote.c
builtin-rev-parse.c
cache-tree.c
cache.h
combine-diff.c
commit.h
config.c
contrib/completion/git-completion.bash
contrib/emacs/git.el
contrib/hooks/post-receive-email
contrib/hooks/pre-auto-gc-battery [new file with mode: 0644]
copy.c
diff-lib.c
diff.c
dir.c
git-am.sh
git-bisect.sh
git-clone.sh
git-compat-util.h
git-cvsimport.perl
git-submodule.sh
git-svn.perl
git.c
gitweb/INSTALL
gitweb/README
gitweb/gitweb.perl
imap-send.c
log-tree.c
path.c
pretty.c
refs.c
remote.c
remote.h
revision.c
revision.h
setup.c
sha1-lookup.c [new file with mode: 0644]
sha1-lookup.h [new file with mode: 0644]
sha1_file.c
sha1_name.c
t/t0003-attributes.sh
t/t0004-unwritable.sh [new file with mode: 0755]
t/t1300-repo-config.sh
t/t1301-shared-repo.sh
t/t2002-checkout-cache-u.sh
t/t3408-rebase-multi-line.sh [new file with mode: 0755]
t/t5505-remote.sh
t/t5516-fetch-push.sh
t/t5601-clone.sh [new file with mode: 0755]
t/t6030-bisect-porcelain.sh
t/t7300-clean.sh
t/t7401-submodule-summary.sh
t/t7502-status.sh
t/t9500-gitweb-standalone-no-errors.sh
write_or_die.c
wt-status.c

diff --git a/Documentation/RelNotes-1.5.5.1.txt b/Documentation/RelNotes-1.5.5.1.txt
new file mode 100644 (file)
index 0000000..7de4197
--- /dev/null
@@ -0,0 +1,44 @@
+GIT v1.5.5.1 Release Notes
+==========================
+
+Fixes since v1.5.5
+------------------
+
+ * "git archive --prefix=$path/" mishandled gitattributes.
+
+ * "git fetch -v" that fetches into FETCH_HEAD did not report the summary
+   the same way as done for updating the tracking refs.
+
+ * "git svn" misbehaved when the configuration file customized the "git
+   log" output format using format.pretty.
+
+ * "git submodule status" leaked an unnecessary error message.
+
+ * "git log --date-order --topo-order" did not override the earlier
+   date-order with topo-order as expected.
+
+ * "git bisect good $this" did not check the validity of the revision
+   given properly.
+
+ * "url.<there>.insteadOf" did not work correctly.
+
+ * "git clean" ran inside subdirectory behaved as if the directory was
+   explicitly specified for removal by the end user from the top level.
+
+ * "git bisect" from a detached head leaked an unnecessary error message.
+
+ * "git bisect good $a $b" when $a is Ok but $b is bogus should have
+   atomically failed before marking $a as good.
+
+ * "git fmt-merge-msg" did not clean up leading empty lines from commit
+   log messages like "git log" family does.
+
+ * "git am" recorded a commit with empty Subject: line without
+   complaining.
+
+ * when given a commit log message whose first paragraph consists of
+   multiple lines, "git rebase" squashed it into a single line.
+
+ * "git remote add $bogus_name $url" did not complain properly.
+
+Also comes with various documentation updates.
diff --git a/Documentation/RelNotes-1.5.6.txt b/Documentation/RelNotes-1.5.6.txt
new file mode 100644 (file)
index 0000000..f3256fb
--- /dev/null
@@ -0,0 +1,59 @@
+GIT v1.5.6 Release Notes
+========================
+
+Updates since v1.5.5
+--------------------
+
+(subsystems)
+
+
+(portability)
+
+
+(performance)
+
+* "git rebase --onto $there $from $branch" used to switch to the tip of
+  $branch only to immediately reset back to $from, smudging work tree
+  files unnecessarily.  This has been optimized.
+
+(usability, bells and whistles)
+
+* "git add -p" (and the "patch" subcommand of "git add -i") can choose to
+  apply (or not apply) mode changes independently from contents changes.
+
+* "git bisect help" gives longer and more helpful usage information.
+
+* "git diff/log --dirstat" output is consistent between binary and textual
+  changes.
+
+* "git gc --auto" honors a new pre-aut-gc hook to temporarily disable it.
+
+* "git log --pretty=tformat:<custom format>" gives a LF after each entry,
+  instead of giving a LF between each pair of entries which is how
+  "git log --pretty=format:<custom format>" works.
+
+* "git send-email" now can send out messages outside a git repository.
+
+* "git status" can optionally include output from "git submodule
+  summary".
+
+* "gitweb" can read from a system-wide configuration file.
+
+(internal)
+
+* "git unpack-objects" and "git receive-pack" is now more strict about
+  detecting breakage in the objects they receive over the wire.
+
+
+Fixes since v1.5.5
+------------------
+
+All of the fixes in v1.5.5 maintenance series are included in
+this release, unless otherwise noted.
+
+
+--
+exec >/var/tmp/1
+O=v1.5.5-56-g5f0734f
+echo O=`git describe refs/heads/master`
+git shortlog --no-merges $O..refs/heads/master ^refs/heads/maint
index bef612705ab9424a33d15cb93af149a112a0fcc4..3cad707be07c1941ec3f1b472d938400248cd3e4 100644 (file)
@@ -234,7 +234,13 @@ core.worktree::
        used in combination with repositories found automatically in
        a .git directory (i.e. $GIT_DIR is not set).
        This can be overridden by the GIT_WORK_TREE environment
-       variable and the '--work-tree' command line option.
+       variable and the '--work-tree' command line option. It can be
+       a absolute path or relative path to the directory specified by
+       --git-dir or GIT_DIR.
+       Note: If --git-dir or GIT_DIR are specified but none of
+       --work-tree, GIT_WORK_TREE and core.worktree is specified,
+       the current working directory is regarded as the top directory
+       of your working tree.
 
 core.logAllRefUpdates::
        Enable the reflog. Updates to a ref <ref> is logged to the file
@@ -261,7 +267,12 @@ core.sharedRepository::
        group-writable). When 'all' (or 'world' or 'everybody'), the
        repository will be readable by all users, additionally to being
        group-shareable. When 'umask' (or 'false'), git will use permissions
-       reported by umask(2). See linkgit:git-init[1]. False by default.
+       reported by umask(2). When '0xxx', where '0xxx' is an octal number,
+       files in the repository will have this mode value. '0xxx' will override
+       user's umask value, and thus, users with a safe umask (0077) can use
+       this option. Examples: '0660' is equivalent to 'group'. '0640' is a
+       repository that is group-readable but not group-writable.
+       See linkgit:git-init[1]. False by default.
 
 core.warnAmbiguousRefs::
        If true, git will warn you if the ref name you passed it is ambiguous
index ea98900228bda97cd4a3da190de9de5ecc3ec6e6..00f2e36b2ec162c6ef6d9c731ff549643ecb3ce7 100644 (file)
@@ -8,7 +8,8 @@ designating a single shared repository which people can synchronize with;
 this document explains how to do that.
 
 Some basic familiarity with git is required.  This
-link:tutorial.html[tutorial introduction to git] should be sufficient.
+link:tutorial.html[tutorial introduction to git] and the
+link:glossary.html[git glossary] should be sufficient.
 
 Developing against a shared repository
 --------------------------------------
index 8dc5b001c42376be1b9f814d516ea43f5c711071..13234fa280b279bfccad0a9aec6989727957567a 100644 (file)
@@ -58,6 +58,14 @@ endif::git-format-patch[]
        number of modified files, as well as number of added and deleted
        lines.
 
+--dirstat[=limit]::
+       Output only the sub-directories that are impacted by a diff,
+       and to what degree they are impacted.  You can override the
+       default cut-off in percent (3) by "--dirstat=limit".  If you
+       want to enable "cumulative" directory statistics, you can use
+       the "--cumulative" flag, which adds up percentages recursively
+       even when they have been already reported for a sub-directory.
+
 --summary::
        Output a condensed summary of extended header information
        such as creations, renames and mode changes.
@@ -75,7 +83,8 @@ endif::git-format-patch[]
        Show only names of changed files.
 
 --name-status::
-       Show only names and status of changed files.
+       Show only names and status of changed files. See the description
+       of the `--diff-filter` option on what the status letters mean.
 
 --color::
        Show colored diff.
index fdbd15a18158f0b0a531c2d3df21afd7b1aa26c8..e598cdda45cf0b953a106d6786765b3316e2cc16 100644 (file)
@@ -48,14 +48,12 @@ $ git gc <3>
 repository health reasonably well.
 <2> check how many loose objects there are and how much
 disk space is wasted by not repacking.
-<3> repacks the local repository and performs other housekeeping tasks. Running
-without `--prune` is a safe operation even while other ones are in progress.
+<3> repacks the local repository and performs other housekeeping tasks.
 
 Repack a small project into single pack.::
 +
 ------------
 $ git gc <1>
-$ git gc --prune
 ------------
 +
 <1> pack all the objects reachable from the refs into one pack,
@@ -182,7 +180,7 @@ $ git pull <3>
 $ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <4>
 $ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <5>
 $ git reset --hard ORIG_HEAD <6>
-$ git gc --prune <7>
+$ git gc <7>
 $ git fetch --tags <8>
 ------------
 +
index e11cddbfc96f742968789abd369a4f7e240db27c..a644173e15da7e3203fa8de8a6cb917f138f93c2 100644 (file)
@@ -47,7 +47,7 @@ OPTIONS
        by linkgit:git-check-ref-format[1].  Some of these checks
        may restrict the characters allowed in a branch name.
 
---track::
+-t, --track::
        When creating a new branch, set up configuration so that git-pull
        will automatically retrieve data from the start point, which must be
        a branch. Use this if you always pull from the same upstream branch
index 975824301a45bfa297f2ecd5c19e429cb9c86c65..9b564420c53e33616c605b6564e2f1f227725805 100644 (file)
@@ -65,10 +65,13 @@ OPTIONS
 +
 *NOTE*: this is a possibly dangerous operation; do *not* use
 it unless you understand what it does. If you clone your
-repository using this option, then delete branches in the
-source repository and then run linkgit:git-gc[1] using the
-'--prune' option in the source repository, it may remove
-objects which are referenced by the cloned repository.
+repository using this option and then delete branches (or use any
+other git command that makes any existing commit unreferenced) in the
+source repository, some objects may become unreferenced (or dangling).
+These objects may be removed by normal git operations (such as git-commit[1])
+which automatically call git-gc[1]. If these objects are removed and
+were referenced by the cloned repository, then the cloned repository
+will become corrupt.
 
 
 
@@ -79,6 +82,8 @@ objects which are referenced by the cloned repository.
        an already existing repository as an alternate will
        require fewer objects to be copied from the repository
        being cloned, reducing network and local storage costs.
++
+*NOTE*: see NOTE to --shared option.
 
 --quiet::
 -q::
index fa161718dd33a0b4c3b58fb3898e74369bcc3d94..5de5d051b7917daabd0ef7c0681c6b75307a931a 100644 (file)
@@ -144,6 +144,8 @@ See also <<FILES>>.
        "auto".  If `stdout-is-tty` is missing, then checks the standard
        output of the command itself, and exits with status 0 if color
        is to be used, or exits with status 1 otherwise.
+       When the color setting for `name` is undefined, the command uses
+       `color.ui` as fallback.
 
 --get-color name default::
 
index 9cec8021b8c66b6bac692e2a9f14204503f7f18a..b1106714b2f7100124826819315e78f7f28325fb 100644 (file)
@@ -110,7 +110,9 @@ cvs -d ":ext;CVS_SERVER=git-cvsserver:user@server/path/repo.git" co <HEAD_name>
 ------
 This has the advantage that it will be saved in your 'CVS/Root' files and
 you don't need to worry about always setting the correct environment
-variable.
+variable.  SSH users restricted to git-shell don't need to override the default
+with CVS_SERVER (and shouldn't) as git-shell understands `cvs` to mean
+git-cvsserver and pretends that the other end runs the real cvs better.
 --
 2. For each repo that you want accessible from CVS you need to edit config in
    the repo and add the following section.
@@ -141,25 +143,29 @@ allowing access over SSH.
         enabled=1
 ------
 --
-3. On the client machine you need to set the following variables.
-   CVSROOT should be set as per normal, but the directory should point at the
-   appropriate git repo. For example:
+3. If you didn't specify the CVSROOT/CVS_SERVER directly in the checkout command,
+   automatically saving it in your 'CVS/Root' files, then you need to set them
+   explicitly in your environment.  CVSROOT should be set as per normal, but the
+   directory should point at the appropriate git repo.  As above, for SSH clients
+   _not_ restricted to git-shell, CVS_SERVER should be set to git-cvsserver.
 +
 --
-For SSH access, CVS_SERVER should be set to git-cvsserver
-
-Example:
-
 ------
      export CVSROOT=:ext:user@server:/var/git/project.git
      export CVS_SERVER=git-cvsserver
 ------
 --
-4. For SSH clients that will make commits, make sure their .bashrc file
-   sets the GIT_AUTHOR and GIT_COMMITTER variables.
+4. For SSH clients that will make commits, make sure their server-side
+   .ssh/environment files (or .bashrc, etc., according to their specific shell)
+   export appropriate values for GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL,
+   GIT_COMMITTER_NAME, and GIT_COMMITTER_EMAIL.  For SSH clients whose login
+   shell is bash, .bashrc may be a reasonable alternative.
 
 5. Clients should now be able to check out the project. Use the CVS 'module'
-   name to indicate what GIT 'head' you want to check out. Example:
+   name to indicate what GIT 'head' you want to check out.  This also sets the
+   name of your newly checked-out directory, unless you tell it otherwise with
+   `-d <dir_name>`.  For example, this checks out 'master' branch to the
+   `project-master` directory:
 +
 ------
      cvs co -d project-master master
index f16cb986122c8560622bfbceebc325ee4d27b768..4cc26fb744e892115d8bfa099e48acc102a8689b 100644 (file)
@@ -22,7 +22,8 @@ OPTIONS
        An object to treat as the head of an unreachability trace.
 +
 If no objects are given, git-fsck defaults to using the
-index file and all SHA1 references in .git/refs/* as heads.
+index file, all SHA1 references in .git/refs/*, and all reflogs (unless
+--no-reflogs is given) as heads.
 
 --unreachable::
        Print out objects that exist but that aren't readable from any
index d424a4ecbe2c751550f50048e63ce640941a3ebb..b6b5ce15199ebfa8f92bff8586d04e502aa23b86 100644 (file)
@@ -104,6 +104,21 @@ The optional configuration variable 'gc.pruneExpire' controls how old
 the unreferenced loose objects have to be before they are pruned.  The
 default is "2 weeks ago".
 
+
+Notes
+-----
+
+git-gc tries very hard to be safe about the garbage it collects. In
+particular, it will keep not only objects referenced by your current set
+of branches and tags, but also objects referenced by the index, remote
+tracking branches, refs saved by linkgit:git-filter-branch[1] in
+refs/original/, or reflogs (which may references commits in branches
+that were later amended or rewound).
+
+If you are expecting some objects to be collected and they aren't, check
+all of those locations and decide whether it makes sense in your case to
+remove those references.
+
 See Also
 --------
 linkgit:git-prune[1]
index 62914da97b5b8335a2c2597606f046dfb2295e03..b17ae8485cf2d3eb4fc21acba769942a57d33e67 100644 (file)
@@ -31,7 +31,7 @@ structure, some suggested "exclude patterns", and copies of non-executing
 "hook" files.  The suggested patterns and hook files are all modifiable and
 extensible.
 
---shared[={false|true|umask|group|all|world|everybody}]::
+--shared[={false|true|umask|group|all|world|everybody|0xxx}]::
 
 Specify that the git repository is to be shared amongst several users.  This
 allows users belonging to the same group to push into that
@@ -52,6 +52,12 @@ is given:
  - 'all' (or 'world' or 'everybody'): Same as 'group', but make the repository
    readable by all users.
 
+ - '0xxx': '0xxx' is an octal number and each file will have mode '0xxx'
+   Any option except 'umask' can be set using this option. '0xxx' will
+   override users umask(2) value, and thus, users with a safe umask (0077)
+   can use this option. '0640' will create a repository which is group-readable
+   but not writable. '0660' is equivalent to 'group'.
+
 By default, the configuration flag receive.denyNonFastForwards is enabled
 in shared repositories, so that you cannot force a non fast-forwarding push
 into it.
index f151cff5d968e5ed7f66a78d21ac74f74b3d4737..f92bb8cfa069283b0e8b78b717eedbef81bbe647 100644 (file)
@@ -13,6 +13,9 @@ SYNOPSIS
 DESCRIPTION
 -----------
 
+NOTE: In most cases, users should run linkgit:git-gc[1], which calls
+git-prune. See the section "NOTES", below.
+
 This runs `git-fsck --unreachable` using all the refs
 available in `$GIT_DIR/refs`, optionally with additional set of
 objects specified on the command line, and prunes all
@@ -50,6 +53,23 @@ borrows from your repository via its
 $ git prune $(cd ../another && $(git-rev-parse --all))
 ------------
 
+Notes
+-----
+
+In most cases, users will not need to call git-prune directly, but
+should instead call linkgit:git-gc[1], which handles pruning along with
+many other housekeeping tasks.
+
+For a description of which objects are considered for pruning, see
+git-fsck's --unreachable option.
+
+See Also
+--------
+
+linkgit:git-fsck[1],
+linkgit:git-gc[1],
+linkgit:git-reflog[1]
+
 Author
 ------
 Written by Linus Torvalds <torvalds@osdl.org>
index 3128170bcd1c3e3eb5981ed4c2f35221dfb06658..05859491378243639e81c9c8ab7deffb90d83d07 100644 (file)
@@ -35,14 +35,15 @@ OPTIONS
        by the source ref, followed by a colon `:`, followed by
        the destination ref.
 +
-The <src> side can be an
-arbitrary "SHA1 expression" that can be used as an
-argument to `git-cat-file -t`.  E.g. `master~4` (push
-four parents before the current master head).
+The <src> side represents the source branch (or arbitrary
+"SHA1 expression", such as `master~4` (four parents before the
+tip of `master` branch); see linkgit:git-rev-parse[1]) that you
+want to push.  The <dst> side represents the destination location.
 +
 The local ref that matches <src> is used
-to fast forward the remote ref that matches <dst>.  If
-the optional plus `+` is used, the remote ref is updated
+to fast forward the remote ref that matches <dst> (or, if no <dst> was
+specified, the same ref that <src> referred to locally).  If
+the optional leading plus `+` is used, the remote ref is updated
 even if it does not result in a fast forward update.
 +
 Note: If no explicit refspec is found, (that is neither
@@ -165,7 +166,8 @@ git push origin master::
        Find a ref that matches `master` in the source repository
        (most likely, it would find `refs/heads/master`), and update
        the same ref (e.g. `refs/heads/master`) in `origin` repository
-       with it.
+       with it.  If `master` did not exist remotely, it would be
+       created.
 
 git push origin :experimental::
        Find a ref that matches `experimental` in the `origin` repository
@@ -179,9 +181,10 @@ git push origin master:satellite/master::
 
 git push origin master:refs/heads/experimental::
        Create the branch `experimental` in the `origin` repository
-       by copying the current `master` branch.  This form is usually
-       needed to create a new branch in the remote repository as
-       there is no `experimental` branch to match.
+       by copying the current `master` branch.  This form is only
+       needed to create a new branch or tag in the remote repository when
+       the local name and the remote name are different; otherwise,
+       the ref name on its own will work.
 
 Author
 ------
index 6513c2efe17668d5fc25a21385ed117ec76b40b5..110e7ba71f48c54cb94f35e819583826e123a8b1 100644 (file)
@@ -52,6 +52,11 @@ OPTIONS
        The parameter given must be usable as a single, valid
        object name.  Otherwise barf and abort.
 
+-q, --quiet::
+       Only meaningful in `--verify` mode. Do not output an error
+       message if the first argument is not a valid object name;
+       instead exit with non-zero status silently.
+
 --sq::
        Usually the output is made one line per flag and
        parameter.  This option makes output a single line,
index dc36c662ae0d60b7dc706fce67a7c81849caace6..9c81b72dbebfec9b77128fb58d5aab33a143d594 100644 (file)
@@ -11,28 +11,37 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-Remove files from the working tree and from the index.  The
-files have to be identical to the tip of the branch, and no
-updates to its contents must have been placed in the staging
-area (aka index).  When --cached is given, the staged content has to
-match either the tip of the branch *or* the file on disk.
+Remove files from the index, or from the working tree and the index.
+`git rm` will not remove a file from just your working directory.
+(There is no option to remove a file only from the work tree
+and yet keep it in the index; use `/bin/rm` if you want to do that.)
+The files being removed have to be identical to the tip of the branch,
+and no updates to their contents can be staged in the index,
+though that default behavior can be overridden with the `-f` option.
+When '--cached' is given, the staged content has to
+match either the tip of the branch or the file on disk,
+allowing the file to be removed from just the index.
 
 
 OPTIONS
 -------
 <file>...::
        Files to remove.  Fileglobs (e.g. `*.c`) can be given to
-       remove all matching files.  Also a leading directory name
-       (e.g. `dir` to add `dir/file1` and `dir/file2`) can be
-       given to remove all files in the directory, recursively,
-       but this requires `-r` option to be given for safety.
+       remove all matching files.  If you want git to expand
+       file glob characters, you may need to shell-escape them.
+       A leading directory name
+       (e.g. `dir` to remove `dir/file1` and `dir/file2`) can be
+       given to remove all files in the directory, and recursively
+       all sub-directories,
+       but this requires the `-r` option to be explicitly given.
 
 -f::
        Override the up-to-date check.
 
 -n, \--dry-run::
-        Don't actually remove the file(s), just show if they exist in
-        the index.
+       Don't actually remove any file(s).  Instead, just show
+       if they exist in the index and would otherwise be removed
+       by the command.
 
 -r::
         Allow recursive removal when a leading directory name is
@@ -44,9 +53,9 @@ OPTIONS
        for command-line options).
 
 \--cached::
-       This option can be used to tell the command to remove
-       the paths only from the index, leaving working tree
-       files.
+       Use this option to unstage and remove paths only from the index.
+       Working tree files, whether modified or not, will be
+       left alone.
 
 \--ignore-unmatch::
        Exit with a zero status even if no files matched.
@@ -59,11 +68,15 @@ OPTIONS
 DISCUSSION
 ----------
 
-The list of <file> given to the command can be exact pathnames,
-file glob patterns, or leading directory name.  The command
-removes only the paths that is known to git.  Giving the name of
+The <file> list given to the command can be exact pathnames,
+file glob patterns, or leading directory names.  The command
+removes only the paths that are known to git.  Giving the name of
 a file that you have not told git about does not remove that file.
 
+File globbing matches across directory boundaries.  Thus, given
+two directories `d` and `d2`, there is a difference between
+using `git rm \'d\*\'` and `git rm \'d/\*\'`, as the former will
+also remove all of directory `d2`.
 
 EXAMPLES
 --------
@@ -72,11 +85,10 @@ git-rm Documentation/\\*.txt::
        `Documentation` directory and any of its subdirectories.
 +
 Note that the asterisk `\*` is quoted from the shell in this
-example; this lets the command include the files from
-subdirectories of `Documentation/` directory.
+example; this lets git, and not the shell, expand the pathnames
+of files and subdirectories under the `Documentation/` directory.
 
 git-rm -f git-*.sh::
-       Remove all git-*.sh scripts that are in the index.
        Because this example lets the shell expand the asterisk
        (i.e. you are listing the files explicitly), it
        does not remove `subdir/git-foo.sh`.
index 3ea269aa7a192d9f48ad2dc71f9cd790634c7852..ea4376a17f17eb2658bdf5d7faad1bd091a4de0e 100644 (file)
@@ -52,6 +52,11 @@ If the config variable `status.relativePaths` is set to false, then all
 paths shown are relative to the repository root, not to the current
 directory.
 
+If `status.submodulesummary` is set to a non zero number or true (identical
+to -1 or an unlimited number), the submodule summary will be enabled and a
+summary of commits for modified submodules will be shown (see --summary-limit
+option of linkgit:git-submodule[1]).
+
 See Also
 --------
 linkgit:gitignore[5]
index 3697896a06b460d9d29f962240dc46388487990a..50947c50df1fe05b7eac8e046556c6ee070c7327 100644 (file)
@@ -8,7 +8,7 @@ git-unpack-objects - Unpack objects from a packed archive
 
 SYNOPSIS
 --------
-'git-unpack-objects' [-n] [-q] [-r] <pack-file
+'git-unpack-objects' [-n] [-q] [-r] [--strict] <pack-file
 
 
 DESCRIPTION
index 336fe99cc78d932f216cc7b04ac3a36685f9f96e..6f445b1e3bbefccdb865f8cb93fb470892b94e41 100644 (file)
@@ -46,8 +46,11 @@ Documentation for older releases are available here:
 * link:v1.5.5/git.html[documentation for release 1.5.5]
 
 * release notes for
+  link:RelNotes-1.5.5.1.txt[1.5.5.1],
   link:RelNotes-1.5.5.txt[1.5.5].
 
+* link:v1.5.5.1/git.html[documentation for release 1.5.5.1]
+
 * link:v1.5.4.5/git.html[documentation for release 1.5.4.5]
 
 * release notes for
@@ -140,7 +143,8 @@ help ...'.
 
 --git-dir=<path>::
        Set the path to the repository. This can also be controlled by
-       setting the GIT_DIR environment variable.
+       setting the GIT_DIR environment variable. It can be an absolute
+       path or relative path to current working directory.
 
 --work-tree=<path>::
        Set the path to the working tree.  The value will not be
@@ -148,7 +152,12 @@ help ...'.
        a .git directory (i.e. $GIT_DIR is not set).
        This can also be controlled by setting the GIT_WORK_TREE
        environment variable and the core.worktree configuration
-       variable.
+       variable. It can be an absolute path or relative path to
+       the directory specified by --git-dir or GIT_DIR.
+       Note: If --git-dir or GIT_DIR are specified but none of
+       --work-tree, GIT_WORK_TREE and core.worktree is specified,
+       the current working directory is regarded as the top directory
+       of your working tree.
 
 --bare::
        Treat the repository as a bare repository.  If GIT_DIR
index ed3ba83c530411801dd1cd8980cad4d005962690..50d12da89fca37b60a024aeb2ac6de9cb2daf001 100644 (file)
@@ -41,6 +41,12 @@ frequently used options.
 
        Show all branches.
 
+--merge::
+
+       After an attempt to merge stops with conflicts, show the commits on
+       the history between two branches (i.e. the HEAD and the MERGE_HEAD)
+       that modify the conflicted files.
+
 <revs>::
 
        Limit the revisions to show. This can be either a single revision
index 76b8d77460e961fda9a5505a4ce0cf20788de133..44fbe58f20701291c0a43779fe0db826185f4322 100644 (file)
@@ -276,3 +276,10 @@ probably enable this hook.
 Both standard output and standard error output are forwarded to
 `git-send-pack` on the other end, so you can simply `echo` messages
 for the user.
+
+pre-auto-gc
+-----------
+
+This hook is invoked by `git-gc --auto`. It takes no parameter, and
+exiting with non-zero status from this script causes the `git-gc --auto`
+to abort.
index 8eadc2049402cc21fd80818ca9f29d15f4cd8462..b7d09c1ec69ac0e76302cef44d5f6884d05a0e0f 100644 (file)
@@ -1,5 +1,5 @@
 From: Rutger Nijlunsing <rutger@nospam.com>
-Subject: Setting up a git repository which can be pushed into and pulled from over HTTP.
+Subject: Setting up a git repository which can be pushed into and pulled from over HTTP(S).
 Date: Thu, 10 Aug 2006 22:00:26 +0200
 
 Since Apache is one of those packages people like to compile
@@ -40,9 +40,13 @@ What's needed:
 
 - have permissions to chown a directory
 
-- have git installed at the server _and_ client
+- have git installed on the client, and
 
-In effect, this probably means you're going to be root.
+- either have git installed on the server or have a webdav client on
+  the client.
+
+In effect, this means you're going to be root, or that you're using a
+preconfigured WebDAV server.
 
 
 Step 1: setup a bare GIT repository
@@ -50,9 +54,9 @@ Step 1: setup a bare GIT repository
 
 At the time of writing, git-http-push cannot remotely create a GIT
 repository. So we have to do that at the server side with git. Another
-option would be to generate an empty repository at the client and copy
-it to the server with WebDAV. But then you're probably the first to
-try that out :)
+option is to generate an empty bare repository at the client and copy
+it to the server with a WebDAV client (which is the only option if Git
+is not installed on the server).
 
 Create the directory under the DocumentRoot of the directories served
 by Apache. As an example we take /usr/local/apache2, but try "grep
@@ -169,7 +173,9 @@ On Debian:
 
    Most tests should pass.
 
-A command line tool to test WebDAV is cadaver.
+A command line tool to test WebDAV is cadaver. If you prefer GUIs, for
+example, konqueror can open WebDAV URLs as "webdav://..." or
+"webdavs://...".
 
 If you're into Windows, from XP onwards Internet Explorer supports
 WebDAV. For this, do Internet Explorer -> Open Location ->
@@ -179,8 +185,9 @@ http://<servername>/my-new-repo.git [x] Open as webfolder -> login .
 Step 3: setup the client
 ------------------------
 
-Make sure that you have HTTP support, i.e. your git was built with curl.
-The easiest way to check is to look for the executable 'git-http-push'.
+Make sure that you have HTTP support, i.e. your git was built with
+curl (version more recent than 7.10). The command 'git http-push' with
+no argument should display a usage message.
 
 Then, add the following to your $HOME/.netrc (you can do without, but will be
 asked to input your password a _lot_ of times):
@@ -197,10 +204,10 @@ instead of the server name.
 
 To check whether all is OK, do:
 
-   curl --netrc --location -v http://<username>@<servername>/my-new-repo.git/
-
-...this should give a directory listing in HTML of /var/www/my-new-repo.git .
+   curl --netrc --location -v http://<username>@<servername>/my-new-repo.git/HEAD
 
+...this should give something like 'ref: refs/heads/master', which is
+the content of the file HEAD on the server.
 
 Now, add the remote in your existing repository which contains the project
 you want to export:
@@ -225,6 +232,15 @@ want to export) to repository called 'upload', which we previously
 defined with git-config.
 
 
+Using a proxy:
+--------------
+
+If you have to access the WebDAV server from behind an HTTP(S) proxy,
+set the variable 'all_proxy' to 'http://proxy-host.com:port', or
+'http://login-on-proxy:passwd-on-proxy@proxy-host.com:port'. See 'man
+curl' for details.
+
+
 Troubleshooting:
 ----------------
 
@@ -248,9 +264,14 @@ Reading /usr/local/apache2/logs/error_log is often helpful.
 
   On Debian: Read /var/log/apache2/error.log instead.
 
+If you access HTTPS locations, git may fail verifying the SSL
+certificate (this is return code 60). Setting http.sslVerify=false can
+help diagnosing the problem, but removes security checks.
+
 
 Debian References: http://www.debian-administration.org/articles/285
 
 Authors
   Johannes Schindelin <Johannes.Schindelin@gmx.de>
   Rutger Nijlunsing <git@wingding.demon.nl>
+  Matthieu Moy <Matthieu.Moy@imag.fr>
index 565aeb98047573bd29cfa0c53aa460c2b7be543c..86b91a53e5c822782ed7682c83d435180d7b682f 100644 (file)
@@ -1548,22 +1548,7 @@ dangling tree b24c2473f1fd3d91352a624795be026d64c8841f
 
 Dangling objects are not a problem.  At worst they may take up a little
 extra disk space.  They can sometimes provide a last-resort method for
-recovering lost work--see <<dangling-objects>> for details.  However, if
-you wish, you can remove them with linkgit:git-prune[1] or the `--prune`
-option to linkgit:git-gc[1]:
-
--------------------------------------------------
-$ git gc --prune
--------------------------------------------------
-
-This may be time-consuming.  Unlike most other git operations (including
-git-gc when run without any options), it is not safe to prune while
-other git operations are in progress in the same repository.
-
-If linkgit:git-fsck[1] complains about sha1 mismatches or missing
-objects, you may have a much more serious problem; your best option is
-probably restoring from backups.  See
-<<recovering-from-repository-corruption>> for a detailed discussion.
+recovering lost work--see <<dangling-objects>> for details.
 
 [[recovering-lost-changes]]
 Recovering lost changes
index 78b773862197d46247aa73e5e38aac30edceecc2..9d84c8d799fc1044177197fb804411b05569dc83 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -366,6 +366,7 @@ LIB_H += refs.h
 LIB_H += remote.h
 LIB_H += revision.h
 LIB_H += run-command.h
+LIB_H += sha1-lookup.h
 LIB_H += sideband.h
 LIB_H += strbuf.h
 LIB_H += tag.h
@@ -446,6 +447,7 @@ LIB_OBJS += run-command.o
 LIB_OBJS += server-info.o
 LIB_OBJS += setup.o
 LIB_OBJS += sha1_file.o
+LIB_OBJS += sha1-lookup.o
 LIB_OBJS += sha1_name.o
 LIB_OBJS += shallow.o
 LIB_OBJS += sideband.o
index 3e77358f704fde7271f18ccbf90a57419550b265..e29d6504d9e8fe45d3f7ff7f82f1e8f1f57b9f6f 120000 (symlink)
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes-1.5.5.txt
\ No newline at end of file
+Documentation/RelNotes-1.5.6.txt
\ No newline at end of file
index fb159fe59e9e6fc40db584468c7b1ddf8495ccb3..7a32c19d3ca8043f3ca22dadfdbc60dbbb747d59 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -16,9 +16,9 @@ static void format_subst(const struct commit *commit,
                const char *b, *c;
 
                b = memmem(src, len, "$Format:", 8);
-               if (!b || src + len < b + 9)
+               if (!b)
                        break;
-               c = memchr(b + 8, '$', len - 8);
+               c = memchr(b + 8, '$', (src + len) - b - 8);
                if (!c)
                        break;
 
diff --git a/attr.c b/attr.c
index 64b77b16636482d3448027d7823e5dc07861faa5..1a15fad294c5db1f922e686995e215b94b89b9a0 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -546,7 +546,9 @@ static int path_matches(const char *pathname, int pathlen,
            (baselen && pathname[baselen] != '/') ||
            strncmp(pathname, base, baselen))
                return 0;
-       return fnmatch(pattern, pathname + baselen + 1, FNM_PATHNAME) == 0;
+       if (baselen != 0)
+               baselen++;
+       return fnmatch(pattern, pathname + baselen, FNM_PATHNAME) == 0;
 }
 
 static int fill_one(const char *what, struct match_attr *a, int rem)
index abe73a0f8194e95c2a10a27c2007560e6d57f3d5..caa3f2aa0ca147091d28013c3d2c11346e350675 100644 (file)
@@ -2981,12 +2981,8 @@ static int apply_patch(int fd, const char *filename, int inaccurate_eof)
 
 static int git_apply_config(const char *var, const char *value)
 {
-       if (!strcmp(var, "apply.whitespace")) {
-               if (!value)
-                       return config_error_nonbool(var);
-               apply_default_whitespace = xstrdup(value);
-               return 0;
-       }
+       if (!strcmp(var, "apply.whitespace"))
+               return git_config_string(&apply_default_whitespace, var, value);
        return git_default_config(var, value);
 }
 
@@ -3121,7 +3117,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
 
                fd = open(arg, O_RDONLY);
                if (fd < 0)
-                       usage(apply_usage);
+                       die("can't open patch '%s': %s", arg, strerror(errno));
                read_stdin = 0;
                set_default_whitespace_mode(whitespace_option);
                errs |= apply_patch(fd, arg, inaccurate_eof);
index 7deb504837d252dd43fa9746c5d12342e93a5923..14b2fe7760766c796d78fd910882c4ef8b917b98 100644 (file)
@@ -504,7 +504,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
                OPT__QUIET(&opts.quiet),
                OPT_STRING('b', NULL, &opts.new_branch, "new branch", "branch"),
                OPT_BOOLEAN('l', NULL, &opts.new_branch_log, "log for new branch"),
-               OPT_SET_INT( 0 , "track",  &opts.track, "track",
+               OPT_SET_INT('t', "track",  &opts.track, "track",
                        BRANCH_TRACK_EXPLICIT),
                OPT_BOOLEAN('f', NULL, &opts.force, "force"),
                OPT_BOOLEAN('m', NULL, &opts.merge, "merge"),
index fefec3010c434219234e7832051ada9ed2e52335..6778a03ae4c901d216e4b91cd41f2073e0e98589 100644 (file)
@@ -95,7 +95,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 
        for (i = 0; i < dir.nr; i++) {
                struct dir_entry *ent = dir.entries[i];
-               int len, pos, matches;
+               int len, pos;
+               int matches = 0;
                struct cache_entry *ce;
                struct stat st;
 
@@ -127,18 +128,18 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 
                if (pathspec) {
                        memset(seen, 0, argc > 0 ? argc : 1);
-                       matches = match_pathspec(pathspec, ent->name, ent->len,
+                       matches = match_pathspec(pathspec, ent->name, len,
                                                 baselen, seen);
-               } else {
-                       matches = 0;
                }
 
                if (S_ISDIR(st.st_mode)) {
                        strbuf_addstr(&directory, ent->name);
                        qname = quote_path_relative(directory.buf, directory.len, &buf, prefix);
-                       if (show_only && (remove_directories || matches)) {
+                       if (show_only && (remove_directories ||
+                           (matches == MATCHED_EXACTLY))) {
                                printf("Would remove %s\n", qname);
-                       } else if (remove_directories || matches) {
+                       } else if (remove_directories ||
+                                  (matches == MATCHED_EXACTLY)) {
                                if (!quiet)
                                        printf("Removing %s\n", qname);
                                if (remove_dir_recursively(&directory, 0) != 0) {
index bcb7aaaa93bb11bfb965fe67a644e2dd46c21c1b..256181a68bd991278fda4ecb48911d03b5f23141 100644 (file)
@@ -90,7 +90,7 @@ static struct option builtin_commit_options[] = {
        OPT_CALLBACK('m', "message", &message, "MESSAGE", "specify commit message", opt_parse_m),
        OPT_STRING('c', "reedit-message", &edit_message, "COMMIT", "reuse and edit message from specified commit "),
        OPT_STRING('C', "reuse-message", &use_message, "COMMIT", "reuse message from specified commit"),
-       OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by: header"),
+       OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
        OPT_STRING('t', "template", &template_file, "FILE", "use specified template file"),
        OPT_BOOLEAN('e', "edit", &edit_flag, "force edit of commit"),
 
@@ -808,7 +808,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 
        rev.verbose_header = 1;
        rev.show_root_diff = 1;
-       rev.commit_format = get_commit_format("format:%h: %s");
+       get_commit_format("format:%h: %s", &rev);
        rev.always_show_header = 0;
        rev.diffopt.detect_rename = 1;
        rev.diffopt.rename_limit = 100;
index c34bc8b6a6957ccee1db23a3c44c99e058384689..8ee01bdecde1ede4062a630761ce56f3366f3a14 100644 (file)
@@ -3,7 +3,7 @@
 #include "color.h"
 
 static const char git_config_set_usage[] =
-"git-config [ --global | --system | [ -f | --file ] config-file ] [ --bool | --int ] [ -z | --null ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list | --get-color var [default] | --get-colorbool name [stdout-is-tty]";
+"git-config [ --global | --system | [ -f | --file ] config-file ] [ --bool | --int | --bool-or-int ] [ -z | --null ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list | --get-color var [default] | --get-colorbool name [stdout-is-tty]";
 
 static char *key;
 static regex_t *key_regexp;
@@ -16,7 +16,7 @@ static int seen;
 static char delim = '=';
 static char key_delim = ' ';
 static char term = '\n';
-static enum { T_RAW, T_INT, T_BOOL } type = T_RAW;
+static enum { T_RAW, T_INT, T_BOOL, T_BOOL_OR_INT } type = T_RAW;
 
 static int show_all_config(const char *key_, const char *value_)
 {
@@ -53,6 +53,14 @@ static int show_config(const char* key_, const char* value_)
                sprintf(value, "%d", git_config_int(key_, value_?value_:""));
        else if (type == T_BOOL)
                vptr = git_config_bool(key_, value_) ? "true" : "false";
+       else if (type == T_BOOL_OR_INT) {
+               int is_bool, v;
+               v = git_config_bool_or_int(key_, value_, &is_bool);
+               if (is_bool)
+                       vptr = v ? "true" : "false";
+               else
+                       sprintf(value, "%d", v);
+       }
        else
                vptr = value_?value_:"";
        seen++;
@@ -157,6 +165,14 @@ char *normalize_value(const char *key, const char *value)
                else if (type == T_BOOL)
                        sprintf(normalized, "%s",
                                git_config_bool(key, value) ? "true" : "false");
+               else if (type == T_BOOL_OR_INT) {
+                       int is_bool, v;
+                       v = git_config_bool_or_int(key, value, &is_bool);
+                       if (!is_bool)
+                               sprintf(normalized, "%d", v);
+                       else
+                               sprintf(normalized, "%s", v ? "true" : "false");
+               }
        }
 
        return normalized;
@@ -224,6 +240,10 @@ static int git_get_colorbool_config(const char *var, const char *value)
                get_diff_color_found =
                        git_config_colorbool(var, value, stdout_is_tty);
        }
+       if (!strcmp(var, "color.ui")) {
+               git_use_color_default = git_config_colorbool(var, value, stdout_is_tty);
+               return 0;
+       }
        return 0;
 }
 
@@ -251,7 +271,7 @@ static int get_colorbool(int argc, const char **argv)
                if (!strcmp(get_color_slot, "color.diff"))
                        get_colorbool_found = get_diff_color_found;
                if (get_colorbool_found < 0)
-                       get_colorbool_found = 0;
+                       get_colorbool_found = git_use_color_default;
        }
 
        if (argc == 1) {
@@ -273,6 +293,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
                        type = T_INT;
                else if (!strcmp(argv[1], "--bool"))
                        type = T_BOOL;
+               else if (!strcmp(argv[1], "--bool-or-int"))
+                       type = T_BOOL_OR_INT;
                else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l")) {
                        if (argc != 2)
                                usage(git_config_set_usage);
index 65350ca52240bad95c1632ae604d66279d9a8997..c97a42739d23ac7ed90ae207e5a3770c388e66a7 100644 (file)
@@ -117,15 +117,15 @@ static const unsigned char* get_rev(void)
 
        while (commit == NULL) {
                unsigned int mark;
-               struct commit_list *parents = NULL;
+               struct commit_list *parents;
 
                if (rev_list == NULL || non_common_revs == 0)
                        return NULL;
 
                commit = rev_list->item;
-               if (!(commit->object.parsed))
-                       if (!parse_commit(commit))
-                               parents = commit->parents;
+               if (!commit->object.parsed)
+                       parse_commit(commit);
+               parents = commit->parents;
 
                commit->object.flags |= POPPED;
                if (!(commit->object.flags & COMMON))
index 139a6b10c50d38fa3caf224e8031a152eac1a22e..167f948036170fd2ec5a8e3bd3ca20359d8c9ee5 100644 (file)
@@ -577,8 +577,6 @@ static int do_fetch(struct transport *transport,
                free_refs(ref_map);
        }
 
-       transport_disconnect(transport);
-
        return 0;
 }
 
@@ -599,6 +597,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
        int i;
        static const char **refs = NULL;
        int ref_nr = 0;
+       int exit_code;
 
        /* Record the command line for the reflog */
        strbuf_addstr(&default_rla, "fetch");
@@ -652,6 +651,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 
        signal(SIGINT, unlock_pack_on_signal);
        atexit(unlock_pack);
-       return do_fetch(transport,
+       exit_code = do_fetch(transport,
                        parse_fetch_refspec(ref_nr, refs), ref_nr);
+       transport_disconnect(transport);
+       transport = NULL;
+       return exit_code;
 }
index d49f5454e8d77a090fca28ce5f5b7db93f14287b..b72cb59e6a6aab33e7170826242d82785e4fa1e4 100644 (file)
@@ -206,6 +206,15 @@ static void shortlog(const char *name, unsigned char *sha1,
                        continue;
 
                bol = strstr(commit->buffer, "\n\n");
+               if (bol) {
+                       unsigned char c;
+                       do {
+                               c = *++bol;
+                       } while (isspace(c));
+                       if (!c)
+                               bol = NULL;
+               }
+
                if (!bol) {
                        append_to_list(&subjects, xstrdup(sha1_to_hex(
                                                        commit->object.sha1)),
@@ -213,7 +222,6 @@ static void shortlog(const char *name, unsigned char *sha1,
                        continue;
                }
 
-               bol += 2;
                eol = strchr(bol, '\n');
                if (eol) {
                        oneline = xmemdupz(bol, eol - bol);
index 8cef36f6a4445b163b299f282785f66af9662cb8..f99ebc7926b95b04f1140d257da7a52bfc33ee50 100644 (file)
@@ -157,6 +157,34 @@ static int too_many_packs(void)
        return gc_auto_pack_limit <= cnt;
 }
 
+static int run_hook(void)
+{
+       const char *argv[2];
+       struct child_process hook;
+       int ret;
+
+       argv[0] = git_path("hooks/pre-auto-gc");
+       argv[1] = NULL;
+
+       if (access(argv[0], X_OK) < 0)
+               return 0;
+
+       memset(&hook, 0, sizeof(hook));
+       hook.argv = argv;
+       hook.no_stdin = 1;
+       hook.stdout_to_stderr = 1;
+
+       ret = start_command(&hook);
+       if (ret) {
+               warning("Could not spawn %s", argv[0]);
+               return ret;
+       }
+       ret = finish_command(&hook);
+       if (ret == -ERR_RUN_COMMAND_WAITPID_SIGNAL)
+               warning("%s exited due to uncaught signal", argv[0]);
+       return ret;
+}
+
 static int need_to_gc(void)
 {
        /*
@@ -176,6 +204,9 @@ static int need_to_gc(void)
                append_option(argv_repack, "-A", MAX_ADD);
        else if (!too_many_loose_objects())
                return 0;
+
+       if (run_hook())
+               return 0;
        return 1;
 }
 
index 2854868b4e4185d33024b9fe5d00ad631c18bb36..a76f5d3474f9d1e16bfc988ad6fd1d971876fe91 100644 (file)
@@ -400,9 +400,16 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
                char buf[10];
                /* We do not spell "group" and such, so that
                 * the configuration can be read by older version
-                * of git.
+                * of git. Note, we use octal numbers for new share modes,
+                * and compatibility values for PERM_GROUP and
+                * PERM_EVERYBODY.
                 */
-               sprintf(buf, "%d", shared_repository);
+               if (shared_repository == PERM_GROUP)
+                       sprintf(buf, "%d", OLD_PERM_GROUP);
+               else if (shared_repository == PERM_EVERYBODY)
+                       sprintf(buf, "%d", OLD_PERM_EVERYBODY);
+               else
+                       sprintf(buf, "0%o", shared_repository);
                git_config_set("core.sharedrepository", buf);
                git_config_set("receive.denyNonFastforwards", "true");
        }
index 5c00725f030460ba34c702b9ad31e577ca70d361..1670d0b334efe7d01cbf0118f7b9dca874f8d473 100644 (file)
@@ -56,7 +56,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
        rev->abbrev = DEFAULT_ABBREV;
        rev->commit_format = CMIT_FMT_DEFAULT;
        if (fmt_pretty)
-               rev->commit_format = get_commit_format(fmt_pretty);
+               get_commit_format(fmt_pretty, rev);
        rev->verbose_header = 1;
        DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
        rev->show_root_diff = default_show_root;
@@ -400,6 +400,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
         * allow us to set a different default.
         */
        rev.commit_format = CMIT_FMT_ONELINE;
+       rev.use_terminator = 1;
        rev.always_show_header = 1;
 
        /*
index d77f10a0eaa64466b919bcede37ad8c67b70b3fc..93bb84e1d4c762c6c049276202ebc2320447e9c8 100644 (file)
@@ -19,6 +19,8 @@ static const char * const builtin_remote_usage[] = {
 
 static int verbose;
 
+static int show_all(void);
+
 static inline int postfixcmp(const char *string, const char *postfix)
 {
        int len1 = strlen(string), len2 = strlen(postfix);
@@ -88,19 +90,24 @@ static int add(int argc, const char **argv)
        strbuf_init(&buf, 0);
        strbuf_init(&buf2, 0);
 
+       strbuf_addf(&buf2, "refs/heads/test:refs/remotes/%s/test", name);
+       if (!valid_fetch_refspec(buf2.buf))
+               die("'%s' is not a valid remote name", name);
+
        strbuf_addf(&buf, "remote.%s.url", name);
        if (git_config_set(buf.buf, url))
                return 1;
 
+       strbuf_reset(&buf);
+       strbuf_addf(&buf, "remote.%s.fetch", name);
+
        if (track.nr == 0)
                path_list_append("*", &track);
        for (i = 0; i < track.nr; i++) {
                struct path_list_item *item = track.items + i;
 
-               strbuf_reset(&buf);
-               strbuf_addf(&buf, "remote.%s.fetch", name);
-
                strbuf_reset(&buf2);
+               strbuf_addch(&buf2, '+');
                if (mirror)
                        strbuf_addf(&buf2, "refs/%s:refs/%s",
                                        item->path, item->path);
@@ -380,8 +387,11 @@ static int show_or_prune(int argc, const char **argv, int prune)
 
        argc = parse_options(argc, argv, options, builtin_remote_usage, 0);
 
-       if (argc < 1)
+       if (argc < 1) {
+               if (!prune)
+                       return show_all();
                usage_with_options(builtin_remote_usage, options);
+       }
 
        memset(&states, 0, sizeof(states));
        for (; argc; argc--, argv++) {
index 0351d54435b566d5030f3a83df57fb140fffc143..0e597073239c97160582fbb7047794796f67987f 100644 (file)
@@ -365,9 +365,17 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
        return 0;
 }
 
+static void die_no_single_rev(int quiet)
+{
+       if (quiet)
+               exit(1);
+       else
+               die("Needed a single revision");
+}
+
 int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 {
-       int i, as_is = 0, verify = 0;
+       int i, as_is = 0, verify = 0, quiet = 0;
        unsigned char sha1[20];
 
        if (argc > 1 && !strcmp("--parseopt", argv[1]))
@@ -432,6 +440,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                verify = 1;
                                continue;
                        }
+                       if (!strcmp(arg, "--quiet") || !strcmp(arg, "-q")) {
+                               quiet = 1;
+                               continue;
+                       }
                        if (!strcmp(arg, "--short") ||
                            !prefixcmp(arg, "--short=")) {
                                filter &= ~(DO_FLAGS|DO_NOREV);
@@ -549,7 +561,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                continue;
                        }
                        if (show_flag(arg) && verify)
-                               die("Needed a single revision");
+                               die_no_single_rev(quiet);
                        continue;
                }
 
@@ -564,15 +576,15 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                        show_rev(REVERSED, sha1, arg+1);
                        continue;
                }
+               if (verify)
+                       die_no_single_rev(quiet);
                as_is = 1;
                if (!show_file(arg))
                        continue;
-               if (verify)
-                       die("Needed a single revision");
                verify_filename(prefix, arg);
        }
        show_default();
        if (verify && revs_count != 1)
-               die("Needed a single revision");
+               die_no_single_rev(quiet);
        return 0;
 }
index 39da54d1e56b5905655eafed1aff0f51c2540a8e..73cb3407077275f82677839d2c9e794c12833c95 100644 (file)
@@ -341,8 +341,11 @@ static int update_one(struct cache_tree *it,
 
        if (dryrun)
                hash_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1);
-       else
-               write_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1);
+       else if (write_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1)) {
+               strbuf_release(&buffer);
+               return -1;
+       }
+
        strbuf_release(&buffer);
        it->entry_count = i;
 #if DEBUG
diff --git a/cache.h b/cache.h
index 50b28fad0126d14d012769d5e8b95eb9ab6853d3..5a28dddec931f983a4aeff2ee7129444d07e07aa 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -474,10 +474,20 @@ static inline void hashclr(unsigned char *hash)
 
 int git_mkstemp(char *path, size_t n, const char *template);
 
+/*
+ * NOTE NOTE NOTE!!
+ *
+ * PERM_UMASK, OLD_PERM_GROUP and OLD_PERM_EVERYBODY enumerations must
+ * not be changed. Old repositories have core.sharedrepository written in
+ * numeric format, and therefore these values are preserved for compatibility
+ * reasons.
+ */
 enum sharedrepo {
-       PERM_UMASK = 0,
-       PERM_GROUP,
-       PERM_EVERYBODY
+       PERM_UMASK          = 0,
+       OLD_PERM_GROUP      = 1,
+       OLD_PERM_EVERYBODY  = 2,
+       PERM_GROUP          = 0660,
+       PERM_EVERYBODY      = 0664,
 };
 int git_config_perm(const char *var, const char *value);
 int adjust_shared_perm(const char *path);
@@ -716,8 +726,8 @@ extern const char *git_log_output_encoding;
 extern void maybe_flush_or_die(FILE *, const char *);
 extern int copy_fd(int ifd, int ofd);
 extern int copy_file(const char *dst, const char *src, int mode);
-extern int read_in_full(int fd, void *buf, size_t count);
-extern int write_in_full(int fd, const void *buf, size_t count);
+extern ssize_t read_in_full(int fd, void *buf, size_t count);
+extern ssize_t write_in_full(int fd, const void *buf, size_t count);
 extern void write_or_die(int fd, const void *buf, size_t count);
 extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg);
 extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg);
index 0e19cbaacc1099fd69f7f2d9b4a17c94a327baa9..f1e7a4d5d98f8705b6a1a7a420dccc9ecad69d63 100644 (file)
@@ -718,9 +718,9 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
                        result = xmalloc(len + 1);
                        while (sz < len) {
                                ssize_t done = xread(fd, result+sz, len-sz);
-                               if (done == 0)
-                                       break;
-                               if (done < 0)
+                               if (done == 0 && sz != len)
+                                       die("early EOF '%s'", elem->path);
+                               else if (done < 0)
                                        die("read error '%s'", elem->path);
                                sz += done;
                        }
index 2f63bc8b2fac0d748e13d4435d550d61002092b3..2d94d4148ed4048469ba79cae4f6ff2a2e3f9bca 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -63,7 +63,8 @@ enum cmit_fmt {
 };
 
 extern int non_ascii(int);
-extern enum cmit_fmt get_commit_format(const char *arg);
+struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
+extern void get_commit_format(const char *arg, struct rev_info *);
 extern void format_commit_message(const struct commit *commit,
                                   const void *format, struct strbuf *sb);
 extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*,
index 5ea18efaec4a03bc7701be61af42d014adbb670e..b0ada515b9d839fc8691bc9af320353ff323b251 100644 (file)
--- a/config.c
+++ b/config.c
@@ -315,13 +315,13 @@ int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
        if (!strcasecmp(value, "false") || !strcasecmp(value, "no"))
                return 0;
        *is_bool = 0;
-       return git_config_int(name, value) != 0;
+       return git_config_int(name, value);
 }
 
 int git_config_bool(const char *name, const char *value)
 {
        int discard;
-       return git_config_bool_or_int(name, value, &discard);
+       return !!git_config_bool_or_int(name, value, &discard);
 }
 
 int git_config_string(const char **dest, const char *var, const char *value)
index 8091d2deb7d01f79b15d31812dd733aca479f03b..16984632d984006e2f2867a26714086bf3045ca3 100755 (executable)
@@ -152,7 +152,7 @@ __git_heads ()
                done
                return
        fi
-       for i in $(git-ls-remote "$1" 2>/dev/null); do
+       for i in $(git ls-remote "$1" 2>/dev/null); do
                case "$is_hash,$i" in
                y,*) is_hash=n ;;
                n,*^{}) is_hash=y ;;
@@ -173,7 +173,7 @@ __git_tags ()
                done
                return
        fi
-       for i in $(git-ls-remote "$1" 2>/dev/null); do
+       for i in $(git ls-remote "$1" 2>/dev/null); do
                case "$is_hash,$i" in
                y,*) is_hash=n ;;
                n,*^{}) is_hash=y ;;
@@ -200,7 +200,7 @@ __git_refs ()
                done
                return
        fi
-       for i in $(git-ls-remote "$dir" 2>/dev/null); do
+       for i in $(git ls-remote "$dir" 2>/dev/null); do
                case "$is_hash,$i" in
                y,*) is_hash=n ;;
                n,*^{}) is_hash=y ;;
@@ -223,7 +223,7 @@ __git_refs2 ()
 __git_refs_remotes ()
 {
        local cmd i is_hash=y
-       for i in $(git-ls-remote "$1" 2>/dev/null); do
+       for i in $(git ls-remote "$1" 2>/dev/null); do
                case "$is_hash,$i" in
                n,refs/heads/*)
                        is_hash=y
@@ -641,6 +641,7 @@ _git_diff ()
                        --ignore-all-space --exit-code --quiet --ext-diff
                        --no-ext-diff
                        --no-prefix --src-prefix= --dst-prefix=
+                       --base --ours --theirs
                        "
                return
                ;;
@@ -1052,6 +1053,7 @@ _git_remote ()
        local subcommands="add rm show prune update"
        local subcommand="$(__git_find_subcommand "$subcommands")"
        if [ -z "$subcommand" ]; then
+               __gitcomp "$subcommands"
                return
        fi
 
@@ -1344,9 +1346,14 @@ _git ()
 _gitk ()
 {
        local cur="${COMP_WORDS[COMP_CWORD]}"
+       local g="$(git rev-parse --git-dir 2>/dev/null)"
+       local merge=""
+       if [ -f $g/MERGE_HEAD ]; then
+               merge="--merge"
+       fi
        case "$cur" in
        --*)
-               __gitcomp "--not --all"
+               __gitcomp "--not --all $merge"
                return
                ;;
        esac
index 4fa853fae76dc2ac132e489f5f1b630b3fc0f1de..2557a7667f1d3a272698b213e8cf9cfbafddaea2 100644 (file)
@@ -232,10 +232,8 @@ and returns the process output as a string, or nil if the git failed."
 
 (defun git-run-command-region (buffer start end env &rest args)
   "Run a git command with specified buffer region as input."
-  (unless (eq 0 (if env
-                    (git-run-process-region
-                     buffer start end "env"
-                     (append (git-get-env-strings env) (list "git") args))
+  (unless (eq 0 (let ((process-environment (append (git-get-env-strings env)
+                                                   process-environment)))
                   (git-run-process-region
                    buffer start end "git" args)))
     (error "Failed to run \"git %s\":\n%s" (mapconcat (lambda (x) x) args " ") (buffer-string))))
@@ -250,9 +248,8 @@ and returns the process output as a string, or nil if the git failed."
             (erase-buffer)
             (cd dir)
             (setq status
-                  (if env
-                      (apply #'call-process "env" nil (list buffer t) nil
-                             (append (git-get-env-strings env) (list hook-name) args))
+                  (let ((process-environment (append (git-get-env-strings env)
+                                                     process-environment)))
                     (apply #'call-process hook-name nil (list buffer t) nil args))))
           (display-message-or-buffer buffer)
           (eq 0 status)))))
index 62a740c48248d94e1e0577c8676b13b7a726f21c..41368950d6b29121089ee9239b8e07ece209a31e 100644 (file)
@@ -202,11 +202,12 @@ generate_email_header()
 
 generate_email_footer()
 {
+       SPACE=" "
        cat <<-EOF
 
 
        hooks/post-receive
-       --
+       --${SPACE}
        $projectdesc
        EOF
 }
diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery
new file mode 100644 (file)
index 0000000..0096f57
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# An example hook script to verify if you are on battery, in case you
+# are running Linux. Called by git-gc --auto with no arguments. The hook
+# should exit with non-zero status after issuing an appropriate message
+# if it wants to stop the auto repacking.
+#
+# This hook is stored in the contrib/hooks directory. Your distribution
+# may have put this somewhere else. If you want to use this hook, you
+# should make this script executable then link to it in the repository
+# you would like to use it in.
+#
+# For example, if the hook is stored in
+# /usr/share/git-core/contrib/hooks/pre-auto-gc-battery:
+#
+# chmod a+x pre-auto-gc-battery
+# cd /path/to/your/repository.git
+# ln -sf /usr/share/git-core/contrib/hooks/pre-auto-gc-battery \
+#      hooks/pre-auto-gc
+
+if test -x /sbin/on_ac_power && /sbin/on_ac_power
+then
+       exit 0
+elif test "$(cat /sys/class/power_supply/AC/online 2>/dev/null)" = 1
+then
+       exit 0
+elif grep -q 'on-line' /proc/acpi/ac_adapter/AC/state 2>/dev/null
+then
+       exit 0
+elif grep -q '0x01$' /proc/apm 2>/dev/null
+then
+       exit 0
+fi
+
+echo "Auto packing deferred; not on AC"
+exit 1
diff --git a/copy.c b/copy.c
index afc4fbf41405d42d2751ea35ec7a9a32f8df6274..e54d15aced7595ccb11423b0de121db9051ad1f3 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -9,8 +9,7 @@ int copy_fd(int ifd, int ofd)
                if (!len)
                        break;
                if (len < 0) {
-                       int read_error;
-                       read_error = errno;
+                       int read_error = errno;
                        close(ifd);
                        return error("copy-fd: read returned %s",
                                     strerror(read_error));
@@ -25,9 +24,10 @@ int copy_fd(int ifd, int ofd)
                                close(ifd);
                                return error("copy-fd: write returned 0");
                        } else {
+                               int write_error = errno;
                                close(ifd);
                                return error("copy-fd: write returned %s",
-                                            strerror(errno));
+                                            strerror(write_error));
                        }
                }
        }
@@ -48,7 +48,7 @@ int copy_file(const char *dst, const char *src, int mode)
        }
        status = copy_fd(fdi, fdo);
        if (close(fdo) != 0)
-               return error("%s: write error: %s", dst, strerror(errno));
+               return error("%s: close error: %s", dst, strerror(errno));
 
        if (!status && adjust_shared_perm(dst))
                return -1;
index 069e4507ae7caa70f79d5369bc61dfefd0f174e2..cfd629da48526f5949124b5d9baeb52dfadd5f64 100644 (file)
@@ -264,6 +264,9 @@ int setup_diff_no_index(struct rev_info *revs,
                        DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
                        break;
                }
+       if (nongit && argc != i + 2)
+               die("git diff [--no-index] takes two paths");
+
        if (argc != i + 2 || (!is_outside_repo(argv[i + 1], nongit, prefix) &&
                                !is_outside_repo(argv[i], nongit, prefix)))
                return -1;
diff --git a/diff.c b/diff.c
index 8022e678d1fc26eab75d73d01110d635fba11fd7..3632b552b2eae5bda3cdec3323f3a68907c6f09a 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -991,18 +991,23 @@ static void show_numstat(struct diffstat_t* data, struct diff_options *options)
        }
 }
 
-struct diffstat_dir {
-       struct diffstat_file **files;
-       int nr, percent, cumulative;
+struct dirstat_file {
+       const char *name;
+       unsigned long changed;
 };
 
-static long gather_dirstat(FILE *file, struct diffstat_dir *dir, unsigned long changed, const char *base, int baselen)
+struct dirstat_dir {
+       struct dirstat_file *files;
+       int alloc, nr, percent, cumulative;
+};
+
+static long gather_dirstat(FILE *file, struct dirstat_dir *dir, unsigned long changed, const char *base, int baselen)
 {
        unsigned long this_dir = 0;
        unsigned int sources = 0;
 
        while (dir->nr) {
-               struct diffstat_file *f = *dir->files;
+               struct dirstat_file *f = dir->files;
                int namelen = strlen(f->name);
                unsigned long this;
                char *slash;
@@ -1017,10 +1022,7 @@ static long gather_dirstat(FILE *file, struct diffstat_dir *dir, unsigned long c
                        this = gather_dirstat(file, dir, changed, f->name, newbaselen);
                        sources++;
                } else {
-                       if (f->is_unmerged || f->is_binary)
-                               this = 0;
-                       else
-                               this = f->added + f->deleted;
+                       this = f->changed;
                        dir->files++;
                        dir->nr--;
                        sources += 2;
@@ -1048,19 +1050,58 @@ static long gather_dirstat(FILE *file, struct diffstat_dir *dir, unsigned long c
        return this_dir;
 }
 
-static void show_dirstat(struct diffstat_t *data, struct diff_options *options)
+static void show_dirstat(struct diff_options *options)
 {
        int i;
        unsigned long changed;
-       struct diffstat_dir dir;
+       struct dirstat_dir dir;
+       struct diff_queue_struct *q = &diff_queued_diff;
+
+       dir.files = NULL;
+       dir.alloc = 0;
+       dir.nr = 0;
+       dir.percent = options->dirstat_percent;
+       dir.cumulative = options->output_format & DIFF_FORMAT_CUMULATIVE;
 
-       /* Calculate total changes */
        changed = 0;
-       for (i = 0; i < data->nr; i++) {
-               if (data->files[i]->is_binary || data->files[i]->is_unmerged)
+       for (i = 0; i < q->nr; i++) {
+               struct diff_filepair *p = q->queue[i];
+               const char *name;
+               unsigned long copied, added, damage;
+
+               name = p->one->path ? p->one->path : p->two->path;
+
+               if (DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two)) {
+                       diff_populate_filespec(p->one, 0);
+                       diff_populate_filespec(p->two, 0);
+                       diffcore_count_changes(p->one, p->two, NULL, NULL, 0,
+                                              &copied, &added);
+                       diff_free_filespec_data(p->one);
+                       diff_free_filespec_data(p->two);
+               } else if (DIFF_FILE_VALID(p->one)) {
+                       diff_populate_filespec(p->one, 1);
+                       copied = added = 0;
+                       diff_free_filespec_data(p->one);
+               } else if (DIFF_FILE_VALID(p->two)) {
+                       diff_populate_filespec(p->two, 1);
+                       copied = 0;
+                       added = p->two->size;
+                       diff_free_filespec_data(p->two);
+               } else
                        continue;
-               changed += data->files[i]->added;
-               changed += data->files[i]->deleted;
+
+               /*
+                * Original minus copied is the removed material,
+                * added is the new material.  They are both damages
+                * made to the preimage.
+                */
+               damage = (p->one->size - copied) + added;
+
+               ALLOC_GROW(dir.files, dir.nr + 1, dir.alloc);
+               dir.files[dir.nr].name = name;
+               dir.files[dir.nr].changed = damage;
+               changed += damage;
+               dir.nr++;
        }
 
        /* This can happen even with many files, if everything was renames */
@@ -1068,10 +1109,6 @@ static void show_dirstat(struct diffstat_t *data, struct diff_options *options)
                return;
 
        /* Show all directories with more than x% of the changes */
-       dir.files = data->files;
-       dir.nr = data->nr;
-       dir.percent = options->dirstat_percent;
-       dir.cumulative = options->output_format & DIFF_FORMAT_CUMULATIVE;
        gather_dirstat(options->file, &dir, changed, "", 0);
 }
 
@@ -3095,7 +3132,7 @@ void diff_flush(struct diff_options *options)
                separator++;
        }
 
-       if (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIRSTAT)) {
+       if (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT)) {
                struct diffstat_t diffstat;
 
                memset(&diffstat, 0, sizeof(struct diffstat_t));
@@ -3105,8 +3142,6 @@ void diff_flush(struct diff_options *options)
                        if (check_pair_status(p))
                                diff_flush_stat(p, options, &diffstat);
                }
-               if (output_format & DIFF_FORMAT_DIRSTAT)
-                       show_dirstat(&diffstat, options);
                if (output_format & DIFF_FORMAT_NUMSTAT)
                        show_numstat(&diffstat, options);
                if (output_format & DIFF_FORMAT_DIFFSTAT)
@@ -3116,6 +3151,8 @@ void diff_flush(struct diff_options *options)
                free_diffstat_info(&diffstat);
                separator++;
        }
+       if (output_format & DIFF_FORMAT_DIRSTAT)
+               show_dirstat(options);
 
        if (output_format & DIFF_FORMAT_SUMMARY && !is_summary_empty(q)) {
                for (i = 0; i < q->nr; i++)
diff --git a/dir.c b/dir.c
index edc458e020772a7ab704e9cf69786d3aa641bcd4..d79762c7c0bc9e762ed8dc5f00fb2fd3ce01ad57 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -80,7 +80,7 @@ static int match_one(const char *match, const char *name, int namelen)
        if (strncmp(match, name, matchlen))
                return !fnmatch(match, name, 0) ? MATCHED_FNMATCH : 0;
 
-       if (!name[matchlen])
+       if (namelen == matchlen)
                return MATCHED_EXACTLY;
        if (match[matchlen-1] == '/' || name[matchlen] == '/')
                return MATCHED_RECURSIVELY;
index ac5c388060789e559f80d61d6eae1db926b66ad4..75886a8f2fb0c2244ba921398ae2339dc9ffea26 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -107,7 +107,7 @@ It does not apply to blobs recorded in its index."
     # patch did not touch, so recursive ends up canceling them,
     # saying that we reverted all those changes.
 
-    eval GITHEAD_$his_tree='"$SUBJECT"'
+    eval GITHEAD_$his_tree='"$FIRSTLINE"'
     export GITHEAD_$his_tree
     git-merge-recursive $orig_tree -- HEAD $his_tree || {
            git rerere
@@ -117,10 +117,6 @@ It does not apply to blobs recorded in its index."
     unset GITHEAD_$his_tree
 }
 
-reread_subject () {
-       git stripspace <"$1" | sed -e 1q
-}
-
 prec=4
 dotest=".dotest"
 sign= utf8=t keep= skip= interactive= resolved= binary= rebasing=
@@ -331,7 +327,20 @@ do
                        echo "Patch is empty.  Was it split wrong?"
                        stop_here $this
                }
-               git stripspace < "$dotest/msg" > "$dotest/msg-clean"
+               if test -f "$dotest/rebasing" &&
+                       commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
+                               -e q "$dotest/$msgnum") &&
+                       test "$(git cat-file -t "$commit")" = commit
+               then
+                       git cat-file commit "$commit" |
+                       sed -e '1,/^$/d' >"$dotest/msg-clean"
+               else
+                       SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
+                       case "$keep_subject" in -k)  SUBJECT="[PATCH] $SUBJECT" ;; esac
+
+                       (printf '%s\n\n' "$SUBJECT"; cat "$dotest/msg") |
+                               git stripspace > "$dotest/msg-clean"
+               fi
                ;;
        esac
 
@@ -347,9 +356,6 @@ do
 
        export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE
 
-       SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
-       case "$keep_subject" in -k)  SUBJECT="[PATCH] $SUBJECT" ;; esac
-
        case "$resume" in
        '')
            if test '' != "$SIGNOFF"
@@ -368,10 +374,8 @@ do
                ADD_SIGNOFF=
            fi
            {
-               printf '%s\n' "$SUBJECT"
                if test -s "$dotest/msg-clean"
                then
-                       echo
                        cat "$dotest/msg-clean"
                fi
                if test '' != "$ADD_SIGNOFF"
@@ -408,7 +412,6 @@ do
                [aA]*) action=yes interactive= ;;
                [nN]*) action=skip ;;
                [eE]*) git_editor "$dotest/final-commit"
-                      SUBJECT=$(reread_subject "$dotest/final-commit")
                       action=again ;;
                [vV]*) action=again
                       LESS=-S ${PAGER:-less} "$dotest/patch" ;;
@@ -418,6 +421,7 @@ do
        else
            action=yes
        fi
+       FIRSTLINE=$(head -1 "$dotest/final-commit")
 
        if test $action = skip
        then
@@ -431,7 +435,7 @@ do
                stop_here $this
        fi
 
-       printf 'Applying %s\n' "$SUBJECT"
+       printf 'Applying %s\n' "$FIRSTLINE"
 
        case "$resolved" in
        '')
@@ -489,7 +493,7 @@ do
        tree=$(git write-tree) &&
        parent=$(git rev-parse --verify HEAD) &&
        commit=$(git commit-tree $tree -p $parent <"$dotest/final-commit") &&
-       git update-ref -m "$GIT_REFLOG_ACTION: $SUBJECT" HEAD $commit $parent ||
+       git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
        stop_here $this
 
        if test -x "$GIT_DIR"/hooks/post-applypatch
index 408775a51e2ad7b3007ea8a0001516c26166318a..d8d9bfde4cdd4b558992c68cb7cdaaa1b8a1212d 100755 (executable)
@@ -66,9 +66,10 @@ bisect_start() {
        # Verify HEAD. If we were bisecting before this, reset to the
        # top-of-line master first!
        #
-       head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) ||
+       head=$(GIT_DIR="$GIT_DIR" git symbolic-ref -q HEAD) ||
        head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
        die "Bad HEAD - I need a HEAD"
+       start_head=''
        case "$head" in
        refs/heads/bisect)
                if [ -s "$GIT_DIR/BISECT_START" ]; then
@@ -82,7 +83,7 @@ bisect_start() {
                # This error message should only be triggered by cogito usage,
                # and cogito users should understand it relates to cg-seek.
                [ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree"
-               echo "${head#refs/heads/}" >"$GIT_DIR/BISECT_START"
+               start_head="${head#refs/heads/}"
                ;;
        *)
                die "Bad HEAD - strange symbolic ref"
@@ -103,6 +104,7 @@ bisect_start() {
        done
        orig_args=$(sq "$@")
        bad_seen=0
+       eval=''
        while [ $# -gt 0 ]; do
            arg="$1"
            case "$arg" in
@@ -120,13 +122,15 @@ bisect_start() {
                0) state='bad' ; bad_seen=1 ;;
                *) state='good' ;;
                esac
-               bisect_write "$state" "$rev" 'nolog'
+               eval="$eval bisect_write '$state' '$rev' 'nolog'; "
                shift
                ;;
            esac
        done
 
        sq "$@" >"$GIT_DIR/BISECT_NAMES"
+       test -n "$start_head" && echo "$start_head" >"$GIT_DIR/BISECT_START"
+       eval "$eval"
        echo "git-bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG"
        bisect_auto_next
 }
@@ -157,12 +161,14 @@ bisect_state() {
                bisect_write "$state" "$rev" ;;
        2,bad|*,good|*,skip)
                shift
+               eval=''
                for rev in "$@"
                do
                        sha=$(git rev-parse --verify "$rev^{commit}") ||
                                die "Bad rev input: $rev"
-                       bisect_write "$state" "$sha"
-               done ;;
+                       eval="$eval bisect_write '$state' '$sha'; "
+               done
+               eval "$eval" ;;
        *,bad)
                die "'git bisect bad' can take only one argument." ;;
        *)
index 2636159aaa7a6278d9b8fc64b853b319ac8da123..8c7fc7f6317113fcef923dcc625fb94e13fb77a0 100755 (executable)
@@ -219,6 +219,7 @@ fi
 if test -n "$2"
 then
        dir="$2"
+       test $# = 2 || die "excess parameter to git-clone"
 else
        # Derive one from the repository name
        # Try using "humanish" part of source repo if user didn't specify one
index a18235e6d053322a85805d1b07b631c6739deb93..167c3fe63a4fd9ca4abf5c16694e22a9ae22717b 100644 (file)
@@ -268,6 +268,12 @@ static inline void *xmalloc(size_t size)
        return ret;
 }
 
+/*
+ * xmemdupz() allocates (len + 1) bytes of memory, duplicates "len" bytes of
+ * "data" to the allocated memory, zero terminates the allocated memory,
+ * and returns a pointer to the allocated memory. If the allocation fails,
+ * the program dies.
+ */
 static inline void *xmemdupz(const void *data, size_t len)
 {
        char *p = xmalloc(len + 1);
@@ -329,6 +335,11 @@ static inline void *xmmap(void *start, size_t length,
        return ret;
 }
 
+/*
+ * xread() is the same a read(), but it automatically restarts read()
+ * operations with a recoverable error (EAGAIN and EINTR). xread()
+ * DOES NOT GUARANTEE that "len" bytes is read even if the data is available.
+ */
 static inline ssize_t xread(int fd, void *buf, size_t len)
 {
        ssize_t nr;
@@ -340,6 +351,11 @@ static inline ssize_t xread(int fd, void *buf, size_t len)
        }
 }
 
+/*
+ * xwrite() is the same a write(), but it automatically restarts write()
+ * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT
+ * GUARANTEE that "len" bytes is written even if the operation is successful.
+ */
 static inline ssize_t xwrite(int fd, const void *buf, size_t len)
 {
        ssize_t nr;
index 95c5eec51ecc6ab6f142cef51eb4bd3b5842debb..bdac5d51b6dfb721bb648e455cb8f3c5078217e4 100755 (executable)
@@ -772,7 +772,7 @@ sub commit {
        waitpid($pid,0);
        die "Error running git-commit-tree: $?\n" if $?;
 
-       system("git-update-ref $remote/$branch $cid") == 0
+       system('git-update-ref', "$remote/$branch", $cid) == 0
                or die "Cannot write branch $branch for update: $!\n";
 
        if ($tag) {
index 7674346c8d9525b0d8928f48354bdbe0af8b8e23..ce0f00c8a4f6d5f9a2c1c3ebdbadff52106b60d0 100755 (executable)
@@ -327,7 +327,8 @@ set_name_rev () {
                cd "$1" && {
                        git describe "$2" 2>/dev/null ||
                        git describe --tags "$2" 2>/dev/null ||
-                       git describe --contains --tags --always "$2"
+                       git describe --contains "$2" 2>/dev/null ||
+                       git describe --all --always "$2"
                }
        ) )
        test -z "$revname" || revname=" ($revname)"
@@ -342,6 +343,7 @@ set_name_rev () {
 #
 cmd_summary() {
        summary_limit=-1
+       for_status=
 
        # parse $args after "submodule ... summary".
        while test $# -ne 0
@@ -350,6 +352,9 @@ cmd_summary() {
                --cached)
                        cached="$1"
                        ;;
+               --for-status)
+                       for_status="$1"
+                       ;;
                -n|--summary-limit)
                        if summary_limit=$(($2 + 0)) 2>/dev/null && test "$summary_limit" = "$2"
                        then
@@ -397,7 +402,8 @@ cmd_summary() {
                done
        )
 
-       test -n "$modules" &&
+       test -z "$modules" && return
+
        git diff-index $cached --raw $head -- $modules |
        grep -e '^:160000' -e '^:[0-7]* 160000' |
        cut -c2- |
@@ -499,7 +505,14 @@ cmd_summary() {
                        echo
                fi
                echo
-       done
+       done |
+       if test -n "$for_status"; then
+               echo "# Modified submodules:"
+               echo "#"
+               sed -e 's|^|# |' -e 's|^# $|#|'
+       else
+               cat
+       fi
 }
 #
 # List all submodules, prefixed with:
index b864b54a4440537900cab47e71ee93bd01d72d28..711e7b7eb9274c9de292d6f36fca9a9f0baf6318 100755 (executable)
@@ -410,10 +410,12 @@ sub cmd_dcommit {
        $head ||= 'HEAD';
        my @refs;
        my ($url, $rev, $uuid, $gs) = working_head_info($head, \@refs);
-       print "Committing to $url ...\n";
+       if ($url) {
+               print "Committing to $url ...\n";
+       }
        unless ($gs) {
                die "Unable to determine upstream SVN information from ",
-                   "$head history\n";
+                   "$head history.\nPerhaps the repository is empty.";
        }
        my $last_rev;
        my ($linear_refs, $parents) = linearize_history($gs, \@refs);
@@ -2375,8 +2377,7 @@ sub check_author {
        my ($author) = @_;
        if (!defined $author || length $author == 0) {
                $author = '(no author)';
-       }
-       if (defined $::_authors && ! defined $::users{$author}) {
+       } elsif (defined $::_authors && ! defined $::users{$author}) {
                die "Author: $author not defined in $::_authors file\n";
        }
        $author;
@@ -2519,6 +2520,7 @@ sub rebuild_from_rev_db {
        my ($self, $path) = @_;
        my $r = -1;
        open my $fh, '<', $path or croak "open: $!";
+       binmode $fh or croak "binmode: $!";
        while (<$fh>) {
                length($_) == 41 or croak "inconsistent size in ($_) != 41";
                chomp($_);
@@ -2616,6 +2618,7 @@ sub rebuild {
 sub _rev_map_set {
        my ($fh, $rev, $commit) = @_;
 
+       binmode $fh or croak "binmode: $!";
        my $size = (stat($fh))[7];
        ($size % 24) == 0 or croak "inconsistent size: $size";
 
@@ -2719,6 +2722,7 @@ sub rev_map_max {
        my $map_path = $self->map_path;
        stat $map_path or return $want_commit ? (0, undef) : 0;
        sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
+       binmode $fh or croak "binmode: $!";
        my $size = (stat($fh))[7];
        ($size % 24) == 0 or croak "inconsistent size: $size";
 
@@ -2751,6 +2755,7 @@ sub rev_map_get {
        return undef unless -e $map_path;
 
        sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
+       binmode $fh or croak "binmode: $!";
        my $size = (stat($fh))[7];
        ($size % 24) == 0 or croak "inconsistent size: $size";
 
diff --git a/git.c b/git.c
index c4e4644b30e184e6496fb5a4877f3141488f8f44..89b431fa28162adbd0f64d7a036a71b5bfce9eee 100644 (file)
--- a/git.c
+++ b/git.c
@@ -347,7 +347,7 @@ static void handle_internal_command(int argc, const char **argv)
                { "shortlog", cmd_shortlog, USE_PAGER },
                { "show-branch", cmd_show_branch, RUN_SETUP },
                { "show", cmd_show, RUN_SETUP | USE_PAGER },
-               { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
+               { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE | USE_PAGER },
                { "stripspace", cmd_stripspace },
                { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
                { "tag", cmd_tag, RUN_SETUP },
index 743f2d4442b48af3627c1117aaaf73c89da306be..f7194dbef79f3b03cc3524469c4b504a195807b6 100644 (file)
@@ -29,40 +29,40 @@ Build time configuration
 See also "How to configure gitweb for your local system" in README
 file for gitweb (in gitweb/README).
 
-- There are many configuration variables which affects building of
+- There are many configuration variables which affect building of
   gitweb.cgi; see "default configuration for gitweb" section in main
   (top dir) Makefile, and instructions for building gitweb/gitweb.cgi
   target.
 
-  One of most important is where to find git wrapper binary. Gitweb
-  tries to find git wrapper at $(bindir)/git, so you have to set $bindir
+  One of the most important is where to find the git wrapper binary. Gitweb
+  tries to find the git wrapper at $(bindir)/git, so you have to set $bindir
   when building gitweb.cgi, or $prefix from which $bindir is derived. If
-  you build and install gitweb together with the rest of git suite,
+  you build and install gitweb together with the rest of the git suite,
   there should be no problems. Otherwise, if git was for example
   installed from a binary package, you have to set $prefix (or $bindir)
   accordingly.
 
 - Another important issue is where are git repositories you want to make
-  available to gitweb. By default gitweb search for repositories under
+  available to gitweb. By default gitweb searches for repositories under
   /pub/git; if you want to have projects somewhere else, like /home/git,
   use GITWEB_PROJECTROOT build configuration variable.
 
   By default all git repositories under projectroot are visible and
-  available to gitweb. List of projects is generated by default by
+  available to gitweb. The list of projects is generated by default by
   scanning the projectroot directory for git repositories. This can be
   changed (configured) as described in "Gitweb repositories" section
   below.
 
-  Note that gitweb deals directly with object database, and does not
-  need working directory; the name of the project is the name of its
+  Note that gitweb deals directly with the object database, and does not
+  need working directory; the name of the project is the name of its
   repository object database, usually projectname.git for bare
   repositories. If you want to provide gitweb access to non-bare (live)
-  repository, you can make projectname.git symbolic link under
+  repositories, you can make projectname.git a symbolic link under
   projectroot linking to projectname/.git (but it is just
   a suggestion).
 
 - You can control where gitweb tries to find its main CSS style file,
-  its favicon and logo with GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO
+  its favicon and logo with the GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO
   build configuration variables. By default gitweb tries to find them
   in the same directory as gitweb.cgi script.
 
@@ -91,17 +91,17 @@ Gitweb config file
 See also "Runtime gitweb configuration" section in README file
 for gitweb (in gitweb/README).
 
-- You can configure gitweb further using gitweb configuration file;
-  by default it is file named gitweb_config.perl in the same place as
-  gitweb.cgi script. You can control default place for config file
-  using GITWEB_CONFIG build configuration variable, and you can set it
-  using GITWEB_CONFIG environmental variable. If this file does not
+- You can configure gitweb further using the gitweb configuration file;
+  by default this is a file named gitweb_config.perl in the same place as
+  gitweb.cgi script. You can control the default place for the config file
+  using the GITWEB_CONFIG build configuration variable, and you can set it
+  using the GITWEB_CONFIG environment variable. If this file does not
   exist, gitweb looks for a system-wide configuration file, normally
   /etc/gitweb.conf. You can change the default using the
   GITWEB_CONFIG_SYSTEM build configuration variable, and override it
-  through GITWEB_CONFIG_SYSTEM environmental variable.
+  through the GITWEB_CONFIG_SYSTEM environment variable.
 
-- Gitweb config file is [fragment] of perl code. You can set variables
+- The gitweb config file is a fragment of perl code. You can set variables
   using "our $variable = value"; text from "#" character until the end
   of a line is ignored. See perlsyn(1) for details.
 
@@ -128,36 +128,37 @@ Gitweb repositories
 -------------------
 
 - By default all git repositories under projectroot are visible and
-  available to gitweb. List of projects is generated by default by
+  available to gitweb. The list of projects is generated by default by
   scanning the projectroot directory for git repositories (for object
   databases to be more exact).
 
-  You can provide pre-generated list of [visible] repositories,
+  You can provide pre-generated list of [visible] repositories,
   together with information about their owners (the project ownership
-  is taken from owner of repository directory otherwise), by setting
-  GITWEB_LIST build configuration variable (or $projects_list variable
-  in gitweb config file) to point to a plain file.
-
-  Each line of projects list file should consist of url-encoded path
-  to project repository database (relative to projectroot) separated
-  by space from url-encoded project owner; spaces in both project path
-  and project owner have to be encoded as either '%20' or '+'.
-
-  You can generate projects list index file using project_index action
-  (the 'TXT' link on projects list page) directly from gitweb.
-
-- By default even if project is not visible on projects list page, you
-  can view it nevertheless by hand-crafting gitweb URL. You can set
-  GITWEB_STRICT_EXPORT build configuration variable (or $strict_export
-  variable in gitweb config file) to only allow viewing of
+  defaults to the owner of the repository directory otherwise), by setting
+  the GITWEB_LIST build configuration variable (or the $projects_list
+  variable in the gitweb config file) to point to a plain file.
+
+  Each line of the projects list file should consist of the url-encoded path
+  to the project repository database (relative to projectroot), followed
+  by the url-encoded project owner on the same line (separated by a space).
+  Spaces in both project path and project owner have to be encoded as either
+  '%20' or '+'.
+
+  You can generate the projects list index file using the project_index
+  action (the 'TXT' link on projects list page) directly from gitweb.
+
+- By default, even if a project is not visible on projects list page, you
+  can view it nevertheless by hand-crafting a gitweb URL. You can set the
+  GITWEB_STRICT_EXPORT build configuration variable (or the $strict_export
+  variable in the gitweb config file) to only allow viewing of
   repositories also shown on the overview page.
 
 - Alternatively, you can configure gitweb to only list and allow
-  viewing of the explicitly exported repositories, via
-  GITWEB_EXPORT_OK build configuration variable (or $export_ok
+  viewing of the explicitly exported repositories, via the
+  GITWEB_EXPORT_OK build configuration variable (or the $export_ok
   variable in gitweb config file). If it evaluates to true, gitweb
-  show repository only if this file exists in its object database
-  (if directory has the magic file $export_ok).
+  shows repositories only if this file exists in its object database
+  (if directory has the magic file named $export_ok).
 
 Generating projects list using gitweb
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index 8dfe335f73c223fa0da8cd21db6227283adb95ba..8f7ea367bae72ea3ce25b10b968554f9b842fffe 100644 (file)
@@ -2,7 +2,7 @@ GIT web Interface
 =================
 
 The one working on:
-  http://www.kernel.org/git/
+  http://git.kernel.org/
 
 From the git version 1.4.0 gitweb is bundled with git.
 
@@ -10,13 +10,13 @@ From the git version 1.4.0 gitweb is bundled with git.
 How to configure gitweb for your local system
 ---------------------------------------------
 
-See also "Build time configuration" section in INSTALL
+See also the "Build time configuration" section in the INSTALL
 file for gitweb (in gitweb/INSTALL).
 
 You can specify the following configuration variables when building GIT:
  * GIT_BINDIR
-   Points out where to find git executable.  You should set up it to
-   the place where git binary was installed (usually /usr/bin) if you
+   Points where to find the git executable.  You should set it up to
+   the place where the git binary was installed (usually /usr/bin) if you
    don't install git from sources together with gitweb.  [Default: $(bindir)]
  * GITWEB_SITENAME
    Shown in the title of all generated pages, defaults to the server name
@@ -24,13 +24,13 @@ You can specify the following configuration variables when building GIT:
  * GITWEB_PROJECTROOT
    The root directory for all projects shown by gitweb. Must be set
    correctly for gitweb to find repositories to display.  See also
-   "Gitweb repositories" in INSTALL file for gitweb.  [Default: /pub/git]
+   "Gitweb repositories" in the INSTALL file for gitweb.  [Default: /pub/git]
  * GITWEB_PROJECT_MAXDEPTH
-   The filesystem traversing limit for getting projects list; the number
+   The filesystem traversing limit for getting the project list; the number
    is taken as depth relative to the projectroot.  It is used when
    GITWEB_LIST is a directory (or is not set; then project root is used).
    Is is meant to speed up project listing on large work trees by limiting
-   find depth.  [Default: 2007]
+   search depth.  [Default: 2007]
  * GITWEB_LIST
    Points to a directory to scan for projects (defaults to project root
    if not set / if empty) or to a file with explicit listing of projects
@@ -72,15 +72,15 @@ You can specify the following configuration variables when building GIT:
    Git base URLs used for URL to where fetch project from, i.e. full
    URL is "$git_base_url/$project".  Shown on projects summary page.
    Repository URL for project can be also configured per repository; this
-   takes precendence over URL composed from base URL and project name.
+   takes precedence over URLs composed from base URL and a project name.
    Note that you can setup multiple base URLs (for example one for
-   git:// protocol access, one for http:// access) from gitweb config
-   file.  [No default]
+   git:// protocol access, another for http:// access) from the gitweb
+   config file.  [No default]
  * GITWEB_CSS
    Points to the location where you put gitweb.css on your web server
-   (or to be more generic URI of gitweb stylesheet).  Relative to base
-   URI of gitweb.  Note that you can setup multiple stylesheets from
-   gitweb config file.  [Default: gitweb.css]
+   (or to be more generic, the URI of gitweb stylesheet).  Relative to the
+   base URI of gitweb.  Note that you can setup multiple stylesheets from
+   the gitweb config file.  [Default: gitweb.css]
  * GITWEB_LOGO
    Points to the location where you put git-logo.png on your web server
    (or to be more generic URI of logo, 72x27 size, displayed in top right
@@ -121,15 +121,15 @@ Ultimate description on how to reconfigure the default features setting
 in your `GITWEB_CONFIG` or per-project in `project.git/config` can be found
 as comments inside 'gitweb.cgi'.
 
-See also "Gitweb config file" (with example of gitweb config file), and
-"Gitweb repositories" sections in INSTALL file for gitweb.
+See also the "Gitweb config file" (with an example of config file), and
+the "Gitweb repositories" sections in INSTALL file for gitweb.
 
 
-Gitweb config file is [fragment] of perl code. You can set variables
+The gitweb config file is a fragment of perl code. You can set variables
 using "our $variable = value"; text from "#" character until the end
 of a line is ignored. See perlsyn(1) man page for details.
 
-Below there is list of vaiables which you might want to set in gitweb config.
+Below is the list of variables which you might want to set in gitweb config.
 See the top of 'gitweb.cgi' for the full list of variables and their
 descriptions.
 
@@ -140,7 +140,7 @@ You can set, among others, the following variables in gitweb config files
 (with the exception of $projectroot and $projects_list this list does
 not include variables usually directly set during build):
  * $GIT
-   Cure git executable to use.  By default set to "$GIT_BINDIR/git", which
+   Core git executable to use.  By default set to "$GIT_BINDIR/git", which
    in turn is by default set to "$(bindir)/git".  If you use git from binary
    package, set this to "/usr/bin/git".  This can just be "git" if your
    webserver has a sensible PATH.  If you have multiple git versions
@@ -176,7 +176,7 @@ not include variables usually directly set during build):
    to make it easier to upgrade gitweb. You can add 'site' stylesheet
    for example by using
       push @stylesheets, "gitweb-site.css";
-   in gitweb config file.
+   in the gitweb config file.
  * $logo_url, $logo_label
    URI and label (title) of GIT logo link (or your site logo, if you choose
    to use different logo image). By default they point to git homepage;
@@ -198,12 +198,12 @@ not include variables usually directly set during build):
    Default mimetype for blob_plain (raw) view, if mimetype checking
    doesn't result in some other type; by default 'text/plain'.
  * $default_text_plain_charset
-   Default charset for text files. If not set, web serwer configuration
+   Default charset for text files. If not set, web server configuration
    would be used.
  * $mimetypes_file
    File to use for (filename extension based) guessing of MIME types before
-   trying /etc/mime.types. Path, if relative, is taken currently as taken
-   relative to current git repositoy.
+   trying /etc/mime.types. Path, if relative, is taken currently as
+   relative to the current git repository.
  * $fallback_encoding
    Gitweb assumes this charset if line contains non-UTF-8 characters.
    Fallback decoding is used without error checking, so it can be even
@@ -232,14 +232,14 @@ You can use the following files in repository:
    single line description of a project (of a repository). Plain text file;
    HTML will be escaped. By default set to
      Unnamed repository; edit this file to name it for gitweb.
-   from the template during creating repository. You can use
+   from the template during repository creation. You can use the
    gitweb.description repo configuration variable, but the file takes
-   precendence.
+   precedence.
  * cloneurl (or multiple-valued gitweb.url)
    File with repository URL (used for clone and fetch), one per line.
    Displayed in the project summary page. You can use multiple-valued
    gitweb.url repository configuration variable for that, but the file
-   takes precendence.
+   takes precedence.
  * gitweb.owner
    You can use the gitweb.owner repository configuration variable to set
    repository's owner. It is displayed in the project list and summary
index e69d7fd07b74d2e1c06f26e98eb72c83183c19f8..f83567ec39e8781cc10d3f3f3cb39c7cb6aa11ef 100755 (executable)
@@ -511,7 +511,7 @@ sub evaluate_path_info {
        }
        # do not change any parameters if an action is given using the query string
        return if $action;
-       $path_info =~ s,^$project/*,,;
+       $path_info =~ s,^\Q$project\E/*,,;
        my ($refname, $pathname) = split(/:/, $path_info, 2);
        if (defined $pathname) {
                # we got "project.git/branch:filename" or "project.git/branch:dir/"
@@ -633,7 +633,7 @@ sub href(%) {
        my ($use_pathinfo) = gitweb_check_feature('pathinfo');
        if ($use_pathinfo) {
                # use PATH_INFO for project name
-               $href .= "/$params{'project'}" if defined $params{'project'};
+               $href .= "/".esc_url($params{'project'}) if defined $params{'project'};
                delete $params{'project'};
 
                # Summary just uses the project path URL
@@ -2575,7 +2575,7 @@ EOF
                my $action = $my_uri;
                my ($use_pathinfo) = gitweb_check_feature('pathinfo');
                if ($use_pathinfo) {
-                       $action .= "/$project";
+                       $action .= "/".esc_url($project);
                } else {
                        $cgi->param("p", $project);
                }
@@ -5176,14 +5176,26 @@ sub git_history {
        my $refs = git_get_references();
        my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
 
+       my @commitlist = parse_commits($hash_base, 101, (100 * $page),
+                                      $file_name, "--full-history");
+       if (!@commitlist) {
+               die_error('404 Not Found', "No such file or directory on given branch");
+       }
+
        if (!defined $hash && defined $file_name) {
-               $hash = git_get_hash_by_path($hash_base, $file_name);
+               # some commits could have deleted file in question,
+               # and not have it in tree, but one of them has to have it
+               for (my $i = 0; $i <= @commitlist; $i++) {
+                       $hash = git_get_hash_by_path($commitlist[$i]{'id'}, $file_name);
+                       last if defined $hash;
+               }
        }
        if (defined $hash) {
                $ftype = git_get_type($hash);
        }
-
-       my @commitlist = parse_commits($hash_base, 101, (100 * $page), $file_name, "--full-history");
+       if (!defined $ftype) {
+               die_error(undef, "Unknown type of object");
+       }
 
        my $paging_nav = '';
        if ($page > 0) {
index 04afbc492485d95a85a7f0f57bbb48def6337a99..db6559725e6867131800b6682348ebbf896ddbf5 100644 (file)
@@ -1303,8 +1303,11 @@ main(int argc, char **argv)
                return 1;
        }
        if (!server.host) {
-               fprintf( stderr, "no imap host specified\n" );
-               return 1;
+               if (!server.tunnel) {
+                       fprintf( stderr, "no imap host specified\n" );
+                       return 1;
+               }
+               server.host = "tunnel";
        }
 
        /* read the messages */
index 9d54061601c2b378089a88142138ce3e0da1761e..8f5436b747830cc3e91d862efc3cbcb30fab65ae 100644 (file)
@@ -249,9 +249,9 @@ void show_log(struct rev_info *opt, const char *sep)
         *    not have an empty line between entries.
         */
        extra = "";
-       if (*sep != '\n' && opt->commit_format == CMIT_FMT_ONELINE)
+       if (*sep != '\n' && opt->use_terminator)
                extra = "\n";
-       if (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE)
+       if (opt->shown_one && !opt->use_terminator)
                putchar(opt->diffopt.line_termination);
        opt->shown_one = 1;
 
diff --git a/path.c b/path.c
index f4ed979997b6a968ba1987a199beae39035d5da2..b7c24a2aacf87ffea6bd6380dbff44e5d317b240 100644 (file)
--- a/path.c
+++ b/path.c
@@ -91,7 +91,8 @@ int validate_headref(const char *path)
        struct stat st;
        char *buf, buffer[256];
        unsigned char sha1[20];
-       int len, fd;
+       int fd;
+       ssize_t len;
 
        if (lstat(path, &st) < 0)
                return -1;
@@ -266,24 +267,25 @@ int adjust_shared_perm(const char *path)
        if (lstat(path, &st) < 0)
                return -1;
        mode = st.st_mode;
-       if (mode & S_IRUSR)
-               mode |= (shared_repository == PERM_GROUP
-                        ? S_IRGRP
-                        : (shared_repository == PERM_EVERYBODY
-                           ? (S_IRGRP|S_IROTH)
-                           : 0));
-
-       if (mode & S_IWUSR)
-               mode |= S_IWGRP;
-
-       if (mode & S_IXUSR)
-               mode |= (shared_repository == PERM_GROUP
-                        ? S_IXGRP
-                        : (shared_repository == PERM_EVERYBODY
-                           ? (S_IXGRP|S_IXOTH)
-                           : 0));
-       if (S_ISDIR(mode))
+
+       if (shared_repository) {
+               int tweak = shared_repository;
+               if (!(mode & S_IWUSR))
+                       tweak &= ~0222;
+               mode = (mode & ~0777) | tweak;
+       } else {
+               /* Preserve old PERM_UMASK behaviour */
+               if (mode & S_IWUSR)
+                       mode |= S_IWGRP;
+       }
+
+       if (S_ISDIR(mode)) {
                mode |= FORCE_DIR_SET_GID;
+
+               /* Copy read bits to execute bits */
+               mode |= (shared_repository & 0444) >> 2;
+       }
+
        if ((mode & st.st_mode) != mode && chmod(path, mode) < 0)
                return -2;
        return 0;
index 6c04176cb877bf78ca1336d40011edcba29996ae..687293224c3bca20da413d132e17a436e2c79990 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -4,40 +4,49 @@
 #include "diff.h"
 #include "revision.h"
 
-static struct cmt_fmt_map {
-       const char *n;
-       size_t cmp_len;
-       enum cmit_fmt v;
-} cmt_fmts[] = {
-       { "raw",        1,      CMIT_FMT_RAW },
-       { "medium",     1,      CMIT_FMT_MEDIUM },
-       { "short",      1,      CMIT_FMT_SHORT },
-       { "email",      1,      CMIT_FMT_EMAIL },
-       { "full",       5,      CMIT_FMT_FULL },
-       { "fuller",     5,      CMIT_FMT_FULLER },
-       { "oneline",    1,      CMIT_FMT_ONELINE },
-       { "format:",    7,      CMIT_FMT_USERFORMAT},
-};
-
 static char *user_format;
 
-enum cmit_fmt get_commit_format(const char *arg)
+void get_commit_format(const char *arg, struct rev_info *rev)
 {
        int i;
-
-       if (!arg || !*arg)
-               return CMIT_FMT_DEFAULT;
+       static struct cmt_fmt_map {
+               const char *n;
+               size_t cmp_len;
+               enum cmit_fmt v;
+       } cmt_fmts[] = {
+               { "raw",        1,      CMIT_FMT_RAW },
+               { "medium",     1,      CMIT_FMT_MEDIUM },
+               { "short",      1,      CMIT_FMT_SHORT },
+               { "email",      1,      CMIT_FMT_EMAIL },
+               { "full",       5,      CMIT_FMT_FULL },
+               { "fuller",     5,      CMIT_FMT_FULLER },
+               { "oneline",    1,      CMIT_FMT_ONELINE },
+       };
+
+       rev->use_terminator = 0;
+       if (!arg || !*arg) {
+               rev->commit_format = CMIT_FMT_DEFAULT;
+               return;
+       }
        if (*arg == '=')
                arg++;
-       if (!prefixcmp(arg, "format:")) {
+       if (!prefixcmp(arg, "format:") || !prefixcmp(arg, "tformat:")) {
+               const char *cp = strchr(arg, ':') + 1;
                free(user_format);
-               user_format = xstrdup(arg + 7);
-               return CMIT_FMT_USERFORMAT;
+               user_format = xstrdup(cp);
+               if (arg[0] == 't')
+                       rev->use_terminator = 1;
+               rev->commit_format = CMIT_FMT_USERFORMAT;
+               return;
        }
        for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
                if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
-                   !strncmp(arg, cmt_fmts[i].n, strlen(arg)))
-                       return cmt_fmts[i].v;
+                   !strncmp(arg, cmt_fmts[i].n, strlen(arg))) {
+                       if (cmt_fmts[i].v == CMIT_FMT_ONELINE)
+                               rev->use_terminator = 1;
+                       rev->commit_format = cmt_fmts[i].v;
+                       return;
+               }
        }
 
        die("invalid --pretty format: %s", arg);
diff --git a/refs.c b/refs.c
index 1b0050eee4e037aec8396edd0ff6c14bda5985a2..4db73ed8f01200fca4008bafb23bda36a8e23446 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -368,7 +368,8 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *re
 
 const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *flag)
 {
-       int depth = MAXDEPTH, len;
+       int depth = MAXDEPTH;
+       ssize_t len;
        char buffer[256];
        static char ref_buffer[256];
 
index 369dc3398cc22206497f17cd846702783f59cf76..2d9af4023eba6f8b2fe528ccbf03569fcaa265ee 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -409,7 +409,7 @@ static void read_config(void)
        alias_all_urls();
 }
 
-static struct refspec *parse_refspec_internal(int nr_refspec, const char **refspec, int fetch)
+static struct refspec *parse_refspec_internal(int nr_refspec, const char **refspec, int fetch, int verify)
 {
        int i;
        int st;
@@ -519,17 +519,32 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
        return rs;
 
  invalid:
+       if (verify) {
+               free(rs);
+               return NULL;
+       }
        die("Invalid refspec '%s'", refspec[i]);
 }
 
+int valid_fetch_refspec(const char *fetch_refspec_str)
+{
+       const char *fetch_refspec[] = { fetch_refspec_str };
+       struct refspec *refspec;
+
+       refspec = parse_refspec_internal(1, fetch_refspec, 1, 1);
+       if (refspec)
+               free(refspec);
+       return !!refspec;
+}
+
 struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec)
 {
-       return parse_refspec_internal(nr_refspec, refspec, 1);
+       return parse_refspec_internal(nr_refspec, refspec, 1, 0);
 }
 
 struct refspec *parse_push_refspec(int nr_refspec, const char **refspec)
 {
-       return parse_refspec_internal(nr_refspec, refspec, 0);
+       return parse_refspec_internal(nr_refspec, refspec, 0, 0);
 }
 
 static int valid_remote_nick(const char *name)
@@ -797,6 +812,26 @@ static struct ref *make_linked_ref(const char *name, struct ref ***tail)
        return ret;
 }
 
+static char *guess_ref(const char *name, struct ref *peer)
+{
+       struct strbuf buf = STRBUF_INIT;
+       unsigned char sha1[20];
+
+       const char *r = resolve_ref(peer->name, sha1, 1, NULL);
+       if (!r)
+               return NULL;
+
+       if (!prefixcmp(r, "refs/heads/"))
+               strbuf_addstr(&buf, "refs/heads/");
+       else if (!prefixcmp(r, "refs/tags/"))
+               strbuf_addstr(&buf, "refs/tags/");
+       else
+               return NULL;
+
+       strbuf_addstr(&buf, name);
+       return strbuf_detach(&buf, NULL);
+}
+
 static int match_explicit(struct ref *src, struct ref *dst,
                          struct ref ***dst_tail,
                          struct refspec *rs,
@@ -805,6 +840,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
        struct ref *matched_src, *matched_dst;
 
        const char *dst_value = rs->dst;
+       char *dst_guess;
 
        if (rs->pattern)
                return errs;
@@ -851,10 +887,15 @@ static int match_explicit(struct ref *src, struct ref *dst,
        case 0:
                if (!memcmp(dst_value, "refs/", 5))
                        matched_dst = make_linked_ref(dst_value, dst_tail);
+               else if((dst_guess = guess_ref(dst_value, matched_src)))
+                       matched_dst = make_linked_ref(dst_guess, dst_tail);
                else
-                       error("dst refspec %s does not match any "
-                             "existing ref on the remote and does "
-                             "not start with refs/.", dst_value);
+                       error("unable to push to unqualified destination: %s\n"
+                             "The destination refspec neither matches an "
+                             "existing ref on the remote nor\n"
+                             "begins with refs/, and we are unable to "
+                             "guess a prefix based on the source ref.",
+                             dst_value);
                break;
        default:
                matched_dst = NULL;
index 7e9ae792dc69bb8b07cb9b8cf4e53845595d320e..a38774bbdc5acfb5ed9360ac92e1049fa79b26e1 100644 (file)
--- a/remote.h
+++ b/remote.h
@@ -67,6 +67,7 @@ void free_refs(struct ref *ref);
  */
 void ref_remove_duplicates(struct ref *ref_map);
 
+int valid_fetch_refspec(const char *refspec);
 struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec);
 struct refspec *parse_push_refspec(int nr_refspec, const char **refspec);
 
index ffbed3fbf22c22b8862c49bdddd10cab201f86a2..4231ea2cce57c74a4110c9c69459a4caf67dc15c 100644 (file)
@@ -1199,7 +1199,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                        }
                        if (!prefixcmp(arg, "--pretty")) {
                                revs->verbose_header = 1;
-                               revs->commit_format = get_commit_format(arg+8);
+                               get_commit_format(arg+8, revs);
                                continue;
                        }
                        if (!strcmp(arg, "--root")) {
index c8b3b948ecc1cc8b45859a6e1ea11763addfb8b5..31217f8c67307aa09c2f470ccdbdebd5c2445890 100644 (file)
@@ -64,7 +64,8 @@ struct rev_info {
 
        /* Format info */
        unsigned int    shown_one:1,
-                       abbrev_commit:1;
+                       abbrev_commit:1,
+                       use_terminator:1;
        enum date_mode date_mode;
 
        const char **ignore_packed; /* pretend objects in these are unpacked */
diff --git a/setup.c b/setup.c
index 3d2d9580f3283b4e4bc741d98863777510bd5173..1b4fa6a8c4289bedf10f57d9aa19db4c7f186b01 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -428,21 +428,53 @@ const char *setup_git_directory_gently(int *nongit_ok)
 
 int git_config_perm(const char *var, const char *value)
 {
-       if (value) {
-               int i;
-               if (!strcmp(value, "umask"))
-                       return PERM_UMASK;
-               if (!strcmp(value, "group"))
-                       return PERM_GROUP;
-               if (!strcmp(value, "all") ||
-                   !strcmp(value, "world") ||
-                   !strcmp(value, "everybody"))
-                       return PERM_EVERYBODY;
-               i = atoi(value);
-               if (i > 1)
-                       return i;
+       int i;
+       char *endptr;
+
+       if (value == NULL)
+               return PERM_GROUP;
+
+       if (!strcmp(value, "umask"))
+               return PERM_UMASK;
+       if (!strcmp(value, "group"))
+               return PERM_GROUP;
+       if (!strcmp(value, "all") ||
+           !strcmp(value, "world") ||
+           !strcmp(value, "everybody"))
+               return PERM_EVERYBODY;
+
+       /* Parse octal numbers */
+       i = strtol(value, &endptr, 8);
+
+       /* If not an octal number, maybe true/false? */
+       if (*endptr != 0)
+               return git_config_bool(var, value) ? PERM_GROUP : PERM_UMASK;
+
+       /*
+        * Treat values 0, 1 and 2 as compatibility cases, otherwise it is
+        * a chmod value.
+        */
+       switch (i) {
+       case PERM_UMASK:               /* 0 */
+               return PERM_UMASK;
+       case OLD_PERM_GROUP:           /* 1 */
+               return PERM_GROUP;
+       case OLD_PERM_EVERYBODY:       /* 2 */
+               return PERM_EVERYBODY;
        }
-       return git_config_bool(var, value);
+
+       /* A filemode value was given: 0xxx */
+
+       if ((i & 0600) != 0600)
+               die("Problem with core.sharedRepository filemode value "
+                   "(0%.3o).\nThe owner of files must always have "
+                   "read and write permissions.", i);
+
+       /*
+        * Mask filemode value. Others can not get write permission.
+        * x flags for directories are handled separately.
+        */
+       return i & 0666;
 }
 
 int check_repository_format_version(const char *var, const char *value)
diff --git a/sha1-lookup.c b/sha1-lookup.c
new file mode 100644 (file)
index 0000000..da35747
--- /dev/null
@@ -0,0 +1,171 @@
+#include "cache.h"
+#include "sha1-lookup.h"
+
+/*
+ * Conventional binary search loop looks like this:
+ *
+ *     unsigned lo, hi;
+ *      do {
+ *              unsigned mi = (lo + hi) / 2;
+ *              int cmp = "entry pointed at by mi" minus "target";
+ *              if (!cmp)
+ *                      return (mi is the wanted one)
+ *              if (cmp > 0)
+ *                      hi = mi; "mi is larger than target"
+ *              else
+ *                      lo = mi+1; "mi is smaller than target"
+ *      } while (lo < hi);
+ *
+ * The invariants are:
+ *
+ * - When entering the loop, lo points at a slot that is never
+ *   above the target (it could be at the target), hi points at a
+ *   slot that is guaranteed to be above the target (it can never
+ *   be at the target).
+ *
+ * - We find a point 'mi' between lo and hi (mi could be the same
+ *   as lo, but never can be as same as hi), and check if it hits
+ *   the target.  There are three cases:
+ *
+ *    - if it is a hit, we are happy.
+ *
+ *    - if it is strictly higher than the target, we set it to hi,
+ *      and repeat the search.
+ *
+ *    - if it is strictly lower than the target, we update lo to
+ *      one slot after it, because we allow lo to be at the target.
+ *
+ *   If the loop exits, there is no matching entry.
+ *
+ * When choosing 'mi', we do not have to take the "middle" but
+ * anywhere in between lo and hi, as long as lo <= mi < hi is
+ * satisfied.  When we somehow know that the distance between the
+ * target and lo is much shorter than the target and hi, we could
+ * pick mi that is much closer to lo than the midway.
+ *
+ * Now, we can take advantage of the fact that SHA-1 is a good hash
+ * function, and as long as there are enough entries in the table, we
+ * can expect uniform distribution.  An entry that begins with for
+ * example "deadbeef..." is much likely to appear much later than in
+ * the midway of the table.  It can reasonably be expected to be near
+ * 87% (222/256) from the top of the table.
+ *
+ * However, we do not want to pick "mi" too precisely.  If the entry at
+ * the 87% in the above example turns out to be higher than the target
+ * we are looking for, we would end up narrowing the search space down
+ * only by 13%, instead of 50% we would get if we did a simple binary
+ * search.  So we would want to hedge our bets by being less aggressive.
+ *
+ * The table at "table" holds at least "nr" entries of "elem_size"
+ * bytes each.  Each entry has the SHA-1 key at "key_offset".  The
+ * table is sorted by the SHA-1 key of the entries.  The caller wants
+ * to find the entry with "key", and knows that the entry at "lo" is
+ * not higher than the entry it is looking for, and that the entry at
+ * "hi" is higher than the entry it is looking for.
+ */
+int sha1_entry_pos(const void *table,
+                  size_t elem_size,
+                  size_t key_offset,
+                  unsigned lo, unsigned hi, unsigned nr,
+                  const unsigned char *key)
+{
+       const unsigned char *base = table;
+       const unsigned char *hi_key, *lo_key;
+       unsigned ofs_0;
+       static int debug_lookup = -1;
+
+       if (debug_lookup < 0)
+               debug_lookup = !!getenv("GIT_DEBUG_LOOKUP");
+
+       if (!nr || lo >= hi)
+               return -1;
+
+       if (nr == hi)
+               hi_key = NULL;
+       else
+               hi_key = base + elem_size * hi + key_offset;
+       lo_key = base + elem_size * lo + key_offset;
+
+       ofs_0 = 0;
+       do {
+               int cmp;
+               unsigned ofs, mi, range;
+               unsigned lov, hiv, kyv;
+               const unsigned char *mi_key;
+
+               range = hi - lo;
+               if (hi_key) {
+                       for (ofs = ofs_0; ofs < 20; ofs++)
+                               if (lo_key[ofs] != hi_key[ofs])
+                                       break;
+                       ofs_0 = ofs;
+                       /*
+                        * byte 0 thru (ofs-1) are the same between
+                        * lo and hi; ofs is the first byte that is
+                        * different.
+                        */
+                       hiv = hi_key[ofs_0];
+                       if (ofs_0 < 19)
+                               hiv = (hiv << 8) | hi_key[ofs_0+1];
+               } else {
+                       hiv = 256;
+                       if (ofs_0 < 19)
+                               hiv <<= 8;
+               }
+               lov = lo_key[ofs_0];
+               kyv = key[ofs_0];
+               if (ofs_0 < 19) {
+                       lov = (lov << 8) | lo_key[ofs_0+1];
+                       kyv = (kyv << 8) | key[ofs_0+1];
+               }
+               assert(lov < hiv);
+
+               if (kyv < lov)
+                       return -1 - lo;
+               if (hiv < kyv)
+                       return -1 - hi;
+
+               /*
+                * Even if we know the target is much closer to 'hi'
+                * than 'lo', if we pick too precisely and overshoot
+                * (e.g. when we know 'mi' is closer to 'hi' than to
+                * 'lo', pick 'mi' that is higher than the target), we
+                * end up narrowing the search space by a smaller
+                * amount (i.e. the distance between 'mi' and 'hi')
+                * than what we would have (i.e. about half of 'lo'
+                * and 'hi').  Hedge our bets to pick 'mi' less
+                * aggressively, i.e. make 'mi' a bit closer to the
+                * middle than we would otherwise pick.
+                */
+               kyv = (kyv * 6 + lov + hiv) / 8;
+               if (lov < hiv - 1) {
+                       if (kyv == lov)
+                               kyv++;
+                       else if (kyv == hiv)
+                               kyv--;
+               }
+               mi = (range - 1) * (kyv - lov) / (hiv - lov) + lo;
+
+               if (debug_lookup) {
+                       printf("lo %u hi %u rg %u mi %u ", lo, hi, range, mi);
+                       printf("ofs %u lov %x, hiv %x, kyv %x\n",
+                              ofs_0, lov, hiv, kyv);
+               }
+               if (!(lo <= mi && mi < hi))
+                       die("assertion failure lo %u mi %u hi %u %s",
+                           lo, mi, hi, sha1_to_hex(key));
+
+               mi_key = base + elem_size * mi + key_offset;
+               cmp = memcmp(mi_key + ofs_0, key + ofs_0, 20 - ofs_0);
+               if (!cmp)
+                       return mi;
+               if (cmp > 0) {
+                       hi = mi;
+                       hi_key = mi_key;
+               } else {
+                       lo = mi + 1;
+                       lo_key = mi_key + elem_size;
+               }
+       } while (lo < hi);
+       return -lo-1;
+}
diff --git a/sha1-lookup.h b/sha1-lookup.h
new file mode 100644 (file)
index 0000000..3249a81
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef SHA1_LOOKUP_H
+#define SHA1_LOOKUP_H
+
+extern int sha1_entry_pos(const void *table,
+                         size_t elem_size,
+                         size_t key_offset,
+                         unsigned lo, unsigned hi, unsigned nr,
+                         const unsigned char *key);
+#endif
index 445a871db31673af20017d36ff22fd106f77f510..c2ab7ea11d7a838c54e5cc8f91ae06a3ee0a2e67 100644 (file)
@@ -15,6 +15,7 @@
 #include "tree.h"
 #include "refs.h"
 #include "pack-revindex.h"
+#include "sha1-lookup.h"
 
 #ifndef O_NOATIME
 #if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
@@ -1675,7 +1676,12 @@ off_t find_pack_entry_one(const unsigned char *sha1,
 {
        const uint32_t *level1_ofs = p->index_data;
        const unsigned char *index = p->index_data;
-       unsigned hi, lo;
+       unsigned hi, lo, stride;
+       static int use_lookup = -1;
+       static int debug_lookup = -1;
+
+       if (debug_lookup < 0)
+               debug_lookup = !!getenv("GIT_DEBUG_LOOKUP");
 
        if (!index) {
                if (open_pack_index(p))
@@ -1690,11 +1696,34 @@ off_t find_pack_entry_one(const unsigned char *sha1,
        index += 4 * 256;
        hi = ntohl(level1_ofs[*sha1]);
        lo = ((*sha1 == 0x0) ? 0 : ntohl(level1_ofs[*sha1 - 1]));
+       if (p->index_version > 1) {
+               stride = 20;
+       } else {
+               stride = 24;
+               index += 4;
+       }
+
+       if (debug_lookup)
+               printf("%02x%02x%02x... lo %u hi %u nr %u\n",
+                      sha1[0], sha1[1], sha1[2], lo, hi, p->num_objects);
+
+       if (use_lookup < 0)
+               use_lookup = !!getenv("GIT_USE_LOOKUP");
+       if (use_lookup) {
+               int pos = sha1_entry_pos(index, stride, 0,
+                                        lo, hi, p->num_objects, sha1);
+               if (pos < 0)
+                       return 0;
+               return nth_packed_object_offset(p, pos);
+       }
 
        do {
                unsigned mi = (lo + hi) / 2;
-               unsigned x = (p->index_version > 1) ? (mi * 20) : (mi * 24 + 4);
-               int cmp = hashcmp(index + x, sha1);
+               int cmp = hashcmp(index + mi * stride, sha1);
+
+               if (debug_lookup)
+                       printf("lo %u hi %u rg %u mi %u\n",
+                              lo, hi, hi - lo, mi);
                if (!cmp)
                        return nth_packed_object_offset(p, mi);
                if (cmp > 0)
index 491d2e7ebf19d5c582adbc5ece28d931b09b8a6d..b0b2167578a7baebeba676af0b33161fb688bae0 100644 (file)
@@ -351,8 +351,11 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
                }
                if (0 <= nth)
                        at_time = 0;
-               else
-                       at_time = approxidate(str + at + 2);
+               else {
+                       char *tmp = xstrndup(str + at + 2, reflog_len);
+                       at_time = approxidate(tmp);
+                       free(tmp);
+               }
                if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
                                &co_time, &co_tz, &co_cnt)) {
                        if (at_time)
index 3faf135e38ccbe71241679da464d7cf709ae73d7..c56d2fbabaa0fdd90547ce8b629a629c21fbbc0e 100755 (executable)
@@ -21,6 +21,7 @@ test_expect_success 'setup' '
        mkdir -p a/b/d a/c &&
        (
                echo "f test=f"
+               echo "a/i test=a/i"
        ) >.gitattributes &&
        (
                echo "g test=a/g" &&
@@ -46,4 +47,11 @@ test_expect_success 'attribute test' '
 
 '
 
+test_expect_success 'root subdir attribute test' '
+
+       attr_check a/i a/i &&
+       attr_check subdir/a/i unspecified
+
+'
+
 test_done
diff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh
new file mode 100755 (executable)
index 0000000..9255c63
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+test_description='detect unwritable repository and fail correctly'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+       >file &&
+       git add file &&
+       git commit -m initial &&
+       echo >file &&
+       git add file
+
+'
+
+test_expect_success 'write-tree should notice unwritable repository' '
+
+       (
+               chmod a-w .git/objects
+               test_must_fail git write-tree
+       )
+       status=$?
+       chmod 775 .git/objects
+       (exit $status)
+
+'
+
+test_expect_success 'commit should notice unwritable repository' '
+
+       (
+               chmod a-w .git/objects
+               test_must_fail git commit -m second
+       )
+       status=$?
+       chmod 775 .git/objects
+       (exit $status)
+
+'
+
+test_expect_success 'update-index should notice unwritable repository' '
+
+       (
+               echo a >file &&
+               chmod a-w .git/objects
+               test_must_fail git update-index file
+       )
+       status=$?
+       chmod 775 .git/objects
+       (exit $status)
+
+'
+
+test_expect_success 'add should notice unwritable repository' '
+
+       (
+               echo b >file &&
+               chmod a-w .git/objects
+               test_must_fail git add file
+       )
+       status=$?
+       chmod 775 .git/objects
+       (exit $status)
+
+'
+
+test_done
index b36a9012ecb3a34761027de77635741e1cd80aab..a675cbb51b5dafad22dd494784a0b4c8ec396db3 100755 (executable)
@@ -595,6 +595,64 @@ test_expect_success 'set --int' '
 
 rm .git/config
 
+cat >expect <<\EOF
+[bool]
+       true1 = true
+       true2 = true
+       false1 = false
+       false2 = false
+[int]
+       int1 = 0
+       int2 = 1
+       int3 = -1
+EOF
+
+test_expect_success 'get --bool-or-int' '
+       (
+               echo "[bool]"
+               echo true1
+               echo true2 = true
+               echo false = false
+               echo "[int]"
+               echo int1 = 0
+               echo int2 = 1
+               echo int3 = -1
+       ) >>.git/config &&
+       test $(git config --bool-or-int bool.true1) = true &&
+       test $(git config --bool-or-int bool.true2) = true &&
+       test $(git config --bool-or-int bool.false) = false &&
+       test $(git config --bool-or-int int.int1) = 0 &&
+       test $(git config --bool-or-int int.int2) = 1 &&
+       test $(git config --bool-or-int int.int3) = -1
+
+'
+
+rm .git/config
+cat >expect <<\EOF
+[bool]
+       true1 = true
+       false1 = false
+       true2 = true
+       false2 = false
+[int]
+       int1 = 0
+       int2 = 1
+       int3 = -1
+EOF
+
+test_expect_success 'set --bool-or-int' '
+       git config --bool-or-int bool.true1 true &&
+       git config --bool-or-int bool.false1 false &&
+       git config --bool-or-int bool.true2 yes &&
+       git config --bool-or-int bool.false2 no &&
+       git config --bool-or-int int.int1 0 &&
+       git config --bool-or-int int.int2 1 &&
+       git config --bool-or-int int.int3 -1 &&
+       test_cmp expect .git/config
+'
+
+rm .git/config
+
 git config quote.leading " test"
 git config quote.ending "test "
 git config quote.semicolon "test;test"
index 6bfe19a4e5e8a22bfd286636e62c0c2d5cd56846..5e4252a320d5f967eacb9bd68bb0a510fe748e80 100755 (executable)
@@ -7,6 +7,16 @@ test_description='Test shared repository initialization'
 
 . ./test-lib.sh
 
+# User must have read permissions to the repo -> failure on --shared=0400
+test_expect_success 'shared = 0400 (faulty permission u-w)' '
+       mkdir sub && (
+               cd sub && git init --shared=0400
+       )
+       ret="$?"
+       rm -rf sub
+       test $ret != "0"
+'
+
 test_expect_success 'shared=all' '
        mkdir sub &&
        cd sub &&
@@ -33,4 +43,44 @@ test_expect_success 'update-server-info honors core.sharedRepository' '
        esac
 '
 
+for u in       0660:rw-rw---- \
+               0640:rw-r----- \
+               0600:rw------- \
+               0666:rw-rw-rw- \
+               0664:rw-rw-r--
+do
+       x=$(expr "$u" : ".*:\([rw-]*\)") &&
+       y=$(echo "$x" | sed -e "s/w/-/g") &&
+       u=$(expr "$u" : "\([0-7]*\)") &&
+       git config core.sharedrepository "$u" &&
+       umask 0277 &&
+
+       test_expect_success "shared = $u ($y) ro" '
+
+               rm -f .git/info/refs &&
+               git update-server-info &&
+               actual="$(ls -l .git/info/refs)" &&
+               actual=${actual%% *} &&
+               test "x$actual" = "x-$y" || {
+                       ls -lt .git/info
+                       false
+               }
+       '
+
+       umask 077 &&
+       test_expect_success "shared = $u ($x) rw" '
+
+               rm -f .git/info/refs &&
+               git update-server-info &&
+               actual="$(ls -l .git/info/refs)" &&
+               actual=${actual%% *} &&
+               test "x$actual" = "x-$x" || {
+                       ls -lt .git/info
+                       false
+               }
+
+       '
+
+done
+
 test_done
index 0f441bcef768ca68ead9bfa2d06b714b8d2c35ac..70361c806e1baf1b26810983374c53eb49ea2f2d 100755 (executable)
@@ -21,13 +21,13 @@ test_expect_success \
 rm -f path0 &&
 git read-tree $t &&
 git checkout-index -f -a &&
-! git diff-files | diff - /dev/null'
+test_must_fail git diff-files --exit-code'
 
 test_expect_success \
 'with -u, git checkout-index picks up stat information from new files.' '
 rm -f path0 &&
 git read-tree $t &&
 git checkout-index -u -f -a &&
-git diff-files | diff - /dev/null'
+git diff-files --exit-code'
 
 test_done
diff --git a/t/t3408-rebase-multi-line.sh b/t/t3408-rebase-multi-line.sh
new file mode 100755 (executable)
index 0000000..e12cd57
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+test_description='rebasing a commit with multi-line first paragraph.'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+       >file &&
+       git add file &&
+       test_tick &&
+       git commit -m initial &&
+
+       echo hello >file &&
+       test_tick &&
+       git commit -a -m "A sample commit log message that has a long
+summary that spills over multiple lines.
+
+But otherwise with a sane description."
+
+       git branch side &&
+
+       git reset --hard HEAD^ &&
+       >elif &&
+       git add elif &&
+       test_tick &&
+       git commit -m second
+
+'
+
+test_expect_success rebase '
+
+       git checkout side &&
+       git rebase master &&
+       git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
+       git cat-file commit side@{1} | sed -e "1,/^$/d" >expect &&
+       test_cmp expect actual
+
+'
+
+test_done
index 0a7fea865d2be6e1a74e2016f336af22956de414..48ff2d424d1587bde388422da874feb3d55cbf0d 100755 (executable)
@@ -77,6 +77,16 @@ test_expect_success 'add another remote' '
 )
 '
 
+test_expect_success 'remote forces tracking branches' '
+(
+       cd test &&
+       case `git config remote.second.fetch` in
+       +*) true ;;
+        *) false ;;
+       esac
+)
+'
+
 test_expect_success 'remove remote' '
 (
        cd test &&
@@ -253,4 +263,10 @@ test_expect_success '"remote show" does not show symbolic refs' '
 
 '
 
+test_expect_success 'reject adding remote with an invalid name' '
+
+       ! git remote add some:url desired-name
+
+'
+
 test_done
index 6d7e7385483bda6223d8d222980bf33b2679f711..0a757d5b9fe660245ced7749e445eabd0369bcf0 100755 (executable)
@@ -209,19 +209,7 @@ test_expect_success 'push with weak ambiguity (2)' '
 
 '
 
-test_expect_success 'push with ambiguity (1)' '
-
-       mk_test remotes/origin/master remotes/frotz/master &&
-       if git push testrepo master:master
-       then
-               echo "Oops, should have failed"
-               false
-       else
-               check_push_result $the_first_commit remotes/origin/master remotes/frotz/master
-       fi
-'
-
-test_expect_success 'push with ambiguity (2)' '
+test_expect_success 'push with ambiguity' '
 
        mk_test heads/frotz tags/frotz &&
        if git push testrepo master:frotz
@@ -285,6 +273,37 @@ test_expect_success 'push with colon-less refspec (4)' '
 
 '
 
+test_expect_success 'push head with non-existant, incomplete dest' '
+
+       mk_test &&
+       git push testrepo master:branch &&
+       check_push_result $the_commit heads/branch
+
+'
+
+test_expect_success 'push tag with non-existant, incomplete dest' '
+
+       mk_test &&
+       git tag -f v1.0 &&
+       git push testrepo v1.0:tag &&
+       check_push_result $the_commit tags/tag
+
+'
+
+test_expect_success 'push sha1 with non-existant, incomplete dest' '
+
+       mk_test &&
+       test_must_fail git push testrepo `git rev-parse master`:foo
+
+'
+
+test_expect_success 'push ref expression with non-existant, incomplete dest' '
+
+       mk_test &&
+       test_must_fail git push testrepo master^:branch
+
+'
+
 test_expect_success 'push with HEAD' '
 
        mk_test heads/master &&
@@ -323,6 +342,15 @@ test_expect_success 'push with +HEAD' '
 
 '
 
+test_expect_success 'push HEAD with non-existant, incomplete dest' '
+
+       mk_test &&
+       git checkout master &&
+       git push testrepo HEAD:branch &&
+       check_push_result $the_commit heads/branch
+
+'
+
 test_expect_success 'push with config remote.*.push = HEAD' '
 
        mk_test heads/local &&
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
new file mode 100755 (executable)
index 0000000..dc9d63d
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+test_description=clone
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+       rm -fr .git &&
+       test_create_repo src &&
+       (
+               cd src
+               >file
+               git add file
+               git commit -m initial
+       )
+
+'
+
+test_expect_success 'clone with excess parameters' '
+
+       test_must_fail git clone -n "file://$(pwd)/src" dst junk
+
+'
+
+test_done
index 32d6118183c20e90aca115f8feda9e3c72f94eaf..5e3e5445c730140ad6c2fa9cc5bda4a7029e7fbf 100755 (executable)
@@ -71,8 +71,12 @@ test_expect_success 'bisect start with one bad and good' '
        git bisect next
 '
 
-test_expect_success 'bisect good and bad fails if not given only revs' '
+test_expect_success 'bisect fails if given any junk instead of revs' '
        git bisect reset &&
+       test_must_fail git bisect start foo $HASH1 -- &&
+       test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
+       test -z "$(git for-each-ref "refs/bisect/*")" &&
+       test_must_fail ls .git/BISECT_* &&
        git bisect start &&
        test_must_fail git bisect good foo $HASH1 &&
        test_must_fail git bisect good $HASH1 bar &&
@@ -80,6 +84,7 @@ test_expect_success 'bisect good and bad fails if not given only revs' '
        test_must_fail git bisect bad $HASH3 $HASH4 &&
        test_must_fail git bisect skip bar $HASH3 &&
        test_must_fail git bisect skip $HASH1 foo &&
+       test -z "$(git for-each-ref "refs/bisect/*")" &&
        git bisect good $HASH1 &&
        git bisect bad $HASH4
 '
index afccfc9973ba864167387b1e1caf6fe8b12f68f9..a50492f7c065d034cb344eac965d51a82cb5a599 100755 (executable)
@@ -75,8 +75,8 @@ test_expect_success 'git-clean src/ src/' '
 
 test_expect_success 'git-clean with prefix' '
 
-       mkdir -p build docs &&
-       touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+       mkdir -p build docs src/test &&
+       touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
        (cd src/ && git-clean) &&
        test -f Makefile &&
        test -f README &&
@@ -84,6 +84,7 @@ test_expect_success 'git-clean with prefix' '
        test -f src/part2.c &&
        test -f a.out &&
        test ! -f src/part3.c &&
+       test -f src/test/1.c &&
        test -f docs/manual.txt &&
        test -f obj.o &&
        test -f build/lib.so
index b9a22190e86a0b8718b215771352ecefbdf86edc..bf12dbdeef6e307850a91eb6be5ebe537b2de0c8 100755 (executable)
@@ -192,4 +192,17 @@ test_expect_success 'given commit' "
 EOF
 "
 
+test_expect_success '--for-status' "
+    git submodule summary --for-status HEAD^ >actual &&
+    test_cmp actual - <<EOF
+# Modified submodules:
+#
+# * sm1 $head6...0000000:
+#
+# * sm2 0000000...$head7 (2):
+#   > Add foo9
+#
+EOF
+"
+
 test_done
index cd08516e6de6b5c4b39ffee14302d76c99229825..e4bfcaece0c3ac4ea4b33521e84bd7fc1c19422e 100755 (executable)
@@ -149,4 +149,138 @@ test_expect_success 'status of partial commit excluding new file in index' '
        test_cmp expect output
 '
 
+test_expect_success 'setup status submodule summary' '
+       test_create_repo sm && (
+               cd sm &&
+               >foo &&
+               git add foo &&
+               git commit -m "Add foo"
+       ) &&
+       git add sm
+'
+
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+#   (use "git reset HEAD <file>..." to unstage)
+#
+#      new file:   dir2/added
+#      new file:   sm
+#
+# Changed but not updated:
+#   (use "git add <file>..." to update what will be committed)
+#
+#      modified:   dir1/modified
+#
+# Untracked files:
+#   (use "git add <file>..." to include in what will be committed)
+#
+#      dir1/untracked
+#      dir2/modified
+#      dir2/untracked
+#      expect
+#      output
+#      untracked
+EOF
+test_expect_success 'status submodule summary is disabled by default' '
+       git status >output &&
+       test_cmp expect output
+'
+
+head=$(cd sm && git rev-parse --short=7 --verify HEAD)
+
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+#   (use "git reset HEAD <file>..." to unstage)
+#
+#      new file:   dir2/added
+#      new file:   sm
+#
+# Changed but not updated:
+#   (use "git add <file>..." to update what will be committed)
+#
+#      modified:   dir1/modified
+#
+# Modified submodules:
+#
+# * sm 0000000...$head (1):
+#   > Add foo
+#
+# Untracked files:
+#   (use "git add <file>..." to include in what will be committed)
+#
+#      dir1/untracked
+#      dir2/modified
+#      dir2/untracked
+#      expect
+#      output
+#      untracked
+EOF
+test_expect_success 'status submodule summary' '
+       git config status.submodulesummary 10 &&
+       git status >output &&
+       test_cmp expect output
+'
+
+
+cat >expect <<EOF
+# On branch master
+# Changed but not updated:
+#   (use "git add <file>..." to update what will be committed)
+#
+#      modified:   dir1/modified
+#
+# Untracked files:
+#   (use "git add <file>..." to include in what will be committed)
+#
+#      dir1/untracked
+#      dir2/modified
+#      dir2/untracked
+#      expect
+#      output
+#      untracked
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
+test_expect_success 'status submodule summary (clean submodule)' '
+       git commit -m "commit submodule" &&
+       git config status.submodulesummary 10 &&
+       test_must_fail git status >output &&
+       test_cmp expect output
+'
+
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+#   (use "git reset HEAD^1 <file>..." to unstage)
+#
+#      new file:   dir2/added
+#      new file:   sm
+#
+# Changed but not updated:
+#   (use "git add <file>..." to update what will be committed)
+#
+#      modified:   dir1/modified
+#
+# Modified submodules:
+#
+# * sm 0000000...$head (1):
+#   > Add foo
+#
+# Untracked files:
+#   (use "git add <file>..." to include in what will be committed)
+#
+#      dir1/untracked
+#      dir2/modified
+#      dir2/untracked
+#      expect
+#      output
+#      untracked
+EOF
+test_expect_success 'status submodule summary (--amend)' '
+       git config status.submodulesummary 10 &&
+       git status --amend >output &&
+       test_cmp expect output
+'
+
 test_done
index 796cd7dba0cdc64e6b9e68e81663e9a70327d8e5..061a2596d3b63e7d737d735c4a6cb097bfcf387f 100755 (executable)
@@ -483,6 +483,22 @@ test_expect_success \
        'gitweb_run "p=.git;a=history;f=file"'
 test_debug 'cat gitweb.log'
 
+test_expect_success \
+       'logs: history (implicit HEAD, non-existent file)' \
+       'gitweb_run "p=.git;a=history;f=non-existent"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'logs: history (implicit HEAD, deleted file)' \
+       'git checkout master &&
+        echo "to be deleted" > deleted_file &&
+        git add deleted_file &&
+        git commit -m "Add file to be deleted" &&
+        git rm deleted_file &&
+        git commit -m "Delete file" &&
+        gitweb_run "p=.git;a=history;f=deleted_file"'
+test_debug 'cat gitweb.log'
+
 # ----------------------------------------------------------------------
 # feed generation
 
index e125e11d3b63e3dab9077d7b414e83e7ff7d16ad..32f99140205f8969d8a884b3cf9448eec3f1dd16 100644 (file)
@@ -40,7 +40,7 @@ void maybe_flush_or_die(FILE *f, const char *desc)
        }
 }
 
-int read_in_full(int fd, void *buf, size_t count)
+ssize_t read_in_full(int fd, void *buf, size_t count)
 {
        char *p = buf;
        ssize_t total = 0;
@@ -57,7 +57,7 @@ int read_in_full(int fd, void *buf, size_t count)
        return total;
 }
 
-int write_in_full(int fd, const void *buf, size_t count)
+ssize_t write_in_full(int fd, const void *buf, size_t count)
 {
        const char *p = buf;
        ssize_t total = 0;
index b3fd57b79df3513d271c23caf3ab46b3ba405e40..532b4ea2c1960f18e41a5167a60f6de1b481606b 100644 (file)
@@ -8,9 +8,11 @@
 #include "revision.h"
 #include "diffcore.h"
 #include "quote.h"
+#include "run-command.h"
 
 int wt_status_relative_paths = 1;
 int wt_status_use_color = -1;
+int wt_status_submodule_summary;
 static char wt_status_colors[][COLOR_MAXLEN] = {
        "",         /* WT_STATUS_HEADER: normal */
        "\033[32m", /* WT_STATUS_UPDATED: green */
@@ -220,6 +222,36 @@ static void wt_status_print_changed(struct wt_status *s)
        run_diff_files(&rev, 0);
 }
 
+static void wt_status_print_submodule_summary(struct wt_status *s)
+{
+       struct child_process sm_summary;
+       char summary_limit[64];
+       char index[PATH_MAX];
+       const char *env[] = { index, NULL };
+       const char *argv[] = {
+               "submodule",
+               "summary",
+               "--cached",
+               "--for-status",
+               "--summary-limit",
+               summary_limit,
+               s->amend ? "HEAD^" : "HEAD",
+               NULL
+       };
+
+       sprintf(summary_limit, "%d", wt_status_submodule_summary);
+       snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
+
+       memset(&sm_summary, 0, sizeof(sm_summary));
+       sm_summary.argv = argv;
+       sm_summary.env = env;
+       sm_summary.git_cmd = 1;
+       sm_summary.no_stdin = 1;
+       fflush(s->fp);
+       sm_summary.out = dup(fileno(s->fp));    /* run_command closes it */
+       run_command(&sm_summary);
+}
+
 static void wt_status_print_untracked(struct wt_status *s)
 {
        struct dir_struct dir;
@@ -308,6 +340,8 @@ void wt_status_print(struct wt_status *s)
        }
 
        wt_status_print_changed(s);
+       if (wt_status_submodule_summary)
+               wt_status_print_submodule_summary(s);
        wt_status_print_untracked(s);
 
        if (s->verbose && !s->is_initial)
@@ -330,6 +364,13 @@ void wt_status_print(struct wt_status *s)
 
 int git_status_config(const char *k, const char *v)
 {
+       if (!strcmp(k, "status.submodulesummary")) {
+               int is_bool;
+               wt_status_submodule_summary = git_config_bool_or_int(k, v, &is_bool);
+               if (is_bool && wt_status_submodule_summary)
+                       wt_status_submodule_summary = -1;
+               return 0;
+       }
        if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
                wt_status_use_color = git_config_colorbool(k, v, -1);
                return 0;