]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jn/grep-open'
authorJunio C Hamano <gitster@pobox.com>
Thu, 15 Jul 2010 19:07:18 +0000 (12:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Jul 2010 19:07:18 +0000 (12:07 -0700)
* jn/grep-open:
  grep -O: Do not pass color sequences as filenames to pager

304 files changed:
Documentation/Makefile
Documentation/RelNotes-1.7.1.1.txt [new file with mode: 0644]
Documentation/RelNotes-1.7.1.2.txt [new file with mode: 0644]
Documentation/RelNotes-1.7.2.txt
Documentation/config.txt
Documentation/diff-options.txt
Documentation/fetch-options.txt
Documentation/git-add.txt
Documentation/git-cat-file.txt
Documentation/git-check-ref-format.txt
Documentation/git-checkout.txt
Documentation/git-cherry-pick.txt
Documentation/git-commit.txt
Documentation/git-cvsserver.txt
Documentation/git-diff.txt
Documentation/git-fast-import.txt
Documentation/git-format-patch.txt
Documentation/git-gc.txt
Documentation/git-grep.txt
Documentation/git-instaweb.txt
Documentation/git-log.txt
Documentation/git-mailinfo.txt
Documentation/git-merge.txt
Documentation/git-notes.txt
Documentation/git-push.txt
Documentation/git-rebase.txt
Documentation/git-reflog.txt
Documentation/git-remote.txt
Documentation/git-rerere.txt
Documentation/git-rev-parse.txt
Documentation/git-revert.txt
Documentation/git-send-email.txt
Documentation/git-show-branch.txt
Documentation/git-show.txt
Documentation/git-status.txt
Documentation/git-submodule.txt
Documentation/git-update-index.txt
Documentation/git.txt
Documentation/gitattributes.txt
Documentation/gitcore-tutorial.txt
Documentation/gitignore.txt
Documentation/gitk.txt
Documentation/gitmodules.txt
Documentation/gitrevisions.txt [new file with mode: 0644]
Documentation/install-webdoc.sh
Documentation/pretty-formats.txt
Documentation/rev-list-options.txt
Documentation/revisions.txt [new file with mode: 0644]
Documentation/technical/api-run-command.txt
Documentation/technical/protocol-capabilities.txt
Documentation/user-manual.txt
Makefile
aclocal.m4 [new file with mode: 0644]
attr.c
attr.h
block-sha1/sha1.c
builtin.h
builtin/add.c
builtin/apply.c
builtin/blame.c
builtin/branch.c
builtin/cat-file.c
builtin/checkout.c
builtin/clone.c
builtin/commit.c
builtin/fetch.c
builtin/fmt-merge-msg.c
builtin/for-each-ref.c
builtin/grep.c
builtin/help.c
builtin/log.c
builtin/ls-files.c
builtin/ls-remote.c
builtin/mailinfo.c
builtin/merge-file.c
builtin/merge-tree.c
builtin/merge.c
builtin/notes.c
builtin/pack-objects.c
builtin/read-tree.c
builtin/receive-pack.c
builtin/remote.c
builtin/rerere.c
builtin/rev-list.c
builtin/rev-parse.c
builtin/revert.c
cache.h
combine-diff.c
commit.h
compat/mingw.h
compat/win32/pthread.c
compat/win32/pthread.h
config.c
config.mak.in
configure.ac
connect.c
contrib/completion/git-completion.bash
convert.c
ctype.c
daemon.c
date.c
diff-lib.c
diff.c
diff.h
dir.c
environment.c
fast-import.c
fsck.c
git-add--interactive.perl
git-am.sh
git-compat-util.h
git-cvsserver.perl
git-instaweb.sh
git-merge-one-file.sh
git-pull.sh
git-rebase--interactive.sh
git-rebase.sh
git-remote-testgit.py
git-request-pull.sh
git-send-email.perl
git-submodule.sh
git-svn.perl
git-web--browse.sh
git.spec.in
git_remote_helpers/git/exporter.py
git_remote_helpers/git/importer.py
git_remote_helpers/git/non_local.py
git_remote_helpers/git/repo.py
gitweb/INSTALL
gitweb/Makefile
gitweb/README
gitweb/gitweb.perl
gitweb/static/git-favicon.png [moved from gitweb/git-favicon.png with 100% similarity]
gitweb/static/git-logo.png [moved from gitweb/git-logo.png with 100% similarity]
gitweb/static/gitweb.css [moved from gitweb/gitweb.css with 93% similarity]
gitweb/static/gitweb.js [moved from gitweb/gitweb.js with 100% similarity]
graph.c
grep.c
grep.h
http-backend.c
http-push.c
http-walker.c
imap-send.c
ll-merge.c
log-tree.c
log-tree.h
merge-file.c
merge-recursive.h
notes.c
notes.h
parse-options.c
parse-options.h
perl/Git.pm
pretty.c
quote.c
quote.h
refs.c
refs.h
remote.c
remote.h
rerere.c
revision.c
revision.h
run-command.c
run-command.h
setup.c
sha1_file.c
sha1_name.c
submodule.c
submodule.h
t/Makefile
t/README
t/aggregate-results.sh
t/gitweb-lib.sh
t/lib-cvs.sh
t/lib-git-svn.sh
t/lib-httpd.sh
t/lib-patch-mode.sh
t/lib-t6000.sh [moved from t/t6000lib.sh with 98% similarity]
t/t0000-basic.sh
t/t0005-signals.sh
t/t0006-date.sh
t/t0020-crlf.sh
t/t0021-conversion.sh
t/t0025-crlf-auto.sh [new file with mode: 0755]
t/t0026-eol-config.sh [new file with mode: 0755]
t/t0040-parse-options.sh
t/t1001-read-tree-m-2way.sh
t/t1020-subdirectory.sh
t/t1304-default-acl.sh
t/t1450-fsck.sh
t/t1502-rev-parse-parseopt.sh
t/t1509-root-worktree.sh
t/t2007-checkout-symlink.sh
t/t2017-checkout-orphan.sh
t/t2102-update-index-symlinks.sh
t/t2106-update-index-assume-unchanged.sh [new file with mode: 0755]
t/t3030-merge-recursive.sh
t/t3200-branch.sh
t/t3210-pack-refs.sh
t/t3300-funny-names.sh
t/t3301-notes.sh
t/t3302-notes-index-expensive.sh
t/t3306-notes-prune.sh
t/t3307-notes-man.sh [new file with mode: 0755]
t/t3400-rebase.sh
t/t3404-rebase-interactive.sh
t/t3501-revert-cherry-pick.sh
t/t3508-cherry-pick-many-commits.sh [new file with mode: 0755]
t/t3600-rm.sh
t/t3700-add.sh
t/t3701-add-interactive.sh
t/t3902-quoted.sh
t/t3903-stash.sh
t/t4002-diff-basic.sh
t/t4004-diff-rename-symlink.sh
t/t4011-diff-symlink.sh
t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^
t/t4014-format-patch.sh
t/t4015-diff-whitespace.sh
t/t4016-diff-quote.sh
t/t4023-diff-rename-typechange.sh
t/t4027-diff-submodule.sh
t/t4041-diff-submodule-option.sh [moved from t/t4041-diff-submodule.sh with 74% similarity]
t/t4043-diff-rename-binary.sh [new file with mode: 0755]
t/t4044-diff-index-unique-abbrev.sh [new file with mode: 0755]
t/t4114-apply-typechange.sh
t/t4115-apply-symlink.sh
t/t4122-apply-symlink-inside.sh
t/t4124-apply-ws-rule.sh
t/t4127-apply-same-fn.sh
t/t4205-log-pretty-formats.sh [new file with mode: 0755]
t/t4207-log-decoration-colors.sh [new file with mode: 0755]
t/t5150-request-pull.sh
t/t5300-pack-object.sh
t/t5302-pack-index.sh
t/t5503-tagfollow.sh
t/t5505-remote.sh
t/t5510-fetch.sh
t/t5512-ls-remote.sh
t/t5520-pull.sh
t/t5522-pull-symlink.sh
t/t5530-upload-pack-error.sh
t/t5540-http-push.sh
t/t5541-http-push.sh
t/t5550-http-fetch.sh
t/t5551-http-fetch.sh
t/t5561-http-backend.sh
t/t5601-clone.sh
t/t5700-clone-reference.sh
t/t5705-clone-2gb.sh
t/t5800-remote-helpers.sh
t/t6001-rev-list-graft.sh
t/t6002-rev-list-bisect.sh
t/t6003-rev-list-topo-order.sh
t/t6006-rev-list-format.sh
t/t6007-rev-list-cherry-pick-file.sh
t/t6018-rev-list-glob.sh
t/t6019-rev-list-ancestry-path.sh [new file with mode: 0755]
t/t6022-merge-rename.sh
t/t6035-merge-dir-to-symlink.sh
t/t6101-rev-parse-parents.sh
t/t7004-tag.sh
t/t7005-editor.sh
t/t7006-pager.sh
t/t7008-grep-binary.sh [new file with mode: 0755]
t/t7010-setup.sh
t/t7400-submodule-basic.sh
t/t7405-submodule-merge.sh
t/t7407-submodule-foreach.sh
t/t7502-commit.sh
t/t7508-status.sh
t/t7509-commit.sh
t/t7604-merge-custom-message.sh
t/t7800-difftool.sh
t/t7810-grep.sh
t/t8006-blame-textconv.sh [new file with mode: 0755]
t/t8007-cat-file-textconv.sh [new file with mode: 0755]
t/t9001-send-email.sh
t/t9100-git-svn-basic.sh
t/t9118-git-svn-funky-branch-names.sh
t/t9119-git-svn-info.sh
t/t9129-git-svn-i18n-commitencoding.sh
t/t9143-git-svn-gc.sh
t/t9200-git-cvsexportcommit.sh
t/t9400-git-cvsserver-server.sh
t/t9401-git-cvsserver-crlf.sh
t/t9500-gitweb-standalone-no-errors.sh
t/t9600-cvsimport.sh
t/t9700-perl-git.sh
t/t9700/test.pl
t/test-lib.sh
test-date.c
trace.c
transport.c
unpack-trees.c
url.c [new file with mode: 0644]
url.h [new file with mode: 0644]
usage.c
userdiff.c
wrapper.c
wt-status.c
wt-status.h
xdiff/xutils.c

index 04f69cf64e5d989bac3cd1c235e6a7e657c6c103..a4c4063e50d3eb3bd36d94b399f790e56fe4b050 100644 (file)
@@ -6,7 +6,7 @@ MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt \
        gitrepository-layout.txt
 MAN7_TXT=gitcli.txt gittutorial.txt gittutorial-2.txt \
        gitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt \
-       gitdiffcore.txt gitworkflows.txt
+       gitdiffcore.txt gitrevisions.txt gitworkflows.txt
 
 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
 MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
diff --git a/Documentation/RelNotes-1.7.1.1.txt b/Documentation/RelNotes-1.7.1.1.txt
new file mode 100644 (file)
index 0000000..3f6b314
--- /dev/null
@@ -0,0 +1,96 @@
+Git v1.7.1.1 Release Notes
+==========================
+
+Fixes since v1.7.1
+------------------
+
+ * Authentication over http transport can now be made lazily, in that the
+   request can first go to a URL without username, get a 401 response and
+   then the client will ask for the username to use.
+
+ * We used to mistakenly think "../work" is a subdirectory of the current
+   directory when we are in "../work-xyz".
+
+ * The attribute mechanism now allows an entry that uses an attribute
+   macro that set/unset one attribute, immediately followed by an
+   overriding setting; this makes attribute macros much easier to use.
+
+ * We didn't recognize timezone "Z" as a synonym for "UTC" (75b37e70).
+
+ * In 1.7.0, read-tree and user commands that use the mechanism such as
+   checkout and merge were fixed to handle switching between branches one
+   of which has a file while the other has a directory at the same path
+   correctly even when there are some "confusing" pathnames in them.  But
+   the algorithm used for this fix was suboptimal and had a terrible
+   performance degradation especially in larger trees.
+
+ * "git am -3" did not show diagnosis when the patch in the message was corrupt.
+
+ * After "git apply --whitespace=fix" removed trailing blank lines in an
+   patch in a patch series, it failed to apply later patches that depend
+   on the presence of such blank lines.
+
+ * "git bundle --stdin" segfaulted.
+
+ * "git checkout" and "git rebase" overwrote paths that are marked "assume
+   unchanged".
+
+ * "git commit --amend" on a commit with an invalid author-name line that
+   lacks the display name didn't work.
+
+ * "git describe" did not tie-break tags that point at the same commit
+   correctly; newer ones are preferred by paying attention to the
+   tagger date now.
+
+ * "git diff" used to tell underlying xdiff machinery to work very hard to
+   minimize the output, but this often was spending too many extra cycles
+   for very little gain.
+
+ * "git diff --color" did not paint extended diff headers per line
+   (i.e. the coloring escape sequence didn't end at the end of line),
+   which confused "less -R".
+
+ * "git fetch" over HTTP verifies the downloaded packfiles more robustly.
+
+ * The memory usage by "git index-pack" (run during "git fetch" and "git
+   push") got leaner.
+
+ * "GIT_DIR=foo.git git init --bare bar.git" created foo.git instead of bar.git.
+
+ * "git log --abbrev=$num --format='%h' ignored --abbrev=$num.
+
+ * "git ls-files ../out/side/cwd" refused to work.
+
+ * "git merge --log" used to replace the custom message given by "-m" with
+   the shortlog, instead of appending to it.
+
+ * "git notes copy" without any other argument segfaulted.
+
+ * "git pull" accepted "--dry-run", gave it to underlying "git fetch" but
+   ignored the option itself, resulting in a bogus attempt to merge
+   unrelated commit.
+
+ * "git rebase" did not faithfully reproduce a malformed author ident, that
+   is often seen in a repository converted from foreign SCMs.
+
+ * "git reset --hard" started from a wrong directory and a working tree in
+   a nonstandard location is in use got confused.
+
+ * "git send-email" lacked a way to specify the domainname used in the
+   EHLO/HELO exchange, causing rejected connection from picky servers.
+   It learned --smtp-domain option to solve this issue.
+
+ * "git send-email" did not declare a content-transfer-encoding and
+   content-type even when its payload needs to be sent in 8-bit.
+
+ * "git show -C -C" and other corner cases lost diff metainfo output
+   in 1.7.0.
+
+ * "git stash" incorrectly lost paths in the working tree that were
+   previously removed from the index.
+
+ * "git status" stopped refreshing the index by mistake in 1.7.1.
+
+ * "git status" showed excess "hints" even when advice.statusHints is set to false.
+
+And other minor fixes and documentation updates.
diff --git a/Documentation/RelNotes-1.7.1.2.txt b/Documentation/RelNotes-1.7.1.2.txt
new file mode 100644 (file)
index 0000000..46b6a96
--- /dev/null
@@ -0,0 +1,19 @@
+Git v1.7.1.2 Release Notes
+==========================
+
+Fixes since v1.7.1.1
+--------------------
+
+ * "git commit" did not honor GIT_REFLOG_ACTION environment variable, resulting
+   reflog messages for cherry-pick and revert actions to be recorded as "commit".
+
+ * "git clone/fetch/pull" issued an incorrect error message when a ref and
+   a symref that points to the ref were updated at the same time.  This
+   obviously would update them to the same value, and should not result in
+   an error condition.
+
+ * "git diff" inside a tree with many pathnames that have certain
+   characters has become very slow in 1.7.0 by mistake.
+
+ * "git rev-parse --parseopt --stop-at-non-option" did not stop at non option
+   when --keep-dashdash was in effect.
index 37781b4f149a0af5a1c61a538ac320879f4470f2..f24b3876af6e2edbfdd7e8af2eff445fb8e6f85d 100644 (file)
@@ -4,37 +4,152 @@ Git v1.7.2 Release Notes (draft)
 Updates since v1.7.1
 --------------------
 
- * After "git apply --whitespace=fix" removed trailing blank lines in an
-   patch in a patch series, it failed to apply later patches that depend
-   on the presense of such blank lines.
+ * core.eol configuration and text/eol attributes are the new way to control
+   the end of line conventions for files in the working tree.
+
+ * core.autocrlf has been made safer - it will now only handle line
+   endings for new files and files that are LF-only in the
+   repository. To normalize content that has been checked in with
+   CRLF, use the new eol/text attributes.
+
+ * The whitespace rules used in "git apply --whitespace" and "git diff"
+   gained a new member in the family (tab-in-indent) to help projects with
+   policy to indent only with spaces.
+
+ * When working from a subdirectory, by default, git does not look for its
+   metadirectory ".git" across filesystems, primarily to help people who
+   have invocations of git in their custom PS1 prompts, as being outside
+   of a git repository would look for ".git" all the way up to the root
+   directory, and NFS mounts are often slow.  DISCOVERY_ACROSS_FILESYSTEM
+   environment variable can be used to tell git not to stop at a
+   filesystem boundary.
+
+ * Usage help messages generated by parse-options library (i.e. most
+   of the Porcelain commands) are sent to the standard output now.
+
+ * ':/<string>' notation to look for a commit now takes regular expression
+   and it is not anchored at the beginning of the commit log message
+   anymore (this is a backward incompatible change).
+
+ * "git" wrapper learned "-c name=value" option to override configuration
+   variable from the command line.
+
+ * Improved portability for various platforms including older SunOS,
+   HP-UX 10/11, AIX, Tru64, etc. and platforms with Python 2.4.
+
+ * The message from "git am -3" has been improved when conflict
+   resolution ended up making the patch a no-op.
+
+ * "git blame" applies the textconv filter to the contents it works
+   on, when available.
+
+ * "git checkout --orphan newbranch" is similar to "-b newbranch" but
+   prepares to create a root commit that is not connected to any existing
+   commit.
+
+ * "git cherry-pick" learned to pick a range of commits
+   (e.g. "cherry-pick A..B" and "cherry-pick --stdin"), so did "git
+   revert"; these do not support the nicer sequencing control "rebase
+   [-i]" has, though.
+
+ * "git cherry-pick" and "git revert" learned --strategy option to specify
+   the merge strategy to be used when performing three-way merges.
+
+ * "git cvsserver" can be told to use pserver; its password file can be
+   stored outside the repository.
 
  * The output from the textconv filter used by "git diff" can be cached to
    speed up their reuse.
 
- * "git send-email" learned --smtp-domain option to specify the domainname
-   used in the EHLO/HELO exchange.
+ * "git diff --word-diff=<mode>" extends the existing "--color-words"
+   option, making it more useful in color-challenged environments.
 
- * "git revert" learned --strategy option to specify the merge strategy.
+ * The regexp to detect function headers used by "git diff" for PHP has
+   been enhanced for visibility modifiers (public, protected, etc.) to
+   better support PHP5.
 
- * The whitespace rules used in "git apply --whitespace" and "git diff"
-   gained a new member in the family (tab-in-indent) to help projects with
-   policy to indent only with spaces.
+ * "diff.noprefix" configuration variable can be used to implicitly
+   ask for "diff --no-prefix" behaviour.
+
+ * "git for-each-ref" learned "%(objectname:short)" that gives the object
+   name abbreviated.
+
+ * "git format-patch" learned --signature option and format.signature
+   configuration variable to customize the e-mail signature used in the
+   output.
+
+ * Various options to "git grep" (e.g. --count, --name-only) work better
+   with binary files.
 
- * Authentication over http transport can now be made lazily, in that the
-   request can first go to a URL without username, get a 401 response and
-   then the client will ask for the username to use.
+ * "git grep" learned "-Ovi" to open the files with hits in your editor.
+
+ * "git help -w" learned "chrome" and "chromium" browsers.
+
+ * "git log --decorate" shows commit decorations in various colours.
+
+ * "git log --follow <path>" follows across copies (it used to only follow
+   renames).  This may make the processing more expensive.
+
+ * "git log --pretty=format:<template>" specifier learned "% <something>"
+   magic that inserts a space only when %<something> expands to a
+   non-empty string; this is similar to "%+<something>" magic, but is
+   useful in a context to generate a single line output.
+
+ * "git notes prune" learned "-n" (dry-run) and "-v" options, similar to
+   what "git prune" has.
+
+ * "git patch-id" can be fed a mbox without getting confused by the
+   signature line in the format-patch output.
+
+ * "git remote" learned "set-branches" subcommand.
+
+ * "git rev-list A..B" learned --ancestry-path option to further limit
+   the result to the commits that are on the ancestry chain between A and
+   B (i.e. commits that are not descendants of A are excluded).
+
+ * "git show -5" is equivalent to "git show --do-walk 5"; this is similar
+   to the update to make "git show master..next" walk the history,
+   introduced in 1.6.4.
+
+ * "git status [-s] --ignored" can be used to list ignored paths.
+
+ * "git status -s -b" shows the current branch in the output.
+
+ * "git status" learned "--ignore-submodules" option.
+
+ * Various "gitweb" enhancements and clean-ups, including syntax
+   highlighting, "plackup" support for instaweb, .fcgi suffix to run
+   it as FastCGI script, etc.
+
+ * The test harness has been updated to produce TAP-friendly output.
 
 
 Fixes since v1.7.1
 ------------------
 
- * In 1.7.1, "git status" stopped refreshing the index by mistake.
-
 All of the fixes in v1.7.1.X maintenance series are included in this
 release, unless otherwise noted.
 
+ * We didn't URL decode "file:///path/to/repo" correctly when path/to/repo
+   had percent-encoded characters (638794c, 9d2e942, ce83eda, 3c73a1d).
+
+ * "git clone" did not configure remote.origin.url correctly for bare
+   clones (df61c889).
+
+ * "git diff --graph" works better with "--color-words" and other options
+   (81fa024..4297c0a).
+
+ * "git diff" could show ambiguous abbreviation of blob object names on
+   its "index" line (3e5a188).
+
+ * "git reset --hard" started from a wrong directory and a working tree in
+   a nonstandard location is in use got confused (560fb6a1).
+
+ * "git read-tree -m A B" used to switch to branch B while retaining
+   local changes added an incorrect cache-tree information (b1f47514).
+
 --
 exec >/var/tmp/1
-O=v1.7.1-77-gb751157
-echo O=$(git describe master)
-git shortlog --no-merges master ^maint ^$O
+O=v1.7.2-rc2-17-gc9a9766
+echo O=$(git describe HEAD)
+git shortlog --no-merges HEAD ^maint ^$O
index 85f763c4d0dc6656a45fa876b453d2cb34a72cb3..e75434b3ef2d81fa8dafd552d4b689eb84eea441 100644 (file)
@@ -196,20 +196,17 @@ core.quotepath::
        quoted without `-z` regardless of the setting of this
        variable.
 
-core.autocrlf::
-       If true, makes git convert `CRLF` at the end of lines in text files to
-       `LF` when reading from the work tree, and convert in reverse when
-       writing to the work tree.  The variable can be set to
-       'input', in which case the conversion happens only while
-       reading from the work tree but files are written out to the work
-       tree with `LF` at the end of lines.  A file is considered
-       "text" (i.e. be subjected to the autocrlf mechanism) based on
-       the file's `crlf` attribute, or if `crlf` is unspecified,
-       based on the file's contents.  See linkgit:gitattributes[5].
+core.eol::
+       Sets the line ending type to use in the working directory for
+       files that have the `text` property set.  Alternatives are
+       'lf', 'crlf' and 'native', which uses the platform's native
+       line ending.  The default value is `native`.  See
+       linkgit:gitattributes[5] for more information on end-of-line
+       conversion.
 
 core.safecrlf::
-       If true, makes git check if converting `CRLF` as controlled by
-       `core.autocrlf` is reversible.  Git will verify if a command
+       If true, makes git check if converting `CRLF` is reversible when
+       end-of-line conversion is active.  Git will verify if a command
        modifies a file in the work tree either directly or indirectly.
        For example, committing a file followed by checking out the
        same file should yield the original file in the work tree.  If
@@ -219,7 +216,7 @@ core.safecrlf::
        irreversible conversion but continue the operation.
 +
 CRLF conversion bears a slight chance of corrupting data.
-autocrlf=true will convert CRLF to LF during commit and LF to
+When it is enabled, git will convert CRLF to LF during commit and LF to
 CRLF during checkout.  A file that contains a mixture of LF and
 CRLF before the commit cannot be recreated by git.  For text
 files this is the right thing to do: it corrects line endings
@@ -243,15 +240,25 @@ converting CRLFs corrupts data.
 +
 Note, this safety check does not mean that a checkout will generate a
 file identical to the original file for a different setting of
-`core.autocrlf`, but only for the current one.  For example, a text
-file with `LF` would be accepted with `core.autocrlf=input` and could
-later be checked out with `core.autocrlf=true`, in which case the
+`core.eol` and `core.autocrlf`, but only for the current one.  For
+example, a text file with `LF` would be accepted with `core.eol=lf`
+and could later be checked out with `core.eol=crlf`, in which case the
 resulting file would contain `CRLF`, although the original file
 contained `LF`.  However, in both work trees the line endings would be
 consistent, that is either all `LF` or all `CRLF`, but never mixed.  A
 file with mixed line endings would be reported by the `core.safecrlf`
 mechanism.
 
+core.autocrlf::
+       Setting this variable to "true" is almost the same as setting
+       the `text` attribute to "auto" on all files except that text
+       files are not guaranteed to be normalized: files that contain
+       `CRLF` in the repository will not be touched.  Use this
+       setting if you want to have `CRLF` line endings in your
+       working directory even though the repository does not have
+       normalized line endings.  This variable can be set to 'input',
+       in which case no output conversion is performed.
+
 core.symlinks::
        If false, symbolic links are checked out as small plain files that
        contain the link text. linkgit:git-update-index[1] and
@@ -520,18 +527,12 @@ check that makes sure that existing object files will not get overwritten.
 
 core.notesRef::
        When showing commit messages, also show notes which are stored in
-       the given ref.  This ref is expected to contain files named
-       after the full SHA-1 of the commit they annotate.  The ref
-       must be fully qualified.
+       the given ref.  The ref must be fully qualified.  If the given
+       ref does not exist, it is not an error but means that no
+       notes should be printed.
 +
-If such a file exists in the given ref, the referenced blob is read, and
-appended to the commit message, separated by a "Notes (<refname>):"
-line (shortened to "Notes:" in the case of "refs/notes/commits").  If the
-given ref itself does not exist, it is not an error, but means that no
-notes should be printed.
-+
-This setting defaults to "refs/notes/commits", and can be overridden by
-the `GIT_NOTES_REF` environment variable.
+This setting defaults to "refs/notes/commits", and it can be overridden by
+the 'GIT_NOTES_REF' environment variable.  See linkgit:git-notes[1].
 
 core.sparseCheckout::
        Enable "sparse checkout" feature. See section "Sparse checkout" in
@@ -689,6 +690,11 @@ color.diff.<slot>::
        (highlighting whitespace errors). The values of these variables may be
        specified as in color.branch.<slot>.
 
+color.decorate.<slot>::
+       Use customized color for 'git log --decorate' output.  `<slot>` is one
+       of `branch`, `remoteBranch`, `tag`, `stash` or `HEAD` for local
+       branches, remote tracking branches, tags, stash and HEAD, respectively.
+
 color.grep::
        When set to `always`, always highlight matches.  When `false` (or
        `never`), never.  When set to `true` or `auto`, use color only
@@ -798,6 +804,8 @@ diff.mnemonicprefix::
        standard "a/" and "b/" depending on what is being compared.  When
        this configuration is in effect, reverse diff output also swaps
        the order of the prefixes:
+diff.noprefix::
+       If set, 'git diff' does not show any source or destination prefix.
 `git diff`;;
        compares the (i)ndex and the (w)ork tree;
 `git diff HEAD`;;
@@ -878,14 +886,22 @@ format.headers::
        Additional email headers to include in a patch to be submitted
        by mail.  See linkgit:git-format-patch[1].
 
+format.to::
 format.cc::
-       Additional "Cc:" headers to include in a patch to be submitted
-       by mail.  See the --cc option in linkgit:git-format-patch[1].
+       Additional recipients to include in a patch to be submitted
+       by mail.  See the --to and --cc options in
+       linkgit:git-format-patch[1].
 
 format.subjectprefix::
        The default for format-patch is to output files with the '[PATCH]'
        subject prefix. Use this variable to change that prefix.
 
+format.signature::
+       The default for format-patch is to output a signature containing
+       the git version number. Use this variable to change that default.
+       Set this variable to the empty string ("") to suppress
+       signature generation.
+
 format.suffix::
        The default for format-patch is to output files with the suffix
        `.patch`. Use this variable to change that suffix (make sure to
@@ -983,13 +999,15 @@ gitcvs.logfile::
        various stuff. See linkgit:git-cvsserver[1].
 
 gitcvs.usecrlfattr::
-       If true, the server will look up the `crlf` attribute for
-       files to determine the '-k' modes to use. If `crlf` is set,
-       the '-k' mode will be left blank, so cvs clients will
-       treat it as text. If `crlf` is explicitly unset, the file
+       If true, the server will look up the end-of-line conversion
+       attributes for files to determine the '-k' modes to use. If
+       the attributes force git to treat a file as text,
+       the '-k' mode will be left blank so cvs clients will
+       treat it as text. If they suppress text conversion, the file
        will be set with '-kb' mode, which suppresses any newline munging
-       the client might otherwise do. If `crlf` is not specified,
-       then 'gitcvs.allbinary' is used. See linkgit:gitattributes[5].
+       the client might otherwise do. If the attributes do not allow
+       the file type to be determined, then 'gitcvs.allbinary' is
+       used. See linkgit:gitattributes[5].
 
 gitcvs.allbinary::
        This is used if 'gitcvs.usecrlfattr' does not resolve
@@ -1481,6 +1499,16 @@ pager.<cmd>::
        it takes precedence over this option.  To disable pagination for
        all commands, set `core.pager` or `GIT_PAGER` to `cat`.
 
+pretty.<name>::
+       Alias for a --pretty= format string, as specified in
+       linkgit:git-log[1]. Any aliases defined here can be used just
+       as the built-in pretty formats could. For example,
+       running `git config pretty.changelog "format:{asterisk} %H %s"`
+       would cause the invocation `git log --pretty=changelog`
+       to be equivalent to running `git log "--pretty=format:{asterisk} %H %s"`.
+       Note that an alias with the same name as a built-in format
+       will be silently ignored.
+
 pull.octopus::
        The default merge strategy to use when pulling multiple branches
        at once.
@@ -1706,6 +1734,15 @@ status.submodulesummary::
        summary of commits for modified submodules will be shown (see
        --summary-limit option of linkgit:git-submodule[1]).
 
+submodule.<name>.path::
+submodule.<name>.url::
+submodule.<name>.update::
+       The path within this project, URL, and the updating strategy
+       for a submodule.  These variables are initially populated
+       by 'git submodule init'; edit them to override the
+       URL and other values found in the `.gitmodules` file.  See
+       linkgit:git-submodule[1] and linkgit:gitmodules[5] for details.
+
 tar.umask::
        This variable can be used to restrict the permission bits of
        tar archive entries.  The default is 0002, which turns off the
index 0d89aaaf2aac365f78823c05b57b02ecffa95928..2371262b10aad44391406e126a1a8027b543fd49 100644 (file)
@@ -210,7 +210,14 @@ endif::git-format-patch[]
        Break complete rewrite changes into pairs of delete and create.
 
 -M::
+ifndef::git-log[]
        Detect renames.
+endif::git-log[]
+ifdef::git-log[]
+       If generating diffs, detect and report renames for each commit.
+       For following files across renames while traversing history, see
+       `--follow`.
+endif::git-log[]
 
 -C::
        Detect copies as well as renames.  See also `--find-copies-harder`.
@@ -321,8 +328,14 @@ endif::git-format-patch[]
 --no-ext-diff::
        Disallow external diff drivers.
 
---ignore-submodules::
-       Ignore changes to submodules in the diff generation.
+--ignore-submodules[=<when>]::
+       Ignore changes to submodules in the diff generation. <when> can be
+       either "untracked", "dirty" or "all", which is the default. When
+       "untracked" is used submodules are not considered dirty when they only
+       contain untracked content (but they are still scanned for modified
+       content). Using "dirty" ignores all changes to the work tree of submodules,
+       only changes to the commits stored in the superproject are shown (this was
+       the behavior until 1.7.0). Using "all" hides all changes to submodules.
 
 --src-prefix=<prefix>::
        Show the given source prefix instead of "a/".
index 044ec882ccf9f8437862a5e59a3caee7030c36ae..9333c42c558464ce2430df39e9864f932e786b36 100644 (file)
@@ -34,6 +34,7 @@ ifndef::git-pull[]
        Allow several <repository> and <group> arguments to be
        specified. No <refspec>s may be specified.
 
+-p::
 --prune::
        After fetching, remove any remote tracking branches which
        no longer exist on the remote.
index 51cbeb7032865599317fd9d7d36a9c9e2f8cc0c5..74741a42f409a7af5c60584a0d3b7a0be851811c 100644 (file)
@@ -266,9 +266,9 @@ patch::
 
        y - stage this hunk
        n - do not stage this hunk
-       q - quit, do not stage this hunk nor any of the remaining ones
-       a - stage this and all the remaining hunks in the file
-       d - do not stage this hunk nor any of the remaining hunks in the file
+       q - quit; do not stage this hunk nor any of the remaining ones
+       a - stage this hunk and all later hunks in the file
+       d - do not stage this hunk nor any of the later hunks in the file
        g - select a hunk to go to
        / - search for a hunk matching the given regex
        j - leave this hunk undecided, see next undecided hunk
index 58c8d65772af4ef20ad573af9dd28691f5357437..a3f56b07fd251cbd121c28189d1f9018b892b48e 100644 (file)
@@ -9,14 +9,15 @@ git-cat-file - Provide content or type and size information for repository objec
 SYNOPSIS
 --------
 [verse]
-'git cat-file' (-t | -s | -e | -p | <type>) <object>
+'git cat-file' (-t | -s | -e | -p | <type> | --textconv ) <object>
 'git cat-file' (--batch | --batch-check) < <list-of-objects>
 
 DESCRIPTION
 -----------
 In its first form, the command provides the content or the type of an object in
 the repository. The type is required unless '-t' or '-p' is used to find the
-object type, or '-s' is used to find the object size.
+object type, or '-s' is used to find the object size, or '--textconv' is used
+(which implies type "blob").
 
 In the second form, a list of objects (separated by linefeeds) is provided on
 stdin, and the SHA1, type, and size of each object is printed on stdout.
@@ -26,7 +27,7 @@ OPTIONS
 <object>::
        The name of the object to show.
        For a more complete list of ways to spell object names, see
-       the "SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
+       the "SPECIFYING REVISIONS" section in linkgit:gitrevisions[1].
 
 -t::
        Instead of the content, show the object type identified by
@@ -51,6 +52,11 @@ OPTIONS
        or to ask for a "blob" with <object> being a tag object that
        points at it.
 
+--textconv::
+       Show the content as transformed by a textconv filter. In this case,
+       <object> has be of the form <treeish>:<path>, or :<path> in order
+       to apply the filter to the content recorded in the index at <path>.
+
 --batch::
        Print the SHA1, type, size, and contents of each object provided on
        stdin. May not be combined with any other options or arguments.
index 379eee6734323ee566480d5f9159dd28ed27ecd2..f5c2e0601db6782b2a8690c687611b93da935024 100644 (file)
@@ -49,7 +49,7 @@ git imposes the following rules on how references are named:
 These rules make it easy for shell script based tools to parse
 reference names, pathname expansion by the shell when a reference name is used
 unquoted (by mistake), and also avoids ambiguities in certain
-reference name expressions (see linkgit:git-rev-parse[1]):
+reference name expressions (see linkgit:gitrevisions[1]):
 
 . A double-dot `..` is often used as in `ref1..ref2`, and in some
   contexts this notation means `{caret}ref1 ref2` (i.e. not in
index afda5c36b5ac0061d94d706cd7a07ef8197b6b31..1bacd2e1044f5b3b7d5a60e1687387cc277fc52a 100644 (file)
@@ -15,33 +15,41 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-
-When <paths> are not given, this command switches branches by
-updating the index, working tree, and HEAD to reflect the specified
+Updates files in the working tree to match the version in the index
+or the specified tree.  If no paths are given, 'git checkout' will
+also update `HEAD` to set the specified branch as the current
 branch.
 
-If `-b` is given, a new branch is created and checked out, as if
-linkgit:git-branch[1] were called; in this case you can
-use the --track or --no-track options, which will be passed to `git
-branch`.  As a convenience, --track without `-b` implies branch
-creation; see the description of --track below.
-
-When <paths> or --patch are given, this command does *not* switch
-branches.  It updates the named paths in the working tree from
-the index file, or from a named <tree-ish> (most often a commit).  In
-this case, the `-b` and `--track` options are meaningless and giving
-either of them results in an error. The <tree-ish> argument can be
-used to specify a specific tree-ish (i.e. commit, tag or tree)
-to update the index for the given paths before updating the
-working tree.
-
-The index may contain unmerged entries after a failed merge.  By
-default, if you try to check out such an entry from the index, the
+'git checkout' [<branch>]::
+'git checkout' -b <new branch> [<start point>]::
+
+       This form switches branches by updating the index, working
+       tree, and HEAD to reflect the specified branch.
++
+If `-b` is given, a new branch is created as if linkgit:git-branch[1]
+were called and then checked out; in this case you can
+use the `--track` or `--no-track` options, which will be passed to
+'git branch'.  As a convenience, `--track` without `-b` implies branch
+creation; see the description of `--track` below.
+
+'git checkout' [--patch] [<tree-ish>] [--] <pathspec>...::
+
+       When <paths> or `--patch` are given, 'git checkout' *not* switch
+       branches.  It updates the named paths in the working tree from
+       the index file or from a named <tree-ish> (most often a commit).  In
+       this case, the `-b` and `--track` options are meaningless and giving
+       either of them results in an error. The <tree-ish> argument can be
+       used to specify a specific tree-ish (i.e. commit, tag or tree)
+       to update the index for the given paths before updating the
+       working tree.
++
+The index may contain unmerged entries because of a previous failed merge.
+By default, if you try to check out such an entry from the index, the
 checkout operation will fail and nothing will be checked out.
-Using -f will ignore these unmerged entries.  The contents from a
+Using `-f` will ignore these unmerged entries.  The contents from a
 specific side of the merge can be checked out of the index by
-using --ours or --theirs.  With -m, changes made to the working tree
-file can be discarded to recreate the original conflicted merge result.
+using `--ours` or `--theirs`.  With `-m`, changes made to the working tree
+file can be discarded to re-create the original conflicted merge result.
 
 OPTIONS
 -------
@@ -91,22 +99,29 @@ explicitly give a name with '-b' in such a case.
        details.
 
 --orphan::
-       Create a new branch named <new_branch>, unparented to any other
-       branch.  The new branch you switch to does not have any commit
-       and after the first one it will become the root of a new history
-       completely unconnected from all the other branches.
+       Create a new 'orphan' branch, named <new_branch>, started from
+       <start_point> and switch to it.  The first commit made on this
+       new branch will have no parents and it will be the root of a new
+       history totally disconnected from all the other branches and
+       commits.
++
+The index and the working tree are adjusted as if you had previously run
+"git checkout <start_point>".  This allows you to start a new history
+that records a set of paths similar to <start_point> by easily running
+"git commit -a" to make the root commit.
 +
-When you use "--orphan", the index and the working tree are kept intact.
-This allows you to start a new history that records set of paths similar
-to that of the start-point commit, which is useful when you want to keep
-different branches for different audiences you are working to like when
-you have an open source and commercial versions of a software, for example.
+This can be useful when you want to publish the tree from a commit
+without exposing its full history. You might want to do this to publish
+an open source branch of a project whose current tree is "clean", but
+whose full history contains proprietary or otherwise encumbered bits of
+code.
 +
-If you want to start a disconnected history that records set of paths
-totally different from the original branch, you may want to first clear
-the index and the working tree, by running "git rm -rf ." from the
-top-level of the working tree, before preparing your files (by copying
-from elsewhere, extracting a tarball, etc.) in the working tree.
+If you want to start a disconnected history that records a set of paths
+that is totally different from the one of <start_point>, then you should
+clear the index and the working tree right after creating the orphan
+branch by running "git rm -rf ." from the top level of the working tree.
+Afterwards you will be ready to prepare your new files, repopulating the
+working tree, by copying them from elsewhere, extracting a tarball, etc.
 
 -m::
 --merge::
@@ -248,7 +263,7 @@ the above checkout would fail like this:
 +
 ------------
 $ git checkout mytopic
-fatal: Entry 'frotz' not uptodate. Cannot merge.
+error: You have local changes to 'frotz'; not switching branches.
 ------------
 +
 You can give the `-m` flag to the command, which would try a
index d71607a85d03062c76f7d17d4fd8e8b4168a279d..2cef579316ba11e68d65dc4d7309f2e56a465b3d 100644 (file)
@@ -3,24 +3,28 @@ git-cherry-pick(1)
 
 NAME
 ----
-git-cherry-pick - Apply the change introduced by an existing commit
+git-cherry-pick - Apply the changes introduced by some existing commits
 
 SYNOPSIS
 --------
-'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>
+'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...
 
 DESCRIPTION
 -----------
-Given one existing commit, apply the change the patch introduces, and record a
-new commit that records it.  This requires your working tree to be clean (no
-modifications from the HEAD commit).
+
+Given one or more existing commits, apply the change each one
+introduces, recording a new commit for each.  This requires your
+working tree to be clean (no modifications from the HEAD commit).
 
 OPTIONS
 -------
-<commit>::
-       Commit to cherry-pick.
-       For a more complete list of ways to spell commits, see the
-       "SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
+<commit>...::
+       Commits to cherry-pick.
+       For a more complete list of ways to spell commits, see
+       linkgit:gitrevisions[1].
+       Sets of commits can be passed but no traversal is done by
+       default, as if the '--no-walk' option was specified, see
+       linkgit:git-rev-list[1].
 
 -e::
 --edit::
@@ -55,10 +59,10 @@ OPTIONS
 
 -n::
 --no-commit::
-       Usually the command automatically creates a commit.
-       This flag applies the change necessary to cherry-pick
-       the named commit to your working tree and the index,
-       but does not make the commit.  In addition, when this
+       Usually the command automatically creates a sequence of commits.
+       This flag applies the changes necessary to cherry-pick
+       each named commit to your working tree and the index,
+       without making any commit.  In addition, when this
        option is used, your index does not have to match the
        HEAD commit.  The cherry-pick is done against the
        beginning state of your index.
@@ -75,6 +79,47 @@ effect to your index in a row.
        cherry-pick'ed commit, then a fast forward to this commit will
        be performed.
 
+EXAMPLES
+--------
+git cherry-pick master::
+
+       Apply the change introduced by the commit at the tip of the
+       master branch and create a new commit with this change.
+
+git cherry-pick ..master::
+git cherry-pick ^HEAD master::
+
+       Apply the changes introduced by all commits that are ancestors
+       of master but not of HEAD to produce new commits.
+
+git cherry-pick master\~4 master~2::
+
+       Apply the changes introduced by the fifth and third last
+       commits pointed to by master and create 2 new commits with
+       these changes.
+
+git cherry-pick -n master~1 next::
+
+       Apply to the working tree and the index the changes introduced
+       by the second last commit pointed to by master and by the last
+       commit pointed to by next, but do not create any commit with
+       these changes.
+
+git cherry-pick --ff ..next::
+
+       If history is linear and HEAD is an ancestor of next, update
+       the working tree and advance the HEAD pointer to match next.
+       Otherwise, apply the changes introduced by those commits that
+       are in next but not HEAD to the current branch, creating a new
+       commit for each new change.
+
+git rev-list --reverse master \-- README | git cherry-pick -n --stdin::
+
+       Apply the changes introduced by all commits on the master
+       branch that touched README to the working tree and index,
+       so the result can be inspected and made into a single new
+       commit if suitable.
+
 Author
 ------
 Written by Junio C Hamano <gitster@pobox.com>
@@ -83,6 +128,10 @@ Documentation
 --------------
 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 
+SEE ALSO
+--------
+linkgit:git-revert[1]
+
 GIT
 ---
 Part of the linkgit:git[1] suite
index 32c482f33ff331dbae9c8072a7050d10d875454a..c28603ecf58bd065cc8f7c3c4436f1c0f82a7d2e 100644 (file)
@@ -95,10 +95,11 @@ OPTIONS
        read the message from the standard input.
 
 --author=<author>::
-       Override the author name used in the commit.  You can use the
-       standard `A U Thor <author@example.com>` format.  Otherwise,
-       an existing commit that matches the given string and its author
-       name is used.
+       Override the commit author. Specify an explicit author using the
+       standard `A U Thor <author@example.com>` format. Otherwise <author>
+       is assumed to be a pattern and is used to search for an existing
+       commit by that author (i.e. rev-list --all -i --author=<author>);
+       the commit author is then copied from the first such commit found.
 
 --date=<date>::
        Override the author date used in the commit.
index dbb053ee17fbc9e254aac42bf87d204655e00614..7004dd2decfb2a9cf82b248aae1f848beaf885cb 100644 (file)
@@ -72,9 +72,6 @@ plugin. Most functionality works fine with both of these clients.
 LIMITATIONS
 -----------
 
-Currently cvsserver works over SSH connections for read/write clients, and
-over pserver for anonymous CVS access.
-
 CVS clients cannot tag, branch or perform GIT merges.
 
 'git-cvsserver' maps GIT branches to CVS modules. This is very different
@@ -84,7 +81,7 @@ one or more directories.
 INSTALLATION
 ------------
 
-1. If you are going to offer anonymous CVS access via pserver, add a line in
+1. If you are going to offer CVS access via pserver, add a line in
    /etc/inetd.conf like
 +
 --
@@ -101,6 +98,38 @@ looks like
    cvspserver stream tcp nowait nobody /usr/bin/git-cvsserver git-cvsserver pserver
 
 ------
+
+Only anonymous access is provided by pserve by default. To commit you
+will have to create pserver accounts, simply add a gitcvs.authdb
+setting in the config file of the repositories you want the cvsserver
+to allow writes to, for example:
+
+------
+
+   [gitcvs]
+       authdb = /etc/cvsserver/passwd
+
+------
+The format of these files is username followed by the crypted password,
+for example:
+
+------
+   myuser:$1Oyx5r9mdGZ2
+   myuser:$1$BA)@$vbnMJMDym7tA32AamXrm./
+------
+You can use the 'htpasswd' facility that comes with Apache to make these
+files, but Apache's MD5 crypt method differs from the one used by most C
+library's crypt() function, so don't use the -m option.
+
+Alternatively you can produce the password with perl's crypt() operator:
+-----
+   perl -e 'my ($user, $pass) = @ARGV; printf "%s:%s\n", $user, crypt($user, $pass)' $USER password
+-----
+
+Then provide your password via the pserver method, for example:
+------
+   cvs -d:pserver:someuser:somepassword <at> server/path/repo.git co <HEAD_name>
+------
 No special setup is needed for SSH access, other than having GIT tools
 in the PATH. If you have clients that do not accept the CVS_SERVER
 environment variable, you can rename 'git-cvsserver' to `cvs`.
@@ -340,16 +369,13 @@ By default the server leaves the '-k' mode blank for all files,
 which causes the cvs client to treat them as a text files, subject
 to crlf conversion on some platforms.
 
-You can make the server use `crlf` attributes to set the '-k' modes
-for files by setting the `gitcvs.usecrlfattr` config variable.
-In this case, if `crlf` is explicitly unset ('-crlf'), then the
-server will set '-kb' mode for binary files. If `crlf` is set,
-then the '-k' mode will explicitly be left blank.  See
-also linkgit:gitattributes[5] for more information about the `crlf`
-attribute.
+You can make the server use the end-of-line conversion attributes to
+set the '-k' modes for files by setting the `gitcvs.usecrlfattr`
+config variable.  See linkgit:gitattributes[5] for more information
+about end-of-line conversion.
 
 Alternatively, if `gitcvs.usecrlfattr` config is not enabled
-or if the `crlf` attribute is unspecified for a filename, then
+or the attributes do not allow automatic detection for a filename, then
 the server uses the `gitcvs.allbinary` config for the default setting.
 If `gitcvs.allbinary` is set, then file not otherwise
 specified will default to '-kb' mode. Otherwise the '-k' mode
index 723a64872fd4b43612d576781d915a7538189f46..08fd4099addac3959e5aedbd1a0668367f07bb21 100644 (file)
@@ -68,11 +68,11 @@ for the last two forms that use ".." notations, can be any
 <tree-ish>.
 
 For a more complete list of ways to spell <commit>, see
-"SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
+"SPECIFYING REVISIONS" section in linkgit:gitrevisions[1].
 However, "diff" is about comparing two _endpoints_, not ranges,
 and the range notations ("<commit>..<commit>" and
 "<commit>\...<commit>") do not mean a range as defined in the
-"SPECIFYING RANGES" section in linkgit:git-rev-parse[1].
+"SPECIFYING RANGES" section in linkgit:gitrevisions[1].
 
 OPTIONS
 -------
index 19082b04eb7ec77bcf974e0c76b8d20bb736c021..77a0a2481a34f987aab4688002a6e6a0ae2e497f 100644 (file)
@@ -439,7 +439,7 @@ Marks must be declared (via `mark`) before they can be used.
 * A complete 40 byte or abbreviated commit SHA-1 in hex.
 
 * Any valid Git SHA-1 expression that resolves to a commit.  See
-  ``SPECIFYING REVISIONS'' in linkgit:git-rev-parse[1] for details.
+  ``SPECIFYING REVISIONS'' in linkgit:gitrevisions[1] for details.
 
 The special case of restarting an incremental import from the
 current branch value should be written as:
index 835fb7135b9d159281ef8eb81daf699c6aeec57b..4b3f5ba5358da469feff4e861e69717f16e81d21 100644 (file)
@@ -13,6 +13,7 @@ SYNOPSIS
                   [--no-thread | --thread[=<style>]]
                   [(--attach|--inline)[=<boundary>] | --no-attach]
                   [-s | --signoff]
+                  [--signature=<signature> | --no-signature]
                   [-n | --numbered | -N | --no-numbered]
                   [--start-number <n>] [--numbered-files]
                   [--in-reply-to=Message-Id] [--suffix=.<sfx>]
@@ -38,7 +39,7 @@ There are two ways to specify which commits to operate on.
    that leads to the <since> to be output.
 
 2. Generic <revision range> expression (see "SPECIFYING
-   REVISIONS" section in linkgit:git-rev-parse[1]) means the
+   REVISIONS" section in linkgit:gitrevisions[1]) means the
    commits in the specified range.
 
 The first rule takes precedence in the case of a single <commit>.  To
@@ -180,6 +181,12 @@ will want to ensure that threading is disabled for `git send-email`.
        containing the shortlog and the overall diffstat.  You can
        fill in a description in the file before sending it out.
 
+--[no]-signature=<signature>::
+       Add a signature to each message produced. Per RFC 3676 the signature
+       is separated from the body by a line with '-- ' on it. If the
+       signature option is omitted the signature defaults to the git version
+       number.
+
 --suffix=.<sfx>::
        Instead of using `.patch` as the suffix for generated
        filenames, use specified suffix.  A common alternative is
index a9e0882e9b81fe15780785dc85e3fb2782480ae1..315f07ef1c6997c98c4e446af507c3e1e4566218 100644 (file)
@@ -137,6 +137,13 @@ If you are expecting some objects to be collected and they aren't, check
 all of those locations and decide whether it makes sense in your case to
 remove those references.
 
+HOOKS
+-----
+
+The 'git gc --auto' command will run the 'pre-auto-gc' hook.  See
+linkgit:githooks[5] for more information.
+
+
 SEE ALSO
 --------
 linkgit:git-prune[1]
index d89ec324855841ebe2c76482f3c34350343523a3..5474dd7f94c4b3217230808e656662d0edcef207 100644 (file)
@@ -191,7 +191,7 @@ OPTIONS
 Examples
 --------
 
-git grep 'time_t' -- '*.[ch]'::
+git grep 'time_t' \-- '*.[ch]'::
        Looks for `time_t` in all tracked .c and .h files in the working
        directory and its subdirectories.
 
index a1f17df0744361ab999314b1834c2e2384af90bd..2c3c4d299472a265bfc4486816933ca3dc69b44f 100644 (file)
@@ -29,7 +29,7 @@ OPTIONS
        The HTTP daemon command-line that will be executed.
        Command-line options may be specified here, and the
        configuration file will be added at the end of the command-line.
-       Currently apache2, lighttpd, mongoose and webrick are supported.
+       Currently apache2, lighttpd, mongoose, plackup and webrick are supported.
        (Default: lighttpd)
 
 -m::
index a2d55f974525c59f3dd51684531861bf0dc49a23..8a69647f5c36979daea537f20cab6f02875ff619 100644 (file)
@@ -34,8 +34,7 @@ include::diff-options.txt[]
        either <since> or <until> is omitted, it defaults to
        `HEAD`, i.e. the tip of the current branch.
        For a more complete list of ways to spell <since>
-       and <until>, see "SPECIFYING REVISIONS" section in
-       linkgit:git-rev-parse[1].
+       and <until>, see linkgit:gitrevisions[1].
 
 --no-decorate::
 --decorate[=short|full|no]::
@@ -133,6 +132,48 @@ Discussion
 
 include::i18n.txt[]
 
+Configuration
+-------------
+
+See linkgit:git-config[1] for core variables and linkgit:git-diff[1]
+for settings related to diff generation.
+
+format.pretty::
+       Default for the `--format` option.  (See "PRETTY FORMATS" above.)
+       Defaults to "medium".
+
+i18n.logOutputEncoding::
+       Encoding to use when displaying logs.  (See "Discussion", above.)
+       Defaults to the value of `i18n.commitEncoding` if set, UTF-8
+       otherwise.
+
+log.date::
+       Default format for human-readable dates.  (Compare the
+       `--date` option.)  Defaults to "default", which means to write
+       dates like `Sat May 8 19:35:34 2010 -0500`.
+
+log.showroot::
+       If `false`, 'git log' and related commands will not treat the
+       initial commit as a big creation event.  Any root commits in
+       `git log -p` output would be shown without a diff attached.
+       The default is `true`.
+
+mailmap.file::
+       See linkgit:git-shortlog[1].
+
+notes.displayRef::
+       Which refs, in addition to the default set by `core.notesRef`
+       or 'GIT_NOTES_REF', to read notes from when showing commit
+       messages with the 'log' family of commands.  See
+       linkgit:git-notes[1].
++
+May be an unabbreviated ref name or a glob and may be specified
+multiple times.  A warning will be issued for refs that do not exist,
+but a glob that does not match any refs is silently ignored.
++
+This setting can be disabled by the `--no-standard-notes` option,
+overridden by the 'GIT_NOTES_DISPLAY_REF' environment variable,
+and supplemented by the `--show-notes` option.
 
 Author
 ------
index e3d58cbac3f162cc01d8731485f220fd70fed17b..3ea5aad56c5e1cec7fc2ca01ba9b5ea6badebe2f 100644 (file)
@@ -40,16 +40,16 @@ OPTIONS
 -u::
        The commit log message, author name and author email are
        taken from the e-mail, and after minimally decoding MIME
-       transfer encoding, re-coded in UTF-8 by transliterating
+       transfer encoding, re-coded in the charset specified by
+       i18n.commitencoding (defaulting to UTF-8) by transliterating
        them.  This used to be optional but now it is the default.
 +
 Note that the patch is always used as-is without charset
 conversion, even with this flag.
 
 --encoding=<encoding>::
-       Similar to -u but if the local convention is different
-       from what is specified by i18n.commitencoding, this flag
-       can be used to override it.
+       Similar to -u.  But when re-coding, the charset specified here is
+       used instead of the one specified by i18n.commitencoding or UTF-8.
 
 -n::
        Disable all charset re-coding of the metadata.
index c2325ef90e336a37df42eb7f71f95e3581c83127..84043cc5b26db7d34c93a70ec005df913c345d85 100644 (file)
@@ -58,7 +58,12 @@ include::merge-options.txt[]
 
 -m <msg>::
        Set the commit message to be used for the merge commit (in
-       case one is created). The 'git fmt-merge-msg' command can be
+       case one is created).
+
+       If `--log` is specified, a shortlog of the commits being merged
+       will be appended to the specified message.
+
+       The 'git fmt-merge-msg' command can be
        used to give a good default for automated 'git merge'
        invocations.
 
index 4e5113b837230c8f050cf4bbe10e8de4b3271bd0..5540af5d1667aad16ac11c53593921733c4af56f 100644 (file)
@@ -3,7 +3,7 @@ git-notes(1)
 
 NAME
 ----
-git-notes - Add/inspect object notes
+git-notes - Add or inspect object notes
 
 SYNOPSIS
 --------
@@ -15,29 +15,31 @@ SYNOPSIS
 'git notes' edit [<object>]
 'git notes' show [<object>]
 'git notes' remove [<object>]
-'git notes' prune
+'git notes' prune [-n | -v]
 
 
 DESCRIPTION
 -----------
-This command allows you to add/remove notes to/from objects, without
-changing the objects themselves.
+Adds, removes, or reads notes attached to objects, without touching
+the objects themselves.
 
-A typical use of notes is to extend a commit message without having
-to change the commit itself. Such commit notes can be shown by `git log`
-along with the original commit message. To discern these notes from the
+By default, notes are saved to and read from `refs/notes/commits`, but
+this default can be overridden.  See the OPTIONS, CONFIGURATION, and
+ENVIRONMENT sections below.  If this ref does not exist, it will be
+quietly created when it is first needed to store a note.
+
+A typical use of notes is to supplement a commit message without
+changing the commit itself. Notes can be shown by 'git log' along with
+the original commit message. To distinguish these notes from the
 message stored in the commit object, the notes are indented like the
 message, after an unindented line saying "Notes (<refname>):" (or
-"Notes:" for the default setting).
+"Notes:" for `refs/notes/commits`).
 
-This command always manipulates the notes specified in "core.notesRef"
-(see linkgit:git-config[1]), which can be overridden by GIT_NOTES_REF.
-To change which notes are shown by 'git-log', see the
-"notes.displayRef" configuration.
+To change which notes are shown by 'git log', see the
+"notes.displayRef" configuration in linkgit:git-log[1].
 
-See the description of "notes.rewrite.<command>" in
-linkgit:git-config[1] for a way of carrying your notes across commands
-that rewrite commits.
+See the "notes.rewrite.<command>" configuration for a way to carry
+notes across commands that rewrite commits.
 
 
 SUBCOMMANDS
@@ -101,15 +103,20 @@ OPTIONS
        Use the given note message (instead of prompting).
        If multiple `-m` options are given, their values
        are concatenated as separate paragraphs.
+       Lines starting with `#` and empty lines other than a
+       single line between paragraphs will be stripped out.
 
 -F <file>::
 --file=<file>::
        Take the note message from the given file.  Use '-' to
        read the note message from the standard input.
+       Lines starting with `#` and empty lines other than a
+       single line between paragraphs will be stripped out.
 
 -C <object>::
 --reuse-message=<object>::
-       Reuse the note message from the given note object.
+       Take the note message from the given blob object (for
+       example, another note).
 
 -c <object>::
 --reedit-message=<object>::
@@ -117,22 +124,151 @@ OPTIONS
        the user can further edit the note message.
 
 --ref <ref>::
-       Manipulate the notes tree in <ref>.  This overrides both
-       GIT_NOTES_REF and the "core.notesRef" configuration.  The ref
+       Manipulate the notes tree in <ref>.  This overrides
+       'GIT_NOTES_REF' and the "core.notesRef" configuration.  The ref
        is taken to be in `refs/notes/` if it is not qualified.
 
+-n::
+       Do not remove anything; just report the object names whose notes
+       would be removed.
+
+-v::
+       Report all object names whose notes are removed.
+
+
+DISCUSSION
+----------
 
-NOTES
------
+Commit notes are blobs containing extra information about an object
+(usually information to supplement a commit's message).  These blobs
+are taken from notes refs.  A notes ref is usually a branch which
+contains "files" whose paths are the object names for the objects
+they describe, with some directory separators included for performance
+reasons footnote:[Permitted pathnames have the form
+'ab'`/`'cd'`/`'ef'`/`'...'`/`'abcdef...': a sequence of directory
+names of two hexadecimal digits each followed by a filename with the
+rest of the object ID.].
 
 Every notes change creates a new commit at the specified notes ref.
 You can therefore inspect the history of the notes by invoking, e.g.,
-`git log -p notes/commits`.
+`git log -p notes/commits`.  Currently the commit message only records
+which operation triggered the update, and the commit authorship is
+determined according to the usual rules (see linkgit:git-commit[1]).
+These details may change in the future.
+
+It is also permitted for a notes ref to point directly to a tree
+object, in which case the history of the notes can be read with
+`git log -p -g <refname>`.
+
+
+EXAMPLES
+--------
+
+You can use notes to add annotations with information that was not
+available at the time a commit was written.
+
+------------
+$ git notes add -m 'Tested-by: Johannes Sixt <j6t@kdbg.org>' 72a144e2
+$ git show -s 72a144e
+[...]
+    Signed-off-by: Junio C Hamano <gitster@pobox.com>
+
+Notes:
+    Tested-by: Johannes Sixt <j6t@kdbg.org>
+------------
+
+In principle, a note is a regular Git blob, and any kind of
+(non-)format is accepted.  You can binary-safely create notes from
+arbitrary files using 'git hash-object':
+
+------------
+$ cc *.c
+$ blob=$(git hash-object -w a.out)
+$ git notes --ref=built add -C "$blob" HEAD
+------------
+
+Of course, it doesn't make much sense to display non-text-format notes
+with 'git log', so if you use such notes, you'll probably need to write
+some special-purpose tools to do something useful with them.
+
+
+CONFIGURATION
+-------------
 
-Currently the commit message only records which operation triggered
-the update, and the commit authorship is determined according to the
-usual rules (see linkgit:git-commit[1]).  These details may change in
-the future.
+core.notesRef::
+       Notes ref to read and manipulate instead of
+       `refs/notes/commits`.  Must be an unabbreviated ref name.
+       This setting can be overridden through the environment and
+       command line.
+
+notes.displayRef::
+       Which ref (or refs, if a glob or specified more than once), in
+       addition to the default set by `core.notesRef` or
+       'GIT_NOTES_REF', to read notes from when showing commit
+       messages with the 'git log' family of commands.
+       This setting can be overridden on the command line or by the
+       'GIT_NOTES_DISPLAY_REF' environment variable.
+       See linkgit:git-log[1].
+
+notes.rewrite.<command>::
+       When rewriting commits with <command> (currently `amend` or
+       `rebase`), if this variable is `false`, git will not copy
+       notes from the original to the rewritten commit.  Defaults to
+       `true`.  See also "`notes.rewriteRef`" below.
++
+This setting can be overridden by the 'GIT_NOTES_REWRITE_REF'
+environment variable.
+
+notes.rewriteMode::
+       When copying notes during a rewrite, what to do if the target
+       commit already has a note.  Must be one of `overwrite`,
+       `concatenate`, and `ignore`.  Defaults to `concatenate`.
++
+This setting can be overridden with the `GIT_NOTES_REWRITE_MODE`
+environment variable.
+
+notes.rewriteRef::
+       When copying notes during a rewrite, specifies the (fully
+       qualified) ref whose notes should be copied.  May be a glob,
+       in which case notes in all matching refs will be copied.  You
+       may also specify this configuration several times.
++
+Does not have a default value; you must configure this variable to
+enable note rewriting.
++
+Can be overridden with the 'GIT_NOTES_REWRITE_REF' environment variable.
+
+
+ENVIRONMENT
+-----------
+
+'GIT_NOTES_REF'::
+       Which ref to manipulate notes from, instead of `refs/notes/commits`.
+       This overrides the `core.notesRef` setting.
+
+'GIT_NOTES_DISPLAY_REF'::
+       Colon-delimited list of refs or globs indicating which refs,
+       in addition to the default from `core.notesRef` or
+       'GIT_NOTES_REF', to read notes from when showing commit
+       messages.
+       This overrides the `notes.displayRef` setting.
++
+A warning will be issued for refs that do not exist, but a glob that
+does not match any refs is silently ignored.
+
+'GIT_NOTES_REWRITE_MODE'::
+       When copying notes during a rewrite, what to do if the target
+       commit already has a note.
+       Must be one of `overwrite`, `concatenate`, and `ignore`.
+       This overrides the `core.rewriteMode` setting.
+
+'GIT_NOTES_REWRITE_REF'::
+       When rewriting commits, which notes to copy from the original
+       to the rewritten commit.  Must be a colon-delimited list of
+       refs or globs.
++
+If not set in the environment, the list of notes to copy depends
+on the `notes.rewrite.<command>` and `notes.rewriteRef` settings.
 
 
 Author
index 48570242fb2dda31a5684e2d678d40690d3c4cab..b68abff28a0fe27fbcb2bbffa2296cffb1297eaf 100644 (file)
@@ -41,7 +41,7 @@ OPTIONS[[OPTIONS]]
 +
 The <src> is often the name of the branch you would want to push, but
 it can be any arbitrary "SHA-1 expression", such as `master~4` or
-`HEAD` (see linkgit:git-rev-parse[1]).
+`HEAD` (see linkgit:gitrevisions[1]).
 +
 The <dst> tells which ref on the remote side is updated with this
 push. Arbitrary expressions cannot be used here, an actual ref must
index 50ba2e469f48f1bc16c3f6e3b6f6451a9e29637a..be23ad2359b486e4da2ef85962d73cdfed7097fe 100644 (file)
@@ -310,6 +310,11 @@ link:howto/revert-a-faulty-merge.txt[revert-a-faulty-merge How-To] for details).
 -p::
 --preserve-merges::
        Instead of ignoring merges, try to recreate them.
++
+This uses the `--interactive` machinery internally, but combining it
+with the `--interactive` option explicitly is generally not a good
+idea unless you know what you are doing (see BUGS below).
+
 
 --root::
        Rebase all commits reachable from <branch>, instead of
@@ -611,6 +616,28 @@ The ripple effect of a "hard case" recovery is especially bad:
 case" recovery too!
 
 
+BUGS
+----
+The todo list presented by `--preserve-merges --interactive` does not
+represent the topology of the revision graph.  Editing commits and
+rewording their commit messages should work fine, but attempts to
+reorder commits tend to produce counterintuitive results.
+
+For example, an attempt to rearrange
+------------
+1 --- 2 --- 3 --- 4 --- 5
+------------
+to
+------------
+1 --- 2 --- 4 --- 3 --- 5
+------------
+by moving the "pick 4" line will result in the following history:
+------------
+       3
+       /
+1 --- 2 --- 4 --- 5
+------------
+
 Authors
 ------
 Written by Junio C Hamano <gitster@pobox.com> and
index 4eaa62b6913f15c354e8008c2884f476428ebb0b..5a0451aaf377d13590d6112a9ee8cf51e217a21d 100644 (file)
@@ -40,7 +40,7 @@ see linkgit:git-log[1].
 The reflog is useful in various git commands, to specify the old value
 of a reference. For example, `HEAD@\{2\}` means "where HEAD used to be
 two moves ago", `master@\{one.week.ago\}` means "where master used to
-point to one week ago", and so on. See linkgit:git-rev-parse[1] for
+point to one week ago", and so on. See linkgit:gitrevisions[1] for
 more details.
 
 To delete single entries from the reflog, use the subcommand "delete"
index ebaaadc1786b3581f70764aff5d0af4038c86644..aa021b0cb803a9cd9f08566f6a6fe407eb025e4b 100644 (file)
@@ -14,6 +14,7 @@ SYNOPSIS
 'git remote rename' <old> <new>
 'git remote rm' <name>
 'git remote set-head' <name> (-a | -d | <branch>)
+'git remote set-branches' <name> [--add] <branch>...
 'git remote set-url' [--push] <name> <newurl> [<oldurl>]
 'git remote set-url --add' [--push] <name> <newurl>
 'git remote set-url --delete' [--push] <name> <url>
@@ -110,6 +111,18 @@ remote set-head origin master" will set `$GIT_DIR/refs/remotes/origin/HEAD` to
 `refs/remotes/origin/master` already exists; if not it must be fetched first.
 +
 
+'set-branches'::
+
+Changes the list of branches tracked by the named remote.
+This can be used to track a subset of the available remote branches
+after the initial setup for a remote.
++
+The named branches will be interpreted as if specified with the
+`-t` option on the 'git remote add' command line.
++
+With `--add`, instead of replacing the list of currently tracked
+branches, adds to that list.
+
 'set-url'::
 
 Changes URL remote points to. Sets first URL remote points to matching
index acc220a00f0013d115366cfc8b7a48aeeef47711..db99d4786e06df1cd2c9352c877c45efcbfb10cc 100644 (file)
@@ -7,7 +7,7 @@ git-rerere - Reuse recorded resolution of conflicted merges
 
 SYNOPSIS
 --------
-'git rerere' ['clear'|'diff'|'status'|'gc']
+'git rerere' ['clear'|'forget' [<pathspec>]|'diff'|'status'|'gc']
 
 DESCRIPTION
 -----------
@@ -40,6 +40,11 @@ This resets the metadata used by rerere if a merge resolution is to be
 aborted.  Calling 'git am [--skip|--abort]' or 'git rebase [--skip|--abort]'
 will automatically invoke this command.
 
+'forget' <pathspec>::
+
+This resets the conflict resolutions which rerere has recorded for the current
+conflict in <pathspec>.  The <pathspec> is optional.
+
 'diff'::
 
 This displays diffs for the current state of the resolution.  It is
index 8db600f6ba01bcb7f85be6c6606795a0034822b2..0727f431c6dc01296b04cc93204ba37d16b5a32b 100644 (file)
@@ -174,202 +174,7 @@ shown.  If the pattern does not contain a globbing character (`?`,
        Flags and parameters to be parsed.
 
 
-SPECIFYING REVISIONS
---------------------
-
-A revision parameter typically, but not necessarily, names a
-commit object.  They use what is called an 'extended SHA1'
-syntax.  Here are various ways to spell object names.  The
-ones listed near the end of this list are to name trees and
-blobs contained in a commit.
-
-* The full SHA1 object name (40-byte hexadecimal string), or
-  a substring of such that is unique within the repository.
-  E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both
-  name the same commit object if there are no other object in
-  your repository whose object name starts with dae86e.
-
-* An output from 'git describe'; i.e. a closest tag, optionally
-  followed by a dash and a number of commits, followed by a dash, a
-  `g`, and an abbreviated object name.
-
-* A symbolic ref name.  E.g. 'master' typically means the commit
-  object referenced by refs/heads/master.  If you
-  happen to have both heads/master and tags/master, you can
-  explicitly say 'heads/master' to tell git which one you mean.
-  When ambiguous, a `<name>` is disambiguated by taking the
-  first match in the following rules:
-
-  . if `$GIT_DIR/<name>` exists, that is what you mean (this is usually
-    useful only for `HEAD`, `FETCH_HEAD`, `ORIG_HEAD` and `MERGE_HEAD`);
-
-  . otherwise, `refs/<name>` if exists;
-
-  . otherwise, `refs/tags/<name>` if exists;
-
-  . otherwise, `refs/heads/<name>` if exists;
-
-  . otherwise, `refs/remotes/<name>` if exists;
-
-  . otherwise, `refs/remotes/<name>/HEAD` if exists.
-+
-HEAD names the commit your changes in the working tree is based on.
-FETCH_HEAD records the branch you fetched from a remote repository
-with your last 'git fetch' invocation.
-ORIG_HEAD is created by commands that moves your HEAD in a drastic
-way, to record the position of the HEAD before their operation, so that
-you can change the tip of the branch back to the state before you ran
-them easily.
-MERGE_HEAD records the commit(s) you are merging into your branch
-when you run 'git merge'.
-+
-Note that any of the `refs/*` cases above may come either from
-the `$GIT_DIR/refs` directory or from the `$GIT_DIR/packed-refs` file.
-
-* A ref followed by the suffix '@' with a date specification
-  enclosed in a brace
-  pair (e.g. '\{yesterday\}', '\{1 month 2 weeks 3 days 1 hour 1
-  second ago\}' or '\{1979-02-26 18:30:00\}') to specify the value
-  of the ref at a prior point in time.  This suffix may only be
-  used immediately following a ref name and the ref must have an
-  existing log ($GIT_DIR/logs/<ref>). Note that this looks up the state
-  of your *local* ref at a given time; e.g., what was in your local
-  `master` branch last week. If you want to look at commits made during
-  certain times, see `--since` and `--until`.
-
-* A ref followed by the suffix '@' with an ordinal specification
-  enclosed in a brace pair (e.g. '\{1\}', '\{15\}') to specify
-  the n-th prior value of that ref.  For example 'master@\{1\}'
-  is the immediate prior value of 'master' while 'master@\{5\}'
-  is the 5th prior value of 'master'. This suffix may only be used
-  immediately following a ref name and the ref must have an existing
-  log ($GIT_DIR/logs/<ref>).
-
-* You can use the '@' construct with an empty ref part to get at a
-  reflog of the current branch. For example, if you are on the
-  branch 'blabla', then '@\{1\}' means the same as 'blabla@\{1\}'.
-
-* The special construct '@\{-<n>\}' means the <n>th branch checked out
-  before the current one.
-
-* The suffix '@\{upstream\}' to a ref (short form 'ref@\{u\}') refers to
-  the branch the ref is set to build on top of.  Missing ref defaults
-  to the current branch.
-
-* A suffix '{caret}' to a revision parameter means the first parent of
-  that commit object.  '{caret}<n>' means the <n>th parent (i.e.
-  'rev{caret}'
-  is equivalent to 'rev{caret}1').  As a special rule,
-  'rev{caret}0' means the commit itself and is used when 'rev' is the
-  object name of a tag object that refers to a commit object.
-
-* A suffix '{tilde}<n>' to a revision parameter means the commit
-  object that is the <n>th generation grand-parent of the named
-  commit object, following only the first parent.  I.e. rev~3 is
-  equivalent to rev{caret}{caret}{caret} which is equivalent to
-  rev{caret}1{caret}1{caret}1.  See below for a illustration of
-  the usage of this form.
-
-* A suffix '{caret}' followed by an object type name enclosed in
-  brace pair (e.g. `v0.99.8{caret}\{commit\}`) means the object
-  could be a tag, and dereference the tag recursively until an
-  object of that type is found or the object cannot be
-  dereferenced anymore (in which case, barf).  `rev{caret}0`
-  introduced earlier is a short-hand for `rev{caret}\{commit\}`.
-
-* A suffix '{caret}' followed by an empty brace pair
-  (e.g. `v0.99.8{caret}\{\}`) means the object could be a tag,
-  and dereference the tag recursively until a non-tag object is
-  found.
-
-* A colon, followed by a slash, followed by a text: this names
-  a commit whose commit message starts with the specified text.
-  This name returns the youngest matching commit which is
-  reachable from any ref.  If the commit message starts with a
-  '!', you have to repeat that;  the special sequence ':/!',
-  followed by something else than '!' is reserved for now.
-
-* A suffix ':' followed by a path; this names the blob or tree
-  at the given path in the tree-ish object named by the part
-  before the colon.
-
-* A colon, optionally followed by a stage number (0 to 3) and a
-  colon, followed by a path; this names a blob object in the
-  index at the given path.  Missing stage number (and the colon
-  that follows it) names a stage 0 entry. During a merge, stage
-  1 is the common ancestor, stage 2 is the target branch's version
-  (typically the current branch), and stage 3 is the version from
-  the branch being merged.
-
-Here is an illustration, by Jon Loeliger.  Both commit nodes B
-and C are parents of commit node A.  Parent commits are ordered
-left-to-right.
-
-........................................
-G   H   I   J
- \ /     \ /
-  D   E   F
-   \  |  / \
-    \ | /   |
-     \|/    |
-      B     C
-       \   /
-        \ /
-         A
-........................................
-
-    A =      = A^0
-    B = A^   = A^1     = A~1
-    C = A^2  = A^2
-    D = A^^  = A^1^1   = A~2
-    E = B^2  = A^^2
-    F = B^3  = A^^3
-    G = A^^^ = A^1^1^1 = A~3
-    H = D^2  = B^^2    = A^^^2  = A~2^2
-    I = F^   = B^3^    = A^^3^
-    J = F^2  = B^3^2   = A^^3^2
-
-
-SPECIFYING RANGES
------------------
-
-History traversing commands such as 'git log' operate on a set
-of commits, not just a single commit.  To these commands,
-specifying a single revision with the notation described in the
-previous section means the set of commits reachable from that
-commit, following the commit ancestry chain.
-
-To exclude commits reachable from a commit, a prefix `{caret}`
-notation is used.  E.g. `{caret}r1 r2` means commits reachable
-from `r2` but exclude the ones reachable from `r1`.
-
-This set operation appears so often that there is a shorthand
-for it.  When you have two commits `r1` and `r2` (named according
-to the syntax explained in SPECIFYING REVISIONS above), you can ask
-for commits that are reachable from r2 excluding those that are reachable
-from r1 by `{caret}r1 r2` and it can be written as `r1..r2`.
-
-A similar notation `r1\...r2` is called symmetric difference
-of `r1` and `r2` and is defined as
-`r1 r2 --not $(git merge-base --all r1 r2)`.
-It is the set of commits that are reachable from either one of
-`r1` or `r2` but not from both.
-
-Two other shorthands for naming a set that is formed by a commit
-and its parent commits exist.  The `r1{caret}@` notation means all
-parents of `r1`.  `r1{caret}!` includes commit `r1` but excludes
-all of its parents.
-
-Here are a handful of examples:
-
-   D                G H D
-   D F              G H I J D F
-   ^G D             H D
-   ^D B             E I J F B
-   B...C            G H D E B C
-   ^D B C           E I J F B C
-   C^@              I J F
-   F^! D            G H D F
+include::revisions.txt[]
 
 PARSEOPT
 --------
index c66bf8072e6720d3edfc17d234fc09c8d01bbb2c..b7d9ef7e4726db40f3b0d1ec9474494bb6e07dcf 100644 (file)
@@ -3,20 +3,22 @@ git-revert(1)
 
 NAME
 ----
-git-revert - Revert an existing commit
+git-revert - Revert some existing commits
 
 SYNOPSIS
 --------
-'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>
+'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>...
 
 DESCRIPTION
 -----------
-Given one existing commit, revert the change the patch introduces, and record a
-new commit that records it.  This requires your working tree to be clean (no
-modifications from the HEAD commit).
 
-Note: 'git revert' is used to record a new commit to reverse the
-effect of an earlier commit (often a faulty one).  If you want to
+Given one or more existing commits, revert the changes that the
+related patches introduce, and record some new commits that record
+them.  This requires your working tree to be clean (no modifications
+from the HEAD commit).
+
+Note: 'git revert' is used to record some new commits to reverse the
+effect of some earlier commits (often only a faulty one).  If you want to
 throw away all uncommitted changes in your working directory, you
 should see linkgit:git-reset[1], particularly the '--hard' option.  If
 you want to extract specific files as they were in another commit, you
@@ -26,10 +28,13 @@ both will discard uncommitted changes in your working directory.
 
 OPTIONS
 -------
-<commit>::
-       Commit to revert.
+<commit>...::
+       Commits to revert.
        For a more complete list of ways to spell commit names, see
-       "SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
+       linkgit:gitrevisions[1].
+       Sets of commits can also be given but no traversal is done by
+       default, see linkgit:git-rev-list[1] and its '--no-walk'
+       option.
 
 -e::
 --edit::
@@ -59,11 +64,11 @@ more details.
 
 -n::
 --no-commit::
-       Usually the command automatically creates a commit with
-       a commit log message stating which commit was
-       reverted.  This flag applies the change necessary
-       to revert the named commit to your working tree
-       and the index, but does not make the commit.  In addition,
+       Usually the command automatically creates some commits with
+       commit log messages stating which commits were
+       reverted.  This flag applies the changes necessary
+       to revert the named commits to your working tree
+       and the index, but does not make the commits.  In addition,
        when this option is used, your index does not have to match
        the HEAD commit.  The revert is done against the
        beginning state of your index.
@@ -75,6 +80,20 @@ effect to your index in a row.
 --signoff::
        Add Signed-off-by line at the end of the commit message.
 
+EXAMPLES
+--------
+git revert HEAD~3::
+
+       Revert the changes specified by the fourth last commit in HEAD
+       and create a new commit with the reverted changes.
+
+git revert -n master\~5..master~2::
+
+       Revert the changes done by commits from the fifth last commit
+       in master (included) to the third last commit in master
+       (included), but do not create any commit with the reverted
+       changes. The revert only modifies the working tree and the
+       index.
 
 Author
 ------
@@ -84,6 +103,10 @@ Documentation
 --------------
 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 
+SEE ALSO
+--------
+linkgit:git-cherry-pick[1]
+
 GIT
 ---
 Part of the linkgit:git[1] suite
index 12622fc49a0825fa8423c46ddddc06ff89f292d4..c283084272090c28d5529d200a1147c9f57c639b 100644 (file)
@@ -101,6 +101,15 @@ See the CONFIGURATION section for 'sendemail.multiedit'.
 +
 The --to option must be repeated for each user you want on the to list.
 
+--8bit-encoding=<encoding>::
+       When encountering a non-ASCII message or subject that does not
+       declare its encoding, add headers/quoting to indicate it is
+       encoded in <encoding>.  Default is the value of the
+       'sendemail.assume8bitEncoding'; if that is unspecified, this
+       will be prompted for if any non-ASCII files are encountered.
++
+Note that no attempts whatsoever are made to validate the encoding.
+
 
 Sending
 ~~~~~~~
index f1499bba88028775032819708db22a3250b5b840..81ba29669c52a7c50fb126b7b70c3a867df25f00 100644 (file)
@@ -32,7 +32,7 @@ no <rev> nor <glob> is given on the command line.
 OPTIONS
 -------
 <rev>::
-       Arbitrary extended SHA1 expression (see linkgit:git-rev-parse[1])
+       Arbitrary extended SHA1 expression (see linkgit:gitrevisions[1])
        that typically names a branch head or a tag.
 
 <glob>::
index 55e687a7c7f2113615c80e1719c4f3a2120ba7fa..0002bfb0455b38eecf6b29da6a2464058ba42c57 100644 (file)
@@ -36,7 +36,7 @@ OPTIONS
 <object>...::
        The names of objects to show.
        For a more complete list of ways to spell object names, see
-       "SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
+       "SPECIFYING REVISIONS" section in linkgit:gitrevisions[1].
 
 include::pretty-options.txt[]
 
index 2d4bbfcaf4cc2d2b92ad827662dc3b4b4ef355c0..2fd054c1040ce43949382e4744a0d7a814a8d9bd 100644 (file)
@@ -27,6 +27,10 @@ OPTIONS
 --short::
        Give the output in the short-format.
 
+-b::
+--branch::
+       Show the branch and tracking info even in short-format.
+
 --porcelain::
        Give the output in a stable, easy-to-parse format for scripts.
        Currently this is identical to --short output, but is guaranteed
@@ -49,6 +53,17 @@ See linkgit:git-config[1] for configuration variable
 used to change the default for when the option is not
 specified.
 
+--ignore-submodules[=<when>]::
+       Ignore changes to submodules when looking for changes. <when> can be
+       either "untracked", "dirty" or "all", which is the default. When
+       "untracked" is used submodules are not considered dirty when they only
+       contain untracked content (but they are still scanned for modified
+       content). Using "dirty" ignores all changes to the work tree of submodules,
+       only changes to the commits stored in the superproject are shown (this was
+       the behavior before 1.7.0). Using "all" hides all changes to submodules
+       (and suppresses the output of submodule summaries when the config option
+       `status.submodulesummary` is set).
+
 -z::
        Terminate entries with NUL, instead of LF.  This implies
        the `--porcelain` output format if no other format is given.
@@ -120,6 +135,10 @@ Ignored files are not listed.
     ?           ?    untracked
     -------------------------------------------------
 
+If -b is used the short-format status is preceded by a line
+
+## branchname tracking info
+
 There is an alternate -z format recommended for machine parsing.  In
 that format, the status field is the same, but some other things
 change.  First, the '->' is omitted from rename entries and the field
@@ -128,7 +147,7 @@ order is reversed (e.g 'from -> to' becomes 'to from'). Second, a NUL
 and the terminating newline (but a space still separates the status
 field from the first filename).  Third, filenames containing special
 characters are not specially formatted; no quoting or
-backslash-escaping is performed.
+backslash-escaping is performed. Fourth, there is no branch line.
 
 CONFIGURATION
 -------------
index 2502531a3dfd0cee67f6d1d9fc1db1d69cf20e30..76a832a3ac893111b2d17333e6bc99b7903b47a8 100644 (file)
@@ -95,6 +95,10 @@ is the superproject and submodule repositories will be kept
 together in the same relative location, and only the
 superproject's URL needs to be provided: git-submodule will correctly
 locate the submodule using the relative URL in .gitmodules.
++
+The submodule will be added with "git add --force <path>". I.e. git
+doesn't care if the new path is in a `gitignore`. Your invocation of
+"git submodule add" is considered enough to override it.
 
 status::
        Show the status of the submodules. This will print the SHA-1 of the
@@ -145,10 +149,12 @@ summary::
 
 foreach::
        Evaluates an arbitrary shell command in each checked out submodule.
-       The command has access to the variables $name, $path and $sha1:
+       The command has access to the variables $name, $path, $sha1 and
+       $toplevel:
        $name is the name of the relevant submodule section in .gitmodules,
        $path is the name of the submodule directory relative to the
-       superproject, and $sha1 is the commit as recorded in the superproject.
+       superproject, $sha1 is the commit as recorded in the superproject,
+       and $toplevel is the absolute path to the top-level of the superproject.
        Any submodules defined in the superproject but not checked out are
        ignored by this command. Unless given --quiet, foreach prints the name
        of each submodule before evaluating the command.
index 68dc1879fe912b1a01b3caa6b1c0168f6a7b8072..765d4b312ed6f062180e83fa0d931e6bd2eef24f 100644 (file)
@@ -93,8 +93,6 @@ OPTIONS
 This option can be also used as a coarse file-level mechanism
 to ignore uncommitted changes in tracked files (akin to what
 `.gitignore` does for untracked files).
-You should remember that an explicit 'git add' operation will
-still cause the file to be refreshed from the working tree.
 Git will fail (gracefully) in case it needs to modify this file
 in the index e.g. when merging in a commit;
 thus, in case the assumed-untracked file is changed upstream,
index bec6348dab45580d90b38dac5667434ba661bf94..12066ab3fc2ba37c0a9eb291d40e1fb4a985714b 100644 (file)
@@ -44,9 +44,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.7.1/git.html[documentation for release 1.7.1]
+* link:v1.7.1.1/git.html[documentation for release 1.7.1.1]
 
 * release notes for
+  link:RelNotes-1.7.1.1.txt[1.7.1.1],
   link:RelNotes-1.7.1.txt[1.7.1].
 
 * link:v1.7.0.6/git.html[documentation for release 1.7.0.6]
@@ -478,7 +479,7 @@ HEAD::
        (i.e. the contents of `$GIT_DIR/refs/heads/<head>`).
 
 For a more complete list of ways to spell object names, see
-"SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
+"SPECIFYING REVISIONS" section in linkgit:gitrevisions[1].
 
 
 File/Directory Structure
index 0523a576989dfb717be06af04c4be22a5a8eafd6..564586b943f439cb5ae04c4e76bc19d093c625da 100644 (file)
@@ -92,53 +92,154 @@ such as 'git checkout' and 'git merge' run.  They also affect how
 git stores the contents you prepare in the working tree in the
 repository upon 'git add' and 'git commit'.
 
-`crlf`
+`text`
 ^^^^^^
 
-This attribute controls the line-ending convention.
+This attribute enables and controls end-of-line normalization.  When a
+text file is normalized, its line endings are converted to LF in the
+repository.  To control what line ending style is used in the working
+directory, use the `eol` attribute for a single file and the
+`core.eol` configuration variable for all text files.
 
 Set::
 
-       Setting the `crlf` attribute on a path is meant to mark
-       the path as a "text" file.  'core.autocrlf' conversion
-       takes place without guessing the content type by
-       inspection.
+       Setting the `text` attribute on a path enables end-of-line
+       normalization and marks the path as a text file.  End-of-line
+       conversion takes place without guessing the content type.
 
 Unset::
 
-       Unsetting the `crlf` attribute on a path tells git not to
+       Unsetting the `text` attribute on a path tells git not to
        attempt any end-of-line conversion upon checkin or checkout.
 
+Set to string value "auto"::
+
+       When `text` is set to "auto", the path is marked for automatic
+       end-of-line normalization.  If git decides that the content is
+       text, its line endings are normalized to LF on checkin.
+
 Unspecified::
 
-       Unspecified `crlf` attribute tells git to apply the
-       `core.autocrlf` conversion when the file content looks
-       like text.
+       If the `text` attribute is unspecified, git uses the
+       `core.autocrlf` configuration variable to determine if the
+       file should be converted.
 
-Set to string value "input"::
+Any other value causes git to act as if `text` has been left
+unspecified.
 
-       This is similar to setting the attribute to `true`, but
-       also forces git to act as if `core.autocrlf` is set to
-       `input` for the path.
+`eol`
+^^^^^
 
-Any other value set to `crlf` attribute is ignored and git acts
-as if the attribute is left unspecified.
+This attribute sets a specific line-ending style to be used in the
+working directory.  It enables end-of-line normalization without any
+content checks, effectively setting the `text` attribute.
 
+Set to string value "crlf"::
 
-The `core.autocrlf` conversion
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+       This setting forces git to normalize line endings for this
+       file on checkin and convert them to CRLF when the file is
+       checked out.
+
+Set to string value "lf"::
+
+       This setting forces git to normalize line endings to LF on
+       checkin and prevents conversion to CRLF when the file is
+       checked out.
+
+Backwards compatibility with `crlf` attribute
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+For backwards compatibility, the `crlf` attribute is interpreted as
+follows:
+
+------------------------
+crlf           text
+-crlf          -text
+crlf=input     eol=lf
+------------------------
+
+End-of-line conversion
+^^^^^^^^^^^^^^^^^^^^^^
+
+While git normally leaves file contents alone, it can be configured to
+normalize line endings to LF in the repository and, optionally, to
+convert them to CRLF when files are checked out.
+
+Here is an example that will make git normalize .txt, .vcproj and .sh
+files, ensure that .vcproj files have CRLF and .sh files have LF in
+the working directory, and prevent .jpg files from being normalized
+regardless of their content.
+
+------------------------
+*.txt          text
+*.vcproj       eol=crlf
+*.sh           eol=lf
+*.jpg          -text
+------------------------
+
+Other source code management systems normalize all text files in their
+repositories, and there are two ways to enable similar automatic
+normalization in git.
+
+If you simply want to have CRLF line endings in your working directory
+regardless of the repository you are working with, you can set the
+config variable "core.autocrlf" without changing any attributes.
+
+------------------------
+[core]
+       autocrlf = true
+------------------------
+
+This does not force normalization of all text files, but does ensure
+that text files that you introduce to the repository have their line
+endings normalized to LF when they are added, and that files that are
+already normalized in the repository stay normalized.
+
+If you want to interoperate with a source code management system that
+enforces end-of-line normalization, or you simply want all text files
+in your repository to be normalized, you should instead set the `text`
+attribute to "auto" for _all_ files.
 
-If the configuration variable `core.autocrlf` is false, no
-conversion is done.
+------------------------
+*      text=auto
+------------------------
+
+This ensures that all files that git considers to be text will have
+normalized (LF) line endings in the repository.  The `core.eol`
+configuration variable controls which line endings git will use for
+normalized files in your working directory; the default is to use the
+native line ending for your platform, or CRLF if `core.autocrlf` is
+set.
+
+NOTE: When `text=auto` normalization is enabled in an existing
+repository, any text files containing CRLFs should be normalized.  If
+they are not they will be normalized the next time someone tries to
+change them, causing unfortunate misattribution.  From a clean working
+directory:
+
+-------------------------------------------------
+$ echo "* text=auto" >>.gitattributes
+$ rm .git/index     # Remove the index to force git to
+$ git reset         # re-scan the working directory
+$ git status        # Show files that will be normalized
+$ git add -u
+$ git add .gitattributes
+$ git commit -m "Introduce end-of-line normalization"
+-------------------------------------------------
+
+If any files that should not be normalized show up in 'git status',
+unset their `text` attribute before running 'git add -u'.
+
+------------------------
+manual.pdf     -text
+------------------------
 
-When `core.autocrlf` is true, it means that the platform wants
-CRLF line endings for files in the working tree, and you want to
-convert them back to the normal LF line endings when checking
-in to the repository.
+Conversely, text files that git does not detect can have normalization
+enabled manually.
 
-When `core.autocrlf` is set to "input", line endings are
-converted to LF upon checkin, but there is no conversion done
-upon checkout.
+------------------------
+weirdchars.txt text
+------------------------
 
 If `core.safecrlf` is set to "true" or "warn", git verifies if
 the conversion is reversible for the current setting of
@@ -223,11 +324,11 @@ Interaction between checkin/checkout attributes
 In the check-in codepath, the worktree file is first converted
 with `filter` driver (if specified and corresponding driver
 defined), then the result is processed with `ident` (if
-specified), and then finally with `crlf` (again, if specified
+specified), and then finally with `text` (again, if specified
 and applicable).
 
 In the check-out codepath, the blob content is first converted
-with `crlf`, and then `ident` and fed to `filter`.
+with `text`, and then `ident` and fed to `filter`.
 
 
 Generating diff text
@@ -651,7 +752,7 @@ You do not want any end-of-line conversions applied to, nor textual diffs
 produced for, any binary file you track.  You would need to specify e.g.
 
 ------------
-*.jpg -crlf -diff
+*.jpg -text -diff
 ------------
 
 but that may become cumbersome, when you have many attributes.  Using
@@ -664,7 +765,7 @@ the same time.  The system knows a built-in attribute macro, `binary`:
 
 which is equivalent to the above.  Note that the attribute macros can only
 be "Set" (see the above example that sets "binary" macro as if it were an
-ordinary attribute --- setting it in turn unsets "crlf" and "diff").
+ordinary attribute --- setting it in turn unsets "text" and "diff").
 
 
 DEFINING ATTRIBUTE MACROS
@@ -675,7 +776,7 @@ at the toplevel (i.e. not in any subdirectory).  The built-in attribute
 macro "binary" is equivalent to:
 
 ------------
-[attr]binary -diff -crlf
+[attr]binary -diff -text
 ------------
 
 
index f7815e96a268f0eac7602e03255c28ea2fe04e6b..ed3ddc92cb51eaeb3d4a988e396a4f90297037c6 100644 (file)
@@ -971,7 +971,7 @@ commits from the master branch.  The string inside brackets
 before the commit log message is a short name you can use to
 name the commit.  In the above example, 'master' and 'mybranch'
 are branch heads.  'master^' is the first parent of 'master'
-branch head.  Please see linkgit:git-rev-parse[1] if you want to
+branch head.  Please see linkgit:gitrevisions[1] if you want to
 see more complex cases.
 
 [NOTE]
index 98c459dc82be46be706b1d7545d7ec95efd8790c..e10fa88b8cf98b796fc9354e7671dc7bec25840d 100644 (file)
@@ -83,16 +83,20 @@ Patterns have the following format:
 
  - If the pattern does not contain a slash '/', git treats it as
    a shell glob pattern and checks for a match against the
-   pathname without leading directories.
+   pathname relative to the location of the `.gitignore` file
+   (relative to the toplevel of the work tree if not from a
+   `.gitignore` file).
 
  - Otherwise, git treats the pattern as a shell glob suitable
    for consumption by fnmatch(3) with the FNM_PATHNAME flag:
    wildcards in the pattern will not match a / in the pathname.
    For example, "Documentation/\*.html" matches
-   "Documentation/git.html" but not
-   "Documentation/ppc/ppc.html".  A leading slash matches the
-   beginning of the pathname; for example, "/*.c" matches
-   "cat-file.c" but not "mozilla-sha1/sha1.c".
+   "Documentation/git.html" but not "Documentation/ppc/ppc.html"
+   or "tools/perf/Documentation/perf.html".
+
+ - A leading slash matches the beginning of the pathname.
+   For example, "/*.c" matches "cat-file.c" but not
+   "mozilla-sha1/sha1.c".
 
 An example:
 
index 99baa24a2d5c8c703d3ad5ce7442bb8363359cd6..05ac1c79f768352be8756eeb483e71f0d09131de 100644 (file)
@@ -69,7 +69,7 @@ frequently used options.
        the form "'<from>'..'<to>'" to show all revisions between '<from>' and
        back to '<to>'. Note, more advanced revision selection can be applied.
        For a more complete list of ways to spell object names, see
-       "SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
+       linkgit:gitrevisions[1].
 
 <path>...::
 
index 5daf750d1942f3b97844b4ef378daf9346cb46d4..72a13d18e019ef00de0e8a79bbe5fe4651ab8dba 100644 (file)
@@ -29,6 +29,9 @@ submodule.<name>.path::
 
 submodule.<name>.url::
        Defines an url from where the submodule repository can be cloned.
+       This may be either an absolute URL ready to be passed to
+       linkgit:git-clone[1] or (if it begins with ./ or ../) a location
+       relative to the superproject's origin repository.
 
 submodule.<name>.update::
        Defines what to do when the submodule is updated by the superproject.
diff --git a/Documentation/gitrevisions.txt b/Documentation/gitrevisions.txt
new file mode 100644 (file)
index 0000000..fc4789f
--- /dev/null
@@ -0,0 +1,35 @@
+gitrevisions(7)
+================
+
+NAME
+----
+gitrevisions - specifying revisions and ranges for git
+
+SYNOPSIS
+--------
+gitrevisions
+
+
+DESCRIPTION
+-----------
+
+Many Git commands take revision parameters as arguments. Depending on
+the command, they denote a specific commit or, for commands which
+walk the revision graph (such as linkgit:git-log[1]), all commits which can
+be reached from that commit. In the latter case one can also specify a
+range of revisions explicitly.
+
+In addition, some Git commands (such as linkgit:git-show[1]) also take
+revision parameters which denote other objects than commits, e.g. blobs
+("files") or trees ("directories of files").
+
+include::revisions.txt[]
+
+
+SEE ALSO
+--------
+linkgit:git-rev-parse[1]
+
+GIT
+---
+Part of the linkgit:git[1] suite
index 2135a8ee1f4f56a8c799437949ba76d7526164c0..34d02a24188921ebac1b70f7cf0c6517a45e8fb1 100755 (executable)
@@ -12,7 +12,7 @@ do
        then
                : did not match
        elif test -f "$T/$h" &&
-          diff -u -I'Last updated [0-9][0-9]-[A-Z][a-z][a-z]-' "$T/$h" "$h"
+          $DIFF -u -I'Last updated [0-9][0-9]-[A-Z][a-z][a-z]-' "$T/$h" "$h"
        then
                :; # up to date
        else
index b055a673d83bcf4c106f3f703ca7f4db4ca1d60f..561cc9f7d7ef1a2502d608e59e2eae345bffd685 100644 (file)
@@ -11,7 +11,12 @@ have limited your view of history: for example, if you are
 only interested in changes related to a certain directory or
 file.
 
-Here are some additional details for each format:
+There are several built-in formats, and you can define
+additional formats by setting a pretty.<name>
+config option to either another format name, or a
+'format:' string, as described below (see
+linkgit:git-config[1]). Here are the details of the
+built-in formats:
 
 * 'oneline'
 
@@ -154,6 +159,10 @@ If you add a `-` (minus sign) after '%' of a placeholder, line-feeds that
 immediately precede the expansion are deleted if and only if the
 placeholder expands to an empty string.
 
+If you add a ` ` (space) after '%' of a placeholder, a space
+is inserted immediately before the expansion if and only if the
+placeholder expands to a non-empty string.
+
 * 'tformat:'
 +
 The 'tformat:' format works exactly like 'format:', except that it
index b9fb7a86bd4bf91205b77275fb51ff13a3bc5622..cc562a057af3694d3518bc91b52ae322b6b1d9cc 100644 (file)
@@ -98,6 +98,15 @@ you would get an output like this:
 This implies the '--topo-order' option by default, but the
 '--date-order' option may also be specified.
 
+ifdef::git-rev-list[]
+--count::
+       Print a number stating how many commits would have been
+       listed, and suppress all other output.  When used together
+       with '--left-right', instead print the counts for left and
+       right commits, separated by a tab.
+endif::git-rev-list[]
+
+
 ifndef::git-rev-list[]
 Diff Formatting
 ~~~~~~~~~~~~~~~
@@ -384,6 +393,14 @@ Default mode::
        merges from the resulting history, as there are no selected
        commits contributing to this merge.
 
+--ancestry-path::
+
+       When given a range of commits to display (e.g. 'commit1..commit2'
+       or 'commit2 {caret}commit1'), only display commits that exist
+       directly on the ancestry chain between the 'commit1' and
+       'commit2', i.e. commits that are both descendants of 'commit1',
+       and ancestors of 'commit2'.
+
 A more detailed explanation follows.
 
 Suppose you specified `foo` as the <paths>.  We shall call commits
@@ -440,7 +457,7 @@ This results in:
 +
 -----------------------------------------------------------------------
          .-A---N---O
-        /         /
+        /     /   /
        I---------D
 -----------------------------------------------------------------------
 +
@@ -511,8 +528,6 @@ Note that without '\--full-history', this still simplifies merges: if
 one of the parents is TREESAME, we follow only that one, so the other
 sides of the merge are never walked.
 
-Finally, there is a fourth simplification mode available:
-
 --simplify-merges::
 
        First, build a history graph in the same way that
@@ -554,6 +569,46 @@ Note the major differences in `N` and `P` over '\--full-history':
   removed completely, because it had one parent and is TREESAME.
 --
 
+Finally, there is a fifth simplification mode available:
+
+--ancestry-path::
+
+       Limit the displayed commits to those directly on the ancestry
+       chain between the "from" and "to" commits in the given commit
+       range. I.e. only display commits that are ancestor of the "to"
+       commit, and descendants of the "from" commit.
++
+As an example use case, consider the following commit history:
++
+-----------------------------------------------------------------------
+           D---E-------F
+          /     \       \
+         B---C---G---H---I---J
+        /                     \
+       A-------K---------------L--M
+-----------------------------------------------------------------------
++
+A regular 'D..M' computes the set of commits that are ancestors of `M`,
+but excludes the ones that are ancestors of `D`. This is useful to see
+what happened to the history leading to `M` since `D`, in the sense
+that "what does `M` have that did not exist in `D`". The result in this
+example would be all the commits, except `A` and `B` (and `D` itself,
+of course).
++
+When we want to find out what commits in `M` are contaminated with the
+bug introduced by `D` and need fixing, however, we might want to view
+only the subset of 'D..M' that are actually descendants of `D`, i.e.
+excluding `C` and `K`. This is exactly what the '\--ancestry-path'
+option does. Applied to the 'D..M' range, it results in:
++
+-----------------------------------------------------------------------
+               E-------F
+                \       \
+                 G---H---I---J
+                              \
+                               L--M
+-----------------------------------------------------------------------
+
 The '\--simplify-by-decoration' option allows you to view only the
 big picture of the topology of the history, by omitting commits
 that are not referenced by tags.  Commits are marked as !TREESAME
diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt
new file mode 100644 (file)
index 0000000..fe846f0
--- /dev/null
@@ -0,0 +1,199 @@
+SPECIFYING REVISIONS
+--------------------
+
+A revision parameter typically, but not necessarily, names a
+commit object.  They use what is called an 'extended SHA1'
+syntax.  Here are various ways to spell object names.  The
+ones listed near the end of this list are to name trees and
+blobs contained in a commit.
+
+* The full SHA1 object name (40-byte hexadecimal string), or
+  a substring of such that is unique within the repository.
+  E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both
+  name the same commit object if there are no other object in
+  your repository whose object name starts with dae86e.
+
+* An output from 'git describe'; i.e. a closest tag, optionally
+  followed by a dash and a number of commits, followed by a dash, a
+  `g`, and an abbreviated object name.
+
+* A symbolic ref name.  E.g. 'master' typically means the commit
+  object referenced by refs/heads/master.  If you
+  happen to have both heads/master and tags/master, you can
+  explicitly say 'heads/master' to tell git which one you mean.
+  When ambiguous, a `<name>` is disambiguated by taking the
+  first match in the following rules:
+
+  . if `$GIT_DIR/<name>` exists, that is what you mean (this is usually
+    useful only for `HEAD`, `FETCH_HEAD`, `ORIG_HEAD` and `MERGE_HEAD`);
+
+  . otherwise, `refs/<name>` if exists;
+
+  . otherwise, `refs/tags/<name>` if exists;
+
+  . otherwise, `refs/heads/<name>` if exists;
+
+  . otherwise, `refs/remotes/<name>` if exists;
+
+  . otherwise, `refs/remotes/<name>/HEAD` if exists.
++
+HEAD names the commit your changes in the working tree is based on.
+FETCH_HEAD records the branch you fetched from a remote repository
+with your last 'git fetch' invocation.
+ORIG_HEAD is created by commands that moves your HEAD in a drastic
+way, to record the position of the HEAD before their operation, so that
+you can change the tip of the branch back to the state before you ran
+them easily.
+MERGE_HEAD records the commit(s) you are merging into your branch
+when you run 'git merge'.
++
+Note that any of the `refs/*` cases above may come either from
+the `$GIT_DIR/refs` directory or from the `$GIT_DIR/packed-refs` file.
+
+* A ref followed by the suffix '@' with a date specification
+  enclosed in a brace
+  pair (e.g. '\{yesterday\}', '\{1 month 2 weeks 3 days 1 hour 1
+  second ago\}' or '\{1979-02-26 18:30:00\}') to specify the value
+  of the ref at a prior point in time.  This suffix may only be
+  used immediately following a ref name and the ref must have an
+  existing log ($GIT_DIR/logs/<ref>). Note that this looks up the state
+  of your *local* ref at a given time; e.g., what was in your local
+  `master` branch last week. If you want to look at commits made during
+  certain times, see `--since` and `--until`.
+
+* A ref followed by the suffix '@' with an ordinal specification
+  enclosed in a brace pair (e.g. '\{1\}', '\{15\}') to specify
+  the n-th prior value of that ref.  For example 'master@\{1\}'
+  is the immediate prior value of 'master' while 'master@\{5\}'
+  is the 5th prior value of 'master'. This suffix may only be used
+  immediately following a ref name and the ref must have an existing
+  log ($GIT_DIR/logs/<ref>).
+
+* You can use the '@' construct with an empty ref part to get at a
+  reflog of the current branch. For example, if you are on the
+  branch 'blabla', then '@\{1\}' means the same as 'blabla@\{1\}'.
+
+* The special construct '@\{-<n>\}' means the <n>th branch checked out
+  before the current one.
+
+* The suffix '@\{upstream\}' to a ref (short form 'ref@\{u\}') refers to
+  the branch the ref is set to build on top of.  Missing ref defaults
+  to the current branch.
+
+* A suffix '{caret}' to a revision parameter (e.g. 'HEAD{caret}') means the first parent of
+  that commit object.  '{caret}<n>' means the <n>th parent (i.e.
+  'rev{caret}'
+  is equivalent to 'rev{caret}1').  As a special rule,
+  'rev{caret}0' means the commit itself and is used when 'rev' is the
+  object name of a tag object that refers to a commit object.
+
+* A suffix '{tilde}<n>' to a revision parameter means the commit
+  object that is the <n>th generation grand-parent of the named
+  commit object, following only the first parent.  I.e. rev~3 is
+  equivalent to rev{caret}{caret}{caret} which is equivalent to
+  rev{caret}1{caret}1{caret}1.  See below for a illustration of
+  the usage of this form.
+
+* A suffix '{caret}' followed by an object type name enclosed in
+  brace pair (e.g. `v0.99.8{caret}\{commit\}`) means the object
+  could be a tag, and dereference the tag recursively until an
+  object of that type is found or the object cannot be
+  dereferenced anymore (in which case, barf).  `rev{caret}0`
+  introduced earlier is a short-hand for `rev{caret}\{commit\}`.
+
+* A suffix '{caret}' followed by an empty brace pair
+  (e.g. `v0.99.8{caret}\{\}`) means the object could be a tag,
+  and dereference the tag recursively until a non-tag object is
+  found.
+
+* A colon, followed by a slash, followed by a text (e.g. `:/fix nasty bug`): this names
+  a commit whose commit message starts with the specified text.
+  This name returns the youngest matching commit which is
+  reachable from any ref.  If the commit message starts with a
+  '!', you have to repeat that;  the special sequence ':/!',
+  followed by something else than '!' is reserved for now.
+
+* A suffix ':' followed by a path (e.g. `HEAD:README`); this names the blob or tree
+  at the given path in the tree-ish object named by the part
+  before the colon.
+  ':path' (with an empty part before the colon, e.g. `:README`)
+  is a special case of the syntax described next: content
+  recorded in the index at the given path.
+
+* A colon, optionally followed by a stage number (0 to 3) and a
+  colon, followed by a path (e.g. `:0:README`); this names a blob object in the
+  index at the given path. Missing stage number (and the colon
+  that follows it, e.g. `:README`) names a stage 0 entry. During a merge, stage
+  1 is the common ancestor, stage 2 is the target branch's version
+  (typically the current branch), and stage 3 is the version from
+  the branch being merged.
+
+Here is an illustration, by Jon Loeliger.  Both commit nodes B
+and C are parents of commit node A.  Parent commits are ordered
+left-to-right.
+
+........................................
+G   H   I   J
+ \ /     \ /
+  D   E   F
+   \  |  / \
+    \ | /   |
+     \|/    |
+      B     C
+       \   /
+        \ /
+         A
+........................................
+
+    A =      = A^0
+    B = A^   = A^1     = A~1
+    C = A^2  = A^2
+    D = A^^  = A^1^1   = A~2
+    E = B^2  = A^^2
+    F = B^3  = A^^3
+    G = A^^^ = A^1^1^1 = A~3
+    H = D^2  = B^^2    = A^^^2  = A~2^2
+    I = F^   = B^3^    = A^^3^
+    J = F^2  = B^3^2   = A^^3^2
+
+
+SPECIFYING RANGES
+-----------------
+
+History traversing commands such as 'git log' operate on a set
+of commits, not just a single commit.  To these commands,
+specifying a single revision with the notation described in the
+previous section means the set of commits reachable from that
+commit, following the commit ancestry chain.
+
+To exclude commits reachable from a commit, a prefix `{caret}`
+notation is used.  E.g. `{caret}r1 r2` means commits reachable
+from `r2` but exclude the ones reachable from `r1`.
+
+This set operation appears so often that there is a shorthand
+for it.  When you have two commits `r1` and `r2` (named according
+to the syntax explained in SPECIFYING REVISIONS above), you can ask
+for commits that are reachable from r2 excluding those that are reachable
+from r1 by `{caret}r1 r2` and it can be written as `r1..r2`.
+
+A similar notation `r1\...r2` is called symmetric difference
+of `r1` and `r2` and is defined as
+`r1 r2 --not $(git merge-base --all r1 r2)`.
+It is the set of commits that are reachable from either one of
+`r1` or `r2` but not from both.
+
+Two other shorthands for naming a set that is formed by a commit
+and its parent commits exist.  The `r1{caret}@` notation means all
+parents of `r1`.  `r1{caret}!` includes commit `r1` but excludes
+all of its parents.
+
+Here are a handful of examples:
+
+   D                G H D
+   D F              G H I J D F
+   ^G D             H D
+   ^D B             E I J F B
+   B...C            G H D E B C
+   ^D B C           E I J F B C
+   C^@              I J F
+   F^! D            G H D F
index 44876fa703578f4952d6e928993e15ddec70439c..f18b4f4817448530a5adbe2c8835bb7791add42a 100644 (file)
@@ -231,8 +231,9 @@ The function pointer in .proc has the following signature:
 
 
 There are serious restrictions on what the asynchronous function can do
-because this facility is implemented by a pipe to a forked process on
-UNIX, but by a thread in the same address space on Windows:
+because this facility is implemented by a thread in the same address
+space on most platforms (when pthreads is available), but by a pipe to
+a forked process otherwise:
 
 . It cannot change the program's state (global variables, environment,
   etc.) in a way that the caller notices; in other words, .in and .out
index fd1a593149a0ed1a12085bb83067576674a04e81..b15517fa06bd782fb757e6b0836f9bceea8b7c05 100644 (file)
@@ -119,7 +119,7 @@ both.
 ofs-delta
 ---------
 
-Server can send, and client understand PACKv2 with delta refering to
+Server can send, and client understand PACKv2 with delta referring to
 its base by position in pack rather than by an obj-id.  That is, they can
 send/read OBJ_OFS_DELTA (aka type 6) in a packfile.
 
index fe6fb722da1a5c288c7ae3757622aac8cac79a73..22aee34d4a49b242370e5244f35d542ad0b79391 100644 (file)
@@ -397,7 +397,7 @@ is usually a shortcut for the HEAD branch in the repository "origin".
 For the complete list of paths which git checks for references, and
 the order it uses to decide which to choose when there are multiple
 references with the same shorthand name, see the "SPECIFYING
-REVISIONS" section of linkgit:git-rev-parse[1].
+REVISIONS" section of linkgit:gitrevisions[1].
 
 [[Updating-a-repository-With-git-fetch]]
 Updating a repository with git fetch
@@ -568,7 +568,7 @@ We have seen several ways of naming commits already:
        - HEAD: refers to the head of the current branch
 
 There are many more; see the "SPECIFYING REVISIONS" section of the
-linkgit:git-rev-parse[1] man page for the complete list of ways to
+linkgit:gitrevisions[1] man page for the complete list of ways to
 name revisions.  Some examples:
 
 -------------------------------------------------
@@ -909,7 +909,7 @@ commits reachable from some head but not from any tag in the repository:
 $ gitk $( git show-ref --heads ) --not  $( git show-ref --tags )
 -------------------------------------------------
 
-(See linkgit:git-rev-parse[1] for explanations of commit-selecting
+(See linkgit:gitrevisions[1] for explanations of commit-selecting
 syntax such as `--not`.)
 
 [[making-a-release]]
@@ -1635,7 +1635,7 @@ you've checked out.
 The reflogs are kept by default for 30 days, after which they may be
 pruned.  See linkgit:git-reflog[1] and linkgit:git-gc[1] to learn
 how to control this pruning, and see the "SPECIFYING REVISIONS"
-section of linkgit:git-rev-parse[1] for details.
+section of linkgit:gitrevisions[1] for details.
 
 Note that the reflog history is very different from normal git history.
 While normal history is shared by every repository that works on the
index d5d6565c86242a10e5f0c10365375d2b8ba990c4..bc3c57058faba66f6a7a947e1e9642f47053b5bb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,12 @@ all::
 # Define SANE_TOOL_PATH to a colon-separated list of paths to prepend
 # to PATH if your tools in /usr/bin are broken.
 #
+# Define SOCKLEN_T to a suitable type (such as 'size_t') if your
+# system headers do not define a socklen_t type.
+#
+# Define INLINE to a suitable substitute (such as '__inline' or '') if git
+# fails to compile with errors about undefined inline functions or similar.
+#
 # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
 # or vsnprintf() return -1 instead of number of characters which would
 # have been written to the final string if enough space had been available.
@@ -227,6 +233,8 @@ all::
 #
 # Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
 # dependency rules.
+#
+# Define NATIVE_CRLF if your platform uses CRLF for line endings.
 
 GIT-VERSION-FILE: FORCE
        @$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -249,7 +257,7 @@ endif
 
 CFLAGS = -g -O2 -Wall
 LDFLAGS =
-ALL_CFLAGS = $(CFLAGS)
+ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
 ALL_LDFLAGS = $(LDFLAGS)
 STRIP ?= strip
 
@@ -272,6 +280,7 @@ mandir = share/man
 infodir = share/info
 gitexecdir = libexec/git-core
 sharedir = $(prefix)/share
+gitwebdir = $(sharedir)/gitweb
 template_dir = share/git-core/templates
 htmldir = share/doc/git-doc
 ifeq ($(prefix),/usr)
@@ -285,11 +294,12 @@ lib = lib
 # DESTDIR=
 pathsep = :
 
-export prefix bindir sharedir sysconfdir
+export prefix bindir sharedir sysconfdir gitwebdir
 
 CC = gcc
 AR = ar
 RM = rm -f
+DIFF = diff
 TAR = tar
 FIND = find
 INSTALL = install
@@ -297,6 +307,7 @@ RPMBUILD = rpmbuild
 TCL_PATH = tclsh
 TCLTK_PATH = wish
 PTHREAD_LIBS = -lpthread
+PTHREAD_CFLAGS =
 
 export TCL_PATH TCLTK_PATH
 
@@ -627,6 +638,7 @@ LIB_OBJS += tree-diff.o
 LIB_OBJS += tree.o
 LIB_OBJS += tree-walk.o
 LIB_OBJS += unpack-trees.o
+LIB_OBJS += url.o
 LIB_OBJS += usage.o
 LIB_OBJS += userdiff.o
 LIB_OBJS += utf8.o
@@ -739,6 +751,13 @@ EXTLIBS =
 # because maintaining the nesting to match is a pain.  If
 # we had "elif" things would have been much nicer...
 
+ifeq ($(uname_S),OSF1)
+       # Need this for u_short definitions et al
+       BASIC_CFLAGS += -D_OSF_SOURCE
+       SOCKLEN_T = int
+       NO_STRTOULL = YesPlease
+       NO_NSEC = YesPlease
+endif
 ifeq ($(uname_S),Linux)
        NO_STRLCPY = YesPlease
        NO_MKSTEMPS = YesPlease
@@ -813,6 +832,18 @@ ifeq ($(uname_S),SunOS)
        NO_MKDTEMP = YesPlease
        NO_MKSTEMPS = YesPlease
        NO_REGEX = YesPlease
+       ifeq ($(uname_R),5.6)
+               SOCKLEN_T = int
+               NO_HSTRERROR = YesPlease
+               NO_IPV6 = YesPlease
+               NO_SOCKADDR_STORAGE = YesPlease
+               NO_UNSETENV = YesPlease
+               NO_SETENV = YesPlease
+               NO_STRLCPY = YesPlease
+               NO_C99_FORMAT = YesPlease
+               NO_STRTOUMAX = YesPlease
+               GIT_TEST_CMP = cmp
+       endif
        ifeq ($(uname_R),5.7)
                NEEDS_RESOLV = YesPlease
                NO_IPV6 = YesPlease
@@ -822,18 +853,21 @@ ifeq ($(uname_S),SunOS)
                NO_STRLCPY = YesPlease
                NO_C99_FORMAT = YesPlease
                NO_STRTOUMAX = YesPlease
+               GIT_TEST_CMP = cmp
        endif
        ifeq ($(uname_R),5.8)
                NO_UNSETENV = YesPlease
                NO_SETENV = YesPlease
                NO_C99_FORMAT = YesPlease
                NO_STRTOUMAX = YesPlease
+               GIT_TEST_CMP = cmp
        endif
        ifeq ($(uname_R),5.9)
                NO_UNSETENV = YesPlease
                NO_SETENV = YesPlease
                NO_C99_FORMAT = YesPlease
                NO_STRTOUMAX = YesPlease
+               GIT_TEST_CMP = cmp
        endif
        INSTALL = /usr/ucb/install
        TAR = gtar
@@ -898,6 +932,7 @@ ifeq ($(uname_S),NetBSD)
        HAVE_PATHS_H = YesPlease
 endif
 ifeq ($(uname_S),AIX)
+       DEFAULT_PAGER = more
        NO_STRCASESTR=YesPlease
        NO_MEMMEM = YesPlease
        NO_MKDTEMP = YesPlease
@@ -910,7 +945,13 @@ ifeq ($(uname_S),AIX)
        BASIC_CFLAGS += -D_LARGE_FILES
        ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
                NO_PTHREADS = YesPlease
+       else
+               PTHREAD_LIBS = -lpthread
+       endif
+       ifeq ($(shell expr "$(uname_V).$(uname_R)" : '5\.1'),3)
+               INLINE=''
        endif
+       GIT_TEST_CMP = cmp
 endif
 ifeq ($(uname_S),GNU)
        # GNU/Hurd
@@ -955,6 +996,7 @@ ifeq ($(uname_S),IRIX64)
        NEEDS_LIBGEN = YesPlease
 endif
 ifeq ($(uname_S),HP-UX)
+       INLINE = __inline
        NO_IPV6=YesPlease
        NO_SETENV=YesPlease
        NO_STRCASESTR=YesPlease
@@ -966,6 +1008,20 @@ ifeq ($(uname_S),HP-UX)
        NO_HSTRERROR = YesPlease
        NO_SYS_SELECT_H = YesPlease
        SNPRINTF_RETURNS_BOGUS = YesPlease
+       NO_NSEC = YesPlease
+       ifeq ($(uname_R),B.11.00)
+               NO_INET_NTOP = YesPlease
+               NO_INET_PTON = YesPlease
+       endif
+       ifeq ($(uname_R),B.10.20)
+               # Override HP-UX 11.x setting:
+               INLINE =
+               SOCKLEN_T = size_t
+               NO_PREAD = YesPlease
+               NO_INET_NTOP = YesPlease
+               NO_INET_PTON = YesPlease
+       endif
+       GIT_TEST_CMP = cmp
 endif
 ifeq ($(uname_S),Windows)
        GIT_VERSION := $(GIT_VERSION).MSVC
@@ -1002,6 +1058,7 @@ ifeq ($(uname_S),Windows)
        NO_CURL = YesPlease
        NO_PYTHON = YesPlease
        BLK_SHA1 = YesPlease
+       NATIVE_CRLF = YesPlease
 
        CC = compat/vcbuild/scripts/clink.pl
        AR = compat/vcbuild/scripts/lib.pl
@@ -1039,7 +1096,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))
        NO_STRTOUMAX = YesPlease
        NO_MKDTEMP = YesPlease
        NO_MKSTEMPS = YesPlease
-       SNPRINTF_RETURNS_BOGUS = YesPlease
        NO_SVN_TESTS = YesPlease
        NO_PERL_MAKEMAKER = YesPlease
        RUNTIME_PREFIX = YesPlease
@@ -1076,6 +1132,7 @@ endif
 -include config.mak
 
 ifdef CHECK_HEADER_DEPENDENCIES
+COMPUTE_HEADER_DEPENDENCIES =
 USE_COMPUTED_HEADER_DEPENDENCIES =
 endif
 
@@ -1091,6 +1148,14 @@ else
 BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
 endif
 
+ifneq (,$(INLINE))
+       BASIC_CFLAGS += -Dinline=$(INLINE)
+endif
+
+ifneq (,$(SOCKLEN_T))
+       BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T)
+endif
+
 ifeq ($(uname_S),Darwin)
        ifndef NO_FINK
                ifeq ($(shell test -d /sw/lib && echo y),y)
@@ -1362,6 +1427,7 @@ endif
 ifdef NO_PTHREADS
        BASIC_CFLAGS += -DNO_PTHREADS
 else
+       BASIC_CFLAGS += $(PTHREAD_CFLAGS)
        EXTLIBS += $(PTHREAD_LIBS)
        LIB_OBJS += thread-utils.o
 endif
@@ -1386,6 +1452,10 @@ ifdef USE_NED_ALLOCATOR
        COMPAT_OBJS += compat/nedmalloc/nedmalloc.o
 endif
 
+ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
+       export GIT_TEST_CMP_USE_COPIED_CONTEXT
+endif
+
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK=NoThanks
 endif
@@ -1442,11 +1512,13 @@ gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
 template_dir_SQ = $(subst ','\'',$(template_dir))
 htmldir_SQ = $(subst ','\'',$(htmldir))
 prefix_SQ = $(subst ','\'',$(prefix))
+gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
 
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
 PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
+DIFF_SQ = $(subst ','\'',$(DIFF))
 
 LIBS = $(GITLIBS) $(EXTLIBS)
 
@@ -1473,7 +1545,7 @@ endif
 ALL_CFLAGS += $(BASIC_CFLAGS)
 ALL_LDFLAGS += $(BASIC_LDFLAGS)
 
-export TAR INSTALL DESTDIR SHELL_PATH
+export DIFF TAR INSTALL DESTDIR SHELL_PATH
 
 
 ### Build rules
@@ -1535,6 +1607,7 @@ define cmd_munge_script
 $(RM) $@ $@+ && \
 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
     -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
+    -e 's|@@DIFF@@|$(DIFF_SQ)|' \
     -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
     -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
     -e $(BROKEN_PATH_FIX) \
@@ -1562,11 +1635,10 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
        sed -e '1{' \
            -e '        s|#!.*perl|#!$(PERL_PATH_SQ)|' \
            -e '        h' \
-           -e '        s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
+           -e '        s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "'"$$INSTLIBDIR"'"));=' \
            -e '        H' \
            -e '        x' \
            -e '}' \
-           -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
            $@.perl >$@+ && \
        chmod +x $@+ && \
@@ -1578,45 +1650,38 @@ gitweb:
        $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all
 
 ifdef JSMIN
-GITWEB_PROGRAMS += gitweb/gitweb.min.js
-GITWEB_JS = gitweb/gitweb.min.js
+GITWEB_PROGRAMS += gitweb/static/gitweb.min.js
+GITWEB_JS = gitweb/static/gitweb.min.js
 else
-GITWEB_JS = gitweb/gitweb.js
+GITWEB_JS = gitweb/static/gitweb.js
 endif
 ifdef CSSMIN
-GITWEB_PROGRAMS += gitweb/gitweb.min.css
-GITWEB_CSS = gitweb/gitweb.min.css
+GITWEB_PROGRAMS += gitweb/static/gitweb.min.css
+GITWEB_CSS = gitweb/static/gitweb.min.css
 else
-GITWEB_CSS = gitweb/gitweb.css
+GITWEB_CSS = gitweb/static/gitweb.css
 endif
 OTHER_PROGRAMS +=  gitweb/gitweb.cgi  $(GITWEB_PROGRAMS)
 gitweb/gitweb.cgi: gitweb/gitweb.perl $(GITWEB_PROGRAMS)
        $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
 
 ifdef JSMIN
-gitweb/gitweb.min.js: gitweb/gitweb.js
+gitweb/static/gitweb.min.js: gitweb/static/gitweb.js
        $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
 endif # JSMIN
 ifdef CSSMIN
-gitweb/gitweb.min.css: gitweb/gitweb.css
+gitweb/static/gitweb.min.css: gitweb/static/gitweb.css
        $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
 endif # CSSMIN
 
 
-git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.js
+git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/static/gitweb.css gitweb/static/gitweb.js
        $(QUIET_GEN)$(RM) $@ $@+ && \
        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
            -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
-           -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
-           -e '/@@GITWEB_CGI@@/d' \
-           -e '/@@GITWEB_CSS@@/r $(GITWEB_CSS)' \
-           -e '/@@GITWEB_CSS@@/d' \
-           -e '/@@GITWEB_JS@@/r $(GITWEB_JS)' \
-           -e '/@@GITWEB_JS@@/d' \
+           -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
            -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
-            -e 's|@@GITWEB_CSS_NAME@@|$(GITWEB_CSS)|' \
-            -e 's|@@GITWEB_JS_NAME@@|$(GITWEB_JS)|' \
            $@.sh > $@+ && \
        chmod +x $@+ && \
        mv $@+ $@
@@ -1668,7 +1733,10 @@ git.o git.spec \
 
 TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
 GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
-       git.o http.o http-walker.o remote-curl.o
+       git.o
+ifndef NO_CURL
+       GIT_OBJS += http.o http-walker.o remote-curl.o
+endif
 XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
        xdiff/xmerge.o xdiff/xpatience.o
 OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
@@ -1885,10 +1953,18 @@ GIT-CFLAGS: FORCE
 GIT-BUILD-OPTIONS: FORCE
        @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
        @echo PERL_PATH=\''$(subst ','\'',$(PERL_PATH_SQ))'\' >>$@
+       @echo DIFF=\''$(subst ','\'',$(subst ','\'',$(DIFF)))'\' >>$@
+       @echo PYTHON_PATH=\''$(subst ','\'',$(PYTHON_PATH_SQ))'\' >>$@
        @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
        @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
        @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
        @echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@
+ifdef GIT_TEST_CMP
+       @echo GIT_TEST_CMP=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_CMP)))'\' >>$@
+endif
+ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
+       @echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
+endif
 
 ### Detect Tck/Tk interpreter path changes
 ifndef NO_TCLTK
@@ -1983,6 +2059,7 @@ install: all
        $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
 ifndef NO_PERL
        $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
+       $(MAKE) -C gitweb install
 endif
 ifndef NO_PYTHON
        $(MAKE) -C git_remote_helpers prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
@@ -2002,19 +2079,19 @@ endif
                test -z "$(NO_CROSS_DIRECTORY_HARDLINKS)" && \
                ln "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \
                cp "$$bindir/git$X" "$$execdir/git$X"; } ; } && \
-       for p in $(BUILT_INS); do \
+       for p in $(BUILT_INS); do \
                $(RM) "$$execdir/$$p" && \
                ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
                ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
                cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
-         done; } && \
-       { test x"$(REMOTE_CURL_ALIASES)" = x || \
-               { for p in $(REMOTE_CURL_ALIASES); do \
+       done && \
+       remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
+       for p in $$remote_curl_aliases; do \
                $(RM) "$$execdir/$$p" && \
                ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
                ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
                cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
-         done; } ; } && \
+       done && \
        ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
 
 install-gitweb:
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644 (file)
index 0000000..d399de2
--- /dev/null
@@ -0,0 +1,40 @@
+dnl Check for socklen_t: historically on BSD it is an int, and in
+dnl POSIX 1g it is a type of its own, but some platforms use different
+dnl types for the argument to getsockopt, getpeername, etc.  So we
+dnl have to test to find something that will work.
+AC_DEFUN([TYPE_SOCKLEN_T],
+[
+   AC_CHECK_TYPE([socklen_t], ,[
+      AC_MSG_CHECKING([for socklen_t equivalent])
+      AC_CACHE_VAL([git_cv_socklen_t_equiv],
+      [
+         # Systems have either "struct sockaddr *" or
+         # "void *" as the second argument to getpeername
+         git_cv_socklen_t_equiv=
+         for arg2 in "struct sockaddr" void; do
+            for t in int size_t unsigned long "unsigned long"; do
+               AC_TRY_COMPILE([
+                  #include <sys/types.h>
+                  #include <sys/socket.h>
+
+                  int getpeername (int, $arg2 *, $t *);
+               ],[
+                  $t len;
+                  getpeername(0,0,&len);
+               ],[
+                  git_cv_socklen_t_equiv="$t"
+                  break 2
+               ])
+            done
+         done
+
+         if test "x$git_cv_socklen_t_equiv" = x; then
+            AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
+         fi
+      ])
+      AC_MSG_RESULT($git_cv_socklen_t_equiv)
+      AC_DEFINE_UNQUOTED(socklen_t, $git_cv_socklen_t_equiv,
+                       [type to use in place of socklen_t if not defined])],
+      [#include <sys/types.h>
+#include <sys/socket.h>])
+])
diff --git a/attr.c b/attr.c
index 7467baf2d6c81f94a7d043dcde13d463b3b46272..8ba606c933088e27ac08aabb546b764745f8187e 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -287,7 +287,7 @@ static void free_attr_elem(struct attr_stack *e)
 }
 
 static const char *builtin_attr[] = {
-       "[attr]binary -diff -crlf",
+       "[attr]binary -diff -text",
        NULL,
 };
 
diff --git a/attr.h b/attr.h
index 450f49d648a013ffddc6321b7fd79b3fc1b66f7a..8b3f19be67f17c1fbf6edb37ac3ea27002ca6415 100644 (file)
--- a/attr.h
+++ b/attr.h
@@ -34,7 +34,7 @@ int git_checkattr(const char *path, int, struct git_attr_check *);
 enum git_attr_direction {
        GIT_ATTR_CHECKIN,
        GIT_ATTR_CHECKOUT,
-       GIT_ATTR_INDEX,
+       GIT_ATTR_INDEX
 };
 void git_attr_set_direction(enum git_attr_direction, struct index_state *);
 
index d8934757a5e5e259f26c4a09f7ea5d10615df0c1..c0054a0b0a441090184a141ee73954a94a2904d5 100644 (file)
@@ -70,6 +70,7 @@
  */
 
 #if defined(__i386__) || defined(__x86_64__) || \
+    defined(_M_IX86) || defined(_M_X64) || \
     defined(__ppc__) || defined(__ppc64__) || \
     defined(__powerpc__) || defined(__powerpc64__) || \
     defined(__s390__) || defined(__s390x__)
@@ -236,13 +237,13 @@ void blk_SHA1_Init(blk_SHA_CTX *ctx)
 
 void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len)
 {
-       int lenW = ctx->size & 63;
+       unsigned int lenW = ctx->size & 63;
 
        ctx->size += len;
 
        /* Read the data into W and process blocks as they get full */
        if (lenW) {
-               int left = 64 - lenW;
+               unsigned int left = 64 - lenW;
                if (len < left)
                        left = len;
                memcpy(lenW + (char *)ctx->W, data, left);
@@ -269,8 +270,8 @@ void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx)
        int i;
 
        /* Pad with a binary 1 (ie 0x80), then zeroes, then length */
-       padlen[0] = htonl(ctx->size >> 29);
-       padlen[1] = htonl(ctx->size << 3);
+       padlen[0] = htonl((uint32_t)(ctx->size >> 29));
+       padlen[1] = htonl((uint32_t)(ctx->size << 3));
 
        i = ctx->size & 63;
        blk_SHA1_Update(ctx, pad, 1+ (63 & (55 - i)));
index 5c887ef61bbf67411a81691c67fc14cc4e0bc682..ed6ee26933430e1db4e29e62badfaf0b217935ad 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -16,19 +16,20 @@ extern const char *help_unknown_cmd(const char *cmd);
 extern void prune_packed_objects(int);
 extern int fmt_merge_msg(int merge_summary, struct strbuf *in,
        struct strbuf *out);
+extern int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out);
 extern int commit_notes(struct notes_tree *t, const char *msg);
 
 struct notes_rewrite_cfg {
        struct notes_tree **trees;
        const char *cmd;
        int enabled;
-       combine_notes_fn *combine;
+       combine_notes_fn combine;
        struct string_list *refs;
        int refs_from_env;
        int mode_from_env;
 };
 
-combine_notes_fn *parse_combine_notes_fn(const char *v);
+combine_notes_fn parse_combine_notes_fn(const char *v);
 struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd);
 int copy_note_for_rewrite(struct notes_rewrite_cfg *c,
                          const unsigned char *from_obj, const unsigned char *to_obj);
@@ -36,6 +37,8 @@ void finish_copy_notes_for_rewrite(struct notes_rewrite_cfg *c);
 
 extern int check_pager_config(const char *cmd);
 
+extern int textconv_object(const char *path, const unsigned char *sha1, char **buf, unsigned long *buf_size);
+
 extern int cmd_add(int argc, const char **argv, const char *prefix);
 extern int cmd_annotate(int argc, const char **argv, const char *prefix);
 extern int cmd_apply(int argc, const char **argv, const char *prefix);
index 87d2980313e71afc08df3eacde4a99a8468ff874..17149cfeedcc39956dc55f8b72acc1227fed5213 100644 (file)
@@ -261,12 +261,14 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 {
        char *file = xstrdup(git_path("ADD_EDIT.patch"));
        const char *apply_argv[] = { "apply", "--recount", "--cached",
-               file, NULL };
+               NULL, NULL };
        struct child_process child;
        struct rev_info rev;
        int out;
        struct stat st;
 
+       apply_argv[3] = file;
+
        git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 
        if (read_cache() < 0)
index 03639282e1cc3e14d83043047a174bd71a776db3..12ef9ea8afb0aa1e554e3ce6c6085e97ff7e7466 100644 (file)
@@ -56,7 +56,7 @@ static enum ws_error_action {
        nowarn_ws_error,
        warn_on_ws_error,
        die_on_ws_error,
-       correct_ws_error,
+       correct_ws_error
 } ws_error_action = warn_on_ws_error;
 static int whitespace_error;
 static int squelch_whitespace_errors = 5;
@@ -64,7 +64,7 @@ static int applied_after_fixing_ws;
 
 static enum ws_ignore {
        ignore_ws_none,
-       ignore_ws_change,
+       ignore_ws_change
 } ws_ignore_action = ignore_ws_none;
 
 
index fc1586350f94ae48e7e48a51818517b465e7a40d..01e62fdeb00b2d085efe96a07f2ee77776081a69 100644 (file)
@@ -20,6 +20,7 @@
 #include "mailmap.h"
 #include "parse-options.h"
 #include "utf8.h"
+#include "userdiff.h"
 
 static char blame_usage[] = "git blame [options] [rev-opts] [rev] [--] file";
 
@@ -39,7 +40,7 @@ static int show_root;
 static int reverse;
 static int blank_boundary;
 static int incremental;
-static int xdl_opts = XDF_NEED_MINIMAL;
+static int xdl_opts;
 
 static enum date_mode blame_date_mode = DATE_ISO8601;
 static size_t blame_date_width;
@@ -85,17 +86,51 @@ struct origin {
        char path[FLEX_ARRAY];
 };
 
+/*
+ * Prepare diff_filespec and convert it using diff textconv API
+ * if the textconv driver exists.
+ * Return 1 if the conversion succeeds, 0 otherwise.
+ */
+int textconv_object(const char *path,
+                   const unsigned char *sha1,
+                   char **buf,
+                   unsigned long *buf_size)
+{
+       struct diff_filespec *df;
+       struct userdiff_driver *textconv;
+
+       df = alloc_filespec(path);
+       fill_filespec(df, sha1, S_IFREG | 0664);
+       textconv = get_textconv(df);
+       if (!textconv) {
+               free_filespec(df);
+               return 0;
+       }
+
+       *buf_size = fill_textconv(textconv, df, buf);
+       free_filespec(df);
+       return 1;
+}
+
 /*
  * Given an origin, prepare mmfile_t structure to be used by the
  * diff machinery
  */
-static void fill_origin_blob(struct origin *o, mmfile_t *file)
+static void fill_origin_blob(struct diff_options *opt,
+                            struct origin *o, mmfile_t *file)
 {
        if (!o->file.ptr) {
                enum object_type type;
+               unsigned long file_size;
+
                num_read_blob++;
-               file->ptr = read_sha1_file(o->blob_sha1, &type,
-                                          (unsigned long *)(&(file->size)));
+               if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&
+                   textconv_object(o->path, o->blob_sha1, &file->ptr, &file_size))
+                       ;
+               else
+                       file->ptr = read_sha1_file(o->blob_sha1, &type, &file_size);
+               file->size = file_size;
+
                if (!file->ptr)
                        die("Cannot read blob %s for path %s",
                            sha1_to_hex(o->blob_sha1),
@@ -282,7 +317,6 @@ static struct origin *get_origin(struct scoreboard *sb,
 static int fill_blob_sha1(struct origin *origin)
 {
        unsigned mode;
-
        if (!is_null_sha1(origin->blob_sha1))
                return 0;
        if (get_tree_entry(origin->commit->object.sha1,
@@ -733,16 +767,17 @@ static int pass_blame_to_parent(struct scoreboard *sb,
 {
        int last_in_target;
        mmfile_t file_p, file_o;
-       struct blame_chunk_cb_data d = { sb, target, parent, 0, 0 };
+       struct blame_chunk_cb_data d;
        xpparam_t xpp;
        xdemitconf_t xecfg;
-
+       memset(&d, 0, sizeof(d));
+       d.sb = sb; d.target = target; d.parent = parent;
        last_in_target = find_last_in_target(sb, target);
        if (last_in_target < 0)
                return 1; /* nothing remains for this target */
 
-       fill_origin_blob(parent, &file_p);
-       fill_origin_blob(target, &file_o);
+       fill_origin_blob(&sb->revs->diffopt, parent, &file_p);
+       fill_origin_blob(&sb->revs->diffopt, target, &file_o);
        num_get_patch++;
 
        memset(&xpp, 0, sizeof(xpp));
@@ -875,10 +910,11 @@ static void find_copy_in_blob(struct scoreboard *sb,
        const char *cp;
        int cnt;
        mmfile_t file_o;
-       struct handle_split_cb_data d = { sb, ent, parent, split, 0, 0 };
+       struct handle_split_cb_data d;
        xpparam_t xpp;
        xdemitconf_t xecfg;
-
+       memset(&d, 0, sizeof(d));
+       d.sb = sb; d.ent = ent; d.parent = parent; d.split = split;
        /*
         * Prepare mmfile that contains only the lines in ent.
         */
@@ -922,7 +958,7 @@ static int find_move_in_parent(struct scoreboard *sb,
        if (last_in_target < 0)
                return 1; /* nothing remains for this target */
 
-       fill_origin_blob(parent, &file_p);
+       fill_origin_blob(&sb->revs->diffopt, parent, &file_p);
        if (!file_p.ptr)
                return 0;
 
@@ -1063,7 +1099,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
 
                        norigin = get_origin(sb, parent, p->one->path);
                        hashcpy(norigin->blob_sha1, p->one->sha1);
-                       fill_origin_blob(norigin, &file_p);
+                       fill_origin_blob(&sb->revs->diffopt, norigin, &file_p);
                        if (!file_p.ptr)
                                continue;
 
@@ -1589,7 +1625,7 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)
        strcpy(hex, sha1_to_hex(suspect->commit->object.sha1));
        printf("%s%c%d %d %d\n",
               hex,
-              ent->guilty ? ' ' : '*', // purely for debugging
+              ent->guilty ? ' ' : '*', /* purely for debugging */
               ent->s_lno + 1,
               ent->lno + 1,
               ent->num_lines);
@@ -1983,6 +2019,16 @@ static int git_blame_config(const char *var, const char *value, void *cb)
                blame_date_mode = parse_date_format(value);
                return 0;
        }
+
+       switch (userdiff_config(var, value)) {
+       case 0:
+               break;
+       case -1:
+               return -1;
+       default:
+               return 0;
+       }
+
        return git_default_config(var, value, cb);
 }
 
@@ -1990,7 +2036,9 @@ static int git_blame_config(const char *var, const char *value, void *cb)
  * Prepare a dummy commit that represents the work tree (or staged) item.
  * Note that annotating work tree item never works in the reverse.
  */
-static struct commit *fake_working_tree_commit(const char *path, const char *contents_from)
+static struct commit *fake_working_tree_commit(struct diff_options *opt,
+                                              const char *path,
+                                              const char *contents_from)
 {
        struct commit *commit;
        struct origin *origin;
@@ -2018,6 +2066,7 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
        if (!contents_from || strcmp("-", contents_from)) {
                struct stat st;
                const char *read_from;
+               unsigned long buf_len;
 
                if (contents_from) {
                        if (stat(contents_from, &st) < 0)
@@ -2030,9 +2079,13 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
                        read_from = path;
                }
                mode = canon_mode(st.st_mode);
+
                switch (st.st_mode & S_IFMT) {
                case S_IFREG:
-                       if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
+                       if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&
+                           textconv_object(read_from, null_sha1, &buf.buf, &buf_len))
+                               buf.len = buf_len;
+                       else if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
                                die_errno("cannot open or read '%s'", read_from);
                        break;
                case S_IFLNK:
@@ -2248,6 +2301,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
        git_config(git_blame_config, NULL);
        init_revisions(&revs, NULL);
        revs.date_mode = blame_date_mode;
+       DIFF_OPT_SET(&revs.diffopt, ALLOW_TEXTCONV);
 
        save_commit_buffer = 0;
        dashdash_pos = 0;
@@ -2384,7 +2438,8 @@ parse_done:
                 * or "--contents".
                 */
                setup_work_tree();
-               sb.final = fake_working_tree_commit(path, contents_from);
+               sb.final = fake_working_tree_commit(&sb.revs->diffopt,
+                                                   path, contents_from);
                add_pending_object(&revs, &(sb.final->object), ":");
        }
        else if (contents_from)
@@ -2411,8 +2466,14 @@ parse_done:
                if (fill_blob_sha1(o))
                        die("no such path %s in %s", path, final_commit_name);
 
-               sb.final_buf = read_sha1_file(o->blob_sha1, &type,
-                                             &sb.final_buf_size);
+               if (DIFF_OPT_TST(&sb.revs->diffopt, ALLOW_TEXTCONV) &&
+                   textconv_object(path, o->blob_sha1, (char **) &sb.final_buf,
+                                   &sb.final_buf_size))
+                       ;
+               else
+                       sb.final_buf = read_sha1_file(o->blob_sha1, &type,
+                                                     &sb.final_buf_size);
+
                if (!sb.final_buf)
                        die("Cannot read blob %s for path %s",
                            sha1_to_hex(o->blob_sha1),
index 6cf7e721e6b59f50c7a8018296aa49848deecda3..87976f0921d87f2a8564eb54aa3b81d30ee7f214 100644 (file)
@@ -43,13 +43,13 @@ enum color_branch {
        BRANCH_COLOR_PLAIN = 1,
        BRANCH_COLOR_REMOTE = 2,
        BRANCH_COLOR_LOCAL = 3,
-       BRANCH_COLOR_CURRENT = 4,
+       BRANCH_COLOR_CURRENT = 4
 };
 
 static enum merge_filter {
        NO_FILTER = 0,
        SHOW_NOT_MERGED,
-       SHOW_MERGED,
+       SHOW_MERGED
 } merge_filter;
 static unsigned char merge_filter_ref[20];
 
@@ -257,9 +257,15 @@ static char *resolve_symref(const char *src, const char *prefix)
        return xstrdup(dst);
 }
 
+struct append_ref_cb {
+       struct ref_list *ref_list;
+       int ret;
+};
+
 static int append_ref(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
 {
-       struct ref_list *ref_list = (struct ref_list*)(cb_data);
+       struct append_ref_cb *cb = (struct append_ref_cb *)(cb_data);
+       struct ref_list *ref_list = cb->ref_list;
        struct ref_item *newitem;
        struct commit *commit;
        int kind, i;
@@ -293,8 +299,10 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
        commit = NULL;
        if (ref_list->verbose || ref_list->with_commit || merge_filter != NO_FILTER) {
                commit = lookup_commit_reference_gently(sha1, 1);
-               if (!commit)
-                       return error("branch '%s' does not point at a commit", refname);
+               if (!commit) {
+                       cb->ret = error("branch '%s' does not point at a commit", refname);
+                       return 0;
+               }
 
                /* Filter with with_commit if specified */
                if (!is_descendant_of(commit, ref_list->with_commit))
@@ -484,9 +492,10 @@ static void show_detached(struct ref_list *ref_list)
        }
 }
 
-static void print_ref_list(int kinds, int detached, int verbose, int abbrev, struct commit_list *with_commit)
+static int print_ref_list(int kinds, int detached, int verbose, int abbrev, struct commit_list *with_commit)
 {
        int i;
+       struct append_ref_cb cb;
        struct ref_list ref_list;
 
        memset(&ref_list, 0, sizeof(ref_list));
@@ -496,7 +505,9 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev, str
        ref_list.with_commit = with_commit;
        if (merge_filter != NO_FILTER)
                init_revisions(&ref_list.revs, NULL);
-       for_each_rawref(append_ref, &ref_list);
+       cb.ref_list = &ref_list;
+       cb.ret = 0;
+       for_each_rawref(append_ref, &cb);
        if (merge_filter != NO_FILTER) {
                struct commit *filter;
                filter = lookup_commit_reference_gently(merge_filter_ref, 0);
@@ -527,6 +538,11 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev, str
        }
 
        free_ref_list(&ref_list);
+
+       if (cb.ret)
+               error("some refs could not be read");
+
+       return cb.ret;
 }
 
 static void rename_branch(const char *oldname, const char *newname, int force)
@@ -679,7 +695,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
        if (delete)
                return delete_branches(argc, argv, delete > 1, kinds);
        else if (argc == 0)
-               print_ref_list(kinds, detached, verbose, abbrev, with_commit);
+               return print_ref_list(kinds, detached, verbose, abbrev, with_commit);
        else if (rename && (argc == 1))
                rename_branch(head, argv[0], rename > 1);
        else if (rename && (argc == 2))
index a933eaa043257c84f35e1d86728ca91be035caff..76ec3fec9279f38520fa4b5b525ce2c03cc9cbb0 100644 (file)
@@ -9,6 +9,8 @@
 #include "tree.h"
 #include "builtin.h"
 #include "parse-options.h"
+#include "diff.h"
+#include "userdiff.h"
 
 #define BATCH 1
 #define BATCH_CHECK 2
@@ -84,10 +86,11 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
 {
        unsigned char sha1[20];
        enum object_type type;
-       void *buf;
+       char *buf;
        unsigned long size;
+       struct object_context obj_context;
 
-       if (get_sha1(obj_name, sha1))
+       if (get_sha1_with_context(obj_name, sha1, &obj_context))
                die("Not a valid object name %s", obj_name);
 
        buf = NULL;
@@ -118,7 +121,9 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
 
                /* custom pretty-print here */
                if (type == OBJ_TREE) {
-                       const char *ls_args[3] = {"ls-tree", obj_name, NULL};
+                       const char *ls_args[3] = { NULL };
+                       ls_args[0] =  "ls-tree";
+                       ls_args[1] =  obj_name;
                        return cmd_ls_tree(2, ls_args, NULL);
                }
 
@@ -132,6 +137,17 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
 
                /* otherwise just spit out the data */
                break;
+
+       case 'c':
+               if (!obj_context.path[0])
+                       die("git cat-file --textconv %s: <object> must be <sha1:path>",
+                           obj_name);
+
+               if (!textconv_object(obj_context.path, sha1, &buf, &size))
+                       die("git cat-file --textconv: unable to run textconv on %s",
+                           obj_name);
+               break;
+
        case 0:
                buf = read_object_with_reference(sha1, exp_type, &size, NULL);
                break;
@@ -201,11 +217,25 @@ static int batch_objects(int print_contents)
 }
 
 static const char * const cat_file_usage[] = {
-       "git cat-file (-t|-s|-e|-p|<type>) <object>",
+       "git cat-file (-t|-s|-e|-p|<type>|--textconv) <object>",
        "git cat-file (--batch|--batch-check) < <list_of_objects>",
        NULL
 };
 
+static int git_cat_file_config(const char *var, const char *value, void *cb)
+{
+       switch (userdiff_config(var, value)) {
+       case 0:
+               break;
+       case -1:
+               return -1;
+       default:
+               return 0;
+       }
+
+       return git_default_config(var, value, cb);
+}
+
 int cmd_cat_file(int argc, const char **argv, const char *prefix)
 {
        int opt = 0, batch = 0;
@@ -218,6 +248,8 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
                OPT_SET_INT('e', NULL, &opt,
                            "exit with zero when there's no error", 'e'),
                OPT_SET_INT('p', NULL, &opt, "pretty-print object's content", 'p'),
+               OPT_SET_INT(0, "textconv", &opt,
+                           "for blob objects, run textconv on object's content", 'c'),
                OPT_SET_INT(0, "batch", &batch,
                            "show info and content of objects fed from the standard input",
                            BATCH),
@@ -227,7 +259,7 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
                OPT_END()
        };
 
-       git_config(git_default_config, NULL);
+       git_config(git_cat_file_config, NULL);
 
        if (argc != 3 && argc != 2)
                usage_with_options(cat_file_usage, options);
index c3825219c1efbd4939af6d18bcad6efcfa74f406..1994be92c66257da18c31502bda605be170fd092 100644 (file)
@@ -493,7 +493,24 @@ static void update_refs_for_switch(struct checkout_opts *opts,
        struct strbuf msg = STRBUF_INIT;
        const char *old_desc;
        if (opts->new_branch) {
-               if (!opts->new_orphan_branch)
+               if (opts->new_orphan_branch) {
+                       if (opts->new_branch_log && !log_all_ref_updates) {
+                               int temp;
+                               char log_file[PATH_MAX];
+                               char *ref_name = mkpath("refs/heads/%s", opts->new_orphan_branch);
+
+                               temp = log_all_ref_updates;
+                               log_all_ref_updates = 1;
+                               if (log_ref_setup(ref_name, log_file, sizeof(log_file))) {
+                                       fprintf(stderr, "Can not do reflog for '%s'\n",
+                                           opts->new_orphan_branch);
+                                       log_all_ref_updates = temp;
+                                       return;
+                               }
+                               log_all_ref_updates = temp;
+                       }
+               }
+               else
                        create_branch(old->name, opts->new_branch, new->name, 0,
                                      opts->new_branch_log, opts->track);
                new->name = opts->new_branch;
@@ -517,6 +534,14 @@ static void update_refs_for_switch(struct checkout_opts *opts,
                                        opts->new_branch ? " a new" : "",
                                        new->name);
                }
+               if (old->path && old->name) {
+                       char log_file[PATH_MAX], ref_file[PATH_MAX];
+
+                       git_snpath(log_file, sizeof(log_file), "logs/%s", old->path);
+                       git_snpath(ref_file, sizeof(ref_file), "%s", old->path);
+                       if (!file_exists(ref_file) && file_exists(log_file))
+                               remove_path(log_file);
+               }
        } else if (strcmp(new->name, "HEAD")) {
                update_ref(msg.buf, "HEAD", new->commit->object.sha1, NULL,
                           REF_NODEREF, DIE_ON_ERR);
@@ -611,7 +636,8 @@ static int check_tracking_name(const char *refname, const unsigned char *sha1,
 
 static const char *unique_tracking_name(const char *name)
 {
-       struct tracking_name_data cb_data = { name, NULL, 1 };
+       struct tracking_name_data cb_data = { NULL, NULL, 1 };
+       cb_data.name = name;
        for_each_ref(check_tracking_name, &cb_data);
        if (cb_data.unique)
                return cb_data.remote;
@@ -684,8 +710,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
        if (opts.new_orphan_branch) {
                if (opts.new_branch)
                        die("--orphan and -b are mutually exclusive");
-               if (opts.track > 0 || opts.new_branch_log)
-                       die("--orphan cannot be used with -t or -l");
+               if (opts.track > 0)
+                       die("--orphan cannot be used with -t");
                opts.new_branch = opts.new_orphan_branch;
        }
 
index 44579224270c194a0ab4a90280515ec55e3b6842..efb1e6faa539935de0e9dc590237185a1d222322 100644 (file)
@@ -464,7 +464,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        set_git_dir(make_absolute_path(git_dir));
 
        if (0 <= option_verbosity)
-               printf("Cloning into %s...\n", get_git_dir());
+               printf("Cloning into %s%s...\n",
+                      option_bare ? "bare repository " : "", dir);
        init_db(option_template, INIT_DB_QUIET);
 
        /*
index 763fe74b905f28a2061fa1da16b935d3bf4d5fd4..a78dbd83bf04c7080487b8508321d79d848e9b1f 100644 (file)
@@ -48,6 +48,11 @@ static const char implicit_ident_advice[] =
 "\n"
 "    git commit --amend --author='Your Name <you@example.com>'\n";
 
+static const char empty_amend_advice[] =
+"You asked to amend the most recent commit, but doing so would make\n"
+"it empty. You can repeat your command with --allow-empty, or you can\n"
+"remove the commit entirely with \"git reset HEAD^\".\n";
+
 static unsigned char head_sha1[20];
 
 static char *use_message_buffer;
@@ -57,7 +62,7 @@ static struct lock_file false_lock; /* used only for partial commits */
 static enum {
        COMMIT_AS_IS = 1,
        COMMIT_NORMAL,
-       COMMIT_PARTIAL,
+       COMMIT_PARTIAL
 } commit_style;
 
 static const char *logfile, *force_author;
@@ -67,7 +72,7 @@ static char *author_name, *author_email, *author_date;
 static int all, edit_flag, also, interactive, only, amend, signoff;
 static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
 static int no_post_rewrite, allow_empty_message;
-static char *untracked_files_arg, *force_date;
+static char *untracked_files_arg, *force_date, *ignore_submodule_arg;
 /*
  * The default commit message cleanup mode will remove the lines
  * beginning with # (shell comments) and leading and trailing
@@ -78,7 +83,7 @@ static char *untracked_files_arg, *force_date;
 static enum {
        CLEANUP_SPACE,
        CLEANUP_NONE,
-       CLEANUP_ALL,
+       CLEANUP_ALL
 } cleanup_mode;
 static char *cleanup_arg;
 
@@ -91,8 +96,9 @@ static int null_termination;
 static enum {
        STATUS_FORMAT_LONG,
        STATUS_FORMAT_SHORT,
-       STATUS_FORMAT_PORCELAIN,
+       STATUS_FORMAT_PORCELAIN
 } status_format = STATUS_FORMAT_LONG;
+static int status_show_branch;
 
 static int opt_parse_m(const struct option *opt, const char *arg, int unset)
 {
@@ -134,6 +140,7 @@ static struct option builtin_commit_options[] = {
        OPT_BOOLEAN(0, "dry-run", &dry_run, "show what would be committed"),
        OPT_SET_INT(0, "short", &status_format, "show status concisely",
                    STATUS_FORMAT_SHORT),
+       OPT_BOOLEAN(0, "branch", &status_show_branch, "show branch information"),
        OPT_SET_INT(0, "porcelain", &status_format,
                    "show porcelain output format", STATUS_FORMAT_PORCELAIN),
        OPT_BOOLEAN('z', "null", &null_termination,
@@ -336,9 +343,13 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
        if (!pathspec || !*pathspec) {
                fd = hold_locked_index(&index_lock, 1);
                refresh_cache_or_die(refresh_flags);
-               if (write_cache(fd, active_cache, active_nr) ||
-                   commit_locked_index(&index_lock))
-                       die("unable to write new_index file");
+               if (active_cache_changed) {
+                       if (write_cache(fd, active_cache, active_nr) ||
+                           commit_locked_index(&index_lock))
+                               die("unable to write new_index file");
+               } else {
+                       rollback_lock_file(&index_lock);
+               }
                commit_style = COMMIT_AS_IS;
                return get_index_file();
        }
@@ -424,7 +435,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
 
        switch (status_format) {
        case STATUS_FORMAT_SHORT:
-               wt_shortstatus_print(s, null_termination);
+               wt_shortstatus_print(s, null_termination, status_show_branch);
                break;
        case STATUS_FORMAT_PORCELAIN:
                wt_porcelain_print(s, null_termination);
@@ -462,15 +473,21 @@ static void determine_author_info(void)
                if (!a)
                        die("invalid commit: %s", use_message);
 
-               lb = strstr(a + 8, " <");
-               rb = strstr(a + 8, "> ");
-               eol = strchr(a + 8, '\n');
-               if (!lb || !rb || !eol)
+               lb = strchrnul(a + strlen("\nauthor "), '<');
+               rb = strchrnul(lb, '>');
+               eol = strchrnul(rb, '\n');
+               if (!*lb || !*rb || !*eol)
                        die("invalid commit: %s", use_message);
 
-               name = xstrndup(a + 8, lb - (a + 8));
-               email = xstrndup(lb + 2, rb - (lb + 2));
-               date = xstrndup(rb + 2, eol - (rb + 2));
+               if (lb == a + strlen("\nauthor "))
+                       /* \nauthor <foo@example.com> */
+                       name = xcalloc(1, 1);
+               else
+                       name = xmemdupz(a + strlen("\nauthor "),
+                                       (lb - strlen(" ") -
+                                        (a + strlen("\nauthor "))));
+               email = xmemdupz(lb + strlen("<"), rb - (lb + strlen("<")));
+               date = xmemdupz(rb + strlen("> "), eol - (rb + strlen("> ")));
        }
 
        if (force_author) {
@@ -700,6 +717,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
        if (!commitable && !in_merge && !allow_empty &&
            !(amend && is_a_merge(head_sha1))) {
                run_status(stdout, index_file, prefix, 0, s);
+               if (amend)
+                       fputs(empty_amend_advice, stderr);
                return 0;
        }
 
@@ -724,7 +743,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 
        if (use_editor) {
                char index[PATH_MAX];
-               const char *env[2] = { index, NULL };
+               const char *env[2] = { NULL };
+               env[0] =  index;
                snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
                if (launch_editor(git_path(commit_editmsg), NULL, env)) {
                        fprintf(stderr,
@@ -1030,6 +1050,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
                OPT__VERBOSE(&verbose),
                OPT_SET_INT('s', "short", &status_format,
                            "show status concisely", STATUS_FORMAT_SHORT),
+               OPT_BOOLEAN('b', "branch", &status_show_branch,
+                           "show branch information"),
                OPT_SET_INT(0, "porcelain", &status_format,
                            "show porcelain output format",
                            STATUS_FORMAT_PORCELAIN),
@@ -1041,6 +1063,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
                  PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
                OPT_BOOLEAN(0, "ignored", &show_ignored_in_status,
                            "show ignored files"),
+               { OPTION_STRING, 0, "ignore-submodules", &ignore_submodule_arg, "when",
+                 "ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)",
+                 PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
                OPT_END(),
        };
 
@@ -1064,13 +1089,16 @@ int cmd_status(int argc, const char **argv, const char *prefix)
 
        fd = hold_locked_index(&index_lock, 0);
        if (0 <= fd) {
-               if (!write_cache(fd, active_cache, active_nr))
+               if (active_cache_changed &&
+                   !write_cache(fd, active_cache, active_nr))
                        commit_locked_index(&index_lock);
-               rollback_lock_file(&index_lock);
+               else
+                       rollback_lock_file(&index_lock);
        }
 
        s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
        s.in_merge = in_merge;
+       s.ignore_submodule_arg = ignore_submodule_arg;
        wt_status_collect(&s);
 
        if (s.relative_paths)
@@ -1082,13 +1110,14 @@ int cmd_status(int argc, const char **argv, const char *prefix)
 
        switch (status_format) {
        case STATUS_FORMAT_SHORT:
-               wt_shortstatus_print(&s, null_termination);
+               wt_shortstatus_print(&s, null_termination, status_show_branch);
                break;
        case STATUS_FORMAT_PORCELAIN:
                wt_porcelain_print(&s, null_termination);
                break;
        case STATUS_FORMAT_LONG:
                s.verbose = verbose;
+               s.ignore_submodule_arg = ignore_submodule_arg;
                wt_status_print(&s);
                break;
        }
@@ -1157,13 +1186,11 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
                initial_commit ? " (root-commit)" : "");
 
        if (!log_tree_commit(&rev, commit)) {
-               struct pretty_print_context ctx = {0};
-               struct strbuf buf = STRBUF_INIT;
-               ctx.date_mode = DATE_NORMAL;
-               format_commit_message(commit, format.buf + 7, &buf, &ctx);
-               printf("%s\n", buf.buf);
-               strbuf_release(&buf);
+               rev.always_show_header = 1;
+               rev.use_terminator = 1;
+               log_tree_commit(&rev, commit);
        }
+
        strbuf_release(&format);
 }
 
@@ -1251,13 +1278,16 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        }
 
        /* Determine parents */
+       reflog_msg = getenv("GIT_REFLOG_ACTION");
        if (initial_commit) {
-               reflog_msg = "commit (initial)";
+               if (!reflog_msg)
+                       reflog_msg = "commit (initial)";
        } else if (amend) {
                struct commit_list *c;
                struct commit *commit;
 
-               reflog_msg = "commit (amend)";
+               if (!reflog_msg)
+                       reflog_msg = "commit (amend)";
                commit = lookup_commit(head_sha1);
                if (!commit || parse_commit(commit))
                        die("could not parse HEAD commit");
@@ -1268,7 +1298,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                struct strbuf m = STRBUF_INIT;
                FILE *fp;
 
-               reflog_msg = "commit (merge)";
+               if (!reflog_msg)
+                       reflog_msg = "commit (merge)";
                pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
                fp = fopen(git_path("MERGE_HEAD"), "r");
                if (fp == NULL)
@@ -1291,7 +1322,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                if (allow_fast_forward)
                        parents = reduce_heads(parents);
        } else {
-               reflog_msg = "commit";
+               if (!reflog_msg)
+                       reflog_msg = "commit";
                pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
        }
 
index c5e24b50ec73d181bc67a0702d84b96748c3fbb5..6eb1dfea092e2873c5910bf4389d3b071786d8b0 100644 (file)
@@ -574,9 +574,10 @@ static void find_non_local_tags(struct transport *transport,
 {
        struct string_list existing_refs = { NULL, 0, 0, 0 };
        struct string_list remote_refs = { NULL, 0, 0, 0 };
-       struct tag_data data = {head, tail};
+       struct tag_data data;
        const struct ref *ref;
        struct string_list_item *item = NULL;
+       data.head = head; data.tail = tail;
 
        for_each_ref(add_existing, &existing_refs);
        for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
@@ -778,7 +779,8 @@ static int get_remote_group(const char *key, const char *value, void *priv)
 static int add_remote_or_group(const char *name, struct string_list *list)
 {
        int prev_nr = list->nr;
-       struct remote_group_data g = { name, list };
+       struct remote_group_data g;
+       g.name = name; g.list = list;
 
        git_config(get_remote_group, &g);
        if (list->nr == prev_nr) {
index 601201264ed0cd6f331c6517efa3e6a1504002bd..bc3c5e6d3ec50eaa9829358ee0a82a1438c19f89 100644 (file)
@@ -202,35 +202,10 @@ static void shortlog(const char *name, unsigned char *sha1,
        string_list_clear(&subjects, 0);
 }
 
-int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
-       int limit = 20, i = 0, pos = 0;
+static void do_fmt_merge_msg_title(struct strbuf *out,
+       const char *current_branch) {
+       int i = 0;
        char *sep = "";
-       unsigned char head_sha1[20];
-       const char *current_branch;
-
-       /* get current branch */
-       current_branch = resolve_ref("HEAD", head_sha1, 1, NULL);
-       if (!current_branch)
-               die("No current branch");
-       if (!prefixcmp(current_branch, "refs/heads/"))
-               current_branch += 11;
-
-       /* get a line */
-       while (pos < in->len) {
-               int len;
-               char *newline, *p = in->buf + pos;
-
-               newline = strchr(p, '\n');
-               len = newline ? newline - p : strlen(p);
-               pos += len + !!newline;
-               i++;
-               p[len] = 0;
-               if (handle_line(p))
-                       die ("Error in line %d: %.*s", i, len, p);
-       }
-
-       if (!srcs.nr)
-               return 0;
 
        strbuf_addstr(out, "Merge ");
        for (i = 0; i < srcs.nr; i++) {
@@ -278,6 +253,40 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
                strbuf_addch(out, '\n');
        else
                strbuf_addf(out, " into %s\n", current_branch);
+}
+
+static int do_fmt_merge_msg(int merge_title, int merge_summary,
+       struct strbuf *in, struct strbuf *out) {
+       int limit = 20, i = 0, pos = 0;
+       unsigned char head_sha1[20];
+       const char *current_branch;
+
+       /* get current branch */
+       current_branch = resolve_ref("HEAD", head_sha1, 1, NULL);
+       if (!current_branch)
+               die("No current branch");
+       if (!prefixcmp(current_branch, "refs/heads/"))
+               current_branch += 11;
+
+       /* get a line */
+       while (pos < in->len) {
+               int len;
+               char *newline, *p = in->buf + pos;
+
+               newline = strchr(p, '\n');
+               len = newline ? newline - p : strlen(p);
+               pos += len + !!newline;
+               i++;
+               p[len] = 0;
+               if (handle_line(p))
+                       die ("Error in line %d: %.*s", i, len, p);
+       }
+
+       if (!srcs.nr)
+               return 0;
+
+       if (merge_title)
+               do_fmt_merge_msg_title(out, current_branch);
 
        if (merge_summary) {
                struct commit *head;
@@ -289,6 +298,9 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
                rev.ignore_merges = 1;
                rev.limited = 1;
 
+               if (suffixcmp(out->buf, "\n"))
+                       strbuf_addch(out, '\n');
+
                for (i = 0; i < origins.nr; i++)
                        shortlog(origins.items[i].string, origins.items[i].util,
                                        head, &rev, limit, out);
@@ -296,6 +308,14 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
        return 0;
 }
 
+int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
+       return do_fmt_merge_msg(1, merge_summary, in, out);
+}
+
+int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out) {
+       return do_fmt_merge_msg(0, 1, in, out);
+}
+
 int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 {
        const char *inpath = NULL;
index 3a97953177eee234c310bbf37bab5f2d7e03e5aa..a2b28c6962be8ea6f8882bae3d4fde9d972e78d2 100644 (file)
@@ -552,10 +552,10 @@ static void grab_values(struct atom_value *val, int deref, struct object *obj, v
                grab_person("committer", val, deref, obj, buf, sz);
                break;
        case OBJ_TREE:
-               // grab_tree_values(val, deref, obj, buf, sz);
+               /* grab_tree_values(val, deref, obj, buf, sz); */
                break;
        case OBJ_BLOB:
-               // grab_blob_values(val, deref, obj, buf, sz);
+               /* grab_blob_values(val, deref, obj, buf, sz); */
                break;
        default:
                die("Eh?  Object of type %d?", obj->type);
index 7a9427d357cf54e02f7f251a509911a7e4a6c936..597f76bc42f51e0fc1906c287981e3d37dc0f536 100644 (file)
@@ -770,11 +770,15 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
        if (!patterns)
                die_errno("cannot open '%s'", arg);
        while (strbuf_getline(&sb, patterns, '\n') == 0) {
+               char *s;
+               size_t len;
+
                /* ignore empty line like grep does */
                if (sb.len == 0)
                        continue;
-               append_grep_pattern(grep_opt, strbuf_detach(&sb, NULL), arg,
-                                   ++lno, GREP_PATTERN);
+
+               s = strbuf_detach(&sb, &len);
+               append_grep_pat(grep_opt, s, len, arg, ++lno, GREP_PATTERN);
        }
        fclose(patterns);
        strbuf_release(&sb);
index 3182a2bec466c50a9a1db1e91888bad3335414b1..a9836b00aec8df68e7a615dce83d3c60f73e242f 100644 (file)
@@ -26,7 +26,7 @@ enum help_format {
        HELP_FORMAT_NONE,
        HELP_FORMAT_MAN,
        HELP_FORMAT_INFO,
-       HELP_FORMAT_WEB,
+       HELP_FORMAT_WEB
 };
 
 static int show_all = 0;
index 40bdd01e82136594f23472636373b081dd26bc98..08b872263cd646ec9d7dc8ad91273c71b1af2b69 100644 (file)
@@ -296,6 +296,9 @@ static int git_log_config(const char *var, const char *value, void *cb)
                default_show_root = git_config_bool(var, value);
                return 0;
        }
+       if (!prefixcmp(var, "color.decorate."))
+               return parse_decorate_color_config(var, 15, value);
+
        return git_diff_ui_config(var, value, cb);
 }
 
@@ -549,8 +552,9 @@ static void add_header(const char *value)
 
 #define THREAD_SHALLOW 1
 #define THREAD_DEEP 2
-static int thread = 0;
-static int do_signoff = 0;
+static int thread;
+static int do_signoff;
+static const char *signature = git_version_string;
 
 static int git_format_config(const char *var, const char *value, void *cb)
 {
@@ -609,6 +613,8 @@ static int git_format_config(const char *var, const char *value, void *cb)
                do_signoff = git_config_bool(var, value);
                return 0;
        }
+       if (!strcmp(var, "format.signature"))
+               return git_config_string(&signature, var, value);
 
        return git_log_config(var, value, cb);
 }
@@ -703,6 +709,12 @@ static void gen_message_id(struct rev_info *info, char *base)
        info->message_id = strbuf_detach(&buf, NULL);
 }
 
+static void print_signature(void)
+{
+       if (signature && *signature)
+               printf("-- \n%s\n\n", signature);
+}
+
 static void make_cover_letter(struct rev_info *rev, int use_stdout,
                              int numbered, int numbered_files,
                              struct commit *origin,
@@ -796,6 +808,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
        diff_flush(&opts);
 
        printf("\n");
+       print_signature();
 }
 
 static const char *clean_message_id(const char *msg_id)
@@ -1035,6 +1048,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                { OPTION_CALLBACK, 0, "thread", &thread, "style",
                            "enable message threading, styles: shallow, deep",
                            PARSE_OPT_OPTARG, thread_callback },
+               OPT_STRING(0, "signature", &signature, "signature",
+                           "add a signature"),
                OPT_END()
        };
 
@@ -1313,7 +1328,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                                       mime_boundary_leader,
                                       rev.mime_boundary);
                        else
-                               printf("-- \n%s\n\n", git_version_string);
+                               print_signature();
                }
                if (!use_stdout)
                        fclose(stdout);
index 3eeacdc6999249983e68add8a6c5745df90c647b..1b9b8a8b4ac2baff6b9676bcf23b148f147dac6a 100644 (file)
@@ -26,8 +26,9 @@ static int show_killed;
 static int show_valid_bit;
 static int line_terminator = '\n';
 
+static const char *prefix;
+static int max_prefix_len;
 static int prefix_len;
-static int prefix_offset;
 static const char **pathspec;
 static int error_unmatch;
 static char *ps_matched;
@@ -43,10 +44,15 @@ static const char *tag_modified = "";
 static const char *tag_skip_worktree = "";
 static const char *tag_resolve_undo = "";
 
+static void write_name(const char* name, size_t len)
+{
+       write_name_quoted_relative(name, len, prefix, prefix_len, stdout,
+                       line_terminator);
+}
+
 static void show_dir_entry(const char *tag, struct dir_entry *ent)
 {
-       int len = prefix_len;
-       int offset = prefix_offset;
+       int len = max_prefix_len;
 
        if (len >= ent->len)
                die("git ls-files: internal error - directory entry not superset of prefix");
@@ -55,7 +61,7 @@ static void show_dir_entry(const char *tag, struct dir_entry *ent)
                return;
 
        fputs(tag, stdout);
-       write_name_quoted(ent->name + offset, stdout, line_terminator);
+       write_name(ent->name, ent->len);
 }
 
 static void show_other_files(struct dir_struct *dir)
@@ -121,8 +127,7 @@ static void show_killed_files(struct dir_struct *dir)
 
 static void show_ce_entry(const char *tag, struct cache_entry *ce)
 {
-       int len = prefix_len;
-       int offset = prefix_offset;
+       int len = max_prefix_len;
 
        if (len >= ce_namelen(ce))
                die("git ls-files: internal error - cache entry not superset of prefix");
@@ -156,20 +161,19 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
                       find_unique_abbrev(ce->sha1,abbrev),
                       ce_stage(ce));
        }
-       write_name_quoted(ce->name + offset, stdout, line_terminator);
+       write_name(ce->name, ce_namelen(ce));
 }
 
 static int show_one_ru(struct string_list_item *item, void *cbdata)
 {
-       int offset = prefix_offset;
        const char *path = item->string;
        struct resolve_undo_info *ui = item->util;
        int i, len;
 
        len = strlen(path);
-       if (len < prefix_len)
+       if (len < max_prefix_len)
                return 0; /* outside of the prefix */
-       if (!match_pathspec(pathspec, path, len, prefix_len, ps_matched))
+       if (!match_pathspec(pathspec, path, len, max_prefix_len, ps_matched))
                return 0; /* uninterested */
        for (i = 0; i < 3; i++) {
                if (!ui->mode[i])
@@ -177,19 +181,19 @@ static int show_one_ru(struct string_list_item *item, void *cbdata)
                printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i],
                       find_unique_abbrev(ui->sha1[i], abbrev),
                       i + 1);
-               write_name_quoted(path + offset, stdout, line_terminator);
+               write_name(path, len);
        }
        return 0;
 }
 
-static void show_ru_info(const char *prefix)
+static void show_ru_info(void)
 {
        if (!the_index.resolve_undo)
                return;
        for_each_string_list(the_index.resolve_undo, show_one_ru, NULL);
 }
 
-static void show_files(struct dir_struct *dir, const char *prefix)
+static void show_files(struct dir_struct *dir)
 {
        int i;
 
@@ -243,7 +247,7 @@ static void show_files(struct dir_struct *dir, const char *prefix)
  */
 static void prune_cache(const char *prefix)
 {
-       int pos = cache_name_pos(prefix, prefix_len);
+       int pos = cache_name_pos(prefix, max_prefix_len);
        unsigned int first, last;
 
        if (pos < 0)
@@ -256,7 +260,7 @@ static void prune_cache(const char *prefix)
        while (last > first) {
                int next = (last + first) >> 1;
                struct cache_entry *ce = active_cache[next];
-               if (!strncmp(ce->name, prefix, prefix_len)) {
+               if (!strncmp(ce->name, prefix, max_prefix_len)) {
                        first = next+1;
                        continue;
                }
@@ -265,11 +269,16 @@ static void prune_cache(const char *prefix)
        active_nr = last;
 }
 
-static const char *verify_pathspec(const char *prefix)
+static const char *pathspec_prefix(const char *prefix)
 {
        const char **p, *n, *prev;
        unsigned long max;
 
+       if (!pathspec) {
+               max_prefix_len = prefix ? strlen(prefix) : 0;
+               return prefix;
+       }
+
        prev = NULL;
        max = PATH_MAX;
        for (p = pathspec; (n = *p) != NULL; p++) {
@@ -291,10 +300,7 @@ static const char *verify_pathspec(const char *prefix)
                }
        }
 
-       if (prefix_offset > max || memcmp(prev, prefix, prefix_offset))
-               die("git ls-files: cannot generate relative filenames containing '..'");
-
-       prefix_len = max;
+       max_prefix_len = max;
        return max ? xmemdupz(prev, max) : NULL;
 }
 
@@ -374,7 +380,7 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
        }
 }
 
-int report_path_error(const char *ps_matched, const char **pathspec, int prefix_offset)
+int report_path_error(const char *ps_matched, const char **pathspec, int prefix_len)
 {
        /*
         * Make sure all pathspec matched; otherwise it is an error.
@@ -404,7 +410,7 @@ int report_path_error(const char *ps_matched, const char **pathspec, int prefix_
                        continue;
 
                error("pathspec '%s' did not match any file(s) known to git.",
-                     pathspec[num] + prefix_offset);
+                     pathspec[num] + prefix_len);
                errors++;
        }
        return errors;
@@ -456,9 +462,10 @@ static int option_parse_exclude_standard(const struct option *opt,
        return 0;
 }
 
-int cmd_ls_files(int argc, const char **argv, const char *prefix)
+int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 {
        int require_work_tree = 0, show_tag = 0;
+       const char *max_prefix;
        struct dir_struct dir;
        struct option builtin_ls_files_options[] = {
                { OPTION_CALLBACK, 'z', NULL, NULL, NULL,
@@ -504,7 +511,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
                { OPTION_CALLBACK, 0, "exclude-standard", &dir, NULL,
                        "add the standard git exclusions",
                        PARSE_OPT_NOARG, option_parse_exclude_standard },
-               { OPTION_SET_INT, 0, "full-name", &prefix_offset, NULL,
+               { OPTION_SET_INT, 0, "full-name", &prefix_len, NULL,
                        "make the output relative to the project top directory",
                        PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL },
                OPT_BOOLEAN(0, "error-unmatch", &error_unmatch,
@@ -516,8 +523,9 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
        };
 
        memset(&dir, 0, sizeof(dir));
+       prefix = cmd_prefix;
        if (prefix)
-               prefix_offset = strlen(prefix);
+               prefix_len = strlen(prefix);
        git_config(git_default_config, NULL);
 
        if (read_cache() < 0)
@@ -555,9 +563,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
        if (pathspec)
                strip_trailing_slash_from_submodules();
 
-       /* Verify that the pathspec matches the prefix */
-       if (pathspec)
-               prefix = verify_pathspec(prefix);
+       /* Find common prefix for all pathspec's */
+       max_prefix = pathspec_prefix(prefix);
 
        /* Treat unmatching pathspec elements as errors */
        if (pathspec && error_unmatch) {
@@ -575,8 +582,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
              show_killed | show_modified | show_resolve_undo))
                show_cached = 1;
 
-       if (prefix)
-               prune_cache(prefix);
+       if (max_prefix)
+               prune_cache(max_prefix);
        if (with_tree) {
                /*
                 * Basic sanity check; show-stages and show-unmerged
@@ -584,15 +591,15 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
                 */
                if (show_stage || show_unmerged)
                        die("ls-files --with-tree is incompatible with -s or -u");
-               overlay_tree_on_cache(with_tree, prefix);
+               overlay_tree_on_cache(with_tree, max_prefix);
        }
-       show_files(&dir, prefix);
+       show_files(&dir);
        if (show_resolve_undo)
-               show_ru_info(prefix);
+               show_ru_info();
 
        if (ps_matched) {
                int bad;
-               bad = report_path_error(ps_matched, pathspec, prefix_offset);
+               bad = report_path_error(ps_matched, pathspec, prefix_len);
                if (bad)
                        fprintf(stderr, "Did you forget to 'git add'?\n");
 
index 8ee91eb547c2bafedd573045c977cc7d0469c95f..34480cfad6a8842d65ae61f6257c597a2a987b33 100644 (file)
@@ -5,7 +5,7 @@
 
 static const char ls_remote_usage[] =
 "git ls-remote [--heads] [--tags]  [-u <exec> | --upload-pack <exec>]\n"
-"                     [<repository> [<refs>...]]";
+"                     [-q|--quiet] [<repository> [<refs>...]]";
 
 /*
  * Is there one among the list of patterns that match the tail part
@@ -34,6 +34,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
        const char *dest = NULL;
        int nongit;
        unsigned flags = 0;
+       int quiet = 0;
        const char *uploadpack = NULL;
        const char **pattern = NULL;
 
@@ -67,6 +68,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
                                flags |= REF_NORMAL;
                                continue;
                        }
+                       if (!strcmp("--quiet", arg) || !strcmp("-q", arg)) {
+                               quiet = 1;
+                               continue;
+                       }
                        usage(ls_remote_usage);
                }
                dest = arg;
@@ -99,6 +104,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
        ref = transport_get_remote_refs(transport);
        if (transport_disconnect(transport))
                return 1;
+
+       if (!dest && !quiet)
+               fprintf(stderr, "From %s\n", *remote->url);
        for ( ; ref; ref = ref->next) {
                if (!check_ref_type(ref, flags))
                        continue;
index 4a9729b9b388a1e589e9250d8157e723c68140de..2320d981ceab220e287e42c21f3c9f3be5b3722f 100644 (file)
@@ -17,10 +17,10 @@ static struct strbuf name = STRBUF_INIT;
 static struct strbuf email = STRBUF_INIT;
 
 static enum  {
-       TE_DONTCARE, TE_QP, TE_BASE64,
+       TE_DONTCARE, TE_QP, TE_BASE64
 } transfer_encoding;
 static enum  {
-       TYPE_TEXT, TYPE_OTHER,
+       TYPE_TEXT, TYPE_OTHER
 } message_type;
 
 static struct strbuf charset = STRBUF_INIT;
index 610849a6533c6fd2d3d2e8d3f8d233757174aabd..b8e9e5ba01658bbdd6e9d712b00da902b6f33fbe 100644 (file)
@@ -25,7 +25,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
        const char *names[3] = { NULL, NULL, NULL };
        mmfile_t mmfs[3];
        mmbuffer_t result = {NULL, 0};
-       xmparam_t xmp = {{XDF_NEED_MINIMAL}};
+       xmparam_t xmp = {{0}};
        int ret = 0, i = 0, to_stdout = 0;
        int quiet = 0;
        int nongit;
index a4a4f2ce4c3f147062070c2acc08eaf9f4d40be8..fc00d794d641c146023a78d7d8e4143f0fdac302 100644 (file)
@@ -106,7 +106,7 @@ static void show_diff(struct merge_list *entry)
        xdemitconf_t xecfg;
        xdemitcb_t ecb;
 
-       xpp.flags = XDF_NEED_MINIMAL;
+       xpp.flags = 0;
        memset(&xecfg, 0, sizeof(xecfg));
        xecfg.ctxlen = 3;
        ecb.outf = show_outf;
index 37d414b3ba95162953aec001e6036956eb1a97f6..37ce4f589f6582abf0d1ef5bd263f590a16853d5 100644 (file)
@@ -982,7 +982,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                reset_hard(remote_head->sha1, 0);
                return 0;
        } else {
-               struct strbuf msg = STRBUF_INIT;
+               struct strbuf merge_names = STRBUF_INIT;
 
                /* We are invoked directly as the first-class UI. */
                head_arg = "HEAD";
@@ -995,13 +995,17 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                 * codepath so we discard the error in this
                 * loop.
                 */
-               if (!have_message) {
-                       for (i = 0; i < argc; i++)
-                               merge_name(argv[i], &msg);
-                       fmt_merge_msg(option_log, &msg, &merge_msg);
-                       if (merge_msg.len)
-                               strbuf_setlen(&merge_msg, merge_msg.len-1);
-               }
+               for (i = 0; i < argc; i++)
+                       merge_name(argv[i], &merge_names);
+
+               if (have_message && option_log)
+                       fmt_merge_msg_shortlog(&merge_names, &merge_msg);
+               else if (!have_message)
+                       fmt_merge_msg(option_log, &merge_names, &merge_msg);
+
+
+               if (!(have_message && !option_log) && merge_msg.len)
+                       strbuf_setlen(&merge_msg, merge_msg.len-1);
        }
 
        if (head_invalid || !argc)
index 52b72fca687d42dc09d1d79a8e76584a55c0c546..190005f3cd44a35a6fffb20b1e4c74622b4d93f7 100644 (file)
@@ -26,7 +26,7 @@ static const char * const git_notes_usage[] = {
        "git notes [--ref <notes_ref>] edit [<object>]",
        "git notes [--ref <notes_ref>] show [<object>]",
        "git notes [--ref <notes_ref>] remove [<object>]",
-       "git notes [--ref <notes_ref>] prune",
+       "git notes [--ref <notes_ref>] prune [-n | -v]",
        NULL
 };
 
@@ -67,7 +67,7 @@ static const char * const git_notes_remove_usage[] = {
 };
 
 static const char * const git_notes_prune_usage[] = {
-       "git notes prune",
+       "git notes prune [<options>]",
        NULL
 };
 
@@ -313,7 +313,7 @@ int commit_notes(struct notes_tree *t, const char *msg)
        return 0;
 }
 
-combine_notes_fn *parse_combine_notes_fn(const char *v)
+combine_notes_fn parse_combine_notes_fn(const char *v)
 {
        if (!strcasecmp(v, "overwrite"))
                return combine_notes_overwrite;
@@ -416,7 +416,7 @@ int notes_copy_from_stdin(int force, const char *rewrite_cmd)
 {
        struct strbuf buf = STRBUF_INIT;
        struct notes_rewrite_cfg *c = NULL;
-       struct notes_tree *t;
+       struct notes_tree *t = NULL;
        int ret = 0;
 
        if (rewrite_cmd) {
@@ -614,6 +614,10 @@ static int copy(int argc, const char **argv, const char *prefix)
                }
        }
 
+       if (argc < 2) {
+               error("too few parameters");
+               usage_with_options(git_notes_copy_usage, options);
+       }
        if (2 < argc) {
                error("too many parameters");
                usage_with_options(git_notes_copy_usage, options);
@@ -792,7 +796,10 @@ static int remove_cmd(int argc, const char **argv, const char *prefix)
 static int prune(int argc, const char **argv, const char *prefix)
 {
        struct notes_tree *t;
+       int show_only = 0, verbose = 0;
        struct option options[] = {
+               OPT_BOOLEAN('n', NULL, &show_only, "do not remove, show only"),
+               OPT_BOOLEAN('v', NULL, &verbose, "report pruned notes"),
                OPT_END()
        };
 
@@ -806,8 +813,10 @@ static int prune(int argc, const char **argv, const char *prefix)
 
        t = init_notes_check("prune");
 
-       prune_notes(t);
-       commit_notes(t, "Notes removed by 'git notes prune'");
+       prune_notes(t, (verbose ? NOTES_PRUNE_VERBOSE : 0) |
+               (show_only ? NOTES_PRUNE_VERBOSE|NOTES_PRUNE_DRYRUN : 0) );
+       if (!show_only)
+               commit_notes(t, "Notes removed by 'git notes prune'");
        free_notes(t);
        return 0;
 }
index 214d7ef2b12d41e8d70539fe4a4b16fde71a780a..0e8167311884d38c48a9421bf8aede89e7f2c22d 100644 (file)
@@ -1529,6 +1529,8 @@ static void try_to_free_from_threads(size_t size)
        read_unlock();
 }
 
+try_to_free_t old_try_to_free_routine;
+
 /*
  * The main thread waits on the condition that (at least) one of the workers
  * has stopped working (which is indicated in the .working member of
@@ -1563,12 +1565,12 @@ static void init_threaded_search(void)
        pthread_mutex_init(&cache_mutex, NULL);
        pthread_mutex_init(&progress_mutex, NULL);
        pthread_cond_init(&progress_cond, NULL);
-       set_try_to_free_routine(try_to_free_from_threads);
+       old_try_to_free_routine = set_try_to_free_routine(try_to_free_from_threads);
 }
 
 static void cleanup_threaded_search(void)
 {
-       set_try_to_free_routine(NULL);
+       set_try_to_free_routine(old_try_to_free_routine);
        pthread_cond_destroy(&progress_cond);
        pthread_mutex_destroy(&read_mutex);
        pthread_mutex_destroy(&cache_mutex);
index 8bdcab11389e8b4facab355f27f0e1926134b86f..9ad1e66916545dd2aeeb110661e56edfa5921019 100644 (file)
@@ -219,14 +219,9 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
         * "-m ent" or "--reset ent" form), we can obtain a fully
         * valid cache-tree because the index must match exactly
         * what came from the tree.
-        *
-        * The same holds true if we are switching between two trees
-        * using read-tree -m A B.  The index must match B after that.
         */
        if (nr_trees == 1 && !opts.prefix)
                prime_cache_tree(&active_cache_tree, trees[0]);
-       else if (nr_trees == 2 && opts.merge)
-               prime_cache_tree(&active_cache_tree, trees[1]);
 
        if (write_cache(newfd, active_cache, active_nr) ||
            commit_locked_index(&lock_file))
index 5170abf2a02d915238bfb5a01e7a1223cdefb642..d634b5a3d5212b8e49217d94430c294b911dfc7d 100644 (file)
@@ -17,7 +17,7 @@ enum deny_action {
        DENY_UNCONFIGURED,
        DENY_IGNORE,
        DENY_WARN,
-       DENY_REFUSE,
+       DENY_REFUSE
 };
 
 static int deny_deletes;
@@ -515,9 +515,9 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
        dst_cmd->skip_update = 1;
 
        strcpy(cmd_oldh, find_unique_abbrev(cmd->old_sha1, DEFAULT_ABBREV));
-       strcat(cmd_newh, find_unique_abbrev(cmd->new_sha1, DEFAULT_ABBREV));
+       strcpy(cmd_newh, find_unique_abbrev(cmd->new_sha1, DEFAULT_ABBREV));
        strcpy(dst_oldh, find_unique_abbrev(dst_cmd->old_sha1, DEFAULT_ABBREV));
-       strcat(dst_newh, find_unique_abbrev(dst_cmd->new_sha1, DEFAULT_ABBREV));
+       strcpy(dst_newh, find_unique_abbrev(dst_cmd->new_sha1, DEFAULT_ABBREV));
        rp_error("refusing inconsistent update between symref '%s' (%s..%s) and"
                 " its target '%s' (%s..%s)",
                 cmd->ref_name, cmd_oldh, cmd_newh,
index 03d90cde024967f56af53122ba2b1ca175a83566..6699bc571235167f5cae60106522c09a10ae341d 100644 (file)
@@ -16,6 +16,7 @@ static const char * const builtin_remote_usage[] = {
        "git remote [-v | --verbose] show [-n] <name>",
        "git remote prune [-n | --dry-run] <name>",
        "git remote [-v | --verbose] update [-p | --prune] [group | remote]",
+       "git remote set-branches <name> [--add] <branch>...",
        "git remote set-url <name> <newurl> [<oldurl>]",
        "git remote set-url --add <name> <newurl>",
        "git remote set-url --delete <name> <url>",
@@ -42,6 +43,12 @@ static const char * const builtin_remote_sethead_usage[] = {
        NULL
 };
 
+static const char * const builtin_remote_setbranches_usage[] = {
+       "git remote set-branches <name> <branch>...",
+       "git remote set-branches --add <name> <branch>...",
+       NULL
+};
+
 static const char * const builtin_remote_show_usage[] = {
        "git remote show [<options>] <name>",
        NULL
@@ -110,6 +117,20 @@ enum {
        TAGS_SET = 2
 };
 
+static int add_branch(const char *key, const char *branchname,
+               const char *remotename, int mirror, struct strbuf *tmp)
+{
+       strbuf_reset(tmp);
+       strbuf_addch(tmp, '+');
+       if (mirror)
+               strbuf_addf(tmp, "refs/%s:refs/%s",
+                               branchname, branchname);
+       else
+               strbuf_addf(tmp, "refs/heads/%s:refs/remotes/%s/%s",
+                               branchname, remotename, branchname);
+       return git_config_set_multivar(key, tmp->buf, "^$", 0);
+}
+
 static int add(int argc, const char **argv)
 {
        int fetch = 0, mirror = 0, fetch_tags = TAGS_DEFAULT;
@@ -162,17 +183,8 @@ static int add(int argc, const char **argv)
        if (track.nr == 0)
                string_list_append(&track, "*");
        for (i = 0; i < track.nr; i++) {
-               struct string_list_item *item = track.items + i;
-
-               strbuf_reset(&buf2);
-               strbuf_addch(&buf2, '+');
-               if (mirror)
-                       strbuf_addf(&buf2, "refs/%s:refs/%s",
-                                       item->string, item->string);
-               else
-                       strbuf_addf(&buf2, "refs/heads/%s:refs/remotes/%s/%s",
-                                       item->string, name, item->string);
-               if (git_config_set_multivar(buf.buf, buf2.buf, "^$", 0))
+               if (add_branch(buf.buf, track.items[i].string,
+                               name, mirror, &buf2))
                        return 1;
        }
 
@@ -336,7 +348,7 @@ struct push_info {
                PUSH_STATUS_UPTODATE,
                PUSH_STATUS_FASTFORWARD,
                PUSH_STATUS_OUTOFDATE,
-               PUSH_STATUS_NOTQUERIED,
+               PUSH_STATUS_NOTQUERIED
        } status;
 };
 
@@ -724,11 +736,14 @@ static int rm(int argc, const char **argv)
        struct known_remotes known_remotes = { NULL, NULL };
        struct string_list branches = { NULL, 0, 0, 1 };
        struct string_list skipped = { NULL, 0, 0, 1 };
-       struct branches_for_remote cb_data = {
-               NULL, &branches, &skipped, &known_remotes
-       };
+       struct branches_for_remote cb_data;
        int i, result;
 
+       memset(&cb_data, 0, sizeof(cb_data));
+       cb_data.branches = &branches;
+       cb_data.skipped = &skipped;
+       cb_data.keep = &known_remotes;
+
        if (argc != 2)
                usage_with_options(builtin_remote_rm_usage, options);
 
@@ -1284,6 +1299,72 @@ static int update(int argc, const char **argv)
        return run_command_v_opt(fetch_argv, RUN_GIT_CMD);
 }
 
+static int remove_all_fetch_refspecs(const char *remote, const char *key)
+{
+       return git_config_set_multivar(key, NULL, NULL, 1);
+}
+
+static int add_branches(struct remote *remote, const char **branches,
+                       const char *key)
+{
+       const char *remotename = remote->name;
+       int mirror = remote->mirror;
+       struct strbuf refspec = STRBUF_INIT;
+
+       for (; *branches; branches++)
+               if (add_branch(key, *branches, remotename, mirror, &refspec)) {
+                       strbuf_release(&refspec);
+                       return 1;
+               }
+
+       strbuf_release(&refspec);
+       return 0;
+}
+
+static int set_remote_branches(const char *remotename, const char **branches,
+                               int add_mode)
+{
+       struct strbuf key = STRBUF_INIT;
+       struct remote *remote;
+
+       strbuf_addf(&key, "remote.%s.fetch", remotename);
+
+       if (!remote_is_configured(remotename))
+               die("No such remote '%s'", remotename);
+       remote = remote_get(remotename);
+
+       if (!add_mode && remove_all_fetch_refspecs(remotename, key.buf)) {
+               strbuf_release(&key);
+               return 1;
+       }
+       if (add_branches(remote, branches, key.buf)) {
+               strbuf_release(&key);
+               return 1;
+       }
+
+       strbuf_release(&key);
+       return 0;
+}
+
+static int set_branches(int argc, const char **argv)
+{
+       int add_mode = 0;
+       struct option options[] = {
+               OPT_BOOLEAN('\0', "add", &add_mode, "add branch"),
+               OPT_END()
+       };
+
+       argc = parse_options(argc, argv, NULL, options,
+                            builtin_remote_setbranches_usage, 0);
+       if (argc == 0) {
+               error("no remote specified");
+               usage_with_options(builtin_remote_seturl_usage, options);
+       }
+       argv[argc] = NULL;
+
+       return set_remote_branches(argv[0], argv + 1, add_mode);
+}
+
 static int set_url(int argc, const char **argv)
 {
        int i, push_mode = 0, add_mode = 0, delete_mode = 0;
@@ -1449,6 +1530,8 @@ int cmd_remote(int argc, const char **argv, const char *prefix)
                result = rm(argc, argv);
        else if (!strcmp(argv[0], "set-head"))
                result = set_head(argc, argv);
+       else if (!strcmp(argv[0], "set-branches"))
+               result = set_branches(argc, argv);
        else if (!strcmp(argv[0], "set-url"))
                result = set_url(argc, argv);
        else if (!strcmp(argv[0], "show"))
index 73610b6bc29285a4a4481458c86817ea2ab3ccf6..980d5421eee881ccb84c20dfb7aaae7dbb6a06ab 100644 (file)
@@ -89,7 +89,7 @@ static int diff_two(const char *file1, const char *label1,
        printf("--- a/%s\n+++ b/%s\n", label1, label2);
        fflush(stdout);
        memset(&xpp, 0, sizeof(xpp));
-       xpp.flags = XDF_NEED_MINIMAL;
+       xpp.flags = 0;
        memset(&xecfg, 0, sizeof(xecfg));
        xecfg.ctxlen = 3;
        ecb.outf = outf;
index 51ceb19d88918445c90eccc37f1fe5f90cedd385..efe9360e2fdb9aac3bae0c61c85531041f24708a 100644 (file)
@@ -50,6 +50,15 @@ static void show_commit(struct commit *commit, void *data)
 
        graph_show_commit(revs->graph);
 
+       if (revs->count) {
+               if (commit->object.flags & SYMMETRIC_LEFT)
+                       revs->count_left++;
+               else
+                       revs->count_right++;
+               finish_commit(commit, data);
+               return;
+       }
+
        if (info->show_timestamp)
                printf("%lu ", commit->date);
        if (info->header_prefix)
@@ -400,5 +409,12 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
                             quiet ? finish_object : show_object,
                             &info);
 
+       if (revs.count) {
+               if (revs.left_right)
+                       printf("%d\t%d\n", revs.count_left, revs.count_right);
+               else
+                       printf("%d\n", revs.count_left + revs.count_right);
+       }
+
        return 0;
 }
index 8fbf9d0db6f40aa8c7cb61d72d0f44446de46826..a5a1c86e92720e8beefd8275acfc5df2dbdce175 100644 (file)
@@ -407,8 +407,9 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
        ALLOC_GROW(opts, onb + 1, osz);
        memset(opts + onb, 0, sizeof(opts[onb]));
        argc = parse_options(argc, argv, prefix, opts, usage,
-                       keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0 |
-                       stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0);
+                       (keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0) |
+                       (stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0) |
+                       PARSE_OPT_SHELL_EVAL);
 
        strbuf_addf(&parsed, " --");
        sq_quote_argv(&parsed, argv, 0);
index 7976b5a3295d4c70f003212485680f4dd3ceead2..8b9d829a73a0862dfdf2c2499b18878489620f16 100644 (file)
@@ -39,7 +39,8 @@ static const char * const cherry_pick_usage[] = {
 static int edit, no_replay, no_commit, mainline, signoff, allow_ff;
 static enum { REVERT, CHERRY_PICK } action;
 static struct commit *commit;
-static const char *commit_name;
+static int commit_argc;
+static const char **commit_argv;
 static int allow_rerere_auto;
 
 static const char *me;
@@ -49,16 +50,18 @@ static const char *strategy;
 
 static char *get_encoding(const char *message);
 
+static const char * const *revert_or_cherry_pick_usage(void)
+{
+       return action == REVERT ? revert_usage : cherry_pick_usage;
+}
+
 static void parse_args(int argc, const char **argv)
 {
-       const char * const * usage_str =
-               action == REVERT ?  revert_usage : cherry_pick_usage;
-       unsigned char sha1[20];
+       const char * const * usage_str = revert_or_cherry_pick_usage();
        int noop;
        struct option options[] = {
                OPT_BOOLEAN('n', "no-commit", &no_commit, "don't automatically commit"),
                OPT_BOOLEAN('e', "edit", &edit, "edit the commit message"),
-               OPT_BOOLEAN('x', NULL, &no_replay, "append commit name when cherry-picking"),
                OPT_BOOLEAN('r', NULL, &noop, "no-op (backward compatibility)"),
                OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
                OPT_INTEGER('m', "mainline", &mainline, "parent number"),
@@ -71,6 +74,7 @@ static void parse_args(int argc, const char **argv)
 
        if (action == CHERRY_PICK) {
                struct option cp_extra[] = {
+                       OPT_BOOLEAN('x', NULL, &no_replay, "append commit name"),
                        OPT_BOOLEAN(0, "ff", &allow_ff, "allow fast-forward"),
                        OPT_END(),
                };
@@ -78,15 +82,13 @@ static void parse_args(int argc, const char **argv)
                        die("program error");
        }
 
-       if (parse_options(argc, argv, NULL, options, usage_str, 0) != 1)
+       commit_argc = parse_options(argc, argv, NULL, options, usage_str,
+                                   PARSE_OPT_KEEP_ARGV0 |
+                                   PARSE_OPT_KEEP_UNKNOWN);
+       if (commit_argc < 2)
                usage_with_options(usage_str, options);
 
-       commit_name = argv[0];
-       if (get_sha1(commit_name, sha1))
-               die ("Cannot find '%s'", commit_name);
-       commit = lookup_commit_reference(sha1);
-       if (!commit)
-               exit(1);
+       commit_argv = argv;
 }
 
 struct commit_message {
@@ -239,7 +241,7 @@ static void set_author_ident_env(const char *message)
                        sha1_to_hex(commit->object.sha1));
 }
 
-static char *help_msg(const char *name)
+static char *help_msg(void)
 {
        struct strbuf helpbuf = STRBUF_INIT;
        char *msg = getenv("GIT_CHERRY_PICK_HELP");
@@ -255,7 +257,7 @@ static char *help_msg(const char *name)
                strbuf_addf(&helpbuf, " with: \n"
                        "\n"
                        "        git commit -c %s\n",
-                       name);
+                           sha1_to_hex(commit->object.sha1));
        }
        else
                strbuf_addch(&helpbuf, '.');
@@ -357,7 +359,7 @@ static void do_recursive_merge(struct commit *base, struct commit *next,
                }
                write_message(msgbuf, defmsg);
                fprintf(stderr, "Automatic %s failed.%s\n",
-                       me, help_msg(commit_name));
+                       me, help_msg());
                rerere(allow_rerere_auto);
                exit(1);
        }
@@ -365,7 +367,7 @@ static void do_recursive_merge(struct commit *base, struct commit *next,
        fprintf(stderr, "Finished one %s.\n", me);
 }
 
-static int revert_or_cherry_pick(int argc, const char **argv)
+static int do_pick_commit(void)
 {
        unsigned char head[20];
        struct commit *base, *next, *parent;
@@ -374,28 +376,6 @@ static int revert_or_cherry_pick(int argc, const char **argv)
        char *defmsg = NULL;
        struct strbuf msgbuf = STRBUF_INIT;
 
-       git_config(git_default_config, NULL);
-       me = action == REVERT ? "revert" : "cherry-pick";
-       setenv(GIT_REFLOG_ACTION, me, 0);
-       parse_args(argc, argv);
-
-       /* this is copied from the shell script, but it's never triggered... */
-       if (action == REVERT && !no_replay)
-               die("revert is incompatible with replay");
-
-       if (allow_ff) {
-               if (signoff)
-                       die("cherry-pick --ff cannot be used with --signoff");
-               if (no_commit)
-                       die("cherry-pick --ff cannot be used with --no-commit");
-               if (no_replay)
-                       die("cherry-pick --ff cannot be used with -x");
-               if (edit)
-                       die("cherry-pick --ff cannot be used with --edit");
-       }
-
-       if (read_cache() < 0)
-               die("git %s: failed to read the index", me);
        if (no_commit) {
                /*
                 * We do not intend to commit immediately.  We just want to
@@ -506,12 +486,14 @@ static int revert_or_cherry_pick(int argc, const char **argv)
                free_commit_list(remotes);
                if (res) {
                        fprintf(stderr, "Automatic %s with strategy %s failed.%s\n",
-                               me, strategy, help_msg(commit_name));
+                               me, strategy, help_msg());
                        rerere(allow_rerere_auto);
                        exit(1);
                }
        }
 
+       free_message(&msg);
+
        /*
         *
         * If we are cherry-pick, and if the merge did not result in
@@ -524,7 +506,9 @@ static int revert_or_cherry_pick(int argc, const char **argv)
        if (!no_commit) {
                /* 6 is max possible length of our args array including NULL */
                const char *args[6];
+               int res;
                int i = 0;
+
                args[i++] = "commit";
                args[i++] = "-n";
                if (signoff)
@@ -534,26 +518,81 @@ static int revert_or_cherry_pick(int argc, const char **argv)
                        args[i++] = defmsg;
                }
                args[i] = NULL;
-               return execv_git_cmd(args);
+               res = run_command_v_opt(args, RUN_GIT_CMD);
+               free(defmsg);
+
+               return res;
        }
-       free_message(&msg);
+
        free(defmsg);
 
        return 0;
 }
 
+static void prepare_revs(struct rev_info *revs)
+{
+       int argc;
+
+       init_revisions(revs, NULL);
+       revs->no_walk = 1;
+       if (action != REVERT)
+               revs->reverse = 1;
+
+       argc = setup_revisions(commit_argc, commit_argv, revs, NULL);
+       if (argc > 1)
+               usage(*revert_or_cherry_pick_usage());
+
+       if (prepare_revision_walk(revs))
+               die("revision walk setup failed");
+
+       if (!revs->commits)
+               die("empty commit set passed");
+}
+
+static int revert_or_cherry_pick(int argc, const char **argv)
+{
+       struct rev_info revs;
+
+       git_config(git_default_config, NULL);
+       me = action == REVERT ? "revert" : "cherry-pick";
+       setenv(GIT_REFLOG_ACTION, me, 0);
+       parse_args(argc, argv);
+
+       if (allow_ff) {
+               if (signoff)
+                       die("cherry-pick --ff cannot be used with --signoff");
+               if (no_commit)
+                       die("cherry-pick --ff cannot be used with --no-commit");
+               if (no_replay)
+                       die("cherry-pick --ff cannot be used with -x");
+               if (edit)
+                       die("cherry-pick --ff cannot be used with --edit");
+       }
+
+       if (read_cache() < 0)
+               die("git %s: failed to read the index", me);
+
+       prepare_revs(&revs);
+
+       while ((commit = get_revision(&revs))) {
+               int res = do_pick_commit();
+               if (res)
+                       return res;
+       }
+
+       return 0;
+}
+
 int cmd_revert(int argc, const char **argv, const char *prefix)
 {
        if (isatty(0))
                edit = 1;
-       no_replay = 1;
        action = REVERT;
        return revert_or_cherry_pick(argc, argv);
 }
 
 int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
 {
-       no_replay = 0;
        action = CHERRY_PICK;
        return revert_or_cherry_pick(argc, argv);
 }
diff --git a/cache.h b/cache.h
index c96602305f94b50e3f39be124c5e8d5af5a36f51..c9fa3df7f5b343ecea980ceb423e7c23d2eb22b2 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -361,7 +361,7 @@ enum object_type {
        OBJ_OFS_DELTA = 6,
        OBJ_REF_DELTA = 7,
        OBJ_ANY,
-       OBJ_MAX,
+       OBJ_MAX
 };
 
 static inline enum object_type object_type(unsigned int mode)
@@ -547,7 +547,6 @@ extern int core_compression_seen;
 extern size_t packed_git_window_size;
 extern size_t packed_git_limit;
 extern size_t delta_base_cache_limit;
-extern int auto_crlf;
 extern int read_replace_refs;
 extern int fsync_object_files;
 extern int core_preload_index;
@@ -556,32 +555,53 @@ extern int core_apply_sparse_checkout;
 enum safe_crlf {
        SAFE_CRLF_FALSE = 0,
        SAFE_CRLF_FAIL = 1,
-       SAFE_CRLF_WARN = 2,
+       SAFE_CRLF_WARN = 2
 };
 
 extern enum safe_crlf safe_crlf;
 
+enum auto_crlf {
+       AUTO_CRLF_FALSE = 0,
+       AUTO_CRLF_TRUE = 1,
+       AUTO_CRLF_INPUT = -1,
+};
+
+extern enum auto_crlf auto_crlf;
+
+enum eol {
+       EOL_UNSET,
+       EOL_CRLF,
+       EOL_LF,
+#ifdef NATIVE_CRLF
+       EOL_NATIVE = EOL_CRLF
+#else
+       EOL_NATIVE = EOL_LF
+#endif
+};
+
+extern enum eol eol;
+
 enum branch_track {
        BRANCH_TRACK_UNSPECIFIED = -1,
        BRANCH_TRACK_NEVER = 0,
        BRANCH_TRACK_REMOTE,
        BRANCH_TRACK_ALWAYS,
        BRANCH_TRACK_EXPLICIT,
-       BRANCH_TRACK_OVERRIDE,
+       BRANCH_TRACK_OVERRIDE
 };
 
 enum rebase_setup_type {
        AUTOREBASE_NEVER = 0,
        AUTOREBASE_LOCAL,
        AUTOREBASE_REMOTE,
-       AUTOREBASE_ALWAYS,
+       AUTOREBASE_ALWAYS
 };
 
 enum push_default_type {
        PUSH_DEFAULT_NOTHING = 0,
        PUSH_DEFAULT_MATCHING,
        PUSH_DEFAULT_TRACKING,
-       PUSH_DEFAULT_CURRENT,
+       PUSH_DEFAULT_CURRENT
 };
 
 extern enum branch_track git_branch_track;
@@ -590,7 +610,7 @@ extern enum push_default_type push_default;
 
 enum object_creation_mode {
        OBJECT_CREATION_USES_HARDLINKS = 0,
-       OBJECT_CREATION_USES_RENAMES = 1,
+       OBJECT_CREATION_USES_RENAMES = 1
 };
 
 extern enum object_creation_mode object_creation_mode;
@@ -670,7 +690,7 @@ enum sharedrepo {
        OLD_PERM_GROUP      = 1,
        OLD_PERM_EVERYBODY  = 2,
        PERM_GROUP          = 0660,
-       PERM_EVERYBODY      = 0664,
+       PERM_EVERYBODY      = 0664
 };
 int git_config_perm(const char *var, const char *value);
 int set_shared_perm(const char *path, int mode);
@@ -730,12 +750,23 @@ static inline unsigned int hexval(unsigned char c)
 #define MINIMUM_ABBREV 4
 #define DEFAULT_ABBREV 7
 
+struct object_context {
+       unsigned char tree[20];
+       char path[PATH_MAX];
+       unsigned mode;
+};
+
 extern int get_sha1(const char *str, unsigned char *sha1);
 extern int get_sha1_with_mode_1(const char *str, unsigned char *sha1, unsigned *mode, int gently, const char *prefix);
 static inline int get_sha1_with_mode(const char *str, unsigned char *sha1, unsigned *mode)
 {
        return get_sha1_with_mode_1(str, sha1, mode, 1, NULL);
 }
+extern int get_sha1_with_context_1(const char *name, unsigned char *sha1, struct object_context *orc, int gently, const char *prefix);
+static inline int get_sha1_with_context(const char *str, unsigned char *sha1, struct object_context *orc)
+{
+       return get_sha1_with_context_1(str, sha1, orc, 1, NULL);
+}
 extern int get_sha1_hex(const char *hex, unsigned char *sha1);
 extern char *sha1_to_hex(const unsigned char *sha1);   /* static buffer result! */
 extern int read_ref(const char *filename, unsigned char *sha1);
@@ -882,7 +913,7 @@ struct ref {
                REF_STATUS_REJECT_NODELETE,
                REF_STATUS_UPTODATE,
                REF_STATUS_REMOTE_REJECT,
-               REF_STATUS_EXPECTING_REPORT,
+               REF_STATUS_EXPECTING_REPORT
        } status;
        char *remote_status;
        struct ref *peer_ref; /* when renaming */
index 7557136c820a10570e72f6870ecc7a45c4c7ce36..655fa89d8a7ffe3c3823080f5af3e5e385e95440 100644 (file)
@@ -220,7 +220,7 @@ static void combine_diff(const unsigned char *parent, unsigned int mode,
        parent_file.ptr = grab_blob(parent, mode, &sz);
        parent_file.size = sz;
        memset(&xpp, 0, sizeof(xpp));
-       xpp.flags = XDF_NEED_MINIMAL;
+       xpp.flags = 0;
        memset(&xecfg, 0, sizeof(xecfg));
        memset(&state, 0, sizeof(state));
        state.nmask = nmask;
index 6ef88dcf45d6c5b2cd0f26397db2fc7b8859d581..eb2b8ac3cd5f375e70354e8c364abd036b0966ed 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -28,6 +28,7 @@ extern const char *commit_type;
 extern struct decoration name_decoration;
 struct name_decoration {
        struct name_decoration *next;
+       int type;
        char name[1];
 };
 
@@ -60,7 +61,7 @@ enum cmit_fmt {
        CMIT_FMT_EMAIL,
        CMIT_FMT_USERFORMAT,
 
-       CMIT_FMT_UNSPECIFIED,
+       CMIT_FMT_UNSPECIFIED
 };
 
 struct pretty_print_context
index 0e3e74304138ab2f279c74599ee934ade72ae37d..3b2477be5f658be665f19a12b48cc47fa07d1c6b 100644 (file)
@@ -80,7 +80,7 @@ static inline int fork(void)
 static inline unsigned int alarm(unsigned int seconds)
 { return 0; }
 static inline int fsync(int fd)
-{ return 0; }
+{ return _commit(fd); }
 static inline int getppid(void)
 { return 1; }
 static inline void sync(void)
@@ -89,7 +89,7 @@ static inline int getuid()
 { return 1; }
 static inline struct passwd *getpwnam(const char *name)
 { return NULL; }
-static inline int fcntl(int fd, int cmd, long arg)
+static inline int fcntl(int fd, int cmd, ...)
 {
        if (cmd == F_GETFD || cmd == F_SETFD)
                return 0;
index 0f949fc4250b5de4a3545931506fc48373ad8c6b..010e875ec4dd8d7154a0911661570165ac1ae874 100644 (file)
@@ -16,6 +16,7 @@
 static unsigned __stdcall win32_start_routine(void *arg)
 {
        pthread_t *thread = arg;
+       thread->tid = GetCurrentThreadId();
        thread->arg = thread->start_routine(thread->arg);
        return 0;
 }
@@ -49,6 +50,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)
        }
 }
 
+pthread_t pthread_self(void)
+{
+       pthread_t t = { 0 };
+       t.tid = GetCurrentThreadId();
+       return t;
+}
+
 int pthread_cond_init(pthread_cond_t *cond, const void *unused)
 {
        cond->waiters = 0;
index a45f8d66df8d1e452d9392945bf12a74c32bbca9..2e205485570bf62a11112c665624203207c724a9 100644 (file)
@@ -58,6 +58,7 @@ typedef struct {
        HANDLE handle;
        void *(*start_routine)(void*);
        void *arg;
+       DWORD tid;
 } pthread_t;
 
 extern int pthread_create(pthread_t *thread, const void *unused,
@@ -71,4 +72,28 @@ extern int pthread_create(pthread_t *thread, const void *unused,
 
 extern int win32_pthread_join(pthread_t *thread, void **value_ptr);
 
+#define pthread_equal(t1, t2) ((t1).tid == (t2).tid)
+extern pthread_t pthread_self(void);
+
+static inline int pthread_exit(void *ret)
+{
+       ExitThread((DWORD)ret);
+}
+
+typedef DWORD pthread_key_t;
+static inline int pthread_key_create(pthread_key_t *keyp, void (*destructor)(void *value))
+{
+       return (*keyp = TlsAlloc()) == TLS_OUT_OF_INDEXES ? EAGAIN : 0;
+}
+
+static inline int pthread_setspecific(pthread_key_t key, const void *value)
+{
+       return TlsSetValue(key, (void *)value) ? 0 : EINVAL;
+}
+
+static inline void *pthread_getspecific(pthread_key_t key)
+{
+       return TlsGetValue(key);
+}
+
 #endif /* PTHREAD_H */
index 9b6b1df212252901b2e577009651ba8d26e4f25a..cdcf5836c6c374eb59e80f89dbcf525fd6bf780f 100644 (file)
--- a/config.c
+++ b/config.c
@@ -517,7 +517,9 @@ static int git_default_core_config(const char *var, const char *value)
 
        if (!strcmp(var, "core.autocrlf")) {
                if (value && !strcasecmp(value, "input")) {
-                       auto_crlf = -1;
+                       if (eol == EOL_CRLF)
+                               return error("core.autocrlf=input conflicts with core.eol=crlf");
+                       auto_crlf = AUTO_CRLF_INPUT;
                        return 0;
                }
                auto_crlf = git_config_bool(var, value);
@@ -533,6 +535,20 @@ static int git_default_core_config(const char *var, const char *value)
                return 0;
        }
 
+       if (!strcmp(var, "core.eol")) {
+               if (value && !strcasecmp(value, "lf"))
+                       eol = EOL_LF;
+               else if (value && !strcasecmp(value, "crlf"))
+                       eol = EOL_CRLF;
+               else if (value && !strcasecmp(value, "native"))
+                       eol = EOL_NATIVE;
+               else
+                       eol = EOL_UNSET;
+               if (eol == EOL_CRLF && auto_crlf == AUTO_CRLF_INPUT)
+                       return error("core.autocrlf=input conflicts with core.eol=crlf");
+               return 0;
+       }
+
        if (!strcmp(var, "core.notesref")) {
                notes_ref_name = xstrdup(value);
                return 0;
index 0d4b64d076b8041a3701715a83ca46a4675ac9d6..b4e65c32b235eafafefeed1c755be7e1ad5c71ae 100644 (file)
@@ -3,10 +3,12 @@
 
 CC = @CC@
 CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@
 CC_LD_DYNPATH = @CC_LD_DYNPATH@
 AR = @AR@
 TAR = @TAR@
+DIFF = @DIFF@
 #INSTALL = @INSTALL@           # needs install-sh or install.sh in sources
 TCLTK_PATH = @TCLTK_PATH@
 
@@ -42,6 +44,7 @@ NO_D_TYPE_IN_DIRENT=@NO_D_TYPE_IN_DIRENT@
 NO_SOCKADDR_STORAGE=@NO_SOCKADDR_STORAGE@
 NO_IPV6=@NO_IPV6@
 NO_C99_FORMAT=@NO_C99_FORMAT@
+NO_HSTRERROR=@NO_HSTRERROR@
 NO_STRCASESTR=@NO_STRCASESTR@
 NO_MEMMEM=@NO_MEMMEM@
 NO_STRLCPY=@NO_STRLCPY@
@@ -51,10 +54,15 @@ NO_SETENV=@NO_SETENV@
 NO_UNSETENV=@NO_UNSETENV@
 NO_MKDTEMP=@NO_MKDTEMP@
 NO_MKSTEMPS=@NO_MKSTEMPS@
+NO_INET_NTOP=@NO_INET_NTOP@
+NO_INET_PTON=@NO_INET_PTON@
 NO_ICONV=@NO_ICONV@
 OLD_ICONV=@OLD_ICONV@
 NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
+INLINE=@INLINE@
+SOCKLEN_T=@SOCKLEN_T@
 FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
 SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
 NO_PTHREADS=@NO_PTHREADS@
+PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
 PTHREAD_LIBS=@PTHREAD_LIBS@
index 71038fcf1cd04fdfa3bcd133b6fc82974a135141..5601e8bac953c670e35f32ffe48d157dd5694ce7 100644 (file)
@@ -327,6 +327,12 @@ GIT_PARSE_WITH(tcltk))
 AC_MSG_NOTICE([CHECKS for programs])
 #
 AC_PROG_CC([cc gcc])
+AC_C_INLINE
+case $ac_cv_c_inline in
+  inline | yes | no)   ;;
+  *)                   AC_SUBST([INLINE], [$ac_cv_c_inline]) ;;
+esac
+
 # which switch to pass runtime path to dynamic libraries to the linker
 AC_CACHE_CHECK([if linker supports -R], git_cv_ld_dashr, [
    SAVE_LDFLAGS="${LDFLAGS}"
@@ -362,6 +368,7 @@ fi
 #AC_PROG_INSTALL               # needs install-sh or install.sh in sources
 AC_CHECK_TOOLS(AR, [gar ar], :)
 AC_CHECK_PROGS(TAR, [gtar tar])
+AC_CHECK_PROGS(DIFF, [gnudiff gdiff diff])
 # TCLTK_PATH will be set to some value if we want Tcl/Tk
 # or will be empty otherwise.
 if test -z "$NO_TCLTK"; then
@@ -544,13 +551,47 @@ AC_SUBST(NEEDS_SOCKET)
 test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket"
 
 #
-# Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough.
-# Notably on Solaris hstrerror resides in libresolv and on Solaris 7
-# inet_ntop and inet_pton additionally reside there.
-AC_CHECK_LIB([c], [hstrerror],
-[NEEDS_RESOLV=],
-[NEEDS_RESOLV=YesPlease])
+# The next few tests will define NEEDS_RESOLV if linking with
+# libresolv provides some of the functions we would normally get
+# from libc.
+NEEDS_RESOLV=
 AC_SUBST(NEEDS_RESOLV)
+#
+# Define NO_INET_NTOP if linking with -lresolv is not enough.
+# Solaris 2.7 in particular hos inet_ntop in -lresolv.
+NO_INET_NTOP=
+AC_SUBST(NO_INET_NTOP)
+AC_CHECK_FUNC([inet_ntop],
+       [],
+    [AC_CHECK_LIB([resolv], [inet_ntop],
+           [NEEDS_RESOLV=YesPlease],
+       [NO_INET_NTOP=YesPlease])
+])
+#
+# Define NO_INET_PTON if linking with -lresolv is not enough.
+# Solaris 2.7 in particular hos inet_pton in -lresolv.
+NO_INET_PTON=
+AC_SUBST(NO_INET_PTON)
+AC_CHECK_FUNC([inet_pton],
+       [],
+    [AC_CHECK_LIB([resolv], [inet_pton],
+           [NEEDS_RESOLV=YesPlease],
+       [NO_INET_PTON=YesPlease])
+])
+#
+# Define NO_HSTRERROR if linking with -lresolv is not enough.
+# Solaris 2.6 in particular has no hstrerror, even in -lresolv.
+NO_HSTRERROR=
+AC_CHECK_FUNC([hstrerror],
+       [],
+    [AC_CHECK_LIB([resolv], [hstrerror],
+           [NEEDS_RESOLV=YesPlease],
+       [NO_HSTRERROR=YesPlease])
+])
+AC_SUBST(NO_HSTRERROR)
+#
+# If any of the above tests determined that -lresolv is needed at
+# build-time, also set it here for remaining configure-time checks.
 test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv"
 
 AC_CHECK_LIB([c], [basename],
@@ -598,6 +639,12 @@ AC_SUBST(OLD_ICONV)
 ## Checks for typedefs, structures, and compiler characteristics.
 AC_MSG_NOTICE([CHECKS for typedefs, structures, and compiler characteristics])
 #
+TYPE_SOCKLEN_T
+case $ac_cv_type_socklen_t in
+  yes) ;;
+  *)   AC_SUBST([SOCKLEN_T], [$git_cv_socklen_t_equiv]) ;;
+esac
+
 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
 AC_CHECK_MEMBER(struct dirent.d_ino,
 [NO_D_INO_IN_DIRENT=],
@@ -808,7 +855,11 @@ AC_DEFUN([PTHREADTEST_SRC], [
 int main(void)
 {
        pthread_mutex_t test_mutex;
-       return (0);
+       int retcode = 0;
+       retcode |= pthread_mutex_init(&test_mutex,(void *)0);
+       retcode |= pthread_mutex_lock(&test_mutex);
+       retcode |= pthread_mutex_unlock(&test_mutex);
+       return retcode;
 }
 ])
 
@@ -825,7 +876,8 @@ if test -n "$USER_NOPTHREAD"; then
 # handle these separately since PTHREAD_CFLAGS could be '-lpthreads
 # -D_REENTRANT' or some such.
 elif test -z "$PTHREAD_CFLAGS"; then
-  for opt in -pthread -lpthread; do
+  threads_found=no
+  for opt in -mt -pthread -lpthread; do
      old_CFLAGS="$CFLAGS"
      CFLAGS="$opt $CFLAGS"
      AC_MSG_CHECKING([Checking for POSIX Threads with '$opt'])
@@ -833,11 +885,18 @@ elif test -z "$PTHREAD_CFLAGS"; then
        [AC_MSG_RESULT([yes])
                NO_PTHREADS=
                PTHREAD_LIBS="$opt"
+               PTHREAD_CFLAGS="$opt"
+               threads_found=yes
                break
        ],
        [AC_MSG_RESULT([no])])
       CFLAGS="$old_CFLAGS"
   done
+  if test $threads_found != yes; then
+    AC_CHECK_LIB([pthread], [pthread_create],
+       [PTHREAD_LIBS="-lpthread"],
+       [NO_PTHREADS=UnfortunatelyYes])
+  fi
 else
   old_CFLAGS="$CFLAGS"
   CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
@@ -854,6 +913,7 @@ fi
 
 CFLAGS="$old_CFLAGS"
 
+AC_SUBST(PTHREAD_CFLAGS)
 AC_SUBST(PTHREAD_LIBS)
 AC_SUBST(NO_PTHREADS)
 
index 9ae991ac42544716599ff8bf3ebaaa376c8119e4..02e738a0146a5c46aaf3f1d8edc3c055a99e98b9 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -5,6 +5,7 @@
 #include "refs.h"
 #include "run-command.h"
 #include "remote.h"
+#include "url.h"
 
 static char *server_capabilities;
 
@@ -131,7 +132,7 @@ int path_match(const char *path, int nr, char **match)
 enum protocol {
        PROTO_LOCAL = 1,
        PROTO_SSH,
-       PROTO_GIT,
+       PROTO_GIT
 };
 
 static enum protocol get_protocol(const char *name)
@@ -450,7 +451,7 @@ static struct child_process no_fork;
 struct child_process *git_connect(int fd[2], const char *url_orig,
                                  const char *prog, int flags)
 {
-       char *url = xstrdup(url_orig);
+       char *url;
        char *host, *path;
        char *end;
        int c;
@@ -466,6 +467,11 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
         */
        signal(SIGCHLD, SIG_DFL);
 
+       if (is_url(url_orig))
+               url = url_decode(url_orig);
+       else
+               url = xstrdup(url_orig);
+
        host = strstr(url, "://");
        if (host) {
                *host = '\0';
index 57245a8c01fa3aba4f9e3f2bc258b40f38f446c0..67569901e71e5062199e48304afc424f15b57ba1 100755 (executable)
 #       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're
 #       untracked files, then a '%' will be shown next to the branch name.
 #
+#       If you would like to see the difference between HEAD and its
+#       upstream, set GIT_PS1_SHOWUPSTREAM="auto".  A "<" indicates
+#       you are behind, ">" indicates you are ahead, and "<>"
+#       indicates you have diverged.  You can further control
+#       behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated
+#       list of values:
+#           verbose       show number of commits ahead/behind (+/-) upstream
+#           legacy        don't use the '--count' option available in recent
+#                         versions of git-rev-list
+#           git           always compare HEAD to @{upstream}
+#           svn           always compare HEAD to your SVN upstream
+#       By default, __git_ps1 will compare HEAD to your SVN upstream
+#       if it can find one, or @{upstream} otherwise.  Once you have
+#       set GIT_PS1_SHOWUPSTREAM, you can override it on a
+#       per-repository basis by setting the bash.showUpstream config
+#       variable.
+#
+#
 # To submit patches:
 #
 #    *) Read Documentation/SubmittingPatches
@@ -78,14 +96,133 @@ __gitdir ()
        fi
 }
 
+# stores the divergence from upstream in $p
+# used by GIT_PS1_SHOWUPSTREAM
+__git_ps1_show_upstream ()
+{
+       local key value
+       local svn_remote=() svn_url_pattern count n
+       local upstream=git legacy="" verbose=""
+
+       # get some config options from git-config
+       while read key value; do
+               case "$key" in
+               bash.showupstream)
+                       GIT_PS1_SHOWUPSTREAM="$value"
+                       if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
+                               p=""
+                               return
+                       fi
+                       ;;
+               svn-remote.*.url)
+                       svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value"
+                       svn_url_pattern+="\\|$value"
+                       upstream=svn+git # default upstream is SVN if available, else git
+                       ;;
+               esac
+       done < <(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')
+
+       # parse configuration values
+       for option in ${GIT_PS1_SHOWUPSTREAM}; do
+               case "$option" in
+               git|svn) upstream="$option" ;;
+               verbose) verbose=1 ;;
+               legacy)  legacy=1  ;;
+               esac
+       done
+
+       # Find our upstream
+       case "$upstream" in
+       git)    upstream="@{upstream}" ;;
+       svn*)
+               # get the upstream from the "git-svn-id: ..." in a commit message
+               # (git-svn uses essentially the same procedure internally)
+               local svn_upstream=($(git log --first-parent -1 \
+                                       --grep="^git-svn-id: \(${svn_url_pattern:2}\)" 2>/dev/null))
+               if [[ 0 -ne ${#svn_upstream[@]} ]]; then
+                       svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
+                       svn_upstream=${svn_upstream%@*}
+                       for ((n=1; "$n" <= "${#svn_remote[@]}"; ++n)); do
+                               svn_upstream=${svn_upstream#${svn_remote[$n]}}
+                       done
+
+                       if [[ -z "$svn_upstream" ]]; then
+                               # default branch name for checkouts with no layout:
+                               upstream=${GIT_SVN_ID:-git-svn}
+                       else
+                               upstream=${svn_upstream#/}
+                       fi
+               elif [[ "svn+git" = "$upstream" ]]; then
+                       upstream="@{upstream}"
+               fi
+               ;;
+       esac
+
+       # Find how many commits we are ahead/behind our upstream
+       if [[ -z "$legacy" ]]; then
+               count="$(git rev-list --count --left-right \
+                               "$upstream"...HEAD 2>/dev/null)"
+       else
+               # produce equivalent output to --count for older versions of git
+               local commits
+               if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
+               then
+                       local commit behind=0 ahead=0
+                       for commit in $commits
+                       do
+                               case "$commit" in
+                               "<"*) let ++behind
+                                       ;;
+                               *)    let ++ahead
+                                       ;;
+                               esac
+                       done
+                       count="$behind  $ahead"
+               else
+                       count=""
+               fi
+       fi
+
+       # calculate the result
+       if [[ -z "$verbose" ]]; then
+               case "$count" in
+               "") # no upstream
+                       p="" ;;
+               "0      0") # equal to upstream
+                       p="=" ;;
+               "0      "*) # ahead of upstream
+                       p=">" ;;
+               *"      0") # behind upstream
+                       p="<" ;;
+               *)          # diverged from upstream
+                       p="<>" ;;
+               esac
+       else
+               case "$count" in
+               "") # no upstream
+                       p="" ;;
+               "0      0") # equal to upstream
+                       p=" u=" ;;
+               "0      "*) # ahead of upstream
+                       p=" u+${count#0 }" ;;
+               *"      0") # behind upstream
+                       p=" u-${count%  0}" ;;
+               *)          # diverged from upstream
+                       p=" u+${count#* }-${count%      *}" ;;
+               esac
+       fi
+
+}
+
+
 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
 # returns text to add to bash PS1 prompt (includes branch name)
 __git_ps1 ()
 {
        local g="$(__gitdir)"
        if [ -n "$g" ]; then
-               local r
-               local b
+               local r=""
+               local b=""
                if [ -f "$g/rebase-merge/interactive" ]; then
                        r="|REBASE-i"
                        b="$(cat "$g/rebase-merge/head-name")"
@@ -127,11 +264,12 @@ __git_ps1 ()
                        }
                fi
 
-               local w
-               local i
-               local s
-               local u
-               local c
+               local w=""
+               local i=""
+               local s=""
+               local u=""
+               local c=""
+               local p=""
 
                if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
                        if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
@@ -159,10 +297,14 @@ __git_ps1 ()
                              u="%"
                           fi
                        fi
+
+                       if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
+                               __git_ps1_show_upstream
+                       fi
                fi
 
                local f="$w$i$s$u"
-               printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r"
+               printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
        fi
 }
 
@@ -842,7 +984,7 @@ _git_checkout ()
        --*)
                __gitcomp "
                        --quiet --ours --theirs --track --no-track --merge
-                       --conflict= --patch
+                       --conflict= --orphan --patch
                        "
                ;;
        *)
@@ -1052,7 +1194,7 @@ _git_format_patch ()
                        --numbered --start-number
                        --numbered-files
                        --keep-subject
-                       --signoff
+                       --signoff --signature --no-signature
                        --in-reply-to= --cc=
                        --full-index --binary
                        --not --all
@@ -1726,6 +1868,7 @@ _git_config ()
                format.headers
                format.numbered
                format.pretty
+               format.signature
                format.signoff
                format.subjectprefix
                format.suffix
index 4f8fcb7bbb00b66f1eaa354119784e6ef57e1eb4..e41a31e4807e92e210854214d46767b9752c5181 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -8,13 +8,17 @@
  * This should use the pathname to decide on whether it wants to do some
  * more interesting conversions (automatic gzip/unzip, general format
  * conversions etc etc), but by default it just does automatic CRLF<->LF
- * translation when the "auto_crlf" option is set.
+ * translation when the "text" attribute or "auto_crlf" option is set.
  */
 
-#define CRLF_GUESS     (-1)
-#define CRLF_BINARY    0
-#define CRLF_TEXT      1
-#define CRLF_INPUT     2
+enum action {
+       CRLF_GUESS = -1,
+       CRLF_BINARY = 0,
+       CRLF_TEXT,
+       CRLF_INPUT,
+       CRLF_CRLF,
+       CRLF_AUTO,
+};
 
 struct text_stat {
        /* NUL, CR, LF and CRLF counts */
@@ -89,49 +93,111 @@ static int is_binary(unsigned long size, struct text_stat *stats)
        return 0;
 }
 
-static void check_safe_crlf(const char *path, int action,
+static enum eol determine_output_conversion(enum action action) {
+       switch (action) {
+       case CRLF_BINARY:
+               return EOL_UNSET;
+       case CRLF_CRLF:
+               return EOL_CRLF;
+       case CRLF_INPUT:
+               return EOL_LF;
+       case CRLF_GUESS:
+               if (!auto_crlf)
+                       return EOL_UNSET;
+               /* fall through */
+       case CRLF_TEXT:
+       case CRLF_AUTO:
+               if (auto_crlf == AUTO_CRLF_TRUE)
+                       return EOL_CRLF;
+               else if (auto_crlf == AUTO_CRLF_INPUT)
+                       return EOL_LF;
+               else if (eol == EOL_UNSET)
+                       return EOL_NATIVE;
+       }
+       return eol;
+}
+
+static void check_safe_crlf(const char *path, enum action action,
                             struct text_stat *stats, enum safe_crlf checksafe)
 {
        if (!checksafe)
                return;
 
-       if (action == CRLF_INPUT || auto_crlf <= 0) {
+       if (determine_output_conversion(action) == EOL_LF) {
                /*
                 * CRLFs would not be restored by checkout:
                 * check if we'd remove CRLFs
                 */
                if (stats->crlf) {
                        if (checksafe == SAFE_CRLF_WARN)
-                               warning("CRLF will be replaced by LF in %s.", path);
+                               warning("CRLF will be replaced by LF in %s.\nThe file will have its original line endings in your working directory.", path);
                        else /* i.e. SAFE_CRLF_FAIL */
                                die("CRLF would be replaced by LF in %s.", path);
                }
-       } else if (auto_crlf > 0) {
+       } else if (determine_output_conversion(action) == EOL_CRLF) {
                /*
                 * CRLFs would be added by checkout:
                 * check if we have "naked" LFs
                 */
                if (stats->lf != stats->crlf) {
                        if (checksafe == SAFE_CRLF_WARN)
-                               warning("LF will be replaced by CRLF in %s", path);
+                               warning("LF will be replaced by CRLF in %s.\nThe file will have its original line endings in your working directory.", path);
                        else /* i.e. SAFE_CRLF_FAIL */
                                die("LF would be replaced by CRLF in %s", path);
                }
        }
 }
 
+static int has_cr_in_index(const char *path)
+{
+       int pos, len;
+       unsigned long sz;
+       enum object_type type;
+       void *data;
+       int has_cr;
+       struct index_state *istate = &the_index;
+
+       len = strlen(path);
+       pos = index_name_pos(istate, path, len);
+       if (pos < 0) {
+               /*
+                * We might be in the middle of a merge, in which
+                * case we would read stage #2 (ours).
+                */
+               int i;
+               for (i = -pos - 1;
+                    (pos < 0 && i < istate->cache_nr &&
+                     !strcmp(istate->cache[i]->name, path));
+                    i++)
+                       if (ce_stage(istate->cache[i]) == 2)
+                               pos = i;
+       }
+       if (pos < 0)
+               return 0;
+       data = read_sha1_file(istate->cache[pos]->sha1, &type, &sz);
+       if (!data || type != OBJ_BLOB) {
+               free(data);
+               return 0;
+       }
+
+       has_cr = memchr(data, '\r', sz) != NULL;
+       free(data);
+       return has_cr;
+}
+
 static int crlf_to_git(const char *path, const char *src, size_t len,
-                       struct strbuf *buf, int action, enum safe_crlf checksafe)
+                      struct strbuf *buf, enum action action, enum safe_crlf checksafe)
 {
        struct text_stat stats;
        char *dst;
 
-       if ((action == CRLF_BINARY) || !auto_crlf || !len)
+       if (action == CRLF_BINARY ||
+           (action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE) || !len)
                return 0;
 
        gather_stats(src, len, &stats);
 
-       if (action == CRLF_GUESS) {
+       if (action == CRLF_AUTO || action == CRLF_GUESS) {
                /*
                 * We're currently not going to even try to convert stuff
                 * that has bare CR characters. Does anybody do that crazy
@@ -145,6 +211,15 @@ static int crlf_to_git(const char *path, const char *src, size_t len,
                 */
                if (is_binary(len, &stats))
                        return 0;
+
+               if (action == CRLF_GUESS) {
+                       /*
+                        * If the file in the index has any CR in it, do not convert.
+                        * This is the new safer autocrlf handling.
+                        */
+                       if (has_cr_in_index(path))
+                               return 0;
+               }
        }
 
        check_safe_crlf(path, action, &stats, checksafe);
@@ -157,7 +232,7 @@ static int crlf_to_git(const char *path, const char *src, size_t len,
        if (strbuf_avail(buf) + buf->len < len)
                strbuf_grow(buf, len - buf->len);
        dst = buf->buf;
-       if (action == CRLF_GUESS) {
+       if (action == CRLF_AUTO || action == CRLF_GUESS) {
                /*
                 * If we guessed, we already know we rejected a file with
                 * lone CR, and we can strip a CR without looking at what
@@ -180,16 +255,12 @@ static int crlf_to_git(const char *path, const char *src, size_t len,
 }
 
 static int crlf_to_worktree(const char *path, const char *src, size_t len,
-                            struct strbuf *buf, int action)
+                           struct strbuf *buf, enum action action)
 {
        char *to_free = NULL;
        struct text_stat stats;
 
-       if ((action == CRLF_BINARY) || (action == CRLF_INPUT) ||
-           auto_crlf <= 0)
-               return 0;
-
-       if (!len)
+       if (!len || determine_output_conversion(action) != EOL_CRLF)
                return 0;
 
        gather_stats(src, len, &stats);
@@ -202,7 +273,14 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,
        if (stats.lf == stats.crlf)
                return 0;
 
-       if (action == CRLF_GUESS) {
+       if (action == CRLF_AUTO || action == CRLF_GUESS) {
+               if (action == CRLF_GUESS) {
+                       /* If we have any CR or CRLF line endings, we do not touch it */
+                       /* This is the new safer autocrlf-handling */
+                       if (stats.cr > 0 || stats.crlf > 0)
+                               return 0;
+               }
+
                /* If we have any bare CR characters, we're not going to touch it */
                if (stats.cr != stats.crlf)
                        return 0;
@@ -249,7 +327,9 @@ static int filter_buffer(int in, int out, void *data)
        struct child_process child_process;
        struct filter_params *params = (struct filter_params *)data;
        int write_err, status;
-       const char *argv[] = { params->cmd, NULL };
+       const char *argv[] = { NULL, NULL };
+
+       argv[0] = params->cmd;
 
        memset(&child_process, 0, sizeof(child_process));
        child_process.argv = argv;
@@ -374,12 +454,16 @@ static int read_convert_config(const char *var, const char *value, void *cb)
 
 static void setup_convert_check(struct git_attr_check *check)
 {
+       static struct git_attr *attr_text;
        static struct git_attr *attr_crlf;
+       static struct git_attr *attr_eol;
        static struct git_attr *attr_ident;
        static struct git_attr *attr_filter;
 
-       if (!attr_crlf) {
+       if (!attr_text) {
+               attr_text = git_attr("text");
                attr_crlf = git_attr("crlf");
+               attr_eol = git_attr("eol");
                attr_ident = git_attr("ident");
                attr_filter = git_attr("filter");
                user_convert_tail = &user_convert;
@@ -388,6 +472,8 @@ static void setup_convert_check(struct git_attr_check *check)
        check[0].attr = attr_crlf;
        check[1].attr = attr_ident;
        check[2].attr = attr_filter;
+       check[3].attr = attr_eol;
+       check[4].attr = attr_text;
 }
 
 static int count_ident(const char *cp, unsigned long size)
@@ -425,6 +511,8 @@ static int count_ident(const char *cp, unsigned long size)
                                cnt++;
                                break;
                        }
+                       if (ch == '\n')
+                               break;
                }
        }
        return cnt;
@@ -455,6 +543,11 @@ static int ident_to_git(const char *path, const char *src, size_t len,
                        dollar = memchr(src + 3, '$', len - 3);
                        if (!dollar)
                                break;
+                       if (memchr(src + 3, '\n', dollar - src - 3)) {
+                               /* Line break before the next dollar. */
+                               continue;
+                       }
+
                        memcpy(dst, "Id$", 3);
                        dst += 3;
                        len -= dollar + 1 - src;
@@ -470,7 +563,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
                              struct strbuf *buf, int ident)
 {
        unsigned char sha1[20];
-       char *to_free = NULL, *dollar;
+       char *to_free = NULL, *dollar, *spc;
        int cnt;
 
        if (!ident)
@@ -506,7 +599,10 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
                } else if (src[2] == ':') {
                        /*
                         * It's possible that an expanded Id has crept its way into the
-                        * repository, we cope with that by stripping the expansion out
+                        * repository, we cope with that by stripping the expansion out.
+                        * This is probably not a good idea, since it will cause changes
+                        * on checkout, which won't go away by stash, but let's keep it
+                        * for git-style ids.
                         */
                        dollar = memchr(src + 3, '$', len - 3);
                        if (!dollar) {
@@ -514,6 +610,20 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
                                break;
                        }
 
+                       if (memchr(src + 3, '\n', dollar - src - 3)) {
+                               /* Line break before the next dollar. */
+                               continue;
+                       }
+
+                       spc = memchr(src + 4, ' ', dollar - src - 4);
+                       if (spc && spc < dollar-1) {
+                               /* There are spaces in unexpected places.
+                                * This is probably an id from some other
+                                * versioning system. Keep it for now.
+                                */
+                               continue;
+                       }
+
                        len -= dollar + 1 - src;
                        src  = dollar + 1;
                } else {
@@ -544,9 +654,24 @@ static int git_path_check_crlf(const char *path, struct git_attr_check *check)
                ;
        else if (!strcmp(value, "input"))
                return CRLF_INPUT;
+       else if (!strcmp(value, "auto"))
+               return CRLF_AUTO;
        return CRLF_GUESS;
 }
 
+static int git_path_check_eol(const char *path, struct git_attr_check *check)
+{
+       const char *value = check->value;
+
+       if (ATTR_UNSET(value))
+               ;
+       else if (!strcmp(value, "lf"))
+               return EOL_LF;
+       else if (!strcmp(value, "crlf"))
+               return EOL_CRLF;
+       return EOL_UNSET;
+}
+
 static struct convert_driver *git_path_check_convert(const char *path,
                                             struct git_attr_check *check)
 {
@@ -568,20 +693,34 @@ static int git_path_check_ident(const char *path, struct git_attr_check *check)
        return !!ATTR_TRUE(value);
 }
 
+enum action determine_action(enum action text_attr, enum eol eol_attr) {
+       if (text_attr == CRLF_BINARY)
+               return CRLF_BINARY;
+       if (eol_attr == EOL_LF)
+               return CRLF_INPUT;
+       if (eol_attr == EOL_CRLF)
+               return CRLF_CRLF;
+       return text_attr;
+}
+
 int convert_to_git(const char *path, const char *src, size_t len,
                    struct strbuf *dst, enum safe_crlf checksafe)
 {
-       struct git_attr_check check[3];
-       int crlf = CRLF_GUESS;
+       struct git_attr_check check[5];
+       enum action action = CRLF_GUESS;
+       enum eol eol_attr = EOL_UNSET;
        int ident = 0, ret = 0;
        const char *filter = NULL;
 
        setup_convert_check(check);
        if (!git_checkattr(path, ARRAY_SIZE(check), check)) {
                struct convert_driver *drv;
-               crlf = git_path_check_crlf(path, check + 0);
+               action = git_path_check_crlf(path, check + 4);
+               if (action == CRLF_GUESS)
+                       action = git_path_check_crlf(path, check + 0);
                ident = git_path_check_ident(path, check + 1);
                drv = git_path_check_convert(path, check + 2);
+               eol_attr = git_path_check_eol(path, check + 3);
                if (drv && drv->clean)
                        filter = drv->clean;
        }
@@ -591,7 +730,8 @@ int convert_to_git(const char *path, const char *src, size_t len,
                src = dst->buf;
                len = dst->len;
        }
-       ret |= crlf_to_git(path, src, len, dst, crlf, checksafe);
+       action = determine_action(action, eol_attr);
+       ret |= crlf_to_git(path, src, len, dst, action, checksafe);
        if (ret) {
                src = dst->buf;
                len = dst->len;
@@ -601,17 +741,21 @@ int convert_to_git(const char *path, const char *src, size_t len,
 
 int convert_to_working_tree(const char *path, const char *src, size_t len, struct strbuf *dst)
 {
-       struct git_attr_check check[3];
-       int crlf = CRLF_GUESS;
+       struct git_attr_check check[5];
+       enum action action = CRLF_GUESS;
+       enum eol eol_attr = EOL_UNSET;
        int ident = 0, ret = 0;
        const char *filter = NULL;
 
        setup_convert_check(check);
        if (!git_checkattr(path, ARRAY_SIZE(check), check)) {
                struct convert_driver *drv;
-               crlf = git_path_check_crlf(path, check + 0);
+               action = git_path_check_crlf(path, check + 4);
+               if (action == CRLF_GUESS)
+                       action = git_path_check_crlf(path, check + 0);
                ident = git_path_check_ident(path, check + 1);
                drv = git_path_check_convert(path, check + 2);
+               eol_attr = git_path_check_eol(path, check + 3);
                if (drv && drv->smudge)
                        filter = drv->smudge;
        }
@@ -621,7 +765,8 @@ int convert_to_working_tree(const char *path, const char *src, size_t len, struc
                src = dst->buf;
                len = dst->len;
        }
-       ret |= crlf_to_worktree(path, src, len, dst, crlf);
+       action = determine_action(action, eol_attr);
+       ret |= crlf_to_worktree(path, src, len, dst, action);
        if (ret) {
                src = dst->buf;
                len = dst->len;
diff --git a/ctype.c b/ctype.c
index 7ee64c7d77dd4a5665f70d80ffba1bcdecb9a408..de600279eef4765db497599e6654c2bedd978129 100644 (file)
--- a/ctype.c
+++ b/ctype.c
@@ -10,7 +10,7 @@ enum {
        A = GIT_ALPHA,
        D = GIT_DIGIT,
        G = GIT_GLOB_SPECIAL,   /* *, ?, [, \\ */
-       R = GIT_REGEX_SPECIAL,  /* $, (, ), +, ., ^, {, | */
+       R = GIT_REGEX_SPECIAL   /* $, (, ), +, ., ^, {, | */
 };
 
 unsigned char sane_ctype[256] = {
index a90ab10505a3694de83a0ffd8fc472518f12cf2b..e22a2b7fa5f6fcfc5b26541a21c10d3c8b7eda81 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -141,15 +141,14 @@ static char *path_ok(char *directory)
        }
        else if (interpolated_path && saw_extended_args) {
                struct strbuf expanded_path = STRBUF_INIT;
-               struct strbuf_expand_dict_entry dict[] = {
-                       { "H", hostname },
-                       { "CH", canon_hostname },
-                       { "IP", ip_address },
-                       { "P", tcp_port },
-                       { "D", directory },
-                       { NULL }
-               };
-
+               struct strbuf_expand_dict_entry dict[6];
+
+               dict[0].placeholder = "H"; dict[0].value = hostname;
+               dict[1].placeholder = "CH"; dict[1].value = canon_hostname;
+               dict[2].placeholder = "IP"; dict[2].value = ip_address;
+               dict[3].placeholder = "P"; dict[3].value = tcp_port;
+               dict[4].placeholder = "D"; dict[4].value = directory;
+               dict[5].placeholder = NULL; dict[5].value = NULL;
                if (*dir != '/') {
                        /* Allow only absolute */
                        logerror("'%s': Non-absolute path denied (interpolated-path active)", dir);
@@ -343,7 +342,9 @@ static int upload_pack(void)
 {
        /* Timeout as string */
        char timeout_buf[64];
-       const char *argv[] = { "upload-pack", "--strict", timeout_buf, ".", NULL };
+       const char *argv[] = { "upload-pack", "--strict", NULL, ".", NULL };
+
+       argv[2] = timeout_buf;
 
        snprintf(timeout_buf, sizeof timeout_buf, "--timeout=%u", timeout);
        return run_service_command(argv);
diff --git a/date.c b/date.c
index 002aa3c8d6d4ff08d8790a155b8979bc117a2b95..3c981f7eb5ebaed1ba621f3d4cd960f14145b97a 100644 (file)
--- a/date.c
+++ b/date.c
@@ -229,6 +229,7 @@ static const struct {
 
        { "GMT",    0, 0, },    /* Greenwich Mean */
        { "UTC",    0, 0, },    /* Universal (Coordinated) */
+       { "Z",      0, 0, },    /* Zulu, alias for UTC */
 
        { "WET",    0, 0, },    /* Western European */
        { "BST",    0, 1, },    /* British Summer */
@@ -305,7 +306,7 @@ static int match_alpha(const char *date, struct tm *tm, int *offset)
 
        for (i = 0; i < ARRAY_SIZE(timezone_names); i++) {
                int match = match_string(date, timezone_names[i].name);
-               if (match >= 3) {
+               if (match >= 3 || match == strlen(timezone_names[i].name)) {
                        int off = timezone_names[i].offset;
 
                        /* This is bogus, but we like summer */
@@ -585,11 +586,17 @@ static int date_string(unsigned long date, int offset, char *buf, int len)
 
 /* Gr. strptime is crap for this; it doesn't have a way to require RFC2822
    (i.e. English) day/month names, and it doesn't work correctly with %z. */
-int parse_date(const char *date, char *result, int maxlen)
+int parse_date_toffset(const char *date, unsigned long *timestamp, int *offset)
 {
        struct tm tm;
-       int offset, tm_gmt;
-       time_t then;
+       int tm_gmt;
+       unsigned long dummy_timestamp;
+       int dummy_offset;
+
+       if (!timestamp)
+               timestamp = &dummy_timestamp;
+       if (!offset)
+               offset = &dummy_offset;
 
        memset(&tm, 0, sizeof(tm));
        tm.tm_year = -1;
@@ -599,7 +606,7 @@ int parse_date(const char *date, char *result, int maxlen)
        tm.tm_hour = -1;
        tm.tm_min = -1;
        tm.tm_sec = -1;
-       offset = -1;
+       *offset = -1;
        tm_gmt = 0;
 
        for (;;) {
@@ -611,11 +618,11 @@ int parse_date(const char *date, char *result, int maxlen)
                        break;
 
                if (isalpha(c))
-                       match = match_alpha(date, &tm, &offset);
+                       match = match_alpha(date, &tm, offset);
                else if (isdigit(c))
-                       match = match_digit(date, &tm, &offset, &tm_gmt);
+                       match = match_digit(date, &tm, offset, &tm_gmt);
                else if ((c == '-' || c == '+') && isdigit(date[1]))
-                       match = match_tz(date, &offset);
+                       match = match_tz(date, offset);
 
                if (!match) {
                        /* BAD CRAP */
@@ -626,16 +633,26 @@ int parse_date(const char *date, char *result, int maxlen)
        }
 
        /* mktime uses local timezone */
-       then = tm_to_time_t(&tm);
-       if (offset == -1)
-               offset = (then - mktime(&tm)) / 60;
+       *timestamp = tm_to_time_t(&tm);
+       if (*offset == -1)
+               *offset = ((time_t)*timestamp - mktime(&tm)) / 60;
 
-       if (then == -1)
+       if (*timestamp == -1)
                return -1;
 
        if (!tm_gmt)
-               then -= offset * 60;
-       return date_string(then, offset, result, maxlen);
+               *timestamp -= *offset * 60;
+       return 1; /* success */
+}
+
+int parse_date(const char *date, char *result, int maxlen)
+{
+       unsigned long timestamp;
+       int offset;
+       if (parse_date_toffset(date, &timestamp, &offset) > 0)
+               return date_string(timestamp, offset, result, maxlen);
+       else
+               return -1;
 }
 
 enum date_mode parse_date_format(const char *format)
@@ -983,11 +1000,12 @@ static unsigned long approxidate_str(const char *date,
 
 unsigned long approxidate_relative(const char *date, const struct timeval *tv)
 {
-       char buffer[50];
+       unsigned long timestamp;
+       int offset;
        int errors = 0;
 
-       if (parse_date(date, buffer, sizeof(buffer)) > 0)
-               return strtoul(buffer, NULL, 0);
+       if (parse_date_toffset(date, &timestamp, &offset) > 0)
+               return timestamp;
 
        return approxidate_str(date, tv, &errors);
 }
@@ -995,14 +1013,15 @@ unsigned long approxidate_relative(const char *date, const struct timeval *tv)
 unsigned long approxidate_careful(const char *date, int *error_ret)
 {
        struct timeval tv;
-       char buffer[50];
+       unsigned long timestamp;
+       int offset;
        int dummy = 0;
        if (!error_ret)
                error_ret = &dummy;
 
-       if (parse_date(date, buffer, sizeof(buffer)) > 0) {
+       if (parse_date_toffset(date, &timestamp, &offset) > 0) {
                *error_ret = 0;
-               return strtoul(buffer, NULL, 0);
+               return timestamp;
        }
 
        gettimeofday(&tv, NULL);
index c9f6e05badf7b752188dcb5fa28a9bef53521dee..8b8978ae6d1b4d947952b7fe9ec9cea013aaa8c3 100644 (file)
@@ -70,6 +70,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,
        int changed = ce_match_stat(ce, st, ce_option);
        if (S_ISGITLINK(ce->ce_mode)
            && !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)
+           && !DIFF_OPT_TST(diffopt, IGNORE_DIRTY_SUBMODULES)
            && (!changed || DIFF_OPT_TST(diffopt, DIRTY_SUBMODULES))) {
                *dirty_submodule = is_submodule_modified(ce->name, DIFF_OPT_TST(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES));
        }
diff --git a/diff.c b/diff.c
index 494f5601e97e7395e647296bc7f8090331a47c43..17873f3d9e88fccbf98e790d243397dcc4ccb24b 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -30,6 +30,7 @@ static const char *diff_word_regex_cfg;
 static const char *external_diff_cmd_cfg;
 int diff_auto_refresh_index = 1;
 static int diff_mnemonic_prefix;
+static int diff_no_prefix;
 
 static char diff_colors[][COLOR_MAXLEN] = {
        GIT_COLOR_RESET,
@@ -43,10 +44,6 @@ static char diff_colors[][COLOR_MAXLEN] = {
        GIT_COLOR_NORMAL,       /* FUNCINFO */
 };
 
-static void diff_filespec_load_driver(struct diff_filespec *one);
-static size_t fill_textconv(struct userdiff_driver *driver,
-                           struct diff_filespec *df, char **outbuf);
-
 static int parse_diff_color_slot(const char *var, int ofs)
 {
        if (!strcasecmp(var+ofs, "plain"))
@@ -101,6 +98,10 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
                diff_mnemonic_prefix = git_config_bool(var, value);
                return 0;
        }
+       if (!strcmp(var, "diff.noprefix")) {
+               diff_no_prefix = git_config_bool(var, value);
+               return 0;
+       }
        if (!strcmp(var, "diff.external"))
                return git_config_string(&external_diff_cmd_cfg, var, value);
        if (!strcmp(var, "diff.wordregex"))
@@ -194,8 +195,8 @@ struct emit_callback {
        sane_truncate_fn truncate;
        const char **label_path;
        struct diff_words_data *diff_words;
+       struct diff_options *opt;
        int *found_changesp;
-       FILE *file;
        struct strbuf *header;
 };
 
@@ -282,11 +283,19 @@ static void check_blank_at_eof(mmfile_t *mf1, mmfile_t *mf2,
        ecbdata->blank_at_eof_in_postimage = (at - l2) + 1;
 }
 
-static void emit_line_0(FILE *file, const char *set, const char *reset,
+static void emit_line_0(struct diff_options *o, const char *set, const char *reset,
                        int first, const char *line, int len)
 {
        int has_trailing_newline, has_trailing_carriage_return;
        int nofirst;
+       FILE *file = o->file;
+
+       if (o->output_prefix) {
+               struct strbuf *msg = NULL;
+               msg = o->output_prefix(o, o->output_prefix_data);
+               assert(msg);
+               fwrite(msg->buf, msg->len, 1, file);
+       }
 
        if (len == 0) {
                has_trailing_newline = (first == '\n');
@@ -316,10 +325,10 @@ static void emit_line_0(FILE *file, const char *set, const char *reset,
                fputc('\n', file);
 }
 
-static void emit_line(FILE *file, const char *set, const char *reset,
+static void emit_line(struct diff_options *o, const char *set, const char *reset,
                      const char *line, int len)
 {
-       emit_line_0(file, set, reset, line[0], line+1, len-1);
+       emit_line_0(o, set, reset, line[0], line+1, len-1);
 }
 
 static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line, int len)
@@ -341,15 +350,15 @@ static void emit_add_line(const char *reset,
        const char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_NEW);
 
        if (!*ws)
-               emit_line_0(ecbdata->file, set, reset, '+', line, len);
+               emit_line_0(ecbdata->opt, set, reset, '+', line, len);
        else if (new_blank_line_at_eof(ecbdata, line, len))
                /* Blank line at EOF - paint '+' as well */
-               emit_line_0(ecbdata->file, ws, reset, '+', line, len);
+               emit_line_0(ecbdata->opt, ws, reset, '+', line, len);
        else {
                /* Emit just the prefix, then the rest. */
-               emit_line_0(ecbdata->file, set, reset, '+', "", 0);
+               emit_line_0(ecbdata->opt, set, reset, '+', "", 0);
                ws_check_emit(line, len, ecbdata->ws_rule,
-                             ecbdata->file, set, reset, ws);
+                             ecbdata->opt->file, set, reset, ws);
        }
 }
 
@@ -362,6 +371,9 @@ static void emit_hunk_header(struct emit_callback *ecbdata,
        const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
        static const char atat[2] = { '@', '@' };
        const char *cp, *ep;
+       struct strbuf msgbuf = STRBUF_INIT;
+       int org_len = len;
+       int i = 1;
 
        /*
         * As a hunk header must begin with "@@ -<old>, +<new> @@",
@@ -370,23 +382,42 @@ static void emit_hunk_header(struct emit_callback *ecbdata,
        if (len < 10 ||
            memcmp(line, atat, 2) ||
            !(ep = memmem(line + 2, len - 2, atat, 2))) {
-               emit_line(ecbdata->file, plain, reset, line, len);
+               emit_line(ecbdata->opt, plain, reset, line, len);
                return;
        }
        ep += 2; /* skip over @@ */
 
        /* The hunk header in fraginfo color */
-       emit_line(ecbdata->file, frag, reset, line, ep - line);
+       strbuf_add(&msgbuf, frag, strlen(frag));
+       strbuf_add(&msgbuf, line, ep - line);
+       strbuf_add(&msgbuf, reset, strlen(reset));
+
+       /*
+        * trailing "\r\n"
+        */
+       for ( ; i < 3; i++)
+               if (line[len - i] == '\r' || line[len - i] == '\n')
+                       len--;
 
        /* blank before the func header */
        for (cp = ep; ep - line < len; ep++)
                if (*ep != ' ' && *ep != '\t')
                        break;
-       if (ep != cp)
-               emit_line(ecbdata->file, plain, reset, cp, ep - cp);
+       if (ep != cp) {
+               strbuf_add(&msgbuf, plain, strlen(plain));
+               strbuf_add(&msgbuf, cp, ep - cp);
+               strbuf_add(&msgbuf, reset, strlen(reset));
+       }
 
-       if (ep < line + len)
-               emit_line(ecbdata->file, func, reset, ep, line + len - ep);
+       if (ep < line + len) {
+               strbuf_add(&msgbuf, func, strlen(func));
+               strbuf_add(&msgbuf, ep, line + len - ep);
+               strbuf_add(&msgbuf, reset, strlen(reset));
+       }
+
+       strbuf_add(&msgbuf, line + len, org_len - len);
+       emit_line(ecbdata->opt, "", "", msgbuf.buf, msgbuf.len);
+       strbuf_release(&msgbuf);
 }
 
 static struct diff_tempfile *claim_diff_tempfile(void) {
@@ -446,7 +477,7 @@ static void emit_rewrite_lines(struct emit_callback *ecb,
                len = endp ? (endp - data + 1) : size;
                if (prefix != '+') {
                        ecb->lno_in_preimage++;
-                       emit_line_0(ecb->file, old, reset, '-',
+                       emit_line_0(ecb->opt, old, reset, '-',
                                    data, len);
                } else {
                        ecb->lno_in_postimage++;
@@ -458,7 +489,7 @@ static void emit_rewrite_lines(struct emit_callback *ecb,
        if (!endp) {
                const char *plain = diff_get_color(ecb->color_diff,
                                                   DIFF_PLAIN);
-               emit_line_0(ecb->file, plain, reset, '\\',
+               emit_line_0(ecb->opt, plain, reset, '\\',
                            nneof, strlen(nneof));
        }
 }
@@ -482,6 +513,13 @@ static void emit_rewrite_diff(const char *name_a,
        char *data_one, *data_two;
        size_t size_one, size_two;
        struct emit_callback ecbdata;
+       char *line_prefix = "";
+       struct strbuf *msgbuf;
+
+       if (o && o->output_prefix) {
+               msgbuf = o->output_prefix(o, o->output_prefix_data);
+               line_prefix = msgbuf->buf;
+       }
 
        if (diff_mnemonic_prefix && DIFF_OPT_TST(o, REVERSE_DIFF)) {
                a_prefix = o->b_prefix;
@@ -508,7 +546,7 @@ static void emit_rewrite_diff(const char *name_a,
        ecbdata.color_diff = color_diff;
        ecbdata.found_changesp = &o->found_changes;
        ecbdata.ws_rule = whitespace_rule(name_b ? name_b : name_a);
-       ecbdata.file = o->file;
+       ecbdata.opt = o;
        if (ecbdata.ws_rule & WS_BLANK_AT_EOF) {
                mmfile_t mf1, mf2;
                mf1.ptr = (char *)data_one;
@@ -523,9 +561,10 @@ static void emit_rewrite_diff(const char *name_a,
        lc_a = count_lines(data_one, size_one);
        lc_b = count_lines(data_two, size_two);
        fprintf(o->file,
-               "%s--- %s%s%s\n%s+++ %s%s%s\n%s@@ -",
-               metainfo, a_name.buf, name_a_tab, reset,
-               metainfo, b_name.buf, name_b_tab, reset, fraginfo);
+               "%s%s--- %s%s%s\n%s%s+++ %s%s%s\n%s%s@@ -",
+               line_prefix, metainfo, a_name.buf, name_a_tab, reset,
+               line_prefix, metainfo, b_name.buf, name_b_tab, reset,
+               line_prefix, fraginfo);
        print_line_count(o->file, lc_a);
        fprintf(o->file, " +");
        print_line_count(o->file, lc_b);
@@ -584,7 +623,8 @@ struct diff_words_style diff_words_styles[] = {
 struct diff_words_data {
        struct diff_words_buffer minus, plus;
        const char *current_plus;
-       FILE *file;
+       int last_minus;
+       struct diff_options *opt;
        regex_t *word_regex;
        enum diff_words_type type;
        struct diff_words_style *style;
@@ -593,10 +633,15 @@ struct diff_words_data {
 static int fn_out_diff_words_write_helper(FILE *fp,
                                          struct diff_words_style_elem *st_el,
                                          const char *newline,
-                                         size_t count, const char *buf)
+                                         size_t count, const char *buf,
+                                         const char *line_prefix)
 {
+       int print = 0;
+
        while (count) {
                char *p = memchr(buf, '\n', count);
+               if (print)
+                       fputs(line_prefix, fp);
                if (p != buf) {
                        if (st_el->color && fputs(st_el->color, fp) < 0)
                                return -1;
@@ -614,21 +659,74 @@ static int fn_out_diff_words_write_helper(FILE *fp,
                        return -1;
                count -= p + 1 - buf;
                buf = p + 1;
+               print = 1;
        }
        return 0;
 }
 
+/*
+ * '--color-words' algorithm can be described as:
+ *
+ *   1. collect a the minus/plus lines of a diff hunk, divided into
+ *      minus-lines and plus-lines;
+ *
+ *   2. break both minus-lines and plus-lines into words and
+ *      place them into two mmfile_t with one word for each line;
+ *
+ *   3. use xdiff to run diff on the two mmfile_t to get the words level diff;
+ *
+ * And for the common parts of the both file, we output the plus side text.
+ * diff_words->current_plus is used to trace the current position of the plus file
+ * which printed. diff_words->last_minus is used to trace the last minus word
+ * printed.
+ *
+ * For '--graph' to work with '--color-words', we need to output the graph prefix
+ * on each line of color words output. Generally, there are two conditions on
+ * which we should output the prefix.
+ *
+ *   1. diff_words->last_minus == 0 &&
+ *      diff_words->current_plus == diff_words->plus.text.ptr
+ *
+ *      that is: the plus text must start as a new line, and if there is no minus
+ *      word printed, a graph prefix must be printed.
+ *
+ *   2. diff_words->current_plus > diff_words->plus.text.ptr &&
+ *      *(diff_words->current_plus - 1) == '\n'
+ *
+ *      that is: a graph prefix must be printed following a '\n'
+ */
+static int color_words_output_graph_prefix(struct diff_words_data *diff_words)
+{
+       if ((diff_words->last_minus == 0 &&
+               diff_words->current_plus == diff_words->plus.text.ptr) ||
+               (diff_words->current_plus > diff_words->plus.text.ptr &&
+               *(diff_words->current_plus - 1) == '\n')) {
+               return 1;
+       } else {
+               return 0;
+       }
+}
+
 static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)
 {
        struct diff_words_data *diff_words = priv;
        struct diff_words_style *style = diff_words->style;
        int minus_first, minus_len, plus_first, plus_len;
        const char *minus_begin, *minus_end, *plus_begin, *plus_end;
+       struct diff_options *opt = diff_words->opt;
+       struct strbuf *msgbuf;
+       char *line_prefix = "";
 
        if (line[0] != '@' || parse_hunk_header(line, len,
                        &minus_first, &minus_len, &plus_first, &plus_len))
                return;
 
+       assert(opt);
+       if (opt->output_prefix) {
+               msgbuf = opt->output_prefix(opt, opt->output_prefix_data);
+               line_prefix = msgbuf->buf;
+       }
+
        /* POSIX requires that first be decremented by one if len == 0... */
        if (minus_len) {
                minus_begin = diff_words->minus.orig[minus_first].begin;
@@ -644,21 +742,32 @@ static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)
        } else
                plus_begin = plus_end = diff_words->plus.orig[plus_first].end;
 
-       if (diff_words->current_plus != plus_begin)
-               fn_out_diff_words_write_helper(diff_words->file,
+       if (color_words_output_graph_prefix(diff_words)) {
+               fputs(line_prefix, diff_words->opt->file);
+       }
+       if (diff_words->current_plus != plus_begin) {
+               fn_out_diff_words_write_helper(diff_words->opt->file,
                                &style->ctx, style->newline,
                                plus_begin - diff_words->current_plus,
-                               diff_words->current_plus);
-       if (minus_begin != minus_end)
-               fn_out_diff_words_write_helper(diff_words->file,
+                               diff_words->current_plus, line_prefix);
+               if (*(plus_begin - 1) == '\n')
+                       fputs(line_prefix, diff_words->opt->file);
+       }
+       if (minus_begin != minus_end) {
+               fn_out_diff_words_write_helper(diff_words->opt->file,
                                &style->old, style->newline,
-                               minus_end - minus_begin, minus_begin);
-       if (plus_begin != plus_end)
-               fn_out_diff_words_write_helper(diff_words->file,
+                               minus_end - minus_begin, minus_begin,
+                               line_prefix);
+       }
+       if (plus_begin != plus_end) {
+               fn_out_diff_words_write_helper(diff_words->opt->file,
                                &style->new, style->newline,
-                               plus_end - plus_begin, plus_begin);
+                               plus_end - plus_begin, plus_begin,
+                               line_prefix);
+       }
 
        diff_words->current_plus = plus_end;
+       diff_words->last_minus = minus_first;
 }
 
 /* This function starts looking at *begin, and returns 0 iff a word was found. */
@@ -739,22 +848,35 @@ static void diff_words_show(struct diff_words_data *diff_words)
        mmfile_t minus, plus;
        struct diff_words_style *style = diff_words->style;
 
+       struct diff_options *opt = diff_words->opt;
+       struct strbuf *msgbuf;
+       char *line_prefix = "";
+
+       assert(opt);
+       if (opt->output_prefix) {
+               msgbuf = opt->output_prefix(opt, opt->output_prefix_data);
+               line_prefix = msgbuf->buf;
+       }
+
        /* special case: only removal */
        if (!diff_words->plus.text.size) {
-               fn_out_diff_words_write_helper(diff_words->file,
+               fputs(line_prefix, diff_words->opt->file);
+               fn_out_diff_words_write_helper(diff_words->opt->file,
                        &style->old, style->newline,
-                       diff_words->minus.text.size, diff_words->minus.text.ptr);
+                       diff_words->minus.text.size,
+                       diff_words->minus.text.ptr, line_prefix);
                diff_words->minus.text.size = 0;
                return;
        }
 
        diff_words->current_plus = diff_words->plus.text.ptr;
+       diff_words->last_minus = 0;
 
        memset(&xpp, 0, sizeof(xpp));
        memset(&xecfg, 0, sizeof(xecfg));
        diff_words_fill(&diff_words->minus, &minus, diff_words->word_regex);
        diff_words_fill(&diff_words->plus, &plus, diff_words->word_regex);
-       xpp.flags = XDF_NEED_MINIMAL;
+       xpp.flags = 0;
        /* as only the hunk header will be parsed, we need a 0-context */
        xecfg.ctxlen = 0;
        xdi_diff_outf(&minus, &plus, fn_out_diff_words_aux, diff_words,
@@ -762,11 +884,15 @@ static void diff_words_show(struct diff_words_data *diff_words)
        free(minus.ptr);
        free(plus.ptr);
        if (diff_words->current_plus != diff_words->plus.text.ptr +
-                       diff_words->plus.text.size)
-               fn_out_diff_words_write_helper(diff_words->file,
+                       diff_words->plus.text.size) {
+               if (color_words_output_graph_prefix(diff_words))
+                       fputs(line_prefix, diff_words->opt->file);
+               fn_out_diff_words_write_helper(diff_words->opt->file,
                        &style->ctx, style->newline,
                        diff_words->plus.text.ptr + diff_words->plus.text.size
-                       - diff_words->current_plus, diff_words->current_plus);
+                       - diff_words->current_plus, diff_words->current_plus,
+                       line_prefix);
+       }
        diff_words->minus.text.size = diff_words->plus.text.size = 0;
 }
 
@@ -838,9 +964,17 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
        const char *meta = diff_get_color(ecbdata->color_diff, DIFF_METAINFO);
        const char *plain = diff_get_color(ecbdata->color_diff, DIFF_PLAIN);
        const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
+       struct diff_options *o = ecbdata->opt;
+       char *line_prefix = "";
+       struct strbuf *msgbuf;
+
+       if (o && o->output_prefix) {
+               msgbuf = o->output_prefix(o, o->output_prefix_data);
+               line_prefix = msgbuf->buf;
+       }
 
        if (ecbdata->header) {
-               fprintf(ecbdata->file, "%s", ecbdata->header->buf);
+               fprintf(ecbdata->opt->file, "%s", ecbdata->header->buf);
                strbuf_reset(ecbdata->header);
                ecbdata->header = NULL;
        }
@@ -852,10 +986,10 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
                name_a_tab = strchr(ecbdata->label_path[0], ' ') ? "\t" : "";
                name_b_tab = strchr(ecbdata->label_path[1], ' ') ? "\t" : "";
 
-               fprintf(ecbdata->file, "%s--- %s%s%s\n",
-                       meta, ecbdata->label_path[0], reset, name_a_tab);
-               fprintf(ecbdata->file, "%s+++ %s%s%s\n",
-                       meta, ecbdata->label_path[1], reset, name_b_tab);
+               fprintf(ecbdata->opt->file, "%s%s--- %s%s%s\n",
+                       line_prefix, meta, ecbdata->label_path[0], reset, name_a_tab);
+               fprintf(ecbdata->opt->file, "%s%s+++ %s%s%s\n",
+                       line_prefix, meta, ecbdata->label_path[1], reset, name_b_tab);
                ecbdata->label_path[0] = ecbdata->label_path[1] = NULL;
        }
 
@@ -872,15 +1006,15 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
                find_lno(line, ecbdata);
                emit_hunk_header(ecbdata, line, len);
                if (line[len-1] != '\n')
-                       putc('\n', ecbdata->file);
+                       putc('\n', ecbdata->opt->file);
                return;
        }
 
        if (len < 1) {
-               emit_line(ecbdata->file, reset, reset, line, len);
+               emit_line(ecbdata->opt, reset, reset, line, len);
                if (ecbdata->diff_words
                    && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)
-                       fputs("~\n", ecbdata->file);
+                       fputs("~\n", ecbdata->opt->file);
                return;
        }
 
@@ -896,11 +1030,11 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
                }
                diff_words_flush(ecbdata);
                if (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {
-                       emit_line(ecbdata->file, plain, reset, line, len);
-                       fputs("~\n", ecbdata->file);
+                       emit_line(ecbdata->opt, plain, reset, line, len);
+                       fputs("~\n", ecbdata->opt->file);
                } else {
                        /* don't print the prefix character */
-                       emit_line(ecbdata->file, plain, reset, line+1, len-1);
+                       emit_line(ecbdata->opt, plain, reset, line+1, len-1);
                }
                return;
        }
@@ -912,7 +1046,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
                ecbdata->lno_in_preimage++;
                if (line[0] == ' ')
                        ecbdata->lno_in_postimage++;
-               emit_line(ecbdata->file, color, reset, line, len);
+               emit_line(ecbdata->opt, color, reset, line, len);
        } else {
                ecbdata->lno_in_postimage++;
                emit_add_line(reset, ecbdata, line + 1, len - 1);
@@ -1092,10 +1226,17 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
        int total_files = data->nr;
        int width, name_width;
        const char *reset, *set, *add_c, *del_c;
+       const char *line_prefix = "";
+       struct strbuf *msg = NULL;
 
        if (data->nr == 0)
                return;
 
+       if (options->output_prefix) {
+               msg = options->output_prefix(options, options->output_prefix_data);
+               line_prefix = msg->buf;
+       }
+
        width = options->stat_width ? options->stat_width : 80;
        name_width = options->stat_name_width ? options->stat_name_width : 50;
 
@@ -1165,6 +1306,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
                }
 
                if (data->files[i]->is_binary) {
+                       fprintf(options->file, "%s", line_prefix);
                        show_name(options->file, prefix, name, len);
                        fprintf(options->file, "  Bin ");
                        fprintf(options->file, "%s%"PRIuMAX"%s",
@@ -1177,6 +1319,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
                        continue;
                }
                else if (data->files[i]->is_unmerged) {
+                       fprintf(options->file, "%s", line_prefix);
                        show_name(options->file, prefix, name, len);
                        fprintf(options->file, "  Unmerged\n");
                        continue;
@@ -1199,6 +1342,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
                        add = scale_linear(add, width, max_change);
                        del = scale_linear(del, width, max_change);
                }
+               fprintf(options->file, "%s", line_prefix);
                show_name(options->file, prefix, name, len);
                fprintf(options->file, "%5"PRIuMAX"%s", added + deleted,
                                added + deleted ? " " : "");
@@ -1206,6 +1350,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
                show_graph(options->file, '-', del, del_c, reset);
                fprintf(options->file, "\n");
        }
+       fprintf(options->file, "%s", line_prefix);
        fprintf(options->file,
               " %d files changed, %d insertions(+), %d deletions(-)\n",
               total_files, adds, dels);
@@ -1232,6 +1377,12 @@ static void show_shortstats(struct diffstat_t *data, struct diff_options *option
                        }
                }
        }
+       if (options->output_prefix) {
+               struct strbuf *msg = NULL;
+               msg = options->output_prefix(options,
+                               options->output_prefix_data);
+               fprintf(options->file, "%s", msg->buf);
+       }
        fprintf(options->file, " %d files changed, %d insertions(+), %d deletions(-)\n",
               total_files, adds, dels);
 }
@@ -1246,6 +1397,13 @@ static void show_numstat(struct diffstat_t *data, struct diff_options *options)
        for (i = 0; i < data->nr; i++) {
                struct diffstat_file *file = data->files[i];
 
+               if (options->output_prefix) {
+                       struct strbuf *msg = NULL;
+                       msg = options->output_prefix(options,
+                                       options->output_prefix_data);
+                       fprintf(options->file, "%s", msg->buf);
+               }
+
                if (file->is_binary)
                        fprintf(options->file, "-\t-\t");
                else
@@ -1281,10 +1439,18 @@ struct dirstat_dir {
        int alloc, nr, percent, cumulative;
 };
 
-static long gather_dirstat(FILE *file, struct dirstat_dir *dir, unsigned long changed, const char *base, int baselen)
+static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,
+               unsigned long changed, const char *base, int baselen)
 {
        unsigned long this_dir = 0;
        unsigned int sources = 0;
+       const char *line_prefix = "";
+       struct strbuf *msg = NULL;
+
+       if (opt->output_prefix) {
+               msg = opt->output_prefix(opt, opt->output_prefix_data);
+               line_prefix = msg->buf;
+       }
 
        while (dir->nr) {
                struct dirstat_file *f = dir->files;
@@ -1299,7 +1465,7 @@ static long gather_dirstat(FILE *file, struct dirstat_dir *dir, unsigned long ch
                slash = strchr(f->name + baselen, '/');
                if (slash) {
                        int newbaselen = slash + 1 - f->name;
-                       this = gather_dirstat(file, dir, changed, f->name, newbaselen);
+                       this = gather_dirstat(opt, dir, changed, f->name, newbaselen);
                        sources++;
                } else {
                        this = f->changed;
@@ -1321,7 +1487,8 @@ static long gather_dirstat(FILE *file, struct dirstat_dir *dir, unsigned long ch
                if (permille) {
                        int percent = permille / 10;
                        if (percent >= dir->percent) {
-                               fprintf(file, "%4d.%01d%% %.*s\n", percent, permille % 10, baselen, base);
+                               fprintf(opt->file, "%s%4d.%01d%% %.*s\n", line_prefix,
+                                       percent, permille % 10, baselen, base);
                                if (!dir->cumulative)
                                        return 0;
                        }
@@ -1401,7 +1568,7 @@ static void show_dirstat(struct diff_options *options)
 
        /* Show all directories with more than x% of the changes */
        qsort(dir.files, dir.nr, sizeof(dir.files[0]), dirstat_compare);
-       gather_dirstat(options->file, &dir, changed, "", 0);
+       gather_dirstat(options, &dir, changed, "", 0);
 }
 
 static void free_diffstat_info(struct diffstat_t *diffstat)
@@ -1459,6 +1626,15 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
        const char *reset = diff_get_color(color_diff, DIFF_RESET);
        const char *set = diff_get_color(color_diff, DIFF_FILE_NEW);
        char *err;
+       char *line_prefix = "";
+       struct strbuf *msgbuf;
+
+       assert(data->o);
+       if (data->o->output_prefix) {
+               msgbuf = data->o->output_prefix(data->o,
+                       data->o->output_prefix_data);
+               line_prefix = msgbuf->buf;
+       }
 
        if (line[0] == '+') {
                unsigned bad;
@@ -1466,18 +1642,18 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
                if (is_conflict_marker(line + 1, marker_size, len - 1)) {
                        data->status |= 1;
                        fprintf(data->o->file,
-                               "%s:%d: leftover conflict marker\n",
-                               data->filename, data->lineno);
+                               "%s%s:%d: leftover conflict marker\n",
+                               line_prefix, data->filename, data->lineno);
                }
                bad = ws_check(line + 1, len - 1, data->ws_rule);
                if (!bad)
                        return;
                data->status |= bad;
                err = whitespace_error_string(bad);
-               fprintf(data->o->file, "%s:%d: %s.\n",
-                       data->filename, data->lineno, err);
+               fprintf(data->o->file, "%s%s:%d: %s.\n",
+                       line_prefix, data->filename, data->lineno, err);
                free(err);
-               emit_line(data->o->file, set, reset, line, 1);
+               emit_line(data->o, set, reset, line, 1);
                ws_check_emit(line + 1, len - 1, data->ws_rule,
                              data->o->file, set, reset, ws);
        } else if (line[0] == ' ') {
@@ -1515,7 +1691,7 @@ static unsigned char *deflate_it(char *data,
        return deflated;
 }
 
-static void emit_binary_diff_body(FILE *file, mmfile_t *one, mmfile_t *two)
+static void emit_binary_diff_body(FILE *file, mmfile_t *one, mmfile_t *two, char *prefix)
 {
        void *cp;
        void *delta;
@@ -1544,13 +1720,13 @@ static void emit_binary_diff_body(FILE *file, mmfile_t *one, mmfile_t *two)
        }
 
        if (delta && delta_size < deflate_size) {
-               fprintf(file, "delta %lu\n", orig_size);
+               fprintf(file, "%sdelta %lu\n", prefix, orig_size);
                free(deflated);
                data = delta;
                data_size = delta_size;
        }
        else {
-               fprintf(file, "literal %lu\n", two->size);
+               fprintf(file, "%sliteral %lu\n", prefix, two->size);
                free(delta);
                data = deflated;
                data_size = deflate_size;
@@ -1568,18 +1744,19 @@ static void emit_binary_diff_body(FILE *file, mmfile_t *one, mmfile_t *two)
                        line[0] = bytes - 26 + 'a' - 1;
                encode_85(line + 1, cp, bytes);
                cp = (char *) cp + bytes;
+               fprintf(file, "%s", prefix);
                fputs(line, file);
                fputc('\n', file);
        }
-       fprintf(file, "\n");
+       fprintf(file, "%s\n", prefix);
        free(data);
 }
 
-static void emit_binary_diff(FILE *file, mmfile_t *one, mmfile_t *two)
+static void emit_binary_diff(FILE *file, mmfile_t *one, mmfile_t *two, char *prefix)
 {
-       fprintf(file, "GIT binary patch\n");
-       emit_binary_diff_body(file, one, two);
-       emit_binary_diff_body(file, two, one);
+       fprintf(file, "%sGIT binary patch\n", prefix);
+       emit_binary_diff_body(file, one, two, prefix);
+       emit_binary_diff_body(file, two, one, prefix);
 }
 
 static void diff_filespec_load_driver(struct diff_filespec *one)
@@ -1629,7 +1806,7 @@ void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const
                options->b_prefix = b;
 }
 
-static struct userdiff_driver *get_textconv(struct diff_filespec *one)
+struct userdiff_driver *get_textconv(struct diff_filespec *one)
 {
        if (!DIFF_FILE_VALID(one))
                return NULL;
@@ -1656,6 +1833,7 @@ static void builtin_diff(const char *name_a,
                         struct diff_filespec *one,
                         struct diff_filespec *two,
                         const char *xfrm_msg,
+                        int must_show_header,
                         struct diff_options *o,
                         int complete_rewrite)
 {
@@ -1668,6 +1846,13 @@ static void builtin_diff(const char *name_a,
        struct userdiff_driver *textconv_one = NULL;
        struct userdiff_driver *textconv_two = NULL;
        struct strbuf header = STRBUF_INIT;
+       struct strbuf *msgbuf;
+       char *line_prefix = "";
+
+       if (o->output_prefix) {
+               msgbuf = o->output_prefix(o, o->output_prefix_data);
+               line_prefix = msgbuf->buf;
+       }
 
        if (DIFF_OPT_TST(o, SUBMODULE_LOG) &&
                        (!one->mode || S_ISGITLINK(one->mode)) &&
@@ -1702,25 +1887,28 @@ static void builtin_diff(const char *name_a,
        b_two = quote_two(b_prefix, name_b + (*name_b == '/'));
        lbl[0] = DIFF_FILE_VALID(one) ? a_one : "/dev/null";
        lbl[1] = DIFF_FILE_VALID(two) ? b_two : "/dev/null";
-       strbuf_addf(&header, "%sdiff --git %s %s%s\n", set, a_one, b_two, reset);
+       strbuf_addf(&header, "%s%sdiff --git %s %s%s\n", line_prefix, set, a_one, b_two, reset);
        if (lbl[0][0] == '/') {
                /* /dev/null */
-               strbuf_addf(&header, "%snew file mode %06o%s\n", set, two->mode, reset);
-               if (xfrm_msg && xfrm_msg[0])
-                       strbuf_addf(&header, "%s%s%s\n", set, xfrm_msg, reset);
+               strbuf_addf(&header, "%s%snew file mode %06o%s\n", line_prefix, set, two->mode, reset);
+               if (xfrm_msg)
+                       strbuf_addstr(&header, xfrm_msg);
+               must_show_header = 1;
        }
        else if (lbl[1][0] == '/') {
-               strbuf_addf(&header, "%sdeleted file mode %06o%s\n", set, one->mode, reset);
-               if (xfrm_msg && xfrm_msg[0])
-                       strbuf_addf(&header, "%s%s%s\n", set, xfrm_msg, reset);
+               strbuf_addf(&header, "%s%sdeleted file mode %06o%s\n", line_prefix, set, one->mode, reset);
+               if (xfrm_msg)
+                       strbuf_addstr(&header, xfrm_msg);
+               must_show_header = 1;
        }
        else {
                if (one->mode != two->mode) {
-                       strbuf_addf(&header, "%sold mode %06o%s\n", set, one->mode, reset);
-                       strbuf_addf(&header, "%snew mode %06o%s\n", set, two->mode, reset);
+                       strbuf_addf(&header, "%s%sold mode %06o%s\n", line_prefix, set, one->mode, reset);
+                       strbuf_addf(&header, "%s%snew mode %06o%s\n", line_prefix, set, two->mode, reset);
+                       must_show_header = 1;
                }
-               if (xfrm_msg && xfrm_msg[0])
-                       strbuf_addf(&header, "%s%s%s\n", set, xfrm_msg, reset);
+               if (xfrm_msg)
+                       strbuf_addstr(&header, xfrm_msg);
 
                /*
                 * we do not run diff between different kind
@@ -1747,15 +1935,18 @@ static void builtin_diff(const char *name_a,
                        die("unable to read files to diff");
                /* Quite common confusing case */
                if (mf1.size == mf2.size &&
-                   !memcmp(mf1.ptr, mf2.ptr, mf1.size))
+                   !memcmp(mf1.ptr, mf2.ptr, mf1.size)) {
+                       if (must_show_header)
+                               fprintf(o->file, "%s", header.buf);
                        goto free_ab_and_return;
+               }
                fprintf(o->file, "%s", header.buf);
                strbuf_reset(&header);
                if (DIFF_OPT_TST(o, BINARY))
-                       emit_binary_diff(o->file, &mf1, &mf2);
+                       emit_binary_diff(o->file, &mf1, &mf2, line_prefix);
                else
-                       fprintf(o->file, "Binary files %s and %s differ\n",
-                               lbl[0], lbl[1]);
+                       fprintf(o->file, "%sBinary files %s and %s differ\n",
+                               line_prefix, lbl[0], lbl[1]);
                o->found_changes = 1;
        }
        else {
@@ -1766,7 +1957,7 @@ static void builtin_diff(const char *name_a,
                struct emit_callback ecbdata;
                const struct userdiff_funcname *pe;
 
-               if (!DIFF_XDL_TST(o, WHITESPACE_FLAGS)) {
+               if (!DIFF_XDL_TST(o, WHITESPACE_FLAGS) || must_show_header) {
                        fprintf(o->file, "%s", header.buf);
                        strbuf_reset(&header);
                }
@@ -1787,9 +1978,9 @@ static void builtin_diff(const char *name_a,
                ecbdata.ws_rule = whitespace_rule(name_b ? name_b : name_a);
                if (ecbdata.ws_rule & WS_BLANK_AT_EOF)
                        check_blank_at_eof(&mf1, &mf2, &ecbdata);
-               ecbdata.file = o->file;
+               ecbdata.opt = o;
                ecbdata.header = header.len ? &header : NULL;
-               xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
+               xpp.flags = o->xdl_opts;
                xecfg.ctxlen = o->context;
                xecfg.interhunkctxlen = o->interhunkcontext;
                xecfg.flags = XDL_EMIT_FUNCNAMES;
@@ -1806,8 +1997,8 @@ static void builtin_diff(const char *name_a,
 
                        ecbdata.diff_words =
                                xcalloc(1, sizeof(struct diff_words_data));
-                       ecbdata.diff_words->file = o->file;
                        ecbdata.diff_words->type = o->word_diff;
+                       ecbdata.diff_words->opt = o;
                        if (!o->word_regex)
                                o->word_regex = userdiff_word_regex(one);
                        if (!o->word_regex)
@@ -1894,7 +2085,7 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
 
                memset(&xpp, 0, sizeof(xpp));
                memset(&xecfg, 0, sizeof(xecfg));
-               xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
+               xpp.flags = o->xdl_opts;
                xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
                              &xpp, &xecfg);
        }
@@ -1942,7 +2133,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
                memset(&xpp, 0, sizeof(xpp));
                memset(&xecfg, 0, sizeof(xecfg));
                xecfg.ctxlen = 1; /* at least one context line */
-               xpp.flags = XDF_NEED_MINIMAL;
+               xpp.flags = 0;
                xdi_diff_outf(&mf1, &mf2, checkdiff_consume, &data,
                              &xpp, &xecfg);
 
@@ -2379,36 +2570,53 @@ static void fill_metainfo(struct strbuf *msg,
                          struct diff_filespec *one,
                          struct diff_filespec *two,
                          struct diff_options *o,
-                         struct diff_filepair *p)
+                         struct diff_filepair *p,
+                         int *must_show_header,
+                         int use_color)
 {
+       const char *set = diff_get_color(use_color, DIFF_METAINFO);
+       const char *reset = diff_get_color(use_color, DIFF_RESET);
+       struct strbuf *msgbuf;
+       char *line_prefix = "";
+
+       *must_show_header = 1;
+       if (o->output_prefix) {
+               msgbuf = o->output_prefix(o, o->output_prefix_data);
+               line_prefix = msgbuf->buf;
+       }
        strbuf_init(msg, PATH_MAX * 2 + 300);
        switch (p->status) {
        case DIFF_STATUS_COPIED:
-               strbuf_addf(msg, "similarity index %d%%", similarity_index(p));
-               strbuf_addstr(msg, "\ncopy from ");
+               strbuf_addf(msg, "%s%ssimilarity index %d%%",
+                           line_prefix, set, similarity_index(p));
+               strbuf_addf(msg, "%s\n%s%scopy from ",
+                           reset,  line_prefix, set);
                quote_c_style(name, msg, NULL, 0);
-               strbuf_addstr(msg, "\ncopy to ");
+               strbuf_addf(msg, "%s\n%s%scopy to ", reset, line_prefix, set);
                quote_c_style(other, msg, NULL, 0);
-               strbuf_addch(msg, '\n');
+               strbuf_addf(msg, "%s\n", reset);
                break;
        case DIFF_STATUS_RENAMED:
-               strbuf_addf(msg, "similarity index %d%%", similarity_index(p));
-               strbuf_addstr(msg, "\nrename from ");
+               strbuf_addf(msg, "%s%ssimilarity index %d%%",
+                           line_prefix, set, similarity_index(p));
+               strbuf_addf(msg, "%s\n%s%srename from ",
+                           reset, line_prefix, set);
                quote_c_style(name, msg, NULL, 0);
-               strbuf_addstr(msg, "\nrename to ");
+               strbuf_addf(msg, "%s\n%s%srename to ",
+                           reset, line_prefix, set);
                quote_c_style(other, msg, NULL, 0);
-               strbuf_addch(msg, '\n');
+               strbuf_addf(msg, "%s\n", reset);
                break;
        case DIFF_STATUS_MODIFIED:
                if (p->score) {
-                       strbuf_addf(msg, "dissimilarity index %d%%\n",
-                                   similarity_index(p));
+                       strbuf_addf(msg, "%s%sdissimilarity index %d%%%s\n",
+                                   line_prefix,
+                                   set, similarity_index(p), reset);
                        break;
                }
                /* fallthru */
        default:
-               /* nothing */
-               ;
+               *must_show_header = 0;
        }
        if (one && two && hashcmp(one->sha1, two->sha1)) {
                int abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;
@@ -2419,15 +2627,13 @@ static void fill_metainfo(struct strbuf *msg,
                            (!fill_mmfile(&mf, two) && diff_filespec_is_binary(two)))
                                abbrev = 40;
                }
-               strbuf_addf(msg, "index %.*s..%.*s",
-                           abbrev, sha1_to_hex(one->sha1),
-                           abbrev, sha1_to_hex(two->sha1));
+               strbuf_addf(msg, "%s%sindex %s..", line_prefix, set,
+                           find_unique_abbrev(one->sha1, abbrev));
+               strbuf_addstr(msg, find_unique_abbrev(two->sha1, abbrev));
                if (one->mode == two->mode)
                        strbuf_addf(msg, " %06o", one->mode);
-               strbuf_addch(msg, '\n');
+               strbuf_addf(msg, "%s\n", reset);
        }
-       if (msg->len)
-               strbuf_setlen(msg, msg->len - 1);
 }
 
 static void run_diff_cmd(const char *pgm,
@@ -2442,11 +2648,7 @@ static void run_diff_cmd(const char *pgm,
 {
        const char *xfrm_msg = NULL;
        int complete_rewrite = (p->status == DIFF_STATUS_MODIFIED) && p->score;
-
-       if (msg) {
-               fill_metainfo(msg, name, other, one, two, o, p);
-               xfrm_msg = msg->len ? msg->buf : NULL;
-       }
+       int must_show_header = 0;
 
        if (!DIFF_OPT_TST(o, ALLOW_EXTERNAL))
                pgm = NULL;
@@ -2456,6 +2658,17 @@ static void run_diff_cmd(const char *pgm,
                        pgm = drv->external;
        }
 
+       if (msg) {
+               /*
+                * don't use colors when the header is intended for an
+                * external diff driver
+                */
+               fill_metainfo(msg, name, other, one, two, o, p,
+                             &must_show_header,
+                             DIFF_OPT_TST(o, COLOR_DIFF) && !pgm);
+               xfrm_msg = msg->len ? msg->buf : NULL;
+       }
+
        if (pgm) {
                run_external_diff(pgm, name, other, one, two, xfrm_msg,
                                  complete_rewrite);
@@ -2463,7 +2676,8 @@ static void run_diff_cmd(const char *pgm,
        }
        if (one && two)
                builtin_diff(name, other ? other : name,
-                            one, two, xfrm_msg, o, complete_rewrite);
+                            one, two, xfrm_msg, must_show_header,
+                            o, complete_rewrite);
        else
                fprintf(o->file, "* Unmerged path %s\n", name);
 }
@@ -2616,7 +2830,9 @@ void diff_setup(struct diff_options *options)
                DIFF_OPT_SET(options, COLOR_DIFF);
        options->detect_rename = diff_detect_rename_default;
 
-       if (!diff_mnemonic_prefix) {
+       if (diff_no_prefix) {
+               options->a_prefix = options->b_prefix = "";
+       } else if (!diff_mnemonic_prefix) {
                options->a_prefix = "a/";
                options->b_prefix = "b/";
        }
@@ -2951,7 +3167,9 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
        else if (!strcmp(arg, "--no-textconv"))
                DIFF_OPT_CLR(options, ALLOW_TEXTCONV);
        else if (!strcmp(arg, "--ignore-submodules"))
-               DIFF_OPT_SET(options, IGNORE_SUBMODULES);
+               handle_ignore_submodules_arg(options, "all");
+       else if (!prefixcmp(arg, "--ignore-submodules="))
+               handle_ignore_submodules_arg(options, arg + 20);
        else if (!strcmp(arg, "--submodule"))
                DIFF_OPT_SET(options, SUBMODULE_LOG);
        else if (!prefixcmp(arg, "--submodule=")) {
@@ -3124,6 +3342,11 @@ static void diff_flush_raw(struct diff_filepair *p, struct diff_options *opt)
 {
        int line_termination = opt->line_termination;
        int inter_name_termination = line_termination ? '\t' : '\0';
+       if (opt->output_prefix) {
+               struct strbuf *msg = NULL;
+               msg = opt->output_prefix(opt, opt->output_prefix_data);
+               fprintf(opt->file, "%s", msg->buf);
+       }
 
        if (!(opt->output_format & DIFF_FORMAT_NAME_STATUS)) {
                fprintf(opt->file, ":%06o %06o %s ", p->one->mode, p->two->mode,
@@ -3369,48 +3592,62 @@ static void show_file_mode_name(FILE *file, const char *newdelete, struct diff_f
 }
 
 
-static void show_mode_change(FILE *file, struct diff_filepair *p, int show_name)
+static void show_mode_change(FILE *file, struct diff_filepair *p, int show_name,
+               const char *line_prefix)
 {
        if (p->one->mode && p->two->mode && p->one->mode != p->two->mode) {
-               fprintf(file, " mode change %06o => %06o%c", p->one->mode, p->two->mode,
-                       show_name ? ' ' : '\n');
+               fprintf(file, "%s mode change %06o => %06o%c", line_prefix, p->one->mode,
+                       p->two->mode, show_name ? ' ' : '\n');
                if (show_name) {
                        write_name_quoted(p->two->path, file, '\n');
                }
        }
 }
 
-static void show_rename_copy(FILE *file, const char *renamecopy, struct diff_filepair *p)
+static void show_rename_copy(FILE *file, const char *renamecopy, struct diff_filepair *p,
+                       const char *line_prefix)
 {
        char *names = pprint_rename(p->one->path, p->two->path);
 
        fprintf(file, " %s %s (%d%%)\n", renamecopy, names, similarity_index(p));
        free(names);
-       show_mode_change(file, p, 0);
+       show_mode_change(file, p, 0, line_prefix);
 }
 
-static void diff_summary(FILE *file, struct diff_filepair *p)
+static void diff_summary(struct diff_options *opt, struct diff_filepair *p)
 {
+       FILE *file = opt->file;
+       char *line_prefix = "";
+
+       if (opt->output_prefix) {
+               struct strbuf *buf = opt->output_prefix(opt, opt->output_prefix_data);
+               line_prefix = buf->buf;
+       }
+
        switch(p->status) {
        case DIFF_STATUS_DELETED:
+               fputs(line_prefix, file);
                show_file_mode_name(file, "delete", p->one);
                break;
        case DIFF_STATUS_ADDED:
+               fputs(line_prefix, file);
                show_file_mode_name(file, "create", p->two);
                break;
        case DIFF_STATUS_COPIED:
-               show_rename_copy(file, "copy", p);
+               fputs(line_prefix, file);
+               show_rename_copy(file, "copy", p, line_prefix);
                break;
        case DIFF_STATUS_RENAMED:
-               show_rename_copy(file, "rename", p);
+               fputs(line_prefix, file);
+               show_rename_copy(file, "rename", p, line_prefix);
                break;
        default:
                if (p->score) {
-                       fputs(" rewrite ", file);
+                       fprintf(file, "%s rewrite ", line_prefix);
                        write_name_quoted(p->two->path, file, ' ');
                        fprintf(file, "(%d%%)\n", similarity_index(p));
                }
-               show_mode_change(file, p, !p->score);
+               show_mode_change(file, p, !p->score, line_prefix);
                break;
        }
 }
@@ -3521,7 +3758,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
                                        len2, p->two->path);
                git_SHA1_Update(&ctx, buffer, len1);
 
-               xpp.flags = XDF_NEED_MINIMAL;
+               xpp.flags = 0;
                xecfg.ctxlen = 3;
                xecfg.flags = XDL_EMIT_FUNCNAMES;
                xdi_diff_outf(&mf1, &mf2, patch_id_consume, &data,
@@ -3619,8 +3856,9 @@ void diff_flush(struct diff_options *options)
                show_dirstat(options);
 
        if (output_format & DIFF_FORMAT_SUMMARY && !is_summary_empty(q)) {
-               for (i = 0; i < q->nr; i++)
-                       diff_summary(options->file, q->queue[i]);
+               for (i = 0; i < q->nr; i++) {
+                       diff_summary(options, q->queue[i]);
+               }
                separator++;
        }
 
@@ -4002,9 +4240,9 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
        return strbuf_detach(&buf, outsize);
 }
 
-static size_t fill_textconv(struct userdiff_driver *driver,
-                           struct diff_filespec *df,
-                           char **outbuf)
+size_t fill_textconv(struct userdiff_driver *driver,
+                    struct diff_filespec *df,
+                    char **outbuf)
 {
        size_t size;
 
diff --git a/diff.h b/diff.h
index 9ace08cbae0651d53dd558f80a3d88777b5521c3..063d10ac2216071ef218fab2ad51c13787614acf 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -9,6 +9,9 @@
 struct rev_info;
 struct diff_options;
 struct diff_queue_struct;
+struct strbuf;
+struct diff_filespec;
+struct userdiff_driver;
 
 typedef void (*change_fn_t)(struct diff_options *options,
                 unsigned old_mode, unsigned new_mode,
@@ -25,6 +28,8 @@ typedef void (*add_remove_fn_t)(struct diff_options *options,
 typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
                struct diff_options *options, void *data);
 
+typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data);
+
 #define DIFF_FORMAT_RAW                0x0001
 #define DIFF_FORMAT_DIFFSTAT   0x0002
 #define DIFF_FORMAT_NUMSTAT    0x0004
@@ -71,6 +76,7 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
 #define DIFF_OPT_SUBMODULE_LOG       (1 << 23)
 #define DIFF_OPT_DIRTY_SUBMODULES    (1 << 24)
 #define DIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES (1 << 25)
+#define DIFF_OPT_IGNORE_DIRTY_SUBMODULES (1 << 26)
 
 #define DIFF_OPT_TST(opts, flag)    ((opts)->flags & DIFF_OPT_##flag)
 #define DIFF_OPT_SET(opts, flag)    ((opts)->flags |= DIFF_OPT_##flag)
@@ -130,6 +136,8 @@ struct diff_options {
        add_remove_fn_t add_remove;
        diff_format_fn_t format_callback;
        void *format_callback_data;
+       diff_prefix_fn_t output_prefix;
+       void *output_prefix_data;
 };
 
 enum color_diff {
@@ -141,7 +149,7 @@ enum color_diff {
        DIFF_FILE_NEW = 5,
        DIFF_COMMIT = 6,
        DIFF_WHITESPACE = 7,
-       DIFF_FUNCINFO = 8,
+       DIFF_FUNCINFO = 8
 };
 const char *diff_get_color(int diff_use_color, enum color_diff ix);
 #define diff_get_color_opt(o, ix) \
@@ -287,4 +295,10 @@ extern void diff_no_index(struct rev_info *, int, const char **, int, const char
 
 extern int index_differs_from(const char *def, int diff_flags);
 
+extern size_t fill_textconv(struct userdiff_driver *driver,
+                           struct diff_filespec *df,
+                           char **outbuf);
+
+extern struct userdiff_driver *get_textconv(struct diff_filespec *one);
+
 #endif /* DIFF_H */
diff --git a/dir.c b/dir.c
index 5615f33af187f381f8c2dfe7ab53910fe165fd59..151ea670d961d39394990f122469557b6f217de3 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -31,22 +31,22 @@ static int common_prefix(const char **pathspec)
        if (!slash)
                return 0;
 
+       /*
+        * The first 'prefix' characters of 'path' are common leading
+        * path components among the pathspecs we have seen so far,
+        * including the trailing slash.
+        */
        prefix = slash - path + 1;
        while ((next = *++pathspec) != NULL) {
-               int len = strlen(next);
-               if (len >= prefix && !memcmp(path, next, prefix))
+               int len, last_matching_slash = -1;
+               for (len = 0; len < prefix && next[len] == path[len]; len++)
+                       if (next[len] == '/')
+                               last_matching_slash = len;
+               if (len == prefix)
                        continue;
-               len = prefix - 1;
-               for (;;) {
-                       if (!len)
-                               return 0;
-                       if (next[--len] != '/')
-                               continue;
-                       if (memcmp(path, next, len+1))
-                               continue;
-                       prefix = len + 1;
-                       break;
-               }
+               if (last_matching_slash < 0)
+                       return 0;
+               prefix = last_matching_slash + 1;
        }
        return prefix;
 }
@@ -465,7 +465,7 @@ static struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pat
 enum exist_status {
        index_nonexistent = 0,
        index_directory,
-       index_gitdir,
+       index_gitdir
 };
 
 /*
@@ -533,7 +533,7 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
 enum directory_treatment {
        show_directory,
        ignore_directory,
-       recurse_into_directory,
+       recurse_into_directory
 };
 
 static enum directory_treatment treat_directory(struct dir_struct *dir,
@@ -684,7 +684,7 @@ static int get_dtype(struct dirent *de, const char *path, int len)
 enum path_treatment {
        path_ignored,
        path_handled,
-       path_recurse,
+       path_recurse
 };
 
 static enum path_treatment treat_one_path(struct dir_struct *dir,
index 876c5e53410250b5f2744671e39907c234771af3..83d38d3c2354e8582d5af91c6d529a2f2836dc2c 100644 (file)
@@ -38,8 +38,9 @@ const char *pager_program;
 int pager_use_color = 1;
 const char *editor_program;
 const char *excludes_file;
-int auto_crlf = 0;     /* 1: both ways, -1: only when adding git objects */
+enum auto_crlf auto_crlf = AUTO_CRLF_FALSE;
 int read_replace_refs = 1;
+enum eol eol = EOL_UNSET;
 enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
 unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
index 129a786832c2dc863e33ae2fc039a0212c1751d5..1e5d66ed0ab3b605de670758887b13f146bdd8a5 100644 (file)
@@ -267,7 +267,7 @@ struct hash_list
 typedef enum {
        WHENSPEC_RAW = 1,
        WHENSPEC_RFC2822,
-       WHENSPEC_NOW,
+       WHENSPEC_NOW
 } whenspec_type;
 
 struct recent_command
diff --git a/fsck.c b/fsck.c
index ae9ae1abee8e406e838fc32802aeb2c50ba4ca7d..3d05d4a794a4158a421ce1265422d241e28a5278 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -311,8 +311,6 @@ static int fsck_commit(struct commit *commit, fsck_error error_func)
        err = fsck_ident(&buffer, &commit->object, error_func);
        if (err)
                return err;
-       if (*buffer != '\n')
-               return error_func(&commit->object, FSCK_ERROR, "invalid format - expected blank line");
        if (!commit->tree)
                return error_func(&commit->object, FSCK_ERROR, "could not load commit's tree %s", sha1_to_hex(tree_sha1));
 
index 21f1330a5bf26c955051ce9cf263289d90c7667b..27fc79347af428dd39daa5b550814cc6cf980510 100755 (executable)
@@ -1111,9 +1111,9 @@ sub help_patch_cmd {
        print colored $help_color, <<EOF ;
 y - $verb this hunk$target
 n - do not $verb this hunk$target
-q - quit, do not $verb this hunk nor any of the remaining ones
-a - $verb this and all the remaining hunks in the file
-d - do not $verb this hunk nor any of the remaining hunks in the file
+q - quit; do not $verb this hunk nor any of the remaining ones
+a - $verb this hunk and all later hunks in the file
+d - do not $verb this hunk nor any of the later hunks in the file
 g - select a hunk to go to
 / - search for a hunk matching the given regex
 j - leave this hunk undecided, see next undecided hunk
index 87ffae252b3f2ff88646d142ea9c2dfb38a28953..e7f008c7baae2ff484e16882e199b6b9d75195aa 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -52,6 +52,16 @@ else
        HAS_HEAD=
 fi
 
+cmdline="git am"
+if test '' != "$interactive"
+then
+       cmdline="$cmdline -i"
+fi
+if test '' != "$threeway"
+then
+       cmdline="$cmdline -3"
+fi
+
 sq () {
        git rev-parse --sq-quote "$@"
 }
@@ -66,15 +76,6 @@ stop_here_user_resolve () {
            printf '%s\n' "$resolvemsg"
            stop_here $1
     fi
-    cmdline="git am"
-    if test '' != "$interactive"
-    then
-        cmdline="$cmdline -i"
-    fi
-    if test '' != "$threeway"
-    then
-        cmdline="$cmdline -3"
-    fi
     echo "When you have resolved this problem run \"$cmdline --resolved\"."
     echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"."
     echo "To restore the original branch and stop patching run \"$cmdline --abort\"."
@@ -591,9 +592,11 @@ do
 
                test -s "$dotest/patch" || {
                        echo "Patch is empty.  Was it split wrong?"
+                       echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"."
+                       echo "To restore the original branch and stop patching run \"$cmdline --abort\"."
                        stop_here $this
                }
-               rm -f "$dotest/original-commit"
+               rm -f "$dotest/original-commit" "$dotest/author-script"
                if test -f "$dotest/rebasing" &&
                        commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
                                -e q "$dotest/$msgnum") &&
@@ -602,6 +605,7 @@ do
                        git cat-file commit "$commit" |
                        sed -e '1,/^$/d' >"$dotest/msg-clean"
                        echo "$commit" > "$dotest/original-commit"
+                       get_author_ident_from_commit "$commit" > "$dotest/author-script"
                else
                        {
                                sed -n '/^Subject/ s/Subject: //p' "$dotest/info"
@@ -613,9 +617,14 @@ do
                ;;
        esac
 
-       GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")"
-       GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")"
-       GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
+       if test -f "$dotest/author-script"
+       then
+               eval $(cat "$dotest/author-script")
+       else
+               GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")"
+               GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")"
+               GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
+       fi
 
        if test -z "$GIT_AUTHOR_EMAIL"
        then
@@ -690,7 +699,13 @@ do
        else
            action=yes
        fi
-       FIRSTLINE=$(sed 1q "$dotest/final-commit")
+
+       if test -f "$dotest/final-commit"
+       then
+               FIRSTLINE=$(sed 1q "$dotest/final-commit")
+       else
+               FIRSTLINE=""
+       fi
 
        if test $action = skip
        then
@@ -726,6 +741,8 @@ do
                resolved=
                git diff-index --quiet --cached HEAD -- && {
                        echo "No changes - did you forget to use 'git add'?"
+                       echo "If there is nothing left to stage, chances are that something else"
+                       echo "already introduced the same changes; you might want to skip this patch."
                        stop_here_user_resolve $this
                }
                unmerged=$(git ls-files -u)
index c0198dde4c2c6a61718228ca2ade463c22e0bec3..02a73eeb667e798fca29de25fed6b0b2900f6912 100644 (file)
@@ -200,6 +200,7 @@ extern char *gitbasename(char *);
 #include "compat/bswap.h"
 
 /* General helper functions */
+extern void vreportf(const char *prefix, const char *err, va_list params);
 extern NORETURN void usage(const char *err);
 extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
@@ -224,7 +225,6 @@ static inline const char *skip_prefix(const char *str, const char *prefix)
 #define PROT_READ 1
 #define PROT_WRITE 2
 #define MAP_PRIVATE 1
-#define MAP_FAILED ((void*)-1)
 #endif
 
 #define mmap git_mmap
@@ -253,6 +253,10 @@ extern int git_munmap(void *start, size_t length);
 
 #endif /* NO_MMAP */
 
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
 #ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
 #define on_disk_bytes(st) ((st).st_size)
 #else
@@ -363,7 +367,8 @@ static inline void *gitmempcpy(void *dest, const void *src, size_t n)
 
 extern void release_pack_memory(size_t, int);
 
-extern void set_try_to_free_routine(void (*routine)(size_t));
+typedef void (*try_to_free_t)(size_t);
+extern try_to_free_t set_try_to_free_routine(try_to_free_t);
 
 extern char *xstrdup(const char *str);
 extern void *xmalloc(size_t size);
index 13751db882dd2c40e2c78503eba0d3f941297644..e9f3037df351ceed0262a8995f19903464163af8 100755 (executable)
@@ -183,12 +183,58 @@ if ($state->{method} eq 'pserver') {
        exit 1;
     }
     $line = <STDIN>; chomp $line;
-    unless ($line eq 'anonymous') {
-       print "E Only anonymous user allowed via pserver\n";
-       print "I HATE YOU\n";
-       exit 1;
+    my $user = $line;
+    $line = <STDIN>; chomp $line;
+    my $password = $line;
+
+    if ($user eq 'anonymous') {
+        # "A" will be 1 byte, use length instead in case the
+        # encryption method ever changes (yeah, right!)
+        if (length($password) > 1 ) {
+            print "E Don't supply a password for the `anonymous' user\n";
+            print "I HATE YOU\n";
+            exit 1;
+        }
+
+        # Fall through to LOVE
+    } else {
+        # Trying to authenticate a user
+        if (not exists $cfg->{gitcvs}->{authdb}) {
+            print "E the repo config file needs a [gitcvs] section with an 'authdb' parameter set to the filename of the authentication database\n";
+            print "I HATE YOU\n";
+            exit 1;
+        }
+
+        my $authdb = $cfg->{gitcvs}->{authdb};
+
+        unless (-e $authdb) {
+            print "E The authentication database specified in [gitcvs.authdb] does not exist\n";
+            print "I HATE YOU\n";
+            exit 1;
+        }
+
+        my $auth_ok;
+        open my $passwd, "<", $authdb or die $!;
+        while (<$passwd>) {
+            if (m{^\Q$user\E:(.*)}) {
+                if (crypt($user, descramble($password)) eq $1) {
+                    $auth_ok = 1;
+                }
+            };
+        }
+        close $passwd;
+
+        unless ($auth_ok) {
+            print "I HATE YOU\n";
+            exit 1;
+        }
+
+        # Fall through to LOVE
     }
-    $line = <STDIN>; chomp $line;    # validate the password?
+
+    # For checking whether the user is anonymous on commit
+    $state->{user} = $user;
+
     $line = <STDIN>; chomp $line;
     unless ($line eq "END $request REQUEST") {
        die "E Do not understand $line -- expecting END $request REQUEST\n";
@@ -1271,9 +1317,9 @@ sub req_ci
 
     $log->info("req_ci : " . ( defined($data) ? $data : "[NULL]" ));
 
-    if ( $state->{method} eq 'pserver')
+    if ( $state->{method} eq 'pserver' and $state->{user} eq 'anonymous' )
     {
-        print "error 1 pserver access cannot commit\n";
+        print "error 1 anonymous user cannot commit via pserver\n";
         cleanupWorkTree();
         exit;
     }
@@ -2369,15 +2415,20 @@ sub kopts_from_path
     if ( defined ( $cfg->{gitcvs}{usecrlfattr} ) and
          $cfg->{gitcvs}{usecrlfattr} =~ /\s*(1|true|yes)\s*$/i )
     {
-        my ($val) = check_attr( "crlf", $path );
-        if ( $val eq "set" )
+        my ($val) = check_attr( "text", $path );
+        if ( $val eq "unspecified" )
         {
-            return "";
+            $val = check_attr( "crlf", $path );
         }
-        elsif ( $val eq "unset" )
+        if ( $val eq "unset" )
         {
             return "-kb"
         }
+        elsif ( check_attr( "eol", $path ) ne "unspecified" ||
+                $val eq "set" || $val eq "input" )
+        {
+            return "";
+        }
         else
         {
             $log->info("Unrecognized check_attr crlf $path : $val");
@@ -2586,6 +2637,43 @@ sub cvs_author
     $author;
 }
 
+
+sub descramble
+{
+    # This table is from src/scramble.c in the CVS source
+    my @SHIFTS = (
+        0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
+        16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+        114,120, 53, 79, 96,109, 72,108, 70, 64, 76, 67,116, 74, 68, 87,
+        111, 52, 75,119, 49, 34, 82, 81, 95, 65,112, 86,118,110,122,105,
+        41, 57, 83, 43, 46,102, 40, 89, 38,103, 45, 50, 42,123, 91, 35,
+        125, 55, 54, 66,124,126, 59, 47, 92, 71,115, 78, 88,107,106, 56,
+        36,121,117,104,101,100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48,
+        58,113, 32, 90, 44, 98, 60, 51, 33, 97, 62, 77, 84, 80, 85,223,
+        225,216,187,166,229,189,222,188,141,249,148,200,184,136,248,190,
+        199,170,181,204,138,232,218,183,255,234,220,247,213,203,226,193,
+        174,172,228,252,217,201,131,230,197,211,145,238,161,179,160,212,
+        207,221,254,173,202,146,224,151,140,196,205,130,135,133,143,246,
+        192,159,244,239,185,168,215,144,139,165,180,157,147,186,214,176,
+        227,231,219,169,175,156,206,198,129,164,150,210,154,177,134,127,
+        182,128,158,208,162,132,167,209,149,241,153,251,237,236,171,195,
+        243,233,253,240,194,250,191,155,142,137,245,235,163,242,178,152
+    );
+    my ($str) = @_;
+
+    # This should never happen, the same password format (A) has been
+    # used by CVS since the beginning of time
+    {
+        my $fmt = substr($str, 0, 1);
+        die "invalid password format `$fmt'" unless $fmt eq 'A';
+    }
+
+    my @str = unpack "C*", substr($str, 1);
+    my $ret = join '', map { chr $SHIFTS[$_] } @str;
+    return $ret;
+}
+
+
 package GITCVS::log;
 
 ####
index f6080149c22bad8b3434b874b9e4079ac508ca69..6635fbefdf2a06e556716f91a70181ecf4f3252a 100755 (executable)
@@ -24,6 +24,7 @@ restart        restart the web server
 fqgitdir="$GIT_DIR"
 local="$(git config --bool --get instaweb.local)"
 httpd="$(git config --get instaweb.httpd)"
+root="$(git config --get instaweb.gitwebdir)"
 port=$(git config --get instaweb.port)
 module_path="$(git config --get instaweb.modulepath)"
 
@@ -34,6 +35,9 @@ conf="$GIT_DIR/gitweb/httpd.conf"
 # if installed, it doesn't need further configuration (module_path)
 test -z "$httpd" && httpd='lighttpd -f'
 
+# Default is @@GITWEBDIR@@
+test -z "$root" && root='@@GITWEBDIR@@'
+
 # any untaken local port will do...
 test -z "$port" && port=1234
 
@@ -46,6 +50,12 @@ resolve_full_httpd () {
                        httpd="$httpd -f"
                fi
                ;;
+       *plackup*)
+               # server is started by running via generated gitweb.psgi in $fqgitdir/gitweb
+               full_httpd="$fqgitdir/gitweb/gitweb.psgi"
+               httpd_only="${httpd%% *}" # cut on first space
+               return
+               ;;
        esac
 
        httpd_only="$(echo $httpd | cut -f1 -d' ')"
@@ -57,7 +67,7 @@ resolve_full_httpd () {
                # these days and those are not in most users $PATHs
                # in addition, we may have generated a server script
                # in $fqgitdir/gitweb.
-               for i in /usr/local/sbin /usr/sbin "$fqgitdir/gitweb"
+               for i in /usr/local/sbin /usr/sbin "$root" "$fqgitdir/gitweb"
                do
                        if test -x "$i/$httpd_only"
                        then
@@ -83,8 +93,8 @@ start_httpd () {
 
        # don't quote $full_httpd, there can be arguments to it (-f)
        case "$httpd" in
-       *mongoose*)
-               #The mongoose server doesn't have a daemon mode so we'll have to fork it
+       *mongoose*|*plackup*)
+               #These servers don't have a daemon mode so we'll have to fork it
                $full_httpd "$fqgitdir/gitweb/httpd.conf" &
                #Save the pid before doing anything else (we'll print it later)
                pid=$!
@@ -110,6 +120,20 @@ EOF
 
 stop_httpd () {
        test -f "$fqgitdir/pid" && kill $(cat "$fqgitdir/pid")
+       rm -f "$fqgitdir/pid"
+}
+
+httpd_is_ready () {
+       "$PERL" -MIO::Socket::INET -e "
+local \$| = 1; # turn on autoflush
+exit if (IO::Socket::INET->new('127.0.0.1:$port'));
+print 'Waiting for \'$httpd\' to start ..';
+do {
+       print '.';
+       sleep(1);
+} until (IO::Socket::INET->new('127.0.0.1:$port'));
+print qq! (done)\n!;
+"
 }
 
 while test $# != 0
@@ -159,8 +183,8 @@ done
 mkdir -p "$GIT_DIR/gitweb/tmp"
 GIT_EXEC_PATH="$(git --exec-path)"
 GIT_DIR="$fqgitdir"
-export GIT_EXEC_PATH GIT_DIR
-
+GITWEB_CONFIG="$fqgitdir/gitweb/gitweb_config.perl"
+export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
 
 webrick_conf () {
        # generate a standalone server script in $fqgitdir/gitweb.
@@ -192,7 +216,7 @@ EOF
 
        cat >"$conf" <<EOF
 :Port: $port
-:DocumentRoot: "$fqgitdir/gitweb"
+:DocumentRoot: "$root"
 :DirectoryIndex: ["gitweb.cgi"]
 :PidFile: "$fqgitdir/pid"
 EOF
@@ -201,18 +225,18 @@ EOF
 
 lighttpd_conf () {
        cat > "$conf" <<EOF
-server.document-root = "$fqgitdir/gitweb"
+server.document-root = "$root"
 server.port = $port
 server.modules = ( "mod_setenv", "mod_cgi" )
 server.indexfiles = ( "gitweb.cgi" )
 server.pid-file = "$fqgitdir/pid"
-server.errorlog = "$fqgitdir/gitweb/error.log"
+server.errorlog = "$fqgitdir/gitweb/$httpd_only/error.log"
 
 # to enable, add "mod_access", "mod_accesslog" to server.modules
 # variable above and uncomment this
-#accesslog.filename = "$fqgitdir/gitweb/access.log"
+#accesslog.filename = "$fqgitdir/gitweb/$httpd_only/access.log"
 
-setenv.add-environment = ( "PATH" => env.PATH )
+setenv.add-environment = ( "PATH" => env.PATH, "GITWEB_CONFIG" => env.GITWEB_CONFIG )
 
 cgi.assign = ( ".cgi" => "" )
 
@@ -277,14 +301,15 @@ EOF
 
 apache2_conf () {
        test -z "$module_path" && module_path=/usr/lib/apache2/modules
-       mkdir -p "$GIT_DIR/gitweb/logs"
        bind=
        test x"$local" = xtrue && bind='127.0.0.1:'
        echo 'text/css css' > "$fqgitdir/mime.types"
        cat > "$conf" <<EOF
 ServerName "git-instaweb"
-ServerRoot "$fqgitdir/gitweb"
-DocumentRoot "$fqgitdir/gitweb"
+ServerRoot "$root"
+DocumentRoot "$root"
+ErrorLog "$fqgitdir/gitweb/$httpd_only/error.log"
+CustomLog "$fqgitdir/gitweb/$httpd_only/access.log" combined
 PidFile "$fqgitdir/pid"
 Listen $bind$port
 EOF
@@ -303,13 +328,14 @@ EOF
        # check to see if Dennis Stosberg's mod_perl compatibility patch
        # (<20060621130708.Gcbc6e5c@leonov.stosberg.net>) has been applied
        if test -f "$module_path/mod_perl.so" &&
-          sane_grep 'MOD_PERL' "$GIT_DIR/gitweb/gitweb.cgi" >/dev/null
+          sane_grep 'MOD_PERL' "$root/gitweb.cgi" >/dev/null
        then
                # favor mod_perl if available
                cat >> "$conf" <<EOF
 LoadModule perl_module $module_path/mod_perl.so
 PerlPassEnv GIT_DIR
 PerlPassEnv GIT_EXEC_DIR
+PerlPassEnv GITWEB_CONFIG
 <Location /gitweb.cgi>
        SetHandler perl-script
        PerlResponseHandler ModPerl::Registry
@@ -353,15 +379,15 @@ mongoose_conf() {
 # For detailed description of every option, visit
 # http://code.google.com/p/mongoose/wiki/MongooseManual
 
-root           $fqgitdir/gitweb
+root           $root
 ports          $port
 index_files    gitweb.cgi
 #ssl_cert      $fqgitdir/gitweb/ssl_cert.pem
-error_log      $fqgitdir/gitweb/error.log
-access_log     $fqgitdir/gitweb/access.log
+error_log      $fqgitdir/gitweb/$httpd_only/error.log
+access_log     $fqgitdir/gitweb/$httpd_only/access.log
 
 #cgi setup
-cgi_env                PATH=$PATH,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH
+cgi_env                PATH=$PATH,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH,GITWEB_CONFIG=$GITWEB_CONFIG
 cgi_interp     $PERL
 cgi_ext                cgi,pl
 
@@ -370,41 +396,165 @@ mime_types       .gz=application/x-gzip,.tar.gz=application/x-tgz,.tgz=application/x-t
 EOF
 }
 
-
-script='
-s#^(my|our) \$projectroot =.*#$1 \$projectroot = "'$(dirname "$fqgitdir")'";#;
-s#(my|our) \$gitbin =.*#$1 \$gitbin = "'$GIT_EXEC_PATH'";#;
-s#(my|our) \$projects_list =.*#$1 \$projects_list = \$projectroot;#;
-s#(my|our) \$git_temp =.*#$1 \$git_temp = "'$fqgitdir/gitweb/tmp'";#;'
-
-gitweb_cgi () {
-       cat > "$1.tmp" <<\EOFGITWEB
-@@GITWEB_CGI@@
-EOFGITWEB
-       # Use the configured full path to perl to match the generated
-       # scripts' 'hashpling' line
-       "$PERL" -p -e "$script" "$1.tmp"  > "$1"
-       chmod +x "$1"
-       rm -f "$1.tmp"
+plackup_conf () {
+       # generate a standalone 'plackup' server script in $fqgitdir/gitweb
+       # with embedded configuration; it does not use "$conf" file
+       cat > "$fqgitdir/gitweb/gitweb.psgi" <<EOF
+#!$PERL
+
+# gitweb - simple web interface to track changes in git repositories
+#          PSGI wrapper and server starter (see http://plackperl.org)
+
+use strict;
+
+use IO::Handle;
+use Plack::MIME;
+use Plack::Builder;
+use Plack::App::WrapCGI;
+use CGI::Emulate::PSGI 0.07; # minimum version required to work with gitweb
+
+# mimetype mapping (from lighttpd_conf)
+Plack::MIME->add_type(
+       ".pdf"          =>      "application/pdf",
+       ".sig"          =>      "application/pgp-signature",
+       ".spl"          =>      "application/futuresplash",
+       ".class"        =>      "application/octet-stream",
+       ".ps"           =>      "application/postscript",
+       ".torrent"      =>      "application/x-bittorrent",
+       ".dvi"          =>      "application/x-dvi",
+       ".gz"           =>      "application/x-gzip",
+       ".pac"          =>      "application/x-ns-proxy-autoconfig",
+       ".swf"          =>      "application/x-shockwave-flash",
+       ".tar.gz"       =>      "application/x-tgz",
+       ".tgz"          =>      "application/x-tgz",
+       ".tar"          =>      "application/x-tar",
+       ".zip"          =>      "application/zip",
+       ".mp3"          =>      "audio/mpeg",
+       ".m3u"          =>      "audio/x-mpegurl",
+       ".wma"          =>      "audio/x-ms-wma",
+       ".wax"          =>      "audio/x-ms-wax",
+       ".ogg"          =>      "application/ogg",
+       ".wav"          =>      "audio/x-wav",
+       ".gif"          =>      "image/gif",
+       ".jpg"          =>      "image/jpeg",
+       ".jpeg"         =>      "image/jpeg",
+       ".png"          =>      "image/png",
+       ".xbm"          =>      "image/x-xbitmap",
+       ".xpm"          =>      "image/x-xpixmap",
+       ".xwd"          =>      "image/x-xwindowdump",
+       ".css"          =>      "text/css",
+       ".html"         =>      "text/html",
+       ".htm"          =>      "text/html",
+       ".js"           =>      "text/javascript",
+       ".asc"          =>      "text/plain",
+       ".c"            =>      "text/plain",
+       ".cpp"          =>      "text/plain",
+       ".log"          =>      "text/plain",
+       ".conf"         =>      "text/plain",
+       ".text"         =>      "text/plain",
+       ".txt"          =>      "text/plain",
+       ".dtd"          =>      "text/xml",
+       ".xml"          =>      "text/xml",
+       ".mpeg"         =>      "video/mpeg",
+       ".mpg"          =>      "video/mpeg",
+       ".mov"          =>      "video/quicktime",
+       ".qt"           =>      "video/quicktime",
+       ".avi"          =>      "video/x-msvideo",
+       ".asf"          =>      "video/x-ms-asf",
+       ".asx"          =>      "video/x-ms-asf",
+       ".wmv"          =>      "video/x-ms-wmv",
+       ".bz2"          =>      "application/x-bzip",
+       ".tbz"          =>      "application/x-bzip-compressed-tar",
+       ".tar.bz2"      =>      "application/x-bzip-compressed-tar",
+       ""              =>      "text/plain"
+);
+
+my \$app = builder {
+       # to be able to override \$SIG{__WARN__} to log build time warnings
+       use CGI::Carp; # it sets \$SIG{__WARN__} itself
+
+       my \$logdir = "$fqgitdir/gitweb/$httpd_only";
+       open my \$access_log_fh, '>>', "\$logdir/access.log"
+               or die "Couldn't open access log '\$logdir/access.log': \$!";
+       open my \$error_log_fh,  '>>', "\$logdir/error.log"
+               or die "Couldn't open error log '\$logdir/error.log': \$!";
+
+       \$access_log_fh->autoflush(1);
+       \$error_log_fh->autoflush(1);
+
+       # redirect build time warnings to error.log
+       \$SIG{'__WARN__'} = sub {
+               my \$msg = shift;
+               # timestamp warning like in CGI::Carp::warn
+               my \$stamp = CGI::Carp::stamp();
+               \$msg =~ s/^/\$stamp/gm;
+               print \$error_log_fh \$msg;
+       };
+
+       # write errors to error.log, access to access.log
+       enable 'AccessLog',
+               format => "combined",
+               logger => sub { print \$access_log_fh @_; };
+       enable sub {
+               my \$app = shift;
+               sub {
+                       my \$env = shift;
+                       \$env->{'psgi.errors'} = \$error_log_fh;
+                       \$app->(\$env);
+               }
+       };
+       # gitweb currently doesn't work with $SIG{CHLD} set to 'IGNORE',
+       # because it uses 'close $fd or die...' on piped filehandle $fh
+       # (which causes the parent process to wait for child to finish).
+       enable_if { \$SIG{'CHLD'} eq 'IGNORE' } sub {
+               my \$app = shift;
+               sub {
+                       my \$env = shift;
+                       local \$SIG{'CHLD'} = 'DEFAULT';
+                       local \$SIG{'CLD'}  = 'DEFAULT';
+                       \$app->(\$env);
+               }
+       };
+       # serve static files, i.e. stylesheet, images, script
+       enable 'Static',
+               path => sub { m!\.(js|css|png)\$! && s!^/gitweb/!! },
+               root => "$root/",
+               encoding => 'utf-8'; # encoding for 'text/plain' files
+       # convert CGI application to PSGI app
+       Plack::App::WrapCGI->new(script => "$root/gitweb.cgi")->to_app;
+};
+
+# make it runnable as standalone app,
+# like it would be run via 'plackup' utility
+if (__FILE__ eq \$0) {
+       require Plack::Runner;
+
+       my \$runner = Plack::Runner->new();
+       \$runner->parse_options(qw(--env deployment --port $port),
+                              "$local" ? qw(--host 127.0.0.1) : ());
+       \$runner->run(\$app);
 }
+__END__
+EOF
 
-gitweb_css () {
-       cat > "$1" <<\EOFGITWEB
-@@GITWEB_CSS@@
-
-EOFGITWEB
+       chmod a+x "$fqgitdir/gitweb/gitweb.psgi"
+       # configuration is embedded in server script file, gitweb.psgi
+       rm -f "$conf"
 }
 
-gitweb_js () {
-       cat > "$1" <<\EOFGITWEB
-@@GITWEB_JS@@
-
-EOFGITWEB
+gitweb_conf() {
+       cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
+#!/usr/bin/perl
+our \$projectroot = "$(dirname "$fqgitdir")";
+our \$git_temp = "$fqgitdir/gitweb/tmp";
+our \$projects_list = \$projectroot;
+EOF
 }
 
-gitweb_cgi "$GIT_DIR/gitweb/gitweb.cgi"
-gitweb_css "$GIT_DIR/@@GITWEB_CSS_NAME@@"
-gitweb_js  "$GIT_DIR/@@GITWEB_JS_NAME@@"
+gitweb_conf
+
+resolve_full_httpd
+mkdir -p "$fqgitdir/gitweb/$httpd_only"
 
 case "$httpd" in
 *lighttpd*)
@@ -419,6 +569,9 @@ webrick)
 *mongoose*)
        mongoose_conf
        ;;
+*plackup*)
+       plackup_conf
+       ;;
 *)
        echo "Unknown httpd specified: $httpd"
        exit 1
@@ -429,7 +582,7 @@ start_httpd
 url=http://127.0.0.1:$port
 
 if test -n "$browser"; then
-       git web--browse -b "$browser" $url || echo $url
+       httpd_is_ready && git web--browse -b "$browser" $url || echo $url
 else
-       git web--browse -c "instaweb.browser" $url || echo $url
+       httpd_is_ready && git web--browse -c "instaweb.browser" $url || echo $url
 fi
index d067894bf45fd0a50513e196ea2a5e671d901681..b86402afa5d079df8d1cf6eebb15e5727cc8a5de 100755 (executable)
@@ -107,7 +107,7 @@ case "${1:-.}${2:-.}${3:-.}" in
                # remove lines that are unique to ours.
                orig=`git-unpack-file $2`
                sz0=`wc -c <"$orig"`
-               diff -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add
+               @@DIFF@@ -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add
                sz1=`wc -c <"$orig"`
 
                # If we do not have enough common material, it is not
index 1a4729f7bb29205fb7bc251887dcd4f5237f1659..a09a44ec4ce3d82cebc5f972f09e94c7c35dc948 100755 (executable)
@@ -43,6 +43,7 @@ merge_args=
 curr_branch=$(git symbolic-ref -q HEAD)
 curr_branch_short="${curr_branch#refs/heads/}"
 rebase=$(git config --bool branch.$curr_branch_short.rebase)
+dry_run=
 while :
 do
        case "$1" in
@@ -104,6 +105,9 @@ do
        --no-r|--no-re|--no-reb|--no-reba|--no-rebas|--no-rebase)
                rebase=false
                ;;
+       --d|--dr|--dry|--dry-|--dry-r|--dry-ru|--dry-run)
+               dry_run=--dry-run
+               ;;
        -h|--h|--he|--hel|--help)
                usage
                ;;
@@ -216,7 +220,8 @@ test true = "$rebase" && {
        done
 }
 orig_head=$(git rev-parse -q --verify HEAD)
-git fetch $verbosity $progress --update-head-ok "$@" || exit 1
+git fetch $verbosity $progress $dry_run --update-head-ok "$@" || exit 1
+test -z "$dry_run" || exit 0
 
 curr_head=$(git rev-parse -q --verify HEAD)
 if test -n "$orig_head" && test "$curr_head" != "$orig_head"
index 436b7f5977c05c347debc12130f822af482c03e3..31e68603f4e8124fd67f42c8aae6033a792892cb 100755 (executable)
@@ -263,10 +263,10 @@ pick_one_preserving_merges () {
        then
                if test "$fast_forward" = t
                then
-                       cat "$DOTEST"/current-commit | while read current_commit
+                       while read current_commit
                        do
                                git rev-parse HEAD > "$REWRITTEN"/$current_commit
-                       done
+                       done <"$DOTEST"/current-commit
                        rm "$DOTEST"/current-commit ||
                        die "Cannot write current commit's replacement sha1"
                fi
@@ -440,9 +440,9 @@ record_in_rewritten() {
        echo "$oldsha1" >> "$REWRITTEN_PENDING"
 
        case "$(peek_next_command)" in
-           squash|s|fixup|f)
+       squash|s|fixup|f)
                ;;
-           *)
+       *)
                flush_rewritten_pending
                ;;
        esac
@@ -450,7 +450,7 @@ record_in_rewritten() {
 
 do_next () {
        rm -f "$MSG" "$AUTHOR_SCRIPT" "$AMEND" || exit
-       read command sha1 rest < "$TODO"
+       read -r command sha1 rest < "$TODO"
        case "$command" in
        '#'*|''|noop)
                mark_action_done
@@ -591,7 +591,7 @@ do_rest () {
 # skip picking commits whose parents are unchanged
 skip_unnecessary_picks () {
        fd=3
-       while read command sha1 rest
+       while read -r command sha1 rest
        do
                # fd=3 means we skip the command
                case "$fd,$command,$(git rev-parse --verify --quiet $sha1^)" in
@@ -644,13 +644,13 @@ rearrange_squash () {
        test -s "$1.sq" || return
 
        used=
-       while read pick sha1 message
+       while read -r pick sha1 message
        do
                case " $used" in
                *" $sha1 "*) continue ;;
                esac
                echo "$pick $sha1 $message"
-               while read squash action msg
+               while read -r squash action msg
                do
                        case "$message" in
                        "$msg"*)
@@ -890,7 +890,8 @@ first and then run 'git rebase --continue' again."
                git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
                        --abbrev=7 --reverse --left-right --topo-order \
                        $REVISIONS | \
-                       sed -n "s/^>//p" | while read shortsha1 rest
+                       sed -n "s/^>//p" |
+               while read -r shortsha1 rest
                do
                        if test t != "$PRESERVE_MERGES"
                        then
@@ -974,8 +975,9 @@ EOF
 
                test -d "$REWRITTEN" || test -n "$NEVER_FF" || skip_unnecessary_picks
 
+               output git checkout $ONTO || die_abort "could not detach HEAD"
                git update-ref ORIG_HEAD $HEAD
-               output git checkout $ONTO && do_rest
+               do_rest
                ;;
        esac
        shift
index 44f5c65fdb5e81c4b660a666c2edd71aa75c5c1a..ab4afa7dee377707484e7f76c7d44ac955f09397 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Junio C Hamano.
 #
 
-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'
+USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--onto <newbase>] (<upstream>|--root) [<branch>] [--quiet | -q]'
 LONG_USAGE='git-rebase replaces <branch> with a new branch of the
 same name.  When the --onto option is provided the new branch starts
 out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
@@ -198,14 +198,6 @@ test -f "$GIT_DIR"/rebase-apply/applying &&
 
 is_interactive "$@" && exec git-rebase--interactive "$@"
 
-if test $# -eq 0
-then
-       test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || usage
-       test -d "$dotest" -o -f "$GIT_DIR"/rebase-apply/rebasing &&
-               die 'A rebase is in progress, try --continue, --skip or --abort.'
-       die "No arguments given and $GIT_DIR/rebase-apply already exists."
-fi
-
 while test $# != 0
 do
        case "$1" in
@@ -370,6 +362,13 @@ do
 done
 test $# -gt 2 && usage
 
+if test $# -eq 0 && test -z "$rebase_root"
+then
+       test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || usage
+       test -d "$dotest" -o -f "$GIT_DIR"/rebase-apply/rebasing &&
+               die 'A rebase is in progress, try --continue, --skip or --abort.'
+fi
+
 # Make sure we do not have $GIT_DIR/rebase-apply
 if test -z "$do_merge"
 then
index 92539222c57d1966f847a641c976754f1941dc2b..df9d512f1a966635828cb7a8dadde3b0c2b7b9d8 100644 (file)
@@ -1,6 +1,12 @@
 #!/usr/bin/env python
 
-import hashlib
+# hashlib is only available in python >= 2.5
+try:
+    import hashlib
+    _digest = hashlib.sha1
+except ImportError:
+    import sha
+    _digest = sha.new
 import sys
 import os
 sys.path.insert(0, os.getenv("GITPYTHONLIB","."))
@@ -19,7 +25,7 @@ def get_repo(alias, url):
     repo.get_revs()
     repo.get_head()
 
-    hasher = hashlib.sha1()
+    hasher = _digest()
     hasher.update(repo.path)
     repo.hash = hasher.hexdigest()
 
@@ -133,7 +139,10 @@ def do_export(repo, args):
 
     path = os.path.join(dirname, 'testgit.marks')
     print path
-    print path if os.path.exists(path) else ""
+    if os.path.exists(path):
+        print path
+    else:
+        print ""
     sys.stdout.flush()
 
     update_local_repo(repo)
index 74238b031370a02d8456aeee9003977f001bd9c7..6fdea397ddec3cfa4ff37cdf672e7cced840bb60 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/sh
 # Copyright 2005, Ryan Anderson <ryan@michonline.com>
 #
 # This file is licensed under the GPL v2, or a later version
@@ -70,10 +70,10 @@ git show -s --format='The following changes since commit %H:
 
   %s (%ci)
 
-are available in the git repository at:' $baserev
-echo "  $url $branch"
-echo
+are available in the git repository at:' $baserev &&
+echo "  $url $branch" &&
+echo &&
 
-git shortlog ^$baserev $headrev
-git diff -M --stat --summary $patch $merge_base..$headrev
+git shortlog ^$baserev $headrev &&
+git diff -M --stat --summary $patch $merge_base..$headrev || exit
 exit $status
index 111c981229bf2c0bc6afa4a22db011b68d93fdfa..6dab3bf6a74bb52c7294e33dbac5bf87b51a9fdf 100755 (executable)
@@ -54,6 +54,7 @@ git send-email [options] <file | directory | rev-list options >
     --in-reply-to           <str>  * Email "In-Reply-To:"
     --annotate                     * Review each patch that will be sent in an editor.
     --compose                      * Open an editor for introduction.
+    --8bit-encoding         <str>  * Encoding to assume 8bit mails if undeclared
 
   Sending:
     --envelope-sender       <str>  * Email envelope sender.
@@ -191,6 +192,7 @@ my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);
 my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain);
 my ($validate, $confirm);
 my (@suppress_cc);
+my ($auto_8bit_encoding);
 
 my ($debug_net_smtp) = 0;              # Net::SMTP, see send_message()
 
@@ -222,6 +224,7 @@ my %config_settings = (
     "multiedit" => \$multiedit,
     "confirm"   => \$confirm,
     "from" => \$sender,
+    "assume8bitencoding" => \$auto_8bit_encoding,
 );
 
 # Help users prepare for 1.7.0
@@ -297,6 +300,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
                    "thread!" => \$thread,
                    "validate!" => \$validate,
                    "format-patch!" => \$format_patch,
+                   "8bit-encoding=s" => \$auto_8bit_encoding,
         );
 
 unless ($rc) {
@@ -669,6 +673,35 @@ sub ask {
        return undef;
 }
 
+my %broken_encoding;
+
+sub file_declares_8bit_cte($) {
+       my $fn = shift;
+       open (my $fh, '<', $fn);
+       while (my $line = <$fh>) {
+               last if ($line =~ /^$/);
+               return 1 if ($line =~ /^Content-Transfer-Encoding: .*8bit.*$/);
+       }
+       close $fh;
+       return 0;
+}
+
+foreach my $f (@files) {
+       next unless (body_or_subject_has_nonascii($f)
+                    && !file_declares_8bit_cte($f));
+       $broken_encoding{$f} = 1;
+}
+
+if (!defined $auto_8bit_encoding && scalar %broken_encoding) {
+       print "The following files are 8bit, but do not declare " .
+               "a Content-Transfer-Encoding.\n";
+       foreach my $f (sort keys %broken_encoding) {
+               print "    $f\n";
+       }
+       $auto_8bit_encoding = ask("Which 8bit encoding should I declare [UTF-8]? ",
+                                 default => "UTF-8");
+}
+
 my $prompting = 0;
 if (!defined $sender) {
        $sender = $repoauthor || $repocommitter || '';
@@ -1221,6 +1254,18 @@ foreach my $t (@files) {
                        or die "(cc-cmd) failed to close pipe to '$cc_cmd'";
        }
 
+       if ($broken_encoding{$t} && !$has_content_type) {
+               $has_content_type = 1;
+               push @xh, "MIME-Version: 1.0",
+                       "Content-Type: text/plain; charset=$auto_8bit_encoding",
+                       "Content-Transfer-Encoding: 8bit";
+               $body_encoding = $auto_8bit_encoding;
+       }
+
+       if ($broken_encoding{$t} && !is_rfc2047_quoted($subject)) {
+               $subject = quote_rfc2047($subject, $auto_8bit_encoding);
+       }
+
        if (defined $author and $author ne $sender) {
                $message = "From: $author\n\n$message";
                if (defined $author_encoding) {
@@ -1233,6 +1278,7 @@ foreach my $t (@files) {
                                }
                        }
                        else {
+                               $has_content_type = 1;
                                push @xh,
                                  'MIME-Version: 1.0',
                                  "Content-Type: text/plain; charset=$author_encoding",
@@ -1310,3 +1356,17 @@ sub file_has_nonascii {
        }
        return 0;
 }
+
+sub body_or_subject_has_nonascii {
+       my $fn = shift;
+       open(my $fh, '<', $fn)
+               or die "unable to open $fn: $!\n";
+       while (my $line = <$fh>) {
+               last if $line =~ /^$/;
+               return 1 if $line =~ /^Subject.*[^[:ascii:]]/;
+       }
+       while (my $line = <$fh>) {
+               return 1 if $line =~ /[^[:ascii:]]/;
+       }
+       return 0;
+}
index 8175cb279d38a663fc0481e2b11f4b5ea60f8a32..ad2417d1b0827b80ec884009447adada0ddb8173 100755 (executable)
@@ -234,12 +234,12 @@ cmd_add()
                ) || die "Unable to checkout submodule '$path'"
        fi
 
-       git add "$path" ||
+       git add --force "$path" ||
        die "Failed to add submodule '$path'"
 
        git config -f .gitmodules submodule."$path".path "$path" &&
        git config -f .gitmodules submodule."$path".url "$repo" &&
-       git add .gitmodules ||
+       git add --force .gitmodules ||
        die "Failed to register submodule '$path'"
 }
 
@@ -271,6 +271,8 @@ cmd_foreach()
                shift
        done
 
+       toplevel=$(pwd)
+
        module_list |
        while read mode sha1 stage path
        do
@@ -578,7 +580,7 @@ cmd_summary() {
 
        cd_to_toplevel
        # Get modified modules cared by user
-       modules=$(git $diff_cmd $cached --raw $head -- "$@" |
+       modules=$(git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- "$@" |
                sane_egrep '^:([0-7]* )?160000' |
                while read mod_src mod_dst sha1_src sha1_dst status name
                do
@@ -592,7 +594,7 @@ cmd_summary() {
 
        test -z "$modules" && return
 
-       git $diff_cmd $cached --raw $head -- $modules |
+       git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- $modules |
        sane_egrep '^:([0-7]* )?160000' |
        cut -c2- |
        while read mod_src mod_dst sha1_src sha1_dst status name
@@ -758,7 +760,7 @@ cmd_status()
                        continue;
                fi
                set_name_rev "$path" "$sha1"
-               if git diff-files --quiet -- "$path"
+               if git diff-files --ignore-submodules=dirty --quiet -- "$path"
                then
                        say " $sha1 $displaypath$revname"
                else
index 09c4ca56f0c9af9c6ff49d3b3a197a8e30602520..19d6848d0e7754b9afb9fdbbac6fce31286468a5 100755 (executable)
@@ -963,6 +963,7 @@ sub cmd_multi_init {
        }
        do_git_init_db();
        if (defined $_trunk) {
+               $_trunk =~ s#^/+##;
                my $trunk_ref = 'refs/remotes/' . $_prefix . 'trunk';
                # try both old-style and new-style lookups:
                my $gs_trunk = eval { Git::SVN->new($trunk_ref) };
@@ -2054,6 +2055,9 @@ sub new {
                         "\":$ref_id\$\" in config\n";
                ($self->{path}, undef) = split(/\s*:\s*/, $fetch);
        }
+       $self->{path} =~ s{/+}{/}g;
+       $self->{path} =~ s{\A/}{};
+       $self->{path} =~ s{/\z}{};
        $self->{url} = command_oneline('config', '--get',
                                       "svn-remote.$repo_id.url") or
                   die "Failed to read \"svn-remote.$repo_id.url\" in config\n";
index a578c3a73203fbf1bf4abfb024b1e83c45f2b2ce..dbded76aaf5499dd116e5ad22f95d4518b79c0d8 100755 (executable)
@@ -31,7 +31,7 @@ valid_custom_tool()
 
 valid_tool() {
        case "$1" in
-               firefox | iceweasel | konqueror | w3m | links | lynx | dillo | open | start)
+               firefox | iceweasel | chrome | chromium | konqueror | w3m | links | lynx | dillo | open | start)
                        ;; # happy
                *)
                        valid_custom_tool "$1" || return 1
@@ -103,7 +103,7 @@ fi
 
 if test -z "$browser" ; then
     if test -n "$DISPLAY"; then
-       browser_candidates="firefox iceweasel konqueror w3m links lynx dillo"
+       browser_candidates="firefox iceweasel chrome chromium konqueror w3m links lynx dillo"
        if test "$KDE_FULL_SESSION" = "true"; then
            browser_candidates="konqueror $browser_candidates"
        fi
@@ -146,6 +146,11 @@ case "$browser" in
        test "$vers" -lt 2 && NEWTAB=''
        "$browser_path" $NEWTAB "$@" &
        ;;
+    chrome|chromium)
+       # Actual command for chromium is chromium-browser.
+       # No need to specify newTab. It's default in chromium
+       eval "$browser_path" "$@" &
+       ;;
     konqueror)
        case "$(basename "$browser_path")" in
            konqueror)
index 9533147ff2e06282dc8d60aeb371afa715e22cc1..91c8462b7dae171247c40db7f7b5b36d2c0633a1 100644 (file)
@@ -35,6 +35,7 @@ Requires:     git-cvs = %{version}-%{release}
 Requires:      git-arch = %{version}-%{release}
 Requires:      git-email = %{version}-%{release}
 Requires:      gitk = %{version}-%{release}
+Requires:      gitweb = %{version}-%{release}
 Requires:      git-gui = %{version}-%{release}
 Obsoletes:     git <= 1.5.4.2
 
@@ -87,6 +88,13 @@ Requires:       git = %{version}-%{release}, tk >= 8.4
 %description -n gitk
 Git revision tree visualiser ('gitk')
 
+%package -n gitweb
+Summary:       Git web interface
+Group:          Development/Tools
+Requires:       git = %{version}-%{release}
+%description -n gitweb
+Browsing git repository on the web
+
 %package -n perl-Git
 Summary:        Perl interface to Git
 Group:          Development/Libraries
@@ -189,6 +197,10 @@ rm -rf $RPM_BUILD_ROOT
 %{!?_without_docs: %{_mandir}/man1/*gitk*.1*}
 %{!?_without_docs: %doc Documentation/*gitk*.html }
 
+%files -n gitweb
+%defattr(-,root,root)
+%{_datadir}/gitweb
+
 %files -n perl-Git -f perl-files
 %defattr(-,root,root)
 
@@ -196,6 +208,9 @@ rm -rf $RPM_BUILD_ROOT
 # No files for you!
 
 %changelog
+* Wed Jun 30 2010 Junio C Hamano <gitster@pobox.com>
+- Add 'gitweb' subpackage.
+
 * Fri Mar 26 2010 Ian Ward Comfort <icomfort@stanford.edu>
 - Ship bash completion support from contrib/ in the core package.
 
index dfaab00b5fe971a6d2379710795b3038dd851e90..f40f9d6a29cda39ee7f989e11ef66cdf3d54d625 100644 (file)
@@ -48,4 +48,6 @@ class GitExporter(object):
 
         args = ["sed", "s_refs/heads/_" + self.repo.prefix + "_g"]
 
-        subprocess.check_call(args, stdin=p1.stdout)
+        child = subprocess.Popen(args, stdin=p1.stdout)
+        if child.wait() != 0:
+            raise CalledProcessError
index af2919d92cee77b5e806dfdcb8361187d86e4b0e..70a712729b63047b9760b72d3e2b0a45ff176646 100644 (file)
@@ -35,4 +35,6 @@ class GitImporter(object):
         if os.path.exists(path):
             args.append("--import-marks=" + path)
 
-        subprocess.check_call(args)
+        child = subprocess.Popen(args)
+        if child.wait() != 0:
+            raise CalledProcessError
index d75ef8f214fda0748d7f8d690d3a811aa07d76c1..f27389bb945ef423dc412c2368762439086f593e 100644 (file)
@@ -29,7 +29,9 @@ class NonLocalGit(object):
         os.makedirs(path)
         args = ["git", "clone", "--bare", "--quiet", self.repo.gitpath, path]
 
-        subprocess.check_call(args)
+        child = subprocess.Popen(args)
+        if child.wait() != 0:
+            raise CalledProcessError
 
         return path
 
@@ -43,10 +45,14 @@ class NonLocalGit(object):
             die("could not find repo at %s", path)
 
         args = ["git", "--git-dir=" + path, "fetch", "--quiet", self.repo.gitpath]
-        subprocess.check_call(args)
+        child = subprocess.Popen(args)
+        if child.wait() != 0:
+            raise CalledProcessError
 
         args = ["git", "--git-dir=" + path, "update-ref", "refs/heads/master", "FETCH_HEAD"]
-        subprocess.check_call(args)
+        child = subprocess.Popen(args)
+        if child.wait() != 0:
+            raise CalledProcessError
 
     def push(self, base):
         """Pushes from the non-local repo to base.
@@ -58,4 +64,6 @@ class NonLocalGit(object):
             die("could not find repo at %s", path)
 
         args = ["git", "--git-dir=" + path, "push", "--quiet", self.repo.gitpath]
-        subprocess.check_call(args)
+        child = subprocess.Popen(args)
+        if child.wait() != 0:
+            raise CalledProcessError
index 82d5f78c7eeb3eef7e307d654b424b4c831bf2ba..58e1cdb560fa0fe1a4745f971064e5e967408502 100644 (file)
@@ -19,7 +19,10 @@ def is_remote(url):
 
     prefixes = ["http", "file", "git"]
 
-    return any(url.startswith(i) for i in prefixes)
+    for prefix in prefixes:
+        if url.startswith(prefix):
+            return True
+    return False
 
 class GitRepo(object):
     """Repo object representing a repo.
@@ -50,7 +53,9 @@ class GitRepo(object):
         path = ".cached_revs"
         ofile = open(path, "w")
 
-        subprocess.check_call(args, stdout=ofile)
+        child = subprocess.Popen(args, stdout=ofile)
+        if child.wait() != 0:
+            raise CalledProcessError
         output = open(path).readlines()
         self.revmap = dict(sanitize(i) for i in output)
         if "HEAD" in self.revmap:
index d484d76b753ef3d4ca0d75725e44f3c58ab2b482..823053173c92e4097dad54945db16f42b4b5d994 100644 (file)
@@ -2,9 +2,10 @@ GIT web Interface (gitweb) Installation
 =======================================
 
 First you have to generate gitweb.cgi from gitweb.perl using
-"make gitweb", then copy appropriate files (gitweb.cgi, gitweb.js,
-gitweb.css, git-logo.png and git-favicon.png) to their destination.
-For example if git was (or is) installed with /usr prefix, you can do
+"make gitweb", then "make install-gitweb" appropriate files
+(gitweb.cgi, gitweb.js, gitweb.css, git-logo.png and git-favicon.png)
+to their destination. For example if git was (or is) installed with
+/usr prefix and gitwebdir is /var/www/cgi-bin, you can do
 
        $ make prefix=/usr gitweb                            ;# as yourself
        # make gitwebdir=/var/www/cgi-bin install-gitweb     ;# as root
@@ -81,16 +82,14 @@ Build example
   minifiers, you can do
 
        make GITWEB_PROJECTROOT="/home/local/scm" \
-            GITWEB_JS="/gitweb/gitweb.js" \
-            GITWEB_CSS="/gitweb/gitweb.css" \
-            GITWEB_LOGO="/gitweb/git-logo.png" \
-            GITWEB_FAVICON="/gitweb/git-favicon.png" \
+            GITWEB_JS="gitweb/static/gitweb.js" \
+            GITWEB_CSS="gitweb/static/gitweb.css" \
+            GITWEB_LOGO="gitweb/static/git-logo.png" \
+            GITWEB_FAVICON="gitweb/static/git-favicon.png" \
             bindir=/usr/local/bin \
             gitweb
 
-       cp -fv gitweb/gitweb.{cgi,js,css} \
-              gitweb/git-{favicon,logo}.png \
-            /var/www/cgi-bin/gitweb/
+       make gitwebdir=/var/www/cgi-bin/gitweb install-gitweb
 
 
 Gitweb config file
index 935d2d2e0775234fc99a29fd5b7610978a00099f..2fb7c2d77bbd5f2041341822859dce51ae504d83 100644 (file)
@@ -4,10 +4,10 @@ all::
 # Define V=1 to have a more verbose compile.
 #
 # Define JSMIN to point to JavaScript minifier that functions as
-# a filter to have gitweb.js minified.
+# a filter to have static/gitweb.js minified.
 #
 # Define CSSMIN to point to a CSS minifier in order to generate a minified
-# version of gitweb.css
+# version of static/gitweb.css
 #
 
 prefix ?= $(HOME)
@@ -29,10 +29,10 @@ GITWEB_STRICT_EXPORT =
 GITWEB_BASE_URL =
 GITWEB_LIST =
 GITWEB_HOMETEXT = indextext.html
-GITWEB_CSS = gitweb.css
-GITWEB_LOGO = git-logo.png
-GITWEB_FAVICON = git-favicon.png
-GITWEB_JS = gitweb.js
+GITWEB_CSS = static/gitweb.css
+GITWEB_LOGO = static/git-logo.png
+GITWEB_FAVICON = static/git-favicon.png
+GITWEB_JS = static/gitweb.js
 GITWEB_SITE_HEADER =
 GITWEB_SITE_FOOTER =
 
@@ -54,6 +54,7 @@ PERL_PATH  ?= /usr/bin/perl
 # Shell quote;
 bindir_SQ = $(subst ','\'',$(bindir))#'
 gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
+gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#'
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
 PERL_PATH_SQ  = $(subst ','\'',$(PERL_PATH))#'
 DESTDIR_SQ    = $(subst ','\'',$(DESTDIR))#'
@@ -88,26 +89,26 @@ all:: gitweb.cgi
 GITWEB_PROGRAMS = gitweb.cgi
 
 ifdef JSMIN
-GITWEB_FILES += gitweb.min.js
-GITWEB_JS = gitweb.min.js
-all:: gitweb.min.js
-gitweb.min.js: gitweb.js GITWEB-BUILD-OPTIONS
+GITWEB_FILES += static/gitweb.min.js
+GITWEB_JS = static/gitweb.min.js
+all:: static/gitweb.min.js
+static/gitweb.min.js: static/gitweb.js GITWEB-BUILD-OPTIONS
        $(QUIET_GEN)$(JSMIN) <$< >$@
 else
-GITWEB_FILES += gitweb.js
+GITWEB_FILES += static/gitweb.js
 endif
 
 ifdef CSSMIN
-GITWEB_FILES += gitweb.min.css
-GITWEB_CSS = gitweb.min.css
-all:: gitweb.min.css
-gitweb.min.css: gitweb.css GITWEB-BUILD-OPTIONS
-       $(QUIET_GEN)$(CSSMIN) <$ >$@
+GITWEB_FILES += static/gitweb.min.css
+GITWEB_CSS = static/gitweb.min.css
+all:: static/gitweb.min.css
+static/gitweb.min.css: static/gitweb.css GITWEB-BUILD-OPTIONS
+       $(QUIET_GEN)$(CSSMIN) <$< >$@
 else
-GITWEB_FILES += gitweb.css
+GITWEB_FILES += static/gitweb.css
 endif
 
-GITWEB_FILES += git-logo.png git-favicon.png
+GITWEB_FILES += static/git-logo.png static/git-favicon.png
 
 GITWEB_REPLACE = \
        -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
@@ -147,12 +148,13 @@ gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
 install: all
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
        $(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
-       $(INSTALL) -m 644 $(GITWEB_FILES)    '$(DESTDIR_SQ)$(gitwebdir_SQ)'
+       $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
+       $(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
 
 ### Cleaning rules
 
 clean:
-       $(RM) gitweb.cgi gitweb.min.js gitweb.min.css GITWEB-BUILD-OPTIONS
+       $(RM) gitweb.cgi static/gitweb.min.js static/gitweb.min.css GITWEB-BUILD-OPTIONS
 
 .PHONY: all clean install .FORCE-GIT-VERSION-FILE FORCE
 
index 71742b335dd786a24699b06b17519e264724ea5b..0e19be8d216aa813221c8663d6424f96f80bfb14 100644 (file)
@@ -80,24 +80,26 @@ You can specify the following configuration variables when building GIT:
    Points to the location where you put gitweb.css on your web server
    (or to be more generic, the URI of gitweb stylesheet).  Relative to the
    base URI of gitweb.  Note that you can setup multiple stylesheets from
-   the gitweb config file.  [Default: gitweb.css (or gitweb.min.css if the
-   CSSMIN variable is defined / CSS minifier is used)]
+   the gitweb config file.  [Default: static/gitweb.css (or
+   static/gitweb.min.css if the CSSMIN variable is defined / CSS minifier
+   is used)]
  * GITWEB_LOGO
    Points to the location where you put git-logo.png on your web server
    (or to be more generic URI of logo, 72x27 size, displayed in top right
    corner of each gitweb page, and used as logo for Atom feed).  Relative
-   to base URI of gitweb.  [Default: git-logo.png]
+   to base URI of gitweb.  [Default: static/git-logo.png]
  * GITWEB_FAVICON
    Points to the location where you put git-favicon.png on your web server
    (or to be more generic URI of favicon, assumed to be image/png type;
    web browsers that support favicons (website icons) may display them
    in the browser's URL bar and next to site name in bookmarks).  Relative
-   to base URI of gitweb.  [Default: git-favicon.png]
+   to base URI of gitweb.  [Default: static/git-favicon.png]
  * GITWEB_JS
    Points to the localtion where you put gitweb.js on your web server
    (or to be more generic URI of JavaScript code used by gitweb).
-   Relative to base URI of gitweb.  [Default: gitweb.js (or gitweb.min.js
-   if JSMIN build variable is defined / JavaScript minifier is used)]
+   Relative to base URI of gitweb.  [Default: static/gitweb.js (or
+   static/gitweb.min.js if JSMIN build variable is defined / JavaScript
+   minifier is used)]
  * GITWEB_CONFIG
    This Perl file will be loaded using 'do' and can be used to override any
    of the options above as well as some other options -- see the "Runtime
index 934aacb61494a666ed0bdf9a9f1ef77dc6147c23..cedc3573136922d424971ef2a16feeb82496c37d 100755 (executable)
@@ -28,34 +28,42 @@ BEGIN {
        CGI->compile() if $ENV{'MOD_PERL'};
 }
 
-our $cgi = new CGI;
 our $version = "++GIT_VERSION++";
-our $my_url = $cgi->url();
-our $my_uri = $cgi->url(-absolute => 1);
 
-# Base URL for relative URLs in gitweb ($logo, $favicon, ...),
-# needed and used only for URLs with nonempty PATH_INFO
-our $base_url = $my_url;
+our ($my_url, $my_uri, $base_url, $path_info, $home_link);
+sub evaluate_uri {
+       our $cgi;
 
-# When the script is used as DirectoryIndex, the URL does not contain the name
-# of the script file itself, and $cgi->url() fails to strip PATH_INFO, so we
-# have to do it ourselves. We make $path_info global because it's also used
-# later on.
-#
-# Another issue with the script being the DirectoryIndex is that the resulting
-# $my_url data is not the full script URL: this is good, because we want
-# generated links to keep implying the script name if it wasn't explicitly
-# indicated in the URL we're handling, but it means that $my_url cannot be used
-# as base URL.
-# Therefore, if we needed to strip PATH_INFO, then we know that we have
-# to build the base URL ourselves:
-our $path_info = $ENV{"PATH_INFO"};
-if ($path_info) {
-       if ($my_url =~ s,\Q$path_info\E$,, &&
-           $my_uri =~ s,\Q$path_info\E$,, &&
-           defined $ENV{'SCRIPT_NAME'}) {
-               $base_url = $cgi->url(-base => 1) . $ENV{'SCRIPT_NAME'};
+       our $my_url = $cgi->url();
+       our $my_uri = $cgi->url(-absolute => 1);
+
+       # Base URL for relative URLs in gitweb ($logo, $favicon, ...),
+       # needed and used only for URLs with nonempty PATH_INFO
+       our $base_url = $my_url;
+
+       # When the script is used as DirectoryIndex, the URL does not contain the name
+       # of the script file itself, and $cgi->url() fails to strip PATH_INFO, so we
+       # have to do it ourselves. We make $path_info global because it's also used
+       # later on.
+       #
+       # Another issue with the script being the DirectoryIndex is that the resulting
+       # $my_url data is not the full script URL: this is good, because we want
+       # generated links to keep implying the script name if it wasn't explicitly
+       # indicated in the URL we're handling, but it means that $my_url cannot be used
+       # as base URL.
+       # Therefore, if we needed to strip PATH_INFO, then we know that we have
+       # to build the base URL ourselves:
+       our $path_info = $ENV{"PATH_INFO"};
+       if ($path_info) {
+               if ($my_url =~ s,\Q$path_info\E$,, &&
+                   $my_uri =~ s,\Q$path_info\E$,, &&
+                   defined $ENV{'SCRIPT_NAME'}) {
+                       $base_url = $cgi->url(-base => 1) . $ENV{'SCRIPT_NAME'};
+               }
        }
+
+       # target of the home link on top of all pages
+       our $home_link = $my_uri || "/";
 }
 
 # core git executable to use
@@ -70,9 +78,6 @@ our $projectroot = "++GITWEB_PROJECTROOT++";
 # the number is relative to the projectroot
 our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";
 
-# target of the home link on top of all pages
-our $home_link = $my_uri || "/";
-
 # string of the home link on top of all pages
 our $home_link_str = "++GITWEB_HOME_LINK_STR++";
 
@@ -445,6 +450,19 @@ our %feature = (
        'javascript-actions' => {
                'override' => 0,
                'default' => [0]},
+
+       # Syntax highlighting support. This is based on Daniel Svensson's
+       # and Sham Chukoury's work in gitweb-xmms2.git.
+       # It requires the 'highlight' program present in $PATH,
+       # and therefore is disabled by default.
+
+       # To enable system wide have in $GITWEB_CONFIG
+       # $feature{'highlight'}{'default'} = [1];
+
+       'highlight' => {
+               'sub' => sub { feature_bool('highlight', @_) },
+               'override' => 0,
+               'default' => [0]},
 );
 
 sub gitweb_get_feature {
@@ -553,15 +571,18 @@ sub filter_snapshot_fmts {
                !$known_snapshot_formats{$_}{'disabled'}} @fmts;
 }
 
-our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
-our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
-# die if there are errors parsing config file
-if (-e $GITWEB_CONFIG) {
-       do $GITWEB_CONFIG;
-       die $@ if $@;
-} elsif (-e $GITWEB_CONFIG_SYSTEM) {
-       do $GITWEB_CONFIG_SYSTEM;
-       die $@ if $@;
+our ($GITWEB_CONFIG, $GITWEB_CONFIG_SYSTEM);
+sub evaluate_gitweb_config {
+       our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
+       our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
+       # die if there are errors parsing config file
+       if (-e $GITWEB_CONFIG) {
+               do $GITWEB_CONFIG;
+               die $@ if $@;
+       } elsif (-e $GITWEB_CONFIG_SYSTEM) {
+               do $GITWEB_CONFIG_SYSTEM;
+               die $@ if $@;
+       }
 }
 
 # Get loadavg of system, to compare against $maxload.
@@ -587,13 +608,16 @@ sub get_loadavg {
 }
 
 # version of the core git binary
-our $git_version = qx("$GIT" --version) =~ m/git version (.*)$/ ? $1 : "unknown";
-$number_of_git_cmds++;
-
-$projects_list ||= $projectroot;
+our $git_version;
+sub evaluate_git_version {
+       our $git_version = qx("$GIT" --version) =~ m/git version (.*)$/ ? $1 : "unknown";
+       $number_of_git_cmds++;
+}
 
-if (defined $maxload && get_loadavg() > $maxload) {
-       die_error(503, "The load average on the server is too high");
+sub check_loadavg {
+       if (defined $maxload && get_loadavg() > $maxload) {
+               die_error(503, "The load average on the server is too high");
+       }
 }
 
 # ======================================================================
@@ -680,11 +704,15 @@ our %allowed_options = (
 # should be single values, but opt can be an array. We should probably
 # build an array of parameters that can be multi-valued, but since for the time
 # being it's only this one, we just single it out
-while (my ($name, $symbol) = each %cgi_param_mapping) {
-       if ($symbol eq 'opt') {
-               $input_params{$name} = [ $cgi->param($symbol) ];
-       } else {
-               $input_params{$name} = $cgi->param($symbol);
+sub evaluate_query_params {
+       our $cgi;
+
+       while (my ($name, $symbol) = each %cgi_param_mapping) {
+               if ($symbol eq 'opt') {
+                       $input_params{$name} = [ $cgi->param($symbol) ];
+               } else {
+                       $input_params{$name} = $cgi->param($symbol);
+               }
        }
 }
 
@@ -831,125 +859,134 @@ sub evaluate_path_info {
                }
        }
 }
-evaluate_path_info();
 
-our $action = $input_params{'action'};
-if (defined $action) {
-       if (!validate_action($action)) {
-               die_error(400, "Invalid action parameter");
+our ($action, $project, $file_name, $file_parent, $hash, $hash_parent, $hash_base,
+     $hash_parent_base, @extra_options, $page, $searchtype, $search_use_regexp,
+     $searchtext, $search_regexp);
+sub evaluate_and_validate_params {
+       our $action = $input_params{'action'};
+       if (defined $action) {
+               if (!validate_action($action)) {
+                       die_error(400, "Invalid action parameter");
+               }
        }
-}
 
-# parameters which are pathnames
-our $project = $input_params{'project'};
-if (defined $project) {
-       if (!validate_project($project)) {
-               undef $project;
-               die_error(404, "No such project");
+       # parameters which are pathnames
+       our $project = $input_params{'project'};
+       if (defined $project) {
+               if (!validate_project($project)) {
+                       undef $project;
+                       die_error(404, "No such project");
+               }
        }
-}
 
-our $file_name = $input_params{'file_name'};
-if (defined $file_name) {
-       if (!validate_pathname($file_name)) {
-               die_error(400, "Invalid file parameter");
+       our $file_name = $input_params{'file_name'};
+       if (defined $file_name) {
+               if (!validate_pathname($file_name)) {
+                       die_error(400, "Invalid file parameter");
+               }
        }
-}
 
-our $file_parent = $input_params{'file_parent'};
-if (defined $file_parent) {
-       if (!validate_pathname($file_parent)) {
-               die_error(400, "Invalid file parent parameter");
+       our $file_parent = $input_params{'file_parent'};
+       if (defined $file_parent) {
+               if (!validate_pathname($file_parent)) {
+                       die_error(400, "Invalid file parent parameter");
+               }
        }
-}
 
-# parameters which are refnames
-our $hash = $input_params{'hash'};
-if (defined $hash) {
-       if (!validate_refname($hash)) {
-               die_error(400, "Invalid hash parameter");
+       # parameters which are refnames
+       our $hash = $input_params{'hash'};
+       if (defined $hash) {
+               if (!validate_refname($hash)) {
+                       die_error(400, "Invalid hash parameter");
+               }
        }
-}
 
-our $hash_parent = $input_params{'hash_parent'};
-if (defined $hash_parent) {
-       if (!validate_refname($hash_parent)) {
-               die_error(400, "Invalid hash parent parameter");
+       our $hash_parent = $input_params{'hash_parent'};
+       if (defined $hash_parent) {
+               if (!validate_refname($hash_parent)) {
+                       die_error(400, "Invalid hash parent parameter");
+               }
        }
-}
 
-our $hash_base = $input_params{'hash_base'};
-if (defined $hash_base) {
-       if (!validate_refname($hash_base)) {
-               die_error(400, "Invalid hash base parameter");
+       our $hash_base = $input_params{'hash_base'};
+       if (defined $hash_base) {
+               if (!validate_refname($hash_base)) {
+                       die_error(400, "Invalid hash base parameter");
+               }
        }
-}
 
-our @extra_options = @{$input_params{'extra_options'}};
-# @extra_options is always defined, since it can only be (currently) set from
-# CGI, and $cgi->param() returns the empty array in array context if the param
-# is not set
-foreach my $opt (@extra_options) {
-       if (not exists $allowed_options{$opt}) {
-               die_error(400, "Invalid option parameter");
-       }
-       if (not grep(/^$action$/, @{$allowed_options{$opt}})) {
-               die_error(400, "Invalid option parameter for this action");
+       our @extra_options = @{$input_params{'extra_options'}};
+       # @extra_options is always defined, since it can only be (currently) set from
+       # CGI, and $cgi->param() returns the empty array in array context if the param
+       # is not set
+       foreach my $opt (@extra_options) {
+               if (not exists $allowed_options{$opt}) {
+                       die_error(400, "Invalid option parameter");
+               }
+               if (not grep(/^$action$/, @{$allowed_options{$opt}})) {
+                       die_error(400, "Invalid option parameter for this action");
+               }
        }
-}
 
-our $hash_parent_base = $input_params{'hash_parent_base'};
-if (defined $hash_parent_base) {
-       if (!validate_refname($hash_parent_base)) {
-               die_error(400, "Invalid hash parent base parameter");
+       our $hash_parent_base = $input_params{'hash_parent_base'};
+       if (defined $hash_parent_base) {
+               if (!validate_refname($hash_parent_base)) {
+                       die_error(400, "Invalid hash parent base parameter");
+               }
        }
-}
 
-# other parameters
-our $page = $input_params{'page'};
-if (defined $page) {
-       if ($page =~ m/[^0-9]/) {
-               die_error(400, "Invalid page parameter");
+       # other parameters
+       our $page = $input_params{'page'};
+       if (defined $page) {
+               if ($page =~ m/[^0-9]/) {
+                       die_error(400, "Invalid page parameter");
+               }
        }
-}
 
-our $searchtype = $input_params{'searchtype'};
-if (defined $searchtype) {
-       if ($searchtype =~ m/[^a-z]/) {
-               die_error(400, "Invalid searchtype parameter");
+       our $searchtype = $input_params{'searchtype'};
+       if (defined $searchtype) {
+               if ($searchtype =~ m/[^a-z]/) {
+                       die_error(400, "Invalid searchtype parameter");
+               }
        }
-}
 
-our $search_use_regexp = $input_params{'search_use_regexp'};
+       our $search_use_regexp = $input_params{'search_use_regexp'};
 
-our $searchtext = $input_params{'searchtext'};
-our $search_regexp;
-if (defined $searchtext) {
-       if (length($searchtext) < 2) {
-               die_error(403, "At least two characters are required for search parameter");
+       our $searchtext = $input_params{'searchtext'};
+       our $search_regexp;
+       if (defined $searchtext) {
+               if (length($searchtext) < 2) {
+                       die_error(403, "At least two characters are required for search parameter");
+               }
+               $search_regexp = $search_use_regexp ? $searchtext : quotemeta $searchtext;
        }
-       $search_regexp = $search_use_regexp ? $searchtext : quotemeta $searchtext;
 }
 
 # path to the current git repository
 our $git_dir;
-$git_dir = "$projectroot/$project" if $project;
-
-# list of supported snapshot formats
-our @snapshot_fmts = gitweb_get_feature('snapshot');
-@snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
-
-# check that the avatar feature is set to a known provider name,
-# and for each provider check if the dependencies are satisfied.
-# if the provider name is invalid or the dependencies are not met,
-# reset $git_avatar to the empty string.
-our ($git_avatar) = gitweb_get_feature('avatar');
-if ($git_avatar eq 'gravatar') {
-       $git_avatar = '' unless (eval { require Digest::MD5; 1; });
-} elsif ($git_avatar eq 'picon') {
-       # no dependencies
-} else {
-       $git_avatar = '';
+sub evaluate_git_dir {
+       our $git_dir = "$projectroot/$project" if $project;
+}
+
+our (@snapshot_fmts, $git_avatar);
+sub configure_gitweb_features {
+       # list of supported snapshot formats
+       our @snapshot_fmts = gitweb_get_feature('snapshot');
+       @snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
+
+       # check that the avatar feature is set to a known provider name,
+       # and for each provider check if the dependencies are satisfied.
+       # if the provider name is invalid or the dependencies are not met,
+       # reset $git_avatar to the empty string.
+       our ($git_avatar) = gitweb_get_feature('avatar');
+       if ($git_avatar eq 'gravatar') {
+               $git_avatar = '' unless (eval { require Digest::MD5; 1; });
+       } elsif ($git_avatar eq 'picon') {
+               # no dependencies
+       } else {
+               $git_avatar = '';
+       }
 }
 
 # custom error handler: 'die <message>' is Internal Server Error
@@ -968,27 +1005,123 @@ sub handle_errors_html {
 set_message(\&handle_errors_html);
 
 # dispatch
-if (!defined $action) {
-       if (defined $hash) {
-               $action = git_get_type($hash);
-       } elsif (defined $hash_base && defined $file_name) {
-               $action = git_get_type("$hash_base:$file_name");
-       } elsif (defined $project) {
-               $action = 'summary';
-       } else {
-               $action = 'project_list';
+sub dispatch {
+       if (!defined $action) {
+               if (defined $hash) {
+                       $action = git_get_type($hash);
+               } elsif (defined $hash_base && defined $file_name) {
+                       $action = git_get_type("$hash_base:$file_name");
+               } elsif (defined $project) {
+                       $action = 'summary';
+               } else {
+                       $action = 'project_list';
+               }
+       }
+       if (!defined($actions{$action})) {
+               die_error(400, "Unknown action");
        }
+       if ($action !~ m/^(?:opml|project_list|project_index)$/ &&
+           !$project) {
+               die_error(400, "Project needed");
+       }
+       $actions{$action}->();
+}
+
+sub reset_timer {
+       our $t0 = [Time::HiRes::gettimeofday()]
+               if defined $t0;
+       our $number_of_git_cmds = 0;
+}
+
+sub run_request {
+       reset_timer();
+
+       evaluate_uri();
+       check_loadavg();
+
+       evaluate_query_params();
+       evaluate_path_info();
+       evaluate_and_validate_params();
+       evaluate_git_dir();
+
+       configure_gitweb_features();
+
+       dispatch();
+}
+
+our $is_last_request = sub { 1 };
+our ($pre_dispatch_hook, $post_dispatch_hook, $pre_listen_hook);
+our $CGI = 'CGI';
+our $cgi;
+sub configure_as_fcgi {
+       require CGI::Fast;
+       our $CGI = 'CGI::Fast';
+
+       my $request_number = 0;
+       # let each child service 100 requests
+       our $is_last_request = sub { ++$request_number > 100 };
+}
+sub evaluate_argv {
+       my $script_name = $ENV{'SCRIPT_NAME'} || $ENV{'SCRIPT_FILENAME'} || __FILE__;
+       configure_as_fcgi()
+               if $script_name =~ /\.fcgi$/;
+
+       return unless (@ARGV);
+
+       require Getopt::Long;
+       Getopt::Long::GetOptions(
+               'fastcgi|fcgi|f' => \&configure_as_fcgi,
+               'nproc|n=i' => sub {
+                       my ($arg, $val) = @_;
+                       return unless eval { require FCGI::ProcManager; 1; };
+                       my $proc_manager = FCGI::ProcManager->new({
+                               n_processes => $val,
+                       });
+                       our $pre_listen_hook    = sub { $proc_manager->pm_manage()        };
+                       our $pre_dispatch_hook  = sub { $proc_manager->pm_pre_dispatch()  };
+                       our $post_dispatch_hook = sub { $proc_manager->pm_post_dispatch() };
+               },
+       );
 }
-if (!defined($actions{$action})) {
-       die_error(400, "Unknown action");
+
+sub run {
+       evaluate_argv();
+       evaluate_gitweb_config();
+       evaluate_git_version();
+
+       # $projectroot and $projects_list might be set in gitweb config file
+       $projects_list ||= $projectroot;
+
+       $pre_listen_hook->()
+               if $pre_listen_hook;
+
+ REQUEST:
+       while ($cgi = $CGI->new()) {
+               $pre_dispatch_hook->()
+                       if $pre_dispatch_hook;
+
+               run_request();
+
+               $pre_dispatch_hook->()
+                       if $post_dispatch_hook;
+
+               last REQUEST if ($is_last_request->());
+       }
+
+ DONE_GITWEB:
+       1;
 }
-if ($action !~ m/^(?:opml|project_list|project_index)$/ &&
-    !$project) {
-       die_error(400, "Project needed");
+
+run();
+
+if (defined caller) {
+       # wrapped in a subroutine processing requests,
+       # e.g. mod_perl with ModPerl::Registry, or PSGI with Plack::App::WrapCGI
+       return;
+} else {
+       # pure CGI script, serving single request
+       exit;
 }
-$actions{$action}->();
-DONE_GITWEB:
-1;
 
 ## ======================================================================
 ## action links
@@ -1194,8 +1327,7 @@ sub esc_param {
 sub esc_url {
        my $str = shift;
        return undef unless defined $str;
-       $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf("%%%02X", ord($1))/eg;
-       $str =~ s/\+/%2B/g;
+       $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&= ]+)/CGI::escape($1)/eg;
        $str =~ s/ /\+/g;
        return $str;
 }
@@ -3179,6 +3311,61 @@ sub blob_contenttype {
        return $type;
 }
 
+# guess file syntax for syntax highlighting; return undef if no highlighting
+# the name of syntax can (in the future) depend on syntax highlighter used
+sub guess_file_syntax {
+       my ($highlight, $mimetype, $file_name) = @_;
+       return undef unless ($highlight && defined $file_name);
+
+       # configuration for 'highlight' (http://www.andre-simon.de/)
+       # match by basename
+       my %highlight_basename = (
+               #'Program' => 'py',
+               #'Library' => 'py',
+               'SConstruct' => 'py', # SCons equivalent of Makefile
+               'Makefile' => 'make',
+       );
+       # match by extension
+       my %highlight_ext = (
+               # main extensions, defining name of syntax;
+               # see files in /usr/share/highlight/langDefs/ directory
+               map { $_ => $_ }
+                       qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),
+               # alternate extensions, see /etc/highlight/filetypes.conf
+               'h' => 'c',
+               map { $_ => 'cpp' } qw(cxx c++ cc),
+               map { $_ => 'php' } qw(php3 php4),
+               map { $_ => 'pl'  } qw(perl pm), # perhaps also 'cgi'
+               'mak' => 'make',
+               map { $_ => 'xml' } qw(xhtml html htm),
+       );
+
+       my $basename = basename($file_name, '.in');
+       return $highlight_basename{$basename}
+               if exists $highlight_basename{$basename};
+
+       $basename =~ /\.([^.]*)$/;
+       my $ext = $1 or return undef;
+       return $highlight_ext{$ext}
+               if exists $highlight_ext{$ext};
+
+       return undef;
+}
+
+# run highlighter and return FD of its output,
+# or return original FD if no highlighting
+sub run_highlighter {
+       my ($fd, $highlight, $syntax) = @_;
+       return $fd unless ($highlight && defined $syntax);
+
+       close $fd
+               or die_error(404, "Reading blob failed");
+       open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ".
+                 "highlight --xhtml --fragment --syntax $syntax |"
+               or die_error(500, "Couldn't open file or run syntax highlighter");
+       return $fd;
+}
+
 ## ======================================================================
 ## functions printing HTML: header, footer, error page
 
@@ -3220,7 +3407,7 @@ sub git_header_html {
        }
        print $cgi->header(-type=>$content_type, -charset => 'utf-8',
                           -status=> $status, -expires => $expires)
-               unless ($opts{'-no_http_headers'});
+               unless ($opts{'-no_http_header'});
        my $mod_perl_version = $ENV{'MOD_PERL'} ? " $ENV{'MOD_PERL'}" : '';
        print <<EOF;
 <?xml version="1.0" encoding="utf-8"?>
@@ -5380,6 +5567,7 @@ sub git_blob {
        open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
                or die_error(500, "Couldn't cat $file_name, $hash");
        my $mimetype = blob_mimetype($fd, $file_name);
+       # use 'blob_plain' (aka 'raw') view for files that cannot be displayed
        if ($mimetype !~ m!^(?:text/|image/(?:gif|png|jpeg)$)! && -B $fd) {
                close $fd;
                return git_blob_plain($mimetype);
@@ -5387,6 +5575,11 @@ sub git_blob {
        # we can have blame only for text/* mimetype
        $have_blame &&= ($mimetype =~ m!^text/!);
 
+       my $highlight = gitweb_check_feature('highlight');
+       my $syntax = guess_file_syntax($highlight, $mimetype, $file_name);
+       $fd = run_highlighter($fd, $highlight, $syntax)
+               if $syntax;
+
        git_header_html(undef, $expires);
        my $formats_nav = '';
        if (defined $hash_base && (my %co = parse_commit($hash_base))) {
@@ -5436,9 +5629,8 @@ sub git_blob {
                        chomp $line;
                        $nr++;
                        $line = untabify($line);
-                       printf "<div class=\"pre\"><a id=\"l%i\" href=\"" . href(-replay => 1)
-                               . "#l%i\" class=\"linenr\">%4i</a> %s</div>\n",
-                              $nr, $nr, $nr, esc_html($line, -nbsp=>1);
+                       printf qq!<div class="pre"><a id="l%i" href="%s#l%i" class="linenr">%4i</a> %s</div>\n!,
+                              $nr, href(-replay => 1), $nr, $nr, $syntax ? $line : esc_html($line, -nbsp=>1);
                }
        }
        close $fd
similarity index 93%
rename from gitweb/gitweb.css
rename to gitweb/static/gitweb.css
index 50067f2e0dea2c1e17a41e9a5e8b2a8f6240c13d..4132aabcdb4ef402ceb1a890b61778b3254fdf18 100644 (file)
@@ -572,3 +572,21 @@ span.match {
 div.binary {
        font-style: italic;
 }
+
+/* Style definition generated by highlight 2.4.5, http://www.andre-simon.de/ */
+
+/* Highlighting theme definition: */
+
+.num    { color:#2928ff; }
+.esc    { color:#ff00ff; }
+.str    { color:#ff0000; }
+.dstr   { color:#818100; }
+.slc    { color:#838183; font-style:italic; }
+.com    { color:#838183; font-style:italic; }
+.dir    { color:#008200; }
+.sym    { color:#000000; }
+.line   { color:#555555; }
+.kwa    { color:#000000; font-weight:bold; }
+.kwb    { color:#830000; }
+.kwc    { color:#000000; font-weight:bold; }
+.kwd    { color:#010181; }
similarity index 100%
rename from gitweb/gitweb.js
rename to gitweb/static/gitweb.js
diff --git a/graph.c b/graph.c
index e6bbcaa8c4655add3ecaca578e948355795e36ca..ac7c60540645761d3c99fb405a69cb2d06aaddc2 100644 (file)
--- a/graph.c
+++ b/graph.c
@@ -211,6 +211,18 @@ struct git_graph {
        unsigned short default_column_color;
 };
 
+static struct strbuf *diff_output_prefix_callback(struct diff_options *opt, void *data)
+{
+       struct git_graph *graph = data;
+       static struct strbuf msgbuf = STRBUF_INIT;
+
+       assert(graph);
+
+       strbuf_reset(&msgbuf);
+       graph_padding_line(graph, &msgbuf);
+       return &msgbuf;
+}
+
 struct git_graph *graph_init(struct rev_info *opt)
 {
        struct git_graph *graph = xmalloc(sizeof(struct git_graph));
@@ -244,6 +256,13 @@ struct git_graph *graph_init(struct rev_info *opt)
        graph->mapping = xmalloc(sizeof(int) * 2 * graph->column_capacity);
        graph->new_mapping = xmalloc(sizeof(int) * 2 * graph->column_capacity);
 
+       /*
+        * The diff output prefix callback, with this we can make
+        * all the diff output to align with the graph lines.
+        */
+       opt->diffopt.output_prefix = diff_output_prefix_callback;
+       opt->diffopt.output_prefix_data = graph;
+
        return graph;
 }
 
diff --git a/grep.c b/grep.c
index 543b1d53784c16020dea089f23c431c7f2608425..82fb349be6f6ef8211d4828101cd8e88bcbb304f 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -7,6 +7,7 @@ void append_header_grep_pattern(struct grep_opt *opt, enum grep_header_field fie
 {
        struct grep_pat *p = xcalloc(1, sizeof(*p));
        p->pattern = pat;
+       p->patternlen = strlen(pat);
        p->origin = "header";
        p->no = 0;
        p->token = GREP_PATTERN_HEAD;
@@ -18,9 +19,16 @@ void append_header_grep_pattern(struct grep_opt *opt, enum grep_header_field fie
 
 void append_grep_pattern(struct grep_opt *opt, const char *pat,
                         const char *origin, int no, enum grep_pat_token t)
+{
+       append_grep_pat(opt, pat, strlen(pat), origin, no, t);
+}
+
+void append_grep_pat(struct grep_opt *opt, const char *pat, size_t patlen,
+                    const char *origin, int no, enum grep_pat_token t)
 {
        struct grep_pat *p = xcalloc(1, sizeof(*p));
        p->pattern = pat;
+       p->patternlen = patlen;
        p->origin = origin;
        p->no = no;
        p->token = t;
@@ -44,8 +52,8 @@ struct grep_opt *grep_opt_dup(const struct grep_opt *opt)
                        append_header_grep_pattern(ret, pat->field,
                                                   pat->pattern);
                else
-                       append_grep_pattern(ret, pat->pattern, pat->origin,
-                                           pat->no, pat->token);
+                       append_grep_pat(ret, pat->pattern, pat->patternlen,
+                                       pat->origin, pat->no, pat->token);
        }
 
        return ret;
@@ -329,14 +337,21 @@ static void show_name(struct grep_opt *opt, const char *name)
        opt->output(opt, opt->null_following_name ? "\0" : "\n", 1);
 }
 
-
-static int fixmatch(const char *pattern, char *line, int ignore_case, regmatch_t *match)
+static int fixmatch(struct grep_pat *p, char *line, char *eol,
+                   regmatch_t *match)
 {
        char *hit;
-       if (ignore_case)
-               hit = strcasestr(line, pattern);
-       else
-               hit = strstr(line, pattern);
+
+       if (p->ignore_case) {
+               char *s = line;
+               do {
+                       hit = strcasestr(s, p->pattern);
+                       if (hit)
+                               break;
+                       s += strlen(s) + 1;
+               } while (s < eol);
+       } else
+               hit = memmem(line, eol - line, p->pattern, p->patternlen);
 
        if (!hit) {
                match->rm_so = match->rm_eo = -1;
@@ -344,11 +359,22 @@ static int fixmatch(const char *pattern, char *line, int ignore_case, regmatch_t
        }
        else {
                match->rm_so = hit - line;
-               match->rm_eo = match->rm_so + strlen(pattern);
+               match->rm_eo = match->rm_so + p->patternlen;
                return 0;
        }
 }
 
+static int regmatch(const regex_t *preg, char *line, char *eol,
+                   regmatch_t *match, int eflags)
+{
+#ifdef REG_STARTEND
+       match->rm_so = 0;
+       match->rm_eo = eol - line;
+       eflags |= REG_STARTEND;
+#endif
+       return regexec(preg, line, 1, match, eflags);
+}
+
 static int strip_timestamp(char *bol, char **eol_p)
 {
        char *eol = *eol_p;
@@ -399,9 +425,9 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
 
  again:
        if (p->fixed)
-               hit = !fixmatch(p->pattern, bol, p->ignore_case, pmatch);
+               hit = !fixmatch(p, bol, eol, pmatch);
        else
-               hit = !regexec(&p->regexp, bol, 1, pmatch, eflags);
+               hit = !regmatch(&p->regexp, bol, eol, pmatch, eflags);
 
        if (hit && p->word_regexp) {
                if ((pmatch[0].rm_so < 0) ||
@@ -726,16 +752,9 @@ static int look_ahead(struct grep_opt *opt,
                regmatch_t m;
 
                if (p->fixed)
-                       hit = !fixmatch(p->pattern, bol, p->ignore_case, &m);
-               else {
-#ifdef REG_STARTEND
-                       m.rm_so = 0;
-                       m.rm_eo = *left_p;
-                       hit = !regexec(&p->regexp, bol, 1, &m, REG_STARTEND);
-#else
-                       hit = !regexec(&p->regexp, bol, 1, &m, 0);
-#endif
-               }
+                       hit = !fixmatch(p, bol, bol + *left_p, &m);
+               else
+                       hit = !regmatch(&p->regexp, bol, bol + *left_p, &m, 0);
                if (!hit || m.rm_so < 0 || m.rm_eo < 0)
                        continue;
                if (earliest < 0 || m.rm_so < earliest)
@@ -800,17 +819,19 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
                opt->show_hunk_mark = 1;
        opt->last_shown = 0;
 
-       if (buffer_is_binary(buf, size)) {
-               switch (opt->binary) {
-               case GREP_BINARY_DEFAULT:
+       switch (opt->binary) {
+       case GREP_BINARY_DEFAULT:
+               if (buffer_is_binary(buf, size))
                        binary_match_only = 1;
-                       break;
-               case GREP_BINARY_NOMATCH:
+               break;
+       case GREP_BINARY_NOMATCH:
+               if (buffer_is_binary(buf, size))
                        return 0; /* Assume unmatch */
-                       break;
-               default:
-                       break;
-               }
+               break;
+       case GREP_BINARY_TEXT:
+               break;
+       default:
+               die("bug: unknown binary handling mode");
        }
 
        memset(&xecfg, 0, sizeof(xecfg));
@@ -871,6 +892,12 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
                        count++;
                        if (opt->status_only)
                                return 1;
+                       if (opt->name_only) {
+                               show_name(opt, name);
+                               return 1;
+                       }
+                       if (opt->count)
+                               goto next_line;
                        if (binary_match_only) {
                                opt->output(opt, "Binary file ", 12);
                                output_color(opt, name, strlen(name),
@@ -878,22 +905,14 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
                                opt->output(opt, " matches\n", 9);
                                return 1;
                        }
-                       if (opt->name_only) {
-                               show_name(opt, name);
-                               return 1;
-                       }
                        /* Hit at this line.  If we haven't shown the
                         * pre-context lines, we would need to show them.
-                        * When asked to do "count", this still show
-                        * the context which is nonsense, but the user
-                        * deserves to get that ;-).
                         */
                        if (opt->pre_context)
                                show_pre_context(opt, name, buf, bol, lno);
                        else if (opt->funcname)
                                show_funcname_line(opt, name, buf, bol, lno);
-                       if (!opt->count)
-                               show_line(opt, bol, eol, name, lno, ':');
+                       show_line(opt, bol, eol, name, lno, ':');
                        last_hit = lno;
                }
                else if (last_hit &&
@@ -937,6 +956,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
                output_sep(opt, ':');
                snprintf(buf, sizeof(buf), "%u\n", count);
                opt->output(opt, buf, strlen(buf));
+               return 1;
        }
        return !!last_hit;
 }
diff --git a/grep.h b/grep.h
index 89342e5b47f6d63dd546e738e4cbf023c447b382..efa8cff980af2b2c06dad080876637d16b5c4985 100644 (file)
--- a/grep.h
+++ b/grep.h
@@ -10,17 +10,17 @@ enum grep_pat_token {
        GREP_OPEN_PAREN,
        GREP_CLOSE_PAREN,
        GREP_NOT,
-       GREP_OR,
+       GREP_OR
 };
 
 enum grep_context {
        GREP_CONTEXT_HEAD,
-       GREP_CONTEXT_BODY,
+       GREP_CONTEXT_BODY
 };
 
 enum grep_header_field {
        GREP_HEADER_AUTHOR = 0,
-       GREP_HEADER_COMMITTER,
+       GREP_HEADER_COMMITTER
 };
 
 struct grep_pat {
@@ -29,6 +29,7 @@ struct grep_pat {
        int no;
        enum grep_pat_token token;
        const char *pattern;
+       size_t patternlen;
        enum grep_header_field field;
        regex_t regexp;
        unsigned fixed:1;
@@ -40,7 +41,7 @@ enum grep_expr_node {
        GREP_NODE_ATOM,
        GREP_NODE_NOT,
        GREP_NODE_AND,
-       GREP_NODE_OR,
+       GREP_NODE_OR
 };
 
 struct grep_expr {
@@ -104,6 +105,7 @@ struct grep_opt {
        void *output_priv;
 };
 
+extern void append_grep_pat(struct grep_opt *opt, const char *pat, size_t patlen, const char *origin, int no, enum grep_pat_token t);
 extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
 extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
 extern void compile_grep_patterns(struct grep_opt *opt);
index 8ec15f99c05cbdcc432cce95bdf1b6a45347368d..14c90c2e84afd9997e1a6453f0065b3f59b32e57 100644 (file)
@@ -6,6 +6,7 @@
 #include "exec_cmd.h"
 #include "run-command.h"
 #include "string-list.h"
+#include "url.h"
 
 static const char content_type[] = "Content-Type";
 static const char content_length[] = "Content-Length";
@@ -25,60 +26,6 @@ static struct rpc_service rpc_service[] = {
        { "receive-pack", "receivepack", -1 },
 };
 
-static int decode_char(const char *q)
-{
-       int i;
-       unsigned char val = 0;
-       for (i = 0; i < 2; i++) {
-               unsigned char c = *q++;
-               val <<= 4;
-               if (c >= '0' && c <= '9')
-                       val += c - '0';
-               else if (c >= 'a' && c <= 'f')
-                       val += c - 'a' + 10;
-               else if (c >= 'A' && c <= 'F')
-                       val += c - 'A' + 10;
-               else
-                       return -1;
-       }
-       return val;
-}
-
-static char *decode_parameter(const char **query, int is_name)
-{
-       const char *q = *query;
-       struct strbuf out;
-
-       strbuf_init(&out, 16);
-       do {
-               unsigned char c = *q;
-
-               if (!c)
-                       break;
-               if (c == '&' || (is_name && c == '=')) {
-                       q++;
-                       break;
-               }
-
-               if (c == '%') {
-                       int val = decode_char(q + 1);
-                       if (0 <= val) {
-                               strbuf_addch(&out, val);
-                               q += 3;
-                               continue;
-                       }
-               }
-
-               if (c == '+')
-                       strbuf_addch(&out, ' ');
-               else
-                       strbuf_addch(&out, c);
-               q++;
-       } while (1);
-       *query = q;
-       return strbuf_detach(&out, NULL);
-}
-
 static struct string_list *get_parameters(void)
 {
        if (!query_params) {
@@ -86,8 +33,8 @@ static struct string_list *get_parameters(void)
 
                query_params = xcalloc(1, sizeof(*query_params));
                while (query && *query) {
-                       char *name = decode_parameter(&query, 1);
-                       char *value = decode_parameter(&query, 0);
+                       char *name = url_decode_parameter_name(&query);
+                       char *value = url_decode_parameter_value(&query);
                        struct string_list_item *i;
 
                        i = string_list_lookup(query_params, name);
@@ -541,14 +488,12 @@ static NORETURN void die_webcgi(const char *err, va_list params)
        static int dead;
 
        if (!dead) {
-               char buffer[1000];
                dead = 1;
-
-               vsnprintf(buffer, sizeof(buffer), err, params);
-               fprintf(stderr, "fatal: %s\n", buffer);
                http_status(500, "Internal Server Error");
                hdr_nocache();
                end_headers();
+
+               vreportf("fatal: ", err, params);
        }
        exit(0); /* we successfully reported a failure ;-) */
 }
index 415b1ab0a7f0a98e3a16f82c39bbcc9b04f85ac2..c9bcd116975635cabf30eceb7909abfc7f341948 100644 (file)
@@ -105,7 +105,7 @@ enum transfer_state {
        RUN_PUT,
        RUN_MOVE,
        ABORTED,
-       COMPLETE,
+       COMPLETE
 };
 
 struct transfer_request
index 8ca76d0507bdc1d95283e1f5fee3f88180cdce26..18bd6504beb99ab68f360c4fa93011efae42fdfb 100644 (file)
@@ -15,7 +15,7 @@ enum object_request_state {
        WAITING,
        ABORTED,
        ACTIVE,
-       COMPLETE,
+       COMPLETE
 };
 
 struct object_request
index 9d0097ca02960460ff3a104f1739982fee453987..1a577a0a094342315bd3f68e8d13ef7f57a22f50 100644 (file)
@@ -230,7 +230,7 @@ enum CAPABILITY {
        LITERALPLUS,
        NAMESPACE,
        STARTTLS,
-       AUTH_CRAM_MD5,
+       AUTH_CRAM_MD5
 };
 
 static const char *cap_list[] = {
index f9b3d854a921ab6fa3eed6f4dbf01af1a8657602..3764a1ab72354a3ce643c899c1e8cf5443d4e7cb 100644 (file)
@@ -139,17 +139,17 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
 {
        char temp[4][50];
        struct strbuf cmd = STRBUF_INIT;
-       struct strbuf_expand_dict_entry dict[] = {
-               { "O", temp[0] },
-               { "A", temp[1] },
-               { "B", temp[2] },
-               { "L", temp[3] },
-               { NULL }
-       };
+       struct strbuf_expand_dict_entry dict[5];
        const char *args[] = { NULL, NULL };
        int status, fd, i;
        struct stat st;
 
+       dict[0].placeholder = "O"; dict[0].value = temp[0];
+       dict[1].placeholder = "A"; dict[1].value = temp[1];
+       dict[2].placeholder = "B"; dict[2].value = temp[2];
+       dict[3].placeholder = "L"; dict[3].value = temp[3];
+       dict[4].placeholder = NULL; dict[4].value = NULL;
+
        if (fn->cmdline == NULL)
                die("custom merge driver %s lacks command line.", fn->name);
 
index d3ae969f608b50a469aa60b2e925558a6bb437e5..b46ed3baef7d9d9971a3886d700059217fbe974a 100644 (file)
 #include "reflog-walk.h"
 #include "refs.h"
 #include "string-list.h"
+#include "color.h"
 
 struct decoration name_decoration = { "object names" };
 
-static void add_name_decoration(const char *prefix, const char *name, struct object *obj)
+enum decoration_type {
+       DECORATION_NONE = 0,
+       DECORATION_REF_LOCAL,
+       DECORATION_REF_REMOTE,
+       DECORATION_REF_TAG,
+       DECORATION_REF_STASH,
+       DECORATION_REF_HEAD,
+};
+
+static char decoration_colors[][COLOR_MAXLEN] = {
+       GIT_COLOR_RESET,
+       GIT_COLOR_BOLD_GREEN,   /* REF_LOCAL */
+       GIT_COLOR_BOLD_RED,     /* REF_REMOTE */
+       GIT_COLOR_BOLD_YELLOW,  /* REF_TAG */
+       GIT_COLOR_BOLD_MAGENTA, /* REF_STASH */
+       GIT_COLOR_BOLD_CYAN,    /* REF_HEAD */
+};
+
+static const char *decorate_get_color(int decorate_use_color, enum decoration_type ix)
+{
+       if (decorate_use_color)
+               return decoration_colors[ix];
+       return "";
+}
+
+static int parse_decorate_color_slot(const char *slot)
+{
+       /*
+        * We're comparing with 'ignore-case' on
+        * (because config.c sets them all tolower),
+        * but let's match the letters in the literal
+        * string values here with how they are
+        * documented in Documentation/config.txt, for
+        * consistency.
+        *
+        * We love being consistent, don't we?
+        */
+       if (!strcasecmp(slot, "branch"))
+               return DECORATION_REF_LOCAL;
+       if (!strcasecmp(slot, "remoteBranch"))
+               return DECORATION_REF_REMOTE;
+       if (!strcasecmp(slot, "tag"))
+               return DECORATION_REF_TAG;
+       if (!strcasecmp(slot, "stash"))
+               return DECORATION_REF_STASH;
+       if (!strcasecmp(slot, "HEAD"))
+               return DECORATION_REF_HEAD;
+       return -1;
+}
+
+int parse_decorate_color_config(const char *var, const int ofs, const char *value)
+{
+       int slot = parse_decorate_color_slot(var + ofs);
+       if (slot < 0)
+               return 0;
+       if (!value)
+               return config_error_nonbool(var);
+       color_parse(value, var, decoration_colors[slot]);
+       return 0;
+}
+
+/*
+ * log-tree.c uses DIFF_OPT_TST for determining whether to use color
+ * for showing the commit sha1, use the same check for --decorate
+ */
+#define decorate_get_color_opt(o, ix) \
+       decorate_get_color(DIFF_OPT_TST((o), COLOR_DIFF), ix)
+
+static void add_name_decoration(enum decoration_type type, const char *name, struct object *obj)
 {
-       int plen = strlen(prefix);
        int nlen = strlen(name);
-       struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + plen + nlen);
-       memcpy(res->name, prefix, plen);
-       memcpy(res->name + plen, name, nlen + 1);
+       struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + nlen);
+       memcpy(res->name, name, nlen + 1);
+       res->type = type;
        res->next = add_decoration(&name_decoration, obj, res);
 }
 
 static int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
 {
        struct object *obj = parse_object(sha1);
+       enum decoration_type type = DECORATION_NONE;
        if (!obj)
                return 0;
+
+       if (!prefixcmp(refname, "refs/heads"))
+               type = DECORATION_REF_LOCAL;
+       else if (!prefixcmp(refname, "refs/remotes"))
+               type = DECORATION_REF_REMOTE;
+       else if (!prefixcmp(refname, "refs/tags"))
+               type = DECORATION_REF_TAG;
+       else if (!prefixcmp(refname, "refs/stash"))
+               type = DECORATION_REF_STASH;
+       else if (!prefixcmp(refname, "HEAD"))
+               type = DECORATION_REF_HEAD;
+
        if (!cb_data || *(int *)cb_data == DECORATE_SHORT_REFS)
                refname = prettify_refname(refname);
-       add_name_decoration("", refname, obj);
+       add_name_decoration(type, refname, obj);
        while (obj->type == OBJ_TAG) {
                obj = ((struct tag *)obj)->tagged;
                if (!obj)
                        break;
-               add_name_decoration("tag: ", refname, obj);
+               add_name_decoration(DECORATION_REF_TAG, refname, obj);
        }
        return 0;
 }
@@ -60,6 +141,10 @@ void show_decorations(struct rev_info *opt, struct commit *commit)
 {
        const char *prefix;
        struct name_decoration *decoration;
+       const char *color_commit =
+               diff_get_color_opt(&opt->diffopt, DIFF_COMMIT);
+       const char *color_reset =
+               decorate_get_color_opt(&opt->diffopt, DECORATION_NONE);
 
        if (opt->show_source && commit->util)
                printf("\t%s", (char *) commit->util);
@@ -70,7 +155,14 @@ void show_decorations(struct rev_info *opt, struct commit *commit)
                return;
        prefix = " (";
        while (decoration) {
-               printf("%s%s", prefix, decoration->name);
+               printf("%s", prefix);
+               fputs(decorate_get_color_opt(&opt->diffopt, decoration->type),
+                     stdout);
+               if (decoration->type == DECORATION_REF_TAG)
+                       fputs("tag: ", stdout);
+               printf("%s", decoration->name);
+               fputs(color_reset, stdout);
+               fputs(color_commit, stdout);
                prefix = ", ";
                decoration = decoration->next;
        }
@@ -469,6 +561,12 @@ int log_tree_diff_flush(struct rev_info *opt)
                        int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
                        if ((pch & opt->diffopt.output_format) == pch)
                                printf("---");
+                       if (opt->diffopt.output_prefix) {
+                               struct strbuf *msg = NULL;
+                               msg = opt->diffopt.output_prefix(&opt->diffopt,
+                                       opt->diffopt.output_prefix_data);
+                               fwrite(msg->buf, msg->len, 1, stdout);
+                       }
                        putchar('\n');
                }
        }
index 3f7b40027b7203985f018e43ab72a6cfc233e8d7..5c4cf7cac3327e2ef6000dff414680cd5c4c0e1e 100644 (file)
@@ -7,6 +7,7 @@ struct log_info {
        struct commit *commit, *parent;
 };
 
+int parse_decorate_color_config(const char *var, const int ofs, const char *value);
 void init_log_tree_opt(struct rev_info *);
 int log_tree_diff_flush(struct rev_info *);
 int log_tree_commit(struct rev_info *, struct commit *);
index c336c93c01c0bad76d6189065f0e6630d0b7f5af..db4d0d50d32d8852d1cb5173125e4173c3badb49 100644 (file)
@@ -66,7 +66,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
        xdemitcb_t ecb;
 
        memset(&xpp, 0, sizeof(xpp));
-       xpp.flags = XDF_NEED_MINIMAL;
+       xpp.flags = 0;
        memset(&xecfg, 0, sizeof(xecfg));
        xecfg.ctxlen = 3;
        xecfg.flags = XDL_EMIT_COMMON;
index 0cc465ec5d13385dd8ecdbd64387cf937c82bce3..b831293b3865ae52584565039e4a893c3c6f45ff 100644 (file)
@@ -10,7 +10,7 @@ struct merge_options {
        enum {
                MERGE_RECURSIVE_NORMAL = 0,
                MERGE_RECURSIVE_OURS,
-               MERGE_RECURSIVE_THEIRS,
+               MERGE_RECURSIVE_THEIRS
        } recursive_variant;
        const char *subtree_shift;
        unsigned buffer_output : 1;
diff --git a/notes.c b/notes.c
index 4a541e43711dea791e64d84f7e6cab851ced6161..197824439826881fc0de3275353ec1b74d86cfa3 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -716,7 +716,7 @@ static int write_each_non_note_until(const char *note_path,
                struct write_each_note_data *d)
 {
        struct non_note *n = d->next_non_note;
-       int cmp, ret;
+       int cmp = 0, ret;
        while (n && (!note_path || (cmp = strcmp(n->path, note_path)) <= 0)) {
                if (note_path && cmp == 0)
                        ; /* do nothing, prefer note to non-note */
@@ -1083,7 +1083,7 @@ int write_notes_tree(struct notes_tree *t, unsigned char *result)
        return ret;
 }
 
-void prune_notes(struct notes_tree *t)
+void prune_notes(struct notes_tree *t, int flags)
 {
        struct note_delete_list *l = NULL;
 
@@ -1094,7 +1094,10 @@ void prune_notes(struct notes_tree *t)
        for_each_note(t, 0, prune_notes_helper, &l);
 
        while (l) {
-               remove_note(t, l->sha1);
+               if (flags & NOTES_PRUNE_VERBOSE)
+                       printf("%s\n", sha1_to_hex(l->sha1));
+               if (!(flags & NOTES_PRUNE_DRYRUN))
+                       remove_note(t, l->sha1);
                l = l->next;
        }
 }
diff --git a/notes.h b/notes.h
index 9f59277c516f7ac78bcc66f91a7d7013b2a77f65..65fc3a66b2f575dd078cc390e7f5ea5cbebffc96 100644 (file)
--- a/notes.h
+++ b/notes.h
@@ -18,7 +18,7 @@
  * combine_notes_concatenate(), which appends the contents of the new note to
  * the contents of the existing note.
  */
-typedef int combine_notes_fn(unsigned char *cur_sha1, const unsigned char *new_sha1);
+typedef int (*combine_notes_fn)(unsigned char *cur_sha1, const unsigned char *new_sha1);
 
 /* Common notes combinators */
 int combine_notes_concatenate(unsigned char *cur_sha1, const unsigned char *new_sha1);
@@ -38,7 +38,7 @@ extern struct notes_tree {
        struct int_node *root;
        struct non_note *first_non_note, *prev_non_note;
        char *ref;
-       combine_notes_fn *combine_notes;
+       combine_notes_fn combine_notes;
        int initialized;
        int dirty;
 } default_notes_tree;
@@ -171,6 +171,9 @@ int for_each_note(struct notes_tree *t, int flags, each_note_fn fn,
  */
 int write_notes_tree(struct notes_tree *t, unsigned char *result);
 
+/* Flags controlling the operation of prune */
+#define NOTES_PRUNE_VERBOSE 1
+#define NOTES_PRUNE_DRYRUN 2
 /*
  * Remove all notes annotating non-existing objects from the given notes tree
  *
@@ -181,7 +184,7 @@ int write_notes_tree(struct notes_tree *t, unsigned char *result);
  * structure are not persistent until a subsequent call to write_notes_tree()
  * returns zero.
  */
-void prune_notes(struct notes_tree *t);
+void prune_notes(struct notes_tree *t, int flags);
 
 /*
  * Free (and de-initialize) the given notes_tree structure
index 8546d8526f311e2a2703c258a4da3f02f8650df4..0fa79bc31d322e2aab8fce738ca6489a35a51ca4 100644 (file)
@@ -4,8 +4,9 @@
 #include "commit.h"
 #include "color.h"
 
-static int parse_options_usage(const char * const *usagestr,
-                              const struct option *opts);
+static int parse_options_usage(struct parse_opt_ctx_t *ctx,
+                              const char * const *usagestr,
+                              const struct option *opts, int err);
 
 #define OPT_SHORT 1
 #define OPT_UNSET 2
@@ -351,8 +352,9 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,
                die("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");
 }
 
-static int usage_with_options_internal(const char * const *,
-                                      const struct option *, int);
+static int usage_with_options_internal(struct parse_opt_ctx_t *,
+                                      const char * const *,
+                                      const struct option *, int, int);
 
 int parse_options_step(struct parse_opt_ctx_t *ctx,
                       const struct option *options,
@@ -380,10 +382,10 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
                if (arg[1] != '-') {
                        ctx->opt = arg + 1;
                        if (internal_help && *ctx->opt == 'h')
-                               return parse_options_usage(usagestr, options);
+                               return parse_options_usage(ctx, usagestr, options, 0);
                        switch (parse_short_opt(ctx, options)) {
                        case -1:
-                               return parse_options_usage(usagestr, options);
+                               return parse_options_usage(ctx, usagestr, options, 1);
                        case -2:
                                goto unknown;
                        }
@@ -391,10 +393,10 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
                                check_typos(arg + 1, options);
                        while (ctx->opt) {
                                if (internal_help && *ctx->opt == 'h')
-                                       return parse_options_usage(usagestr, options);
+                                       return parse_options_usage(ctx, usagestr, options, 0);
                                switch (parse_short_opt(ctx, options)) {
                                case -1:
-                                       return parse_options_usage(usagestr, options);
+                                       return parse_options_usage(ctx, usagestr, options, 1);
                                case -2:
                                        /* fake a short option thing to hide the fact that we may have
                                         * started to parse aggregated stuff
@@ -418,12 +420,12 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
                }
 
                if (internal_help && !strcmp(arg + 2, "help-all"))
-                       return usage_with_options_internal(usagestr, options, 1);
+                       return usage_with_options_internal(ctx, usagestr, options, 1, 0);
                if (internal_help && !strcmp(arg + 2, "help"))
-                       return parse_options_usage(usagestr, options);
+                       return parse_options_usage(ctx, usagestr, options, 0);
                switch (parse_long_opt(ctx, arg + 2, options)) {
                case -1:
-                       return parse_options_usage(usagestr, options);
+                       return parse_options_usage(ctx, usagestr, options, 1);
                case -2:
                        goto unknown;
                }
@@ -468,7 +470,7 @@ int parse_options(int argc, const char **argv, const char *prefix,
        return parse_options_end(&ctx);
 }
 
-static int usage_argh(const struct option *opts)
+static int usage_argh(const struct option *opts, FILE *outfile)
 {
        const char *s;
        int literal = (opts->flags & PARSE_OPT_LITERAL_ARGHELP) || !opts->argh;
@@ -479,72 +481,81 @@ static int usage_argh(const struct option *opts)
                        s = literal ? "[%s]" : "[<%s>]";
        else
                s = literal ? " %s" : " <%s>";
-       return fprintf(stderr, s, opts->argh ? opts->argh : "...");
+       return fprintf(outfile, s, opts->argh ? opts->argh : "...");
 }
 
 #define USAGE_OPTS_WIDTH 24
 #define USAGE_GAP         2
 
-static int usage_with_options_internal(const char * const *usagestr,
-                               const struct option *opts, int full)
+static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
+                                      const char * const *usagestr,
+                                      const struct option *opts, int full, int err)
 {
+       FILE *outfile = err ? stderr : stdout;
+
        if (!usagestr)
                return PARSE_OPT_HELP;
 
-       fprintf(stderr, "usage: %s\n", *usagestr++);
+       if (!err && ctx && ctx->flags & PARSE_OPT_SHELL_EVAL)
+               fprintf(outfile, "cat <<\\EOF\n");
+
+       fprintf(outfile, "usage: %s\n", *usagestr++);
        while (*usagestr && **usagestr)
-               fprintf(stderr, "   or: %s\n", *usagestr++);
+               fprintf(outfile, "   or: %s\n", *usagestr++);
        while (*usagestr) {
-               fprintf(stderr, "%s%s\n",
+               fprintf(outfile, "%s%s\n",
                                **usagestr ? "    " : "",
                                *usagestr);
                usagestr++;
        }
 
        if (opts->type != OPTION_GROUP)
-               fputc('\n', stderr);
+               fputc('\n', outfile);
 
        for (; opts->type != OPTION_END; opts++) {
                size_t pos;
                int pad;
 
                if (opts->type == OPTION_GROUP) {
-                       fputc('\n', stderr);
+                       fputc('\n', outfile);
                        if (*opts->help)
-                               fprintf(stderr, "%s\n", opts->help);
+                               fprintf(outfile, "%s\n", opts->help);
                        continue;
                }
                if (!full && (opts->flags & PARSE_OPT_HIDDEN))
                        continue;
 
-               pos = fprintf(stderr, "    ");
+               pos = fprintf(outfile, "    ");
                if (opts->short_name && !(opts->flags & PARSE_OPT_NEGHELP)) {
                        if (opts->flags & PARSE_OPT_NODASH)
-                               pos += fprintf(stderr, "%c", opts->short_name);
+                               pos += fprintf(outfile, "%c", opts->short_name);
                        else
-                               pos += fprintf(stderr, "-%c", opts->short_name);
+                               pos += fprintf(outfile, "-%c", opts->short_name);
                }
                if (opts->long_name && opts->short_name)
-                       pos += fprintf(stderr, ", ");
+                       pos += fprintf(outfile, ", ");
                if (opts->long_name)
-                       pos += fprintf(stderr, "--%s%s",
+                       pos += fprintf(outfile, "--%s%s",
                                (opts->flags & PARSE_OPT_NEGHELP) ?  "no-" : "",
                                opts->long_name);
                if (opts->type == OPTION_NUMBER)
-                       pos += fprintf(stderr, "-NUM");
+                       pos += fprintf(outfile, "-NUM");
 
                if (!(opts->flags & PARSE_OPT_NOARG))
-                       pos += usage_argh(opts);
+                       pos += usage_argh(opts, outfile);
 
                if (pos <= USAGE_OPTS_WIDTH)
                        pad = USAGE_OPTS_WIDTH - pos;
                else {
-                       fputc('\n', stderr);
+                       fputc('\n', outfile);
                        pad = USAGE_OPTS_WIDTH;
                }
-               fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
+               fprintf(outfile, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
        }
-       fputc('\n', stderr);
+       fputc('\n', outfile);
+
+       if (!err && ctx && ctx->flags & PARSE_OPT_SHELL_EVAL)
+               fputs("EOF\n", outfile);
 
        return PARSE_OPT_HELP;
 }
@@ -552,7 +563,7 @@ static int usage_with_options_internal(const char * const *usagestr,
 void usage_with_options(const char * const *usagestr,
                        const struct option *opts)
 {
-       usage_with_options_internal(usagestr, opts, 0);
+       usage_with_options_internal(NULL, usagestr, opts, 0, 1);
        exit(129);
 }
 
@@ -564,10 +575,11 @@ void usage_msg_opt(const char *msg,
        usage_with_options(usagestr, options);
 }
 
-static int parse_options_usage(const char * const *usagestr,
-                              const struct option *opts)
+static int parse_options_usage(struct parse_opt_ctx_t *ctx,
+                              const char * const *usagestr,
+                              const struct option *opts, int err)
 {
-       return usage_with_options_internal(usagestr, opts, 0);
+       return usage_with_options_internal(ctx, usagestr, opts, 0, err);
 }
 
 
index 7581e931da13151473739036a89d9d19303eb18b..7435cdbf1d94378cf1c3408ae17cb610165a00ba 100644 (file)
@@ -25,7 +25,7 @@ enum parse_opt_flags {
        PARSE_OPT_STOP_AT_NON_OPTION = 2,
        PARSE_OPT_KEEP_ARGV0 = 4,
        PARSE_OPT_KEEP_UNKNOWN = 8,
-       PARSE_OPT_NO_INTERNAL_HELP = 16,
+       PARSE_OPT_NO_INTERNAL_HELP = 16
 };
 
 enum parse_opt_option_flags {
@@ -37,6 +37,7 @@ enum parse_opt_option_flags {
        PARSE_OPT_NODASH = 32,
        PARSE_OPT_LITERAL_ARGHELP = 64,
        PARSE_OPT_NEGHELP = 128,
+       PARSE_OPT_SHELL_EVAL = 256
 };
 
 struct option;
@@ -160,7 +161,7 @@ extern NORETURN void usage_msg_opt(const char *msg,
 enum {
        PARSE_OPT_HELP = -1,
        PARSE_OPT_DONE,
-       PARSE_OPT_UNKNOWN,
+       PARSE_OPT_UNKNOWN
 };
 
 /*
index 1926dc9a4b929c025456227526a93424d4972948..6cb0dd19344ba1169b23b7e4949033f8a9088a00 100644 (file)
@@ -172,7 +172,7 @@ sub repository {
        }
 
        if (defined $opts{Directory}) {
-               -d $opts{Directory} or throw Error::Simple("Directory not found: $!");
+               -d $opts{Directory} or throw Error::Simple("Directory not found: $opts{Directory} $!");
 
                my $search = Git->repository(WorkingCopy => $opts{Directory});
                my $dir;
@@ -545,7 +545,7 @@ sub wc_chdir {
                or throw Error::Simple("bare repository");
 
        -d $self->wc_path().'/'.$subdir
-               or throw Error::Simple("subdir not found: $!");
+               or throw Error::Simple("subdir not found: $subdir $!");
        # Of course we will not "hold" the subdirectory so anyone
        # can delete it now and we will never know. But at least we tried.
 
index 74cda1b44e37f414d9d61326bbc5c548d56ba780..f85444b27d4815547f7cef542291b1f6616f77d5 100644 (file)
--- a/pretty.c
+++ b/pretty.c
 #include "reflog-walk.h"
 
 static char *user_format;
+static struct cmt_fmt_map {
+       const char *name;
+       enum cmit_fmt format;
+       int is_tformat;
+       int is_alias;
+       const char *user_format;
+} *commit_formats;
+static size_t builtin_formats_len;
+static size_t commit_formats_len;
+static size_t commit_formats_alloc;
+static struct cmt_fmt_map *find_commit_format(const char *sought);
 
 static void save_user_format(struct rev_info *rev, const char *cp, int is_tformat)
 {
@@ -21,22 +32,118 @@ static void save_user_format(struct rev_info *rev, const char *cp, int is_tforma
        rev->commit_format = CMIT_FMT_USERFORMAT;
 }
 
-void get_commit_format(const char *arg, struct rev_info *rev)
+static int git_pretty_formats_config(const char *var, const char *value, void *cb)
 {
+       struct cmt_fmt_map *commit_format = NULL;
+       const char *name;
+       const char *fmt;
        int i;
-       static struct cmt_fmt_map {
-               const char *n;
-               size_t cmp_len;
-               enum cmit_fmt v;
-       } cmt_fmts[] = {
-               { "raw",        1,      CMIT_FMT_RAW },
-               { "medium",     1,      CMIT_FMT_MEDIUM },
-               { "short",      1,      CMIT_FMT_SHORT },
-               { "email",      1,      CMIT_FMT_EMAIL },
-               { "full",       5,      CMIT_FMT_FULL },
-               { "fuller",     5,      CMIT_FMT_FULLER },
-               { "oneline",    1,      CMIT_FMT_ONELINE },
+
+       if (prefixcmp(var, "pretty."))
+               return 0;
+
+       name = var + strlen("pretty.");
+       for (i = 0; i < builtin_formats_len; i++) {
+               if (!strcmp(commit_formats[i].name, name))
+                       return 0;
+       }
+
+       for (i = builtin_formats_len; i < commit_formats_len; i++) {
+               if (!strcmp(commit_formats[i].name, name)) {
+                       commit_format = &commit_formats[i];
+                       break;
+               }
+       }
+
+       if (!commit_format) {
+               ALLOC_GROW(commit_formats, commit_formats_len+1,
+                          commit_formats_alloc);
+               commit_format = &commit_formats[commit_formats_len];
+               memset(commit_format, 0, sizeof(*commit_format));
+               commit_formats_len++;
+       }
+
+       commit_format->name = xstrdup(name);
+       commit_format->format = CMIT_FMT_USERFORMAT;
+       git_config_string(&fmt, var, value);
+       if (!prefixcmp(fmt, "format:") || !prefixcmp(fmt, "tformat:")) {
+               commit_format->is_tformat = fmt[0] == 't';
+               fmt = strchr(fmt, ':') + 1;
+       } else if (strchr(fmt, '%'))
+               commit_format->is_tformat = 1;
+       else
+               commit_format->is_alias = 1;
+       commit_format->user_format = fmt;
+
+       return 0;
+}
+
+static void setup_commit_formats(void)
+{
+       struct cmt_fmt_map builtin_formats[] = {
+               { "raw",        CMIT_FMT_RAW,           0 },
+               { "medium",     CMIT_FMT_MEDIUM,        0 },
+               { "short",      CMIT_FMT_SHORT,         0 },
+               { "email",      CMIT_FMT_EMAIL,         0 },
+               { "fuller",     CMIT_FMT_FULLER,        0 },
+               { "full",       CMIT_FMT_FULL,          0 },
+               { "oneline",    CMIT_FMT_ONELINE,       1 }
        };
+       commit_formats_len = ARRAY_SIZE(builtin_formats);
+       builtin_formats_len = commit_formats_len;
+       ALLOC_GROW(commit_formats, commit_formats_len, commit_formats_alloc);
+       memcpy(commit_formats, builtin_formats,
+              sizeof(*builtin_formats)*ARRAY_SIZE(builtin_formats));
+
+       git_config(git_pretty_formats_config, NULL);
+}
+
+static struct cmt_fmt_map *find_commit_format_recursive(const char *sought,
+                                                       const char *original,
+                                                       int num_redirections)
+{
+       struct cmt_fmt_map *found = NULL;
+       size_t found_match_len = 0;
+       int i;
+
+       if (num_redirections >= commit_formats_len)
+               die("invalid --pretty format: "
+                   "'%s' references an alias which points to itself",
+                   original);
+
+       for (i = 0; i < commit_formats_len; i++) {
+               size_t match_len;
+
+               if (prefixcmp(commit_formats[i].name, sought))
+                       continue;
+
+               match_len = strlen(commit_formats[i].name);
+               if (found == NULL || found_match_len > match_len) {
+                       found = &commit_formats[i];
+                       found_match_len = match_len;
+               }
+       }
+
+       if (found && found->is_alias) {
+               found = find_commit_format_recursive(found->user_format,
+                                                    original,
+                                                    num_redirections+1);
+       }
+
+       return found;
+}
+
+static struct cmt_fmt_map *find_commit_format(const char *sought)
+{
+       if (!commit_formats)
+               setup_commit_formats();
+
+       return find_commit_format_recursive(sought, sought, 0);
+}
+
+void get_commit_format(const char *arg, struct rev_info *rev)
+{
+       struct cmt_fmt_map *commit_format;
 
        rev->use_terminator = 0;
        if (!arg || !*arg) {
@@ -47,21 +154,22 @@ void get_commit_format(const char *arg, struct rev_info *rev)
                save_user_format(rev, strchr(arg, ':') + 1, arg[0] == 't');
                return;
        }
-       for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
-               if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
-                   !strncmp(arg, cmt_fmts[i].n, strlen(arg))) {
-                       if (cmt_fmts[i].v == CMIT_FMT_ONELINE)
-                               rev->use_terminator = 1;
-                       rev->commit_format = cmt_fmts[i].v;
-                       return;
-               }
-       }
+
        if (strchr(arg, '%')) {
                save_user_format(rev, arg, 1);
                return;
        }
 
-       die("invalid --pretty format: %s", arg);
+       commit_format = find_commit_format(arg);
+       if (!commit_format)
+               die("invalid --pretty format: %s", arg);
+
+       rev->commit_format = commit_format->format;
+       rev->use_terminator = commit_format->is_tformat;
+       if (commit_format->format == CMIT_FMT_USERFORMAT) {
+               save_user_format(rev, commit_format->user_format,
+                                commit_format->is_tformat);
+       }
 }
 
 /*
@@ -834,6 +942,7 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
                NO_MAGIC,
                ADD_LF_BEFORE_NON_EMPTY,
                DEL_LF_BEFORE_EMPTY,
+               ADD_SP_BEFORE_NON_EMPTY
        } magic = NO_MAGIC;
 
        switch (placeholder[0]) {
@@ -843,6 +952,9 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
        case '+':
                magic = ADD_LF_BEFORE_NON_EMPTY;
                break;
+       case ' ':
+               magic = ADD_SP_BEFORE_NON_EMPTY;
+               break;
        default:
                break;
        }
@@ -857,8 +969,11 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
        if ((orig_len == sb->len) && magic == DEL_LF_BEFORE_EMPTY) {
                while (sb->len && sb->buf[sb->len - 1] == '\n')
                        strbuf_setlen(sb, sb->len - 1);
-       } else if ((orig_len != sb->len) && magic == ADD_LF_BEFORE_NON_EMPTY) {
-               strbuf_insert(sb, orig_len, "\n", 1);
+       } else if (orig_len != sb->len) {
+               if (magic == ADD_LF_BEFORE_NON_EMPTY)
+                       strbuf_insert(sb, orig_len, "\n", 1);
+               else if (magic == ADD_SP_BEFORE_NON_EMPTY)
+                       strbuf_insert(sb, orig_len, " ", 1);
        }
        return consumed + 1;
 }
@@ -868,7 +983,7 @@ static size_t userformat_want_item(struct strbuf *sb, const char *placeholder,
 {
        struct userformat_want *w = context;
 
-       if (*placeholder == '+' || *placeholder == '-')
+       if (*placeholder == '+' || *placeholder == '-' || *placeholder == ' ')
                placeholder++;
 
        switch (*placeholder) {
diff --git a/quote.c b/quote.c
index fc93435727db3b0634c390965258200c61d8b59b..63d3b018183abc05a5231dfd7e134dd7394f7a9b 100644 (file)
--- a/quote.c
+++ b/quote.c
@@ -295,42 +295,75 @@ void write_name_quotedpfx(const char *pfx, size_t pfxlen,
        fputc(terminator, fp);
 }
 
-/* quote path as relative to the given prefix */
-char *quote_path_relative(const char *in, int len,
-                         struct strbuf *out, const char *prefix)
+static const char *path_relative(const char *in, int len,
+                                struct strbuf *sb, const char *prefix,
+                                int prefix_len);
+
+void write_name_quoted_relative(const char *name, size_t len,
+                               const char *prefix, size_t prefix_len,
+                               FILE *fp, int terminator)
 {
-       int needquote;
+       struct strbuf sb = STRBUF_INIT;
+
+       name = path_relative(name, len, &sb, prefix, prefix_len);
+       write_name_quoted(name, fp, terminator);
+
+       strbuf_release(&sb);
+}
+
+/*
+ * Give path as relative to prefix.
+ *
+ * The strbuf may or may not be used, so do not assume it contains the
+ * returned path.
+ */
+static const char *path_relative(const char *in, int len,
+                                struct strbuf *sb, const char *prefix,
+                                int prefix_len)
+{
+       int off, i;
 
        if (len < 0)
                len = strlen(in);
+       if (prefix && prefix_len < 0)
+               prefix_len = strlen(prefix);
+
+       off = 0;
+       i = 0;
+       while (i < prefix_len && i < len && prefix[i] == in[i]) {
+               if (prefix[i] == '/')
+                       off = i + 1;
+               i++;
+       }
+       in += off;
+       len -= off;
+
+       if (i >= prefix_len)
+               return in;
 
-       /* "../" prefix itself does not need quoting, but "in" might. */
-       needquote = next_quote_pos(in, len) < len;
-       strbuf_setlen(out, 0);
-       strbuf_grow(out, len);
-
-       if (needquote)
-               strbuf_addch(out, '"');
-       if (prefix) {
-               int off = 0;
-               while (prefix[off] && off < len && prefix[off] == in[off])
-                       if (prefix[off] == '/') {
-                               prefix += off + 1;
-                               in += off + 1;
-                               len -= off + 1;
-                               off = 0;
-                       } else
-                               off++;
-
-               for (; *prefix; prefix++)
-                       if (*prefix == '/')
-                               strbuf_addstr(out, "../");
+       strbuf_reset(sb);
+       strbuf_grow(sb, len);
+
+       while (i < prefix_len) {
+               if (prefix[i] == '/')
+                       strbuf_addstr(sb, "../");
+               i++;
        }
+       strbuf_add(sb, in, len);
+
+       return sb->buf;
+}
 
-       quote_c_style_counted (in, len, out, NULL, 1);
+/* quote path as relative to the given prefix */
+char *quote_path_relative(const char *in, int len,
+                         struct strbuf *out, const char *prefix)
+{
+       struct strbuf sb = STRBUF_INIT;
+       const char *rel = path_relative(in, len, &sb, prefix, -1);
+       strbuf_reset(out);
+       quote_c_style_counted(rel, strlen(rel), out, NULL, 0);
+       strbuf_release(&sb);
 
-       if (needquote)
-               strbuf_addch(out, '"');
        if (!out->len)
                strbuf_addstr(out, "./");
 
diff --git a/quote.h b/quote.h
index f83eb233c4b153c4c073b3ccd5bf2f5dd926b739..38003bff5f97a11e051b106522a8548d43d24f6c 100644 (file)
--- a/quote.h
+++ b/quote.h
@@ -54,9 +54,12 @@ extern void quote_two_c_style(struct strbuf *, const char *, const char *, int);
 extern void write_name_quoted(const char *name, FILE *, int terminator);
 extern void write_name_quotedpfx(const char *pfx, size_t pfxlen,
                                  const char *name, FILE *, int terminator);
+extern void write_name_quoted_relative(const char *name, size_t len,
+               const char *prefix, size_t prefix_len,
+               FILE *fp, int terminator);
 
 /* quote path as relative to the given prefix */
-char *quote_path_relative(const char *in, int len,
+extern char *quote_path_relative(const char *in, int len,
                          struct strbuf *out, const char *prefix);
 
 /* quoting as a string literal for other languages */
diff --git a/refs.c b/refs.c
index d3db15a76cc46f6f6a31d4448816c09e6c48e543..b5400674d7a1fcf4cc16dd630b8671b2ad7b9f7b 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -314,7 +314,11 @@ static int warn_if_dangling_symref(const char *refname, const unsigned char *sha
 
 void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname)
 {
-       struct warn_if_dangling_data data = { fp, refname, msg_fmt };
+       struct warn_if_dangling_data data;
+
+       data.fp = fp;
+       data.refname = refname;
+       data.msg_fmt = msg_fmt;
        for_each_rawref(warn_if_dangling_symref, &data);
 }
 
@@ -1086,6 +1090,15 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
        return ret;
 }
 
+/*
+ * People using contrib's git-new-workdir have .git/logs/refs ->
+ * /some/other/path/.git/logs/refs, and that may live on another device.
+ *
+ * IOW, to avoid cross device rename errors, the temporary renamed log must
+ * live into logs/refs.
+ */
+#define TMP_RENAMED_LOG  "logs/refs/.tmp-renamed-log"
+
 int rename_ref(const char *oldref, const char *newref, const char *logmsg)
 {
        static const char renamed_ref[] = "RENAMED-REF";
@@ -1119,8 +1132,8 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
        if (write_ref_sha1(lock, orig_sha1, logmsg))
                return error("unable to save current sha1 in %s", renamed_ref);
 
-       if (log && rename(git_path("logs/%s", oldref), git_path("tmp-renamed-log")))
-               return error("unable to move logfile logs/%s to tmp-renamed-log: %s",
+       if (log && rename(git_path("logs/%s", oldref), git_path(TMP_RENAMED_LOG)))
+               return error("unable to move logfile logs/%s to "TMP_RENAMED_LOG": %s",
                        oldref, strerror(errno));
 
        if (delete_ref(oldref, orig_sha1, REF_NODEREF)) {
@@ -1146,7 +1159,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
        }
 
  retry:
-       if (log && rename(git_path("tmp-renamed-log"), git_path("logs/%s", newref))) {
+       if (log && rename(git_path(TMP_RENAMED_LOG), git_path("logs/%s", newref))) {
                if (errno==EISDIR || errno==ENOTDIR) {
                        /*
                         * rename(a, b) when b is an existing
@@ -1159,7 +1172,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
                        }
                        goto retry;
                } else {
-                       error("unable to move logfile tmp-renamed-log to logs/%s: %s",
+                       error("unable to move logfile "TMP_RENAMED_LOG" to logs/%s: %s",
                                newref, strerror(errno));
                        goto rollback;
                }
@@ -1199,8 +1212,8 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
                error("unable to restore logfile %s from %s: %s",
                        oldref, newref, strerror(errno));
        if (!logmoved && log &&
-           rename(git_path("tmp-renamed-log"), git_path("logs/%s", oldref)))
-               error("unable to restore logfile %s from tmp-renamed-log: %s",
+           rename(git_path(TMP_RENAMED_LOG), git_path("logs/%s", oldref)))
+               error("unable to restore logfile %s from "TMP_RENAMED_LOG": %s",
                        oldref, strerror(errno));
 
        return 1;
@@ -1258,52 +1271,65 @@ static int copy_msg(char *buf, const char *msg)
        return cp - buf;
 }
 
-static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
-                        const unsigned char *new_sha1, const char *msg)
+int log_ref_setup(const char *ref_name, char *logfile, int bufsize)
 {
-       int logfd, written, oflags = O_APPEND | O_WRONLY;
-       unsigned maxlen, len;
-       int msglen;
-       char log_file[PATH_MAX];
-       char *logrec;
-       const char *committer;
-
-       if (log_all_ref_updates < 0)
-               log_all_ref_updates = !is_bare_repository();
-
-       git_snpath(log_file, sizeof(log_file), "logs/%s", ref_name);
+       int logfd, oflags = O_APPEND | O_WRONLY;
 
+       git_snpath(logfile, bufsize, "logs/%s", ref_name);
        if (log_all_ref_updates &&
            (!prefixcmp(ref_name, "refs/heads/") ||
             !prefixcmp(ref_name, "refs/remotes/") ||
             !prefixcmp(ref_name, "refs/notes/") ||
             !strcmp(ref_name, "HEAD"))) {
-               if (safe_create_leading_directories(log_file) < 0)
+               if (safe_create_leading_directories(logfile) < 0)
                        return error("unable to create directory for %s",
-                                    log_file);
+                                    logfile);
                oflags |= O_CREAT;
        }
 
-       logfd = open(log_file, oflags, 0666);
+       logfd = open(logfile, oflags, 0666);
        if (logfd < 0) {
                if (!(oflags & O_CREAT) && errno == ENOENT)
                        return 0;
 
                if ((oflags & O_CREAT) && errno == EISDIR) {
-                       if (remove_empty_directories(log_file)) {
+                       if (remove_empty_directories(logfile)) {
                                return error("There are still logs under '%s'",
-                                            log_file);
+                                            logfile);
                        }
-                       logfd = open(log_file, oflags, 0666);
+                       logfd = open(logfile, oflags, 0666);
                }
 
                if (logfd < 0)
                        return error("Unable to append to %s: %s",
-                                    log_file, strerror(errno));
+                                    logfile, strerror(errno));
        }
 
-       adjust_shared_perm(log_file);
+       adjust_shared_perm(logfile);
+       close(logfd);
+       return 0;
+}
+
+static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
+                        const unsigned char *new_sha1, const char *msg)
+{
+       int logfd, result, written, oflags = O_APPEND | O_WRONLY;
+       unsigned maxlen, len;
+       int msglen;
+       char log_file[PATH_MAX];
+       char *logrec;
+       const char *committer;
+
+       if (log_all_ref_updates < 0)
+               log_all_ref_updates = !is_bare_repository();
+
+       result = log_ref_setup(ref_name, log_file, sizeof(log_file));
+       if (result)
+               return result;
 
+       logfd = open(log_file, oflags);
+       if (logfd < 0)
+               return 0;
        msglen = msg ? strlen(msg) : 0;
        committer = git_committer_info(0);
        maxlen = strlen(committer) + msglen + 100;
diff --git a/refs.h b/refs.h
index 4a18b083f52a15e5216d583644e590d666cae097..762ce504b5eba3aacff204321a7c41db2b1e6053 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -68,6 +68,9 @@ extern void unlock_ref(struct ref_lock *lock);
 /** Writes sha1 into the ref specified by the lock. **/
 extern int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1, const char *msg);
 
+/** Setup reflog before using. **/
+int log_ref_setup(const char *ref_name, char *logfile, int bufsize);
+
 /** Reads log for the value of ref during at_time. **/
 extern int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt);
 
index 9f0c6ef8f5797b09fc4e63fe87a1221f38d22ce5..afbba47460c0204721d61800033ed0a9f93f92bc 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -478,7 +478,7 @@ static void read_config(void)
        unsigned char sha1[20];
        const char *head_ref;
        int flag;
-       if (default_remote_name) // did this already
+       if (default_remote_name) /* did this already */
                return;
        default_remote_name = xstrdup("origin");
        current_branch = NULL;
@@ -659,10 +659,9 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
 
 int valid_fetch_refspec(const char *fetch_refspec_str)
 {
-       const char *fetch_refspec[] = { fetch_refspec_str };
        struct refspec *refspec;
 
-       refspec = parse_refspec_internal(1, fetch_refspec, 1, 1);
+       refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1);
        free_refspecs(refspec, 1);
        return !!refspec;
 }
index 6e13643cabb6fa9a5b619f53dd148345d9161ad4..888d7c15de2eacc56d869a96d4463aefca7a7a06 100644 (file)
--- a/remote.h
+++ b/remote.h
@@ -145,7 +145,7 @@ int branch_merge_matches(struct branch *, int n, const char *);
 enum match_refs_flags {
        MATCH_REFS_NONE         = 0,
        MATCH_REFS_ALL          = (1 << 0),
-       MATCH_REFS_MIRROR       = (1 << 1),
+       MATCH_REFS_MIRROR       = (1 << 1)
 };
 
 /* Reporting of tracking info */
index 910cfd963dcdbcb096b36b91868955a65ecdffa1..d03a69634b81e1146c20182670a400b0c29b275f 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -153,7 +153,7 @@ static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_siz
        git_SHA_CTX ctx;
        int hunk_no = 0;
        enum {
-               RR_CONTEXT = 0, RR_SIDE_1, RR_SIDE_2, RR_ORIGINAL,
+               RR_CONTEXT = 0, RR_SIDE_1, RR_SIDE_2, RR_ORIGINAL
        } hunk = RR_CONTEXT;
        struct strbuf one = STRBUF_INIT, two = STRBUF_INIT;
        struct strbuf buf = STRBUF_INIT;
index 28f1c6d014d5428948967224ee34f048bd2a04b5..7e82efd9324e84582732485c53c6c25a24c29997 100644 (file)
@@ -646,6 +646,93 @@ static int still_interesting(struct commit_list *src, unsigned long date, int sl
        return slop-1;
 }
 
+/*
+ * "rev-list --ancestry-path A..B" computes commits that are ancestors
+ * of B but not ancestors of A but further limits the result to those
+ * that are descendants of A.  This takes the list of bottom commits and
+ * the result of "A..B" without --ancestry-path, and limits the latter
+ * further to the ones that can reach one of the commits in "bottom".
+ */
+static void limit_to_ancestry(struct commit_list *bottom, struct commit_list *list)
+{
+       struct commit_list *p;
+       struct commit_list *rlist = NULL;
+       int made_progress;
+
+       /*
+        * Reverse the list so that it will be likely that we would
+        * process parents before children.
+        */
+       for (p = list; p; p = p->next)
+               commit_list_insert(p->item, &rlist);
+
+       for (p = bottom; p; p = p->next)
+               p->item->object.flags |= TMP_MARK;
+
+       /*
+        * Mark the ones that can reach bottom commits in "list",
+        * in a bottom-up fashion.
+        */
+       do {
+               made_progress = 0;
+               for (p = rlist; p; p = p->next) {
+                       struct commit *c = p->item;
+                       struct commit_list *parents;
+                       if (c->object.flags & (TMP_MARK | UNINTERESTING))
+                               continue;
+                       for (parents = c->parents;
+                            parents;
+                            parents = parents->next) {
+                               if (!(parents->item->object.flags & TMP_MARK))
+                                       continue;
+                               c->object.flags |= TMP_MARK;
+                               made_progress = 1;
+                               break;
+                       }
+               }
+       } while (made_progress);
+
+       /*
+        * NEEDSWORK: decide if we want to remove parents that are
+        * not marked with TMP_MARK from commit->parents for commits
+        * in the resulting list.  We may not want to do that, though.
+        */
+
+       /*
+        * The ones that are not marked with TMP_MARK are uninteresting
+        */
+       for (p = list; p; p = p->next) {
+               struct commit *c = p->item;
+               if (c->object.flags & TMP_MARK)
+                       continue;
+               c->object.flags |= UNINTERESTING;
+       }
+
+       /* We are done with the TMP_MARK */
+       for (p = list; p; p = p->next)
+               p->item->object.flags &= ~TMP_MARK;
+       for (p = bottom; p; p = p->next)
+               p->item->object.flags &= ~TMP_MARK;
+       free_commit_list(rlist);
+}
+
+/*
+ * Before walking the history, keep the set of "negative" refs the
+ * caller has asked to exclude.
+ *
+ * This is used to compute "rev-list --ancestry-path A..B", as we need
+ * to filter the result of "A..B" further to the ones that can actually
+ * reach A.
+ */
+static struct commit_list *collect_bottom_commits(struct commit_list *list)
+{
+       struct commit_list *elem, *bottom = NULL;
+       for (elem = list; elem; elem = elem->next)
+               if (elem->item->object.flags & UNINTERESTING)
+                       commit_list_insert(elem->item, &bottom);
+       return bottom;
+}
+
 static int limit_list(struct rev_info *revs)
 {
        int slop = SLOP;
@@ -653,6 +740,13 @@ static int limit_list(struct rev_info *revs)
        struct commit_list *list = revs->commits;
        struct commit_list *newlist = NULL;
        struct commit_list **p = &newlist;
+       struct commit_list *bottom = NULL;
+
+       if (revs->ancestry_path) {
+               bottom = collect_bottom_commits(list);
+               if (!bottom)
+                       die("--ancestry-path given but there are no bottom commits");
+       }
 
        while (list) {
                struct commit_list *entry = list;
@@ -694,6 +788,11 @@ static int limit_list(struct rev_info *revs)
        if (revs->cherry_pick)
                cherry_pick_list(newlist, revs);
 
+       if (bottom) {
+               limit_to_ancestry(bottom, newlist);
+               free_commit_list(bottom);
+       }
+
        revs->commits = newlist;
        return 0;
 }
@@ -1063,18 +1162,22 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 
        if (!prefixcmp(arg, "--max-count=")) {
                revs->max_count = atoi(arg + 12);
+               revs->no_walk = 0;
        } else if (!prefixcmp(arg, "--skip=")) {
                revs->skip_count = atoi(arg + 7);
        } else if ((*arg == '-') && isdigit(arg[1])) {
        /* accept -<digit>, like traditional "head" */
                revs->max_count = atoi(arg + 1);
+               revs->no_walk = 0;
        } else if (!strcmp(arg, "-n")) {
                if (argc <= 1)
                        return error("-n requires an argument");
                revs->max_count = atoi(argv[1]);
+               revs->no_walk = 0;
                return 2;
        } else if (!prefixcmp(arg, "-n")) {
                revs->max_count = atoi(arg + 2);
+               revs->no_walk = 0;
        } else if (!prefixcmp(arg, "--max-age=")) {
                revs->max_age = atoi(arg + 10);
        } else if (!prefixcmp(arg, "--since=")) {
@@ -1089,6 +1192,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
                revs->min_age = approxidate(arg + 8);
        } else if (!strcmp(arg, "--first-parent")) {
                revs->first_parent_only = 1;
+       } else if (!strcmp(arg, "--ancestry-path")) {
+               revs->ancestry_path = 1;
+               revs->simplify_history = 0;
+               revs->limited = 1;
        } else if (!strcmp(arg, "-g") || !strcmp(arg, "--walk-reflogs")) {
                init_reflog_walk(&revs->reflog_info);
        } else if (!strcmp(arg, "--default")) {
@@ -1146,6 +1253,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
                revs->boundary = 1;
        } else if (!strcmp(arg, "--left-right")) {
                revs->left_right = 1;
+       } else if (!strcmp(arg, "--count")) {
+               revs->count = 1;
        } else if (!strcmp(arg, "--cherry-pick")) {
                revs->cherry_pick = 1;
                revs->limited = 1;
@@ -1781,7 +1890,7 @@ int prepare_revision_walk(struct rev_info *revs)
 enum rewrite_result {
        rewrite_one_ok,
        rewrite_one_noparents,
-       rewrite_one_error,
+       rewrite_one_error
 };
 
 static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp)
index 568f1c98de844dbadcebf1d583bffc24e6daa677..36fdf22b299c4cc7e6f20d767d5c6a6c3f69d952 100644 (file)
@@ -57,6 +57,7 @@ struct rev_info {
                        limited:1,
                        unpacked:1,
                        boundary:2,
+                       count:1,
                        left_right:1,
                        rewrite_parents:1,
                        print_parents:1,
@@ -66,6 +67,7 @@ struct rev_info {
                        reverse_output_stage:1,
                        cherry_pick:1,
                        bisect:1,
+                       ancestry_path:1,
                        first_parent_only:1;
 
        /* Diff flags */
@@ -131,6 +133,10 @@ struct rev_info {
 
        /* notes-specific options: which refs to show */
        struct display_notes_opt notes_opt;
+
+       /* commit counts */
+       int count_left;
+       int count_right;
 };
 
 #define REV_TREE_SAME          0
index c7793f50fbe0a43495c2b2d36a47c0b5aac37483..2a1041ef6599c84fff6a8d9faf5dea23a2af3ab0 100644 (file)
@@ -84,6 +84,7 @@ static NORETURN void die_child(const char *err, va_list params)
        unused = write(child_err, "\n", 1);
        exit(128);
 }
+#endif
 
 static inline void set_cloexec(int fd)
 {
@@ -91,7 +92,6 @@ static inline void set_cloexec(int fd)
        if (flags >= 0)
                fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
 }
-#endif
 
 static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
 {
@@ -449,11 +449,35 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const
        return run_command(&cmd);
 }
 
-#ifdef WIN32
-static unsigned __stdcall run_thread(void *data)
+#ifndef NO_PTHREADS
+static pthread_t main_thread;
+static int main_thread_set;
+static pthread_key_t async_key;
+
+static void *run_thread(void *data)
 {
        struct async *async = data;
-       return async->proc(async->proc_in, async->proc_out, async->data);
+       intptr_t ret;
+
+       pthread_setspecific(async_key, async);
+       ret = async->proc(async->proc_in, async->proc_out, async->data);
+       return (void *)ret;
+}
+
+static NORETURN void die_async(const char *err, va_list params)
+{
+       vreportf("fatal: ", err, params);
+
+       if (!pthread_equal(main_thread, pthread_self())) {
+               struct async *async = pthread_getspecific(async_key);
+               if (async->proc_in >= 0)
+                       close(async->proc_in);
+               if (async->proc_out >= 0)
+                       close(async->proc_out);
+               pthread_exit((void *)128);
+       }
+
+       exit(128);
 }
 #endif
 
@@ -499,7 +523,7 @@ int start_async(struct async *async)
        else
                proc_out = -1;
 
-#ifndef WIN32
+#ifdef NO_PTHREADS
        /* Flush stdio before fork() to avoid cloning buffers */
        fflush(NULL);
 
@@ -526,12 +550,29 @@ int start_async(struct async *async)
        else if (async->out)
                close(async->out);
 #else
+       if (!main_thread_set) {
+               /*
+                * We assume that the first time that start_async is called
+                * it is from the main thread.
+                */
+               main_thread_set = 1;
+               main_thread = pthread_self();
+               pthread_key_create(&async_key, NULL);
+               set_die_routine(die_async);
+       }
+
+       if (proc_in >= 0)
+               set_cloexec(proc_in);
+       if (proc_out >= 0)
+               set_cloexec(proc_out);
        async->proc_in = proc_in;
        async->proc_out = proc_out;
-       async->tid = (HANDLE) _beginthreadex(NULL, 0, run_thread, async, 0, NULL);
-       if (!async->tid) {
-               error("cannot create thread: %s", strerror(errno));
-               goto error;
+       {
+               int err = pthread_create(&async->tid, NULL, run_thread, async);
+               if (err) {
+                       error("cannot create thread: %s", strerror(err));
+                       goto error;
+               }
        }
 #endif
        return 0;
@@ -551,17 +592,15 @@ error:
 
 int finish_async(struct async *async)
 {
-#ifndef WIN32
-       int ret = wait_or_whine(async->pid, "child process", 0);
+#ifdef NO_PTHREADS
+       return wait_or_whine(async->pid, "child process", 0);
 #else
-       DWORD ret = 0;
-       if (WaitForSingleObject(async->tid, INFINITE) != WAIT_OBJECT_0)
-               ret = error("waiting for thread failed: %lu", GetLastError());
-       else if (!GetExitCodeThread(async->tid, &ret))
-               ret = error("cannot get thread exit code: %lu", GetLastError());
-       CloseHandle(async->tid);
+       void *ret = (void *)(intptr_t)(-1);
+
+       if (pthread_join(async->tid, &ret))
+               error("pthread_join failed");
+       return (int)(intptr_t)ret;
 #endif
-       return ret;
 }
 
 int run_hook(const char *index_file, const char *name, ...)
index 94619f52d95888b320664b7f19db3eeb7d6d8cca..56491b9f2344541c02bd0da2928a535f11193bd8 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef RUN_COMMAND_H
 #define RUN_COMMAND_H
 
+#ifndef NO_PTHREADS
+#include <pthread.h>
+#endif
+
 struct child_process {
        const char **argv;
        pid_t pid;
@@ -74,10 +78,10 @@ struct async {
        void *data;
        int in;         /* caller writes here and closes it */
        int out;        /* caller reads from here and closes it */
-#ifndef WIN32
+#ifdef NO_PTHREADS
        pid_t pid;
 #else
-       HANDLE tid;
+       pthread_t tid;
        int proc_in;
        int proc_out;
 #endif
diff --git a/setup.c b/setup.c
index 5a083fa77dda016d0f3f511787ebf771aaf1be08..87c21f02e0e3bedb42305bbfe2b4223885d4250f 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -323,7 +323,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
        const char *gitdirenv;
        const char *gitfile_dir;
        int len, offset, ceil_offset, root_len;
-       int current_device = 0, one_filesystem = 1;
+       dev_t current_device = 0;
+       int one_filesystem = 1;
        struct stat buf;
 
        /*
@@ -546,6 +547,12 @@ int check_repository_format(void)
        return check_repository_format_gently(NULL);
 }
 
+/*
+ * Returns the "prefix", a path to the current working directory
+ * relative to the work tree root, or NULL, if the current working
+ * directory is not a strict subdirectory of the work tree root. The
+ * prefix always ends with a '/' character.
+ */
 const char *setup_git_directory(void)
 {
        const char *retval = setup_git_directory_gently(NULL);
index d8e61a65d10ed6fa792d207e36fb6b245ef86970..e42ef96d457f6aa12ab7d0057acf936db0335d40 100644 (file)
@@ -102,20 +102,22 @@ static void fill_sha1_path(char *pathbuf, const unsigned char *sha1)
  */
 char *sha1_file_name(const unsigned char *sha1)
 {
-       static char *name, *base;
+       static char buf[PATH_MAX];
+       const char *objdir;
+       int len;
 
-       if (!base) {
-               const char *sha1_file_directory = get_object_directory();
-               int len = strlen(sha1_file_directory);
-               base = xmalloc(len + 60);
-               memcpy(base, sha1_file_directory, len);
-               memset(base+len, 0, 60);
-               base[len] = '/';
-               base[len+3] = '/';
-               name = base + len + 1;
-       }
-       fill_sha1_path(name, sha1);
-       return base;
+       objdir = get_object_directory();
+       len = strlen(objdir);
+
+       /* '/' + sha1(2) + '/' + sha1(38) + '\0' */
+       if (len + 43 > PATH_MAX)
+               die("insanely long object directory %s", objdir);
+       memcpy(buf, objdir, len);
+       buf[len] = '/';
+       buf[len+3] = '/';
+       buf[len+42] = '\0';
+       fill_sha1_path(buf + len + 1, sha1);
+       return buf;
 }
 
 static char *sha1_get_pack_name(const unsigned char *sha1,
index bf924178380c42a50b2fd7a02ff869dcc3ddff6a..4f2af8da934b125f2c09ceb4d8185dabc58f7831 100644 (file)
@@ -679,8 +679,8 @@ static int handle_one_ref(const char *path,
 
 /*
  * This interprets names like ':/Initial revision of "git"' by searching
- * through history and returning the first commit whose message starts
- * with the given string.
+ * through history and returning the first commit whose message matches
+ * the given regular expression.
  *
  * For future extension, ':/!' is reserved. If you want to match a message
  * beginning with a '!', you have to repeat the exclamation mark.
@@ -692,12 +692,17 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1)
        struct commit_list *list = NULL, *backup = NULL, *l;
        int retval = -1;
        char *temp_commit_buffer = NULL;
+       regex_t regex;
 
        if (prefix[0] == '!') {
                if (prefix[1] != '!')
                        die ("Invalid search pattern: %s", prefix);
                prefix++;
        }
+
+       if (regcomp(&regex, prefix, REG_EXTENDED))
+               die("Invalid search pattern: %s", prefix);
+
        for_each_ref(handle_one_ref, &list);
        for (l = list; l; l = l->next)
                commit_list_insert(l->item, &backup);
@@ -721,12 +726,13 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1)
                }
                if (!(p = strstr(p, "\n\n")))
                        continue;
-               if (!prefixcmp(p + 2, prefix)) {
+               if (!regexec(&regex, p + 2, 0, NULL, 0)) {
                        hashcpy(sha1, commit->object.sha1);
                        retval = 0;
                        break;
                }
        }
+       regfree(&regex);
        free(temp_commit_buffer);
        free_commit_list(list);
        for (l = backup; l; l = l->next)
@@ -933,8 +939,8 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
  */
 int get_sha1(const char *name, unsigned char *sha1)
 {
-       unsigned unused;
-       return get_sha1_with_mode(name, sha1, &unused);
+       struct object_context unused;
+       return get_sha1_with_context(name, sha1, &unused);
 }
 
 /* Must be called only when object_name:filename doesn't exist. */
@@ -1031,12 +1037,24 @@ static void diagnose_invalid_index_path(int stage,
 
 
 int get_sha1_with_mode_1(const char *name, unsigned char *sha1, unsigned *mode, int gently, const char *prefix)
+{
+       struct object_context oc;
+       int ret;
+       ret = get_sha1_with_context_1(name, sha1, &oc, gently, prefix);
+       *mode = oc.mode;
+       return ret;
+}
+
+int get_sha1_with_context_1(const char *name, unsigned char *sha1,
+                           struct object_context *oc,
+                           int gently, const char *prefix)
 {
        int ret, bracket_depth;
        int namelen = strlen(name);
        const char *cp;
 
-       *mode = S_IFINVALID;
+       memset(oc, 0, sizeof(*oc));
+       oc->mode = S_IFINVALID;
        ret = get_sha1_1(name, namelen, sha1);
        if (!ret)
                return ret;
@@ -1059,6 +1077,11 @@ int get_sha1_with_mode_1(const char *name, unsigned char *sha1, unsigned *mode,
                        cp = name + 3;
                }
                namelen = namelen - (cp - name);
+
+               strncpy(oc->path, cp,
+                       sizeof(oc->path));
+               oc->path[sizeof(oc->path)-1] = '\0';
+
                if (!active_cache)
                        read_cache();
                pos = cache_name_pos(cp, namelen);
@@ -1071,7 +1094,6 @@ int get_sha1_with_mode_1(const char *name, unsigned char *sha1, unsigned *mode,
                                break;
                        if (ce_stage(ce) == stage) {
                                hashcpy(sha1, ce->sha1);
-                               *mode = ce->ce_mode;
                                return 0;
                        }
                        pos++;
@@ -1098,12 +1120,17 @@ int get_sha1_with_mode_1(const char *name, unsigned char *sha1, unsigned *mode,
                }
                if (!get_sha1_1(name, cp-name, tree_sha1)) {
                        const char *filename = cp+1;
-                       ret = get_tree_entry(tree_sha1, filename, sha1, mode);
+                       ret = get_tree_entry(tree_sha1, filename, sha1, &oc->mode);
                        if (!gently) {
                                diagnose_invalid_sha1_path(prefix, filename,
                                                           tree_sha1, object_name);
                                free(object_name);
                        }
+                       hashcpy(oc->tree, tree_sha1);
+                       strncpy(oc->path, filename,
+                               sizeof(oc->path));
+                       oc->path[sizeof(oc->path)-1] = '\0';
+
                        return ret;
                } else {
                        if (!gently)
index 676d48fb33119f393befcaf8998ad38741366525..61cb6e21ddfc789ce59597c96204e7904cd9359e 100644 (file)
@@ -46,6 +46,19 @@ done:
        return ret;
 }
 
+void handle_ignore_submodules_arg(struct diff_options *diffopt,
+                                 const char *arg)
+{
+       if (!strcmp(arg, "all"))
+               DIFF_OPT_SET(diffopt, IGNORE_SUBMODULES);
+       else if (!strcmp(arg, "untracked"))
+               DIFF_OPT_SET(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);
+       else if (!strcmp(arg, "dirty"))
+               DIFF_OPT_SET(diffopt, IGNORE_DIRTY_SUBMODULES);
+       else
+               die("bad --ignore-submodules argument: %s", arg);
+}
+
 void show_submodule_summary(FILE *f, const char *path,
                unsigned char one[20], unsigned char two[20],
                unsigned dirty_submodule,
index dbda270873171c41f20c0f07b70773ce67c6a303..6fd3bb40702e5fb905eb4ae519d487e3c9f40073 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef SUBMODULE_H
 #define SUBMODULE_H
 
+struct diff_options;
+
+void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
 void show_submodule_summary(FILE *f, const char *path,
                unsigned char one[20], unsigned char two[20],
                unsigned dirty_submodule,
index 25c559bb49d04586c69242cd7ef03713f0939e9d..f9de24b4d2baa9fad1d6caa72fea651da78d6878 100644 (file)
@@ -3,6 +3,7 @@
 # Copyright (c) 2005 Junio C Hamano
 #
 
+-include ../config.mak.autogen
 -include ../config.mak
 
 #GIT_TEST_OPTS=--verbose --debug
@@ -35,7 +36,9 @@ aggregate-results-and-cleanup: $(T)
        $(MAKE) clean
 
 aggregate-results:
-       '$(SHELL_PATH_SQ)' ./aggregate-results.sh test-results/t*-*
+       for f in test-results/t*-*; do \
+               echo "$$f"; \
+       done | '$(SHELL_PATH_SQ)' ./aggregate-results.sh
 
 # we can test NO_OPTIMIZE_COMMITS independently of LC_ALL
 full-svn-test:
index dcd3ebb5f2dcdbf15ca0e4a043b45cd2fc36cbb5..b906ceb4766a283ae6b22bd037f9e1619feb12d1 100644 (file)
--- a/t/README
+++ b/t/README
@@ -18,25 +18,48 @@ The easiest way to run tests is to say "make".  This runs all
 the tests.
 
     *** t0000-basic.sh ***
-    *   ok 1: .git/objects should be empty after git-init in an empty repo.
-    *   ok 2: .git/objects should have 256 subdirectories.
-    *   ok 3: git-update-index without --add should fail adding.
+    ok 1 - .git/objects should be empty after git init in an empty repo.
+    ok 2 - .git/objects should have 3 subdirectories.
+    ok 3 - success is reported like this
     ...
-    *   ok 23: no diff after checkout and git-update-index --refresh.
-    * passed all 23 test(s)
-    *** t0100-environment-names.sh ***
-    *   ok 1: using old names should issue warnings.
-    *   ok 2: using old names but having new names should not issue warnings.
-    ...
-
-Or you can run each test individually from command line, like
-this:
-
-    $ sh ./t3001-ls-files-killed.sh
-    *   ok 1: git-update-index --add to add various paths.
-    *   ok 2: git-ls-files -k to show killed files.
-    *   ok 3: validate git-ls-files -k output.
-    * passed all 3 test(s)
+    ok 43 - very long name in the index handled sanely
+    # fixed 1 known breakage(s)
+    # still have 1 known breakage(s)
+    # passed all remaining 42 test(s)
+    1..43
+    *** t0001-init.sh ***
+    ok 1 - plain
+    ok 2 - plain with GIT_WORK_TREE
+    ok 3 - plain bare
+
+Since the tests all output TAP (see http://testanything.org) they can
+be run with any TAP harness. Here's an example of parallel testing
+powered by a recent version of prove(1):
+
+    $ prove --timer --jobs 15 ./t[0-9]*.sh
+    [19:17:33] ./t0005-signals.sh ................................... ok       36 ms
+    [19:17:33] ./t0022-crlf-rename.sh ............................... ok       69 ms
+    [19:17:33] ./t0024-crlf-archive.sh .............................. ok      154 ms
+    [19:17:33] ./t0004-unwritable.sh ................................ ok      289 ms
+    [19:17:33] ./t0002-gitfile.sh ................................... ok      480 ms
+    ===(     102;0  25/?  6/?  5/?  16/?  1/?  4/?  2/?  1/?  3/?  1... )===
+
+prove and other harnesses come with a lot of useful options. The
+--state option in particular is very useful:
+
+    # Repeat until no more failures
+    $ prove -j 15 --state=failed,save ./t[0-9]*.sh
+
+You can also run each test individually from command line, like this:
+
+    $ sh ./t3010-ls-files-killed-modified.sh
+    ok 1 - git update-index --add to add various paths.
+    ok 2 - git ls-files -k to show killed files.
+    ok 3 - validate git ls-files -k output.
+    ok 4 - git ls-files -m to show modified files.
+    ok 5 - validate git ls-files -m output.
+    # passed all 5 test(s)
+    1..5
 
 You can pass --verbose (or -v), --debug (or -d), and --immediate
 (or -i) command line argument to the test, or by setting GIT_TEST_OPTS
@@ -84,6 +107,12 @@ appropriately before running "make".
        implied by other options like --valgrind and
        GIT_TEST_INSTALLED.
 
+--root=<directory>::
+       Create "trash" directories used to store all temporary data during
+       testing under <directory>, instead of the t/ directory.
+       Using this option with a RAM-based filesystem (such as tmpfs)
+       can massively speed up the test suite.
+
 You can also set the GIT_TEST_INSTALLED environment variable to
 the bindir of an existing git installation to test that installation.
 You still need to have built this git sandbox, from which various
@@ -192,15 +221,101 @@ This test harness library does the following things:
  - If the script is invoked with command line argument --help
    (or -h), it shows the test_description and exits.
 
- - Creates an empty test directory with an empty .git/objects
-   database and chdir(2) into it.  This directory is 't/trash directory'
-   if you must know, but I do not think you care.
+ - Creates an empty test directory with an empty .git/objects database
+   and chdir(2) into it.  This directory is 't/trash
+   directory.$test_name_without_dotsh', with t/ subject to change by
+   the --root option documented above.
 
  - Defines standard test helper functions for your scripts to
    use.  These functions are designed to make all scripts behave
    consistently when command line arguments --verbose (or -v),
    --debug (or -d), and --immediate (or -i) is given.
 
+Do's, don'ts & things to keep in mind
+-------------------------------------
+
+Here are a few examples of things you probably should and shouldn't do
+when writing tests.
+
+Do:
+
+ - Put all code inside test_expect_success and other assertions.
+
+   Even code that isn't a test per se, but merely some setup code
+   should be inside a test assertion.
+
+ - Chain your test assertions
+
+   Write test code like this:
+
+       git merge foo &&
+       git push bar &&
+       test ...
+
+   Instead of:
+
+       git merge hla
+       git push gh
+       test ...
+
+   That way all of the commands in your tests will succeed or fail. If
+   you must ignore the return value of something (e.g. the return
+   value of export is unportable) it's best to indicate so explicitly
+   with a semicolon:
+
+       export HLAGH;
+       git merge hla &&
+       git push gh &&
+       test ...
+
+Don't:
+
+ - exit() within a <script> part.
+
+   The harness will catch this as a programming error of the test.
+   Use test_done instead if you need to stop the tests early (see
+   "Skipping tests" below).
+
+ - Break the TAP output
+
+   The raw output from your test may be interpreted by a TAP harness. TAP
+   harnesses will ignore everything they don't know about, but don't step
+   on their toes in these areas:
+
+   - Don't print lines like "$x..$y" where $x and $y are integers.
+
+   - Don't print lines that begin with "ok" or "not ok".
+
+   TAP harnesses expect a line that begins with either "ok" and "not
+   ok" to signal a test passed or failed (and our harness already
+   produces such lines), so your script shouldn't emit such lines to
+   their output.
+
+   You can glean some further possible issues from the TAP grammar
+   (see http://search.cpan.org/perldoc?TAP::Parser::Grammar#TAP_Grammar)
+   but the best indication is to just run the tests with prove(1),
+   it'll complain if anything is amiss.
+
+Keep in mind:
+
+ - Inside <script> part, the standard output and standard error
+   streams are discarded, and the test harness only reports "ok" or
+   "not ok" to the end user running the tests. Under --verbose, they
+   are shown to help debugging the tests.
+
+
+Skipping tests
+--------------
+
+If you need to skip all the remaining tests you should set skip_all
+and immediately call test_done. The string you give to skip_all will
+be used as an explanation for why the test was skipped. for instance:
+
+       if ! test_have_prereq PERL
+       then
+           skip_all='skipping perl interface tests, perl not available'
+           test_done
+       fi
 
 End with test_done
 ------------------
@@ -216,9 +331,9 @@ Test harness library
 There are a handful helper functions defined in the test harness
 library for your script to use.
 
- - test_expect_success <message> <script>
+ - test_expect_success [<prereq>] <message> <script>
 
-   This takes two strings as parameter, and evaluates the
+   Usually takes two strings as parameter, and evaluates the
    <script>.  If it yields success, test is considered
    successful.  <message> should state what it is testing.
 
@@ -228,7 +343,14 @@ library for your script to use.
            'git-write-tree should be able to write an empty tree.' \
            'tree=$(git-write-tree)'
 
- - test_expect_failure <message> <script>
+   If you supply three parameters the first will be taken to be a
+   prerequisite, see the test_set_prereq and test_have_prereq
+   documentation below:
+
+       test_expect_success TTY 'git --paginate rev-list uses a pager' \
+           ' ... '
+
+ - test_expect_failure [<prereq>] <message> <script>
 
    This is NOT the opposite of test_expect_success, but is used
    to mark a test that demonstrates a known breakage.  Unlike
@@ -237,6 +359,16 @@ library for your script to use.
    success and "still broken" on failure.  Failures from these
    tests won't cause -i (immediate) to stop.
 
+   Like test_expect_success this function can optionally use a three
+   argument invocation with a prerequisite as the first argument.
+
+ - test_expect_code [<prereq>] <code> <message> <script>
+
+   Analogous to test_expect_success, but pass the test if it exits
+   with a given exit <code>
+
+ test_expect_code 1 'Merge with d/f conflicts' 'git merge "merge msg" B master'
+
  - test_debug <script>
 
    This takes a single argument, <script>, and evaluates it only
@@ -269,6 +401,85 @@ library for your script to use.
    Merges the given rev using the given message.  Like test_commit,
    creates a tag and calls test_tick before committing.
 
+ - test_set_prereq SOME_PREREQ
+
+   Set a test prerequisite to be used later with test_have_prereq. The
+   test-lib will set some prerequisites for you, e.g. PERL and PYTHON
+   which are derived from ./GIT-BUILD-OPTIONS (grep test_set_prereq
+   test-lib.sh for more). Others you can set yourself and use later
+   with either test_have_prereq directly, or the three argument
+   invocation of test_expect_success and test_expect_failure.
+
+ - test_have_prereq SOME PREREQ
+
+   Check if we have a prerequisite previously set with
+   test_set_prereq. The most common use of this directly is to skip
+   all the tests if we don't have some essential prerequisite:
+
+       if ! test_have_prereq PERL
+       then
+           skip_all='skipping perl interface tests, perl not available'
+           test_done
+       fi
+
+ - test_external [<prereq>] <message> <external> <script>
+
+   Execute a <script> with an <external> interpreter (like perl). This
+   was added for tests like t9700-perl-git.sh which do most of their
+   work in an external test script.
+
+       test_external \
+           'GitwebCache::*FileCache*' \
+           "$PERL_PATH" "$TEST_DIRECTORY"/t9503/test_cache_interface.pl
+
+   If the test is outputting its own TAP you should set the
+   test_external_has_tap variable somewhere before calling the first
+   test_external* function. See t9700-perl-git.sh for an example.
+
+       # The external test will outputs its own plan
+       test_external_has_tap=1
+
+ - test_external_without_stderr [<prereq>] <message> <external> <script>
+
+   Like test_external but fail if there's any output on stderr,
+   instead of checking the exit code.
+
+       test_external_without_stderr \
+           'Perl API' \
+           "$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl
+
+ - test_must_fail <git-command>
+
+   Run a git command and ensure it fails in a controlled way.  Use
+   this instead of "! <git-command>" to fail when git commands
+   segfault.
+
+ - test_might_fail <git-command>
+
+   Similar to test_must_fail, but tolerate success, too.  Use this
+   instead of "<git-command> || :" to catch failures due to segv.
+
+ - test_cmp <expected> <actual>
+
+   Check whether the content of the <actual> file matches the
+   <expected> file.  This behaves like "cmp" but produces more
+   helpful output when the test is run with "-v" option.
+
+ - test_when_finished <script>
+
+   Prepend <script> to a list of commands to run to clean up
+   at the end of the current test.  If some clean-up command
+   fails, the test will not pass.
+
+   Example:
+
+       test_expect_success 'branch pointing to non-commit' '
+               git rev-parse HEAD^{tree} >.git/refs/heads/invalid &&
+               test_when_finished "git update-ref -d refs/heads/invalid" &&
+               ...
+       '
+
+
 Tips for Writing Tests
 ----------------------
 
index d5bab75d7da49ebb53e368d67f6b867f5417a125..d206b7c4cfa4f7d61d151cebc35a0f296fbe4c6b 100755 (executable)
@@ -6,7 +6,7 @@ failed=0
 broken=0
 total=0
 
-for file
+while read file
 do
        while read type value
        do
index 5a734b1b7b2df4a5c5c35f5347c618f3735317ac..81ef2a0969d98f05ce22cd8a06fcb55a7af9aee8 100644 (file)
@@ -19,9 +19,9 @@ our \$site_name = '[localhost]';
 our \$site_header = '';
 our \$site_footer = '';
 our \$home_text = 'indextext.html';
-our @stylesheets = ('file:///$TEST_DIRECTORY/../gitweb/gitweb.css');
-our \$logo = 'file:///$TEST_DIRECTORY/../gitweb/git-logo.png';
-our \$favicon = 'file:///$TEST_DIRECTORY/../gitweb/git-favicon.png';
+our @stylesheets = ('file:///$TEST_DIRECTORY/../gitweb/static/gitweb.css');
+our \$logo = 'file:///$TEST_DIRECTORY/../gitweb/static/git-logo.png';
+our \$favicon = 'file:///$TEST_DIRECTORY/../gitweb/static/git-favicon.png';
 our \$projects_list = '';
 our \$export_ok = '';
 our \$strict_export = '';
@@ -76,12 +76,12 @@ gitweb_run () {
 . ./test-lib.sh
 
 if ! test_have_prereq PERL; then
-       say 'skipping gitweb tests, perl not available'
+       skip_all='skipping gitweb tests, perl not available'
        test_done
 fi
 
 perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
-    say 'skipping gitweb tests, perl version is too old'
+    skip_all='skipping gitweb tests, perl version is too old'
     test_done
 }
 
index 4b3b793730604e5b513c5017f39f4560b3083338..648d1619c86bb676faadf62bd831683cb46d6be2 100644 (file)
@@ -9,7 +9,7 @@ export HOME
 
 if ! type cvs >/dev/null 2>&1
 then
-       say 'skipping cvsimport tests, cvs not found'
+       skip_all='skipping cvsimport tests, cvs not found'
        test_done
 fi
 
@@ -21,11 +21,11 @@ case "$cvsps_version" in
 2.1 | 2.2*)
        ;;
 '')
-       say 'skipping cvsimport tests, cvsps not found'
+       skip_all='skipping cvsimport tests, cvsps not found'
        test_done
        ;;
 *)
-       say 'skipping cvsimport tests, unsupported cvsps version'
+       skip_all='skipping cvsimport tests, unsupported cvsps version'
        test_done
        ;;
 esac
index 0f7f35ccc9e1315d3ac8e5d37df51c106847d920..c3f6676ca2c4a37cbe1cf2779e97a678c1345559 100644 (file)
@@ -5,11 +5,11 @@ git_svn_id=git""-svn-id
 
 if test -n "$NO_SVN_TESTS"
 then
-       say 'skipping git svn tests, NO_SVN_TESTS defined'
+       skip_all='skipping git svn tests, NO_SVN_TESTS defined'
        test_done
 fi
 if ! test_have_prereq PERL; then
-       say 'skipping git svn tests, perl not available'
+       skip_all='skipping git svn tests, perl not available'
        test_done
 fi
 
@@ -21,7 +21,7 @@ PERL=${PERL:-perl}
 svn >/dev/null 2>&1
 if test $? -ne 1
 then
-    say 'skipping git svn tests, svn not found'
+    skip_all='skipping git svn tests, svn not found'
     test_done
 fi
 
@@ -40,13 +40,12 @@ x=$?
 if test $x -ne 0
 then
        if test $x -eq 42; then
-               err='Perl SVN libraries must be >= 1.1.0'
+               skip_all='Perl SVN libraries must be >= 1.1.0'
        elif test $x -eq 41; then
-               err='svnadmin failed to create fsfs repository'
+               skip_all='svnadmin failed to create fsfs repository'
        else
-               err='Perl SVN libraries not found or unusable, skipping test'
+               skip_all='Perl SVN libraries not found or unusable'
        fi
-       say "$err"
        test_done
 fi
 
@@ -159,7 +158,7 @@ EOF
 require_svnserve () {
     if test -z "$SVNSERVE_PORT"
     then
-        say 'skipping svnserve test. (set $SVNSERVE_PORT to enable)'
+       skip_all='skipping svnserve test. (set $SVNSERVE_PORT to enable)'
         test_done
     fi
 }
index da4b8d5a6fbf18adac103a5a6dd26ea3498c178f..71effc5becd09d1289361767f6f54af8f1594627 100644 (file)
@@ -5,8 +5,7 @@
 
 if test -z "$GIT_TEST_HTTPD"
 then
-       say "skipping test, network testing disabled by default"
-       say "(define GIT_TEST_HTTPD to enable)"
+       skip_all="Network testing disabled (define GIT_TEST_HTTPD to enable)"
        test_done
 fi
 
@@ -46,7 +45,7 @@ HTTPD_DOCUMENT_ROOT_PATH=$HTTPD_ROOT_PATH/www
 
 if ! test -x "$LIB_HTTPD_PATH"
 then
-       say "skipping test, no web server found at '$LIB_HTTPD_PATH'"
+       skip_all="skipping test, no web server found at '$LIB_HTTPD_PATH'"
        test_done
 fi
 
@@ -59,12 +58,12 @@ then
        then
                if ! test $HTTPD_VERSION -ge 2
                then
-                       say "skipping test, at least Apache version 2 is required"
+                       skip_all="skipping test, at least Apache version 2 is required"
                        test_done
                fi
                if ! test -d "$DEFAULT_HTTPD_MODULE_PATH"
                then
-                       say "Apache module directory not found.  Skipping tests."
+                       skip_all="Apache module directory not found.  Skipping tests."
                        test_done
                fi
 
@@ -119,7 +118,7 @@ start_httpd() {
                >&3 2>&4
        if test $? -ne 0
        then
-               say "skipping test, web server setup failed"
+               skip_all="skipping test, web server setup failed"
                trap 'die' EXIT
                test_done
        fi
index ce36f34d0337d29f6ec8f274cd99ad201bd3965d..375e2486511656df4294f0a4b750fd8d3f16d273 100644 (file)
@@ -3,7 +3,7 @@
 . ./test-lib.sh
 
 if ! test_have_prereq PERL; then
-       say 'skipping --patch tests, perl not available'
+       skip_all='skipping --patch tests, perl not available'
        test_done
 fi
 
similarity index 98%
rename from t/t6000lib.sh
rename to t/lib-t6000.sh
index 985d517a1ce4cf2f80eed3d54c25b5fc912d5c6b..ea25dd89e505525507c16c62d91fb07c092b064a 100644 (file)
@@ -91,7 +91,7 @@ check_output()
        shift 1
        if eval "$*" | entag > $_name.actual
        then
-               diff $_name.expected $_name.actual
+               test_cmp $_name.expected $_name.actual
        else
                return 1;
        fi
index 3ec9cbef2c88f65e5fb254d10cc551c6c4062c88..f2c73369a5b93544ee837229da965d7efbdc45bf 100755 (executable)
@@ -301,7 +301,7 @@ $expectfilter >expected <<\EOF
 EOF
 test_expect_success \
     'validate git diff-files output for a know cache/work tree state.' \
-    'git diff-files >current && diff >/dev/null -b current expected'
+    'git diff-files >current && test_cmp current expected >/dev/null'
 
 test_expect_success \
     'git update-index --refresh should succeed.' \
index 09f855af3e9cded903c828f3f946a0c2403ddcdf..93e58c00e886db22b5ebf86af103efc4e65ec832 100755 (executable)
@@ -13,6 +13,7 @@ test_expect_success 'sigchain works' '
        test-sigchain >actual
        case "$?" in
        143) true ;; # POSIX w/ SIGTERM=15
+       271) true ;; # ksh w/ SIGTERM=15
          3) true ;; # Windows
          *) false ;;
        esac &&
index 75b02af86d4d613fac91b3cec28044e3b7f6274e..1d4d0a5c7d2549c67334a8d5dd3f462962db81f2 100755 (executable)
@@ -28,8 +28,8 @@ check_show 31449600 '12 months ago'
 
 check_parse() {
        echo "$1 -> $2" >expect
-       test_expect_${3:-success} "parse date ($1)" "
-       test-date parse '$1' >actual &&
+       test_expect_${4:-success} "parse date ($1${3:+ TZ=$3})" "
+       TZ=${3:-$TZ} test-date parse '$1' >actual &&
        test_cmp expect actual
        "
 }
@@ -38,6 +38,8 @@ check_parse 2008 bad
 check_parse 2008-02 bad
 check_parse 2008-02-14 bad
 check_parse '2008-02-14 20:30:45' '2008-02-14 20:30:45 +0000'
+check_parse '2008-02-14 20:30:45 -0500' '2008-02-14 20:30:45 -0500'
+check_parse '2008-02-14 20:30:45' '2008-02-14 20:30:45 -0500' EST5
 
 check_approxidate() {
        echo "$1 -> $2 +0000" >expect
index c3e7e322a8d62b988999b166d2abcf08930adbf7..234a94f3e6311c529b5bb476ee5a6a2ea705017f 100755 (executable)
@@ -453,5 +453,57 @@ test_expect_success 'invalid .gitattributes (must not crash)' '
        git diff
 
 '
+# Some more tests here to add new autocrlf functionality.
+# We want to have a known state here, so start a bit from scratch
+
+test_expect_success 'setting up for new autocrlf tests' '
+       git config core.autocrlf false &&
+       git config core.safecrlf false &&
+       rm -rf .????* * &&
+       for w in I am all LF; do echo $w; done >alllf &&
+       for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >mixed &&
+       for w in I am all CRLF; do echo $w; done | append_cr >allcrlf &&
+       git add -A . &&
+       git commit -m "alllf, allcrlf and mixed only" &&
+       git tag -a -m "message" autocrlf-checkpoint
+'
+
+test_expect_success 'report no change after setting autocrlf' '
+       git config core.autocrlf true &&
+       touch * &&
+       git diff --exit-code
+'
+
+test_expect_success 'files are clean after checkout' '
+       rm * &&
+       git checkout -f &&
+       git diff --exit-code
+'
+
+cr_to_Q_no_NL () {
+    tr '\015' Q | tr -d '\012'
+}
+
+test_expect_success 'LF only file gets CRLF with autocrlf' '
+       test "$(cr_to_Q_no_NL < alllf)" = "IQamQallQLFQ"
+'
+
+test_expect_success 'Mixed file is still mixed with autocrlf' '
+       test "$(cr_to_Q_no_NL < mixed)" = "OhhereisCRLFQintext"
+'
+
+test_expect_success 'CRLF only file has CRLF with autocrlf' '
+       test "$(cr_to_Q_no_NL < allcrlf)" = "IQamQallQCRLFQ"
+'
+
+test_expect_success 'New CRLF file gets LF in repo' '
+       tr -d "\015" < alllf | append_cr > alllf2 &&
+       git add alllf2 &&
+       git commit -m "alllf2 added" &&
+       git config core.autocrlf false &&
+       rm * &&
+       git checkout -f &&
+       test_cmp alllf alllf2
+'
 
 test_done
index 6cb8d60ea2649495c0e3c8bbb8b7cc75c36799b7..828e35baf72d94908ad1f30dbd2e1aa6f9376e69 100755 (executable)
@@ -65,17 +65,21 @@ test_expect_success expanded_in_repo '
                echo "\$Id:NoSpaceAtFront \$"
                echo "\$Id:NoSpaceAtEitherEnd\$"
                echo "\$Id: NoTerminatingSymbol"
+               echo "\$Id: Foreign Commit With Spaces \$"
+               echo "\$Id: NoTerminatingSymbolAtEOF"
        } > expanded-keywords &&
 
        {
                echo "File with expanded keywords"
-               echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
-               echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
-               echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
-               echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
-               echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
-               echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
+               echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
+               echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
+               echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
+               echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
+               echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
+               echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
                echo "\$Id: NoTerminatingSymbol"
+               echo "\$Id: Foreign Commit With Spaces \$"
+               echo "\$Id: NoTerminatingSymbolAtEOF"
        } > expected-output &&
 
        git add expanded-keywords &&
diff --git a/t/t0025-crlf-auto.sh b/t/t0025-crlf-auto.sh
new file mode 100755 (executable)
index 0000000..f5f67a6
--- /dev/null
@@ -0,0 +1,155 @@
+#!/bin/sh
+
+test_description='CRLF conversion'
+
+. ./test-lib.sh
+
+has_cr() {
+       tr '\015' Q <"$1" | grep Q >/dev/null
+}
+
+test_expect_success setup '
+
+       git config core.autocrlf false &&
+
+       for w in Hello world how are you; do echo $w; done >one &&
+       for w in I am very very fine thank you; do echo ${w}Q; done | q_to_cr >two &&
+       for w in Oh here is a QNUL byte how alarming; do echo ${w}; done | q_to_nul >three &&
+       git add . &&
+
+       git commit -m initial &&
+
+       one=`git rev-parse HEAD:one` &&
+       two=`git rev-parse HEAD:two` &&
+       three=`git rev-parse HEAD:three` &&
+
+       echo happy.
+'
+
+test_expect_success 'default settings cause no changes' '
+
+       rm -f .gitattributes tmp one two three &&
+       git read-tree --reset -u HEAD &&
+
+       ! has_cr one &&
+       has_cr two &&
+       onediff=`git diff one` &&
+       twodiff=`git diff two` &&
+       threediff=`git diff three` &&
+       test -z "$onediff" -a -z "$twodiff" -a -z "$threediff"
+'
+
+test_expect_success 'crlf=true causes a CRLF file to be normalized' '
+
+       # Backwards compatibility check
+       rm -f .gitattributes tmp one two three &&
+       echo "two crlf" > .gitattributes &&
+       git read-tree --reset -u HEAD &&
+
+       # Note, "normalized" means that git will normalize it if added
+       has_cr two &&
+       twodiff=`git diff two` &&
+       test -n "$twodiff"
+'
+
+test_expect_success 'text=true causes a CRLF file to be normalized' '
+
+       rm -f .gitattributes tmp one two three &&
+       echo "two text" > .gitattributes &&
+       git read-tree --reset -u HEAD &&
+
+       # Note, "normalized" means that git will normalize it if added
+       has_cr two &&
+       twodiff=`git diff two` &&
+       test -n "$twodiff"
+'
+
+test_expect_success 'eol=crlf gives a normalized file CRLFs with autocrlf=false' '
+
+       rm -f .gitattributes tmp one two three &&
+       git config core.autocrlf false &&
+       echo "one eol=crlf" > .gitattributes &&
+       git read-tree --reset -u HEAD &&
+
+       has_cr one &&
+       onediff=`git diff one` &&
+       test -z "$onediff"
+'
+
+test_expect_success 'eol=crlf gives a normalized file CRLFs with autocrlf=input' '
+
+       rm -f .gitattributes tmp one two three &&
+       git config core.autocrlf input &&
+       echo "one eol=crlf" > .gitattributes &&
+       git read-tree --reset -u HEAD &&
+
+       has_cr one &&
+       onediff=`git diff one` &&
+       test -z "$onediff"
+'
+
+test_expect_success 'eol=lf gives a normalized file LFs with autocrlf=true' '
+
+       rm -f .gitattributes tmp one two three &&
+       git config core.autocrlf true &&
+       echo "one eol=lf" > .gitattributes &&
+       git read-tree --reset -u HEAD &&
+
+       ! has_cr one &&
+       onediff=`git diff one` &&
+       test -z "$onediff"
+'
+
+test_expect_success 'autocrlf=true does not normalize CRLF files' '
+
+       rm -f .gitattributes tmp one two three &&
+       git config core.autocrlf true &&
+       git read-tree --reset -u HEAD &&
+
+       has_cr one &&
+       has_cr two &&
+       onediff=`git diff one` &&
+       twodiff=`git diff two` &&
+       threediff=`git diff three` &&
+       test -z "$onediff" -a -z "$twodiff" -a -z "$threediff"
+'
+
+test_expect_success 'text=auto, autocrlf=true _does_ normalize CRLF files' '
+
+       rm -f .gitattributes tmp one two three &&
+       git config core.autocrlf true &&
+       echo "* text=auto" > .gitattributes &&
+       git read-tree --reset -u HEAD &&
+
+       has_cr one &&
+       has_cr two &&
+       onediff=`git diff one` &&
+       twodiff=`git diff two` &&
+       threediff=`git diff three` &&
+       test -z "$onediff" -a -n "$twodiff" -a -z "$threediff"
+'
+
+test_expect_success 'text=auto, autocrlf=true does not normalize binary files' '
+
+       rm -f .gitattributes tmp one two three &&
+       git config core.autocrlf true &&
+       echo "* text=auto" > .gitattributes &&
+       git read-tree --reset -u HEAD &&
+
+       ! has_cr three &&
+       threediff=`git diff three` &&
+       test -z "$threediff"
+'
+
+test_expect_success 'eol=crlf _does_ normalize binary files' '
+
+       rm -f .gitattributes tmp one two three &&
+       echo "three eol=crlf" > .gitattributes &&
+       git read-tree --reset -u HEAD &&
+
+       has_cr three &&
+       threediff=`git diff three` &&
+       test -z "$threediff"
+'
+
+test_done
diff --git a/t/t0026-eol-config.sh b/t/t0026-eol-config.sh
new file mode 100755 (executable)
index 0000000..f37ac8f
--- /dev/null
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+test_description='CRLF conversion'
+
+. ./test-lib.sh
+
+has_cr() {
+       tr '\015' Q <"$1" | grep Q >/dev/null
+}
+
+test_expect_success setup '
+
+       git config core.autocrlf false &&
+
+       echo "one text" > .gitattributes
+
+       for w in Hello world how are you; do echo $w; done >one &&
+       for w in I am very very fine thank you; do echo $w; done >two &&
+       git add . &&
+
+       git commit -m initial &&
+
+       one=`git rev-parse HEAD:one` &&
+       two=`git rev-parse HEAD:two` &&
+
+       echo happy.
+'
+
+test_expect_success 'eol=lf puts LFs in normalized file' '
+
+       rm -f .gitattributes tmp one two &&
+       git config core.eol lf &&
+       git read-tree --reset -u HEAD &&
+
+       ! has_cr one &&
+       ! has_cr two &&
+       onediff=`git diff one` &&
+       twodiff=`git diff two` &&
+       test -z "$onediff" -a -z "$twodiff"
+'
+
+test_expect_success 'eol=crlf puts CRLFs in normalized file' '
+
+       rm -f .gitattributes tmp one two &&
+       git config core.eol crlf &&
+       git read-tree --reset -u HEAD &&
+
+       has_cr one &&
+       ! has_cr two &&
+       onediff=`git diff one` &&
+       twodiff=`git diff two` &&
+       test -z "$onediff" -a -z "$twodiff"
+'
+
+test_expect_success 'autocrlf=true overrides eol=lf' '
+
+       rm -f .gitattributes tmp one two &&
+       git config core.eol lf &&
+       git config core.autocrlf true &&
+       git read-tree --reset -u HEAD &&
+
+       has_cr one &&
+       has_cr two &&
+       onediff=`git diff one` &&
+       twodiff=`git diff two` &&
+       test -z "$onediff" -a -z "$twodiff"
+'
+
+test_expect_success 'autocrlf=true overrides unset eol' '
+
+       rm -f .gitattributes tmp one two &&
+       git config --unset-all core.eol &&
+       git config core.autocrlf true &&
+       git read-tree --reset -u HEAD &&
+
+       has_cr one &&
+       has_cr two &&
+       onediff=`git diff one` &&
+       twodiff=`git diff two` &&
+       test -z "$onediff" -a -z "$twodiff"
+'
+
+test_done
index 3d450ed379fcd1bf480fc75feb0e6ddb8f05e5be..20924506af886c8d0ce28f3fcb2742214d80020f 100755 (executable)
@@ -7,7 +7,7 @@ test_description='our own option parser'
 
 . ./test-lib.sh
 
-cat > expect.err << EOF
+cat > expect << EOF
 usage: test-parse-options <options>
 
     -b, --boolean         get a boolean
@@ -46,10 +46,12 @@ EOF
 
 test_expect_success 'test help' '
        test_must_fail test-parse-options -h > output 2> output.err &&
-       test ! -s output &&
-       test_cmp expect.err output.err
+       test ! -s output.err &&
+       test_cmp expect output
 '
 
+mv expect expect.err
+
 cat > expect << EOF
 boolean: 2
 integer: 1729
index 6327d205cb89b00e77502031e3b56b4b895cc32d..0c562bb820cb747a8f0d0df1eabb39da0b9eea21 100755 (executable)
@@ -390,4 +390,20 @@ test_expect_success \
      git ls-files --stage | tee >treeMcheck.out &&
      test_cmp treeM.out treeMcheck.out'
 
+test_expect_success '-m references the correct modified tree' '
+       echo >file-a &&
+       echo >file-b &&
+       git add file-a file-b &&
+       git commit -a -m "test for correct modified tree"
+       git branch initial-mod &&
+       echo b >file-b &&
+       git commit -a -m "B" &&
+       echo a >file-a &&
+       git add file-a &&
+       git ls-tree $(git write-tree) file-a >expect &&
+       git read-tree -m HEAD initial-mod &&
+       git ls-tree $(git write-tree) file-a >actual &&
+       test_cmp expect actual
+'
+
 test_done
index 210e594f6f3c83cc1b0c423a0f692380ff57176b..56874996a6df278202c0bc476abec4bca3ce99c5 100755 (executable)
@@ -24,18 +24,18 @@ test_expect_success 'update-index and ls-files' '
        cd "$HERE" &&
        git update-index --add one &&
        case "`git ls-files`" in
-       one) echo ok one ;;
+       one) echo pass one ;;
        *) echo bad one; exit 1 ;;
        esac &&
        cd dir &&
        git update-index --add two &&
        case "`git ls-files`" in
-       two) echo ok two ;;
+       two) echo pass two ;;
        *) echo bad two; exit 1 ;;
        esac &&
        cd .. &&
        case "`git ls-files`" in
-       dir/two"$LF"one) echo ok both ;;
+       dir/two"$LF"one) echo pass both ;;
        *) echo bad; exit 1 ;;
        esac
 '
@@ -58,17 +58,17 @@ test_expect_success 'diff-files' '
        echo a >>one &&
        echo d >>dir/two &&
        case "`git diff-files --name-only`" in
-       dir/two"$LF"one) echo ok top ;;
+       dir/two"$LF"one) echo pass top ;;
        *) echo bad top; exit 1 ;;
        esac &&
        # diff should not omit leading paths
        cd dir &&
        case "`git diff-files --name-only`" in
-       dir/two"$LF"one) echo ok subdir ;;
+       dir/two"$LF"one) echo pass subdir ;;
        *) echo bad subdir; exit 1 ;;
        esac &&
        case "`git diff-files --name-only .`" in
-       dir/two) echo ok subdir limited ;;
+       dir/two) echo pass subdir limited ;;
        *) echo bad subdir limited; exit 1 ;;
        esac
 '
index 055ad00f778eda1de02a418bbc602e580acdaca1..97ab02aceb8d9448ca5d4b13b94a8e3d7221375a 100755 (executable)
@@ -15,9 +15,12 @@ umask 077
 # is a good candidate: exists on all unices, and it has permission
 # anyway, so we don't create a security hole running the testsuite.
 
-if ! setfacl -m u:root:rwx .; then
-    say "Skipping ACL tests: unable to use setfacl"
-    test_done
+setfacl_out="$(setfacl -m u:root:rwx . 2>&1)"
+setfacl_ret=$?
+
+if [ $setfacl_ret != 0 ]; then
+       skip_all="Skipping ACL tests: unable to use setfacl (output: '$setfacl_out'; return code: '$setfacl_ret')"
+       test_done
 fi
 
 check_perms_and_acl () {
index 22a80c8268b368963d58fd26fffde5cc8d084ee6..759cf12e16bcddc3dab9d6b3ad8abd5590245a94 100755 (executable)
@@ -5,7 +5,9 @@ test_description='git fsck random collection of tests'
 . ./test-lib.sh
 
 test_expect_success setup '
+       git config i18n.commitencoding ISO-8859-1 &&
        test_commit A fileA one &&
+       git config --unset i18n.commitencoding &&
        git checkout HEAD^0 &&
        test_commit B fileB two &&
        git tag -d A B &&
@@ -28,6 +30,12 @@ test_expect_success 'loose objects borrowed from alternate are not missing' '
        )
 '
 
+test_expect_success 'valid objects appear valid' '
+       { git fsck 2>out; true; } &&
+       ! grep error out &&
+       ! grep fatal out
+'
+
 # Corruption tests follow.  Make sure to remove all traces of the
 # specific corruption you test afterwards, lest a later test trip over
 # it.
index e5040580626f4df6159c929c1ad54f085f03d830..b3195c47070b35d555f8cfae90497a2d00d10ca7 100755 (executable)
@@ -3,7 +3,8 @@
 test_description='test git rev-parse --parseopt'
 . ./test-lib.sh
 
-cat > expect.err <<EOF
+cat > expect <<\END_EXPECT
+cat <<\EOF
 usage: some-command [options] <args>...
 
     some-command does foo and bar!
@@ -19,6 +20,7 @@ Extras
     --extra1              line above used to cause a segfault but no longer does
 
 EOF
+END_EXPECT
 
 cat > optionspec << EOF
 some-command [options] <args>...
@@ -38,8 +40,8 @@ extra1    line above used to cause a segfault but no longer does
 EOF
 
 test_expect_success 'test --parseopt help output' '
-       git rev-parse --parseopt -- -h 2> output.err < optionspec
-       test_cmp expect.err output.err
+       git rev-parse --parseopt -- -h > output < optionspec
+       test_cmp expect output
 '
 
 cat > expect <<EOF
@@ -79,4 +81,22 @@ test_expect_success 'test --parseopt --keep-dashdash' '
        test_cmp expect output
 '
 
+cat >expect <<EOF
+set -- --foo -- '--' 'arg' '--spam=ham'
+EOF
+
+test_expect_success 'test --parseopt --keep-dashdash --stop-at-non-option with --' '
+       git rev-parse --parseopt --keep-dashdash --stop-at-non-option -- --foo -- arg --spam=ham <optionspec >output &&
+       test_cmp expect output
+'
+
+cat > expect <<EOF
+set -- --foo -- 'arg' '--spam=ham'
+EOF
+
+test_expect_success 'test --parseopt --keep-dashdash --stop-at-non-option without --' '
+       git rev-parse --parseopt --keep-dashdash --stop-at-non-option -- --foo arg --spam=ham <optionspec >output &&
+       test_cmp expect output
+'
+
 test_done
index 5322a3bf9703fab9f6b199dcd3f861b8e27c3ed3..7f60fd0b2e8904ec231975df3d65e66c9363ff45 100755 (executable)
@@ -99,17 +99,17 @@ test_foobar_foobar() {
 }
 
 if ! test_have_prereq POSIXPERM || ! [ -w / ]; then
-       say "Dangerous test skipped. Read this test if you want to execute it"
+       skip_all="Dangerous test skipped. Read this test if you want to execute it"
        test_done
 fi
 
 if [ "$IKNOWWHATIAMDOING" != "YES" ]; then
-       say "You must set env var IKNOWWHATIAMDOING=YES in order to run this test"
+       skip_all="You must set env var IKNOWWHATIAMDOING=YES in order to run this test"
        test_done
 fi
 
 if [ "$UID" = 0 ]; then
-       say "No you can't run this with root"
+       skip_all="No you can't run this with root"
        test_done
 fi
 
index 20f33436d00077b64dcc855fc263cd5d0efcca38..05cc8fdd0168d33d0fe6f2ca54aa4162a0c6cdd0 100755 (executable)
@@ -8,7 +8,7 @@ test_description='git checkout to switch between branches with symlink<->dir'
 
 if ! test_have_prereq SYMLINKS
 then
-       say "symbolic links not supported - skipping tests"
+       skip_all="symbolic links not supported - skipping tests"
        test_done
 fi
 
@@ -44,8 +44,10 @@ test_expect_success 'switch from symlink to dir' '
 
 '
 
-rm -fr frotz xyzzy nitfol &&
-git checkout -f master || exit
+test_expect_success 'Remove temporary directories & switch to master' '
+       rm -fr frotz xyzzy nitfol &&
+       git checkout -f master
+'
 
 test_expect_success 'switch from dir to symlink' '
 
index a8297c61bd7402423eec6af1ba92f46cd13dd1bd..be88d4b5ee86b75eb0e5654404064f712192d0a9 100755 (executable)
@@ -49,6 +49,62 @@ test_expect_success '--orphan must be rejected with -b' '
        test refs/heads/master = "$(git symbolic-ref HEAD)"
 '
 
+test_expect_success '--orphan must be rejected with -t' '
+       git checkout master &&
+       test_must_fail git checkout --orphan new -t master &&
+       test refs/heads/master = "$(git symbolic-ref HEAD)"
+'
+
+test_expect_success '--orphan ignores branch.autosetupmerge' '
+       git checkout master &&
+       git config branch.autosetupmerge always &&
+       git checkout --orphan gamma &&
+       test -z "$(git config branch.gamma.merge)" &&
+       test refs/heads/gamma = "$(git symbolic-ref HEAD)" &&
+       test_must_fail git rev-parse --verify HEAD^
+'
+
+test_expect_success '--orphan makes reflog by default' '
+       git checkout master &&
+       git config --unset core.logAllRefUpdates &&
+       git checkout --orphan delta &&
+       ! test -f .git/logs/refs/heads/delta &&
+       test_must_fail PAGER= git reflog show delta &&
+       git commit -m Delta &&
+       test -f .git/logs/refs/heads/delta &&
+       PAGER= git reflog show delta
+'
+
+test_expect_success '--orphan does not make reflog when core.logAllRefUpdates = false' '
+       git checkout master &&
+       git config core.logAllRefUpdates false &&
+       git checkout --orphan epsilon &&
+       ! test -f .git/logs/refs/heads/epsilon &&
+       test_must_fail PAGER= git reflog show epsilon &&
+       git commit -m Epsilon &&
+       ! test -f .git/logs/refs/heads/epsilon &&
+       test_must_fail PAGER= git reflog show epsilon
+'
+
+test_expect_success '--orphan with -l makes reflog when core.logAllRefUpdates = false' '
+       git checkout master &&
+       git checkout -l --orphan zeta &&
+       test -f .git/logs/refs/heads/zeta &&
+       test_must_fail PAGER= git reflog show zeta &&
+       git commit -m Zeta &&
+       PAGER= git reflog show zeta
+'
+
+test_expect_success 'giving up --orphan not committed when -l and core.logAllRefUpdates = false deletes reflog' '
+       git checkout master &&
+       git checkout -l --orphan eta &&
+       test -f .git/logs/refs/heads/eta &&
+       test_must_fail PAGER= git reflog show eta &&
+       git checkout master &&
+       ! test -f .git/logs/refs/heads/eta &&
+       test_must_fail PAGER= git reflog show eta
+'
+
 test_expect_success '--orphan is rejected with an existing name' '
        git checkout master &&
        test_must_fail git checkout --orphan master &&
@@ -60,31 +116,11 @@ test_expect_success '--orphan refuses to switch if a merge is needed' '
        git reset --hard &&
        echo local >>"$TEST_FILE" &&
        cat "$TEST_FILE" >"$TEST_FILE.saved" &&
-       test_must_fail git checkout --orphan gamma master^ &&
+       test_must_fail git checkout --orphan new master^ &&
        test refs/heads/master = "$(git symbolic-ref HEAD)" &&
        test_cmp "$TEST_FILE" "$TEST_FILE.saved" &&
        git diff-index --quiet --cached HEAD &&
        git reset --hard
 '
 
-test_expect_success '--orphan does not mix well with -t' '
-       git checkout master &&
-       test_must_fail git checkout -t master --orphan gamma &&
-       test refs/heads/master = "$(git symbolic-ref HEAD)"
-'
-
-test_expect_success '--orphan ignores branch.autosetupmerge' '
-       git checkout -f master &&
-       git config branch.autosetupmerge always &&
-       git checkout --orphan delta &&
-       test -z "$(git config branch.delta.merge)" &&
-       test refs/heads/delta = "$(git symbolic-ref HEAD)" &&
-       test_must_fail git rev-parse --verify HEAD^
-'
-
-test_expect_success '--orphan does not mix well with -l' '
-       git checkout -f master &&
-       test_must_fail git checkout -l --orphan gamma
-'
-
 test_done
index 1ed44ee503f9ecfb5222a9bce3f42ff2aa8127bc..4d0d0a35156ee1a7604f0ea719e93d3f765a2f91 100755 (executable)
@@ -24,7 +24,7 @@ git update-index symlink'
 test_expect_success \
 'the index entry must still be a symbolic link' '
 case "`git ls-files --stage --cached symlink`" in
-120000" "*symlink) echo ok;;
+120000" "*symlink) echo pass;;
 *) echo fail; git ls-files --stage --cached symlink; (exit 1);;
 esac'
 
diff --git a/t/t2106-update-index-assume-unchanged.sh b/t/t2106-update-index-assume-unchanged.sh
new file mode 100755 (executable)
index 0000000..99d858c
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+test_description='git update-index --assume-unchanged test.
+'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' \
+       ': >file &&
+        git add file &&
+        git commit -m initial &&
+        git branch other &&
+        echo upstream >file &&
+        git add file &&
+        git commit -m upstream'
+
+test_expect_success 'do not switch branches with dirty file' \
+       'git reset --hard &&
+        git checkout other &&
+        echo dirt >file &&
+        git update-index --assume-unchanged file &&
+        test_must_fail git checkout master'
+
+test_done
index 9929f82021deeb20358016b487400b80e27b596f..d541544537d47587abad8d27565cf9197387cfd6 100755 (executable)
@@ -22,6 +22,7 @@ test_expect_success 'setup 1' '
        git branch df-2 &&
        git branch df-3 &&
        git branch remove &&
+       git branch submod &&
 
        echo hello >>a &&
        cp a d/e &&
@@ -236,6 +237,17 @@ test_expect_success 'setup 6' '
        test_cmp expected actual
 '
 
+test_expect_success 'setup 7' '
+
+       git checkout submod &&
+       git rm d/e &&
+       test_tick &&
+       git commit -m "remove d/e" &&
+       git update-index --add --cacheinfo 160000 $c1 d &&
+       test_tick &&
+       git commit -m "make d/ a submodule"
+'
+
 test_expect_success 'merge-recursive simple' '
 
        rm -fr [abcd] &&
@@ -551,4 +563,21 @@ test_expect_success 'merge removes empty directories' '
        test_must_fail test -d d
 '
 
+test_expect_failure 'merge-recursive simple w/submodule' '
+
+       git checkout submod &&
+       git merge remove
+'
+
+test_expect_failure 'merge-recursive simple w/submodule result' '
+
+       git ls-files -s >actual &&
+       (
+               echo "100644 $o5 0      a"
+               echo "100644 $o0 0      c"
+               echo "160000 $c1 0      d"
+       ) >expected &&
+       test_cmp expected actual
+'
+
 test_done
index e0b760513cfc065126cecd6e273180826c8f6bc9..859b99abf1cc62c966322fcfc552c0a7eb7356df 100755 (executable)
@@ -43,7 +43,7 @@ test_expect_success \
      git branch -l d/e/f &&
         test -f .git/refs/heads/d/e/f &&
         test -f .git/logs/refs/heads/d/e/f &&
-        diff expect .git/logs/refs/heads/d/e/f'
+        test_cmp expect .git/logs/refs/heads/d/e/f'
 
 test_expect_success \
     'git branch -d d/e/f should delete a branch and a log' \
@@ -222,7 +222,31 @@ test_expect_success \
      git checkout -b g/h/i -l master &&
         test -f .git/refs/heads/g/h/i &&
         test -f .git/logs/refs/heads/g/h/i &&
-        diff expect .git/logs/refs/heads/g/h/i'
+        test_cmp expect .git/logs/refs/heads/g/h/i'
+
+test_expect_success 'checkout -b makes reflog by default' '
+       git checkout master &&
+       git config --unset core.logAllRefUpdates &&
+       git checkout -b alpha &&
+       test -f .git/logs/refs/heads/alpha &&
+       PAGER= git reflog show alpha
+'
+
+test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' '
+       git checkout master &&
+       git config core.logAllRefUpdates false &&
+       git checkout -b beta &&
+       ! test -f .git/logs/refs/heads/beta &&
+       test_must_fail PAGER= git reflog show beta
+'
+
+test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' '
+       git checkout master &&
+       git checkout -lb gamma &&
+       git config --unset core.logAllRefUpdates &&
+       test -f .git/logs/refs/heads/gamma &&
+       PAGER= git reflog show gamma
+'
 
 test_expect_success 'avoid ambiguous track' '
        git config branch.autosetupmerge true &&
index 413019acafc98646a61e77960527f042a8f96ac6..525174013c4c33eab5bdbde8831d43f1ddbaeaae 100755 (executable)
@@ -28,7 +28,7 @@ test_expect_success \
      SHA1=`cat .git/refs/heads/a` &&
      echo "$SHA1 refs/heads/a" >expect &&
      git show-ref a >result &&
-     diff expect result'
+     test_cmp expect result'
 
 test_expect_success \
     'see if a branch still exists when packed' \
@@ -37,7 +37,7 @@ test_expect_success \
      rm -f .git/refs/heads/b &&
      echo "$SHA1 refs/heads/b" >expect &&
      git show-ref b >result &&
-     diff expect result'
+     test_cmp expect result'
 
 test_expect_success 'git branch c/d should barf if branch c exists' '
      git branch c &&
@@ -52,7 +52,7 @@ test_expect_success \
      git pack-refs --all --prune &&
      echo "$SHA1 refs/heads/e" >expect &&
      git show-ref e >result &&
-     diff expect result'
+     test_cmp expect result'
 
 test_expect_success 'see if git pack-refs --prune remove ref files' '
      git branch f &&
@@ -109,7 +109,7 @@ test_expect_success 'pack, prune and repack' '
        git show-ref >all-of-them &&
        git pack-refs &&
        git show-ref >again &&
-       diff all-of-them again
+       test_cmp all-of-them again
 '
 
 test_done
index db46d53e8271c0410a0dbf53a3560a8b635e2853..a99e4d8b923cd0d85e5f7e875af4182d2238c9fb 100755 (executable)
@@ -26,7 +26,7 @@ echo 'Foo Bar Baz' >"$p2"
 
 test -f "$p1" && cmp "$p0" "$p1" || {
        # since FAT/NTFS does not allow tabs in filenames, skip this test
-       say 'Your filesystem does not allow tabs in filenames, test skipped.'
+       skip_all='Your filesystem does not allow tabs in filenames, test skipped.'
        test_done
 }
 
index 64f32ad94dfe842746774596b88c91e873da864f..2d67a40fc16385b8bee37968f4058b094a174a98 100755 (executable)
@@ -1044,4 +1044,10 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
        git log -1 > output &&
        test_cmp expect output
 '
+
+test_expect_success 'git notes copy diagnoses too many or too few parameters' '
+       test_must_fail git notes copy &&
+       test_must_fail git notes copy one two three
+'
+
 test_done
index ee84fc4884676ef683e6b3d2b6ad718dc2817445..361a10aeb17108049bf0e47b71153800727edd87 100755 (executable)
@@ -8,7 +8,7 @@ test_description='Test commit notes index (expensive!)'
 . ./test-lib.sh
 
 test -z "$GIT_NOTES_TIMING_TESTS" && {
-       say Skipping timing tests
+       skip_all="Skipping timing tests"
        test_done
        exit
 }
index a0ed0353e69dd6dbc96f1a8e3c9251757b4f408f..b4554041b49d1ab7b56430f2e85b76a23d360fb4 100755 (executable)
@@ -60,7 +60,7 @@ test_expect_success 'verify commits and notes' '
 
 test_expect_success 'remove some commits' '
 
-       git reset --hard HEAD~2 &&
+       git reset --hard HEAD~1 &&
        git reflog expire --expire=now HEAD &&
        git gc --prune=now
 '
@@ -68,7 +68,7 @@ test_expect_success 'remove some commits' '
 test_expect_success 'verify that commits are gone' '
 
        ! git cat-file -p 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
-       git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 &&
+       git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 &&
        git cat-file -p ab5f302035f2e7aaf04265f08b42034c23256e1f
 '
 
@@ -79,11 +79,55 @@ test_expect_success 'verify that notes are still present' '
        git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
 '
 
+test_expect_success 'prune -n does not remove notes' '
+
+       git notes list > expect &&
+       git notes prune -n &&
+       git notes list > actual &&
+       test_cmp expect actual
+'
+
+cat > expect <<EOF
+5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29
+EOF
+
+test_expect_success 'prune -n lists prunable notes' '
+
+
+       git notes prune -n > actual &&
+       test_cmp expect actual
+'
+
+
 test_expect_success 'prune notes' '
 
        git notes prune
 '
 
+test_expect_success 'verify that notes are gone' '
+
+       ! git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
+       git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
+       git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
+'
+
+test_expect_success 'remove some commits' '
+
+       git reset --hard HEAD~1 &&
+       git reflog expire --expire=now HEAD &&
+       git gc --prune=now
+'
+
+cat > expect <<EOF
+08341ad9e94faa089d60fd3f523affb25c6da189
+EOF
+
+test_expect_success 'prune -v notes' '
+
+       git notes prune -v > actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'verify that notes are gone' '
 
        ! git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
diff --git a/t/t3307-notes-man.sh b/t/t3307-notes-man.sh
new file mode 100755 (executable)
index 0000000..3269f2e
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='Examples from the git-notes man page
+
+Make sure the manual is not full of lies.'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+       test_commit A &&
+       test_commit B &&
+       test_commit C
+'
+
+test_expect_success 'example 1: notes to add an Acked-by line' '
+       cat <<-\EOF >expect &&
+           B
+
+       Notes:
+           Acked-by: A C Ker <acker@example.com>
+       EOF
+       git notes add -m "Acked-by: A C Ker <acker@example.com>" B &&
+       git show -s B^{commit} >log &&
+       tail -n 4 log >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'example 2: binary notes' '
+       cp "$TEST_DIRECTORY"/test4012.png .
+       git checkout B &&
+       blob=$(git hash-object -w test4012.png) &&
+       git notes --ref=logo add -C "$blob" &&
+       git notes --ref=logo copy B C &&
+       git notes --ref=logo show C >actual &&
+       test_cmp test4012.png actual
+'
+
+test_done
index dbf7dfba9b55e906d44a35d7b11ca2ceaad7e6f5..d98c7b5571245ccfebf19547186c3cf116a13cfe 100755 (executable)
@@ -10,8 +10,9 @@ among other things.
 '
 . ./test-lib.sh
 
-GIT_AUTHOR_EMAIL=bogus_email_address
-export GIT_AUTHOR_EMAIL
+GIT_AUTHOR_NAME=author@name
+GIT_AUTHOR_EMAIL=bogus@email@address
+export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
 
 test_expect_success \
     'prepare repository with topic branches' \
@@ -80,6 +81,10 @@ test_expect_success \
     'the rebase operation should not have destroyed author information' \
     '! (git log | grep "Author:" | grep "<>")'
 
+test_expect_success \
+    'the rebase operation should not have destroyed author information (2)' \
+    "git log -1 | grep 'Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>'"
+
 test_expect_success 'HEAD was detached during rebase' '
      test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1})
 '
@@ -126,9 +131,20 @@ test_expect_success 'Show verbose error when HEAD could not be detached' '
      test_must_fail git rebase topic 2> output.err > output.out &&
      grep "Untracked working tree file .B. would be overwritten" output.err
 '
+rm -f B
+
+test_expect_success 'dump usage when upstream arg is missing' '
+     git checkout -b usage topic &&
+     test_must_fail git rebase 2>error1 &&
+     grep "[Uu]sage" error1 &&
+     test_must_fail git rebase --abort 2>error2 &&
+     grep "No rebase in progress" error2 &&
+     test_must_fail git rebase --onto master 2>error3 &&
+     grep "[Uu]sage" error3 &&
+     ! grep "can.t shift" error3
+'
 
 test_expect_success 'rebase -q is quiet' '
-     rm B &&
      git checkout -b quiet topic &&
      git rebase -q master > output.out 2>&1 &&
      test ! -s output.out
index f20ea38411d0ca67709dbde0bfd1108e28c0dd71..47ca88fc5231a5e0689b43a35eb660285a73190d 100755 (executable)
@@ -146,6 +146,16 @@ test_expect_success 'abort' '
        ! test -d .git/rebase-merge
 '
 
+test_expect_success 'abort with error when new base cannot be checked out' '
+       git rm --cached file1 &&
+       git commit -m "remove file in base" &&
+       test_must_fail git rebase -i master > output 2>&1 &&
+       grep "Untracked working tree file .file1. would be overwritten" \
+               output &&
+       ! test -d .git/rebase-merge &&
+       git reset --hard HEAD^
+'
+
 test_expect_success 'retain authorship' '
        echo A > file7 &&
        git add file7 &&
@@ -181,6 +191,12 @@ test_expect_success '-p handles "no changes" gracefully' '
        test $HEAD = $(git rev-parse HEAD)
 '
 
+test_expect_failure 'exchange two commits with -p' '
+       FAKE_LINES="2 1" git rebase -i -p HEAD~2 &&
+       test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
+       test G = $(git cat-file commit HEAD | sed -ne \$p)
+'
+
 test_expect_success 'preserve merges with -p' '
        git checkout -b to-be-preserved master^ &&
        : > unrelated-file &&
@@ -614,4 +630,22 @@ test_expect_success 'always cherry-pick with --no-ff' '
        test_cmp empty out
 '
 
+test_expect_success 'set up commits with funny messages' '
+       git checkout -b funny A &&
+       echo >>file1 &&
+       test_tick &&
+       git commit -a -m "end with slash\\" &&
+       echo >>file1 &&
+       test_tick &&
+       git commit -a -m "another commit"
+'
+
+test_expect_success 'rebase-i history with funny messages' '
+       git rev-list A..funny >expect &&
+       test_tick &&
+       FAKE_LINES="1 2" git rebase -i A &&
+       git rev-list A.. >actual &&
+       test_cmp expect actual
+'
+
 test_done
index 7f858151d4d7c1548803944de0dd8c54cdd8c78b..bc7aedd0484ed5ad1115cac0f22943445d658f47 100755 (executable)
@@ -41,13 +41,32 @@ test_expect_success setup '
        git tag rename2
 '
 
+test_expect_success 'cherry-pick --nonsense' '
+
+       pos=$(git rev-parse HEAD) &&
+       git diff --exit-code HEAD &&
+       test_must_fail git cherry-pick --nonsense 2>msg &&
+       git diff --exit-code HEAD "$pos" &&
+       grep '[Uu]sage:' msg
+'
+
+test_expect_success 'revert --nonsense' '
+
+       pos=$(git rev-parse HEAD) &&
+       git diff --exit-code HEAD &&
+       test_must_fail git revert --nonsense 2>msg &&
+       git diff --exit-code HEAD "$pos" &&
+       grep '[Uu]sage:' msg
+'
+
 test_expect_success 'cherry-pick after renaming branch' '
 
        git checkout rename2 &&
        git cherry-pick added &&
        test $(git rev-parse HEAD^) = $(git rev-parse rename2) &&
        test -f opos &&
-       grep "Add extra line at the end" opos
+       grep "Add extra line at the end" opos &&
+       git reflog -1 | grep cherry-pick
 
 '
 
@@ -57,7 +76,8 @@ test_expect_success 'revert after renaming branch' '
        git revert added &&
        test $(git rev-parse HEAD^) = $(git rev-parse rename1) &&
        test -f spoo &&
-       ! grep "Add extra line at the end" spoo
+       ! grep "Add extra line at the end" spoo &&
+       git reflog -1 | grep revert
 
 '
 
diff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh
new file mode 100755 (executable)
index 0000000..f90ed3d
--- /dev/null
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+test_description='test cherry-picking many commits'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+       echo first > file1 &&
+       git add file1 &&
+       test_tick &&
+       git commit -m "first" &&
+       git tag first &&
+
+       git checkout -b other &&
+       for val in second third fourth
+       do
+               echo $val >> file1 &&
+               git add file1 &&
+               test_tick &&
+               git commit -m "$val" &&
+               git tag $val
+       done
+'
+
+test_expect_success 'cherry-pick first..fourth works' '
+       git checkout -f master &&
+       git reset --hard first &&
+       test_tick &&
+       git cherry-pick first..fourth &&
+       git diff --quiet other &&
+       git diff --quiet HEAD other &&
+       test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
+'
+
+test_expect_success 'cherry-pick --ff first..fourth works' '
+       git checkout -f master &&
+       git reset --hard first &&
+       test_tick &&
+       git cherry-pick --ff first..fourth &&
+       git diff --quiet other &&
+       git diff --quiet HEAD other &&
+       test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify fourth)"
+'
+
+test_expect_success 'cherry-pick -n first..fourth works' '
+       git checkout -f master &&
+       git reset --hard first &&
+       test_tick &&
+       git cherry-pick -n first..fourth &&
+       git diff --quiet other &&
+       git diff --cached --quiet other &&
+       git diff --quiet HEAD first
+'
+
+test_expect_success 'revert first..fourth works' '
+       git checkout -f master &&
+       git reset --hard fourth &&
+       test_tick &&
+       git revert first..fourth &&
+       git diff --quiet first &&
+       git diff --cached --quiet first &&
+       git diff --quiet HEAD first
+'
+
+test_expect_success 'revert ^first fourth works' '
+       git checkout -f master &&
+       git reset --hard fourth &&
+       test_tick &&
+       git revert ^first fourth &&
+       git diff --quiet first &&
+       git diff --cached --quiet first &&
+       git diff --quiet HEAD first
+'
+
+test_expect_success 'revert fourth fourth~1 fourth~2 works' '
+       git checkout -f master &&
+       git reset --hard fourth &&
+       test_tick &&
+       git revert fourth fourth~1 fourth~2 &&
+       git diff --quiet first &&
+       git diff --cached --quiet first &&
+       git diff --quiet HEAD first
+'
+
+test_expect_success 'cherry-pick -3 fourth works' '
+       git checkout -f master &&
+       git reset --hard first &&
+       test_tick &&
+       git cherry-pick -3 fourth &&
+       git diff --quiet other &&
+       git diff --quiet HEAD other &&
+       test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
+'
+
+test_expect_success 'cherry-pick --stdin works' '
+       git checkout -f master &&
+       git reset --hard first &&
+       test_tick &&
+       git rev-list --reverse first..fourth | git cherry-pick --stdin &&
+       git diff --quiet other &&
+       git diff --quiet HEAD other &&
+       test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
+'
+
+test_done
index 0aaf0ad84b05e1ee17e9789811ea06f2d2798556..b514cbb60665fef9d5cd67b8f7bcd8e8a3c2d0a5 100755 (executable)
@@ -39,7 +39,7 @@ if test -f test-file
 then
        test_set_prereq RO_DIR
 else
-       say 'skipping removal failure test (perhaps running as root?)'
+       skip_all='skipping removal failure test (perhaps running as root?)'
 fi
 chmod 775 .
 rm -f test-file
index 525c9a8fdfb4953612e6946994c8e555f676bfd2..6f031af9f35e4d6350e8e6dd4619d55c66214aa6 100755 (executable)
@@ -26,7 +26,7 @@ test_expect_success \
         chmod 755 xfoo1 &&
         git add xfoo1 &&
         case "`git ls-files --stage xfoo1`" in
-        100644" "*xfoo1) echo ok;;
+        100644" "*xfoo1) echo pass;;
         *) echo fail; git ls-files --stage xfoo1; (exit 1);;
         esac'
 
@@ -35,7 +35,7 @@ test_expect_success SYMLINKS 'git add: filemode=0 should not get confused by sym
        ln -s foo xfoo1 &&
        git add xfoo1 &&
        case "`git ls-files --stage xfoo1`" in
-       120000" "*xfoo1) echo ok;;
+       120000" "*xfoo1) echo pass;;
        *) echo fail; git ls-files --stage xfoo1; (exit 1);;
        esac
 '
@@ -47,7 +47,7 @@ test_expect_success \
         chmod 755 xfoo2 &&
         git update-index --add xfoo2 &&
         case "`git ls-files --stage xfoo2`" in
-        100644" "*xfoo2) echo ok;;
+        100644" "*xfoo2) echo pass;;
         *) echo fail; git ls-files --stage xfoo2; (exit 1);;
         esac'
 
@@ -56,7 +56,7 @@ test_expect_success SYMLINKS 'git add: filemode=0 should not get confused by sym
        ln -s foo xfoo2 &&
        git update-index --add xfoo2 &&
        case "`git ls-files --stage xfoo2`" in
-       120000" "*xfoo2) echo ok;;
+       120000" "*xfoo2) echo pass;;
        *) echo fail; git ls-files --stage xfoo2; (exit 1);;
        esac
 '
@@ -67,7 +67,7 @@ test_expect_success SYMLINKS \
         ln -s xfoo2 xfoo3 &&
         git update-index --add xfoo3 &&
         case "`git ls-files --stage xfoo3`" in
-        120000" "*xfoo3) echo ok;;
+        120000" "*xfoo3) echo pass;;
         *) echo fail; git ls-files --stage xfoo3; (exit 1);;
         esac'
 
@@ -172,7 +172,7 @@ test_expect_success 'git add --refresh' '
        test -z "`git diff-index HEAD -- foo`" &&
        git read-tree HEAD &&
        case "`git diff-index HEAD -- foo`" in
-       :100644" "*"M   foo") echo ok;;
+       :100644" "*"M   foo") echo pass;;
        *) echo fail; (exit 1);;
        esac &&
        git add --refresh -- foo &&
index b6eba6a83904a00724b7b550a9bc3b1b35825bee..7ad8465f8f89656bf0ce57feb45e12bc9cea5d65 100755 (executable)
@@ -4,7 +4,7 @@ test_description='add -i basic tests'
 . ./test-lib.sh
 
 if ! test_have_prereq PERL; then
-       say 'skipping git add -i tests, perl not available'
+       skip_all='skipping git add -i tests, perl not available'
        test_done
 fi
 
@@ -154,7 +154,7 @@ rm -f .gitignore
 
 if test "$(git config --bool core.filemode)" = false
 then
-       say 'skipping filemode tests (filesystem does not properly support modes)'
+       say 'skipping filemode tests (filesystem does not properly support modes)'
 else
        test_set_prereq FILEMODE
 fi
index 29103f65dc60a81d071b9dd5600f416b3a31860f..147e634cd65b616ea6c8059897f191b761996c6f 100755 (executable)
@@ -17,7 +17,7 @@ DQ='"'
 echo foo 2>/dev/null > "Name and an${HT}HT"
 test -f "Name and an${HT}HT" || {
        # since FAT/NTFS does not allow tabs in filenames, skip this test
-       say 'Your filesystem does not allow tabs in filenames, test skipped.'
+       skip_all='Your filesystem does not allow tabs in filenames, test skipped.'
        test_done
 }
 
index 8fe14ccc5444df95960bee88e5b79eb68156572b..62e208aadd592ddaa5c519cf328e636d948221c0 100755 (executable)
@@ -81,7 +81,7 @@ test_expect_success 'drop top stash' '
        git stash &&
        git stash drop &&
        git stash list > stashlist2 &&
-       diff stashlist1 stashlist2 &&
+       test_cmp stashlist1 stashlist2 &&
        git stash apply &&
        test 3 = $(cat file) &&
        test 1 = $(git show :file) &&
index 18695ce8218a7b383258eeb0bad84b4d4bde45be..73441a516572dcf826582c04f3fe9d3ad0c1a88c 100755 (executable)
@@ -135,7 +135,7 @@ cmp_diff_files_output () {
     # filesystem.
     sed <"$2" >.test-tmp \
        -e '/^:000000 /d;s/'$x40'\( [MCRNDU][0-9]*\)    /'$z40'\1       /' &&
-    diff "$1" .test-tmp
+    test_cmp "$1" .test-tmp
 }
 
 test_expect_success \
index a4da1196a93a00502c8945a14e3aafd628efda53..1a09e8db403adc9c65859b0a369ce9d06e00e6f4 100755 (executable)
@@ -14,7 +14,7 @@ by an edit for them.
 
 if ! test_have_prereq SYMLINKS
 then
-       say 'Symbolic links not supported, skipping tests.'
+       skip_all='Symbolic links not supported, skipping tests.'
        test_done
 fi
 
index e12fbea1b5df970f22a1526c4d9ba8fc32a027ba..918a21a2f41caf2e8ed6bb6120631ff0e4ccb0fc 100755 (executable)
@@ -11,7 +11,7 @@ test_description='Test diff of symlinks.
 
 if ! test_have_prereq SYMLINKS
 then
-       say 'Symbolic links not supported, skipping tests.'
+       skip_all='Symbolic links not supported, skipping tests.'
        test_done
 fi
 
index 8dab4bf93ebd5f3e5ee6e899890d6e53af9ab967..1f0f9ad44b241e57e867c0676b73f37a1dc93d60 100644 (file)
@@ -18,6 +18,9 @@ A U Thor (2):
  create mode 100644 file1
  delete mode 100644 file2
 
+-- 
+g-i-t--v-e-r-s-i-o-n
+
 From 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 Mon Sep 17 00:00:00 2001
 From: A U Thor <author@example.com>
 Date: Mon, 26 Jun 2006 00:01:00 +0000
index d21c37f3a20c42b05044e45c5e5af71294c8420c..f87434b9f8e0d520813389e6ea7c94f74222767b 100755 (executable)
@@ -613,4 +613,56 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
        git format-patch --ignore-if-in-upstream HEAD
 '
 
+test_expect_success 'format-patch --signature' '
+       git format-patch --stdout --signature="my sig" -1 >output &&
+       grep "my sig" output
+'
+
+test_expect_success 'format-patch with format.signature config' '
+       git config format.signature "config sig" &&
+       git format-patch --stdout -1 >output &&
+       grep "config sig" output
+'
+
+test_expect_success 'format-patch --signature overrides format.signature' '
+       git config format.signature "config sig" &&
+       git format-patch --stdout --signature="overrides" -1 >output &&
+       ! grep "config sig" output &&
+       grep "overrides" output
+'
+
+test_expect_success 'format-patch --no-signature ignores format.signature' '
+       git config format.signature "config sig" &&
+       git format-patch --stdout --signature="my sig" --no-signature \
+               -1 >output &&
+       ! grep "config sig" output &&
+       ! grep "my sig" output &&
+       ! grep "^-- \$" output
+'
+
+test_expect_success 'format-patch --signature --cover-letter' '
+       git config --unset-all format.signature &&
+       git format-patch --stdout --signature="my sig" --cover-letter \
+               -1 >output &&
+       grep "my sig" output &&
+       test 2 = $(grep "my sig" output | wc -l)
+'
+
+test_expect_success 'format.signature="" supresses signatures' '
+       git config format.signature "" &&
+       git format-patch --stdout -1 >output &&
+       ! grep "^-- \$" output
+'
+
+test_expect_success 'format-patch --no-signature supresses signatures' '
+       git config --unset-all format.signature &&
+       git format-patch --stdout --no-signature -1 >output &&
+       ! grep "^-- \$" output
+'
+
+test_expect_success 'format-patch --signature="" supresses signatures' '
+       git format-patch --signature="" -1 >output &&
+       ! grep "^-- \$" output
+'
+
 test_done
index e92eab09cb3155e602027ce4104fe7ceb7af245e..935d101fe8d880ff426452ca6f611ce8d30b8bc1 100755 (executable)
@@ -438,6 +438,43 @@ test_expect_success 'whitespace-only changes not reported' '
        test_cmp expect actual
 '
 
+cat <<EOF >expect
+diff --git a/x b/z
+similarity index NUM%
+rename from x
+rename to z
+index 380c32a..a97b785 100644
+EOF
+test_expect_success 'whitespace-only changes reported across renames' '
+       git reset --hard &&
+       for i in 1 2 3 4 5 6 7 8 9; do echo "$i$i$i$i$i$i"; done >x &&
+       git add x &&
+       git commit -m "base" &&
+       sed -e "5s/^/ /" x >z &&
+       git rm x &&
+       git add z &&
+       git diff -w -M --cached |
+       sed -e "/^similarity index /s/[0-9][0-9]*/NUM/" >actual &&
+       test_cmp expect actual
+'
+
+cat >expected <<\EOF
+diff --git a/empty b/void
+similarity index 100%
+rename from empty
+rename to void
+EOF
+
+test_expect_success 'rename empty' '
+       git reset --hard &&
+       >empty &&
+       git add empty &&
+       git commit -m empty &&
+       git mv empty void &&
+       git diff -w --cached -M >current &&
+       test_cmp expected current
+'
+
 test_expect_success 'combined diff with autocrlf conversion' '
 
        git reset --hard &&
index 55eb5f83f17c0ebfb537d390fd3913b7c89d65f4..34e5144eed8958a3f3341574ff8ecbcc6a4157a9 100755 (executable)
@@ -14,7 +14,7 @@ P2='pathname with SP'
 P3='pathname
 with LF'
 : 2>/dev/null >"$P1" && test -f "$P1" && rm -f "$P1" || {
-       say 'Your filesystem does not allow tabs in filenames, test skipped.'
+       skip_all='Your filesystem does not allow tabs in filenames, test skipped.'
        test_done
 }
 
index 9bdf6596d82878f709a375084095697124a97609..40a95a149e4e84924d961d43f03115f466a9acc1 100755 (executable)
@@ -6,7 +6,7 @@ test_description='typechange rename detection'
 
 if ! test_have_prereq SYMLINKS
 then
-       say 'Symbolic links not supported, skipping tests.'
+       skip_all='Symbolic links not supported, skipping tests.'
        test_done
 fi
 
index 83c19147717f2a5e6c634918c74b93e54376d725..1bd8e5ee3ac5ca4d101738048e6769ae798b23dc 100755 (executable)
@@ -103,7 +103,15 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)'
        git diff HEAD >actual &&
        sed -e "1,/^@@/d" actual >actual.body &&
        expect_from_to >expect.body $subprev $subprev-dirty &&
-       test_cmp expect.body actual.body
+       test_cmp expect.body actual.body &&
+       git diff --ignore-submodules HEAD >actual2 &&
+       ! test -s actual2 &&
+       git diff --ignore-submodules=untracked HEAD >actual3 &&
+       sed -e "1,/^@@/d" actual3 >actual3.body &&
+       expect_from_to >expect.body $subprev $subprev-dirty &&
+       test_cmp expect.body actual3.body &&
+       git diff --ignore-submodules=dirty HEAD >actual4 &&
+       ! test -s actual4
 '
 
 test_expect_success 'git diff HEAD with dirty submodule (index, refs match)' '
@@ -129,7 +137,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'
        git diff HEAD >actual &&
        sed -e "1,/^@@/d" actual >actual.body &&
        expect_from_to >expect.body $subprev $subprev-dirty &&
-       test_cmp expect.body actual.body
+       test_cmp expect.body actual.body &&
+       git diff --ignore-submodules=all HEAD >actual2 &&
+       ! test -s actual2 &&
+       git diff --ignore-submodules=untracked HEAD >actual3 &&
+       ! test -s actual3 &&
+       git diff --ignore-submodules=dirty HEAD >actual4 &&
+       ! test -s actual4
 '
 
 test_expect_success 'git diff (empty submodule dir)' '
similarity index 74%
rename from t/t4041-diff-submodule.sh
rename to t/t4041-diff-submodule-option.sh
index 019acb926d6765bf24e1dfe4bea2a9dba28ca797..8e391cf9a72c6518217526155cbea93d74b9e626 100755 (executable)
@@ -205,6 +205,21 @@ Submodule sm1 contains untracked content
 EOF
 "
 
+test_expect_success 'submodule contains untracked content (untracked ignored)' "
+       git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
+       ! test -s actual
+"
+
+test_expect_success 'submodule contains untracked content (dirty ignored)' "
+       git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
+       ! test -s actual
+"
+
+test_expect_success 'submodule contains untracked content (all ignored)' "
+       git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
+       ! test -s actual
+"
+
 test_expect_success 'submodule contains untracked and modifed content' "
        echo new > sm1/foo6 &&
        git diff-index -p --submodule=log HEAD >actual &&
@@ -214,6 +229,26 @@ Submodule sm1 contains modified content
 EOF
 "
 
+test_expect_success 'submodule contains untracked and modifed content (untracked ignored)' "
+       echo new > sm1/foo6 &&
+       git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
+       diff actual - <<-EOF
+Submodule sm1 contains modified content
+EOF
+"
+
+test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' "
+       echo new > sm1/foo6 &&
+       git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
+       ! test -s actual
+"
+
+test_expect_success 'submodule contains untracked and modifed content (all ignored)' "
+       echo new > sm1/foo6 &&
+       git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
+       ! test -s actual
+"
+
 test_expect_success 'submodule contains modifed content' "
        rm -f sm1/new-file &&
        git diff-index -p --submodule=log HEAD >actual &&
@@ -242,6 +277,27 @@ Submodule sm1 $head6..$head8:
 EOF
 "
 
+test_expect_success 'modified submodule contains untracked content (untracked ignored)' "
+       git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
+       diff actual - <<-EOF
+Submodule sm1 $head6..$head8:
+  > change
+EOF
+"
+
+test_expect_success 'modified submodule contains untracked content (dirty ignored)' "
+       git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
+       diff actual - <<-EOF
+Submodule sm1 $head6..$head8:
+  > change
+EOF
+"
+
+test_expect_success 'modified submodule contains untracked content (all ignored)' "
+       git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
+       ! test -s actual
+"
+
 test_expect_success 'modified submodule contains untracked and modifed content' "
        echo modification >> sm1/foo6 &&
        git diff-index -p --submodule=log HEAD >actual &&
@@ -253,6 +309,31 @@ Submodule sm1 $head6..$head8:
 EOF
 "
 
+test_expect_success 'modified submodule contains untracked and modifed content (untracked ignored)' "
+       echo modification >> sm1/foo6 &&
+       git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
+       diff actual - <<-EOF
+Submodule sm1 contains modified content
+Submodule sm1 $head6..$head8:
+  > change
+EOF
+"
+
+test_expect_success 'modified submodule contains untracked and modifed content (dirty ignored)' "
+       echo modification >> sm1/foo6 &&
+       git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
+       diff actual - <<-EOF
+Submodule sm1 $head6..$head8:
+  > change
+EOF
+"
+
+test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' "
+       echo modification >> sm1/foo6 &&
+       git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
+       ! test -s actual
+"
+
 test_expect_success 'modified submodule contains modifed content' "
        rm -f sm1/new-file &&
        git diff-index -p --submodule=log HEAD >actual &&
diff --git a/t/t4043-diff-rename-binary.sh b/t/t4043-diff-rename-binary.sh
new file mode 100755 (executable)
index 0000000..0601281
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Jakub Narebski, Christian Couder
+#
+
+test_description='Move a binary file'
+
+. ./test-lib.sh
+
+
+test_expect_success 'prepare repository' '
+       git init &&
+       echo foo > foo &&
+       echo "barQ" | q_to_nul > bar &&
+       git add . &&
+       git commit -m "Initial commit"
+'
+
+test_expect_success 'move the files into a "sub" directory' '
+       mkdir sub &&
+       git mv bar foo sub/ &&
+       git commit -m "Moved to sub/"
+'
+
+cat > expected <<\EOF
+ bar => sub/bar |  Bin 5 -> 5 bytes
+ foo => sub/foo |    0
+ 2 files changed, 0 insertions(+), 0 deletions(-)
+
+diff --git a/bar b/sub/bar
+similarity index 100%
+rename from bar
+rename to sub/bar
+diff --git a/foo b/sub/foo
+similarity index 100%
+rename from foo
+rename to sub/foo
+EOF
+
+test_expect_success 'git show -C -C report renames' '
+       git show -C -C --raw --binary --stat | tail -n 12 > current &&
+       test_cmp expected current
+'
+
+test_done
diff --git a/t/t4044-diff-index-unique-abbrev.sh b/t/t4044-diff-index-unique-abbrev.sh
new file mode 100755 (executable)
index 0000000..d5ce72b
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+test_description='test unique sha1 abbreviation on "index from..to" line'
+. ./test-lib.sh
+
+cat >expect_initial <<EOF
+100644 blob 51d2738463ea4ca66f8691c91e33ce64b7d41bb1   foo
+EOF
+
+cat >expect_update <<EOF
+100644 blob 51d2738efb4ad8a1e40bed839ab8e116f0a15e47   foo
+EOF
+
+test_expect_success 'setup' '
+       echo 4827 > foo &&
+       git add foo &&
+       git commit -m "initial" &&
+       git cat-file -p HEAD: > actual &&
+       test_cmp expect_initial actual &&
+       echo 11742 > foo &&
+       git commit -a -m "update" &&
+       git cat-file -p HEAD: > actual &&
+       test_cmp expect_update actual
+'
+
+cat >expect <<EOF
+index 51d27384..51d2738e 100644
+EOF
+
+test_expect_success 'diff does not produce ambiguous index line' '
+       git diff HEAD^..HEAD | grep index > actual &&
+       test_cmp expect actual
+'
+
+test_done
index 99ec13dd531c71299681acc3eb678b490ff68707..164d58c222088bd42becf07c044f51bf23eda8b6 100755 (executable)
@@ -11,7 +11,7 @@ test_description='git apply should not get confused with type changes.
 
 if ! test_have_prereq SYMLINKS
 then
-       say 'Symbolic links not supported, skipping tests.'
+       skip_all='Symbolic links not supported, skipping tests.'
        test_done
 fi
 
index b852e5898009bca0205c231033f8f72f48962b81..aff4348034b21644818fb8f938ef006001b0b099 100755 (executable)
@@ -11,7 +11,7 @@ test_description='git apply symlinks and partial files
 
 if ! test_have_prereq SYMLINKS
 then
-       say 'Symbolic links not supported, skipping tests.'
+       skip_all='Symbolic links not supported, skipping tests.'
        test_done
 fi
 
index 0d3c1d5dd5c0f35f9cc44eab4fcba5ba2e36ddd7..923fcab7f96a76ee7038bfcb20b1270565bc2230 100755 (executable)
@@ -5,7 +5,7 @@ test_description='apply to deeper directory without getting fooled with symlink'
 
 if ! test_have_prereq SYMLINKS
 then
-       say 'Symbolic links not supported, skipping tests.'
+       skip_all='Symbolic links not supported, skipping tests.'
        test_done
 fi
 
index d0af697aa129466172e27456c597f329f9c4f027..8a676a5dcd113418c2bd4ea4aa885fddd5951a3a 100755 (executable)
@@ -44,7 +44,7 @@ test_fix () {
        apply_patch --whitespace=fix || return 1
 
        # find touched lines
-       diff file target | sed -n -e "s/^> //p" >fixed
+       $DIFF file target | sed -n -e "s/^> //p" >fixed
 
        # the changed lines are all expeced to change
        fixed_cnt=$(wc -l <fixed)
@@ -85,14 +85,14 @@ test_expect_success setup '
 test_expect_success 'whitespace=nowarn, default rule' '
 
        apply_patch --whitespace=nowarn &&
-       diff file target
+       test_cmp file target
 
 '
 
 test_expect_success 'whitespace=warn, default rule' '
 
        apply_patch --whitespace=warn &&
-       diff file target
+       test_cmp file target
 
 '
 
@@ -108,7 +108,7 @@ test_expect_success 'whitespace=error-all, no rule' '
 
        git config core.whitespace -trailing,-space-before,-indent &&
        apply_patch --whitespace=error-all &&
-       diff file target
+       test_cmp file target
 
 '
 
@@ -117,7 +117,7 @@ test_expect_success 'whitespace=error-all, no rule (attribute)' '
        git config --unset core.whitespace &&
        echo "target -whitespace" >.gitattributes &&
        apply_patch --whitespace=error-all &&
-       diff file target
+       test_cmp file target
 
 '
 
index 3a8202ea9311b1c90158ad0d115dda985060fdeb..77200c0b2d969d621623f3be8621a3f9925d50a5 100755 (executable)
@@ -27,7 +27,7 @@ test_expect_success 'apply same filename with independent changes' '
        cp same_fn same_fn2 &&
        git reset --hard &&
        git apply patch0 &&
-       diff same_fn same_fn2
+       test_cmp same_fn same_fn2
 '
 
 test_expect_success 'apply same filename with overlapping changes' '
@@ -40,7 +40,7 @@ test_expect_success 'apply same filename with overlapping changes' '
        cp same_fn same_fn2 &&
        git reset --hard &&
        git apply patch0 &&
-       diff same_fn same_fn2
+       test_cmp same_fn same_fn2
 '
 
 test_expect_success 'apply same new filename after rename' '
@@ -54,7 +54,7 @@ test_expect_success 'apply same new filename after rename' '
        cp new_fn new_fn2 &&
        git reset --hard &&
        git apply --index patch1 &&
-       diff new_fn new_fn2
+       test_cmp new_fn new_fn2
 '
 
 test_expect_success 'apply same old filename after rename -- should fail.' '
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
new file mode 100755 (executable)
index 0000000..cb9f2bd
--- /dev/null
@@ -0,0 +1,74 @@
+#!/bin/sh
+#
+# Copyright (c) 2010, Will Palmer
+#
+
+test_description='Test pretty formats'
+. ./test-lib.sh
+
+test_expect_success 'set up basic repos' '
+       >foo &&
+       >bar &&
+       git add foo &&
+       test_tick &&
+       git commit -m initial &&
+       git add bar &&
+       test_tick &&
+       git commit -m "add bar"
+'
+
+test_expect_success 'alias builtin format' '
+       git log --pretty=oneline >expected &&
+       git config pretty.test-alias oneline &&
+       git log --pretty=test-alias >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'alias masking builtin format' '
+       git log --pretty=oneline >expected &&
+       git config pretty.oneline "%H" &&
+       git log --pretty=oneline >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'alias user-defined format' '
+       git log --pretty="format:%h" >expected &&
+       git config pretty.test-alias "format:%h" &&
+       git log --pretty=test-alias >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'alias user-defined tformat' '
+       git log --pretty="tformat:%h" >expected &&
+       git config pretty.test-alias "tformat:%h" &&
+       git log --pretty=test-alias >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'alias non-existant format' '
+       git config pretty.test-alias format-that-will-never-exist &&
+       test_must_fail git log --pretty=test-alias
+'
+
+test_expect_success 'alias of an alias' '
+       git log --pretty="tformat:%h" >expected &&
+       git config pretty.test-foo "tformat:%h" &&
+       git config pretty.test-bar test-foo &&
+       git log --pretty=test-bar >actual && test_cmp expected actual
+'
+
+test_expect_success 'alias masking an alias' '
+       git log --pretty=format:"Two %H" >expected &&
+       git config pretty.duplicate "format:One %H" &&
+       git config --add pretty.duplicate "format:Two %H" &&
+       git log --pretty=duplicate >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'alias loop' '
+       git config pretty.test-foo test-bar &&
+       git config pretty.test-bar test-foo &&
+       test_must_fail git log --pretty=test-foo
+'
+
+test_done
diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh
new file mode 100755 (executable)
index 0000000..bbde31b
--- /dev/null
@@ -0,0 +1,66 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Nazri Ramliy
+#
+
+test_description='Test for "git log --decorate" colors'
+
+. ./test-lib.sh
+
+get_color ()
+{
+       git config --get-color no.such.slot "$1"
+}
+
+test_expect_success setup '
+       git config diff.color.commit yellow &&
+       git config color.decorate.branch green &&
+       git config color.decorate.remoteBranch red &&
+       git config color.decorate.tag "reverse bold yellow" &&
+       git config color.decorate.stash magenta &&
+       git config color.decorate.HEAD cyan &&
+
+       c_reset=$(get_color reset) &&
+
+       c_commit=$(get_color yellow) &&
+       c_branch=$(get_color green) &&
+       c_remoteBranch=$(get_color red) &&
+       c_tag=$(get_color "reverse bold yellow") &&
+       c_stash=$(get_color magenta) &&
+       c_HEAD=$(get_color cyan) &&
+
+       test_commit A &&
+       git clone . other &&
+       (
+               cd other &&
+               test_commit A1
+       ) &&
+
+       git remote add -f other ./other &&
+       test_commit B &&
+       git tag v1.0 &&
+       echo >>A.t &&
+       git stash save Changes to A.t
+'
+
+cat >expected <<EOF
+${c_commit}COMMIT_ID (${c_HEAD}HEAD${c_reset}${c_commit},\
+ ${c_tag}tag: v1.0${c_reset}${c_commit},\
+ ${c_tag}tag: B${c_reset}${c_commit},\
+ ${c_branch}master${c_reset}${c_commit})${c_reset} B
+${c_commit}COMMIT_ID (${c_tag}tag: A1${c_reset}${c_commit},\
+ ${c_remoteBranch}other/master${c_reset}${c_commit})${c_reset} A1
+${c_commit}COMMIT_ID (${c_stash}refs/stash${c_reset}${c_commit})${c_reset}\
+ On master: Changes to A.t
+${c_commit}COMMIT_ID (${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
+EOF
+
+# We want log to show all, but the second parent to refs/stash is irrelevant
+# to this test since it does not contain any decoration, hence --first-parent
+test_expect_success 'Commit Decorations Colored Correctly' '
+       git log --first-parent --abbrev=10 --all --decorate --oneline --color=always |
+       sed "s/[0-9a-f]\{10,10\}/COMMIT_ID/" >out &&
+       test_cmp expected out
+'
+
+test_done
index 169d3ea376f68a0924920b52748ba64356084eab..9cc0a42ea977e184be7af02e05352da8155c4728 100755 (executable)
@@ -67,7 +67,7 @@ test_expect_success 'setup: two scripts for reading pull requests' '
 
        cat <<-\EOT >read-request.sed &&
        #!/bin/sed -nf
-       / in the git repository at:$/! d
+       / in the git repository at:$/!d
        n
        /^$/ n
        s/^[    ]*\(.*\) \([^ ]*\)/please pull\
@@ -102,7 +102,7 @@ test_expect_success 'setup: two scripts for reading pull requests' '
        /^        [a-zA-Z]/ n
        /^[a-zA-Z]* ([0-9]*):\$/ n
        /^\$/ N
-       /^\n[a-zA-Z]* ([0-9]*):\$/! {
+       /^\n[a-zA-Z]* ([0-9]*):\$/!{
                a\\
        SHORTLOG
                D
index 7649b810b1469724ff738fb0bf8b23ea61b37bda..bbb9c1251d97bdaf5bca8f8260e481c3cac56dea 100755 (executable)
@@ -147,7 +147,7 @@ test_expect_success \
            git cat-file $t $object || return 1
         done <obj-list
     } >current &&
-    diff expect current'
+    test_cmp expect current'
 
 test_expect_success \
     'use packed deltified (REF_DELTA) objects' \
@@ -162,7 +162,7 @@ test_expect_success \
            git cat-file $t $object || return 1
         done <obj-list
     } >current &&
-    diff expect current'
+    test_cmp expect current'
 
 test_expect_success \
     'use packed deltified (OFS_DELTA) objects' \
@@ -177,7 +177,7 @@ test_expect_success \
            git cat-file $t $object || return 1
         done <obj-list
     } >current &&
-    diff expect current'
+    test_cmp expect current'
 
 unset GIT_OBJECT_DIRECTORY
 
index 4360e77d317bfdaf7b40795859b4a023a5b89c13..fb3a270822c9a4ac2e4f79bfa71c784291859d4f 100755 (executable)
@@ -74,7 +74,7 @@ if msg=$(git verify-pack -v "test-3-${pack3}.pack" 2>&1) ||
 then
        test_set_prereq OFF64_T
 else
-       say "skipping tests concerning 64-bit offsets"
+       say "skipping tests concerning 64-bit offsets"
 fi
 
 test_expect_success OFF64_T \
index d5db75d826c8584e1d7f0f5ef298021fecd6f055..bab1a536f562c63db67035712588d3e9a5222649 100755 (executable)
@@ -6,7 +6,7 @@ test_description='test automatic tag following'
 
 case $(uname -s) in
 *MINGW*)
-       say "GIT_DEBUG_SEND_PACK not supported - skipping tests"
+       skip_all="GIT_DEBUG_SEND_PACK not supported - skipping tests"
        test_done
 esac
 
index 41f17e76939ff0470878018cfbc11b45a8e92137..4c498b1902e4b0c74ea8d6bfc039d583bcc4364e 100755 (executable)
@@ -597,6 +597,94 @@ test_expect_success 'show empty remote' '
        )
 '
 
+test_expect_success 'remote set-branches requires a remote' '
+       test_must_fail git remote set-branches &&
+       test_must_fail git remote set-branches --add
+'
+
+test_expect_success 'remote set-branches' '
+       echo "+refs/heads/*:refs/remotes/scratch/*" >expect.initial &&
+       sort <<-\EOF >expect.add &&
+       +refs/heads/*:refs/remotes/scratch/*
+       +refs/heads/other:refs/remotes/scratch/other
+       EOF
+       sort <<-\EOF >expect.replace &&
+       +refs/heads/maint:refs/remotes/scratch/maint
+       +refs/heads/master:refs/remotes/scratch/master
+       +refs/heads/next:refs/remotes/scratch/next
+       EOF
+       sort <<-\EOF >expect.add-two &&
+       +refs/heads/maint:refs/remotes/scratch/maint
+       +refs/heads/master:refs/remotes/scratch/master
+       +refs/heads/next:refs/remotes/scratch/next
+       +refs/heads/pu:refs/remotes/scratch/pu
+       +refs/heads/t/topic:refs/remotes/scratch/t/topic
+       EOF
+       sort <<-\EOF >expect.setup-ffonly &&
+       refs/heads/master:refs/remotes/scratch/master
+       +refs/heads/next:refs/remotes/scratch/next
+       EOF
+       sort <<-\EOF >expect.respect-ffonly &&
+       refs/heads/master:refs/remotes/scratch/master
+       +refs/heads/next:refs/remotes/scratch/next
+       +refs/heads/pu:refs/remotes/scratch/pu
+       EOF
+
+       git clone .git/ setbranches &&
+       (
+               cd setbranches &&
+               git remote rename origin scratch &&
+               git config --get-all remote.scratch.fetch >config-result &&
+               sort <config-result >../actual.initial &&
+
+               git remote set-branches scratch --add other &&
+               git config --get-all remote.scratch.fetch >config-result &&
+               sort <config-result >../actual.add &&
+
+               git remote set-branches scratch maint master next &&
+               git config --get-all remote.scratch.fetch >config-result &&
+               sort <config-result >../actual.replace &&
+
+               git remote set-branches --add scratch pu t/topic &&
+               git config --get-all remote.scratch.fetch >config-result &&
+               sort <config-result >../actual.add-two &&
+
+               git config --unset-all remote.scratch.fetch &&
+               git config remote.scratch.fetch \
+                       refs/heads/master:refs/remotes/scratch/master &&
+               git config --add remote.scratch.fetch \
+                       +refs/heads/next:refs/remotes/scratch/next &&
+               git config --get-all remote.scratch.fetch >config-result &&
+               sort <config-result >../actual.setup-ffonly &&
+
+               git remote set-branches --add scratch pu &&
+               git config --get-all remote.scratch.fetch >config-result &&
+               sort <config-result >../actual.respect-ffonly
+       ) &&
+       test_cmp expect.initial actual.initial &&
+       test_cmp expect.add actual.add &&
+       test_cmp expect.replace actual.replace &&
+       test_cmp expect.add-two actual.add-two &&
+       test_cmp expect.setup-ffonly actual.setup-ffonly &&
+       test_cmp expect.respect-ffonly actual.respect-ffonly
+'
+
+test_expect_success 'remote set-branches with --mirror' '
+       echo "+refs/*:refs/*" >expect.initial &&
+       echo "+refs/heads/master:refs/heads/master" >expect.replace &&
+       git clone --mirror .git/ setbranches-mirror &&
+       (
+               cd setbranches-mirror &&
+               git remote rename origin scratch &&
+               git config --get-all remote.scratch.fetch >../actual.initial &&
+
+               git remote set-branches scratch heads/master &&
+               git config --get-all remote.scratch.fetch >../actual.replace
+       ) &&
+       test_cmp expect.initial actual.initial &&
+       test_cmp expect.replace actual.replace
+'
+
 test_expect_success 'new remote' '
        git remote add someremote foo &&
        echo foo >expect &&
index 721821ec92e476ed9a16222bc49b72f2fd9b2c68..4eb10f602fdcba354c6d140ed6b910ee89641708 100755 (executable)
@@ -71,7 +71,7 @@ test_expect_success "fetch test for-merge" '
                echo "$one_in_two       "
        } >expected &&
        cut -f -2 .git/FETCH_HEAD >actual &&
-       diff expected actual'
+       test_cmp expected actual'
 
 test_expect_success 'fetch tags when there is no tags' '
 
index 3cf1b3da40a8d99631fabaa2cce4ff2b6d1b52ac..d1912351db7da4a7c457fd44895b5ea076c84e7e 100755 (executable)
@@ -57,12 +57,24 @@ test_expect_success 'dies when no remote specified and no default remotes found'
 
 test_expect_success 'use "origin" when no remote specified' '
 
-       git remote add origin "$(pwd)/.git" &&
-       git ls-remote >actual &&
+       URL="$(pwd)/.git" &&
+       echo "From $URL" >exp_err &&
+
+       git remote add origin "$URL" &&
+       git ls-remote 2>actual_err >actual &&
+
+       test_cmp exp_err actual_err &&
        test_cmp expected.all actual
 
 '
 
+test_expect_success 'suppress "From <url>" with -q' '
+
+       git ls-remote -q 2>actual_err &&
+       test_must_fail test_cmp exp_err actual_err
+
+'
+
 test_expect_success 'use branch.<name>.remote if possible' '
 
        #
@@ -78,10 +90,14 @@ test_expect_success 'use branch.<name>.remote if possible' '
                git show-ref    | sed -e "s/ /  /"
        ) >exp &&
 
-       git remote add other other.git &&
+       URL="other.git" &&
+       echo "From $URL" >exp_err &&
+
+       git remote add other $URL &&
        git config branch.master.remote other &&
 
-       git ls-remote >actual &&
+       git ls-remote 2>actual_err >actual &&
+       test_cmp exp_err actual_err &&
        test_cmp exp actual
 
 '
index dd2ee842e020c23b49ed4e2070c4e31cdb7ac055..319e389ed0dbb9c920d8d619cdf94ab52145e9f4 100755 (executable)
@@ -26,7 +26,7 @@ cd "$D"
 test_expect_success 'checking the results' '
        test -f file &&
        test -f cloned/file &&
-       diff file cloned/file
+       test_cmp file cloned/file
 '
 
 test_expect_success 'pulling into void using master:master' '
index 7206817ca1c7a450b47f9a1d7d8a3af53452dac6..298200fa4cafc61b5f16f9337314a2b887593a36 100755 (executable)
@@ -6,7 +6,7 @@ test_description='pulling from symlinked subdir'
 
 if ! test_have_prereq SYMLINKS
 then
-       say 'Symbolic links not supported, skipping tests.'
+       skip_all='Symbolic links not supported, skipping tests.'
        test_done
 fi
 
index a696b8791b7caa44ae2bd16d6970a791f3a28d3d..044603c26ed62e3ddf03ebb2542f783e4dd7d9ff 100755 (executable)
@@ -32,9 +32,9 @@ test_expect_success 'fsck fails' '
 
 test_expect_success 'upload-pack fails due to error in pack-objects packing' '
 
-       ! echo "0032want $(git rev-parse HEAD)
-00000009done
-0000" | git upload-pack . > /dev/null 2> output.err &&
+       printf "0032want %s\n00000009done\n0000" \
+               $(git rev-parse HEAD) >input &&
+       test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
        grep "unable to read" output.err &&
        grep "pack-objects died" output.err
 '
@@ -51,9 +51,9 @@ test_expect_success 'fsck fails' '
 '
 test_expect_success 'upload-pack fails due to error in rev-list' '
 
-       ! echo "0032want $(git rev-parse HEAD)
-0034shallow $(git rev-parse HEAD^)00000009done
-0000" | git upload-pack . > /dev/null 2> output.err &&
+       printf "0032want %s\n0034shallow %s00000009done\n0000" \
+               $(git rev-parse HEAD) $(git rev-parse HEAD^) >input &&
+       test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
        # pack-objects survived
        grep "Total.*, reused" output.err &&
        # but there was an error, which must have been in rev-list
@@ -62,9 +62,9 @@ test_expect_success 'upload-pack fails due to error in rev-list' '
 
 test_expect_success 'upload-pack fails due to error in pack-objects enumeration' '
 
-       ! echo "0032want $(git rev-parse HEAD)
-00000009done
-0000" | git upload-pack . > /dev/null 2> output.err &&
+       printf "0032want %s\n00000009done\n0000" \
+               $(git rev-parse HEAD) >input &&
+       test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
        grep "bad tree object" output.err &&
        grep "pack-objects died" output.err
 '
index 37fe87541127887742530a8f8859f1dd369d3f34..a266ca56361347fe751495e1531b5a26e4733493 100755 (executable)
@@ -11,7 +11,7 @@ This test runs various sanity checks on http-push.'
 
 if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
 then
-       say "skipping test, USE_CURL_MULTI is not defined"
+       skip_all="skipping test, USE_CURL_MULTI is not defined"
        test_done
 fi
 
index 17e1bdc5a81ce4802f5074ddb9c1996c68fc97be..504884b9f8fab3bfa34e3dc97d3dc7aad297e626 100755 (executable)
@@ -7,7 +7,7 @@ test_description='test smart pushing over http via http-backend'
 . ./test-lib.sh
 
 if test -n "$NO_CURL"; then
-       say 'skipping test, git built without http support'
+       skip_all='skipping test, git built without http support'
        test_done
 fi
 
index fc675b50adfa945724cd7d17dbb6034df53426d3..2fb48d09edb47129d9cea8b9686e46a6d8f35615 100755 (executable)
@@ -4,7 +4,7 @@ test_description='test dumb fetching over http via static file'
 . ./test-lib.sh
 
 if test -n "$NO_CURL"; then
-       say 'skipping test, git built without http support'
+       skip_all='skipping test, git built without http support'
        test_done
 fi
 
index 7faa31a299f263b0628d4a23e4500d3e43e0fdda..fd19121372aecc0806e17e62d639855f391045d3 100755 (executable)
@@ -4,7 +4,7 @@ test_description='test smart fetching over http via http-backend'
 . ./test-lib.sh
 
 if test -n "$NO_CURL"; then
-       say 'skipping test, git built without http support'
+       skip_all='skipping test, git built without http support'
        test_done
 fi
 
index 8c6d0b2f20c803574af273b9d7c4ffd41870adcc..b5d7fbc3815aed53ec50bdf7f5dbf2c796fed1fe 100755 (executable)
@@ -4,7 +4,7 @@ test_description='test git-http-backend'
 . ./test-lib.sh
 
 if test -n "$NO_CURL"; then
-       say 'skipping test, git built without http support'
+       skip_all='skipping test, git built without http support'
        test_done
 fi
 
index 678cee502de54e5a9c18a43f114446d3392ec7f3..8abb71afcd4d7389260baa6f82ecb9b53bb9524c 100755 (executable)
@@ -176,4 +176,16 @@ test_expect_success 'clone respects global branch.autosetuprebase' '
        )
 '
 
+test_expect_success 'respect url-encoding of file://' '
+       git init x+y &&
+       test_must_fail git clone "file://$PWD/x+y" xy-url &&
+       git clone "file://$PWD/x%2By" xy-url
+'
+
+test_expect_success 'do not respect url-encoding of non-url path' '
+       git init x+y &&
+       test_must_fail git clone x%2By xy-regular &&
+       git clone x+y xy-regular
+'
+
 test_done
index 1c109160690d273451f7a089be42e45f36a3b5bb..895f5595aee9341276e79497b9c4a8736c78e5e7 100755 (executable)
@@ -48,7 +48,7 @@ test_expect_success 'that reference gets used' \
 'cd C &&
 echo "0 objects, 0 kilobytes" > expected &&
 git count-objects > current &&
-diff expected current'
+test_cmp expected current'
 
 cd "$base_dir"
 
@@ -75,7 +75,7 @@ cd "$base_dir"
 test_expect_success 'that reference gets used' \
 'cd D && echo "0 objects, 0 kilobytes" > expected &&
 git count-objects > current &&
-diff expected current'
+test_cmp expected current'
 
 cd "$base_dir"
 
@@ -100,7 +100,7 @@ test_expect_success 'that alternate to origin gets used' \
 'cd C &&
 echo "2 objects" > expected &&
 git count-objects | cut -d, -f1 > current &&
-diff expected current'
+test_cmp expected current'
 
 cd "$base_dir"
 
@@ -116,7 +116,7 @@ test_expect_success 'check objects expected to exist locally' \
 'cd D &&
 echo "5 objects" > expected &&
 git count-objects | cut -d, -f1 > current &&
-diff expected current'
+test_cmp expected current'
 
 cd "$base_dir"
 
index 8afbdd4de2146be763f7454af66a15986490fe60..e4d1b6a0fa39d82d048f4dde62155a059173c5b4 100755 (executable)
@@ -4,7 +4,7 @@ test_description='Test cloning a repository larger than 2 gigabyte'
 . ./test-lib.sh
 
 test -z "$GIT_TEST_CLONE_2GB" &&
-say "Skipping expensive 2GB clone test; enable it with GIT_TEST_CLONE_2GB=t" &&
+skip_all="Skipping expensive 2GB clone test; enable it with GIT_TEST_CLONE_2GB=t" &&
 test_done &&
 exit
 
index 75a0163c074724513accc9f2a482d72d9e51532c..637d8e97ac4d220437ac168dcce49dfd33aa7a24 100755 (executable)
@@ -7,9 +7,15 @@ test_description='Test remote-helper import and export commands'
 
 . ./test-lib.sh
 
-if ! test_have_prereq PYTHON
+if test_have_prereq PYTHON && "$PYTHON_PATH" -c '
+import sys
+if sys.hexversion < 0x02040000:
+    sys.exit(1)
+'
 then
-       say 'skipping git remote-testgit tests: requires Python support'
+       :
+else
+       skip_all='skipping git remote-testgit tests: requires Python 2.4 or newer'
        test_done
 fi
 
index b2131cdacd93e0b62f4ef8fdc62b6a81c6aef6fc..fc57e7d3fd69c60144ee3fb3f66b252a67369b42 100755 (executable)
@@ -84,7 +84,7 @@ check () {
                git rev-list --parents --pretty=raw $arg |
                sed -n -e 's/^commit //p' >test.actual
        fi
-       diff test.expect test.actual
+       test_cmp test.expect test.actual
 }
 
 for type in basic parents parents-raw
index b4e8fbaa5e6f2a56094c05ca505630669a51e101..fb07536a0f5b7e1000cf4945f55be3305df88e90 100755 (executable)
@@ -5,7 +5,7 @@
 test_description='Tests git rev-list --bisect functionality'
 
 . ./test-lib.sh
-. "$TEST_DIRECTORY"/t6000lib.sh # t6xxx specific functions
+. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions
 
 # usage: test_bisection max-diff bisect-option head ^prune...
 #
index 2c73f2da7b0a1f560bfd41376b587d1c91b18615..e4c52b0214b5028e8c3db035dc96ca3285e61506 100755 (executable)
@@ -6,7 +6,7 @@
 test_description='Tests git rev-list --topo-order functionality'
 
 . ./test-lib.sh
-. "$TEST_DIRECTORY"/t6000lib.sh # t6xxx specific functions
+. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions
 
 list_duplicates()
 {
index 9b77073df880d4597742e20d738273244d2e4a10..cccacd4add48524abd4a3021f8048a6c45c245ea 100755 (executable)
@@ -200,6 +200,16 @@ test_expect_success 'add LF before non-empty (2)' '
        grep "^$" actual
 '
 
+test_expect_success 'add SP before non-empty (1)' '
+       git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
+       test $(wc -w <actual) = 2
+'
+
+test_expect_success 'add SP before non-empty (2)' '
+       git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
+       test $(wc -w <actual) = 4
+'
+
 test_expect_success '--abbrev' '
        echo SHORT SHORT SHORT >expect2 &&
        echo LONG LONG LONG >expect3 &&
index 4b8611ce2092f9062aeaeb62ce19a9121d5be537..b565638e92655c12c841c29a108516a8b13cf8d2 100755 (executable)
@@ -32,6 +32,23 @@ test_expect_success setup '
        git tag B
 '
 
+cat >expect <<EOF
+<tags/B
+>tags/C
+EOF
+
+test_expect_success '--left-right' '
+       git rev-list --left-right B...C > actual &&
+       git name-rev --stdin --name-only --refs="*tags/*" \
+               < actual > actual.named &&
+       test_cmp actual.named expect
+'
+
+test_expect_success '--count' '
+       git rev-list --count B...C > actual &&
+       test "$(cat actual)" = 2
+'
+
 test_expect_success '--cherry-pick foo comes up empty' '
        test -z "$(git rev-list --left-right --cherry-pick B...C -- foo)"
 '
@@ -54,4 +71,16 @@ test_expect_success '--cherry-pick with independent, but identical branches' '
                HEAD...master -- foo)"
 '
 
+cat >expect <<EOF
+1      2
+EOF
+
+# Insert an extra commit to break the symmetry
+test_expect_success '--count --left-right' '
+       git checkout branch &&
+       test_commit D &&
+       git rev-list --count --left-right B...D > actual &&
+       test_cmp expect actual
+'
+
 test_done
index 8d3fa7d014c1e5a856f6c4c35cfb46eb8c44e684..58428d9f5c3d079b0e842b5851b100f9e895a239 100755 (executable)
@@ -34,7 +34,9 @@ test_expect_success 'setup' '
        git checkout master &&
        commit master2 &&
        git tag foo/bar master &&
-       git update-ref refs/remotes/foo/baz master
+       commit master3 &&
+       git update-ref refs/remotes/foo/baz master &&
+       commit master4
 '
 
 test_expect_success 'rev-parse --glob=refs/heads/subspace/*' '
@@ -162,6 +164,13 @@ test_expect_success 'rev-list --branches=subspace' '
        compare rev-list "subspace/one subspace/two" "--branches=subspace"
 
 '
+
+test_expect_success 'rev-list --branches' '
+
+       compare rev-list "master subspace-x someref other/three subspace/one subspace/two" "--branches"
+
+'
+
 test_expect_success 'rev-list --glob=heads/someref/* master' '
 
        compare rev-list "master" "--glob=heads/someref/* master"
@@ -186,6 +195,12 @@ test_expect_success 'rev-list --tags=foo' '
 
 '
 
+test_expect_success 'rev-list --tags' '
+
+       compare rev-list "foo/bar" "--tags"
+
+'
+
 test_expect_success 'rev-list --remotes=foo' '
 
        compare rev-list "foo/baz" "--remotes=foo"
diff --git a/t/t6019-rev-list-ancestry-path.sh b/t/t6019-rev-list-ancestry-path.sh
new file mode 100755 (executable)
index 0000000..7641029
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+test_description='--ancestry-path'
+
+#          D---E-------F
+#         /     \       \
+#    B---C---G---H---I---J
+#   /                     \
+#  A-------K---------------L--M
+#
+#  D..M                 == E F G H I J K L M
+#  --ancestry-path D..M == E F H I J L M
+#
+#  D..M -- M.t                 == M
+#  --ancestry-path D..M -- M.t == M
+
+. ./test-lib.sh
+
+test_merge () {
+       test_tick &&
+       git merge -s ours -m "$2" "$1" &&
+       git tag "$2"
+}
+
+test_expect_success setup '
+       test_commit A &&
+       test_commit B &&
+       test_commit C &&
+       test_commit D &&
+       test_commit E &&
+       test_commit F &&
+       git reset --hard C &&
+       test_commit G &&
+       test_merge E H &&
+       test_commit I &&
+       test_merge F J &&
+       git reset --hard A &&
+       test_commit K &&
+       test_merge J L &&
+       test_commit M
+'
+
+test_expect_success 'rev-list D..M' '
+       for c in E F G H I J K L M; do echo $c; done >expect &&
+       git rev-list --format=%s D..M |
+       sed -e "/^commit /d" |
+       sort >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'rev-list --ancestry-path D..M' '
+       for c in E F H I J L M; do echo $c; done >expect &&
+       git rev-list --ancestry-path --format=%s D..M |
+       sed -e "/^commit /d" |
+       sort >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'rev-list D..M -- M.t' '
+       echo M >expect &&
+       git rev-list --format=%s D..M -- M.t |
+       sed -e "/^commit /d" >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'rev-list --ancestry-patch D..M -- M.t' '
+       echo M >expect &&
+       git rev-list --ancestry-path --format=%s D..M -- M.t |
+       sed -e "/^commit /d" >actual &&
+       test_cmp expect actual
+'
+
+test_done
index e3f7ae8120aa2a46b25dd3830597cb863a5f5e20..b66544b76d545a396ef068438f3980b3f544efdd 100755 (executable)
@@ -280,7 +280,7 @@ test_expect_success 'updated working tree file should prevent the merge' '
                echo "BAD: should have complained"
                return 1
        }
-       diff M M.saved || {
+       test_cmp M M.saved || {
                echo "BAD: should have left M intact"
                return 1
        }
@@ -301,7 +301,7 @@ test_expect_success 'updated working tree file should prevent the merge' '
                echo "BAD: should have complained"
                return 1
        }
-       diff M M.saved || {
+       test_cmp M M.saved || {
                echo "BAD: should have left M intact"
                return 1
        }
index 3202e1de6d01bf3c36e82351c7f8426cc2bb44ab..cd3190c4a61f0404491b41a1b22f5143b63f4992 100755 (executable)
@@ -5,7 +5,7 @@ test_description='merging when a directory was replaced with a symlink'
 
 if ! test_have_prereq SYMLINKS
 then
-       say 'Symbolic links not supported, skipping tests.'
+       skip_all='Symbolic links not supported, skipping tests.'
        test_done
 fi
 
index f105fab98e2d493ab489d345676101fc13096c22..e673c25e943f77430d7f61b0ab9e0b21e38e6915 100755 (executable)
@@ -6,7 +6,7 @@
 test_description='Test git rev-parse with different parent options'
 
 . ./test-lib.sh
-. "$TEST_DIRECTORY"/t6000lib.sh # t6xxx specific functions
+. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions
 
 date >path0
 git update-index --add path0
index 73dbc4360b58c95ae135577031fb8e60b3f395f7..ac943f5eeecd17dd1edc5834265df9e16e5032f2 100755 (executable)
@@ -583,7 +583,7 @@ test_expect_success \
 # subsequent tests require gpg; check if it is available
 gpg --version >/dev/null 2>/dev/null
 if [ $? -eq 127 ]; then
-       say "gpg not found - skipping tag signing and verification tests"
+       say "gpg not found - skipping tag signing and verification tests"
 else
        # As said here: http://www.gnupg.org/documentation/faqs.html#q6.19
        # the gpg version 1.0.6 didn't parse trust packets correctly, so for
index 5257f4d261c2060b881d2649034232f76f4ed9b7..26ddf9d496f6eacddbec603659be7fca3dff294b 100755 (executable)
@@ -13,7 +13,7 @@ test_expect_success 'determine default editor' '
 
 '
 
-if ! expr "$vi" : '^[a-z]*$' >/dev/null
+if ! expr "$vi" : '[a-z]*$' >/dev/null
 then
        vi=
 fi
@@ -38,7 +38,7 @@ test_expect_success setup '
        test_commit "$msg" &&
        echo "$msg" >expect &&
        git show -s --format=%s > actual &&
-       diff actual expect
+       test_cmp actual expect
 
 '
 
@@ -85,7 +85,7 @@ do
                git --exec-path=. commit --amend &&
                git show -s --pretty=oneline |
                sed -e "s/^[0-9a-f]* //" >actual &&
-               diff actual expect
+               test_cmp actual expect
        '
 done
 
@@ -107,13 +107,13 @@ do
                git --exec-path=. commit --amend &&
                git show -s --pretty=oneline |
                sed -e "s/^[0-9a-f]* //" >actual &&
-               diff actual expect
+               test_cmp actual expect
        '
 done
 
 if ! echo 'echo space > "$1"' > "e space.sh"
 then
-       say "Skipping; FS does not support spaces in filenames"
+       skip_all="Skipping; FS does not support spaces in filenames"
        test_done
 fi
 
index fc993fc8c48167f7a7deebf15e1969d6e4320e78..eb9651da895f8f520c82aeab7a5406bcf9c09478 100755 (executable)
@@ -37,11 +37,11 @@ then
        }
        test_set_prereq TTY
 else
-       say no usable terminal, so skipping some tests
+       say "# no usable terminal, so skipping some tests"
 fi
 
 test_expect_success 'setup' '
-       unset GIT_PAGER GIT_PAGER_IN_USE &&
+       unset GIT_PAGER GIT_PAGER_IN_USE;
        test_might_fail git config --unset core.pager &&
 
        PAGER="cat >paginated.out" &&
@@ -110,7 +110,7 @@ test_expect_success TTY 'no pager with --no-pager' '
 # for the first color; the text "commit" comes later.
 colorful() {
        read firstline <$1
-       ! expr "$firstline" : "^[a-zA-Z]" >/dev/null
+       ! expr "$firstline" : "[a-zA-Z]" >/dev/null
 }
 
 test_expect_success 'tests can detect color' '
@@ -165,7 +165,7 @@ then
 fi
 
 test_expect_success SIMPLEPAGERTTY 'default pager is used by default' '
-       unset PAGER GIT_PAGER &&
+       unset PAGER GIT_PAGER;
        test_might_fail git config --unset core.pager &&
        rm -f default_pager_used ||
        cleanup_fail &&
@@ -184,7 +184,7 @@ test_expect_success SIMPLEPAGERTTY 'default pager is used by default' '
 '
 
 test_expect_success TTY 'PAGER overrides default pager' '
-       unset GIT_PAGER &&
+       unset GIT_PAGER;
        test_might_fail git config --unset core.pager &&
        rm -f PAGER_used ||
        cleanup_fail &&
@@ -196,7 +196,7 @@ test_expect_success TTY 'PAGER overrides default pager' '
 '
 
 test_expect_success TTY 'core.pager overrides PAGER' '
-       unset GIT_PAGER &&
+       unset GIT_PAGER;
        rm -f core.pager_used ||
        cleanup_fail &&
 
diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh
new file mode 100755 (executable)
index 0000000..eb8ca88
--- /dev/null
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+test_description='git grep in binary files'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' "
+       printf 'binary\000file\n' >a &&
+       git add a &&
+       git commit -m.
+"
+
+test_expect_success 'git grep ina a' '
+       echo Binary file a matches >expect &&
+       git grep ina a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'git grep -ah ina a' '
+       git grep -ah ina a >actual &&
+       test_cmp a actual
+'
+
+test_expect_success 'git grep -I ina a' '
+       : >expect &&
+       test_must_fail git grep -I ina a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'git grep -c ina a' '
+       echo a:1 >expect &&
+       git grep -c ina a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'git grep -l ina a' '
+       echo a >expect &&
+       git grep -l ina a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'git grep -L bar a' '
+       echo a >expect &&
+       git grep -L bar a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'git grep -q ina a' '
+       : >expect &&
+       git grep -q ina a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'git grep -F ile a' '
+       git grep -F ile a
+'
+
+test_expect_success 'git grep -Fi iLE a' '
+       git grep -Fi iLE a
+'
+
+# This test actually passes on platforms where regexec() supports the
+# flag REG_STARTEND.
+test_expect_failure 'git grep ile a' '
+       git grep ile a
+'
+
+test_expect_failure 'git grep .fi a' '
+       git grep .fi a
+'
+
+test_expect_success 'git grep -F y<NUL>f a' "
+       printf 'y\000f' >f &&
+       git grep -f f -F a
+"
+
+test_expect_success 'git grep -F y<NUL>x a' "
+       printf 'y\000x' >f &&
+       test_must_fail git grep -f f -F a
+"
+
+test_expect_success 'git grep -Fi Y<NUL>f a' "
+       printf 'Y\000f' >f &&
+       git grep -f f -Fi a
+"
+
+test_expect_failure 'git grep -Fi Y<NUL>x a' "
+       printf 'Y\000x' >f &&
+       test_must_fail git grep -f f -Fi a
+"
+
+test_expect_success 'git grep y<NUL>f a' "
+       printf 'y\000f' >f &&
+       git grep -f f a
+"
+
+test_expect_failure 'git grep y<NUL>x a' "
+       printf 'y\000x' >f &&
+       test_must_fail git grep -f f a
+"
+
+test_done
index d8a7c798525728ddc8fc5fa9bd8335d8d1f0a710..0335a9a158ab507b2e37e4d7642a69ba4344c0ad 100755 (executable)
@@ -103,14 +103,10 @@ test_expect_success 'git ls-files (relative #3)' '
        git add a &&
        (
                cd a/b &&
-               if git ls-files "../e/f"
-               then
-                       echo Gaah, should have failed
-                       exit 1
-               else
-                       : happy
-               fi
-       )
+               git ls-files "../e/f"
+       )  >current &&
+       echo ../e/f >expect &&
+       test_cmp expect current
 
 '
 
index 97ff074da768cbf3418f22b366ff935d82915f85..d9f27859932c33e126fa64c5c1fb80963dabb97a 100755 (executable)
@@ -42,7 +42,8 @@ test_expect_success 'setup - hide init subdirectory' '
 '
 
 test_expect_success 'setup - repository to add submodules to' '
-       git init addtest
+       git init addtest &&
+       git init addtest-ignore
 '
 
 # The 'submodule add' tests need some repository to add as a submodule.
@@ -85,6 +86,27 @@ test_expect_success 'submodule add' '
        test_cmp empty untracked
 '
 
+test_expect_success 'submodule add to .gitignored path' '
+       echo "refs/heads/master" >expect &&
+       >empty &&
+
+       (
+               cd addtest-ignore &&
+               # Does not use test_commit due to the ignore
+               echo "*" > .gitignore &&
+               git add --force .gitignore &&
+               git commit -m"Ignore everything" &&
+               git submodule add "$submodurl" submod &&
+               git submodule init
+       ) &&
+
+       rm -f heads head untracked &&
+       inspect addtest/submod ../.. &&
+       test_cmp expect heads &&
+       test_cmp expect head &&
+       test_cmp empty untracked
+'
+
 test_expect_success 'submodule add --branch' '
        echo "refs/heads/initial" >expect-head &&
        cat <<-\EOF >expect-heads &&
index 9a21f783d3a5fedaa56df26919ab8e0456872e90..4a7b8933f4bf1036ba1e044d6e2dc54d72084039 100755 (executable)
@@ -45,7 +45,7 @@ test_expect_success setup '
         git commit -m sub-b) &&
        git add sub &&
        test_tick &&
-       git commit -m b
+       git commit -m b &&
 
        git checkout -b c a &&
        git merge -s ours b &&
index 2a527750ce4a81bc168b8ad3d8b09174f487b142..db9365b6454b18eb07f5c0798e13e18d696498c6 100755 (executable)
@@ -59,11 +59,13 @@ test_expect_success 'setup a submodule tree' '
 sub1sha1=$(cd super/sub1 && git rev-parse HEAD)
 sub3sha1=$(cd super/sub3 && git rev-parse HEAD)
 
+pwd=$(pwd)
+
 cat > expect <<EOF
 Entering 'sub1'
-foo1-sub1-$sub1sha1
+$pwd/clone-foo1-sub1-$sub1sha1
 Entering 'sub3'
-foo3-sub3-$sub3sha1
+$pwd/clone-foo3-sub3-$sub3sha1
 EOF
 
 test_expect_success 'test basic "submodule foreach" usage' '
@@ -71,7 +73,9 @@ test_expect_success 'test basic "submodule foreach" usage' '
        (
                cd clone &&
                git submodule update --init -- sub1 sub3 &&
-               git submodule foreach "echo \$name-\$path-\$sha1" > ../actual
+               git submodule foreach "echo \$toplevel-\$name-\$path-\$sha1" > ../actual &&
+               git config foo.bar zar &&
+               git submodule foreach "git config --file \"\$toplevel/.git/config\" foo.bar"
        ) &&
        test_cmp expect actual
 '
index 95044668ee182fc2c1091fba7680e0576f7854bd..ac2e187a5720d1ff947e58073dd6cc403ef40d5d 100755 (executable)
@@ -4,8 +4,76 @@ test_description='git commit porcelain-ish'
 
 . ./test-lib.sh
 
+# Arguments: [<prefix] [<commit message>] [<commit options>]
+check_summary_oneline() {
+       test_tick &&
+       git commit ${3+"$3"} -m "$2" | head -1 > act &&
+
+       # branch name
+       SUMMARY_PREFIX="$(git name-rev --name-only HEAD)" &&
+
+       # append the "special" prefix, like "root-commit", "detached HEAD"
+       if test -n "$1"
+       then
+               SUMMARY_PREFIX="$SUMMARY_PREFIX ($1)"
+       fi
+
+       # abbrev SHA-1
+       SUMMARY_POSTFIX="$(git log -1 --pretty='format:%h')"
+       echo "[$SUMMARY_PREFIX $SUMMARY_POSTFIX] $2" >exp &&
+
+       test_cmp exp act
+}
+
+test_expect_success 'output summary format' '
+
+       echo new >file1 &&
+       git add file1 &&
+       check_summary_oneline "root-commit" "initial" &&
+
+       echo change >>file1 &&
+       git add file1 &&
+       check_summary_oneline "" "a change"
+'
+
+test_expect_success 'output summary format for commit with an empty diff' '
+
+       check_summary_oneline "" "empty" "--allow-empty"
+'
+
+test_expect_success 'output summary format for merges' '
+
+       git checkout -b recursive-base &&
+       test_commit base file1 &&
+
+       git checkout -b recursive-a recursive-base &&
+       test_commit commit-a file1 &&
+
+       git checkout -b recursive-b recursive-base &&
+       test_commit commit-b file1 &&
+
+       # conflict
+       git checkout recursive-a &&
+       test_must_fail git merge recursive-b &&
+       # resolve the conflict
+       echo commit-a > file1 &&
+       git add file1 &&
+       check_summary_oneline "" "Merge"
+'
+
+output_tests_cleanup() {
+       # this is needed for "do not fire editor in the presence of conflicts"
+       git checkout master &&
+
+       # this is needed for the "partial removal" test to pass
+       git rm file1 &&
+       git commit -m "cleanup"
+}
+
 test_expect_success 'the basics' '
 
+       output_tests_cleanup &&
+
        echo doing partial >"commit is" &&
        mkdir not &&
        echo very much encouraged but we should >not/forbid &&
index 008d5711b818a315136290c141c830cdf5af80a0..a72fe3ae640378350102a07124aee201fb1c637b 100755 (executable)
@@ -107,13 +107,32 @@ A  dir2/added
 ?? untracked
 EOF
 
-test_expect_success 'status -s (2)' '
+test_expect_success 'status -s' '
 
        git status -s >output &&
        test_cmp expect output
 
 '
 
+cat >expect <<\EOF
+## master
+ M dir1/modified
+A  dir2/added
+?? dir1/untracked
+?? dir2/modified
+?? dir2/untracked
+?? expect
+?? output
+?? untracked
+EOF
+
+test_expect_success 'status -s -b' '
+
+       git status -s -b >output &&
+       test_cmp expect output
+
+'
+
 cat >expect <<EOF
 # On branch master
 # Changes to be committed:
@@ -436,6 +455,25 @@ test_expect_success 'status -s with color.status' '
 
 '
 
+cat >expect <<\EOF
+## <GREEN>master<RESET>
+ <RED>M<RESET> dir1/modified
+<GREEN>A<RESET>  dir2/added
+<BLUE>??<RESET> dir1/untracked
+<BLUE>??<RESET> dir2/modified
+<BLUE>??<RESET> dir2/untracked
+<BLUE>??<RESET> expect
+<BLUE>??<RESET> output
+<BLUE>??<RESET> untracked
+EOF
+
+test_expect_success 'status -s -b with color.status' '
+
+       git status -s -b | test_decode_color >output &&
+       test_cmp expect output
+
+'
+
 cat >expect <<\EOF
  M dir1/modified
 A  dir2/added
@@ -469,6 +507,13 @@ test_expect_success 'status --porcelain ignores color.status' '
 git config --unset color.status
 git config --unset color.ui
 
+test_expect_success 'status --porcelain ignores -b' '
+
+       git status --porcelain -b >output &&
+       test_cmp expect output
+
+'
+
 cat >expect <<\EOF
 # On branch master
 # Changes to be committed:
@@ -763,4 +808,131 @@ test_expect_success POSIXPERM 'status succeeds in a read-only repository' '
        (exit $status)
 '
 
+cat > expect << EOF
+# On branch master
+# Changed but not updated:
+#   (use "git add <file>..." to update what will be committed)
+#   (use "git checkout -- <file>..." to discard changes in working directory)
+#
+#      modified:   dir1/modified
+#
+# Untracked files:
+#   (use "git add <file>..." to include in what will be committed)
+#
+#      dir1/untracked
+#      dir2/modified
+#      dir2/untracked
+#      expect
+#      output
+#      untracked
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
+
+test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
+       echo modified > sm/untracked &&
+       git status --ignore-submodules=untracked > output &&
+       test_cmp expect output
+'
+
+test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
+       git status --ignore-submodules=dirty > output &&
+       test_cmp expect output
+'
+
+test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
+       echo modified > sm/foo &&
+       git status --ignore-submodules=dirty > output &&
+       test_cmp expect output
+'
+
+cat > expect << EOF
+# On branch master
+# Changed but not updated:
+#   (use "git add <file>..." to update what will be committed)
+#   (use "git checkout -- <file>..." to discard changes in working directory)
+#   (commit or discard the untracked or modified content in submodules)
+#
+#      modified:   dir1/modified
+#      modified:   sm (modified content)
+#
+# Untracked files:
+#   (use "git add <file>..." to include in what will be committed)
+#
+#      dir1/untracked
+#      dir2/modified
+#      dir2/untracked
+#      expect
+#      output
+#      untracked
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
+
+test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
+       git status --ignore-submodules=untracked > output &&
+       test_cmp expect output
+'
+
+head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
+
+cat > expect << EOF
+# On branch master
+# Changed but not updated:
+#   (use "git add <file>..." to update what will be committed)
+#   (use "git checkout -- <file>..." to discard changes in working directory)
+#
+#      modified:   dir1/modified
+#      modified:   sm (new commits)
+#
+# Submodules changed but not updated:
+#
+# * sm $head...$head2 (1):
+#   > 2nd commit
+#
+# Untracked files:
+#   (use "git add <file>..." to include in what will be committed)
+#
+#      dir1/untracked
+#      dir2/modified
+#      dir2/untracked
+#      expect
+#      output
+#      untracked
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
+
+test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
+       git status --ignore-submodules=untracked > output &&
+       test_cmp expect output
+'
+
+test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
+       git status --ignore-submodules=dirty > output &&
+       test_cmp expect output
+'
+
+cat > expect << EOF
+# On branch master
+# Changed but not updated:
+#   (use "git add <file>..." to update what will be committed)
+#   (use "git checkout -- <file>..." to discard changes in working directory)
+#
+#      modified:   dir1/modified
+#
+# Untracked files:
+#   (use "git add <file>..." to include in what will be committed)
+#
+#      dir1/untracked
+#      dir2/modified
+#      dir2/untracked
+#      expect
+#      output
+#      untracked
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
+
+test_expect_success "--ignore-submodules=all suppresses submodule summary" '
+       git status --ignore-submodules=all > output &&
+       test_cmp expect output
+'
+
 test_done
index d52c060b061b3e0af9d9779366f4cc85a8009851..3ea33db6c73df763c22ccfab9f0cdcb2bbaef4d7 100755 (executable)
@@ -83,6 +83,52 @@ test_expect_success '--amend option copies authorship' '
        test_cmp expect actual
 '
 
+sha1_file() {
+       echo "$*" | sed "s#..#.git/objects/&/#"
+}
+remove_object() {
+       rm -f $(sha1_file "$*")
+}
+no_reflog() {
+       cp .git/config .git/config.saved &&
+       echo "[core] logallrefupdates = false" >>.git/config &&
+       test_when_finished "mv -f .git/config.saved .git/config" &&
+
+       if test -e .git/logs
+       then
+               mv .git/logs . &&
+               test_when_finished "mv logs .git/"
+       fi
+}
+
+test_expect_success '--amend option with empty author' '
+       git cat-file commit Initial >tmp &&
+       sed "s/author [^<]* </author  </" tmp >empty-author &&
+       no_reflog &&
+       sha=$(git hash-object -t commit -w empty-author) &&
+       test_when_finished "remove_object $sha" &&
+       git checkout $sha &&
+       test_when_finished "git checkout Initial" &&
+       echo "Empty author test" >>foo &&
+       test_tick &&
+       ! git commit -a -m "empty author" --amend 2>err &&
+       grep "empty ident" err
+'
+
+test_expect_success '--amend option with missing author' '
+       git cat-file commit Initial >tmp &&
+       sed "s/author [^<]* </author </" tmp >malformed &&
+       no_reflog &&
+       sha=$(git hash-object -t commit -w malformed) &&
+       test_when_finished "remove_object $sha" &&
+       git checkout $sha &&
+       test_when_finished "git checkout Initial" &&
+       echo "Missing author test" >>foo &&
+       test_tick &&
+       ! git commit -a -m "malformed author" --amend 2>err &&
+       grep "empty ident" err
+'
+
 test_expect_success '--reset-author makes the commit ours even with --amend option' '
        git checkout Initial &&
        echo "Test 6" >>foo &&
index 269cfdf267443f67ef8c6c921610bc856f4e506b..9114785ef7c850ae2d393bed3565e13f11339ba0 100755 (executable)
@@ -6,6 +6,15 @@ Testing merge when using a custom message for the merge commit.'
 
 . ./test-lib.sh
 
+create_merge_msgs() {
+       echo >exp.subject "custom message"
+
+       cp exp.subject exp.log &&
+       echo >>exp.log "" &&
+       echo >>exp.log "* commit 'c2':" &&
+       echo >>exp.log "  c2"
+}
+
 test_expect_success 'setup' '
        echo c0 > c0.c &&
        git add c0.c &&
@@ -19,16 +28,23 @@ test_expect_success 'setup' '
        echo c2 > c2.c &&
        git add c2.c &&
        git commit -m c2 &&
-       git tag c2
+       git tag c2 &&
+       create_merge_msgs
 '
 
 
 test_expect_success 'merge c2 with a custom message' '
        git reset --hard c1 &&
-       echo >expected "custom message" &&
-       git merge -m "custom message" c2 &&
+       git merge -m "$(cat exp.subject)" c2 &&
+       git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
+       test_cmp exp.subject actual
+'
+
+test_expect_success 'merge --log appends to custom message' '
+       git reset --hard c1 &&
+       git merge --log -m "$(cat exp.subject)" c2 &&
        git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
-       test_cmp expected actual
+       test_cmp exp.log actual
 '
 
 test_done
index 1de83ef98fdcbfd63469e66ba4886c2477b983ff..196827e7eacf0584379630f528fb7a4400f2b865 100755 (executable)
@@ -11,7 +11,7 @@ Testing basic diff tool invocation
 . ./test-lib.sh
 
 if ! test_have_prereq PERL; then
-       say 'skipping difftool tests, perl not available'
+       skip_all='skipping difftool tests, perl not available'
        test_done
 fi
 
index e249c3ed4176b4934ae57541ab8b671801968eae..8a6322765c965bfc3a9158cc14312fdf03295090 100755 (executable)
@@ -60,7 +60,7 @@ do
                        echo ${HC}file:5:foo_mmap bar mmap baz
                } >expected &&
                git grep -n -w -e mmap $H >actual &&
-               diff expected actual
+               test_cmp expected actual
        '
 
        test_expect_success "grep -w $L (w)" '
@@ -74,7 +74,7 @@ do
                        echo ${HC}x:1:x x xx x
                } >expected &&
                git grep -n -w -e "x xx* x" $H >actual &&
-               diff expected actual
+               test_cmp expected actual
        '
 
        test_expect_success "grep -w $L (y-1)" '
@@ -82,7 +82,7 @@ do
                        echo ${HC}y:1:y yy
                } >expected &&
                git grep -n -w -e "^y" $H >actual &&
-               diff expected actual
+               test_cmp expected actual
        '
 
        test_expect_success "grep -w $L (y-2)" '
@@ -93,7 +93,7 @@ do
                        cat actual
                        false
                else
-                       diff expected actual
+                       test_cmp expected actual
                fi
        '
 
@@ -105,14 +105,14 @@ do
                        cat actual
                        false
                else
-                       diff expected actual
+                       test_cmp expected actual
                fi
        '
 
        test_expect_success "grep $L (t-1)" '
                echo "${HC}t/t:1:test" >expected &&
                git grep -n -e test $H >actual &&
-               diff expected actual
+               test_cmp expected actual
        '
 
        test_expect_success "grep $L (t-2)" '
@@ -121,7 +121,7 @@ do
                        cd t &&
                        git grep -n -e test $H
                ) >actual &&
-               diff expected actual
+               test_cmp expected actual
        '
 
        test_expect_success "grep $L (t-3)" '
@@ -130,7 +130,7 @@ do
                        cd t &&
                        git grep --full-name -n -e test $H
                ) >actual &&
-               diff expected actual
+               test_cmp expected actual
        '
 
        test_expect_success "grep -c $L (no /dev/null)" '
diff --git a/t/t8006-blame-textconv.sh b/t/t8006-blame-textconv.sh
new file mode 100755 (executable)
index 0000000..9ad96d4
--- /dev/null
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+test_description='git blame textconv support'
+. ./test-lib.sh
+
+find_blame() {
+       sed -e 's/^[^(]*//'
+}
+
+cat >helper <<'EOF'
+#!/bin/sh
+sed 's/^/converted: /' "$@"
+EOF
+chmod +x helper
+
+test_expect_success 'setup ' '
+       echo test 1 >one.bin &&
+       echo test number 2 >two.bin &&
+       git add . &&
+       GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
+       echo test 1 version 2 >one.bin &&
+       echo test number 2 version 2 >>two.bin &&
+       GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
+'
+
+cat >expected <<EOF
+(Number2 2010-01-01 20:00:00 +0000 1) test 1 version 2
+EOF
+
+test_expect_success 'no filter specified' '
+       git blame one.bin >blame &&
+       find_blame Number2 <blame >result &&
+       test_cmp expected result
+'
+
+test_expect_success 'setup textconv filters' '
+       echo "*.bin diff=test" >.gitattributes &&
+       git config diff.test.textconv ./helper &&
+       git config diff.test.cachetextconv false
+'
+
+test_expect_success 'blame with --no-textconv' '
+       git blame --no-textconv one.bin >blame &&
+       find_blame <blame> result &&
+       test_cmp expected result
+'
+
+cat >expected <<EOF
+(Number2 2010-01-01 20:00:00 +0000 1) converted: test 1 version 2
+EOF
+
+test_expect_success 'basic blame on last commit' '
+       git blame one.bin >blame &&
+       find_blame  <blame >result &&
+       test_cmp expected result
+'
+
+cat >expected <<EOF
+(Number1 2010-01-01 18:00:00 +0000 1) converted: test number 2
+(Number2 2010-01-01 20:00:00 +0000 2) converted: test number 2 version 2
+EOF
+
+test_expect_success 'blame --textconv going through revisions' '
+       git blame --textconv two.bin >blame &&
+       find_blame <blame >result &&
+       test_cmp expected result
+'
+
+test_expect_success 'make a new commit' '
+       echo "test number 2 version 3" >>two.bin &&
+       GIT_AUTHOR_NAME=Number3 git commit -a -m Third --date="2010-01-01 22:00:00"
+'
+
+test_expect_success 'blame from previous revision' '
+       git blame HEAD^ two.bin >blame &&
+       find_blame <blame >result &&
+       test_cmp expected result
+'
+
+test_done
diff --git a/t/t8007-cat-file-textconv.sh b/t/t8007-cat-file-textconv.sh
new file mode 100755 (executable)
index 0000000..38ac05e
--- /dev/null
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+test_description='git cat-file textconv support'
+. ./test-lib.sh
+
+cat >helper <<'EOF'
+#!/bin/sh
+sed 's/^/converted: /' "$@"
+EOF
+chmod +x helper
+
+test_expect_success 'setup ' '
+       echo test >one.bin &&
+       git add . &&
+       GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
+       echo test version 2 >one.bin &&
+       GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
+'
+
+cat >expected <<EOF
+fatal: git cat-file --textconv: unable to run textconv on :one.bin
+EOF
+
+test_expect_success 'no filter specified' '
+       git cat-file --textconv :one.bin 2>result
+       test_cmp expected result
+'
+
+test_expect_success 'setup textconv filters' '
+       echo "*.bin diff=test" >.gitattributes &&
+       git config diff.test.textconv ./helper &&
+       git config diff.test.cachetextconv false
+'
+
+cat >expected <<EOF
+test version 2
+EOF
+
+test_expect_success 'cat-file without --textconv' '
+       git cat-file blob :one.bin >result &&
+       test_cmp expected result
+'
+
+cat >expected <<EOF
+test
+EOF
+
+test_expect_success 'cat-file without --textconv on previous commit' '
+       git cat-file -p HEAD^:one.bin >result &&
+       test_cmp expected result
+'
+
+cat >expected <<EOF
+converted: test version 2
+EOF
+
+test_expect_success 'cat-file --textconv on last commit' '
+       git cat-file --textconv :one.bin >result &&
+       test_cmp expected result
+'
+
+cat >expected <<EOF
+converted: test
+EOF
+
+test_expect_success 'cat-file --textconv on previous commit' '
+       git cat-file --textconv HEAD^:one.bin >result &&
+       test_cmp expected result
+'
+test_done
index 640b3d2bb41636e271d0d55aabeade38ded612bb..23597cc40751addd1473acd2edf7563e0a517c9e 100755 (executable)
@@ -4,7 +4,7 @@ test_description='git send-email'
 . ./test-lib.sh
 
 if ! test_have_prereq PERL; then
-       say 'skipping git send-email tests, perl not available'
+       skip_all='skipping git send-email tests, perl not available'
        test_done
 fi
 
@@ -58,7 +58,7 @@ test_no_confirm () {
 # Exit immediately to prevent hang if a no-confirm test fails
 check_no_confirm () {
        test -f no_confirm_okay || {
-               say 'No confirm test failed; skipping remaining tests to prevent hanging'
+               skip_all='confirm test failed; skipping remaining tests to prevent hanging'
                test_done
        }
 }
@@ -918,4 +918,81 @@ test_expect_success '--no-bcc overrides sendemail.bcc' '
        ! grep "RCPT TO:<other@ex.com>" stdout
 '
 
+cat >email-using-8bit <<EOF
+From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
+Message-Id: <bogus-message-id@example.com>
+From: author@example.com
+Date: Sat, 12 Jun 2010 15:53:58 +0200
+Subject: subject goes here
+
+Dieser deutsche Text enthält einen Umlaut!
+EOF
+
+cat >content-type-decl <<EOF
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+EOF
+
+test_expect_success 'asks about and fixes 8bit encodings' '
+       clean_fake_sendmail &&
+       echo |
+       git send-email --from=author@example.com --to=nobody@example.com \
+                       --smtp-server="$(pwd)/fake.sendmail" \
+                       email-using-8bit >stdout &&
+       grep "do not declare a Content-Transfer-Encoding" stdout &&
+       grep email-using-8bit stdout &&
+       grep "Which 8bit encoding" stdout &&
+       egrep "Content|MIME" msgtxt1 >actual &&
+       test_cmp actual content-type-decl
+'
+
+test_expect_success 'sendemail.8bitEncoding works' '
+       clean_fake_sendmail &&
+       git config sendemail.assume8bitEncoding UTF-8 &&
+       echo bogus |
+       git send-email --from=author@example.com --to=nobody@example.com \
+                       --smtp-server="$(pwd)/fake.sendmail" \
+                       email-using-8bit >stdout &&
+       egrep "Content|MIME" msgtxt1 >actual &&
+       test_cmp actual content-type-decl
+'
+
+test_expect_success '--8bit-encoding overrides sendemail.8bitEncoding' '
+       clean_fake_sendmail &&
+       git config sendemail.assume8bitEncoding "bogus too" &&
+       echo bogus |
+       git send-email --from=author@example.com --to=nobody@example.com \
+                       --smtp-server="$(pwd)/fake.sendmail" \
+                       --8bit-encoding=UTF-8 \
+                       email-using-8bit >stdout &&
+       egrep "Content|MIME" msgtxt1 >actual &&
+       test_cmp actual content-type-decl
+'
+
+cat >email-using-8bit <<EOF
+From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
+Message-Id: <bogus-message-id@example.com>
+From: author@example.com
+Date: Sat, 12 Jun 2010 15:53:58 +0200
+Subject: Dieser Betreff enthält auch einen Umlaut!
+
+Nothing to see here.
+EOF
+
+cat >expected <<EOF
+Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
+EOF
+
+test_expect_success '--8bit-encoding also treats subject' '
+       clean_fake_sendmail &&
+       echo bogus |
+       git send-email --from=author@example.com --to=nobody@example.com \
+                       --smtp-server="$(pwd)/fake.sendmail" \
+                       --8bit-encoding=UTF-8 \
+                       email-using-8bit >stdout &&
+       grep "Subject" msgtxt1 >actual &&
+       test_cmp expected actual
+'
+
 test_done
index 570e0359e4739e178b1836887c53ddd78e3c8ec0..13766ab160e48d2b2ecb6e95079077e4a0704c2c 100755 (executable)
@@ -15,7 +15,7 @@ case "$GIT_SVN_LC_ALL" in
        test_set_prereq UTF8
        ;;
 *)
-       say "UTF-8 locale not set, some tests skipped ($GIT_SVN_LC_ALL)"
+       say "UTF-8 locale not set, some tests skipped ($GIT_SVN_LC_ALL)"
        ;;
 esac
 
index 7d7acc30b4a64ba97afe06e03c65ebca4ca7f242..63fc982c8cdbd9c19eb06bba58ad5e86da5dd03e 100755 (executable)
@@ -28,48 +28,52 @@ test_expect_success 'setup svnrepo' '
        svn_cmd cp -m "trailing .lock" "$svnrepo/pr ject/trunk" \
                        "$svnrepo/pr ject/branches/trailing_dotlock.lock" &&
        svn_cmd cp -m "reflog" "$svnrepo/pr ject/trunk" \
-                       "$svnrepo/pr ject/branches/not-a@{0}reflog" &&
+                       "$svnrepo/pr ject/branches/not-a%40{0}reflog" &&
        start_httpd
        '
 
 test_expect_success 'test clone with funky branch names' '
        git svn clone -s "$svnrepo/pr ject" project &&
-       cd project &&
+       (
+               cd project &&
                git rev-parse "refs/remotes/fun%20plugin" &&
                git rev-parse "refs/remotes/more%20fun%20plugin!" &&
                git rev-parse "refs/remotes/$scary_ref" &&
                git rev-parse "refs/remotes/%2Eleading_dot" &&
                git rev-parse "refs/remotes/trailing_dot%2E" &&
                git rev-parse "refs/remotes/trailing_dotlock%2Elock" &&
-               git rev-parse "refs/remotes/not-a%40{0}reflog" &&
-       cd ..
+               git rev-parse "refs/remotes/not-a%40{0}reflog"
+       )
        '
 
 test_expect_success 'test dcommit to funky branch' "
-       cd project &&
-       git reset --hard 'refs/remotes/more%20fun%20plugin!' &&
-       echo hello >> foo &&
-       git commit -m 'hello' -- foo &&
-       git svn dcommit &&
-       cd ..
+       (
+               cd project &&
+               git reset --hard 'refs/remotes/more%20fun%20plugin!' &&
+               echo hello >> foo &&
+               git commit -m 'hello' -- foo &&
+               git svn dcommit
+       )
        "
 
 test_expect_success 'test dcommit to scary branch' '
-       cd project &&
-       git reset --hard "refs/remotes/$scary_ref" &&
-       echo urls are scary >> foo &&
-       git commit -m "eep" -- foo &&
-       git svn dcommit &&
-       cd ..
+       (
+               cd project &&
+               git reset --hard "refs/remotes/$scary_ref" &&
+               echo urls are scary >> foo &&
+               git commit -m "eep" -- foo &&
+               git svn dcommit
+       )
        '
 
 test_expect_success 'test dcommit to trailing_dotlock branch' '
-       cd project &&
-       git reset --hard "refs/remotes/trailing_dotlock%2Elock" &&
-       echo who names branches like this anyway? >> foo &&
-       git commit -m "bar" -- foo &&
-       git svn dcommit &&
-       cd ..
+       (
+               cd project &&
+               git reset --hard "refs/remotes/trailing_dotlock%2Elock" &&
+               echo who names branches like this anyway? >> foo &&
+               git commit -m "bar" -- foo &&
+               git svn dcommit
+       )
        '
 
 stop_httpd
index a9a558d292231bd4b372552df0364c63ece25299..5fb94fb3d61c2e26dcd448ac5106ec0f9a3a2283 100755 (executable)
@@ -13,7 +13,7 @@ case $v in
 1.[456].*)
        ;;
 *)
-       say "skipping svn-info test (SVN version: $v not supported)"
+       skip_all="skipping svn-info test (SVN version: $v not supported)"
        test_done
        ;;
 esac
index b9224bdb20a397f40f1504684e1144428cf8a24e..8cfdfe790f1e0bb7cd0ddb72a72a55073368ec60 100755 (executable)
@@ -14,10 +14,22 @@ compare_git_head_with () {
        test_cmp current "$1"
 }
 
+a_utf8_locale=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{
+       p
+       q
+}')
+
+if test -n "$a_utf8_locale"
+then
+       test_set_prereq UTF8
+else
+       say "# UTF-8 locale not available, some tests are skipped"
+fi
+
 compare_svn_head_with () {
        # extract just the log message and strip out committer info.
        # don't use --limit here since svn 1.1.x doesn't have it,
-       LC_ALL=en_US.UTF-8 svn log `git svn info --url` | perl -w -e '
+       LC_ALL="$a_utf8_locale" svn log `git svn info --url` | perl -w -e '
                use bytes;
                $/ = ("-"x72) . "\n";
                my @x = <STDIN>;
@@ -69,12 +81,6 @@ do
        '
 done
 
-if locale -a |grep -q en_US.utf8; then
-       test_set_prereq UTF8
-else
-       say "UTF-8 locale not available, test skipped"
-fi
-
 test_expect_success UTF8 'ISO-8859-1 should match UTF-8 in svn' '
        (
                cd ISO8859-1 &&
index 99f69c6a0b8c7d3eea5211db333d0be41f9f5fa4..337ea59711ac7aca78a27afb92693f88e98aed9d 100755 (executable)
@@ -43,7 +43,7 @@ then
                 gunzip .git/svn/refs/remotes/git-svn/unhandled.log.gz
                '
 else
-       say "Perl Compress::Zlib unavailable, skipping gunzip test"
+       say "Perl Compress::Zlib unavailable, skipping gunzip test"
 fi
 
 test_expect_success 'git svn gc does not change unhandled.log files' '
index fc3795dc98803bd98e2ebd6f38a249c331038d54..ee39b36d78a9d5602be5d48ae34b1e5ce4927c79 100755 (executable)
@@ -7,14 +7,14 @@ test_description='Test export of commits to CVS'
 . ./test-lib.sh
 
 if ! test_have_prereq PERL; then
-       say 'skipping git cvsexportcommit tests, perl not available'
+       skip_all='skipping git cvsexportcommit tests, perl not available'
        test_done
 fi
 
 cvs >/dev/null 2>&1
 if test $? -ne 1
 then
-    say 'skipping git cvsexportcommit tests, cvs not found'
+    skip_all='skipping git cvsexportcommit tests, cvs not found'
     test_done
 fi
 
@@ -63,10 +63,10 @@ test_expect_success \
      check_entries B "newfile2.txt/1.1/" &&
      check_entries C "newfile3.png/1.1/-kb" &&
      check_entries D "newfile4.png/1.1/-kb" &&
-     diff A/newfile1.txt ../A/newfile1.txt &&
-     diff B/newfile2.txt ../B/newfile2.txt &&
-     diff C/newfile3.png ../C/newfile3.png &&
-     diff D/newfile4.png ../D/newfile4.png
+     test_cmp A/newfile1.txt ../A/newfile1.txt &&
+     test_cmp B/newfile2.txt ../B/newfile2.txt &&
+     test_cmp C/newfile3.png ../C/newfile3.png &&
+     test_cmp D/newfile4.png ../D/newfile4.png
      )'
 
 test_expect_success \
@@ -89,10 +89,10 @@ test_expect_success \
      check_entries D "newfile4.png/1.2/-kb" &&
      check_entries E "newfile5.txt/1.1/" &&
      check_entries F "newfile6.png/1.1/-kb" &&
-     diff A/newfile1.txt ../A/newfile1.txt &&
-     diff D/newfile4.png ../D/newfile4.png &&
-     diff E/newfile5.txt ../E/newfile5.txt &&
-     diff F/newfile6.png ../F/newfile6.png
+     test_cmp A/newfile1.txt ../A/newfile1.txt &&
+     test_cmp D/newfile4.png ../D/newfile4.png &&
+     test_cmp E/newfile5.txt ../E/newfile5.txt &&
+     test_cmp F/newfile6.png ../F/newfile6.png
      )'
 
 # Should fail (but only on the git cvsexportcommit stage)
@@ -137,9 +137,9 @@ test_expect_success \
      check_entries D "" &&
      check_entries E "newfile5.txt/1.1/" &&
      check_entries F "newfile6.png/1.1/-kb" &&
-     diff A/newfile1.txt ../A/newfile1.txt &&
-     diff E/newfile5.txt ../E/newfile5.txt &&
-     diff F/newfile6.png ../F/newfile6.png
+     test_cmp A/newfile1.txt ../A/newfile1.txt &&
+     test_cmp E/newfile5.txt ../E/newfile5.txt &&
+     test_cmp F/newfile6.png ../F/newfile6.png
      )'
 
 test_expect_success \
@@ -155,8 +155,8 @@ test_expect_success \
      check_entries D "" &&
      check_entries E "newfile5.txt/1.1/" &&
      check_entries F "newfile6.png/1.1/-kb" &&
-     diff E/newfile5.txt ../E/newfile5.txt &&
-     diff F/newfile6.png ../F/newfile6.png
+     test_cmp E/newfile5.txt ../E/newfile5.txt &&
+     test_cmp F/newfile6.png ../F/newfile6.png
      )'
 
 test_expect_success \
index daef2d6c230fb617395feeff6cf330b74ad57832..36c457e7f2312774223f853aab0e3b055659e916 100755 (executable)
@@ -11,17 +11,17 @@ cvs CLI client via git-cvsserver server'
 . ./test-lib.sh
 
 if ! test_have_prereq PERL; then
-       say 'skipping git cvsserver tests, perl not available'
+       skip_all='skipping git cvsserver tests, perl not available'
        test_done
 fi
 cvs >/dev/null 2>&1
 if test $? -ne 1
 then
-    say 'skipping git-cvsserver tests, cvs not found'
+    skip_all='skipping git-cvsserver tests, cvs not found'
     test_done
 fi
 "$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
-    say 'skipping git-cvsserver tests, Perl SQLite interface unavailable'
+    skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
     test_done
 }
 
@@ -48,7 +48,9 @@ test_expect_success 'setup' '
   git pull secondroot master &&
   git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
   GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
-  GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log"
+  GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" &&
+  GIT_DIR="$SERVERDIR" git config gitcvs.authdb "$SERVERDIR/auth.db" &&
+  echo cvsuser:cvGVEarMLnhlA > "$SERVERDIR/auth.db"
 '
 
 # note that cvs doesn't accept absolute pathnames
@@ -94,6 +96,14 @@ git
 END VERIFICATION REQUEST
 EOF
 
+cat >login-git-ok <<EOF
+BEGIN VERIFICATION REQUEST
+$SERVERDIR
+cvsuser
+Ah<Z:yZZ30 e
+END VERIFICATION REQUEST
+EOF
+
 test_expect_success 'pserver authentication' \
   'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
    sed -ne \$p log | grep "^I LOVE YOU\$"'
@@ -107,6 +117,10 @@ test_expect_success 'pserver authentication failure (non-anonymous user)' \
    fi &&
    sed -ne \$p log | grep "^I HATE YOU\$"'
 
+test_expect_success 'pserver authentication success (non-anonymous user with password)' \
+  'cat login-git-ok | git-cvsserver pserver >log 2>&1 &&
+   sed -ne \$p log | grep "^I LOVE YOU\$"'
+
 test_expect_success 'pserver authentication (login)' \
   'cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
    sed -ne \$p log | grep "^I LOVE YOU\$"'
@@ -435,7 +449,7 @@ test_expect_success 'cvs update (-p)' '
     rm -f failures &&
     for i in merge no-lf empty really-empty; do
         GIT_CONFIG="$git_config" cvs update -p "$i" >$i.out
-        diff $i.out ../$i >>failures 2>&1
+       test_cmp $i.out ../$i >>failures 2>&1
     done &&
     test -z "$(cat failures)"
 '
index ed7b513f3e82706f6455bb32f4f19a5161bb0415..925bd0fbedf9865cef834460969c0a9fd2262437 100755 (executable)
@@ -41,16 +41,16 @@ not_present() {
 cvs >/dev/null 2>&1
 if test $? -ne 1
 then
-    say 'skipping git-cvsserver tests, cvs not found'
+    skip_all='skipping git-cvsserver tests, cvs not found'
     test_done
 fi
 if ! test_have_prereq PERL
 then
-    say 'skipping git-cvsserver tests, perl not available'
+    skip_all='skipping git-cvsserver tests, perl not available'
     test_done
 fi
 "$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
-    say 'skipping git-cvsserver tests, Perl SQLite interface unavailable'
+    skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
     test_done
 }
 
index 63b6b060e64948771319294251838394264c84a9..4f2b9b062b08302aedab42dcdd0a33776559c05e 100755 (executable)
@@ -647,4 +647,33 @@ test_expect_success \
         gitweb_run "p=.git;a=summary"'
 test_debug 'cat gitweb.log'
 
+# ----------------------------------------------------------------------
+# syntax highlighting
+
+cat >>gitweb_config.perl <<\EOF
+$feature{'highlight'}{'override'} = 1;
+EOF
+
+highlight --version >/dev/null 2>&1
+if [ $? -eq 127 ]; then
+       say "Skipping syntax highlighting test, because 'highlight' was not found"
+else
+       test_set_prereq HIGHLIGHT
+fi
+
+test_expect_success HIGHLIGHT \
+       'syntax highlighting (no highlight)' \
+       'git config gitweb.highlight yes &&
+        gitweb_run "p=.git;a=blob;f=file"'
+test_debug 'cat gitweb.log'
+
+test_expect_success HIGHLIGHT \
+       'syntax highlighting (highlighted)' \
+       'git config gitweb.highlight yes &&
+        echo "#!/usr/bin/sh" > test.sh &&
+        git add test.sh &&
+        git commit -m "Add test.sh" &&
+        gitweb_run "p=.git;a=blob;f=test.sh"'
+test_debug 'cat gitweb.log'
+
 test_done
index b572ce3ab7f55e1258aa92b37e10a0d067c9d01d..2eff9cd68ce2f51618159df402bfb46382d44434 100755 (executable)
@@ -4,7 +4,7 @@ test_description='git cvsimport basic tests'
 . ./lib-cvs.sh
 
 if ! test_have_prereq PERL; then
-       say 'skipping git cvsimport tests, perl not available'
+       skip_all='skipping git cvsimport tests, perl not available'
        test_done
 fi
 
index 8686086dde9dba742bd805c31f3e28c658b03a9b..3787186703f51f75103824f562c3849483ceaae1 100755 (executable)
@@ -7,12 +7,12 @@ test_description='perl interface (Git.pm)'
 . ./test-lib.sh
 
 if ! test_have_prereq PERL; then
-       say 'skipping perl interface tests, perl not available'
+       skip_all='skipping perl interface tests, perl not available'
        test_done
 fi
 
 "$PERL_PATH" -MTest::More -e 0 2>/dev/null || {
-       say "Perl Test::More unavailable, skipping test"
+       skip_all="Perl Test::More unavailable, skipping test"
        test_done
 }
 
@@ -46,6 +46,9 @@ test_expect_success \
      git config --add test.int 2k
      '
 
+# The external test will outputs its own plan
+test_external_has_tap=1
+
 test_external_without_stderr \
     'Perl API' \
     "$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl
index 666722d9bf1050522a687f4af95792a8e0ec5d64..671f38db2bb78c076b281602ca5b87f10fdf4d00 100755 (executable)
@@ -7,6 +7,13 @@ use strict;
 
 use Test::More qw(no_plan);
 
+BEGIN {
+       # t9700-perl-git.sh kicks off our testing, so we have to go from
+       # there.
+       Test::More->builder->current_test(1);
+       Test::More->builder->no_ending(1);
+}
+
 use Cwd;
 use File::Basename;
 
@@ -105,3 +112,8 @@ my $last_commit = $r2->command_oneline(qw(rev-parse --verify HEAD));
 like($last_commit, qr/^[0-9a-fA-F]{40}$/, 'rev-parse returned hash');
 my $dir_commit = $r2->command_oneline('log', '-n1', '--pretty=format:%H', '.');
 isnt($last_commit, $dir_commit, 'log . does not show last commit');
+
+printf "1..%d\n", Test::More->builder->current_test;
+
+my $is_passing = eval { Test::More->is_passing };
+exit($is_passing ? 0 : 1) unless $@ =~ /Can't locate object method/;
index 454880ac7d281d901156136900814dee9aae46c5..db8371cb170c5924512a5626681f485ea3cf6884 100644 (file)
@@ -75,7 +75,6 @@ export GIT_MERGE_VERBOSITY
 export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
 export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
 export EDITOR
-GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
 
 # Protect ourselves from common misconfiguration to export
 # CDPATH into the environment
@@ -161,7 +160,7 @@ if test -n "$color"; then
                        *) test -n "$quiet" && return;;
                esac
                shift
-               printf "%s" "$*"
+               printf "%s" "$*"
                tput sgr0
                echo
                )
@@ -170,7 +169,7 @@ else
        say_color() {
                test -z "$1" && test -n "$quiet" && return
                shift
-               echo "$*"
+               echo "$*"
        }
 fi
 
@@ -207,6 +206,8 @@ test_fixed=0
 test_broken=0
 test_success=0
 
+test_external_has_tap=0
+
 die () {
        code=$?
        if test -n "$GIT_EXIT_OK"
@@ -340,25 +341,25 @@ test_have_prereq () {
 
 test_ok_ () {
        test_success=$(($test_success + 1))
-       say_color "" "  ok $test_count: $@"
+       say_color "" "ok $test_count - $@"
 }
 
 test_failure_ () {
        test_failure=$(($test_failure + 1))
-       say_color error "FAIL $test_count: $1"
+       say_color error "not ok - $test_count $1"
        shift
-       echo "$@" | sed -e 's/^/        /'
+       echo "$@" | sed -e 's/^/#       /'
        test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
 }
 
 test_known_broken_ok_ () {
        test_fixed=$(($test_fixed+1))
-       say_color "" "  FIXED $test_count: $@"
+       say_color "" "ok $test_count - $@ # TODO known breakage"
 }
 
 test_known_broken_failure_ () {
        test_broken=$(($test_broken+1))
-       say_color skip "  still broken $test_count: $@"
+       say_color skip "not ok $test_count - $@ # TODO known breakage"
 }
 
 test_debug () {
@@ -370,6 +371,9 @@ test_run_ () {
        eval >&3 2>&4 "$1"
        eval_ret=$?
        eval >&3 2>&4 "$test_cleanup"
+       if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then
+               echo ""
+       fi
        return 0
 }
 
@@ -381,6 +385,7 @@ test_skip () {
                case $this_test.$test_count in
                $skp)
                        to_skip=t
+                       break
                esac
        done
        if test -z "$to_skip" && test -n "$prereq" &&
@@ -391,7 +396,7 @@ test_skip () {
        case "$to_skip" in
        t)
                say_color skip >&3 "skipping test: $@"
-               say_color skip "skip $test_count: $1"
+               say_color skip "ok $test_count # skip $1"
                : true
                ;;
        *)
@@ -457,7 +462,7 @@ test_expect_code () {
 # test_external runs external test scripts that provide continuous
 # test output about their progress, and succeeds/fails on
 # zero/non-zero exit code.  It outputs the test output on stdout even
-# in non-verbose mode, and announces the external script with "* run
+# in non-verbose mode, and announces the external script with "# run
 # <n>: ..." before running it.  When providing relative paths, keep in
 # mind that all scripts run in "trash directory".
 # Usage: test_external description command arguments...
@@ -472,7 +477,7 @@ test_external () {
        then
                # Announce the script to reduce confusion about the
                # test output that follows.
-               say_color "" " run $test_count: $descr ($*)"
+               say_color "" "# run $test_count: $descr ($*)"
                # Export TEST_DIRECTORY, TRASH_DIRECTORY and GIT_TEST_LONG
                # to be able to use them in script
                export TEST_DIRECTORY TRASH_DIRECTORY GIT_TEST_LONG
@@ -482,9 +487,19 @@ test_external () {
                "$@" 2>&4
                if [ "$?" = 0 ]
                then
-                       test_ok_ "$descr"
+                       if test $test_external_has_tap -eq 0; then
+                               test_ok_ "$descr"
+                       else
+                               say_color "" "# test_external test $descr was ok"
+                               test_success=$(($test_success + 1))
+                       fi
                else
-                       test_failure_ "$descr" "$@"
+                       if test $test_external_has_tap -eq 0; then
+                               test_failure_ "$descr" "$@"
+                       else
+                               say_color error "# test_external test $descr failed: $@"
+                               test_failure=$(($test_failure + 1))
+                       fi
                fi
        fi
 }
@@ -500,19 +515,30 @@ test_external_without_stderr () {
        [ -f "$stderr" ] || error "Internal error: $stderr disappeared."
        descr="no stderr: $1"
        shift
-       say >&3 "expecting no stderr from previous command"
+       say >&3 "expecting no stderr from previous command"
        if [ ! -s "$stderr" ]; then
                rm "$stderr"
-               test_ok_ "$descr"
+
+               if test $test_external_has_tap -eq 0; then
+                       test_ok_ "$descr"
+               else
+                       say_color "" "# test_external_without_stderr test $descr was ok"
+                       test_success=$(($test_success + 1))
+               fi
        else
                if [ "$verbose" = t ]; then
-                       output=`echo; echo Stderr is:; cat "$stderr"`
+                       output=`echo; echo "# Stderr is:"; cat "$stderr"`
                else
                        output=
                fi
                # rm first in case test_failure exits.
                rm "$stderr"
-               test_failure_ "$descr" "$@" "$output"
+               if test $test_external_has_tap -eq 0; then
+                       test_failure_ "$descr" "$@" "$output"
+               else
+                       say_color error "# test_external_without_stderr test $descr failed: $@: $output"
+                       test_failure=$(($test_failure + 1))
+               fi
        fi
 }
 
@@ -621,18 +647,24 @@ test_done () {
 
        if test "$test_fixed" != 0
        then
-               say_color pass "fixed $test_fixed known breakage(s)"
+               say_color pass "fixed $test_fixed known breakage(s)"
        fi
        if test "$test_broken" != 0
        then
-               say_color error "still have $test_broken known breakage(s)"
+               say_color error "still have $test_broken known breakage(s)"
                msg="remaining $(($test_count-$test_broken)) test(s)"
        else
                msg="$test_count test(s)"
        fi
        case "$test_failure" in
        0)
-               say_color pass "passed all $msg"
+               # Maybe print SKIP message
+               [ -z "$skip_all" ] || skip_all=" # SKIP $skip_all"
+
+               if test $test_external_has_tap -eq 0; then
+                       say_color pass "# passed all $msg"
+                       say "1..$test_count$skip_all"
+               fi
 
                test -d "$remove_trash" &&
                cd "$(dirname "$remove_trash")" &&
@@ -641,7 +673,11 @@ test_done () {
                exit 0 ;;
 
        *)
-               say_color error "failed $test_failure among $msg"
+               if test $test_external_has_tap -eq 0; then
+                       say_color error "# failed $test_failure among $msg"
+                       say "1..$test_count"
+               fi
+
                exit 1 ;;
 
        esac
@@ -740,6 +776,16 @@ export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOB
 
 . ../GIT-BUILD-OPTIONS
 
+if test -z "$GIT_TEST_CMP"
+then
+       if test -n "$GIT_TEST_CMP_USE_COPIED_CONTEXT"
+       then
+               GIT_TEST_CMP="$DIFF -c"
+       else
+               GIT_TEST_CMP="$DIFF -u"
+       fi
+fi
+
 GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
 export GITPERLLIB
 test -d ../templates/blt || {
@@ -784,18 +830,10 @@ this_test=${0##*/}
 this_test=${this_test%%-*}
 for skp in $GIT_SKIP_TESTS
 do
-       to_skip=
-       for skp in $GIT_SKIP_TESTS
-       do
-               case "$this_test" in
-               $skp)
-                       to_skip=t
-               esac
-       done
-       case "$to_skip" in
-       t)
+       case "$this_test" in
+       $skp)
                say_color skip >&3 "skipping test $this_test altogether"
-               say_color skip "skip all tests in $this_test"
+               skip_all="skip all tests in $this_test"
                test_done
        esac
 done
index a9e705f79a148790f4de55c7918dc9c669382a4f..6bcd5b03c078bc532e074ef8e8775a51d0eef219 100644 (file)
@@ -20,13 +20,16 @@ static void parse_dates(char **argv, struct timeval *now)
 {
        for (; *argv; argv++) {
                char result[100];
-               time_t t;
+               unsigned long t;
+               int tz;
 
                result[0] = 0;
                parse_date(*argv, result, sizeof(result));
-               t = strtoul(result, NULL, 0);
-               printf("%s -> %s\n", *argv,
-                       t ? show_date(t, 0, DATE_ISO8601) : "bad");
+               if (sscanf(result, "%lu %d", &t, &tz) == 2)
+                       printf("%s -> %s\n",
+                              *argv, show_date(t, tz, DATE_ISO8601));
+               else
+                       printf("%s -> bad\n", *argv);
        }
 }
 
diff --git a/trace.c b/trace.c
index 4229ae1231d69aedd9f1aa8350989ddbe2bdb845..1e560cb0b977e19beeb095497c8e4f6280b7f0d6 100644 (file)
--- a/trace.c
+++ b/trace.c
 #include "cache.h"
 #include "quote.h"
 
+void do_nothing(size_t unused)
+{
+}
+
 /* Get a trace file descriptor from GIT_TRACE env variable. */
 static int get_trace_fd(int *need_close)
 {
@@ -72,6 +76,7 @@ void trace_printf(const char *fmt, ...)
        if (!fd)
                return;
 
+       set_try_to_free_routine(do_nothing);    /* is never reset */
        strbuf_init(&buf, 64);
        va_start(ap, fmt);
        len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
@@ -103,6 +108,7 @@ void trace_argv_printf(const char **argv, const char *fmt, ...)
        if (!fd)
                return;
 
+       set_try_to_free_routine(do_nothing);    /* is never reset */
        strbuf_init(&buf, 64);
        va_start(ap, fmt);
        len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
index 8ce39364a1e58b338bc45a4eb524b637ce3a8881..4dba6f8815a80093a8ac9edc226d99bba1bb6394 100644 (file)
@@ -9,6 +9,7 @@
 #include "dir.h"
 #include "refs.h"
 #include "branch.h"
+#include "url.h"
 
 /* rsync support */
 
@@ -871,54 +872,6 @@ static int is_file(const char *url)
        return S_ISREG(buf.st_mode);
 }
 
-static int isurlschemechar(int first_flag, int ch)
-{
-       /*
-        * The set of valid URL schemes, as per STD66 (RFC3986) is
-        * '[A-Za-z][A-Za-z0-9+.-]*'. But use sightly looser check
-        * of '[A-Za-z0-9][A-Za-z0-9+.-]*' because earlier version
-        * of check used '[A-Za-z0-9]+' so not to break any remote
-        * helpers.
-        */
-       int alphanumeric, special;
-       alphanumeric = ch > 0 && isalnum(ch);
-       special = ch == '+' || ch == '-' || ch == '.';
-       return alphanumeric || (!first_flag && special);
-}
-
-static int is_url(const char *url)
-{
-       const char *url2, *first_slash;
-
-       if (!url)
-               return 0;
-       url2 = url;
-       first_slash = strchr(url, '/');
-
-       /* Input with no slash at all or slash first can't be URL. */
-       if (!first_slash || first_slash == url)
-               return 0;
-       /* Character before must be : and next must be /. */
-       if (first_slash[-1] != ':' || first_slash[1] != '/')
-               return 0;
-       /* There must be something before the :// */
-       if (first_slash == url + 1)
-               return 0;
-       /*
-        * Check all characters up to first slash - 1. Only alphanum
-        * is allowed.
-        */
-       url2 = url;
-       while (url2 < first_slash - 1) {
-               if (!isurlschemechar(url2 == url, (unsigned char)*url2))
-                       return 0;
-               url2++;
-       }
-
-       /* Valid enough. */
-       return 1;
-}
-
 static int external_specification_len(const char *url)
 {
        return strchr(url, ':') - url;
@@ -946,7 +899,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
        if (url) {
                const char *p = url;
 
-               while (isurlschemechar(p == url, *p))
+               while (is_urlschemechar(p == url, *p))
                        p++;
                if (!prefixcmp(p, "::"))
                        helper = xstrndup(url, p - url);
index c29a9e067ff362063d6626e8e4d1e4466d63b8af..8cf0da317d8afe4bfe3cae7051e3a385d44cf7ef 100644 (file)
@@ -279,9 +279,11 @@ static void add_same_unmerged(struct cache_entry *ce,
 static int unpack_index_entry(struct cache_entry *ce,
                              struct unpack_trees_options *o)
 {
-       struct cache_entry *src[5] = { ce, NULL, };
+       struct cache_entry *src[5] = { NULL };
        int ret;
 
+       src[0] = ce;
+
        mark_ce_used(ce, o);
        if (ce_stage(ce)) {
                if (o->skip_unmerged) {
@@ -520,9 +522,17 @@ static int find_cache_pos(struct traverse_info *info,
                const char *ce_name, *ce_slash;
                int cmp, ce_len;
 
-               if (!ce_in_traverse_path(ce, info))
+               if (ce->ce_flags & CE_UNPACKED) {
+                       /*
+                        * cache_bottom entry is already unpacked, so
+                        * we can never match it; don't check it
+                        * again.
+                        */
+                       if (pos == o->cache_bottom)
+                               ++o->cache_bottom;
                        continue;
-               if (ce->ce_flags & CE_UNPACKED)
+               }
+               if (!ce_in_traverse_path(ce, info))
                        continue;
                ce_name = ce->name + pfxlen;
                ce_slash = strchr(ce_name, '/');
@@ -854,7 +864,7 @@ static int verify_uptodate_1(struct cache_entry *ce,
 {
        struct stat st;
 
-       if (o->index_only || (!ce_skip_worktree(ce) && (o->reset || ce_uptodate(ce))))
+       if (o->index_only || (!((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) && (o->reset || ce_uptodate(ce))))
                return 0;
 
        if (!lstat(ce->name, &st)) {
diff --git a/url.c b/url.c
new file mode 100644 (file)
index 0000000..2306236
--- /dev/null
+++ b/url.c
@@ -0,0 +1,126 @@
+#include "cache.h"
+
+int is_urlschemechar(int first_flag, int ch)
+{
+       /*
+        * The set of valid URL schemes, as per STD66 (RFC3986) is
+        * '[A-Za-z][A-Za-z0-9+.-]*'. But use sightly looser check
+        * of '[A-Za-z0-9][A-Za-z0-9+.-]*' because earlier version
+        * of check used '[A-Za-z0-9]+' so not to break any remote
+        * helpers.
+        */
+       int alphanumeric, special;
+       alphanumeric = ch > 0 && isalnum(ch);
+       special = ch == '+' || ch == '-' || ch == '.';
+       return alphanumeric || (!first_flag && special);
+}
+
+int is_url(const char *url)
+{
+       const char *url2, *first_slash;
+
+       if (!url)
+               return 0;
+       url2 = url;
+       first_slash = strchr(url, '/');
+
+       /* Input with no slash at all or slash first can't be URL. */
+       if (!first_slash || first_slash == url)
+               return 0;
+       /* Character before must be : and next must be /. */
+       if (first_slash[-1] != ':' || first_slash[1] != '/')
+               return 0;
+       /* There must be something before the :// */
+       if (first_slash == url + 1)
+               return 0;
+       /*
+        * Check all characters up to first slash - 1. Only alphanum
+        * is allowed.
+        */
+       url2 = url;
+       while (url2 < first_slash - 1) {
+               if (!is_urlschemechar(url2 == url, (unsigned char)*url2))
+                       return 0;
+               url2++;
+       }
+
+       /* Valid enough. */
+       return 1;
+}
+
+static int url_decode_char(const char *q)
+{
+       int i;
+       unsigned char val = 0;
+       for (i = 0; i < 2; i++) {
+               unsigned char c = *q++;
+               val <<= 4;
+               if (c >= '0' && c <= '9')
+                       val += c - '0';
+               else if (c >= 'a' && c <= 'f')
+                       val += c - 'a' + 10;
+               else if (c >= 'A' && c <= 'F')
+                       val += c - 'A' + 10;
+               else
+                       return -1;
+       }
+       return val;
+}
+
+static char *url_decode_internal(const char **query, const char *stop_at, struct strbuf *out)
+{
+       const char *q = *query;
+
+       do {
+               unsigned char c = *q;
+
+               if (!c)
+                       break;
+               if (stop_at && strchr(stop_at, c)) {
+                       q++;
+                       break;
+               }
+
+               if (c == '%') {
+                       int val = url_decode_char(q + 1);
+                       if (0 <= val) {
+                               strbuf_addch(out, val);
+                               q += 3;
+                               continue;
+                       }
+               }
+
+               if (c == '+')
+                       strbuf_addch(out, ' ');
+               else
+                       strbuf_addch(out, c);
+               q++;
+       } while (1);
+       *query = q;
+       return strbuf_detach(out, NULL);
+}
+
+char *url_decode(const char *url)
+{
+       struct strbuf out = STRBUF_INIT;
+       const char *colon = strchr(url, ':');
+
+       /* Skip protocol part if present */
+       if (colon && url < colon) {
+               strbuf_add(&out, url, colon - url);
+               url = colon;
+       }
+       return url_decode_internal(&url, NULL, &out);
+}
+
+char *url_decode_parameter_name(const char **query)
+{
+       struct strbuf out = STRBUF_INIT;
+       return url_decode_internal(query, "&=", &out);
+}
+
+char *url_decode_parameter_value(const char **query)
+{
+       struct strbuf out = STRBUF_INIT;
+       return url_decode_internal(query, "&", &out);
+}
diff --git a/url.h b/url.h
new file mode 100644 (file)
index 0000000..15817f8
--- /dev/null
+++ b/url.h
@@ -0,0 +1,10 @@
+#ifndef URL_H
+#define URL_H
+
+extern int is_url(const char *url);
+extern int is_urlschemechar(int first_flag, int ch);
+extern char *url_decode(const char *url);
+extern char *url_decode_parameter_name(const char **query);
+extern char *url_decode_parameter_value(const char **query);
+
+#endif /* URL_H */
diff --git a/usage.c b/usage.c
index 79856a2b9f5bc4603252cb10b471a0815416a617..ec4cf53b6bf16f7f9b3528a430891d6c68ef64cc 100644 (file)
--- a/usage.c
+++ b/usage.c
@@ -5,7 +5,7 @@
  */
 #include "git-compat-util.h"
 
-static void report(const char *prefix, const char *err, va_list params)
+void vreportf(const char *prefix, const char *err, va_list params)
 {
        char msg[4096];
        vsnprintf(msg, sizeof(msg), err, params);
@@ -14,24 +14,24 @@ static void report(const char *prefix, const char *err, va_list params)
 
 static NORETURN void usage_builtin(const char *err, va_list params)
 {
-       report("usage: ", err, params);
+       vreportf("usage: ", err, params);
        exit(129);
 }
 
 static NORETURN void die_builtin(const char *err, va_list params)
 {
-       report("fatal: ", err, params);
+       vreportf("fatal: ", err, params);
        exit(128);
 }
 
 static void error_builtin(const char *err, va_list params)
 {
-       report("error: ", err, params);
+       vreportf("error: ", err, params);
 }
 
 static void warn_builtin(const char *warn, va_list params)
 {
-       report("warning: ", warn, params);
+       vreportf("warning: ", warn, params);
 }
 
 /* If we are in a dlopen()ed .so write to a global variable would segfault
index 67003fbb232cd85627f61c02a616b3d6a9ccd5d2..c49cc1b67e1164c561fb20839272bd8b1f7dde6d 100644 (file)
@@ -45,7 +45,9 @@ PATTERNS("pascal",
         "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
         "|<>|<=|>=|:=|\\.\\."
         "|[^[:space:]]|[\x80-\xff]+"),
-PATTERNS("php", "^[\t ]*((function|class).*)",
+PATTERNS("php",
+        "^[\t ]*(((public|protected|private|static)[\t ]+)*function.*)$\n"
+        "^[\t ]*(class.*)$",
         /* -- */
         "[a-zA-Z_][a-zA-Z0-9_]*"
         "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
index 58201b6bcb8d362cffd1222bcb8cd77072c34cf5..afb4f6f773a3ed909433778f4b4da3740ded2b18 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -10,9 +10,11 @@ static void try_to_free_builtin(size_t size)
 
 static void (*try_to_free_routine)(size_t size) = try_to_free_builtin;
 
-void set_try_to_free_routine(void (*routine)(size_t))
+try_to_free_t set_try_to_free_routine(try_to_free_t routine)
 {
-       try_to_free_routine = (routine) ? routine : try_to_free_builtin;
+       try_to_free_t old = try_to_free_routine;
+       try_to_free_routine = routine;
+       return old;
 }
 
 char *xstrdup(const char *str)
index 1653cfa9d66395b97ccdd64f9bd9d35ca9521484..2f9e33c8fa172b129fd956abc4f74a5bf5543ba7 100644 (file)
@@ -9,6 +9,8 @@
 #include "quote.h"
 #include "run-command.h"
 #include "remote.h"
+#include "refs.h"
+#include "submodule.h"
 
 static char default_wt_status_colors[][COLOR_MAXLEN] = {
        GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */
@@ -17,6 +19,8 @@ static char default_wt_status_colors[][COLOR_MAXLEN] = {
        GIT_COLOR_RED,    /* WT_STATUS_UNTRACKED */
        GIT_COLOR_RED,    /* WT_STATUS_NOBRANCH */
        GIT_COLOR_RED,    /* WT_STATUS_UNMERGED */
+       GIT_COLOR_GREEN,  /* WT_STATUS_LOCAL_BRANCH */
+       GIT_COLOR_RED,    /* WT_STATUS_REMOTE_BRANCH */
 };
 
 static const char *color(int slot, struct wt_status *s)
@@ -309,6 +313,8 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
        DIFF_OPT_SET(&rev.diffopt, DIRTY_SUBMODULES);
        if (!s->show_untracked_files)
                DIFF_OPT_SET(&rev.diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);
+       if (s->ignore_submodule_arg)
+               handle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);
        rev.diffopt.format_callback = wt_status_collect_changed_cb;
        rev.diffopt.format_callback_data = s;
        rev.prune_data = s->pathspec;
@@ -325,6 +331,9 @@ static void wt_status_collect_changes_index(struct wt_status *s)
        opt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference;
        setup_revisions(0, NULL, &rev, &opt);
 
+       if (s->ignore_submodule_arg)
+               handle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);
+
        rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
        rev.diffopt.format_callback = wt_status_collect_updated_cb;
        rev.diffopt.format_callback_data = s;
@@ -518,17 +527,18 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
        struct child_process sm_summary;
        char summary_limit[64];
        char index[PATH_MAX];
-       const char *env[] = { index, NULL };
-       const char *argv[] = {
-               "submodule",
-               "summary",
-               uncommitted ? "--files" : "--cached",
-               "--for-status",
-               "--summary-limit",
-               summary_limit,
-               uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD"),
-               NULL
-       };
+       const char *env[] = { NULL, NULL };
+       const char *argv[8];
+
+       env[0] =        index;
+       argv[0] =       "submodule";
+       argv[1] =       "summary";
+       argv[2] =       uncommitted ? "--files" : "--cached";
+       argv[3] =       "--for-status";
+       argv[4] =       "--summary-limit";
+       argv[5] =       summary_limit;
+       argv[6] =       uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD");
+       argv[7] =       NULL;
 
        sprintf(summary_limit, "%d", s->submodule_summary);
        snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
@@ -642,7 +652,9 @@ void wt_status_print(struct wt_status *s)
        wt_status_print_updated(s);
        wt_status_print_unmerged(s);
        wt_status_print_changed(s);
-       if (s->submodule_summary) {
+       if (s->submodule_summary &&
+           (!s->ignore_submodule_arg ||
+            strcmp(s->ignore_submodule_arg, "all"))) {
                wt_status_print_submodule_summary(s, 0);  /* staged */
                wt_status_print_submodule_summary(s, 1);  /* unstaged */
        }
@@ -756,9 +768,69 @@ static void wt_shortstatus_other(int null_termination, struct string_list_item *
        }
 }
 
-void wt_shortstatus_print(struct wt_status *s, int null_termination)
+static void wt_shortstatus_print_tracking(struct wt_status *s)
+{
+       struct branch *branch;
+       const char *header_color = color(WT_STATUS_HEADER, s);
+       const char *branch_color_local = color(WT_STATUS_LOCAL_BRANCH, s);
+       const char *branch_color_remote = color(WT_STATUS_REMOTE_BRANCH, s);
+
+       const char *base;
+       const char *branch_name;
+       int num_ours, num_theirs;
+
+       color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "## ");
+
+       if (!s->branch)
+               return;
+       branch_name = s->branch;
+
+       if (!prefixcmp(branch_name, "refs/heads/"))
+               branch_name += 11;
+       else if (!strcmp(branch_name, "HEAD")) {
+               branch_name = "HEAD (no branch)";
+               branch_color_local = color(WT_STATUS_NOBRANCH, s);
+       }
+
+       branch = branch_get(s->branch + 11);
+       if (s->is_initial)
+               color_fprintf(s->fp, header_color, "Initial commit on ");
+       if (!stat_tracking_info(branch, &num_ours, &num_theirs)) {
+               color_fprintf_ln(s->fp, branch_color_local,
+                       "%s", branch_name);
+               return;
+       }
+
+       base = branch->merge[0]->dst;
+       base = shorten_unambiguous_ref(base, 0);
+       color_fprintf(s->fp, branch_color_local, "%s", branch_name);
+       color_fprintf(s->fp, header_color, "...");
+       color_fprintf(s->fp, branch_color_remote, "%s", base);
+
+       color_fprintf(s->fp, header_color, " [");
+       if (!num_ours) {
+               color_fprintf(s->fp, header_color, "behind ");
+               color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
+       } else if (!num_theirs) {
+               color_fprintf(s->fp, header_color, "ahead ");
+               color_fprintf(s->fp, branch_color_local, "%d", num_ours);
+       } else {
+               color_fprintf(s->fp, header_color, "ahead ");
+               color_fprintf(s->fp, branch_color_local, "%d", num_ours);
+               color_fprintf(s->fp, header_color, ", behind ");
+               color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
+       }
+
+       color_fprintf_ln(s->fp, header_color, "]");
+}
+
+void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_branch)
 {
        int i;
+
+       if (show_branch)
+               wt_shortstatus_print_tracking(s);
+
        for (i = 0; i < s->change.nr; i++) {
                struct wt_status_change_data *d;
                struct string_list_item *it;
@@ -789,5 +861,5 @@ void wt_porcelain_print(struct wt_status *s, int null_termination)
        s->use_color = 0;
        s->relative_paths = 0;
        s->prefix = NULL;
-       wt_shortstatus_print(s, null_termination);
+       wt_shortstatus_print(s, null_termination, 0);
 }
index 1093e65ae00e60c171c740d06628705cfcfb68c2..9df9c9fad2512d7c1d7d6456cdd645d641b5a089 100644 (file)
@@ -12,6 +12,8 @@ enum color_wt_status {
        WT_STATUS_UNTRACKED,
        WT_STATUS_NOBRANCH,
        WT_STATUS_UNMERGED,
+       WT_STATUS_LOCAL_BRANCH,
+       WT_STATUS_REMOTE_BRANCH
 };
 
 enum untracked_status_type {
@@ -43,7 +45,8 @@ struct wt_status {
        int submodule_summary;
        int show_ignored_files;
        enum untracked_status_type show_untracked_files;
-       char color_palette[WT_STATUS_UNMERGED+1][COLOR_MAXLEN];
+       const char *ignore_submodule_arg;
+       char color_palette[WT_STATUS_REMOTE_BRANCH+1][COLOR_MAXLEN];
 
        /* These are computed during processing of the individual sections */
        int commitable;
@@ -60,7 +63,7 @@ void wt_status_prepare(struct wt_status *s);
 void wt_status_print(struct wt_status *s);
 void wt_status_collect(struct wt_status *s);
 
-void wt_shortstatus_print(struct wt_status *s, int null_termination);
+void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_branch);
 void wt_porcelain_print(struct wt_status *s, int null_termination);
 
 #endif /* STATUS_H */
index bc12f298953a4e72b323f73607278028ec4a2805..22f9bd692c2706136b4938bbcb2e0fc3dab212b8 100644 (file)
@@ -190,8 +190,10 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags)
 {
        int i1, i2;
 
+       if (s1 == s2 && !memcmp(l1, l2, s1))
+               return 1;
        if (!(flags & XDF_WHITESPACE_FLAGS))
-               return s1 == s2 && !memcmp(l1, l2, s1);
+               return 0;
 
        i1 = 0;
        i2 = 0;