Code

Merge branch 'cc/revert-strategy'
authorJunio C Hamano <gitster@pobox.com>
Sun, 9 May 2010 05:34:47 +0000 (22:34 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 9 May 2010 05:34:47 +0000 (22:34 -0700)
* cc/revert-strategy:
  revert: add "--strategy" option to choose merge strategy
  merge: make function try_merge_command non static
  merge: refactor code that calls "git merge-STRATEGY"
  revert: refactor merge recursive code into its own function
  revert: use strbuf to refactor the code that writes the merge message

Conflicts:
builtin/revert.c

187 files changed:
.gitignore
.mailmap
Documentation/Makefile
Documentation/RelNotes-1.7.0.3.txt
Documentation/RelNotes-1.7.0.4.txt [new file with mode: 0644]
Documentation/RelNotes-1.7.0.5.txt [new file with mode: 0644]
Documentation/RelNotes-1.7.0.6.txt [new file with mode: 0644]
Documentation/RelNotes-1.7.1.txt
Documentation/SubmittingPatches
Documentation/blame-options.txt
Documentation/config.txt
Documentation/diff-generate-patch.txt
Documentation/diff-options.txt
Documentation/everyday.txt
Documentation/git-branch.txt
Documentation/git-cherry-pick.txt
Documentation/git-clone.txt
Documentation/git-describe.txt
Documentation/git-fetch.txt
Documentation/git-http-backend.txt
Documentation/git-imap-send.txt
Documentation/git-log.txt
Documentation/git-merge.txt
Documentation/git-notes.txt
Documentation/git-push.txt
Documentation/git-rebase.txt
Documentation/git-reflog.txt
Documentation/git-remote-helpers.txt
Documentation/git-send-email.txt
Documentation/git-show-ref.txt
Documentation/git-status.txt
Documentation/git.txt
Documentation/gitattributes.txt
Documentation/gitdiffcore.txt
Documentation/githooks.txt
Documentation/howto/revert-a-faulty-merge.txt
Documentation/merge-options.txt
Documentation/pretty-options.txt
Documentation/rev-list-options.txt
Documentation/technical/api-string-list.txt
Documentation/technical/pack-protocol.txt
Documentation/urls.txt
GIT-VERSION-GEN
Makefile
branch.c
builtin.h
builtin/apply.c
builtin/clone.c
builtin/commit-tree.c
builtin/commit.c
builtin/diff-tree.c
builtin/fast-export.c
builtin/fetch.c
builtin/fmt-merge-msg.c
builtin/grep.c
builtin/index-pack.c
builtin/log.c
builtin/ls-files.c
builtin/ls-tree.c
builtin/mailinfo.c
builtin/merge.c
builtin/notes.c
builtin/push.c
builtin/reflog.c
builtin/reset.c
builtin/rev-list.c
builtin/revert.c
builtin/tag.c
cache.h
combine-diff.c
commit.c
commit.h
compat/bswap.h
compat/mingw.c
compat/mingw.h
compat/vcbuild/include/termios.h [new file with mode: 0644]
configure.ac
contrib/ciabot/README [new file with mode: 0644]
contrib/ciabot/ciabot.py [new file with mode: 0755]
contrib/ciabot/ciabot.sh [new file with mode: 0755]
contrib/completion/git-completion.bash
contrib/fast-import/import-zips.py
contrib/hg-to-git/hg-to-git.py
contrib/p4import/git-p4import.py
daemon.c
diff-lib.c
diff.c
diff.h
diffcore.h
git-am.sh
git-compat-util.h
git-difftool.perl
git-instaweb.sh
git-rebase--interactive.sh
git-rebase.sh
git-send-email.perl
git-stash.sh
git-submodule.sh
git.spec.in
git_remote_helpers/Makefile
gitk-git/gitk
gitk-git/po/de.po
gitk-git/po/es.po
gitk-git/po/fr.po
gitk-git/po/hu.po
gitk-git/po/it.po
gitk-git/po/ja.po
gitk-git/po/ru.po
gitk-git/po/sv.po
gitweb/INSTALL
gitweb/Makefile
gitweb/README
gitweb/gitweb.perl
grep.c
http-backend.c
http.c
http.h
imap-send.c
log-tree.c
merge-recursive.c
notes-cache.c [new file with mode: 0644]
notes-cache.h [new file with mode: 0644]
notes.c
notes.h
parse-options.c
parse-options.h
pretty.c
refs.c
refs.h
remote-curl.c
revision.c
revision.h
run-command.c
sha1_file.c
string-list.c
string-list.h
submodule.c
submodule.h
t/t0000-basic.sh
t/t1010-mktree.sh
t/t1304-default-acl.sh
t/t3301-notes.sh
t/t3400-rebase.sh
t/t3404-rebase-interactive.sh
t/t3506-cherry-pick-ff.sh [new file with mode: 0755]
t/t3507-cherry-pick-conflict.sh [changed mode: 0644->0755]
t/t4013-diff-various.sh
t/t4013/diff.log_-m_-p_--first-parent_master [new file with mode: 0644]
t/t4013/diff.log_-m_-p_master [new file with mode: 0644]
t/t4013/diff.log_-p_--first-parent_master [new file with mode: 0644]
t/t4013/diff.show_--first-parent_master [new file with mode: 0644]
t/t4013/diff.show_-c_master [new file with mode: 0644]
t/t4013/diff.show_-m_master [new file with mode: 0644]
t/t4014-format-patch.sh
t/t4017-diff-retval.sh
t/t4038-diff-combined.sh
t/t4041-diff-submodule.sh
t/t4042-diff-textconv-caching.sh [new file with mode: 0755]
t/t4134-apply-submodule.sh [new file with mode: 0755]
t/t5407-post-rewrite-hook.sh [new file with mode: 0755]
t/t5505-remote.sh
t/t5601-clone.sh
t/t6006-rev-list-format.sh
t/t6200-fmt-merge-msg.sh
t/t7012-skip-worktree-writing.sh
t/t7501-commit.sh
t/t7506-status-submodule.sh
t/t7800-difftool.sh
t/t9350-fast-export.sh
t/test-lib.sh
templates/Makefile
templates/hooks--commit-msg.sample
templates/hooks--post-update.sample
templates/hooks--pre-commit.sample
templates/hooks--pre-rebase.sample
templates/hooks--prepare-commit-msg.sample
templates/hooks--update.sample
templates/info--exclude
unpack-trees.c
userdiff.c
userdiff.h
wrapper.c
wt-status.c
wt-status.h
xdiff-interface.c
xdiff-interface.h
xdiff/xmerge.c

index 7b3acb766491e2e002f293cf9dd50298d0d7d83a..dbf1b90c63573b08efc894ed8c1e02de58fd53e4 100644 (file)
 /git-write-tree
 /git-core-*/?*
 /gitk-git/gitk-wish
+/gitweb/GITWEB-BUILD-OPTIONS
 /gitweb/gitweb.cgi
+/gitweb/gitweb.min.*
 /test-chmtime
 /test-ctype
 /test-date
 *.exe
 *.[aos]
 *.py[co]
-*.o.d
+.depend/
 *+
 /config.mak
 /autom4te.cache
index 975e6758efa85c674207ffd6b400e3bbab2576a2..a8091eb5dfa430bf1b0537da47a31e7cf88d8622 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -5,6 +5,7 @@
 # same person appearing not to be so.
 #
 
+Alex Bennée <kernel-hacker@bennee.com>
 Alexander Gavrilov <angavrilov@gmail.com>
 Aneesh Kumar K.V <aneesh.kumar@gmail.com>
 Brian M. Carlson <sandals@crustytoothpaste.ath.cx>
@@ -15,6 +16,7 @@ Daniel Barkalow <barkalow@iabervon.org>
 David D. Kilzer <ddkilzer@kilzer.net>
 David Kågedal <davidk@lysator.liu.se>
 David S. Miller <davem@davemloft.net>
+Deskin Miller <deskinm@umich.edu>
 Dirk Süsserott <newsletter@dirk.my1.cc>
 Fredrik Kuivinen <freku045@student.liu.se>
 H. Peter Anvin <hpa@bonde.sc.orionmulti.com>
@@ -36,6 +38,7 @@ Li Hong <leehong@pku.edu.cn>
 Lukas Sandström <lukass@etek.chalmers.se>
 Martin Langhoff <martin@catalyst.net.nz>
 Michael Coleman <tutufan@gmail.com>
+Michael J Gruber <git@drmicha.warpmail.net> <michaeljgruber+gmane@fastmail.fm>
 Michael W. Olson <mwolson@gnu.org>
 Michele Ballabio <barra_cuda@katamail.com>
 Nanako Shiraishi <nanako3@bluebottle.com>
@@ -59,6 +62,7 @@ Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
 Uwe Kleine-König <uzeisberger@io.fsforth.de>
 Uwe Kleine-König <zeisberg@informatik.uni-freiburg.de>
 Ville Skyttä <scop@xemacs.org>
+Vitaly "_Vi" Shukela <public_vi@tut.by>
 William Pursell <bill.pursell@gmail.com>
 YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
 anonymous <linux@horizon.com>
index 8a8a3954dc45723f7380b59dadbb7e412198d672..04f69cf64e5d989bac3cd1c235e6a7e657c6c103 100644 (file)
@@ -264,7 +264,9 @@ manpage-base-url.xsl: manpage-base-url.xsl.in
        mv $@+ $@
 
 user-manual.xml: user-manual.txt user-manual.conf
-       $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d book $<
+       $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
+       $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d book -o $@+ $< && \
+       mv $@+ $@
 
 technical/api-index.txt: technical/api-index-skel.txt \
        technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
@@ -278,7 +280,9 @@ XSLT = docbook.xsl
 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
 
 user-manual.html: user-manual.xml
-       $(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
+       $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
+       xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
+       mv $@+ $@
 
 git.info: user-manual.texi
        $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
index 60bcbff112ad4399e7d48d8f889ce334f2a6012d..3b355737c0c0d7a55b843a324e55aed8ff736a94 100644 (file)
@@ -1,5 +1,5 @@
-Git v1.7.0.3 Release Notes (draft)
-==================================
+Git v1.7.0.3 Release Notes
+==========================
 
 Fixes since v1.7.0.2
 --------------------
@@ -32,9 +32,3 @@ Fixes since v1.7.0.2
    matching branch.<name>.remote.
 
 And other minor fixes and documentation updates.
-
---
-exec >/var/tmp/1
-echo O=$(git describe)
-O=v1.7.0.2-69-g730b020
-git shortlog --no-merges $O..
diff --git a/Documentation/RelNotes-1.7.0.4.txt b/Documentation/RelNotes-1.7.0.4.txt
new file mode 100644 (file)
index 0000000..cf7f60e
--- /dev/null
@@ -0,0 +1,27 @@
+Git v1.7.0.4 Release Notes
+==========================
+
+Fixes since v1.7.0.3
+--------------------
+
+ * Optimized ntohl/htonl on big-endian machines were broken.
+
+ * Color values given to "color.<cmd>.<slot>" configuration can now have
+   more than one attributes (e.g. "bold ul").
+
+ * "git add -u nonexistent-path" did not complain.
+
+ * "git apply --whitespace=fix" didn't work well when an early patch in
+   a patch series adds trailing blank lines and a later one depended on
+   such a block of blank lines at the end.
+
+ * "git fast-export" didn't check error status and stop when marks file
+   cannot be opened.
+
+ * "git format-patch --ignore-if-in-upstream" gave unwarranted errors
+   when the range was empty, instead of silently finishing.
+
+ * "git remote prune" did not detect remote tracking refs that became
+   dangling correctly.
+
+And other minor fixes and documentation updates.
diff --git a/Documentation/RelNotes-1.7.0.5.txt b/Documentation/RelNotes-1.7.0.5.txt
new file mode 100644 (file)
index 0000000..3149c91
--- /dev/null
@@ -0,0 +1,26 @@
+Git v1.7.0.5 Release Notes
+==========================
+
+Fixes since v1.7.0.4
+--------------------
+
+ * "git daemon" failed to compile on platforms without sockaddr_storage type.
+
+ * Output from "git rev-list --pretty=oneline" was unparsable when a
+   commit did not have any message, which is abnormal but possible in a
+   repository converted from foreign scm.
+
+ * "git stash show <commit-that-is-not-a-stash>" gave an error message
+   that was not so useful.  Reworded the message to "<it> is not a
+   stash".
+
+ * Python scripts in contrib/ area now start with "#!/usr/bin/env python"
+   to honor user's PATH.
+
+ * "git imap-send" used to mistake any line that begins with "From " as a
+   message separator in format-patch output.
+
+ * Smart http server backend failed to report an internal server error and
+   infinitely looped instead after output pipe was closed.
+
+And other minor fixes and documentation updates.
diff --git a/Documentation/RelNotes-1.7.0.6.txt b/Documentation/RelNotes-1.7.0.6.txt
new file mode 100644 (file)
index 0000000..b2852b6
--- /dev/null
@@ -0,0 +1,13 @@
+Git v1.7.0.6 Release Notes
+==========================
+
+Fixes since v1.7.0.5
+--------------------
+
+ * "git diff --stat" used "int" to count the size of differences,
+   which could result in overflowing.
+
+ * "git rev-list --abbrev-commit" defaulted to 40-byte abbreviations, unlike
+   newer tools in the git toolset.
+
+And other minor fixes and documentation updates.
index 06cefaf01b01d8c1591eb23dfd454c31f7da1f63..9d89fedb36b4d6fa7c8a6a8487cc47b4ca542e3a 100644 (file)
@@ -1,25 +1,31 @@
-Git v1.7.1 Release Notes (draft)
-================================
+Git v1.7.1 Release Notes
+========================
 
 Updates since v1.7.0
 --------------------
 
+ * Eric Raymond is the maintainer of updated CIAbot scripts, in contrib/.
+
+ * gitk updates.
+
  * Some commands (e.g. svn and http interfaces) that interactively ask
-   password can be told to use an external program given via GIT_ASKPASS.
+   for a password can be told to use an external program given via
+   GIT_ASKPASS.
 
- * Color values given to "color.<cmd>.<slot>" configuration can now have
-   more than one attributes (e.g. "bold ul").
+ * Conflict markers that lead the common ancestor in diff3-style output
+   now have a label, which hopefully would help third-party tools that
+   expect one.
 
- * "git apply --whitespace=fix" didn't work well when an early patch in
-   a patch series adds trailing blank lines and a later one depended on
-   such a block of blank lines at the end.
+ * Comes with an updated bash-completion script.
 
  * "git am" learned "--keep-cr" option to handle inputs that are
-   mixture of changes to files with and without CRLF line endings.
+   mixture of changes to files with and without CRLF line endings.
 
  * "git cvsimport" learned -R option to leave revision mapping between
    CVS revisions and resulting git commits.
 
+ * "git diff --submodule" notices and describes dirty submodules.
+
  * "git for-each-ref" learned %(symref), %(symref:short) and %(flag)
    tokens.
 
@@ -36,11 +42,14 @@ Updates since v1.7.0
 
  * "git grep" learned to paint filename and line-number in colors.
 
- * "git merge-file" learned to use custom conflict marker size and also use
-   the "union merge" behaviour.
+ * "git log -p --first-parent -m" shows one-parent diff for merge
+   commits, instead of showing combined diff.
 
- * "git notes" command has been rewritten in C and learned quite a
-   many commands.
+ * "git merge-file" learned to use custom conflict marker size and also
+   to use the "union merge" behaviour.
+
+ * "git notes" command has been rewritten in C and learned many commands
+   and features to help you carry notes forward across rebases and amends.
 
  * "git request-pull" identifies the commit the request is relative to in
    a more readable way.
@@ -49,11 +58,18 @@ Updates since v1.7.0
    near the tip while preserving your local changes in a way similar
    to how "git checkout branch" does.
 
+ * "git status" notices and describes dirty submodules.
+
  * "git svn" should work better when interacting with repositories
    with CRLF line endings.
 
  * "git imap-send" learned to support CRAM-MD5 authentication.
 
+ * "gitweb" installation procedure can use "minified" js/css files
+   better.
+
+ * Various documentation updates.
+
 Fixes since v1.7.0
 ------------------
 
@@ -63,8 +79,11 @@ release, unless otherwise noted.
  * "git add frotz/nitfol" did not complain when the entire frotz/ directory
    was ignored.
 
----
-exec >/var/tmp/1
-echo O=$(git describe)
-O=v1.7.0.2-322-g4e7d08a
-git shortlog --no-merges ^maint $O..
+ * "git diff --stat" used "int" to count the size of differences,
+   which could result in overflowing.
+
+ * "git rev-list --pretty=oneline" didn't terminate a record with LF for
+   commits without any message.
+
+ * "git rev-list --abbrev-commit" defaulted to 40-byte abbreviations, unlike
+   newer tools in the git toolset.
index c686f8646b465860c8a096241797709366cc4dc1..abc65de9464144a7bac38756c01ab315ab6922eb 100644 (file)
@@ -520,11 +520,9 @@ Gmail
 GMail does not appear to have any way to turn off line wrapping in the web
 interface, so this will mangle any emails that you send.  You can however
 use any IMAP email client to connect to the google imap server, and forward
-the emails through that.  Just make sure to disable line wrapping in that
-email client.  Alternatively, use "git send-email" instead.
+the emails through that.
 
-Submitting properly formatted patches via Gmail is simple now that
-IMAP support is available. First, edit your ~/.gitconfig to specify your
+To submit using the IMAP interface, first, edit your ~/.gitconfig to specify your
 account settings:
 
 [imap]
@@ -538,14 +536,29 @@ account settings:
 You might need to instead use: folder = "[Google Mail]/Drafts" if you get an error
 that the "Folder doesn't exist".
 
-Next, ensure that your Gmail settings are correct. In "Settings" the
-"Use Unicode (UTF-8) encoding for outgoing messages" should be checked.
+Once your commits are ready to be sent to the mailing list, run the
+following command to send the patch emails to your Gmail Drafts
+folder.
 
-Once your commits are ready to send to the mailing list, run the following
-command to send the patch emails to your Gmail Drafts folder.
+  $ git format-patch --cover-letter -M --stdout origin/master | git imap-send
 
-       $ git format-patch -M --stdout origin/master | git imap-send
+Just make sure to disable line wrapping in the email client (GMail web
+interface will line wrap no matter what, so you need to use a real
+IMAP client).
 
-Go to your Gmail account, open the Drafts folder, find the patch email, fill
-in the To: and CC: fields and send away!
+Alternatively, you can use "git send-email" and send your patches
+through the GMail SMTP server.  edit ~/.gitconfig to specify your
+account settings:
+
+[sendemail]
+       smtpencryption = tls
+       smtpserver = smtp.gmail.com
+       smtpuser = user@gmail.com
+       smtppass = p4ssw0rd
+       smtpserverport = 587
+
+Once your commits are ready to be sent to the mailing list, run the
+following commands:
 
+  $ git format-patch --cover-letter -M origin/master -o outgoing/
+  $ git send-email outgoing/*
index 4833cac4b996e83e351b70d8f02a160d04e9a8e3..d8205691c6ff85dcbbe5f064463d4671ec10125e 100644 (file)
@@ -79,14 +79,15 @@ of lines before or after the line given by <start>.
        of the --date option at linkgit:git-log[1].
 
 -M|<num>|::
-       Detect moving lines in the file as well.  When a commit
-       moves a block of lines in a file (e.g. the original file
-       has A and then B, and the commit changes it to B and
-       then A), the traditional 'blame' algorithm typically blames
-       the lines that were moved up (i.e. B) to the parent and
-       assigns blame to the lines that were moved down (i.e. A)
-       to the child commit.  With this option, both groups of lines
-       are blamed on the parent.
+       Detect moved or copied lines within a file. When a commit
+       moves or copies a block of lines (e.g. the original file
+       has A and then B, and the commit changes it to B and then
+       A), the traditional 'blame' algorithm notices only half of
+       the movement and typically blames the lines that were moved
+       up (i.e. B) to the parent and assigns blame to the lines that
+       were moved down (i.e. A) to the child commit.  With this
+       option, both groups of lines are blamed on the parent by
+       running extra passes of inspection.
 +
 <num> is optional but it is the lower bound on the number of
 alphanumeric characters that git must detect as moving
@@ -94,7 +95,7 @@ within a file for it to associate those lines with the parent
 commit.
 
 -C|<num>|::
-       In addition to `-M`, detect lines copied from other
+       In addition to `-M`, detect lines moved or copied from other
        files that were modified in the same commit.  This is
        useful when you reorganize your program and move code
        around across files.  When this option is given twice,
index 1dbded0fdc9d4b77809b5c08a99278d1a266e2b4..8f86050b05f5643240cfd760492079dbbcb73c76 100644 (file)
@@ -198,11 +198,11 @@ core.quotepath::
 
 core.autocrlf::
        If true, makes git convert `CRLF` at the end of lines in text files to
-       `LF` when reading from the filesystem, and convert in reverse when
-       writing to the filesystem.  The variable can be set 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 filesystem but files are written out with
-       `LF` at the end of lines.  A file is considered
+       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].
@@ -519,10 +519,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.
+       after the full SHA-1 of the commit they annotate.  The ref
+       must be fully qualified.
 +
 If such a file exists in the given ref, the referenced blob is read, and
-appended to the commit message, separated by a "Notes:" line.  If the
+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.
 +
@@ -912,7 +914,7 @@ format.signoff::
 gc.aggressiveWindow::
        The window size parameter used in the delta compression
        algorithm used by 'git gc --aggressive'.  This defaults
-       to 10.
+       to 250.
 
 gc.auto::
        When there are approximately more than this many loose
@@ -1334,6 +1336,53 @@ mergetool.keepTemporaries::
 mergetool.prompt::
        Prompt before each invocation of the merge resolution program.
 
+notes.displayRef::
+       The (fully qualified) refname from which to show notes when
+       showing commit messages.  The value of this variable can be set
+       to a glob, in which case notes from all matching refs will be
+       shown.  You may also specify this configuration variable
+       several 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 overridden with the `GIT_NOTES_DISPLAY_REF`
+environment variable, which must be a colon separated list of refs or
+globs.
++
+The effective value of "core.notesRef" (possibly overridden by
+GIT_NOTES_REF) is also implicitly added to the list of refs to be
+displayed.
+
+notes.rewrite.<command>::
+       When rewriting commits with <command> (currently `amend` or
+       `rebase`) and this variable is set to `true`, git
+       automatically copies your notes from the original to the
+       rewritten commit.  Defaults to `true`, but see
+       "notes.rewriteRef" below.
+
+notes.rewriteMode::
+       When copying notes during a rewrite (see the
+       "notes.rewrite.<command>" option), determines what to do if
+       the target commit already has a note.  Must be one of
+       `overwrite`, `concatenate`, or `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.  The ref 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.
++
+This setting can be overridden with the `GIT_NOTES_REWRITE_REF`
+environment variable, which must be a colon separated list of refs or
+globs.
+
 pack.window::
        The size of the window used by linkgit:git-pack-objects[1] when no
        window size is given on the command line. Defaults to 10.
index 0f25ba7e3857e6c4f18c3589b31f082b602df6dc..8f9a2412fd44c80f2bf8d63271e2897ebeb3ddeb 100644 (file)
@@ -56,7 +56,8 @@ combined diff format
 
 "git-diff-tree", "git-diff-files" and "git-diff" can take '-c' or
 '--cc' option to produce 'combined diff'.  For showing a merge commit
-with "git log -p", this is the default format.
+with "git log -p", this is the default format; you can force showing
+full diff with the '-m' option.
 A 'combined diff' format looks like this:
 
 ------------
index 60e922e6eff888f83a92d3747579ef45d993528a..c9c6c2b1cb61caa6db5e029d6bce1c76a6c075a7 100644 (file)
@@ -94,8 +94,8 @@ Also, when `--raw` or `--numstat` has been given, do not munge
 pathnames and use NULs as output field terminators.
 endif::git-log[]
 ifndef::git-log[]
-       When `--raw` or `--numstat` has been given, do not munge
-       pathnames and use NULs as output field terminators.
+       When `--raw`, `--numstat`, `--name-only` or `--name-status` has been
+       given, do not munge pathnames and use NULs as output field terminators.
 endif::git-log[]
 +
 Without this option, each pathname output will have TAB, LF, double quotes,
index 9310b650d3ca6b6cb7d69814eb9b800e8c2c85cd..e0ba8cc07549af375c89496c57c016a41b8cc699 100644 (file)
@@ -1,13 +1,8 @@
 Everyday GIT With 20 Commands Or So
 ===================================
 
-<<Basic Repository>> commands are needed by people who have a
-repository --- that is everybody, because every working tree of
-git is a repository.
-
-In addition, <<Individual Developer (Standalone)>> commands are
-essential for anybody who makes a commit, even for somebody who
-works alone.
+<<Individual Developer (Standalone)>> commands are essential for
+anybody who makes a commit, even for somebody who works alone.
 
 If you work with other people, you will need commands listed in
 the <<Individual Developer (Participant)>> section as well.
@@ -20,46 +15,6 @@ administrators who are responsible for the care and feeding
 of git repositories.
 
 
-Basic Repository[[Basic Repository]]
-------------------------------------
-
-Everybody uses these commands to maintain git repositories.
-
-  * linkgit:git-init[1] or linkgit:git-clone[1] to create a
-    new repository.
-
-  * linkgit:git-fsck[1] to check the repository for errors.
-
-  * linkgit:git-gc[1] to do common housekeeping tasks such as
-    repack and prune.
-
-Examples
-~~~~~~~~
-
-Check health and remove cruft.::
-+
-------------
-$ git fsck <1>
-$ git count-objects <2>
-$ git gc <3>
-------------
-+
-<1> running without `\--full` is usually cheap and assures the
-repository health reasonably well.
-<2> check how many loose objects there are and how much
-disk space is wasted by not repacking.
-<3> repacks the local repository and performs other housekeeping tasks.
-
-Repack a small project into single pack.::
-+
-------------
-$ git gc <1>
-------------
-+
-<1> pack all the objects reachable from the refs into one pack,
-then remove the other packs.
-
-
 Individual Developer (Standalone)[[Individual Developer (Standalone)]]
 ----------------------------------------------------------------------
 
@@ -67,6 +22,8 @@ A standalone individual developer does not exchange patches with
 other people, and works alone in a single repository, using the
 following commands.
 
+  * linkgit:git-init[1] to create a new repository.
+
   * linkgit:git-show-branch[1] to see where you are.
 
   * linkgit:git-log[1] to see what happened.
index 903a690f10e3cdb7aea15a19332bf0e8bc87814e..1940256930d92c0679b95bb0cd41f24847828bd4 100644 (file)
@@ -63,7 +63,9 @@ way to clean up all obsolete remote-tracking branches.
 OPTIONS
 -------
 -d::
-       Delete a branch. The branch must be fully merged in HEAD.
+       Delete a branch. The branch must be fully merged in its
+       upstream branch, or in `HEAD` if no upstream was set with
+       `--track` or `--set-upstream`.
 
 -D::
        Delete a branch irrespective of its merged status.
@@ -72,6 +74,8 @@ OPTIONS
        Create the branch's reflog.  This activates recording of
        all changes made to the branch ref, enabling use of date
        based sha1 expressions such as "<branchname>@\{yesterday}".
+       Note that in non-bare repositories, reflogs are usually
+       enabled by default by the `core.logallrefupdates` config option.
 
 -f::
 --force::
index 78f4714da0c226b9523f60f247f60ab13119c7c7..d71607a85d03062c76f7d17d4fd8e8b4168a279d 100644 (file)
@@ -7,7 +7,7 @@ git-cherry-pick - Apply the change introduced by an existing commit
 
 SYNOPSIS
 --------
-'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] <commit>
+'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>
 
 DESCRIPTION
 -----------
@@ -70,6 +70,10 @@ effect to your index in a row.
 --signoff::
        Add Signed-off-by line at the end of the commit message.
 
+--ff::
+       If the current HEAD is the same as the parent of the
+       cherry-pick'ed commit, then a fast forward to this commit will
+       be performed.
 
 Author
 ------
index 43cfba0e4525e15b8f106a1f0f0ab88f5a7b527f..dc7d3d17b151d05827925fdcd2806945e2e278cb 100644 (file)
@@ -187,7 +187,7 @@ include::urls.txt[]
 Examples
 --------
 
-Clone from upstream::
+* Clone from upstream:
 +
 ------------
 $ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
@@ -196,7 +196,7 @@ $ make
 ------------
 
 
-Make a local clone that borrows from the current directory, without checking things out::
+* Make a local clone that borrows from the current directory, without checking things out:
 +
 ------------
 $ git clone -l -s -n . ../copy
@@ -205,7 +205,7 @@ $ git show-branch
 ------------
 
 
-Clone from upstream while borrowing from an existing local directory::
+* Clone from upstream while borrowing from an existing local directory:
 +
 ------------
 $ git clone --reference my2.6 \
@@ -215,14 +215,14 @@ $ cd my2.7
 ------------
 
 
-Create a bare repository to publish your changes to the public::
+* Create a bare repository to publish your changes to the public:
 +
 ------------
 $ git clone --bare -l /home/proj/.git /pub/scm/proj.git
 ------------
 
 
-Create a repository on the kernel.org machine that borrows from Linus::
+* Create a repository on the kernel.org machine that borrows from Linus:
 +
 ------------
 $ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
index 6fc5323ee6a9d3cd22f8c68ebaf514f26c82f684..7ef9d51577594ae6a27f71bae251d6ee2f52befa 100644 (file)
@@ -105,6 +105,9 @@ The number of additional commits is the number
 of commits which would be displayed by "git log v1.0.4..parent".
 The hash suffix is "-g" + 7-char abbreviation for the tip commit
 of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`).
+The "g" prefix stands for "git" and is used to allow describing the version of
+a software depending on the SCM the software is managed with. This is useful
+in an environment where people may use different SCMs.
 
 Doing a 'git describe' on a tag-name will just show the tag name:
 
index 948ea26c5a2b3825e61d0c6495d03829669a7351..400fe7f956961ba0ddf09d2dcc6e539adec7ff74 100644 (file)
@@ -8,13 +8,13 @@ git-fetch - Download objects and refs from another repository
 
 SYNOPSIS
 --------
-'git fetch' <options> <repository> <refspec>...
+'git fetch' [<options>] [<repository> [<refspec>...]]
 
-'git fetch' <options> <group>
+'git fetch' [<options>] <group>
 
-'git fetch' --multiple <options> [<repository> | <group>]...
+'git fetch' --multiple [<options>] [<repository> | <group>]...
 
-'git fetch' --all <options>
+'git fetch' --all [<options>]
 
 
 DESCRIPTION
index 52388206570238636d50ed360120d3464f630a94..277d9e141bf81bddb4ba661e43763b7774a1417d 100644 (file)
@@ -35,7 +35,7 @@ These services can be enabled/disabled using the per-repository
 configuration file:
 
 http.getanyfile::
-       This serves older Git clients which are unable to use the
+       This serves Git clients older than version 1.6.6 that are unable to use the
        upload pack service.  When enabled, clients are able to read
        any file within the repository, including objects that are
        no longer reachable from a branch but are still present.
index 6cafbe2ec191b2e2b35e7855c71837fa0f231785..57aba42e6654e3d32617c3c7b17d18e8dd85852b 100644 (file)
@@ -16,7 +16,9 @@ DESCRIPTION
 This command uploads a mailbox generated with 'git format-patch'
 into an IMAP drafts folder.  This allows patches to be sent as
 other email is when using mail clients that cannot read mailbox
-files directly.
+files directly. The command also works with any general mailbox
+in which emails have the fields "From", "Date", and "Subject" in
+that order.
 
 Typical usage is something like:
 
@@ -122,12 +124,6 @@ Thunderbird in particular is known to be problematic.  Thunderbird
 users may wish to visit this web page for more information:
   http://kb.mozillazine.org/Plain_text_e-mail_-_Thunderbird#Completely_plain_email
 
-
-BUGS
-----
-Doesn't handle lines starting with "From " in the message body.
-
-
 Author
 ------
 Derived from isync 1.0.1 by Mike McCormack.
index 0e39bb61eebfce5d1bff032c65bf04bb77f8ce62..fb184ba1863845797a5f296581ec74a1b31bef1a 100644 (file)
@@ -118,6 +118,15 @@ git log master --not --remotes=*/master::
        Shows all commits that are in local master but not in any remote
        repository master branches.
 
+git log -p -m --first-parent::
+
+       Shows the history including change diffs, but only from the
+       "main branch" perspective, skipping commits that come from merged
+       branches, and showing full diffs of changes introduced by the merges.
+       This makes sense only when following a strict policy of merging all
+       topic branches when staying on a single integration branch.
+
+
 Discussion
 ----------
 
index 9c9618cead5ae73a754ce741dfd423a7bd2298ca..c2325ef90e336a37df42eb7f71f95e3581c83127 100644 (file)
@@ -9,7 +9,8 @@ git-merge - Join two or more development histories together
 SYNOPSIS
 --------
 [verse]
-'git merge' [-n] [--stat] [--no-commit] [--squash] [-s <strategy>]...
+'git merge' [-n] [--stat] [--no-commit] [--squash]
+       [-s <strategy>] [-X <strategy-option>]
        [--[no-]rerere-autoupdate] [-m <msg>] <commit>...
 'git merge' <msg> HEAD <commit>...
 
index bef2f3942e0540a4829a30f39c88d3414046d7d1..4e5113b837230c8f050cf4bbe10e8de4b3271bd0 100644 (file)
@@ -10,7 +10,7 @@ SYNOPSIS
 [verse]
 'git notes' [list [<object>]]
 'git notes' add [-f] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
-'git notes' copy [-f] <from-object> <to-object>
+'git notes' copy [-f] ( --stdin | <from-object> <to-object> )
 'git notes' append [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
 'git notes' edit [<object>]
 'git notes' show [<object>]
@@ -27,12 +27,17 @@ 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
 message stored in the commit object, the notes are indented like the
-message, after an unindented line saying "Notes:".
+message, after an unindented line saying "Notes (<refname>):" (or
+"Notes:" for the default setting).
 
-To disable notes, you have to set the config variable core.notesRef to
-the empty string.  Alternatively, you can set it to a different ref,
-something like "refs/notes/bugzilla".  This setting can be overridden
-by the environment variable "GIT_NOTES_REF".
+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.
+
+See the description of "notes.rewrite.<command>" in
+linkgit:git-config[1] for a way of carrying your notes across commands
+that rewrite commits.
 
 
 SUBCOMMANDS
@@ -55,6 +60,16 @@ copy::
        object has none (use -f to overwrite existing notes to the
        second object). This subcommand is equivalent to:
        `git notes add [-f] -C $(git notes list <from-object>) <to-object>`
++
+In `\--stdin` mode, take lines in the format
++
+----------
+<from-object> SP <to-object> [ SP <rest> ] LF
+----------
++
+on standard input, and copy the notes from each <from-object> to its
+corresponding <to-object>.  (The optional `<rest>` is ignored so that
+the command can read the input given to the `post-rewrite` hook.)
 
 append::
        Append to the notes of an existing object (defaults to HEAD).
@@ -101,6 +116,25 @@ OPTIONS
        Like '-C', but with '-c' the editor is invoked, so that
        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
+       is taken to be in `refs/notes/` if it is not qualified.
+
+
+NOTES
+-----
+
+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`.
+
+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.
+
+
 Author
 ------
 Written by Johannes Schindelin <johannes.schindelin@gmx.de> and
index 59dc8b197ecb4b6912c9ec29f83f21c405ef8634..48570242fb2dda31a5684e2d678d40690d3c4cab 100644 (file)
@@ -11,7 +11,7 @@ SYNOPSIS
 [verse]
 'git push' [--all | --mirror | --tags] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
           [--repo=<repository>] [-f | --force] [-v | --verbose] [-u | --set-upstream]
-          [<repository> <refspec>...]
+          [<repository> [<refspec>...]]
 
 DESCRIPTION
 -----------
index 823f2a4638c5b53671e294faf7a99a56d17c897a..0d07b1b2077c62f1199c5ee96790e5a7121b4f00 100644 (file)
@@ -274,9 +274,16 @@ which makes little sense.
 -f::
 --force-rebase::
        Force the rebase even if the current branch is a descendant
-       of the commit you are rebasing onto.  Normally the command will
+       of the commit you are rebasing onto.  Normally non-interactive rebase will
        exit with the message "Current branch is up to date" in such a
        situation.
+       Incompatible with the --interactive option.
++
+You may find this (or --no-ff with an interactive rebase) helpful after
+reverting a topic branch merge, as this option recreates the topic branch with
+fresh commits so it can be remerged successfully without needing to "revert
+the reversion" (see the
+link:howto/revert-a-faulty-merge.txt[revert-a-faulty-merge How-To] for details).
 
 --ignore-whitespace::
 --whitespace=<option>::
@@ -316,7 +323,19 @@ which makes little sense.
        commit to be modified, and change the action of the moved
        commit from `pick` to `squash` (or `fixup`).
 +
-This option is only valid when '--interactive' option is used.
+This option is only valid when the '--interactive' option is used.
+
+--no-ff::
+       With --interactive, cherry-pick all rebased commits instead of
+       fast-forwarding over the unchanged ones.  This ensures that the
+       entire history of the rebased branch is composed of new commits.
++
+Without --interactive, this is a synonym for --force-rebase.
++
+You may find this helpful after reverting a topic branch merge, as this option
+recreates the topic branch with fresh commits so it can be remerged
+successfully without needing to "revert the reversion" (see the
+link:howto/revert-a-faulty-merge.txt[revert-a-faulty-merge How-To] for details).
 
 include::merge-strategies.txt[]
 
index 802bd5791cdc74dfa487d3a5591aea67c22f6060..4eaa62b6913f15c354e8008c2884f476428ebb0b 100644 (file)
@@ -18,9 +18,7 @@ depending on the subcommand:
 [verse]
 'git reflog expire' [--dry-run] [--stale-fix] [--verbose]
        [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
-+
 'git reflog delete' ref@\{specifier\}...
-+
 'git reflog' ['show'] [log-options] [<ref>]
 
 Reflog is a mechanism to record when the tip of branches are
index 1b5f61aa0b85ec592c6efbfa8be08fe83f576be5..3a23477ce72763b562258a25c3777dd57ac1a962 100644 (file)
@@ -3,20 +3,69 @@ git-remote-helpers(1)
 
 NAME
 ----
-git-remote-helpers - Helper programs for interoperation with remote git
+git-remote-helpers - Helper programs to interact with remote repositories
 
 SYNOPSIS
 --------
-'git remote-<transport>' <remote>
+'git remote-<transport>' <repository> [<URL>]
 
 DESCRIPTION
 -----------
 
-These programs are normally not used directly by end users, but are
-invoked by various git programs that interact with remote repositories
-when the repository they would operate on will be accessed using
-transport code not linked into the main git binary. Various particular
-helper programs will behave as documented here.
+Remote helper programs are normally not used directly by end users,
+but they are invoked by git when it needs to interact with remote
+repositories git does not support natively.  A given helper will
+implement a subset of the capabilities documented here. When git
+needs to interact with a repository using a remote helper, it spawns
+the helper as an independent process, sends commands to the helper's
+standard input, and expects results from the helper's standard
+output. Because a remote helper runs as an independent process from
+git, there is no need to re-link git to add a new helper, nor any
+need to link the helper with the implementation of git.
+
+Every helper must support the "capabilities" command, which git will
+use to determine what other commands the helper will accept.  Other
+commands generally concern facilities like discovering and updating
+remote refs, transporting objects between the object database and
+the remote repository, and updating the local object store.
+
+Helpers supporting the 'fetch' capability can discover refs from the
+remote repository and transfer objects reachable from those refs to
+the local object store. Helpers supporting the 'push' capability can
+transfer local objects to the remote repository and update remote refs.
+
+Git comes with a "curl" family of remote helpers, that handle various
+transport protocols, such as 'git-remote-http', 'git-remote-https',
+'git-remote-ftp' and 'git-remote-ftps'. They implement the capabilities
+'fetch', 'option', and 'push'.
+
+INVOCATION
+----------
+
+Remote helper programs are invoked with one or (optionally) two
+arguments. The first argument specifies a remote repository as in git;
+it is either the name of a configured remote or a URL. The second
+argument specifies a URL; it is usually of the form
+'<transport>://<address>', but any arbitrary string is possible.
+
+When git encounters a URL of the form '<transport>://<address>', where
+'<transport>' is a protocol that it cannot handle natively, it
+automatically invokes 'git remote-<transport>' with the full URL as
+the second argument. If such a URL is encountered directly on the
+command line, the first argument is the same as the second, and if it
+is encountered in a configured remote, the first argument is the name
+of that remote.
+
+A URL of the form '<transport>::<address>' explicitly instructs git to
+invoke 'git remote-<transport>' with '<address>' as the second
+argument. If such a URL is encountered directly on the command line,
+the first argument is '<address>', and if it is encountered in a
+configured remote, the first argument is the name of that remote.
+
+Additionally, when a configured remote has 'remote.<name>.vcs' set to
+'<transport>', git explicitly invokes 'git remote-<transport>' with
+'<name>' as the first argument. If set, the second argument is
+'remote.<name>.url'; otherwise, the second argument is omitted.
 
 COMMANDS
 --------
@@ -25,8 +74,8 @@ Commands are given by the caller on the helper's standard input, one per line.
 
 'capabilities'::
        Lists the capabilities of the helper, one per line, ending
-       with a blank line. Each capability may be preceded with '*'.
-       This marks them mandatory for git version using the remote
+       with a blank line. Each capability may be preceded with '*',
+       which marks them mandatory for git version using the remote
        helper to understand (unknown mandatory capability is fatal
        error).
 
@@ -35,27 +84,27 @@ Commands are given by the caller on the helper's standard input, one per line.
        [<attr> ...]". The value may be a hex sha1 hash, "@<dest>" for
        a symref, or "?" to indicate that the helper could not get the
        value of the ref. A space-separated list of attributes follows
-       the name; unrecognized attributes are ignored. After the
-       complete list, outputs a blank line.
+       the name; unrecognized attributes are ignored. The list ends
+       with a blank line.
 +
 If 'push' is supported this may be called as 'list for-push'
 to obtain the current refs prior to sending one or more 'push'
 commands to the helper.
 
 'option' <name> <value>::
-       Set the transport helper option <name> to <value>.  Outputs a
+       Sets the transport helper option <name> to <value>.  Outputs a
        single line containing one of 'ok' (option successfully set),
        'unsupported' (option not recognized) or 'error <msg>'
-       (option <name> is supported but <value> is not correct
+       (option <name> is supported but <value> is not valid
        for it).  Options should be set before other commands,
-       and may how those commands behave.
+       and may influence the behavior of those commands.
 +
 Supported if the helper has the "option" capability.
 
 'fetch' <sha1> <name>::
        Fetches the given object, writing the necessary objects
        to the database.  Fetch commands are sent in a batch, one
-       per line, and the batch is terminated with a blank line.
+       per line, terminated with a blank line.
        Outputs a single blank line when all fetch commands in the
        same batch are complete. Only objects which were reported
        in the ref list with a sha1 may be fetched this way.
@@ -67,7 +116,7 @@ suitably updated.
 Supported if the helper has the "fetch" capability.
 
 'push' +<src>:<dst>::
-       Pushes the given <src> commit or branch locally to the
+       Pushes the given local <src> commit or branch to the
        remote branch described by <dst>.  A batch sequence of
        one or more push commands is terminated with a blank line.
 +
@@ -91,6 +140,9 @@ Supported if the helper has the "push" capability.
        by applying the refspecs from the "refspec" capability to the
        name of the ref.
 +
+Especially useful for interoperability with a foreign versioning
+system.
++
 Supported if the helper has the "import" capability.
 
 'connect' <service>::
@@ -119,16 +171,11 @@ CAPABILITIES
 ------------
 
 'fetch'::
-       This helper supports the 'fetch' command.
-
 'option'::
-       This helper supports the option command.
-
 'push'::
-       This helper supports the 'push' command.
-
 'import'::
-       This helper supports the 'import' command.
+'connect'::
+       This helper supports the corresponding command with the same name.
 
 'refspec' 'spec'::
        When using the import command, expect the source ref to have
@@ -140,9 +187,6 @@ CAPABILITIES
        all, it must cover all refs reported by the list command; if
        it is not used, it is effectively "*:*"
 
-'connect'::
-       This helper supports the 'connect' command.
-
 REF LIST ATTRIBUTES
 -------------------
 
@@ -158,19 +202,19 @@ REF LIST ATTRIBUTES
 OPTIONS
 -------
 'option verbosity' <N>::
-       Change the level of messages displayed by the helper.
-       When N is 0 the end-user has asked the process to be
-       quiet, and the helper should produce only error output.
-       N of 1 is the default level of verbosity, higher values
+       Changes the verbosity of messages displayed by the helper.
+       A value of 0 for N means that processes operate
+       quietly, and the helper produces only error output.
+       1 is the default level of verbosity, and higher values
        of N correspond to the number of -v flags passed on the
        command line.
 
 'option progress' \{'true'|'false'\}::
-       Enable (or disable) progress messages displayed by the
+       Enables (or disables) progress messages displayed by the
        transport helper during a command.
 
 'option depth' <depth>::
-       Deepen the history of a shallow repository.
+       Deepens the history of a shallow repository.
 
 'option followtags' \{'true'|'false'\}::
        If enabled the helper should automatically fetch annotated
@@ -186,11 +230,15 @@ OPTIONS
        helpers this only applies to the 'push', if supported.
 
 'option servpath <c-style-quoted-path>'::
-       Set service path (--upload-pack, --receive-pack etc.) for
-       next connect. Remote helper MAY support this option. Remote
-       helper MUST NOT rely on this option being set before
+       Sets service path (--upload-pack, --receive-pack etc.) for
+       next connect. Remote helper may support this option, but
+       must not rely on this option being set before
        connect request occurs.
 
+SEE ALSO
+--------
+linkgit:git-remote[1]
+
 Documentation
 -------------
 Documentation by Daniel Barkalow and Ilari Liusvaara
index ced35b2f532dde3580f162a0c23b642002a0e508..3dfdc7cca6cf27be47bf610da5c84a99d1df7926 100644 (file)
@@ -300,6 +300,21 @@ sendemail.confirm::
        in the previous section for the meaning of these values.
 
 
+Use gmail as the smtp server
+----------------------------
+
+Add the following section to the config file:
+
+       [sendemail]
+               smtpencryption = tls
+               smtpserver = smtp.gmail.com
+               smtpuser = yourname@gmail.com
+               smtpserverport = 587
+
+Note: the following perl modules are required
+      Net::SMTP::SSL, MIME::Base64 and Authen::SASL
+
+
 Author
 ------
 Written by Ryan Anderson <ryan@michonline.com>
index df17d49b87c260c6f5b3fd75d4aad41b77fcf8c3..3f9d9c6db39e030c82e1159043c45c834a47012c 100644 (file)
@@ -10,7 +10,7 @@ SYNOPSIS
 [verse]
 'git show-ref' [-q|--quiet] [--verify] [--head] [-d|--dereference]
             [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]
-            [--heads] [--] <pattern>...
+            [--heads] [--] [<pattern>...]
 'git show-ref' --exclude-existing[=<pattern>] < ref-list
 
 DESCRIPTION
index 1cab91b53455e0129e6c4940a2698620e2197624..2d4bbfcaf4cc2d2b92ad827662dc3b4b4ef355c0 100644 (file)
@@ -72,21 +72,37 @@ In short-format, the status of each path is shown as
 
 where `PATH1` is the path in the `HEAD`, and ` -> PATH2` part is
 shown only when `PATH1` corresponds to a different path in the
-index/worktree (i.e. renamed).
-
-For unmerged entries, `X` shows the status of stage #2 (i.e. ours) and `Y`
-shows the status of stage #3 (i.e. theirs).
-
-For entries that do not have conflicts, `X` shows the status of the index,
-and `Y` shows the status of the work tree.  For untracked paths, `XY` are
-`??`.
+index/worktree (i.e. the file is renamed). The 'XY' is a two-letter
+status code.
+
+The fields (including the `->`) are separated from each other by a
+single space. If a filename contains whitespace or other nonprintable
+characters, that field will be quoted in the manner of a C string
+literal: surrounded by ASCII double quote (34) characters, and with
+interior special characters backslash-escaped.
+
+For paths with merge conflicts, `X` and 'Y' show the modification
+states of each side of the merge. For paths that do not have merge
+conflicts, `X` shows the status of the index, and `Y` shows the status
+of the work tree.  For untracked paths, `XY` are `??`.  Other status
+codes can be interpreted as follows:
+
+* ' ' = unmodified
+* 'M' = modified
+* 'A' = added
+* 'D' = deleted
+* 'R' = renamed
+* 'C' = copied
+* 'U' = updated but unmerged
+
+Ignored files are not listed.
 
     X          Y     Meaning
     -------------------------------------------------
               [MD]   not updated
     M        [ MD]   updated in index
     A        [ MD]   added to index
-    D        [ MD]   deleted from index
+    D         [ M]   deleted from index
     R        [ MD]   renamed in index
     C        [ MD]   copied in index
     [MARC]           index and work tree matches
@@ -104,6 +120,15 @@ and `Y` shows the status of the work tree.  For untracked paths, `XY` are
     ?           ?    untracked
     -------------------------------------------------
 
+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
+order is reversed (e.g 'from -> to' becomes 'to from'). Second, a NUL
+(ASCII 0) follows each filename, replacing space as a field separator
+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.
 
 CONFIGURATION
 -------------
index 35c0c7983d2c18bc0701bc5d6ec22bebc53f792f..c4024d0edd9f77c49e6211c6950c6ccb775a70ff 100644 (file)
@@ -43,9 +43,18 @@ 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.0.2/git.html[documentation for release 1.7.0.2]
+* link:v1.7.1/git.html[documentation for release 1.7.1]
 
 * release notes for
+  link:RelNotes-1.7.1.txt[1.7.1].
+
+* link:v1.7.0.6/git.html[documentation for release 1.7.0.6]
+
+* release notes for
+  link:RelNotes-1.7.0.6.txt[1.7.0.6],
+  link:RelNotes-1.7.0.5.txt[1.7.0.5],
+  link:RelNotes-1.7.0.4.txt[1.7.0.4],
+  link:RelNotes-1.7.0.3.txt[1.7.0.3],
   link:RelNotes-1.7.0.2.txt[1.7.0.2],
   link:RelNotes-1.7.0.1.txt[1.7.0.1],
   link:RelNotes-1.7.0.txt[1.7.0].
index d892e642eded92fd0409e39fc34c005f88bc4a9b..a8500d177289c8ed7371c3ef4703b71b01c71b9c 100644 (file)
@@ -414,6 +414,26 @@ because it quickly conveys the changes you have made), you
 should generate it separately and send it as a comment _in
 addition to_ the usual binary diff that you might send.
 
+Because text conversion can be slow, especially when doing a
+large number of them with `git log -p`, git provides a mechanism
+to cache the output and use it in future diffs.  To enable
+caching, set the "cachetextconv" variable in your diff driver's
+config. For example:
+
+------------------------
+[diff "jpg"]
+       textconv = exif
+       cachetextconv = true
+------------------------
+
+This will cache the result of running "exif" on each blob
+indefinitely. If you change the textconv config variable for a
+diff driver, git will automatically invalidate the cache entries
+and re-run the textconv filter. If you want to invalidate the
+cache manually (e.g., because your version of "exif" was updated
+and now produces better output), you can remove the cache
+manually with `git update-ref -d refs/notes/textconv/jpg` (where
+"jpg" is the name of the diff driver, as in the example above).
 
 Performing a three-way merge
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index dcdea54df3450f82cc898db93474e4be4981187c..9de8caf5d11445f6db7193f7b7a4151c97befb29 100644 (file)
@@ -3,7 +3,7 @@ gitdiffcore(7)
 
 NAME
 ----
-gitdiffcore - Tweaking diff output (June 2005)
+gitdiffcore - Tweaking diff output
 
 SYNOPSIS
 --------
index 87e2c035a7bf1bfff8024db6f4d971ddb5b44e57..7183aa9abbc35018dc50a7c0e5254cc72115af23 100644 (file)
@@ -317,6 +317,44 @@ This hook is invoked by 'git gc --auto'. It takes no parameter, and
 exiting with non-zero status from this script causes the 'git gc --auto'
 to abort.
 
+post-rewrite
+~~~~~~~~~~~~
+
+This hook is invoked by commands that rewrite commits (`git commit
+--amend`, 'git-rebase'; currently 'git-filter-branch' does 'not' call
+it!).  Its first argument denotes the command it was invoked by:
+currently one of `amend` or `rebase`.  Further command-dependent
+arguments may be passed in the future.
+
+The hook receives a list of the rewritten commits on stdin, in the
+format
+
+  <old-sha1> SP <new-sha1> [ SP <extra-info> ] LF
+
+The 'extra-info' is again command-dependent.  If it is empty, the
+preceding SP is also omitted.  Currently, no commands pass any
+'extra-info'.
+
+The hook always runs after the automatic note copying (see
+"notes.rewrite.<command>" in linkgit:git-config.txt) has happened, and
+thus has access to these notes.
+
+The following command-specific comments apply:
+
+rebase::
+       For the 'squash' and 'fixup' operation, all commits that were
+       squashed are listed as being rewritten to the squashed commit.
+       This means that there will be several lines sharing the same
+       'new-sha1'.
++
+The commits are guaranteed to be listed in the order that they were
+processed by rebase.
+
+There is no default 'post-rewrite' hook, but see the
+`post-receive-copy-notes` script in `contrib/hooks` for an example
+that copies your git-notes to the rewritten commits.
+
+
 GIT
 ---
 Part of the linkgit:git[1] suite
index 3b4a390005b07c86ee320ee8ca1cf57e46458cb6..ff5c0bc27a416de16f106c15b9076082c6509e42 100644 (file)
@@ -142,6 +142,8 @@ different resolution strategies:
    revert of a merge was rebuilt from scratch (i.e. rebasing and fixing,
    as you seem to have interpreted), then re-merging the result without
    doing anything else fancy would be the right thing to do.
+   (See the ADDENDUM below for how to rebuild a branch from scratch
+   without changing its original branching-off point.)
 
 However, there are things to keep in mind when reverting a merge (and
 reverting such a revert).
@@ -177,3 +179,91 @@ the answer is: "oops, I really shouldn't have merged it, because it wasn't
 ready yet, and I really need to undo _all_ of the merge"). So then you
 really should revert the merge, but when you want to re-do the merge, you
 now need to do it by reverting the revert.
+
+ADDENDUM
+
+Sometimes you have to rewrite one of a topic branch's commits *and* you can't
+change the topic's branching-off point.  Consider the following situation:
+
+ P---o---o---M---x---x---W---x
+  \         /
+   A---B---C
+
+where commit W reverted commit M because it turned out that commit B was wrong
+and needs to be rewritten, but you need the rewritten topic to still branch
+from commit P (perhaps P is a branching-off point for yet another branch, and
+you want be able to merge the topic into both branches).
+
+The natural thing to do in this case is to checkout the A-B-C branch and use
+"rebase -i P" to change commit B.  However this does not rewrite commit A,
+because "rebase -i" by default fast-forwards over any initial commits selected
+with the "pick" command.  So you end up with this:
+
+ P---o---o---M---x---x---W---x
+  \         /
+   A---B---C   <-- old branch
+    \
+     B'---C'   <-- naively rewritten branch
+
+To merge A-B'-C' into the mainline branch you would still have to first revert
+commit W in order to pick up the changes in A, but then it's likely that the
+changes in B' will conflict with the original B changes re-introduced by the
+reversion of W.
+
+However, you can avoid these problems if you recreate the entire branch,
+including commit A:
+
+   A'---B'---C'  <-- completely rewritten branch
+  /
+ P---o---o---M---x---x---W---x
+  \         /
+   A---B---C
+
+You can merge A'-B'-C' into the mainline branch without worrying about first
+reverting W.  Mainline's history would look like this:
+
+   A'---B'---C'------------------
+  /                              \
+ P---o---o---M---x---x---W---x---M2
+  \         /
+   A---B---C
+
+But if you don't actually need to change commit A, then you need some way to
+recreate it as a new commit with the same changes in it.  The rebase commmand's
+--no-ff option provides a way to do this:
+
+    $ git rebase [-i] --no-ff P
+
+The --no-ff option creates a new branch A'-B'-C' with all-new commits (all the
+SHA IDs will be different) even if in the interactive case you only actually
+modify commit B.  You can then merge this new branch directly into the mainline
+branch and be sure you'll get all of the branch's changes.
+
+You can also use --no-ff in cases where you just add extra commits to the topic
+to fix it up.  Let's revisit the situation discussed at the start of this howto:
+
+ P---o---o---M---x---x---W---x
+  \         /
+   A---B---C----------------D---E   <-- fixed-up topic branch
+
+At this point, you can use --no-ff to recreate the topic branch:
+
+    $ git checkout E
+    $ git rebase --no-ff P
+
+yielding
+
+   A'---B'---C'------------D'---E'  <-- recreated topic branch
+  /
+ P---o---o---M---x---x---W---x
+  \         /
+   A---B---C----------------D---E
+
+You can merge the recreated branch into the mainline without reverting commit W,
+and mainline's history will look like this:
+
+   A'---B'---C'------------D'---E'
+  /                              \
+ P---o---o---M---x---x---W---x---M2
+  \         /
+   A---B---C
index 37ce9a17fc3d66c402954246c83d0ec93fe007af..722d704ff2de1abd3d77a18ca396ba96d5cab6bc 100644 (file)
@@ -62,6 +62,11 @@ option can be used to override --squash.
        is used instead ('git merge-recursive' when merging a single
        head, 'git merge-octopus' otherwise).
 
+-X <option>::
+--strategy-option=<option>::
+       Pass merge strategy specific option through to the merge
+       strategy.
+
 --summary::
 --no-summary::
        Synonyms to --stat and --no-stat; these are deprecated and will be
@@ -76,8 +81,3 @@ ifndef::git-pull[]
 --verbose::
        Be verbose.
 endif::git-pull[]
-
--X <option>::
---strategy-option=<option>::
-       Pass merge strategy specific option through to the merge
-       strategy.
index aa96caeab26ee6132adbef03d2ca17e91f634208..af6d2b995a050007ae088dec8e2c3474e9f06ad5 100644 (file)
@@ -30,9 +30,18 @@ people using 80-column terminals.
        defaults to UTF-8.
 
 --no-notes::
---show-notes::
+--show-notes[=<ref>]::
        Show the notes (see linkgit:git-notes[1]) that annotate the
        commit, when showing the commit log message.  This is the default
        for `git log`, `git show` and `git whatchanged` commands when
        there is no `--pretty`, `--format` nor `--oneline` option is
        given on the command line.
++
+With an optional argument, add this ref to the list of notes.  The ref
+is taken to be in `refs/notes/` if it is not qualified.
+
+--[no-]standard-notes::
+       Enable or disable populating the notes ref list from the
+       'core.notesRef' and 'notes.displayRef' variables (or
+       corresponding environment overrides).  Enabled by default.
+       See linkgit:git-config[1].
index 81c0e6f18498ae72e52e7c7ac0b55429143fabf1..b9fb7a86bd4bf91205b77275fb51ff13a3bc5622 100644 (file)
@@ -108,8 +108,8 @@ options may be given. See linkgit:git-diff-files[1] for more options.
 
 -c::
 
-       This flag changes the way a merge commit is displayed.  It shows
-       the differences from each of the parents to the merge result
+       With this option, diff output for a merge commit
+       shows the differences from each of the parents to the merge result
        simultaneously instead of showing pairwise diff between a parent
        and the result one at a time. Furthermore, it lists only files
        which were modified from all parents.
@@ -121,6 +121,15 @@ options may be given. See linkgit:git-diff-files[1] for more options.
        the parents have only two variants and the merge result picks
        one of them without modification.
 
+-m::
+
+       This flag makes the merge commits show the full diff like
+       regular commits; for each merge parent, a separate log entry
+       and diff is generated. An exception is that only diff against
+       the first parent is shown when '--first-parent' option is given;
+       in that case, the output represents the changes the merge
+       brought _into_ the then-current branch.
+
 -r::
 
        Show recursive diffs.
index 293bb15d206e71f57e906b33ca27ee05e3429521..6d8c24bb1e68e86d70d4a68d02e3a4d5ccb94c2a 100644 (file)
@@ -104,8 +104,12 @@ write `string_list_insert(...)->util = ...;`.
 `unsorted_string_list_has_string`::
 
        It's like `string_list_has_string()` but for unsorted lists.
+
+`unsorted_string_list_lookup`::
+
+       It's like `string_list_lookup()` but for unsorted lists.
 +
-This function needs to look through all items, as opposed to its
+The above two functions need to look through all items, as opposed to their
 counterpart for sorted lists, which performs a binary search.
 
 Data structures
index 9a5cdafa9cb8c5af8a3903ae18297a23adab0fbf..369f91d3b949b23682c4deda8234f13513f15732 100644 (file)
@@ -36,7 +36,7 @@ Git Transport
 
 The Git transport starts off by sending the command and repository
 on the wire using the pkt-line format, followed by a NUL byte and a
-hostname paramater, terminated by a NUL byte.
+hostname parameter, terminated by a NUL byte.
 
    0032git-upload-pack /project.git\0host=myserver.com\0
 
@@ -331,7 +331,7 @@ An incremental update (fetch) response might look like this:
 
    C: 0009done\n
 
-   S: 003aACK 74730d410fcb6603ace96f1dc55ea6196122532d\n
+   S: 0031ACK 74730d410fcb6603ace96f1dc55ea6196122532d\n
    S: [PACKFILE]
 ----
 
@@ -488,7 +488,7 @@ An example client/server communication might look like this:
    C: 0000
    C: [PACKDATA]
 
-   S: 000aunpack ok\n
-   S: 0014ok refs/heads/debug\n
-   S: 0026ng refs/heads/master non-fast-forward\n
+   S: 000eunpack ok\n
+   S: 0018ok refs/heads/debug\n
+   S: 002ang refs/heads/master non-fast-forward\n
 ----
index d813ceb7239bc2d22eb0af4ad33a6e1be8408787..1dcd1e7f1ede3382ae992a266f5437fe06f8dc75 100644 (file)
@@ -1,50 +1,57 @@
 GIT URLS[[URLS]]
 ----------------
 
-One of the following notations can be used
-to name the remote repository:
+In general, URLs contain information about the transport protocol, the
+address of the remote server, and the path to the repository.
+Depending on the transport protocol, some of this information may be
+absent.
+
+Git natively supports ssh, git, http, https, ftp, ftps, and rsync
+protocols. The following syntaxes may be used with them:
 
-===============================================================
-- rsync://host.xz/path/to/repo.git/
-- http://host.xz{startsb}:port{endsb}/path/to/repo.git/
-- https://host.xz{startsb}:port{endsb}/path/to/repo.git/
-- git://host.xz{startsb}:port{endsb}/path/to/repo.git/
-- git://host.xz{startsb}:port{endsb}/~user/path/to/repo.git/
 - ssh://{startsb}user@{endsb}host.xz{startsb}:port{endsb}/path/to/repo.git/
-- ssh://{startsb}user@{endsb}host.xz/path/to/repo.git/
-- ssh://{startsb}user@{endsb}host.xz/~user/path/to/repo.git/
-- ssh://{startsb}user@{endsb}host.xz/~/path/to/repo.git
-===============================================================
-
-SSH is the default transport protocol over the network.  You can
-optionally specify which user to log-in as, and an alternate,
-scp-like syntax is also supported.  Both syntaxes support
-username expansion, as does the native git protocol, but
-only the former supports port specification. The following
-three are identical to the last three above, respectively:
-
-===============================================================
-- {startsb}user@{endsb}host.xz:/path/to/repo.git/
-- {startsb}user@{endsb}host.xz:~user/path/to/repo.git/
-- {startsb}user@{endsb}host.xz:path/to/repo.git
-===============================================================
-
-To sync with a local directory, you can use:
-
-===============================================================
+- git://host.xz{startsb}:port{endsb}/path/to/repo.git/
+- http{startsb}s{endsb}://host.xz{startsb}:port{endsb}/path/to/repo.git/
+- ftp{startsb}s{endsb}://host.xz{startsb}:port{endsb}/path/to/repo.git/
+- rsync://host.xz/path/to/repo.git/
+
+An alternative scp-like syntax may also be used with the ssh protocol:
+
+- {startsb}user@{endsb}host.xz:path/to/repo.git/
+
+The ssh and git protocols additionally support ~username expansion:
+
+- ssh://{startsb}user@{endsb}host.xz{startsb}:port{endsb}/~{startsb}user{endsb}/path/to/repo.git/
+- git://host.xz{startsb}:port{endsb}/~{startsb}user{endsb}/path/to/repo.git/
+- {startsb}user@{endsb}host.xz:/~{startsb}user{endsb}/path/to/repo.git/
+
+For local respositories, also supported by git natively, the following
+syntaxes may be used:
+
 - /path/to/repo.git/
 - file:///path/to/repo.git/
-===============================================================
 
 ifndef::git-clone[]
-They are mostly equivalent, except when cloning.  See
-linkgit:git-clone[1] for details.
+These two syntaxes are mostly equivalent, except when cloning, when
+the former implies --local option. See linkgit:git-clone[1] for
+details.
 endif::git-clone[]
 
 ifdef::git-clone[]
-They are equivalent, except the former implies --local option.
+These two syntaxes are mostly equivalent, except the former implies
+--local option.
 endif::git-clone[]
 
+When git doesn't know how to handle a certain transport protocol, it
+attempts to use the 'remote-<transport>' remote helper, if one
+exists. To explicitly request a remote helper, the following syntax
+may be used:
+
+- <transport>::<address>
+
+where <address> may be a path, a server and path, or an arbitrary
+URL-like string recognized by the specific remote helper being
+invoked. See linkgit:git-remote-helpers[1] for details.
 
 If there are a large number of similarly-named remote repositories and
 you want to use a different format for them (such that the URLs you
index d968ff0fcd89176ab0e3e3866d3f30c172a76133..0ad39484eceab30360e1f46c6057a873ca2c26f1 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v1.7.0.2
+DEF_VER=v1.7.1
 
 LF='
 '
index 3a6c6ea5259693db4846b91855675218b1e1a920..4f7224a59a9c93b12a7878b0f692c1bc469d6daf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -34,7 +34,7 @@ all::
 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
 #
 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
-# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
+# d_type in struct dirent (Cygwin 1.5, fixed in Cygwin 1.7).
 #
 # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
 # do not support the 'size specifiers' introduced by C99, namely ll, hh,
@@ -109,7 +109,7 @@ all::
 # Define NO_PTHREADS if you do not have or do not want to use Pthreads.
 #
 # Define NO_PREAD if you have a problem with pread() system call (e.g.
-# cygwin.dll before v1.5.22).
+# cygwin1.dll before v1.5.22).
 #
 # Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
 # generally faster on your platform than accessing the working directory.
@@ -203,6 +203,9 @@ all::
 # Define JSMIN to point to JavaScript minifier that functions as
 # a filter to have gitweb.js minified.
 #
+# Define CSSMIN to point to a CSS minifier in order to generate a minified
+# version of gitweb.css
+#
 # Define DEFAULT_PAGER to a sensible pager command (defaults to "less") if
 # you want to use something different.  The value will be interpreted by the
 # shell at runtime when it is used.
@@ -279,9 +282,6 @@ lib = lib
 # DESTDIR=
 pathsep = :
 
-# JavaScript minifier invocation that can function as filter
-JSMIN =
-
 export prefix bindir sharedir sysconfdir
 
 CC = gcc
@@ -486,6 +486,7 @@ LIB_H += log-tree.h
 LIB_H += mailmap.h
 LIB_H += merge-recursive.h
 LIB_H += notes.h
+LIB_H += notes-cache.h
 LIB_H += object.h
 LIB_H += pack.h
 LIB_H += pack-refs.h
@@ -575,6 +576,7 @@ LIB_OBJS += merge-file.o
 LIB_OBJS += merge-recursive.o
 LIB_OBJS += name-hash.o
 LIB_OBJS += notes.o
+LIB_OBJS += notes-cache.o
 LIB_OBJS += object.o
 LIB_OBJS += pack-check.o
 LIB_OBJS += pack-refs.o
@@ -831,22 +833,24 @@ ifeq ($(uname_S),SunOS)
        BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__ -DHAVE_ALLOCA_H
 endif
 ifeq ($(uname_O),Cygwin)
-       NO_D_TYPE_IN_DIRENT = YesPlease
-       NO_D_INO_IN_DIRENT = YesPlease
-       NO_STRCASESTR = YesPlease
-       NO_MEMMEM = YesPlease
-       NO_MKSTEMPS = YesPlease
-       NO_SYMLINK_HEAD = YesPlease
+       ifeq ($(shell expr "$(uname_R)" : '1\.[1-6]\.'),4)
+               NO_D_TYPE_IN_DIRENT = YesPlease
+               NO_D_INO_IN_DIRENT = YesPlease
+               NO_STRCASESTR = YesPlease
+               NO_MEMMEM = YesPlease
+               NO_MKSTEMPS = YesPlease
+               NO_SYMLINK_HEAD = YesPlease
+               NO_IPV6 = YesPlease
+               OLD_ICONV = UnfortunatelyYes
+       endif
        NEEDS_LIBICONV = YesPlease
        NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
        NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
-       OLD_ICONV = UnfortunatelyYes
        NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
        # There are conflicting reports about this.
        # On some boxes NO_MMAP is needed, and not so elsewhere.
        # Try commenting this out if you suspect MMAP is more efficient
        NO_MMAP = YesPlease
-       NO_IPV6 = YesPlease
        X = .exe
        COMPAT_OBJS += compat/cygwin.o
        UNRELIABLE_FSTAT = UnfortunatelyYes
@@ -864,6 +868,7 @@ ifeq ($(uname_S),FreeBSD)
                NO_UINTMAX_T = YesPlease
                NO_STRTOUMAX = YesPlease
        endif
+       PYTHON_PATH = /usr/local/bin/python
 endif
 ifeq ($(uname_S),OpenBSD)
        NO_STRCASESTR = YesPlease
@@ -1476,7 +1481,7 @@ endif
 ifndef NO_PYTHON
        $(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
 endif
-       $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
+       $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'
 
 please_set_SHELL_PATH_to_a_more_modern_shell:
        @$$(:)
@@ -1558,18 +1563,29 @@ gitweb:
        $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all
 
 ifdef JSMIN
-OTHER_PROGRAMS += gitweb/gitweb.cgi   gitweb/gitweb.min.js
-gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js
+GITWEB_PROGRAMS += gitweb/gitweb.min.js
+GITWEB_JS = gitweb/gitweb.min.js
 else
-OTHER_PROGRAMS += gitweb/gitweb.cgi
-gitweb/gitweb.cgi: gitweb/gitweb.perl
+GITWEB_JS = gitweb/gitweb.js
 endif
+ifdef CSSMIN
+GITWEB_PROGRAMS += gitweb/gitweb.min.css
+GITWEB_CSS = gitweb/gitweb.min.css
+else
+GITWEB_CSS = gitweb/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
        $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
 endif # JSMIN
+ifdef CSSMIN
+gitweb/gitweb.min.css: gitweb/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
@@ -1579,11 +1595,13 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.
            -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
            -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
            -e '/@@GITWEB_CGI@@/d' \
-           -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
+           -e '/@@GITWEB_CSS@@/r $(GITWEB_CSS)' \
            -e '/@@GITWEB_CSS@@/d' \
-           -e '/@@GITWEB_JS@@/r gitweb/gitweb.js' \
+           -e '/@@GITWEB_JS@@/r $(GITWEB_JS)' \
            -e '/@@GITWEB_JS@@/d' \
            -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 $@+ $@
@@ -1609,9 +1627,8 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
            -e '}' \
            -e 's|^import sys.*|&; \\\
                   import os; \\\
-                  sys.path[0] = os.environ.has_key("GITPYTHONLIB") and \\\
-                                os.environ["GITPYTHONLIB"] or \\\
-                                "@@INSTLIBDIR@@"|' \
+                  sys.path.insert(0, os.getenv("GITPYTHONLIB",\
+                                               "@@INSTLIBDIR@@"));|' \
            -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
            $@.py >$@+ && \
        chmod +x $@+ && \
@@ -2083,7 +2100,7 @@ clean:
        $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
        $(MAKE) -C Documentation/ clean
 ifndef NO_PERL
-       $(RM) gitweb/gitweb.cgi
+       $(MAKE) -C gitweb clean
        $(MAKE) -C perl clean
 endif
 ifndef NO_PYTHON
index 9e1f63ed8dbe8b087f99292880059642d9744697..2ab42aaf4da38b4ea45ef7f0a0f6b807313d4a22 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -198,7 +198,7 @@ void create_branch(const char *head,
                log_all_ref_updates = 1;
 
        if (forcing)
-               snprintf(msg, sizeof msg, "branch: Reset from %s",
+               snprintf(msg, sizeof msg, "branch: Reset to %s",
                         start_name);
        else if (!dont_change_ref)
                snprintf(msg, sizeof msg, "branch: Created from %s",
index cdf98477a662a32790b55b70c23221141377633e..5c887ef61bbf67411a81691c67fc14cc4e0bc682 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -16,10 +16,24 @@ 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 commit_tree(const char *msg, unsigned char *tree,
-               struct commit_list *parents, unsigned char *ret,
-               const char *author);
 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;
+       struct string_list *refs;
+       int refs_from_env;
+       int mode_from_env;
+};
+
+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);
+void finish_copy_notes_for_rewrite(struct notes_rewrite_cfg *c);
+
 extern int check_pager_config(const char *cmd);
 
 extern int cmd_add(int argc, const char **argv, const char *prefix);
index 7ca90472c10eed8535e76b1e0ec25c92af7cff05..660cf92538ce125a83d566f3ba2bb7f2c24f5671 100644 (file)
@@ -2824,11 +2824,8 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
                if (stat_ret < 0) {
                        struct checkout costate;
                        /* checkout */
+                       memset(&costate, 0, sizeof(costate));
                        costate.base_dir = "";
-                       costate.base_dir_len = 0;
-                       costate.force = 0;
-                       costate.quiet = 0;
-                       costate.not_new = 0;
                        costate.refresh_cache = 1;
                        if (checkout_entry(*ce, &costate, NULL) ||
                            lstat(old_name, st))
@@ -3144,11 +3141,7 @@ static void remove_file(struct patch *patch, int rmdir_empty)
                        die("unable to remove %s from index", patch->old_name);
        }
        if (!cached) {
-               if (S_ISGITLINK(patch->old_mode)) {
-                       if (rmdir(patch->old_name))
-                               warning("unable to remove submodule %s",
-                                       patch->old_name);
-               } else if (!unlink_or_warn(patch->old_name) && rmdir_empty) {
+               if (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {
                        remove_path(patch->old_name);
                }
        }
index 05f8fb4771b1ef07030338a6fd38dc7cb3bc1d1d..0bedde41f077f7c6e6106b144854c208ed4f6076 100644 (file)
@@ -302,6 +302,8 @@ static const struct ref *clone_local(const char *src_repo,
        transport = transport_get(remote, src_repo);
        ret = transport_get_remote_refs(transport);
        transport_disconnect(transport);
+       if (0 <= option_verbosity)
+               printf("done.\n");
        return ret;
 }
 
@@ -461,7 +463,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                die("could not create leading directories of '%s'", git_dir);
        set_git_dir(make_absolute_path(git_dir));
 
-       init_db(option_template, (option_verbosity < 0) ? INIT_DB_QUIET : 0);
+       if (0 <= option_verbosity)
+               printf("Cloning into %s...\n", get_git_dir());
+       init_db(option_template, INIT_DB_QUIET);
 
        /*
         * At this point, the config exists, so we do not need the
index 90dac349a3137405baaea63bfb6c798d2f8c92a3..87f0591c2f68a03e06c73b352282426b803450ba 100644 (file)
@@ -9,19 +9,6 @@
 #include "builtin.h"
 #include "utf8.h"
 
-/*
- * FIXME! Share the code with "write-tree.c"
- */
-static void check_valid(unsigned char *sha1, enum object_type expect)
-{
-       enum object_type type = sha1_object_info(sha1, NULL);
-       if (type < 0)
-               die("%s is not a valid object", sha1_to_hex(sha1));
-       if (type != expect)
-               die("%s is not a valid '%s' object", sha1_to_hex(sha1),
-                   typename(expect));
-}
-
 static const char commit_tree_usage[] = "git commit-tree <sha1> [-p <sha1>]* < changelog";
 
 static void new_parent(struct commit *parent, struct commit_list **parents_p)
@@ -38,61 +25,6 @@ static void new_parent(struct commit *parent, struct commit_list **parents_p)
        commit_list_insert(parent, parents_p);
 }
 
-static const char commit_utf8_warn[] =
-"Warning: commit message does not conform to UTF-8.\n"
-"You may want to amend it after fixing the message, or set the config\n"
-"variable i18n.commitencoding to the encoding your project uses.\n";
-
-int commit_tree(const char *msg, unsigned char *tree,
-               struct commit_list *parents, unsigned char *ret,
-               const char *author)
-{
-       int result;
-       int encoding_is_utf8;
-       struct strbuf buffer;
-
-       check_valid(tree, OBJ_TREE);
-
-       /* Not having i18n.commitencoding is the same as having utf-8 */
-       encoding_is_utf8 = is_encoding_utf8(git_commit_encoding);
-
-       strbuf_init(&buffer, 8192); /* should avoid reallocs for the headers */
-       strbuf_addf(&buffer, "tree %s\n", sha1_to_hex(tree));
-
-       /*
-        * NOTE! This ordering means that the same exact tree merged with a
-        * different order of parents will be a _different_ changeset even
-        * if everything else stays the same.
-        */
-       while (parents) {
-               struct commit_list *next = parents->next;
-               strbuf_addf(&buffer, "parent %s\n",
-                       sha1_to_hex(parents->item->object.sha1));
-               free(parents);
-               parents = next;
-       }
-
-       /* Person/date information */
-       if (!author)
-               author = git_author_info(IDENT_ERROR_ON_NO_NAME);
-       strbuf_addf(&buffer, "author %s\n", author);
-       strbuf_addf(&buffer, "committer %s\n", git_committer_info(IDENT_ERROR_ON_NO_NAME));
-       if (!encoding_is_utf8)
-               strbuf_addf(&buffer, "encoding %s\n", git_commit_encoding);
-       strbuf_addch(&buffer, '\n');
-
-       /* And add the comment */
-       strbuf_addstr(&buffer, msg);
-
-       /* And check the encoding */
-       if (encoding_is_utf8 && !is_utf8(buffer.buf))
-               fprintf(stderr, commit_utf8_warn);
-
-       result = write_sha1_file(buffer.buf, buffer.len, commit_type, ret);
-       strbuf_release(&buffer);
-       return result;
-}
-
 int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 {
        int i;
@@ -117,7 +49,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 
                if (get_sha1(b, sha1))
                        die("Not a valid object name %s", b);
-               check_valid(sha1, OBJ_COMMIT);
+               assert_sha1_type(sha1, OBJ_COMMIT);
                new_parent(lookup_commit(sha1), &parents);
        }
 
index f4c73442cfba9483a826dcfbf68f5466d43e8351..c5ab683d5b66d5ad85f53d13d6df71e29cd9234d 100644 (file)
@@ -66,6 +66,7 @@ static char *edit_message, *use_message;
 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;
 static char *untracked_files_arg, *force_date;
 /*
  * The default commit message cleanup mode will remove the lines
@@ -137,6 +138,7 @@ static struct option builtin_commit_options[] = {
        OPT_BOOLEAN('z', "null", &null_termination,
                    "terminate entries with NUL"),
        OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
+       OPT_BOOLEAN(0, "no-post-rewrite", &no_post_rewrite, "bypass post-rewrite hook"),
        { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
        OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"),
        /* end commit contents options */
@@ -305,7 +307,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
         * (B) on failure, rollback the real index.
         */
        if (all || (also && pathspec && *pathspec)) {
-               int fd = hold_locked_index(&index_lock, 1);
+               fd = hold_locked_index(&index_lock, 1);
                add_files_to_cache(also ? prefix : NULL, pathspec, 0);
                refresh_cache_or_die(refresh_flags);
                if (write_cache(fd, active_cache, active_nr) ||
@@ -320,8 +322,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
         *
         * (1) return the name of the real index file.
         *
-        * The caller should run hooks on the real index, and run
-        * hooks on the real index, and create commit from the_index.
+        * The caller should run hooks on the real index,
+        * and create commit from the_index.
         * We still need to refresh the index here.
         */
        if (!pathspec || !*pathspec) {
@@ -1160,6 +1162,40 @@ static int git_commit_config(const char *k, const char *v, void *cb)
        return git_status_config(k, v, s);
 }
 
+static const char post_rewrite_hook[] = "hooks/post-rewrite";
+
+static int run_rewrite_hook(const unsigned char *oldsha1,
+                           const unsigned char *newsha1)
+{
+       /* oldsha1 SP newsha1 LF NUL */
+       static char buf[2*40 + 3];
+       struct child_process proc;
+       const char *argv[3];
+       int code;
+       size_t n;
+
+       if (access(git_path(post_rewrite_hook), X_OK) < 0)
+               return 0;
+
+       argv[0] = git_path(post_rewrite_hook);
+       argv[1] = "amend";
+       argv[2] = NULL;
+
+       memset(&proc, 0, sizeof(proc));
+       proc.argv = argv;
+       proc.in = -1;
+       proc.stdout_to_stderr = 1;
+
+       code = start_command(&proc);
+       if (code)
+               return code;
+       n = snprintf(buf, sizeof(buf), "%s %s\n",
+                    sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
+       write_in_full(proc.in, buf, n);
+       close(proc.in);
+       return finish_command(&proc);
+}
+
 int cmd_commit(int argc, const char **argv, const char *prefix)
 {
        struct strbuf sb = STRBUF_INIT;
@@ -1303,6 +1339,15 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
        rerere(0);
        run_hook(get_index_file(), "post-commit", NULL);
+       if (amend && !no_post_rewrite) {
+               struct notes_rewrite_cfg *cfg;
+               cfg = init_copy_notes_for_rewrite("amend");
+               if (cfg) {
+                       copy_note_for_rewrite(cfg, head_sha1, commit_sha1);
+                       finish_copy_notes_for_rewrite(cfg);
+               }
+               run_rewrite_hook(head_sha1, commit_sha1);
+       }
        if (!quiet)
                print_summary(prefix, commit_sha1);
 
index 2380c21951fb5fb8050ab1acf0e7f01f36ea5520..3c78bda5664e20086bcd500105b039d6241e3782 100644 (file)
@@ -92,12 +92,23 @@ static const char diff_tree_usage[] =
 "  --root        include the initial commit as diff against /dev/null\n"
 COMMON_DIFF_OPTIONS_HELP;
 
+static void diff_tree_tweak_rev(struct rev_info *rev, struct setup_revision_opt *opt)
+{
+       if (!rev->diffopt.output_format) {
+               if (rev->dense_combined_merges)
+                       rev->diffopt.output_format = DIFF_FORMAT_PATCH;
+               else
+                       rev->diffopt.output_format = DIFF_FORMAT_RAW;
+       }
+}
+
 int cmd_diff_tree(int argc, const char **argv, const char *prefix)
 {
        int nr_sha1;
        char line[1000];
        struct object *tree1, *tree2;
        static struct rev_info *opt = &log_tree_opt;
+       struct setup_revision_opt s_r_opt;
        int read_stdin = 0;
 
        init_revisions(opt, prefix);
@@ -105,7 +116,9 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
        opt->abbrev = 0;
        opt->diff = 1;
        opt->disable_stdin = 1;
-       argc = setup_revisions(argc, argv, opt, NULL);
+       memset(&s_r_opt, 0, sizeof(s_r_opt));
+       s_r_opt.tweak = diff_tree_tweak_rev;
+       argc = setup_revisions(argc, argv, opt, &s_r_opt);
 
        while (--argc > 0) {
                const char *arg = *++argv;
@@ -117,9 +130,6 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
                usage(diff_tree_usage);
        }
 
-       if (!opt->diffopt.output_format)
-               opt->diffopt.output_format = DIFF_FORMAT_RAW;
-
        /*
         * NOTE! We expect "a ^b" to be equal to "a..b", so we
         * reverse the order of the objects if the second one
index b0a4029c94d1bdb1c673fe604cdbfec93df875aa..c6dd71a7bcd0dfcb4691c9ca66a0c3a7bd4dcaae 100644 (file)
@@ -503,7 +503,7 @@ static void export_marks(char *file)
 
        f = fopen(file, "w");
        if (!f)
-               error("Unable to open marks file %s for writing.", file);
+               die_errno("Unable to open marks file %s for writing.", file);
 
        for (i = 0; i < idnums.size; i++) {
                if (deco->base && deco->base->type == 1) {
index 957be9f9269c657fb094b1b3daa4f309c1324ae0..8470850415c14cad8ceeca9f6baef46ab6feabc3 100644 (file)
 #include "transport.h"
 
 static const char * const builtin_fetch_usage[] = {
-       "git fetch [options] [<repository> <refspec>...]",
-       "git fetch [options] <group>",
-       "git fetch --multiple [options] [<repository> | <group>]...",
-       "git fetch --all [options]",
+       "git fetch [<options>] [<repository> [<refspec>...]]",
+       "git fetch [<options>] <group>",
+       "git fetch --multiple [<options>] [<repository> | <group>]...",
+       "git fetch --all [<options>]",
        NULL
 };
 
index 9d524000b5ba4d9c7566edd5756b68d728ec362b..379a03131fbd84fb2b45a6b05e62daf82b7e4947 100644 (file)
@@ -4,6 +4,7 @@
 #include "diff.h"
 #include "revision.h"
 #include "tag.h"
+#include "string-list.h"
 
 static const char * const fmt_merge_msg_usage[] = {
        "git fmt-merge-msg [--log|--no-log] [--file <file>]",
@@ -24,58 +25,21 @@ static int fmt_merge_msg_config(const char *key, const char *value, void *cb)
        return 0;
 }
 
-struct list {
-       char **list;
-       void **payload;
-       unsigned nr, alloc;
+struct src_data {
+       struct string_list branch, tag, r_branch, generic;
+       int head_status;
 };
 
-static void append_to_list(struct list *list, char *value, void *payload)
-{
-       if (list->nr == list->alloc) {
-               list->alloc += 32;
-               list->list = xrealloc(list->list, sizeof(char *) * list->alloc);
-               list->payload = xrealloc(list->payload,
-                               sizeof(char *) * list->alloc);
-       }
-       list->payload[list->nr] = payload;
-       list->list[list->nr++] = value;
-}
-
-static int find_in_list(struct list *list, char *value)
-{
-       int i;
-
-       for (i = 0; i < list->nr; i++)
-               if (!strcmp(list->list[i], value))
-                       return i;
-
-       return -1;
-}
-
-static void free_list(struct list *list)
+void init_src_data(struct src_data *data)
 {
-       int i;
-
-       if (list->alloc == 0)
-               return;
-
-       for (i = 0; i < list->nr; i++) {
-               free(list->list[i]);
-               free(list->payload[i]);
-       }
-       free(list->list);
-       free(list->payload);
-       list->nr = list->alloc = 0;
+       data->branch.strdup_strings = 1;
+       data->tag.strdup_strings = 1;
+       data->r_branch.strdup_strings = 1;
+       data->generic.strdup_strings = 1;
 }
 
-struct src_data {
-       struct list branch, tag, r_branch, generic;
-       int head_status;
-};
-
-static struct list srcs = { NULL, NULL, 0, 0};
-static struct list origins = { NULL, NULL, 0, 0};
+static struct string_list srcs = { NULL, 0, 0, 1 };
+static struct string_list origins = { NULL, 0, 0, 1 };
 
 static int handle_line(char *line)
 {
@@ -83,6 +47,7 @@ static int handle_line(char *line)
        unsigned char *sha1;
        char *src, *origin;
        struct src_data *src_data;
+       struct string_list_item *item;
        int pulling_head = 0;
 
        if (len < 43 || line[40] != '\t')
@@ -115,64 +80,62 @@ static int handle_line(char *line)
                pulling_head = 1;
        }
 
-       i = find_in_list(&srcs, src);
-       if (i < 0) {
-               i = srcs.nr;
-               append_to_list(&srcs, xstrdup(src),
-                               xcalloc(1, sizeof(struct src_data)));
+       item = unsorted_string_list_lookup(&srcs, src);
+       if (!item) {
+               item = string_list_append(src, &srcs);
+               item->util = xcalloc(1, sizeof(struct src_data));
+               init_src_data(item->util);
        }
-       src_data = srcs.payload[i];
+       src_data = item->util;
 
        if (pulling_head) {
-               origin = xstrdup(src);
+               origin = src;
                src_data->head_status |= 1;
        } else if (!prefixcmp(line, "branch ")) {
-               origin = xstrdup(line + 7);
-               append_to_list(&src_data->branch, origin, NULL);
+               origin = line + 7;
+               string_list_append(origin, &src_data->branch);
                src_data->head_status |= 2;
        } else if (!prefixcmp(line, "tag ")) {
                origin = line;
-               append_to_list(&src_data->tag, xstrdup(origin + 4), NULL);
+               string_list_append(origin + 4, &src_data->tag);
                src_data->head_status |= 2;
        } else if (!prefixcmp(line, "remote branch ")) {
-               origin = xstrdup(line + 14);
-               append_to_list(&src_data->r_branch, origin, NULL);
+               origin = line + 14;
+               string_list_append(origin, &src_data->r_branch);
                src_data->head_status |= 2;
        } else {
-               origin = xstrdup(src);
-               append_to_list(&src_data->generic, xstrdup(line), NULL);
+               origin = src;
+               string_list_append(line, &src_data->generic);
                src_data->head_status |= 2;
        }
 
        if (!strcmp(".", src) || !strcmp(src, origin)) {
                int len = strlen(origin);
-               if (origin[0] == '\'' && origin[len - 1] == '\'') {
+               if (origin[0] == '\'' && origin[len - 1] == '\'')
                        origin = xmemdupz(origin + 1, len - 2);
-               } else {
-                       origin = xstrdup(origin);
-               }
        } else {
                char *new_origin = xmalloc(strlen(origin) + strlen(src) + 5);
                sprintf(new_origin, "%s of %s", origin, src);
                origin = new_origin;
        }
-       append_to_list(&origins, origin, sha1);
+       string_list_append(origin, &origins)->util = sha1;
        return 0;
 }
 
 static void print_joined(const char *singular, const char *plural,
-               struct list *list, struct strbuf *out)
+               struct string_list *list, struct strbuf *out)
 {
        if (list->nr == 0)
                return;
        if (list->nr == 1) {
-               strbuf_addf(out, "%s%s", singular, list->list[0]);
+               strbuf_addf(out, "%s%s", singular, list->items[0].string);
        } else {
                int i;
                strbuf_addstr(out, plural);
                for (i = 0; i < list->nr - 1; i++)
-                       strbuf_addf(out, "%s%s", i > 0 ? ", " : "", list->list[i]);
-               strbuf_addf(out, " and %s", list->list[list->nr - 1]);
+                       strbuf_addf(out, "%s%s", i > 0 ? ", " : "",
+                                   list->items[i].string);
+               strbuf_addf(out, " and %s", list->items[list->nr - 1].string);
        }
 }
 
@@ -183,8 +146,9 @@ static void shortlog(const char *name, unsigned char *sha1,
        int i, count = 0;
        struct commit *commit;
        struct object *branch;
-       struct list subjects = { NULL, NULL, 0, 0 };
+       struct string_list subjects = { NULL, 0, 0, 1 };
        int flags = UNINTERESTING | TREESAME | SEEN | SHOWN | ADDED;
+       struct strbuf sb = STRBUF_INIT;
 
        branch = deref_tag(parse_object(sha1), sha1_to_hex(sha1), 40);
        if (!branch || branch->type != OBJ_COMMIT)
@@ -198,7 +162,7 @@ static void shortlog(const char *name, unsigned char *sha1,
        if (prepare_revision_walk(rev))
                die("revision walk setup failed");
        while ((commit = get_revision(rev)) != NULL) {
-               char *oneline, *bol, *eol;
+               struct pretty_print_context ctx = {0};
 
                /* ignore merges */
                if (commit->parents && commit->parents->next)
@@ -208,30 +172,14 @@ static void shortlog(const char *name, unsigned char *sha1,
                if (subjects.nr > limit)
                        continue;
 
-               bol = strstr(commit->buffer, "\n\n");
-               if (bol) {
-                       unsigned char c;
-                       do {
-                               c = *++bol;
-                       } while (isspace(c));
-                       if (!c)
-                               bol = NULL;
-               }
-
-               if (!bol) {
-                       append_to_list(&subjects, xstrdup(sha1_to_hex(
-                                                       commit->object.sha1)),
-                                       NULL);
-                       continue;
-               }
+               format_commit_message(commit, "%s", &sb, &ctx);
+               strbuf_ltrim(&sb);
 
-               eol = strchr(bol, '\n');
-               if (eol) {
-                       oneline = xmemdupz(bol, eol - bol);
-               } else {
-                       oneline = xstrdup(bol);
-               }
-               append_to_list(&subjects, oneline, NULL);
+               if (!sb.len)
+                       string_list_append(sha1_to_hex(commit->object.sha1),
+                                          &subjects);
+               else
+                       string_list_append(strbuf_detach(&sb, NULL), &subjects);
        }
 
        if (count > limit)
@@ -243,7 +191,7 @@ static void shortlog(const char *name, unsigned char *sha1,
                if (i >= limit)
                        strbuf_addf(out, "  ...\n");
                else
-                       strbuf_addf(out, "  %s\n", subjects.list[i]);
+                       strbuf_addf(out, "  %s\n", subjects.items[i].string);
 
        clear_commit_marks((struct commit *)branch, flags);
        clear_commit_marks(head, flags);
@@ -251,7 +199,7 @@ static void shortlog(const char *name, unsigned char *sha1,
        rev->commits = NULL;
        rev->pending.nr = 0;
 
-       free_list(&subjects);
+       string_list_clear(&subjects, 0);
 }
 
 int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
@@ -281,16 +229,19 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
                        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++) {
-               struct src_data *src_data = srcs.payload[i];
+               struct src_data *src_data = srcs.items[i].util;
                const char *subsep = "";
 
                strbuf_addstr(out, sep);
                sep = "; ";
 
                if (src_data->head_status == 1) {
-                       strbuf_addstr(out, srcs.list[i]);
+                       strbuf_addstr(out, srcs.items[i].string);
                        continue;
                }
                if (src_data->head_status == 3) {
@@ -319,8 +270,8 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
                        print_joined("commit ", "commits ", &src_data->generic,
                                        out);
                }
-               if (strcmp(".", srcs.list[i]))
-                       strbuf_addf(out, " of %s", srcs.list[i]);
+               if (strcmp(".", srcs.items[i].string))
+                       strbuf_addf(out, " of %s", srcs.items[i].string);
        }
 
        if (!strcmp("master", current_branch))
@@ -339,7 +290,7 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
                rev.limited = 1;
 
                for (i = 0; i < origins.nr; i++)
-                       shortlog(origins.list[i], origins.payload[i],
+                       shortlog(origins.items[i].string, origins.items[i].util,
                                        head, &rev, limit, out);
        }
        return 0;
@@ -350,7 +301,9 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
        const char *inpath = NULL;
        struct option options[] = {
                OPT_BOOLEAN(0, "log",     &merge_summary, "populate log with the shortlog"),
-               OPT_BOOLEAN(0, "summary", &merge_summary, "alias for --log"),
+               { OPTION_BOOLEAN, 0, "summary", &merge_summary, NULL,
+                 "alias for --log (deprecated)",
+                 PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
                OPT_FILENAME('F', "file", &inpath, "file to read from"),
                OPT_END()
        };
index 9d30ddb28df16f834c9fbb3bf6ba8cc172a502b3..8e928e217041a159f4a962f0883d740aa84536d7 100644 (file)
@@ -96,6 +96,9 @@ static pthread_cond_t cond_write;
 /* Signalled when we are finished with everything. */
 static pthread_cond_t cond_result;
 
+static int print_hunk_marks_between_files;
+static int printed_something;
+
 static void add_work(enum work_type type, char *name, void *id)
 {
        grep_lock();
@@ -159,7 +162,12 @@ static void work_done(struct work_item *w)
        for(; todo[todo_done].done && todo_done != todo_start;
            todo_done = (todo_done+1) % ARRAY_SIZE(todo)) {
                w = &todo[todo_done];
-               write_or_die(1, w->out.buf, w->out.len);
+               if (w->out.len) {
+                       if (print_hunk_marks_between_files && printed_something)
+                               write_or_die(1, "--\n", 3);
+                       write_or_die(1, w->out.buf, w->out.len);
+                       printed_something = 1;
+               }
                free(w->name);
                free(w->identifier);
        }
@@ -946,8 +954,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
        if (online_cpus() == 1 || !grep_threads_ok(&opt))
                use_threads = 0;
 
-       if (use_threads)
+       if (use_threads) {
+               if (opt.pre_context || opt.post_context)
+                       print_hunk_marks_between_files = 1;
                start_threads(&opt);
+       }
 #else
        use_threads = 0;
 #endif
index b4cf8c53e0ebbee65a0e4bc0ac1afd1173d1b8e8..03d0cd2f47016b59994a75c11403061fcad8a165 100644 (file)
@@ -11,7 +11,7 @@
 #include "exec_cmd.h"
 
 static const char index_pack_usage[] =
-"git index-pack [-v] [-o <index-file>] [{ ---keep | --keep=<msg> }] [--strict] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }";
+"git index-pack [-v] [-o <index-file>] [{ --keep | --keep=<msg> }] [--strict] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }";
 
 struct object_entry
 {
index 9fbc7ab9cee8176ff3e85ec28995d2cd8d992d31..6208703c061abb868201073795cf516bf81b2602 100644 (file)
@@ -32,10 +32,11 @@ static const char * const builtin_log_usage =
        "   or: git show [options] <object>...";
 
 static void cmd_log_init(int argc, const char **argv, const char *prefix,
-                     struct rev_info *rev)
+                        struct rev_info *rev, struct setup_revision_opt *opt)
 {
        int i;
        int decoration_style = 0;
+       struct userformat_want w;
 
        rev->abbrev = DEFAULT_ABBREV;
        rev->commit_format = CMIT_FMT_DEFAULT;
@@ -56,10 +57,15 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
         */
        if (argc == 2 && !strcmp(argv[1], "-h"))
                usage(builtin_log_usage);
-       argc = setup_revisions(argc, argv, rev, "HEAD");
+       argc = setup_revisions(argc, argv, rev, opt);
 
-       if (!rev->show_notes_given && !rev->pretty_given)
+       memset(&w, 0, sizeof(w));
+       userformat_find_requirements(NULL, &w);
+
+       if (!rev->show_notes_given && (!rev->pretty_given || w.notes))
                rev->show_notes = 1;
+       if (rev->show_notes)
+               init_display_notes(&rev->notes_opt);
 
        if (rev->diffopt.pickaxe || rev->diffopt.filter)
                rev->always_show_header = 0;
@@ -262,6 +268,7 @@ static int git_log_config(const char *var, const char *value, void *cb)
 int cmd_whatchanged(int argc, const char **argv, const char *prefix)
 {
        struct rev_info rev;
+       struct setup_revision_opt opt;
 
        git_config(git_log_config, NULL);
 
@@ -271,7 +278,9 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
        init_revisions(&rev, prefix);
        rev.diff = 1;
        rev.simplify_history = 0;
-       cmd_log_init(argc, argv, prefix, &rev);
+       memset(&opt, 0, sizeof(opt));
+       opt.def = "HEAD";
+       cmd_log_init(argc, argv, prefix, &rev, &opt);
        if (!rev.diffopt.output_format)
                rev.diffopt.output_format = DIFF_FORMAT_RAW;
        return cmd_log_walk(&rev);
@@ -324,10 +333,26 @@ static int show_tree_object(const unsigned char *sha1,
        return 0;
 }
 
+static void show_rev_tweak_rev(struct rev_info *rev, struct setup_revision_opt *opt)
+{
+       if (rev->ignore_merges) {
+               /* There was no "-m" on the command line */
+               rev->ignore_merges = 0;
+               if (!rev->first_parent_only && !rev->combine_merges) {
+                       /* No "--first-parent", "-c", nor "--cc" */
+                       rev->combine_merges = 1;
+                       rev->dense_combined_merges = 1;
+               }
+       }
+       if (!rev->diffopt.output_format)
+               rev->diffopt.output_format = DIFF_FORMAT_PATCH;
+}
+
 int cmd_show(int argc, const char **argv, const char *prefix)
 {
        struct rev_info rev;
        struct object_array_entry *objects;
+       struct setup_revision_opt opt;
        int i, count, ret = 0;
 
        git_config(git_log_config, NULL);
@@ -337,12 +362,12 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 
        init_revisions(&rev, prefix);
        rev.diff = 1;
-       rev.combine_merges = 1;
-       rev.dense_combined_merges = 1;
        rev.always_show_header = 1;
-       rev.ignore_merges = 0;
        rev.no_walk = 1;
-       cmd_log_init(argc, argv, prefix, &rev);
+       memset(&opt, 0, sizeof(opt));
+       opt.def = "HEAD";
+       opt.tweak = show_rev_tweak_rev;
+       cmd_log_init(argc, argv, prefix, &rev, &opt);
 
        count = rev.pending.nr;
        objects = rev.pending.objects;
@@ -405,6 +430,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 int cmd_log_reflog(int argc, const char **argv, const char *prefix)
 {
        struct rev_info rev;
+       struct setup_revision_opt opt;
 
        git_config(git_log_config, NULL);
 
@@ -415,7 +441,9 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
        init_reflog_walk(&rev.reflog_info);
        rev.abbrev_commit = 1;
        rev.verbose_header = 1;
-       cmd_log_init(argc, argv, prefix, &rev);
+       memset(&opt, 0, sizeof(opt));
+       opt.def = "HEAD";
+       cmd_log_init(argc, argv, prefix, &rev, &opt);
 
        /*
         * This means that we override whatever commit format the user gave
@@ -438,6 +466,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
 int cmd_log(int argc, const char **argv, const char *prefix)
 {
        struct rev_info rev;
+       struct setup_revision_opt opt;
 
        git_config(git_log_config, NULL);
 
@@ -446,7 +475,9 @@ int cmd_log(int argc, const char **argv, const char *prefix)
 
        init_revisions(&rev, prefix);
        rev.always_show_header = 1;
-       cmd_log_init(argc, argv, prefix, &rev);
+       memset(&opt, 0, sizeof(opt));
+       opt.def = "HEAD";
+       cmd_log_init(argc, argv, prefix, &rev, &opt);
        return cmd_log_walk(&rev);
 }
 
@@ -902,6 +933,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        struct commit *commit;
        struct commit **list = NULL;
        struct rev_info rev;
+       struct setup_revision_opt s_r_opt;
        int nr = 0, total, i;
        int use_stdout = 0;
        int start_number = -1;
@@ -983,8 +1015,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        rev.combine_merges = 0;
        rev.ignore_merges = 1;
        DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
-
        rev.subject_prefix = fmt_patch_subject_prefix;
+       memset(&s_r_opt, 0, sizeof(s_r_opt));
+       s_r_opt.def = "HEAD";
 
        if (default_attach) {
                rev.mime_boundary = default_attach;
@@ -1056,7 +1089,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        if (keep_subject && subject_prefix)
                die ("--subject-prefix and -k are mutually exclusive.");
 
-       argc = setup_revisions(argc, argv, &rev, "HEAD");
+       argc = setup_revisions(argc, argv, &rev, &s_r_opt);
        if (argc > 1)
                die ("unrecognized argument: %s", argv[1]);
 
@@ -1078,6 +1111,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
                DIFF_OPT_SET(&rev.diffopt, BINARY);
 
+       if (rev.show_notes)
+               init_display_notes(&rev.notes_opt);
+
        if (!use_stdout)
                output_directory = set_outdir(prefix, output_directory);
 
@@ -1125,8 +1161,15 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                        return 0;
        }
 
-       if (ignore_if_in_upstream)
+       if (ignore_if_in_upstream) {
+               /* Don't say anything if head and upstream are the same. */
+               if (rev.pending.nr == 2) {
+                       struct object_array_entry *o = rev.pending.objects;
+                       if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0)
+                               return 0;
+               }
                get_patch_ids(&rev, &ids, prefix);
+       }
 
        if (!use_stdout)
                realstdout = xfdopen(xdup(1), "w");
@@ -1264,8 +1307,11 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
        return -1;
 }
 
-static const char cherry_usage[] =
-"git cherry [-v] [<upstream> [<head> [<limit>]]]";
+static const char * const cherry_usage[] = {
+       "git cherry [-v] [<upstream> [<head> [<limit>]]]",
+       NULL
+};
+
 int cmd_cherry(int argc, const char **argv, const char *prefix)
 {
        struct rev_info revs;
@@ -1276,26 +1322,25 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
        const char *upstream;
        const char *head = "HEAD";
        const char *limit = NULL;
-       int verbose = 0;
+       int verbose = 0, abbrev = 0;
 
-       if (argc > 1 && !strcmp(argv[1], "-v")) {
-               verbose = 1;
-               argc--;
-               argv++;
-       }
+       struct option options[] = {
+               OPT__ABBREV(&abbrev),
+               OPT__VERBOSE(&verbose),
+               OPT_END()
+       };
 
-       if (argc > 1 && !strcmp(argv[1], "-h"))
-               usage(cherry_usage);
+       argc = parse_options(argc, argv, prefix, options, cherry_usage, 0);
 
        switch (argc) {
-       case 4:
-               limit = argv[3];
-               /* FALLTHROUGH */
        case 3:
-               head = argv[2];
+               limit = argv[2];
                /* FALLTHROUGH */
        case 2:
-               upstream = argv[1];
+               head = argv[1];
+               /* FALLTHROUGH */
+       case 1:
+               upstream = argv[0];
                break;
        default:
                current_branch = branch_get(NULL);
@@ -1305,7 +1350,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
                        fprintf(stderr, "Could not find a tracked"
                                        " remote branch, please"
                                        " specify <upstream> manually.\n");
-                       usage(cherry_usage);
+                       usage_with_options(cherry_usage, options);
                }
 
                upstream = current_branch->merge[0]->dst;
@@ -1358,12 +1403,13 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
                        pretty_print_commit(CMIT_FMT_ONELINE, commit,
                                            &buf, &ctx);
                        printf("%c %s %s\n", sign,
-                              sha1_to_hex(commit->object.sha1), buf.buf);
+                              find_unique_abbrev(commit->object.sha1, abbrev),
+                              buf.buf);
                        strbuf_release(&buf);
                }
                else {
                        printf("%c %s\n", sign,
-                              sha1_to_hex(commit->object.sha1));
+                              find_unique_abbrev(commit->object.sha1, abbrev));
                }
 
                list = list->next;
index b065061392718e4250d2c52dc3d53a0c1c7938e9..c0fbcdcf4f3447c29c4058907ea2e25fa6d225a6 100644 (file)
@@ -153,8 +153,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
                printf("%s%06o %s %d\t",
                       tag,
                       ce->ce_mode,
-                      abbrev ? find_unique_abbrev(ce->sha1,abbrev)
-                               : sha1_to_hex(ce->sha1),
+                      find_unique_abbrev(ce->sha1,abbrev),
                       ce_stage(ce));
        }
        write_name_quoted(ce->name + offset, stdout, line_terminator);
@@ -176,9 +175,7 @@ static int show_one_ru(struct string_list_item *item, void *cbdata)
                if (!ui->mode[i])
                        continue;
                printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i],
-                      abbrev
-                      ? find_unique_abbrev(ui->sha1[i], abbrev)
-                      : sha1_to_hex(ui->sha1[i]),
+                      find_unique_abbrev(ui->sha1[i], abbrev),
                       i + 1);
                write_name_quoted(path + offset, stdout, line_terminator);
        }
index 4484185afc4c144bc0d88d9c3832cbeb1515841b..dc86b0d9a997f98ad43ca2897055a92b8a3eb7d0 100644 (file)
@@ -103,13 +103,11 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
                        } else
                                strcpy(size_text, "-");
                        printf("%06o %s %s %7s\t", mode, type,
-                              abbrev ? find_unique_abbrev(sha1, abbrev)
-                                     : sha1_to_hex(sha1),
+                              find_unique_abbrev(sha1, abbrev),
                               size_text);
                } else
                        printf("%06o %s %s\t", mode, type,
-                              abbrev ? find_unique_abbrev(sha1, abbrev)
-                                     : sha1_to_hex(sha1));
+                              find_unique_abbrev(sha1, abbrev));
        }
        write_name_quotedpfx(base + chomp_prefix, baselen - chomp_prefix,
                          pathname, stdout, line_termination);
index ce2ef6bede40fde8823336bc85762bd3e7cd4760..4a9729b9b388a1e589e9250d8157e723c68140de 100644 (file)
@@ -746,7 +746,8 @@ static int is_scissors_line(const struct strbuf *line)
                        continue;
                }
                if (i + 1 < len &&
-                   (!memcmp(buf + i, ">8", 2) || !memcmp(buf + i, "8<", 2))) {
+                   (!memcmp(buf + i, ">8", 2) || !memcmp(buf + i, "8<", 2) ||
+                    !memcmp(buf + i, ">%", 2) || !memcmp(buf + i, "%<", 2))) {
                        in_perforation = 1;
                        perforation += 2;
                        scissors += 2;
index 64c6c6f393ffd9a8cc55883cac863c6ab09639a8..37d414b3ba95162953aec001e6036956eb1a97f6 100644 (file)
@@ -676,7 +676,7 @@ static int count_unmerged_entries(void)
        return ret;
 }
 
-static int checkout_fast_forward(unsigned char *head, unsigned char *remote)
+int checkout_fast_forward(const unsigned char *head, const unsigned char *remote)
 {
        struct tree *trees[MAX_UNPACK_TREES];
        struct unpack_trees_options opts;
index feb710ac4ada96339e42fe5838cf137e9ae4f12e..52b72fca687d42dc09d1d79a8e76584a55c0c546 100644 (file)
 #include "exec_cmd.h"
 #include "run-command.h"
 #include "parse-options.h"
+#include "string-list.h"
 
 static const char * const git_notes_usage[] = {
+       "git notes [--ref <notes_ref>] [list [<object>]]",
+       "git notes [--ref <notes_ref>] add [-f] [-m <msg> | -F <file> | (-c | -C) <object>] [<object>]",
+       "git notes [--ref <notes_ref>] copy [-f] <from-object> <to-object>",
+       "git notes [--ref <notes_ref>] append [-m <msg> | -F <file> | (-c | -C) <object>] [<object>]",
+       "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",
+       NULL
+};
+
+static const char * const git_notes_list_usage[] = {
        "git notes [list [<object>]]",
-       "git notes add [-f] [-m <msg> | -F <file> | (-c | -C) <object>] [<object>]",
-       "git notes copy [-f] <from-object> <to-object>",
-       "git notes append [-m <msg> | -F <file> | (-c | -C) <object>] [<object>]",
+       NULL
+};
+
+static const char * const git_notes_add_usage[] = {
+       "git notes add [<options>] [<object>]",
+       NULL
+};
+
+static const char * const git_notes_copy_usage[] = {
+       "git notes copy [<options>] <from-object> <to-object>",
+       "git notes copy --stdin [<from-object> <to-object>]...",
+       NULL
+};
+
+static const char * const git_notes_append_usage[] = {
+       "git notes append [<options>] [<object>]",
+       NULL
+};
+
+static const char * const git_notes_edit_usage[] = {
        "git notes edit [<object>]",
+       NULL
+};
+
+static const char * const git_notes_show_usage[] = {
        "git notes show [<object>]",
+       NULL
+};
+
+static const char * const git_notes_remove_usage[] = {
        "git notes remove [<object>]",
+       NULL
+};
+
+static const char * const git_notes_prune_usage[] = {
        "git notes prune",
        NULL
 };
@@ -239,6 +281,8 @@ int commit_notes(struct notes_tree *t, const char *msg)
                t = &default_notes_tree;
        if (!t->initialized || !t->ref || !*t->ref)
                die("Cannot commit uninitialized/unreferenced notes tree");
+       if (!t->dirty)
+               return 0; /* don't have to commit an unchanged tree */
 
        /* Prepare commit message and reflog message */
        strbuf_addstr(&buf, "notes: "); /* commit message starts at index 7 */
@@ -269,20 +313,219 @@ int commit_notes(struct notes_tree *t, const char *msg)
        return 0;
 }
 
-int cmd_notes(int argc, const char **argv, const char *prefix)
+combine_notes_fn *parse_combine_notes_fn(const char *v)
+{
+       if (!strcasecmp(v, "overwrite"))
+               return combine_notes_overwrite;
+       else if (!strcasecmp(v, "ignore"))
+               return combine_notes_ignore;
+       else if (!strcasecmp(v, "concatenate"))
+               return combine_notes_concatenate;
+       else
+               return NULL;
+}
+
+static int notes_rewrite_config(const char *k, const char *v, void *cb)
+{
+       struct notes_rewrite_cfg *c = cb;
+       if (!prefixcmp(k, "notes.rewrite.") && !strcmp(k+14, c->cmd)) {
+               c->enabled = git_config_bool(k, v);
+               return 0;
+       } else if (!c->mode_from_env && !strcmp(k, "notes.rewritemode")) {
+               if (!v)
+                       config_error_nonbool(k);
+               c->combine = parse_combine_notes_fn(v);
+               if (!c->combine) {
+                       error("Bad notes.rewriteMode value: '%s'", v);
+                       return 1;
+               }
+               return 0;
+       } else if (!c->refs_from_env && !strcmp(k, "notes.rewriteref")) {
+               /* note that a refs/ prefix is implied in the
+                * underlying for_each_glob_ref */
+               if (!prefixcmp(v, "refs/notes/"))
+                       string_list_add_refs_by_glob(c->refs, v);
+               else
+                       warning("Refusing to rewrite notes in %s"
+                               " (outside of refs/notes/)", v);
+               return 0;
+       }
+
+       return 0;
+}
+
+
+struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd)
+{
+       struct notes_rewrite_cfg *c = xmalloc(sizeof(struct notes_rewrite_cfg));
+       const char *rewrite_mode_env = getenv(GIT_NOTES_REWRITE_MODE_ENVIRONMENT);
+       const char *rewrite_refs_env = getenv(GIT_NOTES_REWRITE_REF_ENVIRONMENT);
+       c->cmd = cmd;
+       c->enabled = 1;
+       c->combine = combine_notes_concatenate;
+       c->refs = xcalloc(1, sizeof(struct string_list));
+       c->refs->strdup_strings = 1;
+       c->refs_from_env = 0;
+       c->mode_from_env = 0;
+       if (rewrite_mode_env) {
+               c->mode_from_env = 1;
+               c->combine = parse_combine_notes_fn(rewrite_mode_env);
+               if (!c->combine)
+                       error("Bad " GIT_NOTES_REWRITE_MODE_ENVIRONMENT
+                             " value: '%s'", rewrite_mode_env);
+       }
+       if (rewrite_refs_env) {
+               c->refs_from_env = 1;
+               string_list_add_refs_from_colon_sep(c->refs, rewrite_refs_env);
+       }
+       git_config(notes_rewrite_config, c);
+       if (!c->enabled || !c->refs->nr) {
+               string_list_clear(c->refs, 0);
+               free(c->refs);
+               free(c);
+               return NULL;
+       }
+       c->trees = load_notes_trees(c->refs);
+       string_list_clear(c->refs, 0);
+       free(c->refs);
+       return c;
+}
+
+int copy_note_for_rewrite(struct notes_rewrite_cfg *c,
+                         const unsigned char *from_obj, const unsigned char *to_obj)
+{
+       int ret = 0;
+       int i;
+       for (i = 0; c->trees[i]; i++)
+               ret = copy_note(c->trees[i], from_obj, to_obj, 1, c->combine) || ret;
+       return ret;
+}
+
+void finish_copy_notes_for_rewrite(struct notes_rewrite_cfg *c)
+{
+       int i;
+       for (i = 0; c->trees[i]; i++) {
+               commit_notes(c->trees[i], "Notes added by 'git notes copy'");
+               free_notes(c->trees[i]);
+       }
+       free(c->trees);
+       free(c);
+}
+
+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;
+       int ret = 0;
+
+       if (rewrite_cmd) {
+               c = init_copy_notes_for_rewrite(rewrite_cmd);
+               if (!c)
+                       return 0;
+       } else {
+               init_notes(NULL, NULL, NULL, 0);
+               t = &default_notes_tree;
+       }
+
+       while (strbuf_getline(&buf, stdin, '\n') != EOF) {
+               unsigned char from_obj[20], to_obj[20];
+               struct strbuf **split;
+               int err;
+
+               split = strbuf_split(&buf, ' ');
+               if (!split[0] || !split[1])
+                       die("Malformed input line: '%s'.", buf.buf);
+               strbuf_rtrim(split[0]);
+               strbuf_rtrim(split[1]);
+               if (get_sha1(split[0]->buf, from_obj))
+                       die("Failed to resolve '%s' as a valid ref.", split[0]->buf);
+               if (get_sha1(split[1]->buf, to_obj))
+                       die("Failed to resolve '%s' as a valid ref.", split[1]->buf);
+
+               if (rewrite_cmd)
+                       err = copy_note_for_rewrite(c, from_obj, to_obj);
+               else
+                       err = copy_note(t, from_obj, to_obj, force,
+                                       combine_notes_overwrite);
+
+               if (err) {
+                       error("Failed to copy notes from '%s' to '%s'",
+                             split[0]->buf, split[1]->buf);
+                       ret = 1;
+               }
+
+               strbuf_list_free(split);
+       }
+
+       if (!rewrite_cmd) {
+               commit_notes(t, "Notes added by 'git notes copy'");
+               free_notes(t);
+       } else {
+               finish_copy_notes_for_rewrite(c);
+       }
+       return ret;
+}
+
+static struct notes_tree *init_notes_check(const char *subcommand)
+{
+       struct notes_tree *t;
+       init_notes(NULL, NULL, NULL, 0);
+       t = &default_notes_tree;
+
+       if (prefixcmp(t->ref, "refs/notes/"))
+               die("Refusing to %s notes in %s (outside of refs/notes/)",
+                   subcommand, t->ref);
+       return t;
+}
+
+static int list(int argc, const char **argv, const char *prefix)
 {
        struct notes_tree *t;
-       unsigned char object[20], from_obj[20], new_note[20];
+       unsigned char object[20];
        const unsigned char *note;
+       int retval = -1;
+       struct option options[] = {
+               OPT_END()
+       };
+
+       if (argc)
+               argc = parse_options(argc, argv, prefix, options,
+                                    git_notes_list_usage, 0);
+
+       if (1 < argc) {
+               error("too many parameters");
+               usage_with_options(git_notes_list_usage, options);
+       }
+
+       t = init_notes_check("list");
+       if (argc) {
+               if (get_sha1(argv[0], object))
+                       die("Failed to resolve '%s' as a valid ref.", argv[0]);
+               note = get_note(t, object);
+               if (note) {
+                       puts(sha1_to_hex(note));
+                       retval = 0;
+               } else
+                       retval = error("No note found for object %s.",
+                                      sha1_to_hex(object));
+       } else
+               retval = for_each_note(t, 0, list_each_note, NULL);
+
+       free_notes(t);
+       return retval;
+}
+
+static int add(int argc, const char **argv, const char *prefix)
+{
+       int retval = 0, force = 0;
        const char *object_ref;
+       struct notes_tree *t;
+       unsigned char object[20], new_note[20];
        char logmsg[100];
-
-       int list = 0, add = 0, copy = 0, append = 0, edit = 0, show = 0,
-           remove = 0, prune = 0, force = 0;
-       int given_object = 0, i = 1, retval = 0;
+       const unsigned char *note;
        struct msg_arg msg = { 0, 0, STRBUF_INIT };
        struct option options[] = {
-               OPT_GROUP("Notes contents options"),
                { OPTION_CALLBACK, 'm', "message", &msg, "MSG",
                        "note contents as a string", PARSE_OPT_NONEG,
                        parse_msg_arg},
@@ -295,161 +538,325 @@ int cmd_notes(int argc, const char **argv, const char *prefix)
                { OPTION_CALLBACK, 'C', "reuse-message", &msg, "OBJECT",
                        "reuse specified note object", PARSE_OPT_NONEG,
                        parse_reuse_arg},
-               OPT_GROUP("Other options"),
                OPT_BOOLEAN('f', "force", &force, "replace existing notes"),
                OPT_END()
        };
 
-       git_config(git_default_config, NULL);
+       argc = parse_options(argc, argv, prefix, options, git_notes_add_usage,
+                            0);
 
-       argc = parse_options(argc, argv, prefix, options, git_notes_usage, 0);
-
-       if (argc && !strcmp(argv[0], "list"))
-               list = 1;
-       else if (argc && !strcmp(argv[0], "add"))
-               add = 1;
-       else if (argc && !strcmp(argv[0], "copy"))
-               copy = 1;
-       else if (argc && !strcmp(argv[0], "append"))
-               append = 1;
-       else if (argc && !strcmp(argv[0], "edit"))
-               edit = 1;
-       else if (argc && !strcmp(argv[0], "show"))
-               show = 1;
-       else if (argc && !strcmp(argv[0], "remove"))
-               remove = 1;
-       else if (argc && !strcmp(argv[0], "prune"))
-               prune = 1;
-       else if (!argc) {
-               list = 1; /* Default to 'list' if no other subcommand given */
-               i = 0;
+       if (1 < argc) {
+               error("too many parameters");
+               usage_with_options(git_notes_add_usage, options);
        }
 
-       if (list + add + copy + append + edit + show + remove + prune != 1)
-               usage_with_options(git_notes_usage, options);
-
-       if (msg.given && !(add || append || edit)) {
-               error("cannot use -m/-F/-c/-C options with %s subcommand.",
-                     argv[0]);
-               usage_with_options(git_notes_usage, options);
-       }
+       object_ref = argc ? argv[0] : "HEAD";
 
-       if (msg.given && edit) {
-               fprintf(stderr, "The -m/-F/-c/-C options have been deprecated "
-                       "for the 'edit' subcommand.\n"
-                       "Please use 'git notes add -f -m/-F/-c/-C' instead.\n");
-       }
+       if (get_sha1(object_ref, object))
+               die("Failed to resolve '%s' as a valid ref.", object_ref);
 
-       if (force && !(add || copy)) {
-               error("cannot use -f option with %s subcommand.", argv[0]);
-               usage_with_options(git_notes_usage, options);
-       }
+       t = init_notes_check("add");
+       note = get_note(t, object);
 
-       if (copy) {
-               const char *from_ref;
-               if (argc < 3) {
-                       error("too few parameters");
-                       usage_with_options(git_notes_usage, options);
+       if (note) {
+               if (!force) {
+                       retval = error("Cannot add notes. Found existing notes "
+                                      "for object %s. Use '-f' to overwrite "
+                                      "existing notes", sha1_to_hex(object));
+                       goto out;
                }
-               from_ref = argv[i++];
-               if (get_sha1(from_ref, from_obj))
-                       die("Failed to resolve '%s' as a valid ref.", from_ref);
-       }
-
-       given_object = argc > i;
-       object_ref = given_object ? argv[i++] : "HEAD";
-
-       if (argc > i || (prune && given_object)) {
-               error("too many parameters");
-               usage_with_options(git_notes_usage, options);
+               fprintf(stderr, "Overwriting existing notes for object %s\n",
+                       sha1_to_hex(object));
        }
 
-       if (get_sha1(object_ref, object))
-               die("Failed to resolve '%s' as a valid ref.", object_ref);
+       create_note(object, &msg, 0, note, new_note);
 
-       init_notes(NULL, NULL, NULL, 0);
-       t = &default_notes_tree;
+       if (is_null_sha1(new_note))
+               remove_note(t, object);
+       else
+               add_note(t, object, new_note, combine_notes_overwrite);
 
-       if (prefixcmp(t->ref, "refs/notes/"))
-               die("Refusing to %s notes in %s (outside of refs/notes/)",
-                   argv[0], t->ref);
+       snprintf(logmsg, sizeof(logmsg), "Notes %s by 'git notes %s'",
+                is_null_sha1(new_note) ? "removed" : "added", "add");
+       commit_notes(t, logmsg);
+out:
+       free_notes(t);
+       strbuf_release(&(msg.buf));
+       return retval;
+}
 
-       note = get_note(t, object);
+static int copy(int argc, const char **argv, const char *prefix)
+{
+       int retval = 0, force = 0, from_stdin = 0;
+       const unsigned char *from_note, *note;
+       const char *object_ref;
+       unsigned char object[20], from_obj[20];
+       struct notes_tree *t;
+       const char *rewrite_cmd = NULL;
+       struct option options[] = {
+               OPT_BOOLEAN('f', "force", &force, "replace existing notes"),
+               OPT_BOOLEAN(0, "stdin", &from_stdin, "read objects from stdin"),
+               OPT_STRING(0, "for-rewrite", &rewrite_cmd, "command",
+                          "load rewriting config for <command> (implies "
+                          "--stdin)"),
+               OPT_END()
+       };
 
-       /* list command */
+       argc = parse_options(argc, argv, prefix, options, git_notes_copy_usage,
+                            0);
 
-       if (list) {
-               if (given_object) {
-                       if (note) {
-                               puts(sha1_to_hex(note));
-                               goto end;
-                       }
+       if (from_stdin || rewrite_cmd) {
+               if (argc) {
+                       error("too many parameters");
+                       usage_with_options(git_notes_copy_usage, options);
                } else {
-                       retval = for_each_note(t, 0, list_each_note, NULL);
-                       goto end;
+                       return notes_copy_from_stdin(force, rewrite_cmd);
                }
        }
 
-       /* show command */
-
-       if ((list || show) && !note) {
-               error("No note found for object %s.", sha1_to_hex(object));
-               retval = 1;
-               goto end;
-       } else if (show) {
-               const char *show_args[3] = {"show", sha1_to_hex(note), NULL};
-               retval = execv_git_cmd(show_args);
-               goto end;
+       if (2 < argc) {
+               error("too many parameters");
+               usage_with_options(git_notes_copy_usage, options);
        }
 
-       /* add/append/edit/remove/prune command */
+       if (get_sha1(argv[0], from_obj))
+               die("Failed to resolve '%s' as a valid ref.", argv[0]);
 
-       if ((add || copy) && note) {
+       object_ref = 1 < argc ? argv[1] : "HEAD";
+
+       if (get_sha1(object_ref, object))
+               die("Failed to resolve '%s' as a valid ref.", object_ref);
+
+       t = init_notes_check("copy");
+       note = get_note(t, object);
+
+       if (note) {
                if (!force) {
-                       error("Cannot %s notes. Found existing notes for object"
-                             " %s. Use '-f' to overwrite existing notes",
-                             argv[0], sha1_to_hex(object));
-                       retval = 1;
-                       goto end;
+                       retval = error("Cannot copy notes. Found existing "
+                                      "notes for object %s. Use '-f' to "
+                                      "overwrite existing notes",
+                                      sha1_to_hex(object));
+                       goto out;
                }
                fprintf(stderr, "Overwriting existing notes for object %s\n",
                        sha1_to_hex(object));
        }
 
-       if (remove) {
-               msg.given = 1;
-               msg.use_editor = 0;
-               strbuf_reset(&(msg.buf));
+       from_note = get_note(t, from_obj);
+       if (!from_note) {
+               retval = error("Missing notes on source object %s. Cannot "
+                              "copy.", sha1_to_hex(from_obj));
+               goto out;
        }
 
-       if (prune) {
-               hashclr(new_note);
-               prune_notes(t);
-               goto commit;
-       } else if (copy) {
-               const unsigned char *from_note = get_note(t, from_obj);
-               if (!from_note) {
-                       error("Missing notes on source object %s. Cannot copy.",
-                             sha1_to_hex(from_obj));
-                       retval = 1;
-                       goto end;
-               }
-               hashcpy(new_note, from_note);
-       } else
-               create_note(object, &msg, append, note, new_note);
+       add_note(t, object, from_note, combine_notes_overwrite);
+       commit_notes(t, "Notes added by 'git notes copy'");
+out:
+       free_notes(t);
+       return retval;
+}
+
+static int append_edit(int argc, const char **argv, const char *prefix)
+{
+       const char *object_ref;
+       struct notes_tree *t;
+       unsigned char object[20], new_note[20];
+       const unsigned char *note;
+       char logmsg[100];
+       const char * const *usage;
+       struct msg_arg msg = { 0, 0, STRBUF_INIT };
+       struct option options[] = {
+               { OPTION_CALLBACK, 'm', "message", &msg, "MSG",
+                       "note contents as a string", PARSE_OPT_NONEG,
+                       parse_msg_arg},
+               { OPTION_CALLBACK, 'F', "file", &msg, "FILE",
+                       "note contents in a file", PARSE_OPT_NONEG,
+                       parse_file_arg},
+               { OPTION_CALLBACK, 'c', "reedit-message", &msg, "OBJECT",
+                       "reuse and edit specified note object", PARSE_OPT_NONEG,
+                       parse_reedit_arg},
+               { OPTION_CALLBACK, 'C', "reuse-message", &msg, "OBJECT",
+                       "reuse specified note object", PARSE_OPT_NONEG,
+                       parse_reuse_arg},
+               OPT_END()
+       };
+       int edit = !strcmp(argv[0], "edit");
+
+       usage = edit ? git_notes_edit_usage : git_notes_append_usage;
+       argc = parse_options(argc, argv, prefix, options, usage,
+                            PARSE_OPT_KEEP_ARGV0);
+
+       if (2 < argc) {
+               error("too many parameters");
+               usage_with_options(usage, options);
+       }
+
+       if (msg.given && edit)
+               fprintf(stderr, "The -m/-F/-c/-C options have been deprecated "
+                       "for the 'edit' subcommand.\n"
+                       "Please use 'git notes add -f -m/-F/-c/-C' instead.\n");
+
+       object_ref = 1 < argc ? argv[1] : "HEAD";
+
+       if (get_sha1(object_ref, object))
+               die("Failed to resolve '%s' as a valid ref.", object_ref);
+
+       t = init_notes_check(argv[0]);
+       note = get_note(t, object);
+
+       create_note(object, &msg, !edit, note, new_note);
 
        if (is_null_sha1(new_note))
                remove_note(t, object);
        else
                add_note(t, object, new_note, combine_notes_overwrite);
 
-commit:
        snprintf(logmsg, sizeof(logmsg), "Notes %s by 'git notes %s'",
                 is_null_sha1(new_note) ? "removed" : "added", argv[0]);
        commit_notes(t, logmsg);
-
-end:
        free_notes(t);
        strbuf_release(&(msg.buf));
+       return 0;
+}
+
+static int show(int argc, const char **argv, const char *prefix)
+{
+       const char *object_ref;
+       struct notes_tree *t;
+       unsigned char object[20];
+       const unsigned char *note;
+       int retval;
+       struct option options[] = {
+               OPT_END()
+       };
+
+       argc = parse_options(argc, argv, prefix, options, git_notes_show_usage,
+                            0);
+
+       if (1 < argc) {
+               error("too many parameters");
+               usage_with_options(git_notes_show_usage, options);
+       }
+
+       object_ref = argc ? argv[0] : "HEAD";
+
+       if (get_sha1(object_ref, object))
+               die("Failed to resolve '%s' as a valid ref.", object_ref);
+
+       t = init_notes_check("show");
+       note = get_note(t, object);
+
+       if (!note)
+               retval = error("No note found for object %s.",
+                              sha1_to_hex(object));
+       else {
+               const char *show_args[3] = {"show", sha1_to_hex(note), NULL};
+               retval = execv_git_cmd(show_args);
+       }
+       free_notes(t);
        return retval;
 }
+
+static int remove_cmd(int argc, const char **argv, const char *prefix)
+{
+       struct option options[] = {
+               OPT_END()
+       };
+       const char *object_ref;
+       struct notes_tree *t;
+       unsigned char object[20];
+
+       argc = parse_options(argc, argv, prefix, options,
+                            git_notes_remove_usage, 0);
+
+       if (1 < argc) {
+               error("too many parameters");
+               usage_with_options(git_notes_remove_usage, options);
+       }
+
+       object_ref = argc ? argv[0] : "HEAD";
+
+       if (get_sha1(object_ref, object))
+               die("Failed to resolve '%s' as a valid ref.", object_ref);
+
+       t = init_notes_check("remove");
+
+       fprintf(stderr, "Removing note for object %s\n", sha1_to_hex(object));
+       remove_note(t, object);
+
+       commit_notes(t, "Notes removed by 'git notes remove'");
+       free_notes(t);
+       return 0;
+}
+
+static int prune(int argc, const char **argv, const char *prefix)
+{
+       struct notes_tree *t;
+       struct option options[] = {
+               OPT_END()
+       };
+
+       argc = parse_options(argc, argv, prefix, options, git_notes_prune_usage,
+                            0);
+
+       if (argc) {
+               error("too many parameters");
+               usage_with_options(git_notes_prune_usage, options);
+       }
+
+       t = init_notes_check("prune");
+
+       prune_notes(t);
+       commit_notes(t, "Notes removed by 'git notes prune'");
+       free_notes(t);
+       return 0;
+}
+
+int cmd_notes(int argc, const char **argv, const char *prefix)
+{
+       int result;
+       const char *override_notes_ref = NULL;
+       struct option options[] = {
+               OPT_STRING(0, "ref", &override_notes_ref, "notes_ref",
+                          "use notes from <notes_ref>"),
+               OPT_END()
+       };
+
+       git_config(git_default_config, NULL);
+       argc = parse_options(argc, argv, prefix, options, git_notes_usage,
+                            PARSE_OPT_STOP_AT_NON_OPTION);
+
+       if (override_notes_ref) {
+               struct strbuf sb = STRBUF_INIT;
+               if (!prefixcmp(override_notes_ref, "refs/notes/"))
+                       /* we're happy */;
+               else if (!prefixcmp(override_notes_ref, "notes/"))
+                       strbuf_addstr(&sb, "refs/");
+               else
+                       strbuf_addstr(&sb, "refs/notes/");
+               strbuf_addstr(&sb, override_notes_ref);
+               setenv("GIT_NOTES_REF", sb.buf, 1);
+               strbuf_release(&sb);
+       }
+
+       if (argc < 1 || !strcmp(argv[0], "list"))
+               result = list(argc, argv, prefix);
+       else if (!strcmp(argv[0], "add"))
+               result = add(argc, argv, prefix);
+       else if (!strcmp(argv[0], "copy"))
+               result = copy(argc, argv, prefix);
+       else if (!strcmp(argv[0], "append") || !strcmp(argv[0], "edit"))
+               result = append_edit(argc, argv, prefix);
+       else if (!strcmp(argv[0], "show"))
+               result = show(argc, argv, prefix);
+       else if (!strcmp(argv[0], "remove"))
+               result = remove_cmd(argc, argv, prefix);
+       else if (!strcmp(argv[0], "prune"))
+               result = prune(argc, argv, prefix);
+       else {
+               result = error("Unknown subcommand: %s", argv[0]);
+               usage_with_options(git_notes_usage, options);
+       }
+
+       return result ? 1 : 0;
+}
index 62957ededdf72b93f088586f5d577ef8d38a7f6c..f4358b9d230f6d8d7a9a67fdfbc60279c5ec71ee 100644 (file)
@@ -10,7 +10,7 @@
 #include "parse-options.h"
 
 static const char * const push_usage[] = {
-       "git push [<options>] [<repository> <refspec>...]",
+       "git push [<options>] [<repository> [<refspec>...]]",
        NULL,
 };
 
index 64e45bd8137bef2b6cfe1f8a3da79e2ff6f8fc47..bd7880dc04830253daae932ba534f02db85f6d2a 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 static const char reflog_expire_usage[] =
-"git reflog (show|expire) [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
+"git reflog expire [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
 static const char reflog_delete_usage[] =
 "git reflog delete [--verbose] [--dry-run] [--rewrite] [--updateref] <refs>...";
 
index 2c3a69adc674bb3f539d29b2d29116e89f887066..1283068fd24c371e39f0271d01dd6b3aac437d4b 100644 (file)
@@ -23,7 +23,8 @@
 
 static const char * const git_reset_usage[] = {
        "git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]",
-       "git reset [--mixed] <commit> [--] <paths>...",
+       "git reset [-q] <commit> [--] <paths>...",
+       "git reset --patch [<commit>] [--] [<paths>...]",
        NULL
 };
 
index 5679170e82ed644d4c3eb4f71f26aa0ac9acce24..51ceb19d88918445c90eccc37f1fe5f90cedd385 100644 (file)
@@ -133,9 +133,12 @@ static void show_commit(struct commit *commit, void *data)
                                 */
                                if (graph_show_remainder(revs->graph))
                                        putchar('\n');
+                               if (revs->commit_format == CMIT_FMT_ONELINE)
+                                       putchar('\n');
                        }
                } else {
-                       if (buf.len)
+                       if (revs->commit_format != CMIT_FMT_USERFORMAT ||
+                           buf.len)
                                printf("%s%c", buf.buf, info->hdr_termination);
                }
                strbuf_release(&buf);
@@ -313,7 +316,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 
        git_config(git_default_config, NULL);
        init_revisions(&revs, prefix);
-       revs.abbrev = 0;
+       revs.abbrev = DEFAULT_ABBREV;
        revs.commit_format = CMIT_FMT_UNSPECIFIED;
        argc = setup_revisions(argc, argv, &revs, NULL);
 
index b70f4b0af364caa597ab24630fc43fb41438ca2c..7976b5a3295d4c70f003212485680f4dd3ceead2 100644 (file)
@@ -13,6 +13,7 @@
 #include "revision.h"
 #include "rerere.h"
 #include "merge-recursive.h"
+#include "refs.h"
 
 /*
  * This implements the builtins revert and cherry-pick.
@@ -35,7 +36,7 @@ static const char * const cherry_pick_usage[] = {
        NULL
 };
 
-static int edit, no_replay, no_commit, mainline, signoff;
+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;
@@ -64,8 +65,19 @@ static void parse_args(int argc, const char **argv)
                OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
                OPT_STRING(0, "strategy", &strategy, "strategy", "merge strategy"),
                OPT_END(),
+               OPT_END(),
+               OPT_END(),
        };
 
+       if (action == CHERRY_PICK) {
+               struct option cp_extra[] = {
+                       OPT_BOOLEAN(0, "ff", &allow_ff, "allow fast-forward"),
+                       OPT_END(),
+               };
+               if (parse_options_concat(options, ARRAY_SIZE(options), cp_extra))
+                       die("program error");
+       }
+
        if (parse_options(argc, argv, NULL, options, usage_str, 0) != 1)
                usage_with_options(usage_str, options);
 
@@ -99,8 +111,13 @@ static int get_message(const char *raw_message, struct commit_message *out)
                encoding = "UTF-8";
        if (!git_commit_encoding)
                git_commit_encoding = "UTF-8";
-       if ((out->reencoded_message = reencode_string(raw_message,
-                                       git_commit_encoding, encoding)))
+
+       out->reencoded_message = NULL;
+       out->message = raw_message;
+       if (strcmp(encoding, git_commit_encoding))
+               out->reencoded_message = reencode_string(raw_message,
+                                       git_commit_encoding, encoding);
+       if (out->reencoded_message)
                out->message = out->reencoded_message;
 
        abbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
@@ -281,6 +298,17 @@ static NORETURN void die_dirty_index(const char *me)
        }
 }
 
+static int fast_forward_to(const unsigned char *to, const unsigned char *from)
+{
+       struct ref_lock *ref_lock;
+
+       read_cache();
+       if (checkout_fast_forward(from, to))
+               exit(1); /* the callee should have complained already */
+       ref_lock = lock_any_ref_for_update("HEAD", from, 0);
+       return write_ref_sha1(ref_lock, to, "cherry-pick");
+}
+
 static void do_recursive_merge(struct commit *base, struct commit *next,
                               const char *base_label, const char *next_label,
                               unsigned char *head, struct strbuf *msgbuf,
@@ -343,7 +371,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
        struct commit *base, *next, *parent;
        const char *base_label, *next_label;
        struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };
-       char *defmsg = git_pathdup("MERGE_MSG");
+       char *defmsg = NULL;
        struct strbuf msgbuf = STRBUF_INIT;
 
        git_config(git_default_config, NULL);
@@ -355,6 +383,17 @@ static int revert_or_cherry_pick(int argc, const char **argv)
        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) {
@@ -402,6 +441,9 @@ static int revert_or_cherry_pick(int argc, const char **argv)
        else
                parent = commit->parents->item;
 
+       if (allow_ff && !hashcmp(parent->object.sha1, head))
+               return fast_forward_to(commit->object.sha1, head);
+
        if (parent && parse_commit(parent) < 0)
                die("%s: cannot parse parent commit %s",
                    me, sha1_to_hex(parent->object.sha1));
@@ -417,6 +459,8 @@ static int revert_or_cherry_pick(int argc, const char **argv)
         * reverse of it if we are revert.
         */
 
+       defmsg = git_pathdup("MERGE_MSG");
+
        if (action == REVERT) {
                base = commit;
                base_label = msg.label;
index 4ef1c4f508b0261e725c360e96f2b8cbed50e9ce..d311491e492787ae50aa172f51629abea53eec19 100644 (file)
@@ -147,11 +147,11 @@ static int delete_tag(const char *name, const char *ref,
 static int verify_tag(const char *name, const char *ref,
                                const unsigned char *sha1)
 {
-       const char *argv_verify_tag[] = {"git-verify-tag",
+       const char *argv_verify_tag[] = {"verify-tag",
                                        "-v", "SHA1_HEX", NULL};
        argv_verify_tag[2] = sha1_to_hex(sha1);
 
-       if (run_command_v_opt(argv_verify_tag, 0))
+       if (run_command_v_opt(argv_verify_tag, RUN_GIT_CMD))
                return error("could not verify the tag '%s'", name);
        return 0;
 }
diff --git a/cache.h b/cache.h
index f62db0bd7e8f79f5d8a31e61c6164344bad10b65..bfc4d82f6c4205e11de6d855459d1afa02bf5cbf 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -387,6 +387,9 @@ static inline enum object_type object_type(unsigned int mode)
 #define ATTRIBUTE_MACRO_PREFIX "[attr]"
 #define GIT_NOTES_REF_ENVIRONMENT "GIT_NOTES_REF"
 #define GIT_NOTES_DEFAULT_REF "refs/notes/commits"
+#define GIT_NOTES_DISPLAY_REF_ENVIRONMENT "GIT_NOTES_DISPLAY_REF"
+#define GIT_NOTES_REWRITE_REF_ENVIRONMENT "GIT_NOTES_REWRITE_REF"
+#define GIT_NOTES_REWRITE_MODE_ENVIRONMENT "GIT_NOTES_REWRITE_MODE"
 
 /*
  * Repository-local GIT_* environment variables
@@ -698,7 +701,7 @@ static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *
        return read_sha1_file_repl(sha1, type, size, NULL);
 }
 extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);
-extern int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
+extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
 extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
 extern int force_object_loose(const unsigned char *sha1, time_t mtime);
 
@@ -715,6 +718,8 @@ extern int has_loose_object_nonlocal(const unsigned char *sha1);
 
 extern int has_pack_index(const unsigned char *sha1);
 
+extern void assert_sha1_type(const unsigned char *sha1, enum object_type expect);
+
 extern const signed char hexval_table[256];
 static inline unsigned int hexval(unsigned char c)
 {
@@ -1055,4 +1060,7 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix);
 char *alias_lookup(const char *alias);
 int split_cmdline(char *cmdline, const char ***argv);
 
+/* builtin/merge.c */
+int checkout_fast_forward(const unsigned char *from, const unsigned char *to);
+
 #endif /* CACHE_H */
index 61626912e3bca2571b41fd1256067470dc170cc1..7557136c820a10570e72f6870ecc7a45c4c7ce36 100644 (file)
@@ -204,18 +204,17 @@ static void consume_line(void *state_, char *line, unsigned long len)
 static void combine_diff(const unsigned char *parent, unsigned int mode,
                         mmfile_t *result_file,
                         struct sline *sline, unsigned int cnt, int n,
-                        int num_parent)
+                        int num_parent, int result_deleted)
 {
        unsigned int p_lno, lno;
        unsigned long nmask = (1UL << n);
        xpparam_t xpp;
        xdemitconf_t xecfg;
        mmfile_t parent_file;
-       xdemitcb_t ecb;
        struct combine_diff_state state;
        unsigned long sz;
 
-       if (!cnt)
+       if (result_deleted)
                return; /* result deleted */
 
        parent_file.ptr = grab_blob(parent, mode, &sz);
@@ -231,7 +230,7 @@ static void combine_diff(const unsigned char *parent, unsigned int mode,
        state.n = n;
 
        xdi_diff_outf(&parent_file, result_file, consume_line, &state,
-                     &xpp, &xecfg, &ecb);
+                     &xpp, &xecfg);
        free(parent_file.ptr);
 
        /* Assign line numbers for this parent.
@@ -517,7 +516,7 @@ static void show_line_to_eol(const char *line, int len, const char *reset)
 }
 
 static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
-                      int use_color)
+                      int use_color, int result_deleted)
 {
        unsigned long mark = (1UL<<num_parent);
        unsigned long no_pre_delete = (2UL<<num_parent);
@@ -530,7 +529,7 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
        const char *c_plain = diff_get_color(use_color, DIFF_PLAIN);
        const char *c_reset = diff_get_color(use_color, DIFF_RESET);
 
-       if (!cnt)
+       if (result_deleted)
                return; /* result deleted */
 
        while (1) {
@@ -687,6 +686,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 {
        struct diff_options *opt = &rev->diffopt;
        unsigned long result_size, cnt, lno;
+       int result_deleted = 0;
        char *result, *cp;
        struct sline *sline; /* survived lines */
        int mode_differs = 0;
@@ -767,6 +767,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
                }
                else {
                deleted_file:
+                       result_deleted = 1;
                        result_size = 0;
                        elem->mode = 0;
                        result = xcalloc(1, 1);
@@ -823,7 +824,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
                        combine_diff(elem->parent[i].sha1,
                                     elem->parent[i].mode,
                                     &result_file, sline,
-                                    cnt, i, num_parent);
+                                    cnt, i, num_parent, result_deleted);
                if (elem->parent[i].mode != elem->mode)
                        mode_differs = 1;
        }
@@ -889,7 +890,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
                        dump_quoted_path("+++ ", b_prefix, elem->path,
                                         c_meta, c_reset);
                dump_sline(sline, cnt, num_parent,
-                          DIFF_OPT_TST(opt, COLOR_DIFF));
+                          DIFF_OPT_TST(opt, COLOR_DIFF), result_deleted);
        }
        free(result);
 
index 731191e63bd39a89a8ea4ed0390c49d5605cdbed..e9b07509678f5a4f61e5bedadea14b726e290ed1 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -790,3 +790,58 @@ struct commit_list *reduce_heads(struct commit_list *heads)
        free(other);
        return result;
 }
+
+static const char commit_utf8_warn[] =
+"Warning: commit message does not conform to UTF-8.\n"
+"You may want to amend it after fixing the message, or set the config\n"
+"variable i18n.commitencoding to the encoding your project uses.\n";
+
+int commit_tree(const char *msg, unsigned char *tree,
+               struct commit_list *parents, unsigned char *ret,
+               const char *author)
+{
+       int result;
+       int encoding_is_utf8;
+       struct strbuf buffer;
+
+       assert_sha1_type(tree, OBJ_TREE);
+
+       /* Not having i18n.commitencoding is the same as having utf-8 */
+       encoding_is_utf8 = is_encoding_utf8(git_commit_encoding);
+
+       strbuf_init(&buffer, 8192); /* should avoid reallocs for the headers */
+       strbuf_addf(&buffer, "tree %s\n", sha1_to_hex(tree));
+
+       /*
+        * NOTE! This ordering means that the same exact tree merged with a
+        * different order of parents will be a _different_ changeset even
+        * if everything else stays the same.
+        */
+       while (parents) {
+               struct commit_list *next = parents->next;
+               strbuf_addf(&buffer, "parent %s\n",
+                       sha1_to_hex(parents->item->object.sha1));
+               free(parents);
+               parents = next;
+       }
+
+       /* Person/date information */
+       if (!author)
+               author = git_author_info(IDENT_ERROR_ON_NO_NAME);
+       strbuf_addf(&buffer, "author %s\n", author);
+       strbuf_addf(&buffer, "committer %s\n", git_committer_info(IDENT_ERROR_ON_NO_NAME));
+       if (!encoding_is_utf8)
+               strbuf_addf(&buffer, "encoding %s\n", git_commit_encoding);
+       strbuf_addch(&buffer, '\n');
+
+       /* And add the comment */
+       strbuf_addstr(&buffer, msg);
+
+       /* And check the encoding */
+       if (encoding_is_utf8 && !is_utf8(buffer.buf))
+               fprintf(stderr, commit_utf8_warn);
+
+       result = write_sha1_file(buffer.buf, buffer.len, commit_type, ret);
+       strbuf_release(&buffer);
+       return result;
+}
index 3cf51665816abb5e5855c036f102019eded23bd6..6ef88dcf45d6c5b2cd0f26397db2fc7b8859d581 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -74,11 +74,16 @@ struct pretty_print_context
        struct reflog_walk_info *reflog_info;
 };
 
+struct userformat_want {
+       unsigned notes:1;
+};
+
 extern int has_non_ascii(const char *text);
 struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
 extern char *reencode_commit_message(const struct commit *commit,
                                     const char **encoding_p);
 extern void get_commit_format(const char *arg, struct rev_info *);
+extern void userformat_find_requirements(const char *fmt, struct userformat_want *w);
 extern void format_commit_message(const struct commit *commit,
                                  const char *format, struct strbuf *sb,
                                  const struct pretty_print_context *context);
@@ -158,4 +163,8 @@ static inline int single_parent(struct commit *commit)
 
 struct commit_list *reduce_heads(struct commit_list *heads);
 
+extern int commit_tree(const char *msg, unsigned char *tree,
+               struct commit_list *parents, unsigned char *ret,
+               const char *author);
+
 #endif /* COMMIT_H */
index f3b8c44181776a99c3eb79e15542104d67001c9d..54756dbb05ba99ab1679f17a50f04c3f1cede8e6 100644 (file)
@@ -17,6 +17,8 @@ static inline uint32_t default_swab32(uint32_t val)
                ((val & 0x000000ff) << 24));
 }
 
+#undef bswap32
+
 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
 
 #define bswap32(x) ({ \
index c5bfb39b3949430cd06093afdbc85ecc22f8c9c7..f90a114b021d32c2ee1976bf51a82e87a81ea1cb 100644 (file)
@@ -275,8 +275,17 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
        int fh, rc;
 
        /* must have write permission */
-       if ((fh = open(file_name, O_RDWR | O_BINARY)) < 0)
-               return -1;
+       DWORD attrs = GetFileAttributes(file_name);
+       if (attrs != INVALID_FILE_ATTRIBUTES &&
+           (attrs & FILE_ATTRIBUTE_READONLY)) {
+               /* ignore errors here; open() will report them */
+               SetFileAttributes(file_name, attrs & ~FILE_ATTRIBUTE_READONLY);
+       }
+
+       if ((fh = open(file_name, O_RDWR | O_BINARY)) < 0) {
+               rc = -1;
+               goto revert_attrs;
+       }
 
        time_t_to_filetime(times->modtime, &mft);
        time_t_to_filetime(times->actime, &aft);
@@ -286,6 +295,13 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
        } else
                rc = 0;
        close(fh);
+
+revert_attrs:
+       if (attrs != INVALID_FILE_ATTRIBUTES &&
+           (attrs & FILE_ATTRIBUTE_READONLY)) {
+               /* ignore errors again */
+               SetFileAttributes(file_name, attrs);
+       }
        return rc;
 }
 
@@ -634,6 +650,7 @@ static int env_compare(const void *a, const void *b)
 }
 
 static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
+                             const char *dir,
                              int prepend_cmd, int fhin, int fhout, int fherr)
 {
        STARTUPINFO si;
@@ -713,7 +730,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
 
        memset(&pi, 0, sizeof(pi));
        ret = CreateProcess(cmd, args.buf, NULL, NULL, TRUE, flags,
-               env ? envblk.buf : NULL, NULL, &si, &pi);
+               env ? envblk.buf : NULL, dir, &si, &pi);
 
        if (env)
                strbuf_release(&envblk);
@@ -730,10 +747,11 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
 static pid_t mingw_spawnve(const char *cmd, const char **argv, char **env,
                           int prepend_cmd)
 {
-       return mingw_spawnve_fd(cmd, argv, env, prepend_cmd, 0, 1, 2);
+       return mingw_spawnve_fd(cmd, argv, env, NULL, prepend_cmd, 0, 1, 2);
 }
 
 pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,
+                    const char *dir,
                     int fhin, int fhout, int fherr)
 {
        pid_t pid;
@@ -756,14 +774,14 @@ pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,
                                pid = -1;
                        }
                        else {
-                               pid = mingw_spawnve_fd(iprog, argv, env, 1,
+                               pid = mingw_spawnve_fd(iprog, argv, env, dir, 1,
                                                       fhin, fhout, fherr);
                                free(iprog);
                        }
                        argv[0] = argv0;
                }
                else
-                       pid = mingw_spawnve_fd(prog, argv, env, 0,
+                       pid = mingw_spawnve_fd(prog, argv, env, dir, 0,
                                               fhin, fhout, fherr);
                free(prog);
        }
index e81e752ed2716ac9fb4a6847f97db84764694b4c..7c2ab64cb4eb7532c2495383ab0e7eefb329bcf9 100644 (file)
@@ -229,6 +229,7 @@ int mingw_utime(const char *file_name, const struct utimbuf *times);
 #define utime mingw_utime
 
 pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,
+                    const char *dir,
                     int fhin, int fhout, int fherr);
 void mingw_execvp(const char *cmd, char *const *argv);
 #define execvp mingw_execvp
diff --git a/compat/vcbuild/include/termios.h b/compat/vcbuild/include/termios.h
new file mode 100644 (file)
index 0000000..0d8552a
--- /dev/null
@@ -0,0 +1 @@
+/* Intentionally empty file to support building git with MSVC */
index 914ae5759f6932c28ee39afec1e36d80c8e63cd9..f4d7372ef8d7b45f9810d5f8bc191c71622a71f2 100644 (file)
@@ -179,6 +179,26 @@ fi],
    AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads.])
 ])
 
+# Define option to enable JavaScript minification
+AC_ARG_ENABLE([jsmin],
+[AS_HELP_STRING([--enable-jsmin=PATH],
+  [PATH is the name of a JavaScript minifier or the absolute path to one.])],
+[
+  JSMIN=$enableval;
+  AC_MSG_NOTICE([Setting JSMIN to '$JSMIN' to enable JavaScript minifying])
+  GIT_CONF_APPEND_LINE(JSMIN=$enableval);
+])
+
+# Define option to enable CSS minification
+AC_ARG_ENABLE([cssmin],
+[AS_HELP_STRING([--enable-cssmin=PATH],
+  [PATH is the name of a CSS minifier or the absolute path to one.])],
+[
+  CSSMIN=$enableval;
+  AC_MSG_NOTICE([Setting CSSMIN to '$CSSMIN' to enable CSS minifying])
+  GIT_CONF_APPEND_LINE(CSSMIN=$enableval);
+])
+
 ## Site configuration (override autodetection)
 ## --with-PACKAGE[=ARG] and --without-PACKAGE
 AC_MSG_NOTICE([CHECKS for site configuration])
diff --git a/contrib/ciabot/README b/contrib/ciabot/README
new file mode 100644 (file)
index 0000000..3b916ac
--- /dev/null
@@ -0,0 +1,12 @@
+These are hook scripts for the CIA notification service at <http://cia.vc/>
+
+They are maintained by Eric S. Raymond <esr@thyrsus.com>.  There is an
+upstream resource page for them at <http://www.catb.org/esr/ciabot/>,
+but they are unlikely to change rapidly.
+
+You probably want the Python version; it's faster, more capable, and
+better documented.  The shell version is maintained only as a fallback
+for use on hosting sites that don't permit Python hook scripts.
+
+You will find installation instructions for each script in its comment
+header.
diff --git a/contrib/ciabot/ciabot.py b/contrib/ciabot/ciabot.py
new file mode 100755 (executable)
index 0000000..d0627e0
--- /dev/null
@@ -0,0 +1,222 @@
+#!/usr/bin/env python
+# Copyright (c) 2010 Eric S. Raymond <esr@thyrsus.com>
+# Distributed under BSD terms.
+#
+# This script contains porcelain and porcelain byproducts.
+# It's Python because the Python standard libraries avoid portability/security
+# issues raised by callouts in the ancestral Perl and sh scripts.  It should
+# be compatible back to Python 2.1.5
+#
+# usage: ciabot.py [-V] [-n] [-p projectname]  [refname [commits...]]
+#
+# This script is meant to be run either in a post-commit hook or in an
+# update hook.  If there's nothing unusual about your hosting setup,
+# you can specify the project name with a -p option and avoid having
+# to modify this script.  Try it with -n to see the notification mail
+# dumped to stdout and verify that it looks sane. With -V it dumps its
+# version and exits.
+#
+# In post-commit, run it without arguments (other than possibly a -p
+# option). It will query for current HEAD and the latest commit ID to
+# get the information it needs.
+#
+# In update, call it with a refname followed by a list of commits:
+# You want to reverse the order git rev-list emits becxause it lists
+# from most recent to oldest.
+#
+# /path/to/ciabot.py ${refname} $(git rev-list ${oldhead}..${newhead} | tac)
+#
+# Note: this script uses mail, not XML-RPC, in order to avoid stalling
+# until timeout when the CIA XML-RPC server is down.
+#
+
+#
+# The project as known to CIA. You will either want to change this
+# or invoke the script with a -p option to set it.
+#
+project=None
+
+#
+# You may not need to change these:
+#
+import os, sys, commands, socket, urllib
+
+# Name of the repository.
+# You can hardwire this to make the script faster.
+repo = os.path.basename(os.getcwd())
+
+# Fully-qualified domain name of this host.
+# You can hardwire this to make the script faster.
+host = socket.getfqdn()
+
+# Changeset URL prefix for your repo: when the commit ID is appended
+# to this, it should point at a CGI that will display the commit
+# through gitweb or something similar. The defaults will probably
+# work if you have a typical gitweb/cgit setup.
+#
+#urlprefix="http://%(host)s/cgi-bin/gitweb.cgi?p=%(repo)s;a=commit;h="
+urlprefix="http://%(host)s/cgi-bin/cgit.cgi/%(repo)s/commit/?id="
+
+# The service used to turn your gitwebbish URL into a tinyurl so it
+# will take up less space on the IRC notification line.
+tinyifier = "http://tinyurl.com/api-create.php?url="
+
+# The template used to generate the XML messages to CIA.  You can make
+# visible changes to the IRC-bot notification lines by hacking this.
+# The default will produce a notfication line that looks like this:
+#
+# ${project}: ${author} ${repo}:${branch} * ${rev} ${files}: ${logmsg} ${url}
+#
+# By omitting $files you can collapse the files part to a single slash.
+xml = '''\
+<message>
+  <generator>
+    <name>CIA Python client for Git</name>
+    <version>%(gitver)s</version>
+    <url>%(generator)s</url>
+  </generator>
+  <source>
+    <project>%(project)s</project>
+    <branch>%(repo)s:%(branch)s</branch>
+  </source>
+  <timestamp>%(ts)s</timestamp>
+  <body>
+    <commit>
+      <author>%(author)s</author>
+      <revision>%(rev)s</revision>
+      <files>
+        %(files)s
+      </files>
+      <log>%(logmsg)s %(url)s</log>
+      <url>%(url)s</url>
+    </commit>
+  </body>
+</message>
+'''
+
+#
+# No user-serviceable parts below this line:
+#
+
+# Addresses for the e-mail. The from address is a dummy, since CIA
+# will never reply to this mail.
+fromaddr = "CIABOT-NOREPLY@" + host
+toaddr = "cia@cia.navi.cx"
+
+# Identify the generator script.
+# Should only change when the script itself gets a new home and maintainer.
+generator="http://www.catb.org/~esr/ciabot.py"
+
+def do(command):
+    return commands.getstatusoutput(command)[1]
+
+def report(refname, merged):
+    "Generate a commit notification to be reported to CIA"
+
+    # Try to tinyfy a reference to a web view for this commit.
+    try:
+        url = open(urllib.urlretrieve(tinyifier + urlprefix + merged)[0]).read()
+    except:
+        url = urlprefix + merged
+
+    branch = os.path.basename(refname)
+
+    # Compute a shortnane for the revision
+    rev = do("git describe ${merged} 2>/dev/null") or merged[:12]
+
+    # Extract the neta-information for the commit
+    rawcommit = do("git cat-file commit " + merged)
+    files=do("git diff-tree -r --name-only '"+ merged +"' | sed -e '1d' -e 's-.*-<file>&</file>-'")
+    inheader = True
+    headers = {}
+    logmsg = ""
+    for line in rawcommit.split("\n"):
+        if inheader:
+            if line:
+                fields = line.split()
+                headers[fields[0]] = " ".join(fields[1:])
+            else:
+                inheader = False
+        else:
+            logmsg = line
+            break
+    (author, ts) = headers["author"].split(">")
+
+    # This discards the part of the authors addrsss after @.
+    # Might be bnicece to ship the full email address, if not
+    # for spammers' address harvesters - getting this wrong
+    # would make the freenode #commits channel into harvester heaven.
+    author = author.replace("<", "").split("@")[0].split()[-1]
+
+    # This ignores the timezone.  Not clear what to do with it...
+    ts = ts.strip().split()[0]
+
+    context = locals()
+    context.update(globals())
+
+    out = xml % context
+
+    message = '''\
+Message-ID: <%(merged)s.%(author)s@%(project)s>
+From: %(fromaddr)s
+To: %(toaddr)s
+Content-type: text/xml
+Subject: DeliverXML
+
+%(out)s''' % locals()
+
+    return message
+
+if __name__ == "__main__":
+    import getopt
+
+    try:
+        (options, arguments) = getopt.getopt(sys.argv[1:], "np:V")
+    except getopt.GetoptError, msg:
+        print "ciabot.py: " + str(msg)
+        raise SystemExit, 1
+
+    mailit = True
+    for (switch, val) in options:
+        if switch == '-p':
+            project = val
+        elif switch == '-n':
+            mailit = False
+        elif switch == '-V':
+            print "ciabot.py: version 3.2"
+            sys.exit(0)
+
+    # Cough and die if user has not specified a project
+    if not project:
+        sys.stderr.write("ciabot.py: no project specified, bailing out.\n")
+        sys.exit(1)
+
+    # We'll need the git version number.
+    gitver = do("git --version").split()[0]
+
+    urlprefix = urlprefix % globals()
+
+    # The script wants a reference to head followed by the list of
+    # commit ID to report about.
+    if len(arguments) == 0:
+        refname = do("git symbolic-ref HEAD 2>/dev/null")
+        merges = [do("git rev-parse HEAD")]
+    else:
+        refname = arguments[0]
+        merges = arguments[1:]
+
+    if mailit:
+        import smtplib
+        server = smtplib.SMTP('localhost')
+
+    for merged in merges:
+        message = report(refname, merged)
+        if mailit:
+            server.sendmail(fromaddr, [toaddr], message)
+        else:
+            print message
+
+    if mailit:
+        server.quit()
+
+#End
diff --git a/contrib/ciabot/ciabot.sh b/contrib/ciabot/ciabot.sh
new file mode 100755 (executable)
index 0000000..eb87bba
--- /dev/null
@@ -0,0 +1,192 @@
+#!/bin/sh
+# Distributed under the terms of the GNU General Public License v2
+# Copyright (c) 2006 Fernando J. Pereda <ferdy@gentoo.org>
+# Copyright (c) 2008 Natanael Copa <natanael.copa@gmail.com>
+# Copyright (c) 2010 Eric S. Raymond <esr@thyrsus.com>
+#
+# This is a version 3.x of ciabot.sh; use -V to find the exact
+# version.  Versions 1 and 2 were shipped in 2006 and 2008 and are not
+# version-stamped.  The version 2 maintainer has passed the baton.
+#
+# Note: This script should be considered obsolete.
+# There is a faster, better-documented rewrite in Python: find it as ciabot.py
+# Use this only if your hosting site forbids Python hooks.
+#
+# Originally based on Git ciabot.pl by Petr Baudis.
+# This script contains porcelain and porcelain byproducts.
+#
+# usage: ciabot.sh [-V] [-n] [-p projectname] [refname commit]
+#
+# This script is meant to be run either in a post-commit hook or in an
+# update hook.  If there's nothing unusual about your hosting setup,
+# you can specify the project name with a -p option and avoid having
+# to modify this script.  Try it with -n first to see the notification
+# mail dumped to stdout and verify that it looks sane.  Use -V to dump
+# the version and exit.
+#
+# In post-commit, run it without arguments (other than possibly a -p
+# option). It will query for current HEAD and the latest commit ID to
+# get the information it needs.
+#
+# In update, you have to call it once per merged commit:
+#
+#       refname=$1
+#       oldhead=$2
+#       newhead=$3
+#       for merged in $(git rev-list ${oldhead}..${newhead} | tac) ; do
+#               /path/to/ciabot.bash ${refname} ${merged}
+#       done
+#
+# The reason for the tac call ids that git rev-list emits commits from
+# most recent to least - better to ship notifactions from oldest to newest.
+#
+# Note: this script uses mail, not XML-RPC, in order to avoid stalling
+# until timeout when the CIA XML-RPC server is down.
+#
+
+#
+# The project as known to CIA. You will either want to change this
+# or set the project name with a -p option.
+#
+project=
+
+#
+# You may not need to change these:
+#
+
+# Name of the repository.
+# You can hardwire this to make the script faster.
+repo="`basename ${PWD}`"
+
+# Fully qualified domain name of the repo host.
+# You can hardwire this to make the script faster.
+host=`hostname --fqdn`
+
+# Changeset URL prefix for your repo: when the commit ID is appended
+# to this, it should point at a CGI that will display the commit
+# through gitweb or something similar. The defaults will probably
+# work if you have a typical gitweb/cgit setup.
+#urlprefix="http://${host}/cgi-bin/gitweb.cgi?p=${repo};a=commit;h="
+urlprefix="http://${host}/cgi-bin/cgit.cgi/${repo}/commit/?id="
+
+#
+# You probably will not need to change the following:
+#
+
+# Identify the script. Should change only when the script itself
+# gets a new home and maintainer.
+generator="http://www.catb.org/~esr/ciabot/ciabot.sh"
+
+# Addresses for the e-mail
+from="CIABOT-NOREPLY@${host}"
+to="cia@cia.navi.cx"
+
+# SMTP client to use - may need to edit the absolute pathname for your system
+sendmail="sendmail -t -f ${from}"
+
+#
+# No user-serviceable parts below this line:
+#
+
+# Should include all places sendmail is likely to lurk.
+PATH="$PATH:/usr/sbin/"
+
+mode=mailit
+while getopts pnV opt
+do
+    case $opt in
+       p) project=$2; shift ; shift ;;
+       n) mode=dumpit; shift ;;
+       V) echo "ciabot.sh: version 3.2"; exit 0; shift ;;
+    esac
+done
+
+# Cough and die if user has not specified a project
+if [ -z "$project" ]
+then
+    echo "ciabot.sh: no project specified, bailing out." >&2
+    exit 1
+fi
+
+if [ $# -eq 0 ] ; then
+       refname=$(git symbolic-ref HEAD 2>/dev/null)
+       merged=$(git rev-parse HEAD)
+else
+       refname=$1
+       merged=$2
+fi
+
+# This tries to turn your gitwebbish URL into a tinyurl so it will take up
+# less space on the IRC notification line. Some repo sites (I'm looking at
+# you, berlios.de!) forbid wget calls for security reasons.  On these,
+# the code will fall back to the full un-tinyfied URL.
+longurl=${urlprefix}${merged}
+url=$(wget -O - -q http://tinyurl.com/api-create.php?url=${longurl} 2>/dev/null)
+if [ -z "$url" ]; then
+       url="${longurl}"
+fi
+
+refname=${refname##refs/heads/}
+
+gitver=$(git --version)
+gitver=${gitver##* }
+
+rev=$(git describe ${merged} 2>/dev/null)
+# ${merged:0:12} was the only bashism left in the 2008 version of this
+# script, according to checkbashisms.  Replace it with ${merged} here
+# because it was just a fallback anyway, and it's worth accepting a
+# longer fallback for faster execution and removing the bash
+# dependency.
+[ -z ${rev} ] && rev=${merged}
+
+# This discards the part of the author's address after @.
+# Might be nice to ship the full email address, if not
+# for spammers' address harvesters - getting this wrong
+# would make the freenode #commits channel into harvester heaven.
+rawcommit=$(git cat-file commit ${merged})
+author=$(echo "$rawcommit" | sed -n -e '/^author .*<\([^@]*\).*$/s--\1-p')
+logmessage=$(echo "$rawcommit" | sed -e '1,/^$/d' | head -n 1)
+logmessage=$(echo "$logmessage" | sed 's/\&/&amp\;/g; s/</&lt\;/g; s/>/&gt\;/g')
+ts=$(echo "$rawcommit" | sed -n -e '/^author .*> \([0-9]\+\).*$/s--\1-p')
+files=$(git diff-tree -r --name-only ${merged} | sed -e '1d' -e 's-.*-<file>&</file>-')
+
+out="
+<message>
+  <generator>
+    <name>CIA Shell client for Git</name>
+    <version>${gitver}</version>
+    <url>${generator}</url>
+  </generator>
+  <source>
+    <project>${project}</project>
+    <branch>$repo:${refname}</branch>
+  </source>
+  <timestamp>${ts}</timestamp>
+  <body>
+    <commit>
+      <author>${author}</author>
+      <revision>${rev}</revision>
+      <files>
+       ${files}
+      </files>
+      <log>${logmessage} ${url}</log>
+      <url>${url}</url>
+    </commit>
+  </body>
+</message>"
+
+if [ "$mode" = "dumpit" ]
+then
+    sendmail=cat
+fi
+
+${sendmail} << EOM
+Message-ID: <${merged}.${author}@${project}>
+From: ${from}
+To: ${to}
+Content-type: text/xml
+Subject: DeliverXML
+${out}
+EOM
+
+# vim: set tw=70 :
index 733ac39a32f6fd0b4f1546d429ac55c4ad6699b6..545bd4b38368e3c2a3958133bbeef6a19e831fff 100755 (executable)
@@ -627,10 +627,19 @@ __git_aliased_command ()
        local word cmdline=$(git --git-dir="$(__gitdir)" \
                config --get "alias.$1")
        for word in $cmdline; do
-               if [ "${word##-*}" ]; then
-                       echo $word
+               case "$word" in
+               \!gitk|gitk)
+                       echo "gitk"
                        return
-               fi
+                       ;;
+               \!*)    : shell command alias ;;
+               -*)     : option ;;
+               *=*)    : setting env ;;
+               git)    : git itself ;;
+               *)
+                       echo "$word"
+                       return
+               esac
        done
 }
 
@@ -1084,6 +1093,11 @@ _git_gc ()
        COMPREPLY=()
 }
 
+_git_gitk ()
+{
+       _gitk
+}
+
 _git_grep ()
 {
        __git_has_doubledash && return
@@ -1436,6 +1450,11 @@ _git_send_email ()
        COMPREPLY=()
 }
 
+_git_stage ()
+{
+       _git_add
+}
+
 __git_config_get_set_variables ()
 {
        local prevword word config_file= c=$COMP_CWORD
@@ -2167,6 +2186,11 @@ _git_tag ()
        esac
 }
 
+_git_whatchanged ()
+{
+       _git_log
+}
+
 _git ()
 {
        local i c=1 command __git_dir
@@ -2203,64 +2227,14 @@ _git ()
                return
        fi
 
+       local completion_func="_git_${command//-/_}"
+       declare -F $completion_func >/dev/null && $completion_func && return
+
        local expansion=$(__git_aliased_command "$command")
-       [ "$expansion" ] && command="$expansion"
-
-       case "$command" in
-       am)          _git_am ;;
-       add)         _git_add ;;
-       apply)       _git_apply ;;
-       archive)     _git_archive ;;
-       bisect)      _git_bisect ;;
-       bundle)      _git_bundle ;;
-       branch)      _git_branch ;;
-       checkout)    _git_checkout ;;
-       cherry)      _git_cherry ;;
-       cherry-pick) _git_cherry_pick ;;
-       clean)       _git_clean ;;
-       clone)       _git_clone ;;
-       commit)      _git_commit ;;
-       config)      _git_config ;;
-       describe)    _git_describe ;;
-       diff)        _git_diff ;;
-       difftool)    _git_difftool ;;
-       fetch)       _git_fetch ;;
-       format-patch) _git_format_patch ;;
-       fsck)        _git_fsck ;;
-       gc)          _git_gc ;;
-       grep)        _git_grep ;;
-       help)        _git_help ;;
-       init)        _git_init ;;
-       log)         _git_log ;;
-       ls-files)    _git_ls_files ;;
-       ls-remote)   _git_ls_remote ;;
-       ls-tree)     _git_ls_tree ;;
-       merge)       _git_merge;;
-       mergetool)   _git_mergetool;;
-       merge-base)  _git_merge_base ;;
-       mv)          _git_mv ;;
-       name-rev)    _git_name_rev ;;
-       notes)       _git_notes ;;
-       pull)        _git_pull ;;
-       push)        _git_push ;;
-       rebase)      _git_rebase ;;
-       remote)      _git_remote ;;
-       replace)     _git_replace ;;
-       reset)       _git_reset ;;
-       revert)      _git_revert ;;
-       rm)          _git_rm ;;
-       send-email)  _git_send_email ;;
-       shortlog)    _git_shortlog ;;
-       show)        _git_show ;;
-       show-branch) _git_show_branch ;;
-       stash)       _git_stash ;;
-       stage)       _git_add ;;
-       submodule)   _git_submodule ;;
-       svn)         _git_svn ;;
-       tag)         _git_tag ;;
-       whatchanged) _git_log ;;
-       *)           COMPREPLY=() ;;
-       esac
+       if [ -n "$expansion" ]; then
+               completion_func="_git_${expansion//-/_}"
+               declare -F $completion_func >/dev/null && $completion_func
+       fi
 }
 
 _gitk ()
index 7051a83a59758277dd60fe026dea730eb7b6b115..82f5ed3ddc8adb1b9b281c3912f4e67c53ef152f 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 
 ## zip archive frontend for git-fast-import
 ##
index 854cd94ba55e498a3ff6c26be3dbe5191faa19dc..046cb2b268a82358630e86bb55cf8b4e58c730fb 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!/usr/bin/env python
 
 """ hg-to-git.py - A Mercurial to GIT converter
 
index 0f3d97b67eef3108728265e26f5d79c4526d11ac..b6e534b65b687d955a878d902b9bb46cfa2e42ce 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 #
 # This tool is copyright (c) 2006, Sean Estabrooks.
 # It is released under the Gnu Public License, version 2.
index 7d9e1c03e88d7785f4ff0d534563ba5778fbc244..a90ab10505a3694de83a0ffd8fc472518f12cf2b 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -590,14 +590,17 @@ static int execute(struct sockaddr *addr)
 static int addrcmp(const struct sockaddr_storage *s1,
     const struct sockaddr_storage *s2)
 {
-       if (s1->ss_family != s2->ss_family)
-               return s1->ss_family - s2->ss_family;
-       if (s1->ss_family == AF_INET)
+       const struct sockaddr *sa1 = (const struct sockaddr*) s1;
+       const struct sockaddr *sa2 = (const struct sockaddr*) s2;
+
+       if (sa1->sa_family != sa2->sa_family)
+               return sa1->sa_family - sa2->sa_family;
+       if (sa1->sa_family == AF_INET)
                return memcmp(&((struct sockaddr_in *)s1)->sin_addr,
                    &((struct sockaddr_in *)s2)->sin_addr,
                    sizeof(struct in_addr));
 #ifndef NO_IPV6
-       if (s1->ss_family == AF_INET6)
+       if (sa1->sa_family == AF_INET6)
                return memcmp(&((struct sockaddr_in6 *)s1)->sin6_addr,
                    &((struct sockaddr_in6 *)s2)->sin6_addr,
                    sizeof(struct in6_addr));
index d7e13cb177a3c345eb076a9ffede87c6e6afa367..c9f6e05badf7b752188dcb5fa28a9bef53521dee 100644 (file)
@@ -55,6 +55,27 @@ static int check_removed(const struct cache_entry *ce, struct stat *st)
        return 0;
 }
 
+/*
+ * Has a file changed or has a submodule new commits or a dirty work tree?
+ *
+ * Return 1 when changes are detected, 0 otherwise. If the DIRTY_SUBMODULES
+ * option is set, the caller does not only want to know if a submodule is
+ * modified at all but wants to know all the conditions that are met (new
+ * commits, untracked content and/or modified content).
+ */
+static int match_stat_with_submodule(struct diff_options *diffopt,
+                                     struct cache_entry *ce, struct stat *st,
+                                     unsigned ce_option, unsigned *dirty_submodule)
+{
+       int changed = ce_match_stat(ce, st, ce_option);
+       if (S_ISGITLINK(ce->ce_mode)
+           && !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)
+           && (!changed || DIFF_OPT_TST(diffopt, DIRTY_SUBMODULES))) {
+               *dirty_submodule = is_submodule_modified(ce->name, DIFF_OPT_TST(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES));
+       }
+       return changed;
+}
+
 int run_diff_files(struct rev_info *revs, unsigned int option)
 {
        int entries, i;
@@ -177,15 +198,9 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
                                       ce->sha1, ce->name, 0);
                        continue;
                }
-               changed = ce_match_stat(ce, &st, ce_option);
-               if (S_ISGITLINK(ce->ce_mode)
-                   && !DIFF_OPT_TST(&revs->diffopt, IGNORE_SUBMODULES)
-                   && (!changed || (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
-                   && is_submodule_modified(ce->name)) {
-                       changed = 1;
-                       dirty_submodule = 1;
-               }
-               if (!changed) {
+               changed = match_stat_with_submodule(&revs->diffopt, ce, &st,
+                                                   ce_option, &dirty_submodule);
+               if (!changed && !dirty_submodule) {
                        ce_mark_uptodate(ce);
                        if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
                                continue;
@@ -240,14 +255,8 @@ static int get_stat_data(struct cache_entry *ce,
                        }
                        return -1;
                }
-               changed = ce_match_stat(ce, &st, 0);
-               if (S_ISGITLINK(ce->ce_mode)
-                   && !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)
-                   && (!changed || (diffopt->output_format & DIFF_FORMAT_PATCH))
-                   && is_submodule_modified(ce->name)) {
-                       changed = 1;
-                       *dirty_submodule = 1;
-               }
+               changed = match_stat_with_submodule(diffopt, ce, &st,
+                                                   0, dirty_submodule);
                if (changed) {
                        mode = ce_mode_from_stat(ce, st.st_mode);
                        sha1 = null_sha1;
@@ -322,7 +331,7 @@ static int show_modified(struct rev_info *revs,
        }
 
        oldmode = old->ce_mode;
-       if (mode == oldmode && !hashcmp(sha1, old->sha1) &&
+       if (mode == oldmode && !hashcmp(sha1, old->sha1) && !dirty_submodule &&
            !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
                return 0;
 
@@ -510,9 +519,12 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
 int index_differs_from(const char *def, int diff_flags)
 {
        struct rev_info rev;
+       struct setup_revision_opt opt;
 
        init_revisions(&rev, NULL);
-       setup_revisions(0, NULL, &rev, def);
+       memset(&opt, 0, sizeof(opt));
+       opt.def = def;
+       setup_revisions(0, NULL, &rev, &opt);
        DIFF_OPT_SET(&rev.diffopt, QUICK);
        DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
        rev.diffopt.flags |= diff_flags;
diff --git a/diff.c b/diff.c
index dfdfa1a813c345b7653b1743afa75ff15d8c379f..e49f14a92442117a8e8424bd7a750dc4fda5cab2 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -14,6 +14,7 @@
 #include "userdiff.h"
 #include "sigchain.h"
 #include "submodule.h"
+#include "ll-merge.h"
 
 #ifdef NO_FAST_WORKING_DIRECTORY
 #define FAST_WORKING_DIRECTORY 0
@@ -43,7 +44,8 @@ static char diff_colors[][COLOR_MAXLEN] = {
 };
 
 static void diff_filespec_load_driver(struct diff_filespec *one);
-static char *run_textconv(const char *, struct diff_filespec *, size_t *);
+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)
 {
@@ -465,8 +467,8 @@ static void emit_rewrite_diff(const char *name_a,
                              const char *name_b,
                              struct diff_filespec *one,
                              struct diff_filespec *two,
-                             const char *textconv_one,
-                             const char *textconv_two,
+                             struct userdiff_driver *textconv_one,
+                             struct userdiff_driver *textconv_two,
                              struct diff_options *o)
 {
        int lc_a, lc_b;
@@ -477,7 +479,7 @@ static void emit_rewrite_diff(const char *name_a,
        const char *reset = diff_get_color(color_diff, DIFF_RESET);
        static struct strbuf a_name = STRBUF_INIT, b_name = STRBUF_INIT;
        const char *a_prefix, *b_prefix;
-       const char *data_one, *data_two;
+       char *data_one, *data_two;
        size_t size_one, size_two;
        struct emit_callback ecbdata;
 
@@ -499,26 +501,8 @@ static void emit_rewrite_diff(const char *name_a,
        quote_two_c_style(&a_name, a_prefix, name_a, 0);
        quote_two_c_style(&b_name, b_prefix, name_b, 0);
 
-       diff_populate_filespec(one, 0);
-       diff_populate_filespec(two, 0);
-       if (textconv_one) {
-               data_one = run_textconv(textconv_one, one, &size_one);
-               if (!data_one)
-                       die("unable to read files to diff");
-       }
-       else {
-               data_one = one->data;
-               size_one = one->size;
-       }
-       if (textconv_two) {
-               data_two = run_textconv(textconv_two, two, &size_two);
-               if (!data_two)
-                       die("unable to read files to diff");
-       }
-       else {
-               data_two = two->data;
-               size_two = two->size;
-       }
+       size_one = fill_textconv(textconv_one, one, &data_one);
+       size_two = fill_textconv(textconv_two, two, &data_two);
 
        memset(&ecbdata, 0, sizeof(ecbdata));
        ecbdata.color_diff = color_diff;
@@ -550,6 +534,10 @@ static void emit_rewrite_diff(const char *name_a,
                emit_rewrite_lines(&ecbdata, '-', data_one, size_one);
        if (lc_b)
                emit_rewrite_lines(&ecbdata, '+', data_two, size_two);
+       if (textconv_one)
+               free((char *)data_one);
+       if (textconv_two)
+               free((char *)data_two);
 }
 
 struct diff_words_buffer {
@@ -695,7 +683,6 @@ static void diff_words_show(struct diff_words_data *diff_words)
 {
        xpparam_t xpp;
        xdemitconf_t xecfg;
-       xdemitcb_t ecb;
        mmfile_t minus, plus;
 
        /* special case: only removal */
@@ -717,7 +704,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
        /* 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,
-                     &xpp, &xecfg, &ecb);
+                     &xpp, &xecfg);
        free(minus.ptr);
        free(plus.ptr);
        if (diff_words->current_plus != diff_words->plus.text.ptr +
@@ -948,7 +935,7 @@ struct diffstat_t {
                unsigned is_unmerged:1;
                unsigned is_binary:1;
                unsigned is_renamed:1;
-               unsigned int added, deleted;
+               uintmax_t added, deleted;
        } **files;
 };
 
@@ -1040,7 +1027,7 @@ static void fill_print_name(struct diffstat_file *file)
 static void show_stats(struct diffstat_t *data, struct diff_options *options)
 {
        int i, len, add, del, adds = 0, dels = 0;
-       int max_change = 0, max_len = 0;
+       uintmax_t max_change = 0, max_len = 0;
        int total_files = data->nr;
        int width, name_width;
        const char *reset, *set, *add_c, *del_c;
@@ -1069,7 +1056,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 
        for (i = 0; i < data->nr; i++) {
                struct diffstat_file *file = data->files[i];
-               int change = file->added + file->deleted;
+               uintmax_t change = file->added + file->deleted;
                fill_print_name(file);
                len = strlen(file->print_name);
                if (max_len < len)
@@ -1097,8 +1084,8 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
        for (i = 0; i < data->nr; i++) {
                const char *prefix = "";
                char *name = data->files[i]->print_name;
-               int added = data->files[i]->added;
-               int deleted = data->files[i]->deleted;
+               uintmax_t added = data->files[i]->added;
+               uintmax_t deleted = data->files[i]->deleted;
                int name_len;
 
                /*
@@ -1119,9 +1106,11 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
                if (data->files[i]->is_binary) {
                        show_name(options->file, prefix, name, len);
                        fprintf(options->file, "  Bin ");
-                       fprintf(options->file, "%s%d%s", del_c, deleted, reset);
+                       fprintf(options->file, "%s%"PRIuMAX"%s",
+                               del_c, deleted, reset);
                        fprintf(options->file, " -> ");
-                       fprintf(options->file, "%s%d%s", add_c, added, reset);
+                       fprintf(options->file, "%s%"PRIuMAX"%s",
+                               add_c, added, reset);
                        fprintf(options->file, " bytes");
                        fprintf(options->file, "\n");
                        continue;
@@ -1150,7 +1139,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
                        del = scale_linear(del, width, max_change);
                }
                show_name(options->file, prefix, name, len);
-               fprintf(options->file, "%5d%s", added + deleted,
+               fprintf(options->file, "%5"PRIuMAX"%s", added + deleted,
                                added + deleted ? " " : "");
                show_graph(options->file, '+', add, add_c, reset);
                show_graph(options->file, '-', del, del_c, reset);
@@ -1200,7 +1189,8 @@ static void show_numstat(struct diffstat_t *data, struct diff_options *options)
                        fprintf(options->file, "-\t-\t");
                else
                        fprintf(options->file,
-                               "%d\t%d\t", file->added, file->deleted);
+                               "%"PRIuMAX"\t%"PRIuMAX"\t",
+                               file->added, file->deleted);
                if (options->line_termination) {
                        fill_print_name(file);
                        if (!file->is_renamed)
@@ -1370,37 +1360,32 @@ static void free_diffstat_info(struct diffstat_t *diffstat)
 struct checkdiff_t {
        const char *filename;
        int lineno;
+       int conflict_marker_size;
        struct diff_options *o;
        unsigned ws_rule;
        unsigned status;
 };
 
-static int is_conflict_marker(const char *line, unsigned long len)
+static int is_conflict_marker(const char *line, int marker_size, unsigned long len)
 {
        char firstchar;
        int cnt;
 
-       if (len < 8)
+       if (len < marker_size + 1)
                return 0;
        firstchar = line[0];
        switch (firstchar) {
-       case '=': case '>': case '<':
+       case '=': case '>': case '<': case '|':
                break;
        default:
                return 0;
        }
-       for (cnt = 1; cnt < 7; cnt++)
+       for (cnt = 1; cnt < marker_size; cnt++)
                if (line[cnt] != firstchar)
                        return 0;
-       /* line[0] thru line[6] are same as firstchar */
-       if (firstchar == '=') {
-               /* divider between ours and theirs? */
-               if (len != 8 || line[7] != '\n')
-                       return 0;
-       } else if (len < 8 || !isspace(line[7])) {
-               /* not divider before ours nor after theirs */
+       /* line[1] thru line[marker_size-1] are same as firstchar */
+       if (len < marker_size + 1 || !isspace(line[marker_size]))
                return 0;
-       }
        return 1;
 }
 
@@ -1408,6 +1393,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
 {
        struct checkdiff_t *data = priv;
        int color_diff = DIFF_OPT_TST(data->o, COLOR_DIFF);
+       int marker_size = data->conflict_marker_size;
        const char *ws = diff_get_color(color_diff, DIFF_WHITESPACE);
        const char *reset = diff_get_color(color_diff, DIFF_RESET);
        const char *set = diff_get_color(color_diff, DIFF_FILE_NEW);
@@ -1416,7 +1402,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
        if (line[0] == '+') {
                unsigned bad;
                data->lineno++;
-               if (is_conflict_marker(line + 1, len - 1)) {
+               if (is_conflict_marker(line + 1, marker_size, len - 1)) {
                        data->status |= 1;
                        fprintf(data->o->file,
                                "%s:%d: leftover conflict marker\n",
@@ -1582,14 +1568,26 @@ void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const
                options->b_prefix = b;
 }
 
-static const char *get_textconv(struct diff_filespec *one)
+static struct userdiff_driver *get_textconv(struct diff_filespec *one)
 {
        if (!DIFF_FILE_VALID(one))
                return NULL;
        if (!S_ISREG(one->mode))
                return NULL;
        diff_filespec_load_driver(one);
-       return one->driver->textconv;
+       if (!one->driver->textconv)
+               return NULL;
+
+       if (one->driver->textconv_want_cache && !one->driver->textconv_cache) {
+               struct notes_cache *c = xmalloc(sizeof(*c));
+               struct strbuf name = STRBUF_INIT;
+
+               strbuf_addf(&name, "textconv/%s", one->driver->name);
+               notes_cache_init(c, name.buf, one->driver->textconv);
+               one->driver->textconv_cache = c;
+       }
+
+       return one->driver;
 }
 
 static void builtin_diff(const char *name_a,
@@ -1606,7 +1604,8 @@ static void builtin_diff(const char *name_a,
        const char *set = diff_get_color_opt(o, DIFF_METAINFO);
        const char *reset = diff_get_color_opt(o, DIFF_RESET);
        const char *a_prefix, *b_prefix;
-       const char *textconv_one = NULL, *textconv_two = NULL;
+       struct userdiff_driver *textconv_one = NULL;
+       struct userdiff_driver *textconv_two = NULL;
        struct strbuf header = STRBUF_INIT;
 
        if (DIFF_OPT_TST(o, SUBMODULE_LOG) &&
@@ -1680,12 +1679,11 @@ static void builtin_diff(const char *name_a,
                }
        }
 
-       if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
-               die("unable to read files to diff");
-
        if (!DIFF_OPT_TST(o, TEXT) &&
-           ( (diff_filespec_is_binary(one) && !textconv_one) ||
-             (diff_filespec_is_binary(two) && !textconv_two) )) {
+           ( (!textconv_one && diff_filespec_is_binary(one)) ||
+             (!textconv_two && diff_filespec_is_binary(two)) )) {
+               if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
+                       die("unable to read files to diff");
                /* Quite common confusing case */
                if (mf1.size == mf2.size &&
                    !memcmp(mf1.ptr, mf2.ptr, mf1.size))
@@ -1704,7 +1702,6 @@ static void builtin_diff(const char *name_a,
                const char *diffopts = getenv("GIT_DIFF_OPTS");
                xpparam_t xpp;
                xdemitconf_t xecfg;
-               xdemitcb_t ecb;
                struct emit_callback ecbdata;
                const struct userdiff_funcname *pe;
 
@@ -1713,20 +1710,8 @@ static void builtin_diff(const char *name_a,
                        strbuf_reset(&header);
                }
 
-               if (textconv_one) {
-                       size_t size;
-                       mf1.ptr = run_textconv(textconv_one, one, &size);
-                       if (!mf1.ptr)
-                               die("unable to read files to diff");
-                       mf1.size = size;
-               }
-               if (textconv_two) {
-                       size_t size;
-                       mf2.ptr = run_textconv(textconv_two, two, &size);
-                       if (!mf2.ptr)
-                               die("unable to read files to diff");
-                       mf2.size = size;
-               }
+               mf1.size = fill_textconv(textconv_one, one, &mf1.ptr);
+               mf2.size = fill_textconv(textconv_two, two, &mf2.ptr);
 
                pe = diff_funcname_pattern(one);
                if (!pe)
@@ -1776,7 +1761,7 @@ static void builtin_diff(const char *name_a,
                        }
                }
                xdi_diff_outf(&mf1, &mf2, fn_out_consume, &ecbdata,
-                             &xpp, &xecfg, &ecb);
+                             &xpp, &xecfg);
                if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))
                        free_diff_words_data(&ecbdata);
                if (textconv_one)
@@ -1829,13 +1814,12 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
                /* Crazy xdl interfaces.. */
                xpparam_t xpp;
                xdemitconf_t xecfg;
-               xdemitcb_t ecb;
 
                memset(&xpp, 0, sizeof(xpp));
                memset(&xecfg, 0, sizeof(xecfg));
                xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
                xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
-                             &xpp, &xecfg, &ecb);
+                             &xpp, &xecfg);
        }
 
  free_and_return:
@@ -1860,6 +1844,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
        data.lineno = 0;
        data.o = o;
        data.ws_rule = whitespace_rule(attr_path);
+       data.conflict_marker_size = ll_merge_marker_size(attr_path);
 
        if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
                die("unable to read files to diff");
@@ -1876,14 +1861,13 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
                /* Crazy xdl interfaces.. */
                xpparam_t xpp;
                xdemitconf_t xecfg;
-               xdemitcb_t ecb;
 
                memset(&xpp, 0, sizeof(xpp));
                memset(&xecfg, 0, sizeof(xecfg));
                xecfg.ctxlen = 1; /* at least one context line */
                xpp.flags = XDF_NEED_MINIMAL;
                xdi_diff_outf(&mf1, &mf2, checkdiff_consume, &data,
-                             &xpp, &xecfg, &ecb);
+                             &xpp, &xecfg);
 
                if (data.ws_rule & WS_BLANK_AT_EOF) {
                        struct emit_callback ecbdata;
@@ -2032,7 +2016,7 @@ static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
        char *data = xmalloc(100), *dirty = "";
 
        /* Are we looking at the work tree? */
-       if (!s->sha1_valid && s->dirty_submodule)
+       if (s->dirty_submodule)
                dirty = "-dirty";
 
        len = snprintf(data, 100,
@@ -2628,6 +2612,12 @@ int diff_setup_done(struct diff_options *options)
         */
        if (options->pickaxe)
                DIFF_OPT_SET(options, RECURSIVE);
+       /*
+        * When patches are generated, submodules diffed against the work tree
+        * must be checked for dirtiness too so it can be shown in the output
+        */
+       if (options->output_format & DIFF_FORMAT_PATCH)
+               DIFF_OPT_SET(options, DIRTY_SUBMODULES);
 
        if (options->detect_rename && options->rename_limit < 0)
                options->rename_limit = diff_rename_limit_default;
@@ -3086,7 +3076,8 @@ int diff_unmodified_pair(struct diff_filepair *p)
         * dealing with a change.
         */
        if (one->sha1_valid && two->sha1_valid &&
-           !hashcmp(one->sha1, two->sha1))
+           !hashcmp(one->sha1, two->sha1) &&
+           !one->dirty_submodule && !two->dirty_submodule)
                return 1; /* no change */
        if (!one->sha1_valid && !two->sha1_valid)
                return 1; /* both look at the same file on the filesystem. */
@@ -3221,6 +3212,8 @@ static void diff_resolve_rename_copy(void)
                }
                else if (hashcmp(p->one->sha1, p->two->sha1) ||
                         p->one->mode != p->two->mode ||
+                        p->one->dirty_submodule ||
+                        p->two->dirty_submodule ||
                         is_null_sha1(p->one->sha1))
                        p->status = DIFF_STATUS_MODIFIED;
                else {
@@ -3369,7 +3362,6 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
        for (i = 0; i < q->nr; i++) {
                xpparam_t xpp;
                xdemitconf_t xecfg;
-               xdemitcb_t ecb;
                mmfile_t mf1, mf2;
                struct diff_filepair *p = q->queue[i];
                int len1, len2;
@@ -3431,7 +3423,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
                xecfg.ctxlen = 3;
                xecfg.flags = XDL_EMIT_FUNCNAMES;
                xdi_diff_outf(&mf1, &mf2, patch_id_consume, &data,
-                             &xpp, &xecfg, &ecb);
+                             &xpp, &xecfg);
        }
 
        git_SHA1_Final(sha1, &ctx);
@@ -3874,6 +3866,7 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
        const char **arg = argv;
        struct child_process child;
        struct strbuf buf = STRBUF_INIT;
+       int err = 0;
 
        temp = prepare_temp_file(spec->path, spec);
        *arg++ = pgm;
@@ -3884,17 +3877,65 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
        child.use_shell = 1;
        child.argv = argv;
        child.out = -1;
-       if (start_command(&child) != 0 ||
-           strbuf_read(&buf, child.out, 0) < 0 ||
-           finish_command(&child) != 0) {
-               close(child.out);
-               strbuf_release(&buf);
+       if (start_command(&child)) {
                remove_tempfile();
-               error("error running textconv command '%s'", pgm);
                return NULL;
        }
+
+       if (strbuf_read(&buf, child.out, 0) < 0)
+               err = error("error reading from textconv command '%s'", pgm);
        close(child.out);
+
+       if (finish_command(&child) || err) {
+               strbuf_release(&buf);
+               remove_tempfile();
+               return NULL;
+       }
        remove_tempfile();
 
        return strbuf_detach(&buf, outsize);
 }
+
+static size_t fill_textconv(struct userdiff_driver *driver,
+                           struct diff_filespec *df,
+                           char **outbuf)
+{
+       size_t size;
+
+       if (!driver || !driver->textconv) {
+               if (!DIFF_FILE_VALID(df)) {
+                       *outbuf = "";
+                       return 0;
+               }
+               if (diff_populate_filespec(df, 0))
+                       die("unable to read files to diff");
+               *outbuf = df->data;
+               return df->size;
+       }
+
+       if (driver->textconv_cache) {
+               *outbuf = notes_cache_get(driver->textconv_cache, df->sha1,
+                                         &size);
+               if (*outbuf)
+                       return size;
+       }
+
+       *outbuf = run_textconv(driver->textconv, df, &size);
+       if (!*outbuf)
+               die("unable to read files to diff");
+
+       if (driver->textconv_cache) {
+               /* ignore errors, as we might be in a readonly repository */
+               notes_cache_put(driver->textconv_cache, df->sha1, *outbuf,
+                               size);
+               /*
+                * we could save up changes and flush them all at the end,
+                * but we would need an extra call after all diffing is done.
+                * Since generating a cache entry is the slow path anyway,
+                * this extra overhead probably isn't a big deal.
+                */
+               notes_cache_write(driver->textconv_cache);
+       }
+
+       return size;
+}
diff --git a/diff.h b/diff.h
index 2ef3341fb0852fc8958fa5c5eacab69ee68c0ad9..6a71013dc63fc0912fd4f3d27f70ae909917f1f6 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -69,6 +69,8 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
 #define DIFF_OPT_ALLOW_TEXTCONV      (1 << 21)
 #define DIFF_OPT_DIFF_FROM_CONTENTS  (1 << 22)
 #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_TST(opts, flag)    ((opts)->flags & DIFF_OPT_##flag)
 #define DIFF_OPT_SET(opts, flag)    ((opts)->flags |= DIFF_OPT_##flag)
index 66687c3fe5ea4552cff2b864b73696460ca40b1e..fcd00bf27aee4e1f2823f05ab3dba1d3c70a509d 100644 (file)
@@ -42,7 +42,9 @@ struct diff_filespec {
 #define DIFF_FILE_VALID(spec) (((spec)->mode) != 0)
        unsigned should_free : 1; /* data should be free()'ed */
        unsigned should_munmap : 1; /* data should be munmap()'ed */
-       unsigned dirty_submodule : 1;  /* For submodules: its work tree is dirty */
+       unsigned dirty_submodule : 2;  /* For submodules: its work tree is dirty */
+#define DIRTY_SUBMODULE_UNTRACKED 1
+#define DIRTY_SUBMODULE_MODIFIED  2
 
        struct userdiff_driver *driver;
        /* data should be considered "binary"; -1 means "don't know yet" */
index 50a292a7da58aab3b5ce62347b02dee35395da2a..1056075545ad3e5e42626d167c91c1deada6186b 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -593,6 +593,7 @@ do
                        echo "Patch is empty.  Was it split wrong?"
                        stop_here $this
                }
+               rm -f "$dotest/original-commit"
                if test -f "$dotest/rebasing" &&
                        commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
                                -e q "$dotest/$msgnum") &&
@@ -600,6 +601,7 @@ do
                then
                        git cat-file commit "$commit" |
                        sed -e '1,/^$/d' >"$dotest/msg-clean"
+                       echo "$commit" > "$dotest/original-commit"
                else
                        {
                                sed -n '/^Subject/ s/Subject: //p' "$dotest/info"
@@ -783,6 +785,10 @@ do
        git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
        stop_here $this
 
+       if test -f "$dotest/original-commit"; then
+               echo "$(cat "$dotest/original-commit") $commit" >> "$dotest/rewritten"
+       fi
+
        if test -x "$GIT_DIR"/hooks/post-applypatch
        then
                "$GIT_DIR"/hooks/post-applypatch
@@ -791,5 +797,12 @@ do
        go_next
 done
 
+if test -s "$dotest"/rewritten; then
+    git notes copy --for-rewrite=rebase < "$dotest"/rewritten
+    if test -x "$GIT_DIR"/hooks/post-rewrite; then
+       "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten
+    fi
+fi
+
 rm -fr "$dotest"
 git gc --auto
index 9bed5a0b47b57d64c559faf09250166c77906ceb..6e259772895599b35d13564e62077b882f0de3a6 100644 (file)
@@ -55,7 +55,8 @@
 # else
 # define _XOPEN_SOURCE 500
 # endif
-#elif !defined(__APPLE__) && !defined(__FreeBSD__)  && !defined(__USLC__) && !defined(_M_UNIX) && !defined(sgi)
+#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && \
+      !defined(_M_UNIX) && !defined(sgi) && !defined(__DragonFly__)
 #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
 #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
 #endif
@@ -478,5 +479,14 @@ void git_qsort(void *base, size_t nmemb, size_t size,
  * Always returns the return value of unlink(2).
  */
 int unlink_or_warn(const char *path);
+/*
+ * Likewise for rmdir(2).
+ */
+int rmdir_or_warn(const char *path);
+/*
+ * Calls the correct function out of {unlink,rmdir}_or_warn based on
+ * the supplied file mode.
+ */
+int remove_or_warn(unsigned int mode, const char *path);
 
 #endif
index d975d072dbf0fab36266c3f3a71a69875206e4d8..adc42de8752fd395707f1e395c61991b3146cebb 100755 (executable)
@@ -78,11 +78,13 @@ sub generate_command
                        next;
                }
                if ($arg eq '-g' || $arg eq '--gui') {
-                       my $tool = Git::command_oneline('config',
-                                                       'diff.guitool');
-                       if (length($tool)) {
-                               $ENV{GIT_DIFF_TOOL} = $tool;
-                       }
+                       eval {
+                               my $tool = Git::command_oneline('config',
+                                                               'diff.guitool');
+                               if (length($tool)) {
+                                       $ENV{GIT_DIFF_TOOL} = $tool;
+                               }
+                       };
                        next;
                }
                if ($arg eq '-y' || $arg eq '--no-prompt') {
index 6a65f255cc63cc7a6d0ae0fc0ce4b65298a40e82..f6080149c22bad8b3434b874b9e4079ac508ca69 100755 (executable)
@@ -212,7 +212,7 @@ server.errorlog = "$fqgitdir/gitweb/error.log"
 # variable above and uncomment this
 #accesslog.filename = "$fqgitdir/gitweb/access.log"
 
-setenv.add-environment = ( "PATH" => "/usr/local/bin:/usr/bin:/bin" )
+setenv.add-environment = ( "PATH" => env.PATH )
 
 cgi.assign = ( ".cgi" => "" )
 
@@ -361,7 +361,7 @@ error_log   $fqgitdir/gitweb/error.log
 access_log     $fqgitdir/gitweb/access.log
 
 #cgi setup
-cgi_env                PATH=/usr/local/bin:/usr/bin:/bin,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH
+cgi_env                PATH=$PATH,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH
 cgi_interp     $PERL
 cgi_ext                cgi,pl
 
@@ -391,18 +391,20 @@ EOFGITWEB
 gitweb_css () {
        cat > "$1" <<\EOFGITWEB
 @@GITWEB_CSS@@
+
 EOFGITWEB
 }
 
 gitweb_js () {
        cat > "$1" <<\EOFGITWEB
 @@GITWEB_JS@@
+
 EOFGITWEB
 }
 
 gitweb_cgi "$GIT_DIR/gitweb/gitweb.cgi"
-gitweb_css "$GIT_DIR/gitweb/gitweb.css"
-gitweb_js  "$GIT_DIR/gitweb/gitweb.js"
+gitweb_css "$GIT_DIR/@@GITWEB_CSS_NAME@@"
+gitweb_js  "$GIT_DIR/@@GITWEB_JS_NAME@@"
 
 case "$httpd" in
 *lighttpd*)
index 3e4fd1456f1ebb4aabb61de6d7f13f820ae2abdc..436b7f5977c05c347debc12130f822af482c03e3 100755 (executable)
@@ -20,6 +20,7 @@ v,verbose          display a diffstat of what changed upstream
 onto=              rebase onto given branch instead of upstream
 p,preserve-merges  try to recreate merges instead of ignoring them
 s,strategy=        use the given merge strategy
+no-ff              cherry-pick all commits, even if unchanged
 m,merge            always used (no-op)
 i,interactive      always used (no-op)
  Actions:
@@ -96,6 +97,13 @@ AUTHOR_SCRIPT="$DOTEST"/author-script
 # command is processed, this file is deleted.
 AMEND="$DOTEST"/amend
 
+# For the post-rewrite hook, we make a list of rewritten commits and
+# their new sha1s.  The rewritten-pending list keeps the sha1s of
+# commits that have been processed, but not committed yet,
+# e.g. because they are waiting for a 'squash' command.
+REWRITTEN_LIST="$DOTEST"/rewritten-list
+REWRITTEN_PENDING="$DOTEST"/rewritten-pending
+
 PRESERVE_MERGES=
 STRATEGY=
 ONTO=
@@ -103,6 +111,7 @@ VERBOSE=
 OK_TO_SKIP_PRE_REBASE=
 REBASE_ROOT=
 AUTOSQUASH=
+NEVER_FF=
 
 GIT_CHERRY_PICK_HELP="  After resolving the conflicts,
 mark the corrected paths with 'git add <paths>', and
@@ -198,6 +207,7 @@ make_patch () {
 }
 
 die_with_patch () {
+       echo "$1" > "$DOTEST"/stopped-sha
        make_patch "$1"
        git rerere
        die "$2"
@@ -222,8 +232,9 @@ do_with_author () {
 }
 
 pick_one () {
-       no_ff=
-       case "$1" in -n) sha1=$2; no_ff=t ;; *) sha1=$1 ;; esac
+       ff=--ff
+       case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac
+       case "$NEVER_FF" in '') ;; ?*) ff= ;; esac
        output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
        test -d "$REWRITTEN" &&
                pick_one_preserving_merges "$@" && return
@@ -232,16 +243,7 @@ pick_one () {
                output git cherry-pick "$@"
                return
        fi
-       parent_sha1=$(git rev-parse --verify $sha1^) ||
-               die "Could not get the parent of $sha1"
-       current_sha1=$(git rev-parse --verify HEAD)
-       if test -z "$no_ff" && test "$current_sha1" = "$parent_sha1"
-       then
-               output git reset --hard $sha1
-               output warn Fast-forward to $(git rev-parse --short $sha1)
-       else
-               output git cherry-pick "$@"
-       fi
+       output git cherry-pick $ff "$@"
 }
 
 pick_one_preserving_merges () {
@@ -348,6 +350,7 @@ pick_one_preserving_merges () {
                                printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
                                die_with_patch $sha1 "Error redoing merge $sha1"
                        fi
+                       echo "$sha1 $(git rev-parse HEAD^0)" >> "$REWRITTEN_LIST"
                        ;;
                *)
                        output git cherry-pick "$@" ||
@@ -425,6 +428,26 @@ die_failed_squash() {
        die_with_patch $1 ""
 }
 
+flush_rewritten_pending() {
+       test -s "$REWRITTEN_PENDING" || return
+       newsha1="$(git rev-parse HEAD^0)"
+       sed "s/$/ $newsha1/" < "$REWRITTEN_PENDING" >> "$REWRITTEN_LIST"
+       rm -f "$REWRITTEN_PENDING"
+}
+
+record_in_rewritten() {
+       oldsha1="$(git rev-parse $1)"
+       echo "$oldsha1" >> "$REWRITTEN_PENDING"
+
+       case "$(peek_next_command)" in
+           squash|s|fixup|f)
+               ;;
+           *)
+               flush_rewritten_pending
+               ;;
+       esac
+}
+
 do_next () {
        rm -f "$MSG" "$AUTHOR_SCRIPT" "$AMEND" || exit
        read command sha1 rest < "$TODO"
@@ -438,6 +461,7 @@ do_next () {
                mark_action_done
                pick_one $sha1 ||
                        die_with_patch $sha1 "Could not apply $sha1... $rest"
+               record_in_rewritten $sha1
                ;;
        reword|r)
                comment_for_reflog reword
@@ -445,7 +469,8 @@ do_next () {
                mark_action_done
                pick_one $sha1 ||
                        die_with_patch $sha1 "Could not apply $sha1... $rest"
-               git commit --amend
+               git commit --amend --no-post-rewrite
+               record_in_rewritten $sha1
                ;;
        edit|e)
                comment_for_reflog edit
@@ -453,6 +478,7 @@ do_next () {
                mark_action_done
                pick_one $sha1 ||
                        die_with_patch $sha1 "Could not apply $sha1... $rest"
+               echo "$sha1" > "$DOTEST"/stopped-sha
                make_patch $sha1
                git rev-parse --verify HEAD > "$AMEND"
                warn "Stopped at $sha1... $rest"
@@ -509,6 +535,7 @@ do_next () {
                        rm -f "$SQUASH_MSG" "$FIXUP_MSG"
                        ;;
                esac
+               record_in_rewritten $sha1
                ;;
        *)
                warn "Unknown command: $command $sha1 $rest"
@@ -537,6 +564,16 @@ do_next () {
                test ! -f "$DOTEST"/verbose ||
                        git diff-tree --stat $(cat "$DOTEST"/head)..HEAD
        } &&
+       {
+               test -s "$REWRITTEN_LIST" &&
+               git notes copy --for-rewrite=rebase < "$REWRITTEN_LIST" ||
+               true # we don't care if this copying failed
+       } &&
+       if test -x "$GIT_DIR"/hooks/post-rewrite &&
+               test -s "$REWRITTEN_LIST"; then
+               "$GIT_DIR"/hooks/post-rewrite rebase < "$REWRITTEN_LIST"
+               true # we don't care if this hook failed
+       fi &&
        rm -rf "$DOTEST" &&
        git gc --auto &&
        warn "Successfully rebased and updated $HEADNAME."
@@ -571,7 +608,12 @@ skip_unnecessary_picks () {
                esac
                echo "$command${sha1:+ }$sha1${rest:+ }$rest" >&$fd
        done <"$TODO" >"$TODO.new" 3>>"$DONE" &&
-       mv -f "$TODO".new "$TODO" ||
+       mv -f "$TODO".new "$TODO" &&
+       case "$(peek_next_command)" in
+       squash|s|fixup|f)
+               record_in_rewritten "$ONTO"
+               ;;
+       esac ||
        die "Could not skip unnecessary pick commands"
 }
 
@@ -687,6 +729,8 @@ first and then run 'git rebase --continue' again."
                        }
                fi
 
+               record_in_rewritten "$(cat "$DOTEST"/stopped-sha)"
+
                require_clean_work_tree
                do_rest
                ;;
@@ -742,6 +786,9 @@ first and then run 'git rebase --continue' again."
        -i)
                # yeah, we know
                ;;
+       --no-ff)
+               NEVER_FF=t
+               ;;
        --root)
                REBASE_ROOT=t
                ;;
@@ -783,8 +830,6 @@ first and then run 'git rebase --continue' again."
 
                if test ! -z "$1"
                then
-                       output git show-ref --verify --quiet "refs/heads/$1" ||
-                               die "Invalid branchname: $1"
                        output git checkout "$1" ||
                                die "Could not checkout $1"
                fi
@@ -927,7 +972,7 @@ EOF
                has_action "$TODO" ||
                        die_abort "Nothing to do"
 
-               test -d "$REWRITTEN" || skip_unnecessary_picks
+               test -d "$REWRITTEN" || test -n "$NEVER_FF" || skip_unnecessary_picks
 
                git update-ref ORIG_HEAD $HEAD
                output git checkout $ONTO && do_rest
index fb4fef7b1d6f7abb08fca562ecaad6e36f671768..44f5c65fdb5e81c4b660a666c2edd71aa75c5c1a 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Junio C Hamano.
 #
 
-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--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>
@@ -79,6 +79,7 @@ continue_merge () {
                then
                        printf "Committed: %0${prec}d " $msgnum
                fi
+               echo "$cmt $(git rev-parse HEAD^0)" >> "$dotest/rewritten"
        else
                if test -z "$GIT_QUIET"
                then
@@ -151,6 +152,11 @@ move_to_original_branch () {
 
 finish_rb_merge () {
        move_to_original_branch
+       git notes copy --for-rewrite=rebase < "$dotest"/rewritten
+       if test -x "$GIT_DIR"/hooks/post-rewrite &&
+               test -s "$dotest"/rewritten; then
+               "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten
+       fi
        rm -r "$dotest"
        say All done.
 }
@@ -347,7 +353,7 @@ do
        --root)
                rebase_root=t
                ;;
-       -f|--f|--fo|--for|--forc|force|--force-r|--force-re|--force-reb|--force-reba|--force-rebas|--force-rebase)
+       -f|--f|--fo|--for|--forc|force|--force-r|--force-re|--force-reb|--force-reba|--force-rebas|--force-rebase|--no-ff)
                force_rebase=t
                ;;
        --rerere-autoupdate|--no-rerere-autoupdate)
index d612ae8729e0a15f501214b6f27f4fc32a66e9fd..ce569a9c8f964b3cdc8920325bc817141035c2c3 100755 (executable)
@@ -64,6 +64,8 @@ git send-email [options] <file | directory | rev-list options >
     --smtp-pass             <str>  * Password for SMTP-AUTH; not necessary.
     --smtp-encryption       <str>  * tls or ssl; anything else disables.
     --smtp-ssl                     * Deprecated. Use '--smtp-encryption ssl'.
+    --smtp-domain           <str>  * The domain name sent to HELO/EHLO handshake
+    --smtp-debug            <0|1>  * Disable, enable Net::SMTP debug.
 
   Automating:
     --identity              <str>  * Use the sendemail.<id> options.
@@ -130,6 +132,8 @@ my $have_email_valid = eval { require Email::Valid; 1 };
 my $have_mail_address = eval { require Mail::Address; 1 };
 my $smtp;
 my $auth;
+my $mail_domain_default = "localhost.localdomain";
+my $mail_domain;
 
 sub unique_email_list(@);
 sub cleanup_compose_files();
@@ -162,9 +166,12 @@ my $compose_filename;
 
 # Handle interactive edition of files.
 my $multiedit;
-my $editor = Git::command_oneline('var', 'GIT_EDITOR');
+my $editor;
 
 sub do_edit {
+       if (!defined($editor)) {
+               $editor = Git::command_oneline('var', 'GIT_EDITOR');
+       }
        if (defined($multiedit) && !$multiedit) {
                map {
                        system('sh', '-c', $editor.' "$@"', $editor, $_);
@@ -187,6 +194,8 @@ my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
 my ($validate, $confirm);
 my (@suppress_cc);
 
+my ($debug_net_smtp) = 0;              # Net::SMTP, see send_message()
+
 my $not_set_by_user = "true but not set by the user";
 
 my %config_bool_settings = (
@@ -273,6 +282,8 @@ my $rc = GetOptions("sender|from=s" => \$sender,
                    "smtp-pass:s" => \$smtp_authpass,
                    "smtp-ssl" => sub { $smtp_encryption = 'ssl' },
                    "smtp-encryption=s" => \$smtp_encryption,
+                   "smtp-debug:i" => \$debug_net_smtp,
+                   "smtp-domain:s" => \$mail_domain,
                    "identity=s" => \$identity,
                    "annotate" => \$annotate,
                    "compose" => \$compose,
@@ -836,6 +847,62 @@ sub sanitize_address
 
 }
 
+# Returns the local Fully Qualified Domain Name (FQDN) if available.
+#
+# Tightly configured MTAa require that a caller sends a real DNS
+# domain name that corresponds the IP address in the HELO/EHLO
+# handshake. This is used to verify the connection and prevent
+# spammers from trying to hide their identity. If the DNS and IP don't
+# match, the receiveing MTA may deny the connection.
+#
+# Here is a deny example of Net::SMTP with the default "localhost.localdomain"
+#
+# Net::SMTP=GLOB(0x267ec28)>>> EHLO localhost.localdomain
+# Net::SMTP=GLOB(0x267ec28)<<< 550 EHLO argument does not match calling host
+#
+# This maildomain*() code is based on ideas in Perl library Test::Reporter
+# /usr/share/perl5/Test/Reporter/Mail/Util.pm ==> sub _maildomain ()
+
+sub maildomain_net
+{
+       my $maildomain;
+
+       if (eval { require Net::Domain; 1 }) {
+               my $domain = Net::Domain::domainname();
+               $maildomain = $domain
+                       unless $^O eq 'darwin' && $domain =~ /\.local$/;
+       }
+
+       return $maildomain;
+}
+
+sub maildomain_mta
+{
+       my $maildomain;
+
+       if (eval { require Net::SMTP; 1 }) {
+               for my $host (qw(mailhost localhost)) {
+                       my $smtp = Net::SMTP->new($host);
+                       if (defined $smtp) {
+                               my $domain = $smtp->domain;
+                               $smtp->quit;
+
+                               $maildomain = $domain
+                                       unless $^O eq 'darwin' && $domain =~ /\.local$/;
+
+                               last if $maildomain;
+                       }
+               }
+       }
+
+       return $maildomain;
+}
+
+sub maildomain
+{
+       return maildomain_net() || maildomain_mta() || $mail_domain_default;
+}
+
 # Returns 1 if the message was sent, and 0 otherwise.
 # In actuality, the whole program dies when there
 # is an error sending a message.
@@ -938,13 +1005,19 @@ X-Mailer: git-send-email $gitversion
                if ($smtp_encryption eq 'ssl') {
                        $smtp_server_port ||= 465; # ssmtp
                        require Net::SMTP::SSL;
-                       $smtp ||= Net::SMTP::SSL->new($smtp_server, Port => $smtp_server_port);
+                       $mail_domain ||= maildomain();
+                       $smtp ||= Net::SMTP::SSL->new($smtp_server,
+                                                     Hello => $mail_domain,
+                                                     Port => $smtp_server_port);
                }
                else {
                        require Net::SMTP;
+                       $mail_domain ||= maildomain();
                        $smtp ||= Net::SMTP->new((defined $smtp_server_port)
                                                 ? "$smtp_server:$smtp_server_port"
-                                                : $smtp_server);
+                                                : $smtp_server,
+                                                Hello => $mail_domain,
+                                                Debug => $debug_net_smtp);
                        if ($smtp_encryption eq 'tls' && $smtp) {
                                require Net::SMTP::SSL;
                                $smtp->command('STARTTLS');
@@ -963,7 +1036,11 @@ X-Mailer: git-send-email $gitversion
                }
 
                if (!$smtp) {
-                       die "Unable to initialize SMTP properly.  Is there something wrong with your config?";
+                       die "Unable to initialize SMTP properly. Check config and use --smtp-debug. ",
+                           "VALUES: server=$smtp_server ",
+                           "encryption=$smtp_encryption ",
+                           "maildomain=$mail_domain",
+                           defined $smtp_server_port ? "port=$smtp_server_port" : "";
                }
 
                if (defined $smtp_authuser) {
index aa47e541ee4fe55254edc3fb59ef534ba4d5be66..59db3dc38e72fda88d521171a174c08b919677a9 100755 (executable)
@@ -210,14 +210,18 @@ list_stash () {
 }
 
 show_stash () {
+       have_stash || die 'No stash found'
+
        flags=$(git rev-parse --no-revs --flags "$@")
        if test -z "$flags"
        then
                flags=--stat
        fi
 
-       w_commit=$(git rev-parse --verify --default $ref_stash "$@") &&
-       b_commit=$(git rev-parse --verify "$w_commit^") &&
+       w_commit=$(git rev-parse --quiet --verify --default $ref_stash "$@") &&
+       b_commit=$(git rev-parse --quiet --verify "$w_commit^") ||
+               die "'$*' is not a stash"
+
        git diff $flags $b_commit $w_commit
 }
 
index f21d0bfce7020edeaed8c0066760e5f55e7facb9..3319b836b217a26b4ac55ae5ced328ffafa0a015 100755 (executable)
@@ -21,6 +21,8 @@ command=
 branch=
 reference=
 cached=
+recursive=
+init=
 files=
 nofetch=
 update=
@@ -559,7 +561,9 @@ cmd_summary() {
                test $# = 0 || shift
        elif test -z "$1" -o "$1" = "HEAD"
        then
-               return
+               # before the first commit: compare with an empty tree
+               head=$(git hash-object -w -t tree --stdin </dev/null)
+               test -z "$1" || shift
        else
                head="HEAD"
        fi
index ee74a5eed7758f1267441d85619969a121fb3cec..9533147ff2e06282dc8d60aeb371afa715e22cc1 100644 (file)
@@ -127,6 +127,9 @@ find $RPM_BUILD_ROOT -type f -name perllocal.pod -exec rm -f {} ';'
 rm -rf $RPM_BUILD_ROOT%{_mandir}
 %endif
 
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d
+install -m 644 -T contrib/completion/git-completion.bash $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/git
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
@@ -136,6 +139,7 @@ rm -rf $RPM_BUILD_ROOT
 %doc README COPYING Documentation/*.txt
 %{!?_without_docs: %doc Documentation/*.html Documentation/howto}
 %{!?_without_docs: %doc Documentation/technical}
+%{_sysconfdir}/bash_completion.d
 
 %files svn
 %defattr(-,root,root)
@@ -192,6 +196,9 @@ rm -rf $RPM_BUILD_ROOT
 # No files for you!
 
 %changelog
+* Fri Mar 26 2010 Ian Ward Comfort <icomfort@stanford.edu>
+- Ship bash completion support from contrib/ in the core package.
+
 * Sun Jan 31 2010 Junio C Hamano <gitster@pobox.com>
 - Do not use %define inside %{!?...} construct.
 
index c62dfd0f4ddafbc82be15519f17815bbfcd62e8b..74b05dc91e42414147d5f3dc7b4fc66fb86c0eca 100644 (file)
@@ -7,7 +7,11 @@ pysetupfile:=setup.py
 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
 
 ifndef PYTHON_PATH
-       PYTHON_PATH = /usr/bin/python
+       ifeq ($(uname_S),FreeBSD)
+               PYTHON_PATH = /usr/local/bin/python
+       else
+               PYTHON_PATH = /usr/bin/python
+       endif
 endif
 ifndef prefix
        prefix = $(HOME)
index 1f36a3e815865fcc72b171b497f5c4e341e148ee..1b0e09a561e01c51bdc6dbced052e0c753924618 100644 (file)
@@ -1877,8 +1877,11 @@ proc setoptions {} {
     option add *Menubutton.font uifont startupFile
     option add *Label.font uifont startupFile
     option add *Message.font uifont startupFile
-    option add *Entry.font uifont startupFile
+    option add *Entry.font textfont startupFile
+    option add *Text.font textfont startupFile
     option add *Labelframe.font uifont startupFile
+    option add *Spinbox.font textfont startupFile
+    option add *Listbox.font mainfont startupFile
 }
 
 # Make a menu and submenus.
@@ -2174,7 +2177,7 @@ proc makewindow {} {
     set findstring {}
     set fstring .tf.lbar.findstring
     lappend entries $fstring
-    ${NS}::entry $fstring -width 30 -font textfont -textvariable findstring
+    ${NS}::entry $fstring -width 30 -textvariable findstring
     trace add variable findstring write find_change
     set findtype [mc "Exact"]
     set findtypemenu [makedroplist .tf.lbar.findtype \
@@ -2217,7 +2220,7 @@ proc makewindow {} {
     pack .bleft.top.search -side left -padx 5
     set sstring .bleft.top.sstring
     set searchstring ""
-    ${NS}::entry $sstring -width 20 -font textfont -textvariable searchstring
+    ${NS}::entry $sstring -width 20 -textvariable searchstring
     lappend entries $sstring
     trace add variable searchstring write incrsearch
     pack $sstring -side left -expand 1 -fill x
@@ -2229,7 +2232,7 @@ proc makewindow {} {
        -command changediffdisp -variable diffelide -value {1 0}
     ${NS}::label .bleft.mid.labeldiffcontext -text "      [mc "Lines of context"]: "
     pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
-    spinbox .bleft.mid.diffcontext -width 5 -font textfont \
+    spinbox .bleft.mid.diffcontext -width 5 \
        -from 0 -increment 1 -to 10000000 \
        -validate all -validatecommand "diffcontextvalidate %P" \
        -textvariable diffcontextstring
@@ -2383,6 +2386,8 @@ proc makewindow {} {
     }
     bindall <$::BM> "canvscan mark %W %x %y"
     bindall <B$::BM-Motion> "canvscan dragto %W %x %y"
+    bind all <$M1B-Key-w> {destroy [winfo toplevel %W]}
+    bind . <$M1B-Key-w> doquit
     bindkey <Home> selfirstline
     bindkey <End> sellastline
     bind . <Key-Up> "selnextline -1"
@@ -2782,7 +2787,7 @@ proc about {} {
     message $w.m -text [mc "
 Gitk - a commit viewer for git
 
-Copyright © 2005-2009 Paul Mackerras
+Copyright \u00a9 2005-2010 Paul Mackerras
 
 Use and redistribute under the terms of the GNU General Public License"] \
            -justify center -aspect 400 -border 2 -bg white -relief groove
@@ -2814,6 +2819,7 @@ proc keys {} {
 [mc "Gitk key bindings:"]
 
 [mc "<%s-Q>            Quit" $M1T]
+[mc "<%s-W>            Close window" $M1T]
 [mc "<Home>            Move to first commit"]
 [mc "<End>             Move to last commit"]
 [mc "<Up>, p, i        Move up one commit"]
@@ -3805,10 +3811,10 @@ proc newview {ishighlight} {
        raise $top
        return
     }
+    decode_view_opts $nextviewnum $revtreeargs
     set newviewname($nextviewnum) "[mc "View"] $nextviewnum"
     set newviewopts($nextviewnum,perm) 0
     set newviewopts($nextviewnum,cmd)  $viewargscmd($curview)
-    decode_view_opts $nextviewnum $revtreeargs
     vieweditor $top $nextviewnum [mc "Gitk view definition"]
 }
 
@@ -3845,6 +3851,7 @@ set known_view_options {
     {cmd       t50= +  {}               {mc "Command to generate more commits to include:"}}
     }
 
+# Convert $newviewopts($n, ...) into args for git log.
 proc encode_view_opts {n} {
     global known_view_options newviewopts
 
@@ -3878,6 +3885,7 @@ proc encode_view_opts {n} {
     return [concat $rargs [shellsplit $newviewopts($n,args)]]
 }
 
+# Fill $newviewopts($n, ...) based on args for git log.
 proc decode_view_opts {n view_args} {
     global known_view_options newviewopts
 
@@ -3960,10 +3968,10 @@ proc editview {} {
        raise $top
        return
     }
+    decode_view_opts $curview $viewargs($curview)
     set newviewname($curview)      $viewname($curview)
     set newviewopts($curview,perm) $viewperm($curview)
     set newviewopts($curview,cmd)  $viewargscmd($curview)
-    decode_view_opts $curview $viewargs($curview)
     vieweditor $top $curview "[mc "Gitk: edit view"] $viewname($curview)"
 }
 
@@ -4037,7 +4045,7 @@ proc vieweditor {top n title} {
        } elseif {$type eq "path"} {
            ${NS}::label $top.l -text $title
            pack $top.l -in $top -side top -pady [list 3 0] -anchor w -padx 3
-           text $top.t -width 40 -height 5 -background $bgcolor -font uifont
+           text $top.t -width 40 -height 5 -background $bgcolor
            if {[info exists viewfiles($n)]} {
                foreach f $viewfiles($n) {
                    $top.t insert end $f
@@ -7501,7 +7509,7 @@ proc getblobdiffs {ids} {
     global ignorespace
     global limitdiffs vfilelimit curview
     global diffencoding targetline diffnparents
-    global git_version
+    global git_version currdiffsubmod
 
     set textconv {}
     if {[package vcompare $git_version "1.6.1"] >= 0} {
@@ -7528,6 +7536,7 @@ proc getblobdiffs {ids} {
     set diffencoding [get_path_encoding {}]
     fconfigure $bdf -blocking 0 -encoding binary -eofchar {}
     set blobdifffd($ids) $bdf
+    set currdiffsubmod ""
     filerun $bdf [list getblobdiffline $bdf $diffids]
 }
 
@@ -7598,7 +7607,7 @@ proc getblobdiffline {bdf ids} {
     global diffnexthead diffnextnote difffilestart
     global ctext_file_names ctext_file_lines
     global diffinhdr treediffs mergemax diffnparents
-    global diffencoding jump_to_here targetline diffline
+    global diffencoding jump_to_here targetline diffline currdiffsubmod
 
     set nr 0
     $ctext conf -state normal
@@ -7679,19 +7688,30 @@ proc getblobdiffline {bdf ids} {
 
        } elseif {![string compare -length 10 "Submodule " $line]} {
            # start of a new submodule
-           if {[string compare [$ctext get "end - 4c" end] "\n \n\n"]} {
+           if {[regexp -indices "\[0-9a-f\]+\\.\\." $line nameend]} {
+               set fname [string range $line 10 [expr [lindex $nameend 0] - 2]]
+           } else {
+               set fname [string range $line 10 [expr [string first "contains " $line] - 2]]
+           }
+           if {$currdiffsubmod != $fname} {
                $ctext insert end "\n";     # Add newline after commit message
            }
            set curdiffstart [$ctext index "end - 1c"]
            lappend ctext_file_names ""
-           set fname [string range $line 10 [expr [string last " " $line] - 1]]
-           lappend ctext_file_lines $fname
-           makediffhdr $fname $ids
-           $ctext insert end "\n$line\n" filesep
+           if {$currdiffsubmod != $fname} {
+               lappend ctext_file_lines $fname
+               makediffhdr $fname $ids
+               set currdiffsubmod $fname
+               $ctext insert end "\n$line\n" filesep
+           } else {
+               $ctext insert end "$line\n" filesep
+           }
        } elseif {![string compare -length 3 "  >" $line]} {
+           set $currdiffsubmod ""
            set line [encoding convertfrom $diffencoding $line]
            $ctext insert end "$line\n" dresult
        } elseif {![string compare -length 3 "  <" $line]} {
+           set $currdiffsubmod ""
            set line [encoding convertfrom $diffencoding $line]
            $ctext insert end "$line\n" d0
        } elseif {$diffinhdr} {
@@ -8527,7 +8547,7 @@ proc do_cmp_commits {a b} {
 }
 
 proc diffcommits {a b} {
-    global diffcontext diffids blobdifffd diffinhdr
+    global diffcontext diffids blobdifffd diffinhdr currdiffsubmod
 
     set tmpdir [gitknewtmpdir]
     set fna [file join $tmpdir "commit-[string range $a 0 7]"]
@@ -8548,6 +8568,7 @@ proc diffcommits {a b} {
     set diffids [list commits $a $b]
     set blobdifffd($diffids) $fd
     set diffinhdr 0
+    set currdiffsubmod ""
     filerun $fd [list getblobdiffline $fd $diffids]
 }
 
@@ -10528,7 +10549,6 @@ proc mkfontdisp {font top which} {
     set fontpref($font) [set $font]
     ${NS}::button $top.${font}but -text $which \
        -command [list choosefont $font $which]
-    if {!$use_ttk} {$top.${font}but configure  -font optionfont}
     ${NS}::label $top.$font -relief flat -font $font \
        -text $fontattr($font,family) -justify left
     grid x $top.${font}but $top.$font -sticky w
@@ -10791,15 +10811,6 @@ proc doprefs {} {
     mkfontdisp textfont $top [mc "Diff display font"]
     mkfontdisp uifont $top [mc "User interface font"]
 
-    if {!$use_ttk} {
-       foreach w {maxpctl maxwidthl showlocal autoselect tabstopl ntag
-           ldiff lattr extdifff.l extdifff.b bgbut fgbut
-           diffoldbut diffnewbut hunksepbut markbgbut selbgbut
-           want_ttk ttk_note} {
-           $top.$w configure -font optionfont
-       }
-    }
-
     ${NS}::frame $top.buts
     ${NS}::button $top.buts.ok -text [mc "OK"] -command prefsok -default active
     ${NS}::button $top.buts.can -text [mc "Cancel"] -command prefscan -default normal
@@ -10849,6 +10860,7 @@ proc setselbg {c} {
 # radiobuttons look bad.  This chooses white for selectColor if the
 # background color is light, or black if it is dark.
 proc setui {c} {
+    if {[tk windowingsystem] eq "win32"} { return }
     set bg [winfo rgb . $c]
     set selc black
     if {[lindex $bg 0] + 1.5 * [lindex $bg 1] + 0.5 * [lindex $bg 2] > 100000} {
@@ -11411,8 +11423,6 @@ namespace import ::msgcat::mc
 
 catch {source ~/.gitk}
 
-font create optionfont -family sans-serif -size -12
-
 parsefont mainfont $mainfont
 eval font create mainfont [fontflags mainfont]
 eval font create mainfontbold [fontflags mainfont 1]
@@ -11613,3 +11623,9 @@ if {[tk windowingsystem] eq "win32"} {
 }
 
 getcommits {}
+
+# Local variables:
+# mode: tcl
+# indent-tabs-mode: t
+# tab-width: 8
+# End:
index c79aa9cbc813dfe13bb39db2eacd1cc7ab49441c..bd194a3dff9fd36b2edbe64f053a975f489a159b 100644 (file)
@@ -334,14 +334,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright ©9 2005-2009 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - eine Visualisierung der Git-Historie\n"
 "\n"
-"Copyright © 2005-2009 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Benutzung und Weiterverbreitung gemäß den Bedingungen der GNU General Public License"
 
index 0e19b5eae27ed10e6cae524e9dc69cca1b1f428f..0471dd0672d837371fad32db5eddd32207e63c1f 100644 (file)
@@ -281,14 +281,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2008 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - un visualizador de revisiones para git\n"
 "\n"
-"Copyright © 2005-2008 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Uso y redistribución permitidos según los términos de la Licencia Pública "
 "General de GNU (GNU GPL)"
index cb0e1edc634d29f3ddf83ae39c4f9c75d7374326..5370ddc393dfa0b72220d9e572a60be606927da4 100644 (file)
@@ -334,14 +334,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2008 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - visualisateur de commit pour git\n"
 "\n"
-"Copyright © 2005-2008 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Utilisation et redistribution soumises aux termes de la GNU General Public "
 "License"
index 1df212e8817258da3bf870997e42e75fad09fe95..7262b610dc0489ce9bcc4512a7e02bba5c758682 100644 (file)
@@ -333,14 +333,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright ©9 2005-2009 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - commit nézegető a githez\n"
 "\n"
-"Szerzői jog ©9 2005-2009 Paul Mackerras\n"
+"Szerzői jog \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Használd és terjeszd a GNU General Public License feltételei mellett"
 
index 4818652309d91e90fb4595b500cb687bcdedcb94..a730d63a42ad380548e454410eafcbadece85387 100644 (file)
@@ -334,14 +334,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2009 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - un visualizzatore di revisioni per git\n"
 "\n"
-"Copyright © 2005-2009 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Utilizzo e redistribuzione permessi sotto i termini della GNU General Public "
 "License"
index c0c92addb41c9e1e59c0f314a7b37b4470dcebbe..4f4705164c0c71b64bee4e833c0960b9344c2ad9 100644 (file)
@@ -335,14 +335,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2008 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - gitコミットビューア\n"
 "\n"
-"Copyright © 2005-2008 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "使用および再配布は GNU General Public License に従ってください"
 
index 704eba8f9d39655099aa66864d1dd34a84bd0a9d..c3d0285b2429d92ca40297bfb2135365ba49f371 100644 (file)
@@ -313,14 +313,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2008 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - программа просмотра истории репозиториев Git\n"
 "\n"
-"Copyright (c) 2005-2008 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Использование и распространение согласно условиям GNU General Public License"
 
index 0f5e2fd8d79b585e1487b7ba9e2d1a36a49c7c7d..386763ade786d96b657dd0ab737b633eef44b424 100644 (file)
@@ -334,14 +334,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright ©9 2005-2009 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - en incheckningsvisare för git\n"
 "\n"
-"Copyright © 2005-2009 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
 "\n"
 "Använd och vidareförmedla enligt villkoren i GNU General Public License"
 
index b76a0cffff783ba580294560f0ee53131776136b..cbdc1364700d79b9d8b41850790baee103f31ca1 100644 (file)
@@ -2,11 +2,11 @@ GIT web Interface (gitweb) Installation
 =======================================
 
 First you have to generate gitweb.cgi from gitweb.perl using
-"make gitweb/gitweb.cgi", then copy appropriate files (gitweb.cgi,
+"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 prefix=/usr gitweb/gitweb.cgi  ;# as yourself
+       $ make prefix=/usr gitweb             ;# as yourself
        # cp gitweb/git* /var/www/cgi-bin/    ;# as root
 
 Alternatively you can use autoconf generated ./configure script to
@@ -15,7 +15,7 @@ instead
 
        $ make configure                     ;# as yourself
        $ ./configure --prefix=/usr          ;# as yourself
-       $ make gitweb/gitweb.cgi             ;# as yourself
+       $ make gitweb                        ;# as yourself
        # cp gitweb/git* /var/www/cgi-bin/   ;# as root
 
 The above example assumes that your web server is configured to run
@@ -31,8 +31,7 @@ file for gitweb (in gitweb/README).
 
 - There are many configuration variables which affect building of
   gitweb.cgi; see "default configuration for gitweb" section in main
-  (top dir) Makefile, and instructions for building gitweb/gitweb.cgi
-  target.
+  (top dir) Makefile, and instructions for building gitweb target.
 
   One of the most important is where to find the git wrapper binary. Gitweb
   tries to find the git wrapper at $(bindir)/git, so you have to set $bindir
@@ -62,9 +61,15 @@ file for gitweb (in gitweb/README).
   a suggestion).
 
 - You can control where gitweb tries to find its main CSS style file,
-  its favicon and logo with the GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO
-  build configuration variables. By default gitweb tries to find them
-  in the same directory as gitweb.cgi script.
+  its JavaScript file, its favicon and logo with the GITWEB_CSS, GITWEB_JS
+  GITWEB_FAVICON and GITWEB_LOGO build configuration variables. By default
+  gitweb tries to find them in the same directory as gitweb.cgi script.
+
+- You can optionally generate minified versions of gitweb.js and gitweb.css
+  by defining the JSMIN and CSSMIN build configuration variables. By default
+  the non-minified versions will be used. NOTE: if you enable this option,
+  substitute gitweb.min.js and gitweb.min.css for all uses of gitweb.js and
+  gitweb.css in the help files.
 
 Build example
 ~~~~~~~~~~~~~
@@ -74,13 +79,14 @@ Build example
   we want to display are under /home/local/scm, 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" \
             bindir=/usr/local/bin \
-            gitweb/gitweb.cgi
+            gitweb
 
-       cp -fv ~/git/gitweb/gitweb.{cgi,css} \
+       cp -fv ~/git/gitweb/gitweb.{cgi,js,css} \
               ~/git/gitweb/git-{favicon,logo}.png \
             /var/www/cgi-bin/gitweb/
 
index c9eb1ee6678aa180d74e3da3a74537766f0b1fe4..f2e1d92fbb965893b14adf2e9acb904bab953812 100644 (file)
@@ -6,14 +6,14 @@ all::
 # Define JSMIN to point to JavaScript minifier that functions as
 # a filter to have gitweb.js minified.
 #
+# Define CSSMIN to point to a CSS minifier in order to generate a minified
+# version of gitweb.css
+#
 
 prefix ?= $(HOME)
 bindir ?= $(prefix)/bin
 RM ?= rm -f
 
-# JavaScript minifier invocation that can function as filter
-JSMIN ?=
-
 # default configuration for gitweb
 GITWEB_CONFIG = gitweb_config.perl
 GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
@@ -29,11 +29,7 @@ GITWEB_HOMETEXT = indextext.html
 GITWEB_CSS = gitweb.css
 GITWEB_LOGO = git-logo.png
 GITWEB_FAVICON = git-favicon.png
-ifdef JSMIN
-GITWEB_JS = gitweb.min.js
-else
 GITWEB_JS = gitweb.js
-endif
 GITWEB_SITE_HEADER =
 GITWEB_SITE_FOOTER =
 
@@ -85,45 +81,54 @@ endif
 all:: gitweb.cgi
 
 ifdef JSMIN
-FILES=gitweb.cgi gitweb.min.js
-gitweb.cgi: gitweb.perl gitweb.min.js
-else # !JSMIN
-FILES=gitweb.cgi
-gitweb.cgi: gitweb.perl
-endif # JSMIN
-
-gitweb.cgi:
+GITWEB_JS = gitweb.min.js
+all:: gitweb.min.js
+gitweb.min.js: gitweb.js GITWEB-BUILD-OPTIONS
+       $(QUIET_GEN)$(JSMIN) <$< >$@
+endif
+
+ifdef CSSMIN
+GITWEB_CSS = gitweb.min.css
+all:: gitweb.min.css
+gitweb.min.css: gitweb.css GITWEB-BUILD-OPTIONS
+       $(QUIET_GEN)$(CSSMIN) <$ >$@
+endif
+
+GITWEB_REPLACE = \
+       -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
+       -e 's|++GIT_BINDIR++|$(bindir)|g' \
+       -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
+       -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
+       -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
+       -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
+       -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
+       -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
+       -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
+       -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
+       -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
+       -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
+       -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
+       -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
+       -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
+       -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
+       -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
+       -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
+       -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g'
+
+GITWEB-BUILD-OPTIONS: FORCE
+       @rm -f $@+
+       @echo "x" '$(PERL_PATH_SQ)' $(GITWEB_REPLACE) "$(JSMIN)|$(CSSMIN)" >$@+
+       @cmp -s $@+ $@ && rm -f $@+ || mv -f $@+ $@
+
+gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
        $(QUIET_GEN)$(RM) $@ $@+ && \
        sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
-           -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
-           -e 's|++GIT_BINDIR++|$(bindir)|g' \
-           -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
-           -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
-           -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
-           -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
-           -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
-           -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
-           -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
-           -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
-           -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
-           -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
-           -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
-           -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
-           -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
-           -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
-           -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
-           -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
-           -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
-           $< >$@+ && \
+               $(GITWEB_REPLACE) $< >$@+ && \
        chmod +x $@+ && \
        mv $@+ $@
 
-ifdef JSMIN
-gitweb.min.js: gitweb.js
-       $(QUIET_GEN)$(JSMIN) <$< >$@
-endif # JSMIN
-
 clean:
-       $(RM) $(FILES)
+       $(RM) gitweb.cgi gitweb.min.js gitweb.min.css GITWEB-BUILD-OPTIONS
+
+.PHONY: all clean .FORCE-GIT-VERSION-FILE FORCE
 
-.PHONY: all clean .FORCE-GIT-VERSION-FILE
index ad6a04c464075c31afe3c67222f0bdeabc76f569..71742b335dd786a24699b06b17519e264724ea5b 100644 (file)
@@ -80,7 +80,8 @@ 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]
+   the gitweb config file.  [Default: gitweb.css (or 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
index a2d2283ec921acac7b068537eb85f63c16de9556..c356e95f18f0f784584ce644c08e1966ca1be52f 100755 (executable)
@@ -2216,8 +2216,7 @@ sub config_to_multi {
 sub git_get_project_config {
        my ($key, $type) = @_;
 
-       # do we have project
-       return unless (defined $project && defined $git_dir);
+       return unless defined $git_dir;
 
        # key sanity check
        return unless ($key);
diff --git a/grep.c b/grep.c
index fdc42062687fa6b8bb77c8d09ed58aee9107692d..543b1d53784c16020dea089f23c431c7f2608425 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -570,8 +570,7 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
                        if (opt->show_hunk_mark) {
                                output_color(opt, "--", 2, opt->color_sep);
                                opt->output(opt, "\n", 1);
-                       } else
-                               opt->show_hunk_mark = 1;
+                       }
                } else if (lno > opt->last_shown + 1) {
                        output_color(opt, "--", 2, opt->color_sep);
                        opt->output(opt, "\n", 1);
@@ -772,14 +771,6 @@ int grep_threads_ok(const struct grep_opt *opt)
            !opt->name_only)
                return 0;
 
-       /* If we are showing hunk marks, we should not do it for the
-        * first match. The synchronization problem we get for this
-        * constraint is not yet solved, so we disable threading in
-        * this case.
-        */
-       if (opt->pre_context || opt->post_context)
-               return 0;
-
        return 1;
 }
 
@@ -801,11 +792,14 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
        enum grep_context ctx = GREP_CONTEXT_HEAD;
        xdemitconf_t xecfg;
 
-       opt->last_shown = 0;
-
        if (!opt->output)
                opt->output = std_output;
 
+       if (opt->last_shown && (opt->pre_context || opt->post_context) &&
+           opt->output == std_output)
+               opt->show_hunk_mark = 1;
+       opt->last_shown = 0;
+
        if (buffer_is_binary(buf, size)) {
                switch (opt->binary) {
                case GREP_BINARY_DEFAULT:
index 345c12b79064f23e0ae0a15781731b9a42272d83..d1e83d0906dbc9d677630cdf74615ec3f9dfc46d 100644 (file)
@@ -538,15 +538,19 @@ static void service_rpc(char *service_name)
 
 static NORETURN void die_webcgi(const char *err, va_list params)
 {
-       char buffer[1000];
+       static int dead;
 
-       http_status(500, "Internal Server Error");
-       hdr_nocache();
-       end_headers();
+       if (!dead) {
+               char buffer[1000];
+               dead = 1;
 
-       vsnprintf(buffer, sizeof(buffer), err, params);
-       fprintf(stderr, "fatal: %s\n", buffer);
-       exit(0);
+               vsnprintf(buffer, sizeof(buffer), err, params);
+               fprintf(stderr, "fatal: %s\n", buffer);
+               http_status(500, "Internal Server Error");
+               hdr_nocache();
+               end_headers();
+       }
+       exit(0); /* we successfully reported a failure ;-) */
 }
 
 static char* getdir(void)
diff --git a/http.c b/http.c
index 4814217c6401faa1fd8f13f0288758f57b5e3755..51253e15a160b8bade37d24308ac3de92e5abe89 100644 (file)
--- a/http.c
+++ b/http.c
@@ -815,7 +815,21 @@ static int http_request(const char *url, void *result, int target, int options)
                        ret = HTTP_OK;
                else if (missing_target(&results))
                        ret = HTTP_MISSING_TARGET;
-               else
+               else if (results.http_code == 401) {
+                       if (user_name) {
+                               ret = HTTP_NOAUTH;
+                       } else {
+                               /*
+                                * git_getpass is needed here because its very likely stdin/stdout are
+                                * pipes to our parent process.  So we instead need to use /dev/tty,
+                                * but that is non-portable.  Using git_getpass() can at least be stubbed
+                                * on other platforms with a different implementation if/when necessary.
+                                */
+                               user_name = xstrdup(git_getpass("Username: "));
+                               init_curl_http_auth(slot->curl);
+                               ret = HTTP_REAUTH;
+                       }
+               } else
                        ret = HTTP_ERROR;
        } else {
                error("Unable to start HTTP request for %s", url);
@@ -831,7 +845,11 @@ static int http_request(const char *url, void *result, int target, int options)
 
 int http_get_strbuf(const char *url, struct strbuf *result, int options)
 {
-       return http_request(url, result, HTTP_REQUEST_STRBUF, options);
+       int http_ret = http_request(url, result, HTTP_REQUEST_STRBUF, options);
+       if (http_ret == HTTP_REAUTH) {
+               http_ret = http_request(url, result, HTTP_REQUEST_STRBUF, options);
+       }
+       return http_ret;
 }
 
 /*
diff --git a/http.h b/http.h
index 5c9441c10ce708be426afe7424d63dcbb68a49e2..2dd03e88b75e2f4dd7b328e5baf5359adebc945e 100644 (file)
--- a/http.h
+++ b/http.h
@@ -126,6 +126,8 @@ extern char *get_remote_object_url(const char *url, const char *hex,
 #define HTTP_MISSING_TARGET    1
 #define HTTP_ERROR             2
 #define HTTP_START_FAILED      3
+#define HTTP_REAUTH    4
+#define HTTP_NOAUTH    5
 
 /*
  * Requests an url and stores the result in a strbuf.
index aeb2985b831c982f10c3905f5053136520fcc4fe..9d0097ca02960460ff3a104f1739982fee453987 100644 (file)
@@ -1226,9 +1226,6 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
                        fprintf(stderr, "Skipping account %s@%s, server forbids LOGIN\n", srvc->user, srvc->host);
                        goto bail;
                }
-               if (!imap->buf.sock.ssl)
-                       imap_warn("*** IMAP Warning *** Password is being "
-                                 "sent in the clear\n");
 
                if (srvc->auth_method) {
                        struct imap_cmd_cb cb;
@@ -1253,6 +1250,9 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
                                goto bail;
                        }
                } else {
+                       if (!imap->buf.sock.ssl)
+                               imap_warn("*** IMAP Warning *** Password is being "
+                                         "sent in the clear\n");
                        if (imap_exec(ctx, NULL, "LOGIN \"%s\" \"%s\"", srvc->user, srvc->pass) != RESP_OK) {
                                fprintf(stderr, "IMAP error: LOGIN failed\n");
                                goto bail;
@@ -1431,8 +1431,14 @@ static int count_messages(struct msg_data *msg)
 
        while (1) {
                if (!prefixcmp(p, "From ")) {
+                       p = strstr(p+5, "\nFrom: ");
+                       if (!p) break;
+                       p = strstr(p+7, "\nDate: ");
+                       if (!p) break;
+                       p = strstr(p+7, "\nSubject: ");
+                       if (!p) break;
+                       p += 10;
                        count++;
-                       p += 5;
                }
                p = strstr(p+5, "\nFrom ");
                if (!p)
index 27afcf697238a48c01dd49996f5263cd72a52eac..d3ae969f608b50a469aa60b2e925558a6bb437e5 100644 (file)
@@ -514,6 +514,16 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
                        return 0;
                else if (opt->combine_merges)
                        return do_diff_combined(opt, commit);
+               else if (opt->first_parent_only) {
+                       /*
+                        * Generate merge log entry only for the first
+                        * parent, showing summary diff of the others
+                        * we merged _in_.
+                        */
+                       diff_tree_sha1(parents->item->object.sha1, sha1, "", &opt->diffopt);
+                       log_tree_diff_flush(opt);
+                       return !opt->loginfo;
+               }
 
                /* If we show individual diffs, show the parent info */
                log->parent = parents->item;
index 917397ca7a0c3a702681e1c3e93eb385bb6f28fb..206c1036359ce7b1fc5a1f5734b2d0bc2a760d90 100644 (file)
@@ -409,7 +409,7 @@ static int remove_file(struct merge_options *o, int clean,
                        return -1;
        }
        if (update_working_directory) {
-               if (remove_path(path) && errno != ENOENT)
+               if (remove_path(path))
                        return -1;
        }
        return 0;
diff --git a/notes-cache.c b/notes-cache.c
new file mode 100644 (file)
index 0000000..dee6d62
--- /dev/null
@@ -0,0 +1,94 @@
+#include "cache.h"
+#include "notes-cache.h"
+#include "commit.h"
+#include "refs.h"
+
+static int notes_cache_match_validity(const char *ref, const char *validity)
+{
+       unsigned char sha1[20];
+       struct commit *commit;
+       struct pretty_print_context pretty_ctx;
+       struct strbuf msg = STRBUF_INIT;
+       int ret;
+
+       if (read_ref(ref, sha1) < 0)
+               return 0;
+
+       commit = lookup_commit_reference_gently(sha1, 1);
+       if (!commit)
+               return 0;
+
+       memset(&pretty_ctx, 0, sizeof(pretty_ctx));
+       format_commit_message(commit, "%s", &msg, &pretty_ctx);
+       strbuf_trim(&msg);
+
+       ret = !strcmp(msg.buf, validity);
+       strbuf_release(&msg);
+
+       return ret;
+}
+
+void notes_cache_init(struct notes_cache *c, const char *name,
+                    const char *validity)
+{
+       struct strbuf ref = STRBUF_INIT;
+       int flags = 0;
+
+       memset(c, 0, sizeof(*c));
+       c->validity = xstrdup(validity);
+
+       strbuf_addf(&ref, "refs/notes/%s", name);
+       if (!notes_cache_match_validity(ref.buf, validity))
+               flags = NOTES_INIT_EMPTY;
+       init_notes(&c->tree, ref.buf, combine_notes_overwrite, flags);
+       strbuf_release(&ref);
+}
+
+int notes_cache_write(struct notes_cache *c)
+{
+       unsigned char tree_sha1[20];
+       unsigned char commit_sha1[20];
+
+       if (!c || !c->tree.initialized || !c->tree.ref || !*c->tree.ref)
+               return -1;
+       if (!c->tree.dirty)
+               return 0;
+
+       if (write_notes_tree(&c->tree, tree_sha1))
+               return -1;
+       if (commit_tree(c->validity, tree_sha1, NULL, commit_sha1, NULL) < 0)
+               return -1;
+       if (update_ref("update notes cache", c->tree.ref, commit_sha1, NULL,
+                      0, QUIET_ON_ERR) < 0)
+               return -1;
+
+       return 0;
+}
+
+char *notes_cache_get(struct notes_cache *c, unsigned char key_sha1[20],
+                     size_t *outsize)
+{
+       const unsigned char *value_sha1;
+       enum object_type type;
+       char *value;
+       unsigned long size;
+
+       value_sha1 = get_note(&c->tree, key_sha1);
+       if (!value_sha1)
+               return NULL;
+       value = read_sha1_file(value_sha1, &type, &size);
+
+       *outsize = size;
+       return value;
+}
+
+int notes_cache_put(struct notes_cache *c, unsigned char key_sha1[20],
+                   const char *data, size_t size)
+{
+       unsigned char value_sha1[20];
+
+       if (write_sha1_file(data, size, "blob", value_sha1) < 0)
+               return -1;
+       add_note(&c->tree, key_sha1, value_sha1, NULL);
+       return 0;
+}
diff --git a/notes-cache.h b/notes-cache.h
new file mode 100644 (file)
index 0000000..356f88f
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef NOTES_CACHE_H
+#define NOTES_CACHE_H
+
+#include "notes.h"
+
+struct notes_cache {
+       struct notes_tree tree;
+       char *validity;
+};
+
+void notes_cache_init(struct notes_cache *c, const char *name,
+                    const char *validity);
+int notes_cache_write(struct notes_cache *c);
+
+char *notes_cache_get(struct notes_cache *c, unsigned char sha1[20], size_t
+                     *outsize);
+int notes_cache_put(struct notes_cache *c, unsigned char sha1[20],
+                   const char *data, size_t size);
+
+#endif /* NOTES_CACHE_H */
diff --git a/notes.c b/notes.c
index 07941b72352167fac9ce1b69f59cf377294a3c33..e425e198278bfb5c6a039dc88825568f1518e875 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -5,6 +5,8 @@
 #include "utf8.h"
 #include "strbuf.h"
 #include "tree-walk.h"
+#include "string-list.h"
+#include "refs.h"
 
 /*
  * Use a non-balancing simple 16-tree structure with struct int_node as
@@ -68,6 +70,9 @@ struct non_note {
 
 struct notes_tree default_notes_tree;
 
+static struct string_list display_notes_refs;
+static struct notes_tree **display_notes_trees;
+
 static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
                struct int_node *node, unsigned int n);
 
@@ -828,6 +833,83 @@ int combine_notes_ignore(unsigned char *cur_sha1,
        return 0;
 }
 
+static int string_list_add_one_ref(const char *path, const unsigned char *sha1,
+                                  int flag, void *cb)
+{
+       struct string_list *refs = cb;
+       if (!unsorted_string_list_has_string(refs, path))
+               string_list_append(path, refs);
+       return 0;
+}
+
+void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
+{
+       if (has_glob_specials(glob)) {
+               for_each_glob_ref(string_list_add_one_ref, glob, list);
+       } else {
+               unsigned char sha1[20];
+               if (get_sha1(glob, sha1))
+                       warning("notes ref %s is invalid", glob);
+               if (!unsorted_string_list_has_string(list, glob))
+                       string_list_append(glob, list);
+       }
+}
+
+void string_list_add_refs_from_colon_sep(struct string_list *list,
+                                        const char *globs)
+{
+       struct strbuf globbuf = STRBUF_INIT;
+       struct strbuf **split;
+       int i;
+
+       strbuf_addstr(&globbuf, globs);
+       split = strbuf_split(&globbuf, ':');
+
+       for (i = 0; split[i]; i++) {
+               if (!split[i]->len)
+                       continue;
+               if (split[i]->buf[split[i]->len-1] == ':')
+                       strbuf_setlen(split[i], split[i]->len-1);
+               string_list_add_refs_by_glob(list, split[i]->buf);
+       }
+
+       strbuf_list_free(split);
+       strbuf_release(&globbuf);
+}
+
+static int string_list_add_refs_from_list(struct string_list_item *item,
+                                         void *cb)
+{
+       struct string_list *list = cb;
+       string_list_add_refs_by_glob(list, item->string);
+       return 0;
+}
+
+static int notes_display_config(const char *k, const char *v, void *cb)
+{
+       int *load_refs = cb;
+
+       if (*load_refs && !strcmp(k, "notes.displayref")) {
+               if (!v)
+                       config_error_nonbool(k);
+               string_list_add_refs_by_glob(&display_notes_refs, v);
+       }
+
+       return 0;
+}
+
+static const char *default_notes_ref(void)
+{
+       const char *notes_ref = NULL;
+       if (!notes_ref)
+               notes_ref = getenv(GIT_NOTES_REF_ENVIRONMENT);
+       if (!notes_ref)
+               notes_ref = notes_ref_name; /* value of core.notesRef config */
+       if (!notes_ref)
+               notes_ref = GIT_NOTES_DEFAULT_REF;
+       return notes_ref;
+}
+
 void init_notes(struct notes_tree *t, const char *notes_ref,
                combine_notes_fn combine_notes, int flags)
 {
@@ -840,11 +922,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
        assert(!t->initialized);
 
        if (!notes_ref)
-               notes_ref = getenv(GIT_NOTES_REF_ENVIRONMENT);
-       if (!notes_ref)
-               notes_ref = notes_ref_name; /* value of core.notesRef config */
-       if (!notes_ref)
-               notes_ref = GIT_NOTES_DEFAULT_REF;
+               notes_ref = default_notes_ref();
 
        if (!combine_notes)
                combine_notes = combine_notes_concatenate;
@@ -855,6 +933,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
        t->ref = notes_ref ? xstrdup(notes_ref) : NULL;
        t->combine_notes = combine_notes;
        t->initialized = 1;
+       t->dirty = 0;
 
        if (flags & NOTES_INIT_EMPTY || !notes_ref ||
            read_ref(notes_ref, object_sha1))
@@ -868,6 +947,63 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
        load_subtree(t, &root_tree, t->root, 0);
 }
 
+struct load_notes_cb_data {
+       int counter;
+       struct notes_tree **trees;
+};
+
+static int load_one_display_note_ref(struct string_list_item *item,
+                                    void *cb_data)
+{
+       struct load_notes_cb_data *c = cb_data;
+       struct notes_tree *t = xcalloc(1, sizeof(struct notes_tree));
+       init_notes(t, item->string, combine_notes_ignore, 0);
+       c->trees[c->counter++] = t;
+       return 0;
+}
+
+struct notes_tree **load_notes_trees(struct string_list *refs)
+{
+       struct notes_tree **trees;
+       struct load_notes_cb_data cb_data;
+       trees = xmalloc((refs->nr+1) * sizeof(struct notes_tree *));
+       cb_data.counter = 0;
+       cb_data.trees = trees;
+       for_each_string_list(load_one_display_note_ref, refs, &cb_data);
+       trees[cb_data.counter] = NULL;
+       return trees;
+}
+
+void init_display_notes(struct display_notes_opt *opt)
+{
+       char *display_ref_env;
+       int load_config_refs = 0;
+       display_notes_refs.strdup_strings = 1;
+
+       assert(!display_notes_trees);
+
+       if (!opt || !opt->suppress_default_notes) {
+               string_list_append(default_notes_ref(), &display_notes_refs);
+               display_ref_env = getenv(GIT_NOTES_DISPLAY_REF_ENVIRONMENT);
+               if (display_ref_env) {
+                       string_list_add_refs_from_colon_sep(&display_notes_refs,
+                                                           display_ref_env);
+                       load_config_refs = 0;
+               } else
+                       load_config_refs = 1;
+       }
+
+       git_config(notes_display_config, &load_config_refs);
+
+       if (opt && opt->extra_notes_refs)
+               for_each_string_list(string_list_add_refs_from_list,
+                                    opt->extra_notes_refs,
+                                    &display_notes_refs);
+
+       display_notes_trees = load_notes_trees(&display_notes_refs);
+       string_list_clear(&display_notes_refs, 0);
+}
+
 void add_note(struct notes_tree *t, const unsigned char *object_sha1,
                const unsigned char *note_sha1, combine_notes_fn combine_notes)
 {
@@ -876,6 +1012,7 @@ void add_note(struct notes_tree *t, const unsigned char *object_sha1,
        if (!t)
                t = &default_notes_tree;
        assert(t->initialized);
+       t->dirty = 1;
        if (!combine_notes)
                combine_notes = t->combine_notes;
        l = (struct leaf_node *) xmalloc(sizeof(struct leaf_node));
@@ -891,6 +1028,7 @@ void remove_note(struct notes_tree *t, const unsigned char *object_sha1)
        if (!t)
                t = &default_notes_tree;
        assert(t->initialized);
+       t->dirty = 1;
        hashcpy(l.key_sha1, object_sha1);
        hashclr(l.val_sha1);
        note_tree_remove(t, t->root, 0, &l);
@@ -1016,8 +1154,18 @@ void format_note(struct notes_tree *t, const unsigned char *object_sha1,
        if (msglen && msg[msglen - 1] == '\n')
                msglen--;
 
-       if (flags & NOTES_SHOW_HEADER)
-               strbuf_addstr(sb, "\nNotes:\n");
+       if (flags & NOTES_SHOW_HEADER) {
+               const char *ref = t->ref;
+               if (!ref || !strcmp(ref, GIT_NOTES_DEFAULT_REF)) {
+                       strbuf_addstr(sb, "\nNotes:\n");
+               } else {
+                       if (!prefixcmp(ref, "refs/"))
+                               ref += 5;
+                       if (!prefixcmp(ref, "notes/"))
+                               ref += 6;
+                       strbuf_addf(sb, "\nNotes (%s):\n", ref);
+               }
+       }
 
        for (msg_p = msg; msg_p < msg + msglen; msg_p += linelen + 1) {
                linelen = strchrnul(msg_p, '\n') - msg_p;
@@ -1030,3 +1178,31 @@ void format_note(struct notes_tree *t, const unsigned char *object_sha1,
 
        free(msg);
 }
+
+void format_display_notes(const unsigned char *object_sha1,
+                         struct strbuf *sb, const char *output_encoding, int flags)
+{
+       int i;
+       assert(display_notes_trees);
+       for (i = 0; display_notes_trees[i]; i++)
+               format_note(display_notes_trees[i], object_sha1, sb,
+                           output_encoding, flags);
+}
+
+int copy_note(struct notes_tree *t,
+             const unsigned char *from_obj, const unsigned char *to_obj,
+             int force, combine_notes_fn combine_fn)
+{
+       const unsigned char *note = get_note(t, from_obj);
+       const unsigned char *existing_note = get_note(t, to_obj);
+
+       if (!force && existing_note)
+               return 1;
+
+       if (note)
+               add_note(t, to_obj, note, combine_fn);
+       else if (existing_note)
+               add_note(t, to_obj, null_sha1, combine_fn);
+
+       return 0;
+}
diff --git a/notes.h b/notes.h
index bad03ccab776d837751803623394667bfd1c7d11..9f59277c516f7ac78bcc66f91a7d7013b2a77f65 100644 (file)
--- a/notes.h
+++ b/notes.h
@@ -40,6 +40,7 @@ extern struct notes_tree {
        char *ref;
        combine_notes_fn *combine_notes;
        int initialized;
+       int dirty;
 } default_notes_tree;
 
 /*
@@ -99,6 +100,15 @@ void remove_note(struct notes_tree *t, const unsigned char *object_sha1);
 const unsigned char *get_note(struct notes_tree *t,
                const unsigned char *object_sha1);
 
+/*
+ * Copy a note from one object to another in the given notes_tree.
+ *
+ * Fails if the to_obj already has a note unless 'force' is true.
+ */
+int copy_note(struct notes_tree *t,
+             const unsigned char *from_obj, const unsigned char *to_obj,
+             int force, combine_notes_fn combine_fn);
+
 /*
  * Flags controlling behaviour of for_each_note()
  *
@@ -198,4 +208,59 @@ void free_notes(struct notes_tree *t);
 void format_note(struct notes_tree *t, const unsigned char *object_sha1,
                struct strbuf *sb, const char *output_encoding, int flags);
 
+
+struct string_list;
+
+struct display_notes_opt {
+       unsigned int suppress_default_notes:1;
+       struct string_list *extra_notes_refs;
+};
+
+/*
+ * Load the notes machinery for displaying several notes trees.
+ *
+ * If 'opt' is not NULL, then it specifies additional settings for the
+ * displaying:
+ *
+ * - suppress_default_notes indicates that the notes from
+ *   core.notesRef and notes.displayRef should not be loaded.
+ *
+ * - extra_notes_refs may contain a list of globs (in the same style
+ *   as notes.displayRef) where notes should be loaded from.
+ */
+void init_display_notes(struct display_notes_opt *opt);
+
+/*
+ * Append notes for the given 'object_sha1' from all trees set up by
+ * init_display_notes() to 'sb'.  The 'flags' are a bitwise
+ * combination of
+ *
+ * - NOTES_SHOW_HEADER: add a 'Notes (refname):' header
+ *
+ * - NOTES_INDENT: indent the notes by 4 places
+ *
+ * You *must* call init_display_notes() before using this function.
+ */
+void format_display_notes(const unsigned char *object_sha1,
+                         struct strbuf *sb, const char *output_encoding, int flags);
+
+/*
+ * Load the notes tree from each ref listed in 'refs'.  The output is
+ * an array of notes_tree*, terminated by a NULL.
+ */
+struct notes_tree **load_notes_trees(struct string_list *refs);
+
+/*
+ * Add all refs that match 'glob' to the 'list'.
+ */
+void string_list_add_refs_by_glob(struct string_list *list, const char *glob);
+
+/*
+ * Add all refs from a colon-separated glob list 'globs' to the end of
+ * 'list'.  Empty components are ignored.  This helper is used to
+ * parse GIT_NOTES_DISPLAY_REF style environment variables.
+ */
+void string_list_add_refs_from_colon_sep(struct string_list *list,
+                                        const char *globs);
+
 #endif
index c83035d013d3f50e9367f2b07d49cf17a1e22ff6..8546d8526f311e2a2703c258a4da3f02f8650df4 100644 (file)
@@ -659,3 +659,18 @@ int parse_opt_tertiary(const struct option *opt, const char *arg, int unset)
        *target = unset ? 2 : 1;
        return 0;
 }
+
+int parse_options_concat(struct option *dst, size_t dst_size, struct option *src)
+{
+       int i, j;
+
+       for (i = 0; i < dst_size; i++)
+               if (dst[i].type == OPTION_END)
+                       break;
+       for (j = 0; i < dst_size; i++, j++) {
+               dst[i] = src[j];
+               if (src[j].type == OPTION_END)
+                       return 0;
+       }
+       return -1;
+}
index 9429f7e36112b7b9cf52d4b3b68b007938396322..7581e931da13151473739036a89d9d19303eb18b 100644 (file)
@@ -187,6 +187,7 @@ extern int parse_options_step(struct parse_opt_ctx_t *ctx,
 
 extern int parse_options_end(struct parse_opt_ctx_t *ctx);
 
+extern int parse_options_concat(struct option *dst, size_t, struct option *src);
 
 /*----- some often used options -----*/
 extern int parse_opt_abbrev_cb(const struct option *, const char *, int);
index f999485a54acdb63c699ee1fce00f80433889e81..7cb3a2af508bb5667cd74304f72b50766c749990 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -775,10 +775,13 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
                }
                return 0;       /* unknown %g placeholder */
        case 'N':
-               format_note(NULL, commit->object.sha1, sb,
-                           git_log_output_encoding ? git_log_output_encoding
-                                                   : git_commit_encoding, 0);
-               return 1;
+               if (c->pretty_ctx->show_notes) {
+                       format_display_notes(commit->object.sha1, sb,
+                                   git_log_output_encoding ? git_log_output_encoding
+                                                           : git_commit_encoding, 0);
+                       return 1;
+               }
+               return 0;
        }
 
        /* For the rest we have to parse the commit header. */
@@ -855,6 +858,35 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
        return consumed + 1;
 }
 
+static size_t userformat_want_item(struct strbuf *sb, const char *placeholder,
+                                  void *context)
+{
+       struct userformat_want *w = context;
+
+       if (*placeholder == '+' || *placeholder == '-')
+               placeholder++;
+
+       switch (*placeholder) {
+       case 'N':
+               w->notes = 1;
+               break;
+       }
+       return 0;
+}
+
+void userformat_find_requirements(const char *fmt, struct userformat_want *w)
+{
+       struct strbuf dummy = STRBUF_INIT;
+
+       if (!fmt) {
+               if (!user_format)
+                       return;
+               fmt = user_format;
+       }
+       strbuf_expand(&dummy, user_format, userformat_want_item, w);
+       strbuf_release(&dummy);
+}
+
 void format_commit_message(const struct commit *commit,
                           const char *format, struct strbuf *sb,
                           const struct pretty_print_context *pretty_ctx)
@@ -1096,8 +1128,8 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
                strbuf_addch(sb, '\n');
 
        if (context->show_notes)
-               format_note(NULL, commit->object.sha1, sb, encoding,
-                           NOTES_SHOW_HEADER | NOTES_INDENT);
+               format_display_notes(commit->object.sha1, sb, encoding,
+                                    NOTES_SHOW_HEADER | NOTES_INDENT);
 
        free(reencoded);
 }
diff --git a/refs.c b/refs.c
index 63e30d74a7eacee53682b20068e8e24a37840ccc..d3db15a76cc46f6f6a31d4448816c09e6c48e543 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -6,6 +6,7 @@
 
 /* ISSYMREF=01 and ISPACKED=02 are public interfaces */
 #define REF_KNOWS_PEELED 04
+#define REF_BROKEN 010
 
 struct ref_list {
        struct ref_list *next;
@@ -275,8 +276,10 @@ static struct ref_list *get_ref_dir(const char *base, struct ref_list *list)
                                list = get_ref_dir(ref, list);
                                continue;
                        }
-                       if (!resolve_ref(ref, sha1, 1, &flag))
+                       if (!resolve_ref(ref, sha1, 1, &flag)) {
                                hashclr(sha1);
+                               flag |= REF_BROKEN;
+                       }
                        list = add_ref(ref, sha1, flag, list, NULL);
                }
                free(ref);
@@ -539,10 +542,10 @@ static int do_one_ref(const char *base, each_ref_fn fn, int trim,
 {
        if (strncmp(base, entry->name, trim))
                return 0;
-       /* Is this a "negative ref" that represents a deleted ref? */
-       if (is_null_sha1(entry->sha1))
-               return 0;
+
        if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {
+               if (entry->flag & REF_BROKEN)
+                       return 0; /* ignore dangling symref */
                if (!has_sha1_file(entry->sha1)) {
                        error("%s does not point to a valid object!", entry->name);
                        return 0;
@@ -695,7 +698,6 @@ int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
 {
        struct strbuf real_pattern = STRBUF_INIT;
        struct ref_filter filter;
-       const char *has_glob_specials;
        int ret;
 
        if (!prefix && prefixcmp(pattern, "refs/"))
@@ -704,8 +706,7 @@ int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
                strbuf_addstr(&real_pattern, prefix);
        strbuf_addstr(&real_pattern, pattern);
 
-       has_glob_specials = strpbrk(pattern, "?*[");
-       if (!has_glob_specials) {
+       if (!has_glob_specials(pattern)) {
                /* Append implied '/' '*' if not present. */
                if (real_pattern.buf[real_pattern.len - 1] != '/')
                        strbuf_addch(&real_pattern, '/');
@@ -1275,6 +1276,7 @@ static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
        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)
                        return error("unable to create directory for %s",
diff --git a/refs.h b/refs.h
index f7648b9bd3b719936024678246d0603028e72aa7..4a18b083f52a15e5216d583644e590d666cae097 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -28,6 +28,11 @@ extern int for_each_replace_ref(each_ref_fn, void *);
 extern int for_each_glob_ref(each_ref_fn, const char *pattern, void *);
 extern int for_each_glob_ref_in(each_ref_fn, const char *pattern, const char* prefix, void *);
 
+static inline const char *has_glob_specials(const char *pattern)
+{
+       return strpbrk(pattern, "?*[");
+}
+
 /* can be used to learn about broken ref and symref */
 extern int for_each_rawref(each_ref_fn, void *);
 
index b76bfcb3d3cdbbee2e3279a6696c7d6b526176d7..07827562b56e38be543201f80e77ea581f9428f3 100644 (file)
@@ -132,6 +132,8 @@ static struct discovery* discover_refs(const char *service)
        case HTTP_MISSING_TARGET:
                die("%s not found: did you run git update-server-info on the"
                    " server?", refs_url);
+       case HTTP_NOAUTH:
+               die("Authentication failed");
        default:
                http_error(refs_url, http_ret);
                die("HTTP request failed");
index 490b484084e875e9b6c5aea1168437bba4bb500a..f4b8b383153b2330be1729fa29488bab1848e019 100644 (file)
@@ -12,6 +12,7 @@
 #include "patch-ids.h"
 #include "decorate.h"
 #include "log-tree.h"
+#include "string-list.h"
 
 volatile show_early_output_fn_t show_early_output;
 
@@ -1191,9 +1192,29 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
        } else if (!strcmp(arg, "--show-notes")) {
                revs->show_notes = 1;
                revs->show_notes_given = 1;
+       } else if (!prefixcmp(arg, "--show-notes=")) {
+               struct strbuf buf = STRBUF_INIT;
+               revs->show_notes = 1;
+               revs->show_notes_given = 1;
+               if (!revs->notes_opt.extra_notes_refs)
+                       revs->notes_opt.extra_notes_refs = xcalloc(1, sizeof(struct string_list));
+               if (!prefixcmp(arg+13, "refs/"))
+                       /* happy */;
+               else if (!prefixcmp(arg+13, "notes/"))
+                       strbuf_addstr(&buf, "refs/");
+               else
+                       strbuf_addstr(&buf, "refs/notes/");
+               strbuf_addstr(&buf, arg+13);
+               string_list_append(strbuf_detach(&buf, NULL),
+                                  revs->notes_opt.extra_notes_refs);
        } else if (!strcmp(arg, "--no-notes")) {
                revs->show_notes = 0;
                revs->show_notes_given = 1;
+       } else if (!strcmp(arg, "--standard-notes")) {
+               revs->show_notes_given = 1;
+               revs->notes_opt.suppress_default_notes = 0;
+       } else if (!strcmp(arg, "--no-standard-notes")) {
+               revs->notes_opt.suppress_default_notes = 1;
        } else if (!strcmp(arg, "--oneline")) {
                revs->verbose_header = 1;
                get_commit_format("oneline", revs);
@@ -1332,7 +1353,7 @@ static void append_prune_data(const char ***prune_data, const char **av)
  * Returns the number of arguments left that weren't recognized
  * (which are also moved to the head of the argument list)
  */
-int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def)
+int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt)
 {
        int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0;
        const char **prune_data = NULL;
@@ -1468,7 +1489,9 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                revs->prune_data = get_pathspec(revs->prefix, prune_data);
 
        if (revs->def == NULL)
-               revs->def = def;
+               revs->def = opt ? opt->def : NULL;
+       if (opt && opt->tweak)
+               opt->tweak(revs, opt);
        if (revs->show_merge)
                prepare_show_merge(revs);
        if (revs->def && !revs->pending.nr && !got_rev_arg) {
@@ -1502,11 +1525,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                if (!revs->full_diff)
                        diff_tree_setup_paths(revs->prune_data, &revs->diffopt);
        }
-       if (revs->combine_merges) {
+       if (revs->combine_merges)
                revs->ignore_merges = 0;
-               if (revs->dense_combined_merges && !revs->diffopt.output_format)
-                       revs->diffopt.output_format = DIFF_FORMAT_PATCH;
-       }
        revs->diffopt.abbrev = revs->abbrev;
        if (diff_setup_done(&revs->diffopt) < 0)
                die("diff_setup_done failed");
index a14deefc252bd641fba5e16f7859b4a985a72578..568f1c98de844dbadcebf1d583bffc24e6daa677 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "parse-options.h"
 #include "grep.h"
+#include "notes.h"
 
 #define SEEN           (1u<<0)
 #define UNINTERESTING   (1u<<1)
@@ -20,6 +21,7 @@
 
 struct rev_info;
 struct log_info;
+struct string_list;
 
 struct rev_info {
        /* Starting list */
@@ -126,6 +128,9 @@ struct rev_info {
        struct reflog_walk_info *reflog_info;
        struct decoration children;
        struct decoration merge_simplification;
+
+       /* notes-specific options: which refs to show */
+       struct display_notes_opt notes_opt;
 };
 
 #define REV_TREE_SAME          0
@@ -137,8 +142,13 @@ struct rev_info {
 typedef void (*show_early_output_fn_t)(struct rev_info *, struct commit_list *);
 extern volatile show_early_output_fn_t show_early_output;
 
+struct setup_revision_opt {
+       const char *def;
+       void (*tweak)(struct rev_info *, struct setup_revision_opt *);
+};
+
 extern void init_revisions(struct rev_info *revs, const char *prefix);
-extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def);
+extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *);
 extern void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
                                 const struct option *options,
                                 const char * const usagestr[]);
index c8d53795ec3ae9b8b0a73b3d6900c1a1f212d2c2..eb5c57562909c1e505c2a7688bad6dbeea4b96a0 100644 (file)
@@ -342,8 +342,6 @@ fail_pipe:
        else if (cmd->out > 1)
                fhout = dup(cmd->out);
 
-       if (cmd->dir)
-               die("chdir in start_command() not implemented");
        if (cmd->env)
                env = make_augmented_environ(cmd->env);
 
@@ -353,7 +351,7 @@ fail_pipe:
                cmd->argv = prepare_shell_cmd(cmd->argv);
        }
 
-       cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env,
+       cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env, cmd->dir,
                                  fhin, fhout, fherr);
        failed_errno = errno;
        if (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))
index a08a9d08808bdb2f4a138d7e6f602b61fc093c1b..28c056e074d1a89e4a3d266eff49c899bfd35e59 100644 (file)
@@ -2271,7 +2271,7 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
 }
 
 static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
-                             void *buf, unsigned long len, time_t mtime)
+                             const void *buf, unsigned long len, time_t mtime)
 {
        int fd, ret;
        unsigned char compressed[4096];
@@ -2307,7 +2307,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
        git_SHA1_Update(&c, hdr, hdrlen);
 
        /* Then the data itself.. */
-       stream.next_in = buf;
+       stream.next_in = (void *)buf;
        stream.avail_in = len;
        do {
                unsigned char *in0 = stream.next_in;
@@ -2342,7 +2342,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
        return move_temp_to_file(tmpfile, filename);
 }
 
-int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *returnsha1)
+int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *returnsha1)
 {
        unsigned char sha1[20];
        char hdr[32];
@@ -2516,3 +2516,13 @@ int read_pack_header(int fd, struct pack_header *header)
                return PH_ERROR_PROTOCOL;
        return 0;
 }
+
+void assert_sha1_type(const unsigned char *sha1, enum object_type expect)
+{
+       enum object_type type = sha1_object_info(sha1, NULL);
+       if (type < 0)
+               die("%s is not a valid object", sha1_to_hex(sha1));
+       if (type != expect)
+               die("%s is not a valid '%s' object", sha1_to_hex(sha1),
+                   typename(expect));
+}
index 1ac536e638dbbc02deb2d4e4a607cc52f7f7c108..c9ad7fcd49669b0dff481d9ab857bf70d8a51bca 100644 (file)
@@ -168,12 +168,19 @@ void sort_string_list(struct string_list *list)
        qsort(list->items, list->nr, sizeof(*list->items), cmp_items);
 }
 
-int unsorted_string_list_has_string(struct string_list *list, const char *string)
+struct string_list_item *unsorted_string_list_lookup(struct string_list *list,
+                                                    const char *string)
 {
        int i;
        for (i = 0; i < list->nr; i++)
                if (!strcmp(string, list->items[i].string))
-                       return 1;
-       return 0;
+                       return list->items + i;
+       return NULL;
+}
+
+int unsorted_string_list_has_string(struct string_list *list,
+                                   const char *string)
+{
+       return unsorted_string_list_lookup(list, string) != NULL;
 }
 
index 6569cf607b18b84f39ebee613471f270e42cfbdc..63b69c8d75ee33120a65a23598ddf93e84831bdd 100644 (file)
@@ -38,5 +38,6 @@ struct string_list_item *string_list_lookup(const char *string, struct string_li
 struct string_list_item *string_list_append(const char *string, struct string_list *list);
 void sort_string_list(struct string_list *list);
 int unsorted_string_list_has_string(struct string_list *list, const char *string);
-
+struct string_list_item *unsorted_string_list_lookup(struct string_list *list,
+                                                    const char *string);
 #endif /* STRING_LIST_H */
index 5d286e409ee2a9b12d6b64cb05394eca18fe3e97..676d48fb33119f393befcaf8998ad38741366525 100644 (file)
@@ -5,14 +5,22 @@
 #include "commit.h"
 #include "revision.h"
 #include "run-command.h"
+#include "diffcore.h"
 
 static int add_submodule_odb(const char *path)
 {
        struct strbuf objects_directory = STRBUF_INIT;
        struct alternate_object_database *alt_odb;
        int ret = 0;
+       const char *git_dir;
 
-       strbuf_addf(&objects_directory, "%s/.git/objects/", path);
+       strbuf_addf(&objects_directory, "%s/.git", path);
+       git_dir = read_gitfile_gently(objects_directory.buf);
+       if (git_dir) {
+               strbuf_reset(&objects_directory);
+               strbuf_addstr(&objects_directory, git_dir);
+       }
+       strbuf_addstr(&objects_directory, "/objects/");
        if (!is_directory(objects_directory.buf)) {
                ret = -1;
                goto done;
@@ -85,13 +93,21 @@ void show_submodule_summary(FILE *f, const char *path,
                        message = "(revision walker failed)";
        }
 
+       if (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
+               fprintf(f, "Submodule %s contains untracked content\n", path);
+       if (dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
+               fprintf(f, "Submodule %s contains modified content\n", path);
+
+       if (!hashcmp(one, two)) {
+               strbuf_release(&sb);
+               return;
+       }
+
        strbuf_addf(&sb, "Submodule %s %s..", path,
                        find_unique_abbrev(one, DEFAULT_ABBREV));
        if (!fast_backward && !fast_forward)
                strbuf_addch(&sb, '.');
        strbuf_addf(&sb, "%s", find_unique_abbrev(two, DEFAULT_ABBREV));
-       if (dirty_submodule)
-               strbuf_add(&sb, "-dirty", 6);
        if (message)
                strbuf_addf(&sb, " %s\n", message);
        else
@@ -121,23 +137,26 @@ void show_submodule_summary(FILE *f, const char *path,
        strbuf_release(&sb);
 }
 
-int is_submodule_modified(const char *path)
+unsigned is_submodule_modified(const char *path, int ignore_untracked)
 {
-       int len, i;
+       ssize_t len;
        struct child_process cp;
        const char *argv[] = {
                "status",
                "--porcelain",
                NULL,
+               NULL,
        };
-       const char *env[LOCAL_REPO_ENV_SIZE + 3];
        struct strbuf buf = STRBUF_INIT;
-
-       for (i = 0; i < LOCAL_REPO_ENV_SIZE; i++)
-               env[i] = local_repo_env[i];
-
-       strbuf_addf(&buf, "%s/.git/", path);
-       if (!is_directory(buf.buf)) {
+       unsigned dirty_submodule = 0;
+       const char *line, *next_line;
+       const char *git_dir;
+
+       strbuf_addf(&buf, "%s/.git", path);
+       git_dir = read_gitfile_gently(buf.buf);
+       if (!git_dir)
+               git_dir = buf.buf;
+       if (!is_directory(git_dir)) {
                strbuf_release(&buf);
                /* The submodule is not checked out, so it is not modified */
                return 0;
@@ -145,29 +164,44 @@ int is_submodule_modified(const char *path)
        }
        strbuf_reset(&buf);
 
-       strbuf_addf(&buf, "GIT_WORK_TREE=%s", path);
-       env[i++] = strbuf_detach(&buf, NULL);
-       strbuf_addf(&buf, "GIT_DIR=%s/.git", path);
-       env[i++] = strbuf_detach(&buf, NULL);
-       env[i] = NULL;
+       if (ignore_untracked)
+               argv[2] = "-uno";
 
        memset(&cp, 0, sizeof(cp));
        cp.argv = argv;
-       cp.env = env;
+       cp.env = local_repo_env;
        cp.git_cmd = 1;
        cp.no_stdin = 1;
        cp.out = -1;
+       cp.dir = path;
        if (start_command(&cp))
                die("Could not run git status --porcelain");
 
        len = strbuf_read(&buf, cp.out, 1024);
+       line = buf.buf;
+       while (len > 2) {
+               if ((line[0] == '?') && (line[1] == '?')) {
+                       dirty_submodule |= DIRTY_SUBMODULE_UNTRACKED;
+                       if (dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
+                               break;
+               } else {
+                       dirty_submodule |= DIRTY_SUBMODULE_MODIFIED;
+                       if (ignore_untracked ||
+                           (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED))
+                               break;
+               }
+               next_line = strchr(line, '\n');
+               if (!next_line)
+                       break;
+               next_line++;
+               len -= (next_line - line);
+               line = next_line;
+       }
        close(cp.out);
 
        if (finish_command(&cp))
                die("git status --porcelain failed");
 
-       for (i = LOCAL_REPO_ENV_SIZE; env[i]; i++)
-               free((char *)env[i]);
        strbuf_release(&buf);
-       return len != 0;
+       return dirty_submodule;
 }
index 233696555e913d20b6a6c7c21942586c93595541..dbda270873171c41f20c0f07b70773ce67c6a303 100644 (file)
@@ -5,6 +5,6 @@ void show_submodule_summary(FILE *f, const char *path,
                unsigned char one[20], unsigned char two[20],
                unsigned dirty_submodule,
                const char *del, const char *add, const char *reset);
-int is_submodule_modified(const char *path);
+unsigned is_submodule_modified(const char *path, int ignore_untracked);
 
 #endif
index f4ca4fc85c6b52a2ba919528284f2b668e6bd3d2..3ec9cbef2c88f65e5fb254d10cc551c6c4062c88 100755 (executable)
@@ -73,6 +73,27 @@ then
        exit 1
 fi
 
+clean=no
+test_expect_success 'tests clean up after themselves' '
+    test_when_finished clean=yes
+'
+
+cleaner=no
+test_expect_code 1 'tests clean up even after a failure' '
+    test_when_finished cleaner=yes &&
+    (exit 1)
+'
+
+if test $clean$cleaner != yesyes
+then
+       say "bug in test framework: cleanup commands do not work reliably"
+       exit 1
+fi
+
+test_expect_code 2 'failure to clean up causes the test to fail' '
+    test_when_finished "(exit 2)"
+'
+
 ################################################################
 # Basics of the basics
 
index 9956e3ad625eb1d70789538ecdb55e318669bdf9..b946f8768649dd76d8a175877c63d49244e00ffb 100755 (executable)
@@ -58,14 +58,12 @@ test_expect_success 'allow missing object with --missing' '
        test_cmp tree.missing actual
 '
 
-test_expect_failure 'mktree reads ls-tree -r output (1)' '
-       git mktree <all >actual &&
-       test_cmp tree actual
+test_expect_success 'mktree refuses to read ls-tree -r output (1)' '
+       test_must_fail git mktree <all >actual
 '
 
-test_expect_failure 'mktree reads ls-tree -r output (2)' '
-       git mktree <all.withsub >actual &&
-       test_cmp tree.withsub actual
+test_expect_success 'mktree refuses to read ls-tree -r output (2)' '
+       test_must_fail git mktree <all.withsub >actual
 '
 
 test_done
index cc30be4a655cad98eac233b5da9fc585ddb5d055..055ad00f778eda1de02a418bbc602e580acdaca1 100755 (executable)
@@ -20,34 +20,23 @@ if ! setfacl -m u:root:rwx .; then
     test_done
 fi
 
-modebits () {
-       ls -l "$1" | sed -e 's|^\(..........\).*|\1|'
-}
-
 check_perms_and_acl () {
-       actual=$(modebits "$1") &&
-       case "$actual" in
-       -r--r-----*)
-               : happy
-               ;;
-       *)
-               echo "Got permission '$actual', expected '-r--r-----'"
-               false
-               ;;
-       esac &&
+       test -r "$1" &&
        getfacl "$1" > actual &&
        grep -q "user:root:rwx" actual &&
        grep -q "user:${LOGNAME}:rwx" actual &&
-       grep -q "mask::r--" actual &&
+       egrep "mask::?r--" actual > /dev/null 2>&1 &&
        grep -q "group::---" actual || false
 }
 
 dirs_to_set="./ .git/ .git/objects/ .git/objects/pack/"
 
 test_expect_success 'Setup test repo' '
+       setfacl -m d:u::rwx,d:g::---,d:o:---,d:m:rwx $dirs_to_set &&
+       setfacl -m m:rwx               $dirs_to_set &&
        setfacl -m u:root:rwx          $dirs_to_set &&
-       setfacl -d -m u:"$LOGNAME":rwx $dirs_to_set &&
-       setfacl -d -m u:root:rwx       $dirs_to_set &&
+       setfacl -m d:u:"$LOGNAME":rwx  $dirs_to_set &&
+       setfacl -m d:u:root:rwx        $dirs_to_set &&
 
        touch file.txt &&
        git add file.txt &&
index 37b96871c54037399450dd8c982d83e47dda0184..64f32ad94dfe842746774596b88c91e873da864f 100755 (executable)
@@ -55,6 +55,15 @@ test_expect_success 'handle empty notes gracefully' '
        git notes show ; test 1 = $?
 '
 
+test_expect_success 'show non-existent notes entry with %N' '
+       for l in A B
+       do
+               echo "$l"
+       done >expect &&
+       git show -s --format='A%n%NB' >output &&
+       test_cmp expect output
+'
+
 test_expect_success 'create notes' '
        git config core.notesRef refs/notes/commits &&
        MSG=b4 git notes add &&
@@ -65,6 +74,24 @@ test_expect_success 'create notes' '
        test_must_fail git notes show HEAD^
 '
 
+test_expect_success 'show notes entry with %N' '
+       for l in A b4 B
+       do
+               echo "$l"
+       done >expect &&
+       git show -s --format='A%n%NB' >output &&
+       test_cmp expect output
+'
+
+cat >expect <<EOF
+d423f8c refs/notes/commits@{0}: notes: Notes added by 'git notes add'
+EOF
+
+test_expect_success 'create reflog entry' '
+       git reflog show refs/notes/commits >output &&
+       test_cmp expect output
+'
+
 test_expect_success 'edit existing notes' '
        MSG=b3 git notes edit &&
        test ! -f .git/NOTES_EDITMSG &&
@@ -378,6 +405,17 @@ test_expect_success 'append to existing note with "git notes append"' '
        test_cmp expect output
 '
 
+cat > expect_list << EOF
+c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75
+c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5
+4b6ad22357cc8a1296720574b8d2fbc22fab0671 bd1753200303d0a0344be813e504253b3d98e74d
+EOF
+
+test_expect_success '"git notes list" does not expand to "git notes list HEAD"' '
+       git notes list > output &&
+       test_cmp expect_list output
+'
+
 test_expect_success 'appending empty string does not change existing note' '
        git notes append -m "" &&
        git notes show > output &&
@@ -416,7 +454,7 @@ Date:   Thu Apr 7 15:18:13 2005 -0700
 
     6th
 
-Notes:
+Notes (other):
     other note
 EOF
 
@@ -449,7 +487,139 @@ test_expect_success 'Do not show note when core.notesRef is overridden' '
        test_cmp expect-not-other output
 '
 
+cat > expect-both << EOF
+commit 387a89921c73d7ed72cd94d179c1c7048ca47756
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:18:13 2005 -0700
+
+    6th
+
+Notes:
+    order test
+
+Notes (other):
+    other note
+
+commit bd1753200303d0a0344be813e504253b3d98e74d
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:17:13 2005 -0700
+
+    5th
+
+Notes:
+    replacement for deleted note
+EOF
+
+test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' '
+       GIT_NOTES_REF=refs/notes/commits git notes add \
+               -m"replacement for deleted note" HEAD^ &&
+       GIT_NOTES_REF=refs/notes/commits git notes add -m"order test" &&
+       git config --unset core.notesRef &&
+       git config notes.displayRef "refs/notes/*" &&
+       git log -2 > output &&
+       test_cmp expect-both output
+'
+
+test_expect_success 'core.notesRef is implicitly in notes.displayRef' '
+       git config core.notesRef refs/notes/commits &&
+       git config notes.displayRef refs/notes/other &&
+       git log -2 > output &&
+       test_cmp expect-both output
+'
+
+test_expect_success 'notes.displayRef can be given more than once' '
+       git config --unset core.notesRef &&
+       git config notes.displayRef refs/notes/commits &&
+       git config --add notes.displayRef refs/notes/other &&
+       git log -2 > output &&
+       test_cmp expect-both output
+'
+
+cat > expect-both-reversed << EOF
+commit 387a89921c73d7ed72cd94d179c1c7048ca47756
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:18:13 2005 -0700
+
+    6th
+
+Notes (other):
+    other note
+
+Notes:
+    order test
+EOF
+
+test_expect_success 'notes.displayRef respects order' '
+       git config core.notesRef refs/notes/other &&
+       git config --unset-all notes.displayRef &&
+       git config notes.displayRef refs/notes/commits &&
+       git log -1 > output &&
+       test_cmp expect-both-reversed output
+'
+
+test_expect_success 'GIT_NOTES_DISPLAY_REF works' '
+       git config --unset-all core.notesRef &&
+       git config --unset-all notes.displayRef &&
+       GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
+               git log -2 > output &&
+       test_cmp expect-both output
+'
+
+cat > expect-none << EOF
+commit 387a89921c73d7ed72cd94d179c1c7048ca47756
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:18:13 2005 -0700
+
+    6th
+
+commit bd1753200303d0a0344be813e504253b3d98e74d
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:17:13 2005 -0700
+
+    5th
+EOF
+
+test_expect_success 'GIT_NOTES_DISPLAY_REF overrides config' '
+       git config notes.displayRef "refs/notes/*" &&
+       GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 > output &&
+       test_cmp expect-none output
+'
+
+test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '
+       GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 > output &&
+       test_cmp expect-both output
+'
+
+cat > expect-commits << EOF
+commit 387a89921c73d7ed72cd94d179c1c7048ca47756
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:18:13 2005 -0700
+
+    6th
+
+Notes:
+    order test
+EOF
+
+test_expect_success '--no-standard-notes' '
+       git log --no-standard-notes --show-notes=commits -1 > output &&
+       test_cmp expect-commits output
+'
+
+test_expect_success '--standard-notes' '
+       git log --no-standard-notes --show-notes=commits \
+               --standard-notes -2 > output &&
+       test_cmp expect-both output
+'
+
+test_expect_success '--show-notes=ref accumulates' '
+       git log --show-notes=other --show-notes=commits \
+                --no-standard-notes -1 > output &&
+       test_cmp expect-both-reversed output
+'
+
 test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' '
+       git config core.notesRef refs/notes/other &&
        echo "Note on a tree" > expect
        git notes add -m "Note on a tree" HEAD: &&
        git notes show HEAD: > actual &&
@@ -473,7 +643,7 @@ Date:   Thu Apr 7 15:19:13 2005 -0700
 
     7th
 
-Notes:
+Notes (other):
     other note
 EOF
 
@@ -504,7 +674,7 @@ Date:   Thu Apr 7 15:21:13 2005 -0700
 
     9th
 
-Notes:
+Notes (other):
     yet another note
 EOF
 
@@ -534,7 +704,7 @@ Date:   Thu Apr 7 15:21:13 2005 -0700
 
     9th
 
-Notes:
+Notes (other):
     yet another note
 $whitespace
     yet another note
@@ -553,7 +723,7 @@ Date:   Thu Apr 7 15:22:13 2005 -0700
 
     10th
 
-Notes:
+Notes (other):
     other note
 EOF
 
@@ -570,7 +740,7 @@ Date:   Thu Apr 7 15:22:13 2005 -0700
 
     10th
 
-Notes:
+Notes (other):
     other note
 $whitespace
     yet another note
@@ -589,7 +759,7 @@ Date:   Thu Apr 7 15:23:13 2005 -0700
 
     11th
 
-Notes:
+Notes (other):
     other note
 $whitespace
     yet another note
@@ -620,7 +790,7 @@ Date:   Thu Apr 7 15:23:13 2005 -0700
 
     11th
 
-Notes:
+Notes (other):
     yet another note
 $whitespace
     yet another note
@@ -645,4 +815,233 @@ test_expect_success 'cannot copy note from object without notes' '
        test_must_fail git notes copy HEAD^ HEAD
 '
 
+cat > expect << EOF
+commit e5d4fb5698d564ab8c73551538ecaf2b0c666185
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:25:13 2005 -0700
+
+    13th
+
+Notes (other):
+    yet another note
+$whitespace
+    yet another note
+
+commit 7038787dfe22a14c3867ce816dbba39845359719
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:24:13 2005 -0700
+
+    12th
+
+Notes (other):
+    other note
+$whitespace
+    yet another note
+EOF
+
+test_expect_success 'git notes copy --stdin' '
+       (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
+       echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
+       git notes copy --stdin &&
+       git log -2 > output &&
+       test_cmp expect output &&
+       test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" &&
+       test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)"
+'
+
+cat > expect << EOF
+commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:27:13 2005 -0700
+
+    15th
+
+commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:26:13 2005 -0700
+
+    14th
+EOF
+
+test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
+       test_commit 14th &&
+       test_commit 15th &&
+       (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
+       echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
+       git notes copy --for-rewrite=foo &&
+       git log -2 > output &&
+       test_cmp expect output
+'
+
+cat > expect << EOF
+commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:27:13 2005 -0700
+
+    15th
+
+Notes (other):
+    yet another note
+$whitespace
+    yet another note
+
+commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:26:13 2005 -0700
+
+    14th
+
+Notes (other):
+    other note
+$whitespace
+    yet another note
+EOF
+
+test_expect_success 'git notes copy --for-rewrite (enabled)' '
+       git config notes.rewriteMode overwrite &&
+       git config notes.rewriteRef "refs/notes/*" &&
+       (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
+       echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
+       git notes copy --for-rewrite=foo &&
+       git log -2 > output &&
+       test_cmp expect output
+'
+
+test_expect_success 'git notes copy --for-rewrite (disabled)' '
+       git config notes.rewrite.bar false &&
+       echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) |
+       git notes copy --for-rewrite=bar &&
+       git log -2 > output &&
+       test_cmp expect output
+'
+
+cat > expect << EOF
+commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:27:13 2005 -0700
+
+    15th
+
+Notes (other):
+    a fresh note
+EOF
+
+test_expect_success 'git notes copy --for-rewrite (overwrite)' '
+       git notes add -f -m"a fresh note" HEAD^ &&
+       echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
+       git notes copy --for-rewrite=foo &&
+       git log -1 > output &&
+       test_cmp expect output
+'
+
+test_expect_success 'git notes copy --for-rewrite (ignore)' '
+       git config notes.rewriteMode ignore &&
+       echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
+       git notes copy --for-rewrite=foo &&
+       git log -1 > output &&
+       test_cmp expect output
+'
+
+cat > expect << EOF
+commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:27:13 2005 -0700
+
+    15th
+
+Notes (other):
+    a fresh note
+    another fresh note
+EOF
+
+test_expect_success 'git notes copy --for-rewrite (append)' '
+       git notes add -f -m"another fresh note" HEAD^ &&
+       git config notes.rewriteMode concatenate &&
+       echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
+       git notes copy --for-rewrite=foo &&
+       git log -1 > output &&
+       test_cmp expect output
+'
+
+cat > expect << EOF
+commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:27:13 2005 -0700
+
+    15th
+
+Notes (other):
+    a fresh note
+    another fresh note
+    append 1
+    append 2
+EOF
+
+test_expect_success 'git notes copy --for-rewrite (append two to one)' '
+       git notes add -f -m"append 1" HEAD^ &&
+       git notes add -f -m"append 2" HEAD^^ &&
+       (echo $(git rev-parse HEAD^) $(git rev-parse HEAD);
+       echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) |
+       git notes copy --for-rewrite=foo &&
+       git log -1 > output &&
+       test_cmp expect output
+'
+
+test_expect_success 'git notes copy --for-rewrite (append empty)' '
+       git notes remove HEAD^ &&
+       echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
+       git notes copy --for-rewrite=foo &&
+       git log -1 > output &&
+       test_cmp expect output
+'
+
+cat > expect << EOF
+commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:27:13 2005 -0700
+
+    15th
+
+Notes (other):
+    replacement note 1
+EOF
+
+test_expect_success 'GIT_NOTES_REWRITE_MODE works' '
+       git notes add -f -m"replacement note 1" HEAD^ &&
+       echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
+       GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo &&
+       git log -1 > output &&
+       test_cmp expect output
+'
+
+cat > expect << EOF
+commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:27:13 2005 -0700
+
+    15th
+
+Notes (other):
+    replacement note 2
+EOF
+
+test_expect_success 'GIT_NOTES_REWRITE_REF works' '
+       git config notes.rewriteMode overwrite &&
+       git notes add -f -m"replacement note 2" HEAD^ &&
+       git config --unset-all notes.rewriteRef &&
+       echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
+       GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \
+               git notes copy --for-rewrite=foo &&
+       git log -1 > output &&
+       test_cmp expect output
+'
+
+test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
+       git config notes.rewriteRef refs/notes/other &&
+       git notes add -f -m"replacement note 3" HEAD^ &&
+       echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
+       GIT_NOTES_REWRITE_REF= git notes copy --for-rewrite=foo &&
+       git log -1 > output &&
+       test_cmp expect output
+'
 test_done
index 4314ad2d66d06b411e4bc0c9ee7b07553fc35ac2..dbf7dfba9b55e906d44a35d7b11ca2ceaad7e6f5 100755 (executable)
@@ -151,4 +151,21 @@ test_expect_success 'Rebase a commit that sprinkles CRs in' '
        git diff --exit-code file-with-cr:CR HEAD:CR
 '
 
+test_expect_success 'rebase can copy notes' '
+       git config notes.rewrite.rebase true &&
+       git config notes.rewriteRef "refs/notes/*" &&
+       test_commit n1 &&
+       test_commit n2 &&
+       test_commit n3 &&
+       git notes add -m"a note" n3 &&
+       git rebase --onto n1 n2 &&
+       test "a note" = "$(git notes show HEAD)"
+'
+
+test_expect_success 'rebase -m can copy notes' '
+       git reset --hard n3 &&
+       git rebase -m --onto n1 n2 &&
+       test "a note" = "$(git notes show HEAD)"
+'
+
 test_done
index 4e3513709eb121769f87501c1862c996184a6d05..f20ea38411d0ca67709dbde0bfd1108e28c0dd71 100755 (executable)
@@ -22,12 +22,18 @@ set_fake_editor
 # | \
 # |   F - G - H                (branch1)
 # |     \
-#  \      I                    (branch2)
-#   \
-#     J - K - L - M            (no-conflict-branch)
+# |\      I                    (branch2)
+# | \
+# |   J - K - L - M            (no-conflict-branch)
+#  \
+#    N - O - P                 (no-ff-branch)
 #
 # where A, B, D and G all touch file1, and one, two, three, four all
 # touch file "conflict".
+#
+# WARNING: Modifications to the initial repository can change the SHA ID used
+# in the expect2 file for the 'stop on conflicting pick' test.
+
 
 test_expect_success 'setup' '
        test_commit A file1 &&
@@ -48,6 +54,11 @@ test_expect_success 'setup' '
        done &&
        git checkout -b no-conflict-branch A &&
        for n in J K L M
+       do
+               test_commit $n file$n
+       done &&
+       git checkout -b no-ff-branch A &&
+       for n in N O P
        do
                test_commit $n file$n
        done
@@ -113,7 +124,7 @@ cat > expect2 << EOF
 D
 =======
 G
->>>>>>> 51047de... G
+>>>>>>> 5d18e54... G
 EOF
 
 test_expect_success 'stop on conflicting pick' '
@@ -553,4 +564,54 @@ test_expect_success 'reword' '
        git show HEAD~2 | grep "C changed"
 '
 
+test_expect_success 'rebase -i can copy notes' '
+       git config notes.rewrite.rebase true &&
+       git config notes.rewriteRef "refs/notes/*" &&
+       test_commit n1 &&
+       test_commit n2 &&
+       test_commit n3 &&
+       git notes add -m"a note" n3 &&
+       git rebase --onto n1 n2 &&
+       test "a note" = "$(git notes show HEAD)"
+'
+
+cat >expect <<EOF
+an earlier note
+a note
+EOF
+
+test_expect_success 'rebase -i can copy notes over a fixup' '
+       git reset --hard n3 &&
+       git notes add -m"an earlier note" n2 &&
+       GIT_NOTES_REWRITE_MODE=concatenate FAKE_LINES="1 fixup 2" git rebase -i n1 &&
+       git notes show > output &&
+       test_cmp expect output
+'
+
+test_expect_success 'rebase while detaching HEAD' '
+       git symbolic-ref HEAD &&
+       grandparent=$(git rev-parse HEAD~2) &&
+       test_tick &&
+       FAKE_LINES="2 1" git rebase -i HEAD~2 HEAD^0 &&
+       test $grandparent = $(git rev-parse HEAD~2) &&
+       test_must_fail git symbolic-ref HEAD
+'
+
+test_tick # Ensure that the rebased commits get a different timestamp.
+test_expect_success 'always cherry-pick with --no-ff' '
+       git checkout no-ff-branch &&
+       git tag original-no-ff-branch &&
+       git rebase -i --no-ff A &&
+       touch empty &&
+       for p in 0 1 2
+       do
+               test ! $(git rev-parse HEAD~$p) = $(git rev-parse original-no-ff-branch~$p) &&
+               git diff HEAD~$p original-no-ff-branch~$p > out &&
+               test_cmp empty out
+       done &&
+       test $(git rev-parse HEAD~3) = $(git rev-parse original-no-ff-branch~3) &&
+       git diff HEAD~3 original-no-ff-branch~3 > out &&
+       test_cmp empty out
+'
+
 test_done
diff --git a/t/t3506-cherry-pick-ff.sh b/t/t3506-cherry-pick-ff.sh
new file mode 100755 (executable)
index 0000000..e17ae71
--- /dev/null
@@ -0,0 +1,98 @@
+#!/bin/sh
+
+test_description='test cherry-picking with --ff option'
+
+. ./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 &&
+       echo second >> file1 &&
+       git add file1 &&
+       test_tick &&
+       git commit -m "second" &&
+       git tag second
+'
+
+test_expect_success 'cherry-pick using --ff fast forwards' '
+       git checkout master &&
+       git reset --hard first &&
+       test_tick &&
+       git cherry-pick --ff second &&
+       test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify second)"
+'
+
+test_expect_success 'cherry-pick not using --ff does not fast forwards' '
+       git checkout master &&
+       git reset --hard first &&
+       test_tick &&
+       git cherry-pick second &&
+       test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify second)"
+'
+
+#
+# We setup the following graph:
+#
+#            B---C
+#           /   /
+#      first---A
+#
+# (This has been taken from t3502-cherry-pick-merge.sh)
+#
+test_expect_success 'merge setup' '
+       git checkout master &&
+       git reset --hard first &&
+       echo new line >A &&
+       git add A &&
+       test_tick &&
+       git commit -m "add line to A" A &&
+       git tag A &&
+       git checkout -b side first &&
+       echo new line >B &&
+       git add B &&
+       test_tick &&
+       git commit -m "add line to B" B &&
+       git tag B &&
+       git checkout master &&
+       git merge side &&
+       git tag C &&
+       git checkout -b new A
+'
+
+test_expect_success 'cherry-pick a non-merge with --ff and -m should fail' '
+       git reset --hard A -- &&
+       test_must_fail git cherry-pick --ff -m 1 B &&
+       git diff --exit-code A --
+'
+
+test_expect_success 'cherry pick a merge with --ff but without -m should fail' '
+       git reset --hard A -- &&
+       test_must_fail git cherry-pick --ff C &&
+       git diff --exit-code A --
+'
+
+test_expect_success 'cherry pick with --ff a merge (1)' '
+       git reset --hard A -- &&
+       git cherry-pick --ff -m 1 C &&
+       git diff --exit-code C &&
+       test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify C)"
+'
+
+test_expect_success 'cherry pick with --ff a merge (2)' '
+       git reset --hard B -- &&
+       git cherry-pick --ff -m 2 C &&
+       git diff --exit-code C &&
+       test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify C)"
+'
+
+test_expect_success 'cherry pick a merge relative to nonexistent parent with --ff should fail' '
+       git reset --hard B -- &&
+       test_must_fail git cherry-pick --ff -m 3 C
+'
+
+test_done
old mode 100644 (file)
new mode 100755 (executable)
index 8e3694ed5b80a87602d6533f0aa28307bd7b3d1b..dae635851666a7f5ccf685b89d64f31d5dbdd2fd 100755 (executable)
@@ -204,6 +204,9 @@ log --root --patch-with-stat --summary master
 log --root -c --patch-with-stat --summary master
 # improved by Timo's patch
 log --root --cc --patch-with-stat --summary master
+log -p --first-parent master
+log -m -p --first-parent master
+log -m -p master
 log -SF master
 log -SF -p master
 log --decorate --all
@@ -235,6 +238,9 @@ show initial
 show --root initial
 show side
 show master
+show -c master
+show -m master
+show --first-parent master
 show --stat side
 show --stat --summary side
 show --patch-with-stat side
diff --git a/t/t4013/diff.log_-m_-p_--first-parent_master b/t/t4013/diff.log_-m_-p_--first-parent_master
new file mode 100644 (file)
index 0000000..7a0073f
--- /dev/null
@@ -0,0 +1,100 @@
+$ git log -m -p --first-parent master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:04:00 2006 +0000
+
+    Merge branch 'side'
+
+diff --git a/dir/sub b/dir/sub
+index cead32e..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -4,3 +4,5 @@ C
+ D
+ E
+ F
++1
++2
+diff --git a/file0 b/file0
+index b414108..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -4,3 +4,6 @@
+ 4
+ 5
+ 6
++A
++B
++C
+
+commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:02:00 2006 +0000
+
+    Third
+
+diff --git a/dir/sub b/dir/sub
+index 8422d40..cead32e 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -2,3 +2,5 @@ A
+ B
+ C
+ D
++E
++F
+diff --git a/file1 b/file1
+new file mode 100644
+index 0000000..b1e6722
+--- /dev/null
++++ b/file1
+@@ -0,0 +1,3 @@
++A
++B
++C
+
+commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:01:00 2006 +0000
+
+    Second
+    
+    This is the second commit.
+
+diff --git a/dir/sub b/dir/sub
+index 35d242b..8422d40 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,2 +1,4 @@
+ A
+ B
++C
++D
+diff --git a/file0 b/file0
+index 01e79c3..b414108 100644
+--- a/file0
++++ b/file0
+@@ -1,3 +1,6 @@
+ 1
+ 2
+ 3
++4
++5
++6
+diff --git a/file2 b/file2
+deleted file mode 100644
+index 01e79c3..0000000
+--- a/file2
++++ /dev/null
+@@ -1,3 +0,0 @@
+-1
+-2
+-3
+
+commit 444ac553ac7612cc88969031b02b3767fb8a353a
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:00:00 2006 +0000
+
+    Initial
+$
diff --git a/t/t4013/diff.log_-m_-p_master b/t/t4013/diff.log_-m_-p_master
new file mode 100644 (file)
index 0000000..9ca62a0
--- /dev/null
@@ -0,0 +1,200 @@
+$ git log -m -p master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0)
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:04:00 2006 +0000
+
+    Merge branch 'side'
+
+diff --git a/dir/sub b/dir/sub
+index cead32e..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -4,3 +4,5 @@ C
+ D
+ E
+ F
++1
++2
+diff --git a/file0 b/file0
+index b414108..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -4,3 +4,6 @@
+ 4
+ 5
+ 6
++A
++B
++C
+
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a)
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:04:00 2006 +0000
+
+    Merge branch 'side'
+
+diff --git a/dir/sub b/dir/sub
+index 7289e35..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,4 +1,8 @@
+ A
+ B
++C
++D
++E
++F
+ 1
+ 2
+diff --git a/file0 b/file0
+index f4615da..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -1,6 +1,9 @@
+ 1
+ 2
+ 3
++4
++5
++6
+ A
+ B
+ C
+diff --git a/file1 b/file1
+new file mode 100644
+index 0000000..b1e6722
+--- /dev/null
++++ b/file1
+@@ -0,0 +1,3 @@
++A
++B
++C
+diff --git a/file2 b/file2
+deleted file mode 100644
+index 01e79c3..0000000
+--- a/file2
++++ /dev/null
+@@ -1,3 +0,0 @@
+-1
+-2
+-3
+diff --git a/file3 b/file3
+deleted file mode 100644
+index 7289e35..0000000
+--- a/file3
++++ /dev/null
+@@ -1,4 +0,0 @@
+-A
+-B
+-1
+-2
+
+commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:03:00 2006 +0000
+
+    Side
+
+diff --git a/dir/sub b/dir/sub
+index 35d242b..7289e35 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,2 +1,4 @@
+ A
+ B
++1
++2
+diff --git a/file0 b/file0
+index 01e79c3..f4615da 100644
+--- a/file0
++++ b/file0
+@@ -1,3 +1,6 @@
+ 1
+ 2
+ 3
++A
++B
++C
+diff --git a/file3 b/file3
+new file mode 100644
+index 0000000..7289e35
+--- /dev/null
++++ b/file3
+@@ -0,0 +1,4 @@
++A
++B
++1
++2
+
+commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:02:00 2006 +0000
+
+    Third
+
+diff --git a/dir/sub b/dir/sub
+index 8422d40..cead32e 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -2,3 +2,5 @@ A
+ B
+ C
+ D
++E
++F
+diff --git a/file1 b/file1
+new file mode 100644
+index 0000000..b1e6722
+--- /dev/null
++++ b/file1
+@@ -0,0 +1,3 @@
++A
++B
++C
+
+commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:01:00 2006 +0000
+
+    Second
+    
+    This is the second commit.
+
+diff --git a/dir/sub b/dir/sub
+index 35d242b..8422d40 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,2 +1,4 @@
+ A
+ B
++C
++D
+diff --git a/file0 b/file0
+index 01e79c3..b414108 100644
+--- a/file0
++++ b/file0
+@@ -1,3 +1,6 @@
+ 1
+ 2
+ 3
++4
++5
++6
+diff --git a/file2 b/file2
+deleted file mode 100644
+index 01e79c3..0000000
+--- a/file2
++++ /dev/null
+@@ -1,3 +0,0 @@
+-1
+-2
+-3
+
+commit 444ac553ac7612cc88969031b02b3767fb8a353a
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:00:00 2006 +0000
+
+    Initial
+$
diff --git a/t/t4013/diff.log_-p_--first-parent_master b/t/t4013/diff.log_-p_--first-parent_master
new file mode 100644 (file)
index 0000000..3fc896d
--- /dev/null
@@ -0,0 +1,78 @@
+$ git log -p --first-parent master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:04:00 2006 +0000
+
+    Merge branch 'side'
+
+commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:02:00 2006 +0000
+
+    Third
+
+diff --git a/dir/sub b/dir/sub
+index 8422d40..cead32e 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -2,3 +2,5 @@ A
+ B
+ C
+ D
++E
++F
+diff --git a/file1 b/file1
+new file mode 100644
+index 0000000..b1e6722
+--- /dev/null
++++ b/file1
+@@ -0,0 +1,3 @@
++A
++B
++C
+
+commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:01:00 2006 +0000
+
+    Second
+    
+    This is the second commit.
+
+diff --git a/dir/sub b/dir/sub
+index 35d242b..8422d40 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,2 +1,4 @@
+ A
+ B
++C
++D
+diff --git a/file0 b/file0
+index 01e79c3..b414108 100644
+--- a/file0
++++ b/file0
+@@ -1,3 +1,6 @@
+ 1
+ 2
+ 3
++4
++5
++6
+diff --git a/file2 b/file2
+deleted file mode 100644
+index 01e79c3..0000000
+--- a/file2
++++ /dev/null
+@@ -1,3 +0,0 @@
+-1
+-2
+-3
+
+commit 444ac553ac7612cc88969031b02b3767fb8a353a
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:00:00 2006 +0000
+
+    Initial
+$
diff --git a/t/t4013/diff.show_--first-parent_master b/t/t4013/diff.show_--first-parent_master
new file mode 100644 (file)
index 0000000..3dcbe47
--- /dev/null
@@ -0,0 +1,30 @@
+$ git show --first-parent master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:04:00 2006 +0000
+
+    Merge branch 'side'
+
+diff --git a/dir/sub b/dir/sub
+index cead32e..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -4,3 +4,5 @@ C
+ D
+ E
+ F
++1
++2
+diff --git a/file0 b/file0
+index b414108..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -4,3 +4,6 @@
+ 4
+ 5
+ 6
++A
++B
++C
+$
diff --git a/t/t4013/diff.show_-c_master b/t/t4013/diff.show_-c_master
new file mode 100644 (file)
index 0000000..81aba8d
--- /dev/null
@@ -0,0 +1,36 @@
+$ git show -c master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:04:00 2006 +0000
+
+    Merge branch 'side'
+
+diff --combined dir/sub
+index cead32e,7289e35..992913c
+--- a/dir/sub
++++ b/dir/sub
+@@@ -1,6 -1,4 +1,8 @@@
+  A
+  B
+ +C
+ +D
+ +E
+ +F
++ 1
++ 2
+diff --combined file0
+index b414108,f4615da..10a8a9f
+--- a/file0
++++ b/file0
+@@@ -1,6 -1,6 +1,9 @@@
+  1
+  2
+  3
+ +4
+ +5
+ +6
++ A
++ B
++ C
+$
diff --git a/t/t4013/diff.show_-m_master b/t/t4013/diff.show_-m_master
new file mode 100644 (file)
index 0000000..4ea2ee4
--- /dev/null
@@ -0,0 +1,93 @@
+$ git show -m master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0)
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:04:00 2006 +0000
+
+    Merge branch 'side'
+
+diff --git a/dir/sub b/dir/sub
+index cead32e..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -4,3 +4,5 @@ C
+ D
+ E
+ F
++1
++2
+diff --git a/file0 b/file0
+index b414108..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -4,3 +4,6 @@
+ 4
+ 5
+ 6
++A
++B
++C
+
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a)
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date:   Mon Jun 26 00:04:00 2006 +0000
+
+    Merge branch 'side'
+
+diff --git a/dir/sub b/dir/sub
+index 7289e35..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,4 +1,8 @@
+ A
+ B
++C
++D
++E
++F
+ 1
+ 2
+diff --git a/file0 b/file0
+index f4615da..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -1,6 +1,9 @@
+ 1
+ 2
+ 3
++4
++5
++6
+ A
+ B
+ C
+diff --git a/file1 b/file1
+new file mode 100644
+index 0000000..b1e6722
+--- /dev/null
++++ b/file1
+@@ -0,0 +1,3 @@
++A
++B
++C
+diff --git a/file2 b/file2
+deleted file mode 100644
+index 01e79c3..0000000
+--- a/file2
++++ /dev/null
+@@ -1,3 +0,0 @@
+-1
+-2
+-3
+diff --git a/file3 b/file3
+deleted file mode 100644
+index 7289e35..0000000
+--- a/file3
++++ /dev/null
+@@ -1,4 +0,0 @@
+-A
+-B
+-1
+-2
+$
index c7b625642dd57f4bcb6f7c5aa240cc9c32e15af8..d21c37f3a20c42b05044e45c5e5af71294c8420c 100755 (executable)
@@ -609,4 +609,8 @@ test_expect_success 'format-patch -- <path>' '
        ! grep "Use .--" error
 '
 
+test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
+       git format-patch --ignore-if-in-upstream HEAD
+'
+
 test_done
index 0391a5827ea8ba196b7796b7df818f8ac860c387..61589853df55e063fbe6489fc9c6effc4a9f33b6 100755 (executable)
@@ -120,7 +120,6 @@ test_expect_success '--check with --no-pager returns 2 for dirty difference' '
 
 '
 
-
 test_expect_success 'check should test not just the last line' '
        echo "" >>a &&
        git --no-pager diff --check
@@ -142,4 +141,26 @@ test_expect_success 'check detects leftover conflict markers' '
        git reset --hard
 '
 
+test_expect_success 'check honors conflict marker length' '
+       git reset --hard &&
+       echo ">>>>>>> boo" >>b &&
+       echo "======" >>a &&
+       git diff --check a &&
+       (
+               git diff --check b
+               test $? = 2
+       ) &&
+       git reset --hard &&
+       echo ">>>>>>>> boo" >>b &&
+       echo "========" >>a &&
+       git diff --check &&
+       echo "b conflict-marker-size=8" >.gitattributes &&
+       (
+               git diff --check b
+               test $? = 2
+       ) &&
+       git diff --check a &&
+       git reset --hard
+'
+
 test_done
index 7584efa36b06effd9005b8ebcc6afecec07e424b..40277c77aad5f2d9533e6822da3380bb49621e59 100755 (executable)
@@ -81,4 +81,12 @@ test_expect_success 'check combined output (2)' '
        verify_helper sidesansone
 '
 
+test_expect_success 'diagnose truncated file' '
+       >file &&
+       git add file &&
+       git commit --amend -C HEAD &&
+       git show >out &&
+       grep "diff --cc file" out
+'
+
 test_done
index 464305405ac715411b9cc5faabf55d116f0c6ec7..019acb926d6765bf24e1dfe4bea2a9dba28ca797 100755 (executable)
@@ -201,7 +201,7 @@ test_expect_success 'submodule contains untracked content' "
        echo new > sm1/new-file &&
        git diff-index -p --submodule=log HEAD >actual &&
        diff actual - <<-EOF
-Submodule sm1 $head6..$head6-dirty:
+Submodule sm1 contains untracked content
 EOF
 "
 
@@ -209,7 +209,8 @@ test_expect_success 'submodule contains untracked and modifed content' "
        echo new > sm1/foo6 &&
        git diff-index -p --submodule=log HEAD >actual &&
        diff actual - <<-EOF
-Submodule sm1 $head6..$head6-dirty:
+Submodule sm1 contains untracked content
+Submodule sm1 contains modified content
 EOF
 "
 
@@ -217,7 +218,7 @@ test_expect_success 'submodule contains modifed content' "
        rm -f sm1/new-file &&
        git diff-index -p --submodule=log HEAD >actual &&
        diff actual - <<-EOF
-Submodule sm1 $head6..$head6-dirty:
+Submodule sm1 contains modified content
 EOF
 "
 
@@ -235,7 +236,8 @@ test_expect_success 'modified submodule contains untracked content' "
        echo new > sm1/new-file &&
        git diff-index -p --submodule=log HEAD >actual &&
        diff actual - <<-EOF
-Submodule sm1 $head6..$head8-dirty:
+Submodule sm1 contains untracked content
+Submodule sm1 $head6..$head8:
   > change
 EOF
 "
@@ -244,7 +246,9 @@ test_expect_success 'modified submodule contains untracked and modifed content'
        echo modification >> sm1/foo6 &&
        git diff-index -p --submodule=log HEAD >actual &&
        diff actual - <<-EOF
-Submodule sm1 $head6..$head8-dirty:
+Submodule sm1 contains untracked content
+Submodule sm1 contains modified content
+Submodule sm1 $head6..$head8:
   > change
 EOF
 "
@@ -253,7 +257,8 @@ test_expect_success 'modified submodule contains modifed content' "
        rm -f sm1/new-file &&
        git diff-index -p --submodule=log HEAD >actual &&
        diff actual - <<-EOF
-Submodule sm1 $head6..$head8-dirty:
+Submodule sm1 contains modified content
+Submodule sm1 $head6..$head8:
   > change
 EOF
 "
@@ -324,4 +329,19 @@ index 0000000..$head7
 EOF
 "
 
+test_expect_success 'setup .git file for sm2' '
+       (cd sm2 &&
+        REAL="$(pwd)/../.real" &&
+        mv .git "$REAL"
+        echo "gitdir: $REAL" >.git)
+'
+
+test_expect_success 'diff --submodule with .git file' '
+       git diff --submodule HEAD^ >actual &&
+       diff actual - <<-EOF
+Submodule sm1 $head6...0000000 (submodule deleted)
+Submodule sm2 0000000...$head7 (new submodule)
+EOF
+'
+
 test_done
diff --git a/t/t4042-diff-textconv-caching.sh b/t/t4042-diff-textconv-caching.sh
new file mode 100755 (executable)
index 0000000..91f8198
--- /dev/null
@@ -0,0 +1,109 @@
+#!/bin/sh
+
+test_description='test textconv caching'
+. ./test-lib.sh
+
+cat >helper <<'EOF'
+#!/bin/sh
+sed 's/^/converted: /' "$@" >helper.out
+cat helper.out
+EOF
+chmod +x helper
+
+test_expect_success 'setup' '
+       echo foo content 1 >foo.bin &&
+       echo bar content 1 >bar.bin &&
+       git add . &&
+       git commit -m one &&
+       echo foo content 2 >foo.bin &&
+       echo bar content 2 >bar.bin &&
+       git commit -a -m two &&
+       echo "*.bin diff=magic" >.gitattributes &&
+       git config diff.magic.textconv ./helper &&
+       git config diff.magic.cachetextconv true
+'
+
+cat >expect <<EOF
+diff --git a/bar.bin b/bar.bin
+index fcf9166..28283d5 100644
+--- a/bar.bin
++++ b/bar.bin
+@@ -1 +1 @@
+-converted: bar content 1
++converted: bar content 2
+diff --git a/foo.bin b/foo.bin
+index d5b9fe3..1345db2 100644
+--- a/foo.bin
++++ b/foo.bin
+@@ -1 +1 @@
+-converted: foo content 1
++converted: foo content 2
+EOF
+
+test_expect_success 'first textconv works' '
+       git diff HEAD^ HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'cached textconv produces same output' '
+       git diff HEAD^ HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'cached textconv does not run helper' '
+       rm -f helper.out &&
+       git diff HEAD^ HEAD >actual &&
+       test_cmp expect actual &&
+       ! test -r helper.out
+'
+
+cat >expect <<EOF
+diff --git a/bar.bin b/bar.bin
+index fcf9166..28283d5 100644
+--- a/bar.bin
++++ b/bar.bin
+@@ -1,2 +1,2 @@
+ converted: other
+-converted: bar content 1
++converted: bar content 2
+diff --git a/foo.bin b/foo.bin
+index d5b9fe3..1345db2 100644
+--- a/foo.bin
++++ b/foo.bin
+@@ -1,2 +1,2 @@
+ converted: other
+-converted: foo content 1
++converted: foo content 2
+EOF
+test_expect_success 'changing textconv invalidates cache' '
+       echo other >other &&
+       git config diff.magic.textconv "./helper other" &&
+       git diff HEAD^ HEAD >actual &&
+       test_cmp expect actual
+'
+
+cat >expect <<EOF
+diff --git a/bar.bin b/bar.bin
+index fcf9166..28283d5 100644
+--- a/bar.bin
++++ b/bar.bin
+@@ -1,2 +1,2 @@
+ converted: other
+-converted: bar content 1
++converted: bar content 2
+diff --git a/foo.bin b/foo.bin
+index d5b9fe3..1345db2 100644
+--- a/foo.bin
++++ b/foo.bin
+@@ -1 +1 @@
+-converted: foo content 1
++converted: foo content 2
+EOF
+test_expect_success 'switching diff driver produces correct results' '
+       git config diff.moremagic.textconv ./helper &&
+       echo foo.bin diff=moremagic >>.gitattributes &&
+       git diff HEAD^ HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_done
diff --git a/t/t4134-apply-submodule.sh b/t/t4134-apply-submodule.sh
new file mode 100755 (executable)
index 0000000..1b82f93
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Peter Collingbourne
+#
+
+test_description='git apply submodule tests'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+       cat > create-sm.patch <<EOF
+diff --git a/dir/sm b/dir/sm
+new file mode 160000
+index 0000000..0123456
+--- /dev/null
++++ b/dir/sm
+@@ -0,0 +1 @@
++Subproject commit 0123456789abcdef0123456789abcdef01234567
+EOF
+       cat > remove-sm.patch <<EOF
+diff --git a/dir/sm b/dir/sm
+deleted file mode 160000
+index 0123456..0000000
+--- a/dir/sm
++++ /dev/null
+@@ -1 +0,0 @@
+-Subproject commit 0123456789abcdef0123456789abcdef01234567
+EOF
+'
+
+test_expect_success 'removing a submodule also removes all leading subdirectories' '
+       git apply --index create-sm.patch &&
+       test -d dir/sm &&
+       git apply --index remove-sm.patch &&
+       test \! -d dir
+'
+
+test_done
diff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh
new file mode 100755 (executable)
index 0000000..552da65
--- /dev/null
@@ -0,0 +1,199 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Thomas Rast
+#
+
+test_description='Test the post-rewrite hook.'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+       test_commit A foo A &&
+       test_commit B foo B &&
+       test_commit C foo C &&
+       test_commit D foo D
+'
+
+mkdir .git/hooks
+
+cat >.git/hooks/post-rewrite <<EOF
+#!/bin/sh
+echo \$@ > "$TRASH_DIRECTORY"/post-rewrite.args
+cat > "$TRASH_DIRECTORY"/post-rewrite.data
+EOF
+chmod u+x .git/hooks/post-rewrite
+
+clear_hook_input () {
+       rm -f post-rewrite.args post-rewrite.data
+}
+
+verify_hook_input () {
+       test_cmp "$TRASH_DIRECTORY"/post-rewrite.args expected.args &&
+       test_cmp "$TRASH_DIRECTORY"/post-rewrite.data expected.data
+}
+
+test_expect_success 'git commit --amend' '
+       clear_hook_input &&
+       echo "D new message" > newmsg &&
+       oldsha=$(git rev-parse HEAD^0) &&
+       git commit -Fnewmsg --amend &&
+       echo amend > expected.args &&
+       echo $oldsha $(git rev-parse HEAD^0) > expected.data &&
+       verify_hook_input
+'
+
+test_expect_success 'git commit --amend --no-post-rewrite' '
+       clear_hook_input &&
+       echo "D new message again" > newmsg &&
+       git commit --no-post-rewrite -Fnewmsg --amend &&
+       test ! -f post-rewrite.args &&
+       test ! -f post-rewrite.data
+'
+
+test_expect_success 'git rebase' '
+       git reset --hard D &&
+       clear_hook_input &&
+       test_must_fail git rebase --onto A B &&
+       echo C > foo &&
+       git add foo &&
+       git rebase --continue &&
+       echo rebase >expected.args &&
+       cat >expected.data <<EOF &&
+$(git rev-parse C) $(git rev-parse HEAD^)
+$(git rev-parse D) $(git rev-parse HEAD)
+EOF
+       verify_hook_input
+'
+
+test_expect_success 'git rebase --skip' '
+       git reset --hard D &&
+       clear_hook_input &&
+       test_must_fail git rebase --onto A B &&
+       test_must_fail git rebase --skip &&
+       echo D > foo &&
+       git add foo &&
+       git rebase --continue &&
+       echo rebase >expected.args &&
+       cat >expected.data <<EOF &&
+$(git rev-parse D) $(git rev-parse HEAD)
+EOF
+       verify_hook_input
+'
+
+test_expect_success 'git rebase -m' '
+       git reset --hard D &&
+       clear_hook_input &&
+       test_must_fail git rebase -m --onto A B &&
+       echo C > foo &&
+       git add foo &&
+       git rebase --continue &&
+       echo rebase >expected.args &&
+       cat >expected.data <<EOF &&
+$(git rev-parse C) $(git rev-parse HEAD^)
+$(git rev-parse D) $(git rev-parse HEAD)
+EOF
+       verify_hook_input
+'
+
+test_expect_success 'git rebase -m --skip' '
+       git reset --hard D &&
+       clear_hook_input &&
+       test_must_fail git rebase --onto A B &&
+       test_must_fail git rebase --skip &&
+       echo D > foo &&
+       git add foo &&
+       git rebase --continue &&
+       echo rebase >expected.args &&
+       cat >expected.data <<EOF &&
+$(git rev-parse D) $(git rev-parse HEAD)
+EOF
+       verify_hook_input
+'
+
+. "$TEST_DIRECTORY"/lib-rebase.sh
+
+set_fake_editor
+
+# Helper to work around the lack of one-shot exporting for
+# test_must_fail (as it is a shell function)
+test_fail_interactive_rebase () {
+       (
+               FAKE_LINES="$1" &&
+               shift &&
+               export FAKE_LINES &&
+               test_must_fail git rebase -i "$@"
+       )
+}
+
+test_expect_success 'git rebase -i (unchanged)' '
+       git reset --hard D &&
+       clear_hook_input &&
+       test_fail_interactive_rebase "1 2" --onto A B &&
+       echo C > foo &&
+       git add foo &&
+       git rebase --continue &&
+       echo rebase >expected.args &&
+       cat >expected.data <<EOF &&
+$(git rev-parse C) $(git rev-parse HEAD^)
+$(git rev-parse D) $(git rev-parse HEAD)
+EOF
+       verify_hook_input
+'
+
+test_expect_success 'git rebase -i (skip)' '
+       git reset --hard D &&
+       clear_hook_input &&
+       test_fail_interactive_rebase "2" --onto A B &&
+       echo D > foo &&
+       git add foo &&
+       git rebase --continue &&
+       echo rebase >expected.args &&
+       cat >expected.data <<EOF &&
+$(git rev-parse D) $(git rev-parse HEAD)
+EOF
+       verify_hook_input
+'
+
+test_expect_success 'git rebase -i (squash)' '
+       git reset --hard D &&
+       clear_hook_input &&
+       test_fail_interactive_rebase "1 squash 2" --onto A B &&
+       echo C > foo &&
+       git add foo &&
+       git rebase --continue &&
+       echo rebase >expected.args &&
+       cat >expected.data <<EOF &&
+$(git rev-parse C) $(git rev-parse HEAD)
+$(git rev-parse D) $(git rev-parse HEAD)
+EOF
+       verify_hook_input
+'
+
+test_expect_success 'git rebase -i (fixup without conflict)' '
+       git reset --hard D &&
+       clear_hook_input &&
+       FAKE_LINES="1 fixup 2" git rebase -i B &&
+       echo rebase >expected.args &&
+       cat >expected.data <<EOF &&
+$(git rev-parse C) $(git rev-parse HEAD)
+$(git rev-parse D) $(git rev-parse HEAD)
+EOF
+       verify_hook_input
+'
+
+test_expect_success 'git rebase -i (double edit)' '
+       git reset --hard D &&
+       clear_hook_input &&
+       FAKE_LINES="edit 1 edit 2" git rebase -i B &&
+       git rebase --continue &&
+       echo something > foo &&
+       git add foo &&
+       git rebase --continue &&
+       echo rebase >expected.args &&
+       cat >expected.data <<EOF &&
+$(git rev-parse C) $(git rev-parse HEAD^)
+$(git rev-parse D) $(git rev-parse HEAD)
+EOF
+       verify_hook_input
+'
+
+test_done
index a82c5ffa1c608f45786fe37531ffe93008a3570b..230c0cd784b317856749609cf64a5067e35a6965 100755 (executable)
@@ -110,17 +110,18 @@ test_expect_success 'remove remote' '
 test_expect_success 'remove remote protects non-remote branches' '
 (
        cd test &&
-       (cat >expect1 <<EOF
+       cat >expect1 <<EOF
 Note: A non-remote branch was not removed; to delete it, use:
   git branch -d master
 EOF
-    cat >expect2 <<EOF
+       } &&
+       { cat >expect2 <<EOF
 Note: Non-remote branches were not removed; to delete them, use:
   git branch -d foobranch
   git branch -d master
 EOF
-) &&
-       git tag footag
+       } &&
+       git tag footag &&
        git config --add remote.oops.fetch "+refs/*:refs/*" &&
        git remote rm oops 2>actual1 &&
        git branch foobranch &&
@@ -507,15 +508,15 @@ test_expect_success 'remote prune to cause a dangling symref' '
        (
                cd seven &&
                git remote prune origin
-       ) 2>err &&
+       ) >err 2>&1 &&
        grep "has become dangling" err &&
 
-       : And the dangling symref will not cause other annoying errors
+       : And the dangling symref will not cause other annoying errors &&
        (
                cd seven &&
                git branch -a
        ) 2>err &&
-       ! grep "points nowhere" err
+       ! grep "points nowhere" err &&
        (
                cd seven &&
                test_must_fail git branch nomore origin
@@ -534,43 +535,34 @@ test_expect_success 'show empty remote' '
 '
 
 test_expect_success 'new remote' '
-(
        git remote add someremote foo &&
        echo foo >expect &&
        git config --get-all remote.someremote.url >actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url bar' '
-(
        git remote set-url someremote bar &&
        echo bar >expect &&
        git config --get-all remote.someremote.url >actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url baz bar' '
-(
        git remote set-url someremote baz bar &&
        echo baz >expect &&
        git config --get-all remote.someremote.url >actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url zot bar' '
-(
        test_must_fail git remote set-url someremote zot bar &&
        echo baz >expect &&
        git config --get-all remote.someremote.url >actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --push zot baz' '
-(
        test_must_fail git remote set-url --push someremote zot baz &&
        echo "YYY" >expect &&
        echo baz >>expect &&
@@ -578,11 +570,9 @@ test_expect_success 'remote set-url --push zot baz' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --push zot' '
-(
        git remote set-url --push someremote zot &&
        echo zot >expect &&
        echo "YYY" >>expect &&
@@ -591,11 +581,9 @@ test_expect_success 'remote set-url --push zot' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --push qux zot' '
-(
        git remote set-url --push someremote qux zot &&
        echo qux >expect &&
        echo "YYY" >>expect &&
@@ -604,11 +592,9 @@ test_expect_success 'remote set-url --push qux zot' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --push foo qu+x' '
-(
        git remote set-url --push someremote foo qu+x &&
        echo foo >expect &&
        echo "YYY" >>expect &&
@@ -617,11 +603,9 @@ test_expect_success 'remote set-url --push foo qu+x' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --push --add aaa' '
-(
        git remote set-url --push --add someremote aaa &&
        echo foo >expect &&
        echo aaa >>expect &&
@@ -631,11 +615,9 @@ test_expect_success 'remote set-url --push --add aaa' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --push bar aaa' '
-(
        git remote set-url --push someremote bar aaa &&
        echo foo >expect &&
        echo bar >>expect &&
@@ -645,11 +627,9 @@ test_expect_success 'remote set-url --push bar aaa' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --push --delete bar' '
-(
        git remote set-url --push --delete someremote bar &&
        echo foo >expect &&
        echo "YYY" >>expect &&
@@ -658,11 +638,9 @@ test_expect_success 'remote set-url --push --delete bar' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --push --delete foo' '
-(
        git remote set-url --push --delete someremote foo &&
        echo "YYY" >expect &&
        echo baz >>expect &&
@@ -670,11 +648,9 @@ test_expect_success 'remote set-url --push --delete foo' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --add bbb' '
-(
        git remote set-url --add someremote bbb &&
        echo "YYY" >expect &&
        echo baz >>expect &&
@@ -683,12 +659,10 @@ test_expect_success 'remote set-url --add bbb' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --delete .*' '
-(
-       test_must_fail git remote set-url --delete someremote .* &&
+       test_must_fail git remote set-url --delete someremote .\* &&
        echo "YYY" >expect &&
        echo baz >>expect &&
        echo bbb >>expect &&
@@ -696,11 +670,9 @@ test_expect_success 'remote set-url --delete .*' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --delete bbb' '
-(
        git remote set-url --delete someremote bbb &&
        echo "YYY" >expect &&
        echo baz >>expect &&
@@ -708,11 +680,9 @@ test_expect_success 'remote set-url --delete bbb' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --delete baz' '
-(
        test_must_fail git remote set-url --delete someremote baz &&
        echo "YYY" >expect &&
        echo baz >>expect &&
@@ -720,11 +690,9 @@ test_expect_success 'remote set-url --delete baz' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --add ccc' '
-(
        git remote set-url --add someremote ccc &&
        echo "YYY" >expect &&
        echo baz >>expect &&
@@ -733,11 +701,9 @@ test_expect_success 'remote set-url --add ccc' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_expect_success 'remote set-url --delete baz' '
-(
        git remote set-url --delete someremote baz &&
        echo "YYY" >expect &&
        echo ccc >>expect &&
@@ -745,7 +711,6 @@ test_expect_success 'remote set-url --delete baz' '
        echo "YYY" >>actual &&
        git config --get-all remote.someremote.url >>actual &&
        cmp expect actual
-)
 '
 
 test_done
index 214756731baf199e6a50f9ab2380a8b4bfc0fb18..678cee502de54e5a9c18a43f114446d3392ec7f3 100755 (executable)
@@ -34,7 +34,7 @@ test_expect_success 'clone with excess parameters (2)' '
 test_expect_success 'output from clone' '
        rm -fr dst &&
        git clone -n "file://$(pwd)/src" dst >output &&
-       test $(grep Initialized output | wc -l) = 1
+       test $(grep Clon output | wc -l) = 1
 '
 
 test_expect_success 'clone does not keep pack' '
index b0047d3c6b593795561ce908ab8e10ff574d3dbc..a49b7c5722e6cb675f771c31e4eec87262388548 100755 (executable)
@@ -209,4 +209,13 @@ test_expect_success '%gd shortens ref name' '
        test_cmp expect.gd-short actual.gd-short
 '
 
+test_expect_success 'oneline with empty message' '
+       git commit -m "dummy" --allow-empty &&
+       git commit -m "dummy" --allow-empty &&
+       git filter-branch --msg-filter "sed -e s/dummy//" HEAD^^.. &&
+       git rev-list --oneline HEAD >test.txt &&
+       test $(git rev-list --oneline HEAD | wc -l) -eq 5 &&
+       test $(git rev-list --oneline --graph HEAD | wc -l) -eq 5
+'
+
 test_done
index 42f6fff373ba9707216279011b112c6c59af8780..42f8ece0978f38e10200a52ce8cf1952cf13ecbd 100755 (executable)
@@ -7,65 +7,69 @@ test_description='fmt-merge-msg test'
 
 . ./test-lib.sh
 
-datestamp=1151939923
-setdate () {
-       GIT_COMMITTER_DATE="$datestamp +0200"
-       GIT_AUTHOR_DATE="$datestamp +0200"
-       datestamp=`expr "$datestamp" + 1`
-       export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
-}
-
 test_expect_success setup '
        echo one >one &&
        git add one &&
-       setdate &&
+       test_tick &&
        git commit -m "Initial" &&
 
+       git clone . remote &&
+
        echo uno >one &&
        echo dos >two &&
        git add two &&
-       setdate &&
+       test_tick &&
        git commit -a -m "Second" &&
 
        git checkout -b left &&
 
-       echo $datestamp >one &&
-       setdate &&
+       echo "c1" >one &&
+       test_tick &&
        git commit -a -m "Common #1" &&
 
-       echo $datestamp >one &&
-       setdate &&
+       echo "c2" >one &&
+       test_tick &&
        git commit -a -m "Common #2" &&
 
        git branch right &&
 
-       echo $datestamp >two &&
-       setdate &&
+       echo "l3" >two &&
+       test_tick &&
        git commit -a -m "Left #3" &&
 
-       echo $datestamp >two &&
-       setdate &&
+       echo "l4" >two &&
+       test_tick &&
        git commit -a -m "Left #4" &&
 
-       echo $datestamp >two &&
-       setdate &&
+       echo "l5" >two &&
+       test_tick &&
        git commit -a -m "Left #5" &&
+       git tag tag-l5 &&
 
        git checkout right &&
 
-       echo $datestamp >three &&
+       echo "r3" >three &&
        git add three &&
-       setdate &&
+       test_tick &&
        git commit -a -m "Right #3" &&
+       git tag tag-r3 &&
 
-       echo $datestamp >three &&
-       setdate &&
+       echo "r4" >three &&
+       test_tick &&
        git commit -a -m "Right #4" &&
 
-       echo $datestamp >three &&
-       setdate &&
+       echo "r5" >three &&
+       test_tick &&
        git commit -a -m "Right #5" &&
 
+       git checkout -b long &&
+       i=0 &&
+       while test $i -lt 30
+       do
+               test_commit $i one &&
+               i=$(($i+1))
+       done &&
+
        git show-branch
 '
 
@@ -113,7 +117,7 @@ test_expect_success 'merge-msg test #3-1' '
        git config merge.log true &&
 
        git checkout master &&
-       setdate &&
+       test_tick &&
        git fetch . left &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
@@ -127,7 +131,7 @@ test_expect_success 'merge-msg test #3-2' '
        git config merge.summary true &&
 
        git checkout master &&
-       setdate &&
+       test_tick &&
        git fetch . left &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
@@ -159,7 +163,7 @@ test_expect_success 'merge-msg test #4-1' '
        git config merge.log true &&
 
        git checkout master &&
-       setdate &&
+       test_tick &&
        git fetch . left right &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
@@ -173,7 +177,7 @@ test_expect_success 'merge-msg test #4-2' '
        git config merge.summary true &&
 
        git checkout master &&
-       setdate &&
+       test_tick &&
        git fetch . left right &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
@@ -187,7 +191,7 @@ test_expect_success 'merge-msg test #5-1' '
        git config merge.log yes &&
 
        git checkout master &&
-       setdate &&
+       test_tick &&
        git fetch . left right &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
@@ -201,7 +205,7 @@ test_expect_success 'merge-msg test #5-2' '
        git config merge.summary yes &&
 
        git checkout master &&
-       setdate &&
+       test_tick &&
        git fetch . left right &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
@@ -215,7 +219,7 @@ test_expect_success 'merge-msg -F' '
        git config merge.summary yes &&
 
        git checkout master &&
-       setdate &&
+       test_tick &&
        git fetch . left right &&
 
        git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
@@ -229,7 +233,7 @@ test_expect_success 'merge-msg -F in subdirectory' '
        git config merge.summary yes &&
 
        git checkout master &&
-       setdate &&
+       test_tick &&
        git fetch . left right &&
        mkdir sub &&
        cp .git/FETCH_HEAD sub/FETCH_HEAD &&
@@ -240,4 +244,128 @@ test_expect_success 'merge-msg -F in subdirectory' '
        test_cmp expected actual
 '
 
+test_expect_success 'merge-msg with nothing to merge' '
+
+       git config --unset-all merge.log
+       git config --unset-all merge.summary
+       git config merge.summary yes &&
+
+       (
+               cd remote &&
+               git checkout -b unrelated &&
+               test_tick &&
+               git fetch origin &&
+               git fmt-merge-msg <.git/FETCH_HEAD >../actual
+       ) &&
+
+       test_cmp /dev/null actual
+'
+
+cat >expected <<\EOF
+Merge tag 'tag-r3'
+
+* tag 'tag-r3':
+  Right #3
+  Common #2
+  Common #1
+EOF
+
+test_expect_success 'merge-msg tag' '
+
+       git config --unset-all merge.log
+       git config --unset-all merge.summary
+       git config merge.summary yes &&
+
+       git checkout master &&
+       test_tick &&
+       git fetch . tag tag-r3 &&
+
+       git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+Merge tags 'tag-r3' and 'tag-l5'
+
+* tag 'tag-r3':
+  Right #3
+  Common #2
+  Common #1
+
+* tag 'tag-l5':
+  Left #5
+  Left #4
+  Left #3
+  Common #2
+  Common #1
+EOF
+
+test_expect_success 'merge-msg two tags' '
+
+       git config --unset-all merge.log
+       git config --unset-all merge.summary
+       git config merge.summary yes &&
+
+       git checkout master &&
+       test_tick &&
+       git fetch . tag tag-r3 tag tag-l5 &&
+
+       git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+Merge branch 'left', tag 'tag-r3'
+
+* tag 'tag-r3':
+  Right #3
+  Common #2
+  Common #1
+
+* left:
+  Left #5
+  Left #4
+  Left #3
+  Common #2
+  Common #1
+EOF
+
+test_expect_success 'merge-msg tag and branch' '
+
+       git config --unset-all merge.log
+       git config --unset-all merge.summary
+       git config merge.summary yes &&
+
+       git checkout master &&
+       test_tick &&
+       git fetch . tag tag-r3 left &&
+
+       git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+Merge branch 'long'
+
+* long: (35 commits)
+EOF
+
+test_expect_success 'merge-msg lots of commits' '
+
+       git checkout master &&
+       test_tick &&
+       git fetch . long &&
+
+       i=29 &&
+       while test $i -gt 9
+       do
+               echo "  $i" &&
+               i=$(($i-1))
+       done >>expected &&
+       echo "  ..." >>expected
+
+       git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+'
+
 test_done
index 8d8b1c0e25e857945b17ed5ae4a9abc5f8987bd3..582d0b54f1f1a32459727e59932e95c4b466951f 100755 (executable)
@@ -136,11 +136,11 @@ test_expect_success 'git-clean, dirty case' '
        test_cmp expected result
 '
 
-test_expect_failure 'git-apply adds file' false
-test_expect_failure 'git-apply updates file' false
-test_expect_failure 'git-apply removes file' false
-test_expect_failure 'git-mv to skip-worktree' false
-test_expect_failure 'git-mv from skip-worktree' false
-test_expect_failure 'git-checkout' false
+#TODO test_expect_failure 'git-apply adds file' false
+#TODO test_expect_failure 'git-apply updates file' false
+#TODO test_expect_failure 'git-apply removes file' false
+#TODO test_expect_failure 'git-mv to skip-worktree' false
+#TODO test_expect_failure 'git-mv from skip-worktree' false
+#TODO test_expect_failure 'git-checkout' false
 
 test_done
index 7940901d47fd457cda77ee333aa40145433be4d4..8297cb4f1e6e2d903dfbf6fde825d2c787082e58 100755 (executable)
@@ -425,4 +425,16 @@ test_expect_success 'amend using the message from a commit named with tag' '
 
 '
 
+test_expect_success 'amend can copy notes' '
+
+       git config notes.rewrite.amend true &&
+       git config notes.rewriteRef "refs/notes/*" &&
+       test_commit foo &&
+       git notes add -m"a note" &&
+       test_tick &&
+       git commit --amend -m"new foo" &&
+       test "$(git notes show)" = "a note"
+
+'
+
 test_done
index 253c3343190e88349f6aca1109e7439e3cf2a06e..3d4f85d74f6f378d76bde77e581273af010ba452 100755 (executable)
@@ -34,7 +34,7 @@ test_expect_success 'status with modified file in submodule' '
        (cd sub && git reset --hard) &&
        echo "changed" >sub/foo &&
        git status >output &&
-       grep "modified:   sub" output
+       grep "modified:   sub (modified content)" output
 '
 
 test_expect_success 'status with modified file in submodule (porcelain)' '
@@ -49,7 +49,7 @@ test_expect_success 'status with modified file in submodule (porcelain)' '
 test_expect_success 'status with added file in submodule' '
        (cd sub && git reset --hard && echo >foo && git add foo) &&
        git status >output &&
-       grep "modified:   sub" output
+       grep "modified:   sub (modified content)" output
 '
 
 test_expect_success 'status with added file in submodule (porcelain)' '
@@ -64,7 +64,12 @@ test_expect_success 'status with untracked file in submodule' '
        (cd sub && git reset --hard) &&
        echo "content" >sub/new-file &&
        git status >output &&
-       grep "modified:   sub" output
+       grep "modified:   sub (untracked content)" output
+'
+
+test_expect_success 'status -uno with untracked file in submodule' '
+       git status -uno >output &&
+       grep "^nothing to commit" output
 '
 
 test_expect_success 'status with untracked file in submodule (porcelain)' '
@@ -74,6 +79,100 @@ test_expect_success 'status with untracked file in submodule (porcelain)' '
        EOF
 '
 
+test_expect_success 'status with added and untracked file in submodule' '
+       (cd sub && git reset --hard && echo >foo && git add foo) &&
+       echo "content" >sub/new-file &&
+       git status >output &&
+       grep "modified:   sub (modified content, untracked content)" output
+'
+
+test_expect_success 'status with added and untracked file in submodule (porcelain)' '
+       (cd sub && git reset --hard && echo >foo && git add foo) &&
+       echo "content" >sub/new-file &&
+       git status --porcelain >output &&
+       diff output - <<-\EOF
+        M sub
+       EOF
+'
+
+test_expect_success 'status with modified file in modified submodule' '
+       (cd sub && git reset --hard) &&
+       rm sub/new-file &&
+       (cd sub && echo "next change" >foo && git commit -m "next change" foo) &&
+       echo "changed" >sub/foo &&
+       git status >output &&
+       grep "modified:   sub (new commits, modified content)" output
+'
+
+test_expect_success 'status with modified file in modified submodule (porcelain)' '
+       (cd sub && git reset --hard) &&
+       echo "changed" >sub/foo &&
+       git status --porcelain >output &&
+       diff output - <<-\EOF
+        M sub
+       EOF
+'
+
+test_expect_success 'status with added file in modified submodule' '
+       (cd sub && git reset --hard && echo >foo && git add foo) &&
+       git status >output &&
+       grep "modified:   sub (new commits, modified content)" output
+'
+
+test_expect_success 'status with added file in modified submodule (porcelain)' '
+       (cd sub && git reset --hard && echo >foo && git add foo) &&
+       git status --porcelain >output &&
+       diff output - <<-\EOF
+        M sub
+       EOF
+'
+
+test_expect_success 'status with untracked file in modified submodule' '
+       (cd sub && git reset --hard) &&
+       echo "content" >sub/new-file &&
+       git status >output &&
+       grep "modified:   sub (new commits, untracked content)" output
+'
+
+test_expect_success 'status with untracked file in modified submodule (porcelain)' '
+       git status --porcelain >output &&
+       diff output - <<-\EOF
+        M sub
+       EOF
+'
+
+test_expect_success 'status with added and untracked file in modified submodule' '
+       (cd sub && git reset --hard && echo >foo && git add foo) &&
+       echo "content" >sub/new-file &&
+       git status >output &&
+       grep "modified:   sub (new commits, modified content, untracked content)" output
+'
+
+test_expect_success 'status with added and untracked file in modified submodule (porcelain)' '
+       (cd sub && git reset --hard && echo >foo && git add foo) &&
+       echo "content" >sub/new-file &&
+       git status --porcelain >output &&
+       diff output - <<-\EOF
+        M sub
+       EOF
+'
+
+test_expect_success 'setup .git file for sub' '
+       (cd sub &&
+        rm -f new-file
+        REAL="$(pwd)/../.real" &&
+        mv .git "$REAL"
+        echo "gitdir: $REAL" >.git) &&
+        echo .real >>.gitignore &&
+        git commit -m "added .real to .gitignore" .gitignore
+'
+
+test_expect_success 'status with added file in modified submodule with .git file' '
+       (cd sub && git reset --hard && echo >foo && git add foo) &&
+       git status >output &&
+       grep "modified:   sub (new commits, modified content)" output
+'
+
 test_expect_success 'rm submodule contents' '
        rm -rf sub/* sub/.git
 '
index 19c72f55bf60c746f72e640e24043b2d83e00fe3..1de83ef98fdcbfd63469e66ba4886c2477b983ff 100755 (executable)
@@ -92,6 +92,15 @@ test_expect_success 'difftool honors --gui' '
        restore_test_defaults
 '
 
+test_expect_success 'difftool --gui works without configured diff.guitool' '
+       git config diff.tool test-tool &&
+
+       diff=$(git difftool --no-prompt --gui branch) &&
+       test "$diff" = "branch" &&
+
+       restore_test_defaults
+'
+
 # Specify the diff tool using $GIT_DIFF_TOOL
 test_expect_success 'GIT_DIFF_TOOL variable' '
        git config --unset diff.tool
index 356964e53a1acba1558881865fd99acdee48a17f..d43f37ccafb4ecf6f649a5504d2626f652d48d02 100755 (executable)
@@ -150,20 +150,22 @@ test_expect_success 'setup submodule' '
 
        git checkout -f master &&
        mkdir sub &&
-       cd sub &&
-       git init  &&
-       echo test file > file &&
-       git add file &&
-       git commit -m sub_initial &&
-       cd .. &&
+       (
+               cd sub &&
+               git init  &&
+               echo test file > file &&
+               git add file &&
+               git commit -m sub_initial
+       ) &&
        git submodule add "`pwd`/sub" sub &&
        git commit -m initial &&
        test_tick &&
-       cd sub &&
-       echo more data >> file &&
-       git add file &&
-       git commit -m sub_second &&
-       cd .. &&
+       (
+               cd sub &&
+               echo more data >> file &&
+               git add file &&
+               git commit -m sub_second
+       ) &&
        git add sub &&
        git commit -m second
 
@@ -264,19 +266,20 @@ test_expect_success 'cope with tagger-less tags' '
 
 test_expect_success 'setup for limiting exports by PATH' '
        mkdir limit-by-paths &&
-       cd limit-by-paths &&
-       git init &&
-       echo hi > there &&
-       git add there &&
-       git commit -m "First file" &&
-       echo foo > bar &&
-       git add bar &&
-       git commit -m "Second file" &&
-       git tag -a -m msg mytag &&
-       echo morefoo >> bar &&
-       git add bar &&
-       git commit -m "Change to second file" &&
-       cd ..
+       (
+               cd limit-by-paths &&
+               git init &&
+               echo hi > there &&
+               git add there &&
+               git commit -m "First file" &&
+               echo foo > bar &&
+               git add bar &&
+               git commit -m "Second file" &&
+               git tag -a -m msg mytag &&
+               echo morefoo >> bar &&
+               git add bar &&
+               git commit -m "Change to second file"
+       )
 '
 
 cat > limit-by-paths/expected << EOF
@@ -297,10 +300,11 @@ M 100644 :1 there
 EOF
 
 test_expect_success 'dropping tag of filtered out object' '
+(
        cd limit-by-paths &&
        git fast-export --tag-of-filtered-object=drop mytag -- there > output &&
-       test_cmp output expected &&
-       cd ..
+       test_cmp output expected
+)
 '
 
 cat >> limit-by-paths/expected << EOF
@@ -313,10 +317,11 @@ msg
 EOF
 
 test_expect_success 'rewriting tag of filtered out object' '
+(
        cd limit-by-paths &&
        git fast-export --tag-of-filtered-object=rewrite mytag -- there > output &&
-       test_cmp output expected &&
-       cd ..
+       test_cmp output expected
+)
 '
 
 cat > limit-by-paths/expected << EOF
@@ -343,13 +348,13 @@ M 100644 :2 there
 EOF
 
 test_expect_failure 'no exact-ref revisions included' '
-       cd limit-by-paths &&
-       git fast-export master~2..master~1 > output &&
-       test_cmp output expected &&
-       cd ..
+       (
+               cd limit-by-paths &&
+               git fast-export master~2..master~1 > output &&
+               test_cmp output expected
+       )
 '
 
-
 test_expect_success 'set-up a few more tags for tag export tests' '
        git checkout -f master &&
        HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&
index a0e396a9522cec96443490fd77ff4abffb335287..7422bba47e75e00073779e4b2d7a162862cdb426 100644 (file)
@@ -2,6 +2,18 @@
 #
 # Copyright (c) 2005 Junio C Hamano
 #
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see http://www.gnu.org/licenses/ .
 
 # if --tee was passed, write the output not only to the terminal, but
 # additionally to the file test-results/$BASENAME.out, too.
@@ -54,6 +66,10 @@ unset GIT_OBJECT_DIRECTORY
 unset GIT_CEILING_DIRECTORIES
 unset SHA1_FILE_DIRECTORIES
 unset SHA1_FILE_DIRECTORY
+unset GIT_NOTES_REF
+unset GIT_NOTES_DISPLAY_REF
+unset GIT_NOTES_REWRITE_REF
+unset GIT_NOTES_REWRITE_MODE
 GIT_MERGE_VERBOSITY=5
 export GIT_MERGE_VERBOSITY
 export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
@@ -350,8 +366,10 @@ test_debug () {
 }
 
 test_run_ () {
+       test_cleanup=:
        eval >&3 2>&4 "$1"
-       eval_ret="$?"
+       eval_ret=$?
+       eval >&3 2>&4 "$test_cleanup"
        return 0
 }
 
@@ -529,6 +547,31 @@ test_cmp() {
        $GIT_TEST_CMP "$@"
 }
 
+# This function can be used to schedule some commands to be run
+# unconditionally at the end of the test to restore sanity:
+#
+#      test_expect_success 'test core.capslock' '
+#              git config core.capslock true &&
+#              test_when_finished "git config --unset core.capslock" &&
+#              hello world
+#      '
+#
+# That would be roughly equivalent to
+#
+#      test_expect_success 'test core.capslock' '
+#              git config core.capslock true &&
+#              hello world
+#              git config --unset core.capslock
+#      '
+#
+# except that the greeting and config --unset must both succeed for
+# the test to pass.
+
+test_when_finished () {
+       test_cleanup="{ $*
+               } && (exit \"\$eval_ret\"); eval_ret=\$?; $test_cleanup"
+}
+
 # Most tests can use the created repository, but some may need to create more.
 # Usage: test_create_repo <directory>
 test_create_repo () {
index 408f0137a8342414eedba3a02372ea1ad6050117..d22a71a3999b3dc0e99f5e36053447b33f967bd7 100644 (file)
@@ -11,6 +11,16 @@ prefix ?= $(HOME)
 template_instdir ?= $(prefix)/share/git-core/templates
 # DESTDIR=
 
+ifndef SHELL_PATH
+       SHELL_PATH = /bin/sh
+endif
+ifndef PERL_PATH
+       PERL_PATH = perl
+endif
+
+SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
+PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
+
 # Shell quote (do not use $(call) to accommodate ancient setups);
 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
 template_instdir_SQ = $(subst ','\'',$(template_instdir))
@@ -33,8 +43,11 @@ boilerplates.made : $(bpsrc)
                case "$$boilerplate" in \
                *--) continue;; \
                esac && \
-               cp $$boilerplate blt/$$dst && \
-               if test -x "blt/$$dst"; then rx=rx; else rx=r; fi && \
+               sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
+                   -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
+                   -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$boilerplate > \
+                       blt/$$dst && \
+               if test -x "$$boilerplate"; then rx=rx; else rx=r; fi && \
                chmod a+$$rx "blt/$$dst" || exit; \
        done && \
        date >$@
index 6ef1d29d09a10a5b6c3cbec0ac481931cd0d85fc..b58d1184a9d43a39c0d95f32453efc78581877d6 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # An example hook script to check the commit log message.
-# Called by git-commit with one argument, the name of the file
+# Called by "git commit" with one argument, the name of the file
 # that has the commit message.  The hook should exit with non-zero
 # status after issuing an appropriate message if it wants to stop the
 # commit.  The hook is allowed to edit the commit message file.
index 5323b56b81b9dd3d7f9fb86d8892241becbb5e7e..ec17ec1939b7c3e86b7cb6c0c4de6b0818a7e75e 100755 (executable)
@@ -5,4 +5,4 @@
 #
 # To enable this hook, rename this file to "post-update".
 
-exec git-update-server-info
+exec git update-server-info
index 439eefda510ca8de9f55c63616f2113ac36c8b6b..b187c4bb1f256e19c25f80dd64f3451ced77e123 100755 (executable)
@@ -1,13 +1,13 @@
 #!/bin/sh
 #
 # An example hook script to verify what is about to be committed.
-# Called by git-commit with no arguments.  The hook should
+# Called by "git commit" with no arguments.  The hook should
 # exit with non-zero status after issuing an appropriate message if
 # it wants to stop the commit.
 #
 # To enable this hook, rename this file to "pre-commit".
 
-if git-rev-parse --verify HEAD >/dev/null 2>&1
+if git rev-parse --verify HEAD >/dev/null 2>&1
 then
        against=HEAD
 else
index be1b06e25043146f22261b55548229e6ab524b7c..053f1111c0d734c057e895cdc992188104cc4f84 100755 (executable)
@@ -2,7 +2,7 @@
 #
 # Copyright (c) 2006, 2008 Junio C Hamano
 #
-# The "pre-rebase" hook is run just before "git-rebase" starts doing
+# The "pre-rebase" hook is run just before "git rebase" starts doing
 # its job, and can prevent the command from running by exiting with
 # non-zero status.
 #
@@ -43,7 +43,7 @@ git show-ref -q "$topic" || {
 }
 
 # Is topic fully merged to master?
-not_in_master=`git-rev-list --pretty=oneline ^master "$topic"`
+not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
 if test -z "$not_in_master"
 then
        echo >&2 "$topic is fully merged to master; better remove it."
@@ -51,11 +51,11 @@ then
 fi
 
 # Is topic ever merged to next?  If so you should not be rebasing it.
-only_next_1=`git-rev-list ^master "^$topic" ${publish} | sort`
-only_next_2=`git-rev-list ^master           ${publish} | sort`
+only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
+only_next_2=`git rev-list ^master           ${publish} | sort`
 if test "$only_next_1" = "$only_next_2"
 then
-       not_in_topic=`git-rev-list "^$topic" master`
+       not_in_topic=`git rev-list "^$topic" master`
        if test -z "$not_in_topic"
        then
                echo >&2 "$topic is already up-to-date with master"
@@ -64,8 +64,8 @@ then
                exit 0
        fi
 else
-       not_in_next=`git-rev-list --pretty=oneline ^${publish} "$topic"`
-       perl -e '
+       not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
+       @PERL_PATH@ -e '
                my $topic = $ARGV[0];
                my $msg = "* $topic has commits already merged to public branch:\n";
                my (%not_in_next) = map {
@@ -157,13 +157,13 @@ B to be deleted.
 
 To compute (1):
 
-       git-rev-list ^master ^topic next
-       git-rev-list ^master        next
+       git rev-list ^master ^topic next
+       git rev-list ^master        next
 
        if these match, topic has not merged in next at all.
 
 To compute (2):
 
-       git-rev-list master..topic
+       git rev-list master..topic
 
        if this is empty, it is fully merged to "master".
index 365242499dcf0ee35c26ccb2917724d6e559be69..86b8f227ecab874a4af98bc5ba3164d370e5e4b5 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # An example hook script to prepare the commit log message.
-# Called by git-commit with the name of the file that has the
+# Called by "git commit" with the name of the file that has the
 # commit message, followed by the description of the commit
 # message's source.  The hook's purpose is to edit the commit
 # message file.  If the hook fails with a non-zero status,
 
 case "$2,$3" in
   merge,)
-    perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
+    @PERL_PATH@ -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
 
 # ,|template,)
-#   perl -i.bak -pe '
+#   @PERL_PATH@ -i.bak -pe '
 #      print "\n" . `git diff --cached --name-status -r`
 #       if /^#/ && $first++ == 0' "$1" ;;
 
index fd63b2d662dbcf98ec622a1ab754d041a559e3be..71ab04edc09be7aeefa1e8a0f609a974ffd55a9f 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # An example hook script to blocks unannotated tags from entering.
-# Called by git-receive-pack with arguments: refname sha1-old sha1-new
+# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
 #
 # To enable this hook, rename this file to "update".
 #
@@ -64,7 +64,7 @@ zero="0000000000000000000000000000000000000000"
 if [ "$newrev" = "$zero" ]; then
        newrev_type=delete
 else
-       newrev_type=$(git-cat-file -t $newrev)
+       newrev_type=$(git cat-file -t $newrev)
 fi
 
 case "$refname","$newrev_type" in
index 2c87b72dff61f8394b3f1f32e21c1d936314ec2e..a5196d1be8fb59edf8062bef36d3a602e0812139 100644 (file)
@@ -1,4 +1,4 @@
-# git-ls-files --others --exclude-from=.git/info/exclude
+# git ls-files --others --exclude-from=.git/info/exclude
 # Lines that start with '#' are comments.
 # For a project mostly in C, the following would be a good set of
 # exclude patterns (uncomment them if you want to use them):
index 75f54cac97f62ddaad736c2cd582cc6cdeaaebfa..c29a9e067ff362063d6626e8e4d1e4466d63b8af 100644 (file)
@@ -67,16 +67,8 @@ static void unlink_entry(struct cache_entry *ce)
 {
        if (has_symlink_or_noent_leading_path(ce->name, ce_namelen(ce)))
                return;
-       if (S_ISGITLINK(ce->ce_mode)) {
-               if (rmdir(ce->name)) {
-                       warning("unable to rmdir %s: %s",
-                               ce->name, strerror(errno));
-                       return;
-               }
-       }
-       else
-               if (unlink_or_warn(ce->name))
-                       return;
+       if (remove_or_warn(ce->ce_mode, ce->name))
+               return;
        schedule_dir_for_removal(ce->name, ce_namelen(ce));
 }
 
index df992490d5f86b5eff2b87e90090b1ec576aae9a..67003fbb232cd85627f61c02a616b3d6a9ccd5d2 100644 (file)
@@ -1,3 +1,4 @@
+#include "cache.h"
 #include "userdiff.h"
 #include "cache.h"
 #include "attr.h"
@@ -167,6 +168,12 @@ static int parse_tristate(int *b, const char *k, const char *v)
        return 1;
 }
 
+static int parse_bool(int *b, const char *k, const char *v)
+{
+       *b = git_config_bool(k, v);
+       return 1;
+}
+
 int userdiff_config(const char *k, const char *v)
 {
        struct userdiff_driver *drv;
@@ -181,6 +188,8 @@ int userdiff_config(const char *k, const char *v)
                return parse_string(&drv->external, k, v);
        if ((drv = parse_driver(k, v, "textconv")))
                return parse_string(&drv->textconv, k, v);
+       if ((drv = parse_driver(k, v, "cachetextconv")))
+               return parse_bool(&drv->textconv_want_cache, k, v);
        if ((drv = parse_driver(k, v, "wordregex")))
                return parse_string(&drv->word_regex, k, v);
 
index c3151594f5c0643fead757accc27bf1093cf4a68..942d5949501027fb5d30e0d59629aab38fd2669a 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef USERDIFF_H
 #define USERDIFF_H
 
+#include "notes-cache.h"
+
 struct userdiff_funcname {
        const char *pattern;
        int cflags;
@@ -13,6 +15,8 @@ struct userdiff_driver {
        struct userdiff_funcname funcname;
        const char *word_regex;
        const char *textconv;
+       struct notes_cache *textconv_cache;
+       int textconv_want_cache;
 };
 
 int userdiff_config(const char *k, const char *v);
index 9c71b21242773f52ca560d7e5e5e52123674d334..10a6750795b287beabd50561402ffa8867f3e283 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -311,18 +311,30 @@ int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1)
        return open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
 }
 
-int unlink_or_warn(const char *file)
+static int warn_if_unremovable(const char *op, const char *file, int rc)
 {
-       int rc = unlink(file);
-
        if (rc < 0) {
                int err = errno;
                if (ENOENT != err) {
-                       warning("unable to unlink %s: %s",
-                               file, strerror(errno));
+                       warning("unable to %s %s: %s",
+                               op, file, strerror(errno));
                        errno = err;
                }
        }
        return rc;
 }
 
+int unlink_or_warn(const char *file)
+{
+       return warn_if_unremovable("unlink", file, unlink(file));
+}
+
+int rmdir_or_warn(const char *file)
+{
+       return warn_if_unremovable("rmdir", file, rmdir(file));
+}
+
+int remove_or_warn(unsigned int mode, const char *file)
+{
+       return S_ISGITLINK(mode) ? rmdir_or_warn(file) : unlink_or_warn(file);
+}
index 5807fc3211a3aa8f886694776fe8c86b5bc5eb59..8ca59a2d2abec0c9c4629cd4ae7340fcd79a0c7e 100644 (file)
@@ -78,7 +78,8 @@ static void wt_status_print_cached_header(struct wt_status *s)
 }
 
 static void wt_status_print_dirty_header(struct wt_status *s,
-                                        int has_deleted)
+                                        int has_deleted,
+                                        int has_dirty_submodules)
 {
        const char *c = color(WT_STATUS_HEADER, s);
 
@@ -90,6 +91,8 @@ static void wt_status_print_dirty_header(struct wt_status *s,
        else
                color_fprintf_ln(s->fp, c, "#   (use \"git add/rm <file>...\" to update what will be committed)");
        color_fprintf_ln(s->fp, c, "#   (use \"git checkout -- <file>...\" to discard changes in working directory)");
+       if (has_dirty_submodules)
+               color_fprintf_ln(s->fp, c, "#   (commit or discard the untracked or modified content in submodules)");
        color_fprintf_ln(s->fp, c, "#");
 }
 
@@ -144,6 +147,7 @@ static void wt_status_print_change_data(struct wt_status *s,
        char *two_name;
        const char *one, *two;
        struct strbuf onebuf = STRBUF_INIT, twobuf = STRBUF_INIT;
+       struct strbuf extra = STRBUF_INIT;
 
        one_name = two_name = it->string;
        switch (change_type) {
@@ -153,6 +157,17 @@ static void wt_status_print_change_data(struct wt_status *s,
                        one_name = d->head_path;
                break;
        case WT_STATUS_CHANGED:
+               if (d->new_submodule_commits || d->dirty_submodule) {
+                       strbuf_addstr(&extra, " (");
+                       if (d->new_submodule_commits)
+                               strbuf_addf(&extra, "new commits, ");
+                       if (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
+                               strbuf_addf(&extra, "modified content, ");
+                       if (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
+                               strbuf_addf(&extra, "untracked content, ");
+                       strbuf_setlen(&extra, extra.len - 2);
+                       strbuf_addch(&extra, ')');
+               }
                status = d->worktree_status;
                break;
        }
@@ -189,6 +204,10 @@ static void wt_status_print_change_data(struct wt_status *s,
        default:
                die("bug: unhandled diff status %c", status);
        }
+       if (extra.len) {
+               color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "%s", extra.buf);
+               strbuf_release(&extra);
+       }
        fprintf(s->fp, "\n");
        strbuf_release(&onebuf);
        strbuf_release(&twobuf);
@@ -218,6 +237,9 @@ static void wt_status_collect_changed_cb(struct diff_queue_struct *q,
                }
                if (!d->worktree_status)
                        d->worktree_status = p->status;
+               d->dirty_submodule = p->two->dirty_submodule;
+               if (S_ISGITLINK(p->two->mode))
+                       d->new_submodule_commits = !!hashcmp(p->one->sha1, p->two->sha1);
        }
 }
 
@@ -281,6 +303,9 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
        init_revisions(&rev, NULL);
        setup_revisions(0, NULL, &rev, NULL);
        rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
+       DIFF_OPT_SET(&rev.diffopt, DIRTY_SUBMODULES);
+       if (!s->show_untracked_files)
+               DIFF_OPT_SET(&rev.diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);
        rev.diffopt.format_callback = wt_status_collect_changed_cb;
        rev.diffopt.format_callback_data = s;
        rev.prune_data = s->pathspec;
@@ -290,10 +315,13 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
 static void wt_status_collect_changes_index(struct wt_status *s)
 {
        struct rev_info rev;
+       struct setup_revision_opt opt;
 
        init_revisions(&rev, NULL);
-       setup_revisions(0, NULL, &rev,
-               s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference);
+       memset(&opt, 0, sizeof(opt));
+       opt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference;
+       setup_revisions(0, NULL, &rev, &opt);
+
        rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
        rev.diffopt.format_callback = wt_status_collect_updated_cb;
        rev.diffopt.format_callback_data = s;
@@ -418,33 +446,39 @@ static void wt_status_print_updated(struct wt_status *s)
  *  0 : no change
  *  1 : some change but no delete
  */
-static int wt_status_check_worktree_changes(struct wt_status *s)
+static int wt_status_check_worktree_changes(struct wt_status *s,
+                                            int *dirty_submodules)
 {
        int i;
        int changes = 0;
 
+       *dirty_submodules = 0;
+
        for (i = 0; i < s->change.nr; i++) {
                struct wt_status_change_data *d;
                d = s->change.items[i].util;
                if (!d->worktree_status ||
                    d->worktree_status == DIFF_STATUS_UNMERGED)
                        continue;
-               changes = 1;
+               if (!changes)
+                       changes = 1;
+               if (d->dirty_submodule)
+                       *dirty_submodules = 1;
                if (d->worktree_status == DIFF_STATUS_DELETED)
-                       return -1;
+                       changes = -1;
        }
        return changes;
 }
 
 static void wt_status_print_changed(struct wt_status *s)
 {
-       int i;
-       int worktree_changes = wt_status_check_worktree_changes(s);
+       int i, dirty_submodules;
+       int worktree_changes = wt_status_check_worktree_changes(s, &dirty_submodules);
 
        if (!worktree_changes)
                return;
 
-       wt_status_print_dirty_header(s, worktree_changes < 0);
+       wt_status_print_dirty_header(s, worktree_changes < 0, dirty_submodules);
 
        for (i = 0; i < s->change.nr; i++) {
                struct wt_status_change_data *d;
@@ -512,11 +546,15 @@ static void wt_status_print_untracked(struct wt_status *s)
 static void wt_status_print_verbose(struct wt_status *s)
 {
        struct rev_info rev;
+       struct setup_revision_opt opt;
 
        init_revisions(&rev, NULL);
        DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
-       setup_revisions(0, NULL, &rev,
-               s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference);
+
+       memset(&opt, 0, sizeof(opt));
+       opt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference;
+       setup_revisions(0, NULL, &rev, &opt);
+
        rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
        rev.diffopt.detect_rename = 1;
        rev.diffopt.file = s->fp;
index c60f40a34a89ccdacdc864203d4441cf3e20bcc5..91206739f318233811dbd594d5ff37aa77c06eef 100644 (file)
@@ -25,6 +25,8 @@ struct wt_status_change_data {
        int index_status;
        int stagemask;
        char *head_path;
+       unsigned dirty_submodule       : 2;
+       unsigned new_submodule_commits : 1;
 };
 
 struct wt_status {
index ca5e3fbae8184e7114413ec65fe815e01ad6b2a8..cd2285de1cb1faa9f7c6c97dd22210f20bb046a3 100644 (file)
@@ -138,19 +138,20 @@ int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t co
 
 int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
                  xdiff_emit_consume_fn fn, void *consume_callback_data,
-                 xpparam_t const *xpp,
-                 xdemitconf_t const *xecfg, xdemitcb_t *xecb)
+                 xpparam_t const *xpp, xdemitconf_t const *xecfg)
 {
        int ret;
        struct xdiff_emit_state state;
+       xdemitcb_t ecb;
 
        memset(&state, 0, sizeof(state));
        state.consume = fn;
        state.consume_callback_data = consume_callback_data;
-       xecb->outf = xdiff_outf;
-       xecb->priv = &state;
+       memset(&ecb, 0, sizeof(ecb));
+       ecb.outf = xdiff_outf;
+       ecb.priv = &state;
        strbuf_init(&state.remainder, 0);
-       ret = xdi_diff(mf1, mf2, xpp, xecfg, xecb);
+       ret = xdi_diff(mf1, mf2, xpp, xecfg, &ecb);
        strbuf_release(&state.remainder);
        return ret;
 }
index abba70c16bb31fae0df999241830d0c8df8bfbb3..49d1116fc34f536ab9358313522a25564dd1f6c3 100644 (file)
@@ -9,8 +9,7 @@ typedef void (*xdiff_emit_hunk_consume_fn)(void *, long, long, long);
 int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb);
 int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
                  xdiff_emit_consume_fn fn, void *consume_callback_data,
-                 xpparam_t const *xpp,
-                 xdemitconf_t const *xecfg, xdemitcb_t *xecb);
+                 xpparam_t const *xpp, xdemitconf_t const *xecfg);
 int xdi_diff_hunks(mmfile_t *mf1, mmfile_t *mf2,
                   xdiff_emit_hunk_consume_fn fn, void *consume_callback_data,
                   xpparam_t const *xpp, xdemitconf_t *xecfg);
index 16dd9acd37b431f1e439d9ab051fe2436c54b45c..6d6fc1bc5e01be7305ec5101f43645a1dce69bd3 100644 (file)
@@ -152,7 +152,6 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
        int marker1_size = (name1 ? strlen(name1) + 1 : 0);
        int marker2_size = (name2 ? strlen(name2) + 1 : 0);
        int marker3_size = (name3 ? strlen(name3) + 1 : 0);
-       int j;
 
        if (marker_size <= 0)
                marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
@@ -164,8 +163,8 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
        if (!dest) {
                size += marker_size + 1 + marker1_size;
        } else {
-               for (j = 0; j < marker_size; j++)
-                       dest[size++] = '<';
+               memset(dest + size, '<', marker_size);
+               size += marker_size;
                if (marker1_size) {
                        dest[size] = ' ';
                        memcpy(dest + size + 1, name1, marker1_size - 1);
@@ -183,8 +182,8 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
                if (!dest) {
                        size += marker_size + 1 + marker3_size;
                } else {
-                       for (j = 0; j < marker_size; j++)
-                               dest[size++] = '|';
+                       memset(dest + size, '|', marker_size);
+                       size += marker_size;
                        if (marker3_size) {
                                dest[size] = ' ';
                                memcpy(dest + size + 1, name3, marker3_size - 1);
@@ -199,8 +198,8 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
        if (!dest) {
                size += marker_size + 1;
        } else {
-               for (j = 0; j < marker_size; j++)
-                       dest[size++] = '=';
+               memset(dest + size, '=', marker_size);
+               size += marker_size;
                dest[size++] = '\n';
        }
 
@@ -210,8 +209,8 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
        if (!dest) {
                size += marker_size + 1 + marker2_size;
        } else {
-               for (j = 0; j < marker_size; j++)
-                       dest[size++] = '>';
+               memset(dest + size, '>', marker_size);
+               size += marker_size;
                if (marker2_size) {
                        dest[size] = ' ';
                        memcpy(dest + size + 1, name2, marker2_size - 1);