Merge branch 'pb/prepare-commit-msg'
authorJunio C Hamano <gitster@pobox.com>
Sun, 17 Feb 2008 01:56:59 +0000 (17:56 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 17 Feb 2008 01:56:59 +0000 (17:56 -0800)
* pb/prepare-commit-msg:
  git-commit: add a prepare-commit-msg hook
  git-commit: Refactor creation of log message.
  git-commit: set GIT_EDITOR=: if editor will not be launched
  git-commit: support variable number of hook arguments

128 files changed:
.gitattributes [new file with mode: 0644]
.mailmap
Documentation/.gitattributes [new file with mode: 0644]
Documentation/SubmittingPatches
Documentation/blame-options.txt
Documentation/config.txt
Documentation/git-branch.txt
Documentation/git-checkout.txt
Documentation/git-clone.txt
Documentation/git-cvsimport.txt
Documentation/git-describe.txt
Documentation/git-fast-import.txt
Documentation/git-pack-objects.txt
Documentation/git-pull.txt
Documentation/git-reset.txt
Documentation/git-send-email.txt
Documentation/git-svn.txt
Documentation/git.txt
INSTALL
archive-tar.c
attr.c
builtin-apply.c
builtin-blame.c
builtin-branch.c
builtin-commit.c
builtin-config.c
builtin-describe.c
builtin-fetch-pack.c
builtin-fetch.c
builtin-fsck.c
builtin-gc.c
builtin-grep.c
builtin-log.c
builtin-ls-files.c
builtin-ls-remote.c
builtin-mailinfo.c
builtin-name-rev.c
builtin-pack-objects.c
builtin-prune.c
builtin-read-tree.c
builtin-reflog.c
builtin-rerere.c
builtin-revert.c
builtin-show-branch.c
builtin-tag.c
builtin-update-index.c
builtin-write-tree.c
builtin.h
cache-tree.c
cache-tree.h
cache.h
color.c
config.c
connect.c
contrib/completion/git-completion.bash
contrib/emacs/git-blame.el
contrib/emacs/git.el
contrib/fast-import/git-p4
contrib/hg-to-git/hg-to-git.py
convert.c
diff-lib.c
diff.c
dir.c
entry.c
environment.c
fast-import.c
fetch-pack.h
git-bisect.sh
git-cvsexportcommit.perl
git-cvsimport.perl
git-filter-branch.sh
git-gui/Makefile
git-gui/git-gui.sh
git-gui/lib/about.tcl
git-gui/lib/checkout_op.tcl
git-gui/lib/commit.tcl
git-gui/lib/index.tcl
git-gui/lib/merge.tcl
git-gui/lib/option.tcl
git-gui/lib/spellcheck.tcl [new file with mode: 0644]
git-gui/macosx/Info.plist
git-gui/po/de.po
git-gui/po/git-gui.pot
git-help--browse.sh
git-rebase--interactive.sh
git-remote.perl
git-send-email.perl
git-sh-setup.sh
git-svn.perl
git.c
gitk-git/gitk
gitweb/gitweb.perl
help.c
http.c
imap-send.c
merge-index.c
merge-recursive.c
reachable.c
read-cache.c
remote.c
setup.c
sha1_name.c
t/.gitattributes [new file with mode: 0644]
t/t0000-basic.sh
t/t0003-attributes.sh [new file with mode: 0755]
t/t1300-repo-config.sh
t/t1500-rev-parse.sh
t/t3404-rebase-interactive.sh
t/t4015-diff-whitespace.sh
t/t4026-color.sh [new file with mode: 0755]
t/t5100-mailinfo.sh
t/t5100/info0009 [new file with mode: 0644]
t/t5100/msg0009 [new file with mode: 0644]
t/t5100/patch0009 [new file with mode: 0644]
t/t5100/sample.mbox
t/t5300-pack-object.sh
t/t5304-prune.sh [new file with mode: 0644]
t/t6030-bisect-porcelain.sh
t/t7003-filter-branch.sh
t/t7502-status.sh
t/t9200-git-cvsexportcommit.sh
t/test-lib.sh
transport.c
tree.c
unpack-trees.c
unpack-trees.h
upload-pack.c
wt-status.c

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..6b9c715
--- /dev/null
@@ -0,0 +1,2 @@
+* whitespace=!indent,trail,space
+*.[ch] whitespace
index 695739ea704ae1530a5b0a31d60c5eabba70a89c..a32d9e2a3f95a4d6cdfb050f2454e31192dea34e 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -43,6 +43,7 @@ Steven Grimm <koreth@midwinter.com>
 Theodore Ts'o <tytso@mit.edu>
 Tony Luck <tony.luck@intel.com>
 Uwe Kleine-König <Uwe_Zeisberger@digi.com>
+Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
 Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
 Uwe Kleine-König <uzeisberger@io.fsforth.de>
 Uwe Kleine-König <zeisberg@informatik.uni-freiburg.de>
diff --git a/Documentation/.gitattributes b/Documentation/.gitattributes
new file mode 100644 (file)
index 0000000..ddb0301
--- /dev/null
@@ -0,0 +1 @@
+*.txt whitespace
index de08d094e3e3683913bac49f643bb6b49fbec04d..0e155c936c25255706bc6d47651c2b336c628417 100644 (file)
@@ -34,9 +34,9 @@ Checklist (and a short version for the impatient):
        - if your name is not writable in ASCII, make sure that
          you send off a message in the correct encoding.
        - send the patch to the list (git@vger.kernel.org) and the
-         maintainer (gitster@pobox.com). If you use
-         git-send-email(1), please test it first by sending
-         email to yourself.
+         maintainer (gitster@pobox.com) if (and only if) the patch
+         is ready for inclusion. If you use git-send-email(1),
+         please test it first by sending email to yourself.
 
 Long version:
 
@@ -112,7 +112,12 @@ lose tabs that way if you are not careful.
 
 It is a common convention to prefix your subject line with
 [PATCH].  This lets people easily distinguish patches from other
-e-mail discussions.
+e-mail discussions.  Use of additional markers after PATCH and
+the closing bracket to mark the nature of the patch is also
+encouraged.  E.g. [PATCH/RFC] is often used when the patch is
+not ready to be applied but it is for discussion, [PATCH v2],
+[PATCH v3] etc. are often seen when you are sending an update to
+what you have previously sent.
 
 "git format-patch" command follows the best current practice to
 format the body of an e-mail message.  At the beginning of the
@@ -157,7 +162,8 @@ Note that your maintainer does not necessarily read everything
 on the git mailing list.  If your patch is for discussion first,
 send it "To:" the mailing list, and optionally "cc:" him.  If it
 is trivially correct or after the list reached a consensus, send
-it "To:" the maintainer and optionally "cc:" the list.
+it "To:" the maintainer and optionally "cc:" the list for
+inclusion.
 
 Also note that your maintainer does not actively involve himself in
 maintaining what are in contrib/ hierarchy.  When you send fixes and
@@ -210,10 +216,53 @@ then you just add a line saying
 This line can be automatically added by git if you run the git-commit
 command with the -s option.
 
-Some people also put extra tags at the end.  They'll just be ignored for
-now, but you can do this to mark internal company procedures or just
-point out some special detail about the sign-off.
+Notice that you can place your own Signed-off-by: line when
+forwarding somebody else's patch with the above rules for
+D-C-O.  Indeed you are encouraged to do so.  Do not forget to
+place an in-body "From: " line at the beginning to properly attribute
+the change to its true author (see (2) above).
 
+Some people also put extra tags at the end.
+
+"Acked-by:" says that the patch was reviewed by the person who
+is more familiar with the issues and the area the patch attempts
+to modify.  "Tested-by:" says the patch was tested by the person
+and found to have the desired effect.
+
+------------------------------------------------
+An ideal patch flow
+
+Here is an ideal patch flow for this project the current maintainer
+suggests to the contributors:
+
+ (0) You come up with an itch.  You code it up.
+
+ (1) Send it to the list and cc people who may need to know about
+     the change.
+
+     The people who may need to know are the ones whose code you
+     are butchering.  These people happen to be the ones who are
+     most likely to be knowledgeable enough to help you, but
+     they have no obligation to help you (i.e. you ask for help,
+     don't demand).  "git log -p -- $area_you_are_modifying" would
+     help you find out who they are.
+
+ (2) You get comments and suggestions for improvements.  You may
+     even get them in a "on top of your change" patch form.
+
+ (3) Polish, refine, and re-send to the list and the people who
+     spend their time to improve your patch.  Go back to step (2).
+
+ (4) The list forms consensus that the last round of your patch is
+     good.  Send it to the list and cc the maintainer.
+
+ (5) A topic branch is created with the patch and is merged to 'next',
+     and cooked further and eventually graduates to 'master'.
+
+In any time between the (2)-(3) cycle, the maintainer may pick it up
+from the list and queue it to 'pu', in order to make it easier for
+people play with it without having to pick up and apply the patch to
+their trees themselves.
 
 ------------------------------------------------
 MUA specific hints
index ea1007bfb0e759a7b3704c8d44270023cb78dc6b..c11bb7d36c39899d782f8c2d3f87b5a59178840a 100644 (file)
@@ -52,7 +52,7 @@ of lines before or after the line given by <start>.
        When <rev> is not specified, the command annotates the
        changes starting backwards from the working tree copy.
        This flag makes the command pretend as if the working
-       tree copy has the contents of he named file (specify
+       tree copy has the contents of the named file (specify
        `-` to make the command read from the standard input).
 
 -M|<num>|::
index 4e222f15a5b2b84eb5d55bc79c605510bd89b7b6..f9bdb164e054ec2d633baab3da69ddd47e14931f 100644 (file)
@@ -333,7 +333,7 @@ branch.autosetupmerge::
        so that linkgit:git-pull[1] will appropriately merge from that
        remote branch.  Note that even if this option is not set,
        this behavior can be chosen per-branch using the `--track`
-       and `--no-track` options.  This option defaults to false.
+       and `--no-track` options.  This option defaults to true.
 
 branch.<name>.remote::
        When in branch <name>, it tells `git fetch` which remote to fetch.
@@ -766,6 +766,12 @@ pack.indexVersion::
        whenever the corresponding pack is larger than 2 GB.  Otherwise
        the default is 1.
 
+pack.packSizeLimit:
+       The default maximum size of a pack.  This setting only affects
+       packing to a file, i.e. the git:// protocol is unaffected.  It
+       can be overridden by the `\--max-pack-size` option of
+       linkgit:git-repack[1].
+
 pull.octopus::
        The default merge strategy to use when pulling multiple branches
        at once.
index f920c04cc01e1d8a8675876adcb747f91ed86f30..7e8874acaacbd6990ccaf66d5bddbff6e4c1e5ba 100644 (file)
@@ -34,11 +34,11 @@ Note that this will create the new branch, but it will not switch the
 working tree to it; use "git checkout <newbranch>" to switch to the
 new branch.
 
-When a local branch is started off a remote branch, git can setup the
+When a local branch is started off a remote branch, git sets up the
 branch so that linkgit:git-pull[1] will appropriately merge from that
-remote branch.  If this behavior is desired, it is possible to make it
-the default using the global `branch.autosetupmerge` configuration
-flag.  Otherwise, it can be chosen per-branch using the `--track`
+remote branch.  If this behavior is not desired, it is possible to
+disable it using the global `branch.autosetupmerge` configuration
+flag.  That setting can be overridden by using the `--track`
 and `--no-track` options.
 
 With a '-m' or '-M' option, <oldbranch> will be renamed to <newbranch>.
@@ -108,10 +108,11 @@ OPTIONS
        Set up configuration so that git-pull will automatically
        retrieve data from the remote branch.  Use this if you always
        pull from the same remote branch into the new branch, or if you
-       don't want to use "git pull <repository> <refspec>" explicitly.  Set the
-       branch.autosetupmerge configuration variable to true if you
+       don't want to use "git pull <repository> <refspec>" explicitly.
+       This behavior is the default.  Set the
+       branch.autosetupmerge configuration variable to false if you
        want git-checkout and git-branch to always behave as if
-       '--track' were given.
+       '--no-track' were given.
 
 --no-track::
        When a branch is created off a remote branch,
index 584359ff3fdc4167b4af404ab92d34d3a057033c..b4cfa044bbb969add6f434070a8666fc0c325d15 100644 (file)
@@ -52,10 +52,11 @@ OPTIONS
        set up configuration so that git-pull will automatically
        retrieve data from the remote branch.  Use this if you always
        pull from the same remote branch into the new branch, or if you
-       don't want to use "git pull <repository> <refspec>" explicitly.  Set the
-       branch.autosetupmerge configuration variable to true if you
+       don't want to use "git pull <repository> <refspec>" explicitly.
+       This behavior is the default.  Set the
+       branch.autosetupmerge configuration variable to false if you
        want git-checkout and git-branch to always behave as if
-       '--track' were given.
+       '--no-track' were given.
 
 --no-track::
        When -b is given and a branch is created off a remote branch,
index 23418816146d0b65eeabdd7a3d67dcd7e8c760e1..975824301a45bfa297f2ecd5c19e429cb9c86c65 100644 (file)
@@ -62,12 +62,13 @@ OPTIONS
        .git/objects/info/alternates to share the objects
        with the source repository.  The resulting repository
        starts out without any object of its own.
-       *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.
++
+*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.
 
 
 
index dbce503694049ced5232423ffa11bb9a896e3c52..6f91b9ea2a17df8fc8e3c00fdf0d5c74a6c17950 100644 (file)
@@ -107,8 +107,8 @@ If you need to pass multiple options, separate them with a comma.
 
 -M <regex>::
        Attempt to detect merges based on the commit message with a custom
-       regex. It can be used with '-m' to also see the default regexes.
-       You must escape forward slashes.
+       regex. It can be used with '-m' to enable the default regexes
+       as well. You must escape forward slashes.
 
 -S <regex>::
        Skip paths matching the regex.
index 0742152b811e23ea304feb368c8d949785e2fdfb..1c3dfb40c63350651efb570ed540b69c34ccbc81 100644 (file)
@@ -51,6 +51,10 @@ OPTIONS
        being employed to standard error.  The tag name will still
        be printed to standard out.
 
+--match <pattern>::
+       Only consider tags matching the given pattern (can be used to avoid
+       leaking private tags made from the repository).
+
 EXAMPLES
 --------
 
index bd625ababfc950318714b3271b02da938fbf609b..96f6767075b4173b81acf3eb413f5e1a35acb940 100644 (file)
@@ -805,6 +805,93 @@ Placing a `progress` command immediately after a `checkpoint` will
 inform the reader when the `checkpoint` has been completed and it
 can safely access the refs that fast-import updated.
 
+Crash Reports
+-------------
+If fast-import is supplied invalid input it will terminate with a
+non-zero exit status and create a crash report in the top level of
+the Git repository it was importing into.  Crash reports contain
+a snapshot of the internal fast-import state as well as the most
+recent commands that lead up to the crash.
+
+All recent commands (including stream comments, file changes and
+progress commands) are shown in the command history within the crash
+report, but raw file data and commit messages are excluded from the
+crash report.  This exclusion saves space within the report file
+and reduces the amount of buffering that fast-import must perform
+during execution.
+
+After writing a crash report fast-import will close the current
+packfile and export the marks table.  This allows the frontend
+developer to inspect the repository state and resume the import from
+the point where it crashed.  The modified branches and tags are not
+updated during a crash, as the import did not complete successfully.
+Branch and tag information can be found in the crash report and
+must be applied manually if the update is needed.
+
+An example crash:
+
+====
+       $ cat >in <<END_OF_INPUT
+       # my very first test commit
+       commit refs/heads/master
+       committer Shawn O. Pearce <spearce> 19283 -0400
+       # who is that guy anyway?
+       data <<EOF
+       this is my commit
+       EOF
+       M 644 inline .gitignore
+       data <<EOF
+       .gitignore
+       EOF
+       M 777 inline bob
+       END_OF_INPUT
+
+       $ git-fast-import <in
+       fatal: Corrupt mode: M 777 inline bob
+       fast-import: dumping crash report to .git/fast_import_crash_8434
+
+       $ cat .git/fast_import_crash_8434
+       fast-import crash report:
+           fast-import process: 8434
+           parent process     : 1391
+           at Sat Sep 1 00:58:12 2007
+
+       fatal: Corrupt mode: M 777 inline bob
+
+       Most Recent Commands Before Crash
+       ---------------------------------
+         # my very first test commit
+         commit refs/heads/master
+         committer Shawn O. Pearce <spearce> 19283 -0400
+         # who is that guy anyway?
+         data <<EOF
+         M 644 inline .gitignore
+         data <<EOF
+       * M 777 inline bob
+
+       Active Branch LRU
+       -----------------
+           active_branches = 1 cur, 5 max
+
+         pos  clock name
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+          1)      0 refs/heads/master
+
+       Inactive Branches
+       -----------------
+       refs/heads/master:
+         status      : active loaded dirty
+         tip commit  : 0000000000000000000000000000000000000000
+         old tree    : 0000000000000000000000000000000000000000
+         cur tree    : 0000000000000000000000000000000000000000
+         commit clock: 0
+         last pack   :
+
+
+       -------------------
+       END OF CRASH REPORT
+====
+
 Tips and Tricks
 ---------------
 The following tips and tricks have been collected from various
index 74cc7c1cb831c700c14406f6e306e7a3002054d2..8353be186fcc83092acac16b4fc164d6ea669621 100644 (file)
@@ -99,7 +99,8 @@ base-name::
 --max-pack-size=<n>::
        Maximum size of each output packfile, expressed in MiB.
        If specified,  multiple packfiles may be created.
-       The default is unlimited.
+       The default is unlimited, unless the config variable
+       `pack.packSizeLimit` is set.
 
 --incremental::
        This flag causes an object already in a pack ignored
index 4cc633a5ec4c449e98ac9cb16fd125da6d336798..179bdfc69ddfeff9d272ec309721e4098f3b051e 100644 (file)
@@ -39,11 +39,11 @@ include::merge-strategies.txt[]
        there is a remote ref for the upstream branch, and this branch
        was rebased since last fetched, the rebase uses that information
        to avoid rebasing non-local changes.
-
-       *NOTE:* This is a potentially _dangerous_ mode of operation.
-       It rewrites history, which does not bode well when you
-       published that history already.  Do *not* use this option
-       unless you have read linkgit:git-rebase[1] carefully.
++
+*NOTE:* This is a potentially _dangerous_ mode of operation.
+It rewrites history, which does not bode well when you
+published that history already.  Do *not* use this option
+unless you have read linkgit:git-rebase[1] carefully.
 
 \--no-rebase::
        Override earlier \--rebase.
index a4e0a779de6a8e2de7ec9012bc66f15ca351e2aa..fac59c972659111aa2bba365c6aba94577d95702 100644 (file)
@@ -8,8 +8,8 @@ git-reset - Reset current HEAD to the specified state
 SYNOPSIS
 --------
 [verse]
-'git-reset' [--mixed | --soft | --hard] [-q] [<commit>]
-'git-reset' [--mixed] [-q] [<commit>] [--] <paths>...
+'git reset' [--mixed | --soft | --hard] [-q] [<commit>]
+'git reset' [-q] [<commit>] [--] <paths>...
 
 DESCRIPTION
 -----------
@@ -37,7 +37,7 @@ OPTIONS
 --soft::
        Does not touch the index file nor the working tree at all, but
        requires them to be in a good order. This leaves all your changed
-       files "Added but not yet committed", as linkgit:git-status[1] would
+       files "Changes to be committed", as linkgit:git-status[1] would
        put it.
 
 --hard::
@@ -176,6 +176,23 @@ $ git reset                                       <3>
     committed as 'snapshot WIP'.  This updates the index to show your
     WIP files as uncommitted.
 
+Reset a single file in the index::
++
+Suppose you have added a file to your index, but later decide you do not
+want to add it to your commit. You can remove the file from the index
+while keeping your changes with git reset.
++
+------------
+$ git reset -- frotz.c                      <1>
+$ git commit -m "Commit files in index"     <2>
+$ git add frotz.c                           <3>
+------------
++
+<1> This removes the file from the index while keeping it in the working
+    directory.
+<2> This commits all other changes in the index.
+<3> Adds the file to the index again.
+
 Author
 ------
 Written by Junio C Hamano <junkio@cox.net> and Linus Torvalds <torvalds@osdl.org>
index 0554f2b3741bef4213bf7197bf1bb6335c1268c4..336d797e80f5d2cc21b633588b3a3461a991ca71 100644 (file)
@@ -96,11 +96,40 @@ The --cc option must be repeated for each user you want on the cc list.
        servers typically listen to smtp port 25 and ssmtp port
        465).
 
---smtp-user, --smtp-pass::
-       Username and password for SMTP-AUTH. Defaults are the values of
-       the configuration values 'sendemail.smtpuser' and
-       'sendemail.smtppass', but see also 'sendemail.identity'.
-       If not set, authentication is not attempted.
+--smtp-user::
+       Username for SMTP-AUTH. In place of this option, the following
+       configuration variables can be specified:
++
+--
+               * sendemail.smtpuser
+               * sendemail.<identity>.smtpuser (see sendemail.identity).
+--
++
+However, --smtp-user always overrides these variables.
++
+If a username is not specified (with --smtp-user or a
+configuration variable), then authentication is not attempted.
+
+--smtp-pass::
+       Password for SMTP-AUTH. The argument is optional: If no
+       argument is specified, then the empty string is used as
+       the password.
++
+In place of this option, the following configuration variables
+can be specified:
++
+--
+               * sendemail.smtppass
+               * sendemail.<identity>.smtppass (see sendemail.identity).
+--
++
+However, --smtp-pass always overrides these variables.
++
+Furthermore, passwords need not be specified in configuration files
+or on the command line. If a username has been specified (with
+--smtp-user or a configuration variable), but no password has been
+specified (with --smtp-pass or a configuration variable), then the
+user is prompted for a password while the input is masked for privacy.
 
 --smtp-ssl::
        If set, connects to the SMTP server using SSL.
@@ -117,6 +146,17 @@ The --cc option must be repeated for each user you want on the cc list.
         Default is the value of 'sendemail.suppressfrom' configuration value;
         if that is unspecified, default to --no-suppress-from.
 
+--suppress-cc::
+       Specify an additional category of recipients to suppress the
+       auto-cc of.  'self' will avoid including the sender, 'author' will
+       avoid including the patch author, 'cc' will avoid including anyone
+       mentioned in Cc lines in the patch, 'sob' will avoid including
+       anyone mentioned in Signed-off-by lines, and 'cccmd' will avoid
+       running the --cc-cmd.  'all' will suppress all auto cc values.
+       Default is the value of 'sendemail.suppresscc' configuration value;
+       if that is unspecified, default to 'self' if --suppress-from is
+       specified, as well as 'sob' if --no-signed-off-cc is specified.
+
 --thread, --no-thread::
        If this is set, the In-Reply-To header will be set on each email sent.
        If disabled with "--no-thread", no emails will have the In-Reply-To
index b1d527f74cd72a7c749f1067a91a6d2c6b6235d3..340f1be02a21495182584b0c09512a8608c1a61a 100644 (file)
@@ -161,6 +161,13 @@ New features:
 +
 Any other arguments are passed directly to `git log'
 
+'blame'::
+       Show what revision and author last modified each line of a file. This is
+       identical to `git blame', but SVN revision numbers are shown instead of git
+       commit hashes.
++
+All arguments are passed directly to `git blame'.
+
 --
 'find-rev'::
        When given an SVN revision number of the form 'rN', returns the
index 17aee93ec5c89e1f1d0d499acaf08bf3cc300662..e22c4c4ae9c9b1cefca1c4c64ae03562bc3f301b 100644 (file)
@@ -43,9 +43,10 @@ unreleased) version of git, that is available from 'master'
 branch of the `git.git` repository.
 Documentation for older releases are available here:
 
-* link:v1.5.4/git.html[documentation for release 1.5.4]
+* link:v1.5.4.1/git.html[documentation for release 1.5.4.1]
 
 * release notes for
+  link:RelNotes-1.5.4.1.txt[1.5.4.1],
   link:RelNotes-1.5.4.txt[1.5.4].
 
 * link:v1.5.3.8/git.html[documentation for release 1.5.3.8]
diff --git a/INSTALL b/INSTALL
index f1eb4049b9f839c1b3d1aa5a4d7387d0e93f0f5c..6f3bcb45253367e0bf7fc8e43e45ccb404b23824 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -79,8 +79,8 @@ Issues of note:
        - "perl" and POSIX-compliant shells are needed to use most of
          the barebone Porcelainish scripts.
 
-       - "cpio" is used by git-merge for saving and restoring the index,
-         and by git-clone when doing a local (possibly hardlinked) clone.
+       - "cpio" is used by git-clone when doing a local (possibly
+         hardlinked) clone.
 
  - Some platform specific issues are dealt with Makefile rules,
    but depending on your specific installation, you may not
index e1bced56093dc08bbc260736637af3356b8598bb..30aa2e23fdbb1630dffb27db4509bc529bbd884a 100644 (file)
@@ -222,7 +222,7 @@ static void write_global_extended_header(const unsigned char *sha1)
 static int git_tar_config(const char *var, const char *value)
 {
        if (!strcmp(var, "tar.umask")) {
-               if (!strcmp(value, "user")) {
+               if (value && !strcmp(value, "user")) {
                        tar_umask = umask(0);
                        umask(tar_umask);
                } else {
diff --git a/attr.c b/attr.c
index 741db3b468c6a6ebbcd1414e42b4ef7d6ab3cc9d..64b77b16636482d3448027d7823e5dc07861faa5 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -406,7 +406,7 @@ static void debug_info(const char *what, struct attr_stack *elem)
 {
        fprintf(stderr, "%s: %s\n", what, elem->origin ? elem->origin : "()");
 }
-static void debug_set(const char *what, const char *match, struct git_attr *attr, void *v)
+static void debug_set(const char *what, const char *match, struct git_attr *attr, const void *v)
 {
        const char *value = v;
 
@@ -543,10 +543,10 @@ static int path_matches(const char *pathname, int pathlen,
        if (*pattern == '/')
                pattern++;
        if (pathlen < baselen ||
-           (baselen && pathname[baselen - 1] != '/') ||
+           (baselen && pathname[baselen] != '/') ||
            strncmp(pathname, base, baselen))
                return 0;
-       return fnmatch(pattern, pathname + baselen, FNM_PATHNAME) == 0;
+       return fnmatch(pattern, pathname + baselen + 1, FNM_PATHNAME) == 0;
 }
 
 static int fill_one(const char *what, struct match_attr *a, int rem)
index 15432b6782400b556333ee4117c7daaff20412ab..46dad5b2a1ce6d70d540df8a40da94702dde68c7 100644 (file)
@@ -1946,7 +1946,7 @@ static int read_file_or_gitlink(struct cache_entry *ce, struct strbuf *buf)
        if (!ce)
                return 0;
 
-       if (S_ISGITLINK(ntohl(ce->ce_mode))) {
+       if (S_ISGITLINK(ce->ce_mode)) {
                strbuf_grow(buf, 100);
                strbuf_addf(buf, "Subproject commit %s\n", sha1_to_hex(ce->sha1));
        } else {
@@ -2023,7 +2023,7 @@ static int check_to_create_blob(const char *new_name, int ok_if_exists)
 
 static int verify_index_match(struct cache_entry *ce, struct stat *st)
 {
-       if (S_ISGITLINK(ntohl(ce->ce_mode))) {
+       if (S_ISGITLINK(ce->ce_mode)) {
                if (!S_ISDIR(st->st_mode))
                        return -1;
                return 0;
@@ -2082,12 +2082,12 @@ static int check_patch(struct patch *patch, struct patch *prev_patch)
                                return error("%s: does not match index",
                                             old_name);
                        if (cached)
-                               st_mode = ntohl(ce->ce_mode);
+                               st_mode = ce->ce_mode;
                } else if (stat_ret < 0)
                        return error("%s: %s", old_name, strerror(errno));
 
                if (!cached)
-                       st_mode = ntohl(ce_mode_from_stat(ce, st.st_mode));
+                       st_mode = ce_mode_from_stat(ce, st.st_mode);
 
                if (patch->is_new < 0)
                        patch->is_new = 0;
@@ -2388,7 +2388,7 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
        ce = xcalloc(1, ce_size);
        memcpy(ce->name, path, namelen);
        ce->ce_mode = create_ce_mode(mode);
-       ce->ce_flags = htons(namelen);
+       ce->ce_flags = namelen;
        if (S_ISGITLINK(mode)) {
                const char *s = buf;
 
@@ -2746,6 +2746,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;
        }
index 9b4c02e87f7ef4a20d269ab9315b6977cf7fb3fb..c7e68874e7f02ac150343ab6d7a0aa95601f2ba3 100644 (file)
@@ -2092,7 +2092,7 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
        if (!mode) {
                int pos = cache_name_pos(path, len);
                if (0 <= pos)
-                       mode = ntohl(active_cache[pos]->ce_mode);
+                       mode = active_cache[pos]->ce_mode;
                else
                        /* Let's not bother reading from HEAD tree */
                        mode = S_IFREG | 0644;
index 089cae59299659b20359b7249e57ddc3a43ded06..e414c8898317736d632064d6c0545d7d128c6bc8 100644 (file)
@@ -70,12 +70,15 @@ static int git_branch_config(const char *var, const char *value)
        }
        if (!prefixcmp(var, "color.branch.")) {
                int slot = parse_branch_color_slot(var, 13);
+               if (!value)
+                       return config_error_nonbool(var);
                color_parse(value, var, branch_colors[slot]);
                return 0;
        }
-       if (!strcmp(var, "branch.autosetupmerge"))
-                       branch_track = git_config_bool(var, value);
-
+       if (!strcmp(var, "branch.autosetupmerge")) {
+               branch_track = git_config_bool(var, value);
+               return 0;
+       }
        return git_default_config(var, value);
 }
 
index 03caa30f0e4232bb613f70a04fa2914385e2cd6f..6612b4f40504fea0cd9aec4463c20d8982bfbaeb 100644 (file)
@@ -160,7 +160,7 @@ static int list_paths(struct path_list *list, const char *with_tree,
 
        for (i = 0; i < active_nr; i++) {
                struct cache_entry *ce = active_cache[i];
-               if (ce->ce_flags & htons(CE_UPDATE))
+               if (ce->ce_flags & CE_UPDATE)
                        continue;
                if (!pathspec_match(pattern, m, ce->name, 0))
                        continue;
@@ -317,6 +317,10 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
        if (write_cache(fd, active_cache, active_nr) ||
            close_lock_file(&false_lock))
                die("unable to write temporary index file");
+
+       discard_cache();
+       read_cache_from(false_lock.filename);
+
        return false_lock.filename;
 }
 
@@ -819,6 +823,8 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 int git_commit_config(const char *k, const char *v)
 {
        if (!strcmp(k, "commit.template")) {
+               if (!v)
+                       return config_error_nonbool(v);
                template_file = xstrdup(v);
                return 0;
        }
@@ -966,6 +972,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
        unlink(git_path("MERGE_HEAD"));
        unlink(git_path("MERGE_MSG"));
+       unlink(git_path("SQUASH_MSG"));
 
        if (commit_index_files())
                die ("Repository has been updated, but unable to write\n"
index e4a12e316648e6b0ab1ee0b424773f3c672c751e..2b9a4261d4e98281855ce856041eb730565a4869 100644 (file)
@@ -79,9 +79,10 @@ static int get_value(const char* key_, const char* regex_)
                local = getenv(CONFIG_LOCAL_ENVIRONMENT);
                if (!local)
                        local = repo_config = xstrdup(git_path("config"));
-               if (home)
+               if (git_config_global() && home)
                        global = xstrdup(mkpath("%s/.gitconfig", home));
-               system_wide = git_etc_gitconfig();
+               if (git_config_system())
+                       system_wide = git_etc_gitconfig();
        }
 
        key = xstrdup(key_);
@@ -168,6 +169,8 @@ static char parsed_color[COLOR_MAXLEN];
 static int git_get_color_config(const char *var, const char *value)
 {
        if (!strcmp(var, get_color_slot)) {
+               if (!value)
+                       config_error_nonbool(var);
                color_parse(value, var, parsed_color);
                get_color_found = 1;
        }
index 7a148a2c26591d82e6057d610182445eae5fe171..3428483134156f4e1761aa47ed2e8098a294808c 100644 (file)
@@ -19,6 +19,7 @@ static int all;       /* Default to annotated tags only */
 static int tags;       /* But allow any tags if --tags is specified */
 static int abbrev = DEFAULT_ABBREV;
 static int max_candidates = 10;
+const char *pattern = NULL;
 
 struct commit_name {
        int prio; /* annotated tag = 2, tag = 1, head = 0 */
@@ -57,9 +58,11 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
         * Otherwise only annotated tags are used.
         */
        if (!prefixcmp(path, "refs/tags/")) {
-               if (object->type == OBJ_TAG)
+               if (object->type == OBJ_TAG) {
                        prio = 2;
-               else
+                       if (pattern && fnmatch(pattern, path + 10, 0))
+                               prio = 0;
+               } else
                        prio = 1;
        }
        else
@@ -253,7 +256,9 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
                OPT_BOOLEAN(0, "tags",       &tags, "use any tag in .git/refs/tags"),
                OPT__ABBREV(&abbrev),
                OPT_INTEGER(0, "candidates", &max_candidates,
-                                       "consider <n> most recent tags (default: 10)"),
+                           "consider <n> most recent tags (default: 10)"),
+               OPT_STRING(0, "match",       &pattern, "pattern",
+                          "only consider tags matching <pattern>"),
                OPT_END(),
        };
 
@@ -266,12 +271,19 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
        save_commit_buffer = 0;
 
        if (contains) {
-               const char **args = xmalloc((4 + argc) * sizeof(char*));
+               const char **args = xmalloc((6 + argc) * sizeof(char*));
                int i = 0;
                args[i++] = "name-rev";
                args[i++] = "--name-only";
-               if (!all)
+               args[i++] = "--no-undefined";
+               if (!all) {
                        args[i++] = "--tags";
+                       if (pattern) {
+                               char *s = xmalloc(strlen("--refs=refs/tags/") + strlen(pattern) + 1);
+                               sprintf(s, "--refs=refs/tags/%s", pattern);
+                               args[i++] = s;
+                       }
+               }
                memcpy(args + i, argv, argc * sizeof(char*));
                args[i + argc] = NULL;
                return cmd_name_rev(i + argc, args, prefix);
index e68e01592d044a2c2570f096668856eef5caa1a2..f40135248a5a1e2012c4cb01667f037407aae800 100644 (file)
@@ -7,6 +7,7 @@
 #include "pack.h"
 #include "sideband.h"
 #include "fetch-pack.h"
+#include "remote.h"
 #include "run-command.h"
 
 static int transfer_unpack_limit = -1;
@@ -548,14 +549,14 @@ static int get_pack(int xd[2], char **pack_lockfile)
 }
 
 static struct ref *do_fetch_pack(int fd[2],
+               const struct ref *orig_ref,
                int nr_match,
                char **match,
                char **pack_lockfile)
 {
-       struct ref *ref;
+       struct ref *ref = copy_ref_list(orig_ref);
        unsigned char sha1[20];
 
-       get_remote_heads(fd[0], &ref, 0, NULL, 0);
        if (is_repository_shallow() && !server_supports("shallow"))
                die("Server does not support shallow clients");
        if (server_supports("multi_ack")) {
@@ -573,10 +574,6 @@ static struct ref *do_fetch_pack(int fd[2],
                        fprintf(stderr, "Server supports side-band\n");
                use_sideband = 1;
        }
-       if (!ref) {
-               packet_flush(fd[1]);
-               die("no matching remote head");
-       }
        if (everything_local(&ref, nr_match, match)) {
                packet_flush(fd[1]);
                goto all_done;
@@ -650,8 +647,10 @@ static void fetch_pack_setup(void)
 int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
 {
        int i, ret, nr_heads;
-       struct ref *ref;
+       struct ref *ref = NULL;
        char *dest = NULL, **heads;
+       int fd[2];
+       struct child_process *conn;
 
        nr_heads = 0;
        heads = NULL;
@@ -706,9 +705,33 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
        if (!dest)
                usage(fetch_pack_usage);
 
-       ref = fetch_pack(&args, dest, nr_heads, heads, NULL);
+       conn = git_connect(fd, (char *)dest, args.uploadpack,
+                          args.verbose ? CONNECT_VERBOSE : 0);
+       if (conn) {
+               get_remote_heads(fd[0], &ref, 0, NULL, 0);
+
+               ref = fetch_pack(&args, fd, conn, ref, dest, nr_heads, heads, NULL);
+               close(fd[0]);
+               close(fd[1]);
+               if (finish_connect(conn))
+                       ref = NULL;
+       } else {
+               ref = NULL;
+       }
        ret = !ref;
 
+       if (!ret && nr_heads) {
+               /* If the heads to pull were given, we should have
+                * consumed all of them by matching the remote.
+                * Otherwise, 'git-fetch remote no-such-ref' would
+                * silently succeed without issuing an error.
+                */
+               for (i = 0; i < nr_heads; i++)
+                       if (heads[i] && heads[i][0]) {
+                               error("no such remote ref %s", heads[i]);
+                               ret = 1;
+                       }
+       }
        while (ref) {
                printf("%s %s\n",
                       sha1_to_hex(ref->old_sha1), ref->name);
@@ -719,16 +742,15 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
 }
 
 struct ref *fetch_pack(struct fetch_pack_args *my_args,
+                      int fd[], struct child_process *conn,
+                      const struct ref *ref,
                const char *dest,
                int nr_heads,
                char **heads,
                char **pack_lockfile)
 {
-       int i, ret;
-       int fd[2];
-       struct child_process *conn;
-       struct ref *ref;
        struct stat st;
+       struct ref *ref_cpy;
 
        fetch_pack_setup();
        memcpy(&args, my_args, sizeof(args));
@@ -737,29 +759,15 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
                        st.st_mtime = 0;
        }
 
-       conn = git_connect(fd, (char *)dest, args.uploadpack,
-                          args.verbose ? CONNECT_VERBOSE : 0);
        if (heads && nr_heads)
                nr_heads = remove_duplicates(nr_heads, heads);
-       ref = do_fetch_pack(fd, nr_heads, heads, pack_lockfile);
-       close(fd[0]);
-       close(fd[1]);
-       ret = finish_connect(conn);
-
-       if (!ret && nr_heads) {
-               /* If the heads to pull were given, we should have
-                * consumed all of them by matching the remote.
-                * Otherwise, 'git-fetch remote no-such-ref' would
-                * silently succeed without issuing an error.
-                */
-               for (i = 0; i < nr_heads; i++)
-                       if (heads[i] && heads[i][0]) {
-                               error("no such remote ref %s", heads[i]);
-                               ret = 1;
-                       }
+       if (!ref) {
+               packet_flush(fd[1]);
+               die("no matching remote head");
        }
+       ref_cpy = do_fetch_pack(fd, ref, nr_heads, heads, pack_lockfile);
 
-       if (!ret && args.depth > 0) {
+       if (args.depth > 0) {
                struct cache_time mtime;
                char *shallow = git_path("shallow");
                int fd;
@@ -787,8 +795,5 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
                }
        }
 
-       if (ret)
-               ref = NULL;
-
-       return ref;
+       return ref_cpy;
 }
index 320e235682340f07cb28b0a4de0c39b6bd9da383..ac335f20feba9a9e68098c9e89d69cf61c1c3ed7 100644 (file)
@@ -557,6 +557,8 @@ static int do_fetch(struct transport *transport,
 
        free_refs(fetch_map);
 
+       transport_disconnect(transport);
+
        return 0;
 }
 
index 8c564345f411baeb1fb91e68ebc2f3be42c2f8af..cc7524be80f51bca45ef8a205900cf50135bfc5d 100644 (file)
@@ -765,7 +765,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
                        struct blob *blob;
                        struct object *obj;
 
-                       mode = ntohl(active_cache[i]->ce_mode);
+                       mode = active_cache[i]->ce_mode;
                        if (S_ISGITLINK(mode))
                                continue;
                        blob = lookup_blob(active_cache[i]->sha1);
index ac34788c89c315d036ab041afbac91a0302e6d6a..ad4a75eedddb1dfc0ecef2b536727970335673f9 100644 (file)
@@ -37,7 +37,7 @@ static const char *argv_rerere[] = {"rerere", "gc", NULL};
 static int gc_config(const char *var, const char *value)
 {
        if (!strcmp(var, "gc.packrefs")) {
-               if (!strcmp(value, "notbare"))
+               if (value && !strcmp(value, "notbare"))
                        pack_refs = -1;
                else
                        pack_refs = git_config_bool(var, value);
index 0d6cc7361f6e1a70e4d3d9e24913d60e8ceb9e58..9180b39e3f22e5d3805649c655c61aafc7861968 100644 (file)
@@ -331,7 +331,7 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
                struct cache_entry *ce = active_cache[i];
                char *name;
                int kept;
-               if (!S_ISREG(ntohl(ce->ce_mode)))
+               if (!S_ISREG(ce->ce_mode))
                        continue;
                if (!pathspec_matches(paths, ce->name))
                        continue;
@@ -387,7 +387,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
 
        for (nr = 0; nr < active_nr; nr++) {
                struct cache_entry *ce = active_cache[nr];
-               if (!S_ISREG(ntohl(ce->ce_mode)))
+               if (!S_ISREG(ce->ce_mode))
                        continue;
                if (!pathspec_matches(paths, ce->name))
                        continue;
index dcc9f817930a3caf8d434dfd54fe476501bcdda2..99d69f079132ed67e2d5bc83bf95e6e60ba22f6f 100644 (file)
@@ -219,7 +219,7 @@ static int git_log_config(const char *var, const char *value)
 {
        if (!strcmp(var, "format.subjectprefix")) {
                if (!value)
-                       die("format.subjectprefix without value");
+                       config_error_nonbool(var);
                fmt_patch_subject_prefix = xstrdup(value);
                return 0;
        }
@@ -432,7 +432,7 @@ static int git_format_config(const char *var, const char *value)
        }
        if (!strcmp(var, "format.suffix")) {
                if (!value)
-                       die("format.suffix without value");
+                       return config_error_nonbool(var);
                fmt_patch_suffix = xstrdup(value);
                return 0;
        }
@@ -440,11 +440,10 @@ static int git_format_config(const char *var, const char *value)
                return 0;
        }
        if (!strcmp(var, "format.numbered")) {
-               if (!strcasecmp(value, "auto")) {
+               if (value && !strcasecmp(value, "auto")) {
                        auto_number = 1;
                        return 0;
                }
-
                numbered = git_config_bool(var, value);
                return 0;
        }
index 0f0ab2da167c57402efad9dc09e58964759c23cd..d56e33e251036274dbe48e300fcebd8289624cbe 100644 (file)
@@ -189,7 +189,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
                return;
 
        if (tag && *tag && show_valid_bit &&
-           (ce->ce_flags & htons(CE_VALID))) {
+           (ce->ce_flags & CE_VALID)) {
                static char alttag[4];
                memcpy(alttag, tag, 3);
                if (isalpha(tag[0]))
@@ -210,7 +210,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
        } else {
                printf("%s%06o %s %d\t",
                       tag,
-                      ntohl(ce->ce_mode),
+                      ce->ce_mode,
                       abbrev ? find_unique_abbrev(ce->sha1,abbrev)
                                : sha1_to_hex(ce->sha1),
                       ce_stage(ce));
@@ -242,7 +242,7 @@ static void show_files(struct dir_struct *dir, const char *prefix)
                                continue;
                        if (show_unmerged && !ce_stage(ce))
                                continue;
-                       if (ce->ce_flags & htons(CE_UPDATE))
+                       if (ce->ce_flags & CE_UPDATE)
                                continue;
                        show_ce_entry(ce_stage(ce) ? tag_unmerged : tag_cached, ce);
                }
@@ -350,7 +350,7 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
                struct cache_entry *ce = active_cache[i];
                if (!ce_stage(ce))
                        continue;
-               ce->ce_flags |= htons(CE_STAGEMASK);
+               ce->ce_flags |= CE_STAGEMASK;
        }
 
        if (prefix) {
@@ -379,7 +379,7 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
                         */
                        if (last_stage0 &&
                            !strcmp(last_stage0->name, ce->name))
-                               ce->ce_flags |= htons(CE_UPDATE);
+                               ce->ce_flags |= CE_UPDATE;
                }
        }
 }
index 6dd31d1dd6c14677f91e8a0a941fb0f873b4c1fc..023754986e347a9529d6295d600f665f32f14577 100644 (file)
@@ -94,6 +94,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
                transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
 
        ref = transport_get_remote_refs(transport);
+       transport_disconnect(transport);
 
        if (!ref)
                return 1;
index 2600847974f8a44bdd2148da6ff82ecf761fb193..11f154b31fcbd5c788299855e7d69f54ae8c7e70 100644 (file)
@@ -818,6 +818,7 @@ static void handle_body(void)
 
                switch (transfer_encoding) {
                case TE_BASE64:
+               case TE_QP:
                {
                        char *op = line;
 
index a0c89a827b666d8e01ba64597b732205ce1a643e..f22c8b5f5da0031657f10ddb827d33a07056e3a5 100644 (file)
@@ -125,18 +125,18 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void
 }
 
 /* returns a static buffer */
-static const charget_rev_name(struct object *o)
+static const char *get_rev_name(struct object *o)
 {
        static char buffer[1024];
        struct rev_name *n;
        struct commit *c;
 
        if (o->type != OBJ_COMMIT)
-               return "undefined";
+               return NULL;
        c = (struct commit *) o;
        n = c->util;
        if (!n)
-               return "undefined";
+               return NULL;
 
        if (!n->generation)
                return n->tip_name;
@@ -159,7 +159,7 @@ static char const * const name_rev_usage[] = {
 int cmd_name_rev(int argc, const char **argv, const char *prefix)
 {
        struct object_array revs = { 0, 0, NULL };
-       int all = 0, transform_stdin = 0;
+       int all = 0, transform_stdin = 0, allow_undefined = 1;
        struct name_ref_data data = { 0, 0, NULL };
        struct option opts[] = {
                OPT_BOOLEAN(0, "name-only", &data.name_only, "print only names (no SHA-1)"),
@@ -169,6 +169,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
                OPT_GROUP(""),
                OPT_BOOLEAN(0, "all", &all, "list all commits reachable from all refs"),
                OPT_BOOLEAN(0, "stdin", &transform_stdin, "read from stdin"),
+               OPT_BOOLEAN(0, "undefined", &allow_undefined, "allow to print `undefined` names"),
                OPT_END(),
        };
 
@@ -226,7 +227,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
                                else if (++forty == 40 &&
                                                !ishex(*(p+1))) {
                                        unsigned char sha1[40];
-                                       const char *name = "undefined";
+                                       const char *name = NULL;
                                        char c = *(p+1);
 
                                        forty = 0;
@@ -240,11 +241,10 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
                                        }
                                        *(p+1) = c;
 
-                                       if (!strcmp(name, "undefined"))
+                                       if (!name)
                                                continue;
 
-                                       fwrite(p_start, p - p_start + 1, 1,
-                                              stdout);
+                                       fwrite(p_start, p - p_start + 1, 1, stdout);
                                        printf(" (%s)", name);
                                        p_start = p + 1;
                                }
@@ -260,18 +260,32 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
                max = get_max_object_index();
                for (i = 0; i < max; i++) {
                        struct object * obj = get_indexed_object(i);
+                       const char *name;
                        if (!obj)
                                continue;
                        if (!data.name_only)
                                printf("%s ", sha1_to_hex(obj->sha1));
-                       printf("%s\n", get_rev_name(obj));
+                       name = get_rev_name(obj);
+                       if (name)
+                               printf("%s\n", name);
+                       else if (allow_undefined)
+                               printf("undefined\n");
+                       else
+                               die("cannot describe '%s'", sha1_to_hex(obj->sha1));
                }
        } else {
                int i;
                for (i = 0; i < revs.nr; i++) {
+                       const char *name;
                        if (!data.name_only)
                                printf("%s ", revs.objects[i].name);
-                       printf("%s\n", get_rev_name(revs.objects[i].item));
+                       name = get_rev_name(revs.objects[i].item);
+                       if (name)
+                               printf("%s\n", name);
+                       else if (allow_undefined)
+                               printf("undefined\n");
+                       else
+                               die("cannot describe '%s'", sha1_to_hex(revs.objects[i].item->sha1));
                }
        }
 
index d3efeff03f89cc0f4d0da463ddf878c28effb31e..692a76126b027133fd046f03003fe8e49218f192 100644 (file)
@@ -68,7 +68,7 @@ static int allow_ofs_delta;
 static const char *base_name;
 static int progress = 1;
 static int window = 10;
-static uint32_t pack_size_limit;
+static uint32_t pack_size_limit, pack_size_limit_cfg;
 static int depth = 50;
 static int delta_search_threads = 1;
 static int pack_to_stdout;
@@ -1867,6 +1867,10 @@ static int git_pack_config(const char *k, const char *v)
                        die("bad pack.indexversion=%d", pack_idx_default_version);
                return 0;
        }
+       if (!strcmp(k, "pack.packsizelimit")) {
+               pack_size_limit_cfg = git_config_ulong(k, v);
+               return 0;
+       }
        return git_default_config(k, v);
 }
 
@@ -2096,6 +2100,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                }
                if (!prefixcmp(arg, "--max-pack-size=")) {
                        char *end;
+                       pack_size_limit_cfg = 0;
                        pack_size_limit = strtoul(arg+16, &end, 0) * 1024 * 1024;
                        if (!arg[16] || *end)
                                usage(pack_usage);
@@ -2220,6 +2225,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
        if (pack_to_stdout != !base_name)
                usage(pack_usage);
 
+       if (!pack_to_stdout && !pack_size_limit)
+               pack_size_limit = pack_size_limit_cfg;
+
        if (pack_to_stdout && pack_size_limit)
                die("--max-pack-size cannot be used to build a pack for transfer.");
 
index b5e768421ba548efaf0dd62ca876c15911df55d2..bb8ead92cf41c3cbdbc421a1490fb40ce19f11c3 100644 (file)
@@ -83,6 +83,44 @@ static void prune_object_dir(const char *path)
        }
 }
 
+/*
+ * Write errors (particularly out of space) can result in
+ * failed temporary packs (and more rarely indexes and other
+ * files begining with "tmp_") accumulating in the
+ * object directory.
+ */
+static void remove_temporary_files(void)
+{
+       DIR *dir;
+       struct dirent *de;
+       char* dirname=get_object_directory();
+
+       dir = opendir(dirname);
+       if (!dir) {
+               fprintf(stderr, "Unable to open object directory %s\n",
+                       dirname);
+               return;
+       }
+       while ((de = readdir(dir)) != NULL) {
+               if (!prefixcmp(de->d_name, "tmp_")) {
+                       char name[PATH_MAX];
+                       int c = snprintf(name, PATH_MAX, "%s/%s",
+                                        dirname, de->d_name);
+                       if (c < 0 || c >= PATH_MAX)
+                               continue;
+                       if (expire) {
+                               struct stat st;
+                               if (stat(name, &st) != 0 || st.st_mtime >= expire)
+                                       continue;
+                       }
+                       printf("Removing stale temporary file %s\n", name);
+                       if (!show_only)
+                               unlink(name);
+               }
+       }
+       closedir(dir);
+}
+
 int cmd_prune(int argc, const char **argv, const char *prefix)
 {
        int i;
@@ -115,5 +153,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
 
        sync();
        prune_packed_objects(show_only);
+       remove_temporary_files();
        return 0;
 }
index c0ea0342b755c6749391803d19f852182c0c512e..57854017535a36fc1fcd7bb997f198956391199d 100644 (file)
@@ -45,8 +45,7 @@ static int read_cache_unmerged(void)
                                continue;
                        cache_tree_invalidate_path(active_cache_tree, ce->name);
                        last = ce;
-                       ce->ce_mode = 0;
-                       ce->ce_flags &= ~htons(CE_STAGEMASK);
+                       ce->ce_flags |= CE_REMOVE;
                }
                *dst++ = ce;
        }
index e6834dd831e59b9a076305b0b7088ecdc9a2b3f1..4836ec951be727512bcd550dd3604c43c39aa557 100644 (file)
@@ -307,13 +307,19 @@ static int collect_reflog(const char *ref, const unsigned char *sha1, int unused
 
 static int reflog_expire_config(const char *var, const char *value)
 {
-       if (!strcmp(var, "gc.reflogexpire"))
+       if (!strcmp(var, "gc.reflogexpire")) {
+               if (!value)
+                       config_error_nonbool(var);
                default_reflog_expire = approxidate(value);
-       else if (!strcmp(var, "gc.reflogexpireunreachable"))
+               return 0;
+       }
+       if (!strcmp(var, "gc.reflogexpireunreachable")) {
+               if (!value)
+                       config_error_nonbool(var);
                default_reflog_expire_unreachable = approxidate(value);
-       else
-               return git_default_config(var, value);
-       return 0;
+               return 0;
+       }
+       return git_default_config(var, value);
 }
 
 static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
index a9e3ebc13725cbe8658478797d6e1d8e097e5292..b0c17bde879d42c16fe5c7f0756763cd638f8bac 100644 (file)
@@ -149,8 +149,8 @@ static int find_conflict(struct path_list *conflict)
                if (ce_stage(e2) == 2 &&
                    ce_stage(e3) == 3 &&
                    ce_same_name(e2, e3) &&
-                   S_ISREG(ntohl(e2->ce_mode)) &&
-                   S_ISREG(ntohl(e3->ce_mode))) {
+                   S_ISREG(e2->ce_mode) &&
+                   S_ISREG(e3->ce_mode)) {
                        path_list_insert((const char *)e2->name, conflict);
                        i++; /* skip over both #2 and #3 */
                }
index 358af537476b0b558989f27fe60627af6977635b..e219859f9b04dc94a2444346541e86503085fdea 100644 (file)
@@ -8,6 +8,7 @@
 #include "exec_cmd.h"
 #include "utf8.h"
 #include "parse-options.h"
+#include "cache-tree.h"
 
 /*
  * This implements the builtins revert and cherry-pick.
@@ -270,7 +271,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
                 * that represents the "current" state for merge-recursive
                 * to work on.
                 */
-               if (write_tree(head, 0, NULL))
+               if (write_cache_as_tree(head, 0, NULL))
                        die ("Your index file is unmerged.");
        } else {
                struct wt_status s;
@@ -357,7 +358,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
        if (merge_recursive(sha1_to_hex(base->object.sha1),
                                sha1_to_hex(head), "HEAD",
                                sha1_to_hex(next->object.sha1), oneline) ||
-                       write_tree(head, 0, NULL)) {
+                       write_cache_as_tree(head, 0, NULL)) {
                add_to_msg("\nConflicts:\n\n");
                read_cache();
                for (i = 0; i < active_nr;) {
index 6dc835d30a6a726c3dd40d23564b0dc32d20b7db..019abd3527e7c573c69900a58313749e2ef2280a 100644 (file)
@@ -536,6 +536,8 @@ static void append_one_rev(const char *av)
 static int git_show_branch_config(const char *var, const char *value)
 {
        if (!strcmp(var, "showbranch.default")) {
+               if (!value)
+                       return config_error_nonbool(var);
                if (default_alloc <= default_num + 1) {
                        default_alloc = default_alloc * 3 / 2 + 20;
                        default_arg = xrealloc(default_arg, sizeof *default_arg * default_alloc);
index 03e70155fc676a8dd38ca5cef800ed4a446e921a..4a4a88c10b4b2f9e55662bd4c1c17051ae7e6aac 100644 (file)
@@ -258,7 +258,7 @@ static int git_tag_config(const char *var, const char *value)
 {
        if (!strcmp(var, "user.signingkey")) {
                if (!value)
-                       die("user.signingkey without value");
+                       return config_error_nonbool(value);
                set_signingkey(value);
                return 0;
        }
index c3a14c74ed00db592db55a018db37657148a9900..a8795d3d5fea9f340dfe21a71190f120c63856cd 100644 (file)
@@ -47,10 +47,10 @@ static int mark_valid(const char *path)
        if (0 <= pos) {
                switch (mark_valid_only) {
                case MARK_VALID:
-                       active_cache[pos]->ce_flags |= htons(CE_VALID);
+                       active_cache[pos]->ce_flags |= CE_VALID;
                        break;
                case UNMARK_VALID:
-                       active_cache[pos]->ce_flags &= ~htons(CE_VALID);
+                       active_cache[pos]->ce_flags &= ~CE_VALID;
                        break;
                }
                cache_tree_invalidate_path(active_cache_tree, path);
@@ -95,7 +95,7 @@ static int add_one_path(struct cache_entry *old, const char *path, int len, stru
        size = cache_entry_size(len);
        ce = xcalloc(1, size);
        memcpy(ce->name, path, len);
-       ce->ce_flags = htons(len);
+       ce->ce_flags = len;
        fill_stat_cache_info(ce, st);
        ce->ce_mode = ce_mode_from_stat(old, st->st_mode);
 
@@ -139,7 +139,7 @@ static int process_directory(const char *path, int len, struct stat *st)
        /* Exact match: file or existing gitlink */
        if (pos >= 0) {
                struct cache_entry *ce = active_cache[pos];
-               if (S_ISGITLINK(ntohl(ce->ce_mode))) {
+               if (S_ISGITLINK(ce->ce_mode)) {
 
                        /* Do nothing to the index if there is no HEAD! */
                        if (resolve_gitlink_ref(path, "HEAD", sha1) < 0)
@@ -183,7 +183,7 @@ static int process_file(const char *path, int len, struct stat *st)
        int pos = cache_name_pos(path, len);
        struct cache_entry *ce = pos < 0 ? NULL : active_cache[pos];
 
-       if (ce && S_ISGITLINK(ntohl(ce->ce_mode)))
+       if (ce && S_ISGITLINK(ce->ce_mode))
                return error("%s is already a gitlink, not replacing", path);
 
        return add_one_path(ce, path, len, st);
@@ -226,7 +226,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
        ce->ce_flags = create_ce_flags(len, stage);
        ce->ce_mode = create_ce_mode(mode);
        if (assume_unchanged)
-               ce->ce_flags |= htons(CE_VALID);
+               ce->ce_flags |= CE_VALID;
        option = allow_add ? ADD_CACHE_OK_TO_ADD : 0;
        option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;
        if (add_cache_entry(ce, option))
@@ -246,14 +246,14 @@ static void chmod_path(int flip, const char *path)
        if (pos < 0)
                goto fail;
        ce = active_cache[pos];
-       mode = ntohl(ce->ce_mode);
+       mode = ce->ce_mode;
        if (!S_ISREG(mode))
                goto fail;
        switch (flip) {
        case '+':
-               ce->ce_mode |= htonl(0111); break;
+               ce->ce_mode |= 0111; break;
        case '-':
-               ce->ce_mode &= htonl(~0111); break;
+               ce->ce_mode &= ~0111; break;
        default:
                goto fail;
        }
index d16b9ed0098fd5c12fe83638f51cc3f10fd87ed7..e838d01233eb1d6cfaa0885c6b37c8726079b0ac 100644 (file)
 static const char write_tree_usage[] =
 "git-write-tree [--missing-ok] [--prefix=<prefix>/]";
 
-int write_tree(unsigned char *sha1, int missing_ok, const char *prefix)
-{
-       int entries, was_valid, newfd;
-
-       /* We can't free this memory, it becomes part of a linked list parsed atexit() */
-       struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
-
-       newfd = hold_locked_index(lock_file, 1);
-
-       entries = read_cache();
-       if (entries < 0)
-               die("git-write-tree: error reading cache");
-
-       if (!active_cache_tree)
-               active_cache_tree = cache_tree();
-
-       was_valid = cache_tree_fully_valid(active_cache_tree);
-
-       if (!was_valid) {
-               if (cache_tree_update(active_cache_tree,
-                                     active_cache, active_nr,
-                                     missing_ok, 0) < 0)
-                       die("git-write-tree: error building trees");
-               if (0 <= newfd) {
-                       if (!write_cache(newfd, active_cache, active_nr) &&
-                           !commit_lock_file(lock_file))
-                               newfd = -1;
-               }
-               /* Not being able to write is fine -- we are only interested
-                * in updating the cache-tree part, and if the next caller
-                * ends up using the old index with unupdated cache-tree part
-                * it misses the work we did here, but that is just a
-                * performance penalty and not a big deal.
-                */
-       }
-
-       if (prefix) {
-               struct cache_tree *subtree =
-                       cache_tree_find(active_cache_tree, prefix);
-               if (!subtree)
-                       die("git-write-tree: prefix %s not found", prefix);
-               hashcpy(sha1, subtree->sha1);
-       }
-       else
-               hashcpy(sha1, active_cache_tree->sha1);
-
-       if (0 <= newfd)
-               rollback_lock_file(lock_file);
-
-       return 0;
-}
-
 int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)
 {
        int missing_ok = 0, ret;
        const char *prefix = NULL;
        unsigned char sha1[20];
+       const char *me = "git-write-tree";
 
        git_config(git_default_config);
        while (1 < argc) {
@@ -84,8 +33,20 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)
        if (argc > 2)
                die("too many options");
 
-       ret = write_tree(sha1, missing_ok, prefix);
-       printf("%s\n", sha1_to_hex(sha1));
-
+       ret = write_cache_as_tree(sha1, missing_ok, prefix);
+       switch (ret) {
+       case 0:
+               printf("%s\n", sha1_to_hex(sha1));
+               break;
+       case WRITE_TREE_UNREADABLE_INDEX:
+               die("%s: error reading the index", me);
+               break;
+       case WRITE_TREE_UNMERGED_INDEX:
+               die("%s: error building trees; the index is unmerged?", me);
+               break;
+       case WRITE_TREE_PREFIX_ERROR:
+               die("%s: prefix %s not found", me, prefix);
+               break;
+       }
        return ret;
 }
index cb675c4d7a80b99a06d6d04156e767ea025eb512..3d1628c597b21cc22b750809c27d4499e725d259 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -8,7 +8,6 @@ extern const char git_usage_string[];
 
 extern void list_common_cmds_help(void);
 extern void help_unknown_cmd(const char *cmd);
-extern int write_tree(unsigned char *sha1, int missing_ok, const char *prefix);
 extern void prune_packed_objects(int);
 
 extern int cmd_add(int argc, const char **argv, const char *prefix);
index 50b35264fd0405a299700ef8bf4a61f416f30e46..39da54d1e56b5905655eafed1aff0f51c2540a8e 100644 (file)
@@ -320,13 +320,13 @@ static int update_one(struct cache_tree *it,
                }
                else {
                        sha1 = ce->sha1;
-                       mode = ntohl(ce->ce_mode);
+                       mode = ce->ce_mode;
                        entlen = pathlen - baselen;
                }
                if (mode != S_IFGITLINK && !missing_ok && !has_sha1_file(sha1))
                        return error("invalid object %s", sha1_to_hex(sha1));
 
-               if (!ce->ce_mode)
+               if (ce->ce_flags & CE_REMOVE)
                        continue; /* entry being removed */
 
                strbuf_grow(&buffer, entlen + 100);
@@ -529,3 +529,58 @@ struct cache_tree *cache_tree_find(struct cache_tree *it, const char *path)
        }
        return it;
 }
+
+int write_cache_as_tree(unsigned char *sha1, int missing_ok, const char *prefix)
+{
+       int entries, was_valid, newfd;
+
+       /*
+        * We can't free this memory, it becomes part of a linked list
+        * parsed atexit()
+        */
+       struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
+
+       newfd = hold_locked_index(lock_file, 1);
+
+       entries = read_cache();
+       if (entries < 0)
+               return WRITE_TREE_UNREADABLE_INDEX;
+
+       if (!active_cache_tree)
+               active_cache_tree = cache_tree();
+
+       was_valid = cache_tree_fully_valid(active_cache_tree);
+
+       if (!was_valid) {
+               if (cache_tree_update(active_cache_tree,
+                                     active_cache, active_nr,
+                                     missing_ok, 0) < 0)
+                       return WRITE_TREE_UNMERGED_INDEX;
+               if (0 <= newfd) {
+                       if (!write_cache(newfd, active_cache, active_nr) &&
+                           !commit_lock_file(lock_file))
+                               newfd = -1;
+               }
+               /* Not being able to write is fine -- we are only interested
+                * in updating the cache-tree part, and if the next caller
+                * ends up using the old index with unupdated cache-tree part
+                * it misses the work we did here, but that is just a
+                * performance penalty and not a big deal.
+                */
+       }
+
+       if (prefix) {
+               struct cache_tree *subtree =
+                       cache_tree_find(active_cache_tree, prefix);
+               if (!subtree)
+                       return WRITE_TREE_PREFIX_ERROR;
+               hashcpy(sha1, subtree->sha1);
+       }
+       else
+               hashcpy(sha1, active_cache_tree->sha1);
+
+       if (0 <= newfd)
+               rollback_lock_file(lock_file);
+
+       return 0;
+}
index 8243228e49ffd7078a783582be6ce79c97541a9c..44aad426d319b83eda013e115f35e066cc590cb8 100644 (file)
@@ -30,4 +30,9 @@ int cache_tree_update(struct cache_tree *, struct cache_entry **, int, int, int)
 
 struct cache_tree *cache_tree_find(struct cache_tree *, const char *);
 
+#define WRITE_TREE_UNREADABLE_INDEX (-1)
+#define WRITE_TREE_UNMERGED_INDEX (-2)
+#define WRITE_TREE_PREFIX_ERROR (-3)
+
+int write_cache_as_tree(unsigned char *sha1, int missing_ok, const char *prefix);
 #endif
diff --git a/cache.h b/cache.h
index 549f4bbac7242714283e58dd576460ca86015d52..efd31d8569c27ca18f2f7a7e599c115c8be9251a 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -3,6 +3,7 @@
 
 #include "git-compat-util.h"
 #include "strbuf.h"
+#include "hash.h"
 
 #include SHA1_HEADER
 #include <zlib.h>
@@ -94,48 +95,84 @@ struct cache_time {
  * We save the fields in big-endian order to allow using the
  * index file over NFS transparently.
  */
+struct ondisk_cache_entry {
+       struct cache_time ctime;
+       struct cache_time mtime;
+       unsigned int dev;
+       unsigned int ino;
+       unsigned int mode;
+       unsigned int uid;
+       unsigned int gid;
+       unsigned int size;
+       unsigned char sha1[20];
+       unsigned short flags;
+       char name[FLEX_ARRAY]; /* more */
+};
+
 struct cache_entry {
-       struct cache_time ce_ctime;
-       struct cache_time ce_mtime;
+       struct cache_entry *next;
+       unsigned int ce_ctime;
+       unsigned int ce_mtime;
        unsigned int ce_dev;
        unsigned int ce_ino;
        unsigned int ce_mode;
        unsigned int ce_uid;
        unsigned int ce_gid;
        unsigned int ce_size;
+       unsigned int ce_flags;
        unsigned char sha1[20];
-       unsigned short ce_flags;
        char name[FLEX_ARRAY]; /* more */
 };
 
 #define CE_NAMEMASK  (0x0fff)
 #define CE_STAGEMASK (0x3000)
-#define CE_UPDATE    (0x4000)
 #define CE_VALID     (0x8000)
 #define CE_STAGESHIFT 12
 
-#define create_ce_flags(len, stage) htons((len) | ((stage) << CE_STAGESHIFT))
-#define ce_namelen(ce) (CE_NAMEMASK & ntohs((ce)->ce_flags))
+/* In-memory only */
+#define CE_UPDATE    (0x10000)
+#define CE_REMOVE    (0x20000)
+#define CE_UPTODATE  (0x40000)
+#define CE_UNHASHED  (0x80000)
+
+static inline unsigned create_ce_flags(size_t len, unsigned stage)
+{
+       if (len >= CE_NAMEMASK)
+               len = CE_NAMEMASK;
+       return (len | (stage << CE_STAGESHIFT));
+}
+
+static inline size_t ce_namelen(const struct cache_entry *ce)
+{
+       size_t len = ce->ce_flags & CE_NAMEMASK;
+       if (len < CE_NAMEMASK)
+               return len;
+       return strlen(ce->name + CE_NAMEMASK) + CE_NAMEMASK;
+}
+
 #define ce_size(ce) cache_entry_size(ce_namelen(ce))
-#define ce_stage(ce) ((CE_STAGEMASK & ntohs((ce)->ce_flags)) >> CE_STAGESHIFT)
+#define ondisk_ce_size(ce) ondisk_cache_entry_size(ce_namelen(ce))
+#define ce_stage(ce) ((CE_STAGEMASK & (ce)->ce_flags) >> CE_STAGESHIFT)
+#define ce_uptodate(ce) ((ce)->ce_flags & CE_UPTODATE)
+#define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE)
 
 #define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
 static inline unsigned int create_ce_mode(unsigned int mode)
 {
        if (S_ISLNK(mode))
-               return htonl(S_IFLNK);
+               return S_IFLNK;
        if (S_ISDIR(mode) || S_ISGITLINK(mode))
-               return htonl(S_IFGITLINK);
-       return htonl(S_IFREG | ce_permissions(mode));
+               return S_IFGITLINK;
+       return S_IFREG | ce_permissions(mode);
 }
 static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned int mode)
 {
        extern int trust_executable_bit, has_symlinks;
        if (!has_symlinks && S_ISREG(mode) &&
-           ce && S_ISLNK(ntohl(ce->ce_mode)))
+           ce && S_ISLNK(ce->ce_mode))
                return ce->ce_mode;
        if (!trust_executable_bit && S_ISREG(mode)) {
-               if (ce && S_ISREG(ntohl(ce->ce_mode)))
+               if (ce && S_ISREG(ce->ce_mode))
                        return ce->ce_mode;
                return create_ce_mode(0666);
        }
@@ -146,14 +183,16 @@ static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned in
        S_ISLNK(mode) ? S_IFLNK : S_ISDIR(mode) ? S_IFDIR : S_IFGITLINK)
 
 #define cache_entry_size(len) ((offsetof(struct cache_entry,name) + (len) + 8) & ~7)
+#define ondisk_cache_entry_size(len) ((offsetof(struct ondisk_cache_entry,name) + (len) + 8) & ~7)
 
 struct index_state {
        struct cache_entry **cache;
        unsigned int cache_nr, cache_alloc, cache_changed;
        struct cache_tree *cache_tree;
        time_t timestamp;
-       void *mmap;
-       size_t mmap_size;
+       void *alloc;
+       unsigned name_hash_initialized : 1;
+       struct hash_table name_hash;
 };
 
 extern struct index_state the_index;
@@ -177,6 +216,7 @@ extern struct index_state the_index;
 #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL)
 #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
 #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
+#define cache_name_exists(name, namelen) index_name_exists(&the_index, (name), (namelen))
 #endif
 
 enum object_type {
@@ -263,6 +303,7 @@ extern int read_index_from(struct index_state *, const char *path);
 extern int write_index(struct index_state *, int newfd);
 extern int discard_index(struct index_state *);
 extern int verify_path(const char *path);
+extern int index_name_exists(struct index_state *istate, const char *name, int namelen);
 extern int index_name_pos(struct index_state *, const char *name, int namelen);
 #define ADD_CACHE_OK_TO_ADD 1          /* Ok to add */
 #define ADD_CACHE_OK_TO_REPLACE 2      /* Ok to replace file/directory */
@@ -584,11 +625,16 @@ extern int git_parse_ulong(const char *, unsigned long *);
 extern int git_config_int(const char *, const char *);
 extern unsigned long git_config_ulong(const char *, const char *);
 extern int git_config_bool(const char *, const char *);
+extern int git_config_string(const char **, const char *, const char *);
 extern int git_config_set(const char *, const char *);
 extern int git_config_set_multivar(const char *, const char *, const char *, int);
 extern int git_config_rename_section(const char *, const char *);
 extern const char *git_etc_gitconfig(void);
 extern int check_repository_format_version(const char *var, const char *value);
+extern int git_env_bool(const char *, int);
+extern int git_config_system(void);
+extern int git_config_global(void);
+extern int config_error_nonbool(const char *);
 
 #define MAX_GITNAME (1000)
 extern char git_default_email[MAX_GITNAME];
@@ -608,12 +654,12 @@ extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char
 
 /* pager.c */
 extern void setup_pager(void);
-extern char *pager_program;
+extern const char *pager_program;
 extern int pager_in_use(void);
 extern int pager_use_color;
 
-extern char *editor_program;
-extern char *excludes_file;
+extern const char *editor_program;
+extern const char *excludes_file;
 
 /* base85 */
 int decode_85(char *dst, const char *line, int linelen);
diff --git a/color.c b/color.c
index 7f66c29fae57abceda30b1257c2a66626f3be0b2..cb70340420b6285786b988d4a98d2023a37d4ffc 100644 (file)
--- a/color.c
+++ b/color.c
@@ -17,7 +17,7 @@ static int parse_color(const char *name, int len)
                        return i - 1;
        }
        i = strtol(name, &end, 10);
-       if (*name && !*end && i >= -1 && i <= 255)
+       if (end - name == len && i >= -1 && i <= 255)
                return i;
        return -2;
 }
index 498259ebefb3ba61a75aa5a5ca03d75576a501c0..7881bbc7782b7937e450ad99c4bb6bda67c1f2e3 100644 (file)
--- a/config.c
+++ b/config.c
@@ -309,6 +309,14 @@ int git_config_bool(const char *name, const char *value)
        return git_config_int(name, value) != 0;
 }
 
+int git_config_string(const char **dest, const char *var, const char *value)
+{
+       if (!value)
+               return config_error_nonbool(var);
+       *dest = xstrdup(value);
+       return 0;
+}
+
 int git_default_config(const char *var, const char *value)
 {
        /* This needs a better name */
@@ -408,49 +416,42 @@ int git_default_config(const char *var, const char *value)
        }
 
        if (!strcmp(var, "user.name")) {
+               if (!value)
+                       return config_error_nonbool(var);
                strlcpy(git_default_name, value, sizeof(git_default_name));
                return 0;
        }
 
        if (!strcmp(var, "user.email")) {
+               if (!value)
+                       return config_error_nonbool(var);
                strlcpy(git_default_email, value, sizeof(git_default_email));
                return 0;
        }
 
-       if (!strcmp(var, "i18n.commitencoding")) {
-               git_commit_encoding = xstrdup(value);
-               return 0;
-       }
-
-       if (!strcmp(var, "i18n.logoutputencoding")) {
-               git_log_output_encoding = xstrdup(value);
-               return 0;
-       }
+       if (!strcmp(var, "i18n.commitencoding"))
+               return git_config_string(&git_commit_encoding, var, value);
 
+       if (!strcmp(var, "i18n.logoutputencoding"))
+               return git_config_string(&git_log_output_encoding, var, value);
 
        if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) {
                pager_use_color = git_config_bool(var,value);
                return 0;
        }
 
-       if (!strcmp(var, "core.pager")) {
-               pager_program = xstrdup(value);
-               return 0;
-       }
+       if (!strcmp(var, "core.pager"))
+               return git_config_string(&pager_program, var, value);
 
-       if (!strcmp(var, "core.editor")) {
-               editor_program = xstrdup(value);
-               return 0;
-       }
+       if (!strcmp(var, "core.editor"))
+               return git_config_string(&editor_program, var, value);
 
-       if (!strcmp(var, "core.excludesfile")) {
-               if (!value)
-                       die("core.excludesfile without value");
-               excludes_file = xstrdup(value);
-               return 0;
-       }
+       if (!strcmp(var, "core.excludesfile"))
+               return git_config_string(&excludes_file, var, value);
 
        if (!strcmp(var, "core.whitespace")) {
+               if (!value)
+                       return config_error_nonbool(var);
                whitespace_rule_cfg = parse_whitespace_rule(value);
                return 0;
        }
@@ -492,6 +493,22 @@ const char *git_etc_gitconfig(void)
        return system_wide;
 }
 
+int git_env_bool(const char *k, int def)
+{
+       const char *v = getenv(k);
+       return v ? git_config_bool(k, v) : def;
+}
+
+int git_config_system(void)
+{
+       return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0);
+}
+
+int git_config_global(void)
+{
+       return !git_env_bool("GIT_CONFIG_NOGLOBAL", 0);
+}
+
 int git_config(config_fn_t fn)
 {
        int ret = 0;
@@ -504,7 +521,7 @@ int git_config(config_fn_t fn)
         * config file otherwise. */
        filename = getenv(CONFIG_ENVIRONMENT);
        if (!filename) {
-               if (!access(git_etc_gitconfig(), R_OK))
+               if (git_config_system() && !access(git_etc_gitconfig(), R_OK))
                        ret += git_config_from_file(fn, git_etc_gitconfig());
                home = getenv("HOME");
                filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
@@ -512,7 +529,7 @@ int git_config(config_fn_t fn)
                        filename = repo_config = xstrdup(git_path("config"));
        }
 
-       if (home) {
+       if (git_config_global() && home) {
                char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
                if (!access(user_config, R_OK))
                        ret = git_config_from_file(fn, user_config);
@@ -701,12 +718,17 @@ static ssize_t find_beginning_of_line(const char* contents, size_t size,
        size_t equal_offset = size, bracket_offset = size;
        ssize_t offset;
 
+contline:
        for (offset = offset_-2; offset > 0
                        && contents[offset] != '\n'; offset--)
                switch (contents[offset]) {
                        case '=': equal_offset = offset; break;
                        case ']': bracket_offset = offset; break;
                }
+       if (offset > 0 && contents[offset-1] == '\\') {
+               offset_ = offset;
+               goto contline;
+       }
        if (bracket_offset < equal_offset) {
                *found_bracket = 1;
                offset = bracket_offset+1;
@@ -1074,3 +1096,12 @@ int git_config_rename_section(const char *old_name, const char *new_name)
        free(config_filename);
        return ret;
 }
+
+/*
+ * Call this to report error for your variable that should not
+ * get a boolean value (i.e. "[my] var" means "true").
+ */
+int config_error_nonbool(const char *var)
+{
+       return error("Missing value for '%s'", var);
+}
index 3aefd4ace590082b85bd3c4b9b41b8d1f1c72268..5ac357278464324d82ac6912c1b7ad84d42d0743 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -370,6 +370,8 @@ static int git_proxy_command_options(const char *var, const char *value)
 
                if (git_proxy_command)
                        return 0;
+               if (!value)
+                       return config_error_nonbool(var);
                /* [core]
                 * ;# matches www.kernel.org as well
                 * gitproxy = netcatter-1 for kernel.org
@@ -472,14 +474,18 @@ char *get_port(char *host)
        return NULL;
 }
 
+static struct child_process no_fork;
+
 /*
- * This returns NULL if the transport protocol does not need fork(2), or a
- * struct child_process object if it does.  Once done, finish the connection
- * with finish_connect() with the value returned from this function
- * (it is safe to call finish_connect() with NULL to support the former
- * case).
+ * This returns a dummy child_process if the transport protocol does not
+ * need fork(2), or a struct child_process object if it does.  Once done,
+ * finish the connection with finish_connect() with the value returned from
+ * this function (it is safe to call finish_connect() with NULL to support
+ * the former case).
  *
- * If it returns, the connect is successful; it just dies on errors.
+ * If it returns, the connect is successful; it just dies on errors (this
+ * will hopefully be changed in a libification effort, to return NULL when
+ * the connection failed).
  */
 struct child_process *git_connect(int fd[2], const char *url_orig,
                                  const char *prog, int flags)
@@ -577,7 +583,7 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
                free(url);
                if (free_path)
                        free(path);
-               return NULL;
+               return &no_fork;
        }
 
        conn = xcalloc(1, sizeof(*conn));
@@ -635,7 +641,7 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 int finish_connect(struct child_process *conn)
 {
        int code;
-       if (!conn)
+       if (!conn || conn == &no_fork)
                return 0;
 
        code = finish_command(conn);
index 0d33f9a3dc9d5a593ce2691ab850ba1e38aa32de..4ea727b14303e397117067993dbda446ed154ea1 100755 (executable)
@@ -64,12 +64,41 @@ __gitdir ()
 
 __git_ps1 ()
 {
-       local b="$(git symbolic-ref HEAD 2>/dev/null)"
-       if [ -n "$b" ]; then
+       local g="$(git rev-parse --git-dir 2>/dev/null)"
+       if [ -n "$g" ]; then
+               local r
+               local b
+               if [ -d "$g/../.dotest" ]
+               then
+                       r="|AM/REBASE"
+                       b="$(git symbolic-ref HEAD 2>/dev/null)"
+               elif [ -f "$g/.dotest-merge/interactive" ]
+               then
+                       r="|REBASE-i"
+                       b="$(cat $g/.dotest-merge/head-name)"
+               elif [ -d "$g/.dotest-merge" ]
+               then
+                       r="|REBASE-m"
+                       b="$(cat $g/.dotest-merge/head-name)"
+               elif [ -f "$g/MERGE_HEAD" ]
+               then
+                       r="|MERGING"
+                       b="$(git symbolic-ref HEAD 2>/dev/null)"
+               else
+                       if [ -f $g/BISECT_LOG ]
+                       then
+                               r="|BISECTING"
+                       fi
+                       if ! b="$(git symbolic-ref HEAD 2>/dev/null)"
+                       then
+                               b="$(cut -c1-7 $g/HEAD)..."
+                       fi
+               fi
+
                if [ -n "$1" ]; then
-                       printf "$1" "${b##refs/heads/}"
+                       printf "$1" "${b##refs/heads/}$r"
                else
-                       printf " (%s)" "${b##refs/heads/}"
+                       printf " (%s)" "${b##refs/heads/}$r"
                fi
        fi
 }
index bb671d561ebc9af51bb9a5d52017e71fd81881e9..9f92cd250b2ba2c3057bff87daa1b7990f85403d 100644 (file)
@@ -105,6 +105,13 @@ selected element from l."
      (setq ,l (remove e ,l))
      e))
 
+(defvar git-blame-log-oneline-format
+  "format:[%cr] %cn: %s"
+  "*Formatting option used for describing current line in the minibuffer.
+
+This option is used to pass to git log --pretty= command-line option,
+and describe which commit the current line was made.")
+
 (defvar git-blame-dark-colors
   (git-blame-color-scale "0c" "04" "24" "1c" "2c" "34" "14" "3c")
   "*List of colors (format #RGB) to use in a dark environment.
@@ -371,7 +378,8 @@ See also function `git-blame-mode'."
 (defun git-describe-commit (hash)
   (with-temp-buffer
     (call-process "git" nil t nil
-                  "log" "-1" "--pretty=oneline"
+                  "log" "-1"
+                 (concat "--pretty=" git-blame-log-oneline-format)
                   hash)
     (buffer-substring (point-min) (1- (point-max)))))
 
index d8a06381f4140a777f03fda67f68838e4aa3e493..a8bf0ef883358c7eaf9a13dde8f371a86ff840f0 100644 (file)
@@ -35,7 +35,6 @@
 ;;
 ;; TODO
 ;;  - portability to XEmacs
-;;  - better handling of subprocess errors
 ;;  - diff against other branch
 ;;  - renaming files from the status buffer
 ;;  - creating tags
@@ -191,6 +190,18 @@ if there is already one that displays the same directory."
              (append (git-get-env-strings env) (list "git") args))
     (apply #'call-process "git" nil buffer nil args)))
 
+(defun git-call-process-display-error (&rest args)
+  "Wrapper for call-process that displays error messages."
+  (let* ((dir default-directory)
+         (buffer (get-buffer-create "*Git Command Output*"))
+         (ok (with-current-buffer buffer
+               (let ((default-directory dir)
+                     (buffer-read-only nil))
+                 (erase-buffer)
+                 (eq 0 (apply 'call-process "git" nil (list buffer t) nil args))))))
+    (unless ok (display-message-or-buffer buffer))
+    ok))
+
 (defun git-call-process-env-string (env &rest args)
   "Wrapper for call-process that sets environment strings,
 and returns the process output as a string."
@@ -377,7 +388,7 @@ and returns the process output as a string."
     (when reason
      (push reason args)
      (push "-m" args))
-    (eq 0 (apply #'git-call-process-env nil nil "update-ref" args))))
+    (apply 'git-call-process-display-error "update-ref" args)))
 
 (defun git-read-tree (tree &optional index-file)
   "Read a tree into the index file."
@@ -558,12 +569,15 @@ and returns the process output as a string."
                     (?\100 "   (type change file -> subproject)")
                     (?\120 "   (type change symlink -> subproject)")
                     (t "   (subproject)")))
+                  (?\110 nil)  ;; directory (internal, not a real git state)
                  (?\000  ;; deleted or unknown
                   (case old-type
                     (?\120 "   (symlink)")
                     (?\160 "   (subproject)")))
                  (t (format "   (unknown type %o)" new-type)))))
-    (if str (propertize str 'face 'git-status-face) "")))
+    (cond (str (propertize str 'face 'git-status-face))
+          ((eq new-type ?\110) "/")
+          (t ""))))
 
 (defun git-rename-as-string (info)
   "Return a string describing the copy or rename associated with INFO, or an empty string if none."
@@ -666,9 +680,11 @@ Return the list of files that haven't been handled."
     (with-temp-buffer
       (apply #'git-call-process-env t nil "ls-files" "-z" (append options (list "--") files))
       (goto-char (point-min))
-      (while (re-search-forward "\\([^\0]*\\)\0" nil t 1)
+      (while (re-search-forward "\\([^\0]*?\\)\\(/?\\)\0" nil t 1)
         (let ((name (match-string 1)))
-          (push (git-create-fileinfo default-state name) infolist)
+          (push (git-create-fileinfo default-state name 0
+                                     (if (string-equal "/" (match-string 2)) (lsh ?\110 9) 0))
+                infolist)
           (setq files (delete name files)))))
     (git-insert-info-list status infolist)
     files))
@@ -713,7 +729,7 @@ Return the list of files that haven't been handled."
 (defun git-run-ls-files-with-excludes (status files default-state &rest options)
   "Run git-ls-files on FILES with appropriate --exclude-from options."
   (let ((exclude-files (git-get-exclude-files)))
-    (apply #'git-run-ls-files status files default-state
+    (apply #'git-run-ls-files status files default-state "--directory"
            (concat "--exclude-per-directory=" git-per-dir-ignore-file)
            (append options (mapcar (lambda (f) (concat "--exclude-from=" f)) exclude-files)))))
 
@@ -735,6 +751,27 @@ Return the list of files that haven't been handled."
     (git-refresh-files)
     (git-refresh-ewoc-hf git-status)))
 
+(defun git-mark-files (status files)
+  "Mark all the specified FILES, and unmark the others."
+  (setq files (sort files #'string-lessp))
+  (let ((file (and files (pop files)))
+        (node (ewoc-nth status 0)))
+    (while node
+      (let ((info (ewoc-data node)))
+        (if (and file (string-equal (git-fileinfo->name info) file))
+            (progn
+              (unless (git-fileinfo->marked info)
+                (setf (git-fileinfo->marked info) t)
+                (setf (git-fileinfo->needs-refresh info) t))
+              (setq file (pop files))
+              (setq node (ewoc-next status node)))
+          (when (git-fileinfo->marked info)
+            (setf (git-fileinfo->marked info) nil)
+            (setf (git-fileinfo->needs-refresh info) t))
+          (if (and file (string-lessp file (git-fileinfo->name info)))
+              (setq file (pop files))
+            (setq node (ewoc-next status node))))))))
+
 (defun git-marked-files ()
   "Return a list of all marked files, or if none a list containing just the file at cursor position."
   (unless git-status (error "Not in git-status buffer."))
@@ -840,16 +877,17 @@ Return the list of files that haven't been handled."
                       (if (or (not (string-equal tree head-tree))
                               (yes-or-no-p "The tree was not modified, do you really want to perform an empty commit? "))
                           (let ((commit (git-commit-tree buffer tree head)))
-                            (condition-case nil (delete-file ".git/MERGE_HEAD") (error nil))
-                            (condition-case nil (delete-file ".git/MERGE_MSG") (error nil))
-                            (with-current-buffer buffer (erase-buffer))
-                           (git-update-status-files (git-get-filenames files) 'uptodate)
-                            (git-call-process-env nil nil "rerere")
-                            (git-call-process-env nil nil "gc" "--auto")
-                            (git-refresh-files)
-                            (git-refresh-ewoc-hf git-status)
-                            (message "Committed %s." commit)
-                            (git-run-hook "post-commit" nil))
+                            (when commit
+                              (condition-case nil (delete-file ".git/MERGE_HEAD") (error nil))
+                              (condition-case nil (delete-file ".git/MERGE_MSG") (error nil))
+                              (with-current-buffer buffer (erase-buffer))
+                              (git-update-status-files (git-get-filenames files) 'uptodate)
+                              (git-call-process-env nil nil "rerere")
+                              (git-call-process-env nil nil "gc" "--auto")
+                              (git-refresh-files)
+                              (git-refresh-ewoc-hf git-status)
+                              (message "Committed %s." commit)
+                              (git-run-hook "post-commit" nil)))
                         (message "Commit aborted."))))
                 (message "No files to commit.")))
           (delete-file index-file))))))
@@ -957,11 +995,12 @@ Return the list of files that haven't been handled."
   "Add marked file(s) to the index cache."
   (interactive)
   (let ((files (git-get-filenames (git-marked-files-state 'unknown 'ignored))))
+    ;; FIXME: add support for directories
     (unless files
       (push (file-relative-name (read-file-name "File to add: " nil nil t)) files))
-    (apply #'git-call-process-env nil nil "update-index" "--add" "--" files)
-    (git-update-status-files files 'uptodate)
-    (git-success-message "Added" files)))
+    (when (apply 'git-call-process-display-error "update-index" "--add" "--" files)
+      (git-update-status-files files 'uptodate)
+      (git-success-message "Added" files))))
 
 (defun git-ignore-file ()
   "Add marked file(s) to the ignore list."
@@ -983,16 +1022,19 @@ Return the list of files that haven't been handled."
          (format "Remove %d file%s? " (length files) (if (> (length files) 1) "s" "")))
         (progn
           (dolist (name files)
-            (when (file-exists-p name) (delete-file name)))
-          (apply #'git-call-process-env nil nil "update-index" "--remove" "--" files)
-          (git-update-status-files files nil)
-          (git-success-message "Removed" files))
+            (ignore-errors
+              (if (file-directory-p name)
+                  (delete-directory name)
+                (delete-file name))))
+          (when (apply 'git-call-process-display-error "update-index" "--remove" "--" files)
+            (git-update-status-files files nil)
+            (git-success-message "Removed" files)))
       (message "Aborting"))))
 
 (defun git-revert-file ()
   "Revert changes to the marked file(s)."
   (interactive)
-  (let ((files (git-marked-files))
+  (let ((files (git-marked-files-state 'added 'deleted 'modified 'unmerged))
         added modified)
     (when (and files
                (yes-or-no-p
@@ -1003,21 +1045,31 @@ Return the list of files that haven't been handled."
           ('deleted (push (git-fileinfo->name info) modified))
           ('unmerged (push (git-fileinfo->name info) modified))
           ('modified (push (git-fileinfo->name info) modified))))
-      (when added
-        (apply #'git-call-process-env nil nil "update-index" "--force-remove" "--" added))
-      (when modified
-        (apply #'git-call-process-env nil nil "checkout" "HEAD" modified))
-      (git-update-status-files (append added modified) 'uptodate)
-      (git-success-message "Reverted" (git-get-filenames files)))))
+      ;; check if a buffer contains one of the files and isn't saved
+      (dolist (file modified)
+        (let ((buffer (get-file-buffer file)))
+          (when (and buffer (buffer-modified-p buffer))
+            (error "Buffer %s is modified. Please kill or save modified buffers before reverting." (buffer-name buffer)))))
+      (let ((ok (and
+                 (or (not added)
+                     (apply 'git-call-process-display-error "update-index" "--force-remove" "--" added))
+                 (or (not modified)
+                     (apply 'git-call-process-display-error "checkout" "HEAD" modified)))))
+        (git-update-status-files (append added modified) 'uptodate)
+        (when ok
+          (dolist (file modified)
+            (let ((buffer (get-file-buffer file)))
+              (when buffer (with-current-buffer buffer (revert-buffer t t t)))))
+          (git-success-message "Reverted" (git-get-filenames files)))))))
 
 (defun git-resolve-file ()
   "Resolve conflicts in marked file(s)."
   (interactive)
   (let ((files (git-get-filenames (git-marked-files-state 'unmerged))))
     (when files
-      (apply #'git-call-process-env nil nil "update-index" "--" files)
-      (git-update-status-files files 'uptodate)
-      (git-success-message "Resolved" files))))
+      (when (apply 'git-call-process-display-error "update-index" "--" files)
+        (git-update-status-files files 'uptodate)
+        (git-success-message "Resolved" files)))))
 
 (defun git-remove-handled ()
   "Remove handled files from the status list."
@@ -1063,6 +1115,16 @@ Return the list of files that haven't been handled."
         (message "Inserting unknown files...done"))
     (git-remove-handled)))
 
+(defun git-expand-directory (info)
+  "Expand the directory represented by INFO to list its files."
+  (when (eq (lsh (git-fileinfo->new-perm info) -9) ?\110)
+    (let ((dir (git-fileinfo->name info)))
+      (git-set-filenames-state git-status (list dir) nil)
+      (git-run-ls-files-with-excludes git-status (list (concat dir "/")) 'unknown "-o")
+      (git-refresh-files)
+      (git-refresh-ewoc-hf git-status)
+      t)))
+
 (defun git-setup-diff-buffer (buffer)
   "Setup a buffer for displaying a diff."
   (let ((dir default-directory))
@@ -1199,7 +1261,8 @@ Return the list of files that haven't been handled."
       (goto-char (point-min))
       (when (re-search-forward "\n+\\'" nil t)
         (replace-match "\n" t t))
-      (when sign-off (git-append-sign-off committer-name committer-email)))))
+      (when sign-off (git-append-sign-off committer-name committer-email)))
+    buffer))
 
 (defun git-commit-file ()
   "Commit the marked file(s), asking for a commit message."
@@ -1232,14 +1295,61 @@ Return the list of files that haven't been handled."
       (setq buffer-file-coding-system coding-system)
       (re-search-forward (regexp-quote (concat git-log-msg-separator "\n")) nil t))))
 
+(defun git-setup-commit-buffer (commit)
+  "Setup the commit buffer with the contents of COMMIT."
+  (let (author-name author-email subject date msg)
+    (with-temp-buffer
+      (let ((coding-system (git-get-logoutput-coding-system)))
+        (git-call-process-env t nil "log" "-1" commit)
+        (goto-char (point-min))
+        (when (re-search-forward "^Author: *\\(.*\\) <\\(.*\\)>$" nil t)
+          (setq author-name (match-string 1))
+          (setq author-email (match-string 2)))
+        (when (re-search-forward "^Date: *\\(.*\\)$" nil t)
+          (setq date (match-string 1)))
+        (while (re-search-forward "^    \\(.*\\)$" nil t)
+          (push (match-string 1) msg))
+        (setq msg (nreverse msg))
+        (setq subject (pop msg))
+        (while (and msg (zerop (length (car msg))) (pop msg)))))
+    (git-setup-log-buffer (get-buffer-create "*git-commit*")
+                          author-name author-email subject date
+                          (mapconcat #'identity msg "\n"))))
+
+(defun git-get-commit-files (commit)
+  "Retrieve the list of files modified by COMMIT."
+  (let (files)
+    (with-temp-buffer
+      (git-call-process-env t nil "diff-tree" "-r" "-z" "--name-only" "--no-commit-id" commit)
+      (goto-char (point-min))
+      (while (re-search-forward "\\([^\0]*\\)\0" nil t 1)
+        (push (match-string 1) files)))
+    files))
+
+(defun git-amend-commit ()
+  "Undo the last commit on HEAD, and set things up to commit an
+amended version of it."
+  (interactive)
+  (unless git-status (error "Not in git-status buffer."))
+  (when (git-empty-db-p) (error "No commit to amend."))
+  (let* ((commit (git-rev-parse "HEAD"))
+         (files (git-get-commit-files commit)))
+    (when (git-call-process-display-error "reset" "--soft" "HEAD^")
+      (git-update-status-files (copy-sequence files) 'uptodate)
+      (git-mark-files git-status files)
+      (git-refresh-files)
+      (git-setup-commit-buffer commit)
+      (git-commit-file))))
+
 (defun git-find-file ()
   "Visit the current file in its own buffer."
   (interactive)
   (unless git-status (error "Not in git-status buffer."))
   (let ((info (ewoc-data (ewoc-locate git-status))))
-    (find-file (git-fileinfo->name info))
-    (when (eq 'unmerged (git-fileinfo->state info))
-      (smerge-mode 1))))
+    (unless (git-expand-directory info)
+      (find-file (git-fileinfo->name info))
+      (when (eq 'unmerged (git-fileinfo->state info))
+        (smerge-mode 1)))))
 
 (defun git-find-file-other-window ()
   "Visit the current file in its own buffer in another window."
@@ -1309,6 +1419,7 @@ Return the list of files that haven't been handled."
 
 (unless git-status-mode-map
   (let ((map (make-keymap))
+        (commit-map (make-sparse-keymap))
         (diff-map (make-sparse-keymap))
         (toggle-map (make-sparse-keymap)))
     (suppress-keymap map)
@@ -1317,6 +1428,7 @@ Return the list of files that haven't been handled."
     (define-key map " "   'git-next-file)
     (define-key map "a"   'git-add-file)
     (define-key map "c"   'git-commit-file)
+    (define-key map "\C-c" commit-map)
     (define-key map "d"    diff-map)
     (define-key map "="   'git-diff-file)
     (define-key map "f"   'git-find-file)
@@ -1342,6 +1454,8 @@ Return the list of files that haven't been handled."
     (define-key map "x"   'git-remove-handled)
     (define-key map "\C-?" 'git-unmark-file-up)
     (define-key map "\M-\C-?" 'git-unmark-all)
+    ; the commit submap
+    (define-key commit-map "\C-a" 'git-amend-commit)
     ; the diff submap
     (define-key diff-map "b" 'git-diff-file-base)
     (define-key diff-map "c" 'git-diff-file-combined)
index c17afae94aa4dc0d3c8c38517a52ae91c231deaf..781a0cbbbc96d7bf5c6d77518f2d6c9d043ba68b 100755 (executable)
@@ -1646,7 +1646,7 @@ class P4Clone(P4Sync):
         depotPath = args[0]
         depotDir = re.sub("(@[^@]*)$", "", depotPath)
         depotDir = re.sub("(#[^#]*)$", "", depotDir)
-       depotDir = re.sub(r"\.\.\.$", "", depotDir)
+        depotDir = re.sub(r"\.\.\.$", "", depotDir)
         depotDir = re.sub(r"/$", "", depotDir)
         return os.path.split(depotDir)[1]
 
index c35b15860d3a4edcf2cd93d082308ec7ce80e5f5..d72ffbb7773268514d8de29c5d5c33fdaf31f339 100755 (executable)
@@ -111,7 +111,7 @@ hgparents["0"] = (None, None)
 hgbranch["0"] = "master"
 for cset in range(1, int(tip) + 1):
     hgchildren[str(cset)] = ()
-    prnts = os.popen('hg log -r %d --template "{parents}"' % cset).read().split(' ')
+    prnts = os.popen('hg log -r %d --template "{parents}"' % cset).read().strip().split(' ')
     prnts = map(lambda x: x[:x.find(':')], prnts)
     if prnts[0] != '':
         parent = prnts[0].strip()
index 80f114b2e2d169eef2a046d112d7e8729f2c1880..552707e8e65997ebfc2120887783c4fc5698e19f 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -326,14 +326,14 @@ static int read_convert_config(const char *var, const char *value)
 
        if (!strcmp("smudge", ep)) {
                if (!value)
-                       return error("%s: lacks value", var);
+                       return config_error_nonbool(var);
                drv->smudge = strdup(value);
                return 0;
        }
 
        if (!strcmp("clean", ep)) {
                if (!value)
-                       return error("%s: lacks value", var);
+                       return config_error_nonbool(var);
                drv->clean = strdup(value);
                return 0;
        }
index d85d8f34ba055ad7e02bf5d61ae4a675ce0be1d3..03eaa7cef35dfaec0a8f61b2b96892e5604ed731 100644 (file)
@@ -9,6 +9,7 @@
 #include "revision.h"
 #include "cache-tree.h"
 #include "path-list.h"
+#include "unpack-trees.h"
 
 /*
  * diff-files
@@ -37,7 +38,7 @@ static int get_mode(const char *path, int *mode)
        if (!path || !strcmp(path, "/dev/null"))
                *mode = 0;
        else if (!strcmp(path, "-"))
-               *mode = ntohl(create_ce_mode(0666));
+               *mode = create_ce_mode(0666);
        else if (stat(path, &st))
                return error("Could not access '%s'", path);
        else
@@ -384,7 +385,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
                                        continue;
                        }
                        else
-                               dpath->mode = ntohl(ce_mode_from_stat(ce, st.st_mode));
+                               dpath->mode = ce_mode_from_stat(ce, st.st_mode);
 
                        while (i < entries) {
                                struct cache_entry *nce = active_cache[i];
@@ -398,10 +399,10 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
                                 */
                                stage = ce_stage(nce);
                                if (2 <= stage) {
-                                       int mode = ntohl(nce->ce_mode);
+                                       int mode = nce->ce_mode;
                                        num_compare_stages++;
                                        hashcpy(dpath->parent[stage-2].sha1, nce->sha1);
-                                       dpath->parent[stage-2].mode = ntohl(ce_mode_from_stat(nce, mode));
+                                       dpath->parent[stage-2].mode = ce_mode_from_stat(nce, mode);
                                        dpath->parent[stage-2].status =
                                                DIFF_STATUS_MODIFIED;
                                }
@@ -435,6 +436,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
                                continue;
                }
 
+               if (ce_uptodate(ce))
+                       continue;
                if (lstat(ce->name, &st) < 0) {
                        if (errno != ENOENT && errno != ENOTDIR) {
                                perror(ce->name);
@@ -442,15 +445,15 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
                        }
                        if (silent_on_removed)
                                continue;
-                       diff_addremove(&revs->diffopt, '-', ntohl(ce->ce_mode),
+                       diff_addremove(&revs->diffopt, '-', ce->ce_mode,
                                       ce->sha1, ce->name, NULL);
                        continue;
                }
                changed = ce_match_stat(ce, &st, ce_option);
                if (!changed && !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
                        continue;
-               oldmode = ntohl(ce->ce_mode);
-               newmode = ntohl(ce_mode_from_stat(ce, st.st_mode));
+               oldmode = ce->ce_mode;
+               newmode = ce_mode_from_stat(ce, st.st_mode);
                diff_change(&revs->diffopt, oldmode, newmode,
                            ce->sha1, (changed ? null_sha1 : ce->sha1),
                            ce->name, NULL);
@@ -471,7 +474,7 @@ static void diff_index_show_file(struct rev_info *revs,
                                 struct cache_entry *ce,
                                 unsigned char *sha1, unsigned int mode)
 {
-       diff_addremove(&revs->diffopt, prefix[0], ntohl(mode),
+       diff_addremove(&revs->diffopt, prefix[0], mode,
                       sha1, ce->name, NULL);
 }
 
@@ -550,14 +553,14 @@ static int show_modified(struct rev_info *revs,
                p->len = pathlen;
                memcpy(p->path, new->name, pathlen);
                p->path[pathlen] = 0;
-               p->mode = ntohl(mode);
+               p->mode = mode;
                hashclr(p->sha1);
                memset(p->parent, 0, 2 * sizeof(struct combine_diff_parent));
                p->parent[0].status = DIFF_STATUS_MODIFIED;
-               p->parent[0].mode = ntohl(new->ce_mode);
+               p->parent[0].mode = new->ce_mode;
                hashcpy(p->parent[0].sha1, new->sha1);
                p->parent[1].status = DIFF_STATUS_MODIFIED;
-               p->parent[1].mode = ntohl(old->ce_mode);
+               p->parent[1].mode = old->ce_mode;
                hashcpy(p->parent[1].sha1, old->sha1);
                show_combined_diff(p, 2, revs->dense_combined_merges, revs);
                free(p);
@@ -569,119 +572,154 @@ static int show_modified(struct rev_info *revs,
            !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
                return 0;
 
-       mode = ntohl(mode);
-       oldmode = ntohl(oldmode);
-
        diff_change(&revs->diffopt, oldmode, mode,
                    old->sha1, sha1, old->name, NULL);
        return 0;
 }
 
-static int diff_cache(struct rev_info *revs,
-                     struct cache_entry **ac, int entries,
-                     const char **pathspec,
-                     int cached, int match_missing)
+/*
+ * This turns all merge entries into "stage 3". That guarantees that
+ * when we read in the new tree (into "stage 1"), we won't lose sight
+ * of the fact that we had unmerged entries.
+ */
+static void mark_merge_entries(void)
 {
-       while (entries) {
-               struct cache_entry *ce = *ac;
-               int same = (entries > 1) && ce_same_name(ce, ac[1]);
+       int i;
+       for (i = 0; i < active_nr; i++) {
+               struct cache_entry *ce = active_cache[i];
+               if (!ce_stage(ce))
+                       continue;
+               ce->ce_flags |= CE_STAGEMASK;
+       }
+}
 
-               if (DIFF_OPT_TST(&revs->diffopt, QUIET) &&
-                       DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
-                       break;
+/*
+ * This gets a mix of an existing index and a tree, one pathname entry
+ * at a time. The index entry may be a single stage-0 one, but it could
+ * also be multiple unmerged entries (in which case idx_pos/idx_nr will
+ * give you the position and number of entries in the index).
+ */
+static void do_oneway_diff(struct unpack_trees_options *o,
+       struct cache_entry *idx,
+       struct cache_entry *tree,
+       int idx_pos, int idx_nr)
+{
+       struct rev_info *revs = o->unpack_data;
+       int match_missing, cached;
 
-               if (!ce_path_match(ce, pathspec))
-                       goto skip_entry;
+       /*
+        * Backward compatibility wart - "diff-index -m" does
+        * not mean "do not ignore merges", but "match_missing".
+        *
+        * But with the revision flag parsing, that's found in
+        * "!revs->ignore_merges".
+        */
+       cached = o->index_only;
+       match_missing = !revs->ignore_merges;
+
+       if (cached && idx && ce_stage(idx)) {
+               if (tree)
+                       diff_unmerge(&revs->diffopt, idx->name, idx->ce_mode, idx->sha1);
+               return;
+       }
+
+       /*
+        * Something added to the tree?
+        */
+       if (!tree) {
+               show_new_file(revs, idx, cached, match_missing);
+               return;
+       }
 
-               switch (ce_stage(ce)) {
-               case 0:
-                       /* No stage 1 entry? That means it's a new file */
-                       if (!same) {
-                               show_new_file(revs, ce, cached, match_missing);
+       /*
+        * Something removed from the tree?
+        */
+       if (!idx) {
+               diff_index_show_file(revs, "-", tree, tree->sha1, tree->ce_mode);
+               return;
+       }
+
+       /* Show difference between old and new */
+       show_modified(revs, tree, idx, 1, cached, match_missing);
+}
+
+/*
+ * Count how many index entries go with the first one
+ */
+static inline int count_skip(const struct cache_entry *src, int pos)
+{
+       int skip = 1;
+
+       /* We can only have multiple entries if the first one is not stage-0 */
+       if (ce_stage(src)) {
+               struct cache_entry **p = active_cache + pos;
+               int namelen = ce_namelen(src);
+
+               for (;;) {
+                       const struct cache_entry *ce;
+                       pos++;
+                       if (pos >= active_nr)
                                break;
-                       }
-                       /* Show difference between old and new */
-                       show_modified(revs, ac[1], ce, 1,
-                                     cached, match_missing);
-                       break;
-               case 1:
-                       /* No stage 3 (merge) entry?
-                        * That means it's been deleted.
-                        */
-                       if (!same) {
-                               diff_index_show_file(revs, "-", ce,
-                                                    ce->sha1, ce->ce_mode);
+                       ce = *++p;
+                       if (ce_namelen(ce) != namelen)
                                break;
-                       }
-                       /* We come here with ce pointing at stage 1
-                        * (original tree) and ac[1] pointing at stage
-                        * 3 (unmerged).  show-modified with
-                        * report-missing set to false does not say the
-                        * file is deleted but reports true if work
-                        * tree does not have it, in which case we
-                        * fall through to report the unmerged state.
-                        * Otherwise, we show the differences between
-                        * the original tree and the work tree.
-                        */
-                       if (!cached &&
-                           !show_modified(revs, ce, ac[1], 0,
-                                          cached, match_missing))
+                       if (memcmp(ce->name, src->name, namelen))
                                break;
-                       diff_unmerge(&revs->diffopt, ce->name,
-                                    ntohl(ce->ce_mode), ce->sha1);
-                       break;
-               case 3:
-                       diff_unmerge(&revs->diffopt, ce->name,
-                                    0, null_sha1);
-                       break;
-
-               default:
-                       die("impossible cache entry stage");
+                       skip++;
                }
-
-skip_entry:
-               /*
-                * Ignore all the different stages for this file,
-                * we've handled the relevant cases now.
-                */
-               do {
-                       ac++;
-                       entries--;
-               } while (entries && ce_same_name(ce, ac[0]));
        }
-       return 0;
+       return skip;
 }
 
 /*
- * This turns all merge entries into "stage 3". That guarantees that
- * when we read in the new tree (into "stage 1"), we won't lose sight
- * of the fact that we had unmerged entries.
+ * The unpack_trees() interface is designed for merging, so
+ * the different source entries are designed primarily for
+ * the source trees, with the old index being really mainly
+ * used for being replaced by the result.
+ *
+ * For diffing, the index is more important, and we only have a
+ * single tree.
+ *
+ * We're supposed to return how many index entries we want to skip.
+ *
+ * This wrapper makes it all more readable, and takes care of all
+ * the fairly complex unpack_trees() semantic requirements, including
+ * the skipping, the path matching, the type conflict cases etc.
  */
-static void mark_merge_entries(void)
+static int oneway_diff(struct cache_entry **src,
+       struct unpack_trees_options *o,
+       int index_pos)
 {
-       int i;
-       for (i = 0; i < active_nr; i++) {
-               struct cache_entry *ce = active_cache[i];
-               if (!ce_stage(ce))
-                       continue;
-               ce->ce_flags |= htons(CE_STAGEMASK);
-       }
+       int skip = 0;
+       struct cache_entry *idx = src[0];
+       struct cache_entry *tree = src[1];
+       struct rev_info *revs = o->unpack_data;
+
+       if (index_pos >= 0)
+               skip = count_skip(idx, index_pos);
+
+       /*
+        * Unpack-trees generates a DF/conflict entry if
+        * there was a directory in the index and a tree
+        * in the tree. From a diff standpoint, that's a
+        * delete of the tree and a create of the file.
+        */
+       if (tree == o->df_conflict_entry)
+               tree = NULL;
+
+       if (ce_path_match(idx ? idx : tree, revs->prune_data))
+               do_oneway_diff(o, idx, tree, index_pos, skip);
+
+       return skip;
 }
 
 int run_diff_index(struct rev_info *revs, int cached)
 {
-       int ret;
        struct object *ent;
        struct tree *tree;
        const char *tree_name;
-       int match_missing = 0;
-
-       /*
-        * Backward compatibility wart - "diff-index -m" does
-        * not mean "do not ignore merges", but totally different.
-        */
-       if (!revs->ignore_merges)
-               match_missing = 1;
+       struct unpack_trees_options opts;
+       struct tree_desc t;
 
        mark_merge_entries();
 
@@ -690,13 +728,20 @@ int run_diff_index(struct rev_info *revs, int cached)
        tree = parse_tree_indirect(ent->sha1);
        if (!tree)
                return error("bad tree object %s", tree_name);
-       if (read_tree(tree, 1, revs->prune_data))
-               return error("unable to read tree object %s", tree_name);
-       ret = diff_cache(revs, active_cache, active_nr, revs->prune_data,
-                        cached, match_missing);
+
+       memset(&opts, 0, sizeof(opts));
+       opts.head_idx = 1;
+       opts.index_only = cached;
+       opts.merge = 1;
+       opts.fn = oneway_diff;
+       opts.unpack_data = revs;
+
+       init_tree_desc(&t, tree->buffer, tree->size);
+       unpack_trees(1, &t, &opts);
+
        diffcore_std(&revs->diffopt);
        diff_flush(&revs->diffopt);
-       return ret;
+       return 0;
 }
 
 int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
@@ -706,6 +751,8 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
        int i;
        struct cache_entry **dst;
        struct cache_entry *last = NULL;
+       struct unpack_trees_options opts;
+       struct tree_desc t;
 
        /*
         * This is used by git-blame to run diff-cache internally;
@@ -722,8 +769,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
                        cache_tree_invalidate_path(active_cache_tree,
                                                   ce->name);
                        last = ce;
-                       ce->ce_mode = 0;
-                       ce->ce_flags &= ~htons(CE_STAGEMASK);
+                       ce->ce_flags |= CE_REMOVE;
                }
                *dst++ = ce;
        }
@@ -734,8 +780,15 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
        tree = parse_tree_indirect(tree_sha1);
        if (!tree)
                die("bad tree object %s", sha1_to_hex(tree_sha1));
-       if (read_tree(tree, 1, opt->paths))
-               return error("unable to read tree %s", sha1_to_hex(tree_sha1));
-       return diff_cache(&revs, active_cache, active_nr, revs.prune_data,
-                         1, 0);
+
+       memset(&opts, 0, sizeof(opts));
+       opts.head_idx = 1;
+       opts.index_only = 1;
+       opts.merge = 1;
+       opts.fn = oneway_diff;
+       opts.unpack_data = &revs;
+
+       init_tree_desc(&t, tree->buffer, tree->size);
+       unpack_trees(1, &t, &opts);
+       return 0;
 }
diff --git a/diff.c b/diff.c
index 5b8afdcb05abd4f634b49adb2f521fc75e220647..41ec2ced78d7f0d8fe86eea0285b76f70843a3a8 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -57,7 +57,7 @@ static int parse_diff_color_slot(const char *var, int ofs)
 static struct ll_diff_driver {
        const char *name;
        struct ll_diff_driver *next;
-       char *cmd;
+       const char *cmd;
 } *user_diff, **user_diff_tail;
 
 /*
@@ -86,10 +86,7 @@ static int parse_lldiff_command(const char *var, const char *ep, const char *val
                user_diff_tail = &(drv->next);
        }
 
-       if (!value)
-               return error("%s: lacks value", var);
-       drv->cmd = strdup(value);
-       return 0;
+       return git_config_string(&(drv->cmd), var, value);
 }
 
 /*
@@ -158,16 +155,16 @@ int git_diff_ui_config(const char *var, const char *value)
                return 0;
        }
        if (!strcmp(var, "diff.external")) {
+               if (!value)
+                       return config_error_nonbool(var);
                external_diff_cmd_cfg = xstrdup(value);
                return 0;
        }
        if (!prefixcmp(var, "diff.")) {
                const char *ep = strrchr(var, '.');
 
-               if (ep != var + 4) {
-                       if (!strcmp(ep, ".command"))
-                               return parse_lldiff_command(var, ep, value);
-               }
+               if (ep != var + 4 && !strcmp(ep, ".command"))
+                       return parse_lldiff_command(var, ep, value);
        }
 
        return git_diff_basic_config(var, value);
@@ -177,6 +174,8 @@ int git_diff_basic_config(const char *var, const char *value)
 {
        if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
                int slot = parse_diff_color_slot(var, 11);
+               if (!value)
+                       return config_error_nonbool(var);
                color_parse(value, var, diff_colors[slot]);
                return 0;
        }
@@ -184,8 +183,11 @@ int git_diff_basic_config(const char *var, const char *value)
        if (!prefixcmp(var, "diff.")) {
                const char *ep = strrchr(var, '.');
                if (ep != var + 4) {
-                       if (!strcmp(ep, ".funcname"))
+                       if (!strcmp(ep, ".funcname")) {
+                               if (!value)
+                                       return config_error_nonbool(var);
                                return parse_funcname_pattern(var, ep, value);
+                       }
                }
        }
 
@@ -1011,6 +1013,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
        char *err;
 
        if (line[0] == '+') {
+               data->lineno++;
                data->status = check_and_emit_line(line + 1, len - 1,
                    data->ws_rule, NULL, NULL, NULL, NULL);
                if (!data->status)
@@ -1021,13 +1024,12 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
                emit_line(set, reset, line, 1);
                (void)check_and_emit_line(line + 1, len - 1, data->ws_rule,
                    stdout, set, reset, ws);
-               data->lineno++;
        } else if (line[0] == ' ')
                data->lineno++;
        else if (line[0] == '@') {
                char *plus = strchr(line, '+');
                if (plus)
-                       data->lineno = strtol(plus, NULL, 10);
+                       data->lineno = strtol(plus, NULL, 10) - 1;
                else
                        die("invalid diff");
        }
@@ -1510,17 +1512,22 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
        if (pos < 0)
                return 0;
        ce = active_cache[pos];
-       if ((lstat(name, &st) < 0) ||
-           !S_ISREG(st.st_mode) || /* careful! */
-           ce_match_stat(ce, &st, 0) ||
-           hashcmp(sha1, ce->sha1))
+
+       /*
+        * This is not the sha1 we are looking for, or
+        * unreusable because it is not a regular file.
+        */
+       if (hashcmp(sha1, ce->sha1) || !S_ISREG(ce->ce_mode))
                return 0;
-       /* we return 1 only when we can stat, it is a regular file,
-        * stat information matches, and sha1 recorded in the cache
-        * matches.  I.e. we know the file in the work tree really is
-        * the same as the <name, sha1> pair.
+
+       /*
+        * If ce matches the file in the work tree, we can reuse it.
         */
-       return 1;
+       if (ce_uptodate(ce) ||
+           (!lstat(name, &st) && !ce_match_stat(ce, &st, 0)))
+               return 1;
+
+       return 0;
 }
 
 static int populate_from_stdin(struct diff_filespec *s)
diff --git a/dir.c b/dir.c
index 3e345c2fc508eb82e66f4ffe2c825670f0bddd99..6543105b9622212430a9e5ed131a81074e019d9a 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -346,7 +346,7 @@ static struct dir_entry *dir_entry_new(const char *pathname, int len)
 
 struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len)
 {
-       if (cache_name_pos(pathname, len) >= 0)
+       if (cache_name_exists(pathname, len))
                return NULL;
 
        ALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);
@@ -391,7 +391,7 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
                        break;
                if (endchar == '/')
                        return index_directory;
-               if (!endchar && S_ISGITLINK(ntohl(ce->ce_mode)))
+               if (!endchar && S_ISGITLINK(ce->ce_mode))
                        return index_gitdir;
        }
        return index_nonexistent;
diff --git a/entry.c b/entry.c
index 257ab46e943f1f8b7445f01c10d949224c17112f..44f4b897d4ff7afff7dbab92ce8754645ad8da6a 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -103,7 +103,7 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
        int fd;
        long wrote;
 
-       switch (ntohl(ce->ce_mode) & S_IFMT) {
+       switch (ce->ce_mode & S_IFMT) {
                char *new;
                struct strbuf buf;
                unsigned long size;
@@ -129,7 +129,7 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
                        strcpy(path, ".merge_file_XXXXXX");
                        fd = mkstemp(path);
                } else
-                       fd = create_file(path, ntohl(ce->ce_mode));
+                       fd = create_file(path, ce->ce_mode);
                if (fd < 0) {
                        free(new);
                        return error("git-checkout-index: unable to create file %s (%s)",
@@ -221,7 +221,7 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *t
                unlink(path);
                if (S_ISDIR(st.st_mode)) {
                        /* If it is a gitlink, leave it alone! */
-                       if (S_ISGITLINK(ntohl(ce->ce_mode)))
+                       if (S_ISGITLINK(ce->ce_mode))
                                return 0;
                        if (!state->force)
                                return error("%s is a directory", path);
index 18a1c4eec49bfddcb81d6669c83f8f97a218d7bf..fa3633372b8249899ff1e57a2f1431de029b211d 100644 (file)
@@ -30,10 +30,10 @@ int core_compression_seen;
 size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
 size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
 size_t delta_base_cache_limit = 16 * 1024 * 1024;
-char *pager_program;
+const char *pager_program;
 int pager_use_color = 1;
-char *editor_program;
-char *excludes_file;
+const char *editor_program;
+const char *excludes_file;
 int auto_crlf = 0;     /* 1: both ways, -1: only when adding git objects */
 unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 
index a523b171e22f83d6a656b372cf20afe52d27d1b2..0d3449f2cef93ae0ece87f4204d5e817d6e62439 100644 (file)
@@ -372,6 +372,8 @@ static void write_branch_report(FILE *rpt, struct branch *b)
        fputc('\n', rpt);
 }
 
+static void dump_marks_helper(FILE *, uintmax_t, struct mark_set *);
+
 static void write_crash_report(const char *err)
 {
        char *loc = git_path("fast_import_crash_%d", getpid());
@@ -430,12 +432,37 @@ static void write_crash_report(const char *err)
                        write_branch_report(rpt, b);
        }
 
+       if (first_tag) {
+               struct tag *tg;
+               fputc('\n', rpt);
+               fputs("Annotated Tags\n", rpt);
+               fputs("--------------\n", rpt);
+               for (tg = first_tag; tg; tg = tg->next_tag) {
+                       fputs(sha1_to_hex(tg->sha1), rpt);
+                       fputc(' ', rpt);
+                       fputs(tg->name, rpt);
+                       fputc('\n', rpt);
+               }
+       }
+
+       fputc('\n', rpt);
+       fputs("Marks\n", rpt);
+       fputs("-----\n", rpt);
+       if (mark_file)
+               fprintf(rpt, "  exported to %s\n", mark_file);
+       else
+               dump_marks_helper(rpt, 0, marks);
+
        fputc('\n', rpt);
        fputs("-------------------\n", rpt);
        fputs("END OF CRASH REPORT\n", rpt);
        fclose(rpt);
 }
 
+static void end_packfile(void);
+static void unkeep_all_packs(void);
+static void dump_marks(void);
+
 static NORETURN void die_nicely(const char *err, va_list params)
 {
        static int zombie;
@@ -449,6 +476,9 @@ static NORETURN void die_nicely(const char *err, va_list params)
        if (!zombie) {
                zombie = 1;
                write_crash_report(message);
+               end_packfile();
+               unkeep_all_packs();
+               dump_marks();
        }
        exit(128);
 }
@@ -1204,6 +1234,8 @@ static void load_tree(struct tree_entry *root)
                        die("Not a tree: %s", sha1_to_hex(sha1));
                t->delta_depth = myoe->depth;
                buf = gfi_unpack_entry(myoe, &size);
+               if (!buf)
+                       die("Can't load tree %s", sha1_to_hex(sha1));
        } else {
                enum object_type type;
                buf = read_sha1_file(sha1, &type, &size);
index a7888ea302cde44b072cc019394ae43dbb4cf95d..8d35ef60bf6d975939362a9c01ece4026140f8c9 100644 (file)
@@ -16,6 +16,8 @@ struct fetch_pack_args
 };
 
 struct ref *fetch_pack(struct fetch_pack_args *args,
+               int fd[], struct child_process *conn,
+               const struct ref *ref,
                const char *dest,
                int nr_heads,
                char **heads,
index 5385249890698632dedcaf8dda03d865f66abca9..6594a62919adcf2d1c524cc24435b6fe444f9d52 100755 (executable)
@@ -26,6 +26,9 @@ OPTIONS_SPEC=
 . git-sh-setup
 require_work_tree
 
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+
 sq() {
        @@PERL@@ -e '
                for (@ARGV) {
@@ -60,7 +63,8 @@ bisect_start() {
        # top-of-line master first!
        #
        head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) ||
-       die "Bad HEAD - I need a symbolic ref"
+       head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
+       die "Bad HEAD - I need a HEAD"
        case "$head" in
        refs/heads/bisect)
                if [ -s "$GIT_DIR/head-name" ]; then
@@ -70,7 +74,7 @@ bisect_start() {
                fi
                git checkout $branch || exit
                ;;
-       refs/heads/*)
+       refs/heads/*|$_x40)
                [ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree"
                echo "${head#refs/heads/}" >"$GIT_DIR/head-name"
                ;;
@@ -131,7 +135,7 @@ bisect_write() {
                *)              die "Bad bisect_write argument: $state" ;;
        esac
        git update-ref "refs/bisect/$tag" "$rev"
-       echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
+       echo "# $state: $(git show-branch $rev)" >>"$GIT_DIR/BISECT_LOG"
        test -z "$nolog" && echo "git-bisect $state $rev" >>"$GIT_DIR/BISECT_LOG"
 }
 
index d2e50c34292bc0ccb6e914ed595da9fd8a7e141d..2a8ad1e9f4cbc2c21b83fd72fae1e0d2e582fbdc 100755 (executable)
@@ -5,6 +5,7 @@ use Getopt::Std;
 use File::Temp qw(tempdir);
 use Data::Dumper;
 use File::Basename qw(basename dirname);
+use File::Spec;
 
 our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d, $opt_u, $opt_w);
 
@@ -15,17 +16,15 @@ $opt_h && usage();
 die "Need at least one commit identifier!" unless @ARGV;
 
 if ($opt_w) {
+       # Remember where GIT_DIR is before changing to CVS checkout
        unless ($ENV{GIT_DIR}) {
-               # Remember where our GIT_DIR is before changing to CVS checkout
+               # No GIT_DIR set. Figure it out for ourselves
                my $gd =`git-rev-parse --git-dir`;
                chomp($gd);
-               if ($gd eq '.git') {
-                       my $wd = `pwd`;
-                       chomp($wd);
-                       $gd = $wd."/.git"       ;
-               }
                $ENV{GIT_DIR} = $gd;
        }
+       # Make sure GIT_DIR is absolute
+       $ENV{GIT_DIR} = File::Spec->rel2abs($ENV{GIT_DIR});
 
        if (! -d $opt_w."/CVS" ) {
                die "$opt_w is not a CVS checkout";
index 5694978c466df8e97483b5bdf5e9ae00b481c56c..9516242338d95687b4354a6d21692cbd10547899 100755 (executable)
@@ -164,7 +164,7 @@ if ($#ARGV == 0) {
 
 our @mergerx = ();
 if ($opt_m) {
-       @mergerx = ( qr/\W(?:from|of|merge|merging|merged) (\w+)/i );
+       @mergerx = ( qr/\b(?:from|of|merge|merging|merged) (\w+)/i );
 }
 if ($opt_M) {
        push (@mergerx, qr/$opt_M/);
index ff716cabb084526ddb5655c3b7c6dd02f4ed1b39..49e13f0bb1ed2bcb6e85455f24dffa912927d67a 100755 (executable)
@@ -276,10 +276,11 @@ while read commit parents; do
                eval "$filter_tree" < /dev/null ||
                        die "tree filter failed: $filter_tree"
 
-               git diff-index -r $commit | cut -f 2- | tr '\012' '\000' | \
-                       xargs -0 git update-index --add --replace --remove
-               git ls-files -z --others | \
-                       xargs -0 git update-index --add --replace --remove
+               (
+                       git diff-index -r --name-only $commit
+                       git ls-files --others
+               ) |
+               git update-index --add --replace --remove --stdin
        fi
 
        eval "$filter_index" < /dev/null ||
index 34438cdf5cc219ac71cbc90a23c23550276f5af2..081d7550a7dbc91d8360822a4da3ca51c66a33a2 100644 (file)
@@ -13,6 +13,7 @@ GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
 
 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
+uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
 
 SCRIPT_SH = git-gui.sh
 GITGUI_MAIN := git-gui
@@ -93,7 +94,14 @@ endif
 
 TCL_PATH   ?= tclsh
 TCLTK_PATH ?= wish
-TKFRAMEWORK = /Library/Frameworks/Tk.framework/Resources/Wish.app
+
+ifeq ($(uname_S),Darwin)
+       TKFRAMEWORK = /Library/Frameworks/Tk.framework/Resources/Wish.app
+       ifeq ($(shell expr "$(uname_R)" : '9\.'),2)
+               TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish\ Shell.app
+       endif
+       TKEXECUTABLE = $(shell basename "$(TKFRAMEWORK)" .app)
+endif
 
 ifeq ($(findstring $(MAKEFLAGS),s),s)
 QUIET_GEN =
@@ -147,7 +155,7 @@ git-gui: GIT-VERSION-FILE GIT-GUI-VARS
        echo then >>$@+ && \
        echo '  'echo \'git-gui version '$(GITGUI_VERSION)'\' >>$@+ && \
        echo else >>$@+ && \
-       echo '  'exec \''$(libdir_SQ)/Git Gui.app/Contents/MacOS/Wish'\' \
+       echo '  'exec \''$(libdir_SQ)/Git Gui.app/Contents/MacOS/$(subst \,,$(TKEXECUTABLE))'\' \
                '"$$0" "$$@"' >>$@+ && \
        echo fi >>$@+ && \
        chmod +x $@+ && \
@@ -157,14 +165,15 @@ Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-VARS \
                macosx/Info.plist \
                macosx/git-gui.icns \
                macosx/AppMain.tcl \
-               $(TKFRAMEWORK)/Contents/MacOS/Wish
+               $(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)
        $(QUIET_GEN)rm -rf '$@' '$@'+ && \
        mkdir -p '$@'+/Contents/MacOS && \
        mkdir -p '$@'+/Contents/Resources/Scripts && \
-       cp '$(subst ','\'',$(TKFRAMEWORK))/Contents/MacOS/Wish' \
+       cp '$(subst ','\'',$(subst \,,$(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)))' \
                '$@'+/Contents/MacOS && \
        cp macosx/git-gui.icns '$@'+/Contents/Resources && \
        sed -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
+               -e 's/@@GITGUI_TKEXECUTABLE@@/$(TKEXECUTABLE)/g' \
                macosx/Info.plist \
                >'$@'+/Contents/Info.plist && \
        sed -e 's|@@gitexecdir@@|$(gitexecdir_SQ)|' \
index f42e461fd42ad37075d433f3509d6bd415a0b97a..5d65272e26dd08fc3abb8bf8cdbf57065da53bcc 100755 (executable)
@@ -612,6 +612,7 @@ set default_config(gui.pruneduringfetch) false
 set default_config(gui.trustmtime) false
 set default_config(gui.diffcontext) 5
 set default_config(gui.newbranchtemplate) {}
+set default_config(gui.spellingdictionary) {}
 set default_config(gui.fontui) [font configure font_ui]
 set default_config(gui.fontdiff) [font configure font_diff]
 set font_descs {
@@ -1683,6 +1684,7 @@ set is_quitting 0
 proc do_quit {} {
        global ui_comm is_quitting repo_config commit_type
        global GITGUI_BCK_exists GITGUI_BCK_i
+       global ui_comm_spell
 
        if {$is_quitting} return
        set is_quitting 1
@@ -1710,6 +1712,12 @@ proc do_quit {} {
                        }
                }
 
+               # -- Cancel our spellchecker if its running.
+               #
+               if {[info exists ui_comm_spell]} {
+                       $ui_comm_spell stop
+               }
+
                # -- Remove our editor backup, its not needed.
                #
                after cancel $GITGUI_BCK_i
@@ -2454,7 +2462,7 @@ $ctxm add separator
 $ctxm add command \
        -label [mc "Sign Off"] \
        -command do_signoff
-bind_button3 $ui_comm "tk_popup $ctxm %X %Y"
+set ui_comm_ctxm $ctxm
 
 # -- Diff Header
 #
@@ -2857,6 +2865,30 @@ if {[winfo exists $ui_comm]} {
        }
 
        backup_commit_buffer
+
+       # -- If the user has aspell available we can drive it
+       #    in pipe mode to spellcheck the commit message.
+       #
+       set spell_cmd [list |]
+       set spell_dict [get_config gui.spellingdictionary]
+       lappend spell_cmd aspell
+       if {$spell_dict ne {}} {
+               lappend spell_cmd --master=$spell_dict
+       }
+       lappend spell_cmd --mode=none
+       lappend spell_cmd --encoding=utf-8
+       lappend spell_cmd pipe
+       if {$spell_dict eq {none}
+        || [catch {set spell_fd [open $spell_cmd r+]} spell_err]} {
+               bind_button3 $ui_comm [list tk_popup $ui_comm_ctxm %X %Y]
+       } else {
+               set ui_comm_spell [spellcheck::init \
+                       $spell_fd \
+                       $ui_comm \
+                       $ui_comm_ctxm \
+               ]
+       }
+       unset -nocomplain spell_cmd spell_fd spell_err spell_dict
 }
 
 lock_index begin-read
index 719fc547b3e157cdb14a8a09ba77a1d7c5f1f585..47be8eb97ab79188bba8dca18f3784327302ba9a 100644 (file)
@@ -4,6 +4,7 @@
 proc do_about {} {
        global appvers copyright oguilib
        global tcl_patchLevel tk_patchLevel
+       global ui_comm_spell
 
        set w .about_dialog
        toplevel $w
@@ -40,6 +41,10 @@ proc do_about {} {
                append v "Tcl version $tcl_patchLevel"
                append v ", Tk version $tk_patchLevel"
        }
+       if {[info exists ui_comm_spell]} {
+               append v "\n"
+               append v [$ui_comm_spell version]
+       }
 
        set d {}
        append d "git wrapper: $::_git\n"
index f24396692474e3da66f9502b2f06f13583a3deeb..6e1411711bd46df08c09fd2bc371b017050a8368 100644 (file)
@@ -280,7 +280,7 @@ The rescan will be automatically started now.
        } elseif {[is_config_true gui.trustmtime]} {
                _readtree $this
        } else {
-               ui_status {Refreshing file status...}
+               ui_status [mc "Refreshing file status..."]
                set fd [git_read update-index \
                        -q \
                        --unmerged \
@@ -320,7 +320,7 @@ method _readtree {} {
        set readtree_d {}
        $::main_status start \
                [mc "Updating working directory to '%s'..." [_name $this]] \
-               {files checked out}
+               [mc "files checked out"]
 
        set fd [git_read --stderr read-tree \
                -m \
@@ -447,7 +447,7 @@ If you wanted to be on a branch, create one now starting from 'This Detached Che
        } else {
                repository_state commit_type HEAD MERGE_HEAD
                set PARENT $HEAD
-               ui_status "Checked out '$name'."
+               ui_status [mc "Checked out '%s'." $name]
        }
        delete_this
 }
index 947b201c328eef044cfe21b463e8228031f6f8cd..40a710355751836e78b65101592b753266f507ca 100644 (file)
@@ -218,7 +218,7 @@ A good commit message has the following format:
                return
        }
 
-       ui_status {Calling pre-commit hook...}
+       ui_status [mc "Calling pre-commit hook..."]
        set pch_error {}
        fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
        fileevent $fd_ph readable \
@@ -233,7 +233,7 @@ proc commit_prehook_wait {fd_ph curHEAD msg_p} {
        if {[eof $fd_ph]} {
                if {[catch {close $fd_ph}]} {
                        catch {file delete $msg_p}
-                       ui_status {Commit declined by pre-commit hook.}
+                       ui_status [mc "Commit declined by pre-commit hook."]
                        hook_failed_popup pre-commit $pch_error
                        unlock_index
                } else {
@@ -256,7 +256,7 @@ proc commit_commitmsg {curHEAD msg_p} {
                return
        }
 
-       ui_status {Calling commit-msg hook...}
+       ui_status [mc "Calling commit-msg hook..."]
        set pch_error {}
        fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
        fileevent $fd_ph readable \
@@ -271,7 +271,7 @@ proc commit_commitmsg_wait {fd_ph curHEAD msg_p} {
        if {[eof $fd_ph]} {
                if {[catch {close $fd_ph}]} {
                        catch {file delete $msg_p}
-                       ui_status {Commit declined by commit-msg hook.}
+                       ui_status [mc "Commit declined by commit-msg hook."]
                        hook_failed_popup commit-msg $pch_error
                        unlock_index
                } else {
@@ -284,7 +284,7 @@ proc commit_commitmsg_wait {fd_ph curHEAD msg_p} {
 }
 
 proc commit_writetree {curHEAD msg_p} {
-       ui_status {Committing changes...}
+       ui_status [mc "Committing changes..."]
        set fd_wt [git_read write-tree]
        fileevent $fd_wt readable \
                [list commit_committree $fd_wt $curHEAD $msg_p]
@@ -301,7 +301,7 @@ proc commit_committree {fd_wt curHEAD msg_p} {
        if {[catch {close $fd_wt} err]} {
                catch {file delete $msg_p}
                error_popup [strcat [mc "write-tree failed:"] "\n\n$err"]
-               ui_status {Commit failed.}
+               ui_status [mc "Commit failed."]
                unlock_index
                return
        }
@@ -345,7 +345,7 @@ A rescan will be automatically started now.
        if {[catch {set cmt_id [eval git $cmd]} err]} {
                catch {file delete $msg_p}
                error_popup [strcat [mc "commit-tree failed:"] "\n\n$err"]
-               ui_status {Commit failed.}
+               ui_status [mc "Commit failed."]
                unlock_index
                return
        }
@@ -365,7 +365,7 @@ A rescan will be automatically started now.
                } err]} {
                catch {file delete $msg_p}
                error_popup [strcat [mc "update-ref failed:"] "\n\n$err"]
-               ui_status {Commit failed.}
+               ui_status [mc "Commit failed."]
                unlock_index
                return
        }
index 30a244cc170a344ba99be1c7be07fdebe4333bde..3c1fce7475d362d1880d915ff4bdf168fda28593 100644 (file)
@@ -310,7 +310,7 @@ proc add_helper {txt paths} {
                update_index \
                        $txt \
                        $pathList \
-                       [concat $after {ui_status {Ready to commit.}}]
+                       [concat $after {ui_status [mc "Ready to commit."]}]
        }
 }
 
index 63e14279c183b1d0b8a62926816bb44ab6dc519c..cc26b0780882b6e8bde122c2a724d110f439d84f 100644 (file)
@@ -116,8 +116,7 @@ method _start {} {
        lappend cmd HEAD
        lappend cmd $name
 
-       set msg [mc "Merging %s and %s" $current_branch $stitle]
-       ui_status "$msg..."
+       ui_status [mc "Merging %s and %s..." $current_branch $stitle]
        set cons [console::new [mc "Merge"] "merge $stitle"]
        console::exec $cons $cmd [cb _finish $cons]
 
@@ -236,7 +235,7 @@ Continue with resetting the current changes?"]
                set fd [git_read --stderr read-tree --reset -u -v HEAD]
                fconfigure $fd -blocking 0 -translation binary
                fileevent $fd readable [namespace code [list _reset_wait $fd]]
-               $::main_status start [mc "Aborting"] {files reset}
+               $::main_status start [mc "Aborting"] [mc "files reset"]
        } else {
                unlock_index
        }
index f812e5e89a1f21e2ee96a90e83958a472539bdd5..ea80df009226d0ff14e8fe423abfe3d7a94ef56b 100644 (file)
@@ -5,6 +5,7 @@ proc save_config {} {
        global default_config font_descs
        global repo_config global_config
        global repo_config_new global_config_new
+       global ui_comm_spell
 
        foreach option $font_descs {
                set name [lindex $option 0]
@@ -52,11 +53,23 @@ proc save_config {} {
                        set repo_config($name) $value
                }
        }
+
+       if {[info exists repo_config(gui.spellingdictionary)]} {
+               set value $repo_config(gui.spellingdictionary)
+               if {$value eq {none}} {
+                       if {[info exists ui_comm_spell]} {
+                               $ui_comm_spell stop
+                       }
+               } elseif {[info exists ui_comm_spell]} {
+                       $ui_comm_spell lang $value
+               }
+       }
 }
 
 proc do_options {} {
        global repo_config global_config font_descs
        global repo_config_new global_config_new
+       global ui_comm_spell
 
        array unset repo_config_new
        array unset global_config_new
@@ -159,6 +172,32 @@ proc do_options {} {
                }
        }
 
+       set all_dicts [linsert \
+               [spellcheck::available_langs] \
+               0 \
+               none]
+       incr optid
+       foreach f {repo global} {
+               if {![info exists ${f}_config_new(gui.spellingdictionary)]} {
+                       if {[info exists ui_comm_spell]} {
+                               set value [$ui_comm_spell lang]
+                       } else {
+                               set value none
+                       }
+                       set ${f}_config_new(gui.spellingdictionary) $value
+               }
+
+               frame $w.$f.$optid
+               label $w.$f.$optid.l -text [mc "Spelling Dictionary:"]
+               eval tk_optionMenu $w.$f.$optid.v \
+                       ${f}_config_new(gui.spellingdictionary) \
+                       $all_dicts
+               pack $w.$f.$optid.l -side left -anchor w -fill x
+               pack $w.$f.$optid.v -side right -anchor e -padx 5
+               pack $w.$f.$optid -side top -anchor w -fill x
+       }
+       unset all_dicts
+
        set all_fonts [lsort [font families]]
        foreach option $font_descs {
                set name [lindex $option 0]
diff --git a/git-gui/lib/spellcheck.tcl b/git-gui/lib/spellcheck.tcl
new file mode 100644 (file)
index 0000000..7f018e4
--- /dev/null
@@ -0,0 +1,363 @@
+# git-gui spellchecking support through aspell
+# Copyright (C) 2008 Shawn Pearce
+
+class spellcheck {
+
+field s_fd     {} ; # pipe to aspell
+field s_version   ; # aspell version string
+field s_lang      ; # current language code
+
+field w_text      ; # text widget we are spelling
+field w_menu      ; # context menu for the widget
+field s_menuidx 0 ; # last index of insertion into $w_menu
+
+field s_i              ; # timer registration for _run callbacks
+field s_clear        0 ; # did we erase mispelled tags yet?
+field s_seen    [list] ; # lines last seen from $w_text in _run
+field s_checked [list] ; # lines already checked
+field s_pending [list] ; # [$line $data] sent to aspell
+field s_suggest        ; # array, list of suggestions, keyed by misspelling
+
+constructor init {pipe_fd ui_text ui_menu} {
+       set w_text $ui_text
+       set w_menu $ui_menu
+
+       _connect $this $pipe_fd
+       return $this
+}
+
+method _connect {pipe_fd} {
+       fconfigure $pipe_fd \
+               -encoding utf-8 \
+               -eofchar {} \
+               -translation lf
+
+       if {[gets $pipe_fd s_version] <= 0} {
+               close $pipe_fd
+               error [mc "Not connected to aspell"]
+       }
+       if {{@(#) } ne [string range $s_version 0 4]} {
+               close $pipe_fd
+               error [strcat [mc "Unrecognized aspell version"] ": $s_version"]
+       }
+       set s_version [string range $s_version 5 end]
+
+       puts $pipe_fd !             ; # enable terse mode
+       puts $pipe_fd {$$cr master} ; # fetch the language
+       flush $pipe_fd
+
+       gets $pipe_fd s_lang
+       regexp {[/\\]([^/\\]+)\.[^\.]+$} $s_lang _ s_lang
+
+       if {$::default_config(gui.spellingdictionary) eq {}
+        && [get_config gui.spellingdictionary] eq {}} {
+               set ::default_config(gui.spellingdictionary) $s_lang
+       }
+
+       if {$s_fd ne {}} {
+               catch {close $s_fd}
+       }
+       set s_fd $pipe_fd
+
+       fconfigure $s_fd -blocking 0
+       fileevent $s_fd readable [cb _read]
+
+       $w_text tag conf misspelled \
+               -foreground red \
+               -underline 1
+       bind_button3 $w_text [cb _popup_suggest %X %Y @%x,%y]
+
+       array unset s_suggest
+       set s_seen    [list]
+       set s_checked [list]
+       set s_pending [list]
+       _run $this
+}
+
+method lang {{n {}}} {
+       if {$n ne {} && $s_lang ne $n} {
+               set spell_cmd [list |]
+               lappend spell_cmd aspell
+               lappend spell_cmd --master=$n
+               lappend spell_cmd --mode=none
+               lappend spell_cmd --encoding=UTF-8
+               lappend spell_cmd pipe
+               _connect $this [open $spell_cmd r+]
+       }
+       return $s_lang
+}
+
+method version {} {
+       return "$s_version, $s_lang"
+}
+
+method stop {} {
+       while {$s_menuidx > 0} {
+               $w_menu delete 0
+               incr s_menuidx -1
+       }
+       $w_text tag delete misspelled
+
+       catch {close $s_fd}
+       catch {after cancel $s_i}
+       set s_fd {}
+       set s_i {}
+       set s_lang {}
+}
+
+method _popup_suggest {X Y pos} {
+       while {$s_menuidx > 0} {
+               $w_menu delete 0
+               incr s_menuidx -1
+       }
+
+       set b_loc [$w_text index "$pos wordstart"]
+       set e_loc [_wordend $this $b_loc]
+       set orig  [$w_text get $b_loc $e_loc]
+       set tags  [$w_text tag names $b_loc]
+
+       if {[lsearch -exact $tags misspelled] >= 0} {
+               if {[info exists s_suggest($orig)]} {
+                       set cnt 0
+                       foreach s $s_suggest($orig) {
+                               if {$cnt < 5} {
+                                       $w_menu insert $s_menuidx command \
+                                               -label $s \
+                                               -command [cb _replace $b_loc $e_loc $s]
+                                       incr s_menuidx
+                                       incr cnt
+                               } else {
+                                       break
+                               }
+                       }
+               } else {
+                       $w_menu insert $s_menuidx command \
+                               -label [mc "No Suggestions"] \
+                               -state disabled
+                       incr s_menuidx
+               }
+               $w_menu insert $s_menuidx separator
+               incr s_menuidx
+       }
+
+       $w_text mark set saved-insert insert
+       tk_popup $w_menu $X $Y
+}
+
+method _replace {b_loc e_loc word} {
+       $w_text configure -autoseparators 0
+       $w_text edit separator
+
+       $w_text delete $b_loc $e_loc
+       $w_text insert $b_loc $word
+
+       $w_text edit separator
+       $w_text configure -autoseparators 1
+       $w_text mark set insert saved-insert
+}
+
+method _restart_timer {} {
+       set s_i [after 300 [cb _run]]
+}
+
+proc _match_length {max_line arr_name} {
+       upvar $arr_name a
+
+       if {[llength $a] > $max_line} {
+               set a [lrange $a 0 $max_line]
+       }
+       while {[llength $a] <= $max_line} {
+               lappend a {}
+       }
+}
+
+method _wordend {pos} {
+       set pos  [$w_text index "$pos wordend"]
+       set tags [$w_text tag names $pos]
+       while {[lsearch -exact $tags misspelled] >= 0} {
+               set pos  [$w_text index "$pos +1c"]
+               set tags [$w_text tag names $pos]
+       }
+       return $pos
+}
+
+method _run {} {
+       set cur_pos  [$w_text index {insert -1c}]
+       set cur_line [lindex [split $cur_pos .] 0]
+       set max_line [lindex [split [$w_text index end] .] 0]
+       _match_length $max_line s_seen
+       _match_length $max_line s_checked
+
+       # Nothing in the message buffer?  Nothing to spellcheck.
+       #
+       if {$cur_line == 1
+        && $max_line == 2
+        && [$w_text get 1.0 end] eq "\n"} {
+               array unset s_suggest
+               _restart_timer $this
+               return
+       }
+
+       set active 0
+       for {set n 1} {$n <= $max_line} {incr n} {
+               set s [$w_text get "$n.0" "$n.end"]
+
+               # Don't spellcheck the current line unless we are at
+               # a word boundary.  The user might be typing on it.
+               #
+               if {$n == $cur_line
+                && ![regexp {^\W$} [$w_text get $cur_pos insert]]} {
+
+                       # If the current word is mispelled remove the tag
+                       # but force a spellcheck later.
+                       #
+                       set tags [$w_text tag names $cur_pos]
+                       if {[lsearch -exact $tags misspelled] >= 0} {
+                               $w_text tag remove misspelled \
+                                       "$cur_pos wordstart" \
+                                       [_wordend $this $cur_pos]
+                               lset s_seen    $n $s
+                               lset s_checked $n {}
+                       }
+
+                       continue
+               }
+
+               if {[lindex $s_seen    $n] eq $s
+                && [lindex $s_checked $n] ne $s} {
+                       # Don't send empty lines to Aspell it doesn't check them.
+                       #
+                       if {$s eq {}} {
+                               lset s_checked $n $s
+                               continue
+                       }
+
+                       # Don't send typical s-b-o lines as the emails are
+                       # almost always misspelled according to Aspell.
+                       #
+                       if {[regexp -nocase {^[a-z-]+-by:.*<.*@.*>$} $s]} {
+                               $w_text tag remove misspelled "$n.0" "$n.end"
+                               lset s_checked $n $s
+                               continue
+                       }
+
+                       puts $s_fd ^$s
+                       lappend s_pending [list $n $s]
+                       set active 1
+               } else {
+                       # Delay until another idle loop to make sure we don't
+                       # spellcheck lines the user is actively changing.
+                       #
+                       lset s_seen $n $s
+               }
+       }
+
+       if {$active} {
+               set s_clear 1
+               flush $s_fd
+       } else {
+               _restart_timer $this
+       }
+}
+
+method _read {} {
+       while {[gets $s_fd line] >= 0} {
+               set lineno [lindex $s_pending 0 0]
+
+               if {$s_clear} {
+                       $w_text tag remove misspelled "$lineno.0" "$lineno.end"
+                       set s_clear 0
+               }
+
+               if {$line eq {}} {
+                       lset s_checked $lineno [lindex $s_pending 0 1]
+                       set s_pending [lrange $s_pending 1 end]
+                       set s_clear 1
+                       continue
+               }
+
+               set sugg [list]
+               switch -- [string range $line 0 1] {
+               {& } {
+                       set line [split [string range $line 2 end] :]
+                       set info [split [lindex $line 0] { }]
+                       set orig [lindex $info 0]
+                       set offs [lindex $info 2]
+                       foreach s [split [lindex $line 1] ,] {
+                               lappend sugg [string range $s 1 end]
+                       }
+               }
+               {# } {
+                       set info [split [string range $line 2 end] { }]
+                       set orig [lindex $info 0]
+                       set offs [lindex $info 1]
+               }
+               default {
+                       puts stderr "<spell> $line"
+                       continue
+               }
+               }
+
+               incr offs -1
+               set b_loc "$lineno.$offs"
+               set e_loc [$w_text index "$lineno.$offs wordend"]
+               set curr [$w_text get $b_loc $e_loc]
+
+               # At least for English curr = "bob", orig = "bob's"
+               # so Tk didn't include the 's but Aspell did.  We
+               # try to round out the word.
+               #
+               while {$curr ne $orig
+                && [string equal -length [string length $curr] $curr $orig]} {
+                       set n_loc  [$w_text index "$e_loc +1c"]
+                       set n_curr [$w_text get $b_loc $n_loc]
+                       if {$n_curr eq $curr} {
+                               break
+                       }
+                       set curr  $n_curr
+                       set e_loc $n_loc
+               }
+
+               if {$curr eq $orig} {
+                       $w_text tag add misspelled $b_loc $e_loc
+                       if {[llength $sugg] > 0} {
+                               set s_suggest($orig) $sugg
+                       } else {
+                               unset -nocomplain s_suggest($orig)
+                       }
+               } else {
+                       unset -nocomplain s_suggest($orig)
+               }
+       }
+
+       fconfigure $s_fd -block 1
+       if {[eof $s_fd]} {
+               if {![catch {close $s_fd} err]} {
+                       set err [mc "unexpected eof from aspell"]
+               }
+               catch {after cancel $s_i}
+               $w_text tag remove misspelled 1.0 end
+               error_popup [strcat "Spell Checker Failed" "\n\n" $err]
+               return
+       }
+       fconfigure $s_fd -block 0
+
+       if {[llength $s_pending] == 0} {
+               _restart_timer $this
+       }
+}
+
+proc available_langs {} {
+       set langs [list]
+       catch {
+               set fd [open [list | aspell dump dicts] r]
+               while {[gets $fd line] >= 0} {
+                       if {$line eq {}} continue
+                       lappend langs $line
+               }
+               close $fd
+       }
+       return $langs
+}
+
+}
index 99913ec57a346ad996fefa2d3f1f51be3265170b..b3bf15fa1c1a41265460664417caf47265553a4f 100644 (file)
@@ -5,7 +5,7 @@
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleExecutable</key>
-       <string>Wish</string>
+       <string>@@GITGUI_TKEXECUTABLE@@</string>
        <key>CFBundleGetInfoString</key>
        <string>Git Gui @@GITGUI_VERSION@@ Â© 2006-2007 Shawn Pearce, et. al.</string>
        <key>CFBundleIconFile</key>
index 2dfe07e06f7bbbdc1dd439431e8c56ecf9c60cae..d7c38f9c73fbeb887f8e0dcfe73af84d3edf8138 100644 (file)
@@ -7,8 +7,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: git-gui\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-11-24 10:36+0100\n"
-"PO-Revision-Date: 2008-01-15 20:33+0100\n"
+"POT-Creation-Date: 2008-02-02 10:14+0100\n"
+"PO-Revision-Date: 2008-02-02 10:18+0100\n"
 "Last-Translator: Christian Stimming <stimming@tuhh.de>\n"
 "Language-Team: German\n"
 "MIME-Version: 1.0\n"
@@ -343,7 +343,9 @@ msgstr "Online-Dokumentation"
 #: git-gui.sh:2201
 #, tcl-format
 msgid "fatal: cannot stat path %s: No such file or directory"
-msgstr "Fehler: Verzeichnis Â»%s« kann nicht gelesen werden: Datei oder Verzeichnis nicht gefunden"
+msgstr ""
+"Fehler: Verzeichnis Â»%s« kann nicht gelesen werden: Datei oder Verzeichnis "
+"nicht gefunden"
 
 #: git-gui.sh:2234
 msgid "Current Branch:"
@@ -371,19 +373,19 @@ msgstr "Erste Versionsbeschreibung:"
 
 #: git-gui.sh:2370
 msgid "Amended Commit Message:"
-msgstr "Nachgebesserte Versionsbeschreibung:"
+msgstr "Nachgebesserte Beschreibung:"
 
 #: git-gui.sh:2371
 msgid "Amended Initial Commit Message:"
-msgstr "Nachgebesserte erste Versionsbeschreibung:"
+msgstr "Nachgebesserte erste Beschreibung:"
 
 #: git-gui.sh:2372
 msgid "Amended Merge Commit Message:"
-msgstr "Nachgebesserte ZusammenfĂ¼hrungs-Versionsbeschreibung:"
+msgstr "Nachgebesserte ZusammenfĂ¼hrungs-Beschreibung:"
 
 #: git-gui.sh:2373
 msgid "Merge Commit Message:"
-msgstr "ZusammenfĂ¼hrungs-Versionsbeschreibung:"
+msgstr "ZusammenfĂ¼hrungs-Beschreibung:"
 
 #: git-gui.sh:2374
 msgid "Commit Message:"
@@ -397,31 +399,31 @@ msgstr "Alle kopieren"
 msgid "File:"
 msgstr "Datei:"
 
-#: git-gui.sh:2545
-msgid "Refresh"
-msgstr "Aktualisieren"
-
-#: git-gui.sh:2566
+#: git-gui.sh:2573
 msgid "Apply/Reverse Hunk"
 msgstr "Kontext anwenden/umkehren"
 
-#: git-gui.sh:2572
-msgid "Decrease Font Size"
-msgstr "SchriftgrĂ¶ĂŸe verkleinern"
-
-#: git-gui.sh:2576
-msgid "Increase Font Size"
-msgstr "SchriftgrĂ¶ĂŸe vergrĂ¶ĂŸern"
-
-#: git-gui.sh:2581
+#: git-gui.sh:2579
 msgid "Show Less Context"
 msgstr "Weniger Zeilen anzeigen"
 
-#: git-gui.sh:2588
+#: git-gui.sh:2586
 msgid "Show More Context"
 msgstr "Mehr Zeilen anzeigen"
 
-#: git-gui.sh:2602
+#: git-gui.sh:2594
+msgid "Refresh"
+msgstr "Aktualisieren"
+
+#: git-gui.sh:2615
+msgid "Decrease Font Size"
+msgstr "SchriftgrĂ¶ĂŸe verkleinern"
+
+#: git-gui.sh:2619
+msgid "Increase Font Size"
+msgstr "SchriftgrĂ¶ĂŸe vergrĂ¶ĂŸern"
+
+#: git-gui.sh:2630
 msgid "Unstage Hunk From Commit"
 msgstr "Kontext aus Bereitstellung herausnehmen"
 
@@ -542,7 +544,7 @@ msgstr "Kopiert oder verschoben durch:"
 
 #: lib/branch_checkout.tcl:14 lib/branch_checkout.tcl:19
 msgid "Checkout Branch"
-msgstr "Zweig umstellen"
+msgstr "Auf Zweig umstellen"
 
 #: lib/branch_checkout.tcl:23
 msgid "Checkout"
@@ -805,11 +807,15 @@ msgstr ""
 msgid "Updating working directory to '%s'..."
 msgstr "Arbeitskopie umstellen auf Â»%s«..."
 
+#: lib/checkout_op.tcl:323
+msgid "files checked out"
+msgstr "Dateien aktualisiert"
+
 #: lib/checkout_op.tcl:353
 #, tcl-format
 msgid "Aborted checkout of '%s' (file level merging is required)."
 msgstr ""
-"Zweig umstellen von Â»%s« abgebrochen (ZusammenfĂ¼hren der Dateien ist "
+"Auf Zweig Â»%s« umstellen abgebrochen (ZusammenfĂ¼hren der Dateien ist "
 "notwendig)."
 
 #: lib/checkout_op.tcl:354
@@ -1069,15 +1075,21 @@ msgstr "FĂ¼r Objekt konnte kein Hardlink erstellt werden: %s"
 
 #: lib/choose_repository.tcl:847
 msgid "Cannot fetch branches and objects.  See console output for details."
-msgstr "Zweige und Objekte konnten nicht angefordert werden.  Kontrollieren Sie die Ausgaben auf der Konsole fĂ¼r weitere Angaben."
+msgstr ""
+"Zweige und Objekte konnten nicht angefordert werden.  Kontrollieren Sie die "
+"Ausgaben auf der Konsole fĂ¼r weitere Angaben."
 
 #: lib/choose_repository.tcl:858
 msgid "Cannot fetch tags.  See console output for details."
-msgstr "Markierungen konnten nicht angefordert werden.  Kontrollieren Sie die Ausgaben auf der Konsole fĂ¼r weitere Angaben."
+msgstr ""
+"Markierungen konnten nicht angefordert werden.  Kontrollieren Sie die "
+"Ausgaben auf der Konsole fĂ¼r weitere Angaben."
 
 #: lib/choose_repository.tcl:882
 msgid "Cannot determine HEAD.  See console output for details."
-msgstr "Die Zweigspitze (HEAD) konnte nicht gefunden werden.  Kontrollieren Sie die Ausgaben auf der Konsole fĂ¼r weitere Angaben."
+msgstr ""
+"Die Zweigspitze (HEAD) konnte nicht gefunden werden.  Kontrollieren Sie die "
+"Ausgaben auf der Konsole fĂ¼r weitere Angaben."
 
 #: lib/choose_repository.tcl:891
 #, tcl-format
@@ -1273,11 +1285,40 @@ msgstr ""
 "\n"
 "- Rest: Eine ausfĂ¼hrliche Beschreibung, warum diese Ă„nderung hilfreich ist.\n"
 
-#: lib/commit.tcl:257
+#: lib/commit.tcl:207
+#, tcl-format
+msgid "warning: Tcl does not support encoding '%s'."
+msgstr "Warning: Tcl/Tk unterstĂ¼tzt die Zeichencodierung Â»%s« nicht."
+
+#: lib/commit.tcl:221
+msgid "Calling pre-commit hook..."
+msgstr ""
+
+#: lib/commit.tcl:236
+msgid "Commit declined by pre-commit hook."
+msgstr ""
+
+#: lib/commit.tcl:259
+msgid "Calling commit-msg hook..."
+msgstr ""
+
+#: lib/commit.tcl:274
+msgid "Commit declined by commit-msg hook."
+msgstr ""
+
+#: lib/commit.tcl:287
+msgid "Committing changes..."
+msgstr "Ă„nderungen eintragen..."
+
+#: lib/commit.tcl:303
 msgid "write-tree failed:"
 msgstr "write-tree fehlgeschlagen:"
 
-#: lib/commit.tcl:275
+#: lib/commit.tcl:304 lib/commit.tcl:348 lib/commit.tcl:368
+msgid "Commit failed."
+msgstr "Eintragen fehlgeschlagen."
+
+#: lib/commit.tcl:321
 #, tcl-format
 msgid "Commit %s appears to be corrupt"
 msgstr "Version Â»%s« scheint beschädigt zu sein"
@@ -1301,12 +1342,7 @@ msgstr ""
 msgid "No changes to commit."
 msgstr "Keine Ă„nderungen, die eingetragen werden können."
 
-#: lib/commit.tcl:303
-#, tcl-format
-msgid "warning: Tcl does not support encoding '%s'."
-msgstr "Warning: Tcl/Tk unterstĂ¼tzt die Zeichencodierung Â»%s« nicht."
-
-#: lib/commit.tcl:317
+#: lib/commit.tcl:347
 msgid "commit-tree failed:"
 msgstr "commit-tree fehlgeschlagen:"
 
@@ -1440,7 +1476,8 @@ msgstr "Fehler beim Laden des Vergleichs:"
 
 #: lib/diff.tcl:302
 msgid "Failed to unstage selected hunk."
-msgstr "Fehler beim Herausnehmen des gewählten Kontexts aus der Bereitstellung."
+msgstr ""
+"Fehler beim Herausnehmen des gewählten Kontexts aus der Bereitstellung."
 
 #: lib/diff.tcl:309
 msgid "Failed to stage selected hunk."
@@ -1471,7 +1508,10 @@ msgstr "Fehler in Bereitstellung"
 msgid ""
 "Updating the Git index failed.  A rescan will be automatically started to "
 "resynchronize git-gui."
-msgstr "Das Aktualisieren der Git-Bereitstellung ist fehlgeschlagen. Eine allgemeine Git-Aktualisierung wird jetzt gestartet, um git-gui wieder mit git zu synchronisieren."
+msgstr ""
+"Das Aktualisieren der Git-Bereitstellung ist fehlgeschlagen. Eine allgemeine "
+"Git-Aktualisierung wird jetzt gestartet, um git-gui wieder mit git zu "
+"synchronisieren."
 
 #: lib/index.tcl:27
 msgid "Continue"
@@ -1486,6 +1526,10 @@ msgstr "Bereitstellung freigeben"
 msgid "Unstaging %s from commit"
 msgstr "Datei Â»%s« aus der Bereitstellung herausnehmen"
 
+#: lib/index.tcl:313
+msgid "Ready to commit."
+msgstr "Bereit zum Eintragen."
+
 #: lib/index.tcl:326
 #, tcl-format
 msgid "Adding %s"
@@ -1503,7 +1547,8 @@ msgstr "Ă„nderungen in den gewählten %i Dateien verwerfen?"
 
 #: lib/index.tcl:389
 msgid "Any unstaged changes will be permanently lost by the revert."
-msgstr "Alle nicht bereitgestellten Ă„nderungen werden beim Verwerfen verloren gehen."
+msgstr ""
+"Alle nicht bereitgestellten Ă„nderungen werden beim Verwerfen verloren gehen."
 
 #: lib/index.tcl:392
 msgid "Do Nothing"
@@ -1641,7 +1686,11 @@ msgstr ""
 msgid "Aborting"
 msgstr "Abbruch"
 
-#: lib/merge.tcl:266
+#: lib/merge.tcl:238
+msgid "files reset"
+msgstr "Dateien zurĂ¼ckgesetzt"
+
+#: lib/merge.tcl:265
 msgid "Abort failed."
 msgstr "Abbruch fehlgeschlagen."
 
index dfa48ae26364b5d30a810bfa9b55984bba582692..3f139da6c7aae3cdc81312289083c1752c6e2629 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-11-24 10:36+0100\n"
+"POT-Creation-Date: 2008-02-02 10:14+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -386,31 +386,31 @@ msgstr ""
 msgid "File:"
 msgstr ""
 
-#: git-gui.sh:2545
-msgid "Refresh"
+#: git-gui.sh:2573
+msgid "Apply/Reverse Hunk"
 msgstr ""
 
-#: git-gui.sh:2566
-msgid "Apply/Reverse Hunk"
+#: git-gui.sh:2579
+msgid "Show Less Context"
 msgstr ""
 
-#: git-gui.sh:2572
-msgid "Decrease Font Size"
+#: git-gui.sh:2586
+msgid "Show More Context"
 msgstr ""
 
-#: git-gui.sh:2576
-msgid "Increase Font Size"
+#: git-gui.sh:2594
+msgid "Refresh"
 msgstr ""
 
-#: git-gui.sh:2581
-msgid "Show Less Context"
+#: git-gui.sh:2615
+msgid "Decrease Font Size"
 msgstr ""
 
-#: git-gui.sh:2588
-msgid "Show More Context"
+#: git-gui.sh:2619
+msgid "Increase Font Size"
 msgstr ""
 
-#: git-gui.sh:2602
+#: git-gui.sh:2630
 msgid "Unstage Hunk From Commit"
 msgstr ""
 
@@ -766,6 +766,10 @@ msgstr ""
 msgid "Updating working directory to '%s'..."
 msgstr ""
 
+#: lib/checkout_op.tcl:323
+msgid "files checked out"
+msgstr ""
+
 #: lib/checkout_op.tcl:353
 #, tcl-format
 msgid "Aborted checkout of '%s' (file level merging is required)."
@@ -1182,11 +1186,40 @@ msgid ""
 "- Remaining lines: Describe why this change is good.\n"
 msgstr ""
 
-#: lib/commit.tcl:257
+#: lib/commit.tcl:207
+#, tcl-format
+msgid "warning: Tcl does not support encoding '%s'."
+msgstr ""
+
+#: lib/commit.tcl:221
+msgid "Calling pre-commit hook..."
+msgstr ""
+
+#: lib/commit.tcl:236
+msgid "Commit declined by pre-commit hook."
+msgstr ""
+
+#: lib/commit.tcl:259
+msgid "Calling commit-msg hook..."
+msgstr ""
+
+#: lib/commit.tcl:274
+msgid "Commit declined by commit-msg hook."
+msgstr ""
+
+#: lib/commit.tcl:287
+msgid "Committing changes..."
+msgstr ""
+
+#: lib/commit.tcl:303
 msgid "write-tree failed:"
 msgstr ""
 
-#: lib/commit.tcl:275
+#: lib/commit.tcl:304 lib/commit.tcl:348 lib/commit.tcl:368
+msgid "Commit failed."
+msgstr ""
+
+#: lib/commit.tcl:321
 #, tcl-format
 msgid "Commit %s appears to be corrupt"
 msgstr ""
@@ -1204,12 +1237,7 @@ msgstr ""
 msgid "No changes to commit."
 msgstr ""
 
-#: lib/commit.tcl:303
-#, tcl-format
-msgid "warning: Tcl does not support encoding '%s'."
-msgstr ""
-
-#: lib/commit.tcl:317
+#: lib/commit.tcl:347
 msgid "commit-tree failed:"
 msgstr ""
 
@@ -1373,6 +1401,10 @@ msgstr ""
 msgid "Unstaging %s from commit"
 msgstr ""
 
+#: lib/index.tcl:313
+msgid "Ready to commit."
+msgstr ""
+
 #: lib/index.tcl:326
 #, tcl-format
 msgid "Adding %s"
@@ -1491,7 +1523,11 @@ msgstr ""
 msgid "Aborting"
 msgstr ""
 
-#: lib/merge.tcl:266
+#: lib/merge.tcl:238
+msgid "files reset"
+msgstr ""
+
+#: lib/merge.tcl:265
 msgid "Abort failed."
 msgstr ""
 
index 10b0a36a3d2728d092f9943ace860205d340f220..84e37ef279b11a1461854a7cf37dc962d43e7050 100755 (executable)
@@ -30,7 +30,7 @@ test -f "$html_dir/git.html" || die "No documentation directory found."
 
 valid_tool() {
        case "$1" in
-               firefox | iceweasel | konqueror | w3m | links | lynx | dillo)
+               firefox | iceweasel | konqueror | w3m | links | lynx | dillo | open)
                        ;; # happy
                *)
                        return 1
@@ -94,6 +94,10 @@ if test -z "$browser" ; then
     else
        browser_candidates="w3m links lynx"
     fi
+    # SECURITYSESSIONID indicates an OS X GUI login session
+    if test -n "$SECURITYSESSIONID"; then
+       browser_candidates="open $browser_candidates"
+    fi
 
     for i in $browser_candidates; do
        init_browser_path $i
@@ -140,7 +144,7 @@ case "$browser" in
                ;;
        esac
        ;;
-    w3m|links|lynx)
+    w3m|links|lynx|open)
        eval "$browser_path" $pages
        ;;
     dillo)
index 402ff3782c0aaa472a2013ff3a9bef44a6cd8550..fb12b03b201836bb4c3b43a5d1120b3305d1ccf0 100755 (executable)
@@ -432,7 +432,7 @@ do
                        shift ;;
                esac
                ;;
-       --merge)
+       -m|--merge)
                # we use merge anyway
                ;;
        -C*)
index d13e4c1fea93f0c345f6638bfd8a3715c73fa693..5cd69513cf84111d1152d07f8cda77b201ffc416 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/perl -w
 
+use strict;
 use Git;
 my $git = Git->repository();
 
@@ -296,12 +297,13 @@ sub add_remote {
 
 sub update_remote {
        my ($name) = @_;
+       my @remotes;
 
         my $conf = $git->config("remotes." . $name);
        if (defined($conf)) {
                @remotes = split(' ', $conf);
        } elsif ($name eq 'default') {
-               undef @remotes;
+               @remotes = ();
                for (sort keys %$remote) {
                        my $do_fetch = $git->config_bool("remote." . $_ .
                                                    ".skipDefaultUpdate");
@@ -341,7 +343,7 @@ sub rm_remote {
        my @refs = $git->command('for-each-ref',
                '--format=%(refname) %(objectname)', "refs/remotes/$name");
        for (@refs) {
-               ($ref, $object) = split;
+               my ($ref, $object) = split;
                $git->command(qw(update-ref -d), $ref, $object);
        }
        return 0;
@@ -352,7 +354,7 @@ sub add_usage {
        exit(1);
 }
 
-local $VERBOSE = 0;
+my $VERBOSE = 0;
 @ARGV = grep {
        if ($_ eq '-v' or $_ eq '--verbose') {
                $VERBOSE=1;
@@ -395,7 +397,7 @@ elsif ($ARGV[0] eq 'update') {
                update_remote("default");
                exit(1);
        }
-       for ($i = 1; $i < @ARGV; $i++) {
+       for (my $i = 1; $i < @ARGV; $i++) {
                update_remote($ARGV[$i]);
        }
 }
index a1a9d14b00d01844509a87c598314e2ffbbfa47c..59601e36e854195c93f0a49bc3884567ed502595 100755 (executable)
@@ -24,8 +24,6 @@ use Data::Dumper;
 use Term::ANSIColor;
 use Git;
 
-$SIG{INT} = sub { print color("reset"), "\n"; exit };
-
 package FakeTerm;
 sub new {
        my ($class, $reason) = @_;
@@ -88,6 +86,12 @@ Options:
 
    --smtp-ssl     If set, connects to the SMTP server using SSL.
 
+   --suppress-cc  Suppress the specified category of auto-CC.  The category
+                 can be one of 'author' for the patch author, 'self' to
+                 avoid copying yourself, 'sob' for Signed-off-by lines,
+                 'cccmd' for the output of the cccmd, or 'all' to suppress
+                 all of these.
+
    --suppress-from Suppress sending emails to yourself. Defaults to off.
 
    --thread       Specify that the "In-Reply-To:" header should be set on all
@@ -157,7 +161,7 @@ my $compose_filename = ".msg.$$";
 
 # Variables we fill in automatically, or via prompting:
 my (@to,@cc,@initial_cc,@bcclist,@xh,
-       $initial_reply_to,$initial_subject,@files,$author,$sender,$compose,$time);
+       $initial_reply_to,$initial_subject,@files,$author,$sender,$smtp_authpass,$compose,$time);
 
 my $envelope_sender;
 
@@ -177,15 +181,16 @@ my ($quiet, $dry_run) = (0, 0);
 
 # Variables with corresponding config settings
 my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);
-my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_authpass, $smtp_ssl);
+my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_ssl);
 my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
 my ($no_validate);
+my (@suppress_cc);
 
 my %config_bool_settings = (
     "thread" => [\$thread, 1],
     "chainreplyto" => [\$chain_reply_to, 1],
-    "suppressfrom" => [\$suppress_from, 0],
-    "signedoffcc" => [\$signed_off_cc, 1],
+    "suppressfrom" => [\$suppress_from, undef],
+    "signedoffcc" => [\$signed_off_cc, undef],
     "smtpssl" => [\$smtp_ssl, 0],
 );
 
@@ -199,8 +204,32 @@ my %config_settings = (
     "aliasfiletype" => \$aliasfiletype,
     "bcc" => \@bcclist,
     "aliasesfile" => \@alias_files,
+    "suppresscc" => \@suppress_cc,
 );
 
+# Handle Uncouth Termination
+sub signal_handler {
+
+       # Make text normal
+       print color("reset"), "\n";
+
+       # SMTP password masked
+       system "stty echo";
+
+       # tmp files from --compose
+       if (-e $compose_filename) {
+               print "'$compose_filename' contains an intermediate version of the email you were composing.\n";
+       }
+       if (-e ($compose_filename . ".final")) {
+               print "'$compose_filename.final' contains the composed email.\n"
+       }
+
+       exit;
+};
+
+$SIG{TERM} = \&signal_handler;
+$SIG{INT}  = \&signal_handler;
+
 # Begin by accumulating all the variables (defined above), that we will end up
 # needing, first, from the command line:
 
@@ -214,13 +243,14 @@ my $rc = GetOptions("sender|from=s" => \$sender,
                    "smtp-server=s" => \$smtp_server,
                    "smtp-server-port=s" => \$smtp_server_port,
                    "smtp-user=s" => \$smtp_authuser,
-                   "smtp-pass=s" => \$smtp_authpass,
+                   "smtp-pass:s" => \$smtp_authpass,
                    "smtp-ssl!" => \$smtp_ssl,
                    "identity=s" => \$identity,
                    "compose" => \$compose,
                    "quiet" => \$quiet,
                    "cc-cmd=s" => \$cc_cmd,
                    "suppress-from!" => \$suppress_from,
+                   "suppress-cc=s" => \@suppress_cc,
                    "signed-off-cc|signed-off-by-cc!" => \$signed_off_cc,
                    "dry-run" => \$dry_run,
                    "envelope-sender=s" => \$envelope_sender,
@@ -266,6 +296,35 @@ foreach my $setting (values %config_bool_settings) {
        ${$setting->[0]} = $setting->[1] unless (defined (${$setting->[0]}));
 }
 
+# Set CC suppressions
+my(%suppress_cc);
+if (@suppress_cc) {
+       foreach my $entry (@suppress_cc) {
+               die "Unknown --suppress-cc field: '$entry'\n"
+                       unless $entry =~ /^(all|cccmd|cc|author|self|sob)$/;
+               $suppress_cc{$entry} = 1;
+       }
+}
+
+if ($suppress_cc{'all'}) {
+       foreach my $entry (qw (ccmd cc author self sob)) {
+               $suppress_cc{$entry} = 1;
+       }
+       delete $suppress_cc{'all'};
+}
+
+# If explicit old-style ones are specified, they trump --suppress-cc.
+$suppress_cc{'self'} = $suppress_from if defined $suppress_from;
+$suppress_cc{'sob'} = $signed_off_cc if defined $signed_off_cc;
+
+# Debugging, print out the suppressions.
+if (0) {
+       print "suppressions:\n";
+       foreach my $entry (keys %suppress_cc) {
+               printf "  %-5s -> $suppress_cc{$entry}\n", $entry;
+       }
+}
+
 my ($repoauthor) = $repo->ident_person('author');
 my ($repocommitter) = $repo->ident_person('committer');
 
@@ -355,9 +414,12 @@ if (@files) {
 my $prompting = 0;
 if (!defined $sender) {
        $sender = $repoauthor || $repocommitter;
-       do {
+
+       while (1) {
                $_ = $term->readline("Who should the emails appear to be from? [$sender] ");
-       } while (!defined $_);
+               last if defined $_;
+               print "\n";
+       }
 
        $sender = $_ if ($_);
        print "Emails will be sent from: ", $sender, "\n";
@@ -365,10 +427,14 @@ if (!defined $sender) {
 }
 
 if (!@to) {
-       do {
-               $_ = $term->readline("Who should the emails be sent to? ",
-                               "");
-       } while (!defined $_);
+
+
+       while (1) {
+               $_ = $term->readline("Who should the emails be sent to? ", "");
+               last if defined $_;
+               print "\n";
+       }
+
        my $to = $_;
        push @to, split /,/, $to;
        $prompting++;
@@ -390,19 +456,22 @@ sub expand_aliases {
 @bcclist = expand_aliases(@bcclist);
 
 if (!defined $initial_subject && $compose) {
-       do {
-               $_ = $term->readline("What subject should the initial email start with? ",
-                       $initial_subject);
-       } while (!defined $_);
+       while (1) {
+               $_ = $term->readline("What subject should the initial email start with? ", $initial_subject);
+               last if defined $_;
+               print "\n";
+       }
+
        $initial_subject = $_;
        $prompting++;
 }
 
 if ($thread && !defined $initial_reply_to && $prompting) {
-       do {
-               $_= $term->readline("Message-ID to be used as In-Reply-To for the first email? ",
-                       $initial_reply_to);
-       } while (!defined $_);
+       while (1) {
+               $_= $term->readline("Message-ID to be used as In-Reply-To for the first email? ", $initial_reply_to);
+               last if defined $_;
+               print "\n";
+       }
 
        $initial_reply_to = $_;
 }
@@ -453,9 +522,11 @@ EOT
        close(C);
        close(C2);
 
-       do {
+       while (1) {
                $_ = $term->readline("Send this email? (y|n) ");
-       } while (!defined $_);
+               last if defined $_;
+               print "\n";
+       }
 
        if (uc substr($_,0,1) ne 'Y') {
                cleanup_compose_files();
@@ -647,9 +718,26 @@ X-Mailer: git-send-email $gitversion
                        die "Unable to initialize SMTP properly.  Is there something wrong with your config?";
                }
 
-               if ((defined $smtp_authuser) && (defined $smtp_authpass)) {
+               if (defined $smtp_authuser) {
+
+                       if (!defined $smtp_authpass) {
+
+                               system "stty -echo";
+
+                               do {
+                                       print "Password: ";
+                                       $_ = <STDIN>;
+                                       print "\n";
+                               } while (!defined $_);
+
+                               chomp($smtp_authpass = $_);
+
+                               system "stty echo";
+                       }
+
                        $auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;
                }
+
                $smtp->mail( $raw_from ) or die $smtp->message;
                $smtp->to( @recipients ) or die $smtp->message;
                $smtp->data or die $smtp->message;
@@ -711,11 +799,14 @@ foreach my $t (@files) {
 
                                } elsif (/^(Cc|From):\s+(.*)$/) {
                                        if (unquote_rfc2047($2) eq $sender) {
-                                               next if ($suppress_from);
+                                               next if ($suppress_cc{'self'});
                                        }
                                        elsif ($1 eq 'From') {
                                                ($author, $author_encoding)
                                                  = unquote_rfc2047($2);
+                                               next if ($suppress_cc{'author'});
+                                       } else {
+                                               next if ($suppress_cc{'cc'});
                                        }
                                        printf("(mbox) Adding cc: %s from line '%s'\n",
                                                $2, $_) unless $quiet;
@@ -742,7 +833,7 @@ foreach my $t (@files) {
                                # line 2 = subject
                                # So let's support that, too.
                                $input_format = 'lots';
-                               if (@cc == 0) {
+                               if (@cc == 0 && !$suppress_cc{'cc'}) {
                                        printf("(non-mbox) Adding cc: %s from line '%s'\n",
                                                $_, $_) unless $quiet;
 
@@ -759,10 +850,11 @@ foreach my $t (@files) {
                        }
                } else {
                        $message .=  $_;
-                       if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) {
+                       if (/^(Signed-off-by|Cc): (.*)$/i) {
+                               next if ($suppress_cc{'sob'});
                                my $c = $2;
                                chomp $c;
-                               next if ($c eq $sender and $suppress_from);
+                               next if ($c eq $sender and $suppress_cc{'self'});
                                push @cc, $c;
                                printf("(sob) Adding cc: %s from line '%s'\n",
                                        $c, $_) unless $quiet;
@@ -771,7 +863,7 @@ foreach my $t (@files) {
        }
        close F;
 
-       if (defined $cc_cmd) {
+       if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
                open(F, "$cc_cmd $t |")
                        or die "(cc-cmd) Could not execute '$cc_cmd'";
                while(<F>) {
index aae14090bd884920c7b5cb7530db66719df98ddd..f38827529f2fd60743f5571948742fada975cf93 100755 (executable)
@@ -119,7 +119,7 @@ get_author_ident_from_commit () {
        }
        '
        encoding=$(git config i18n.commitencoding || echo UTF-8)
-       git show -s --pretty=raw --encoding="$encoding" "$1" |
+       git show -s --pretty=raw --encoding="$encoding" "$1" -- |
        LANG=C LC_ALL=C sed -ne "$pick_author_script"
 }
 
index 6cc3157e229f9cc2e4604a872efad16ce27f0323..05fb3582d92e05e6b95ff8f249ae2ecb9892b45b 100755 (executable)
@@ -186,6 +186,9 @@ my %cmd = (
                    "Show info about the latest SVN revision
                     on the current branch",
                    { 'url' => \$_url, } ],
+       'blame' => [ \&Git::SVN::Log::cmd_blame,
+                   "Show what revision and author last modified each line of a file",
+                   {} ],
 );
 
 my $cmd;
@@ -2229,7 +2232,12 @@ sub find_parent_branch {
                # just grow a tail if we're not unique enough :x
                $ref_id .= '-' while find_ref($ref_id);
                print STDERR "Initializing parent: $ref_id\n";
-               $gs = Git::SVN->init($new_url, '', $ref_id, $ref_id, 1);
+               my ($u, $p) = ($new_url, '');
+               if ($u =~ s#^\Q$url\E(/|$)##) {
+                       $p = $u;
+                       $u = $url;
+               }
+               $gs = Git::SVN->init($u, $p, $self->{repo_id}, $ref_id, 1);
        }
        my ($r0, $parent) = $gs->find_rev_before($r, 1);
        if (!defined $r0 || !defined $parent) {
@@ -4443,6 +4451,24 @@ out:
        print commit_log_separator unless $incremental || $oneline;
 }
 
+sub cmd_blame {
+       my $path = shift;
+
+       config_pager();
+       run_pager();
+
+       my ($fh, $ctx) = command_output_pipe('blame', @_, $path);
+       while (my $line = <$fh>) {
+               if ($line =~ /^\^?([[:xdigit:]]+)\s/) {
+                       my (undef, $rev, undef) = ::cmt_metadata($1);
+                       $rev = sprintf('%-10s', $rev);
+                       $line =~ s/^\^?[[:xdigit:]]+(\s)/$rev$1/;
+               }
+               print $line;
+       }
+       command_close_pipe($fh, $ctx);
+}
+
 package Git::SVN::Migration;
 # these version numbers do NOT correspond to actual version numbers
 # of git nor git-svn.  They are just relative.
diff --git a/git.c b/git.c
index 15fec8974ad5361a2308b3c46424e896bc8e3246..0cb86884d738a8314f164c82e4cc619a9998f3db 100644 (file)
--- a/git.c
+++ b/git.c
@@ -93,6 +93,8 @@ static char *alias_string;
 static int git_alias_config(const char *var, const char *value)
 {
        if (!prefixcmp(var, "alias.") && !strcmp(var + 6, alias_command)) {
+               if (!value)
+                       return config_error_nonbool(var);
                alias_string = xstrdup(value);
        }
        return 0;
index 5560e4dc560587c4a551c24a1ee59df394726fc9..f1f21e97bf5e89bd7609cf5b6d1f417e35a43b6c 100644 (file)
@@ -240,11 +240,12 @@ proc getcommitlines {fd view}  {
        set listed 1
        if {$j >= 0 && [string match "commit *" $cmit]} {
            set ids [string range $cmit 7 [expr {$j - 1}]]
-           if {[string match {[-<>]*} $ids]} {
+           if {[string match {[-^<>]*} $ids]} {
                switch -- [string index $ids 0] {
                    "-" {set listed 0}
-                   "<" {set listed 2}
-                   ">" {set listed 3}
+                   "^" {set listed 2}
+                   "<" {set listed 3}
+                   ">" {set listed 4}
                }
                set ids [string range $ids 1 end]
            }
@@ -632,6 +633,7 @@ proc makewindow {} {
     global findtype findtypemenu findloc findstring fstring geometry
     global entries sha1entry sha1string sha1but
     global diffcontextstring diffcontext
+    global ignorespace
     global maincursor textcursor curtextcursor
     global rowctxmenu fakerowmenu mergemax wrapcomment
     global highlight_files gdttype
@@ -849,6 +851,9 @@ proc makewindow {} {
     trace add variable diffcontextstring write diffcontextchange
     lappend entries .bleft.mid.diffcontext
     pack .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
+    checkbutton .bleft.mid.ignspace -text [mc "Ignore space change"] \
+       -command changeignorespace -variable ignorespace
+    pack .bleft.mid.ignspace -side left -padx 5
     set ctext .bleft.ctext
     text $ctext -background $bgcolor -foreground $fgcolor \
        -state disabled -font textfont \
@@ -1307,45 +1312,45 @@ proc keys {} {
     }
     toplevel $w
     wm title $w [mc "Gitk key bindings"]
-    message $w.m -text [mc "
-Gitk key bindings:
-
-<$M1T-Q>               Quit
-<Home>         Move to first commit
-<End>          Move to last commit
-<Up>, p, i     Move up one commit
-<Down>, n, k   Move down one commit
-<Left>, z, j   Go back in history list
-<Right>, x, l  Go forward in history list
-<PageUp>       Move up one page in commit list
-<PageDown>     Move down one page in commit list
-<$M1T-Home>    Scroll to top of commit list
-<$M1T-End>     Scroll to bottom of commit list
-<$M1T-Up>      Scroll commit list up one line
-<$M1T-Down>    Scroll commit list down one line
-<$M1T-PageUp>  Scroll commit list up one page
-<$M1T-PageDown>        Scroll commit list down one page
-<Shift-Up>     Find backwards (upwards, later commits)
-<Shift-Down>   Find forwards (downwards, earlier commits)
-<Delete>, b    Scroll diff view up one page
-<Backspace>    Scroll diff view up one page
-<Space>                Scroll diff view down one page
-u              Scroll diff view up 18 lines
-d              Scroll diff view down 18 lines
-<$M1T-F>               Find
-<$M1T-G>               Move to next find hit
-<Return>       Move to next find hit
-/              Move to next find hit, or redo find
-?              Move to previous find hit
-f              Scroll diff view to next file
-<$M1T-S>               Search for next hit in diff view
-<$M1T-R>               Search for previous hit in diff view
-<$M1T-KP+>     Increase font size
-<$M1T-plus>    Increase font size
-<$M1T-KP->     Decrease font size
-<$M1T-minus>   Decrease font size
-<F5>           Update
-"] \
+    message $w.m -text "
+[mc "Gitk key bindings:"]
+
+[mc "<%s-Q>            Quit" $M1T]
+[mc "<Home>            Move to first commit"]
+[mc "<End>             Move to last commit"]
+[mc "<Up>, p, i        Move up one commit"]
+[mc "<Down>, n, k      Move down one commit"]
+[mc "<Left>, z, j      Go back in history list"]
+[mc "<Right>, x, l     Go forward in history list"]
+[mc "<PageUp>  Move up one page in commit list"]
+[mc "<PageDown>        Move down one page in commit list"]
+[mc "<%s-Home> Scroll to top of commit list" $M1T]
+[mc "<%s-End>  Scroll to bottom of commit list" $M1T]
+[mc "<%s-Up>   Scroll commit list up one line" $M1T]
+[mc "<%s-Down> Scroll commit list down one line" $M1T]
+[mc "<%s-PageUp>       Scroll commit list up one page" $M1T]
+[mc "<%s-PageDown>     Scroll commit list down one page" $M1T]
+[mc "<Shift-Up>        Find backwards (upwards, later commits)"]
+[mc "<Shift-Down>      Find forwards (downwards, earlier commits)"]
+[mc "<Delete>, b       Scroll diff view up one page"]
+[mc "<Backspace>       Scroll diff view up one page"]
+[mc "<Space>           Scroll diff view down one page"]
+[mc "u         Scroll diff view up 18 lines"]
+[mc "d         Scroll diff view down 18 lines"]
+[mc "<%s-F>            Find" $M1T]
+[mc "<%s-G>            Move to next find hit" $M1T]
+[mc "<Return>  Move to next find hit"]
+[mc "/         Move to next find hit, or redo find"]
+[mc "?         Move to previous find hit"]
+[mc "f         Scroll diff view to next file"]
+[mc "<%s-S>            Search for next hit in diff view" $M1T]
+[mc "<%s-R>            Search for previous hit in diff view" $M1T]
+[mc "<%s-KP+>  Increase font size" $M1T]
+[mc "<%s-plus> Increase font size" $M1T]
+[mc "<%s-KP->  Decrease font size" $M1T]
+[mc "<%s-minus>        Decrease font size" $M1T]
+[mc "<F5>              Update"]
+" \
            -justify left -bg white -border 2 -relief groove
     pack $w.m -side top -fill both -padx 2 -pady 2
     button $w.ok -text [mc "Close"] -command "destroy $w" -default active
@@ -3627,23 +3632,23 @@ proc drawcmittext {id row col} {
     global linehtag linentag linedtag selectedline
     global canvxmax boldrows boldnamerows fgcolor nullid nullid2
 
-    # listed is 0 for boundary, 1 for normal, 2 for left, 3 for right
+    # listed is 0 for boundary, 1 for normal, 2 for negative, 3 for left, 4 for right
     set listed [lindex $commitlisted $row]
     if {$id eq $nullid} {
        set ofill red
     } elseif {$id eq $nullid2} {
        set ofill green
     } else {
-       set ofill [expr {$listed != 0? "blue": "white"}]
+       set ofill [expr {$listed != 0 ? $listed == 2 ? "gray" : "blue" : "white"}]
     }
     set x [xc $row $col]
     set y [yc $row]
     set orad [expr {$linespc / 3}]
-    if {$listed <= 1} {
+    if {$listed <= 2} {
        set t [$canv create oval [expr {$x - $orad}] [expr {$y - $orad}] \
                   [expr {$x + $orad - 1}] [expr {$y + $orad - 1}] \
                   -fill $ofill -outline $fgcolor -width 1 -tags circle]
-    } elseif {$listed == 2} {
+    } elseif {$listed == 3} {
        # triangle pointing left for left-side commits
        set t [$canv create polygon \
                   [expr {$x - $orad}] $y \
@@ -5027,13 +5032,14 @@ proc getblobline {bf id} {
 proc mergediff {id l} {
     global diffmergeid mdifffd
     global diffids
+    global diffcontext
     global parentlist
     global limitdiffs viewfiles curview
 
     set diffmergeid $id
     set diffids $id
     # this doesn't seem to actually affect anything...
-    set cmd [concat | git diff-tree --no-commit-id --cc $id]
+    set cmd [concat | git diff-tree --no-commit-id --cc -U$diffcontext $id]
     if {$limitdiffs && $viewfiles($curview) ne {}} {
        set cmd [concat $cmd -- $viewfiles($curview)]
     }
@@ -5270,13 +5276,21 @@ proc diffcontextchange {n1 n2 op} {
     }
 }
 
+proc changeignorespace {} {
+    reselectline
+}
+
 proc getblobdiffs {ids} {
     global blobdifffd diffids env
     global diffinhdr treediffs
     global diffcontext
+    global ignorespace
     global limitdiffs viewfiles curview
 
     set cmd [diffcmd $ids "-p -C --no-commit-id -U$diffcontext"]
+    if {$ignorespace} {
+       append cmd " -w"
+    }
     if {$limitdiffs && $viewfiles($curview) ne {}} {
        set cmd [concat $cmd -- $viewfiles($curview)]
     }
@@ -6137,11 +6151,7 @@ proc domktag {} {
        return
     }
     if {[catch {
-       set dir [gitdir]
-       set fname [file join $dir "refs/tags" $tag]
-       set f [open $fname w]
-       puts $f $id
-       close $f
+       exec git tag $tag $id
     } err]} {
        error_popup "[mc "Error creating tag:"] $err"
        return
@@ -8459,6 +8469,7 @@ set bgcolor white
 set fgcolor black
 set diffcolors {red "#00a000" blue}
 set diffcontext 3
+set ignorespace 0
 set selectbgcolor gray85
 
 ## For msgcat loading, first locate the installation location.
index ae2d05763fc2d41c9bffdad8809e4e370389412c..5e88637b5e0e67143692bac336a57ab6cc1c0c38 100755 (executable)
@@ -1620,7 +1620,7 @@ sub git_get_project_url_list {
        my $path = shift;
 
        $git_dir = "$projectroot/$path";
-       open my $fd, "$projectroot/$path/cloneurl"
+       open my $fd, "$git_dir/cloneurl"
                or return wantarray ?
                @{ config_to_multi(git_get_project_config('url')) } :
                   config_to_multi(git_get_project_config('url'));
@@ -5565,7 +5565,7 @@ XML
                        or next;
 
                # print element (entry, item)
-               my $co_url = href(-full=>1, action=>"commit", hash=>$commit);
+               my $co_url = href(-full=>1, action=>"commitdiff", hash=>$commit);
                if ($format eq 'rss') {
                        print "<item>\n" .
                              "<title>" . esc_html($co{'title'}) . "</title>\n" .
diff --git a/help.c b/help.c
index 1302a61c83c524099e7d39257daa273a09edad4f..95e7640fedebb1574a4259d85d7b95d5220f0e6f 100644 (file)
--- a/help.c
+++ b/help.c
@@ -40,6 +40,8 @@ static void parse_help_format(const char *format)
 static int git_help_config(const char *var, const char *value)
 {
        if (!strcmp(var, "help.format")) {
+               if (!value)
+                       return config_error_nonbool(var);
                help_default_format = xstrdup(value);
                return 0;
        }
diff --git a/http.c b/http.c
index d2c11aee9077e0834c5c56b1284df478eb8debbc..5925d07478b763ee9f91d7b273f64f0ae956219b 100644 (file)
--- a/http.c
+++ b/http.c
@@ -101,16 +101,18 @@ static int http_options(const char *var, const char *value)
 
        if (!strcmp("http.sslcert", var)) {
                if (ssl_cert == NULL) {
-                       ssl_cert = xmalloc(strlen(value)+1);
-                       strcpy(ssl_cert, value);
+                       if (!value)
+                               return config_error_nonbool(var);
+                       ssl_cert = xstrdup(value);
                }
                return 0;
        }
 #if LIBCURL_VERSION_NUM >= 0x070902
        if (!strcmp("http.sslkey", var)) {
                if (ssl_key == NULL) {
-                       ssl_key = xmalloc(strlen(value)+1);
-                       strcpy(ssl_key, value);
+                       if (!value)
+                               return config_error_nonbool(var);
+                       ssl_key = xstrdup(value);
                }
                return 0;
        }
@@ -118,16 +120,18 @@ static int http_options(const char *var, const char *value)
 #if LIBCURL_VERSION_NUM >= 0x070908
        if (!strcmp("http.sslcapath", var)) {
                if (ssl_capath == NULL) {
-                       ssl_capath = xmalloc(strlen(value)+1);
-                       strcpy(ssl_capath, value);
+                       if (!value)
+                               return config_error_nonbool(var);
+                       ssl_capath = xstrdup(value);
                }
                return 0;
        }
 #endif
        if (!strcmp("http.sslcainfo", var)) {
                if (ssl_cainfo == NULL) {
-                       ssl_cainfo = xmalloc(strlen(value)+1);
-                       strcpy(ssl_cainfo, value);
+                       if (!value)
+                               return config_error_nonbool(var);
+                       ssl_cainfo = xstrdup(value);
                }
                return 0;
        }
@@ -157,8 +161,9 @@ static int http_options(const char *var, const char *value)
        }
        if (!strcmp("http.proxy", var)) {
                if (curl_http_proxy == NULL) {
-                       curl_http_proxy = xmalloc(strlen(value)+1);
-                       strcpy(curl_http_proxy, value);
+                       if (!value)
+                               return config_error_nonbool(var);
+                       curl_http_proxy = xstrdup(value);
                }
                return 0;
        }
index a429a76a6385bb7d7935cfaddec9cfc8508c77e5..9025d9aa3ef37b1a1ce4ae5d4b447e3b0918cb7e 100644 (file)
@@ -1254,6 +1254,10 @@ git_imap_config(const char *key, const char *val)
 
        if (strncmp( key, imap_key, sizeof imap_key - 1 ))
                return 0;
+
+       if (!val)
+               return config_error_nonbool(key);
+
        key += sizeof imap_key - 1;
 
        if (!strcmp( "folder", key )) {
index fa719cb0b1bd227423587c9e41eed77c755465a4..bbb700b54eab2a14f60e090231a196874ff3a9e0 100644 (file)
@@ -48,7 +48,7 @@ static int merge_entry(int pos, const char *path)
                        break;
                found++;
                strcpy(hexbuf[stage], sha1_to_hex(ce->sha1));
-               sprintf(ownbuf[stage], "%o", ntohl(ce->ce_mode));
+               sprintf(ownbuf[stage], "%o", ce->ce_mode);
                arguments[stage] = hexbuf[stage];
                arguments[stage + 4] = ownbuf[stage];
        } while (++pos < active_nr);
index c292a77a81d137a3ee73111162c9aa515c975d70..dd52342539cd05e59bb13e956d51251417f21e3c 100644 (file)
@@ -333,7 +333,7 @@ static struct path_list *get_unmerged(void)
                        item->util = xcalloc(1, sizeof(struct stage_data));
                }
                e = item->util;
-               e->stages[ce_stage(ce)].mode = ntohl(ce->ce_mode);
+               e->stages[ce_stage(ce)].mode = ce->ce_mode;
                hashcpy(e->stages[ce_stage(ce)].sha, ce->sha1);
        }
 
@@ -844,8 +844,9 @@ static int read_merge_config(const char *var, const char *value)
        int namelen;
 
        if (!strcmp(var, "merge.default")) {
-               if (value)
-                       default_ll_merge = strdup(value);
+               if (!value)
+                       return config_error_nonbool(var);
+               default_ll_merge = strdup(value);
                return 0;
        }
 
@@ -878,14 +879,14 @@ static int read_merge_config(const char *var, const char *value)
 
        if (!strcmp("name", ep)) {
                if (!value)
-                       return error("%s: lacks value", var);
+                       return config_error_nonbool(var);
                fn->description = strdup(value);
                return 0;
        }
 
        if (!strcmp("driver", ep)) {
                if (!value)
-                       return error("%s: lacks value", var);
+                       return config_error_nonbool(var);
                /*
                 * merge.<name>.driver specifies the command line:
                 *
@@ -908,7 +909,7 @@ static int read_merge_config(const char *var, const char *value)
 
        if (!strcmp("recursive", ep)) {
                if (!value)
-                       return error("%s: lacks value", var);
+                       return config_error_nonbool(var);
                fn->recursive = strdup(value);
                return 0;
        }
index 6383401e2dd6bef3251a105ac136312dfdcdeb3c..00f289f2f470c0f4b95e0fcac043aa2e054d1ce6 100644 (file)
@@ -176,7 +176,7 @@ static void add_cache_refs(struct rev_info *revs)
                 * lookup_blob() on them, to avoid populating the hash table
                 * with invalid information
                 */
-               if (S_ISGITLINK(ntohl(active_cache[i]->ce_mode)))
+               if (S_ISGITLINK(active_cache[i]->ce_mode))
                        continue;
 
                lookup_blob(active_cache[i]->sha1);
index 7db55883d65fd28c2eaa291b5688273532988d88..e45f4b3d61c2982ca20c910a7fc11c5bd89204be 100644 (file)
 
 struct index_state the_index;
 
+static unsigned int hash_name(const char *name, int namelen)
+{
+       unsigned int hash = 0x123;
+
+       do {
+               unsigned char c = *name++;
+               hash = hash*101 + c;
+       } while (--namelen);
+       return hash;
+}
+
+static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)
+{
+       void **pos;
+       unsigned int hash = hash_name(ce->name, ce_namelen(ce));
+
+       pos = insert_hash(hash, ce, &istate->name_hash);
+       if (pos) {
+               ce->next = *pos;
+               *pos = ce;
+       }
+}
+
+static void lazy_init_name_hash(struct index_state *istate)
+{
+       int nr;
+
+       if (istate->name_hash_initialized)
+               return;
+       for (nr = 0; nr < istate->cache_nr; nr++)
+               hash_index_entry(istate, istate->cache[nr]);
+       istate->name_hash_initialized = 1;
+}
+
+static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)
+{
+       istate->cache[nr] = ce;
+       if (istate->name_hash_initialized)
+               hash_index_entry(istate, ce);
+}
+
+/*
+ * We don't actually *remove* it, we can just mark it invalid so that
+ * we won't find it in lookups.
+ *
+ * Not only would we have to search the lists (simple enough), but
+ * we'd also have to rehash other hash buckets in case this makes the
+ * hash bucket empty (common). So it's much better to just mark
+ * it.
+ */
+static void remove_hash_entry(struct index_state *istate, struct cache_entry *ce)
+{
+       ce->ce_flags |= CE_UNHASHED;
+}
+
+static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)
+{
+       struct cache_entry *old = istate->cache[nr];
+
+       if (ce != old) {
+               remove_hash_entry(istate, old);
+               set_index_entry(istate, nr, ce);
+       }
+       istate->cache_changed = 1;
+}
+
+int index_name_exists(struct index_state *istate, const char *name, int namelen)
+{
+       unsigned int hash = hash_name(name, namelen);
+       struct cache_entry *ce;
+
+       lazy_init_name_hash(istate);
+       ce = lookup_hash(hash, &istate->name_hash);
+
+       while (ce) {
+               if (!(ce->ce_flags & CE_UNHASHED)) {
+                       if (!cache_name_compare(name, namelen, ce->name, ce->ce_flags))
+                               return 1;
+               }
+               ce = ce->next;
+       }
+       return 0;
+}
+
 /*
  * This only updates the "non-critical" parts of the directory
  * cache, ie the parts that aren't tracked by GIT, and only used
@@ -30,20 +114,19 @@ struct index_state the_index;
  */
 void fill_stat_cache_info(struct cache_entry *ce, struct stat *st)
 {
-       ce->ce_ctime.sec = htonl(st->st_ctime);
-       ce->ce_mtime.sec = htonl(st->st_mtime);
-#ifdef USE_NSEC
-       ce->ce_ctime.nsec = htonl(st->st_ctim.tv_nsec);
-       ce->ce_mtime.nsec = htonl(st->st_mtim.tv_nsec);
-#endif
-       ce->ce_dev = htonl(st->st_dev);
-       ce->ce_ino = htonl(st->st_ino);
-       ce->ce_uid = htonl(st->st_uid);
-       ce->ce_gid = htonl(st->st_gid);
-       ce->ce_size = htonl(st->st_size);
+       ce->ce_ctime = st->st_ctime;
+       ce->ce_mtime = st->st_mtime;
+       ce->ce_dev = st->st_dev;
+       ce->ce_ino = st->st_ino;
+       ce->ce_uid = st->st_uid;
+       ce->ce_gid = st->st_gid;
+       ce->ce_size = st->st_size;
 
        if (assume_unchanged)
-               ce->ce_flags |= htons(CE_VALID);
+               ce->ce_flags |= CE_VALID;
+
+       if (S_ISREG(st->st_mode))
+               ce_mark_uptodate(ce);
 }
 
 static int ce_compare_data(struct cache_entry *ce, struct stat *st)
@@ -116,7 +199,7 @@ static int ce_modified_check_fs(struct cache_entry *ce, struct stat *st)
                        return DATA_CHANGED;
                break;
        case S_IFDIR:
-               if (S_ISGITLINK(ntohl(ce->ce_mode)))
+               if (S_ISGITLINK(ce->ce_mode))
                        return 0;
        default:
                return TYPE_CHANGED;
@@ -128,14 +211,17 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
 {
        unsigned int changed = 0;
 
-       switch (ntohl(ce->ce_mode) & S_IFMT) {
+       if (ce->ce_flags & CE_REMOVE)
+               return MODE_CHANGED | DATA_CHANGED | TYPE_CHANGED;
+
+       switch (ce->ce_mode & S_IFMT) {
        case S_IFREG:
                changed |= !S_ISREG(st->st_mode) ? TYPE_CHANGED : 0;
                /* We consider only the owner x bit to be relevant for
                 * "mode changes"
                 */
                if (trust_executable_bit &&
-                   (0100 & (ntohl(ce->ce_mode) ^ st->st_mode)))
+                   (0100 & (ce->ce_mode ^ st->st_mode)))
                        changed |= MODE_CHANGED;
                break;
        case S_IFLNK:
@@ -149,32 +235,18 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
                else if (ce_compare_gitlink(ce))
                        changed |= DATA_CHANGED;
                return changed;
-       case 0: /* Special case: unmerged file in index */
-               return MODE_CHANGED | DATA_CHANGED | TYPE_CHANGED;
        default:
-               die("internal error: ce_mode is %o", ntohl(ce->ce_mode));
+               die("internal error: ce_mode is %o", ce->ce_mode);
        }
-       if (ce->ce_mtime.sec != htonl(st->st_mtime))
+       if (ce->ce_mtime != (unsigned int) st->st_mtime)
                changed |= MTIME_CHANGED;
-       if (ce->ce_ctime.sec != htonl(st->st_ctime))
+       if (ce->ce_ctime != (unsigned int) st->st_ctime)
                changed |= CTIME_CHANGED;
 
-#ifdef USE_NSEC
-       /*
-        * nsec seems unreliable - not all filesystems support it, so
-        * as long as it is in the inode cache you get right nsec
-        * but after it gets flushed, you get zero nsec.
-        */
-       if (ce->ce_mtime.nsec != htonl(st->st_mtim.tv_nsec))
-               changed |= MTIME_CHANGED;
-       if (ce->ce_ctime.nsec != htonl(st->st_ctim.tv_nsec))
-               changed |= CTIME_CHANGED;
-#endif
-
-       if (ce->ce_uid != htonl(st->st_uid) ||
-           ce->ce_gid != htonl(st->st_gid))
+       if (ce->ce_uid != (unsigned int) st->st_uid ||
+           ce->ce_gid != (unsigned int) st->st_gid)
                changed |= OWNER_CHANGED;
-       if (ce->ce_ino != htonl(st->st_ino))
+       if (ce->ce_ino != (unsigned int) st->st_ino)
                changed |= INODE_CHANGED;
 
 #ifdef USE_STDEV
@@ -183,16 +255,22 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
         * clients will have different views of what "device"
         * the filesystem is on
         */
-       if (ce->ce_dev != htonl(st->st_dev))
+       if (ce->ce_dev != (unsigned int) st->st_dev)
                changed |= INODE_CHANGED;
 #endif
 
-       if (ce->ce_size != htonl(st->st_size))
+       if (ce->ce_size != (unsigned int) st->st_size)
                changed |= DATA_CHANGED;
 
        return changed;
 }
 
+static int is_racy_timestamp(struct index_state *istate, struct cache_entry *ce)
+{
+       return (istate->timestamp &&
+               ((unsigned int)istate->timestamp) <= ce->ce_mtime);
+}
+
 int ie_match_stat(struct index_state *istate,
                  struct cache_entry *ce, struct stat *st,
                  unsigned int options)
@@ -205,7 +283,7 @@ int ie_match_stat(struct index_state *istate,
         * If it's marked as always valid in the index, it's
         * valid whatever the checked-out copy says.
         */
-       if (!ignore_valid && (ce->ce_flags & htons(CE_VALID)))
+       if (!ignore_valid && (ce->ce_flags & CE_VALID))
                return 0;
 
        changed = ce_match_stat_basic(ce, st);
@@ -226,9 +304,7 @@ int ie_match_stat(struct index_state *istate,
         * whose mtime are the same as the index file timestamp more
         * carefully than others.
         */
-       if (!changed &&
-           istate->timestamp &&
-           istate->timestamp <= ntohl(ce->ce_mtime.sec)) {
+       if (!changed && is_racy_timestamp(istate, ce)) {
                if (assume_racy_is_modified)
                        changed |= DATA_CHANGED;
                else
@@ -257,7 +333,7 @@ int ie_modified(struct index_state *istate,
         * the length field is zero.  For other cases the ce_size
         * should match the SHA1 recorded in the index entry.
         */
-       if ((changed & DATA_CHANGED) && ce->ce_size != htonl(0))
+       if ((changed & DATA_CHANGED) && ce->ce_size != 0)
                return changed;
 
        changed_fs = ce_modified_check_fs(ce, st);
@@ -320,7 +396,7 @@ int index_name_pos(struct index_state *istate, const char *name, int namelen)
        while (last > first) {
                int next = (last + first) >> 1;
                struct cache_entry *ce = istate->cache[next];
-               int cmp = cache_name_compare(name, namelen, ce->name, ntohs(ce->ce_flags));
+               int cmp = cache_name_compare(name, namelen, ce->name, ce->ce_flags);
                if (!cmp)
                        return next;
                if (cmp < 0) {
@@ -335,6 +411,9 @@ int index_name_pos(struct index_state *istate, const char *name, int namelen)
 /* Remove entry, return true if there are more entries to go.. */
 int remove_index_entry_at(struct index_state *istate, int pos)
 {
+       struct cache_entry *ce = istate->cache[pos];
+
+       remove_hash_entry(istate, ce);
        istate->cache_changed = 1;
        istate->cache_nr--;
        if (pos >= istate->cache_nr)
@@ -405,7 +484,7 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose)
        size = cache_entry_size(namelen);
        ce = xcalloc(1, size);
        memcpy(ce->name, path, namelen);
-       ce->ce_flags = htons(namelen);
+       ce->ce_flags = namelen;
        fill_stat_cache_info(ce, &st);
 
        if (trust_executable_bit && has_symlinks)
@@ -427,6 +506,7 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose)
            !ie_match_stat(istate, istate->cache[pos], &st, ce_option)) {
                /* Nothing changed, really */
                free(ce);
+               ce_mark_uptodate(istate->cache[pos]);
                return 0;
        }
 
@@ -583,7 +663,7 @@ static int has_file_name(struct index_state *istate,
                        continue;
                if (p->name[len] != '/')
                        continue;
-               if (!ce_stage(p) && !p->ce_mode)
+               if (p->ce_flags & CE_REMOVE)
                        continue;
                retval = -1;
                if (!ok_to_replace)
@@ -616,7 +696,7 @@ static int has_dir_name(struct index_state *istate,
                }
                len = slash - name;
 
-               pos = index_name_pos(istate, name, ntohs(create_ce_flags(len, stage)));
+               pos = index_name_pos(istate, name, create_ce_flags(len, stage));
                if (pos >= 0) {
                        /*
                         * Found one, but not so fast.  This could
@@ -626,7 +706,7 @@ static int has_dir_name(struct index_state *istate,
                         * it is Ok to have a directory at the same
                         * path.
                         */
-                       if (stage || istate->cache[pos]->ce_mode) {
+                       if (!(istate->cache[pos]->ce_flags & CE_REMOVE)) {
                                retval = -1;
                                if (!ok_to_replace)
                                        break;
@@ -648,8 +728,9 @@ static int has_dir_name(struct index_state *istate,
                            (p->name[len] != '/') ||
                            memcmp(p->name, name, len))
                                break; /* not our subdirectory */
-                       if (ce_stage(p) == stage && (stage || p->ce_mode))
-                               /* p is at the same stage as our entry, and
+                       if (ce_stage(p) == stage && !(p->ce_flags & CE_REMOVE))
+                               /*
+                                * p is at the same stage as our entry, and
                                 * is a subdirectory of what we are looking
                                 * at, so we cannot have conflicts at our
                                 * level or anything shorter.
@@ -679,7 +760,7 @@ static int check_file_directory_conflict(struct index_state *istate,
        /*
         * When ce is an "I am going away" entry, we allow it to be added
         */
-       if (!ce_stage(ce) && !ce->ce_mode)
+       if (ce->ce_flags & CE_REMOVE)
                return 0;
 
        /*
@@ -704,12 +785,11 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
        int skip_df_check = option & ADD_CACHE_SKIP_DFCHECK;
 
        cache_tree_invalidate_path(istate->cache_tree, ce->name);
-       pos = index_name_pos(istate, ce->name, ntohs(ce->ce_flags));
+       pos = index_name_pos(istate, ce->name, ce->ce_flags);
 
        /* existing match? Just replace it. */
        if (pos >= 0) {
-               istate->cache_changed = 1;
-               istate->cache[pos] = ce;
+               replace_index_entry(istate, pos, ce);
                return 0;
        }
        pos = -pos-1;
@@ -736,7 +816,7 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
                if (!ok_to_replace)
                        return error("'%s' appears as both a file and as a directory",
                                     ce->name);
-               pos = index_name_pos(istate, ce->name, ntohs(ce->ce_flags));
+               pos = index_name_pos(istate, ce->name, ce->ce_flags);
                pos = -pos-1;
        }
        return pos + 1;
@@ -769,7 +849,7 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti
                memmove(istate->cache + pos + 1,
                        istate->cache + pos,
                        (istate->cache_nr - pos - 1) * sizeof(ce));
-       istate->cache[pos] = ce;
+       set_index_entry(istate, pos, ce);
        istate->cache_changed = 1;
        return 0;
 }
@@ -794,6 +874,9 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
        int changed, size;
        int ignore_valid = options & CE_MATCH_IGNORE_VALID;
 
+       if (ce_uptodate(ce))
+               return ce;
+
        if (lstat(ce->name, &st) < 0) {
                if (err)
                        *err = errno;
@@ -810,10 +893,17 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
                 * valid again, under "assume unchanged" mode.
                 */
                if (ignore_valid && assume_unchanged &&
-                   !(ce->ce_flags & htons(CE_VALID)))
+                   !(ce->ce_flags & CE_VALID))
                        ; /* mark this one VALID again */
-               else
+               else {
+                       /*
+                        * We do not mark the index itself "modified"
+                        * because CE_UPTODATE flag is in-core only;
+                        * we are not going to write this change out.
+                        */
+                       ce_mark_uptodate(ce);
                        return ce;
+               }
        }
 
        if (ie_modified(istate, ce, &st, options)) {
@@ -826,7 +916,6 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
        updated = xmalloc(size);
        memcpy(updated, ce, size);
        fill_stat_cache_info(updated, &st);
-
        /*
         * If ignore_valid is not set, we should leave CE_VALID bit
         * alone.  Otherwise, paths marked with --no-assume-unchanged
@@ -834,8 +923,8 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
         * automatically, which is not really what we want.
         */
        if (!ignore_valid && assume_unchanged &&
-           !(ce->ce_flags & htons(CE_VALID)))
-               updated->ce_flags &= ~htons(CE_VALID);
+           !(ce->ce_flags & CE_VALID))
+               updated->ce_flags &= ~CE_VALID;
 
        return updated;
 }
@@ -880,7 +969,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
                                /* If we are doing --really-refresh that
                                 * means the index is not valid anymore.
                                 */
-                               ce->ce_flags &= ~htons(CE_VALID);
+                               ce->ce_flags &= ~CE_VALID;
                                istate->cache_changed = 1;
                        }
                        if (quiet)
@@ -889,11 +978,8 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
                        has_errors = 1;
                        continue;
                }
-               istate->cache_changed = 1;
-               /* You can NOT just free istate->cache[i] here, since it
-                * might not be necessarily malloc()ed but can also come
-                * from mmap(). */
-               istate->cache[i] = new;
+
+               replace_index_entry(istate, i, new);
        }
        return has_errors;
 }
@@ -942,16 +1028,58 @@ int read_index(struct index_state *istate)
        return read_index_from(istate, get_index_file());
 }
 
+static void convert_from_disk(struct ondisk_cache_entry *ondisk, struct cache_entry *ce)
+{
+       size_t len;
+
+       ce->ce_ctime = ntohl(ondisk->ctime.sec);
+       ce->ce_mtime = ntohl(ondisk->mtime.sec);
+       ce->ce_dev   = ntohl(ondisk->dev);
+       ce->ce_ino   = ntohl(ondisk->ino);
+       ce->ce_mode  = ntohl(ondisk->mode);
+       ce->ce_uid   = ntohl(ondisk->uid);
+       ce->ce_gid   = ntohl(ondisk->gid);
+       ce->ce_size  = ntohl(ondisk->size);
+       /* On-disk flags are just 16 bits */
+       ce->ce_flags = ntohs(ondisk->flags);
+       hashcpy(ce->sha1, ondisk->sha1);
+
+       len = ce->ce_flags & CE_NAMEMASK;
+       if (len == CE_NAMEMASK)
+               len = strlen(ondisk->name);
+       /*
+        * NEEDSWORK: If the original index is crafted, this copy could
+        * go unchecked.
+        */
+       memcpy(ce->name, ondisk->name, len + 1);
+}
+
+static inline size_t estimate_cache_size(size_t ondisk_size, unsigned int entries)
+{
+       long per_entry;
+
+       per_entry = sizeof(struct cache_entry) - sizeof(struct ondisk_cache_entry);
+
+       /*
+        * Alignment can cause differences. This should be "alignof", but
+        * since that's a gcc'ism, just use the size of a pointer.
+        */
+       per_entry += sizeof(void *);
+       return ondisk_size + entries*per_entry;
+}
+
 /* remember to discard_cache() before reading a different cache! */
 int read_index_from(struct index_state *istate, const char *path)
 {
        int fd, i;
        struct stat st;
-       unsigned long offset;
+       unsigned long src_offset, dst_offset;
        struct cache_header *hdr;
+       void *mmap;
+       size_t mmap_size;
 
        errno = EBUSY;
-       if (istate->mmap)
+       if (istate->alloc)
                return istate->cache_nr;
 
        errno = ENOENT;
@@ -967,31 +1095,47 @@ int read_index_from(struct index_state *istate, const char *path)
                die("cannot stat the open index (%s)", strerror(errno));
 
        errno = EINVAL;
-       istate->mmap_size = xsize_t(st.st_size);
-       if (istate->mmap_size < sizeof(struct cache_header) + 20)
+       mmap_size = xsize_t(st.st_size);
+       if (mmap_size < sizeof(struct cache_header) + 20)
                die("index file smaller than expected");
 
-       istate->mmap = xmmap(NULL, istate->mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+       mmap = xmmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
        close(fd);
+       if (mmap == MAP_FAILED)
+               die("unable to map index file");
 
-       hdr = istate->mmap;
-       if (verify_hdr(hdr, istate->mmap_size) < 0)
+       hdr = mmap;
+       if (verify_hdr(hdr, mmap_size) < 0)
                goto unmap;
 
        istate->cache_nr = ntohl(hdr->hdr_entries);
        istate->cache_alloc = alloc_nr(istate->cache_nr);
        istate->cache = xcalloc(istate->cache_alloc, sizeof(struct cache_entry *));
 
-       offset = sizeof(*hdr);
+       /*
+        * The disk format is actually larger than the in-memory format,
+        * due to space for nsec etc, so even though the in-memory one
+        * has room for a few  more flags, we can allocate using the same
+        * index size
+        */
+       istate->alloc = xmalloc(estimate_cache_size(mmap_size, istate->cache_nr));
+
+       src_offset = sizeof(*hdr);
+       dst_offset = 0;
        for (i = 0; i < istate->cache_nr; i++) {
+               struct ondisk_cache_entry *disk_ce;
                struct cache_entry *ce;
 
-               ce = (struct cache_entry *)((char *)(istate->mmap) + offset);
-               offset = offset + ce_size(ce);
-               istate->cache[i] = ce;
+               disk_ce = (struct ondisk_cache_entry *)((char *)mmap + src_offset);
+               ce = (struct cache_entry *)((char *)istate->alloc + dst_offset);
+               convert_from_disk(disk_ce, ce);
+               set_index_entry(istate, i, ce);
+
+               src_offset += ondisk_ce_size(ce);
+               dst_offset += ce_size(ce);
        }
        istate->timestamp = st.st_mtime;
-       while (offset <= istate->mmap_size - 20 - 8) {
+       while (src_offset <= mmap_size - 20 - 8) {
                /* After an array of active_nr index entries,
                 * there can be arbitrary number of extended
                 * sections, each of which is prefixed with
@@ -999,40 +1143,37 @@ int read_index_from(struct index_state *istate, const char *path)
                 * in 4-byte network byte order.
                 */
                unsigned long extsize;
-               memcpy(&extsize, (char *)(istate->mmap) + offset + 4, 4);
+               memcpy(&extsize, (char *)mmap + src_offset + 4, 4);
                extsize = ntohl(extsize);
                if (read_index_extension(istate,
-                                        ((const char *) (istate->mmap)) + offset,
-                                        (char *) (istate->mmap) + offset + 8,
+                                        (const char *) mmap + src_offset,
+                                        (char *) mmap + src_offset + 8,
                                         extsize) < 0)
                        goto unmap;
-               offset += 8;
-               offset += extsize;
+               src_offset += 8;
+               src_offset += extsize;
        }
+       munmap(mmap, mmap_size);
        return istate->cache_nr;
 
 unmap:
-       munmap(istate->mmap, istate->mmap_size);
+       munmap(mmap, mmap_size);
        errno = EINVAL;
        die("index file corrupt");
 }
 
 int discard_index(struct index_state *istate)
 {
-       int ret;
-
        istate->cache_nr = 0;
        istate->cache_changed = 0;
        istate->timestamp = 0;
+       free_hash(&istate->name_hash);
        cache_tree_free(&(istate->cache_tree));
-       if (istate->mmap == NULL)
-               return 0;
-       ret = munmap(istate->mmap, istate->mmap_size);
-       istate->mmap = NULL;
-       istate->mmap_size = 0;
+       free(istate->alloc);
+       istate->alloc = NULL;
 
        /* no need to throw away allocated active_cache */
-       return ret;
+       return 0;
 }
 
 #define WRITE_BUFFER_SIZE 8192
@@ -1144,10 +1285,32 @@ static void ce_smudge_racily_clean_entry(struct cache_entry *ce)
                 * file, and never calls us, so the cached size information
                 * for "frotz" stays 6 which does not match the filesystem.
                 */
-               ce->ce_size = htonl(0);
+               ce->ce_size = 0;
        }
 }
 
+static int ce_write_entry(SHA_CTX *c, int fd, struct cache_entry *ce)
+{
+       int size = ondisk_ce_size(ce);
+       struct ondisk_cache_entry *ondisk = xcalloc(1, size);
+
+       ondisk->ctime.sec = htonl(ce->ce_ctime);
+       ondisk->ctime.nsec = 0;
+       ondisk->mtime.sec = htonl(ce->ce_mtime);
+       ondisk->mtime.nsec = 0;
+       ondisk->dev  = htonl(ce->ce_dev);
+       ondisk->ino  = htonl(ce->ce_ino);
+       ondisk->mode = htonl(ce->ce_mode);
+       ondisk->uid  = htonl(ce->ce_uid);
+       ondisk->gid  = htonl(ce->ce_gid);
+       ondisk->size = htonl(ce->ce_size);
+       hashcpy(ondisk->sha1, ce->sha1);
+       ondisk->flags = htons(ce->ce_flags);
+       memcpy(ondisk->name, ce->name, ce_namelen(ce));
+
+       return ce_write(c, fd, ondisk, size);
+}
+
 int write_index(struct index_state *istate, int newfd)
 {
        SHA_CTX c;
@@ -1157,7 +1320,7 @@ int write_index(struct index_state *istate, int newfd)
        int entries = istate->cache_nr;
 
        for (i = removed = 0; i < entries; i++)
-               if (!cache[i]->ce_mode)
+               if (cache[i]->ce_flags & CE_REMOVE)
                        removed++;
 
        hdr.hdr_signature = htonl(CACHE_SIGNATURE);
@@ -1170,12 +1333,11 @@ int write_index(struct index_state *istate, int newfd)
 
        for (i = 0; i < entries; i++) {
                struct cache_entry *ce = cache[i];
-               if (!ce->ce_mode)
+               if (ce->ce_flags & CE_REMOVE)
                        continue;
-               if (istate->timestamp &&
-                   istate->timestamp <= ntohl(ce->ce_mtime.sec))
+               if (is_racy_timestamp(istate, ce))
                        ce_smudge_racily_clean_entry(ce);
-               if (ce_write(&c, newfd, ce, ce_size(ce)) < 0)
+               if (ce_write_entry(&c, newfd, ce) < 0)
                        return -1;
        }
 
index 0e006804ef3cc190fa286c85e2de034a33791886..6b56473f5bb7d8ab2226ed83805f30c9e21ba773 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -222,15 +222,18 @@ static int handle_config(const char *key, const char *value)
                subkey = strrchr(name, '.');
                if (!subkey)
                        return 0;
-               if (!value)
-                       return 0;
                branch = make_branch(name, subkey - name);
                if (!strcmp(subkey, ".remote")) {
+                       if (!value)
+                               return config_error_nonbool(key);
                        branch->remote_name = xstrdup(value);
                        if (branch == current_branch)
                                default_remote_name = branch->remote_name;
-               } else if (!strcmp(subkey, ".merge"))
+               } else if (!strcmp(subkey, ".merge")) {
+                       if (!value)
+                               return config_error_nonbool(key);
                        add_merge(branch, xstrdup(value));
+               }
                return 0;
        }
        if (prefixcmp(key,  "remote."))
@@ -340,6 +343,16 @@ struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)
        return rs;
 }
 
+static int valid_remote_nick(const char *name)
+{
+       if (!name[0] || /* not empty */
+           (name[0] == '.' && /* not "." */
+            (!name[1] || /* not ".." */
+             (name[1] == '.' && !name[2]))))
+               return 0;
+       return !strchr(name, '/'); /* no slash */
+}
+
 struct remote *remote_get(const char *name)
 {
        struct remote *ret;
@@ -348,7 +361,7 @@ struct remote *remote_get(const char *name)
        if (!name)
                name = default_remote_name;
        ret = make_remote(name, 0);
-       if (name[0] != '/') {
+       if (valid_remote_nick(name)) {
                if (!ret->url)
                        read_remotes_file(ret);
                if (!ret->url)
diff --git a/setup.c b/setup.c
index adede16a4deea1423f52c3b736de735d27f7172a..4509598d577baba8b1d7e8782d8e6ff8e74f9556 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -372,6 +372,8 @@ int check_repository_format_version(const char *var, const char *value)
                if (is_bare_repository_cfg == 1)
                        inside_work_tree = -1;
        } else if (strcmp(var, "core.worktree") == 0) {
+               if (!value)
+                       return config_error_nonbool(var);
                if (git_work_tree_cfg)
                        free(git_work_tree_cfg);
                git_work_tree_cfg = xstrdup(value);
index 13e11645e1fd6b61812cc3e88d2ad6cd42cad9ce..be8489e4e5fc98c6e38036a40fb5ca8c0db77ebc 100644 (file)
@@ -695,7 +695,7 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
                                break;
                        if (ce_stage(ce) == stage) {
                                hashcpy(sha1, ce->sha1);
-                               *mode = ntohl(ce->ce_mode);
+                               *mode = ce->ce_mode;
                                return 0;
                        }
                        pos++;
diff --git a/t/.gitattributes b/t/.gitattributes
new file mode 100644 (file)
index 0000000..562b12e
--- /dev/null
@@ -0,0 +1 @@
+* -whitespace
index cd0de506d208f3d741aa2223e8cc639850326ae7..92de08822702f780c6895a5d2c070ee009ecfef7 100755 (executable)
@@ -309,4 +309,24 @@ test_expect_success 'absolute path works as expected' '
        test "$sym" = "$(test-absolute-path $dir2/syml)"
 '
 
+test_expect_success 'very long name in the index handled sanely' '
+
+       a=a && # 1
+       a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 16
+       a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 256
+       a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 4096
+       a=${a}q &&
+
+       >path4 &&
+       git update-index --add path4 &&
+       (
+               git ls-files -s path4 |
+               sed -e "s/      .*/     /" |
+               tr -d "\012"
+               echo "$a"
+       ) | git update-index --index-info &&
+       len=$(git ls-files "a*" | wc -c) &&
+       test $len = 4098
+'
+
 test_done
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
new file mode 100755 (executable)
index 0000000..47f08a4
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+test_description=gitattributes
+
+. ./test-lib.sh
+
+attr_check () {
+
+       path="$1"
+       expect="$2"
+
+       git check-attr test -- "$path" >actual &&
+       echo "$path: test: $2" >expect &&
+       diff -u expect actual
+
+}
+
+
+test_expect_success 'setup' '
+
+       mkdir -p a/b/d a/c &&
+       (
+               echo "f test=f"
+       ) >.gitattributes &&
+       (
+               echo "g test=a/g" &&
+               echo "b/g test=a/b/g"
+       ) >a/.gitattributes &&
+       (
+               echo "h test=a/b/h" &&
+               echo "d/* test=a/b/d/*"
+       ) >a/b/.gitattributes
+
+'
+
+test_expect_success 'attribute test' '
+
+       attr_check f f &&
+       attr_check a/f f &&
+       attr_check a/c/f f &&
+       attr_check a/g a/g &&
+       attr_check a/b/g a/b/g &&
+       attr_check b/g unspecified &&
+       attr_check a/b/h a/b/h &&
+       attr_check a/b/d/g "a/b/d/*"
+
+'
+
+test_done
index a786c5c970f83b72f41f2fe1c334152edc071d6a..4928a571144b3fb9ec38312d917e9f95e40ceb99 100755 (executable)
@@ -71,6 +71,25 @@ EOF
 
 test_expect_success 'non-match result' 'cmp .git/config expect'
 
+cat > .git/config <<\EOF
+[alpha]
+bar = foo
+[beta]
+baz = multiple \
+lines
+EOF
+
+test_expect_success 'unset with cont. lines' \
+       'git config --unset beta.baz'
+
+cat > expect <<\EOF
+[alpha]
+bar = foo
+[beta]
+EOF
+
+test_expect_success 'unset with cont. lines is correct' 'cmp .git/config expect'
+
 cat > .git/config << EOF
 [beta] ; silly comment # another comment
 noIndent= sillyValue ; 'nother silly comment
@@ -283,17 +302,40 @@ test_expect_success '--add' \
 cat > .git/config << EOF
 [novalue]
        variable
+[emptyvalue]
+       variable =
 EOF
 
 test_expect_success 'get variable with no value' \
        'git config --get novalue.variable ^$'
 
+test_expect_success 'get variable with empty value' \
+       'git config --get emptyvalue.variable ^$'
+
 echo novalue.variable > expect
 
 test_expect_success 'get-regexp variable with no value' \
        'git config --get-regexp novalue > output &&
         cmp output expect'
 
+echo 'emptyvalue.variable ' > expect
+
+test_expect_success 'get-regexp variable with empty value' \
+       'git config --get-regexp emptyvalue > output &&
+        cmp output expect'
+
+echo true > expect
+
+test_expect_success 'get bool variable with no value' \
+       'git config --bool novalue.variable > output &&
+        cmp output expect'
+
+echo false > expect
+
+test_expect_success 'get bool variable with empty value' \
+       'git config --bool emptyvalue.variable > output &&
+        cmp output expect'
+
 git config > output 2>&1
 
 test_expect_success 'no arguments, but no crash' \
index e474b3f1d5482305356239980248e2ebccbcf561..38a2bf09af286bf681deadb9cdaec80175d13e0c 100755 (executable)
@@ -33,9 +33,9 @@ test_rev_parse() {
 test_rev_parse toplevel false false true ''
 
 cd .git || exit 1
-test_rev_parse .git/ true true false ''
+test_rev_parse .git/ false true false ''
 cd objects || exit 1
-test_rev_parse .git/objects/ true true false ''
+test_rev_parse .git/objects/ false true false ''
 cd ../.. || exit 1
 
 mkdir -p sub/dir || exit 1
index e33ea4e9f4c33cc1f94cd184c371a8fa05bedf3b..e5ed74545b8a2ac9c2063b2ae40d7c661bda0260 100755 (executable)
@@ -340,4 +340,26 @@ test_expect_success 'rebase a commit violating pre-commit' '
 
 '
 
+test_expect_success 'rebase with a file named HEAD in worktree' '
+
+       rm -fr .git/hooks &&
+       git reset --hard &&
+       git checkout -b branch3 A &&
+
+       (
+               GIT_AUTHOR_NAME="Squashed Away" &&
+               export GIT_AUTHOR_NAME &&
+               >HEAD &&
+               git add HEAD &&
+               git commit -m "Add head" &&
+               >BODY &&
+               git add BODY &&
+               git commit -m "Add body"
+       ) &&
+
+       FAKE_LINES="1 squash 2" git rebase -i to-be-rebased &&
+       test "$(git show -s --pretty=format:%an)" = "Squashed Away"
+
+'
+
 test_done
index d30169fbdcafdf51561f024e887f05aa800fc9d4..83c54b747f4efe1f99b67284a7ba72b89df07a6d 100755 (executable)
@@ -326,4 +326,13 @@ test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab:
        ! git diff --check
 
 '
+
+test_expect_success 'line numbers in --check output are correct' '
+
+       echo "" > x &&
+       echo "foo(); " >> x &&
+       git diff --check | grep "x:2:"
+
+'
+
 test_done
diff --git a/t/t4026-color.sh b/t/t4026-color.sh
new file mode 100755 (executable)
index 0000000..b61e516
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Timo Hirvonen
+#
+
+test_description='Test diff/status color escape codes'
+. ./test-lib.sh
+
+color()
+{
+       git config diff.color.new "$1" &&
+       test "`git config --get-color diff.color.new`" = "\e$2"
+}
+
+invalid_color()
+{
+       git config diff.color.new "$1" &&
+       test -z "`git config --get-color diff.color.new 2>/dev/null`"
+}
+
+test_expect_success 'reset' '
+       color "reset" "[m"
+'
+
+test_expect_success 'attribute before color name' '
+       color "bold red" "[1;31m"
+'
+
+test_expect_success 'color name before attribute' '
+       color "red bold" "[1;31m"
+'
+
+test_expect_success 'attr fg bg' '
+       color "ul blue red" "[4;34;41m"
+'
+
+test_expect_success 'fg attr bg' '
+       color "blue ul red" "[4;34;41m"
+'
+
+test_expect_success 'fg bg attr' '
+       color "blue red ul" "[4;34;41m"
+'
+
+test_expect_success '256 colors' '
+       color "254 bold 255" "[1;38;5;254;48;5;255m"
+'
+
+test_expect_success 'color too small' '
+       invalid_color "-2"
+'
+
+test_expect_success 'color too big' '
+       invalid_color "256"
+'
+
+test_expect_success 'extra character after color number' '
+       invalid_color "3X"
+'
+
+test_expect_success 'extra character after color name' '
+       invalid_color "redX"
+'
+
+test_expect_success 'extra character after attribute' '
+       invalid_color "dimX"
+'
+
+test_done
index 9b1a74542a848ef702c1e6208d6ff2537b0f6ac0..d6c55c115779730fdef8d05fbdb039fe90e3fad7 100755 (executable)
@@ -11,7 +11,7 @@ test_expect_success 'split sample box' \
        'git mailsplit -o. ../t5100/sample.mbox >last &&
        last=`cat last` &&
        echo total is $last &&
-       test `cat last` = 8'
+       test `cat last` = 9'
 
 for mail in `echo 00*`
 do
diff --git a/t/t5100/info0009 b/t/t5100/info0009
new file mode 100644 (file)
index 0000000..2a66321
--- /dev/null
@@ -0,0 +1,5 @@
+Author: F U Bar
+Email: f.u.bar@example.com
+Subject: updates
+Date: Mon, 17 Sep 2001 00:00:00 +0900
+
diff --git a/t/t5100/msg0009 b/t/t5100/msg0009
new file mode 100644 (file)
index 0000000..9ffe131
--- /dev/null
@@ -0,0 +1,2 @@
+This is to fix diff-format documentation.
+
diff --git a/t/t5100/patch0009 b/t/t5100/patch0009
new file mode 100644 (file)
index 0000000..65615c3
--- /dev/null
@@ -0,0 +1,13 @@
+diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt
+index b426a14..97756ec 100644
+--- a/Documentation/diff-format.txt
++++ b/Documentation/diff-format.txt
+@@ -81,7 +81,7 @@ The "diff" formatting options can be customized via the
+ environment variable 'GIT_DIFF_OPTS'.  For example, if you
+ prefer context diff:
+-      GIT_DIFF_OPTS=-c git-diff-index -p $(cat .git/HEAD)
++      GIT_DIFF_OPTS=-c git-diff-index -p HEAD
+ 2. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the
index 070c1661b9be8530e619cd0c297673d1e5e958a3..0476b96c33de8bbc6c4b3bc4f510e9fc50aa6440 100644 (file)
@@ -407,3 +407,26 @@ Subject: [PATCH] another patch
 
 Hey you forgot the patch!
 
+From nobody Mon Sep 17 00:00:00 2001
+From: A U Thor <a.u.thor@example.com>
+Date: Mon, 17 Sep 2001 00:00:00 +0900
+Mime-Version: 1.0
+Content-Type: Text/Plain; charset=us-ascii
+Content-Transfer-Encoding: Quoted-Printable
+
+=0A=0AFrom: F U Bar <f.u.bar@example.com>
+Subject: [PATCH] updates=0A=0AThis is to fix diff-format documentation.
+
+diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt
+index b426a14..97756ec 100644
+--- a/Documentation/diff-format.txt
++++ b/Documentation/diff-format.txt
+@@ -81,7 +81,7 @@ The "diff" formatting options can be customized via the
+ environment variable 'GIT_DIFF_OPTS'.  For example, if you
+ prefer context diff:
+=20
+-      GIT_DIFF_OPTS=3D-c git-diff-index -p $(cat .git/HEAD)
++      GIT_DIFF_OPTS=3D-c git-diff-index -p HEAD
+=20
+=20
+ 2. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the
index 4f350dd4ec3658357a7e69f54fb64709a22a2bc9..cd3c149800395553cc973317ef41e89e53771f60 100755 (executable)
@@ -268,4 +268,10 @@ test_expect_success \
     'make sure index-pack detects the SHA1 collision' \
     '! git-index-pack -o bad.idx test-3.pack'
 
+test_expect_success \
+    'honor pack.packSizeLimit' \
+    'git config pack.packSizeLimit 200 &&
+     packname_4=$(git pack-objects test-4 <obj-list) &&
+     test 3 = $(ls test-4-*.pack | wc -l)'
+
 test_done
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
new file mode 100644 (file)
index 0000000..6560af7
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Johannes E. Schindelin
+#
+
+test_description='prune'
+. ./test-lib.sh
+
+test_expect_success setup '
+
+       : > file &&
+       git add file &&
+       test_tick &&
+       git commit -m initial &&
+       git gc
+
+'
+
+test_expect_success 'prune stale packs' '
+
+       orig_pack=$(echo .git/objects/pack/*.pack) &&
+       : > .git/objects/tmp_1.pack &&
+       : > .git/objects/tmp_2.pack &&
+       test-chmtime -86501 .git/objects/tmp_1.pack &&
+       git prune --expire 1.day &&
+       test -f $orig_pack &&
+       test -f .git/objects/tmp_2.pack &&
+       ! test -f .git/objects/tmp_1.pack
+
+'
+
+test_done
index 2ba4b00e526eb00c5d236777f896772c6cad538b..ec71123f4be187c1399c90dc806dbae53cda5b7f 100755 (executable)
@@ -254,6 +254,18 @@ test_expect_success 'bisect run & skip: find first bad' '
        grep "$HASH6 is first bad commit" my_bisect_log.txt
 '
 
+test_expect_success 'bisect starting with a detached HEAD' '
+
+       git bisect reset &&
+       git checkout master^ &&
+       HEAD=$(git rev-parse --verify HEAD) &&
+       git bisect start &&
+       test $HEAD = $(cat .git/head-name) &&
+       git bisect reset &&
+       test $HEAD = $(git rev-parse --verify HEAD)
+
+'
+
 #
 #
 test_done
index 5f60b22d872b5d034e137e0c6c7c5a9d664e57ee..868babc4b2350526192a8df53f6cbec3f81c644e 100755 (executable)
@@ -165,4 +165,18 @@ test_expect_success '"map" works in commit filter' '
        git rev-parse --verify master
 '
 
+test_expect_success 'Name needing quotes' '
+
+       git checkout -b rerere A &&
+       mkdir foo &&
+       name="ă‚Œă‚Œă‚Œ" &&
+       >foo/$name &&
+       git add foo &&
+       git commit -m "Adding a file" &&
+       git filter-branch --tree-filter "rm -fr foo" &&
+       ! git ls-files --error-unmatch "foo/$name" &&
+       test $(git rev-parse --verify rerere) != $(git rev-parse --verify A)
+
+'
+
 test_done
index 9ce50cade8981bb5317397c10b0fabeba4893fc8..e00607490bcb0439c6557003a3419d84823a8f00 100755 (executable)
@@ -17,6 +17,9 @@ test_expect_success 'setup' '
        : > dir1/tracked &&
        : > dir1/modified &&
        git add . &&
+
+       git status >output &&
+
        test_tick &&
        git commit -m initial &&
        : > untracked &&
@@ -28,6 +31,12 @@ test_expect_success 'setup' '
        git add dir2/added
 '
 
+test_expect_success 'status (1)' '
+
+       grep -e "use \"git rm --cached <file>\.\.\.\" to unstage" output
+
+'
+
 cat > expect << \EOF
 # On branch master
 # Changes to be committed:
@@ -51,7 +60,7 @@ cat > expect << \EOF
 #      untracked
 EOF
 
-test_expect_success 'status' '
+test_expect_success 'status (2)' '
 
        git status > output &&
        git diff expect output
@@ -119,4 +128,25 @@ test_expect_success 'status without relative paths' '
 
 '
 
+cat <<EOF >expect
+# On branch master
+# Changes to be committed:
+#   (use "git reset HEAD <file>..." to unstage)
+#
+#      modified:   dir1/modified
+#
+# Untracked files:
+#   (use "git add <file>..." to include in what will be committed)
+#
+#      dir1/untracked
+#      dir2/
+#      expect
+#      output
+#      untracked
+EOF
+test_expect_success 'status of partial commit excluding new file in index' '
+       git status dir1/modified >output &&
+       diff -u expect output
+'
+
 test_done
index a15222ced4d75e70f49df08159cff9dd8d4167a4..49d57a81ec1cc55f83fb63436631dfdc7d647e0b 100755 (executable)
@@ -2,7 +2,7 @@
 #
 # Copyright (c) Robin Rosenberg
 #
-test_description='CVS export comit. '
+test_description='Test export of commits to CVS'
 
 . ./test-lib.sh
 
@@ -246,4 +246,20 @@ test_expect_success \
        ;;
 esac
 
+test_expect_success '-w option should work with relative GIT_DIR' '
+      mkdir W &&
+      echo foobar >W/file1.txt &&
+      echo bazzle >W/file2.txt &&
+      git add W/file1.txt &&
+      git add W/file2.txt &&
+      git commit -m "More updates" &&
+      id=$(git rev-list --max-count=1 HEAD) &&
+      (cd "$GIT_DIR" &&
+      GIT_DIR=. git cvsexportcommit -w "$CVSWORK" -c $id &&
+      check_entries "$CVSWORK/W" "file1.txt/1.1/|file2.txt/1.1/" &&
+      diff -u "$CVSWORK/W/file1.txt" ../W/file1.txt &&
+      diff -u "$CVSWORK/W/file2.txt" ../W/file2.txt
+      )
+'
+
 test_done
index da47bd7c9eaac7f01106c290fab8364e1ce838a4..83889c4f4690d30fd2d5e969d5d445dfb47ad579 100644 (file)
@@ -324,8 +324,11 @@ test_done () {
 PATH=$(pwd)/..:$PATH
 GIT_EXEC_PATH=$(pwd)/..
 GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
-GIT_CONFIG=.git/config
-export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG
+unset GIT_CONFIG
+unset GIT_CONFIG_LOCAL
+GIT_CONFIG_NOSYSTEM=1
+GIT_CONFIG_NOGLOBAL=1
+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL
 
 GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
 export GITPERLLIB
index babaa21398522939076151f1c240a4f18f9a90a1..397983d1155bed967bd48ad47dbbb81cb2e45168 100644 (file)
@@ -441,11 +441,12 @@ static struct ref *get_refs_via_curl(struct transport *transport)
        struct ref *ref = NULL;
        struct ref *last_ref = NULL;
 
+       if (!transport->data)
+               transport->data = get_http_walker(transport->url);
+
        refs_url = xmalloc(strlen(transport->url) + 11);
        sprintf(refs_url, "%s/info/refs", transport->url);
 
-       http_init();
-
        slot = get_active_slot();
        slot->results = &results;
        curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
@@ -473,8 +474,6 @@ static struct ref *get_refs_via_curl(struct transport *transport)
                return NULL;
        }
 
-       http_cleanup();
-
        data = buffer.buf;
        start = NULL;
        mid = data;
@@ -563,6 +562,8 @@ struct git_transport_data {
        unsigned thin : 1;
        unsigned keep : 1;
        int depth;
+       struct child_process *conn;
+       int fd[2];
        const char *uploadpack;
        const char *receivepack;
 };
@@ -593,20 +594,20 @@ static int set_git_option(struct transport *connection,
        return 1;
 }
 
+static int connect_setup(struct transport *transport)
+{
+       struct git_transport_data *data = transport->data;
+       data->conn = git_connect(data->fd, transport->url, data->uploadpack, 0);
+       return 0;
+}
+
 static struct ref *get_refs_via_connect(struct transport *transport)
 {
        struct git_transport_data *data = transport->data;
        struct ref *refs;
-       int fd[2];
-       char *dest = xstrdup(transport->url);
-       struct child_process *conn = git_connect(fd, dest, data->uploadpack, 0);
-
-       get_remote_heads(fd[0], &refs, 0, NULL, 0);
-       packet_flush(fd[1]);
-
-       finish_connect(conn);
 
-       free(dest);
+       connect_setup(transport);
+       get_remote_heads(data->fd[0], &refs, 0, NULL, 0);
 
        return refs;
 }
@@ -617,7 +618,7 @@ static int fetch_refs_via_pack(struct transport *transport,
        struct git_transport_data *data = transport->data;
        char **heads = xmalloc(nr_heads * sizeof(*heads));
        char **origh = xmalloc(nr_heads * sizeof(*origh));
-       struct ref *refs;
+       const struct ref *refs;
        char *dest = xstrdup(transport->url);
        struct fetch_pack_args args;
        int i;
@@ -632,13 +633,27 @@ static int fetch_refs_via_pack(struct transport *transport,
 
        for (i = 0; i < nr_heads; i++)
                origh[i] = heads[i] = xstrdup(to_fetch[i]->name);
-       refs = fetch_pack(&args, dest, nr_heads, heads, &transport->pack_lockfile);
+
+       refs = transport_get_remote_refs(transport);
+       if (!data->conn) {
+               struct ref *refs_tmp;
+               connect_setup(transport);
+               get_remote_heads(data->fd[0], &refs_tmp, 0, NULL, 0);
+               free_refs(refs_tmp);
+       }
+
+       refs = fetch_pack(&args, data->fd, data->conn, transport->remote_refs,
+                         dest, nr_heads, heads, &transport->pack_lockfile);
+       close(data->fd[0]);
+       close(data->fd[1]);
+       if (finish_connect(data->conn))
+               refs = NULL;
+       data->conn = NULL;
 
        for (i = 0; i < nr_heads; i++)
                free(origh[i]);
        free(origh);
        free(heads);
-       free_refs(refs);
        free(dest);
        return (refs ? 0 : -1);
 }
@@ -661,7 +676,15 @@ static int git_transport_push(struct transport *transport, int refspec_nr, const
 
 static int disconnect_git(struct transport *transport)
 {
-       free(transport->data);
+       struct git_transport_data *data = transport->data;
+       if (data->conn) {
+               packet_flush(data->fd[1]);
+               close(data->fd[0]);
+               close(data->fd[1]);
+               finish_connect(data->conn);
+       }
+
+       free(data);
        return 0;
 }
 
@@ -721,6 +744,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
                ret->disconnect = disconnect_git;
 
                data->thin = 1;
+               data->conn = NULL;
                data->uploadpack = "git-upload-pack";
                if (remote && remote->uploadpack)
                        data->uploadpack = remote->uploadpack;
diff --git a/tree.c b/tree.c
index 8c0819fa721771f6dc2e727860345376edb3ea60..87708ef420aaa328c9a8dfcefbcf4aa7ba6d4b72 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -142,8 +142,8 @@ static int cmp_cache_name_compare(const void *a_, const void *b_)
 
        ce1 = *((const struct cache_entry **)a_);
        ce2 = *((const struct cache_entry **)b_);
-       return cache_name_compare(ce1->name, ntohs(ce1->ce_flags),
-                                 ce2->name, ntohs(ce2->ce_flags));
+       return cache_name_compare(ce1->name, ce1->ce_flags,
+                                 ce2->name, ce2->ce_flags);
 }
 
 int read_tree(struct tree *tree, int stage, const char **match)
index aa2513ed798969c02fc5e14097666eb4c4c02bae..ff46fd62fdceeefc2ebd98ae1c9483964cb37bd5 100644 (file)
@@ -289,7 +289,6 @@ static struct checkout state;
 static void check_updates(struct cache_entry **src, int nr,
                        struct unpack_trees_options *o)
 {
-       unsigned short mask = htons(CE_UPDATE);
        unsigned cnt = 0, total = 0;
        struct progress *progress = NULL;
        char last_symlink[PATH_MAX];
@@ -297,7 +296,7 @@ static void check_updates(struct cache_entry **src, int nr,
        if (o->update && o->verbose_update) {
                for (total = cnt = 0; cnt < nr; cnt++) {
                        struct cache_entry *ce = src[cnt];
-                       if (!ce->ce_mode || ce->ce_flags & mask)
+                       if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
                                total++;
                }
 
@@ -310,15 +309,15 @@ static void check_updates(struct cache_entry **src, int nr,
        while (nr--) {
                struct cache_entry *ce = *src++;
 
-               if (!ce->ce_mode || ce->ce_flags & mask)
+               if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
                        display_progress(progress, ++cnt);
-               if (!ce->ce_mode) {
+               if (ce->ce_flags & CE_REMOVE) {
                        if (o->update)
                                unlink_entry(ce->name, last_symlink);
                        continue;
                }
-               if (ce->ce_flags & mask) {
-                       ce->ce_flags &= ~mask;
+               if (ce->ce_flags & CE_UPDATE) {
+                       ce->ce_flags &= ~CE_UPDATE;
                        if (o->update) {
                                checkout_entry(ce, &state, NULL);
                                *last_symlink = '\0';
@@ -408,7 +407,7 @@ static void verify_uptodate(struct cache_entry *ce,
                 * submodules that are marked to be automatically
                 * checked out.
                 */
-               if (S_ISGITLINK(ntohl(ce->ce_mode)))
+               if (S_ISGITLINK(ce->ce_mode))
                        return;
                errno = 0;
        }
@@ -450,7 +449,7 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
        int cnt = 0;
        unsigned char sha1[20];
 
-       if (S_ISGITLINK(ntohl(ce->ce_mode)) &&
+       if (S_ISGITLINK(ce->ce_mode) &&
            resolve_gitlink_ref(ce->name, "HEAD", sha1) == 0) {
                /* If we are not going to update the submodule, then
                 * we don't care.
@@ -481,7 +480,7 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
                 */
                if (!ce_stage(ce)) {
                        verify_uptodate(ce, o);
-                       ce->ce_mode = 0;
+                       ce->ce_flags |= CE_REMOVE;
                }
                cnt++;
        }
@@ -568,7 +567,7 @@ static void verify_absent(struct cache_entry *ce, const char *action,
                cnt = cache_name_pos(ce->name, strlen(ce->name));
                if (0 <= cnt) {
                        struct cache_entry *ce = active_cache[cnt];
-                       if (!ce_stage(ce) && !ce->ce_mode)
+                       if (ce->ce_flags & CE_REMOVE)
                                return;
                }
 
@@ -580,7 +579,7 @@ static void verify_absent(struct cache_entry *ce, const char *action,
 static int merged_entry(struct cache_entry *merge, struct cache_entry *old,
                struct unpack_trees_options *o)
 {
-       merge->ce_flags |= htons(CE_UPDATE);
+       merge->ce_flags |= CE_UPDATE;
        if (old) {
                /*
                 * See if we can re-use the old CE directly?
@@ -601,7 +600,7 @@ static int merged_entry(struct cache_entry *merge, struct cache_entry *old,
                invalidate_ce_path(merge);
        }
 
-       merge->ce_flags &= ~htons(CE_STAGEMASK);
+       merge->ce_flags &= ~CE_STAGEMASK;
        add_cache_entry(merge, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
        return 1;
 }
@@ -613,7 +612,7 @@ static int deleted_entry(struct cache_entry *ce, struct cache_entry *old,
                verify_uptodate(old, o);
        else
                verify_absent(ce, "removed", o);
-       ce->ce_mode = 0;
+       ce->ce_flags |= CE_REMOVE;
        add_cache_entry(ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
        invalidate_ce_path(ce);
        return 1;
@@ -634,7 +633,7 @@ static void show_stage_entry(FILE *o,
        else
                fprintf(o, "%s%06o %s %d\t%s\n",
                        label,
-                       ntohl(ce->ce_mode),
+                       ce->ce_mode,
                        sha1_to_hex(ce->sha1),
                        ce_stage(ce),
                        ce->name);
@@ -920,7 +919,7 @@ int oneway_merge(struct cache_entry **src,
                        struct stat st;
                        if (lstat(old->name, &st) ||
                            ce_match_stat(old, &st, CE_MATCH_IGNORE_VALID))
-                               old->ce_flags |= htons(CE_UPDATE);
+                               old->ce_flags |= CE_UPDATE;
                }
                return keep_entry(old, o);
        }
index 5517faafad6ca3f327c81ab6e8e5f2701ff0ad14..197a0044aa71fc9ca310b36b279b8382487a40a7 100644 (file)
@@ -25,6 +25,7 @@ struct unpack_trees_options {
        int merge_size;
 
        struct cache_entry *df_conflict_entry;
+       void *unpack_data;
 };
 
 extern int unpack_trees(unsigned n, struct tree_desc *t,
index 7e04311027176fc87c1de7dd619000d2a75d4eb9..51e3ec49d120f2e5a095cde45eb0a22bb7e624da 100644 (file)
@@ -620,6 +620,9 @@ int main(int argc, char **argv)
 
        if (i != argc-1)
                usage(upload_pack_usage);
+
+       setup_path(NULL);
+
        dir = argv[i];
 
        if (!enter_repo(dir, strict))
index c0c247243b562a7579ff780b80dffef4774b60a9..0b060934e218f1d6fb95777ea7dd7faef1c2dd93 100644 (file)
@@ -60,7 +60,7 @@ static void wt_status_print_cached_header(struct wt_status *s)
 {
        const char *c = color(WT_STATUS_HEADER);
        color_fprintf_ln(s->fp, c, "# Changes to be committed:");
-       if (s->reference) {
+       if (!s->is_initial) {
                color_fprintf_ln(s->fp, c, "#   (use \"git reset %s <file>...\" to unstage)", s->reference);
        } else {
                color_fprintf_ln(s->fp, c, "#   (use \"git rm --cached <file>...\" to unstage)");
@@ -217,19 +217,12 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
                wt_status_print_trailer(s);
 }
 
-static void wt_read_cache(struct wt_status *s)
-{
-       discard_cache();
-       read_cache_from(s->index_file);
-}
-
 static void wt_status_print_initial(struct wt_status *s)
 {
        int i;
        struct strbuf buf;
 
        strbuf_init(&buf, 0);
-       wt_read_cache(s);
        if (active_nr) {
                s->commitable = 1;
                wt_status_print_cached_header(s);
@@ -256,7 +249,6 @@ static void wt_status_print_updated(struct wt_status *s)
        rev.diffopt.detect_rename = 1;
        rev.diffopt.rename_limit = 100;
        rev.diffopt.break_opt = 0;
-       wt_read_cache(s);
        run_diff_index(&rev, 1);
 }
 
@@ -268,7 +260,6 @@ static void wt_status_print_changed(struct wt_status *s)
        rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
        rev.diffopt.format_callback = wt_status_print_changed_cb;
        rev.diffopt.format_callback_data = s;
-       wt_read_cache(s);
        run_diff_files(&rev, 0);
 }
 
@@ -335,7 +326,6 @@ static void wt_status_print_verbose(struct wt_status *s)
        setup_revisions(0, NULL, &rev, s->reference);
        rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
        rev.diffopt.detect_rename = 1;
-       wt_read_cache(s);
        run_diff_index(&rev, 1);
 
        fflush(stdout);
@@ -402,6 +392,8 @@ int git_status_config(const char *k, const char *v)
        }
        if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
                int slot = parse_status_slot(k, 13);
+               if (!v)
+                       return config_error_nonbool(k);
                color_parse(v, k, wt_status_colors[slot]);
                return 0;
        }