]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/suppress-clang-warning'
authorJunio C Hamano <gitster@pobox.com>
Thu, 24 Jan 2013 05:19:00 +0000 (21:19 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 24 Jan 2013 05:19:00 +0000 (21:19 -0800)
* jk/suppress-clang-warning:
  fix clang -Wunused-value warnings for error functions

235 files changed:
.gitignore
.mailmap
Documentation/CodingGuidelines
Documentation/Makefile
Documentation/RelNotes/1.8.0.3.txt [new file with mode: 0644]
Documentation/RelNotes/1.8.1.1.txt [new file with mode: 0644]
Documentation/RelNotes/1.8.1.2.txt [new file with mode: 0644]
Documentation/RelNotes/1.8.1.txt
Documentation/RelNotes/1.8.2.txt [new file with mode: 0644]
Documentation/SubmittingPatches
Documentation/config.txt
Documentation/diff-options.txt
Documentation/fetch-options.txt
Documentation/git-bundle.txt
Documentation/git-checkout.txt
Documentation/git-commit-tree.txt
Documentation/git-commit.txt
Documentation/git-config.txt
Documentation/git-cvsimport.txt
Documentation/git-cvsserver.txt
Documentation/git-diff.txt
Documentation/git-fast-import.txt
Documentation/git-for-each-ref.txt
Documentation/git-format-patch.txt
Documentation/git-log.txt
Documentation/git-p4.txt
Documentation/git-push.txt
Documentation/git-remote-testgit.txt
Documentation/git-reset.txt
Documentation/git-shortlog.txt
Documentation/git-submodule.txt
Documentation/git-svn.txt
Documentation/git-tag.txt
Documentation/git.txt
Documentation/gitignore.txt
Documentation/gitmodules.txt
Documentation/howto/new-command.txt [moved from Documentation/technical/api-command.txt with 84% similarity]
Documentation/mailmap.txt
Documentation/pretty-formats.txt
Documentation/pt_BR/gittutorial.txt [deleted file]
Documentation/technical/api-allocation-growing.txt
Documentation/technical/api-directory-listing.txt
Documentation/technical/api-history-graph.txt
Documentation/technical/api-index-skel.txt
Documentation/technical/api-run-command.txt
Documentation/technical/api-string-list.txt
Documentation/technical/index-format.txt
GIT-VERSION-GEN
Makefile
README
RelNotes
abspath.c
advice.c
advice.h
archive-tar.c
archive-zip.c
archive.c
attr.c
builtin.h
builtin/add.c
builtin/apply.c
builtin/blame.c
builtin/branch.c
builtin/clean.c
builtin/clone.c
builtin/commit.c
builtin/fast-export.c
builtin/fmt-merge-msg.c
builtin/log.c
builtin/ls-files.c
builtin/ls-tree.c
builtin/merge-index.c
builtin/merge-tree.c
builtin/merge.c
builtin/push.c
builtin/reset.c
builtin/send-pack.c
builtin/shortlog.c
cache-tree.c
cache-tree.h
cache.h
commit.h
compat/fnmatch/fnmatch.c
compat/nedmalloc/nedmalloc.c
config.c
config.mak.uname [new file with mode: 0644]
configure.ac
contrib/ciabot/ciabot.py
contrib/completion/git-completion.bash
contrib/completion/git-completion.tcsh
contrib/completion/git-prompt.sh
contrib/fast-import/import-zips.py
contrib/hg-to-git/hg-to-git.py
contrib/p4import/git-p4import.py
contrib/remote-helpers/git-remote-bzr [new file with mode: 0755]
contrib/remote-helpers/git-remote-hg
contrib/remote-helpers/test-bzr.sh [new file with mode: 0755]
contrib/remote-helpers/test-hg-bidi.sh
contrib/remote-helpers/test-hg-hg-git.sh
contrib/stats/mailmap.pl
contrib/subtree/.gitignore
contrib/subtree/git-subtree.txt
contrib/svn-fe/svnrdump_sim.py
contrib/vim/README
ctype.c
diff.c
dir.c
dir.h
editor.c
fetch-pack.c
fsck.c
git-compat-util.h
git-cvsserver.perl
git-p4.py
git-rebase--am.sh
git-rebase--interactive.sh
git-remote-testgit [new file with mode: 0755]
git-remote-testpy.py [moved from git-remote-testgit.py with 93% similarity]
git-send-email.perl
git-sh-setup.sh
git-submodule.sh
git-svn.perl
git.c
git_remote_helpers/git/__init__.py
git_remote_helpers/git/importer.py
gitk-git/gitk
gitk-git/po/sv.po
gitweb/gitweb.perl
graph.c
http-push.c
http.c
imap-send.c
log-tree.c
log-tree.h
mailmap.c
mailmap.h
merge-blobs.c [moved from merge-file.c with 94% similarity]
merge-blobs.h [new file with mode: 0644]
merge-file.h [deleted file]
merge-recursive.c
mergetools/p4merge
path.c
perl/Git.pm
perl/Git/SVN/Editor.pm
perl/Git/SVN/Prompt.pm
perl/Git/SVN/Utils.pm
po/de.po
pretty.c
refs.c
remote.c
revision.c
revision.h
run-command.c
send-pack.c
sequencer.c
setup.c
strbuf.c
strbuf.h
string-list.c
string-list.h
t/Makefile
t/check-non-portable-shell.pl [new file with mode: 0755]
t/lib-gettext.sh
t/t0000-basic.sh
t/t0003-attributes.sh
t/t0024-crlf-archive.sh
t/t0060-path-utils.sh
t/t0063-string-list.sh
t/t1020-subdirectory.sh
t/t1402-check-ref-format.sh
t/t1450-fsck.sh
t/t1505-rev-parse-last.sh
t/t2013-checkout-submodule.sh
t/t2203-add-intent.sh
t/t3001-ls-files-others-exclude.sh
t/t3070-wildmatch.sh [new file with mode: 0755]
t/t3404-rebase-interactive.sh
t/t3501-revert-cherry-pick.sh
t/t3506-cherry-pick-ff.sh
t/t3507-cherry-pick-conflict.sh
t/t3508-cherry-pick-many-commits.sh
t/t3510-cherry-pick-sequence.sh
t/t3600-rm.sh
t/t4014-format-patch.sh
t/t4201-shortlog.sh
t/t4202-log.sh
t/t4203-mailmap.sh
t/t4300-merge-tree.sh
t/t5000-tar-tree.sh
t/t5002-archive-attr-pattern.sh [new file with mode: 0755]
t/t5003-archive-zip.sh [new file with mode: 0755]
t/t5003/infozip-symlinks.zip [new file with mode: 0644]
t/t5516-fetch-push.sh
t/t5535-fetch-push-symref.sh [new file with mode: 0755]
t/t5600-clone-fail-cleanup.sh
t/t5800-remote-testpy.sh [moved from t/t5800-remote-helpers.sh with 74% similarity]
t/t5801-remote-helpers.sh [new file with mode: 0755]
t/t6006-rev-list-format.sh
t/t6030-bisect-porcelain.sh
t/t6130-pathspec-noglob.sh [new file with mode: 0755]
t/t7004-tag.sh
t/t7061-wtstatus-ignore.sh [new file with mode: 0755]
t/t7102-reset.sh
t/t7106-reset-unborn-branch.sh [new file with mode: 0755]
t/t7400-submodule-basic.sh
t/t7406-submodule-update.sh
t/t7500/add-content-and-comment [new file with mode: 0755]
t/t7502-commit.sh
t/t7505-prepare-commit-msg-hook.sh
t/t9020-remote-svn.sh
t/t9200-git-cvsexportcommit.sh
t/t9350-fast-export.sh
t/t9402-git-cvsserver-refs.sh [new file with mode: 0755]
t/t9502-gitweb-standalone-parse-output.sh
t/t9800-git-p4-basic.sh
t/t9806-git-p4-options.sh
t/t9810-git-p4-rcs.sh
t/test-lib-functions.sh
t/test-lib.sh
t/test-terminal.perl
test-path-utils.c
test-string-list.c
test-wildmatch.c [new file with mode: 0644]
transport-helper.c
transport.c
transport.h
tree-walk.c
unpack-trees.c
upload-pack.c
utf8.c
utf8.h
wildmatch.c [new file with mode: 0644]
wildmatch.h [new file with mode: 0644]
wrapper.c
wt-status.c

index f702415c12c5a4a66180f7ffd697347e5343ac4a..aa258a6bcfe105cdb872c6d77cd9bd19c84e8dc5 100644 (file)
@@ -1,8 +1,8 @@
 /GIT-BUILD-OPTIONS
 /GIT-CFLAGS
 /GIT-LDFLAGS
-/GIT-GUI-VARS
 /GIT-PREFIX
+/GIT-PYTHON-VARS
 /GIT-SCRIPT-DEFINES
 /GIT-USER-AGENT
 /GIT-VERSION-FILE
 /git-remote-ftps
 /git-remote-fd
 /git-remote-ext
-/git-remote-testgit
+/git-remote-testpy
 /git-remote-testsvn
 /git-repack
 /git-replace
 /git-whatchanged
 /git-write-tree
 /git-core-*/?*
-/gitk-git/gitk-wish
 /gitweb/GITWEB-BUILD-OPTIONS
 /gitweb/gitweb.cgi
 /gitweb/static/gitweb.js
 /test-string-list
 /test-subprocess
 /test-svn-fe
+/test-wildmatch
 /common-cmds.h
 *.tar.gz
 *.dsc
index bcf4f8770f0751a61cf1c1b89a0d66cff559c54e..c7e86183001a00ad2105765708b5b59852ef6640 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -9,7 +9,9 @@ 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>
+Cheng Renquan <crquan@gmail.com>
 Chris Shoemaker <c.shoemaker@cox.net>
+Dan Johnson <computerdruid@gmail.com>
 Dana L. How <danahow@gmail.com>
 Dana L. How <how@deathvalley.cswitch.com>
 Daniel Barkalow <barkalow@iabervon.org>
@@ -18,14 +20,18 @@ 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>
+Eric S. Raymond <esr@thyrsus.com>
 Erik Faye-Lund <kusmabite@gmail.com> <kusmabite@googlemail.com>
 Fredrik Kuivinen <freku045@student.liu.se>
+Frédéric Heitzmann <frederic.heitzmann@gmail.com>
 H. Peter Anvin <hpa@bonde.sc.orionmulti.com>
 H. Peter Anvin <hpa@tazenda.sc.orionmulti.com>
 H. Peter Anvin <hpa@trantor.hos.anvin.org>
 Horst H. von Brand <vonbrand@inf.utfsm.cl>
 Ä°smail Dönmez <ismail@pardus.org.tr>
+Jakub NarÄ™bski <jnareb@gmail.com>
 Jay Soffian <jaysoffian+git@gmail.com>
+Jeff King <peff@peff.net> <peff@github.com>
 Joachim Berdal Haga <cjhaga@fys.uio.no>
 Johannes Sixt <j6t@kdbg.org> <johannes.sixt@telecom.at>
 Johannes Sixt <j6t@kdbg.org> <j.sixt@viscovery.net>
@@ -41,12 +47,21 @@ Junio C Hamano <gitster@pobox.com> <junio@hera.kernel.org>
 Junio C Hamano <gitster@pobox.com> <junio@kernel.org>
 Junio C Hamano <gitster@pobox.com> <junkio@cox.net>
 Karl Hasselström <kha@treskal.com>
+Kevin Leung <kevinlsk@gmail.com>
 Kent Engstrom <kent@lysator.liu.se>
 Lars Doelle <lars.doelle@on-line ! de>
 Lars Doelle <lars.doelle@on-line.de>
 Li Hong <leehong@pku.edu.cn>
+Linus Torvalds <torvalds@linux-foundation.org> <torvalds@woody.linux-foundation.org>
+Linus Torvalds <torvalds@linux-foundation.org> <torvalds@osdl.org>
+Linus Torvalds <torvalds@linux-foundation.org> <torvalds@g5.osdl.org>
+Linus Torvalds <torvalds@linux-foundation.org> <torvalds@evo.osdl.org>
+Linus Torvalds <torvalds@linux-foundation.org> <torvalds@ppc970.osdl.org>
+Linus Torvalds <torvalds@linux-foundation.org> <torvalds@ppc970.osdl.org.(none)>
 Lukas Sandström <lukass@etek.chalmers.se>
-Martin Langhoff <martin@laptop.org>
+Marc-André Lureau <marcandre.lureau@gmail.com>
+Mark Rada <marada@uwaterloo.ca>
+Martin Langhoff <martin@laptop.org> <martin@catalyst.net.nz>
 Martin von Zweigbergk <martinvonz@gmail.com> <martin.von.zweigbergk@gmail.com>
 Michael Coleman <tutufan@gmail.com>
 Michael J Gruber <git@drmicha.warpmail.net> <michaeljgruber+gmane@fastmail.fm>
@@ -63,11 +78,13 @@ Ralf Thielow <ralf.thielow@gmail.com> <ralf.thielow@googlemail.com>
 Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
 René Scharfe <rene.scharfe@lsrfire.ath.cx>
 Robert Fitzsimons <robfitz@273k.net>
+Robert Zeh <robert.a.zeh@gmail.com>
 Sam Vilain <sam@vilain.net>
 Santi Béjar <sbejar@gmail.com>
 Sean Estabrooks <seanlkml@sympatico.ca>
 Shawn O. Pearce <spearce@spearce.org>
 Steven Grimm <koreth@midwinter.com>
+Tay Ray Chuan <rctay89@gmail.com>
 Theodore Ts'o <tytso@mit.edu>
 Thomas Rast <trast@inf.ethz.ch> <trast@student.ethz.ch>
 Tony Luck <tony.luck@intel.com>
index 57da6aadeb8b4d65037035afaa269f391e989c38..69f7e9b76c3f9b87b7951fb0df6a9720edadeb3e 100644 (file)
@@ -112,6 +112,14 @@ For C programs:
 
  - We try to keep to at most 80 characters per line.
 
+ - We try to support a wide range of C compilers to compile git with,
+   including old ones. That means that you should not use C99
+   initializers, even if a lot of compilers grok it.
+
+ - Variables have to be declared at the beginning of the block.
+
+ - NULL pointers shall be written as NULL, not as 0.
+
  - When declaring pointers, the star sides with the variable
    name, i.e. "char *string", not "char* string" or
    "char * string".  This makes it easier to understand code
index 361550422a6e180f5614305985cfd12aa964ffe0..971977b8aa3cfbc97f2f60f1be051d7327c00beb 100644 (file)
@@ -21,6 +21,7 @@ ARTICLES += git-tools
 ARTICLES += git-bisect-lk2009
 # with their own formatting rules.
 SP_ARTICLES = user-manual
+SP_ARTICLES += howto/new-command
 SP_ARTICLES += howto/revert-branch-rebase
 SP_ARTICLES += howto/using-merge-subtree
 SP_ARTICLES += howto/using-signed-tag-in-pull-request
@@ -31,7 +32,6 @@ SP_ARTICLES += howto/separating-topic-branches
 SP_ARTICLES += howto/revert-a-faulty-merge
 SP_ARTICLES += howto/recover-corrupted-blob-object
 SP_ARTICLES += howto/rebuild-from-update-hook
-SP_ARTICLES += howto/rebuild-from-update-hook
 SP_ARTICLES += howto/rebase-from-internal-branch
 SP_ARTICLES += howto/maintain-git
 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
@@ -178,8 +178,6 @@ all: html man
 
 html: $(DOC_HTML)
 
-$(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf
-
 man: man1 man5 man7
 man1: $(DOC_MAN1)
 man5: $(DOC_MAN5)
@@ -257,7 +255,7 @@ clean:
        $(RM) $(cmds_txt) *.made
        $(RM) manpage-base-url.xsl
 
-$(MAN_HTML): %.html : %.txt
+$(MAN_HTML): %.html : %.txt asciidoc.conf
        $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
        $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
                $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
@@ -270,7 +268,7 @@ manpage-base-url.xsl: manpage-base-url.xsl.in
        $(QUIET_XMLTO)$(RM) $@ && \
        $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
 
-%.xml : %.txt
+%.xml : %.txt asciidoc.conf
        $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
        $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
                $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
@@ -286,7 +284,7 @@ technical/api-index.txt: technical/api-index-skel.txt \
        $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
 
 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
-$(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt
+$(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
        $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
                $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
 
@@ -331,7 +329,7 @@ $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
 
 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
        $(QUIET_GEN)$(RM) $@+ $@ && \
-       '$(SHELL_PATH_SQ)' ./howto-index.sh $(wildcard howto/*.txt) >$@+ && \
+       '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
        mv $@+ $@
 
 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
diff --git a/Documentation/RelNotes/1.8.0.3.txt b/Documentation/RelNotes/1.8.0.3.txt
new file mode 100644 (file)
index 0000000..92b1e4b
--- /dev/null
@@ -0,0 +1,14 @@
+Git v1.8.0.3 Release Notes
+==========================
+
+Fixes since v1.8.0.2
+--------------------
+
+ * "git log -p -S<string>" did not apply the textconv filter while
+   looking for the <string>.
+
+ * In the documentation, some invalid example e-mail addresses were
+   formatted into mailto: links.
+
+Also contains many documentation updates backported from the 'master'
+branch that is preparing for the upcoming 1.8.1 release.
diff --git a/Documentation/RelNotes/1.8.1.1.txt b/Documentation/RelNotes/1.8.1.1.txt
new file mode 100644 (file)
index 0000000..6cde07b
--- /dev/null
@@ -0,0 +1,87 @@
+Git 1.8.1.1 Release Notes
+=========================
+
+Fixes since v1.8.1
+------------------
+
+ * The attribute mechanism didn't allow limiting attributes to be
+   applied to only a single directory itself with "path/" like the
+   exclude mechanism does.
+
+ * When attempting to read the XDG-style $HOME/.config/git/config and
+   finding that $HOME/.config/git is a file, we gave a wrong error
+   message, instead of treating the case as "a custom config file does
+   not exist there" and moving on.
+
+ * After failing to create a temporary file using mkstemp(), failing
+   pathname was not reported correctly on some platforms.
+
+ * http transport was wrong to ask for the username when the
+   authentication is done by certificate identity.
+
+ * The behaviour visible to the end users was confusing, when they
+   attempt to kill a process spawned in the editor that was in turn
+   launched by Git with SIGINT (or SIGQUIT), as Git would catch that
+   signal and die.  We ignore these signals now.
+
+ * A child process that was killed by a signal (e.g. SIGINT) was
+   reported in an inconsistent way depending on how the process was
+   spawned by us, with or without a shell in between.
+
+ * After "git add -N" and then writing a tree object out of the
+   index, the cache-tree data structure got corrupted.
+
+ * "git apply" misbehaved when fixing whitespace breakages by removing
+   excess trailing blank lines in some corner cases.
+
+ * A tar archive created by "git archive" recorded a directory in a
+   way that made NetBSD's implementation of "tar" sometimes unhappy.
+
+ * When "git clone --separate-git-dir=$over_there" is interrupted, it
+   failed to remove the real location of the $GIT_DIR it created.
+   This was most visible when interrupting a submodule update.
+
+ * "git fetch --mirror" and fetch that uses other forms of refspec
+   with wildcard used to attempt to update a symbolic ref that match
+   the wildcard on the receiving end, which made little sense (the
+   real ref that is pointed at by the symbolic ref would be updated
+   anyway).  Symbolic refs no longer are affected by such a fetch.
+
+ * The "log --graph" codepath fell into infinite loop in some
+   corner cases.
+
+ * "git merge" started calling prepare-commit-msg hook like "git
+   commit" does some time ago, but forgot to pay attention to the exit
+   status of the hook.
+
+ * "git pack-refs" that ran in parallel to another process that
+   created new refs had a race that can lose new ones.
+
+ * When a line to be wrapped has a solid run of non space characters
+   whose length exactly is the wrap width, "git shortlog -w" failed
+   to add a newline after such a line.
+
+ * The way "git svn" asked for password using SSH_ASKPASS and
+   GIT_ASKPASS was not in line with the rest of the system.
+
+ * "gitweb", when sorting by age to show repositories with new
+   activities first, used to sort repositories with absolutely
+   nothing in it early, which was not very useful.
+
+ * "gitweb", when sorting by age to show repositories with new
+   activities first, used to sort repositories with absolutely
+   nothing in it early, which was not very useful.
+
+ * When autoconf is used, any build on a different commit always ran
+   "config.status --recheck" even when unnecessary.
+
+ * Some scripted programs written in Python did not get updated when
+   PYTHON_PATH changed.
+
+ * We have been carrying a translated and long-unmaintained copy of an
+   old version of the tutorial; removed.
+
+ * Portability issues in many self-test scripts have been addressed.
+
+
+Also contains other minor fixes and documentation updates.
diff --git a/Documentation/RelNotes/1.8.1.2.txt b/Documentation/RelNotes/1.8.1.2.txt
new file mode 100644 (file)
index 0000000..76ad0b3
--- /dev/null
@@ -0,0 +1,13 @@
+Git 1.8.1.2 Release Notes
+=========================
+
+Fixes since v1.8.1.1
+--------------------
+
+ * "git archive" did not record uncompressed size in the header when
+   streaming a zip archive, which confused some implementations of unzip.
+
+ * When users spelled "cc:" in lowercase in the fake "header" in the
+   trailer part, "git send-email" failed to pick up the addresses from
+   there. As e-mail headers field names are case insensitive, this
+   script should follow suit and treat "cc:" and "Cc:" the same way.
index 6aa24c64c00282556df58f6b152de6838b58740d..d6f9555923ae900bd9ff04e8283b513a678c1395 100644 (file)
@@ -29,24 +29,17 @@ UI, Workflows & Features
 
  * Command-line completion scripts for tcsh and zsh have been added.
 
- * A new remote-helper interface for Mercurial has been added to
-   contrib/remote-helpers.
+ * "git-prompt" scriptlet (in contrib/completion) can be told to paint
+   pieces of the hints in the prompt string in colors.
+
+ * Some documentation pages that used to ship only in the plain text
+   format are now formatted in HTML as well.
 
  * We used to have a workaround for a bug in ancient "less" that
    causes it to exit without any output when the terminal is resized.
    The bug has been fixed in "less" version 406 (June 2007), and the
    workaround has been removed in this release.
 
- * Some documentation pages that used to ship only in the plain text
-   format are now formatted in HTML as well.
-
- * "git-prompt" scriptlet (in contrib/completion) can be told to paint
-   pieces of the hints in the prompt string in colors.
-
- * A new configuration variable "diff.context" can be used to
-   give the default number of context lines in the patch output, to
-   override the hardcoded default of 3 lines.
-
  * When "git checkout" checks out a branch, it tells the user how far
    behind (or ahead) the new branch is relative to the remote tracking
    branch it builds upon.  The message now also advises how to sync
@@ -60,13 +53,17 @@ UI, Workflows & Features
    API regression but it is expected that nobody will notice it in
    practice.
 
- * "git log -p -S<string>" now looks for the <string> after applying
-   the textconv filter (if defined); earlier it inspected the contents
-   of the blobs without filtering.
+ * A new configuration variable "diff.context" can be used to
+   give the default number of context lines in the patch output, to
+   override the hardcoded default of 3 lines.
 
  * "git format-patch" learned the "--notes=<ref>" option to give
    notes for the commit after the three-dash lines in its output.
 
+ * "git log -p -S<string>" now looks for the <string> after applying
+   the textconv filter (if defined); earlier it inspected the contents
+   of the blobs without filtering.
+
  * "git log --grep=<pcre>" learned to honor the "grep.patterntype"
    configuration set to "perl".
 
@@ -116,11 +113,20 @@ Foreign Interface
  * The remote helper interface to interact with subversion
    repositories (one of the GSoC 2012 projects) has been merged.
 
+ * A new remote-helper interface for Mercurial has been added to
+   contrib/remote-helpers.
+
+ * The documentation for git(1) was pointing at a page at an external
+   site for the list of authors that no longer existed.  The link has
+   been updated to point at an alternative site.
+
 
 Performance, Internal Implementation, etc.
 
  * Compilation on Cygwin with newer header files are supported now.
 
+ * A couple of low-level implementation updates on MinGW.
+
  * The logic to generate the initial advertisement from "upload-pack"
    (i.e. what is invoked by "git fetch" on the other side of the
    connection) to list what refs are available in the repository has
diff --git a/Documentation/RelNotes/1.8.2.txt b/Documentation/RelNotes/1.8.2.txt
new file mode 100644 (file)
index 0000000..0ae40f3
--- /dev/null
@@ -0,0 +1,296 @@
+Git v1.8.2 Release Notes
+========================
+
+Backward compatibility notes
+----------------------------
+
+In the upcoming major release (tentatively called 1.8.2), we will
+change the behavior of the "git push" command.
+
+When "git push [$there]" does not say what to push, we have used the
+traditional "matching" semantics so far (all your branches were sent
+to the remote as long as there already are branches of the same name
+over there).  We will use the "simple" semantics that pushes the
+current branch to the branch with the same name, only when the current
+branch is set to integrate with that remote branch.  There is a user
+preference configuration variable "push.default" to change this.
+
+
+Updates since v1.8.1
+--------------------
+
+UI, Workflows & Features
+
+ * Initial ports to QNX and z/OS UNIX System Services have started.
+
+ * Output from the tests is coloured using "green is okay, yellow is
+   questionable, red is bad and blue is informative" scheme.
+
+ * In bare repositories, "git shortlog" and other commands now read
+   mailmap files from the tip of the history, to help running these
+   tools in server settings.
+
+ * Color specifiers, e.g. "%C(blue)Hello%C(reset)", used in the
+   "--format=" option of "git log" and friends can be disabled when
+   the output is not sent to a terminal by prefixing them with
+   "auto,", e.g. "%C(auto,blue)Hello%C(auto,reset)".
+
+ * Scripts can ask Git that wildcard patterns in pathspecs they give do
+   not have any significance, i.e. take them as literal strings.
+
+ * The pathspec code learned to grok "foo/**/bar" as a pattern that
+   matches "bar" in 0-or-more levels of subdirectory in "foo".
+
+ * "git blame" (and "git diff") learned the "--no-follow" option.
+
+ * "git cherry-pick" can be used to replay a root commit to an unborn
+   branch.
+
+ * "git commit" can be told to use --cleanup=whitespace by setting the
+   configuration variable commit.cleanup to 'whitespace'.
+
+ * "git fetch --mirror" and fetch that uses other forms of refspec
+   with wildcard used to attempt to update a symbolic ref that match
+   the wildcard on the receiving end, which made little sense (the
+   real ref that is pointed at by the symbolic ref would be updated
+   anyway).  Symbolic refs no longer are affected by such a fetch.
+
+ * "git format-patch" now detects more cases in which a whole branch
+   is being exported, and uses the description for the branch, when
+   asked to write a cover letter for the series.
+
+ * "git format-patch" learned "-v $count" option, and prepends a
+   string "v$count-" to the names of its output files, and also
+   automatically sets the subject prefix to "PATCH v$count". This
+   allows patches from rerolled series to be stored under different
+   names and makes it easier to reuse cover letter messsages.
+
+ * "git log" and friends can be told with --use-mailmap option to
+   rewrite the names and email addresses of people using the mailmap
+   mechanism.
+
+ * "git push" now requires "-f" to update a tag, even if it is a
+   fast-forward, as tags are meant to be fixed points.
+
+ * When "git rebase" fails to generate patches to be applied (e.g. due
+   to oom), it failed to detect the failure and instead behaved as if
+   there were nothing to do.  A workaround to use a temporary file has
+   been applied, but we probably would want to revisit this later, as
+   it hurts the common case of not failing at all.
+
+ * Input and preconditions to "git reset" has been loosened where
+   appropriate.  "git reset $fromtree Makefile" requires $fromtree to
+   be any tree (it used to require it to be a commit), for example.
+   "git reset" (without options or parameters) used to error out when
+   you do not have any commits in your history, but it now gives you
+   an empty index (to match non-existent commit you are not even on).
+
+ * "git submodule" started learning a new mode to integrate with the
+   tip of the remote branch (as opposed to integrating with the commit
+   recorded in the superproject's gitlink).
+
+
+Foreign Interface
+
+ * "git fast-export" has been updated for its use in the context of
+   the remote helper interface.
+
+ * A new remote helper to interact with bzr has been added to contrib/.
+
+ * "git p4" got various bugfixes around its branch handling.
+
+ * The remote helper to interact with Hg in contrib/ has seen a few
+   fixes.
+
+
+Performance, Internal Implementation, etc.
+
+ * "git fsck" has been taught to be pickier about entries in tree
+   objects that should not be there, e.g. ".", ".git", and "..".
+
+ * Matching paths with common forms of pathspecs that contain wildcard
+   characters has been optimized further.
+
+ * "git reset" internals has been reworked and should be faster in
+   general. We tried to be careful not to break any behaviour but
+   there could be corner cases, especially when running the command
+   from a conflicted state, that we may have missed.
+
+ * The implementation of "imap-send" has been updated to reuse xml
+   quoting code from http-push codepath.
+
+ * There is a simple-minded checker for the test scripts in t/
+   directory to catch most common mistakes (it is not enabled by
+   default).
+
+
+Also contains minor documentation updates and code clean-ups.
+
+
+Fixes since v1.8.1
+------------------
+
+Unless otherwise noted, all the fixes since v1.8.1 in the maintenance
+track are contained in this release (see release notes to them for
+details).
+
+ * An element on GIT_CEILING_DIRECTORIES list that does not name the
+   real path to a directory (i.e. a symbolic link) could have caused
+   the GIT_DIR discovery logic to escape the ceiling.
+   (merge 059b379 mh/ceiling later to maint).
+
+ * When attempting to read the XDG-style $HOME/.config/git/config and
+   finding that $HOME/.config/git is a file, we gave a wrong error
+   message, instead of treating the case as "a custom config file does
+   not exist there" and moving on.
+   (merge 8f2bbe4 jn/warn-on-inaccessible-loosen later to maint).
+
+ * The behaviour visible to the end users was confusing, when they
+   attempt to kill a process spawned in the editor that was in turn
+   launched by Git with SIGINT (or SIGQUIT), as Git would catch that
+   signal and die.  We ignore these signals now.
+   (merge 1250857 pf/editor-ignore-sigint later to maint).
+
+ * A child process that was killed by a signal (e.g. SIGINT) was
+   reported in an inconsistent way depending on how the process was
+   spawned by us, with or without a shell in between.
+   (merge 709ca73 jk/unify-exit-code-by-receiving-signal later to maint).
+
+ * After failing to create a temporary file using mkstemp(), failing
+   pathname was not reported correctly on some platforms.
+   (merge f7be59b jc/mkstemp-more-careful-error-reporting later to maint).
+
+ * The attribute mechanism didn't allow limiting attributes to be
+   applied to only a single directory itself with "path/" like the
+   exclude mechanism does.  The initial implementation of this that
+   was merged to 'maint' and 1.8.1.2 was with a severe performance
+   degradations and needs to merge a fix-up topic.
+   (merge 9db9eec nd/fix-directory-attrs-off-by-one later to maint).
+
+ * "git apply" misbehaved when fixing whitespace breakages by removing
+   excess trailing blank lines.
+   (merge 5de7166 jc/apply-trailing-blank-removal later to maint).
+
+ * A tar archive created by "git archive" recorded a directory in a
+   way that made NetBSD's implementation of "tar" sometimes unhappy.
+   (merge 22f0dcd rs/leave-base-name-in-name-field-of-tar later to maint).
+
+ * "git archive" did not record uncompressed size in the header when
+   streaming a zip archive, which confused some implementations of unzip.
+   (merge 5ea2c84 rs/zip-with-uncompressed-size-in-the-header later to maint).
+
+ * "git clean" showed what it was going to do, but sometimes end up
+   finding that it was not allowed to do so, which resulted in a
+   confusing output (e.g. after saying that it will remove an
+   untracked directory, it found an embedded git repository there
+   which it is not allowed to remove).  It now performs the actions
+   and then reports the outcome more faithfully.
+   (merge f538a91 zk/clean-report-failure later to maint).
+
+ * When "git clone --separate-git-dir=$over_there" is interrupted, it
+   failed to remove the real location of the $GIT_DIR it created.
+   This was most visible when interrupting a submodule update.
+   (merge 9be1980 jl/interrupt-clone-remove-separate-git-dir later to maint).
+
+ * The way "git svn" asked for password using SSH_ASKPASS and
+   GIT_ASKPASS was not in line with the rest of the system.
+   (merge e9263e4 ss/svn-prompt later to maint).
+
+ * The --graph code fell into infinite loop when asked to do what the
+   code did not expect.
+   (merge 656197a mk/maint-graph-infinity-loop later to maint).
+
+ * http transport was wrong to ask for the username when the
+   authentication is done by certificate identity.
+   (merge 75e9a40 rb/http-cert-cred-no-username-prompt later to maint).
+
+ * "git pack-refs" that ran in parallel to another process that
+   created new refs had a nasty race.
+   (merge b3f1280 jk/repack-ref-racefix later to maint).
+
+ * After "git add -N" and then writing a tree object out of the
+   index, the cache-tree data structure got corrupted.
+   (merge eec3e7e nd/invalidate-i-t-a-cache-tree later to maint).
+
+ * "git clone" used to allow --bare and --separate-git-dir=$there
+   options at the same time, which was nonsensical.
+   (merge 95b63f1 nd/clone-no-separate-git-dir-with-bare later to maint).
+
+ * "git rebase --preserve-merges" lost empty merges in recent versions
+   of Git.
+   (merge 9869778 ph/rebase-preserve-all-merges later to maint).
+
+ * "git merge --no-edit" computed who were involved in the work done
+   on the side branch, even though that information is to be discarded
+   without getting seen in the editor.
+   (merge 9bcbb1c jc/maint-fmt-merge-msg-no-edit-lose-credit later to maint).
+
+ * "git merge" started calling prepare-commit-msg hook like "git
+   commit" does some time ago, but forgot to pay attention to the exit
+   status of the hook.
+   (merge 3e4141d ap/merge-stop-at-prepare-commit-msg-failure later to maint).
+
+ * When users spell "cc:" in lowercase in the fake "header" in the
+   trailer part, "git send-email" failed to pick up the addresses from
+   there. As e-mail headers field names are case insensitive, this
+   script should follow suit and treat "cc:" and "Cc:" the same way.
+   (merge 6310071 nz/send-email-headers-are-case-insensitive later to maint).
+
+ * Output from "git status --ignored" showed an unexpected interaction
+   with "--untracked".
+   (merge a45fb69 ap/status-ignored-in-ignored-directory later to maint).
+
+ * "gitweb", when sorting by age to show repositories with new
+   activities first, used to sort repositories with absolutely
+   nothing in it early, which was not very useful.
+   (merge 28dae18 md/gitweb-sort-by-age later to maint).
+
+ * "gitweb"'s code to sanitize control characters before passing it to
+   "highlight" filter lost known-to-be-safe control characters by
+   mistake.
+   (merge 0e901d2 os/gitweb-highlight-uncaptured later to maint).
+
+ * When a line to be wrapped has a solid run of non space characters
+   whose length exactly is the wrap width, "git shortlog -w" failed
+   to add a newline after such a line.
+   (merge e0db176 sp/shortlog-missing-lf later to maint).
+
+ * Command line completion leaked an unnecessary error message while
+   looking for possible matches with paths in <tree-ish>.
+   (merge ca87dd6 ds/completion-silence-in-tree-path-probe later to maint).
+
+ * Command line completion for "tcsh" emitted an unwanted space
+   after completing a single directory name.
+   (merge 92f1c04 mk/complete-tcsh later to maint).
+
+ * Some shells do not behave correctly when IFS is unset; work it
+   around by explicitly setting it to the default value.
+   (merge 393050c jc/maint-fbsd-sh-ifs-workaround later to maint).
+
+ * Some scripted programs written in Python did not get updated when
+   PYTHON_PATH changed.
+   (cherry-pick 96a4647fca54031974cd6ad1 later to maint).
+
+ * When autoconf is used, any build on a different commit always ran
+   "config.status --recheck" even when unnecessary.
+   (merge 1226504 jn/less-reconfigure later to maint).
+
+ * We have been carrying a translated and long-unmaintained copy of an
+   old version of the tutorial; removed.
+   (merge 0a85441 ta/remove-stale-translated-tut later to maint).
+
+ * t4014, t9502 and t0200 tests had various portability issues that
+   broke on OpenBSD.
+   (merge 27f6342 jc/maint-test-portability later to maint).
+
+ * t9020 and t3600 tests had various portability issues.
+   (merge 5a02966 jc/test-portability later to maint).
+
+ * t9200 runs "cvs init" on a directory that already exists, but a
+   platform can configure this fail for the current user (e.g. you
+   need to be in the cvsadmin group on NetBSD 6.0).
+   (merge 8666df0 jc/test-cvs-no-init-in-existing-dir later to maint).
+
+ * t9020 and t9810 had a few non-portable shell script construct.
+   (merge 2797914 tb/test-t9020-no-which later to maint).
+   (merge 6f4e505 tb/test-t9810-no-sed-i later to maint).
index 3d8b2fe4d18875f8505b91850dd33ec79b122076..90133d8c3b2ea7ea8af55a2bac0876b10aff8f3e 100644 (file)
@@ -1,65 +1,5 @@
-Checklist (and a short version for the impatient):
-
-       Commits:
-
-       - make commits of logical units
-       - check for unnecessary whitespace with "git diff --check"
-         before committing
-       - do not check in commented out code or unneeded files
-       - the first line of the commit message should be a short
-         description (50 characters is the soft limit, see DISCUSSION
-         in git-commit(1)), and should skip the full stop
-       - the body should provide a meaningful commit message, which:
-         . explains the problem the change tries to solve, iow, what
-           is wrong with the current code without the change.
-         . justifies the way the change solves the problem, iow, why
-           the result with the change is better.
-         . alternate solutions considered but discarded, if any.
-       - describe changes in imperative mood, e.g. "make xyzzy do frotz"
-         instead of "[This patch] makes xyzzy do frotz" or "[I] changed
-         xyzzy to do frotz", as if you are giving orders to the codebase
-         to change its behaviour.
-       - try to make sure your explanation can be understood without
-         external resources. Instead of giving a URL to a mailing list
-         archive, summarize the relevant points of the discussion.
-       - add a "Signed-off-by: Your Name <you@example.com>" line to the
-         commit message (or just use the option "-s" when committing)
-         to confirm that you agree to the Developer's Certificate of Origin
-       - make sure that you have tests for the bug you are fixing
-       - make sure that the test suite passes after your commit
-
-       Patch:
-
-       - use "git format-patch -M" to create the patch
-       - do not PGP sign your patch
-       - do not attach your patch, but read in the mail
-         body, unless you cannot teach your mailer to
-         leave the formatting of the patch alone.
-       - be careful doing cut & paste into your mailer, not to
-         corrupt whitespaces.
-       - provide additional information (which is unsuitable for
-         the commit message) between the "---" and the diffstat
-       - if you change, add, or remove a command line option or
-         make some other user interface change, the associated
-         documentation should be updated as well.
-       - if your name is not writable in ASCII, make sure that
-         you send off a message in the correct encoding.
-       - send the patch to the list (git@vger.kernel.org) and the
-         maintainer (gitster@pobox.com) if (and only if) the patch
-         is ready for inclusion. If you use git-send-email(1),
-         please test it first by sending email to yourself.
-       - see below for instructions specific to your mailer
-
-Long version:
-
-I started reading over the SubmittingPatches document for Linux
-kernel, primarily because I wanted to have a document similar to
-it for the core GIT to make sure people understand what they are
-doing when they write "Signed-off-by" line.
-
-But the patch submission requirements are a lot more relaxed
-here on the technical/contents front, because the core GIT is
-thousand times smaller ;-).  So here is only the relevant bits.
+Here are some guidelines for people who want to contribute their code
+to this software.
 
 (0) Decide what to base your work on.
 
@@ -86,6 +26,10 @@ change is relevant to.
    wait until some of the dependent topics graduate to 'master', and
    rebase your work.
 
+ - Some parts of the system have dedicated maintainers with their own
+   repositories (see the section "Subsystems" below).  Changes to
+   these parts should be based on their trees.
+
 To find the tip of a topic branch, run "git log --first-parent
 master..pu" and look for the merge commit. The second parent of this
 commit is the tip of the topic branch.
@@ -113,26 +57,53 @@ change, the approach taken by the change, and if relevant how this
 differs substantially from the prior version, are all good things
 to have.
 
+Make sure that you have tests for the bug you are fixing.
+
+When adding a new feature, make sure that you have new tests to show
+the feature triggers the new behaviour when it should, and to show the
+feature does not trigger when it shouldn't.  Also make sure that the
+test suite passes after your commit.  Do not forget to update the
+documentation to describe the updated behaviour.
+
 Oh, another thing.  I am picky about whitespaces.  Make sure your
 changes do not trigger errors with the sample pre-commit hook shipped
 in templates/hooks--pre-commit.  To help ensure this does not happen,
 run git diff --check on your changes before you commit.
 
 
-(1a) Try to be nice to older C compilers
+(2) Describe your changes well.
+
+The first line of the commit message should be a short description (50
+characters is the soft limit, see DISCUSSION in git-commit(1)), and
+should skip the full stop.  It is also conventional in most cases to
+prefix the first line with "area: " where the area is a filename or
+identifier for the general area of the code being modified, e.g.
+
+  . archive: ustar header checksum is computed unsigned
+  . git-cherry-pick.txt: clarify the use of revision range notation
+
+If in doubt which identifier to use, run "git log --no-merges" on the
+files you are modifying to see the current conventions.
 
-We try to support a wide range of C compilers to compile
-git with. That means that you should not use C99 initializers, even
-if a lot of compilers grok it.
+The body should provide a meaningful commit message, which:
 
-Also, variables have to be declared at the beginning of the block
-(you can check this with gcc, using the -Wdeclaration-after-statement
-option).
+  . explains the problem the change tries to solve, iow, what is wrong
+    with the current code without the change.
 
-Another thing: NULL pointers shall be written as NULL, not as 0.
+  . justifies the way the change solves the problem, iow, why the
+    result with the change is better.
 
+  . alternate solutions considered but discarded, if any.
 
-(2) Generate your patch using git tools out of your commits.
+Describe your changes in imperative mood, e.g. "make xyzzy do frotz"
+instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy
+to do frotz", as if you are giving orders to the codebase to change
+its behaviour.  Try to make sure your explanation can be understood
+without external resources. Instead of giving a URL to a mailing list
+archive, summarize the relevant points of the discussion.
+
+
+(3) Generate your patch using git tools out of your commits.
 
 git based diff tools generate unidiff which is the preferred format.
 
@@ -140,22 +111,27 @@ You do not have to be afraid to use -M option to "git diff" or
 "git format-patch", if your patch involves file renames.  The
 receiving end can handle them just fine.
 
-Please make sure your patch does not include any extra files
-which do not belong in a patch submission.  Make sure to review
+Please make sure your patch does not add commented out debugging code,
+or include any extra files which do not relate to what your patch
+is trying to achieve. Make sure to review
 your patch after generating it, to ensure accuracy.  Before
 sending out, please make sure it cleanly applies to the "master"
 branch head.  If you are preparing a work based on "next" branch,
 that is fine, but please mark it as such.
 
 
-(3) Sending your patches.
+(4) Sending your patches.
 
 People on the git mailing list need to be able to read and
 comment on the changes you are submitting.  It is important for
 a developer to be able to "quote" your changes, using standard
 e-mail tools, so that they may comment on specific portions of
 your code.  For this reason, all patches should be submitted
-"inline".  WARNING: Be wary of your MUAs word-wrap
+"inline".  If your log message (including your name on the
+Signed-off-by line) is not writable in ASCII, make sure that
+you send off a message in the correct encoding.
+
+WARNING: Be wary of your MUAs word-wrap
 corrupting your patch.  Do not cut-n-paste your patch; you can
 lose tabs that way if you are not careful.
 
@@ -208,19 +184,25 @@ patch, format it as "multipart/signed", not a text/plain message
 that starts with '-----BEGIN PGP SIGNED MESSAGE-----'.  That is
 not a text/plain, it's something else.
 
-Unless your patch is a very trivial and an obviously correct one,
-first send it with "To:" set to the mailing list, with "cc:" listing
+Send your patch with "To:" set to the mailing list, with "cc:" listing
 people who are involved in the area you are touching (the output from
 "git blame $path" and "git shortlog --no-merges $path" would help to
-identify them), to solicit comments and reviews.  After the list
-reached a consensus that it is a good idea to apply the patch, re-send
-it with "To:" set to the maintainer and optionally "cc:" the list for
-inclusion.  Do not forget to add trailers such as "Acked-by:",
-"Reviewed-by:" and "Tested-by:" after your "Signed-off-by:" line as
-necessary.
+identify them), to solicit comments and reviews.
+
+After the list reached a consensus that it is a good idea to apply the
+patch, re-send it with "To:" set to the maintainer [*1*] and "cc:" the
+list [*2*] for inclusion.
+
+Do not forget to add trailers such as "Acked-by:", "Reviewed-by:" and
+"Tested-by:" lines as necessary to credit people who helped your
+patch.
 
+    [Addresses]
+     *1* The current maintainer: gitster@pobox.com
+     *2* The mailing list: git@vger.kernel.org
 
-(4) Sign your work
+
+(5) Sign your work
 
 To improve tracking of who did what, we've borrowed the
 "sign-off" procedure from the Linux kernel project on patches
@@ -290,6 +272,26 @@ If you like, you can put extra tags at the end:
 You can also create your own tag or use one that's in common usage
 such as "Thanks-to:", "Based-on-patch-by:", or "Mentored-by:".
 
+------------------------------------------------
+Subsystems with dedicated maintainers
+
+Some parts of the system have dedicated maintainers with their own
+repositories.
+
+ - git-gui/ comes from git-gui project, maintained by Pat Thoyts:
+
+        git://repo.or.cz/git-gui.git
+
+ - gitk-git/ comes from Paul Mackerras's gitk project:
+
+        git://ozlabs.org/~paulus/gitk
+
+ - po/ comes from the localization coordinator, Jiang Xin:
+
+       https://github.com/git-l10n/git-po/
+
+Patches to these parts should be based on their trees.
+
 ------------------------------------------------
 An ideal patch flow
 
index bf8f911e1ffe7820a8e903ec669c690d39612150..b87f7446436ea73ffeb062317ea9869051d5be78 100644 (file)
@@ -140,10 +140,11 @@ advice.*::
        can tell Git that you do not need help by setting these to 'false':
 +
 --
-       pushNonFastForward::
+       pushUpdateRejected::
                Set this variable to 'false' if you want to disable
-               'pushNonFFCurrent', 'pushNonFFDefault', and
-               'pushNonFFMatching' simultaneously.
+               'pushNonFFCurrent', 'pushNonFFDefault',
+               'pushNonFFMatching', and 'pushAlreadyExists'
+               simultaneously.
        pushNonFFCurrent::
                Advice shown when linkgit:git-push[1] fails due to a
                non-fast-forward update to the current branch.
@@ -158,6 +159,9 @@ advice.*::
                'matching refs' explicitly (i.e. you used ':', or
                specified a refspec that isn't your current branch) and
                it resulted in a non-fast-forward error.
+       pushAlreadyExists::
+               Shown when linkgit:git-push[1] rejects an update that
+               does not qualify for fast-forwarding (e.g., a tag.)
        statusHints::
                Show directions on how to proceed from the current
                state in the output of linkgit:git-status[1], in
@@ -735,6 +739,12 @@ branch.<name>.rebase::
 it unless you understand the implications (see linkgit:git-rebase[1]
 for details).
 
+branch.<name>.description::
+       Branch description, can be edited with
+       `git branch --edit-description`. Branch description is
+       automatically added in the format-patch cover letter or
+       request-pull summary.
+
 browser.<tool>.cmd::
        Specify the command to invoke the specified browser. The
        specified command is evaluated in shell with the URLs passed
@@ -913,6 +923,15 @@ column.tag::
        Specify whether to output tag listing in `git tag` in columns.
        See `column.ui` for details.
 
+commit.cleanup::
+       This setting overrides the default of the `--cleanup` option in
+       `git commit`. See linkgit:git-commit[1] for details. Changing the
+       default can be useful when you always want to keep lines that begin
+       with comment character `#` in your log message, in which case you
+       would do `git config commit.cleanup whitespace` (note that you will
+       have to remove the help lines that begin with `#` in the commit log
+       template yourself, if you do this).
+
 commit.status::
        A boolean to enable/disable inclusion of status information in the
        commit message template when using an editor to prepare the commit
@@ -1351,6 +1370,12 @@ help.autocorrect::
        value is 0 - the command will be just shown but not executed.
        This is the default.
 
+help.htmlpath::
+       Specify the path where the HTML documentation resides. File system paths
+       and URLs are supported. HTML pages will be prefixed with this path when
+       help is displayed in the 'web' format. This defaults to the documentation
+       path of your Git installation.
+
 http.proxy::
        Override the HTTP proxy, normally configured using the 'http_proxy',
        'https_proxy', and 'all_proxy' environment variables (see
@@ -1509,6 +1534,10 @@ log.showroot::
        Tools like linkgit:git-log[1] or linkgit:git-whatchanged[1], which
        normally hide the root commit will now show it. True by default.
 
+log.mailmap::
+       If true, makes linkgit:git-log[1], linkgit:git-show[1], and
+       linkgit:git-whatchanged[1] assume `--use-mailmap`.
+
 mailmap.file::
        The location of an augmenting mailmap file. The default
        mailmap, located in the root of the repository, is loaded
@@ -1517,6 +1546,14 @@ mailmap.file::
        subdirectory, or somewhere outside of the repository itself.
        See linkgit:git-shortlog[1] and linkgit:git-blame[1].
 
+mailmap.blob::
+       Like `mailmap.file`, but consider the value as a reference to a
+       blob in the repository. If both `mailmap.file` and
+       `mailmap.blob` are given, both are parsed, with entries from
+       `mailmap.file` taking precedence. In a bare repository, this
+       defaults to `HEAD:.mailmap`. In a non-bare repository, it
+       defaults to empty.
+
 man.viewer::
        Specify the programs that may be used to display help in the
        'man' format. See linkgit:git-help[1].
@@ -1995,6 +2032,12 @@ submodule.<name>.update::
        URL and other values found in the `.gitmodules` file.  See
        linkgit:git-submodule[1] and linkgit:gitmodules[5] for details.
 
+submodule.<name>.branch::
+       The remote branch name for a submodule, used by `git submodule
+       update --remote`.  Set this option to override the value found in
+       the `.gitmodules` file.  See linkgit:git-submodule[1] and
+       linkgit:gitmodules[5] for details.
+
 submodule.<name>.fetchRecurseSubmodules::
        This option can be used to control recursive fetching of this
        submodule. It can be overridden by using the --[no-]recurse-submodules
index f4f7e250c53c8fc51e17d5643b5b3b93d4036efc..39f2c5074c1ac370976bce36cbceb1a676064cfe 100644 (file)
@@ -309,7 +309,11 @@ endif::git-log[]
        index (i.e. amount of addition/deletions compared to the
        file's size). For example, `-M90%` means git should consider a
        delete/add pair to be a rename if more than 90% of the file
-       hasn't changed.
+       hasn't changed.  Without a `%` sign, the number is to be read as
+       a fraction, with a decimal point before it.  I.e., `-M5` becomes
+       0.5, and is thus the same as `-M50%`.  Similarly, `-M05` is
+       the same as `-M5%`.  To limit detection to exact renames, use
+       `-M100%`.
 
 -C[<n>]::
 --find-copies[=<n>]::
index b4d6476ac898db8ff99ab3639efce08050ef71c4..6e98bdf1490a0a5718dd14a4c2d8b2baaee7383e 100644 (file)
@@ -57,14 +57,11 @@ endif::git-pull[]
 ifndef::git-pull[]
 -t::
 --tags::
-       Most of the tags are fetched automatically as branch
-       heads are downloaded, but tags that do not point at
-       objects reachable from the branch heads that are being
-       tracked will not be fetched by this mechanism.  This
-       flag lets all tags and their associated objects be
-       downloaded. The default behavior for a remote may be
-       specified with the remote.<name>.tagopt setting. See
-       linkgit:git-config[1].
+       This is a short-hand for giving "refs/tags/*:refs/tags/*"
+       refspec from the command line, to ask all tags to be fetched
+       and stored locally.  Because this acts as an explicit
+       refspec, the default refspecs (configured with the
+       remote.$name.fetch variable) are overridden and not used.
 
 --recurse-submodules[=yes|on-demand|no]::
        This option controls if and under what conditions new commits of
index 16a6b0acebc7e15bfae0850d6d6c716fd5a32eaa..bc023cc5f3bb6be8cd664ec6a74743f46b396283 100644 (file)
@@ -112,13 +112,12 @@ machineA$ git bundle create file.bundle master
 machineA$ git tag -f lastR2bundle master
 ----------------
 
-Then you transfer file.bundle to the target machine B. If you are creating
-the repository on machine B, then you can clone from the bundle as if it
-were a remote repository instead of creating an empty repository and then
-pulling or fetching objects from the bundle:
+Then you transfer file.bundle to the target machine B. Because this
+bundle does not require any existing object to be extracted, you can
+create a new repository on machine B by cloning from it:
 
 ----------------
-machineB$ git clone /home/me/tmp/file.bundle R2
+machineB$ git clone -b master /home/me/tmp/file.bundle R2
 ----------------
 
 This will define a remote called "origin" in the resulting repository that
index 7958a4700642270ad3f801e314cf870331cf4512..6f04d22f5e15ea0805fb44c9c856952d759bc050 100644 (file)
@@ -21,18 +21,34 @@ or the specified tree.  If no paths are given, 'git checkout' will
 also update `HEAD` to set the specified branch as the current
 branch.
 
-'git checkout' [<branch>]::
+'git checkout' <branch>::
+       To prepare for working on <branch>, switch to it by updating
+       the index and the files in the working tree, and by pointing
+       HEAD at the branch. Local modifications to the files in the
+       working tree are kept, so that they can be committed to the
+       <branch>.
++
+If <branch> is not found but there does exist a tracking branch in
+exactly one remote (call it <remote>) with a matching name, treat as
+equivalent to
++
+------------
+$ git checkout -b <branch> --track <remote>/<branch>
+------------
++
+You could omit <branch>, in which case the command degenerates to
+"check out the current branch", which is a glorified no-op with a
+rather expensive side-effects to show only the tracking information,
+if exists, for the current branch.
+
 'git checkout' -b|-B <new_branch> [<start point>]::
-'git checkout' [--detach] [<commit>]::
 
-       This form switches branches by updating the index, working
-       tree, and HEAD to reflect the specified branch or commit.
-+
-If `-b` is given, a new branch is created as if linkgit:git-branch[1]
-were called and then checked out; in this case you can
-use the `--track` or `--no-track` options, which will be passed to
-'git branch'.  As a convenience, `--track` without `-b` implies branch
-creation; see the description of `--track` below.
+       Specifying `-b` causes a new branch to be created as if
+       linkgit:git-branch[1] were called and then checked out.  In
+       this case you can use the `--track` or `--no-track` options,
+       which will be passed to 'git branch'.  As a convenience,
+       `--track` without `-b` implies branch creation; see the
+       description of `--track` below.
 +
 If `-B` is given, <new_branch> is created if it doesn't exist; otherwise, it
 is reset. This is the transactional equivalent of
@@ -45,6 +61,21 @@ $ git checkout <branch>
 that is to say, the branch is not reset/created unless "git checkout" is
 successful.
 
+'git checkout' --detach [<branch>]::
+'git checkout' <commit>::
+
+       Prepare to work on top of <commit>, by detaching HEAD at it
+       (see "DETACHED HEAD" section), and updating the index and the
+       files in the working tree.  Local modifications to the files
+       in the working tree are kept, so that the resulting working
+       tree will be the state recorded in the commit plus the local
+       modifications.
++
+Passing `--detach` forces this behavior in the case of a <branch> (without
+the option, giving a branch name to the command would check out the branch,
+instead of detaching HEAD at it), or the current commit,
+if no <branch> is specified.
+
 'git checkout' [-p|--patch] [<tree-ish>] [--] <pathspec>...::
 
        When <paths> or `--patch` are given, 'git checkout' does *not*
index 6d5a04c83b6461396b44b3972a539eaae6368a19..a22116951527e4181d85ed23acb029f6920ee1ff 100644 (file)
@@ -72,13 +72,13 @@ if set:
        GIT_COMMITTER_NAME
        GIT_COMMITTER_EMAIL
        GIT_COMMITTER_DATE
-       EMAIL
 
 (nb "<", ">" and "\n"s are stripped)
 
 In case (some of) these environment variables are not set, the information
 is taken from the configuration items user.name and user.email, or, if not
-present, system user name and the hostname used for outgoing mail (taken
+present, the environment variable EMAIL, or, if that is not set,
+system user name and the hostname used for outgoing mail (taken
 from `/etc/mailname` and falling back to the fully qualified hostname when
 that file does not exist).
 
index 7bdb039d5ee9c6ed6c19c70173c733860de2d5b7..41b27da325053a9a817160364ac50e5140f5891c 100644 (file)
@@ -179,7 +179,9 @@ OPTIONS
        only if the message is to be edited. Otherwise only whitespace
        removed. The 'verbatim' mode does not change message at all,
        'whitespace' removes just leading/trailing whitespace lines
-       and 'strip' removes both whitespace and commentary.
+       and 'strip' removes both whitespace and commentary. The default
+       can be changed by the 'commit.cleanup' configuration variable
+       (see linkgit:git-config[1]).
 
 -e::
 --edit::
index eaea0791657386469e448def614b949c0a1f45e9..9ae2508f3fb79b9da5fb4481a4fe2120f4a082b1 100644 (file)
@@ -240,6 +240,10 @@ GIT_CONFIG::
        Using the "--global" option forces this to ~/.gitconfig. Using the
        "--system" option forces this to $(prefix)/etc/gitconfig.
 
+GIT_CONFIG_NOSYSTEM::
+       Whether to skip reading settings from the system-wide
+       $(prefix)/etc/gitconfig file. See linkgit:git[1] for details.
+
 See also <<FILES>>.
 
 
index 98d9881d7e891e4728c09f6536c3506b3688d145..9d5353e8be4a56cb92c1987e40a3695b23733d56 100644 (file)
@@ -213,11 +213,9 @@ Problems related to tags:
 * Multiple tags on the same revision are not imported.
 
 If you suspect that any of these issues may apply to the repository you
-want to import consider using these alternative tools which proved to be
-more stable in practice:
+want to imort, consider using cvs2git:
 
-* cvs2git (part of cvs2svn), `http://cvs2svn.tigris.org`
-* parsecvs, `http://cgit.freedesktop.org/~keithp/parsecvs`
+* cvs2git (part of cvs2svn), `http://subversion.apache.org/`
 
 GIT
 ---
index 88d814af0e050eb3b31f5763cbf12f03a5f6cbc3..940c2ba66a6a92ed8680973e6981c34a7d599309 100644 (file)
@@ -359,6 +359,43 @@ Operations supported
 
 All the operations required for normal use are supported, including
 checkout, diff, status, update, log, add, remove, commit.
+
+Most CVS command arguments that read CVS tags or revision numbers
+(typically -r) work, and also support any git refspec
+(tag, branch, commit ID, etc).
+However, CVS revision numbers for non-default branches are not well
+emulated, and cvs log does not show tags or branches at
+all.  (Non-main-branch CVS revision numbers superficially resemble CVS
+revision numbers, but they actually encode a git commit ID directly,
+rather than represent the number of revisions since the branch point.)
+
+Note that there are two ways to checkout a particular branch.
+As described elsewhere on this page, the "module" parameter
+of cvs checkout is interpreted as a branch name, and it becomes
+the main branch.  It remains the main branch for a given sandbox
+even if you temporarily make another branch sticky with
+cvs update -r.  Alternatively, the -r argument can indicate
+some other branch to actually checkout, even though the module
+is still the "main" branch.  Tradeoffs (as currently
+implemented): Each new "module" creates a new database on disk with
+a history for the given module, and after the database is created,
+operations against that main branch are fast.  Or alternatively,
+-r doesn't take any extra disk space, but may be significantly slower for
+many operations, like cvs update.
+
+If you want to refer to a git refspec that has characters that are
+not allowed by CVS, you have two options.  First, it may just work
+to supply the git refspec directly to the appropriate CVS -r argument;
+some CVS clients don't seem to do much sanity checking of the argument.
+Second, if that fails, you can use a special character escape mechanism
+that only uses characters that are valid in CVS tags.  A sequence
+of 4 or 5 characters of the form (underscore (`"_"`), dash (`"-"`),
+one or two characters, and dash (`"-"`)) can encode various characters based
+on the one or two letters: `"s"` for slash (`"/"`), `"p"` for
+period (`"."`), `"u"` for underscore (`"_"`), or two hexadecimal digits
+for any byte value at all (typically an ASCII number, or perhaps a part
+of a UTF-8 encoded character).
+
 Legacy monitoring operations are not supported (edit, watch and related).
 Exports and tagging (tags and branches) are not supported at this stage.
 
index f8d0819113c52ac7c6388ec27eb96083a8c86d4a..f8c06013f3588a96e66d08265afe8131f054b7ff 100644 (file)
@@ -12,6 +12,7 @@ SYNOPSIS
 'git diff' [options] [<commit>] [--] [<path>...]
 'git diff' [options] --cached [<commit>] [--] [<path>...]
 'git diff' [options] <commit> <commit> [--] [<path>...]
+'git diff' [options] <blob> <blob>
 'git diff' [options] [--no-index] [--] <path> <path>
 
 DESCRIPTION
@@ -55,6 +56,11 @@ directories. This behavior can be forced by --no-index.
        This is to view the changes between two arbitrary
        <commit>.
 
+'git diff' [options] <blob> <blob>::
+
+       This form is to view the differences between the raw
+       contents of two blob objects.
+
 'git diff' [--options] <commit>..<commit> [--] [<path>...]::
 
        This is synonymous to the previous form.  If <commit> on
@@ -72,8 +78,7 @@ directories. This behavior can be forced by --no-index.
 Just in case if you are doing something exotic, it should be
 noted that all of the <commit> in the above description, except
 in the last two forms that use ".." notations, can be any
-<tree>.  The third form ('git diff <commit> <commit>') can also
-be used to compare two <blob> objects.
+<tree>.
 
 For a more complete list of ways to spell <commit>, see
 "SPECIFYING REVISIONS" section in linkgit:gitrevisions[7].
index d1844ead4a4883cc31447c20763b61091f66ed8e..bf1a02a80d5f4a61f5bbd0d826ae7df3bce58911 100644 (file)
@@ -33,38 +33,46 @@ the frontend program in use.
 
 OPTIONS
 -------
---date-format=<fmt>::
-       Specify the type of dates the frontend will supply to
-       fast-import within `author`, `committer` and `tagger` commands.
-       See ``Date Formats'' below for details about which formats
-       are supported, and their syntax.
-
--- done::
-       Terminate with error if there is no 'done' command at the
-       end of the stream.
 
 --force::
        Force updating modified existing branches, even if doing
        so would cause commits to be lost (as the new commit does
        not contain the old commit).
 
---max-pack-size=<n>::
-       Maximum size of each output packfile.
-       The default is unlimited.
+--quiet::
+       Disable all non-fatal output, making fast-import silent when it
+       is successful.  This option disables the output shown by
+       \--stats.
 
---big-file-threshold=<n>::
-       Maximum size of a blob that fast-import will attempt to
-       create a delta for, expressed in bytes.  The default is 512m
-       (512 MiB).  Some importers may wish to lower this on systems
-       with constrained memory.
+--stats::
+       Display some basic statistics about the objects fast-import has
+       created, the packfiles they were stored into, and the
+       memory used by fast-import during this run.  Showing this output
+       is currently the default, but can be disabled with \--quiet.
 
---depth=<n>::
-       Maximum delta depth, for blob and tree deltification.
-       Default is 10.
+Options for Frontends
+~~~~~~~~~~~~~~~~~~~~~
 
---active-branches=<n>::
-       Maximum number of branches to maintain active at once.
-       See ``Memory Utilization'' below for details.  Default is 5.
+--cat-blob-fd=<fd>::
+       Write responses to `cat-blob` and `ls` queries to the
+       file descriptor <fd> instead of `stdout`.  Allows `progress`
+       output intended for the end-user to be separated from other
+       output.
+
+--date-format=<fmt>::
+       Specify the type of dates the frontend will supply to
+       fast-import within `author`, `committer` and `tagger` commands.
+       See ``Date Formats'' below for details about which formats
+       are supported, and their syntax.
+
+--done::
+       Terminate with error if there is no `done` command at the end of
+       the stream.  This option might be useful for detecting errors
+       that cause the frontend to terminate before it has started to
+       write a stream.
+
+Locations of Marks Files
+~~~~~~~~~~~~~~~~~~~~~~~~
 
 --export-marks=<file>::
        Dumps the internal marks table to <file> when complete.
@@ -87,31 +95,33 @@ OPTIONS
        Like --import-marks but instead of erroring out, silently
        skips the file if it does not exist.
 
---relative-marks::
+--[no-]relative-marks::
        After specifying --relative-marks the paths specified
        with --import-marks= and --export-marks= are relative
        to an internal directory in the current repository.
        In git-fast-import this means that the paths are relative
        to the .git/info/fast-import directory. However, other
        importers may use a different location.
++
+Relative and non-relative marks may be combined by interweaving
+--(no-)-relative-marks with the --(import|export)-marks= options.
 
---no-relative-marks::
-       Negates a previous --relative-marks. Allows for combining
-       relative and non-relative marks by interweaving
-       --(no-)-relative-marks with the --(import|export)-marks=
-       options.
+Performance and Compression Tuning
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
---cat-blob-fd=<fd>::
-       Write responses to `cat-blob` and `ls` queries to the
-       file descriptor <fd> instead of `stdout`.  Allows `progress`
-       output intended for the end-user to be separated from other
-       output.
+--active-branches=<n>::
+       Maximum number of branches to maintain active at once.
+       See ``Memory Utilization'' below for details.  Default is 5.
 
---done::
-       Require a `done` command at the end of the stream.
-       This option might be useful for detecting errors that
-       cause the frontend to terminate before it has started to
-       write a stream.
+--big-file-threshold=<n>::
+       Maximum size of a blob that fast-import will attempt to
+       create a delta for, expressed in bytes.  The default is 512m
+       (512 MiB).  Some importers may wish to lower this on systems
+       with constrained memory.
+
+--depth=<n>::
+       Maximum delta depth, for blob and tree deltification.
+       Default is 10.
 
 --export-pack-edges=<file>::
        After creating a packfile, print a line of data to
@@ -122,16 +132,9 @@ OPTIONS
        as these commits can be used as edge points during calls
        to 'git pack-objects'.
 
---quiet::
-       Disable all non-fatal output, making fast-import silent when it
-       is successful.  This option disables the output shown by
-       \--stats.
-
---stats::
-       Display some basic statistics about the objects fast-import has
-       created, the packfiles they were stored into, and the
-       memory used by fast-import during this run.  Showing this output
-       is currently the default, but can be disabled with \--quiet.
+--max-pack-size=<n>::
+       Maximum size of each output packfile.
+       The default is unlimited.
 
 
 Performance
@@ -427,7 +430,7 @@ they made it.
 
 Here `<name>` is the person's display name (for example
 ``Com M Itter'') and `<email>` is the person's email address
-(``cm@example.com'').  `LT` and `GT` are the literal less-than (\x3c)
+(``\cm@example.com'').  `LT` and `GT` are the literal less-than (\x3c)
 and greater-than (\x3e) symbols.  These are required to delimit
 the email address from the other fields in the line.  Note that
 `<name>` and `<email>` are free-form and may contain any sequence
index db55a4e0bbc524c20f08e6862daaa97dd1785b71..f2e08d11c19cf127c5f7d484b0c3d66fc475d547 100644 (file)
@@ -117,7 +117,7 @@ returns an empty string instead.
 
 As a special case for the date-type fields, you may specify a format for
 the date by adding one of `:default`, `:relative`, `:short`, `:local`,
-`:iso8601` or `:rfc2822` to the end of the fieldname; e.g.
+`:iso8601`, `:rfc2822` or `:raw` to the end of the fieldname; e.g.
 `%(taggerdate:relative)`.
 
 
index 259dce49945089de03ad2c0ac8ae8e56cfdc04e0..9a914d01597011d6703e6b560d707c221cba177e 100644 (file)
@@ -18,7 +18,7 @@ SYNOPSIS
                   [--start-number <n>] [--numbered-files]
                   [--in-reply-to=Message-Id] [--suffix=.<sfx>]
                   [--ignore-if-in-upstream]
-                  [--subject-prefix=Subject-Prefix]
+                  [--subject-prefix=Subject-Prefix] [(--reroll-count|-v) <n>]
                   [--to=<email>] [--cc=<email>]
                   [--cover-letter] [--quiet] [--notes[=<ref>]]
                   [<common diff options>]
@@ -166,6 +166,15 @@ will want to ensure that threading is disabled for `git send-email`.
        allows for useful naming of a patch series, and can be
        combined with the `--numbered` option.
 
+-v <n>::
+--reroll-count=<n>::
+       Mark the series as the <n>-th iteration of the topic. The
+       output filenames have `v<n>` pretended to them, and the
+       subject prefix ("PATCH" by default, but configurable via the
+       `--subject-prefix` option) has ` v<n>` appended to it.  E.g.
+       `--reroll-count=4` may produce `v4-0001-add-makefile.patch`
+       file that has "Subject: [PATCH v4 1/20] Add makefile" in it.
+
 --to=<email>::
        Add a `To:` header to the email headers. This is in addition
        to any configured headers, and may be used multiple times.
index 585dac40baabbee291f43a6e7c59c36340286e43..22c0d6e4b1074b71468ac1c9b16d7eeb0434e225 100644 (file)
@@ -47,6 +47,11 @@ OPTIONS
        Print out the ref name given on the command line by which each
        commit was reached.
 
+--use-mailmap::
+       Use mailmap file to map author and committer names and email
+       to canonical real names and email addresses. See
+       linkgit:git-shortlog[1].
+
 --full-diff::
        Without this flag, "git log -p <path>..." shows commits that
        touch the specified paths, and diffs about the same specified
@@ -167,7 +172,7 @@ log.showroot::
        `git log -p` output would be shown without a diff attached.
        The default is `true`.
 
-mailmap.file::
+mailmap.*::
        See linkgit:git-shortlog[1].
 
 notes.displayRef::
index beff6229c8cc4541ca3a8ddd0faf724fceb439e7..f70ef9ded2c7e476c60a90f15ef45e650c663bde 100644 (file)
@@ -112,6 +112,11 @@ will be fetched and consulted first during a 'git p4 sync'.  Since
 importing directly from p4 is considerably slower than pulling changes
 from a git remote, this can be useful in a multi-developer environment.
 
+If there are multiple branches, doing 'git p4 sync' will automatically
+use the "BRANCH DETECTION" algorithm to try to partition new changes
+into the right branch.  This can be overridden with the '--branch'
+option to specify just a single branch to update.
+
 
 Rebase
 ~~~~~~
@@ -173,9 +178,11 @@ subsequent 'sync' operations.
 
 --branch <branch>::
        Import changes into given branch.  If the branch starts with
-       'refs/', it will be used as is, otherwise the path 'refs/heads/'
-       will be prepended.  The default branch is 'master'.  If used
-       with an initial clone, no HEAD will be checked out.
+       'refs/', it will be used as is.  Otherwise if it does not start
+       with 'p4/', that prefix is added.  The branch is assumed to
+       name a remote tracking, but this can be modified using
+       '--import-local', or by giving a full ref name.  The default
+       branch is 'master'.
 +
 This example imports a new remote "p4/proj2" into an existing
 git repository:
@@ -287,6 +294,11 @@ These options can be used to modify 'git p4 submit' behavior.
        to bypass the prompt, causing conflicting commits to be automatically
        skipped, or to quit trying to apply commits, without prompting.
 
+--branch <branch>::
+       After submitting, sync this named branch instead of the default
+       p4/master.  See the "Sync options" section above for more
+       information.
+
 Rebase options
 ~~~~~~~~~~~~~~
 These options can be used to modify 'git p4 rebase' behavior.
@@ -394,8 +406,10 @@ the path elements in the p4 repository.  The example above relied on the
 presence of the p4 branch.  Without p4 branches, the same result will
 occur with:
 ----
+git init depot
+cd depot
 git config git-p4.branchList main:branch1
-git p4 clone --detect-branches //depot@all
+git p4 clone --detect-branches //depot@all .
 ----
 
 
index 8b637d339f522e9dd6f3310efdc0691c5bcb14bf..c964b796be742f01aa974ee4d770891b6a65b2cb 100644 (file)
@@ -51,10 +51,11 @@ be named. If `:`<dst> is omitted, the same ref as <src> will be
 updated.
 +
 The object referenced by <src> is used to update the <dst> reference
-on the remote side, but by default this is only allowed if the
-update can fast-forward <dst>.  By having the optional leading `+`,
-you can tell git to update the <dst> ref even when the update is not a
-fast-forward.  This does *not* attempt to merge <src> into <dst>.  See
+on the remote side.  By default this is only allowed if <dst> is not
+a tag (annotated or lightweight), and then only if it can fast-forward
+<dst>.  By having the optional leading `+`, you can tell git to update
+the <dst> ref even if it is not allowed by default (e.g., it is not a
+fast-forward.)  This does *not* attempt to merge <src> into <dst>.  See
 EXAMPLES below for details.
 +
 `tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.
index 2a67d456a3d2e278d924e792760dfd90f77a680c..612a625ced88919b106c28b79b8d6598f5c5e57c 100644 (file)
@@ -19,7 +19,7 @@ testcase for the remote-helper functionality, and as an example to
 show remote-helper authors one possible implementation.
 
 The best way to learn more is to read the comments and source code in
-'git-remote-testgit.py'.
+'git-remote-testgit'.
 
 SEE ALSO
 --------
index 978d8da50c150a695565958d89daade5434ce8e0..a404b47b7bf80ef85e5f34595044090b7025f32c 100644 (file)
@@ -8,20 +8,20 @@ git-reset - Reset current HEAD to the specified state
 SYNOPSIS
 --------
 [verse]
-'git reset' [-q] [<commit>] [--] <paths>...
-'git reset' (--patch | -p) [<commit>] [--] [<paths>...]
+'git reset' [-q] [<tree-ish>] [--] <paths>...
+'git reset' (--patch | -p) [<tree-sh>] [--] [<paths>...]
 'git reset' [--soft | --mixed | --hard | --merge | --keep] [-q] [<commit>]
 
 DESCRIPTION
 -----------
-In the first and second form, copy entries from <commit> to the index.
+In the first and second form, copy entries from <tree-ish> to the index.
 In the third form, set the current branch head (HEAD) to <commit>, optionally
-modifying index and working tree to match.  The <commit> defaults to HEAD
-in all forms.
+modifying index and working tree to match.  The <tree-ish>/<commit> defaults
+to HEAD in all forms.
 
-'git reset' [-q] [<commit>] [--] <paths>...::
+'git reset' [-q] [<tree-ish>] [--] <paths>...::
        This form resets the index entries for all <paths> to their
-       state at <commit>.  (It does not affect the working tree, nor
+       state at <tree-ish>.  (It does not affect the working tree, nor
        the current branch.)
 +
 This means that `git reset <paths>` is the opposite of `git add
@@ -34,9 +34,9 @@ Alternatively, using linkgit:git-checkout[1] and specifying a commit, you
 can copy the contents of a path out of a commit to the index and to the
 working tree in one go.
 
-'git reset' (--patch | -p) [<commit>] [--] [<paths>...]::
+'git reset' (--patch | -p) [<tree-ish>] [--] [<paths>...]::
        Interactively select hunks in the difference between the index
-       and <commit> (defaults to HEAD).  The chosen hunks are applied
+       and <tree-ish> (defaults to HEAD).  The chosen hunks are applied
        in reverse to the index.
 +
 This means that `git reset -p` is the opposite of `git add -p`, i.e.
index afeb4cdf16df91f63197d390fdbf1540eff66837..c308e91537a02817560d3108be5517d1806b0c9e 100644 (file)
@@ -56,6 +56,9 @@ OPTIONS
        line of each entry is indented by `indent1` spaces, and the second
        and subsequent lines are indented by `indent2` spaces. `width`,
        `indent1`, and `indent2` default to 76, 6 and 9 respectively.
++
+If width is `0` (zero) then indent the lines of the output without wrapping
+them.
 
 
 MAPPING AUTHORS
index b1de3bade751f34b9629e3d4c0d8f654fca86a91..b1996f1a6311f99e2d583a1ad6cb839dd4efc7aa 100644 (file)
@@ -13,7 +13,7 @@ SYNOPSIS
              [--reference <repository>] [--] <repository> [<path>]
 'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
 'git submodule' [--quiet] init [--] [<path>...]
-'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase]
+'git submodule' [--quiet] update [--init] [--remote] [-N|--no-fetch] [--rebase]
              [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
 'git submodule' [--quiet] summary [--cached|--files] [(-n|--summary-limit) <n>]
              [commit] [--] [<path>...]
@@ -208,6 +208,8 @@ OPTIONS
 -b::
 --branch::
        Branch of repository to add as submodule.
+       The name of the branch is recorded as `submodule.<path>.branch` in
+       `.gitmodules` for `update --remote`.
 
 -f::
 --force::
@@ -236,6 +238,27 @@ OPTIONS
        (the default). This limit only applies to modified submodules. The
        size is always limited to 1 for added/deleted/typechanged submodules.
 
+--remote::
+       This option is only valid for the update command.  Instead of using
+       the superproject's recorded SHA-1 to update the submodule, use the
+       status of the submodule's remote tracking branch.  The remote used
+       is branch's remote (`branch.<name>.remote`), defaulting to `origin`.
+       The remote branch used defaults to `master`, but the branch name may
+       be overridden by setting the `submodule.<name>.branch` option in
+       either `.gitmodules` or `.git/config` (with `.git/config` taking
+       precedence).
++
+This works for any of the supported update procedures (`--checkout`,
+`--rebase`, etc.).  The only change is the source of the target SHA-1.
+For example, `submodule update --remote --merge` will merge upstream
+submodule changes into the submodules, while `submodule update
+--merge` will merge superproject gitlink changes into the submodules.
++
+In order to ensure a current tracking branch state, `update --remote`
+fetches the submodule's remote repository before calculating the
+SHA-1.  If you don't want to fetch, you should use `submodule update
+--remote --no-fetch`.
+
 -N::
 --no-fetch::
        This option is only valid for the update command.
index 8b0d3adfede9ebffbddc294d6f30eedea0e2dfa0..34d438b0abd583ca8b2e2156a085e322e8f827eb 100644 (file)
@@ -346,6 +346,16 @@ Any other arguments are passed directly to 'git log'
        corresponding git commit hash (this can optionally be followed by a
        tree-ish to specify which branch should be searched).  When given a
        tree-ish, returns the corresponding SVN revision number.
++
+--before;;
+       Don't require an exact match if given an SVN revision, instead find
+       the commit corresponding to the state of the SVN repository (on the
+       current branch) at the specified revision.
++
+--after;;
+       Don't require an exact match if given an SVN revision; if there is
+       not an exact match return the closest match searching forward in the
+       history.
 
 'set-tree'::
        You should consider using 'dcommit' instead of this command.
@@ -628,10 +638,19 @@ ADVANCED OPTIONS
        Default: "svn"
 
 --follow-parent::
+       This option is only relevant if we are tracking branches (using
+       one of the repository layout options --trunk, --tags,
+       --branches, --stdlayout). For each tracked branch, try to find
+       out where its revision was copied from, and set
+       a suitable parent in the first git commit for the branch.
        This is especially helpful when we're tracking a directory
-       that has been moved around within the repository, or if we
-       started tracking a branch and never tracked the trunk it was
-       descended from. This feature is enabled by default, use
+       that has been moved around within the repository.  If this
+       feature is disabled, the branches created by 'git svn' will all
+       be linear and not share any history, meaning that there will be
+       no information on where branches were branched off or merged.
+       However, following long/convoluted histories can take a long
+       time, so disabling this feature may speed up the cloning
+       process. This feature is enabled by default, use
        --no-follow-parent to disable it.
 +
 [verse]
@@ -739,7 +758,8 @@ for rewriteRoot and rewriteUUID which can be used together.
 BASIC EXAMPLES
 --------------
 
-Tracking and contributing to the trunk of a Subversion-managed project:
+Tracking and contributing to the trunk of a Subversion-managed project
+(ignoring tags and branches):
 
 ------------------------------------------------------------------------
 # Clone a repo (like git clone):
@@ -764,8 +784,10 @@ Tracking and contributing to an entire Subversion-managed project
 (complete with a trunk, tags and branches):
 
 ------------------------------------------------------------------------
-# Clone a repo (like git clone):
-       git svn clone http://svn.example.com/project -T trunk -b branches -t tags
+# Clone a repo with standard SVN directory layout (like git clone):
+       git svn clone http://svn.example.com/project --stdlayout
+# Or, if the repo uses a non-standard directory layout:
+       git svn clone http://svn.example.com/project -T tr -b branch -t tag
 # View all branches and tags you have cloned:
        git branch -r
 # Create a new branch in SVN
@@ -830,6 +852,52 @@ inside git back upstream to SVN users.  Therefore it is advised that
 users keep history as linear as possible inside git to ease
 compatibility with SVN (see the CAVEATS section below).
 
+HANDLING OF SVN BRANCHES
+------------------------
+If 'git svn' is configured to fetch branches (and --follow-branches
+is in effect), it sometimes creates multiple git branches for one
+SVN branch, where the addtional branches have names of the form
+'branchname@nnn' (with nnn an SVN revision number).  These additional
+branches are created if 'git svn' cannot find a parent commit for the
+first commit in an SVN branch, to connect the branch to the history of
+the other branches.
+
+Normally, the first commit in an SVN branch consists
+of a copy operation. 'git svn' will read this commit to get the SVN
+revision the branch was created from. It will then try to find the
+git commit that corresponds to this SVN revision, and use that as the
+parent of the branch. However, it is possible that there is no suitable
+git commit to serve as parent.  This will happen, among other reasons,
+if the SVN branch is a copy of a revision that was not fetched by 'git
+svn' (e.g. because it is an old revision that was skipped with
+'--revision'), or if in SVN a directory was copied that is not tracked
+by 'git svn' (such as a branch that is not tracked at all, or a
+subdirectory of a tracked branch). In these cases, 'git svn' will still
+create a git branch, but instead of using an existing git commit as the
+parent of the branch, it will read the SVN history of the directory the
+branch was copied from and create appropriate git commits.  This is
+indicated by the message "Initializing parent: <branchname>".
+
+Additionally, it will create a special branch named
+'<branchname>@<SVN-Revision>', where <SVN-Revision> is the SVN revision
+number the branch was copied from.  This branch will point to the newly
+created parent commit of the branch.  If in SVN the branch was deleted
+and later recreated from a different version, there will be multiple
+such branches with an '@'.
+
+Note that this may mean that multiple git commits are created for a
+single SVN revision.
+
+An example: in an SVN repository with a standard
+trunk/tags/branches layout, a directory trunk/sub is created in r.100.
+In r.200, trunk/sub is branched by copying it to branches/. 'git svn
+clone -s' will then create a branch 'sub'. It will also create new git
+commits for r.100 through r.199 and use these as the history of branch
+'sub'. Thus there will be two git commits for each revision from r.100
+to r.199 (one containing trunk/, one containing trunk/sub/). Finally,
+it will create a branch 'sub@200' pointing to the new parent commit of
+branch 'sub' (i.e. the commit for r.200 and trunk/sub/).
+
 CAVEATS
 -------
 
@@ -871,6 +939,21 @@ already dcommitted.  It is considered bad practice to --amend commits
 you've already pushed to a remote repository for other users, and
 dcommit with SVN is analogous to that.
 
+When cloning an SVN repository, if none of the options for describing
+the repository layout is used (--trunk, --tags, --branches,
+--stdlayout), 'git svn clone' will create a git repository with
+completely linear history, where branches and tags appear as separate
+directories in the working copy.  While this is the easiest way to get a
+copy of a complete repository, for projects with many branches it will
+lead to a working copy many times larger than just the trunk. Thus for
+projects using the standard directory structure (trunk/branches/tags),
+it is recommended to clone with option '--stdlayout'. If the project
+uses a non-standard structure, and/or if branches and tags are not
+required, it is easiest to only clone one directory (typically trunk),
+without giving any repository layout options.  If the full history with
+branches and tags is required, the options '--trunk' / '--branches' /
+'--tags' must be used.
+
 When using multiple --branches or --tags, 'git svn' does not automatically
 handle name collisions (for example, if two branches from different paths have
 the same name, or if a branch and a tag have the same name).  In these cases,
@@ -894,6 +977,12 @@ the possible corner cases (git doesn't do it, either).  Committing
 renamed and copied files is fully supported if they're similar enough
 for git to detect them.
 
+In SVN, it is possible (though discouraged) to commit changes to a tag
+(because a tag is just a directory copy, thus technically the same as a
+branch). When cloning an SVN repository, 'git svn' cannot know if such a
+commit to a tag will happen in the future. Thus it acts conservatively
+and imports all SVN tags as branches, prefixing the tag name with 'tags/'.
+
 CONFIGURATION
 -------------
 
index 247534e908d9f5b804a60b6707d1962eccc9bb1a..6470cffd325f919d8daa6ddb2ef70cf79334c30f 100644 (file)
@@ -129,7 +129,7 @@ This option is only applicable when listing tags without annotation lines.
 CONFIGURATION
 -------------
 By default, 'git tag' in sign-with-default mode (-s) will use your
-committer identity (of the form "Your Name <your@email.address>") to
+committer identity (of the form "Your Name <\your@email.address>") to
 find a key.  If you want to use a different default key, you can specify
 it in the repository configuration as follows:
 
index 1d797f27ed7682cf7308949b99d4bc27f9767f1a..555250dfa0272f890b6d427ff61b4ea42ba0b814 100644 (file)
@@ -43,9 +43,16 @@ unreleased) version of git, that is available from 'master'
 branch of the `git.git` repository.
 Documentation for older releases are available here:
 
-* link:v1.8.0.2/git.html[documentation for release 1.8.0.2]
+* link:v1.8.1.1/git.html[documentation for release 1.8.1.1]
 
 * release notes for
+  link:RelNotes/1.8.1.1.txt[1.8.1.1],
+  link:RelNotes/1.8.1.txt[1.8.1].
+
+* link:v1.8.0.3/git.html[documentation for release 1.8.0.3]
+
+* release notes for
+  link:RelNotes/1.8.0.3.txt[1.8.0.3],
   link:RelNotes/1.8.0.2.txt[1.8.0.2],
   link:RelNotes/1.8.0.1.txt[1.8.0.1],
   link:RelNotes/1.8.0.txt[1.8.0].
@@ -422,6 +429,11 @@ help ...`.
        Do not use replacement refs to replace git objects. See
        linkgit:git-replace[1] for more information.
 
+--literal-pathspecs::
+       Treat pathspecs literally, rather than as glob patterns. This is
+       equivalent to setting the `GIT_LITERAL_PATHSPECS` environment
+       variable to `1`.
+
 
 GIT COMMANDS
 ------------
@@ -766,6 +778,14 @@ for further details.
        and read the password from its STDOUT. See also the 'core.askpass'
        option in linkgit:git-config[1].
 
+'GIT_CONFIG_NOSYSTEM'::
+       Whether to skip reading settings from the system-wide
+       `$(prefix)/etc/gitconfig` file.  This environment variable can
+       be used along with `$HOME` and `$XDG_CONFIG_HOME` to create a
+       predictable environment for a picky script, or you can set it
+       temporarily to avoid using a buggy `/etc/gitconfig` file while
+       waiting for someone with sufficient permissions to fix it.
+
 'GIT_FLUSH'::
        If this environment variable is set to "1", then commands such
        as 'git blame' (in incremental mode), 'git rev-list', 'git log',
@@ -790,6 +810,16 @@ for further details.
        as a file path and will try to write the trace messages
        into it.
 
+GIT_LITERAL_PATHSPECS::
+       Setting this variable to `1` will cause git to treat all
+       pathspecs literally, rather than as glob patterns. For example,
+       running `GIT_LITERAL_PATHSPECS=1 git log -- '*.c'` will search
+       for commits that touch the path `*.c`, not any paths that the
+       glob `*.c` matches. You might want this if you are feeding
+       literal paths to git (e.g., paths previously given to you by
+       `git ls-tree`, `--raw` diff output, etc).
+
+
 Discussion[[Discussion]]
 ------------------------
 
index 1b82fe1969ed1cf965d946178a423771dd3cfe5f..91a6438031949d83600abc791676bbf0397a0ddc 100644 (file)
@@ -108,6 +108,25 @@ PATTERN FORMAT
    For example, "/{asterisk}.c" matches "cat-file.c" but not
    "mozilla-sha1/sha1.c".
 
+Two consecutive asterisks ("`**`") in patterns matched against
+full pathname may have special meaning:
+
+ - A leading "`**`" followed by a slash means match in all
+   directories. For example, "`**/foo`" matches file or directory
+   "`foo`" anywhere, the same as pattern "`foo`". "**/foo/bar"
+   matches file or directory "`bar`" anywhere that is directly
+   under directory "`foo`".
+
+ - A trailing "/**" matches everything inside. For example,
+   "abc/**" matches all files inside directory "abc", relative
+   to the location of the `.gitignore` file, with infinite depth.
+
+ - A slash followed by two consecutive asterisks then a slash
+   matches zero or more directories. For example, "`a/**/b`"
+   matches "`a/b`", "`a/x/b`", "`a/x/y/b`" and so on.
+
+ - Other consecutive asterisks are considered invalid.
+
 NOTES
 -----
 
index ab3e91c054ca7b4dcf7373b0aac839c18275a791..52d7ae4313389b1766862d3df5d9874a4ac97b36 100644 (file)
@@ -49,6 +49,11 @@ submodule.<name>.update::
        This config option is overridden if 'git submodule update' is given
        the '--merge', '--rebase' or '--checkout' options.
 
+submodule.<name>.branch::
+       A remote branch name for tracking updates in the upstream submodule.
+       If the option is not specified, it defaults to 'master'.  See the
+       `--remote` documentation in linkgit:git-submodule[1] for details.
+
 submodule.<name>.fetchRecurseSubmodules::
        This option can be used to control recursive fetching of this
        submodule. If this option is also present in the submodules entry in
similarity index 84%
rename from Documentation/technical/api-command.txt
rename to Documentation/howto/new-command.txt
index ea9b2eda31f8c5c9b3a30a1f202a55445180ee97..36502f6718232c97820ba9818949337352dca0aa 100644 (file)
@@ -1,5 +1,10 @@
-Integrating new subcommands
-===========================
+From: Eric S. Raymond <esr@thyrsus.com>
+Abstract: This is how-to documentation for people who want to add extension
+ commands to git.  It should be read alongside api-builtin.txt.
+Content-type: text/asciidoc
+
+How to integrate new subcommands
+================================
 
 This is how-to documentation for people who want to add extension
 commands to git.  It should be read alongside api-builtin.txt.
@@ -71,28 +76,28 @@ Integrating a command
 Here are the things you need to do when you want to merge a new
 subcommand into the git tree.
 
-0. Don't forget to sign off your patch!
+1. Don't forget to sign off your patch!
 
-1. Append your command name to one of the variables BUILTIN_OBJS,
+2. Append your command name to one of the variables BUILTIN_OBJS,
 EXTRA_PROGRAMS, SCRIPT_SH, SCRIPT_PERL or SCRIPT_PYTHON.
 
-2. Drop its test in the t directory.
+3. Drop its test in the t directory.
 
-3. If your command is implemented in an interpreted language with a
+4. If your command is implemented in an interpreted language with a
 p-code intermediate form, make sure .gitignore in the main directory
 includes a pattern entry that ignores such files.  Python .pyc and
 .pyo files will already be covered.
 
-4. If your command has any dependency on a particular version of
+5. If your command has any dependency on a particular version of
 your language, document it in the INSTALL file.
 
-5. There is a file command-list.txt in the distribution main directory
+6. There is a file command-list.txt in the distribution main directory
 that categorizes commands by type, so they can be listed in appropriate
 subsections in the documentation's summary command list.  Add an entry
 for yours.  To understand the categories, look at git-cmmands.txt
 in the main directory.
 
-6. Give the maintainer one paragraph to include in the RelNotes file
+7. Give the maintainer one paragraph to include in the RelNotes file
 to describe the new feature; a good place to do so is in the cover
 letter [PATCH 0/n].
 
index 288f04e70c8ea5f0b93a4b099a4a49d1fee13b79..4a8c276529a574355185adf3c77dede6fbd94267 100644 (file)
@@ -1,5 +1,6 @@
 If the file `.mailmap` exists at the toplevel of the repository, or at
-the location pointed to by the mailmap.file configuration option, it
+the location pointed to by the mailmap.file or mailmap.blob
+configuration options, it
 is used to map author and committer names and email addresses to
 canonical real names and email addresses.
 
@@ -46,7 +47,7 @@ Jane Doe         <jane@desktop.(none)>
 Joe R. Developer <joe@example.com>
 ------------
 
-Note how there is no need for an entry for <jane@laptop.(none)>, because the
+Note how there is no need for an entry for `<jane@laptop.(none)>`, because the
 real name of that author is already correct.
 
 Example 2: Your repository contains commits from the following
index d9eddedc72a5e6362d68df1b126b76804b9676e1..105f18a6f9fd9f4a5a388cb3ec8a0e6a99f7abe3 100644 (file)
@@ -144,7 +144,11 @@ The placeholders are:
 - '%Cgreen': switch color to green
 - '%Cblue': switch color to blue
 - '%Creset': reset color
-- '%C(...)': color specification, as described in color.branch.* config option
+- '%C(...)': color specification, as described in color.branch.* config option;
+  adding `auto,` at the beginning will emit color only when colors are
+  enabled for log output (by `color.diff`, `color.ui`, or `--color`, and
+  respecting the `auto` settings of the former if we are going to a
+  terminal)
 - '%m': left, right or boundary mark
 - '%n': newline
 - '%%': a raw '%'
diff --git a/Documentation/pt_BR/gittutorial.txt b/Documentation/pt_BR/gittutorial.txt
deleted file mode 100644 (file)
index beba065..0000000
+++ /dev/null
@@ -1,675 +0,0 @@
-gittutorial(7)
-==============
-
-NOME
-----
-gittutorial - Um tutorial de introdução ao git (para versão 1.5.1 ou mais nova)
-
-SINOPSE
---------
-git *
-
-DESCRIÇÃO
------------
-
-Este tutorial explica como importar um novo projeto para o git,
-adicionar mudanças a ele, e compartilhar mudanças com outros
-desenvolvedores.
-
-Se, ao invés disso, você está interessado primariamente em usar git para
-obter um projeto, por exemplo, para testar a Ãºltima versão, você pode
-preferir começar com os primeiros dois capítulos de
-link:user-manual.html[O Manual do Usuário Git].
-
-Primeiro, note que você pode obter documentação para um comando como
-`git log --graph` com:
-
-------------------------------------------------
-$ man git-log
-------------------------------------------------
-
-ou:
-
-------------------------------------------------
-$ git help log
-------------------------------------------------
-
-Com a Ãºltima forma, você pode usar o visualizador de manual de sua
-escolha; veja linkgit:git-help[1] para maior informação.
-
-É uma boa idéia informar ao git seu nome e endereço público de email
-antes de fazer qualquer operação. A maneira mais fácil de fazê-lo Ã©:
-
-------------------------------------------------
-$ git config --global user.name "Seu Nome Vem Aqui"
-$ git config --global user.email voce@seudominio.exemplo.com
-------------------------------------------------
-
-
-Importando um novo projeto
------------------------
-
-Assuma que você tem um tarball project.tar.gz com seu trabalho inicial.
-Você pode colocá-lo sob controle de revisão git da seguinte forma:
-
-------------------------------------------------
-$ tar xzf project.tar.gz
-$ cd project
-$ git init
-------------------------------------------------
-
-Git irá responder
-
-------------------------------------------------
-Initialized empty Git repository in .git/
-------------------------------------------------
-
-Agora que você iniciou seu diretório de trabalho, você deve ter notado que um
-novo diretório foi criado com o nome de ".git".
-
-A seguir, diga ao git para gravar um instantâneo do conteúdo de todos os
-arquivos sob o diretório atual (note o '.'), com 'git-add':
-
-------------------------------------------------
-$ git add .
-------------------------------------------------
-
-Este instantâneo está agora armazenado em uma Ã¡rea temporária que o git
-chama de "index" ou Ã­ndice. Você pode armazenar permanentemente o
-conteúdo do Ã­ndice no repositório com 'git-commit':
-
-------------------------------------------------
-$ git commit
-------------------------------------------------
-
-Isto vai te pedir por uma mensagem de commit. Você agora gravou sua
-primeira versão de seu projeto no git.
-
-Fazendo mudanças
---------------
-
-Modifique alguns arquivos, e, então, adicione seu conteúdo atualizado ao
-índice:
-
-------------------------------------------------
-$ git add file1 file2 file3
-------------------------------------------------
-
-Você está agora pronto para fazer o commit. Você pode ver o que está
-para ser gravado usando 'git-diff' com a opção --cached:
-
-------------------------------------------------
-$ git diff --cached
-------------------------------------------------
-
-(Sem --cached, o comando 'git-diff' irá te mostrar quaisquer mudanças
-que você tenha feito mas ainda não adicionou ao Ã­ndice.) Você também
-pode obter um breve sumário da situação com 'git-status':
-
-------------------------------------------------
-$ git status
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      modified:   file1
-#      modified:   file2
-#      modified:   file3
-#
-------------------------------------------------
-
-Se você precisar fazer qualquer outro ajuste, faça-o agora, e, então,
-adicione qualquer conteúdo modificado ao Ã­ndice. Finalmente, grave suas
-mudanças com:
-
-------------------------------------------------
-$ git commit
-------------------------------------------------
-
-Ao executar esse comando, ele irá te pedir uma mensagem descrevendo a mudança,
-e, então, irá gravar a nova versão do projeto.
-
-Alternativamente, ao invés de executar 'git-add' antes, você pode usar
-
-------------------------------------------------
-$ git commit -a
-------------------------------------------------
-
-o que irá automaticamente notar quaisquer arquivos modificados (mas não
-novos), adicioná-los ao Ã­ndices, e gravar, tudo em um Ãºnico passo.
-
-Uma nota em mensagens de commit: Apesar de não ser exigido, Ã© uma boa
-idéia começar a mensagem com uma simples e curta (menos de 50
-caracteres) linha sumarizando a mudança, seguida de uma linha em branco
-e, então, uma descrição mais detalhada. Ferramentas que transformam
-commits em email, por exemplo, usam a primeira linha no campo de
-cabeçalho "Subject:" e o resto no corpo.
-
-Git rastreia conteúdo, não arquivos
-----------------------------
-
-Muitos sistemas de controle de revisão provêem um comando `add` que diz
-ao sistema para começar a rastrear mudanças em um novo arquivo. O
-comando `add` do git faz algo mais simples e mais poderoso: 'git-add' Ã©
-usado tanto para arquivos novos e arquivos recentemente modificados, e
-em ambos os casos, ele tira o instantâneo dos arquivos dados e armazena
-o conteúdo no Ã­ndice, pronto para inclusão do próximo commit.
-
-Visualizando a história do projeto
------------------------
-
-Em qualquer ponto você pode visualizar a história das suas mudanças
-usando
-
-------------------------------------------------
-$ git log
-------------------------------------------------
-
-Se você também quiser ver a diferença completa a cada passo, use
-
-------------------------------------------------
-$ git log -p
-------------------------------------------------
-
-Geralmente, uma visão geral da mudança Ã© Ãºtil para ter a sensação de
-cada passo
-
-------------------------------------------------
-$ git log --stat --summary
-------------------------------------------------
-
-Gerenciando "branches"/ramos
------------------
-
-Um simples repositório git pode manter múltiplos ramos de
-desenvolvimento. Para criar um novo ramo chamado "experimental", use
-
-------------------------------------------------
-$ git branch experimental
-------------------------------------------------
-
-Se você executar agora
-
-------------------------------------------------
-$ git branch
-------------------------------------------------
-
-você vai obter uma lista de todos os ramos existentes:
-
-------------------------------------------------
-  experimental
-* master
-------------------------------------------------
-
-O ramo "experimental" Ã© o que você acaba de criar, e o ramo "master" Ã© o
-ramo padrão que foi criado pra você automaticamente. O asterisco marca
-o ramo em que você está atualmente; digite
-
-------------------------------------------------
-$ git checkout experimental
-------------------------------------------------
-
-para mudar para o ramo experimental. Agora edite um arquivo, grave a
-mudança, e mude de volta para o ramo master:
-
-------------------------------------------------
-(edita arquivo)
-$ git commit -a
-$ git checkout master
-------------------------------------------------
-
-Verifique que a mudança que você fez não está mais visível, já que ela
-foi feita no ramo experimental e você está de volta ao ramo master.
-
-Você pode fazer uma mudança diferente no ramo master:
-
-------------------------------------------------
-(edit file)
-$ git commit -a
-------------------------------------------------
-
-neste ponto, os dois ramos divergiram, com diferentes mudanças feitas em
-cada um. Para unificar as mudanças feitas no experimental para o
-master, execute
-
-------------------------------------------------
-$ git merge experimental
-------------------------------------------------
-
-Se as mudanças não conflitarem, estará pronto. Se existirem conflitos,
-marcadores serão deixados nos arquivos problemáticos exibindo o
-conflito;
-
-------------------------------------------------
-$ git diff
-------------------------------------------------
-
-vai exibir isto. Após você editar os arquivos para resolver os
-conflitos,
-
-------------------------------------------------
-$ git commit -a
-------------------------------------------------
-
-irá gravar o resultado da unificação. Finalmente,
-
-------------------------------------------------
-$ gitk
-------------------------------------------------
-
-vai mostrar uma bela representação gráfica da história resultante.
-
-Neste ponto você pode remover seu ramo experimental com
-
-------------------------------------------------
-$ git branch -d experimental
-------------------------------------------------
-
-Este comando garante que as mudanças no ramo experimental já estão no
-ramo atual.
-
-Se você desenvolve em um ramo ideia-louca, e se arrepende, você pode
-sempre remover o ramo com
-
--------------------------------------
-$ git branch -D ideia-louca
--------------------------------------
-
-Ramos são baratos e fáceis, então isto Ã© uma boa maneira de experimentar
-alguma coisa.
-
-Usando git para colaboração
----------------------------
-
-Suponha que Alice começou um novo projeto com um repositório git em
-/home/alice/project, e que Bob, que tem um diretório home na mesma
-máquina, quer contribuir.
-
-Bob começa com:
-
-------------------------------------------------
-bob$ git clone /home/alice/project myrepo
-------------------------------------------------
-
-Isso cria um novo diretório "myrepo" contendo um clone do repositório de
-Alice. O clone está no mesmo pé que o projeto original, possuindo sua
-própria cópia da história do projeto original.
-
-Bob então faz algumas mudanças e as grava:
-
-------------------------------------------------
-(editar arquivos)
-bob$ git commit -a
-(repetir conforme necessário)
-------------------------------------------------
-
-Quanto está pronto, ele diz a Alice para puxar as mudanças do
-repositório em /home/bob/myrepo. Ela o faz com:
-
-------------------------------------------------
-alice$ cd /home/alice/project
-alice$ git pull /home/bob/myrepo master
-------------------------------------------------
-
-Isto unifica as mudanças do ramo "master" do Bob ao ramo atual de Alice.
-Se Alice fez suas próprias mudanças no intervalo, ela, então, pode
-precisar corrigir manualmente quaisquer conflitos. (Note que o argumento
-"master" no comando acima Ã©, de fato, desnecessário, já que Ã© o padrão.)
-
-O comando "pull" executa, então, duas operações: ele obtém mudanças de
-um ramo remoto, e, então, as unifica no ramo atual.
-
-Note que, em geral, Alice gostaria que suas mudanças locais fossem
-gravadas antes de iniciar este "pull". Se o trabalho de Bob conflita
-com o que Alice fez desde que suas histórias se ramificaram, Alice irá
-usar seu diretório de trabalho e o Ã­ndice para resolver conflitos, e
-mudanças locais existentes irão interferir com o processo de resolução
-de conflitos (git ainda irá realizar a obtenção mas irá se recusar a
-unificar --- Alice terá que se livrar de suas mudanças locais de alguma
-forma e puxar de novo quando isso acontecer).
-
-Alice pode espiar o que Bob fez sem unificar primeiro, usando o comando
-"fetch"; isto permite Alice inspecionar o que Bob fez, usando um símbolo
-especial "FETCH_HEAD", com o fim de determinar se ele tem alguma coisa
-que vale puxar, assim:
-
-------------------------------------------------
-alice$ git fetch /home/bob/myrepo master
-alice$ git log -p HEAD..FETCH_HEAD
-------------------------------------------------
-
-Esta operação Ã© segura mesmo se Alice tem mudanças locais não gravadas.
-A notação de intervalo "HEAD..FETCH_HEAD" significa mostrar tudo que Ã©
-alcançável de FETCH_HEAD mas exclua tudo o que Ã© alcançável de HEAD.
-Alice já sabe tudo que leva a seu estado atual (HEAD), e revisa o que Bob
-tem em seu estado (FETCH_HEAD) que ela ainda não viu com esse comando.
-
-Se Alice quer visualizar o que Bob fez desde que suas histórias se
-ramificaram, ela pode disparar o seguinte comando:
-
-------------------------------------------------
-$ gitk HEAD..FETCH_HEAD
-------------------------------------------------
-
-Isto usa a mesma notação de intervalo que vimos antes com 'git log'.
-
-Alice pode querer ver o que ambos fizeram desde que ramificaram. Ela
-pode usar a forma com três pontos ao invés da forma com dois pontos:
-
-------------------------------------------------
-$ gitk HEAD...FETCH_HEAD
-------------------------------------------------
-
-Isto significa "mostre tudo que Ã© alcançável de qualquer um deles, mas
-exclua tudo que Ã© alcançável a partir de ambos".
-
-Por favor, note que essas notações de intervalo podem ser usadas tanto
-com gitk quanto com "git log".
-
-Após inspecionar o que Bob fez, se não há nada urgente, Alice pode
-decidir continuar trabalhando sem puxar de Bob. Se a história de Bob
-tem alguma coisa que Alice precisa imediatamente, Alice pode optar por
-separar seu trabalho em progresso primeiro, fazer um "pull", e, então,
-finalmente, retomar seu trabalho em progresso em cima da história
-resultante.
-
-Quando você está trabalhando em um pequeno grupo unido, não Ã© incomum
-interagir com o mesmo repositório várias e várias vezes. Definindo um
-repositório remoto antes de tudo, você pode fazê-lo mais facilmente:
-
-------------------------------------------------
-alice$ git remote add bob /home/bob/myrepo
-------------------------------------------------
-
-Com isso, Alice pode executar a primeira parte da operação "pull" usando
-o comando 'git-fetch' sem unificar suas mudanças com seu próprio ramo,
-usando:
-
--------------------------------------
-alice$ git fetch bob
--------------------------------------
-
-Diferente da forma longa, quando Alice obteve de Bob usando um
-repositório remoto antes definido com 'git-remote', o que foi obtido Ã©
-armazenado em um ramo remoto, neste caso `bob/master`. Então, após isso:
-
--------------------------------------
-alice$ git log -p master..bob/master
--------------------------------------
-
-mostra uma lista de todas as mudanças que Bob fez desde que ramificou do
-ramo master de Alice.
-
-Após examinar essas mudanças, Alice pode unificá-las em seu ramo master:
-
--------------------------------------
-alice$ git merge bob/master
--------------------------------------
-
-Esse `merge` pode também ser feito puxando de seu próprio ramo remoto,
-assim:
-
--------------------------------------
-alice$ git pull . remotes/bob/master
--------------------------------------
-
-Note que 'git pull' sempre unifica ao ramo atual, independente do que
-mais foi passado na linha de comando.
-
-Depois, Bob pode atualizar seu repositório com as Ãºltimas mudanças de
-Alice, usando
-
--------------------------------------
-bob$ git pull
--------------------------------------
-
-Note que ele não precisa dar o caminho do repositório de Alice; quando
-Bob clonou seu repositório, o git armazenou a localização de seu
-repositório na configuração do mesmo, e essa localização Ã© usada
-para puxar:
-
--------------------------------------
-bob$ git config --get remote.origin.url
-/home/alice/project
--------------------------------------
-
-(A configuração completa criada por 'git-clone' Ã© visível usando `git
-config -l`, e a página de manual linkgit:git-config[1] explica o
-significado de cada opção.)
-
-Git também mantém uma cópia limpa do ramo master de Alice sob o nome
-"origin/master":
-
--------------------------------------
-bob$ git branch -r
-  origin/master
--------------------------------------
-
-Se Bob decidir depois em trabalhar em um host diferente, ele ainda pode
-executar clones e puxar usando o protocolo ssh:
-
--------------------------------------
-bob$ git clone alice.org:/home/alice/project myrepo
--------------------------------------
-
-Alternativamente, o git tem um protocolo nativo, ou pode usar rsync ou
-http; veja linkgit:git-pull[1] para detalhes.
-
-Git pode também ser usado em um modo parecido com CVS, com um
-repositório central para o qual vários usuários empurram modificações;
-veja linkgit:git-push[1] e linkgit:gitcvs-migration[7].
-
-Explorando história
------------------
-
-A história no git Ã© representada como uma série de commits
-interrelacionados. Nós já vimos que o comando 'git-log' pode listar
-esses commits. Note que a primeira linha de cada entrada no log também
-dá o nome para o commit:
-
--------------------------------------
-$ git log
-commit c82a22c39cbc32576f64f5c6b3f24b99ea8149c7
-Author: Junio C Hamano <junkio@cox.net>
-Date:   Tue May 16 17:18:22 2006 -0700
-
-    merge-base: Clarify the comments on post processing.
--------------------------------------
-
-Nós podemos dar este nome ao 'git-show' para ver os detalhes sobre este
-commit.
-
--------------------------------------
-$ git show c82a22c39cbc32576f64f5c6b3f24b99ea8149c7
--------------------------------------
-
-Mas há outras formas de se referir aos commits. Você pode usar qualquer
-parte inicial do nome que seja longo o bastante para identificar
-unicamente o commit:
-
--------------------------------------
-$ git show c82a22c39c  # os primeiros caracteres do nome são o bastante
-                       # usualmente
-$ git show HEAD                # a ponta do ramo atual
-$ git show experimental        # a ponta do ramo "experimental"
--------------------------------------
-
-Todo commit normalmente tem um commit "pai" que aponta para o estado
-anterior do projeto:
-
--------------------------------------
-$ git show HEAD^  # para ver o pai de HEAD
-$ git show HEAD^^ # para ver o avô de HEAD
-$ git show HEAD~4 # para ver o trisavô de HEAD
--------------------------------------
-
-Note que commits de unificação podem ter mais de um pai:
-
--------------------------------------
-$ git show HEAD^1 # mostra o primeiro pai de HEAD (o mesmo que HEAD^)
-$ git show HEAD^2 # mostra o segundo pai de HEAD
--------------------------------------
-
-Você também pode dar aos commits nomes Ã  sua escolha; após executar
-
--------------------------------------
-$ git tag v2.5 1b2e1d63ff
--------------------------------------
-
-você pode se referir a 1b2e1d63ff pelo nome "v2.5". Se você pretende
-compartilhar esse nome com outras pessoas (por exemplo, para identificar
-uma versão de lançamento), você deveria criar um objeto "tag", e talvez
-assiná-lo; veja linkgit:git-tag[1] para detalhes.
-
-Qualquer comando git que precise conhecer um commit pode receber
-quaisquer desses nomes. Por exemplo:
-
--------------------------------------
-$ git diff v2.5 HEAD    # compara o HEAD atual com v2.5
-$ git branch stable v2.5 # inicia um novo ramo chamado "stable" baseado
-                        # em v2.5
-$ git reset --hard HEAD^ # reseta seu ramo atual e seu diretório de
-                        # trabalho a seu estado em HEAD^
--------------------------------------
-
-Seja cuidadoso com o Ãºltimo comando: além de perder quaisquer mudanças
-em seu diretório de trabalho, ele também remove todos os commits
-posteriores desse ramo. Se esse ramo Ã© o Ãºnico ramo contendo esses
-commits, eles serão perdidos. Também, não use 'git-reset' num ramo
-publicamente visível de onde outros desenvolvedores puxam, já que vai
-forçar unificações desnecessárias para que outros desenvolvedores limpem
-a história. Se você precisa desfazer mudanças que você empurrou, use
-'git-revert' no lugar.
-
-O comando 'git-grep' pode buscar strings em qualquer versão de seu
-projeto, então
-
--------------------------------------
-$ git grep "hello" v2.5
--------------------------------------
-
-procura por todas as ocorrências de "hello" em v2.5.
-
-Se você deixar de fora o nome do commit, 'git-grep' irá procurar
-quaisquer dos arquivos que ele gerencia no diretório corrente. Então
-
--------------------------------------
-$ git grep "hello"
--------------------------------------
-
-é uma forma rápida de buscar somente os arquivos que são rastreados pelo
-git.
-
-Muitos comandos git também recebem um conjunto de commits, o que pode
-ser especificado de várias formas. Aqui estão alguns exemplos com 'git-log':
-
--------------------------------------
-$ git log v2.5..v2.6            # commits entre v2.5 e v2.6
-$ git log v2.5..                # commits desde v2.5
-$ git log --since="2 weeks ago" # commits das Ãºltimas 2 semanas
-$ git log v2.5.. Makefile       # commits desde v2.5 que modificam
-                               # Makefile
--------------------------------------
-
-Você também pode dar ao 'git-log' um "intervalo" de commits onde o
-primeiro não Ã© necessariamente um ancestral do segundo; por exemplo, se
-as pontas dos ramos "stable" e "master" divergiram de um commit
-comum algum tempo atrás, então
-
--------------------------------------
-$ git log stable..master
--------------------------------------
-
-irá listar os commits feitos no ramo "master" mas não no ramo
-"stable", enquanto
-
--------------------------------------
-$ git log master..stable
--------------------------------------
-
-irá listar a lista de commits feitos no ramo "stable" mas não no ramo
-"master".
-
-O comando 'git-log' tem uma fraqueza: ele precisa mostrar os commits em
-uma lista. Quando a história tem linhas de desenvolvimento que
-divergiram e então foram unificadas novamente, a ordem em que 'git-log'
-apresenta essas mudanças Ã© irrelevante.
-
-A maioria dos projetos com múltiplos contribuidores (como o kernel
-Linux, ou o próprio git) tem unificações frequentes, e 'gitk' faz um
-trabalho melhor de visualizar sua história. Por exemplo,
-
--------------------------------------
-$ gitk --since="2 weeks ago" drivers/
--------------------------------------
-
-permite a você navegar em quaisquer commits desde as Ãºltimas duas semanas
-de commits que modificaram arquivos sob o diretório "drivers". (Nota:
-você pode ajustar as fontes do gitk segurando a tecla control enquanto
-pressiona "-" ou "+".)
-
-Finalmente, a maioria dos comandos que recebem nomes de arquivo permitirão
-também, opcionalmente, preceder qualquer nome de arquivo por um
-commit, para especificar uma versão particular do arquivo:
-
--------------------------------------
-$ git diff v2.5:Makefile HEAD:Makefile.in
--------------------------------------
-
-Você pode usar 'git-show' para ver tal arquivo:
-
--------------------------------------
-$ git show v2.5:Makefile
--------------------------------------
-
-Próximos passos
-----------
-
-Este tutorial deve ser o bastante para operar controle de revisão
-distribuído básico para seus projetos. No entanto, para entender
-plenamente a profundidade e o poder do git você precisa entender duas
-idéias simples nas quais ele se baseia:
-
-  * A base de objetos Ã© um sistema bem elegante usado para armazenar a
-    história de seu projeto--arquivos, diretórios, e commits.
-
-  * O arquivo de Ã­ndice Ã© um cache do estado de uma Ã¡rvore de diretório,
-    usado para criar commits, restaurar diretórios de trabalho, e
-    armazenar as várias Ã¡rvores envolvidas em uma unificação.
-
-A parte dois deste tutorial explica a base de objetos, o arquivo de
-índice, e algumas outras coisinhas que você vai precisar pra usar o
-máximo do git. Você pode encontrá-la em linkgit:gittutorial-2[7].
-
-Se você não quiser continuar com o tutorial agora nesse momento, algumas
-outras digressões que podem ser interessantes neste ponto são:
-
-  * linkgit:git-format-patch[1], linkgit:git-am[1]: Estes convertem
-    séries de commits em patches para email, e vice-versa, Ãºteis para
-    projetos como o kernel Linux que dependem fortemente de patches
-    enviados por email.
-
-  * linkgit:git-bisect[1]: Quando há uma regressão em seu projeto, uma
-    forma de rastrear um bug Ã© procurando pela história para encontrar o
-    commit culpado. Git bisect pode ajudar a executar uma busca binária
-    por esse commit. Ele Ã© inteligente o bastante para executar uma
-    busca próxima da Ã³tima mesmo no caso de uma história complexa
-    não-linear com muitos ramos unificados.
-
-  * link:everyday.html[GIT diariamente com 20 e tantos comandos]
-
-  * linkgit:gitcvs-migration[7]: Git para usuários de CVS.
-
-VEJA TAMBÉM
---------
-linkgit:gittutorial-2[7],
-linkgit:gitcvs-migration[7],
-linkgit:gitcore-tutorial[7],
-linkgit:gitglossary[7],
-linkgit:git-help[1],
-link:everyday.html[git diariamente],
-link:user-manual.html[O Manual do Usuário git]
-
-GIT
----
-Parte da suite linkgit:git[1].
index 43dbe09f735525b0a1549ccfb4de2f2ca87252a0..542946b1ba701069837b702cbd8fe8079cecf56d 100644 (file)
@@ -5,7 +5,9 @@ Dynamically growing an array using realloc() is error prone and boring.
 
 Define your array with:
 
-* a pointer (`ary`) that points at the array, initialized to `NULL`;
+* a pointer (`item`) that points at the array, initialized to `NULL`
+  (although please name the variable based on its contents, not on its
+  type);
 
 * an integer variable (`alloc`) that keeps track of how big the current
   allocation is, initialized to `0`;
@@ -13,22 +15,22 @@ Define your array with:
 * another integer variable (`nr`) to keep track of how many elements the
   array currently has, initialized to `0`.
 
-Then before adding `n`th element to the array, call `ALLOC_GROW(ary, n,
+Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
 alloc)`.  This ensures that the array can hold at least `n` elements by
 calling `realloc(3)` and adjusting `alloc` variable.
 
 ------------
-sometype *ary;
+sometype *item;
 size_t nr;
 size_t alloc
 
 for (i = 0; i < nr; i++)
-       if (we like ary[i] already)
+       if (we like item[i] already)
                return;
 
 /* we did not like any existing one, so add one */
-ALLOC_GROW(ary, nr + 1, alloc);
-ary[nr++] = value you like;
+ALLOC_GROW(item, nr + 1, alloc);
+item[nr++] = value you like;
 ------------
 
 You are responsible for updating the `nr` variable.
index add6f435b59e3df095e507d8a5d4f911cee9d3b2..944fc39fac8b26ceaee781fe4a18b9ba2d78ac9d 100644 (file)
@@ -9,37 +9,40 @@ Data structure
 --------------
 
 `struct dir_struct` structure is used to pass directory traversal
-options to the library and to record the paths discovered.  The notable
-options are:
+options to the library and to record the paths discovered.  A single
+`struct dir_struct` is used regardless of whether or not the traversal
+recursively descends into subdirectories.
+
+The notable options are:
 
 `exclude_per_dir`::
 
        The name of the file to be read in each directory for excluded
        files (typically `.gitignore`).
 
-`collect_ignored`::
+`flags`::
 
-       Include paths that are to be excluded in the result.
+       A bit-field of options:
 
-`show_ignored`::
+`DIR_SHOW_IGNORED`:::
 
        The traversal is for finding just ignored files, not unignored
        files.
 
-`show_other_directories`::
+`DIR_SHOW_OTHER_DIRECTORIES`:::
 
        Include a directory that is not tracked.
 
-`hide_empty_directories`::
+`DIR_HIDE_EMPTY_DIRECTORIES`:::
 
        Do not include a directory that is not tracked and is empty.
 
-`no_gitlinks`::
+`DIR_NO_GITLINKS`:::
 
        If set, recurse into a directory that looks like a git
        directory.  Otherwise it is shown as a directory.
 
-The result of the enumeration is left in these fields::
+The result of the enumeration is left in these fields:
 
 `entries[]`::
 
index d6fc90ac7eb210bd492057422748817a59cfc2a3..18142b6d29283bbf6e325ce71d50761a3f50a227 100644 (file)
@@ -33,11 +33,11 @@ The following utility functions are wrappers around `graph_next_line()` and
 They can all be called with a NULL graph argument, in which case no graph
 output will be printed.
 
-* `graph_show_commit()` calls `graph_next_line()` until it returns non-zero.
-  This prints all graph lines up to, and including, the line containing this
-  commit.  Output is printed to stdout.  The last line printed does not contain
-  a terminating newline.  This should not be called if the commit line has
-  already been printed, or it will loop forever.
+* `graph_show_commit()` calls `graph_next_line()` and
+  `graph_is_commit_finished()` until one of them return non-zero.  This prints
+  all graph lines up to, and including, the line containing this commit.
+  Output is printed to stdout.  The last line printed does not contain a
+  terminating newline.
 
 * `graph_show_oneline()` calls `graph_next_line()` and prints the result to
   stdout.  The line printed does not contain a terminating newline.
index af7cc2e395f1399830f9eacc52468376b216fb86..730cfacf783ef26b408f22c13599420db46e28b4 100644 (file)
@@ -11,5 +11,3 @@ documents them.
 ////////////////////////////////////////////////////////////////
 // table of contents end
 ////////////////////////////////////////////////////////////////
-
-2007-11-24
index f18b4f4817448530a5adbe2c8835bb7791add42a..5d7d7f2d32f58f8682ca5efb2fd98fe7e74247dd 100644 (file)
@@ -55,10 +55,8 @@ The functions above do the following:
   non-zero.
 
 . If the program terminated due to a signal, then the return value is the
-  signal number - 128, ie. it is negative and so indicates an unusual
-  condition; a diagnostic is printed. This return value can be passed to
-  exit(2), which will report the same code to the parent process that a
-  POSIX shell's $? would report for a program that died from the signal.
+  signal number + 128, ie. the same value that a POSIX shell's $? would
+  report.  A diagnostic is printed.
 
 
 `start_async`::
index 7386bcab3ec30a06f4663c953fa46e78ed26c07b..20be3488349c2ddbafbd90c0200f2a7d3862a12f 100644 (file)
@@ -82,14 +82,6 @@ Functions
        call free() on the util members of any items that have to be
        deleted.  Preserve the order of the items that are retained.
 
-`string_list_longest_prefix`::
-
-       Return the longest string within a string_list that is a
-       prefix (in the sense of prefixcmp()) of the specified string,
-       or NULL if no such prefix exists.  This function does not
-       require the string_list to be sorted (it does a linear
-       search).
-
 `print_string_list`::
 
        Dump a string_list to stdout, useful mainly for debugging purposes. It
index 57d6f915b143765b9e58b3793f14795ddab71200..73241548381fcb0b3c0dbd2cb09f9526a64e637d 100644 (file)
@@ -161,8 +161,9 @@ GIT index format
     this span of index as a tree.
 
   An entry can be in an invalidated state and is represented by having
-  -1 in the entry_count field. In this case, there is no object name
-  and the next entry starts immediately after the newline.
+  a negative number in the entry_count field. In this case, there is no
+  object name and the next entry starts immediately after the newline.
+  When writing an invalid entry, -1 should always be used as entry_count.
 
   The entries are written out in the top-down, depth-first order.  The
   first entry represents the root level of the repository, followed by the
index 4bc073cc135f6bda73a06b24c7b368d6c653224e..e9f7abca91b96c2f9c99744c49adefe04a4daf56 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v1.8.1-rc1
+DEF_VER=v1.8.1.GIT
 
 LF='
 '
index 736ecd45b58da32575cc20019d41a2b178843a09..fd635acb2e4f05672e899129ae483ee421a59e2d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -74,10 +74,14 @@ all::
 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
 # d_type in struct dirent (Cygwin 1.5, fixed in Cygwin 1.7).
 #
+# Define HAVE_STRINGS_H if you have strings.h and need it for strcasecmp.
+#
 # Define NO_STRCASESTR if you don't have strcasestr.
 #
 # Define NO_MEMMEM if you don't have memmem.
 #
+# Define NO_GETPAGESIZE if you don't have getpagesize.
+#
 # Define NO_STRLCPY if you don't have strlcpy.
 #
 # Define NO_STRTOUMAX if you don't have both strtoimax and strtoumax in the
@@ -165,6 +169,10 @@ all::
 # Define NO_POLL if you do not have or don't want to use poll().
 # This also implies NO_SYS_POLL_H.
 #
+# Define NEEDS_SYS_PARAM_H if you need to include sys/param.h to compile,
+# *PLEASE* REPORT to git@vger.kernel.org if your platform needs this;
+# we want to know more about the issue.
+#
 # 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.
@@ -233,11 +241,16 @@ all::
 # apostrophes to be ASCII so that cut&pasting examples to the shell
 # will work.
 #
+# Define PERL_PATH to the path of your Perl binary (usually /usr/bin/perl).
+#
 # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
 # MakeMaker (e.g. using ActiveState under Cygwin).
 #
 # Define NO_PERL if you do not want Perl scripts or libraries at all.
 #
+# Define PYTHON_PATH to the path of your Python binary (often /usr/bin/python
+# but /usr/bin/python2.7 on some platforms).
+#
 # Define NO_PYTHON if you do not want Python scripts or libraries at all.
 #
 # Define NO_TCLTK if you do not want Tcl/Tk GUI.
@@ -273,6 +286,10 @@ all::
 #
 # Define NO_REGEX if you have no or inferior regex support in your C library.
 #
+# Define CYGWIN_V15_WIN32API if you are using Cygwin v1.7.x but are not
+# using the current w32api packages. The recommended approach, however,
+# is to update your installation if compilation errors occur.
+#
 # Define HAVE_DEV_TTY if your system can open /dev/tty to interact with the
 # user.
 #
@@ -326,19 +343,6 @@ GIT-VERSION-FILE: FORCE
        @$(SHELL_PATH) ./GIT-VERSION-GEN
 -include GIT-VERSION-FILE
 
-uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
-uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
-uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
-uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
-uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
-uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
-
-ifdef MSVC
-       # avoid the MingW and Cygwin configuration sections
-       uname_S := Windows
-       uname_O := Windows
-endif
-
 # CFLAGS and LDFLAGS are for the users to override from the command line.
 
 CFLAGS = -g -O2 -Wall
@@ -470,7 +474,7 @@ SCRIPT_PERL += git-relink.perl
 SCRIPT_PERL += git-send-email.perl
 SCRIPT_PERL += git-svn.perl
 
-SCRIPT_PYTHON += git-remote-testgit.py
+SCRIPT_PYTHON += git-remote-testpy.py
 SCRIPT_PYTHON += git-p4.py
 
 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
@@ -524,6 +528,7 @@ TEST_PROGRAMS_NEED_X += test-sigchain
 TEST_PROGRAMS_NEED_X += test-string-list
 TEST_PROGRAMS_NEED_X += test-subprocess
 TEST_PROGRAMS_NEED_X += test-svn-fe
+TEST_PROGRAMS_NEED_X += test-wildmatch
 
 TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
 
@@ -649,7 +654,7 @@ LIB_H += list-objects.h
 LIB_H += ll-merge.h
 LIB_H += log-tree.h
 LIB_H += mailmap.h
-LIB_H += merge-file.h
+LIB_H += merge-blobs.h
 LIB_H += merge-recursive.h
 LIB_H += mergesort.h
 LIB_H += notes-cache.h
@@ -696,6 +701,7 @@ LIB_H += userdiff.h
 LIB_H += utf8.h
 LIB_H += varint.h
 LIB_H += walker.h
+LIB_H += wildmatch.h
 LIB_H += wt-status.h
 LIB_H += xdiff-interface.h
 LIB_H += xdiff/xdiff.h
@@ -765,7 +771,7 @@ LIB_OBJS += log-tree.o
 LIB_OBJS += mailmap.o
 LIB_OBJS += match-trees.o
 LIB_OBJS += merge.o
-LIB_OBJS += merge-file.o
+LIB_OBJS += merge-blobs.o
 LIB_OBJS += merge-recursive.o
 LIB_OBJS += mergesort.o
 LIB_OBJS += name-hash.o
@@ -830,6 +836,7 @@ LIB_OBJS += utf8.o
 LIB_OBJS += varint.o
 LIB_OBJS += version.o
 LIB_OBJS += walker.o
+LIB_OBJS += wildmatch.o
 LIB_OBJS += wrapper.o
 LIB_OBJS += write_or_die.o
 LIB_OBJS += ws.o
@@ -937,518 +944,7 @@ EXTLIBS =
 
 GIT_USER_AGENT = git/$(GIT_VERSION)
 
-#
-# Platform specific tweaks
-#
-
-# We choose to avoid "if .. else if .. else .. endif endif"
-# because maintaining the nesting to match is a pain.  If
-# we had "elif" things would have been much nicer...
-
-ifeq ($(uname_M),x86_64)
-       XDL_FAST_HASH = YesPlease
-endif
-ifeq ($(uname_S),OSF1)
-       # Need this for u_short definitions et al
-       BASIC_CFLAGS += -D_OSF_SOURCE
-       SOCKLEN_T = int
-       NO_STRTOULL = YesPlease
-       NO_NSEC = YesPlease
-endif
-ifeq ($(uname_S),Linux)
-       NO_STRLCPY = YesPlease
-       NO_MKSTEMPS = YesPlease
-       HAVE_PATHS_H = YesPlease
-       LIBC_CONTAINS_LIBINTL = YesPlease
-       HAVE_DEV_TTY = YesPlease
-endif
-ifeq ($(uname_S),GNU/kFreeBSD)
-       NO_STRLCPY = YesPlease
-       NO_MKSTEMPS = YesPlease
-       HAVE_PATHS_H = YesPlease
-       DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
-       LIBC_CONTAINS_LIBINTL = YesPlease
-endif
-ifeq ($(uname_S),UnixWare)
-       CC = cc
-       NEEDS_SOCKET = YesPlease
-       NEEDS_NSL = YesPlease
-       NEEDS_SSL_WITH_CRYPTO = YesPlease
-       NEEDS_LIBICONV = YesPlease
-       SHELL_PATH = /usr/local/bin/bash
-       NO_IPV6 = YesPlease
-       NO_HSTRERROR = YesPlease
-       NO_MKSTEMPS = YesPlease
-       BASIC_CFLAGS += -Kthread
-       BASIC_CFLAGS += -I/usr/local/include
-       BASIC_LDFLAGS += -L/usr/local/lib
-       INSTALL = ginstall
-       TAR = gtar
-       NO_STRCASESTR = YesPlease
-       NO_MEMMEM = YesPlease
-endif
-ifeq ($(uname_S),SCO_SV)
-       ifeq ($(uname_R),3.2)
-               CFLAGS = -O2
-       endif
-       ifeq ($(uname_R),5)
-               CC = cc
-               BASIC_CFLAGS += -Kthread
-       endif
-       NEEDS_SOCKET = YesPlease
-       NEEDS_NSL = YesPlease
-       NEEDS_SSL_WITH_CRYPTO = YesPlease
-       NEEDS_LIBICONV = YesPlease
-       SHELL_PATH = /usr/bin/bash
-       NO_IPV6 = YesPlease
-       NO_HSTRERROR = YesPlease
-       NO_MKSTEMPS = YesPlease
-       BASIC_CFLAGS += -I/usr/local/include
-       BASIC_LDFLAGS += -L/usr/local/lib
-       NO_STRCASESTR = YesPlease
-       NO_MEMMEM = YesPlease
-       INSTALL = ginstall
-       TAR = gtar
-endif
-ifeq ($(uname_S),Darwin)
-       NEEDS_CRYPTO_WITH_SSL = YesPlease
-       NEEDS_SSL_WITH_CRYPTO = YesPlease
-       NEEDS_LIBICONV = YesPlease
-       ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
-               OLD_ICONV = UnfortunatelyYes
-       endif
-       ifeq ($(shell expr "$(uname_R)" : '[15]\.'),2)
-               NO_STRLCPY = YesPlease
-       endif
-       NO_MEMMEM = YesPlease
-       USE_ST_TIMESPEC = YesPlease
-       HAVE_DEV_TTY = YesPlease
-       COMPAT_OBJS += compat/precompose_utf8.o
-       BASIC_CFLAGS += -DPRECOMPOSE_UNICODE
-endif
-ifeq ($(uname_S),SunOS)
-       NEEDS_SOCKET = YesPlease
-       NEEDS_NSL = YesPlease
-       SHELL_PATH = /bin/bash
-       SANE_TOOL_PATH = /usr/xpg6/bin:/usr/xpg4/bin
-       NO_STRCASESTR = YesPlease
-       NO_MEMMEM = YesPlease
-       NO_MKDTEMP = YesPlease
-       NO_MKSTEMPS = YesPlease
-       NO_REGEX = YesPlease
-       NO_FNMATCH_CASEFOLD = YesPlease
-       NO_MSGFMT_EXTENDED_OPTIONS = YesPlease
-       HAVE_DEV_TTY = YesPlease
-       ifeq ($(uname_R),5.6)
-               SOCKLEN_T = int
-               NO_HSTRERROR = YesPlease
-               NO_IPV6 = YesPlease
-               NO_SOCKADDR_STORAGE = YesPlease
-               NO_UNSETENV = YesPlease
-               NO_SETENV = YesPlease
-               NO_STRLCPY = YesPlease
-               NO_STRTOUMAX = YesPlease
-               GIT_TEST_CMP = cmp
-       endif
-       ifeq ($(uname_R),5.7)
-               NEEDS_RESOLV = YesPlease
-               NO_IPV6 = YesPlease
-               NO_SOCKADDR_STORAGE = YesPlease
-               NO_UNSETENV = YesPlease
-               NO_SETENV = YesPlease
-               NO_STRLCPY = YesPlease
-               NO_STRTOUMAX = YesPlease
-               GIT_TEST_CMP = cmp
-       endif
-       ifeq ($(uname_R),5.8)
-               NO_UNSETENV = YesPlease
-               NO_SETENV = YesPlease
-               NO_STRTOUMAX = YesPlease
-               GIT_TEST_CMP = cmp
-       endif
-       ifeq ($(uname_R),5.9)
-               NO_UNSETENV = YesPlease
-               NO_SETENV = YesPlease
-               NO_STRTOUMAX = YesPlease
-               GIT_TEST_CMP = cmp
-       endif
-       INSTALL = /usr/ucb/install
-       TAR = gtar
-       BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__ -DHAVE_ALLOCA_H
-endif
-ifeq ($(uname_O),Cygwin)
-       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
-               CYGWIN_V15_WIN32API = YesPlease
-       endif
-       NO_THREAD_SAFE_PREAD = YesPlease
-       NEEDS_LIBICONV = YesPlease
-       NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
-       NO_TRUSTABLE_FILEMODE = 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
-       X = .exe
-       COMPAT_OBJS += compat/cygwin.o
-       UNRELIABLE_FSTAT = UnfortunatelyYes
-       SPARSE_FLAGS = -isystem /usr/include/w32api -Wno-one-bit-signed-bitfield
-endif
-ifeq ($(uname_S),FreeBSD)
-       NEEDS_LIBICONV = YesPlease
-       OLD_ICONV = YesPlease
-       NO_MEMMEM = YesPlease
-       BASIC_CFLAGS += -I/usr/local/include
-       BASIC_LDFLAGS += -L/usr/local/lib
-       DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
-       USE_ST_TIMESPEC = YesPlease
-       ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
-               PTHREAD_LIBS = -pthread
-               NO_UINTMAX_T = YesPlease
-               NO_STRTOUMAX = YesPlease
-       endif
-       PYTHON_PATH = /usr/local/bin/python
-       HAVE_PATHS_H = YesPlease
-endif
-ifeq ($(uname_S),OpenBSD)
-       NO_STRCASESTR = YesPlease
-       NO_MEMMEM = YesPlease
-       USE_ST_TIMESPEC = YesPlease
-       NEEDS_LIBICONV = YesPlease
-       BASIC_CFLAGS += -I/usr/local/include
-       BASIC_LDFLAGS += -L/usr/local/lib
-       HAVE_PATHS_H = YesPlease
-endif
-ifeq ($(uname_S),NetBSD)
-       ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
-               NEEDS_LIBICONV = YesPlease
-       endif
-       BASIC_CFLAGS += -I/usr/pkg/include
-       BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
-       USE_ST_TIMESPEC = YesPlease
-       NO_MKSTEMPS = YesPlease
-       HAVE_PATHS_H = YesPlease
-endif
-ifeq ($(uname_S),AIX)
-       DEFAULT_PAGER = more
-       NO_STRCASESTR = YesPlease
-       NO_MEMMEM = YesPlease
-       NO_MKDTEMP = YesPlease
-       NO_MKSTEMPS = YesPlease
-       NO_STRLCPY = YesPlease
-       NO_NSEC = YesPlease
-       FREAD_READS_DIRECTORIES = UnfortunatelyYes
-       INTERNAL_QSORT = UnfortunatelyYes
-       NEEDS_LIBICONV = YesPlease
-       BASIC_CFLAGS += -D_LARGE_FILES
-       ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
-               NO_PTHREADS = YesPlease
-       else
-               PTHREAD_LIBS = -lpthread
-       endif
-       ifeq ($(shell expr "$(uname_V).$(uname_R)" : '5\.1'),3)
-               INLINE = ''
-       endif
-       GIT_TEST_CMP = cmp
-endif
-ifeq ($(uname_S),GNU)
-       # GNU/Hurd
-       NO_STRLCPY = YesPlease
-       NO_MKSTEMPS = YesPlease
-       HAVE_PATHS_H = YesPlease
-       LIBC_CONTAINS_LIBINTL = YesPlease
-endif
-ifeq ($(uname_S),IRIX)
-       NO_SETENV = YesPlease
-       NO_UNSETENV = YesPlease
-       NO_STRCASESTR = YesPlease
-       NO_MEMMEM = YesPlease
-       NO_MKSTEMPS = YesPlease
-       NO_MKDTEMP = YesPlease
-       # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
-       # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
-       # git dies with a segmentation fault when trying to access the first
-       # entry of a reflog.  The conservative choice is made to always set
-       # NO_MMAP.  If you suspect that your compiler is not affected by this
-       # issue, comment out the NO_MMAP statement.
-       NO_MMAP = YesPlease
-       NO_REGEX = YesPlease
-       NO_FNMATCH_CASEFOLD = YesPlease
-       SNPRINTF_RETURNS_BOGUS = YesPlease
-       SHELL_PATH = /usr/gnu/bin/bash
-       NEEDS_LIBGEN = YesPlease
-endif
-ifeq ($(uname_S),IRIX64)
-       NO_SETENV = YesPlease
-       NO_UNSETENV = YesPlease
-       NO_STRCASESTR = YesPlease
-       NO_MEMMEM = YesPlease
-       NO_MKSTEMPS = YesPlease
-       NO_MKDTEMP = YesPlease
-       # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
-       # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
-       # git dies with a segmentation fault when trying to access the first
-       # entry of a reflog.  The conservative choice is made to always set
-       # NO_MMAP.  If you suspect that your compiler is not affected by this
-       # issue, comment out the NO_MMAP statement.
-       NO_MMAP = YesPlease
-       NO_REGEX = YesPlease
-       NO_FNMATCH_CASEFOLD = YesPlease
-       SNPRINTF_RETURNS_BOGUS = YesPlease
-       SHELL_PATH = /usr/gnu/bin/bash
-       NEEDS_LIBGEN = YesPlease
-endif
-ifeq ($(uname_S),HP-UX)
-       INLINE = __inline
-       NO_IPV6 = YesPlease
-       NO_SETENV = YesPlease
-       NO_STRCASESTR = YesPlease
-       NO_MEMMEM = YesPlease
-       NO_MKSTEMPS = YesPlease
-       NO_STRLCPY = YesPlease
-       NO_MKDTEMP = YesPlease
-       NO_UNSETENV = YesPlease
-       NO_HSTRERROR = YesPlease
-       NO_SYS_SELECT_H = YesPlease
-       NO_FNMATCH_CASEFOLD = YesPlease
-       SNPRINTF_RETURNS_BOGUS = YesPlease
-       NO_NSEC = YesPlease
-       ifeq ($(uname_R),B.11.00)
-               NO_INET_NTOP = YesPlease
-               NO_INET_PTON = YesPlease
-       endif
-       ifeq ($(uname_R),B.10.20)
-               # Override HP-UX 11.x setting:
-               INLINE =
-               SOCKLEN_T = size_t
-               NO_PREAD = YesPlease
-               NO_INET_NTOP = YesPlease
-               NO_INET_PTON = YesPlease
-       endif
-       GIT_TEST_CMP = cmp
-endif
-ifeq ($(uname_S),Windows)
-       GIT_VERSION := $(GIT_VERSION).MSVC
-       pathsep = ;
-       NO_PREAD = YesPlease
-       NEEDS_CRYPTO_WITH_SSL = YesPlease
-       NO_LIBGEN_H = YesPlease
-       NO_POLL = YesPlease
-       NO_SYMLINK_HEAD = YesPlease
-       NO_IPV6 = YesPlease
-       NO_UNIX_SOCKETS = YesPlease
-       NO_SETENV = YesPlease
-       NO_UNSETENV = YesPlease
-       NO_STRCASESTR = YesPlease
-       NO_STRLCPY = YesPlease
-       NO_STRTOK_R = YesPlease
-       NO_FNMATCH = YesPlease
-       NO_MEMMEM = YesPlease
-       # NEEDS_LIBICONV = YesPlease
-       NO_ICONV = YesPlease
-       NO_STRTOUMAX = YesPlease
-       NO_STRTOULL = YesPlease
-       NO_MKDTEMP = YesPlease
-       NO_MKSTEMPS = YesPlease
-       SNPRINTF_RETURNS_BOGUS = YesPlease
-       NO_SVN_TESTS = YesPlease
-       NO_PERL_MAKEMAKER = YesPlease
-       RUNTIME_PREFIX = YesPlease
-       NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
-       NO_NSEC = YesPlease
-       USE_WIN32_MMAP = YesPlease
-       # USE_NED_ALLOCATOR = YesPlease
-       UNRELIABLE_FSTAT = UnfortunatelyYes
-       OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
-       NO_REGEX = YesPlease
-       NO_CURL = YesPlease
-       NO_PYTHON = YesPlease
-       BLK_SHA1 = YesPlease
-       NO_POSIX_GOODIES = UnfortunatelyYes
-       NATIVE_CRLF = YesPlease
-       DEFAULT_HELP_FORMAT = html
-
-       CC = compat/vcbuild/scripts/clink.pl
-       AR = compat/vcbuild/scripts/lib.pl
-       CFLAGS =
-       BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
-       COMPAT_OBJS = compat/msvc.o compat/winansi.o \
-               compat/win32/pthread.o compat/win32/syslog.o \
-               compat/win32/dirent.o
-       COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
-       BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib
-       EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib
-       PTHREAD_LIBS =
-       lib =
-ifndef DEBUG
-       BASIC_CFLAGS += -GL -Os -MT
-       BASIC_LDFLAGS += -LTCG
-       AR += -LTCG
-else
-       BASIC_CFLAGS += -Zi -MTd
-endif
-       X = .exe
-endif
-ifeq ($(uname_S),Interix)
-       NO_INITGROUPS = YesPlease
-       NO_IPV6 = YesPlease
-       NO_MEMMEM = YesPlease
-       NO_MKDTEMP = YesPlease
-       NO_STRTOUMAX = YesPlease
-       NO_NSEC = YesPlease
-       NO_MKSTEMPS = YesPlease
-       ifeq ($(uname_R),3.5)
-               NO_INET_NTOP = YesPlease
-               NO_INET_PTON = YesPlease
-               NO_SOCKADDR_STORAGE = YesPlease
-               NO_FNMATCH_CASEFOLD = YesPlease
-       endif
-       ifeq ($(uname_R),5.2)
-               NO_INET_NTOP = YesPlease
-               NO_INET_PTON = YesPlease
-               NO_SOCKADDR_STORAGE = YesPlease
-               NO_FNMATCH_CASEFOLD = YesPlease
-       endif
-endif
-ifeq ($(uname_S),Minix)
-       NO_IPV6 = YesPlease
-       NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
-       NO_NSEC = YesPlease
-       NEEDS_LIBGEN =
-       NEEDS_CRYPTO_WITH_SSL = YesPlease
-       NEEDS_IDN_WITH_CURL = YesPlease
-       NEEDS_SSL_WITH_CURL = YesPlease
-       NEEDS_RESOLV =
-       NO_HSTRERROR = YesPlease
-       NO_MMAP = YesPlease
-       NO_CURL =
-       NO_EXPAT =
-endif
-ifeq ($(uname_S),NONSTOP_KERNEL)
-       # Needs some C99 features, "inline" is just one of them.
-       # INLINE='' would just replace one set of warnings with another and
-       # still not compile in c89 mode, due to non-const array initializations.
-       CC = cc -c99
-       # Disable all optimization, seems to result in bad code, with -O or -O2
-       # or even -O1 (default), /usr/local/libexec/git-core/git-pack-objects
-       # abends on "git push". Needs more investigation.
-       CFLAGS = -g -O0
-       # We'd want it to be here.
-       prefix = /usr/local
-       # Our's are in ${prefix}/bin (perl might also be in /usr/bin/perl).
-       PERL_PATH = ${prefix}/bin/perl
-       PYTHON_PATH = ${prefix}/bin/python
-
-       # As detected by './configure'.
-       # Missdetected, hence commented out, see below.
-       #NO_CURL = YesPlease
-       # Added manually, see above.
-       NEEDS_SSL_WITH_CURL = YesPlease
-       HAVE_LIBCHARSET_H = YesPlease
-       NEEDS_LIBICONV = YesPlease
-       NEEDS_LIBINTL_BEFORE_LIBICONV = YesPlease
-       NO_SYS_SELECT_H = UnfortunatelyYes
-       NO_D_TYPE_IN_DIRENT = YesPlease
-       NO_HSTRERROR = YesPlease
-       NO_STRCASESTR = YesPlease
-       NO_FNMATCH_CASEFOLD = YesPlease
-       NO_MEMMEM = YesPlease
-       NO_STRLCPY = YesPlease
-       NO_SETENV = YesPlease
-       NO_UNSETENV = YesPlease
-       NO_MKDTEMP = YesPlease
-       NO_MKSTEMPS = YesPlease
-       # Currently libiconv-1.9.1.
-       OLD_ICONV = UnfortunatelyYes
-       NO_REGEX = YesPlease
-       NO_PTHREADS = UnfortunatelyYes
-
-       # Not detected (nor checked for) by './configure'.
-       # We don't have SA_RESTART on NonStop, unfortunalety.
-       COMPAT_CFLAGS += -DSA_RESTART=0
-       # Apparently needed in compat/fnmatch/fnmatch.c.
-       COMPAT_CFLAGS += -DHAVE_STRING_H=1
-       NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
-       NO_NSEC = YesPlease
-       NO_PREAD = YesPlease
-       NO_MMAP = YesPlease
-       NO_POLL = YesPlease
-       NO_INTPTR_T = UnfortunatelyYes
-       # Bug report 10-120822-4477 submitted to HP NonStop development.
-       MKDIR_WO_TRAILING_SLASH = YesPlease
-       # RFE 10-120912-4693 submitted to HP NonStop development.
-       NO_SETITIMER = UnfortunatelyYes
-       SANE_TOOL_PATH = /usr/coreutils/bin:/usr/local/bin
-       SHELL_PATH = /usr/local/bin/bash
-       # as of H06.25/J06.14, we might better use this
-       #SHELL_PATH = /usr/coreutils/bin/bash
-endif
-ifneq (,$(findstring MINGW,$(uname_S)))
-       pathsep = ;
-       NO_PREAD = YesPlease
-       NEEDS_CRYPTO_WITH_SSL = YesPlease
-       NO_LIBGEN_H = YesPlease
-       NO_POLL = YesPlease
-       NO_SYMLINK_HEAD = YesPlease
-       NO_UNIX_SOCKETS = YesPlease
-       NO_SETENV = YesPlease
-       NO_UNSETENV = YesPlease
-       NO_STRCASESTR = YesPlease
-       NO_STRLCPY = YesPlease
-       NO_STRTOK_R = YesPlease
-       NO_FNMATCH = YesPlease
-       NO_MEMMEM = YesPlease
-       NEEDS_LIBICONV = YesPlease
-       OLD_ICONV = YesPlease
-       NO_STRTOUMAX = YesPlease
-       NO_MKDTEMP = YesPlease
-       NO_MKSTEMPS = YesPlease
-       NO_SVN_TESTS = YesPlease
-       NO_PERL_MAKEMAKER = YesPlease
-       RUNTIME_PREFIX = YesPlease
-       NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
-       NO_NSEC = YesPlease
-       USE_WIN32_MMAP = YesPlease
-       USE_NED_ALLOCATOR = YesPlease
-       UNRELIABLE_FSTAT = UnfortunatelyYes
-       OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
-       NO_REGEX = YesPlease
-       NO_PYTHON = YesPlease
-       BLK_SHA1 = YesPlease
-       ETAGS_TARGET = ETAGS
-       NO_INET_PTON = YesPlease
-       NO_INET_NTOP = YesPlease
-       NO_POSIX_GOODIES = UnfortunatelyYes
-       COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/win32
-       COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
-       COMPAT_OBJS += compat/mingw.o compat/winansi.o \
-               compat/win32/pthread.o compat/win32/syslog.o \
-               compat/win32/dirent.o
-       EXTLIBS += -lws2_32
-       PTHREAD_LIBS =
-       X = .exe
-       SPARSE_FLAGS = -Wno-one-bit-signed-bitfield
-ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
-       htmldir = doc/git/html/
-       prefix =
-       INSTALL = /bin/install
-       EXTLIBS += /mingw/lib/libz.a
-       NO_R_TO_GCC_LINKER = YesPlease
-       INTERNAL_QSORT = YesPlease
-       HAVE_LIBCHARSET_H = YesPlease
-else
-       NO_CURL = YesPlease
-endif
-endif
-
+include config.mak.uname
 -include config.mak.autogen
 -include config.mak
 
@@ -1655,6 +1151,9 @@ endif
 ifdef NO_D_INO_IN_DIRENT
        BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
 endif
+ifdef NO_GECOS_IN_PWENT
+       BASIC_CFLAGS += -DNO_GECOS_IN_PWENT
+endif
 ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
        BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
 endif
@@ -1748,6 +1247,9 @@ endif
 ifdef NO_SYS_POLL_H
        BASIC_CFLAGS += -DNO_SYS_POLL_H
 endif
+ifdef NEEDS_SYS_PARAM_H
+       BASIC_CFLAGS += -DNEEDS_SYS_PARAM_H
+endif
 ifdef NO_INTTYPES_H
        BASIC_CFLAGS += -DNO_INTTYPES_H
 endif
@@ -1859,6 +1361,9 @@ ifdef NO_MEMMEM
        COMPAT_CFLAGS += -DNO_MEMMEM
        COMPAT_OBJS += compat/memmem.o
 endif
+ifdef NO_GETPAGESIZE
+       COMPAT_CFLAGS += -DNO_GETPAGESIZE
+endif
 ifdef INTERNAL_QSORT
        COMPAT_CFLAGS += -DINTERNAL_QSORT
        COMPAT_OBJS += compat/qsort.o
@@ -1884,6 +1389,10 @@ ifdef HAVE_LIBCHARSET_H
        EXTLIBS += $(CHARSET_LIB)
 endif
 
+ifdef HAVE_STRINGS_H
+       BASIC_CFLAGS += -DHAVE_STRINGS_H
+endif
+
 ifdef HAVE_DEV_TTY
        BASIC_CFLAGS += -DHAVE_DEV_TTY
 endif
@@ -2183,7 +1692,7 @@ endef
 GIT-SCRIPT-DEFINES: FORCE
        @FLAGS='$(SCRIPT_DEFINES)'; \
            if test x"$$FLAGS" != x"`cat $@ 2>/dev/null`" ; then \
-               echo 1>&2 "    * new script parameters"; \
+               echo >&2 "    * new script parameters"; \
                echo "$$FLAGS" >$@; \
             fi
 
@@ -2245,7 +1754,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
 endif # NO_PERL
 
 ifndef NO_PYTHON
-$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX
+$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS
 $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
        $(QUIET_GEN)$(RM) $@ $@+ && \
        INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
@@ -2275,8 +1784,14 @@ configure: configure.ac GIT-VERSION-FILE
        $(RM) $<+
 
 ifdef AUTOCONFIGURED
-config.status: configure
-       $(QUIET_GEN)if test -f config.status; then \
+# We avoid depending on 'configure' here, because it gets rebuilt
+# every time GIT-VERSION-FILE is modified, only to update the embedded
+# version number string, which config.status does not care about.  We
+# do want to recheck when the platform/environment detection logic
+# changes, hence this depends on configure.ac.
+config.status: configure.ac
+       $(QUIET_GEN)$(MAKE) configure && \
+       if test -f config.status; then \
          ./config.status --recheck; \
        else \
          ./configure; \
@@ -2564,7 +2079,7 @@ TRACK_PREFIX = $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\
 GIT-PREFIX: FORCE
        @FLAGS='$(TRACK_PREFIX)'; \
        if test x"$$FLAGS" != x"`cat GIT-PREFIX 2>/dev/null`" ; then \
-               echo 1>&2 "    * new prefix flags"; \
+               echo >&2 "    * new prefix flags"; \
                echo "$$FLAGS" >GIT-PREFIX; \
        fi
 
@@ -2573,7 +2088,7 @@ TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):$(USE_GETTEXT_SCHEME)
 GIT-CFLAGS: FORCE
        @FLAGS='$(TRACK_CFLAGS)'; \
            if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
-               echo 1>&2 "    * new build flags"; \
+               echo >&2 "    * new build flags"; \
                echo "$$FLAGS" >GIT-CFLAGS; \
             fi
 
@@ -2582,7 +2097,7 @@ TRACK_LDFLAGS = $(subst ','\'',$(ALL_LDFLAGS))
 GIT-LDFLAGS: FORCE
        @FLAGS='$(TRACK_LDFLAGS)'; \
            if test x"$$FLAGS" != x"`cat GIT-LDFLAGS 2>/dev/null`" ; then \
-               echo 1>&2 "    * new link flags"; \
+               echo >&2 "    * new link flags"; \
                echo "$$FLAGS" >GIT-LDFLAGS; \
             fi
 
@@ -2624,14 +2139,14 @@ ifdef GIT_PERF_MAKE_OPTS
        @echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_MAKE_OPTS)))'\' >>$@
 endif
 
-### Detect Tck/Tk interpreter path changes
-ifndef NO_TCLTK
-TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
+### Detect Python interpreter path changes
+ifndef NO_PYTHON
+TRACK_PYTHON = $(subst ','\'',-DPYTHON_PATH='$(PYTHON_PATH_SQ)')
 
-GIT-GUI-VARS: FORCE
-       @VARS='$(TRACK_VARS)'; \
+GIT-PYTHON-VARS: FORCE
+       @VARS='$(TRACK_PYTHON)'; \
            if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
-               echo 1>&2 "    * new Tcl/Tk interpreter location"; \
+               echo >&2 "    * new Python interpreter location"; \
                echo "$$VARS" >$@; \
             fi
 endif
@@ -2910,8 +2425,8 @@ ifndef NO_TCLTK
        $(MAKE) -C gitk-git clean
        $(MAKE) -C git-gui clean
 endif
-       $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
-       $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES
+       $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
+       $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES GIT-PYTHON-VARS
 
 .PHONY: all install profile-clean clean strip
 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
diff --git a/README b/README
index d2690ec8dc6e5f054c33a5f3b4c26f6ad038706d..49713ea08e6aa107d9e164de6c06a0b8fc5125f4 100644 (file)
--- a/README
+++ b/README
@@ -19,9 +19,10 @@ Git is a fast, scalable, distributed revision control system with an
 unusually rich command set that provides both high-level operations
 and full access to internals.
 
-Git is an Open Source project covered by the GNU General Public License.
-It was originally written by Linus Torvalds with help of a group of
-hackers around the net. It is currently maintained by Junio C Hamano.
+Git is an Open Source project covered by the GNU General Public
+License version 2 (some parts of it are under different licenses,
+compatible with the GPLv2). It was originally written by Linus
+Torvalds with help of a group of hackers around the net.
 
 Please read the file INSTALL for installation instructions.
 
index 28607146f3fec3b69cf5edacf2727e37ca2c89de..bdce3136ea5164d82f0d25d0a7a8b50181f572f7 120000 (symlink)
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes/1.8.1.txt
\ No newline at end of file
+Documentation/RelNotes/1.8.2.txt
\ No newline at end of file
index 05f2d7934878a832f5a2efdf4222c16223050853..40cdc46219d4eba87ba947d9f5556eb80dfdfa9b 100644 (file)
--- a/abspath.c
+++ b/abspath.c
@@ -15,16 +15,34 @@ int is_directory(const char *path)
 #define MAXDEPTH 5
 
 /*
- * Use this to get the real path, i.e. resolve links. If you want an
- * absolute path but don't mind links, use absolute_path.
+ * Return the real path (i.e., absolute path, with symlinks resolved
+ * and extra slashes removed) equivalent to the specified path.  (If
+ * you want an absolute path but don't mind links, use
+ * absolute_path().)  The return value is a pointer to a static
+ * buffer.
+ *
+ * The input and all intermediate paths must be shorter than MAX_PATH.
+ * The directory part of path (i.e., everything up to the last
+ * dir_sep) must denote a valid, existing directory, but the last
+ * component need not exist.  If die_on_error is set, then die with an
+ * informative error message if there is a problem.  Otherwise, return
+ * NULL on errors (without generating any output).
  *
  * If path is our buffer, then return path, as it's already what the
  * user wants.
  */
-const char *real_path(const char *path)
+static const char *real_path_internal(const char *path, int die_on_error)
 {
        static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
+       char *retval = NULL;
+
+       /*
+        * If we have to temporarily chdir(), store the original CWD
+        * here so that we can chdir() back to it at the end of the
+        * function:
+        */
        char cwd[1024] = "";
+
        int buf_index = 1;
 
        int depth = MAXDEPTH;
@@ -35,11 +53,19 @@ const char *real_path(const char *path)
        if (path == buf || path == next_buf)
                return path;
 
-       if (!*path)
-               die("The empty string is not a valid path");
+       if (!*path) {
+               if (die_on_error)
+                       die("The empty string is not a valid path");
+               else
+                       goto error_out;
+       }
 
-       if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
-               die ("Too long path: %.*s", 60, path);
+       if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX) {
+               if (die_on_error)
+                       die("Too long path: %.*s", 60, path);
+               else
+                       goto error_out;
+       }
 
        while (depth--) {
                if (!is_directory(buf)) {
@@ -54,20 +80,36 @@ const char *real_path(const char *path)
                }
 
                if (*buf) {
-                       if (!*cwd && !getcwd(cwd, sizeof(cwd)))
-                               die_errno ("Could not get current working directory");
+                       if (!*cwd && !getcwd(cwd, sizeof(cwd))) {
+                               if (die_on_error)
+                                       die_errno("Could not get current working directory");
+                               else
+                                       goto error_out;
+                       }
 
-                       if (chdir(buf))
-                               die_errno ("Could not switch to '%s'", buf);
+                       if (chdir(buf)) {
+                               if (die_on_error)
+                                       die_errno("Could not switch to '%s'", buf);
+                               else
+                                       goto error_out;
+                       }
+               }
+               if (!getcwd(buf, PATH_MAX)) {
+                       if (die_on_error)
+                               die_errno("Could not get current working directory");
+                       else
+                               goto error_out;
                }
-               if (!getcwd(buf, PATH_MAX))
-                       die_errno ("Could not get current working directory");
 
                if (last_elem) {
                        size_t len = strlen(buf);
-                       if (len + strlen(last_elem) + 2 > PATH_MAX)
-                               die ("Too long path name: '%s/%s'",
-                                               buf, last_elem);
+                       if (len + strlen(last_elem) + 2 > PATH_MAX) {
+                               if (die_on_error)
+                                       die("Too long path name: '%s/%s'",
+                                           buf, last_elem);
+                               else
+                                       goto error_out;
+                       }
                        if (len && !is_dir_sep(buf[len-1]))
                                buf[len++] = '/';
                        strcpy(buf + len, last_elem);
@@ -77,10 +119,18 @@ const char *real_path(const char *path)
 
                if (!lstat(buf, &st) && S_ISLNK(st.st_mode)) {
                        ssize_t len = readlink(buf, next_buf, PATH_MAX);
-                       if (len < 0)
-                               die_errno ("Invalid symlink '%s'", buf);
-                       if (PATH_MAX <= len)
-                               die("symbolic link too long: %s", buf);
+                       if (len < 0) {
+                               if (die_on_error)
+                                       die_errno("Invalid symlink '%s'", buf);
+                               else
+                                       goto error_out;
+                       }
+                       if (PATH_MAX <= len) {
+                               if (die_on_error)
+                                       die("symbolic link too long: %s", buf);
+                               else
+                                       goto error_out;
+                       }
                        next_buf[len] = '\0';
                        buf = next_buf;
                        buf_index = 1 - buf_index;
@@ -89,10 +139,23 @@ const char *real_path(const char *path)
                        break;
        }
 
+       retval = buf;
+error_out:
+       free(last_elem);
        if (*cwd && chdir(cwd))
                die_errno ("Could not change back to '%s'", cwd);
 
-       return buf;
+       return retval;
+}
+
+const char *real_path(const char *path)
+{
+       return real_path_internal(path, 1);
+}
+
+const char *real_path_if_valid(const char *path)
+{
+       return real_path_internal(path, 0);
 }
 
 static const char *get_pwd_cwd(void)
index edfbd4a6fb01a6905671d6d842d22c4869fad729..d2879272802cb3477dd6b47a78098ffdc26dcb37 100644 (file)
--- a/advice.c
+++ b/advice.c
@@ -1,9 +1,10 @@
 #include "cache.h"
 
-int advice_push_nonfastforward = 1;
+int advice_push_update_rejected = 1;
 int advice_push_non_ff_current = 1;
 int advice_push_non_ff_default = 1;
 int advice_push_non_ff_matching = 1;
+int advice_push_already_exists = 1;
 int advice_status_hints = 1;
 int advice_commit_before_merge = 1;
 int advice_resolve_conflict = 1;
@@ -14,15 +15,19 @@ static struct {
        const char *name;
        int *preference;
 } advice_config[] = {
-       { "pushnonfastforward", &advice_push_nonfastforward },
+       { "pushupdaterejected", &advice_push_update_rejected },
        { "pushnonffcurrent", &advice_push_non_ff_current },
        { "pushnonffdefault", &advice_push_non_ff_default },
        { "pushnonffmatching", &advice_push_non_ff_matching },
+       { "pushalreadyexists", &advice_push_already_exists },
        { "statushints", &advice_status_hints },
        { "commitbeforemerge", &advice_commit_before_merge },
        { "resolveconflict", &advice_resolve_conflict },
        { "implicitidentity", &advice_implicit_identity },
        { "detachedhead", &advice_detached_head },
+
+       /* make this an alias for backward compatibility */
+       { "pushnonfastforward", &advice_push_update_rejected }
 };
 
 void advise(const char *advice, ...)
index f3cdbbf29e570e151b2b6b329ee9a9940ae59a98..8bf63563a5cf1573e0e6bf7ffcd5c55643d3f439 100644 (file)
--- a/advice.h
+++ b/advice.h
@@ -3,10 +3,11 @@
 
 #include "git-compat-util.h"
 
-extern int advice_push_nonfastforward;
+extern int advice_push_update_rejected;
 extern int advice_push_non_ff_current;
 extern int advice_push_non_ff_default;
 extern int advice_push_non_ff_matching;
+extern int advice_push_already_exists;
 extern int advice_status_hints;
 extern int advice_commit_before_merge;
 extern int advice_resolve_conflict;
index 0ba3f25cf579d6629566a39d4d5ac19b51293ed5..d1cce46e3310d64af32b231de697449ae90ddccf 100644 (file)
@@ -153,6 +153,8 @@ static unsigned int ustar_header_chksum(const struct ustar_header *header)
 static size_t get_path_prefix(const char *path, size_t pathlen, size_t maxlen)
 {
        size_t i = pathlen;
+       if (i > 1 && path[i - 1] == '/')
+               i--;
        if (i > maxlen)
                i = maxlen;
        do {
index 55f66b4060c64789bdb443f6c71f82a75ef22d0b..d3aef532b7e4b844f2ac9995b2e987d378737079 100644 (file)
@@ -240,7 +240,7 @@ static int write_zip_entry(struct archiver_args *args,
                        (mode & 0111) ? ((mode) << 16) : 0;
                if (S_ISREG(mode) && args->compression_level != 0 && size > 0)
                        method = 8;
-               compressed_size = size;
+               compressed_size = (method == 0) ? size : 0;
 
                if (S_ISREG(mode) && type == OBJ_BLOB && !args->convert &&
                    size > big_file_threshold) {
@@ -313,10 +313,7 @@ static int write_zip_entry(struct archiver_args *args,
        copy_le16(header.compression_method, method);
        copy_le16(header.mtime, zip_time);
        copy_le16(header.mdate, zip_date);
-       if (flags & ZIP_STREAM)
-               set_zip_header_data_desc(&header, 0, 0, 0);
-       else
-               set_zip_header_data_desc(&header, size, compressed_size, crc);
+       set_zip_header_data_desc(&header, size, compressed_size, crc);
        copy_le16(header.filename_length, pathlen);
        copy_le16(header.extra_length, ZIP_EXTRA_MTIME_SIZE);
        write_or_die(1, &header, ZIP_LOCAL_HEADER_SIZE);
index 466640479ecb332d8d06f6f26254023eb6e22c85..93e00bb4ae8ff9637be9e55fd41536b8837c3ba2 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -120,6 +120,8 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
        strbuf_add(&path, args->base, args->baselen);
        strbuf_add(&path, base, baselen);
        strbuf_addstr(&path, filename);
+       if (S_ISDIR(mode) || S_ISGITLINK(mode))
+               strbuf_addch(&path, '/');
        path_without_prefix = path.buf + args->baselen;
 
        setup_archive_check(check);
@@ -130,7 +132,6 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
        }
 
        if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
-               strbuf_addch(&path, '/');
                if (args->verbose)
                        fprintf(stderr, "%.*s\n", (int)path.len, path.buf);
                err = write_entry(args, sha1, path.buf, path.len, mode);
diff --git a/attr.c b/attr.c
index 097ae87f3c2b4093fffe6586f036918367fa672e..4657cc233c4aa7cff90e745a58ac7ad0a5fa8cd2 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -284,7 +284,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
  * (reading the file from top to bottom), .gitattribute of the root
  * directory (again, reading the file from top to bottom) down to the
  * current directory, and then scan the list backwards to find the first match.
- * This is exactly the same as what excluded() does in dir.c to deal with
+ * This is exactly the same as what is_excluded() does in dir.c to deal with
  * .gitignore
  */
 
@@ -564,18 +564,12 @@ static void bootstrap_attr_stack(void)
        attr_stack = elem;
 }
 
-static void prepare_attr_stack(const char *path)
+static void prepare_attr_stack(const char *path, int dirlen)
 {
        struct attr_stack *elem, *info;
-       int dirlen, len;
+       int len;
        const char *cp;
 
-       cp = strrchr(path, '/');
-       if (!cp)
-               dirlen = 0;
-       else
-               dirlen = cp - path;
-
        /*
         * At the bottom of the attribute stack is the built-in
         * set of attribute definitions, followed by the contents
@@ -668,6 +662,10 @@ static int path_matches(const char *pathname, int pathlen,
        const char *pattern = pat->pattern;
        int prefix = pat->nowildcardlen;
 
+       if ((pat->flags & EXC_FLAG_MUSTBEDIR) &&
+           ((!pathlen) || (pathname[pathlen-1] != '/')))
+               return 0;
+
        if (pat->flags & EXC_FLAG_NODIR) {
                return match_basename(basename,
                                      pathlen - (basename - pathname),
@@ -693,7 +691,7 @@ static int fill_one(const char *what, struct match_attr *a, int rem)
 
                if (*n == ATTR__UNKNOWN) {
                        debug_set(what,
-                                 a->is_macro ? a->u.attr->name : a->u.pattern,
+                                 a->is_macro ? a->u.attr->name : a->u.pat.pattern,
                                  attr, v);
                        *n = v;
                        rem--;
@@ -751,17 +749,26 @@ static int macroexpand_one(int attr_nr, int rem)
 static void collect_all_attrs(const char *path)
 {
        struct attr_stack *stk;
-       int i, pathlen, rem;
-       const char *basename;
+       int i, pathlen, rem, dirlen;
+       const char *basename, *cp, *last_slash = NULL;
 
-       prepare_attr_stack(path);
+       for (cp = path; *cp; cp++) {
+               if (*cp == '/' && cp[1])
+                       last_slash = cp;
+       }
+       pathlen = cp - path;
+       if (last_slash) {
+               basename = last_slash + 1;
+               dirlen = last_slash - path;
+       } else {
+               basename = path;
+               dirlen = 0;
+       }
+
+       prepare_attr_stack(path, dirlen);
        for (i = 0; i < attr_nr; i++)
                check_all_attr[i].value = ATTR__UNKNOWN;
 
-       basename = strrchr(path, '/');
-       basename = basename ? basename + 1 : path;
-
-       pathlen = strlen(path);
        rem = attr_nr;
        for (stk = attr_stack; 0 < rem && stk; stk = stk->prev)
                rem = fill(path, pathlen, basename, stk, rem);
index 3faf9d6691413c006f4c82702aa5e0c5e4bc88a0..7e7bbd665a905b0fdf9ce5351f6f09dfd3dd7e8a 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -15,7 +15,8 @@ extern const char git_more_info_string[];
 extern void prune_packed_objects(int);
 
 struct fmt_merge_msg_opts {
-       unsigned add_title:1;
+       unsigned add_title:1,
+               credit_people:1;
        int shortlog_len;
 };
 
index e664100c7122d6c4116763716c2260756feffac2..075312afcd8813c3a7dbf08f6be519a37498fe4f 100644 (file)
@@ -454,7 +454,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                            && !file_exists(pathspec[i])) {
                                if (ignore_missing) {
                                        int dtype = DT_UNKNOWN;
-                                       if (path_excluded(&check, pathspec[i], -1, &dtype))
+                                       if (is_path_excluded(&check, pathspec[i], -1, &dtype))
                                                dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
                                } else
                                        die(_("pathspec '%s' did not match any files"),
index 156b3ce3b72f51013baacff0a8ffd37ac97e6158..6c11e8bc73892b15f91fcb65d65e18ee05956ec8 100644 (file)
@@ -2095,7 +2095,7 @@ static void update_pre_post_images(struct image *preimage,
                                   char *buf,
                                   size_t len, size_t postlen)
 {
-       int i, ctx;
+       int i, ctx, reduced;
        char *new, *old, *fixed;
        struct image fixed_preimage;
 
@@ -2105,8 +2105,10 @@ static void update_pre_post_images(struct image *preimage,
         * free "oldlines".
         */
        prepare_image(&fixed_preimage, buf, len, 1);
-       assert(fixed_preimage.nr == preimage->nr);
-       for (i = 0; i < preimage->nr; i++)
+       assert(postlen
+              ? fixed_preimage.nr == preimage->nr
+              : fixed_preimage.nr <= preimage->nr);
+       for (i = 0; i < fixed_preimage.nr; i++)
                fixed_preimage.line[i].flag = preimage->line[i].flag;
        free(preimage->line_allocated);
        *preimage = fixed_preimage;
@@ -2126,7 +2128,8 @@ static void update_pre_post_images(struct image *preimage,
        else
                new = old;
        fixed = preimage->buf;
-       for (i = ctx = 0; i < postimage->nr; i++) {
+
+       for (i = reduced = ctx = 0; i < postimage->nr; i++) {
                size_t len = postimage->line[i].len;
                if (!(postimage->line[i].flag & LINE_COMMON)) {
                        /* an added line -- no counterparts in preimage */
@@ -2145,8 +2148,15 @@ static void update_pre_post_images(struct image *preimage,
                        fixed += preimage->line[ctx].len;
                        ctx++;
                }
-               if (preimage->nr <= ctx)
-                       die(_("oops"));
+
+               /*
+                * preimage is expected to run out, if the caller
+                * fixed addition of trailing blank lines.
+                */
+               if (preimage->nr <= ctx) {
+                       reduced++;
+                       continue;
+               }
 
                /* and copy it in, while fixing the line length */
                len = preimage->line[ctx].len;
@@ -2159,6 +2169,7 @@ static void update_pre_post_images(struct image *preimage,
 
        /* Fix the length of the whole thing */
        postimage->len = new - postimage->buf;
+       postimage->nr -= reduced;
 }
 
 static int match_fragment(struct image *img,
index cfae5699051312943d90212fc9cbfda2aafb2288..b431ba320997918324a76c29b81dd01613cfa9db 100644 (file)
@@ -42,6 +42,7 @@ static int blank_boundary;
 static int incremental;
 static int xdl_opts;
 static int abbrev = -1;
+static int no_whole_file_rename;
 
 static enum date_mode blame_date_mode = DATE_ISO8601;
 static size_t blame_date_width;
@@ -1226,7 +1227,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
         * The first pass looks for unrenamed path to optimize for
         * common cases, then we look for renames in the second pass.
         */
-       for (pass = 0; pass < 2; pass++) {
+       for (pass = 0; pass < 2 - no_whole_file_rename; pass++) {
                struct origin *(*find)(struct scoreboard *,
                                       struct commit *, struct origin *);
                find = pass ? find_rename : find_origin;
@@ -1321,30 +1322,31 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
  * Information on commits, used for output.
  */
 struct commit_info {
-       const char *author;
-       const char *author_mail;
+       struct strbuf author;
+       struct strbuf author_mail;
        unsigned long author_time;
-       const char *author_tz;
+       struct strbuf author_tz;
 
        /* filled only when asked for details */
-       const char *committer;
-       const char *committer_mail;
+       struct strbuf committer;
+       struct strbuf committer_mail;
        unsigned long committer_time;
-       const char *committer_tz;
+       struct strbuf committer_tz;
 
-       const char *summary;
+       struct strbuf summary;
 };
 
 /*
  * Parse author/committer line in the commit object buffer
  */
 static void get_ac_line(const char *inbuf, const char *what,
-                       int person_len, char *person,
-                       int mail_len, char *mail,
-                       unsigned long *time, const char **tz)
+       struct strbuf *name, struct strbuf *mail,
+       unsigned long *time, struct strbuf *tz)
 {
-       int len, tzlen, maillen;
-       char *tmp, *endp, *timepos, *mailpos;
+       struct ident_split ident;
+       size_t len, maillen, namelen;
+       char *tmp, *endp;
+       const char *namebuf, *mailbuf;
 
        tmp = strstr(inbuf, what);
        if (!tmp)
@@ -1355,69 +1357,61 @@ static void get_ac_line(const char *inbuf, const char *what,
                len = strlen(tmp);
        else
                len = endp - tmp;
-       if (person_len <= len) {
+
+       if (split_ident_line(&ident, tmp, len)) {
        error_out:
                /* Ugh */
-               *tz = "(unknown)";
-               strcpy(person, *tz);
-               strcpy(mail, *tz);
+               tmp = "(unknown)";
+               strbuf_addstr(name, tmp);
+               strbuf_addstr(mail, tmp);
+               strbuf_addstr(tz, tmp);
                *time = 0;
                return;
        }
-       memcpy(person, tmp, len);
 
-       tmp = person;
-       tmp += len;
-       *tmp = 0;
-       while (person < tmp && *tmp != ' ')
-               tmp--;
-       if (tmp <= person)
-               goto error_out;
-       *tz = tmp+1;
-       tzlen = (person+len)-(tmp+1);
+       namelen = ident.name_end - ident.name_begin;
+       namebuf = ident.name_begin;
 
-       *tmp = 0;
-       while (person < tmp && *tmp != ' ')
-               tmp--;
-       if (tmp <= person)
-               goto error_out;
-       *time = strtoul(tmp, NULL, 10);
-       timepos = tmp;
+       maillen = ident.mail_end - ident.mail_begin;
+       mailbuf = ident.mail_begin;
 
-       *tmp = 0;
-       while (person < tmp && !(*tmp == ' ' && tmp[1] == '<'))
-               tmp--;
-       if (tmp <= person)
-               return;
-       mailpos = tmp + 1;
-       *tmp = 0;
-       maillen = timepos - tmp;
-       memcpy(mail, mailpos, maillen);
+       *time = strtoul(ident.date_begin, NULL, 10);
 
-       if (!mailmap.nr)
-               return;
-
-       /*
-        * mailmap expansion may make the name longer.
-        * make room by pushing stuff down.
-        */
-       tmp = person + person_len - (tzlen + 1);
-       memmove(tmp, *tz, tzlen);
-       tmp[tzlen] = 0;
-       *tz = tmp;
+       len = ident.tz_end - ident.tz_begin;
+       strbuf_add(tz, ident.tz_begin, len);
 
        /*
         * Now, convert both name and e-mail using mailmap
         */
-       if (map_user(&mailmap, mail+1, mail_len-1, person, tmp-person-1)) {
-               /* Add a trailing '>' to email, since map_user returns plain emails
-                  Note: It already has '<', since we replace from mail+1 */
-               mailpos = memchr(mail, '\0', mail_len);
-               if (mailpos && mailpos-mail < mail_len - 1) {
-                       *mailpos = '>';
-                       *(mailpos+1) = '\0';
-               }
-       }
+       map_user(&mailmap, &mailbuf, &maillen,
+                &namebuf, &namelen);
+
+       strbuf_addf(mail, "<%.*s>", (int)maillen, mailbuf);
+       strbuf_add(name, namebuf, namelen);
+}
+
+static void commit_info_init(struct commit_info *ci)
+{
+
+       strbuf_init(&ci->author, 0);
+       strbuf_init(&ci->author_mail, 0);
+       strbuf_init(&ci->author_tz, 0);
+       strbuf_init(&ci->committer, 0);
+       strbuf_init(&ci->committer_mail, 0);
+       strbuf_init(&ci->committer_tz, 0);
+       strbuf_init(&ci->summary, 0);
+}
+
+static void commit_info_destroy(struct commit_info *ci)
+{
+
+       strbuf_release(&ci->author);
+       strbuf_release(&ci->author_mail);
+       strbuf_release(&ci->author_tz);
+       strbuf_release(&ci->committer);
+       strbuf_release(&ci->committer_mail);
+       strbuf_release(&ci->committer_tz);
+       strbuf_release(&ci->summary);
 }
 
 static void get_commit_info(struct commit *commit,
@@ -1427,11 +1421,8 @@ static void get_commit_info(struct commit *commit,
        int len;
        const char *subject, *encoding;
        char *reencoded, *message;
-       static char author_name[1024];
-       static char author_mail[1024];
-       static char committer_name[1024];
-       static char committer_mail[1024];
-       static char summary_buf[1024];
+
+       commit_info_init(ret);
 
        /*
         * We've operated without save_commit_buffer, so
@@ -1449,11 +1440,8 @@ static void get_commit_info(struct commit *commit,
        encoding = get_log_output_encoding();
        reencoded = logmsg_reencode(commit, encoding);
        message   = reencoded ? reencoded : commit->buffer;
-       ret->author = author_name;
-       ret->author_mail = author_mail;
        get_ac_line(message, "\nauthor ",
-                   sizeof(author_name), author_name,
-                   sizeof(author_mail), author_mail,
+                   &ret->author, &ret->author_mail,
                    &ret->author_time, &ret->author_tz);
 
        if (!detailed) {
@@ -1461,21 +1449,16 @@ static void get_commit_info(struct commit *commit,
                return;
        }
 
-       ret->committer = committer_name;
-       ret->committer_mail = committer_mail;
        get_ac_line(message, "\ncommitter ",
-                   sizeof(committer_name), committer_name,
-                   sizeof(committer_mail), committer_mail,
+                   &ret->committer, &ret->committer_mail,
                    &ret->committer_time, &ret->committer_tz);
 
-       ret->summary = summary_buf;
        len = find_commit_subject(message, &subject);
-       if (len && len < sizeof(summary_buf)) {
-               memcpy(summary_buf, subject, len);
-               summary_buf[len] = 0;
-       } else {
-               sprintf(summary_buf, "(%s)", sha1_to_hex(commit->object.sha1));
-       }
+       if (len)
+               strbuf_add(&ret->summary, subject, len);
+       else
+               strbuf_addf(&ret->summary, "(%s)", sha1_to_hex(commit->object.sha1));
+
        free(reencoded);
 }
 
@@ -1504,15 +1487,15 @@ static int emit_one_suspect_detail(struct origin *suspect, int repeat)
 
        suspect->commit->object.flags |= METAINFO_SHOWN;
        get_commit_info(suspect->commit, &ci, 1);
-       printf("author %s\n", ci.author);
-       printf("author-mail %s\n", ci.author_mail);
+       printf("author %s\n", ci.author.buf);
+       printf("author-mail %s\n", ci.author_mail.buf);
        printf("author-time %lu\n", ci.author_time);
-       printf("author-tz %s\n", ci.author_tz);
-       printf("committer %s\n", ci.committer);
-       printf("committer-mail %s\n", ci.committer_mail);
+       printf("author-tz %s\n", ci.author_tz.buf);
+       printf("committer %s\n", ci.committer.buf);
+       printf("committer-mail %s\n", ci.committer_mail.buf);
        printf("committer-time %lu\n", ci.committer_time);
-       printf("committer-tz %s\n", ci.committer_tz);
-       printf("summary %s\n", ci.summary);
+       printf("committer-tz %s\n", ci.committer_tz.buf);
+       printf("summary %s\n", ci.summary.buf);
        if (suspect->commit->object.flags & UNINTERESTING)
                printf("boundary\n");
        if (suspect->previous) {
@@ -1520,6 +1503,9 @@ static int emit_one_suspect_detail(struct origin *suspect, int repeat)
                printf("previous %s ", sha1_to_hex(prev->commit->object.sha1));
                write_name_quoted(prev->path, stdout, '\n');
        }
+
+       commit_info_destroy(&ci);
+
        return 1;
 }
 
@@ -1706,11 +1692,11 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
                if (opt & OUTPUT_ANNOTATE_COMPAT) {
                        const char *name;
                        if (opt & OUTPUT_SHOW_EMAIL)
-                               name = ci.author_mail;
+                               name = ci.author_mail.buf;
                        else
-                               name = ci.author;
+                               name = ci.author.buf;
                        printf("\t(%10s\t%10s\t%d)", name,
-                              format_time(ci.author_time, ci.author_tz,
+                              format_time(ci.author_time, ci.author_tz.buf,
                                           show_raw_time),
                               ent->lno + 1 + cnt);
                } else {
@@ -1729,14 +1715,14 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
                                const char *name;
                                int pad;
                                if (opt & OUTPUT_SHOW_EMAIL)
-                                       name = ci.author_mail;
+                                       name = ci.author_mail.buf;
                                else
-                                       name = ci.author;
+                                       name = ci.author.buf;
                                pad = longest_author - utf8_strwidth(name);
                                printf(" (%s%*s %10s",
                                       name, pad, "",
                                       format_time(ci.author_time,
-                                                  ci.author_tz,
+                                                  ci.author_tz.buf,
                                                   show_raw_time));
                        }
                        printf(" %*d) ",
@@ -1751,6 +1737,8 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
 
        if (sb->final_buf_size && cp[-1] != '\n')
                putchar('\n');
+
+       commit_info_destroy(&ci);
 }
 
 static void output(struct scoreboard *sb, int option)
@@ -1875,9 +1863,9 @@ static void find_alignment(struct scoreboard *sb, int *option)
                        suspect->commit->object.flags |= METAINFO_SHOWN;
                        get_commit_info(suspect->commit, &ci, 1);
                        if (*option & OUTPUT_SHOW_EMAIL)
-                               num = utf8_strwidth(ci.author_mail);
+                               num = utf8_strwidth(ci.author_mail.buf);
                        else
-                               num = utf8_strwidth(ci.author);
+                               num = utf8_strwidth(ci.author.buf);
                        if (longest_author < num)
                                longest_author = num;
                }
@@ -1889,6 +1877,8 @@ static void find_alignment(struct scoreboard *sb, int *option)
                        longest_dst_lines = num;
                if (largest_score < ent_score(sb, e))
                        largest_score = ent_score(sb, e);
+
+               commit_info_destroy(&ci);
        }
        max_orig_digits = decimal_width(longest_src_lines);
        max_digits = decimal_width(longest_dst_lines);
@@ -2403,6 +2393,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
        init_revisions(&revs, NULL);
        revs.date_mode = blame_date_mode;
        DIFF_OPT_SET(&revs.diffopt, ALLOW_TEXTCONV);
+       DIFF_OPT_SET(&revs.diffopt, FOLLOW_RENAMES);
 
        save_commit_buffer = 0;
        dashdash_pos = 0;
@@ -2426,6 +2417,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
                parse_revision_opt(&revs, &ctx, options, blame_opt_usage);
        }
 parse_done:
+       no_whole_file_rename = !DIFF_OPT_TST(&revs.diffopt, FOLLOW_RENAMES);
+       DIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES);
        argc = parse_options_end(&ctx);
 
        if (0 < abbrev)
index 1ec9c02612d0391984b484a5850f45c277a3e804..873f624d1cc70e03da4c67b30f8c839b4afe099d 100644 (file)
@@ -725,7 +725,7 @@ static int edit_branch_description(const char *branch_name)
        stripspace(&buf, 1);
 
        strbuf_addf(&name, "branch.%s.description", branch_name);
-       status = git_config_set(name.buf, buf.buf);
+       status = git_config_set(name.buf, buf.len ? buf.buf : NULL);
        strbuf_release(&name);
        strbuf_release(&buf);
 
index 69c1cda9061f248479377d2841a1ddf703ea59ba..f4b760bf3dcb2371da6ae9d77f2f8fb1c0fa9eb9 100644 (file)
@@ -10,6 +10,7 @@
 #include "cache.h"
 #include "dir.h"
 #include "parse-options.h"
+#include "refs.h"
 #include "string-list.h"
 #include "quote.h"
 
@@ -20,6 +21,12 @@ static const char *const builtin_clean_usage[] = {
        NULL
 };
 
+static const char *msg_remove = N_("Removing %s\n");
+static const char *msg_would_remove = N_("Would remove %s\n");
+static const char *msg_skip_git_dir = N_("Skipping repository %s\n");
+static const char *msg_would_skip_git_dir = N_("Would skip repository %s\n");
+static const char *msg_warn_remove_failed = N_("failed to remove %s");
+
 static int git_clean_config(const char *var, const char *value, void *cb)
 {
        if (!strcmp(var, "clean.requireforce"))
@@ -34,11 +41,112 @@ static int exclude_cb(const struct option *opt, const char *arg, int unset)
        return 0;
 }
 
+static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
+               int dry_run, int quiet, int *dir_gone)
+{
+       DIR *dir;
+       struct strbuf quoted = STRBUF_INIT;
+       struct dirent *e;
+       int res = 0, ret = 0, gone = 1, original_len = path->len, len, i;
+       unsigned char submodule_head[20];
+       struct string_list dels = STRING_LIST_INIT_DUP;
+
+       *dir_gone = 1;
+
+       if ((force_flag & REMOVE_DIR_KEEP_NESTED_GIT) &&
+                       !resolve_gitlink_ref(path->buf, "HEAD", submodule_head)) {
+               if (!quiet) {
+                       quote_path_relative(path->buf, strlen(path->buf), &quoted, prefix);
+                       printf(dry_run ?  _(msg_would_skip_git_dir) : _(msg_skip_git_dir),
+                                       quoted.buf);
+               }
+
+               *dir_gone = 0;
+               return 0;
+       }
+
+       dir = opendir(path->buf);
+       if (!dir) {
+               /* an empty dir could be removed even if it is unreadble */
+               res = dry_run ? 0 : rmdir(path->buf);
+               if (res) {
+                       quote_path_relative(path->buf, strlen(path->buf), &quoted, prefix);
+                       warning(_(msg_warn_remove_failed), quoted.buf);
+                       *dir_gone = 0;
+               }
+               return res;
+       }
+
+       if (path->buf[original_len - 1] != '/')
+               strbuf_addch(path, '/');
+
+       len = path->len;
+       while ((e = readdir(dir)) != NULL) {
+               struct stat st;
+               if (is_dot_or_dotdot(e->d_name))
+                       continue;
+
+               strbuf_setlen(path, len);
+               strbuf_addstr(path, e->d_name);
+               if (lstat(path->buf, &st))
+                       ; /* fall thru */
+               else if (S_ISDIR(st.st_mode)) {
+                       if (remove_dirs(path, prefix, force_flag, dry_run, quiet, &gone))
+                               ret = 1;
+                       if (gone) {
+                               quote_path_relative(path->buf, strlen(path->buf), &quoted, prefix);
+                               string_list_append(&dels, quoted.buf);
+                       } else
+                               *dir_gone = 0;
+                       continue;
+               } else {
+                       res = dry_run ? 0 : unlink(path->buf);
+                       if (!res) {
+                               quote_path_relative(path->buf, strlen(path->buf), &quoted, prefix);
+                               string_list_append(&dels, quoted.buf);
+                       } else {
+                               quote_path_relative(path->buf, strlen(path->buf), &quoted, prefix);
+                               warning(_(msg_warn_remove_failed), quoted.buf);
+                               *dir_gone = 0;
+                               ret = 1;
+                       }
+                       continue;
+               }
+
+               /* path too long, stat fails, or non-directory still exists */
+               *dir_gone = 0;
+               ret = 1;
+               break;
+       }
+       closedir(dir);
+
+       strbuf_setlen(path, original_len);
+
+       if (*dir_gone) {
+               res = dry_run ? 0 : rmdir(path->buf);
+               if (!res)
+                       *dir_gone = 1;
+               else {
+                       quote_path_relative(path->buf, strlen(path->buf), &quoted, prefix);
+                       warning(_(msg_warn_remove_failed), quoted.buf);
+                       *dir_gone = 0;
+                       ret = 1;
+               }
+       }
+
+       if (!*dir_gone && !quiet) {
+               for (i = 0; i < dels.nr; i++)
+                       printf(dry_run ?  _(msg_would_remove) : _(msg_remove), dels.items[i].string);
+       }
+       string_list_clear(&dels, 0);
+       return ret;
+}
+
 int cmd_clean(int argc, const char **argv, const char *prefix)
 {
-       int i;
-       int show_only = 0, remove_directories = 0, quiet = 0, ignored = 0;
-       int ignored_only = 0, config_set = 0, errors = 0;
+       int i, res;
+       int dry_run = 0, remove_directories = 0, quiet = 0, ignored = 0;
+       int ignored_only = 0, config_set = 0, errors = 0, gone = 1;
        int rm_flags = REMOVE_DIR_KEEP_NESTED_GIT;
        struct strbuf directory = STRBUF_INIT;
        struct dir_struct dir;
@@ -49,7 +157,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
        char *seen = NULL;
        struct option options[] = {
                OPT__QUIET(&quiet, N_("do not print names of files removed")),
-               OPT__DRY_RUN(&show_only, N_("dry run")),
+               OPT__DRY_RUN(&dry_run, N_("dry run")),
                OPT__FORCE(&force, N_("force")),
                OPT_BOOLEAN('d', NULL, &remove_directories,
                                N_("remove whole directories")),
@@ -77,7 +185,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
        if (ignored && ignored_only)
                die(_("-x and -X cannot be used together"));
 
-       if (!show_only && !force) {
+       if (!dry_run && !force) {
                if (config_set)
                        die(_("clean.requireForce set to true and neither -n nor -f given; "
                                  "refusing to clean"));
@@ -149,38 +257,26 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 
                if (S_ISDIR(st.st_mode)) {
                        strbuf_addstr(&directory, ent->name);
-                       qname = quote_path_relative(directory.buf, directory.len, &buf, prefix);
-                       if (show_only && (remove_directories ||
-                           (matches == MATCHED_EXACTLY))) {
-                               printf(_("Would remove %s\n"), qname);
-                       } else if (remove_directories ||
-                                  (matches == MATCHED_EXACTLY)) {
-                               if (!quiet)
-                                       printf(_("Removing %s\n"), qname);
-                               if (remove_dir_recursively(&directory,
-                                                          rm_flags) != 0) {
-                                       warning(_("failed to remove %s"), qname);
+                       if (remove_directories || (matches == MATCHED_EXACTLY)) {
+                               if (remove_dirs(&directory, prefix, rm_flags, dry_run, quiet, &gone))
                                        errors++;
+                               if (gone && !quiet) {
+                                       qname = quote_path_relative(directory.buf, directory.len, &buf, prefix);
+                                       printf(dry_run ? _(msg_would_remove) : _(msg_remove), qname);
                                }
-                       } else if (show_only) {
-                               printf(_("Would not remove %s\n"), qname);
-                       } else {
-                               printf(_("Not removing %s\n"), qname);
                        }
                        strbuf_reset(&directory);
                } else {
                        if (pathspec && !matches)
                                continue;
-                       qname = quote_path_relative(ent->name, -1, &buf, prefix);
-                       if (show_only) {
-                               printf(_("Would remove %s\n"), qname);
-                               continue;
-                       } else if (!quiet) {
-                               printf(_("Removing %s\n"), qname);
-                       }
-                       if (unlink(ent->name) != 0) {
-                               warning(_("failed to remove %s"), qname);
+                       res = dry_run ? 0 : unlink(ent->name);
+                       if (res) {
+                               qname = quote_path_relative(ent->name, -1, &buf, prefix);
+                               warning(_(msg_warn_remove_failed), qname);
                                errors++;
+                       } else if (!quiet) {
+                               qname = quote_path_relative(ent->name, -1, &buf, prefix);
+                               printf(dry_run ? _(msg_would_remove) : _(msg_remove), qname);
                        }
                }
        }
index ec2f75b4f3b9d9acfb8aa6b423f3b0fc7fbbafdf..36ec99db3f5a7dbd59705aa68bcd592c08c773cd 100644 (file)
@@ -704,6 +704,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                if (option_origin)
                        die(_("--bare and --origin %s options are incompatible."),
                            option_origin);
+               if (real_git_dir)
+                       die(_("--bare and --separate-git-dir are incompatible."));
                option_no_checkout = 1;
        }
 
@@ -771,8 +773,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                die(_("could not create leading directories of '%s'"), git_dir);
 
        set_git_dir_init(git_dir, real_git_dir, 0);
-       if (real_git_dir)
+       if (real_git_dir) {
                git_dir = real_git_dir;
+               junk_git_dir = real_git_dir;
+       }
 
        if (0 <= option_verbosity) {
                if (option_bare)
index d6dd3df8b1e1f449e7781bdb033f5cfa11753436..7c2a3d48b4ac6bf6f55539946adacb433b51dabb 100644 (file)
@@ -103,7 +103,7 @@ static enum {
        CLEANUP_NONE,
        CLEANUP_ALL
 } cleanup_mode;
-static char *cleanup_arg;
+static const char *cleanup_arg;
 
 static enum commit_whence whence;
 static int use_editor = 1, include_status = 1;
@@ -1320,6 +1320,8 @@ static int git_commit_config(const char *k, const char *v, void *cb)
                include_status = git_config_bool(k, v);
                return 0;
        }
+       if (!strcmp(k, "commit.cleanup"))
+               return git_config_string(&cleanup_arg, k, v);
 
        status = git_gpg_config(k, v, NULL);
        if (status)
index 12220ad8dac65acaa556c6524310d5540709f324..77dffd1ce3a5f809a81793f67b9297a555bab1fa 100644 (file)
@@ -474,18 +474,21 @@ static void handle_tag(const char *name, struct tag *tag)
               (int)message_size, (int)message_size, message ? message : "");
 }
 
-static void get_tags_and_duplicates(struct object_array *pending,
+static void get_tags_and_duplicates(struct rev_cmdline_info *info,
                                    struct string_list *extra_refs)
 {
        struct tag *tag;
        int i;
 
-       for (i = 0; i < pending->nr; i++) {
-               struct object_array_entry *e = pending->objects + i;
+       for (i = 0; i < info->nr; i++) {
+               struct rev_cmdline_entry *e = info->rev + i;
                unsigned char sha1[20];
-               struct commit *commit = commit;
+               struct commit *commit;
                char *full_name;
 
+               if (e->flags & UNINTERESTING)
+                       continue;
+
                if (dwim_ref(e->name, strlen(e->name), sha1, &full_name) != 1)
                        continue;
 
@@ -523,10 +526,14 @@ static void get_tags_and_duplicates(struct object_array *pending,
                                typename(e->item->type));
                        continue;
                }
-               if (commit->util)
-                       /* more than one name for the same object */
+
+               /*
+                * This ref will not be updated through a commit, lets make
+                * sure it gets properly updated eventually.
+                */
+               if (commit->util || commit->object.flags & SHOWN)
                        string_list_append(extra_refs, full_name)->util = commit;
-               else
+               if (!commit->util)
                        commit->util = full_name;
        }
 }
@@ -614,6 +621,10 @@ static void import_marks(char *input_file)
                if (object->flags & SHOWN)
                        error("Object %s already has a mark", sha1_to_hex(sha1));
 
+               if (object->type != OBJ_COMMIT)
+                       /* only commits */
+                       continue;
+
                mark_object(object, mark);
                if (last_idnum < mark)
                        last_idnum = mark;
@@ -677,7 +688,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
        if (import_filename && revs.prune_data.nr)
                full_tree = 1;
 
-       get_tags_and_duplicates(&revs.pending, &extra_refs);
+       get_tags_and_duplicates(&revs.cmdline, &extra_refs);
 
        if (prepare_revision_walk(&revs))
                die("revision walk setup failed");
index e2e27b2c404a1c451a20e396a7aa03dece722dad..d9af43c257150c957bf3bc3c3b7a7e43e370174c 100644 (file)
@@ -232,8 +232,9 @@ static void record_person(int which, struct string_list *people,
 {
        char *name_buf, *name, *name_end;
        struct string_list_item *elem;
-       const char *field = (which == 'a') ? "\nauthor " : "\ncommitter ";
+       const char *field;
 
+       field = (which == 'a') ? "\nauthor " : "\ncommitter ";
        name = strstr(commit->buffer, field);
        if (!name)
                return;
@@ -323,7 +324,8 @@ static void add_people_info(struct strbuf *out,
 static void shortlog(const char *name,
                     struct origin_data *origin_data,
                     struct commit *head,
-                    struct rev_info *rev, int limit,
+                    struct rev_info *rev,
+                    struct fmt_merge_msg_opts *opts,
                     struct strbuf *out)
 {
        int i, count = 0;
@@ -335,6 +337,7 @@ static void shortlog(const char *name,
        int flags = UNINTERESTING | TREESAME | SEEN | SHOWN | ADDED;
        struct strbuf sb = STRBUF_INIT;
        const unsigned char *sha1 = origin_data->sha1;
+       int limit = opts->shortlog_len;
 
        branch = deref_tag(parse_object(sha1), sha1_to_hex(sha1), 40);
        if (!branch || branch->type != OBJ_COMMIT)
@@ -351,13 +354,15 @@ static void shortlog(const char *name,
 
                if (commit->parents && commit->parents->next) {
                        /* do not list a merge but count committer */
-                       record_person('c', &committers, commit);
+                       if (opts->credit_people)
+                               record_person('c', &committers, commit);
                        continue;
                }
-               if (!count)
+               if (!count && opts->credit_people)
                        /* the 'tip' committer */
                        record_person('c', &committers, commit);
-               record_person('a', &authors, commit);
+               if (opts->credit_people)
+                       record_person('a', &authors, commit);
                count++;
                if (subjects.nr > limit)
                        continue;
@@ -372,7 +377,8 @@ static void shortlog(const char *name,
                        string_list_append(&subjects, strbuf_detach(&sb, NULL));
        }
 
-       add_people_info(out, &authors, &committers);
+       if (opts->credit_people)
+               add_people_info(out, &authors, &committers);
        if (count > limit)
                strbuf_addf(out, "\n* %s: (%d commits)\n", name, count);
        else
@@ -635,7 +641,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
                for (i = 0; i < origins.nr; i++)
                        shortlog(origins.items[i].string,
                                 origins.items[i].util,
-                                head, &rev, opts->shortlog_len, out);
+                                head, &rev, opts, out);
        }
 
        strbuf_complete_line(out);
@@ -690,6 +696,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 
        memset(&opts, 0, sizeof(opts));
        opts.add_title = !message;
+       opts.credit_people = 1;
        opts.shortlog_len = shortlog_len;
 
        ret = fmt_merge_msg(&input, &output, &opts);
index e7b7db1cacf1934a9bb0b96beb98ddda15a66074..8f0b2e84fef5d1b9c07ea8846c9fbc1318d8d51b 100644 (file)
@@ -22,6 +22,7 @@
 #include "branch.h"
 #include "streaming.h"
 #include "version.h"
+#include "mailmap.h"
 
 /* Set a default date-time format for git log ("log.date" config variable) */
 static const char *default_date_mode = NULL;
@@ -30,6 +31,7 @@ static int default_abbrev_commit;
 static int default_show_root = 1;
 static int decoration_style;
 static int decoration_given;
+static int use_mailmap_config;
 static const char *fmt_patch_subject_prefix = "PATCH";
 static const char *fmt_pretty;
 
@@ -94,16 +96,18 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
                         struct rev_info *rev, struct setup_revision_opt *opt)
 {
        struct userformat_want w;
-       int quiet = 0, source = 0;
+       int quiet = 0, source = 0, mailmap = 0;
 
        const struct option builtin_log_options[] = {
                OPT_BOOLEAN(0, "quiet", &quiet, N_("suppress diff output")),
                OPT_BOOLEAN(0, "source", &source, N_("show source")),
+               OPT_BOOLEAN(0, "use-mailmap", &mailmap, N_("Use mail map file")),
                { OPTION_CALLBACK, 0, "decorate", NULL, NULL, N_("decorate options"),
                  PARSE_OPT_OPTARG, decorate_callback},
                OPT_END()
        };
 
+       mailmap = use_mailmap_config;
        argc = parse_options(argc, argv, prefix,
                             builtin_log_options, builtin_log_usage,
                             PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
@@ -136,6 +140,11 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
        if (source)
                rev->show_source = 1;
 
+       if (mailmap) {
+               rev->mailmap = xcalloc(1, sizeof(struct string_list));
+               read_mailmap(rev->mailmap, NULL);
+       }
+
        if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {
                /*
                 * "log --pretty=raw" is special; ignore UI oriented
@@ -351,6 +360,11 @@ static int git_log_config(const char *var, const char *value, void *cb)
        }
        if (!prefixcmp(var, "color.decorate."))
                return parse_decorate_color_config(var, 15, value);
+       if (!strcmp(var, "log.mailmap")) {
+               use_mailmap_config = git_config_bool(var, value);
+               return 0;
+       }
+
        if (grep_config(var, value, cb) < 0)
                return -1;
        return git_diff_ui_config(var, value, cb);
@@ -678,7 +692,7 @@ static int reopen_stdout(struct commit *commit, const char *subject,
                         struct rev_info *rev, int quiet)
 {
        struct strbuf filename = STRBUF_INIT;
-       int suffix_len = strlen(fmt_patch_suffix) + 1;
+       int suffix_len = strlen(rev->patch_suffix) + 1;
 
        if (output_directory) {
                strbuf_addstr(&filename, output_directory);
@@ -689,7 +703,12 @@ static int reopen_stdout(struct commit *commit, const char *subject,
                        strbuf_addch(&filename, '/');
        }
 
-       get_patch_filename(commit, subject, rev->nr, fmt_patch_suffix, &filename);
+       if (rev->numbered_files)
+               strbuf_addf(&filename, "%d", rev->nr);
+       else if (commit)
+               fmt_output_commit(&filename, commit, rev);
+       else
+               fmt_output_subject(&filename, subject, rev);
 
        if (!quiet)
                fprintf(realstdout, "%s\n", filename.buf + outdir_offset);
@@ -773,7 +792,6 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)
 }
 
 static void make_cover_letter(struct rev_info *rev, int use_stdout,
-                             int numbered, int numbered_files,
                              struct commit *origin,
                              int nr, struct commit **list, struct commit *head,
                              const char *branch_name,
@@ -796,7 +814,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
        committer = git_committer_info(0);
 
        if (!use_stdout &&
-           reopen_stdout(NULL, numbered_files ? NULL : "cover-letter", rev, quiet))
+           reopen_stdout(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet))
                return;
 
        log_write_email_headers(rev, head, &pp.subject, &pp.after_subject,
@@ -1016,8 +1034,9 @@ static char *find_branch_name(struct rev_info *rev)
 {
        int i, positive = -1;
        unsigned char branch_sha1[20];
-       struct strbuf buf = STRBUF_INIT;
-       const char *branch;
+       const unsigned char *tip_sha1;
+       const char *ref;
+       char *full_ref, *branch = NULL;
 
        for (i = 0; i < rev->cmdline.nr; i++) {
                if (rev->cmdline.rev[i].flags & UNINTERESTING)
@@ -1027,18 +1046,27 @@ static char *find_branch_name(struct rev_info *rev)
                else
                        return NULL;
        }
-       if (positive < 0)
+       if (0 <= positive) {
+               ref = rev->cmdline.rev[positive].name;
+               tip_sha1 = rev->cmdline.rev[positive].item->sha1;
+       } else if (!rev->cmdline.nr && rev->pending.nr == 1 &&
+                  !strcmp(rev->pending.objects[0].name, "HEAD")) {
+               /*
+                * No actual ref from command line, but "HEAD" from
+                * rev->def was added in setup_revisions()
+                * e.g. format-patch --cover-letter -12
+                */
+               ref = "HEAD";
+               tip_sha1 = rev->pending.objects[0].item->sha1;
+       } else {
                return NULL;
-       strbuf_addf(&buf, "refs/heads/%s", rev->cmdline.rev[positive].name);
-       branch = resolve_ref_unsafe(buf.buf, branch_sha1, 1, NULL);
-       if (!branch ||
-           prefixcmp(branch, "refs/heads/") ||
-           hashcmp(rev->cmdline.rev[positive].item->sha1, branch_sha1))
-               branch = NULL;
-       strbuf_release(&buf);
-       if (branch)
-               return xstrdup(rev->cmdline.rev[positive].name);
-       return NULL;
+       }
+       if (dwim_ref(ref, strlen(ref), branch_sha1, &full_ref) &&
+           !prefixcmp(full_ref, "refs/heads/") &&
+           !hashcmp(tip_sha1, branch_sha1))
+               branch = xstrdup(full_ref + strlen("refs/heads/"));
+       free(full_ref);
+       return branch;
 }
 
 int cmd_format_patch(int argc, const char **argv, const char *prefix)
@@ -1050,7 +1078,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        int nr = 0, total, i;
        int use_stdout = 0;
        int start_number = -1;
-       int numbered_files = 0;         /* _just_ numbers */
+       int just_numbers = 0;
        int ignore_if_in_upstream = 0;
        int cover_letter = 0;
        int boundary_count = 0;
@@ -1062,6 +1090,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        struct strbuf buf = STRBUF_INIT;
        int use_patch_format = 0;
        int quiet = 0;
+       int reroll_count = -1;
        char *branch_name = NULL;
        const struct option builtin_format_patch_options[] = {
                { OPTION_CALLBACK, 'n', "numbered", &numbered, NULL,
@@ -1075,12 +1104,14 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                            N_("print patches to standard out")),
                OPT_BOOLEAN(0, "cover-letter", &cover_letter,
                            N_("generate a cover letter")),
-               OPT_BOOLEAN(0, "numbered-files", &numbered_files,
+               OPT_BOOLEAN(0, "numbered-files", &just_numbers,
                            N_("use simple number sequence for output file names")),
                OPT_STRING(0, "suffix", &fmt_patch_suffix, N_("sfx"),
                            N_("use <sfx> instead of '.patch'")),
                OPT_INTEGER(0, "start-number", &start_number,
                            N_("start numbering patches at <n> instead of 1")),
+               OPT_INTEGER('v', "reroll-count", &reroll_count,
+                           N_("mark the series as Nth re-roll")),
                { OPTION_CALLBACK, 0, "subject-prefix", &rev, N_("prefix"),
                            N_("Use [<prefix>] instead of [PATCH]"),
                            PARSE_OPT_NONEG, subject_prefix_callback },
@@ -1154,6 +1185,14 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                             PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
                             PARSE_OPT_KEEP_DASHDASH);
 
+       if (0 < reroll_count) {
+               struct strbuf sprefix = STRBUF_INIT;
+               strbuf_addf(&sprefix, "%s v%d",
+                           rev.subject_prefix, reroll_count);
+               rev.reroll_count = reroll_count;
+               rev.subject_prefix = strbuf_detach(&sprefix, NULL);
+       }
+
        if (do_signoff) {
                const char *committer;
                const char *endpos;
@@ -1344,12 +1383,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                const char *msgid = clean_message_id(in_reply_to);
                string_list_append(rev.ref_message_ids, msgid);
        }
-       rev.numbered_files = numbered_files;
+       rev.numbered_files = just_numbers;
        rev.patch_suffix = fmt_patch_suffix;
        if (cover_letter) {
                if (thread)
                        gen_message_id(&rev, "cover");
-               make_cover_letter(&rev, use_stdout, numbered, numbered_files,
+               make_cover_letter(&rev, use_stdout,
                                  origin, nr, list, head, branch_name, quiet);
                total++;
                start_number--;
@@ -1396,7 +1435,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                }
 
                if (!use_stdout &&
-                   reopen_stdout(numbered_files ? NULL : commit, NULL, &rev, quiet))
+                   reopen_stdout(rev.numbered_files ? NULL : commit, NULL, &rev, quiet))
                        die(_("Failed to create output files"));
                shown = log_tree_commit(&rev, commit);
                free(commit->buffer);
index b5434af0c87741f3160388cf86904c6e3f903527..373c573449b5771f9b56d7d4ce04e4c0b3957cd9 100644 (file)
@@ -203,7 +203,7 @@ static void show_ru_info(void)
 static int ce_excluded(struct path_exclude_check *check, struct cache_entry *ce)
 {
        int dtype = ce_to_dtype(ce);
-       return path_excluded(check, ce->name, ce_namelen(ce), &dtype);
+       return is_path_excluded(check, ce->name, ce_namelen(ce), &dtype);
 }
 
 static void show_files(struct dir_struct *dir)
@@ -337,7 +337,7 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
                matchbuf[0] = prefix;
                matchbuf[1] = NULL;
                init_pathspec(&pathspec, matchbuf);
-               pathspec.items[0].use_wildcard = 0;
+               pathspec.items[0].nowildcard_len = pathspec.items[0].len;
        } else
                init_pathspec(&pathspec, NULL);
        if (read_tree(tree, 1, &pathspec))
index 235c17cc015acfb73358bc5ee5bde712fa2b0fa9..fb76e38d849fc6f7b9cc1a534f62efb605a3655c 100644 (file)
@@ -168,7 +168,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
 
        init_pathspec(&pathspec, get_pathspec(prefix, argv + 1));
        for (i = 0; i < pathspec.nr; i++)
-               pathspec.items[i].use_wildcard = 0;
+               pathspec.items[i].nowildcard_len = pathspec.items[i].len;
        pathspec.has_wildcard = 0;
        tree = parse_tree_indirect(sha1);
        if (!tree)
index 23388325879c5a52a4a8c25f254aafe23573e820..be5e514324aba1d50d8afe653dd72ccc5db060d8 100644 (file)
@@ -42,7 +42,7 @@ static int merge_entry(int pos, const char *path)
        return found;
 }
 
-static void merge_file(const char *path)
+static void merge_one_path(const char *path)
 {
        int pos = cache_name_pos(path, strlen(path));
 
@@ -102,7 +102,7 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix)
                        }
                        die("git merge-index: unknown option %s", arg);
                }
-               merge_file(arg);
+               merge_one_path(arg);
        }
        if (err && !quiet)
                die("merge program failed");
index 897a563bc6662e108c29656d633b7400384154f9..e0d0b7d28b9e1e67fe6ea6521a683df89f5c9416 100644 (file)
@@ -3,17 +3,15 @@
 #include "xdiff-interface.h"
 #include "blob.h"
 #include "exec_cmd.h"
-#include "merge-file.h"
+#include "merge-blobs.h"
 
 static const char merge_tree_usage[] = "git merge-tree <base-tree> <branch1> <branch2>";
-static int resolve_directories = 1;
 
 struct merge_list {
        struct merge_list *next;
        struct merge_list *link;        /* other stages for this object */
 
-       unsigned int stage : 2,
-                    flags : 30;
+       unsigned int stage : 2;
        unsigned int mode;
        const char *path;
        struct blob *blob;
@@ -27,7 +25,7 @@ static void add_merge_entry(struct merge_list *entry)
        merge_result_end = &entry->next;
 }
 
-static void merge_trees(struct tree_desc t[3], const char *base);
+static void merge_trees_recursive(struct tree_desc t[3], const char *base, int df_conflict);
 
 static const char *explanation(struct merge_list *entry)
 {
@@ -76,7 +74,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
        their = NULL;
        if (entry)
                their = entry->blob;
-       return merge_file(path, base, our, their, size);
+       return merge_blobs(path, base, our, their, size);
 }
 
 static void *origin(struct merge_list *entry, unsigned long *size)
@@ -174,17 +172,17 @@ static char *traverse_path(const struct traverse_info *info, const struct name_e
        return make_traverse_path(path, info, n);
 }
 
-static void resolve(const struct traverse_info *info, struct name_entry *branch1, struct name_entry *result)
+static void resolve(const struct traverse_info *info, struct name_entry *ours, struct name_entry *result)
 {
        struct merge_list *orig, *final;
        const char *path;
 
-       /* If it's already branch1, don't bother showing it */
-       if (!branch1)
+       /* If it's already ours, don't bother showing it */
+       if (!ours)
                return;
 
        path = traverse_path(info, result);
-       orig = create_entry(2, branch1->mode, branch1->sha1, path);
+       orig = create_entry(2, ours->mode, ours->sha1, path);
        final = create_entry(0, result->mode, result->sha1, path);
 
        final->link = orig;
@@ -192,34 +190,35 @@ static void resolve(const struct traverse_info *info, struct name_entry *branch1
        add_merge_entry(final);
 }
 
-static int unresolved_directory(const struct traverse_info *info, struct name_entry n[3])
+static void unresolved_directory(const struct traverse_info *info, struct name_entry n[3],
+                                int df_conflict)
 {
        char *newbase;
        struct name_entry *p;
        struct tree_desc t[3];
        void *buf0, *buf1, *buf2;
 
-       if (!resolve_directories)
-               return 0;
-       p = n;
-       if (!p->mode) {
-               p++;
-               if (!p->mode)
-                       p++;
+       for (p = n; p < n + 3; p++) {
+               if (p->mode && S_ISDIR(p->mode))
+                       break;
        }
-       if (!S_ISDIR(p->mode))
-               return 0;
+       if (n + 3 <= p)
+               return; /* there is no tree here */
+
        newbase = traverse_path(info, p);
-       buf0 = fill_tree_descriptor(t+0, n[0].sha1);
-       buf1 = fill_tree_descriptor(t+1, n[1].sha1);
-       buf2 = fill_tree_descriptor(t+2, n[2].sha1);
-       merge_trees(t, newbase);
+
+#define ENTRY_SHA1(e) (((e)->mode && S_ISDIR((e)->mode)) ? (e)->sha1 : NULL)
+       buf0 = fill_tree_descriptor(t+0, ENTRY_SHA1(n + 0));
+       buf1 = fill_tree_descriptor(t+1, ENTRY_SHA1(n + 1));
+       buf2 = fill_tree_descriptor(t+2, ENTRY_SHA1(n + 2));
+#undef ENTRY_SHA1
+
+       merge_trees_recursive(t, newbase, df_conflict);
 
        free(buf0);
        free(buf1);
        free(buf2);
        free(newbase);
-       return 1;
 }
 
 
@@ -242,18 +241,26 @@ static struct merge_list *link_entry(unsigned stage, const struct traverse_info
 static void unresolved(const struct traverse_info *info, struct name_entry n[3])
 {
        struct merge_list *entry = NULL;
+       int i;
+       unsigned dirmask = 0, mask = 0;
+
+       for (i = 0; i < 3; i++) {
+               mask |= (1 << 1);
+               if (n[i].mode && S_ISDIR(n[i].mode))
+                       dirmask |= (1 << i);
+       }
 
-       if (unresolved_directory(info, n))
+       unresolved_directory(info, n, dirmask && (dirmask != mask));
+
+       if (dirmask == mask)
                return;
 
-       /*
-        * Do them in reverse order so that the resulting link
-        * list has the stages in order - link_entry adds new
-        * links at the front.
-        */
-       entry = link_entry(3, info, n + 2, entry);
-       entry = link_entry(2, info, n + 1, entry);
-       entry = link_entry(1, info, n + 0, entry);
+       if (n[2].mode && !S_ISDIR(n[2].mode))
+               entry = link_entry(3, info, n + 2, entry);
+       if (n[1].mode && !S_ISDIR(n[1].mode))
+               entry = link_entry(2, info, n + 1, entry);
+       if (n[0].mode && !S_ISDIR(n[0].mode))
+               entry = link_entry(1, info, n + 0, entry);
 
        add_merge_entry(entry);
 }
@@ -292,20 +299,29 @@ static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, s
        /* Same in both? */
        if (same_entry(entry+1, entry+2)) {
                if (entry[0].sha1) {
+                       /* Modified identically */
                        resolve(info, NULL, entry+1);
                        return mask;
                }
+               /* "Both added the same" is left unresolved */
        }
 
        if (same_entry(entry+0, entry+1)) {
                if (entry[2].sha1 && !S_ISDIR(entry[2].mode)) {
+                       /* We did not touch, they modified -- take theirs */
                        resolve(info, entry+1, entry+2);
                        return mask;
                }
+               /*
+                * If we did not touch a directory but they made it
+                * into a file, we fall through and unresolved()
+                * recurses down.  Likewise for the opposite case.
+                */
        }
 
        if (same_entry(entry+0, entry+2)) {
                if (entry[1].sha1 && !S_ISDIR(entry[1].mode)) {
+                       /* We modified, they did not touch -- take ours */
                        resolve(info, NULL, entry+1);
                        return mask;
                }
@@ -315,15 +331,21 @@ static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, s
        return mask;
 }
 
-static void merge_trees(struct tree_desc t[3], const char *base)
+static void merge_trees_recursive(struct tree_desc t[3], const char *base, int df_conflict)
 {
        struct traverse_info info;
 
        setup_traverse_info(&info, base);
+       info.data = &df_conflict;
        info.fn = threeway_callback;
        traverse_trees(3, t, &info);
 }
 
+static void merge_trees(struct tree_desc t[3], const char *base)
+{
+       merge_trees_recursive(t, base, 0);
+}
+
 static void *get_tree_descriptor(struct tree_desc *desc, const char *rev)
 {
        unsigned char sha1[20];
index a96e8eac19911c710f0f6870a53bda480b09747b..9307e9c726587461d002530938dbf2c0d74d55a1 100644 (file)
@@ -800,8 +800,9 @@ static void prepare_to_commit(struct commit_list *remoteheads)
        if (0 < option_edit)
                strbuf_add_lines(&msg, "# ", comment, strlen(comment));
        write_merge_msg(&msg);
-       run_hook(get_index_file(), "prepare-commit-msg",
-                git_path("MERGE_MSG"), "merge", NULL, NULL);
+       if (run_hook(get_index_file(), "prepare-commit-msg",
+                    git_path("MERGE_MSG"), "merge", NULL, NULL))
+               abort_commit(remoteheads, NULL);
        if (0 < option_edit) {
                if (launch_editor(git_path("MERGE_MSG"), NULL, NULL))
                        abort_commit(remoteheads, NULL);
@@ -1221,6 +1222,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                        memset(&opts, 0, sizeof(opts));
                        opts.add_title = !have_message;
                        opts.shortlog_len = shortlog_len;
+                       opts.credit_people = (0 < option_edit);
 
                        fmt_merge_msg(&merge_names, &merge_msg, &opts);
                        if (merge_msg.len)
index db9ba30b08c221ac2290b1ffc939713fe378e666..8491e431e41aaff32c76ab0c61f528682b3babdb 100644 (file)
@@ -220,31 +220,42 @@ static const char message_advice_checkout_pull_push[] =
           "(e.g. 'git pull') before pushing again.\n"
           "See the 'Note about fast-forwards' in 'git push --help' for details.");
 
+static const char message_advice_ref_already_exists[] =
+       N_("Updates were rejected because the destination reference already exists\n"
+          "in the remote.");
+
 static void advise_pull_before_push(void)
 {
-       if (!advice_push_non_ff_current || !advice_push_nonfastforward)
+       if (!advice_push_non_ff_current || !advice_push_update_rejected)
                return;
        advise(_(message_advice_pull_before_push));
 }
 
 static void advise_use_upstream(void)
 {
-       if (!advice_push_non_ff_default || !advice_push_nonfastforward)
+       if (!advice_push_non_ff_default || !advice_push_update_rejected)
                return;
        advise(_(message_advice_use_upstream));
 }
 
 static void advise_checkout_pull_push(void)
 {
-       if (!advice_push_non_ff_matching || !advice_push_nonfastforward)
+       if (!advice_push_non_ff_matching || !advice_push_update_rejected)
                return;
        advise(_(message_advice_checkout_pull_push));
 }
 
+static void advise_ref_already_exists(void)
+{
+       if (!advice_push_already_exists || !advice_push_update_rejected)
+               return;
+       advise(_(message_advice_ref_already_exists));
+}
+
 static int push_with_options(struct transport *transport, int flags)
 {
        int err;
-       int nonfastforward;
+       unsigned int reject_reasons;
 
        transport_set_verbosity(transport, verbosity, progress);
 
@@ -257,7 +268,7 @@ static int push_with_options(struct transport *transport, int flags)
        if (verbosity > 0)
                fprintf(stderr, _("Pushing to %s\n"), transport->url);
        err = transport_push(transport, refspec_nr, refspec, flags,
-                            &nonfastforward);
+                            &reject_reasons);
        if (err != 0)
                error(_("failed to push some refs to '%s'"), transport->url);
 
@@ -265,18 +276,15 @@ static int push_with_options(struct transport *transport, int flags)
        if (!err)
                return 0;
 
-       switch (nonfastforward) {
-       default:
-               break;
-       case NON_FF_HEAD:
+       if (reject_reasons & REJECT_NON_FF_HEAD) {
                advise_pull_before_push();
-               break;
-       case NON_FF_OTHER:
+       } else if (reject_reasons & REJECT_NON_FF_OTHER) {
                if (default_matching_used)
                        advise_use_upstream();
                else
                        advise_checkout_pull_push();
-               break;
+       } else if (reject_reasons & REJECT_ALREADY_EXISTS) {
+               advise_ref_already_exists();
        }
 
        return 1;
index 915cc9f86f855d517abaa55d31c502899fb77220..6032131a9087281e97d0abc05365b7485004121b 100644 (file)
@@ -23,8 +23,8 @@
 
 static const char * const git_reset_usage[] = {
        N_("git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]"),
-       N_("git reset [-q] <commit> [--] <paths>..."),
-       N_("git reset --patch [<commit>] [--] [<paths>...]"),
+       N_("git reset [-q] <tree-ish> [--] <paths>..."),
+       N_("git reset --patch [<tree-ish>] [--] [<paths>...]"),
        NULL
 };
 
@@ -38,14 +38,12 @@ static inline int is_merge(void)
        return !access(git_path("MERGE_HEAD"), F_OK);
 }
 
-static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet)
+static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
 {
        int nr = 1;
-       int newfd;
        struct tree_desc desc[2];
        struct tree *tree;
        struct unpack_trees_options opts;
-       struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
 
        memset(&opts, 0, sizeof(opts));
        opts.head_idx = 1;
@@ -67,8 +65,6 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet
                opts.reset = 1;
        }
 
-       newfd = hold_locked_index(lock, 1);
-
        read_cache_unmerged();
 
        if (reset_type == KEEP) {
@@ -91,10 +87,6 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet
                prime_cache_tree(&active_cache_tree, tree);
        }
 
-       if (write_cache(newfd, active_cache, active_nr) ||
-           commit_locked_index(lock))
-               return error(_("Could not write new index file."));
-
        return 0;
 }
 
@@ -117,36 +109,10 @@ static void print_new_head_line(struct commit *commit)
                printf("\n");
 }
 
-static int update_index_refresh(int fd, struct lock_file *index_lock, int flags)
-{
-       int result;
-
-       if (!index_lock) {
-               index_lock = xcalloc(1, sizeof(struct lock_file));
-               fd = hold_locked_index(index_lock, 1);
-       }
-
-       if (read_cache() < 0)
-               return error(_("Could not read index"));
-
-       result = refresh_index(&the_index, (flags), NULL, NULL,
-                              _("Unstaged changes after reset:")) ? 1 : 0;
-       if (write_cache(fd, active_cache, active_nr) ||
-                       commit_locked_index(index_lock))
-               return error ("Could not refresh index");
-       return result;
-}
-
 static void update_index_from_diff(struct diff_queue_struct *q,
                struct diff_options *opt, void *data)
 {
        int i;
-       int *discard_flag = data;
-
-       /* do_diff_cache() mangled the index */
-       discard_cache();
-       *discard_flag = 1;
-       read_cache();
 
        for (i = 0; i < q->nr; i++) {
                struct diff_filespec *one = q->queue[i]->one;
@@ -164,32 +130,15 @@ static void update_index_from_diff(struct diff_queue_struct *q,
        }
 }
 
-static int interactive_reset(const char *revision, const char **argv,
-                            const char *prefix)
+static int read_from_tree(const char **pathspec, unsigned char *tree_sha1)
 {
-       const char **pathspec = NULL;
-
-       if (*argv)
-               pathspec = get_pathspec(prefix, argv);
-
-       return run_add_interactive(revision, "--patch=reset", pathspec);
-}
-
-static int read_from_tree(const char *prefix, const char **argv,
-               unsigned char *tree_sha1, int refresh_flags)
-{
-       struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
-       int index_fd, index_was_discarded = 0;
        struct diff_options opt;
 
        memset(&opt, 0, sizeof(opt));
-       diff_tree_setup_paths(get_pathspec(prefix, (const char **)argv), &opt);
+       diff_tree_setup_paths(pathspec, &opt);
        opt.output_format = DIFF_FORMAT_CALLBACK;
        opt.format_callback = update_index_from_diff;
-       opt.format_callback_data = &index_was_discarded;
 
-       index_fd = hold_locked_index(lock, 1);
-       index_was_discarded = 0;
        read_cache();
        if (do_diff_cache(tree_sha1, &opt))
                return 1;
@@ -197,10 +146,7 @@ static int read_from_tree(const char *prefix, const char **argv,
        diff_flush(&opt);
        diff_tree_release_paths(&opt);
 
-       if (!index_was_discarded)
-               /* The index is still clobbered from do_diff_cache() */
-               discard_cache();
-       return update_index_refresh(index_fd, lock, refresh_flags);
+       return 0;
 }
 
 static void set_reflog_message(struct strbuf *sb, const char *action,
@@ -225,15 +171,79 @@ static void die_if_unmerged_cache(int reset_type)
 
 }
 
-int cmd_reset(int argc, const char **argv, const char *prefix)
+static const char **parse_args(const char **argv, const char *prefix, const char **rev_ret)
 {
-       int i = 0, reset_type = NONE, update_ref_status = 0, quiet = 0;
-       int patch_mode = 0;
        const char *rev = "HEAD";
-       unsigned char sha1[20], *orig = NULL, sha1_orig[20],
-                               *old_orig = NULL, sha1_old_orig[20];
-       struct commit *commit;
+       unsigned char unused[20];
+       /*
+        * Possible arguments are:
+        *
+        * git reset [-opts] [<rev>]
+        * git reset [-opts] <tree> [<paths>...]
+        * git reset [-opts] <tree> -- [<paths>...]
+        * git reset [-opts] -- [<paths>...]
+        * git reset [-opts] <paths>...
+        *
+        * At this point, argv points immediately after [-opts].
+        */
+
+       if (argv[0]) {
+               if (!strcmp(argv[0], "--")) {
+                       argv++; /* reset to HEAD, possibly with paths */
+               } else if (argv[1] && !strcmp(argv[1], "--")) {
+                       rev = argv[0];
+                       argv += 2;
+               }
+               /*
+                * Otherwise, argv[0] could be either <rev> or <paths> and
+                * has to be unambiguous. If there is a single argument, it
+                * can not be a tree
+                */
+               else if ((!argv[1] && !get_sha1_committish(argv[0], unused)) ||
+                        (argv[1] && !get_sha1_treeish(argv[0], unused))) {
+                       /*
+                        * Ok, argv[0] looks like a commit/tree; it should not
+                        * be a filename.
+                        */
+                       verify_non_filename(prefix, argv[0]);
+                       rev = *argv++;
+               } else {
+                       /* Otherwise we treat this as a filename */
+                       verify_filename(prefix, argv[0], 1);
+               }
+       }
+       *rev_ret = rev;
+       return argv[0] ? get_pathspec(prefix, argv) : NULL;
+}
+
+static int update_refs(const char *rev, const unsigned char *sha1)
+{
+       int update_ref_status;
        struct strbuf msg = STRBUF_INIT;
+       unsigned char *orig = NULL, sha1_orig[20],
+               *old_orig = NULL, sha1_old_orig[20];
+
+       if (!get_sha1("ORIG_HEAD", sha1_old_orig))
+               old_orig = sha1_old_orig;
+       if (!get_sha1("HEAD", sha1_orig)) {
+               orig = sha1_orig;
+               set_reflog_message(&msg, "updating ORIG_HEAD", NULL);
+               update_ref(msg.buf, "ORIG_HEAD", orig, old_orig, 0, MSG_ON_ERR);
+       } else if (old_orig)
+               delete_ref("ORIG_HEAD", old_orig, 0);
+       set_reflog_message(&msg, "updating HEAD", rev);
+       update_ref_status = update_ref(msg.buf, "HEAD", sha1, orig, 0, MSG_ON_ERR);
+       strbuf_release(&msg);
+       return update_ref_status;
+}
+
+int cmd_reset(int argc, const char **argv, const char *prefix)
+{
+       int reset_type = NONE, update_ref_status = 0, quiet = 0;
+       int patch_mode = 0, unborn;
+       const char *rev;
+       unsigned char sha1[20];
+       const char **pathspec = NULL;
        const struct option options[] = {
                OPT__QUIET(&quiet, N_("be quiet, only report errors")),
                OPT_SET_INT(0, "mixed", &reset_type,
@@ -253,73 +263,45 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 
        argc = parse_options(argc, argv, prefix, options, git_reset_usage,
                                                PARSE_OPT_KEEP_DASHDASH);
-
-       /*
-        * Possible arguments are:
-        *
-        * git reset [-opts] <rev> <paths>...
-        * git reset [-opts] <rev> -- <paths>...
-        * git reset [-opts] -- <paths>...
-        * git reset [-opts] <paths>...
-        *
-        * At this point, argv[i] points immediately after [-opts].
-        */
-
-       if (i < argc) {
-               if (!strcmp(argv[i], "--")) {
-                       i++; /* reset to HEAD, possibly with paths */
-               } else if (i + 1 < argc && !strcmp(argv[i+1], "--")) {
-                       rev = argv[i];
-                       i += 2;
-               }
-               /*
-                * Otherwise, argv[i] could be either <rev> or <paths> and
-                * has to be unambiguous.
-                */
-               else if (!get_sha1_committish(argv[i], sha1)) {
-                       /*
-                        * Ok, argv[i] looks like a rev; it should not
-                        * be a filename.
-                        */
-                       verify_non_filename(prefix, argv[i]);
-                       rev = argv[i++];
-               } else {
-                       /* Otherwise we treat this as a filename */
-                       verify_filename(prefix, argv[i], 1);
-               }
+       pathspec = parse_args(argv, prefix, &rev);
+
+       unborn = !strcmp(rev, "HEAD") && get_sha1("HEAD", sha1);
+       if (unborn) {
+               /* reset on unborn branch: treat as reset to empty tree */
+               hashcpy(sha1, EMPTY_TREE_SHA1_BIN);
+       } else if (!pathspec) {
+               struct commit *commit;
+               if (get_sha1_committish(rev, sha1))
+                       die(_("Failed to resolve '%s' as a valid revision."), rev);
+               commit = lookup_commit_reference(sha1);
+               if (!commit)
+                       die(_("Could not parse object '%s'."), rev);
+               hashcpy(sha1, commit->object.sha1);
+       } else {
+               struct tree *tree;
+               if (get_sha1_treeish(rev, sha1))
+                       die(_("Failed to resolve '%s' as a valid tree."), rev);
+               tree = parse_tree_indirect(sha1);
+               if (!tree)
+                       die(_("Could not parse object '%s'."), rev);
+               hashcpy(sha1, tree->object.sha1);
        }
 
-       if (get_sha1_committish(rev, sha1))
-               die(_("Failed to resolve '%s' as a valid ref."), rev);
-
-       /*
-        * NOTE: As "git reset $treeish -- $path" should be usable on
-        * any tree-ish, this is not strictly correct. We are not
-        * moving the HEAD to any commit; we are merely resetting the
-        * entries in the index to that of a treeish.
-        */
-       commit = lookup_commit_reference(sha1);
-       if (!commit)
-               die(_("Could not parse object '%s'."), rev);
-       hashcpy(sha1, commit->object.sha1);
-
        if (patch_mode) {
                if (reset_type != NONE)
                        die(_("--patch is incompatible with --{hard,mixed,soft}"));
-               return interactive_reset(rev, argv + i, prefix);
+               return run_add_interactive(sha1_to_hex(sha1), "--patch=reset", pathspec);
        }
 
        /* git reset tree [--] paths... can be used to
         * load chosen paths from the tree into the index without
         * affecting the working tree nor HEAD. */
-       if (i < argc) {
+       if (pathspec) {
                if (reset_type == MIXED)
                        warning(_("--mixed with paths is deprecated; use 'git reset -- <paths>' instead."));
                else if (reset_type != NONE)
                        die(_("Cannot do %s reset with paths."),
                                        _(reset_type_names[reset_type]));
-               return read_from_tree(prefix, argv + i, sha1,
-                               quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN);
        }
        if (reset_type == NONE)
                reset_type = MIXED; /* by default */
@@ -334,49 +316,44 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
        /* Soft reset does not touch the index file nor the working tree
         * at all, but requires them in a good order.  Other resets reset
         * the index file to the tree object we are switching to. */
-       if (reset_type == SOFT)
+       if (reset_type == SOFT || reset_type == KEEP)
                die_if_unmerged_cache(reset_type);
-       else {
-               int err;
-               if (reset_type == KEEP)
-                       die_if_unmerged_cache(reset_type);
-               err = reset_index_file(sha1, reset_type, quiet);
-               if (reset_type == KEEP)
-                       err = err || reset_index_file(sha1, MIXED, quiet);
-               if (err)
-                       die(_("Could not reset index file to revision '%s'."), rev);
-       }
 
-       /* Any resets update HEAD to the head being switched to,
-        * saving the previous head in ORIG_HEAD before. */
-       if (!get_sha1("ORIG_HEAD", sha1_old_orig))
-               old_orig = sha1_old_orig;
-       if (!get_sha1("HEAD", sha1_orig)) {
-               orig = sha1_orig;
-               set_reflog_message(&msg, "updating ORIG_HEAD", NULL);
-               update_ref(msg.buf, "ORIG_HEAD", orig, old_orig, 0, MSG_ON_ERR);
-       }
-       else if (old_orig)
-               delete_ref("ORIG_HEAD", old_orig, 0);
-       set_reflog_message(&msg, "updating HEAD", rev);
-       update_ref_status = update_ref(msg.buf, "HEAD", sha1, orig, 0, MSG_ON_ERR);
+       if (reset_type != SOFT) {
+               struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
+               int newfd = hold_locked_index(lock, 1);
+               if (reset_type == MIXED) {
+                       if (read_from_tree(pathspec, sha1))
+                               return 1;
+               } else {
+                       int err = reset_index(sha1, reset_type, quiet);
+                       if (reset_type == KEEP && !err)
+                               err = reset_index(sha1, MIXED, quiet);
+                       if (err)
+                               die(_("Could not reset index file to revision '%s'."), rev);
+               }
 
-       switch (reset_type) {
-       case HARD:
-               if (!update_ref_status && !quiet)
-                       print_new_head_line(commit);
-               break;
-       case SOFT: /* Nothing else to do. */
-               break;
-       case MIXED: /* Report what has not been updated. */
-               update_index_refresh(0, NULL,
-                               quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN);
-               break;
+               if (reset_type == MIXED) { /* Report what has not been updated. */
+                       int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN;
+                       refresh_index(&the_index, flags, NULL, NULL,
+                                     _("Unstaged changes after reset:"));
+               }
+
+               if (write_cache(newfd, active_cache, active_nr) ||
+                   commit_locked_index(lock))
+                       die(_("Could not write new index file."));
        }
 
-       remove_branch_state();
+       if (!pathspec && !unborn) {
+               /* Any resets without paths update HEAD to the head being
+                * switched to, saving the previous head in ORIG_HEAD before. */
+               update_ref_status = update_refs(rev, sha1);
 
-       strbuf_release(&msg);
+               if (reset_type == HARD && !update_ref_status && !quiet)
+                       print_new_head_line(lookup_commit_reference(sha1));
+       }
+       if (!pathspec)
+               remove_branch_state();
 
        return update_ref_status;
 }
index d34201372d71d0c5683d4d01fe162bd9b7182aa4..f849e0a4a041610dc258a9dc56cc8a357cff31b6 100644 (file)
@@ -44,6 +44,11 @@ static void print_helper_status(struct ref *ref)
                        msg = "non-fast forward";
                        break;
 
+               case REF_STATUS_REJECT_ALREADY_EXISTS:
+                       res = "error";
+                       msg = "already exists";
+                       break;
+
                case REF_STATUS_REJECT_NODELETE:
                case REF_STATUS_REMOTE_REJECT:
                        res = "error";
@@ -85,7 +90,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
        int send_all = 0;
        const char *receivepack = "git-receive-pack";
        int flags;
-       int nonfastforward = 0;
+       unsigned int reject_reasons;
        int progress = -1;
 
        argv++;
@@ -223,7 +228,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
        ret |= finish_connect(conn);
 
        if (!helper_status)
-               transport_print_push_status(dest, remote_refs, args.verbose, 0, &nonfastforward);
+               transport_print_push_status(dest, remote_refs, args.verbose, 0, &reject_reasons);
 
        if (!args.dry_run && remote) {
                struct ref *ref;
index b316cf37ca768f1502c5d0cfa64372a9b322a572..240bff3efa80b3af087fe1e6c16a75108ffee4de 100644 (file)
@@ -36,52 +36,28 @@ static void insert_one_record(struct shortlog *log,
        const char *dot3 = log->common_repo_prefix;
        char *buffer, *p;
        struct string_list_item *item;
-       char namebuf[1024];
-       char emailbuf[1024];
-       size_t len;
+       const char *mailbuf, *namebuf;
+       size_t namelen, maillen;
        const char *eol;
-       const char *boemail, *eoemail;
        struct strbuf subject = STRBUF_INIT;
+       struct strbuf namemailbuf = STRBUF_INIT;
+       struct ident_split ident;
 
-       boemail = strchr(author, '<');
-       if (!boemail)
-               return;
-       eoemail = strchr(boemail, '>');
-       if (!eoemail)
+       if (split_ident_line(&ident, author, strlen(author)))
                return;
 
-       /* copy author name to namebuf, to support matching on both name and email */
-       memcpy(namebuf, author, boemail - author);
-       len = boemail - author;
-       while (len > 0 && isspace(namebuf[len-1]))
-               len--;
-       namebuf[len] = 0;
-
-       /* copy email name to emailbuf, to allow email replacement as well */
-       memcpy(emailbuf, boemail+1, eoemail - boemail);
-       emailbuf[eoemail - boemail - 1] = 0;
-
-       if (!map_user(&log->mailmap, emailbuf, sizeof(emailbuf), namebuf, sizeof(namebuf))) {
-               while (author < boemail && isspace(*author))
-                       author++;
-               for (len = 0;
-                    len < sizeof(namebuf) - 1 && author + len < boemail;
-                    len++)
-                       namebuf[len] = author[len];
-               while (0 < len && isspace(namebuf[len-1]))
-                       len--;
-               namebuf[len] = '\0';
-       }
-       else
-               len = strlen(namebuf);
+       namebuf = ident.name_begin;
+       mailbuf = ident.mail_begin;
+       namelen = ident.name_end - ident.name_begin;
+       maillen = ident.mail_end - ident.mail_begin;
 
-       if (log->email) {
-               size_t room = sizeof(namebuf) - len - 1;
-               int maillen = strlen(emailbuf);
-               snprintf(namebuf + len, room, " <%.*s>", maillen, emailbuf);
-       }
+       map_user(&log->mailmap, &mailbuf, &maillen, &namebuf, &namelen);
+       strbuf_add(&namemailbuf, namebuf, namelen);
+
+       if (log->email)
+               strbuf_addf(&namemailbuf, " <%.*s>", (int)maillen, mailbuf);
 
-       item = string_list_insert(&log->list, namebuf);
+       item = string_list_insert(&log->list, namemailbuf.buf);
        if (item->util == NULL)
                item->util = xcalloc(1, sizeof(struct string_list));
 
@@ -306,9 +282,8 @@ parse_done:
 static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s,
                                     const struct shortlog *log)
 {
-       int col = strbuf_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap);
-       if (col != log->wrap)
-               strbuf_addch(sb, '\n');
+       strbuf_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap);
+       strbuf_addch(sb, '\n');
 }
 
 void shortlog_output(struct shortlog *log)
index 28ed6574a2faf3151056aa20e681e06a157e4a2d..37e4d008b59420338ce97f1b2cf2eb660dab8a34 100644 (file)
@@ -166,12 +166,8 @@ static int verify_cache(struct cache_entry **cache,
                                fprintf(stderr, "...\n");
                                break;
                        }
-                       if (ce_stage(ce))
-                               fprintf(stderr, "%s: unmerged (%s)\n",
-                                       ce->name, sha1_to_hex(ce->sha1));
-                       else
-                               fprintf(stderr, "%s: not added yet\n",
-                                       ce->name);
+                       fprintf(stderr, "%s: unmerged (%s)\n",
+                               ce->name, sha1_to_hex(ce->sha1));
                }
        }
        if (funny)
@@ -242,13 +238,17 @@ static int update_one(struct cache_tree *it,
                      int entries,
                      const char *base,
                      int baselen,
+                     int *skip_count,
                      int flags)
 {
        struct strbuf buffer;
        int missing_ok = flags & WRITE_TREE_MISSING_OK;
        int dryrun = flags & WRITE_TREE_DRY_RUN;
+       int to_invalidate = 0;
        int i;
 
+       *skip_count = 0;
+
        if (0 <= it->entry_count && has_sha1_file(it->sha1))
                return it->entry_count;
 
@@ -263,11 +263,12 @@ static int update_one(struct cache_tree *it,
        /*
         * Find the subtrees and update them.
         */
-       for (i = 0; i < entries; i++) {
+       i = 0;
+       while (i < entries) {
                struct cache_entry *ce = cache[i];
                struct cache_tree_sub *sub;
                const char *path, *slash;
-               int pathlen, sublen, subcnt;
+               int pathlen, sublen, subcnt, subskip;
 
                path = ce->name;
                pathlen = ce_namelen(ce);
@@ -275,8 +276,10 @@ static int update_one(struct cache_tree *it,
                        break; /* at the end of this level */
 
                slash = strchr(path + baselen, '/');
-               if (!slash)
+               if (!slash) {
+                       i++;
                        continue;
+               }
                /*
                 * a/bbb/c (base = a/, slash = /c)
                 * ==>
@@ -290,10 +293,13 @@ static int update_one(struct cache_tree *it,
                                    cache + i, entries - i,
                                    path,
                                    baselen + sublen + 1,
+                                   &subskip,
                                    flags);
                if (subcnt < 0)
                        return subcnt;
-               i += subcnt - 1;
+               i += subcnt;
+               sub->count = subcnt; /* to be used in the next loop */
+               *skip_count += subskip;
                sub->used = 1;
        }
 
@@ -304,7 +310,8 @@ static int update_one(struct cache_tree *it,
         */
        strbuf_init(&buffer, 8192);
 
-       for (i = 0; i < entries; i++) {
+       i = 0;
+       while (i < entries) {
                struct cache_entry *ce = cache[i];
                struct cache_tree_sub *sub;
                const char *path, *slash;
@@ -324,14 +331,17 @@ static int update_one(struct cache_tree *it,
                        if (!sub)
                                die("cache-tree.c: '%.*s' in '%s' not found",
                                    entlen, path + baselen, path);
-                       i += sub->cache_tree->entry_count - 1;
+                       i += sub->count;
                        sha1 = sub->cache_tree->sha1;
                        mode = S_IFDIR;
+                       if (sub->cache_tree->entry_count < 0)
+                               to_invalidate = 1;
                }
                else {
                        sha1 = ce->sha1;
                        mode = ce->ce_mode;
                        entlen = pathlen - baselen;
+                       i++;
                }
                if (mode != S_IFGITLINK && !missing_ok && !has_sha1_file(sha1)) {
                        strbuf_release(&buffer);
@@ -339,8 +349,25 @@ static int update_one(struct cache_tree *it,
                                mode, sha1_to_hex(sha1), entlen+baselen, path);
                }
 
-               if (ce->ce_flags & (CE_REMOVE | CE_INTENT_TO_ADD))
-                       continue; /* entry being removed or placeholder */
+               /*
+                * CE_REMOVE entries are removed before the index is
+                * written to disk. Skip them to remain consistent
+                * with the future on-disk index.
+                */
+               if (ce->ce_flags & CE_REMOVE) {
+                       *skip_count = *skip_count + 1;
+                       continue;
+               }
+
+               /*
+                * CE_INTENT_TO_ADD entries exist on on-disk index but
+                * they are not part of generated trees. Invalidate up
+                * to root to force cache-tree users to read elsewhere.
+                */
+               if (ce->ce_flags & CE_INTENT_TO_ADD) {
+                       to_invalidate = 1;
+                       continue;
+               }
 
                strbuf_grow(&buffer, entlen + 100);
                strbuf_addf(&buffer, "%o %.*s%c", mode, entlen, path + baselen, '\0');
@@ -360,7 +387,7 @@ static int update_one(struct cache_tree *it,
        }
 
        strbuf_release(&buffer);
-       it->entry_count = i;
+       it->entry_count = to_invalidate ? -1 : i - *skip_count;
 #if DEBUG
        fprintf(stderr, "cache-tree update-one (%d ent, %d subtree) %s\n",
                it->entry_count, it->subtree_nr,
@@ -374,11 +401,11 @@ int cache_tree_update(struct cache_tree *it,
                      int entries,
                      int flags)
 {
-       int i;
+       int i, skip;
        i = verify_cache(cache, entries, flags);
        if (i)
                return i;
-       i = update_one(it, cache, entries, "", 0, flags);
+       i = update_one(it, cache, entries, "", 0, &skip, flags);
        if (i < 0)
                return i;
        return 0;
index d8cb2e9e39d2be9c4dad67db44a464c2a1004d2f..55d0f59f2b7a42b40fe4be32297b56656206983d 100644 (file)
@@ -7,6 +7,7 @@
 struct cache_tree;
 struct cache_tree_sub {
        struct cache_tree *cache_tree;
+       int count;              /* internally used by update_one() */
        int namelen;
        int used;
        char name[FLEX_ARRAY];
diff --git a/cache.h b/cache.h
index 98b62bcb5ae0c95db95a971bfa9ccaa2b1fcc8a0..1f96f659e484fd1407dbc403c4095205cf3b0c54 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -362,6 +362,7 @@ static inline enum object_type object_type(unsigned int mode)
 #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"
+#define GIT_LITERAL_PATHSPECS_ENVIRONMENT "GIT_LITERAL_PATHSPECS"
 
 /*
  * Repository-local GIT_* environment variables
@@ -473,6 +474,8 @@ extern int index_name_is_other(const struct index_state *, const char *, int);
 extern int ie_match_stat(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);
 extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);
 
+#define PATHSPEC_ONESTAR 1     /* the pathspec pattern sastisfies GFNM_ONESTAR */
+
 struct pathspec {
        const char **raw; /* get_pathspec() result, not freed by free_pathspec() */
        int nr;
@@ -482,7 +485,8 @@ struct pathspec {
        struct pathspec_item {
                const char *match;
                int len;
-               unsigned int use_wildcard:1;
+               int nowildcard_len;
+               int flags;
        } *items;
 };
 
@@ -490,6 +494,8 @@ extern int init_pathspec(struct pathspec *, const char **);
 extern void free_pathspec(struct pathspec *);
 extern int ce_path_match(const struct cache_entry *ce, const struct pathspec *pathspec);
 
+extern int limit_pathspec_to_literal(void);
+
 #define HASH_WRITE_OBJECT 1
 #define HASH_FORMAT_CHECK 2
 extern int index_fd(unsigned char *sha1, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
@@ -714,10 +720,11 @@ static inline int is_absolute_path(const char *path)
 }
 int is_directory(const char *);
 const char *real_path(const char *path);
+const char *real_path_if_valid(const char *path);
 const char *absolute_path(const char *path);
 const char *relative_path(const char *abs, const char *base);
 int normalize_path_copy(char *dst, const char *src);
-int longest_ancestor_length(const char *path, const char *prefix_list);
+int longest_ancestor_length(const char *path, struct string_list *prefixes);
 char *strip_path_suffix(const char *path, const char *suffix);
 int daemon_avoid_alias(const char *path);
 int offset_1st_component(const char *path);
@@ -999,14 +1006,18 @@ struct ref {
        unsigned char old_sha1[20];
        unsigned char new_sha1[20];
        char *symref;
-       unsigned int force:1,
+       unsigned int
+               force:1,
+               requires_force:1,
                merge:1,
                nonfastforward:1,
+               update:1,
                deletion:1;
        enum {
                REF_STATUS_NONE = 0,
                REF_STATUS_OK,
                REF_STATUS_REJECT_NONFASTFORWARD,
+               REF_STATUS_REJECT_ALREADY_EXISTS,
                REF_STATUS_REJECT_NODELETE,
                REF_STATUS_UPTODATE,
                REF_STATUS_REMOTE_REJECT,
@@ -1158,6 +1169,7 @@ extern int author_ident_sufficiently_given(void);
 extern const char *git_commit_encoding;
 extern const char *git_log_output_encoding;
 extern const char *git_mailmap_file;
+extern const char *git_mailmap_blob;
 
 /* IO helper functions */
 extern void maybe_flush_or_die(FILE *, const char *);
index b6ad8f3f307a46cd5a0555ab346abaa20013b13a..c16c8a75349f2ef4dba1f3c05528d04750a925da 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -89,6 +89,8 @@ struct pretty_print_context {
        char *notes_message;
        struct reflog_walk_info *reflog_info;
        const char *output_encoding;
+       struct string_list *mailmap;
+       int color;
 };
 
 struct userformat_want {
index 0ff1d273a5839d15a908a4ed90b56d59b151e6e0..5ef0685135662e3cefc80eed5c5ae030fe1a5d49 100644 (file)
@@ -55,7 +55,8 @@
    program understand `configure --with-gnu-libc' and omit the object files,
    it is simpler to just do this in the source for each such file.  */
 
-#if defined _LIBC || !defined __GNU_LIBRARY__
+#if defined NO_FNMATCH || defined NO_FNMATCH_CASEFOLD || \
+    defined _LIBC || !defined __GNU_LIBRARY__
 
 
 # if defined STDC_HEADERS || !defined isascii
@@ -135,9 +136,9 @@ extern int errno;
 
 # if !defined HAVE___STRCHRNUL && !defined _LIBC
 static char *
-__strchrnul (s, c)
-     const char *s;
-     int c;
+__strchrnul (const char *s, int c)
+
+
 {
   char *result = strchr (s, c);
   if (result == NULL)
@@ -159,11 +160,11 @@ static int internal_fnmatch __P ((const char *pattern, const char *string,
      internal_function;
 static int
 internal_function
-internal_fnmatch (pattern, string, no_leading_period, flags)
-     const char *pattern;
-     const char *string;
-     int no_leading_period;
-     int flags;
+internal_fnmatch (const char *pattern, const char *string, int no_leading_period, int flags)
+
+
+
+
 {
   register const char *p = pattern, *n = string;
   register unsigned char c;
@@ -481,10 +482,10 @@ internal_fnmatch (pattern, string, no_leading_period, flags)
 
 
 int
-fnmatch (pattern, string, flags)
-     const char *pattern;
-     const char *string;
-     int flags;
+fnmatch (const char *pattern, const char *string, int flags)
+
+
+
 {
   return internal_fnmatch (pattern, string, flags & FNM_PERIOD, flags);
 }
index d9a17a8057c5740edea3d7888c4607e63af9eddd..91c4e7f27b4063c7ceffeeb1cd43530ce18cf096 100644 (file)
@@ -603,7 +603,10 @@ static NOINLINE mstate FindMSpace(nedpool *p, threadcache *tc, int *lastUsed, si
                }
                /* We really want to make sure this goes into memory now but we
                have to be careful of breaking aliasing rules, so write it twice */
-               *((volatile struct malloc_state **) &p->m[end])=p->m[end]=temp;
+               {
+                       volatile struct malloc_state **_m=(volatile struct malloc_state **) &p->m[end];
+                       *_m=(p->m[end]=temp);
+               }
                ACQUIRE_LOCK(&p->m[end]->mutex);
                /*printf("Created mspace idx %d\n", end);*/
                RELEASE_LOCK(&p->mutex);
index 526f6823740bc266a15ea7488b4c834a36f58029..7b444b68abcebb5829a5628ee5b74cf3f0020c0b 100644 (file)
--- a/config.c
+++ b/config.c
@@ -58,7 +58,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
                path = buf.buf;
        }
 
-       if (!access_or_warn(path, R_OK)) {
+       if (!access_or_die(path, R_OK)) {
                if (++inc->depth > MAX_INCLUDE_DEPTH)
                        die(include_depth_advice, MAX_INCLUDE_DEPTH, path,
                            cf && cf->name ? cf->name : "the command line");
@@ -839,6 +839,8 @@ static int git_default_mailmap_config(const char *var, const char *value)
 {
        if (!strcmp(var, "mailmap.file"))
                return git_config_string(&git_mailmap_file, var, value);
+       if (!strcmp(var, "mailmap.blob"))
+               return git_config_string(&git_mailmap_blob, var, value);
 
        /* Add other config variables here and to Documentation/config.txt. */
        return 0;
@@ -938,23 +940,23 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
 
        home_config_paths(&user_config, &xdg_config, "config");
 
-       if (git_config_system() && !access_or_warn(git_etc_gitconfig(), R_OK)) {
+       if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK)) {
                ret += git_config_from_file(fn, git_etc_gitconfig(),
                                            data);
                found += 1;
        }
 
-       if (xdg_config && !access_or_warn(xdg_config, R_OK)) {
+       if (xdg_config && !access_or_die(xdg_config, R_OK)) {
                ret += git_config_from_file(fn, xdg_config, data);
                found += 1;
        }
 
-       if (user_config && !access_or_warn(user_config, R_OK)) {
+       if (user_config && !access_or_die(user_config, R_OK)) {
                ret += git_config_from_file(fn, user_config, data);
                found += 1;
        }
 
-       if (repo_config && !access_or_warn(repo_config, R_OK)) {
+       if (repo_config && !access_or_die(repo_config, R_OK)) {
                ret += git_config_from_file(fn, repo_config, data);
                found += 1;
        }
diff --git a/config.mak.uname b/config.mak.uname
new file mode 100644 (file)
index 0000000..bea34f0
--- /dev/null
@@ -0,0 +1,539 @@
+# Platform specific Makefile tweaks based on uname detection
+
+uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
+uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
+uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
+uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
+uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
+uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
+
+ifdef MSVC
+       # avoid the MingW and Cygwin configuration sections
+       uname_S := Windows
+       uname_O := Windows
+endif
+
+# We choose to avoid "if .. else if .. else .. endif endif"
+# because maintaining the nesting to match is a pain.  If
+# we had "elif" things would have been much nicer...
+
+ifeq ($(uname_M),x86_64)
+       XDL_FAST_HASH = YesPlease
+endif
+ifeq ($(uname_S),OSF1)
+       # Need this for u_short definitions et al
+       BASIC_CFLAGS += -D_OSF_SOURCE
+       SOCKLEN_T = int
+       NO_STRTOULL = YesPlease
+       NO_NSEC = YesPlease
+endif
+ifeq ($(uname_S),Linux)
+       NO_STRLCPY = YesPlease
+       NO_MKSTEMPS = YesPlease
+       HAVE_PATHS_H = YesPlease
+       LIBC_CONTAINS_LIBINTL = YesPlease
+       HAVE_DEV_TTY = YesPlease
+endif
+ifeq ($(uname_S),GNU/kFreeBSD)
+       NO_STRLCPY = YesPlease
+       NO_MKSTEMPS = YesPlease
+       HAVE_PATHS_H = YesPlease
+       DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
+       LIBC_CONTAINS_LIBINTL = YesPlease
+endif
+ifeq ($(uname_S),UnixWare)
+       CC = cc
+       NEEDS_SOCKET = YesPlease
+       NEEDS_NSL = YesPlease
+       NEEDS_SSL_WITH_CRYPTO = YesPlease
+       NEEDS_LIBICONV = YesPlease
+       SHELL_PATH = /usr/local/bin/bash
+       NO_IPV6 = YesPlease
+       NO_HSTRERROR = YesPlease
+       NO_MKSTEMPS = YesPlease
+       BASIC_CFLAGS += -Kthread
+       BASIC_CFLAGS += -I/usr/local/include
+       BASIC_LDFLAGS += -L/usr/local/lib
+       INSTALL = ginstall
+       TAR = gtar
+       NO_STRCASESTR = YesPlease
+       NO_MEMMEM = YesPlease
+endif
+ifeq ($(uname_S),SCO_SV)
+       ifeq ($(uname_R),3.2)
+               CFLAGS = -O2
+       endif
+       ifeq ($(uname_R),5)
+               CC = cc
+               BASIC_CFLAGS += -Kthread
+       endif
+       NEEDS_SOCKET = YesPlease
+       NEEDS_NSL = YesPlease
+       NEEDS_SSL_WITH_CRYPTO = YesPlease
+       NEEDS_LIBICONV = YesPlease
+       SHELL_PATH = /usr/bin/bash
+       NO_IPV6 = YesPlease
+       NO_HSTRERROR = YesPlease
+       NO_MKSTEMPS = YesPlease
+       BASIC_CFLAGS += -I/usr/local/include
+       BASIC_LDFLAGS += -L/usr/local/lib
+       NO_STRCASESTR = YesPlease
+       NO_MEMMEM = YesPlease
+       INSTALL = ginstall
+       TAR = gtar
+endif
+ifeq ($(uname_S),Darwin)
+       NEEDS_CRYPTO_WITH_SSL = YesPlease
+       NEEDS_SSL_WITH_CRYPTO = YesPlease
+       NEEDS_LIBICONV = YesPlease
+       ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
+               OLD_ICONV = UnfortunatelyYes
+       endif
+       ifeq ($(shell expr "$(uname_R)" : '[15]\.'),2)
+               NO_STRLCPY = YesPlease
+       endif
+       NO_MEMMEM = YesPlease
+       USE_ST_TIMESPEC = YesPlease
+       HAVE_DEV_TTY = YesPlease
+       COMPAT_OBJS += compat/precompose_utf8.o
+       BASIC_CFLAGS += -DPRECOMPOSE_UNICODE
+endif
+ifeq ($(uname_S),SunOS)
+       NEEDS_SOCKET = YesPlease
+       NEEDS_NSL = YesPlease
+       SHELL_PATH = /bin/bash
+       SANE_TOOL_PATH = /usr/xpg6/bin:/usr/xpg4/bin
+       NO_STRCASESTR = YesPlease
+       NO_MEMMEM = YesPlease
+       NO_MKDTEMP = YesPlease
+       NO_MKSTEMPS = YesPlease
+       NO_REGEX = YesPlease
+       NO_FNMATCH_CASEFOLD = YesPlease
+       NO_MSGFMT_EXTENDED_OPTIONS = YesPlease
+       HAVE_DEV_TTY = YesPlease
+       ifeq ($(uname_R),5.6)
+               SOCKLEN_T = int
+               NO_HSTRERROR = YesPlease
+               NO_IPV6 = YesPlease
+               NO_SOCKADDR_STORAGE = YesPlease
+               NO_UNSETENV = YesPlease
+               NO_SETENV = YesPlease
+               NO_STRLCPY = YesPlease
+               NO_STRTOUMAX = YesPlease
+               GIT_TEST_CMP = cmp
+       endif
+       ifeq ($(uname_R),5.7)
+               NEEDS_RESOLV = YesPlease
+               NO_IPV6 = YesPlease
+               NO_SOCKADDR_STORAGE = YesPlease
+               NO_UNSETENV = YesPlease
+               NO_SETENV = YesPlease
+               NO_STRLCPY = YesPlease
+               NO_STRTOUMAX = YesPlease
+               GIT_TEST_CMP = cmp
+       endif
+       ifeq ($(uname_R),5.8)
+               NO_UNSETENV = YesPlease
+               NO_SETENV = YesPlease
+               NO_STRTOUMAX = YesPlease
+               GIT_TEST_CMP = cmp
+       endif
+       ifeq ($(uname_R),5.9)
+               NO_UNSETENV = YesPlease
+               NO_SETENV = YesPlease
+               NO_STRTOUMAX = YesPlease
+               GIT_TEST_CMP = cmp
+       endif
+       INSTALL = /usr/ucb/install
+       TAR = gtar
+       BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__ -DHAVE_ALLOCA_H
+endif
+ifeq ($(uname_O),Cygwin)
+       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
+               CYGWIN_V15_WIN32API = YesPlease
+       endif
+       NO_THREAD_SAFE_PREAD = YesPlease
+       NEEDS_LIBICONV = YesPlease
+       NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
+       NO_TRUSTABLE_FILEMODE = 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
+       X = .exe
+       COMPAT_OBJS += compat/cygwin.o
+       UNRELIABLE_FSTAT = UnfortunatelyYes
+       SPARSE_FLAGS = -isystem /usr/include/w32api -Wno-one-bit-signed-bitfield
+endif
+ifeq ($(uname_S),FreeBSD)
+       NEEDS_LIBICONV = YesPlease
+       OLD_ICONV = YesPlease
+       NO_MEMMEM = YesPlease
+       BASIC_CFLAGS += -I/usr/local/include
+       BASIC_LDFLAGS += -L/usr/local/lib
+       DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
+       USE_ST_TIMESPEC = YesPlease
+       ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
+               PTHREAD_LIBS = -pthread
+               NO_UINTMAX_T = YesPlease
+               NO_STRTOUMAX = YesPlease
+       endif
+       PYTHON_PATH = /usr/local/bin/python
+       HAVE_PATHS_H = YesPlease
+endif
+ifeq ($(uname_S),OpenBSD)
+       NO_STRCASESTR = YesPlease
+       NO_MEMMEM = YesPlease
+       USE_ST_TIMESPEC = YesPlease
+       NEEDS_LIBICONV = YesPlease
+       BASIC_CFLAGS += -I/usr/local/include
+       BASIC_LDFLAGS += -L/usr/local/lib
+       HAVE_PATHS_H = YesPlease
+endif
+ifeq ($(uname_S),NetBSD)
+       ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
+               NEEDS_LIBICONV = YesPlease
+       endif
+       BASIC_CFLAGS += -I/usr/pkg/include
+       BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
+       USE_ST_TIMESPEC = YesPlease
+       NO_MKSTEMPS = YesPlease
+       HAVE_PATHS_H = YesPlease
+endif
+ifeq ($(uname_S),AIX)
+       DEFAULT_PAGER = more
+       NO_STRCASESTR = YesPlease
+       NO_MEMMEM = YesPlease
+       NO_MKDTEMP = YesPlease
+       NO_MKSTEMPS = YesPlease
+       NO_STRLCPY = YesPlease
+       NO_NSEC = YesPlease
+       FREAD_READS_DIRECTORIES = UnfortunatelyYes
+       INTERNAL_QSORT = UnfortunatelyYes
+       NEEDS_LIBICONV = YesPlease
+       BASIC_CFLAGS += -D_LARGE_FILES
+       ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
+               NO_PTHREADS = YesPlease
+       else
+               PTHREAD_LIBS = -lpthread
+       endif
+       ifeq ($(shell expr "$(uname_V).$(uname_R)" : '5\.1'),3)
+               INLINE = ''
+       endif
+       GIT_TEST_CMP = cmp
+endif
+ifeq ($(uname_S),GNU)
+       # GNU/Hurd
+       NO_STRLCPY = YesPlease
+       NO_MKSTEMPS = YesPlease
+       HAVE_PATHS_H = YesPlease
+       LIBC_CONTAINS_LIBINTL = YesPlease
+endif
+ifeq ($(uname_S),IRIX)
+       NO_SETENV = YesPlease
+       NO_UNSETENV = YesPlease
+       NO_STRCASESTR = YesPlease
+       NO_MEMMEM = YesPlease
+       NO_MKSTEMPS = YesPlease
+       NO_MKDTEMP = YesPlease
+       # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
+       # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
+       # git dies with a segmentation fault when trying to access the first
+       # entry of a reflog.  The conservative choice is made to always set
+       # NO_MMAP.  If you suspect that your compiler is not affected by this
+       # issue, comment out the NO_MMAP statement.
+       NO_MMAP = YesPlease
+       NO_REGEX = YesPlease
+       NO_FNMATCH_CASEFOLD = YesPlease
+       SNPRINTF_RETURNS_BOGUS = YesPlease
+       SHELL_PATH = /usr/gnu/bin/bash
+       NEEDS_LIBGEN = YesPlease
+endif
+ifeq ($(uname_S),IRIX64)
+       NO_SETENV = YesPlease
+       NO_UNSETENV = YesPlease
+       NO_STRCASESTR = YesPlease
+       NO_MEMMEM = YesPlease
+       NO_MKSTEMPS = YesPlease
+       NO_MKDTEMP = YesPlease
+       # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
+       # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
+       # git dies with a segmentation fault when trying to access the first
+       # entry of a reflog.  The conservative choice is made to always set
+       # NO_MMAP.  If you suspect that your compiler is not affected by this
+       # issue, comment out the NO_MMAP statement.
+       NO_MMAP = YesPlease
+       NO_REGEX = YesPlease
+       NO_FNMATCH_CASEFOLD = YesPlease
+       SNPRINTF_RETURNS_BOGUS = YesPlease
+       SHELL_PATH = /usr/gnu/bin/bash
+       NEEDS_LIBGEN = YesPlease
+endif
+ifeq ($(uname_S),HP-UX)
+       INLINE = __inline
+       NO_IPV6 = YesPlease
+       NO_SETENV = YesPlease
+       NO_STRCASESTR = YesPlease
+       NO_MEMMEM = YesPlease
+       NO_MKSTEMPS = YesPlease
+       NO_STRLCPY = YesPlease
+       NO_MKDTEMP = YesPlease
+       NO_UNSETENV = YesPlease
+       NO_HSTRERROR = YesPlease
+       NO_SYS_SELECT_H = YesPlease
+       NO_FNMATCH_CASEFOLD = YesPlease
+       SNPRINTF_RETURNS_BOGUS = YesPlease
+       NO_NSEC = YesPlease
+       ifeq ($(uname_R),B.11.00)
+               NO_INET_NTOP = YesPlease
+               NO_INET_PTON = YesPlease
+       endif
+       ifeq ($(uname_R),B.10.20)
+               # Override HP-UX 11.x setting:
+               INLINE =
+               SOCKLEN_T = size_t
+               NO_PREAD = YesPlease
+               NO_INET_NTOP = YesPlease
+               NO_INET_PTON = YesPlease
+       endif
+       GIT_TEST_CMP = cmp
+endif
+ifeq ($(uname_S),Windows)
+       GIT_VERSION := $(GIT_VERSION).MSVC
+       pathsep = ;
+       NO_PREAD = YesPlease
+       NEEDS_CRYPTO_WITH_SSL = YesPlease
+       NO_LIBGEN_H = YesPlease
+       NO_POLL = YesPlease
+       NO_SYMLINK_HEAD = YesPlease
+       NO_IPV6 = YesPlease
+       NO_UNIX_SOCKETS = YesPlease
+       NO_SETENV = YesPlease
+       NO_UNSETENV = YesPlease
+       NO_STRCASESTR = YesPlease
+       NO_STRLCPY = YesPlease
+       NO_STRTOK_R = YesPlease
+       NO_FNMATCH = YesPlease
+       NO_MEMMEM = YesPlease
+       # NEEDS_LIBICONV = YesPlease
+       NO_ICONV = YesPlease
+       NO_STRTOUMAX = YesPlease
+       NO_STRTOULL = YesPlease
+       NO_MKDTEMP = YesPlease
+       NO_MKSTEMPS = YesPlease
+       SNPRINTF_RETURNS_BOGUS = YesPlease
+       NO_SVN_TESTS = YesPlease
+       NO_PERL_MAKEMAKER = YesPlease
+       RUNTIME_PREFIX = YesPlease
+       NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
+       NO_NSEC = YesPlease
+       USE_WIN32_MMAP = YesPlease
+       # USE_NED_ALLOCATOR = YesPlease
+       UNRELIABLE_FSTAT = UnfortunatelyYes
+       OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
+       NO_REGEX = YesPlease
+       NO_CURL = YesPlease
+       NO_PYTHON = YesPlease
+       BLK_SHA1 = YesPlease
+       NO_POSIX_GOODIES = UnfortunatelyYes
+       NATIVE_CRLF = YesPlease
+       DEFAULT_HELP_FORMAT = html
+
+       CC = compat/vcbuild/scripts/clink.pl
+       AR = compat/vcbuild/scripts/lib.pl
+       CFLAGS =
+       BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
+       COMPAT_OBJS = compat/msvc.o compat/winansi.o \
+               compat/win32/pthread.o compat/win32/syslog.o \
+               compat/win32/dirent.o
+       COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
+       BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib
+       EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib
+       PTHREAD_LIBS =
+       lib =
+ifndef DEBUG
+       BASIC_CFLAGS += -GL -Os -MT
+       BASIC_LDFLAGS += -LTCG
+       AR += -LTCG
+else
+       BASIC_CFLAGS += -Zi -MTd
+endif
+       X = .exe
+endif
+ifeq ($(uname_S),Interix)
+       NO_INITGROUPS = YesPlease
+       NO_IPV6 = YesPlease
+       NO_MEMMEM = YesPlease
+       NO_MKDTEMP = YesPlease
+       NO_STRTOUMAX = YesPlease
+       NO_NSEC = YesPlease
+       NO_MKSTEMPS = YesPlease
+       ifeq ($(uname_R),3.5)
+               NO_INET_NTOP = YesPlease
+               NO_INET_PTON = YesPlease
+               NO_SOCKADDR_STORAGE = YesPlease
+               NO_FNMATCH_CASEFOLD = YesPlease
+       endif
+       ifeq ($(uname_R),5.2)
+               NO_INET_NTOP = YesPlease
+               NO_INET_PTON = YesPlease
+               NO_SOCKADDR_STORAGE = YesPlease
+               NO_FNMATCH_CASEFOLD = YesPlease
+       endif
+endif
+ifeq ($(uname_S),Minix)
+       NO_IPV6 = YesPlease
+       NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
+       NO_NSEC = YesPlease
+       NEEDS_LIBGEN =
+       NEEDS_CRYPTO_WITH_SSL = YesPlease
+       NEEDS_IDN_WITH_CURL = YesPlease
+       NEEDS_SSL_WITH_CURL = YesPlease
+       NEEDS_RESOLV =
+       NO_HSTRERROR = YesPlease
+       NO_MMAP = YesPlease
+       NO_CURL =
+       NO_EXPAT =
+endif
+ifeq ($(uname_S),NONSTOP_KERNEL)
+       # Needs some C99 features, "inline" is just one of them.
+       # INLINE='' would just replace one set of warnings with another and
+       # still not compile in c89 mode, due to non-const array initializations.
+       CC = cc -c99
+       # Disable all optimization, seems to result in bad code, with -O or -O2
+       # or even -O1 (default), /usr/local/libexec/git-core/git-pack-objects
+       # abends on "git push". Needs more investigation.
+       CFLAGS = -g -O0
+       # We'd want it to be here.
+       prefix = /usr/local
+       # Our's are in ${prefix}/bin (perl might also be in /usr/bin/perl).
+       PERL_PATH = ${prefix}/bin/perl
+       PYTHON_PATH = ${prefix}/bin/python
+
+       # As detected by './configure'.
+       # Missdetected, hence commented out, see below.
+       #NO_CURL = YesPlease
+       # Added manually, see above.
+       NEEDS_SSL_WITH_CURL = YesPlease
+       HAVE_LIBCHARSET_H = YesPlease
+       HAVE_STRINGS_H = YesPlease
+       NEEDS_LIBICONV = YesPlease
+       NEEDS_LIBINTL_BEFORE_LIBICONV = YesPlease
+       NO_SYS_SELECT_H = UnfortunatelyYes
+       NO_D_TYPE_IN_DIRENT = YesPlease
+       NO_HSTRERROR = YesPlease
+       NO_STRCASESTR = YesPlease
+       NO_FNMATCH_CASEFOLD = YesPlease
+       NO_MEMMEM = YesPlease
+       NO_STRLCPY = YesPlease
+       NO_SETENV = YesPlease
+       NO_UNSETENV = YesPlease
+       NO_MKDTEMP = YesPlease
+       NO_MKSTEMPS = YesPlease
+       # Currently libiconv-1.9.1.
+       OLD_ICONV = UnfortunatelyYes
+       NO_REGEX = YesPlease
+       NO_PTHREADS = UnfortunatelyYes
+
+       # Not detected (nor checked for) by './configure'.
+       # We don't have SA_RESTART on NonStop, unfortunalety.
+       COMPAT_CFLAGS += -DSA_RESTART=0
+       # Apparently needed in compat/fnmatch/fnmatch.c.
+       COMPAT_CFLAGS += -DHAVE_STRING_H=1
+       NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
+       NO_NSEC = YesPlease
+       NO_PREAD = YesPlease
+       NO_MMAP = YesPlease
+       NO_POLL = YesPlease
+       NO_INTPTR_T = UnfortunatelyYes
+       # Bug report 10-120822-4477 submitted to HP NonStop development.
+       MKDIR_WO_TRAILING_SLASH = YesPlease
+       # RFE 10-120912-4693 submitted to HP NonStop development.
+       NO_SETITIMER = UnfortunatelyYes
+       SANE_TOOL_PATH = /usr/coreutils/bin:/usr/local/bin
+       SHELL_PATH = /usr/local/bin/bash
+       # as of H06.25/J06.14, we might better use this
+       #SHELL_PATH = /usr/coreutils/bin/bash
+endif
+ifneq (,$(findstring MINGW,$(uname_S)))
+       pathsep = ;
+       NO_PREAD = YesPlease
+       NEEDS_CRYPTO_WITH_SSL = YesPlease
+       NO_LIBGEN_H = YesPlease
+       NO_POLL = YesPlease
+       NO_SYMLINK_HEAD = YesPlease
+       NO_UNIX_SOCKETS = YesPlease
+       NO_SETENV = YesPlease
+       NO_UNSETENV = YesPlease
+       NO_STRCASESTR = YesPlease
+       NO_STRLCPY = YesPlease
+       NO_STRTOK_R = YesPlease
+       NO_FNMATCH = YesPlease
+       NO_MEMMEM = YesPlease
+       NEEDS_LIBICONV = YesPlease
+       OLD_ICONV = YesPlease
+       NO_STRTOUMAX = YesPlease
+       NO_MKDTEMP = YesPlease
+       NO_MKSTEMPS = YesPlease
+       NO_SVN_TESTS = YesPlease
+       NO_PERL_MAKEMAKER = YesPlease
+       RUNTIME_PREFIX = YesPlease
+       NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
+       NO_NSEC = YesPlease
+       USE_WIN32_MMAP = YesPlease
+       USE_NED_ALLOCATOR = YesPlease
+       UNRELIABLE_FSTAT = UnfortunatelyYes
+       OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
+       NO_REGEX = YesPlease
+       NO_PYTHON = YesPlease
+       BLK_SHA1 = YesPlease
+       ETAGS_TARGET = ETAGS
+       NO_INET_PTON = YesPlease
+       NO_INET_NTOP = YesPlease
+       NO_POSIX_GOODIES = UnfortunatelyYes
+       COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/win32
+       COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
+       COMPAT_OBJS += compat/mingw.o compat/winansi.o \
+               compat/win32/pthread.o compat/win32/syslog.o \
+               compat/win32/dirent.o
+       EXTLIBS += -lws2_32
+       PTHREAD_LIBS =
+       X = .exe
+       SPARSE_FLAGS = -Wno-one-bit-signed-bitfield
+ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
+       htmldir = doc/git/html/
+       prefix =
+       INSTALL = /bin/install
+       EXTLIBS += /mingw/lib/libz.a
+       NO_R_TO_GCC_LINKER = YesPlease
+       INTERNAL_QSORT = YesPlease
+       HAVE_LIBCHARSET_H = YesPlease
+else
+       NO_CURL = YesPlease
+endif
+endif
+ifeq ($(uname_S),QNX)
+       COMPAT_CFLAGS += -DSA_RESTART=0
+       HAVE_STRINGS_H = YesPlease
+       NEEDS_SOCKET = YesPlease
+       NO_FNMATCH_CASEFOLD = YesPlease
+       NO_GETPAGESIZE = YesPlease
+       NO_ICONV = YesPlease
+       NO_MEMMEM = YesPlease
+       NO_MKDTEMP = YesPlease
+       NO_MKSTEMPS = YesPlease
+       NO_NSEC = YesPlease
+       NO_PTHREADS = YesPlease
+       NO_R_TO_GCC_LINKER = YesPlease
+       NO_STRCASESTR = YesPlease
+       NO_STRLCPY = YesPlease
+endif
index ad215cc4a10ed95804e7cec929f003c985d25a3d..1991258ae031cd656a8b599fda16ec73695216cb 100644 (file)
@@ -753,6 +753,14 @@ AC_CHECK_MEMBER(struct dirent.d_type,
 [#include <dirent.h>])
 GIT_CONF_SUBST([NO_D_TYPE_IN_DIRENT])
 #
+# Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
+# in the C library.
+AC_CHECK_MEMBER(struct passwd.pw_gecos,
+[NO_GECOS_IN_PWENT=],
+[NO_GECOS_IN_PWENT=YesPlease],
+[#include <pwd.h>])
+GIT_CONF_SUBST([NO_GECOS_IN_PWENT])
+#
 # Define NO_SOCKADDR_STORAGE if your platform does not have struct
 # sockaddr_storage.
 AC_CHECK_TYPE(struct sockaddr_storage,
@@ -872,6 +880,12 @@ AC_CHECK_HEADER([libcharset.h],
 [HAVE_LIBCHARSET_H=YesPlease],
 [HAVE_LIBCHARSET_H=])
 GIT_CONF_SUBST([HAVE_LIBCHARSET_H])
+#
+# Define HAVE_STRINGS_H if you have strings.h
+AC_CHECK_HEADER([strings.h],
+[HAVE_STRINGS_H=YesPlease],
+[HAVE_STRINGS_H=])
+GIT_CONF_SUBST([HAVE_STRINGS_H])
 # Define CHARSET_LIB if libiconv does not export the locale_charset symbol
 # and libcharset does
 CHARSET_LIB=
@@ -1021,7 +1035,17 @@ if test -n "$USER_NOPTHREAD"; then
 # -D_REENTRANT' or some such.
 elif test -z "$PTHREAD_CFLAGS"; then
   threads_found=no
-  for opt in -mt -pthread -lpthread; do
+  # Attempt to compile and link some code using pthreads to determine
+  # required linker flags. The order is somewhat important here: We
+  # first try it without any extra flags, to catch systems where
+  # pthreads are part of the C library, then go on testing various other
+  # flags. We do so to avoid false positives. For example, on Mac OS X
+  # pthreads are part of the C library; moreover, the compiler allows us
+  # to add "-mt" to the CFLAGS (although it will do nothing except
+  # trigger a warning about an unused flag). Hence if we checked for
+  # "-mt" before "" we would end up picking it. But unfortunately this
+  # would then trigger compiler warnings on every single file we compile.
+  for opt in "" -mt -pthread -lpthread; do
      old_CFLAGS="$CFLAGS"
      CFLAGS="$opt $CFLAGS"
      AC_MSG_CHECKING([for POSIX Threads with '$opt'])
index bd24395d4cf404f886803892d0be98c964a43ce7..36b5665ff81af1d52be5e926b029452d3e838c35 100755 (executable)
 # we default to that.
 #
 
-import os, sys, commands, socket, urllib
+import sys
+if sys.hexversion < 0x02000000:
+        # The limiter is the xml.sax module
+        sys.stderr.write("ciabot.py: requires Python 2.0.0 or later.\n")
+        sys.exit(1)
+
+import os, commands, socket, urllib
 from xml.sax.saxutils import escape
 
 # Changeset URL prefix for your repo: when the commit ID is appended
index 0b77eb1fa4074fb8ed5ef4cd4c37513f49804e7e..14dd5e7ca272350b3fa13d6fc8da3ccb46e12227 100644 (file)
@@ -397,7 +397,7 @@ __git_complete_revlist_file ()
                *)   pfx="$ref:$pfx" ;;
                esac
 
-               __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
+               __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null \
                                | sed '/^100... blob /{
                                           s,^.*        ,,
                                           s,$, ,
@@ -971,6 +971,13 @@ _git_commit ()
 {
        __git_has_doubledash && return
 
+       case "$prev" in
+       -c|-C)
+               __gitcomp_nl "$(__git_refs)" "" "${cur}"
+               return
+               ;;
+       esac
+
        case "$cur" in
        --cleanup=*)
                __gitcomp "default strip verbatim whitespace
index 8aafb63315c52a08e6f581e0ef13aa9c239b03a8..3e3889f2b4fd3acb441e56284750cb22fef80547 100644 (file)
@@ -13,6 +13,7 @@
 #
 # To use this completion script:
 #
+#    0) You need tcsh 6.16.00 or newer.
 #    1) Copy both this file and the bash completion script to ${HOME}.
 #       You _must_ use the name ${HOME}/.git-completion.bash for the
 #       bash script.
 #        set autolist=ambiguous
 #       It will tell tcsh to list the possible completion choices.
 
+set __git_tcsh_completion_version = `\echo ${tcsh} | \sed 's/\./ /g'`
+if ( ${__git_tcsh_completion_version[1]} < 6 || \
+     ( ${__git_tcsh_completion_version[1]} == 6 && \
+       ${__git_tcsh_completion_version[2]} < 16 ) ) then
+       echo "git-completion.tcsh: Your version of tcsh is too old, you need version 6.16.00 or newer.  Git completion will not work."
+       exit
+endif
+unset __git_tcsh_completion_version
+
 set __git_tcsh_completion_original_script = ${HOME}/.git-completion.bash
 set __git_tcsh_completion_script = ${HOME}/.git-completion.tcsh.bash
 
@@ -64,9 +74,7 @@ fi
 _\${1}
 
 IFS=\$'\n'
-if [ \${#COMPREPLY[*]} -gt 0 ]; then
-       echo "\${COMPREPLY[*]}" | sort | uniq
-else
+if [ \${#COMPREPLY[*]} -eq 0 ]; then
        # No completions suggested.  In this case, we want tcsh to perform
        # standard file completion.  However, there does not seem to be way
        # to tell tcsh to do that.  To help the user, we try to simulate
@@ -85,19 +93,20 @@ else
                # We don't support ~ expansion: too tricky.
                if [ "\${TO_COMPLETE:0:1}" != "~" ]; then
                        # Use ls so as to add the '/' at the end of directories.
-                       RESULT=(\`ls -dp \${TO_COMPLETE}* 2> /dev/null\`)
-                       echo \${RESULT[*]}
-
-                       # If there is a single completion and it is a directory,
-                       # we output it a second time to trick tcsh into not adding a space
-                       # after it.
-                       if [ \${#RESULT[*]} -eq 1 ] && [ "\${RESULT[0]: -1}" == "/" ]; then
-                               echo \${RESULT[*]}
-                       fi
+                       COMPREPLY=(\`ls -dp \${TO_COMPLETE}* 2> /dev/null\`)
                fi
        fi
 fi
 
+# tcsh does not automatically remove duplicates, so we do it ourselves
+echo "\${COMPREPLY[*]}" | sort | uniq
+
+# If there is a single completion and it is a directory, we output it
+# a second time to trick tcsh into not adding a space after it.
+if [ \${#COMPREPLY[*]} -eq 1 ] && [ "\${COMPREPLY[0]: -1}" == "/" ]; then
+       echo "\${COMPREPLY[*]}"
+fi
+
 EOF
 
 # Don't need this variable anymore, so don't pollute the users environment
index 9b074e148d980e5b96819345be23f9b614db849d..9bef0531c5d9358e906bb7872f0775e165caac2c 100644 (file)
@@ -24,6 +24,8 @@
 #        will show username, at-sign, host, colon, cwd, then
 #        various status string, followed by dollar and SP, as
 #        your prompt.
+#        Optionally, you can supply a third argument with a printf
+#        format string to finetune the output of the branch status
 #
 # The argument to __git_ps1 will be displayed only if you are currently
 # in a git repository.  The %s token will be the name of the current
@@ -222,10 +224,12 @@ __git_ps1_show_upstream ()
 # when called from PS1 using command substitution
 # in this mode it prints text to add to bash PS1 prompt (includes branch name)
 #
-# __git_ps1 requires 2 arguments when called from PROMPT_COMMAND (pc)
+# __git_ps1 requires 2 or 3 arguments when called from PROMPT_COMMAND (pc)
 # in that case it _sets_ PS1. The arguments are parts of a PS1 string.
-# when both arguments are given, the first is prepended and the second appended
+# when two arguments are given, the first is prepended and the second appended
 # to the state string when assigned to PS1.
+# The optional third parameter will be used as printf format string to further
+# customize the output of the git-status string.
 # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
 __git_ps1 ()
 {
@@ -236,9 +240,10 @@ __git_ps1 ()
        local printf_format=' (%s)'
 
        case "$#" in
-               2)      pcmode=yes
+               2|3)    pcmode=yes
                        ps1pc_start="$1"
                        ps1pc_end="$2"
+                       printf_format="${3:-$printf_format}"
                ;;
                0|1)    printf_format="${1:-$printf_format}"
                ;;
@@ -339,6 +344,7 @@ __git_ps1 ()
 
                local f="$w$i$s$u"
                if [ $pcmode = yes ]; then
+                       local gitstring=
                        if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
                                local c_red='\e[31m'
                                local c_green='\e[32m'
@@ -356,29 +362,31 @@ __git_ps1 ()
                                        branch_color="$bad_color"
                                fi
 
-                               # Setting PS1 directly with \[ and \] around colors
+                               # Setting gitstring directly with \[ and \] around colors
                                # is necessary to prevent wrapping issues!
-                               PS1="$ps1pc_start (\[$branch_color\]$branchstring\[$c_clear\]"
+                               gitstring="\[$branch_color\]$branchstring\[$c_clear\]"
 
                                if [ -n "$w$i$s$u$r$p" ]; then
-                                       PS1="$PS1 "
+                                       gitstring="$gitstring "
                                fi
                                if [ "$w" = "*" ]; then
-                                       PS1="$PS1\[$bad_color\]$w"
+                                       gitstring="$gitstring\[$bad_color\]$w"
                                fi
                                if [ -n "$i" ]; then
-                                       PS1="$PS1\[$ok_color\]$i"
+                                       gitstring="$gitstring\[$ok_color\]$i"
                                fi
                                if [ -n "$s" ]; then
-                                       PS1="$PS1\[$flags_color\]$s"
+                                       gitstring="$gitstring\[$flags_color\]$s"
                                fi
                                if [ -n "$u" ]; then
-                                       PS1="$PS1\[$bad_color\]$u"
+                                       gitstring="$gitstring\[$bad_color\]$u"
                                fi
-                               PS1="$PS1\[$c_clear\]$r$p)$ps1pc_end"
+                               gitstring="$gitstring\[$c_clear\]$r$p"
                        else
-                               PS1="$ps1pc_start ($c${b##refs/heads/}${f:+ $f}$r$p)$ps1pc_end"
+                               gitstring="$c${b##refs/heads/}${f:+ $f}$r$p"
                        fi
+                       gitstring=$(printf -- "$printf_format" "$gitstring")
+                       PS1="$ps1pc_start$gitstring$ps1pc_end"
                else
                        # NO color option unless in PROMPT_COMMAND mode
                        printf -- "$printf_format" "$c${b##refs/heads/}${f:+ $f}$r$p"
index 82f5ed3ddc8adb1b9b281c3912f4e67c53ef152f..5cec9b012994de61ba6ed1e4c17992edbfd8a07d 100755 (executable)
@@ -9,10 +9,15 @@
 ##  git log --stat import-zips
 
 from os import popen, path
-from sys import argv, exit
+from sys import argv, exit, hexversion, stderr
 from time import mktime
 from zipfile import ZipFile
 
+if hexversion < 0x01060000:
+        # The limiter is the zipfile module
+        sys.stderr.write("import-zips.py: requires Python 1.6.0 or later.\n")
+        sys.exit(1)
+
 if len(argv) < 2:
        print 'Usage:', argv[0], '<zipfile>...'
        exit(1)
index 046cb2b268a82358630e86bb55cf8b4e58c730fb..232625a7b72aef88ef9cc0285eb7208ce38a2138 100755 (executable)
@@ -23,6 +23,11 @@ import os, os.path, sys
 import tempfile, pickle, getopt
 import re
 
+if sys.hexversion < 0x02030000:
+   # The behavior of the pickle module changed significantly in 2.3
+   sys.stderr.write("hg-to-git.py: requires Python 2.3 or later.\n")
+   sys.exit(1)
+
 # Maps hg version -> git version
 hgvers = {}
 # List of children for each hg revision
index b6e534b65b687d955a878d902b9bb46cfa2e42ce..593d6a0682ba49e31e40e1b4e5c3e0af82fd9cda 100644 (file)
@@ -14,6 +14,11 @@ import sys
 import time
 import getopt
 
+if sys.hexversion < 0x02020000:
+   # The behavior of the marshal module changed significantly in 2.2
+   sys.stderr.write("git-p4import.py: requires Python 2.2 or later.\n")
+   sys.exit(1)
+
 from signal import signal, \
    SIGPIPE, SIGINT, SIG_DFL, \
    default_int_handler
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
new file mode 100755 (executable)
index 0000000..c5822e4
--- /dev/null
@@ -0,0 +1,725 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2012 Felipe Contreras
+#
+
+#
+# Just copy to your ~/bin, or anywhere in your $PATH.
+# Then you can clone with:
+# % git clone bzr::/path/to/bzr/repo/or/url
+#
+# For example:
+# % git clone bzr::$HOME/myrepo
+# or
+# % git clone bzr::lp:myrepo
+#
+
+import sys
+
+import bzrlib
+if hasattr(bzrlib, "initialize"):
+    bzrlib.initialize()
+
+import bzrlib.plugin
+bzrlib.plugin.load_plugins()
+
+import bzrlib.generate_ids
+import bzrlib.transport
+
+import sys
+import os
+import json
+import re
+import StringIO
+
+NAME_RE = re.compile('^([^<>]+)')
+AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
+RAW_AUTHOR_RE = re.compile('^(\w+) (.+)? <(.*)> (\d+) ([+-]\d+)')
+
+def die(msg, *args):
+    sys.stderr.write('ERROR: %s\n' % (msg % args))
+    sys.exit(1)
+
+def warn(msg, *args):
+    sys.stderr.write('WARNING: %s\n' % (msg % args))
+
+def gittz(tz):
+    return '%+03d%02d' % (tz / 3600, tz % 3600 / 60)
+
+class Marks:
+
+    def __init__(self, path):
+        self.path = path
+        self.tips = {}
+        self.marks = {}
+        self.rev_marks = {}
+        self.last_mark = 0
+        self.load()
+
+    def load(self):
+        if not os.path.exists(self.path):
+            return
+
+        tmp = json.load(open(self.path))
+        self.tips = tmp['tips']
+        self.marks = tmp['marks']
+        self.last_mark = tmp['last-mark']
+
+        for rev, mark in self.marks.iteritems():
+            self.rev_marks[mark] = rev
+
+    def dict(self):
+        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark }
+
+    def store(self):
+        json.dump(self.dict(), open(self.path, 'w'))
+
+    def __str__(self):
+        return str(self.dict())
+
+    def from_rev(self, rev):
+        return self.marks[rev]
+
+    def to_rev(self, mark):
+        return self.rev_marks[mark]
+
+    def next_mark(self):
+        self.last_mark += 1
+        return self.last_mark
+
+    def get_mark(self, rev):
+        self.last_mark += 1
+        self.marks[rev] = self.last_mark
+        return self.last_mark
+
+    def is_marked(self, rev):
+        return self.marks.has_key(rev)
+
+    def new_mark(self, rev, mark):
+        self.marks[rev] = mark
+        self.rev_marks[mark] = rev
+        self.last_mark = mark
+
+    def get_tip(self, branch):
+        return self.tips.get(branch, None)
+
+    def set_tip(self, branch, tip):
+        self.tips[branch] = tip
+
+class Parser:
+
+    def __init__(self, repo):
+        self.repo = repo
+        self.line = self.get_line()
+
+    def get_line(self):
+        return sys.stdin.readline().strip()
+
+    def __getitem__(self, i):
+        return self.line.split()[i]
+
+    def check(self, word):
+        return self.line.startswith(word)
+
+    def each_block(self, separator):
+        while self.line != separator:
+            yield self.line
+            self.line = self.get_line()
+
+    def __iter__(self):
+        return self.each_block('')
+
+    def next(self):
+        self.line = self.get_line()
+        if self.line == 'done':
+            self.line = None
+
+    def get_mark(self):
+        i = self.line.index(':') + 1
+        return int(self.line[i:])
+
+    def get_data(self):
+        if not self.check('data'):
+            return None
+        i = self.line.index(' ') + 1
+        size = int(self.line[i:])
+        return sys.stdin.read(size)
+
+    def get_author(self):
+        m = RAW_AUTHOR_RE.match(self.line)
+        if not m:
+            return None
+        _, name, email, date, tz = m.groups()
+        committer = '%s <%s>' % (name, email)
+        tz = int(tz)
+        tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
+        return (committer, int(date), tz)
+
+def rev_to_mark(rev):
+    global marks
+    return marks.from_rev(rev)
+
+def mark_to_rev(mark):
+    global marks
+    return marks.to_rev(mark)
+
+def fixup_user(user):
+    name = mail = None
+    user = user.replace('"', '')
+    m = AUTHOR_RE.match(user)
+    if m:
+        name = m.group(1)
+        mail = m.group(2).strip()
+    else:
+        m = NAME_RE.match(user)
+        if m:
+            name = m.group(1).strip()
+
+    return '%s <%s>' % (name, mail)
+
+def get_filechanges(cur, prev):
+    modified = {}
+    removed = {}
+
+    changes = cur.changes_from(prev)
+
+    for path, fid, kind in changes.added:
+        modified[path] = fid
+    for path, fid, kind in changes.removed:
+        removed[path] = None
+    for path, fid, kind, mod, _ in changes.modified:
+        modified[path] = fid
+    for oldpath, newpath, fid, kind, mod, _ in changes.renamed:
+        removed[oldpath] = None
+        modified[newpath] = fid
+
+    return modified, removed
+
+def export_files(tree, files):
+    global marks, filenodes
+
+    final = []
+    for path, fid in files.iteritems():
+        kind = tree.kind(fid)
+
+        h = tree.get_file_sha1(fid)
+
+        if kind == 'symlink':
+            d = tree.get_symlink_target(fid)
+            mode = '120000'
+        elif kind == 'file':
+
+            if tree.is_executable(fid):
+                mode = '100755'
+            else:
+                mode = '100644'
+
+            # is the blog already exported?
+            if h in filenodes:
+                mark = filenodes[h]
+                final.append((mode, mark, path))
+                continue
+
+            d = tree.get_file_text(fid)
+        elif kind == 'directory':
+            continue
+        else:
+            die("Unhandled kind '%s' for path '%s'" % (kind, path))
+
+        mark = marks.next_mark()
+        filenodes[h] = mark
+
+        print "blob"
+        print "mark :%u" % mark
+        print "data %d" % len(d)
+        print d
+
+        final.append((mode, mark, path))
+
+    return final
+
+def export_branch(branch, name):
+    global prefix, dirname
+
+    ref = '%s/heads/%s' % (prefix, name)
+    tip = marks.get_tip(name)
+
+    repo = branch.repository
+    repo.lock_read()
+    revs = branch.iter_merge_sorted_revisions(None, tip, 'exclude', 'forward')
+    count = 0
+
+    revs = [revid for revid, _, _, _ in revs if not marks.is_marked(revid)]
+
+    for revid in revs:
+
+        rev = repo.get_revision(revid)
+
+        parents = rev.parent_ids
+        time = rev.timestamp
+        tz = rev.timezone
+        committer = rev.committer.encode('utf-8')
+        committer = "%s %u %s" % (fixup_user(committer), time, gittz(tz))
+        author = committer
+        msg = rev.message.encode('utf-8')
+
+        msg += '\n'
+
+        if len(parents) == 0:
+            parent = bzrlib.revision.NULL_REVISION
+        else:
+            parent = parents[0]
+
+        cur_tree = repo.revision_tree(revid)
+        prev = repo.revision_tree(parent)
+        modified, removed = get_filechanges(cur_tree, prev)
+
+        modified_final = export_files(cur_tree, modified)
+
+        if len(parents) == 0:
+            print 'reset %s' % ref
+
+        print "commit %s" % ref
+        print "mark :%d" % (marks.get_mark(revid))
+        print "author %s" % (author)
+        print "committer %s" % (committer)
+        print "data %d" % (len(msg))
+        print msg
+
+        for i, p in enumerate(parents):
+            try:
+                m = rev_to_mark(p)
+            except KeyError:
+                # ghost?
+                continue
+            if i == 0:
+                print "from :%s" % m
+            else:
+                print "merge :%s" % m
+
+        for f in modified_final:
+            print "M %s :%u %s" % f
+        for f in removed:
+            print "D %s" % (f)
+        print
+
+        count += 1
+        if (count % 100 == 0):
+            print "progress revision %s (%d/%d)" % (revid, count, len(revs))
+            print "#############################################################"
+
+    repo.unlock()
+
+    revid = branch.last_revision()
+
+    # make sure the ref is updated
+    print "reset %s" % ref
+    print "from :%u" % rev_to_mark(revid)
+    print
+
+    marks.set_tip(name, revid)
+
+def export_tag(repo, name):
+    global tags
+    try:
+        print "reset refs/tags/%s" % name
+        print "from :%u" % rev_to_mark(tags[name])
+        print
+    except KeyError:
+        warn("TODO: fetch tag '%s'" % name)
+
+def do_import(parser):
+    global dirname
+
+    branch = parser.repo
+    path = os.path.join(dirname, 'marks-git')
+
+    print "feature done"
+    if os.path.exists(path):
+        print "feature import-marks=%s" % path
+    print "feature export-marks=%s" % path
+    sys.stdout.flush()
+
+    while parser.check('import'):
+        ref = parser[1]
+        if ref.startswith('refs/heads/'):
+            name = ref[len('refs/heads/'):]
+            export_branch(branch, name)
+        if ref.startswith('refs/tags/'):
+            name = ref[len('refs/tags/'):]
+            export_tag(branch, name)
+        parser.next()
+
+    print 'done'
+
+    sys.stdout.flush()
+
+def parse_blob(parser):
+    global blob_marks
+
+    parser.next()
+    mark = parser.get_mark()
+    parser.next()
+    data = parser.get_data()
+    blob_marks[mark] = data
+    parser.next()
+
+class CustomTree():
+
+    def __init__(self, repo, revid, parents, files):
+        global files_cache
+
+        self.repo = repo
+        self.revid = revid
+        self.parents = parents
+        self.updates = {}
+
+        def copy_tree(revid):
+            files = files_cache[revid] = {}
+            tree = repo.repository.revision_tree(revid)
+            repo.lock_read()
+            try:
+                for path, entry in tree.iter_entries_by_dir():
+                    files[path] = entry.file_id
+            finally:
+                repo.unlock()
+            return files
+
+        if len(parents) == 0:
+            self.base_id = bzrlib.revision.NULL_REVISION
+            self.base_files = {}
+        else:
+            self.base_id = parents[0]
+            self.base_files = files_cache.get(self.base_id, None)
+            if not self.base_files:
+                self.base_files = copy_tree(self.base_id)
+
+        self.files = files_cache[revid] = self.base_files.copy()
+
+        for path, f in files.iteritems():
+            fid = self.files.get(path, None)
+            if not fid:
+                fid = bzrlib.generate_ids.gen_file_id(path)
+            f['path'] = path
+            self.updates[fid] = f
+
+    def last_revision(self):
+        return self.base_id
+
+    def iter_changes(self):
+        changes = []
+
+        def get_parent(dirname, basename):
+            parent_fid = self.base_files.get(dirname, None)
+            if parent_fid:
+                return parent_fid
+            parent_fid = self.files.get(dirname, None)
+            if parent_fid:
+                return parent_fid
+            if basename == '':
+                return None
+            fid = bzrlib.generate_ids.gen_file_id(path)
+            d = add_entry(fid, dirname, 'directory')
+            return fid
+
+        def add_entry(fid, path, kind, mode = None):
+            dirname, basename = os.path.split(path)
+            parent_fid = get_parent(dirname, basename)
+
+            executable = False
+            if mode == '100755':
+                executable = True
+            elif mode == '120000':
+                kind = 'symlink'
+
+            change = (fid,
+                    (None, path),
+                    True,
+                    (False, True),
+                    (None, parent_fid),
+                    (None, basename),
+                    (None, kind),
+                    (None, executable))
+            self.files[path] = change[0]
+            changes.append(change)
+            return change
+
+        def update_entry(fid, path, kind, mode = None):
+            dirname, basename = os.path.split(path)
+            parent_fid = get_parent(dirname, basename)
+
+            executable = False
+            if mode == '100755':
+                executable = True
+            elif mode == '120000':
+                kind = 'symlink'
+
+            change = (fid,
+                    (path, path),
+                    True,
+                    (True, True),
+                    (None, parent_fid),
+                    (None, basename),
+                    (None, kind),
+                    (None, executable))
+            self.files[path] = change[0]
+            changes.append(change)
+            return change
+
+        def remove_entry(fid, path, kind):
+            dirname, basename = os.path.split(path)
+            parent_fid = get_parent(dirname, basename)
+            change = (fid,
+                    (path, None),
+                    True,
+                    (True, False),
+                    (parent_fid, None),
+                    (None, None),
+                    (None, None),
+                    (None, None))
+            del self.files[path]
+            changes.append(change)
+            return change
+
+        for fid, f in self.updates.iteritems():
+            path = f['path']
+
+            if 'deleted' in f:
+                remove_entry(fid, path, 'file')
+                continue
+
+            if path in self.base_files:
+                update_entry(fid, path, 'file', f['mode'])
+            else:
+                add_entry(fid, path, 'file', f['mode'])
+
+        return changes
+
+    def get_file_with_stat(self, file_id, path=None):
+        return (StringIO.StringIO(self.updates[file_id]['data']), None)
+
+    def get_symlink_target(self, file_id):
+        return self.updates[file_id]['data']
+
+def parse_commit(parser):
+    global marks, blob_marks, bmarks, parsed_refs
+    global mode
+
+    parents = []
+
+    ref = parser[1]
+    parser.next()
+
+    if ref != 'refs/heads/master':
+        die("bzr doesn't support multiple branches; use 'master'")
+
+    commit_mark = parser.get_mark()
+    parser.next()
+    author = parser.get_author()
+    parser.next()
+    committer = parser.get_author()
+    parser.next()
+    data = parser.get_data()
+    parser.next()
+    if parser.check('from'):
+        parents.append(parser.get_mark())
+        parser.next()
+    while parser.check('merge'):
+        parents.append(parser.get_mark())
+        parser.next()
+
+    files = {}
+
+    for line in parser:
+        if parser.check('M'):
+            t, m, mark_ref, path = line.split(' ', 3)
+            mark = int(mark_ref[1:])
+            f = { 'mode' : m, 'data' : blob_marks[mark] }
+        elif parser.check('D'):
+            t, path = line.split(' ')
+            f = { 'deleted' : True }
+        else:
+            die('Unknown file command: %s' % line)
+        files[path] = f
+
+    repo = parser.repo
+
+    committer, date, tz = committer
+    parents = [str(mark_to_rev(p)) for p in parents]
+    revid = bzrlib.generate_ids.gen_revision_id(committer, date)
+    props = {}
+    props['branch-nick'] = repo.nick
+
+    mtree = CustomTree(repo, revid, parents, files)
+    changes = mtree.iter_changes()
+
+    repo.lock_write()
+    try:
+        builder = repo.get_commit_builder(parents, None, date, tz, committer, props, revid)
+        try:
+            list(builder.record_iter_changes(mtree, mtree.last_revision(), changes))
+            builder.finish_inventory()
+            builder.commit(data.decode('utf-8', 'replace'))
+        except Exception, e:
+            builder.abort()
+            raise
+    finally:
+        repo.unlock()
+
+    parsed_refs[ref] = revid
+    marks.new_mark(revid, commit_mark)
+
+def parse_reset(parser):
+    global parsed_refs
+
+    ref = parser[1]
+    parser.next()
+
+    if ref != 'refs/heads/master':
+        die("bzr doesn't support multiple branches; use 'master'")
+
+    # ugh
+    if parser.check('commit'):
+        parse_commit(parser)
+        return
+    if not parser.check('from'):
+        return
+    from_mark = parser.get_mark()
+    parser.next()
+
+    parsed_refs[ref] = mark_to_rev(from_mark)
+
+def do_export(parser):
+    global parsed_refs, dirname, peer
+
+    parser.next()
+
+    for line in parser.each_block('done'):
+        if parser.check('blob'):
+            parse_blob(parser)
+        elif parser.check('commit'):
+            parse_commit(parser)
+        elif parser.check('reset'):
+            parse_reset(parser)
+        elif parser.check('tag'):
+            pass
+        elif parser.check('feature'):
+            pass
+        else:
+            die('unhandled export command: %s' % line)
+
+    repo = parser.repo
+
+    for ref, revid in parsed_refs.iteritems():
+        if ref == 'refs/heads/master':
+            repo.generate_revision_history(revid, marks.get_tip('master'))
+            revno, revid = repo.last_revision_info()
+            if peer:
+                if hasattr(peer, "import_last_revision_info_and_tags"):
+                    peer.import_last_revision_info_and_tags(repo, revno, revid)
+                else:
+                    peer.import_last_revision_info(repo.repository, revno, revid)
+                wt = peer.bzrdir.open_workingtree()
+            else:
+                wt = repo.bzrdir.open_workingtree()
+            wt.update()
+        print "ok %s" % ref
+    print
+
+def do_capabilities(parser):
+    global dirname
+
+    print "import"
+    print "export"
+    print "refspec refs/heads/*:%s/heads/*" % prefix
+
+    path = os.path.join(dirname, 'marks-git')
+
+    if os.path.exists(path):
+        print "*import-marks %s" % path
+    print "*export-marks %s" % path
+
+    print
+
+def do_list(parser):
+    global tags
+    print "? refs/heads/%s" % 'master'
+    for tag, revid in parser.repo.tags.get_tag_dict().items():
+        print "? refs/tags/%s" % tag
+        tags[tag] = revid
+    print "@refs/heads/%s HEAD" % 'master'
+    print
+
+def get_repo(url, alias):
+    global dirname, peer
+
+    origin = bzrlib.bzrdir.BzrDir.open(url)
+    branch = origin.open_branch()
+
+    if not isinstance(origin.transport, bzrlib.transport.local.LocalTransport):
+        clone_path = os.path.join(dirname, 'clone')
+        remote_branch = branch
+        if os.path.exists(clone_path):
+            # pull
+            d = bzrlib.bzrdir.BzrDir.open(clone_path)
+            branch = d.open_branch()
+            result = branch.pull(remote_branch, [], None, False)
+        else:
+            # clone
+            d = origin.sprout(clone_path, None,
+                    hardlink=True, create_tree_if_local=False,
+                    source_branch=remote_branch)
+            branch = d.open_branch()
+            branch.bind(remote_branch)
+
+        peer = remote_branch
+    else:
+        peer = None
+
+    return branch
+
+def main(args):
+    global marks, prefix, dirname
+    global tags, filenodes
+    global blob_marks
+    global parsed_refs
+    global files_cache
+
+    alias = args[1]
+    url = args[2]
+
+    prefix = 'refs/bzr/%s' % alias
+    tags = {}
+    filenodes = {}
+    blob_marks = {}
+    parsed_refs = {}
+    files_cache = {}
+
+    gitdir = os.environ['GIT_DIR']
+    dirname = os.path.join(gitdir, 'bzr', alias)
+
+    if not os.path.exists(dirname):
+        os.makedirs(dirname)
+
+    repo = get_repo(url, alias)
+
+    marks_path = os.path.join(dirname, 'marks-int')
+    marks = Marks(marks_path)
+
+    parser = Parser(repo)
+    for line in parser:
+        if parser.check('capabilities'):
+            do_capabilities(parser)
+        elif parser.check('list'):
+            do_list(parser)
+        elif parser.check('import'):
+            do_import(parser)
+        elif parser.check('export'):
+            do_export(parser)
+        else:
+            die('unhandled command: %s' % line)
+        sys.stdout.flush()
+
+    marks.store()
+
+sys.exit(main(sys.argv))
index 016cdadb4d8d5af3b0b68c21c1df3054dd1c5f17..328c2dc76dd33e47cfe69064757631e9717771e6 100755 (executable)
@@ -31,7 +31,7 @@ import urllib
 # hg:
 # Emulate hg-git.
 # Only hg bookmarks are exported as git branches.
-# Commits are modified to preserve hg information and allow biridectionality.
+# Commits are modified to preserve hg information and allow bidirectionality.
 #
 
 NAME_RE = re.compile('^([^<>]+)')
@@ -53,7 +53,7 @@ def gittz(tz):
     return '%+03d%02d' % (-tz / 3600, -tz % 3600 / 60)
 
 def hgmode(mode):
-    m = { '0100755': 'x', '0120000': 'l' }
+    m = { '100755': 'x', '120000': 'l' }
     return m.get(mode, '')
 
 def get_config(config):
@@ -720,6 +720,14 @@ def do_export(parser):
     if peer:
         parser.repo.push(peer, force=False)
 
+def fix_path(alias, repo, orig_url):
+    repo_url = util.url(repo.url())
+    url = util.url(orig_url)
+    if str(url) == str(repo_url):
+        return
+    cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % repo_url]
+    subprocess.call(cmd)
+
 def main(args):
     global prefix, dirname, branches, bmarks
     global marks, blob_marks, parsed_refs
@@ -766,6 +774,9 @@ def main(args):
     repo = get_repo(url, alias)
     prefix = 'refs/hg/%s' % alias
 
+    if not is_tmp:
+        fix_path(alias, peer or repo, url)
+
     if not os.path.exists(dirname):
         os.makedirs(dirname)
 
diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh
new file mode 100755 (executable)
index 0000000..70aa8a0
--- /dev/null
@@ -0,0 +1,143 @@
+#!/bin/sh
+#
+# Copyright (c) 2012 Felipe Contreras
+#
+
+test_description='Test remote-bzr'
+
+. ./test-lib.sh
+
+if ! test_have_prereq PYTHON; then
+       skip_all='skipping remote-bzr tests; python not available'
+       test_done
+fi
+
+if ! "$PYTHON_PATH" -c 'import bzrlib'; then
+       skip_all='skipping remote-bzr tests; bzr not available'
+       test_done
+fi
+
+cmd='
+import bzrlib
+bzrlib.initialize()
+import bzrlib.plugin
+bzrlib.plugin.load_plugins()
+import bzrlib.plugins.fastimport
+'
+
+if ! "$PYTHON_PATH" -c "$cmd"; then
+       echo "consider setting BZR_PLUGIN_PATH=$HOME/.bazaar/plugins" 1>&2
+       skip_all='skipping remote-bzr tests; bzr-fastimport not available'
+       test_done
+fi
+
+check () {
+       (cd $1 &&
+       git log --format='%s' -1 &&
+       git symbolic-ref HEAD) > actual &&
+       (echo $2 &&
+       echo "refs/heads/$3") > expected &&
+       test_cmp expected actual
+}
+
+bzr whoami "A U Thor <author@example.com>"
+
+test_expect_success 'cloning' '
+  (bzr init bzrrepo &&
+  cd bzrrepo &&
+  echo one > content &&
+  bzr add content &&
+  bzr commit -m one
+  ) &&
+
+  git clone "bzr::$PWD/bzrrepo" gitrepo &&
+  check gitrepo one master
+'
+
+test_expect_success 'pulling' '
+  (cd bzrrepo &&
+  echo two > content &&
+  bzr commit -m two
+  ) &&
+
+  (cd gitrepo && git pull) &&
+
+  check gitrepo two master
+'
+
+test_expect_success 'pushing' '
+  (cd gitrepo &&
+  echo three > content &&
+  git commit -a -m three &&
+  git push
+  ) &&
+
+  echo three > expected &&
+  cat bzrrepo/content > actual &&
+  test_cmp expected actual
+'
+
+test_expect_success 'roundtrip' '
+  (cd gitrepo &&
+  git pull &&
+  git log --format="%s" -1 origin/master > actual) &&
+  echo three > expected &&
+  test_cmp expected actual &&
+
+  (cd gitrepo && git push && git pull) &&
+
+  (cd bzrrepo &&
+  echo four > content &&
+  bzr commit -m four
+  ) &&
+
+  (cd gitrepo && git pull && git push) &&
+
+  check gitrepo four master &&
+
+  (cd gitrepo &&
+  echo five > content &&
+  git commit -a -m five &&
+  git push && git pull
+  ) &&
+
+  (cd bzrrepo && bzr revert) &&
+
+  echo five > expected &&
+  cat bzrrepo/content > actual &&
+  test_cmp expected actual
+'
+
+cat > expected <<EOF
+100644 blob 54f9d6da5c91d556e6b54340b1327573073030af   content
+100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb   executable
+120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea   link
+EOF
+
+test_expect_success 'special modes' '
+  (cd bzrrepo &&
+  echo exec > executable
+  chmod +x executable &&
+  bzr add executable
+  bzr commit -m exec &&
+  ln -s content link
+  bzr add link
+  bzr commit -m link &&
+  mkdir dir &&
+  bzr add dir &&
+  bzr commit -m dir) &&
+
+  (cd gitrepo &&
+  git pull
+  git ls-tree HEAD > ../actual) &&
+
+  test_cmp expected actual &&
+
+  (cd gitrepo &&
+  git cat-file -p HEAD:link > ../actual) &&
+
+  echo -n content > expected &&
+  test_cmp expected actual
+'
+
+test_done
index a94eb28092503c060cc725b720715d611d54527a..1d6198243667c655639781019d8d608e0791e00b 100755 (executable)
@@ -6,7 +6,7 @@
 # https://bitbucket.org/durin42/hg-git/src
 #
 
-test_description='Test biridectionality of remote-hg'
+test_description='Test bidirectionality of remote-hg'
 
 . ./test-lib.sh
 
index 3e76d9fb60bff8b25f5b2751c6e11cfabb6c9dc6..7e3967f5b6f0c19939bf1c0c30be0d756ec6aa04 100755 (executable)
@@ -109,6 +109,74 @@ setup () {
 
 setup
 
+test_expect_success 'executable bit' '
+       mkdir -p tmp && cd tmp &&
+       test_when_finished "cd .. && rm -rf tmp" &&
+
+       (
+       git init -q gitrepo &&
+       cd gitrepo &&
+       echo alpha > alpha &&
+       chmod 0644 alpha &&
+       git add alpha &&
+       git commit -m "add alpha" &&
+       chmod 0755 alpha &&
+       git add alpha &&
+       git commit -m "set executable bit" &&
+       chmod 0644 alpha &&
+       git add alpha &&
+       git commit -m "clear executable bit"
+       ) &&
+
+       for x in hg git; do
+               (
+               hg_clone_$x gitrepo hgrepo-$x &&
+               cd hgrepo-$x &&
+               hg_log . &&
+               hg manifest -r 1 -v &&
+               hg manifest -v
+               ) > output-$x &&
+
+               git_clone_$x hgrepo-$x gitrepo2-$x &&
+               git_log gitrepo2-$x > log-$x
+       done &&
+       cp -r log-* output-* /tmp/foo/ &&
+
+       test_cmp output-hg output-git &&
+       test_cmp log-hg log-git
+'
+
+test_expect_success 'symlink' '
+       mkdir -p tmp && cd tmp &&
+       test_when_finished "cd .. && rm -rf tmp" &&
+
+       (
+       git init -q gitrepo &&
+       cd gitrepo &&
+       echo alpha > alpha &&
+       git add alpha &&
+       git commit -m "add alpha" &&
+       ln -s alpha beta &&
+       git add beta &&
+       git commit -m "add beta"
+       ) &&
+
+       for x in hg git; do
+               (
+               hg_clone_$x gitrepo hgrepo-$x &&
+               cd hgrepo-$x &&
+               hg_log . &&
+               hg manifest -v
+               ) > output-$x &&
+
+               git_clone_$x hgrepo-$x gitrepo2-$x &&
+               git_log gitrepo2-$x > log-$x
+       done &&
+
+       test_cmp output-hg output-git &&
+       test_cmp log-hg log-git
+'
+
 test_expect_success 'merge conflict 1' '
        mkdir -p tmp && cd tmp &&
        test_when_finished "cd .. && rm -rf tmp" &&
index 4b852e2455bab324e3bd16e02ec712fbacbf34b0..9513f5e35b443c13cead1f73a27b5e76f94e8d66 100755 (executable)
@@ -1,38 +1,70 @@
-#!/usr/bin/perl -w
-my %mailmap = ();
-open I, "<", ".mailmap";
-while (<I>) {
-       chomp;
-       next if /^#/;
-       if (my ($author, $mail) = /^(.*?)\s+<(.+)>$/) {
-               $mailmap{$mail} = $author;
-       }
+#!/usr/bin/perl
+
+use warnings 'all';
+use strict;
+use Getopt::Long;
+
+my $match_emails;
+my $match_names;
+my $order_by = 'count';
+Getopt::Long::Configure(qw(bundling));
+GetOptions(
+       'emails|e!' => \$match_emails,
+       'names|n!'  => \$match_names,
+       'count|c'   => sub { $order_by = 'count' },
+       'time|t'    => sub { $order_by = 'stamp' },
+) or exit 1;
+$match_emails = 1 unless $match_names;
+
+my $email = {};
+my $name = {};
+
+open(my $fh, '-|', "git log --format='%at <%aE> %aN'");
+while(<$fh>) {
+       my ($t, $e, $n) = /(\S+) <(\S+)> (.*)/;
+       mark($email, $e, $n, $t);
+       mark($name, $n, $e, $t);
 }
-close I;
-
-my %mail2author = ();
-open I, "git log --pretty='format:%ae  %an' |";
-while (<I>) {
-       chomp;
-       my ($mail, $author) = split(/\t/, $_);
-       next if exists $mailmap{$mail};
-       $mail2author{$mail} ||= {};
-       $mail2author{$mail}{$author} ||= 0;
-       $mail2author{$mail}{$author}++;
+close($fh);
+
+if ($match_emails) {
+       foreach my $e (dups($email)) {
+               foreach my $n (vals($email->{$e})) {
+                       show($n, $e, $email->{$e}->{$n});
+               }
+               print "\n";
+       }
 }
-close I;
-
-while (my ($mail, $authorcount) = each %mail2author) {
-       # %$authorcount is ($author => $count);
-       # sort and show the names from the most frequent ones.
-       my @names = (map { $_->[0] }
-               sort { $b->[1] <=> $a->[1] }
-               map { [$_, $authorcount->{$_}] }
-               keys %$authorcount);
-       if (1 < @names) {
-               for (@names) {
-                       print "$_ <$mail>\n";
+if ($match_names) {
+       foreach my $n (dups($name)) {
+               foreach my $e (vals($name->{$n})) {
+                       show($n, $e, $name->{$n}->{$e});
                }
+               print "\n";
        }
 }
+exit 0;
 
+sub mark {
+       my ($h, $k, $v, $t) = @_;
+       my $e = $h->{$k}->{$v} ||= { count => 0, stamp => 0 };
+       $e->{count}++;
+       $e->{stamp} = $t unless $t < $e->{stamp};
+}
+
+sub dups {
+       my $h = shift;
+       return grep { keys($h->{$_}) > 1 } keys($h);
+}
+
+sub vals {
+       my $h = shift;
+       return sort {
+               $h->{$b}->{$order_by} <=> $h->{$a}->{$order_by}
+       } keys($h);
+}
+
+sub show {
+       my ($n, $e, $h) = @_;
+       print "$n <$e> ($h->{$order_by})\n";
+}
index 7e77c9d0229e949c034c8c46811e19d2325e9cca..91360a3d7f0ad2d589dfe0365d4456d56853e7c0 100644 (file)
@@ -1,4 +1,5 @@
 *~
+git-subtree
 git-subtree.xml
 git-subtree.1
 mainline
index 0c44fda011bcfd39fd8c464c35017df620a91ff9..c5bce41ac7ccd88013f3de3c663f980d2277938c 100644 (file)
@@ -93,7 +93,7 @@ pull::
        repository.
        
 push::
-       Does a 'split' (see above) using the <prefix> supplied
+       Does a 'split' (see below) using the <prefix> supplied
        and then does a 'git push' to push the result to the 
        repository and refspec. This can be used to push your
        subtree to different branches of the remote repository.
index 1cfac4a6f84051d625ee2e1800ffd074b215eb86..17cf6f961f5fdf1e8f790acf7f498dc863e11e45 100755 (executable)
@@ -7,6 +7,10 @@ to the highest revision that should be available.
 """
 import sys, os
 
+if sys.hexversion < 0x02040000:
+        # The limiter is the ValueError() calls. This may be too conservative
+        sys.stderr.write("svnrdump-sim.py: requires Python 2.4 or later.\n")
+        sys.exit(1)
 
 def getrevlimit():
         var = 'SVNRMAX'
index fca1e17251f1f414a1d97bf6e6240bdf20daa648..8f16d069721c5b9885b2e700981618878b54191e 100644 (file)
@@ -17,16 +17,6 @@ To install:
 
   1. Copy these files to vim's syntax directory $HOME/.vim/syntax
   2. To auto-detect the editing of various git-related filetypes:
-       $ cat >>$HOME/.vim/filetype.vim <<'EOF'
-       autocmd BufNewFile,BufRead *.git/COMMIT_EDITMSG    setf gitcommit
-       autocmd BufNewFile,BufRead *.git/config,.gitconfig setf gitconfig
-       autocmd BufNewFile,BufRead git-rebase-todo         setf gitrebase
-       autocmd BufNewFile,BufRead .msg.[0-9]*
-               \ if getline(1) =~ '^From.*# This line is ignored.$' |
-               \   setf gitsendemail |
-               \ endif
-       autocmd BufNewFile,BufRead *.git/**
-               \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' |
-               \   setf git |
-               \ endif
-       EOF
+
+       $ curl http://ftp.vim.org/pub/vim/runtime/filetype.vim |
+               sed -ne '/^" Git$/, /^$/ p' >>$HOME/.vim/filetype.vim
diff --git a/ctype.c b/ctype.c
index 935327164b1066ad011d11fdcd3fd1dc1a936c58..0bfebb4e75866ba0e97713fab5394490290831c0 100644 (file)
--- a/ctype.c
+++ b/ctype.c
@@ -11,18 +11,21 @@ enum {
        D = GIT_DIGIT,
        G = GIT_GLOB_SPECIAL,   /* *, ?, [, \\ */
        R = GIT_REGEX_SPECIAL,  /* $, (, ), +, ., ^, {, | */
-       P = GIT_PATHSPEC_MAGIC  /* other non-alnum, except for ] and } */
+       P = GIT_PATHSPEC_MAGIC, /* other non-alnum, except for ] and } */
+       X = GIT_CNTRL,
+       U = GIT_PUNCT,
+       Z = GIT_CNTRL | GIT_SPACE
 };
 
-unsigned char sane_ctype[256] = {
-       0, 0, 0, 0, 0, 0, 0, 0, 0, S, S, 0, 0, S, 0, 0,         /*   0.. 15 */
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,         /*  16.. 31 */
+const unsigned char sane_ctype[256] = {
+       X, X, X, X, X, X, X, X, X, Z, Z, X, X, Z, X, X,         /*   0.. 15 */
+       X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X,         /*  16.. 31 */
        S, P, P, P, R, P, P, P, R, R, G, R, P, P, R, P,         /*  32.. 47 */
        D, D, D, D, D, D, D, D, D, D, P, P, P, P, P, G,         /*  48.. 63 */
        P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,         /*  64.. 79 */
-       A, A, A, A, A, A, A, A, A, A, A, G, G, 0, R, P,         /*  80.. 95 */
+       A, A, A, A, A, A, A, A, A, A, A, G, G, U, R, P,         /*  80.. 95 */
        P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,         /*  96..111 */
-       A, A, A, A, A, A, A, A, A, A, A, R, R, 0, P, 0,         /* 112..127 */
+       A, A, A, A, A, A, A, A, A, A, A, R, R, U, P, X,         /* 112..127 */
        /* Nothing in the 128.. range */
 };
 
diff --git a/diff.c b/diff.c
index 732d4c227595873bb94224da618ce5612a7415af..348f71b46256657860a2f7f79598e1d9b19d6c54 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -3626,6 +3626,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
                DIFF_OPT_SET(options, FIND_COPIES_HARDER);
        else if (!strcmp(arg, "--follow"))
                DIFF_OPT_SET(options, FOLLOW_RENAMES);
+       else if (!strcmp(arg, "--no-follow"))
+               DIFF_OPT_CLR(options, FOLLOW_RENAMES);
        else if (!strcmp(arg, "--color"))
                options->use_color = 1;
        else if (!prefixcmp(arg, "--color=")) {
diff --git a/dir.c b/dir.c
index 5a83aa7897f270279c403778f43aea6db1efc5af..9dde68a2f3a1a325d2c5b90fa4d20dbf7670652c 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -2,12 +2,15 @@
  * This handles recursive filename detection with exclude
  * files, index knowledge etc..
  *
+ * See Documentation/technical/api-directory-listing.txt
+ *
  * Copyright (C) Linus Torvalds, 2005-2006
  *              Junio Hamano, 2005-2006
  */
 #include "cache.h"
 #include "dir.h"
 #include "refs.h"
+#include "wildmatch.h"
 
 struct path_simplify {
        int len;
@@ -34,10 +37,33 @@ int fnmatch_icase(const char *pattern, const char *string, int flags)
        return fnmatch(pattern, string, flags | (ignore_case ? FNM_CASEFOLD : 0));
 }
 
+inline int git_fnmatch(const char *pattern, const char *string,
+                      int flags, int prefix)
+{
+       int fnm_flags = 0;
+       if (flags & GFNM_PATHNAME)
+               fnm_flags |= FNM_PATHNAME;
+       if (prefix > 0) {
+               if (strncmp(pattern, string, prefix))
+                       return FNM_NOMATCH;
+               pattern += prefix;
+               string += prefix;
+       }
+       if (flags & GFNM_ONESTAR) {
+               int pattern_len = strlen(++pattern);
+               int string_len = strlen(string);
+               return string_len < pattern_len ||
+                      strcmp(pattern,
+                             string + string_len - pattern_len);
+       }
+       return fnmatch(pattern, string, fnm_flags);
+}
+
 static size_t common_prefix_len(const char **pathspec)
 {
        const char *n, *first;
        size_t max = 0;
+       int literal = limit_pathspec_to_literal();
 
        if (!pathspec)
                return max;
@@ -47,7 +73,7 @@ static size_t common_prefix_len(const char **pathspec)
                size_t i, len = 0;
                for (i = 0; first == n || i < max; i++) {
                        char c = n[i];
-                       if (!c || c != first[i] || is_glob_special(c))
+                       if (!c || c != first[i] || (!literal && is_glob_special(c)))
                                break;
                        if (c == '/')
                                len = i + 1;
@@ -117,6 +143,7 @@ int within_depth(const char *name, int namelen,
 static int match_one(const char *match, const char *name, int namelen)
 {
        int matchlen;
+       int literal = limit_pathspec_to_literal();
 
        /* If the match was just the prefix, we matched */
        if (!*match)
@@ -126,7 +153,7 @@ static int match_one(const char *match, const char *name, int namelen)
                for (;;) {
                        unsigned char c1 = tolower(*match);
                        unsigned char c2 = tolower(*name);
-                       if (c1 == '\0' || is_glob_special(c1))
+                       if (c1 == '\0' || (!literal && is_glob_special(c1)))
                                break;
                        if (c1 != c2)
                                return 0;
@@ -138,7 +165,7 @@ static int match_one(const char *match, const char *name, int namelen)
                for (;;) {
                        unsigned char c1 = *match;
                        unsigned char c2 = *name;
-                       if (c1 == '\0' || is_glob_special(c1))
+                       if (c1 == '\0' || (!literal && is_glob_special(c1)))
                                break;
                        if (c1 != c2)
                                return 0;
@@ -148,14 +175,16 @@ static int match_one(const char *match, const char *name, int namelen)
                }
        }
 
-
        /*
         * If we don't match the matchstring exactly,
         * we need to match by fnmatch
         */
        matchlen = strlen(match);
-       if (strncmp_icase(match, name, matchlen))
+       if (strncmp_icase(match, name, matchlen)) {
+               if (literal)
+                       return 0;
                return !fnmatch_icase(match, name, 0) ? MATCHED_FNMATCH : 0;
+       }
 
        if (namelen == matchlen)
                return MATCHED_EXACTLY;
@@ -230,7 +259,10 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
                        return MATCHED_RECURSIVELY;
        }
 
-       if (item->use_wildcard && !fnmatch(match, name, 0))
+       if (item->nowildcard_len < item->len &&
+           !git_fnmatch(match, name,
+                        item->flags & PATHSPEC_ONESTAR ? GFNM_ONESTAR : 0,
+                        item->nowildcard_len - prefix))
                return MATCHED_FNMATCH;
 
        return 0;
@@ -347,7 +379,7 @@ void parse_exclude_pattern(const char **pattern,
 }
 
 void add_exclude(const char *string, const char *base,
-                int baselen, struct exclude_list *which)
+                int baselen, struct exclude_list *el)
 {
        struct exclude *x;
        int patternlen;
@@ -371,8 +403,8 @@ void add_exclude(const char *string, const char *base,
        x->base = base;
        x->baselen = baselen;
        x->flags = flags;
-       ALLOC_GROW(which->excludes, which->nr + 1, which->alloc);
-       which->excludes[which->nr++] = x;
+       ALLOC_GROW(el->excludes, el->nr + 1, el->alloc);
+       el->excludes[el->nr++] = x;
 }
 
 static void *read_skip_worktree_file_from_index(const char *path, size_t *size)
@@ -398,7 +430,11 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size)
        return data;
 }
 
-void free_excludes(struct exclude_list *el)
+/*
+ * Frees memory within el which was allocated for exclude patterns and
+ * the file buffer.  Does not free el itself.
+ */
+void clear_exclude_list(struct exclude_list *el)
 {
        int i;
 
@@ -414,7 +450,7 @@ int add_excludes_from_file_to_list(const char *fname,
                                   const char *base,
                                   int baselen,
                                   char **buf_p,
-                                  struct exclude_list *which,
+                                  struct exclude_list *el,
                                   int check_index)
 {
        struct stat st;
@@ -463,7 +499,7 @@ int add_excludes_from_file_to_list(const char *fname,
                if (buf[i] == '\n') {
                        if (entry != buf + i && entry[0] != '#') {
                                buf[i - (i && buf[i-1] == '\r')] = 0;
-                               add_exclude(entry, base, baselen, which);
+                               add_exclude(entry, base, baselen, el);
                        }
                        entry = buf + i + 1;
                }
@@ -478,6 +514,10 @@ void add_excludes_from_file(struct dir_struct *dir, const char *fname)
                die("cannot use %s as an exclude file", fname);
 }
 
+/*
+ * Loads the per-directory exclude list for the substring of base
+ * which has a char length of baselen.
+ */
 static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
 {
        struct exclude_list *el;
@@ -488,7 +528,7 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
            (baselen + strlen(dir->exclude_per_dir) >= PATH_MAX))
                return; /* too long a path -- ignore */
 
-       /* Pop the ones that are not the prefix of the path being checked. */
+       /* Pop the directories that are not the prefix of the path being checked. */
        el = &dir->exclude_list[EXC_DIRS];
        while ((stk = dir->exclude_stack) != NULL) {
                if (stk->baselen <= baselen &&
@@ -595,25 +635,30 @@ int match_pathname(const char *pathname, int pathlen,
                namelen -= prefix;
        }
 
-       return fnmatch_icase(pattern, name, FNM_PATHNAME) == 0;
+       return wildmatch(pattern, name,
+                        ignore_case ? FNM_CASEFOLD : 0) == 0;
 }
 
-/* Scan the list and let the last match determine the fate.
- * Return 1 for exclude, 0 for include and -1 for undecided.
+/*
+ * Scan the given exclude list in reverse to see whether pathname
+ * should be ignored.  The first match (i.e. the last on the list), if
+ * any, determines the fate.  Returns the exclude_list element which
+ * matched, or NULL for undecided.
  */
-int excluded_from_list(const char *pathname,
-                      int pathlen, const char *basename, int *dtype,
-                      struct exclude_list *el)
+static struct exclude *last_exclude_matching_from_list(const char *pathname,
+                                                      int pathlen,
+                                                      const char *basename,
+                                                      int *dtype,
+                                                      struct exclude_list *el)
 {
        int i;
 
        if (!el->nr)
-               return -1;      /* undefined */
+               return NULL;    /* undefined */
 
        for (i = el->nr - 1; 0 <= i; i--) {
                struct exclude *x = el->excludes[i];
                const char *exclude = x->pattern;
-               int to_exclude = x->flags & EXC_FLAG_NEGATIVE ? 0 : 1;
                int prefix = x->nowildcardlen;
 
                if (x->flags & EXC_FLAG_MUSTBEDIR) {
@@ -628,7 +673,7 @@ int excluded_from_list(const char *pathname,
                                           pathlen - (basename - pathname),
                                           exclude, prefix, x->patternlen,
                                           x->flags))
-                               return to_exclude;
+                               return x;
                        continue;
                }
 
@@ -636,28 +681,64 @@ int excluded_from_list(const char *pathname,
                if (match_pathname(pathname, pathlen,
                                   x->base, x->baselen ? x->baselen - 1 : 0,
                                   exclude, prefix, x->patternlen, x->flags))
-                       return to_exclude;
+                       return x;
        }
+       return NULL; /* undecided */
+}
+
+/*
+ * Scan the list and let the last match determine the fate.
+ * Return 1 for exclude, 0 for include and -1 for undecided.
+ */
+int is_excluded_from_list(const char *pathname,
+                         int pathlen, const char *basename, int *dtype,
+                         struct exclude_list *el)
+{
+       struct exclude *exclude;
+       exclude = last_exclude_matching_from_list(pathname, pathlen, basename, dtype, el);
+       if (exclude)
+               return exclude->flags & EXC_FLAG_NEGATIVE ? 0 : 1;
        return -1; /* undecided */
 }
 
-static int excluded(struct dir_struct *dir, const char *pathname, int *dtype_p)
+/*
+ * Loads the exclude lists for the directory containing pathname, then
+ * scans all exclude lists to determine whether pathname is excluded.
+ * Returns the exclude_list element which matched, or NULL for
+ * undecided.
+ */
+static struct exclude *last_exclude_matching(struct dir_struct *dir,
+                                            const char *pathname,
+                                            int *dtype_p)
 {
        int pathlen = strlen(pathname);
        int st;
+       struct exclude *exclude;
        const char *basename = strrchr(pathname, '/');
        basename = (basename) ? basename+1 : pathname;
 
        prep_exclude(dir, pathname, basename-pathname);
        for (st = EXC_CMDL; st <= EXC_FILE; st++) {
-               switch (excluded_from_list(pathname, pathlen, basename,
-                                          dtype_p, &dir->exclude_list[st])) {
-               case 0:
-                       return 0;
-               case 1:
-                       return 1;
-               }
+               exclude = last_exclude_matching_from_list(
+                       pathname, pathlen, basename, dtype_p,
+                       &dir->exclude_list[st]);
+               if (exclude)
+                       return exclude;
        }
+       return NULL;
+}
+
+/*
+ * Loads the exclude lists for the directory containing pathname, then
+ * scans all exclude lists to determine whether pathname is excluded.
+ * Returns 1 if true, otherwise 0.
+ */
+static int is_excluded(struct dir_struct *dir, const char *pathname, int *dtype_p)
+{
+       struct exclude *exclude =
+               last_exclude_matching(dir, pathname, dtype_p);
+       if (exclude)
+               return exclude->flags & EXC_FLAG_NEGATIVE ? 0 : 1;
        return 0;
 }
 
@@ -665,6 +746,7 @@ void path_exclude_check_init(struct path_exclude_check *check,
                             struct dir_struct *dir)
 {
        check->dir = dir;
+       check->exclude = NULL;
        strbuf_init(&check->path, 256);
 }
 
@@ -674,32 +756,41 @@ void path_exclude_check_clear(struct path_exclude_check *check)
 }
 
 /*
- * Is this name excluded?  This is for a caller like show_files() that
- * do not honor directory hierarchy and iterate through paths that are
- * possibly in an ignored directory.
+ * For each subdirectory in name, starting with the top-most, checks
+ * to see if that subdirectory is excluded, and if so, returns the
+ * corresponding exclude structure.  Otherwise, checks whether name
+ * itself (which is presumably a file) is excluded.
  *
  * A path to a directory known to be excluded is left in check->path to
  * optimize for repeated checks for files in the same excluded directory.
  */
-int path_excluded(struct path_exclude_check *check,
-                 const char *name, int namelen, int *dtype)
+struct exclude *last_exclude_matching_path(struct path_exclude_check *check,
+                                          const char *name, int namelen,
+                                          int *dtype)
 {
        int i;
        struct strbuf *path = &check->path;
+       struct exclude *exclude;
 
        /*
         * we allow the caller to pass namelen as an optimization; it
         * must match the length of the name, as we eventually call
-        * excluded() on the whole name string.
+        * is_excluded() on the whole name string.
         */
        if (namelen < 0)
                namelen = strlen(name);
 
+       /*
+        * If path is non-empty, and name is equal to path or a
+        * subdirectory of path, name should be excluded, because
+        * it's inside a directory which is already known to be
+        * excluded and was previously left in check->path.
+        */
        if (path->len &&
            path->len <= namelen &&
            !memcmp(name, path->buf, path->len) &&
            (!name[path->len] || name[path->len] == '/'))
-               return 1;
+               return check->exclude;
 
        strbuf_setlen(path, 0);
        for (i = 0; name[i]; i++) {
@@ -707,8 +798,12 @@ int path_excluded(struct path_exclude_check *check,
 
                if (ch == '/') {
                        int dt = DT_DIR;
-                       if (excluded(check->dir, path->buf, &dt))
-                               return 1;
+                       exclude = last_exclude_matching(check->dir,
+                                                       path->buf, &dt);
+                       if (exclude) {
+                               check->exclude = exclude;
+                               return exclude;
+                       }
                }
                strbuf_addch(path, ch);
        }
@@ -716,7 +811,22 @@ int path_excluded(struct path_exclude_check *check,
        /* An entry in the index; cannot be a directory with subentries */
        strbuf_setlen(path, 0);
 
-       return excluded(check->dir, name, dtype);
+       return last_exclude_matching(check->dir, name, dtype);
+}
+
+/*
+ * Is this name excluded?  This is for a caller like show_files() that
+ * do not honor directory hierarchy and iterate through paths that are
+ * possibly in an ignored directory.
+ */
+int is_path_excluded(struct path_exclude_check *check,
+                 const char *name, int namelen, int *dtype)
+{
+       struct exclude *exclude =
+               last_exclude_matching_path(check, name, namelen, dtype);
+       if (exclude)
+               return exclude->flags & EXC_FLAG_NEGATIVE ? 0 : 1;
+       return 0;
 }
 
 static struct dir_entry *dir_entry_new(const char *pathname, int len)
@@ -732,7 +842,8 @@ static struct dir_entry *dir_entry_new(const char *pathname, int len)
 
 static struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len)
 {
-       if (cache_name_exists(pathname, len, ignore_case))
+       if (!(dir->flags & DIR_SHOW_IGNORED) &&
+           cache_name_exists(pathname, len, ignore_case))
                return NULL;
 
        ALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);
@@ -834,8 +945,9 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
  * traversal routine.
  *
  * Case 1: If we *already* have entries in the index under that
- * directory name, we always recurse into the directory to see
- * all the files.
+ * directory name, we recurse into the directory to see all the files,
+ * unless the directory is excluded and we want to show ignored
+ * directories
  *
  * Case 2: If we *already* have that directory name as a gitlink,
  * we always continue to see it as a gitlink, regardless of whether
@@ -849,6 +961,9 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
  *      just a directory, unless "hide_empty_directories" is
  *      also true and the directory is empty, in which case
  *      we just ignore it entirely.
+ *      if we are looking for ignored directories, look if it
+ *      contains only ignored files to decide if it must be shown as
+ *      ignored or not.
  *  (b) if it looks like a git directory, and we don't have
  *      'no_gitlinks' set we treat it as a gitlink, and show it
  *      as a directory.
@@ -861,12 +976,15 @@ enum directory_treatment {
 };
 
 static enum directory_treatment treat_directory(struct dir_struct *dir,
-       const char *dirname, int len,
+       const char *dirname, int len, int exclude,
        const struct path_simplify *simplify)
 {
        /* The "len-1" is to strip the final '/' */
        switch (directory_exists_in_index(dirname, len-1)) {
        case index_directory:
+               if ((dir->flags & DIR_SHOW_OTHER_DIRECTORIES) && exclude)
+                       break;
+
                return recurse_into_directory;
 
        case index_gitdir:
@@ -886,13 +1004,68 @@ static enum directory_treatment treat_directory(struct dir_struct *dir,
        }
 
        /* This is the "show_other_directories" case */
-       if (!(dir->flags & DIR_HIDE_EMPTY_DIRECTORIES))
+
+       /*
+        * We are looking for ignored files and our directory is not ignored,
+        * check if it contains only ignored files
+        */
+       if ((dir->flags & DIR_SHOW_IGNORED) && !exclude) {
+               int ignored;
+               dir->flags &= ~DIR_SHOW_IGNORED;
+               dir->flags |= DIR_HIDE_EMPTY_DIRECTORIES;
+               ignored = read_directory_recursive(dir, dirname, len, 1, simplify);
+               dir->flags &= ~DIR_HIDE_EMPTY_DIRECTORIES;
+               dir->flags |= DIR_SHOW_IGNORED;
+
+               return ignored ? ignore_directory : show_directory;
+       }
+       if (!(dir->flags & DIR_SHOW_IGNORED) &&
+           !(dir->flags & DIR_HIDE_EMPTY_DIRECTORIES))
                return show_directory;
        if (!read_directory_recursive(dir, dirname, len, 1, simplify))
                return ignore_directory;
        return show_directory;
 }
 
+/*
+ * Decide what to do when we find a file while traversing the
+ * filesystem. Mostly two cases:
+ *
+ *  1. We are looking for ignored files
+ *   (a) File is ignored, include it
+ *   (b) File is in ignored path, include it
+ *   (c) File is not ignored, exclude it
+ *
+ *  2. Other scenarios, include the file if not excluded
+ *
+ * Return 1 for exclude, 0 for include.
+ */
+static int treat_file(struct dir_struct *dir, struct strbuf *path, int exclude, int *dtype)
+{
+       struct path_exclude_check check;
+       int exclude_file = 0;
+
+       if (exclude)
+               exclude_file = !(dir->flags & DIR_SHOW_IGNORED);
+       else if (dir->flags & DIR_SHOW_IGNORED) {
+               /* Always exclude indexed files */
+               struct cache_entry *ce = index_name_exists(&the_index,
+                   path->buf, path->len, ignore_case);
+
+               if (ce)
+                       return 1;
+
+               path_exclude_check_init(&check, dir);
+
+               if (!is_path_excluded(&check, path->buf, path->len, dtype))
+                       exclude_file = 1;
+
+               path_exclude_check_clear(&check);
+       }
+
+       return exclude_file;
+}
+
 /*
  * This is an inexact early pruning of any recursive directory
  * reading - if the path cannot possibly be in the pathspec,
@@ -1016,7 +1189,7 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
                                          const struct path_simplify *simplify,
                                          int dtype, struct dirent *de)
 {
-       int exclude = excluded(dir, path->buf, &dtype);
+       int exclude = is_excluded(dir, path->buf, &dtype);
        if (exclude && (dir->flags & DIR_COLLECT_IGNORED)
            && exclude_matches_pathspec(path->buf, path->len, simplify))
                dir_add_ignored(dir, path->buf, path->len);
@@ -1031,27 +1204,14 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
        if (dtype == DT_UNKNOWN)
                dtype = get_dtype(de, path->buf, path->len);
 
-       /*
-        * Do we want to see just the ignored files?
-        * We still need to recurse into directories,
-        * even if we don't ignore them, since the
-        * directory may contain files that we do..
-        */
-       if (!exclude && (dir->flags & DIR_SHOW_IGNORED)) {
-               if (dtype != DT_DIR)
-                       return path_ignored;
-       }
-
        switch (dtype) {
        default:
                return path_ignored;
        case DT_DIR:
                strbuf_addch(path, '/');
-               switch (treat_directory(dir, path->buf, path->len, simplify)) {
+
+               switch (treat_directory(dir, path->buf, path->len, exclude, simplify)) {
                case show_directory:
-                       if (exclude != !!(dir->flags
-                                         & DIR_SHOW_IGNORED))
-                               return path_ignored;
                        break;
                case recurse_into_directory:
                        return path_recurse;
@@ -1061,7 +1221,12 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
                break;
        case DT_REG:
        case DT_LNK:
-               break;
+               switch (treat_file(dir, path, exclude, &dtype)) {
+               case 1:
+                       return path_ignored;
+               default:
+                       break;
+               }
        }
        return path_handled;
 }
@@ -1429,9 +1594,18 @@ int init_pathspec(struct pathspec *pathspec, const char **paths)
 
                item->match = path;
                item->len = strlen(path);
-               item->use_wildcard = !no_wildcard(path);
-               if (item->use_wildcard)
-                       pathspec->has_wildcard = 1;
+               item->flags = 0;
+               if (limit_pathspec_to_literal()) {
+                       item->nowildcard_len = item->len;
+               } else {
+                       item->nowildcard_len = simple_length(path);
+                       if (item->nowildcard_len < item->len) {
+                               pathspec->has_wildcard = 1;
+                               if (path[item->nowildcard_len] == '*' &&
+                                   no_wildcard(path + item->nowildcard_len + 1))
+                                       item->flags |= PATHSPEC_ONESTAR;
+                       }
+               }
        }
 
        qsort(pathspec->items, pathspec->nr,
@@ -1445,3 +1619,11 @@ void free_pathspec(struct pathspec *pathspec)
        free(pathspec->items);
        pathspec->items = NULL;
 }
+
+int limit_pathspec_to_literal(void)
+{
+       static int flag = -1;
+       if (flag < 0)
+               flag = git_env_bool(GIT_LITERAL_PATHSPECS_ENVIRONMENT, 0);
+       return flag;
+}
diff --git a/dir.h b/dir.h
index f5c89e3b80143f2508ac5b69d432aa82a4254751..ae1bc467ae909e6db151b055e212ded45fac34f6 100644 (file)
--- a/dir.h
+++ b/dir.h
@@ -1,6 +1,8 @@
 #ifndef DIR_H
 #define DIR_H
 
+/* See Documentation/technical/api-directory-listing.txt */
+
 #include "strbuf.h"
 
 struct dir_entry {
@@ -13,6 +15,12 @@ struct dir_entry {
 #define EXC_FLAG_MUSTBEDIR 8
 #define EXC_FLAG_NEGATIVE 16
 
+/*
+ * Each .gitignore file will be parsed into patterns which are then
+ * appended to the relevant exclude_list (either EXC_DIRS or
+ * EXC_FILE).  exclude_lists are also used to represent the list of
+ * --exclude values passed via CLI args (EXC_CMDL).
+ */
 struct exclude_list {
        int nr;
        int alloc;
@@ -26,9 +34,15 @@ struct exclude_list {
        } **excludes;
 };
 
+/*
+ * The contents of the per-directory exclude files are lazily read on
+ * demand and then cached in memory, one per exclude_stack struct, in
+ * order to avoid opening and parsing each one every time that
+ * directory is traversed.
+ */
 struct exclude_stack {
-       struct exclude_stack *prev;
-       char *filebuf;
+       struct exclude_stack *prev; /* the struct exclude_stack for the parent directory */
+       char *filebuf; /* remember pointer to per-directory exclude file contents so we can free() */
        int baselen;
        int exclude_ix;
 };
@@ -59,6 +73,14 @@ struct dir_struct {
 #define EXC_DIRS 1
 #define EXC_FILE 2
 
+       /*
+        * Temporary variables which are used during loading of the
+        * per-directory exclude lists.
+        *
+        * exclude_stack points to the top of the exclude_stack, and
+        * basebuf contains the full path to the current
+        * (sub)directory in the traversal.
+        */
        struct exclude_stack *exclude_stack;
        char basebuf[PATH_MAX];
 };
@@ -76,8 +98,8 @@ extern int within_depth(const char *name, int namelen, int depth, int max_depth)
 extern int fill_directory(struct dir_struct *dir, const char **pathspec);
 extern int read_directory(struct dir_struct *, const char *path, int len, const char **pathspec);
 
-extern int excluded_from_list(const char *pathname, int pathlen, const char *basename,
-                             int *dtype, struct exclude_list *el);
+extern int is_excluded_from_list(const char *pathname, int pathlen, const char *basename,
+                                int *dtype, struct exclude_list *el);
 struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len);
 
 /*
@@ -91,26 +113,29 @@ extern int match_pathname(const char *, int,
                          const char *, int, int, int);
 
 /*
- * The excluded() API is meant for callers that check each level of leading
- * directory hierarchies with excluded() to avoid recursing into excluded
+ * The is_excluded() API is meant for callers that check each level of leading
+ * directory hierarchies with is_excluded() to avoid recursing into excluded
  * directories.  Callers that do not do so should use this API instead.
  */
 struct path_exclude_check {
        struct dir_struct *dir;
+       struct exclude *exclude;
        struct strbuf path;
 };
 extern void path_exclude_check_init(struct path_exclude_check *, struct dir_struct *);
 extern void path_exclude_check_clear(struct path_exclude_check *);
-extern int path_excluded(struct path_exclude_check *, const char *, int namelen, int *dtype);
+extern struct exclude *last_exclude_matching_path(struct path_exclude_check *, const char *,
+                                                 int namelen, int *dtype);
+extern int is_path_excluded(struct path_exclude_check *, const char *, int namelen, int *dtype);
 
 
 extern int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen,
-                                         char **buf_p, struct exclude_list *which, int check_index);
+                                         char **buf_p, struct exclude_list *el, int check_index);
 extern void add_excludes_from_file(struct dir_struct *, const char *fname);
 extern void parse_exclude_pattern(const char **string, int *patternlen, int *flags, int *nowildcardlen);
 extern void add_exclude(const char *string, const char *base,
-                       int baselen, struct exclude_list *which);
-extern void free_excludes(struct exclude_list *el);
+                       int baselen, struct exclude_list *el);
+extern void clear_exclude_list(struct exclude_list *el);
 extern int file_exists(const char *);
 
 extern int is_inside_dir(const char *dir);
@@ -139,4 +164,13 @@ extern int strcmp_icase(const char *a, const char *b);
 extern int strncmp_icase(const char *a, const char *b, size_t count);
 extern int fnmatch_icase(const char *pattern, const char *string, int flags);
 
+/*
+ * The prefix part of pattern must not contains wildcards.
+ */
+#define GFNM_PATHNAME 1                /* similar to FNM_PATHNAME */
+#define GFNM_ONESTAR  2                /* there is only _one_ wildcard, a star */
+
+extern int git_fnmatch(const char *pattern, const char *string,
+                      int flags, int prefix);
+
 #endif
index d8340031d24828483697c10257806efedfe041f5..27bdecdaf3d99d3179737e07be971d2458408660 100644 (file)
--- a/editor.c
+++ b/editor.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "strbuf.h"
 #include "run-command.h"
+#include "sigchain.h"
 
 #ifndef DEFAULT_EDITOR
 #define DEFAULT_EDITOR "vi"
@@ -37,8 +38,25 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
 
        if (strcmp(editor, ":")) {
                const char *args[] = { editor, path, NULL };
+               struct child_process p;
+               int ret, sig;
 
-               if (run_command_v_opt_cd_env(args, RUN_USING_SHELL, NULL, env))
+               memset(&p, 0, sizeof(p));
+               p.argv = args;
+               p.env = env;
+               p.use_shell = 1;
+               if (start_command(&p) < 0)
+                       return error("unable to start editor '%s'", editor);
+
+               sigchain_push(SIGINT, SIG_IGN);
+               sigchain_push(SIGQUIT, SIG_IGN);
+               ret = finish_command(&p);
+               sig = ret - 128;
+               sigchain_pop(SIGINT);
+               sigchain_pop(SIGQUIT);
+               if (sig == SIGINT || sig == SIGQUIT)
+                       raise(sig);
+               if (ret)
                        return error("There was a problem with the editor '%s'.",
                                        editor);
        }
index 099ff4ddffecee85d964bfa9f03795ed168edf5f..f0acdf7331eeaf7a55ad09309a788c5971fe9b7f 100644 (file)
@@ -874,8 +874,6 @@ static int fetch_pack_config(const char *var, const char *value, void *cb)
        return git_default_config(var, value, cb);
 }
 
-static struct lock_file lock;
-
 static void fetch_pack_setup(void)
 {
        static int did_setup;
@@ -917,6 +915,7 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
        ref_cpy = do_fetch_pack(args, fd, ref, sought, pack_lockfile);
 
        if (args->depth > 0) {
+               static struct lock_file lock;
                struct cache_time mtime;
                struct strbuf sb = STRBUF_INIT;
                char *shallow = git_path("shallow");
diff --git a/fsck.c b/fsck.c
index 7395ef6a425f5c7725767f34a0383f61907fce93..99c049767484288f273f036b57683df04c1ef0df 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -142,6 +142,9 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
        int has_null_sha1 = 0;
        int has_full_path = 0;
        int has_empty_name = 0;
+       int has_dot = 0;
+       int has_dotdot = 0;
+       int has_dotgit = 0;
        int has_zero_pad = 0;
        int has_bad_modes = 0;
        int has_dup_entries = 0;
@@ -168,6 +171,12 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
                        has_full_path = 1;
                if (!*name)
                        has_empty_name = 1;
+               if (!strcmp(name, "."))
+                       has_dot = 1;
+               if (!strcmp(name, ".."))
+                       has_dotdot = 1;
+               if (!strcmp(name, ".git"))
+                       has_dotgit = 1;
                has_zero_pad |= *(char *)desc.buffer == '0';
                update_tree_entry(&desc);
 
@@ -217,6 +226,12 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
                retval += error_func(&item->object, FSCK_WARN, "contains full pathnames");
        if (has_empty_name)
                retval += error_func(&item->object, FSCK_WARN, "contains empty pathname");
+       if (has_dot)
+               retval += error_func(&item->object, FSCK_WARN, "contains '.'");
+       if (has_dotdot)
+               retval += error_func(&item->object, FSCK_WARN, "contains '..'");
+       if (has_dotgit)
+               retval += error_func(&item->object, FSCK_WARN, "contains '.git'");
        if (has_zero_pad)
                retval += error_func(&item->object, FSCK_WARN, "contains zero-padded file modes");
        if (has_bad_modes)
index 77fd848511675c2330214c9f72c3c8b3b7238da6..dab545e02e17b834da63d911615bd2afa04a702c 100644 (file)
@@ -75,7 +75,7 @@
 # endif
 #elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && \
       !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) && \
-      !defined(__TANDEM)
+      !defined(__TANDEM) && !defined(__QNX__)
 #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
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
-#ifdef __TANDEM /* or HAVE_STRINGS_H or !NO_STRINGS_H? */
+#ifdef HAVE_STRINGS_H
 #include <strings.h> /* for strcasecmp() */
 #endif
 #include <errno.h>
 #include <limits.h>
+#ifdef NEEDS_SYS_PARAM_H
 #include <sys/param.h>
+#endif
 #include <sys/types.h>
 #include <dirent.h>
 #include <sys/time.h>
@@ -422,6 +424,10 @@ void *gitmemmem(const void *haystack, size_t haystacklen,
                 const void *needle, size_t needlelen);
 #endif
 
+#ifdef NO_GETPAGESIZE
+#define getpagesize() sysconf(_SC_PAGESIZE)
+#endif
+
 #ifdef FREAD_READS_DIRECTORIES
 #ifdef fopen
 #undef fopen
@@ -522,13 +528,19 @@ extern const char tolower_trans_tbl[256];
 #undef isupper
 #undef tolower
 #undef toupper
-extern unsigned char sane_ctype[256];
+#undef iscntrl
+#undef ispunct
+#undef isxdigit
+
+extern const unsigned char sane_ctype[256];
 #define GIT_SPACE 0x01
 #define GIT_DIGIT 0x02
 #define GIT_ALPHA 0x04
 #define GIT_GLOB_SPECIAL 0x08
 #define GIT_REGEX_SPECIAL 0x10
 #define GIT_PATHSPEC_MAGIC 0x20
+#define GIT_CNTRL 0x40
+#define GIT_PUNCT 0x80
 #define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)
 #define isascii(x) (((x) & ~0x7f) == 0)
 #define isspace(x) sane_istest(x,GIT_SPACE)
@@ -540,6 +552,10 @@ extern unsigned char sane_ctype[256];
 #define isupper(x) sane_iscase(x, 0)
 #define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL)
 #define is_regex_special(x) sane_istest(x,GIT_GLOB_SPECIAL | GIT_REGEX_SPECIAL)
+#define iscntrl(x) (sane_istest(x,GIT_CNTRL))
+#define ispunct(x) sane_istest(x, GIT_PUNCT | GIT_REGEX_SPECIAL | \
+               GIT_GLOB_SPECIAL | GIT_PATHSPEC_MAGIC)
+#define isxdigit(x) (hexval_table[x] != -1)
 #define tolower(x) sane_case((unsigned char)(x), 0x20)
 #define toupper(x) sane_case((unsigned char)(x), 0)
 #define is_pathspec_magic(x) sane_istest(x,GIT_PATHSPEC_MAGIC)
@@ -648,8 +664,12 @@ int rmdir_or_warn(const char *path);
  */
 int remove_or_warn(unsigned int mode, const char *path);
 
-/* Call access(2), but warn for any error besides ENOENT. */
+/*
+ * Call access(2), but warn for any error except "missing file"
+ * (ENOENT or ENOTDIR).
+ */
 int access_or_warn(const char *path, int mode);
+int access_or_die(const char *path, int mode);
 
 /* Warn on an inaccessible file that ought to be accessible */
 void warn_on_inaccessible(const char *path);
index c5ebfa06365da82d68103300ad6e8c818ab37fb6..36790749830251854fa475f2bd8d33ece07203f6 100755 (executable)
@@ -60,6 +60,7 @@ my $methods = {
     'Valid-responses' => \&req_Validresponses,
     'valid-requests'  => \&req_validrequests,
     'Directory'       => \&req_Directory,
+    'Sticky'          => \&req_Sticky,
     'Entry'           => \&req_Entry,
     'Modified'        => \&req_Modified,
     'Unchanged'       => \&req_Unchanged,
@@ -470,11 +471,19 @@ sub req_Directory
     {
         $log->info("Setting prepend to '$state->{path}'");
         $state->{prependdir} = $state->{path};
+        my %entries;
         foreach my $entry ( keys %{$state->{entries}} )
         {
-            $state->{entries}{$state->{prependdir} . $entry} = $state->{entries}{$entry};
-            delete $state->{entries}{$entry};
+            $entries{$state->{prependdir} . $entry} = $state->{entries}{$entry};
         }
+        $state->{entries}=\%entries;
+
+        my %dirMap;
+        foreach my $dir ( keys %{$state->{dirMap}} )
+        {
+            $dirMap{$state->{prependdir} . $dir} = $state->{dirMap}{$dir};
+        }
+        $state->{dirMap}=\%dirMap;
     }
 
     if ( defined ( $state->{prependdir} ) )
@@ -482,9 +491,60 @@ sub req_Directory
         $log->debug("Prepending '$state->{prependdir}' to state|directory");
         $state->{directory} = $state->{prependdir} . $state->{directory}
     }
+
+    if ( ! defined($state->{dirMap}{$state->{directory}}) )
+    {
+        $state->{dirMap}{$state->{directory}} =
+            {
+                'names' => {}
+                #'tagspec' => undef
+            };
+    }
+
     $log->debug("req_Directory : localdir=$data repository=$repository path=$state->{path} directory=$state->{directory} module=$state->{module}");
 }
 
+# Sticky tagspec \n
+#     Response expected: no. Tell the server that the directory most
+#     recently specified with Directory has a sticky tag or date
+#     tagspec. The first character of tagspec is T for a tag, D for
+#     a date, or some other character supplied by a Set-sticky
+#     response from a previous request to the server. The remainder
+#     of tagspec contains the actual tag or date, again as supplied
+#     by Set-sticky.
+#          The server should remember Static-directory and Sticky requests
+#     for a particular directory; the client need not resend them each
+#     time it sends a Directory request for a given directory. However,
+#     the server is not obliged to remember them beyond the context
+#     of a single command.
+sub req_Sticky
+{
+    my ( $cmd, $tagspec ) = @_;
+
+    my ( $stickyInfo );
+    if($tagspec eq "")
+    {
+        # nothing
+    }
+    elsif($tagspec=~/^T([^ ]+)\s*$/)
+    {
+        $stickyInfo = { 'tag' => $1 };
+    }
+    elsif($tagspec=~/^D([0-9.]+)\s*$/)
+    {
+        $stickyInfo= { 'date' => $1 };
+    }
+    else
+    {
+        die "Unknown tag_or_date format\n";
+    }
+    $state->{dirMap}{$state->{directory}}{stickyInfo}=$stickyInfo;
+
+    $log->debug("req_Sticky : tagspec=$tagspec repository=$state->{repository}"
+                . " path=$state->{path} directory=$state->{directory}"
+                . " module=$state->{module}");
+}
+
 # Entry entry-line \n
 #     Response expected: no. Tell the server what version of a file is on the
 #     local machine. The name in entry-line is a name relative to the directory
@@ -511,6 +571,8 @@ sub req_Entry
         tag_or_date => $data[5],
     };
 
+    $state->{dirMap}{$state->{directory}}{names}{$data[1]} = 'F';
+
     $log->info("Received entry line '$data' => '" . $state->{directory} . $data[1] . "'");
 }
 
@@ -549,7 +611,10 @@ sub req_add
     {
         $filename = filecleanup($filename);
 
-        my $meta = $updater->getmeta($filename);
+        # no -r, -A, or -D with add
+        my $stickyInfo = resolveStickyInfo($filename);
+
+        my $meta = $updater->getmeta($filename,$stickyInfo);
         my $wrev = revparse($filename);
 
         if ($wrev && $meta && ($wrev=~/^-/))
@@ -572,8 +637,10 @@ sub req_add
 
                 # this is an "entries" line
                 my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash});
-                $log->debug("/$filepart/$meta->{revision}//$kopts/");
-                print "/$filepart/$meta->{revision}//$kopts/\n";
+                my $entryLine = "/$filepart/$meta->{revision}//$kopts/";
+                $entryLine .= getStickyTagOrDate($stickyInfo);
+                $log->debug($entryLine);
+                print "$entryLine\n";
                 # permissions
                 $log->debug("SEND : u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}");
                 print "u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}\n";
@@ -604,7 +671,8 @@ sub req_add
         print "$filename\n";
         my $kopts = kopts_from_path($filename,"file",
                         $state->{entries}{$filename}{modified_filename});
-        print "/$filepart/0//$kopts/\n";
+        print "/$filepart/0//$kopts/" .
+              getStickyTagOrDate($stickyInfo) . "\n";
 
         my $requestedKopts = $state->{opt}{k};
         if(defined($requestedKopts))
@@ -672,7 +740,10 @@ sub req_remove
             next;
         }
 
-        my $meta = $updater->getmeta($filename);
+        # only from entries
+        my $stickyInfo = resolveStickyInfo($filename);
+
+        my $meta = $updater->getmeta($filename,$stickyInfo);
         my $wrev = revparse($filename);
 
         unless ( defined ( $wrev ) )
@@ -702,7 +773,7 @@ sub req_remove
         print "Checked-in $dirpart\n";
         print "$filename\n";
         my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash});
-        print "/$filepart/-$wrev//$kopts/\n";
+        print "/$filepart/-$wrev//$kopts/" . getStickyTagOrDate($stickyInfo) . "\n";
 
         $rmcount++;
     }
@@ -882,6 +953,9 @@ sub req_co
         return 1;
     }
 
+    my $stickyInfo = { 'tag' => $state->{opt}{r},
+                       'date' => $state->{opt}{D} };
+
     my $module = $state->{args}[0];
     $state->{module} = $module;
     my $checkout_path = $module;
@@ -899,64 +973,32 @@ sub req_co
     my $updater = GITCVS::updater->new($state->{CVSROOT}, $module, $log);
     $updater->update();
 
-    $checkout_path =~ s|/$||; # get rid of trailing slashes
+    my $headHash;
+    if( defined($stickyInfo) && defined($stickyInfo->{tag}) )
+    {
+        $headHash = $updater->lookupCommitRef($stickyInfo->{tag});
+        if( !defined($headHash) )
+        {
+            print "error 1 no such tag `$stickyInfo->{tag}'\n";
+            cleanupWorkTree();
+            exit;
+        }
+    }
 
-    # Eclipse seems to need the Clear-sticky command
-    # to prepare the 'Entries' file for the new directory.
-    print "Clear-sticky $checkout_path/\n";
-    print $state->{CVSROOT} . "/$module/\n";
-    print "Clear-static-directory $checkout_path/\n";
-    print $state->{CVSROOT} . "/$module/\n";
-    print "Clear-sticky $checkout_path/\n"; # yes, twice
-    print $state->{CVSROOT} . "/$module/\n";
-    print "Template $checkout_path/\n";
-    print $state->{CVSROOT} . "/$module/\n";
-    print "0\n";
-
-    # instruct the client that we're checking out to $checkout_path
-    print "E cvs checkout: Updating $checkout_path\n";
+    $checkout_path =~ s|/$||; # get rid of trailing slashes
 
     my %seendirs = ();
     my $lastdir ='';
 
-    # recursive
-    sub prepdir {
-       my ($dir, $repodir, $remotedir, $seendirs) = @_;
-       my $parent = dirname($dir);
-       $dir       =~ s|/+$||;
-       $repodir   =~ s|/+$||;
-       $remotedir =~ s|/+$||;
-       $parent    =~ s|/+$||;
-       $log->debug("announcedir $dir, $repodir, $remotedir" );
-
-       if ($parent eq '.' || $parent eq './') {
-           $parent = '';
-       }
-       # recurse to announce unseen parents first
-       if (length($parent) && !exists($seendirs->{$parent})) {
-           prepdir($parent, $repodir, $remotedir, $seendirs);
-       }
-       # Announce that we are going to modify at the parent level
-       if ($parent) {
-           print "E cvs checkout: Updating $remotedir/$parent\n";
-       } else {
-           print "E cvs checkout: Updating $remotedir\n";
-       }
-       print "Clear-sticky $remotedir/$parent/\n";
-       print "$repodir/$parent/\n";
-
-       print "Clear-static-directory $remotedir/$dir/\n";
-       print "$repodir/$dir/\n";
-       print "Clear-sticky $remotedir/$parent/\n"; # yes, twice
-       print "$repodir/$parent/\n";
-       print "Template $remotedir/$dir/\n";
-       print "$repodir/$dir/\n";
-       print "0\n";
-
-       $seendirs->{$dir} = 1;
-    }
-
-    foreach my $git ( @{$updater->gethead} )
+    prepDirForOutput(
+            ".",
+            $state->{CVSROOT} . "/$module",
+            $checkout_path,
+            \%seendirs,
+            'checkout',
+            $state->{dirArgs} );
+
+    foreach my $git ( @{$updater->getAnyHead($headHash)} )
     {
         # Don't want to check out deleted files
         next if ( $git->{filehash} eq "deleted" );
@@ -964,16 +1006,13 @@ sub req_co
         my $fullName = $git->{name};
         ( $git->{name}, $git->{dir} ) = filenamesplit($git->{name});
 
-       if (length($git->{dir}) && $git->{dir} ne './'
-           && $git->{dir} ne $lastdir ) {
-           unless (exists($seendirs{$git->{dir}})) {
-               prepdir($git->{dir}, $state->{CVSROOT} . "/$module/",
-                       $checkout_path, \%seendirs);
-               $lastdir = $git->{dir};
-               $seendirs{$git->{dir}} = 1;
-           }
-           print "E cvs checkout: Updating /$checkout_path/$git->{dir}\n";
-       }
+        unless (exists($seendirs{$git->{dir}})) {
+            prepDirForOutput($git->{dir}, $state->{CVSROOT} . "/$module/",
+                             $checkout_path, \%seendirs, 'checkout',
+                             $state->{dirArgs} );
+            $lastdir = $git->{dir};
+            $seendirs{$git->{dir}} = 1;
+        }
 
         # modification time of this file
         print "Mod-time $git->{modified}\n";
@@ -993,7 +1032,8 @@ sub req_co
 
         # this is an "entries" line
         my $kopts = kopts_from_path($fullName,"sha1",$git->{filehash});
-        print "/$git->{name}/$git->{revision}//$kopts/\n";
+        print "/$git->{name}/$git->{revision}//$kopts/" .
+                        getStickyTagOrDate($stickyInfo) . "\n";
         # permissions
         print "u=$git->{mode},g=$git->{mode},o=$git->{mode}\n";
 
@@ -1006,6 +1046,119 @@ sub req_co
     statecleanup();
 }
 
+# used by req_co and req_update to set up directories for files
+# recursively handles parents
+sub prepDirForOutput
+{
+    my ($dir, $repodir, $remotedir, $seendirs, $request, $dirArgs) = @_;
+
+    my $parent = dirname($dir);
+    $dir       =~ s|/+$||;
+    $repodir   =~ s|/+$||;
+    $remotedir =~ s|/+$||;
+    $parent    =~ s|/+$||;
+
+    if ($parent eq '.' || $parent eq './')
+    {
+        $parent = '';
+    }
+    # recurse to announce unseen parents first
+    if( length($parent) &&
+        !exists($seendirs->{$parent}) &&
+        ( $request eq "checkout" ||
+          exists($dirArgs->{$parent}) ) )
+    {
+        prepDirForOutput($parent, $repodir, $remotedir,
+                         $seendirs, $request, $dirArgs);
+    }
+    # Announce that we are going to modify at the parent level
+    if ($dir eq '.' || $dir eq './')
+    {
+        $dir = '';
+    }
+    if(exists($seendirs->{$dir}))
+    {
+        return;
+    }
+    $log->debug("announcedir $dir, $repodir, $remotedir" );
+    my($thisRemoteDir,$thisRepoDir);
+    if ($dir ne "")
+    {
+        $thisRepoDir="$repodir/$dir";
+        if($remotedir eq ".")
+        {
+            $thisRemoteDir=$dir;
+        }
+        else
+        {
+            $thisRemoteDir="$remotedir/$dir";
+        }
+    }
+    else
+    {
+        $thisRepoDir=$repodir;
+        $thisRemoteDir=$remotedir;
+    }
+    unless ( $state->{globaloptions}{-Q} || $state->{globaloptions}{-q} )
+    {
+        print "E cvs $request: Updating $thisRemoteDir\n";
+    }
+
+    my ($opt_r)=$state->{opt}{r};
+    my $stickyInfo;
+    if(exists($state->{opt}{A}))
+    {
+        # $stickyInfo=undef;
+    }
+    elsif( defined($opt_r) && $opt_r ne "" )
+           # || ( defined($state->{opt}{D}) && $state->{opt}{D} ne "" ) # TODO
+    {
+        $stickyInfo={ 'tag' => (defined($opt_r)?$opt_r:undef) };
+
+        # TODO: Convert -D value into the form 2011.04.10.04.46.57,
+        #   similar to an entry line's sticky date, without the D prefix.
+        #   It sometimes (always?) arrives as something more like
+        #   '10 Apr 2011 04:46:57 -0000'...
+        # $stickyInfo={ 'date' => (defined($stickyDate)?$stickyDate:undef) };
+    }
+    else
+    {
+        $stickyInfo=getDirStickyInfo($state->{prependdir} . $dir);
+    }
+
+    my $stickyResponse;
+    if(defined($stickyInfo))
+    {
+        $stickyResponse = "Set-sticky $thisRemoteDir/\n" .
+                          "$thisRepoDir/\n" .
+                          getStickyTagOrDate($stickyInfo) . "\n";
+    }
+    else
+    {
+        $stickyResponse = "Clear-sticky $thisRemoteDir/\n" .
+                          "$thisRepoDir/\n";
+    }
+
+    unless ( $state->{globaloptions}{-n} )
+    {
+        print $stickyResponse;
+
+        print "Clear-static-directory $thisRemoteDir/\n";
+        print "$thisRepoDir/\n";
+        print $stickyResponse; # yes, twice
+        print "Template $thisRemoteDir/\n";
+        print "$thisRepoDir/\n";
+        print "0\n";
+    }
+
+    $seendirs->{$dir} = 1;
+
+    # FUTURE: This would more accurately emulate CVS by sending
+    #   another copy of sticky after processing the files in that
+    #   directory.  Or intermediate: perhaps send all sticky's for
+    #   $seendirs after after processing all files.
+}
+
 # update \n
 #     Response expected: yes. Actually do a cvs update command. This uses any
 #     previous Argument, Directory, Entry, or Modified requests, if they have
@@ -1049,29 +1202,19 @@ sub req_update
 
     #$log->debug("update state : " . Dumper($state));
 
-    my $last_dirname = "///";
+    my($repoDir);
+    $repoDir=$state->{CVSROOT} . "/$state->{module}/$state->{prependdir}";
+
+    my %seendirs = ();
 
     # foreach file specified on the command line ...
-    foreach my $filename ( @{$state->{args}} )
+    foreach my $argsFilename ( @{$state->{args}} )
     {
-        $filename = filecleanup($filename);
+        my $filename;
+        $filename = filecleanup($argsFilename);
 
         $log->debug("Processing file $filename");
 
-        unless ( $state->{globaloptions}{-Q} || $state->{globaloptions}{-q} )
-        {
-            my $cur_dirname = dirname($filename);
-            if ( $cur_dirname ne $last_dirname )
-            {
-                $last_dirname = $cur_dirname;
-                if ( $cur_dirname eq "" )
-                {
-                    $cur_dirname = ".";
-                }
-                print "E cvs update: Updating $cur_dirname\n";
-            }
-        }
-
         # if we have a -C we should pretend we never saw modified stuff
         if ( exists ( $state->{opt}{C} ) )
         {
@@ -1080,13 +1223,11 @@ sub req_update
             $state->{entries}{$filename}{unchanged} = 1;
         }
 
-        my $meta;
-        if ( defined($state->{opt}{r}) and $state->{opt}{r} =~ /^(1\.\d+)$/ )
-        {
-            $meta = $updater->getmeta($filename, $1);
-        } else {
-            $meta = $updater->getmeta($filename);
-        }
+        my $stickyInfo = resolveStickyInfo($filename,
+                                           $state->{opt}{r},
+                                           $state->{opt}{D},
+                                           exists($state->{opt}{A}));
+        my $meta = $updater->getmeta($filename, $stickyInfo);
 
         # If -p was given, "print" the contents of the requested revision.
         if ( exists ( $state->{opt}{p} ) ) {
@@ -1099,6 +1240,17 @@ sub req_update
             next;
         }
 
+        # Directories:
+        prepDirForOutput(
+                dirname($argsFilename),
+                $repoDir,
+                ".",
+                \%seendirs,
+                "update",
+                $state->{dirArgs} );
+
+        my $wrev = revparse($filename);
+
        if ( ! defined $meta )
        {
            $meta = {
@@ -1106,16 +1258,23 @@ sub req_update
                revision => '0',
                filehash => 'added'
            };
+           if($wrev ne "0")
+           {
+               $meta->{filehash}='deleted';
+           }
        }
 
         my $oldmeta = $meta;
 
-        my $wrev = revparse($filename);
-
         # If the working copy is an old revision, lets get that version too for comparison.
-        if ( defined($wrev) and $wrev ne $meta->{revision} )
+        my $oldWrev=$wrev;
+        if(defined($oldWrev))
         {
-            $oldmeta = $updater->getmeta($filename, $wrev);
+            $oldWrev=~s/^-//;
+            if($oldWrev ne $meta->{revision})
+            {
+                $oldmeta = $updater->getmeta($filename, $oldWrev);
+            }
         }
 
         #$log->debug("Target revision is $meta->{revision}, current working revision is $wrev");
@@ -1133,6 +1292,7 @@ sub req_update
         if ( defined ( $wrev )
              and defined($meta->{revision})
              and $wrev eq $meta->{revision}
+             and $wrev ne "0"
              and defined($state->{entries}{$filename}{modified_hash})
              and not exists ( $state->{opt}{C} ) )
         {
@@ -1143,7 +1303,7 @@ sub req_update
             next;
         }
 
-        if ( $meta->{filehash} eq "deleted" )
+        if ( $meta->{filehash} eq "deleted" && $wrev ne "0" )
         {
             # TODO: If it has been modified in the sandbox, error out
             #   with the appropriate message, rather than deleting a modified
@@ -1205,10 +1365,6 @@ sub req_update
                    $log->debug("Updating existing file 'Update-existing $dirpart'");
                } else {
                    # instruct client we're sending a file to put in this path as a new file
-                   print "Clear-static-directory $dirpart\n";
-                   print $state->{CVSROOT} . "/$state->{module}/$dirpart\n";
-                   print "Clear-sticky $dirpart\n";
-                   print $state->{CVSROOT} . "/$state->{module}/$dirpart\n";
 
                    $log->debug("Creating new file 'Created $dirpart'");
                    print "Created $dirpart\n";
@@ -1217,8 +1373,10 @@ sub req_update
 
                # this is an "entries" line
                my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash});
-               $log->debug("/$filepart/$meta->{revision}//$kopts/");
-               print "/$filepart/$meta->{revision}//$kopts/\n";
+                my $entriesLine = "/$filepart/$meta->{revision}//$kopts/";
+                $entriesLine .= getStickyTagOrDate($stickyInfo);
+               $log->debug($entriesLine);
+               print "$entriesLine\n";
 
                # permissions
                $log->debug("SEND : u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}");
@@ -1266,7 +1424,9 @@ sub req_update
                     my $kopts = kopts_from_path("$dirpart/$filepart",
                                                 "file",$mergedFile);
                     $log->debug("/$filepart/$meta->{revision}//$kopts/");
-                    print "/$filepart/$meta->{revision}//$kopts/\n";
+                    my $entriesLine="/$filepart/$meta->{revision}//$kopts/";
+                    $entriesLine .= getStickyTagOrDate($stickyInfo);
+                    print "$entriesLine\n";
                 }
             }
             elsif ( $return == 1 )
@@ -1282,7 +1442,9 @@ sub req_update
                     print $state->{CVSROOT} . "/$state->{module}/$filename\n";
                     my $kopts = kopts_from_path("$dirpart/$filepart",
                                                 "file",$mergedFile);
-                    print "/$filepart/$meta->{revision}/+/$kopts/\n";
+                    my $entriesLine = "/$filepart/$meta->{revision}/+/$kopts/";
+                    $entriesLine .= getStickyTagOrDate($stickyInfo);
+                    print "$entriesLine\n";
                 }
             }
             else
@@ -1310,6 +1472,43 @@ sub req_update
 
     }
 
+    # prepDirForOutput() any other existing directories unless they already
+    # have the right sticky tag:
+    unless ( $state->{globaloptions}{n} )
+    {
+        my $dir;
+        foreach $dir (keys(%{$state->{dirMap}}))
+        {
+            if( ! $seendirs{$dir} &&
+                exists($state->{dirArgs}{$dir}) )
+            {
+                my($oldTag);
+                $oldTag=$state->{dirMap}{$dir}{tagspec};
+
+                unless( ( exists($state->{opt}{A}) &&
+                          defined($oldTag) ) ||
+                          ( defined($state->{opt}{r}) &&
+                            ( !defined($oldTag) ||
+                              $state->{opt}{r} ne $oldTag ) ) )
+                        # TODO?: OR sticky dir is different...
+                {
+                    next;
+                }
+
+                prepDirForOutput(
+                        $dir,
+                        $repoDir,
+                        ".",
+                        \%seendirs,
+                        'update',
+                        $state->{dirArgs} );
+            }
+
+            # TODO?: Consider sending a final duplicate Sticky response
+            #   to more closely mimic real CVS.
+        }
+    }
+
     print "ok\n";
 }
 
@@ -1342,23 +1541,11 @@ sub req_ci
     my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
     $updater->update();
 
-    # Remember where the head was at the beginning.
-    my $parenthash = `git show-ref -s refs/heads/$state->{module}`;
-    chomp $parenthash;
-    if ($parenthash !~ /^[0-9a-f]{40}$/) {
-           print "error 1 pserver cannot find the current HEAD of module";
-           cleanupWorkTree();
-           exit;
-    }
-
-    setupWorkTree($parenthash);
-
-    $log->info("Lockless commit start, basing commit on '$work->{workDir}', index file is '$work->{index}'");
-
-    $log->info("Created index '$work->{index}' for head $state->{module} - exit status $?");
-
     my @committedfiles = ();
     my %oldmeta;
+    my $stickyInfo;
+    my $branchRef;
+    my $parenthash;
 
     # foreach file specified on the command line ...
     foreach my $filename ( @{$state->{args}} )
@@ -1368,7 +1555,67 @@ sub req_ci
 
         next unless ( exists $state->{entries}{$filename}{modified_filename} or not $state->{entries}{$filename}{unchanged} );
 
-        my $meta = $updater->getmeta($filename);
+        #####
+        # Figure out which branch and parenthash we are committing
+        # to, and setup worktree:
+
+        # should always come from entries:
+        my $fileStickyInfo = resolveStickyInfo($filename);
+        if( !defined($branchRef) )
+        {
+            $stickyInfo = $fileStickyInfo;
+            if( defined($stickyInfo) &&
+                ( defined($stickyInfo->{date}) ||
+                  !defined($stickyInfo->{tag}) ) )
+            {
+                print "error 1 cannot commit with sticky date for file `$filename'\n";
+                cleanupWorkTree();
+                exit;
+            }
+
+            $branchRef = "refs/heads/$state->{module}";
+            if ( defined($stickyInfo) && defined($stickyInfo->{tag}) )
+            {
+                $branchRef = "refs/heads/$stickyInfo->{tag}";
+            }
+
+            $parenthash = `git show-ref -s $branchRef`;
+            chomp $parenthash;
+            if ($parenthash !~ /^[0-9a-f]{40}$/)
+            {
+                if ( defined($stickyInfo) && defined($stickyInfo->{tag}) )
+                {
+                    print "error 1 sticky tag `$stickyInfo->{tag}' for file `$filename' is not a branch\n";
+                }
+                else
+                {
+                    print "error 1 pserver cannot find the current HEAD of module";
+                }
+                cleanupWorkTree();
+                exit;
+            }
+
+            setupWorkTree($parenthash);
+
+            $log->info("Lockless commit start, basing commit on '$work->{workDir}', index file is '$work->{index}'");
+
+            $log->info("Created index '$work->{index}' for head $state->{module} - exit status $?");
+        }
+        elsif( !refHashEqual($stickyInfo,$fileStickyInfo) )
+        {
+            #TODO: We could split the cvs commit into multiple
+            #  git commits by distinct stickyTag values, but that
+            #  is lowish priority.
+            print "error 1 Committing different files to different"
+                  . " branches is not currently supported\n";
+            cleanupWorkTree();
+            exit;
+        }
+
+        #####
+        # Process this file:
+
+        my $meta = $updater->getmeta($filename,$stickyInfo);
        $oldmeta{$filename} = $meta;
 
         my $wrev = revparse($filename);
@@ -1470,7 +1717,7 @@ sub req_ci
     }
 
        ### Emulate git-receive-pack by running hooks/update
-       my @hook = ( $ENV{GIT_DIR}.'hooks/update', "refs/heads/$state->{module}",
+       my @hook = ( $ENV{GIT_DIR}.'hooks/update', $branchRef,
                        $parenthash, $commithash );
        if( -x $hook[0] ) {
                unless( system( @hook ) == 0 )
@@ -1484,7 +1731,7 @@ sub req_ci
 
        ### Update the ref
        if (system(qw(git update-ref -m), "cvsserver ci",
-                       "refs/heads/$state->{module}", $commithash, $parenthash)) {
+                       $branchRef, $commithash, $parenthash)) {
                $log->warn("update-ref for $state->{module} failed.");
                print "error 1 Cannot commit -- update first\n";
                cleanupWorkTree();
@@ -1498,7 +1745,7 @@ sub req_ci
 
                local $SIG{PIPE} = sub { die 'pipe broke' };
 
-               print $pipe "$parenthash $commithash refs/heads/$state->{module}\n";
+               print $pipe "$parenthash $commithash $branchRef\n";
 
                close $pipe || die "bad pipe: $! $?";
        }
@@ -1508,7 +1755,7 @@ sub req_ci
        ### Then hooks/post-update
        $hook = $ENV{GIT_DIR}.'hooks/post-update';
        if (-x $hook) {
-               system($hook, "refs/heads/$state->{module}");
+               system($hook, $branchRef);
        }
 
     # foreach file specified on the command line ...
@@ -1516,7 +1763,7 @@ sub req_ci
     {
         $filename = filecleanup($filename);
 
-        my $meta = $updater->getmeta($filename);
+        my $meta = $updater->getmeta($filename,$stickyInfo);
        unless (defined $meta->{revision}) {
          $meta->{revision} = "1.1";
        }
@@ -1540,7 +1787,8 @@ sub req_ci
             print "Checked-in $dirpart\n";
             print "$filename\n";
             my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash});
-            print "/$filepart/$meta->{revision}//$kopts/\n";
+            print "/$filepart/$meta->{revision}//$kopts/" .
+                  getStickyTagOrDate($stickyInfo) . "\n";
         }
     }
 
@@ -1577,16 +1825,19 @@ sub req_status
            next;
         }
 
-        my $meta = $updater->getmeta($filename);
-        my $oldmeta = $meta;
-
         my $wrev = revparse($filename);
 
+        my $stickyInfo = resolveStickyInfo($filename);
+        my $meta = $updater->getmeta($filename,$stickyInfo);
+        my $oldmeta = $meta;
+
         # If the working copy is an old revision, lets get that
         # version too for comparison.
         if ( defined($wrev) and $wrev ne $meta->{revision} )
         {
-            $oldmeta = $updater->getmeta($filename, $wrev);
+            my($rmRev)=$wrev;
+            $rmRev=~s/^-//;
+            $oldmeta = $updater->getmeta($filename, $rmRev);
         }
 
         # TODO : All possible statuses aren't yet implemented
@@ -1629,6 +1880,7 @@ sub req_status
         # same revision but there are local changes
         if ( defined ( $wrev ) and defined($meta->{revision}) and
              $wrev eq $meta->{revision} and
+             $wrev ne "0" and
              $state->{entries}{$filename}{modified_filename} )
         {
             $status ||= "Locally Modified";
@@ -1644,7 +1896,8 @@ sub req_status
         }
 
         if ( defined ( $state->{entries}{$filename}{revision} ) and
-             not defined ( $meta->{revision} ) )
+             ( !defined($meta->{revision}) ||
+               $meta->{revision} eq "0" ) )
         {
             $status ||= "Locally Added";
         }
@@ -1740,98 +1993,133 @@ sub req_diff
     # be providing status on ...
     argsfromdir($updater);
 
+    my($foundDiff);
+
     # foreach file specified on the command line ...
-    foreach my $filename ( @{$state->{args}} )
+    foreach my $argFilename ( @{$state->{args}} )
     {
-        $filename = filecleanup($filename);
+        my($filename) = filecleanup($argFilename);
 
         my ( $fh, $file1, $file2, $meta1, $meta2, $filediff );
 
         my $wrev = revparse($filename);
 
-        # We need _something_ to diff against
-        next unless ( defined ( $wrev ) );
+        # Priority for revision1:
+        #  1. First -r (missing file: check -N)
+        #  2. wrev from client's Entry line
+        #      - missing line/file: check -N
+        #      - "0": added file not committed (empty contents for rev1)
+        #      - Prefixed with dash (to be removed): check -N
 
-        # if we have a -r switch, use it
         if ( defined ( $revision1 ) )
         {
-            ( undef, $file1 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 );
             $meta1 = $updater->getmeta($filename, $revision1);
-            unless ( defined ( $meta1 ) and $meta1->{filehash} ne "deleted" )
+        }
+        elsif( defined($wrev) && $wrev ne "0" )
+        {
+            my($rmRev)=$wrev;
+            $rmRev=~s/^-//;
+            $meta1 = $updater->getmeta($filename, $rmRev);
+        }
+        if ( !defined($meta1) ||
+             $meta1->{filehash} eq "deleted" )
+        {
+            if( !exists($state->{opt}{N}) )
             {
-                print "E File $filename at revision $revision1 doesn't exist\n";
+                if(!defined($revision1))
+                {
+                    print "E File $filename at revision $revision1 doesn't exist\n";
+                }
                 next;
             }
-            transmitfile($meta1->{filehash}, { targetfile => $file1 });
-        }
-        # otherwise we just use the working copy revision
-        else
-        {
-            ( undef, $file1 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 );
-            $meta1 = $updater->getmeta($filename, $wrev);
-            transmitfile($meta1->{filehash}, { targetfile => $file1 });
+            elsif( !defined($meta1) )
+            {
+                $meta1 = {
+                    name => $filename,
+                    revision => '0',
+                    filehash => 'deleted'
+                };
+            }
         }
 
+        # Priority for revision2:
+        #  1. Second -r (missing file: check -N)
+        #  2. Modified file contents from client
+        #  3. wrev from client's Entry line
+        #      - missing line/file: check -N
+        #      - Prefixed with dash (to be removed): check -N
+
         # if we have a second -r switch, use it too
         if ( defined ( $revision2 ) )
         {
-            ( undef, $file2 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 );
             $meta2 = $updater->getmeta($filename, $revision2);
-
-            unless ( defined ( $meta2 ) and $meta2->{filehash} ne "deleted" )
-            {
-                print "E File $filename at revision $revision2 doesn't exist\n";
-                next;
-            }
-
-            transmitfile($meta2->{filehash}, { targetfile => $file2 });
         }
-        # otherwise we just use the working copy
-        else
+        elsif(defined($state->{entries}{$filename}{modified_filename}))
         {
             $file2 = $state->{entries}{$filename}{modified_filename};
+           $meta2 = {
+                name => $filename,
+               revision => '0',
+               filehash => 'modified'
+            };
         }
-
-        # if we have been given -r, and we don't have a $file2 yet, lets
-        # get one
-        if ( defined ( $revision1 ) and not defined ( $file2 ) )
+        elsif( defined($wrev) && ($wrev!~/^-/) )
         {
-            ( undef, $file2 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 );
+            if(!defined($revision1))  # no revision and no modifications:
+            {
+                next;
+            }
             $meta2 = $updater->getmeta($filename, $wrev);
-            transmitfile($meta2->{filehash}, { targetfile => $file2 });
+        }
+        if(!defined($file2))
+        {
+            if ( !defined($meta2) ||
+                 $meta2->{filehash} eq "deleted" )
+            {
+                if( !exists($state->{opt}{N}) )
+                {
+                    if(!defined($revision2))
+                    {
+                        print "E File $filename at revision $revision2 doesn't exist\n";
+                    }
+                    next;
+                }
+                elsif( !defined($meta2) )
+                {
+                   $meta2 = {
+                        name => $filename,
+                       revision => '0',
+                       filehash => 'deleted'
+                    };
+                }
+            }
         }
 
-        # We need to have retrieved something useful
-        next unless ( defined ( $meta1 ) );
-
-        # Files to date if the working copy and repo copy have the same
-        # revision, and the working copy is unmodified
-        if ( not defined ( $meta2 ) and $wrev eq $meta1->{revision} and
-             ( ( $state->{entries}{$filename}{unchanged} and
-                 ( not defined ( $state->{entries}{$filename}{conflict} ) or
-                   $state->{entries}{$filename}{conflict} !~ /^\+=/ ) ) or
-               ( defined($state->{entries}{$filename}{modified_hash}) and
-                 $state->{entries}{$filename}{modified_hash} eq
-                        $meta1->{filehash} ) ) )
+        if( $meta1->{filehash} eq $meta2->{filehash} )
         {
+            $log->info("unchanged $filename");
             next;
         }
 
-        # Apparently we only show diffs for locally modified files
-        unless ( defined($meta2) or
-                 defined ( $state->{entries}{$filename}{modified_filename} ) )
+        # Retrieve revision contents:
+        ( undef, $file1 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 );
+        transmitfile($meta1->{filehash}, { targetfile => $file1 });
+
+        if(!defined($file2))
         {
-            next;
+            ( undef, $file2 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 );
+            transmitfile($meta2->{filehash}, { targetfile => $file2 });
         }
 
-        print "M Index: $filename\n";
+        # Generate the actual diff:
+        print "M Index: $argFilename\n";
         print "M =======" . ( "=" x 60 ) . "\n";
         print "M RCS file: $state->{CVSROOT}/$state->{module}/$filename,v\n";
-        if ( defined ( $meta1 ) )
+        if ( defined ( $meta1 ) && $meta1->{revision} ne "0" )
         {
             print "M retrieving revision $meta1->{revision}\n"
         }
-        if ( defined ( $meta2 ) )
+        if ( defined ( $meta2 ) && $meta2->{revision} ne "0" )
         {
             print "M retrieving revision $meta2->{revision}\n"
         }
@@ -1852,33 +2140,73 @@ sub req_diff
                 }
             }
         }
-        print "$filename\n";
+        print "$argFilename\n";
 
         $log->info("Diffing $filename -r $meta1->{revision} -r " .
                    ( $meta2->{revision} or "workingcopy" ));
 
-        ( $fh, $filediff ) = tempfile ( DIR => $TEMP_DIR );
-
-        if ( exists $state->{opt}{u} )
+        # TODO: Use --label instead of -L because -L is no longer
+        #  documented and may go away someday.  Not sure if there there are
+        #  versions that only support -L, which would make this change risky?
+        #  http://osdir.com/ml/bug-gnu-utils-gnu/2010-12/msg00060.html
+        #    ("man diff" should actually document the best migration strategy,
+        #  [current behavior, future changes, old compatibility issues
+        #  or lack thereof, etc], not just stop mentioning the option...)
+        # TODO: Real CVS seems to include a date in the label, before
+        #  the revision part, without the keyword "revision".  The following
+        #  has minimal changes compared to original versions of
+        #  git-cvsserver.perl.  (Mostly tab vs space after filename.)
+
+        my (@diffCmd) = ( 'diff' );
+        if ( exists($state->{opt}{N}) )
         {
-            system("diff -u -L '$filename revision $meta1->{revision}'" .
-                        " -L '$filename " .
-                        ( defined($meta2->{revision}) ?
-                                "revision $meta2->{revision}" :
-                                "working copy" ) .
-                        "' $file1 $file2 > $filediff" );
-        } else {
-            system("diff $file1 $file2 > $filediff");
+            push @diffCmd,"-N";
         }
+        if ( exists $state->{opt}{u} )
+        {
+            push @diffCmd,("-u","-L");
+            if( $meta1->{filehash} eq "deleted" )
+            {
+                push @diffCmd,"/dev/null";
+            } else {
+                push @diffCmd,("$argFilename\trevision $meta1->{revision}");
+            }
 
-        while ( <$fh> )
+            if( defined($meta2->{filehash}) )
+            {
+                if( $meta2->{filehash} eq "deleted" )
+                {
+                    push @diffCmd,("-L","/dev/null");
+                } else {
+                    push @diffCmd,("-L",
+                                   "$argFilename\trevision $meta2->{revision}");
+                }
+            } else {
+                push @diffCmd,("-L","$argFilename\tworking copy");
+            }
+        }
+        push @diffCmd,($file1,$file2);
+        if(!open(DIFF,"-|",@diffCmd))
         {
-            print "M $_";
+            $log->warn("Unable to run diff: $!");
         }
-        close $fh;
+        my($diffLine);
+        while(defined($diffLine=<DIFF>))
+        {
+            print "M $diffLine";
+            $foundDiff=1;
+        }
+        close(DIFF);
     }
 
-    print "ok\n";
+    if($foundDiff)
+    {
+        print "error  \n";
+    }
+    else
+    {
+        print "ok\n";
+    }
 }
 
 sub req_log
@@ -2098,7 +2426,7 @@ sub argsplit
         $opt = { A => 0, N => 0, P => 0, R => 0, c => 0, f => 0, l => 0, n => 0, p => 0, s => 0, r => 1, D => 1, d => 1, k => 1, j => 1, } if ( $type eq "co" );
         $opt = { v => 0, l => 0, R => 0 } if ( $type eq "status" );
         $opt = { A => 0, P => 0, C => 0, d => 0, f => 0, l => 0, R => 0, p => 0, k => 1, r => 1, D => 1, j => 1, I => 1, W => 1 } if ( $type eq "update" );
-        $opt = { l => 0, R => 0, k => 1, D => 1, D => 1, r => 2 } if ( $type eq "diff" );
+        $opt = { l => 0, R => 0, k => 1, D => 1, D => 1, r => 2, N => 0 } if ( $type eq "diff" );
         $opt = { c => 0, R => 0, l => 0, f => 0, F => 1, m => 1, r => 1 } if ( $type eq "ci" );
         $opt = { k => 1, m => 1 } if ( $type eq "add" );
         $opt = { f => 0, l => 0, R => 0 } if ( $type eq "remove" );
@@ -2164,62 +2492,335 @@ sub argsplit
     }
 }
 
-# This method uses $state->{directory} to populate $state->{args} with a list of filenames
-sub argsfromdir
+# Used by argsfromdir
+sub expandArg
 {
-    my $updater = shift;
-
-    $state->{args} = [] if ( scalar(@{$state->{args}}) == 1 and $state->{args}[0] eq "." );
+    my ($updater,$outNameMap,$outDirMap,$path,$isDir) = @_;
 
-    return if ( scalar ( @{$state->{args}} ) > 1 );
+    my $fullPath = filecleanup($path);
 
-    my @gethead = @{$updater->gethead};
+      # Is it a directory?
+    if( defined($state->{dirMap}{$fullPath}) ||
+        defined($state->{dirMap}{"$fullPath/"}) )
+    {
+          # It is a directory in the user's sandbox.
+        $isDir=1;
 
-    # push added files
-    foreach my $file (keys %{$state->{entries}}) {
-       if ( exists $state->{entries}{$file}{revision} &&
-               $state->{entries}{$file}{revision} eq '0' )
-       {
-           push @gethead, { name => $file, filehash => 'added' };
-       }
+        if(defined($state->{entries}{$fullPath}))
+        {
+            $log->fatal("Inconsistent file/dir type");
+            die "Inconsistent file/dir type";
+        }
     }
-
-    if ( scalar(@{$state->{args}}) == 1 )
+    elsif(defined($state->{entries}{$fullPath}))
     {
-        my $arg = $state->{args}[0];
-        $arg .= $state->{prependdir} if ( defined ( $state->{prependdir} ) );
-
-        $log->info("Only one arg specified, checking for directory expansion on '$arg'");
-
-        foreach my $file ( @gethead )
+          # It is a file in the user's sandbox.
+        $isDir=0;
+    }
+    my($revDirMap,$otherRevDirMap);
+    if(!defined($isDir) || $isDir)
+    {
+          # Resolve version tree for sticky tag:
+          # (for now we only want list of files for the version, not
+          # particular versions of those files: assume it is a directory
+          # for the moment; ignore Entry's stick tag)
+
+          # Order of precedence of sticky tags:
+          #    -A       [head]
+          #    -r /tag/
+          #    [file entry sticky tag, but that is only relevant to files]
+          #    [the tag specified in dir req_Sticky]
+          #    [the tag specified in a parent dir req_Sticky]
+          #    [head]
+          # Also, -r may appear twice (for diff).
+          #
+          # FUTURE: When/if -j (merges) are supported, we also
+          #  need to add relevant files from one or two
+          #  versions specified with -j.
+
+        if(exists($state->{opt}{A}))
         {
-            next if ( $file->{filehash} eq "deleted" and not defined ( $state->{entries}{$file->{name}} ) );
-            next unless ( $file->{name} =~ /^$arg\// or $file->{name} eq $arg  );
-            push @{$state->{args}}, $file->{name};
+            $revDirMap=$updater->getRevisionDirMap();
         }
-
-        shift @{$state->{args}} if ( scalar(@{$state->{args}}) > 1 );
-    } else {
-        $log->info("Only one arg specified, populating file list automatically");
-
-        $state->{args} = [];
-
-        foreach my $file ( @gethead )
+        elsif( defined($state->{opt}{r}) and
+               ref $state->{opt}{r} eq "ARRAY" )
         {
-            next if ( $file->{filehash} eq "deleted" and not defined ( $state->{entries}{$file->{name}} ) );
-            next unless ( $file->{name} =~ s/^$state->{prependdir}// );
-            push @{$state->{args}}, $file->{name};
+            $revDirMap=$updater->getRevisionDirMap($state->{opt}{r}[0]);
+            $otherRevDirMap=$updater->getRevisionDirMap($state->{opt}{r}[1]);
         }
-    }
-}
-
-# This method cleans up the $state variable after a command that uses arguments has run
+        elsif(defined($state->{opt}{r}))
+        {
+            $revDirMap=$updater->getRevisionDirMap($state->{opt}{r});
+        }
+        else
+        {
+            my($sticky)=getDirStickyInfo($fullPath);
+            $revDirMap=$updater->getRevisionDirMap($sticky->{tag});
+        }
+
+          # Is it a directory?
+        if( defined($revDirMap->{$fullPath}) ||
+            defined($otherRevDirMap->{$fullPath}) )
+        {
+            $isDir=1;
+        }
+    }
+
+      # What to do with it?
+    if(!$isDir)
+    {
+        $outNameMap->{$fullPath}=1;
+    }
+    else
+    {
+        $outDirMap->{$fullPath}=1;
+
+        if(defined($revDirMap->{$fullPath}))
+        {
+            addDirMapFiles($updater,$outNameMap,$outDirMap,
+                           $revDirMap->{$fullPath});
+        }
+        if( defined($otherRevDirMap) &&
+            defined($otherRevDirMap->{$fullPath}) )
+        {
+            addDirMapFiles($updater,$outNameMap,$outDirMap,
+                           $otherRevDirMap->{$fullPath});
+        }
+    }
+}
+
+# Used by argsfromdir
+# Add entries from dirMap to outNameMap.  Also recurse into entries
+# that are subdirectories.
+sub addDirMapFiles
+{
+    my($updater,$outNameMap,$outDirMap,$dirMap)=@_;
+
+    my($fullName);
+    foreach $fullName (keys(%$dirMap))
+    {
+        my $cleanName=$fullName;
+        if(defined($state->{prependdir}))
+        {
+            if(!($cleanName=~s/^\Q$state->{prependdir}\E//))
+            {
+                $log->fatal("internal error stripping prependdir");
+                die "internal error stripping prependdir";
+            }
+        }
+
+        if($dirMap->{$fullName} eq "F")
+        {
+            $outNameMap->{$cleanName}=1;
+        }
+        elsif($dirMap->{$fullName} eq "D")
+        {
+            if(!$state->{opt}{l})
+            {
+                expandArg($updater,$outNameMap,$outDirMap,$cleanName,1);
+            }
+        }
+        else
+        {
+            $log->fatal("internal error in addDirMapFiles");
+            die "internal error in addDirMapFiles";
+        }
+    }
+}
+
+# This method replaces $state->{args} with a directory-expanded
+# list of all relevant filenames (recursively unless -d), based
+# on $state->{entries}, and the "current" list of files in
+# each directory.  "Current" files as determined by
+# either the requested (-r/-A) or "req_Sticky" version of
+# that directory.
+#    Both the input args and the new output args are relative
+# to the cvs-client's CWD, although some of the internal
+# computations are relative to the top of the project.
+sub argsfromdir
+{
+    my $updater = shift;
+
+    # Notes about requirements for specific callers:
+    #   update # "standard" case (entries; a single -r/-A/default; -l)
+    #          # Special case: -d for create missing directories.
+    #   diff # 0 or 1 -r's: "standard" case.
+    #        # 2 -r's: We could ignore entries (just use the two -r's),
+    #        # but it doesn't really matter.
+    #   annotate # "standard" case
+    #   log # Punting: log -r has a more complex non-"standard"
+    #       # meaning, and we don't currently try to support log'ing
+    #       # branches at all (need a lot of work to
+    #       # support CVS-consistent branch relative version
+    #       # numbering).
+#HERE: But we still want to expand directories.  Maybe we should
+#  essentially force "-A".
+    #   status # "standard", except that -r/-A/default are not possible.
+    #          # Mostly only used to expand entries only)
+    #
+    # Don't use argsfromdir at all:
+    #   add # Explicit arguments required.  Directory args imply add
+    #       # the directory itself, not the files in it.
+    #   co  # Obtain list directly.
+    #   remove # HERE: TEST: MAYBE client does the recursion for us,
+    #          # since it only makes sense to remove stuff already in
+    #          # the sandobx?
+    #   ci # HERE: Similar to remove...
+    #      # Don't try to implement the confusing/weird
+    #      # ci -r bug er.."feature".
+
+    if(scalar(@{$state->{args}})==0)
+    {
+        $state->{args} = [ "." ];
+    }
+    my %allArgs;
+    my %allDirs;
+    for my $file (@{$state->{args}})
+    {
+        expandArg($updater,\%allArgs,\%allDirs,$file);
+    }
+
+    # Include any entries from sandbox.  Generally client won't
+    # send entries that shouldn't be used.
+    foreach my $file (keys %{$state->{entries}})
+    {
+        $allArgs{remove_prependdir($file)} = 1;
+    }
+
+    $state->{dirArgs} = \%allDirs;
+    $state->{args} = [
+        sort {
+                # Sort priority: by directory depth, then actual file name:
+            my @piecesA=split('/',$a);
+            my @piecesB=split('/',$b);
+
+            my $count=scalar(@piecesA);
+            my $tmp=scalar(@piecesB);
+            return $count<=>$tmp if($count!=$tmp);
+
+            for($tmp=0;$tmp<$count;$tmp++)
+            {
+                if($piecesA[$tmp] ne $piecesB[$tmp])
+                {
+                    return $piecesA[$tmp] cmp $piecesB[$tmp]
+                }
+            }
+            return 0;
+        } keys(%allArgs) ];
+}
+
+## look up directory sticky tag, of either fullPath or a parent:
+sub getDirStickyInfo
+{
+    my($fullPath)=@_;
+
+    $fullPath=~s%/+$%%;
+    while($fullPath ne "" && !defined($state->{dirMap}{"$fullPath/"}))
+    {
+        $fullPath=~s%/?[^/]*$%%;
+    }
+
+    if( !defined($state->{dirMap}{"$fullPath/"}) &&
+        ( $fullPath eq "" ||
+          $fullPath eq "." ) )
+    {
+        return $state->{dirMap}{""}{stickyInfo};
+    }
+    else
+    {
+        return $state->{dirMap}{"$fullPath/"}{stickyInfo};
+    }
+}
+
+# Resolve precedence of various ways of specifying which version of
+# a file you want.  Returns undef (for default head), or a ref to a hash
+# that contains "tag" and/or "date" keys.
+sub resolveStickyInfo
+{
+    my($filename,$stickyTag,$stickyDate,$reset) = @_;
+
+    # Order of precedence of sticky tags:
+    #    -A       [head]
+    #    -r /tag/
+    #    [file entry sticky tag]
+    #    [the tag specified in dir req_Sticky]
+    #    [the tag specified in a parent dir req_Sticky]
+    #    [head]
+
+    my $result;
+    if($reset)
+    {
+        # $result=undef;
+    }
+    elsif( defined($stickyTag) && $stickyTag ne "" )
+           # || ( defined($stickyDate) && $stickyDate ne "" )   # TODO
+    {
+        $result={ 'tag' => (defined($stickyTag)?$stickyTag:undef) };
+
+        # TODO: Convert -D value into the form 2011.04.10.04.46.57,
+        #   similar to an entry line's sticky date, without the D prefix.
+        #   It sometimes (always?) arrives as something more like
+        #   '10 Apr 2011 04:46:57 -0000'...
+        # $result={ 'date' => (defined($stickyDate)?$stickyDate:undef) };
+    }
+    elsif( defined($state->{entries}{$filename}) &&
+           defined($state->{entries}{$filename}{tag_or_date}) &&
+           $state->{entries}{$filename}{tag_or_date} ne "" )
+    {
+        my($tagOrDate)=$state->{entries}{$filename}{tag_or_date};
+        if($tagOrDate=~/^T([^ ]+)\s*$/)
+        {
+            $result = { 'tag' => $1 };
+        }
+        elsif($tagOrDate=~/^D([0-9.]+)\s*$/)
+        {
+            $result= { 'date' => $1 };
+        }
+        else
+        {
+            die "Unknown tag_or_date format\n";
+        }
+    }
+    else
+    {
+        $result=getDirStickyInfo($filename);
+    }
+
+    return $result;
+}
+
+# Convert a stickyInfo (ref to a hash) as returned by resolveStickyInfo into
+# a form appropriate for the sticky tag field of an Entries
+# line (field index 5, 0-based).
+sub getStickyTagOrDate
+{
+    my($stickyInfo)=@_;
+
+    my $result;
+    if(defined($stickyInfo) && defined($stickyInfo->{tag}))
+    {
+        $result="T$stickyInfo->{tag}";
+    }
+    # TODO: When/if we actually pick versions by {date} properly,
+    #   also handle it here:
+    #   "D$stickyInfo->{date}" (example: "D2011.04.13.20.37.07").
+    else
+    {
+        $result="";
+    }
+
+    return $result;
+}
+
+# This method cleans up the $state variable after a command that uses arguments has run
 sub statecleanup
 {
     $state->{files} = [];
+    $state->{dirArgs} = {};
     $state->{args} = [];
     $state->{arguments} = [];
     $state->{entries} = {};
+    $state->{dirMap} = {};
 }
 
 # Return working directory CVS revision "1.X" out
@@ -2309,6 +2910,9 @@ sub filenamesplit
     return ( $filepart, $dirpart );
 }
 
+# Cleanup various junk in filename (try to canonicalize it), and
+# add prependdir to accomodate running CVS client from a
+# subdirectory (so the output is relative to top directory of the project).
 sub filecleanup
 {
     my $filename = shift;
@@ -2320,11 +2924,36 @@ sub filecleanup
         return undef;
     }
 
+    if($filename eq ".")
+    {
+        $filename="";
+    }
     $filename =~ s/^\.\///g;
+    $filename =~ s%/+%/%g;
     $filename = $state->{prependdir} . $filename;
+    $filename =~ s%/$%%;
     return $filename;
 }
 
+# Remove prependdir from the path, so that is is relative to the directory
+# the CVS client was started from, rather than the top of the project.
+# Essentially the inverse of filecleanup().
+sub remove_prependdir
+{
+    my($path) = @_;
+    if(defined($state->{prependdir}) && $state->{prependdir} ne "")
+    {
+        my($pre)=$state->{prependdir};
+        $pre=~s%/$%%;
+        if(!($path=~s%^\Q$pre\E/?%%))
+        {
+            $log->fatal("internal error missing prependdir");
+            die("internal error missing prependdir");
+        }
+    }
+    return $path;
+}
+
 sub validateGitDir
 {
     if( !defined($state->{CVSROOT}) )
@@ -2738,6 +3367,45 @@ sub descramble
     return $ret;
 }
 
+# Test if the (deep) values of two references to a hash are the same.
+sub refHashEqual
+{
+    my($v1,$v2) = @_;
+
+    my $out;
+    if(!defined($v1))
+    {
+        if(!defined($v2))
+        {
+            $out=1;
+        }
+    }
+    elsif( !defined($v2) ||
+           scalar(keys(%{$v1})) != scalar(keys(%{$v2})) )
+    {
+        # $out=undef;
+    }
+    else
+    {
+        $out=1;
+
+        my $key;
+        foreach $key (keys(%{$v1}))
+        {
+            if( !exists($v2->{$key}) ||
+                defined($v1->{$key}) ne defined($v2->{$key}) ||
+                ( defined($v1->{$key}) &&
+                  $v1->{$key} ne $v2->{$key} ) )
+            {
+               $out=undef;
+               last;
+            }
+        }
+    }
+
+    return $out;
+}
+
 
 package GITCVS::log;
 
@@ -2958,6 +3626,9 @@ sub new
 
     die "Git repo '$self->{git_path}' doesn't exist" unless ( -d $self->{git_path} );
 
+    # Stores full sha1's for various branch/tag names, abbreviations, etc:
+    $self->{commitRefCache} = {};
+
     $self->{dbdriver} = $cfg->{gitcvs}{$state->{method}}{dbdriver} ||
         $cfg->{gitcvs}{dbdriver} || "SQLite";
     $self->{dbname} = $cfg->{gitcvs}{$state->{method}}{dbname} ||
@@ -3140,6 +3811,8 @@ sub update
     my $lastcommit = $self->_get_prop("last_commit");
 
     if (defined $lastcommit && $lastcommit eq $commitsha1) { # up-to-date
+         # invalidate the gethead cache
+         $self->clearCommitRefCaches();
          return 1;
     }
 
@@ -3157,45 +3830,10 @@ sub update
         push @git_log_params, $self->{module};
     }
     # git-rev-list is the backend / plumbing version of git-log
-    open(GITLOG, '-|', 'git', 'rev-list', @git_log_params) or die "Cannot call git-rev-list: $!";
-
-    my @commits;
-
-    my %commit = ();
-
-    while ( <GITLOG> )
-    {
-        chomp;
-        if (m/^commit\s+(.*)$/) {
-            # on ^commit lines put the just seen commit in the stack
-            # and prime things for the next one
-            if (keys %commit) {
-                my %copy = %commit;
-                unshift @commits, \%copy;
-                %commit = ();
-            }
-            my @parents = split(m/\s+/, $1);
-            $commit{hash} = shift @parents;
-            $commit{parents} = \@parents;
-        } elsif (m/^(\w+?):\s+(.*)$/ && !exists($commit{message})) {
-            # on rfc822-like lines seen before we see any message,
-            # lowercase the entry and put it in the hash as key-value
-            $commit{lc($1)} = $2;
-        } else {
-            # message lines - skip initial empty line
-            # and trim whitespace
-            if (!exists($commit{message}) && m/^\s*$/) {
-                # define it to mark the end of headers
-                $commit{message} = '';
-                next;
-            }
-            s/^\s+//; s/\s+$//; # trim ws
-            $commit{message} .= $_ . "\n";
-        }
-    }
-    close GITLOG;
-
-    unshift @commits, \%commit if ( keys %commit );
+    open(my $gitLogPipe, '-|', 'git', 'rev-list', @git_log_params)
+                or die "Cannot call git-rev-list: $!";
+    my @commits=readCommits($gitLogPipe);
+    close $gitLogPipe;
 
     # Now all the commits are in the @commits bucket
     # ordered by time DESC. for each commit that needs processing,
@@ -3294,7 +3932,7 @@ sub update
         }
 
         # convert the date to CVS-happy format
-        $commit->{date} = "$2 $1 $4 $3 $5" if ( $commit->{date} =~ /^\w+\s+(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+(\d+)\s+([+-]\d+)$/ );
+        my $cvsDate = convertToCvsDate($commit->{date});
 
         if ( defined ( $lastpicked ) )
         {
@@ -3303,7 +3941,7 @@ sub update
             while ( <FILELIST> )
             {
                chomp;
-                unless ( /^:\d{6}\s+\d{3}(\d)\d{2}\s+[a-zA-Z0-9]{40}\s+([a-zA-Z0-9]{40})\s+(\w)$/o )
+                unless ( /^:\d{6}\s+([0-7]{6})\s+[a-f0-9]{40}\s+([a-f0-9]{40})\s+(\w)$/o )
                 {
                     die("Couldn't process git-diff-tree line : $_");
                 }
@@ -3313,11 +3951,7 @@ sub update
 
                 # $log->debug("File mode=$mode, hash=$hash, change=$change, name=$name");
 
-                my $git_perms = "";
-                $git_perms .= "r" if ( $mode & 4 );
-                $git_perms .= "w" if ( $mode & 2 );
-                $git_perms .= "x" if ( $mode & 1 );
-                $git_perms = "rw" if ( $git_perms eq "" );
+                my $dbMode = convertToDbMode($mode);
 
                 if ( $change eq "D" )
                 {
@@ -3327,11 +3961,11 @@ sub update
                         revision => $head->{$name}{revision} + 1,
                         filehash => "deleted",
                         commithash => $commit->{hash},
-                        modified => $commit->{date},
+                        modified => $cvsDate,
                         author => $commit->{author},
-                        mode => $git_perms,
+                        mode => $dbMode,
                     };
-                    $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
+                    $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $cvsDate, $commit->{author}, $dbMode);
                 }
                 elsif ( $change eq "M" || $change eq "T" )
                 {
@@ -3341,11 +3975,11 @@ sub update
                         revision => $head->{$name}{revision} + 1,
                         filehash => $hash,
                         commithash => $commit->{hash},
-                        modified => $commit->{date},
+                        modified => $cvsDate,
                         author => $commit->{author},
-                        mode => $git_perms,
+                        mode => $dbMode,
                     };
-                    $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
+                    $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $cvsDate, $commit->{author}, $dbMode);
                 }
                 elsif ( $change eq "A" )
                 {
@@ -3355,11 +3989,11 @@ sub update
                         revision => $head->{$name}{revision} ? $head->{$name}{revision}+1 : 1,
                         filehash => $hash,
                         commithash => $commit->{hash},
-                        modified => $commit->{date},
+                        modified => $cvsDate,
                         author => $commit->{author},
-                        mode => $git_perms,
+                        mode => $dbMode,
                     };
-                    $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
+                    $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $cvsDate, $commit->{author}, $dbMode);
                 }
                 else
                 {
@@ -3382,7 +4016,7 @@ sub update
                     die("Couldn't process git-ls-tree line : $_");
                 }
 
-                my ( $git_perms, $git_type, $git_hash, $git_filename ) = ( $1, $2, $3, $4 );
+                my ( $mode, $git_type, $git_hash, $git_filename ) = ( $1, $2, $3, $4 );
 
                 $seen_files->{$git_filename} = 1;
 
@@ -3392,18 +4026,10 @@ sub update
                     $head->{$git_filename}{mode}
                 );
 
-                if ( $git_perms =~ /^\d\d\d(\d)\d\d/o )
-                {
-                    $git_perms = "";
-                    $git_perms .= "r" if ( $1 & 4 );
-                    $git_perms .= "w" if ( $1 & 2 );
-                    $git_perms .= "x" if ( $1 & 1 );
-                } else {
-                    $git_perms = "rw";
-                }
+                my $dbMode = convertToDbMode($mode);
 
                 # unless the file exists with the same hash, we need to update it ...
-                unless ( defined($oldhash) and $oldhash eq $git_hash and defined($oldmode) and $oldmode eq $git_perms )
+                unless ( defined($oldhash) and $oldhash eq $git_hash and defined($oldmode) and $oldmode eq $dbMode )
                 {
                     my $newrevision = ( $oldrevision or 0 ) + 1;
 
@@ -3412,13 +4038,13 @@ sub update
                         revision => $newrevision,
                         filehash => $git_hash,
                         commithash => $commit->{hash},
-                        modified => $commit->{date},
+                        modified => $cvsDate,
                         author => $commit->{author},
-                        mode => $git_perms,
+                        mode => $dbMode,
                     };
 
 
-                    $self->insert_rev($git_filename, $newrevision, $git_hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
+                    $self->insert_rev($git_filename, $newrevision, $git_hash, $commit->{hash}, $cvsDate, $commit->{author}, $dbMode);
                 }
             }
             close FILELIST;
@@ -3431,10 +4057,10 @@ sub update
                     $head->{$file}{revision}++;
                     $head->{$file}{filehash} = "deleted";
                     $head->{$file}{commithash} = $commit->{hash};
-                    $head->{$file}{modified} = $commit->{date};
+                    $head->{$file}{modified} = $cvsDate;
                     $head->{$file}{author} = $commit->{author};
 
-                    $self->insert_rev($file, $head->{$file}{revision}, $head->{$file}{filehash}, $commit->{hash}, $commit->{date}, $commit->{author}, $head->{$file}{mode});
+                    $self->insert_rev($file, $head->{$file}{revision}, $head->{$file}{filehash}, $commit->{hash}, $cvsDate, $commit->{author}, $head->{$file}{mode});
                 }
             }
             # END : "Detect deleted files"
@@ -3465,13 +4091,94 @@ sub update
         );
     }
     # invalidate the gethead cache
-    $self->{gethead_cache} = undef;
+    $self->clearCommitRefCaches();
 
 
     # Ending exclusive lock here
     $self->{dbh}->commit() or die "Failed to commit changes to SQLite";
 }
 
+sub readCommits
+{
+    my $pipeHandle = shift;
+    my @commits;
+
+    my %commit = ();
+
+    while ( <$pipeHandle> )
+    {
+        chomp;
+        if (m/^commit\s+(.*)$/) {
+            # on ^commit lines put the just seen commit in the stack
+            # and prime things for the next one
+            if (keys %commit) {
+                my %copy = %commit;
+                unshift @commits, \%copy;
+                %commit = ();
+            }
+            my @parents = split(m/\s+/, $1);
+            $commit{hash} = shift @parents;
+            $commit{parents} = \@parents;
+        } elsif (m/^(\w+?):\s+(.*)$/ && !exists($commit{message})) {
+            # on rfc822-like lines seen before we see any message,
+            # lowercase the entry and put it in the hash as key-value
+            $commit{lc($1)} = $2;
+        } else {
+            # message lines - skip initial empty line
+            # and trim whitespace
+            if (!exists($commit{message}) && m/^\s*$/) {
+                # define it to mark the end of headers
+                $commit{message} = '';
+                next;
+            }
+            s/^\s+//; s/\s+$//; # trim ws
+            $commit{message} .= $_ . "\n";
+        }
+    }
+
+    unshift @commits, \%commit if ( keys %commit );
+
+    return @commits;
+}
+
+sub convertToCvsDate
+{
+    my $date = shift;
+    # Convert from: "git rev-list --pretty" formatted date
+    # Convert to: "the format specified by RFC822 as modified by RFC1123."
+    # Example: 26 May 1997 13:01:40 -0400
+    if( $date =~ /^\w+\s+(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+(\d+)\s+([+-]\d+)$/ )
+    {
+        $date = "$2 $1 $4 $3 $5";
+    }
+
+    return $date;
+}
+
+sub convertToDbMode
+{
+    my $mode = shift;
+
+    # NOTE: The CVS protocol uses a string similar "u=rw,g=rw,o=rw",
+    #  but the database "mode" column historically (and currently)
+    #  only stores the "rw" (for user) part of the string.
+    #    FUTURE: It might make more sense to persist the raw
+    #  octal mode (or perhaps the final full CVS form) instead of
+    #  this half-converted form, but it isn't currently worth the
+    #  backwards compatibility headaches.
+
+    $mode=~/^\d\d(\d)\d{3}$/;
+    my $userBits=$1;
+
+    my $dbMode = "";
+    $dbMode .= "r" if ( $userBits & 4 );
+    $dbMode .= "w" if ( $userBits & 2 );
+    $dbMode .= "x" if ( $userBits & 1 );
+    $dbMode = "rw" if ( $dbMode eq "" );
+
+    return $dbMode;
+}
+
 sub insert_rev
 {
     my $self = shift;
@@ -3586,6 +4293,169 @@ sub gethead
     return $tree;
 }
 
+=head2 getAnyHead
+
+Returns a reference to an array of getmeta structures, one
+per file in the specified tree hash.
+
+=cut
+
+sub getAnyHead
+{
+    my ($self,$hash) = @_;
+
+    if(!defined($hash))
+    {
+        return $self->gethead();
+    }
+
+    my @files;
+    {
+        open(my $filePipe, '-|', 'git', 'ls-tree', '-z', '-r', $hash)
+                or die("Cannot call git-ls-tree : $!");
+        local $/ = "\0";
+        @files=<$filePipe>;
+        close $filePipe;
+    }
+
+    my $tree=[];
+    my($line);
+    foreach $line (@files)
+    {
+        $line=~s/\0$//;
+        unless ( $line=~/^(\d+)\s+(\w+)\s+([a-zA-Z0-9]+)\t(.*)$/o )
+        {
+            die("Couldn't process git-ls-tree line : $_");
+        }
+
+        my($mode, $git_type, $git_hash, $git_filename) = ($1, $2, $3, $4);
+        push @$tree, $self->getMetaFromCommithash($git_filename,$hash);
+    }
+
+    return $tree;
+}
+
+=head2 getRevisionDirMap
+
+A "revision dir map" contains all the plain-file filenames associated
+with a particular revision (treeish), organized by directory:
+
+  $type = $out->{$dir}{$fullName}
+
+The type of each is "F" (for ordinary file) or "D" (for directory,
+for which the map $out->{$fullName} will also exist).
+
+=cut
+
+sub getRevisionDirMap
+{
+    my ($self,$ver)=@_;
+
+    if(!defined($self->{revisionDirMapCache}))
+    {
+        $self->{revisionDirMapCache}={};
+    }
+
+        # Get file list (previously cached results are dependent on HEAD,
+        # but are early in each case):
+    my $cacheKey;
+    my (@fileList);
+    if( !defined($ver) || $ver eq "" )
+    {
+        $cacheKey="";
+        if( defined($self->{revisionDirMapCache}{$cacheKey}) )
+        {
+            return $self->{revisionDirMapCache}{$cacheKey};
+        }
+
+        my @head = @{$self->gethead()};
+        foreach my $file ( @head )
+        {
+            next if ( $file->{filehash} eq "deleted" );
+
+            push @fileList,$file->{name};
+        }
+    }
+    else
+    {
+        my ($hash)=$self->lookupCommitRef($ver);
+        if( !defined($hash) )
+        {
+            return undef;
+        }
+
+        $cacheKey=$hash;
+        if( defined($self->{revisionDirMapCache}{$cacheKey}) )
+        {
+            return $self->{revisionDirMapCache}{$cacheKey};
+        }
+
+        open(my $filePipe, '-|', 'git', 'ls-tree', '-z', '-r', $hash)
+                or die("Cannot call git-ls-tree : $!");
+        local $/ = "\0";
+        while ( <$filePipe> )
+        {
+            chomp;
+            unless ( /^(\d+)\s+(\w+)\s+([a-zA-Z0-9]+)\t(.*)$/o )
+            {
+                die("Couldn't process git-ls-tree line : $_");
+            }
+
+            my($mode, $git_type, $git_hash, $git_filename) = ($1, $2, $3, $4);
+
+            push @fileList, $git_filename;
+        }
+        close $filePipe;
+    }
+
+        # Convert to normalized form:
+    my %revMap;
+    my $file;
+    foreach $file (@fileList)
+    {
+        my($dir) = ($file=~m%^(?:(.*)/)?([^/]*)$%);
+        $dir='' if(!defined($dir));
+
+            # parent directories:
+            # ... create empty dir maps for parent dirs:
+        my($td)=$dir;
+        while(!defined($revMap{$td}))
+        {
+            $revMap{$td}={};
+
+            my($tp)=($td=~m%^(?:(.*)/)?([^/]*)$%);
+            $tp='' if(!defined($tp));
+            $td=$tp;
+        }
+            # ... add children to parent maps (now that they exist):
+        $td=$dir;
+        while($td ne "")
+        {
+            my($tp)=($td=~m%^(?:(.*)/)?([^/]*)$%);
+            $tp='' if(!defined($tp));
+
+            if(defined($revMap{$tp}{$td}))
+            {
+                if($revMap{$tp}{$td} ne 'D')
+                {
+                    die "Weird file/directory inconsistency in $cacheKey";
+                }
+                last;   # loop exit
+            }
+            $revMap{$tp}{$td}='D';
+
+            $td=$tp;
+        }
+
+            # file
+        $revMap{$dir}{$file}='F';
+    }
+
+        # Save in cache:
+    $self->{revisionDirMapCache}{$cacheKey}=\%revMap;
+    return $self->{revisionDirMapCache}{$cacheKey};
+}
+
 =head2 getlog
 
 See also gethistorydense().
@@ -3646,6 +4516,19 @@ sub getlog
 This function takes a filename (with path) argument and returns a hashref of
 metadata for that file.
 
+There are several ways $revision can be specified:
+
+   - A reference to hash that contains a "tag" that is the
+     actual revision (one of the below).  TODO: Also allow it to
+     specify a "date" in the hash.
+   - undef, to refer to the latest version on the main branch.
+   - Full CVS client revision number (mapped to integer in DB, without the
+     "1." prefix),
+   - Complex CVS-compatible "special" revision number for
+     non-linear history (see comment below)
+   - git commit sha1 hash
+   - branch or tag name
+
 =cut
 
 sub getmeta
@@ -3656,23 +4539,144 @@ sub getmeta
     my $tablename_rev = $self->tablename("revision");
     my $tablename_head = $self->tablename("head");
 
-    my $db_query;
-    if ( defined($revision) and $revision =~ /^1\.(\d+)$/ )
+    if ( ref($revision) eq "HASH" )
     {
-        my ($intRev) = $1;
-        $db_query = $self->{dbh}->prepare_cached("SELECT * FROM $tablename_rev WHERE name=? AND revision=?",{},1);
-        $db_query->execute($filename, $intRev);
+        $revision = $revision->{tag};
     }
-    elsif ( defined($revision) and $revision =~ /^[a-zA-Z0-9]{40}$/ )
+
+    # Overview of CVS revision numbers:
+    #
+    # General CVS numbering scheme:
+    #   - Basic mainline branch numbers: "1.1", "1.2", "1.3", etc.
+    #   - Result of "cvs checkin -r" (possible, but not really
+    #     recommended): "2.1", "2.2", etc
+    #   - Branch tag: "1.2.0.n", where "1.2" is revision it was branched
+    #     from, "0" is a magic placeholder that identifies it as a
+    #     branch tag instead of a version tag, and n is 2 times the
+    #     branch number off of "1.2", starting with "2".
+    #   - Version on a branch: "1.2.n.x", where "1.2" is branch-from, "n"
+    #     is branch number off of "1.2" (like n above), and "x" is
+    #     the version number on the branch.
+    #   - Branches can branch off of branches: "1.3.2.7.4.1" (even number
+    #     of components).
+    #   - Odd "n"s are used by "vendor branches" that result
+    #     from "cvs import".  Vendor branches have additional
+    #     strangeness in the sense that the main rcs "head" of the main
+    #     branch will (temporarily until first normal commit) point
+    #     to the version on the vendor branch, rather than the actual
+    #     main branch.  (FUTURE: This may provide an opportunity
+    #     to use "strange" revision numbers for fast-forward-merged
+    #     branch tip when CVS client is asking for the main branch.)
+    #
+    # git-cvsserver CVS-compatible special numbering schemes:
+    #   - Currently git-cvsserver only tries to be identical to CVS for
+    #     simple "1.x" numbers on the "main" branch (as identified
+    #     by the module name that was originally cvs checkout'ed).
+    #   - The database only stores the "x" part, for historical reasons.
+    #     But most of the rest of the cvsserver preserves
+    #     and thinks using the full revision number.
+    #   - To handle non-linear history, it uses a version of the form
+    #     "2.1.1.2000.b.b.b."..., where the 2.1.1.2000 is to help uniquely
+    #     identify this as a special revision number, and there are
+    #     20 b's that together encode the sha1 git commit from which
+    #     this version of this file originated.  Each b is
+    #     the numerical value of the corresponding byte plus
+    #     100.
+    #      - "plus 100" avoids "0"s, and also reduces the
+    #        likelyhood of a collision in the case that someone someday
+    #        writes an import tool that tries to preserve original
+    #        CVS revision numbers, and the original CVS data had done
+    #        lots of branches off of branches and other strangeness to
+    #        end up with a real version number that just happens to look
+    #        like this special revision number form.  Also, if needed
+    #        there are several ways to extend/identify alternative encodings
+    #        within the "2.1.1.2000" part if necessary.
+    #      - Unlike real CVS revisions, you can't really reconstruct what
+    #        relation a revision of this form has to other revisions.
+    #   - FUTURE: TODO: Rework database somehow to make up and remember
+    #     fully-CVS-compatible branches and branch version numbers.
+
+    my $meta;
+    if ( defined($revision) )
     {
-        $db_query = $self->{dbh}->prepare_cached("SELECT * FROM $tablename_rev WHERE name=? AND commithash=?",{},1);
-        $db_query->execute($filename, $revision);
-    } else {
-        $db_query = $self->{dbh}->prepare_cached("SELECT * FROM $tablename_head WHERE name=?",{},1);
+        if ( $revision =~ /^1\.(\d+)$/ )
+        {
+            my ($intRev) = $1;
+            my $db_query;
+            $db_query = $self->{dbh}->prepare_cached(
+                "SELECT * FROM $tablename_rev WHERE name=? AND revision=?",
+                {},1);
+            $db_query->execute($filename, $intRev);
+            $meta = $db_query->fetchrow_hashref;
+        }
+        elsif ( $revision =~ /^2\.1\.1\.2000(\.[1-3][0-9][0-9]){20}$/ )
+        {
+            my ($commitHash)=($revision=~/^2\.1\.1\.2000(.*)$/);
+            $commitHash=~s/\.([0-9]+)/sprintf("%02x",$1-100)/eg;
+            if($commitHash=~/^[0-9a-f]{40}$/)
+            {
+                return $self->getMetaFromCommithash($filename,$commitHash);
+            }
+
+            # error recovery: fall back on head version below
+            print "E Failed to find $filename version=$revision or commit=$commitHash\n";
+            $log->warning("failed get $revision with commithash=$commitHash");
+            undef $revision;
+        }
+        elsif ( $revision =~ /^[0-9a-f]{40}$/ )
+        {
+            # Try DB first.  This is mostly only useful for req_annotate(),
+            # which only calls this for stuff that should already be in
+            # the DB.  It is fairly likely to be a waste of time
+            # in most other cases [unless the file happened to be
+            # modified in $revision specifically], but
+            # it is probably in the noise compared to how long
+            # getMetaFromCommithash() will take.
+            my $db_query;
+            $db_query = $self->{dbh}->prepare_cached(
+                "SELECT * FROM $tablename_rev WHERE name=? AND commithash=?",
+                {},1);
+            $db_query->execute($filename, $revision);
+            $meta = $db_query->fetchrow_hashref;
+
+            if(! $meta)
+            {
+                my($revCommit)=$self->lookupCommitRef($revision);
+                if($revCommit=~/^[0-9a-f]{40}$/)
+                {
+                    return $self->getMetaFromCommithash($filename,$revCommit);
+                }
+
+                # error recovery: nothing found:
+                print "E Failed to find $filename version=$revision\n";
+                $log->warning("failed get $revision");
+                return $meta;
+            }
+        }
+        else
+        {
+            my($revCommit)=$self->lookupCommitRef($revision);
+            if($revCommit=~/^[0-9a-f]{40}$/)
+            {
+                return $self->getMetaFromCommithash($filename,$revCommit);
+            }
+
+            # error recovery: fall back on head version below
+            print "E Failed to find $filename version=$revision\n";
+            $log->warning("failed get $revision");
+            undef $revision;  # Allow fallback
+        }
+    }
+
+    if(!defined($revision))
+    {
+        my $db_query;
+        $db_query = $self->{dbh}->prepare_cached(
+                "SELECT * FROM $tablename_head WHERE name=?",{},1);
         $db_query->execute($filename);
+        $meta = $db_query->fetchrow_hashref;
     }
 
-    my $meta = $db_query->fetchrow_hashref;
     if($meta)
     {
         $meta->{revision} = "1.$meta->{revision}";
@@ -3680,6 +4684,204 @@ sub getmeta
     return $meta;
 }
 
+sub getMetaFromCommithash
+{
+    my $self = shift;
+    my $filename = shift;
+    my $revCommit = shift;
+
+    # NOTE: This function doesn't scale well (lots of forks), especially
+    #   if you have many files that have not been modified for many commits
+    #   (each git-rev-parse redoes a lot of work for each file
+    #   that theoretically could be done in parallel by smarter
+    #   graph traversal).
+    #
+    # TODO: Possible optimization strategies:
+    #   - Solve the issue of assigning and remembering "real" CVS
+    #     revision numbers for branches, and ensure the
+    #     data structure can do this efficiently.  Perhaps something
+    #     similar to "git notes", and carefully structured to take
+    #     advantage same-sha1-is-same-contents, to roll the same
+    #     unmodified subdirectory data onto multiple commits?
+    #   - Write and use a C tool that is like git-blame, but
+    #     operates on multiple files with file granularity, instead
+    #     of one file with line granularity.  Cache
+    #     most-recently-modified in $self->{commitRefCache}{$revCommit}.
+    #     Try to be intelligent about how many files we do with
+    #     one fork (perhaps one directory at a time, without recursion,
+    #     and/or include directory as one line item, recurse from here
+    #     instead of in C tool?).
+    #   - Perhaps we could ask the DB for (filename,fileHash),
+    #     and just guess that it is correct (that the file hadn't
+    #     changed between $revCommit and the found commit, then
+    #     changed back, confusing anything trying to interpret
+    #     history).  Probably need to add another index to revisions
+    #     DB table for this.
+    #   - NOTE: Trying to store all (commit,file) keys in DB [to
+    #     find "lastModfiedCommit] (instead of
+    #     just files that changed in each commit as we do now) is
+    #     probably not practical from a disk space perspective.
+
+        # Does the file exist in $revCommit?
+    # TODO: Include file hash in dirmap cache.
+    my($dirMap)=$self->getRevisionDirMap($revCommit);
+    my($dir,$file)=($filename=~m%^(?:(.*)/)?([^/]*$)%);
+    if(!defined($dir))
+    {
+        $dir="";
+    }
+    if( !defined($dirMap->{$dir}) ||
+        !defined($dirMap->{$dir}{$filename}) )
+    {
+        my($fileHash)="deleted";
+
+        my($retVal)={};
+        $retVal->{name}=$filename;
+        $retVal->{filehash}=$fileHash;
+
+            # not needed and difficult to compute:
+        $retVal->{revision}="0";  # $revision;
+        $retVal->{commithash}=$revCommit;
+        #$retVal->{author}=$commit->{author};
+        #$retVal->{modified}=convertToCvsDate($commit->{date});
+        #$retVal->{mode}=convertToDbMode($mode);
+
+        return $retVal;
+    }
+
+    my($fileHash)=safe_pipe_capture("git","rev-parse","$revCommit:$filename");
+    chomp $fileHash;
+    if(!($fileHash=~/^[0-9a-f]{40}$/))
+    {
+        die "Invalid fileHash '$fileHash' looking up"
+                    ." '$revCommit:$filename'\n";
+    }
+
+    # information about most recent commit to modify $filename:
+    open(my $gitLogPipe, '-|', 'git', 'rev-list',
+         '--max-count=1', '--pretty', '--parents',
+         $revCommit, '--', $filename)
+                or die "Cannot call git-rev-list: $!";
+    my @commits=readCommits($gitLogPipe);
+    close $gitLogPipe;
+    if(scalar(@commits)!=1)
+    {
+        die "Can't find most recent commit changing $filename\n";
+    }
+    my($commit)=$commits[0];
+    if( !defined($commit) || !defined($commit->{hash}) )
+    {
+        return undef;
+    }
+
+    # does this (commit,file) have a real assigned CVS revision number?
+    my $tablename_rev = $self->tablename("revision");
+    my $db_query;
+    $db_query = $self->{dbh}->prepare_cached(
+        "SELECT * FROM $tablename_rev WHERE name=? AND commithash=?",
+        {},1);
+    $db_query->execute($filename, $commit->{hash});
+    my($meta)=$db_query->fetchrow_hashref;
+    if($meta)
+    {
+        $meta->{revision} = "1.$meta->{revision}";
+        return $meta;
+    }
+
+    # fall back on special revision number
+    my($revision)=$commit->{hash};
+    $revision=~s/(..)/'.' . (hex($1)+100)/eg;
+    $revision="2.1.1.2000$revision";
+
+    # meta data about $filename:
+    open(my $filePipe, '-|', 'git', 'ls-tree', '-z',
+                $commit->{hash}, '--', $filename)
+            or die("Cannot call git-ls-tree : $!");
+    local $/ = "\0";
+    my $line;
+    $line=<$filePipe>;
+    if(defined(<$filePipe>))
+    {
+        die "Expected only a single file for git-ls-tree $filename\n";
+    }
+    close $filePipe;
+
+    chomp $line;
+    unless ( $line=~m/^(\d+)\s+(\w+)\s+([a-zA-Z0-9]+)\t(.*)$/o )
+    {
+        die("Couldn't process git-ls-tree line : $line\n");
+    }
+    my ( $mode, $git_type, $git_hash, $git_filename ) = ( $1, $2, $3, $4 );
+
+    # save result:
+    my($retVal)={};
+    $retVal->{name}=$filename;
+    $retVal->{revision}=$revision;
+    $retVal->{filehash}=$fileHash;
+    $retVal->{commithash}=$revCommit;
+    $retVal->{author}=$commit->{author};
+    $retVal->{modified}=convertToCvsDate($commit->{date});
+    $retVal->{mode}=convertToDbMode($mode);
+
+    return $retVal;
+}
+
+=head2 lookupCommitRef
+
+Convert tag/branch/abbreviation/etc into a commit sha1 hash.  Caches
+the result so looking it up again is fast.
+
+=cut
+
+sub lookupCommitRef
+{
+    my $self = shift;
+    my $ref = shift;
+
+    my $commitHash = $self->{commitRefCache}{$ref};
+    if(defined($commitHash))
+    {
+        return $commitHash;
+    }
+
+    $commitHash=safe_pipe_capture("git","rev-parse","--verify","--quiet",
+                                  $self->unescapeRefName($ref));
+    $commitHash=~s/\s*$//;
+    if(!($commitHash=~/^[0-9a-f]{40}$/))
+    {
+        $commitHash=undef;
+    }
+
+    if( defined($commitHash) )
+    {
+        my $type=safe_pipe_capture("git","cat-file","-t",$commitHash);
+        if( ! ($type=~/^commit\s*$/ ) )
+        {
+            $commitHash=undef;
+        }
+    }
+    if(defined($commitHash))
+    {
+        $self->{commitRefCache}{$ref}=$commitHash;
+    }
+    return $commitHash;
+}
+
+=head2 clearCommitRefCaches
+
+Clears cached commit cache (sha1's for various tags/abbeviations/etc),
+and related caches.
+
+=cut
+
+sub clearCommitRefCaches
+{
+    my $self = shift;
+    $self->{commitRefCache} = {};
+    $self->{revisionDirMapCache} = undef;
+    $self->{gethead_cache} = undef;
+}
+
 =head2 commitmessage
 
 this function takes a commithash and returns the commit message for that commit
@@ -3745,6 +4947,97 @@ sub gethistorydense
     return $result;
 }
 
+=head2 escapeRefName
+
+Apply an escape mechanism to compensate for characters that
+git ref names can have that CVS tags can not.
+
+=cut
+sub escapeRefName
+{
+    my($self,$refName)=@_;
+
+    # CVS officially only allows [-_A-Za-z0-9] in tag names (or in
+    # many contexts it can also be a CVS revision number).
+    #
+    # Git tags commonly use '/' and '.' as well, but also handle
+    # anything else just in case:
+    #
+    #   = "_-s-"  For '/'.
+    #   = "_-p-"  For '.'.
+    #   = "_-u-"  For underscore, in case someone wants a literal "_-" in
+    #     a tag name.
+    #   = "_-xx-" Where "xx" is the hexadecimal representation of the
+    #     desired ASCII character byte. (for anything else)
+
+    if(! $refName=~/^[1-9][0-9]*(\.[1-9][0-9]*)*$/)
+    {
+        $refName=~s/_-/_-u--/g;
+        $refName=~s/\./_-p-/g;
+        $refName=~s%/%_-s-%g;
+        $refName=~s/[^-_a-zA-Z0-9]/sprintf("_-%02x-",$1)/eg;
+    }
+}
+
+=head2 unescapeRefName
+
+Undo an escape mechanism to compensate for characters that
+git ref names can have that CVS tags can not.
+
+=cut
+sub unescapeRefName
+{
+    my($self,$refName)=@_;
+
+    # see escapeRefName() for description of escape mechanism.
+
+    $refName=~s/_-([spu]|[0-9a-f][0-9a-f])-/unescapeRefNameChar($1)/eg;
+
+    # allowed tag names
+    # TODO: Perhaps use git check-ref-format, with an in-process cache of
+    #  validated names?
+    if( !( $refName=~m%^[^-][-a-zA-Z0-9_/.]*$% ) ||
+        ( $refName=~m%[/.]$% ) ||
+        ( $refName=~/\.lock$/ ) ||
+        ( $refName=~m%\.\.|/\.|[[\\:?*~]|\@\{% ) )  # matching }
+    {
+        # Error:
+        $log->warn("illegal refName: $refName");
+        $refName=undef;
+    }
+    return $refName;
+}
+
+sub unescapeRefNameChar
+{
+    my($char)=@_;
+
+    if($char eq "s")
+    {
+        $char="/";
+    }
+    elsif($char eq "p")
+    {
+        $char=".";
+    }
+    elsif($char eq "u")
+    {
+        $char="_";
+    }
+    elsif($char=~/^[0-9a-f][0-9a-f]$/)
+    {
+        $char=chr(hex($char));
+    }
+    else
+    {
+        # Error case: Maybe it has come straight from user, and
+        # wasn't supposed to be escaped?  Restore it the way we got it:
+        $char="_-$char-";
+    }
+
+    return $char;
+}
+
 =head2 in_array()
 
 from Array::PAT - mimics the in_array() function
index 551aec9417401dcd7ef526dd6c9b554e5194f861..2da564995dd82ac3fa96d8d7ad6273152f6f161d 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -8,7 +8,13 @@
 # License: MIT <http://www.opensource.org/licenses/mit-license.php>
 #
 
-import optparse, sys, os, marshal, subprocess, shelve
+import sys
+if sys.hexversion < 0x02040000:
+    # The limiter is the subprocess module
+    sys.stderr.write("git-p4: requires Python 2.4 or later.\n")
+    sys.exit(1)
+
+import optparse, os, marshal, subprocess, shelve
 import tempfile, getopt, os.path, time, platform
 import re, shutil
 
@@ -547,29 +553,49 @@ def gitConfigList(key):
         _gitConfig[key] = read_pipe("git config --get-all %s" % key, ignore_error=True).strip().split(os.linesep)
     return _gitConfig[key]
 
-def p4BranchesInGit(branchesAreInRemotes = True):
+def p4BranchesInGit(branchesAreInRemotes=True):
+    """Find all the branches whose names start with "p4/", looking
+       in remotes or heads as specified by the argument.  Return
+       a dictionary of { branch: revision } for each one found.
+       The branch names are the short names, without any
+       "p4/" prefix."""
+
     branches = {}
 
     cmdline = "git rev-parse --symbolic "
     if branchesAreInRemotes:
-        cmdline += " --remotes"
+        cmdline += "--remotes"
     else:
-        cmdline += " --branches"
+        cmdline += "--branches"
 
     for line in read_pipe_lines(cmdline):
         line = line.strip()
 
-        ## only import to p4/
-        if not line.startswith('p4/') or line == "p4/HEAD":
+        # only import to p4/
+        if not line.startswith('p4/'):
+            continue
+        # special symbolic ref to p4/master
+        if line == "p4/HEAD":
             continue
-        branch = line
 
-        # strip off p4
-        branch = re.sub ("^p4/", "", line)
+        # strip off p4/ prefix
+        branch = line[len("p4/"):]
 
         branches[branch] = parseRevision(line)
+
     return branches
 
+def branch_exists(branch):
+    """Make sure that the given ref name really exists."""
+
+    cmd = [ "git", "rev-parse", "--symbolic", "--verify", branch ]
+    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    out, _ = p.communicate()
+    if p.returncode:
+        return False
+    # expect exactly one line of output: the branch name
+    return out.rstrip() == branch
+
 def findUpstreamBranchPoint(head = "HEAD"):
     branches = p4BranchesInGit()
     # map from depot-path to branch name
@@ -901,7 +927,8 @@ class P4Submit(Command, P4UserMap):
                 optparse.make_option("--dry-run", "-n", dest="dry_run", action="store_true"),
                 optparse.make_option("--prepare-p4-only", dest="prepare_p4_only", action="store_true"),
                 optparse.make_option("--conflict", dest="conflict_behavior",
-                                     choices=self.conflict_behavior_choices)
+                                     choices=self.conflict_behavior_choices),
+                optparse.make_option("--branch", dest="branch"),
         ]
         self.description = "Submit changes from git to the perforce depot."
         self.usage += " [name of git branch to submit into perforce depot]"
@@ -914,6 +941,7 @@ class P4Submit(Command, P4UserMap):
         self.isWindows = (platform.system() == "Windows")
         self.exportLabels = False
         self.p4HasMoveCommand = p4_has_move_command()
+        self.branch = None
 
     def check(self):
         if len(p4CmdList("opened ...")) > 0:
@@ -1650,6 +1678,8 @@ class P4Submit(Command, P4UserMap):
             print "All commits applied!"
 
             sync = P4Sync()
+            if self.branch:
+                sync.branch = self.branch
             sync.run([])
 
             rebase = P4Rebase()
@@ -2503,13 +2533,6 @@ class P4Sync(Command, P4UserMap):
                 branch = branch[len(self.projectName):]
             self.knownBranches[branch] = branch
 
-    def listExistingP4GitBranches(self):
-        # branches holds mapping from name to commit
-        branches = p4BranchesInGit(self.importIntoRemotes)
-        self.p4BranchesInGit = branches.keys()
-        for branch in branches.keys():
-            self.initialParents[self.refPrefix + branch] = branches[branch]
-
     def updateOptionDict(self, d):
         option_keys = {}
         if self.keepRepoPath:
@@ -2681,6 +2704,7 @@ class P4Sync(Command, P4UserMap):
                     files = self.extractFilesFromCommit(description)
                     self.commit(description, files, self.branch,
                                 self.initialParent)
+                    # only needed once, to connect to the previous commit
                     self.initialParent = ""
             except IOError:
                 print self.gitError.read()
@@ -2746,34 +2770,31 @@ class P4Sync(Command, P4UserMap):
     def run(self, args):
         self.depotPaths = []
         self.changeRange = ""
-        self.initialParent = ""
         self.previousDepotPaths = []
+        self.hasOrigin = False
 
         # map from branch depot path to parent branch
         self.knownBranches = {}
         self.initialParents = {}
-        self.hasOrigin = originP4BranchesExist()
-        if not self.syncWithOrigin:
-            self.hasOrigin = False
 
         if self.importIntoRemotes:
             self.refPrefix = "refs/remotes/p4/"
         else:
             self.refPrefix = "refs/heads/p4/"
 
-        if self.syncWithOrigin and self.hasOrigin:
-            if not self.silent:
-                print "Syncing with origin first by calling git fetch origin"
-            system("git fetch origin")
+        if self.syncWithOrigin:
+            self.hasOrigin = originP4BranchesExist()
+            if self.hasOrigin:
+                if not self.silent:
+                    print 'Syncing with origin first, using "git fetch origin"'
+                system("git fetch origin")
 
+        branch_arg_given = bool(self.branch)
         if len(self.branch) == 0:
             self.branch = self.refPrefix + "master"
             if gitBranchExists("refs/heads/p4") and self.importIntoRemotes:
                 system("git update-ref %s refs/heads/p4" % self.branch)
-                system("git branch -D p4");
-            # create it /after/ importing, when master exists
-            if not gitBranchExists(self.refPrefix + "HEAD") and self.importIntoRemotes and gitBranchExists(self.branch):
-                system("git symbolic-ref %sHEAD %s" % (self.refPrefix, self.branch))
+                system("git branch -D p4")
 
         # accept either the command-line option, or the configuration variable
         if self.useClientSpec:
@@ -2790,12 +2811,25 @@ class P4Sync(Command, P4UserMap):
         if args == []:
             if self.hasOrigin:
                 createOrUpdateBranchesFromOrigin(self.refPrefix, self.silent)
-            self.listExistingP4GitBranches()
+
+            # branches holds mapping from branch name to sha1
+            branches = p4BranchesInGit(self.importIntoRemotes)
+
+            # restrict to just this one, disabling detect-branches
+            if branch_arg_given:
+                short = self.branch.split("/")[-1]
+                if short in branches:
+                    self.p4BranchesInGit = [ short ]
+            else:
+                self.p4BranchesInGit = branches.keys()
 
             if len(self.p4BranchesInGit) > 1:
                 if not self.silent:
                     print "Importing from/into multiple branches"
                 self.detectBranches = True
+                for branch in branches.keys():
+                    self.initialParents[self.refPrefix + branch] = \
+                        branches[branch]
 
             if self.verbose:
                 print "branches: %s" % self.p4BranchesInGit
@@ -2832,13 +2866,21 @@ class P4Sync(Command, P4UserMap):
             if p4Change > 0:
                 self.depotPaths = sorted(self.previousDepotPaths)
                 self.changeRange = "@%s,#head" % p4Change
-                if not self.detectBranches:
-                    self.initialParent = parseRevision(self.branch)
                 if not self.silent and not self.detectBranches:
                     print "Performing incremental import into %s git branch" % self.branch
 
+        # accept multiple ref name abbreviations:
+        #    refs/foo/bar/branch -> use it exactly
+        #    p4/branch -> prepend refs/remotes/ or refs/heads/
+        #    branch -> prepend refs/remotes/p4/ or refs/heads/p4/
         if not self.branch.startswith("refs/"):
-            self.branch = "refs/heads/" + self.branch
+            if self.importIntoRemotes:
+                prepend = "refs/remotes/"
+            else:
+                prepend = "refs/heads/"
+            if not self.branch.startswith("p4/"):
+                prepend += "p4/"
+            self.branch = prepend + self.branch
 
         if len(args) == 0 and self.depotPaths:
             if not self.silent:
@@ -2949,8 +2991,21 @@ class P4Sync(Command, P4UserMap):
             else:
                 # catch "git p4 sync" with no new branches, in a repo that
                 # does not have any existing p4 branches
-                if len(args) == 0 and not self.p4BranchesInGit:
-                    die("No remote p4 branches.  Perhaps you never did \"git p4 clone\" in here.");
+                if len(args) == 0:
+                    if not self.p4BranchesInGit:
+                        die("No remote p4 branches.  Perhaps you never did \"git p4 clone\" in here.")
+
+                    # The default branch is master, unless --branch is used to
+                    # specify something else.  Make sure it exists, or complain
+                    # nicely about how to use --branch.
+                    if not self.detectBranches:
+                        if not branch_exists(self.branch):
+                            if branch_arg_given:
+                                die("Error: branch %s does not exist." % self.branch)
+                            else:
+                                die("Error: no branch %s; perhaps specify one with --branch." %
+                                    self.branch)
+
                 if self.verbose:
                     print "Getting p4 changes for %s...%s" % (', '.join(self.depotPaths),
                                                               self.changeRange)
@@ -2968,6 +3023,14 @@ class P4Sync(Command, P4UserMap):
 
                 self.updatedBranches = set()
 
+                if not self.detectBranches:
+                    if args:
+                        # start a new branch
+                        self.initialParent = ""
+                    else:
+                        # build on a previous revision
+                        self.initialParent = parseRevision(self.branch)
+
                 self.importChanges(changes)
 
                 if not self.silent:
@@ -3000,6 +3063,13 @@ class P4Sync(Command, P4UserMap):
                 read_pipe("git update-ref -d %s" % branch)
             os.rmdir(os.path.join(os.environ.get("GIT_DIR", ".git"), self.tempBranchLocation))
 
+        # Create a symbolic ref p4/HEAD pointing to p4/<branch> to allow
+        # a convenient shortcut refname "p4".
+        if self.importIntoRemotes:
+            head_ref = self.refPrefix + "HEAD"
+            if not gitBranchExists(head_ref) and gitBranchExists(self.branch):
+                system(["git", "symbolic-ref", head_ref, self.branch])
+
         return True
 
 class P4Rebase(Command):
@@ -3107,17 +3177,15 @@ class P4Clone(P4Sync):
 
         if not P4Sync.run(self, depotPaths):
             return False
-        if self.branch != "master":
-            if self.importIntoRemotes:
-                masterbranch = "refs/remotes/p4/master"
-            else:
-                masterbranch = "refs/heads/p4/master"
-            if gitBranchExists(masterbranch):
-                system("git branch master %s" % masterbranch)
-                if not self.cloneBare:
-                    system("git checkout -f")
-            else:
-                print "Could not detect main branch. No checkout/master branch created."
+
+        # create a master branch and check out a work tree
+        if gitBranchExists(self.branch):
+            system([ "git", "branch", "master", self.branch ])
+            if not self.cloneBare:
+                system([ "git", "checkout", "-f" ])
+        else:
+            print 'Not checking out any branch, use ' \
+                  '"git checkout -q -b master <branch>"'
 
         # auto-set this variable if invoked with --use-client-spec
         if self.useClientSpec_from_options:
index 392ebc9790c88f9857fc4e943d1fe6351e953c7d..97f31dc7af43bafe36d3222ba2f78da861a4e620 100644 (file)
@@ -18,6 +18,7 @@ esac
 
 test -n "$rebase_root" && root_flag=--root
 
+ret=0
 if test -n "$keep_empty"
 then
        # we have to do this the hard way.  git format-patch completely squashes
@@ -25,13 +26,49 @@ then
        # itself well to recording empty patches.  fortunately, cherry-pick
        # makes this easy
        git cherry-pick --allow-empty "$revisions"
+       ret=$?
 else
+       rm -f "$GIT_DIR/rebased-patches"
+
        git format-patch -k --stdout --full-index --ignore-if-in-upstream \
                --src-prefix=a/ --dst-prefix=b/ \
-               --no-renames $root_flag "$revisions" |
-       git am $git_am_opt --rebasing --resolvemsg="$resolvemsg"
-fi && move_to_original_branch
+               --no-renames $root_flag "$revisions" >"$GIT_DIR/rebased-patches"
+       ret=$?
+
+       if test 0 != $ret
+       then
+               rm -f "$GIT_DIR/rebased-patches"
+               case "$head_name" in
+               refs/heads/*)
+                       git checkout -q "$head_name"
+                       ;;
+               *)
+                       git checkout -q "$orig_head"
+                       ;;
+               esac
+
+               cat >&2 <<-EOF
+
+               git encountered an error while preparing the patches to replay
+               these revisions:
+
+                   $revisions
+
+               As a result, git cannot rebase them.
+               EOF
+               exit $?
+       fi
+
+       git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" <"$GIT_DIR/rebased-patches"
+       ret=$?
+
+       rm -f "$GIT_DIR/rebased-patches"
+fi
+
+if test 0 != $ret
+then
+       test -d "$state_dir" && write_basic_state
+       exit $ret
+fi
 
-ret=$?
-test 0 != $ret -a -d "$state_dir" && write_basic_state
-exit $ret
+move_to_original_branch
index 44901d53c43d972e03a71bfbe0b769f2e8f22d7b..8ed7fccc18507b6f3e2508bb117ce056a764de77 100644 (file)
@@ -190,6 +190,11 @@ is_empty_commit() {
        test "$tree" = "$ptree"
 }
 
+is_merge_commit()
+{
+       git rev-parse --verify --quiet "$1"^2 >/dev/null 2>&1
+}
+
 # Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
 # GIT_AUTHOR_DATE exported from the current environment.
 do_with_author () {
@@ -874,7 +879,7 @@ git rev-list $merges_option --pretty=oneline --abbrev-commit \
 while read -r shortsha1 rest
 do
 
-       if test -z "$keep_empty" && is_empty_commit $shortsha1
+       if test -z "$keep_empty" && is_empty_commit $shortsha1 && ! is_merge_commit $shortsha1
        then
                comment_out="# "
        else
diff --git a/git-remote-testgit b/git-remote-testgit
new file mode 100755 (executable)
index 0000000..b395c8d
--- /dev/null
@@ -0,0 +1,90 @@
+#!/usr/bin/env bash
+# Copyright (c) 2012 Felipe Contreras
+
+alias=$1
+url=$2
+
+dir="$GIT_DIR/testgit/$alias"
+prefix="refs/testgit/$alias"
+
+default_refspec="refs/heads/*:${prefix}/heads/*"
+
+refspec="${GIT_REMOTE_TESTGIT_REFSPEC-$default_refspec}"
+
+test -z "$refspec" && prefix="refs"
+
+export GIT_DIR="$url/.git"
+
+mkdir -p "$dir"
+
+if test -z "$GIT_REMOTE_TESTGIT_NO_MARKS"
+then
+       gitmarks="$dir/git.marks"
+       testgitmarks="$dir/testgit.marks"
+       test -e "$gitmarks" || >"$gitmarks"
+       test -e "$testgitmarks" || >"$testgitmarks"
+       testgitmarks_args=( "--"{import,export}"-marks=$testgitmarks" )
+fi
+
+while read line
+do
+       case $line in
+       capabilities)
+               echo 'import'
+               echo 'export'
+               test -n "$refspec" && echo "refspec $refspec"
+               if test -n "$gitmarks"
+               then
+                       echo "*import-marks $gitmarks"
+                       echo "*export-marks $gitmarks"
+               fi
+               echo
+               ;;
+       list)
+               git for-each-ref --format='? %(refname)' 'refs/heads/'
+               head=$(git symbolic-ref HEAD)
+               echo "@$head HEAD"
+               echo
+               ;;
+       import*)
+               # read all import lines
+               while true
+               do
+                       ref="${line#* }"
+                       refs="$refs $ref"
+                       read line
+                       test "${line%% *}" != "import" && break
+               done
+
+               if test -n "$gitmarks"
+               then
+                       echo "feature import-marks=$gitmarks"
+                       echo "feature export-marks=$gitmarks"
+               fi
+               echo "feature done"
+               git fast-export "${testgitmarks_args[@]}" $refs |
+               sed -e "s#refs/heads/#${prefix}/heads/#g"
+               echo "done"
+               ;;
+       export)
+               before=$(git for-each-ref --format='%(refname) %(objectname)')
+
+               git fast-import "${testgitmarks_args[@]}" --quiet
+
+               after=$(git for-each-ref --format='%(refname) %(objectname)')
+
+               # figure out which refs were updated
+               join -e 0 -o '0 1.2 2.2' -a 2 <(echo "$before") <(echo "$after") |
+               while read ref a b
+               do
+                       test $a == $b && continue
+                       echo "ok $ref"
+               done
+
+               echo
+               ;;
+       '')
+               exit
+               ;;
+       esac
+done
similarity index 93%
rename from git-remote-testgit.py
rename to git-remote-testpy.py
index 5f3ebd244dac3ca28298ece9df914102b8155660..d94a66a87094436efcb6cf8dd0171b0683f0376c 100644 (file)
@@ -31,6 +31,11 @@ from git_remote_helpers.git.exporter import GitExporter
 from git_remote_helpers.git.importer import GitImporter
 from git_remote_helpers.git.non_local import NonLocalGit
 
+if sys.hexversion < 0x01050200:
+    # os.makedirs() is the limiter
+    sys.stderr.write("git-remote-testgit: requires Python 1.5.2 or later.\n")
+    sys.exit(1)
+
 def get_repo(alias, url):
     """Returns a git repository object initialized for usage.
     """
@@ -91,7 +96,7 @@ def do_capabilities(repo, args):
     if not os.path.exists(dirname):
         os.makedirs(dirname)
 
-    path = os.path.join(dirname, 'testgit.marks')
+    path = os.path.join(dirname, 'git.marks')
 
     print "*export-marks %s" % path
     if os.path.exists(path):
@@ -159,6 +164,11 @@ def do_import(repo, args):
         ref = line[7:].strip()
         refs.append(ref)
 
+    print "feature done"
+
+    if os.environ.get("GIT_REMOTE_TESTGIT_FAILURE"):
+        die('Told to fail')
+
     repo = update_local_repo(repo)
     repo.exporter.export_repo(repo.gitdir, refs)
 
@@ -172,6 +182,9 @@ def do_export(repo, args):
     if not repo.gitdir:
         die("Need gitdir to export")
 
+    if os.environ.get("GIT_REMOTE_TESTGIT_FAILURE"):
+        die('Told to fail')
+
     update_local_repo(repo)
     changed = repo.importer.do_import(repo.gitdir)
 
index 94c7f76a156f1eaa4c622db267710f2982cf7826..be809e5b59394a4fd2f4f2b73cad6bac47a39600 100755 (executable)
@@ -1285,10 +1285,10 @@ foreach my $t (@files) {
                }
 
                if (defined $input_format && $input_format eq 'mbox') {
-                       if (/^Subject:\s+(.*)$/) {
+                       if (/^Subject:\s+(.*)$/i) {
                                $subject = $1;
                        }
-                       elsif (/^From:\s+(.*)$/) {
+                       elsif (/^From:\s+(.*)$/i) {
                                ($author, $author_encoding) = unquote_rfc2047($1);
                                next if $suppress_cc{'author'};
                                next if $suppress_cc{'self'} and $author eq $sender;
@@ -1296,14 +1296,14 @@ foreach my $t (@files) {
                                        $1, $_) unless $quiet;
                                push @cc, $1;
                        }
-                       elsif (/^To:\s+(.*)$/) {
+                       elsif (/^To:\s+(.*)$/i) {
                                foreach my $addr (parse_address_line($1)) {
                                        printf("(mbox) Adding to: %s from line '%s'\n",
                                                $addr, $_) unless $quiet;
                                        push @to, $addr;
                                }
                        }
-                       elsif (/^Cc:\s+(.*)$/) {
+                       elsif (/^Cc:\s+(.*)$/i) {
                                foreach my $addr (parse_address_line($1)) {
                                        if (unquote_rfc2047($addr) eq $sender) {
                                                next if ($suppress_cc{'self'});
@@ -1325,7 +1325,7 @@ foreach my $t (@files) {
                        elsif (/^Message-Id: (.*)/i) {
                                $message_id = $1;
                        }
-                       elsif (!/^Date:\s/ && /^[-A-Za-z]+:\s+\S/) {
+                       elsif (!/^Date:\s/i && /^[-A-Za-z]+:\s+\S/) {
                                push @xh, $_;
                        }
 
index 22f0aed6db366c3d4a291b3ae646c45002ff86c1..795edd2852aa1c680c3db1776bb84aca7662899d 100644 (file)
 # But we protect ourselves from such a user mistake nevertheless.
 unset CDPATH
 
-# Similarly for IFS
-unset IFS
+# Similarly for IFS, but some shells (e.g. FreeBSD 7.2) are buggy and
+# do not equate an unset IFS with IFS with the default, so here is
+# an explicit SP HT LF.
+IFS='  
+'
 
 git_broken_path_fix () {
        case ":$PATH:" in
index 2365149d0b920ece4d076dafbebf23fef6888df1..22ec5b63b4cd36dd10277e842970f9534a623a2f 100755 (executable)
@@ -8,7 +8,7 @@ dashless=$(basename "$0" | sed -e 's/-/ /')
 USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
    or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]
    or: $dashless [--quiet] init [--] [<path>...]
-   or: $dashless [--quiet] update [--init] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
+   or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
    or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
    or: $dashless [--quiet] foreach [--recursive] <command>
    or: $dashless [--quiet] sync [--recursive] [--] [<path>...]"
@@ -26,6 +26,7 @@ cached=
 recursive=
 init=
 files=
+remote=
 nofetch=
 update=
 prefix=
@@ -152,6 +153,32 @@ die_if_unmatched ()
        fi
 }
 
+#
+# Print a submodule configuration setting
+#
+# $1 = submodule name
+# $2 = option name
+# $3 = default value
+#
+# Checks in the usual git-config places first (for overrides),
+# otherwise it falls back on .gitmodules.  This allows you to
+# distribute project-wide defaults in .gitmodules, while still
+# customizing individual repositories if necessary.  If the option is
+# not in .gitmodules either, print a default value.
+#
+get_submodule_config () {
+       name="$1"
+       option="$2"
+       default="$3"
+       value=$(git config submodule."$name"."$option")
+       if test -z "$value"
+       then
+               value=$(git config -f .gitmodules submodule."$name"."$option")
+       fi
+       printf '%s' "${value:-$default}"
+}
+
+
 #
 # Map submodule path to submodule name
 #
@@ -390,6 +417,10 @@ Use -f if you really want to add it." >&2
 
        git config -f .gitmodules submodule."$sm_name".path "$sm_path" &&
        git config -f .gitmodules submodule."$sm_name".url "$repo" &&
+       if test -n "$branch"
+       then
+               git config -f .gitmodules submodule."$sm_name".branch "$branch"
+       fi &&
        git add --force .gitmodules ||
        die "$(eval_gettext "Failed to register submodule '\$sm_path'")"
 }
@@ -533,6 +564,9 @@ cmd_update()
                -i|--init)
                        init=1
                        ;;
+               --remote)
+                       remote=1
+                       ;;
                -N|--no-fetch)
                        nofetch=1
                        ;;
@@ -593,6 +627,7 @@ cmd_update()
                fi
                name=$(module_name "$sm_path") || exit
                url=$(git config submodule."$name".url)
+               branch=$(get_submodule_config "$name" branch master)
                if ! test -z "$update"
                then
                        update_module=$update
@@ -627,6 +662,20 @@ Maybe you want to use 'update --init'?")"
                        die "$(eval_gettext "Unable to find current revision in submodule path '\$sm_path'")"
                fi
 
+               if test -n "$remote"
+               then
+                       if test -z "$nofetch"
+                       then
+                               # Fetch remote before determining tracking $sha1
+                               (clear_local_git_env; cd "$sm_path" && git-fetch) ||
+                               die "$(eval_gettext "Unable to fetch in submodule path '\$sm_path'")"
+                       fi
+                       remote_name=$(clear_local_git_env; cd "$sm_path" && get_default_remote)
+                       sha1=$(clear_local_git_env; cd "$sm_path" &&
+                               git rev-parse --verify "${remote_name}/${branch}") ||
+                       die "$(eval_gettext "Unable to find current ${remote_name}/${branch} revision in submodule path '\$sm_path'")"
+               fi
+
                if test "$subsha1" != "$sha1" -o -n "$force"
                then
                        subforce=$force
index bd5266c86b299bbc75878b7529820798d194fc72..d0866946cee0076dd167cf6234dfec192d8d194e 100755 (executable)
@@ -114,6 +114,7 @@ my ($_stdin, $_help, $_edit,
        $_message, $_file, $_branch_dest,
        $_template, $_shared,
        $_version, $_fetch_all, $_no_rebase, $_fetch_parent,
+       $_before, $_after,
        $_merge, $_strategy, $_preserve_merges, $_dry_run, $_local,
        $_prefix, $_no_checkout, $_url, $_verbose,
        $_commit_url, $_tag, $_merge_info, $_interactive);
@@ -258,7 +259,8 @@ my %cmd = (
                        } ],
        'find-rev' => [ \&cmd_find_rev,
                        "Translate between SVN revision numbers and tree-ish",
-                       {} ],
+                       { 'before' => \$_before,
+                         'after' => \$_after } ],
        'rebase' => [ \&cmd_rebase, "Fetch and rebase your working directory",
                        { 'merge|m|M' => \$_merge,
                          'verbose|v' => \$_verbose,
@@ -1191,7 +1193,13 @@ sub cmd_find_rev {
                            "$head history\n";
                }
                my $desired_revision = substr($revision_or_hash, 1);
-               $result = $gs->rev_map_get($desired_revision, $uuid);
+               if ($_before) {
+                       $result = $gs->find_rev_before($desired_revision, 1);
+               } elsif ($_after) {
+                       $result = $gs->find_rev_after($desired_revision, 1);
+               } else {
+                       $result = $gs->rev_map_get($desired_revision, $uuid);
+               }
        } else {
                my (undef, $rev, undef) = cmt_metadata($revision_or_hash);
                $result = $rev;
diff --git a/git.c b/git.c
index d33f9b32a2895ef9f062f9fda487588daac6f5bc..ed66c660d15010af9a8b0c2ea1da8839e316e1db 100644 (file)
--- a/git.c
+++ b/git.c
@@ -135,6 +135,14 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                        git_config_push_parameter((*argv)[1]);
                        (*argv)++;
                        (*argc)--;
+               } else if (!strcmp(cmd, "--literal-pathspecs")) {
+                       setenv(GIT_LITERAL_PATHSPECS_ENVIRONMENT, "1", 1);
+                       if (envchanged)
+                               *envchanged = 1;
+               } else if (!strcmp(cmd, "--no-literal-pathspecs")) {
+                       setenv(GIT_LITERAL_PATHSPECS_ENVIRONMENT, "0", 1);
+                       if (envchanged)
+                               *envchanged = 1;
                } else {
                        fprintf(stderr, "Unknown option: %s\n", cmd);
                        usage(git_usage_string);
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1dbb1b0148074ac34fb4e4240c06f1042b12c10a 100644 (file)
@@ -0,0 +1,5 @@
+import sys
+if sys.hexversion < 0x02040000:
+    # The limiter is the subprocess module
+    sys.stderr.write("git_remote_helpers: requires Python 2.4 or later.\n")
+    sys.exit(1)
index 5c6b595e16665bc508625ab0e96c95776bacba1a..e28cc8f98655b16e5930c9c623a1f3098ae0ca93 100644 (file)
@@ -39,7 +39,7 @@ class GitImporter(object):
             gitdir = self.repo.gitpath
         else:
             gitdir = os.path.abspath(os.path.join(dirname, '.git'))
-        path = os.path.abspath(os.path.join(dirname, 'git.marks'))
+        path = os.path.abspath(os.path.join(dirname, 'testgit.marks'))
 
         if not os.path.exists(dirname):
             os.makedirs(dirname)
index d93bd990a9d7fc9ad7c926e25f5d58f4e7514260..b3706fc9b9bef1361f6872b00905443dea584a7d 100755 (executable)
@@ -2161,7 +2161,7 @@ proc makewindow {} {
     trace add variable sha1string write sha1change
     pack $sha1entry -side left -pady 2
 
-    image create bitmap bm-left -data {
+    set bm_left_data {
        #define left_width 16
        #define left_height 16
        static unsigned char left_bits[] = {
@@ -2169,7 +2169,7 @@ proc makewindow {} {
        0x0e, 0x00, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x0e, 0x00, 0x1c, 0x00,
        0x38, 0x00, 0x70, 0x00, 0xe0, 0x00, 0xc0, 0x01};
     }
-    image create bitmap bm-right -data {
+    set bm_right_data {
        #define right_width 16
        #define right_height 16
        static unsigned char right_bits[] = {
@@ -2177,11 +2177,24 @@ proc makewindow {} {
        0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,
        0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};
     }
-    ${NS}::button .tf.bar.leftbut -image bm-left -command goback \
-       -state disabled -width 26
+    image create bitmap bm-left -data $bm_left_data
+    image create bitmap bm-left-gray -data $bm_left_data -foreground "#999"
+    image create bitmap bm-right -data $bm_right_data
+    image create bitmap bm-right-gray -data $bm_right_data -foreground "#999"
+
+    ${NS}::button .tf.bar.leftbut -command goback -state disabled -width 26
+    if {$use_ttk} {
+       .tf.bar.leftbut configure -image [list bm-left disabled bm-left-gray]
+    } else {
+       .tf.bar.leftbut configure -image bm-left
+    }
     pack .tf.bar.leftbut -side left -fill y
-    ${NS}::button .tf.bar.rightbut -image bm-right -command goforw \
-       -state disabled -width 26
+    ${NS}::button .tf.bar.rightbut -command goforw -state disabled -width 26
+    if {$use_ttk} {
+       .tf.bar.rightbut configure -image [list bm-right disabled bm-right-gray]
+    } else {
+       .tf.bar.rightbut configure -image bm-right
+    }
     pack .tf.bar.rightbut -side left -fill y
 
     ${NS}::label .tf.bar.rowlabel -text [mc "Row"]
@@ -2361,6 +2374,8 @@ proc makewindow {} {
     $ctext tag conf mresult -font textfontbold
     $ctext tag conf msep -font textfontbold
     $ctext tag conf found -back yellow
+    $ctext tag conf currentsearchhit -back orange
+    $ctext tag conf wwrap -wrap word
 
     .pwbottom add .bleft
     if {!$use_ttk} {
@@ -2495,10 +2510,9 @@ proc makewindow {} {
     bindkey ? {dofind -1 1}
     bindkey f nextfile
     bind . <F5> updatecommits
-    bind . <Shift-F5> reloadcommits
+    bindmodfunctionkey Shift 5 reloadcommits
     bind . <F2> showrefs
-    bind . <Shift-F4> {newview 0}
-    catch { bind . <Shift-Key-XF86_Switch_VT_4> {newview 0} }
+    bindmodfunctionkey Shift 4 {newview 0}
     bind . <F4> edit_or_newview
     bind . <$M1B-q> doquit
     bind . <$M1B-f> {dofind 1 1}
@@ -2523,6 +2537,7 @@ proc makewindow {} {
     bind $cflist $ctxbut {pop_flist_menu %W %X %Y %x %y}
     bind $ctext $ctxbut {pop_diff_menu %W %X %Y %x %y}
     bind $ctext <Button-1> {focus %W}
+    bind $ctext <<Selection>> rehighlight_search_results
 
     set maincursor [. cget -cursor]
     set textcursor [$ctext cget -cursor]
@@ -2646,6 +2661,11 @@ proc bindkey {ev script} {
     }
 }
 
+proc bindmodfunctionkey {mod n script} {
+    bind . <$mod-F$n> $script
+    catch { bind . <$mod-XF86_Switch_VT_$n> $script }
+}
+
 # set the focus back to the toplevel for any click outside
 # the entry widgets
 proc click {w} {
@@ -2702,7 +2722,7 @@ proc savestuff {w} {
     global cmitmode wrapcomment datetimeformat limitdiffs
     global colors uicolor bgcolor fgcolor diffcolors diffcontext selectbgcolor
     global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk
-    global hideremotes want_ttk
+    global hideremotes want_ttk maxrefs
 
     if {$stuffsaved} return
     if {![winfo viewable .]} return
@@ -2724,6 +2744,7 @@ proc savestuff {w} {
        puts $f [list set autoselect $autoselect]
        puts $f [list set autosellen $autosellen]
        puts $f [list set showneartags $showneartags]
+       puts $f [list set maxrefs $maxrefs]
        puts $f [list set hideremotes $hideremotes]
        puts $f [list set showlocalchanges $showlocalchanges]
        puts $f [list set datetimeformat $datetimeformat]
@@ -3309,6 +3330,7 @@ proc sel_flist {w x y} {
     } else {
        catch {$ctext yview [lindex $difffilestart [expr {$l - 2}]]}
     }
+    suppress_highlighting_file_for_current_scrollpos
 }
 
 proc pop_flist_menu {w X Y x y} {
@@ -6857,7 +6879,7 @@ proc viewnextline {dir} {
 # add a list of tag or branch names at position pos
 # returns the number of names inserted
 proc appendrefs {pos ids var} {
-    global ctext linknum curview $var maxrefs
+    global ctext linknum curview $var maxrefs mainheadid
 
     if {[catch {$ctext index $pos}]} {
        return 0
@@ -6870,24 +6892,54 @@ proc appendrefs {pos ids var} {
            lappend tags [list $tag $id]
        }
     }
+
+    set sep {}
+    set tags [lsort -index 0 -decreasing $tags]
+    set nutags 0
+
     if {[llength $tags] > $maxrefs} {
-       $ctext insert $pos "[mc "many"] ([llength $tags])"
-    } else {
-       set tags [lsort -index 0 -decreasing $tags]
-       set sep {}
-       foreach ti $tags {
-           set id [lindex $ti 1]
-           set lk link$linknum
-           incr linknum
-           $ctext tag delete $lk
-           $ctext insert $pos $sep
-           $ctext insert $pos [lindex $ti 0] $lk
-           setlink $id $lk
-           set sep ", "
+       # If we are displaying heads, and there are too many,
+       # see if there are some important heads to display.
+       # Currently this means "master" and the current head.
+       set itags {}
+       if {$var eq "idheads"} {
+           set utags {}
+           foreach ti $tags {
+               set hname [lindex $ti 0]
+               set id [lindex $ti 1]
+               if {($hname eq "master" || $id eq $mainheadid) &&
+                   [llength $itags] < $maxrefs} {
+                   lappend itags $ti
+               } else {
+                   lappend utags $ti
+               }
+           }
+           set tags $utags
+       }
+       if {$itags ne {}} {
+           set str [mc "and many more"]
+           set sep " "
+       } else {
+           set str [mc "many"]
        }
+       $ctext insert $pos "$str ([llength $tags])"
+       set nutags [llength $tags]
+       set tags $itags
+    }
+
+    foreach ti $tags {
+       set id [lindex $ti 1]
+       set lk link$linknum
+       incr linknum
+       $ctext tag delete $lk
+       $ctext insert $pos $sep
+       $ctext insert $pos [lindex $ti 0] $lk
+       setlink $id $lk
+       set sep ", "
     }
+    $ctext tag add wwrap "$pos linestart" "$pos lineend"
     $ctext conf -state disabled
-    return [llength $tags]
+    return [expr {[llength $tags] + $nutags}]
 }
 
 # called when we have finished computing the nearby tags
@@ -7947,32 +7999,45 @@ proc changediffdisp {} {
     $ctext tag conf dresult -elide [lindex $diffelide 1]
 }
 
-proc highlightfile {loc cline} {
-    global ctext cflist cflist_top
+proc highlightfile {cline} {
+    global cflist cflist_top
+
+    if {![info exists cflist_top]} return
 
-    $ctext yview $loc
     $cflist tag remove highlight $cflist_top.0 "$cflist_top.0 lineend"
     $cflist tag add highlight $cline.0 "$cline.0 lineend"
     $cflist see $cline.0
     set cflist_top $cline
 }
 
+proc highlightfile_for_scrollpos {topidx} {
+    global cmitmode difffilestart
+
+    if {$cmitmode eq "tree"} return
+    if {![info exists difffilestart]} return
+
+    set top [lindex [split $topidx .] 0]
+    if {$difffilestart eq {} || $top < [lindex $difffilestart 0]} {
+       highlightfile 0
+    } else {
+       highlightfile [expr {[bsearch $difffilestart $top] + 2}]
+    }
+}
+
 proc prevfile {} {
     global difffilestart ctext cmitmode
 
     if {$cmitmode eq "tree"} return
     set prev 0.0
-    set prevline 1
     set here [$ctext index @0,0]
     foreach loc $difffilestart {
        if {[$ctext compare $loc >= $here]} {
-           highlightfile $prev $prevline
+           $ctext yview $prev
            return
        }
        set prev $loc
-       incr prevline
     }
-    highlightfile $prev $prevline
+    $ctext yview $prev
 }
 
 proc nextfile {} {
@@ -7980,11 +8045,9 @@ proc nextfile {} {
 
     if {$cmitmode eq "tree"} return
     set here [$ctext index @0,0]
-    set line 1
     foreach loc $difffilestart {
-       incr line
        if {[$ctext compare $loc > $here]} {
-           highlightfile $loc $line
+           $ctext yview $loc
            return
        }
     }
@@ -8030,7 +8093,6 @@ proc settabs {{firstab {}}} {
 proc incrsearch {name ix op} {
     global ctext searchstring searchdirn
 
-    $ctext tag remove found 1.0 end
     if {[catch {$ctext index anchor}]} {
        # no anchor set, use start of selection, or of visible area
        set sel [$ctext tag ranges sel]
@@ -8043,12 +8105,17 @@ proc incrsearch {name ix op} {
        }
     }
     if {$searchstring ne {}} {
-       set here [$ctext search $searchdirn -- $searchstring anchor]
+       set here [$ctext search -count mlen $searchdirn -- $searchstring anchor]
        if {$here ne {}} {
            $ctext see $here
+           set mend "$here + $mlen c"
+           $ctext tag remove sel 1.0 end
+           $ctext tag add sel $here $mend
+           suppress_highlighting_file_for_current_scrollpos
+           highlightfile_for_scrollpos $here
        }
-       searchmarkvisible 1
     }
+    rehighlight_search_results
 }
 
 proc dosearch {} {
@@ -8071,9 +8138,12 @@ proc dosearch {} {
            return
        }
        $ctext see $match
+       suppress_highlighting_file_for_current_scrollpos
+       highlightfile_for_scrollpos $match
        set mend "$match + $mlen c"
        $ctext tag add sel $match $mend
        $ctext mark unset anchor
+       rehighlight_search_results
     }
 }
 
@@ -8097,21 +8167,41 @@ proc dosearchback {} {
            return
        }
        $ctext see $match
+       suppress_highlighting_file_for_current_scrollpos
+       highlightfile_for_scrollpos $match
        set mend "$match + $ml c"
        $ctext tag add sel $match $mend
        $ctext mark unset anchor
+       rehighlight_search_results
+    }
+}
+
+proc rehighlight_search_results {} {
+    global ctext searchstring
+
+    $ctext tag remove found 1.0 end
+    $ctext tag remove currentsearchhit 1.0 end
+
+    if {$searchstring ne {}} {
+       searchmarkvisible 1
     }
 }
 
 proc searchmark {first last} {
     global ctext searchstring
 
+    set sel [$ctext tag ranges sel]
+
     set mend $first.0
     while {1} {
        set match [$ctext search -count mlen -- $searchstring $mend $last.end]
        if {$match eq {}} break
        set mend "$match + $mlen c"
-       $ctext tag add found $match $mend
+       if {$sel ne {} && [$ctext compare $match == [lindex $sel 0]]} {
+           $ctext tag add currentsearchhit $match $mend
+       } else {
+           $ctext tag add found $match $mend
+       }
     }
 }
 
@@ -8137,8 +8227,23 @@ proc searchmarkvisible {doall} {
     }
 }
 
+proc suppress_highlighting_file_for_current_scrollpos {} {
+    global ctext suppress_highlighting_file_for_this_scrollpos
+
+    set suppress_highlighting_file_for_this_scrollpos [$ctext index @0,0]
+}
+
 proc scrolltext {f0 f1} {
-    global searchstring
+    global searchstring cmitmode ctext
+    global suppress_highlighting_file_for_this_scrollpos
+
+    set topidx [$ctext index @0,0]
+    if {![info exists suppress_highlighting_file_for_this_scrollpos]
+       || $topidx ne $suppress_highlighting_file_for_this_scrollpos} {
+       highlightfile_for_scrollpos $topidx
+    }
+
+    catch {unset suppress_highlighting_file_for_this_scrollpos}
 
     .bleft.bottom.sb set $f0 $f1
     if {$searchstring ne {}} {
@@ -10509,13 +10614,13 @@ proc anctags {id} {
 # including id itself if it has a head.
 proc descheads {id} {
     global arcnos arcstart arcids archeads idheads cached_dheads
-    global allparents
+    global allparents arcout
 
     if {![info exists allparents($id)]} {
        return {}
     }
     set aret {}
-    if {[llength $arcnos($id)] == 1 && [llength $allparents($id)] == 1} {
+    if {![info exists arcout($id)]} {
        # part-way along an arc; check it first
        set a [lindex $arcnos($id) 0]
        if {$archeads($a) ne {}} {
@@ -10864,7 +10969,7 @@ proc create_prefs_page {w} {
 proc prefspage_general {notebook} {
     global NS maxwidth maxgraphpct showneartags showlocalchanges
     global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
-    global hideremotes want_ttk have_ttk
+    global hideremotes want_ttk have_ttk maxrefs
 
     set page [create_prefs_page $notebook.general]
 
@@ -10893,9 +10998,12 @@ proc prefspage_general {notebook} {
     ${NS}::label $page.tabstopl -text [mc "Tab spacing"]
     spinbox $page.tabstop -from 1 -to 20 -width 4 -textvariable tabstop
     grid x $page.tabstopl $page.tabstop -sticky w
-    ${NS}::checkbutton $page.ntag -text [mc "Display nearby tags"] \
+    ${NS}::checkbutton $page.ntag -text [mc "Display nearby tags/heads"] \
        -variable showneartags
     grid x $page.ntag -sticky w
+    ${NS}::label $page.maxrefsl -text [mc "Maximum # tags/heads to show"]
+    spinbox $page.maxrefs -from 1 -to 1000 -width 4 -textvariable maxrefs
+    grid x $page.maxrefsl $page.maxrefs -sticky w
     ${NS}::checkbutton $page.ldiff -text [mc "Limit diffs to listed paths"] \
        -variable limitdiffs
     grid x $page.ldiff -sticky w
index 2f07a2e2d93d655cfe5cf2d3535e7b86422233c6..8cc98dc0794d6a6fae196b4fa17b922ca5394436 100644 (file)
@@ -1,40 +1,50 @@
 # Swedish translation for gitk
-# Copyright (C) 2005-2010 Paul Mackerras
+# Copyright (C) 2005-2012 Paul Mackerras
 # This file is distributed under the same license as the gitk package.
 #
-# Peter Krefting <peter@softwolves.pp.se>, 2008-2010.
 # Mikael Magnusson <mikachu@gmail.com>, 2008.
+# Peter Krefting <peter@softwolves.pp.se>, 2008, 2009, 2010, 2012.
+#
 msgid ""
 msgstr ""
 "Project-Id-Version: sv\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-09-12 21:14+0100\n"
-"PO-Revision-Date: 2010-09-12 21:16+0100\n"
+"POT-Creation-Date: 2012-10-03 08:09+0100\n"
+"PO-Revision-Date: 2012-10-03 08:13+0100\n"
 "Last-Translator: Peter Krefting <peter@softwolves.pp.se>\n"
 "Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n"
+"Language: sv\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit"
+"Content-Transfer-Encoding: 8bit\n"
 
-#: gitk:115
+#: gitk:140
 msgid "Couldn't get list of unmerged files:"
 msgstr "Kunde inte hämta lista Ã¶ver ej sammanslagna filer:"
 
-#: gitk:274
+#: gitk:210 gitk:2317
+msgid "Color words"
+msgstr "Färga ord"
+
+#: gitk:215 gitk:2317 gitk:7888 gitk:7921
+msgid "Markup words"
+msgstr "Märk upp ord"
+
+#: gitk:312
 msgid "Error parsing revisions:"
 msgstr "Fel vid tolkning av revisioner:"
 
-#: gitk:330
+#: gitk:368
 msgid "Error executing --argscmd command:"
 msgstr "Fel vid körning av --argscmd-kommando:"
 
-#: gitk:343
+#: gitk:381
 msgid "No files selected: --merge specified but no files are unmerged."
 msgstr ""
 "Inga filer valdes: --merge angavs men det finns inga filer som inte har "
 "slagits samman."
 
-#: gitk:346
+#: gitk:384
 msgid ""
 "No files selected: --merge specified but no unmerged files are within file "
 "limit."
@@ -42,605 +52,617 @@ msgstr ""
 "Inga filer valdes: --merge angavs men det finns inga filer inom "
 "filbegränsningen."
 
-#: gitk:368 gitk:516
+#: gitk:406 gitk:554
 msgid "Error executing git log:"
 msgstr "Fel vid körning av git log:"
 
-#: gitk:386 gitk:532
+#: gitk:424 gitk:570
 msgid "Reading"
 msgstr "Läser"
 
-#: gitk:446 gitk:4271
+#: gitk:484 gitk:4353
 msgid "Reading commits..."
 msgstr "Läser incheckningar..."
 
-#: gitk:449 gitk:1580 gitk:4274
+#: gitk:487 gitk:1625 gitk:4356
 msgid "No commits selected"
 msgstr "Inga incheckningar markerade"
 
-#: gitk:1456
+#: gitk:1499
 msgid "Can't parse git log output:"
 msgstr "Kan inte tolka utdata frÃ¥n git log:"
 
-#: gitk:1676
+#: gitk:1719
 msgid "No commit information available"
 msgstr "Ingen incheckningsinformation Ã¤r tillgänglig"
 
-#: gitk:1818
+#: gitk:1876
 msgid "mc"
 msgstr "mc"
 
-#: gitk:1853 gitk:4064 gitk:9067 gitk:10607 gitk:10817
+#: gitk:1911 gitk:4146 gitk:9282 gitk:10824 gitk:11100
 msgid "OK"
 msgstr "OK"
 
-#: gitk:1855 gitk:4066 gitk:8657 gitk:8736 gitk:8851 gitk:8900 gitk:9069
-#: gitk:10608 gitk:10818
+#: gitk:1913 gitk:4148 gitk:8871 gitk:8950 gitk:9065 gitk:9114 gitk:9284
+#: gitk:10825 gitk:11101
 msgid "Cancel"
 msgstr "Avbryt"
 
-#: gitk:1980
+#: gitk:2040
 msgid "Update"
 msgstr "Uppdatera"
 
-#: gitk:1981
+#: gitk:2041
 msgid "Reload"
 msgstr "Ladda om"
 
-#: gitk:1982
+#: gitk:2042
 msgid "Reread references"
 msgstr "Läs om referenser"
 
-#: gitk:1983
+#: gitk:2043
 msgid "List references"
 msgstr "Visa referenser"
 
-#: gitk:1985
+#: gitk:2045
 msgid "Start git gui"
 msgstr "Starta git gui"
 
-#: gitk:1987
+#: gitk:2047
 msgid "Quit"
 msgstr "Avsluta"
 
-#: gitk:1979
+#: gitk:2039
 msgid "File"
 msgstr "Arkiv"
 
-#: gitk:1991
+#: gitk:2051
 msgid "Preferences"
 msgstr "Inställningar"
 
-#: gitk:1990
+#: gitk:2050
 msgid "Edit"
 msgstr "Redigera"
 
-#: gitk:1995
+#: gitk:2055
 msgid "New view..."
 msgstr "Ny vy..."
 
-#: gitk:1996
+#: gitk:2056
 msgid "Edit view..."
 msgstr "Ändra vy..."
 
-#: gitk:1997
+#: gitk:2057
 msgid "Delete view"
 msgstr "Ta bort vy"
 
-#: gitk:1999
+#: gitk:2059
 msgid "All files"
 msgstr "Alla filer"
 
-#: gitk:1994 gitk:3817
+#: gitk:2054 gitk:3899
 msgid "View"
 msgstr "Visa"
 
-#: gitk:2004 gitk:2014 gitk:2787
+#: gitk:2064 gitk:2074 gitk:2869
 msgid "About gitk"
 msgstr "Om gitk"
 
-#: gitk:2005 gitk:2019
+#: gitk:2065 gitk:2079
 msgid "Key bindings"
 msgstr "Tangentbordsbindningar"
 
-#: gitk:2003 gitk:2018
+#: gitk:2063 gitk:2078
 msgid "Help"
 msgstr "Hjälp"
 
-#: gitk:2096 gitk:8132
+#: gitk:2156 gitk:8330
 msgid "SHA1 ID:"
 msgstr "SHA1-id:"
 
-#: gitk:2127
+#: gitk:2192
 msgid "Row"
 msgstr "Rad"
 
-#: gitk:2165
+#: gitk:2230
 msgid "Find"
 msgstr "Sök"
 
-#: gitk:2166
+#: gitk:2231
 msgid "next"
 msgstr "nästa"
 
-#: gitk:2167
+#: gitk:2232
 msgid "prev"
 msgstr "föreg"
 
-#: gitk:2168
+#: gitk:2233
 msgid "commit"
 msgstr "incheckning"
 
-#: gitk:2171 gitk:2173 gitk:4432 gitk:4455 gitk:4479 gitk:6420 gitk:6492
-#: gitk:6576
+#: gitk:2236 gitk:2238 gitk:4514 gitk:4537 gitk:4561 gitk:6528 gitk:6600
+#: gitk:6685
 msgid "containing:"
 msgstr "som innehÃ¥ller:"
 
-#: gitk:2174 gitk:3298 gitk:3303 gitk:4507
+#: gitk:2239 gitk:3381 gitk:3386 gitk:4590
 msgid "touching paths:"
 msgstr "som rör sökväg:"
 
-#: gitk:2175 gitk:4512
+#: gitk:2240 gitk:4604
 msgid "adding/removing string:"
 msgstr "som lägger/till tar bort sträng:"
 
-#: gitk:2184 gitk:2186
+#: gitk:2249 gitk:2251 gitk:4593
 msgid "Exact"
 msgstr "Exakt"
 
-#: gitk:2186 gitk:4587 gitk:6388
+#: gitk:2251 gitk:4679 gitk:6496
 msgid "IgnCase"
 msgstr "IgnVersaler"
 
-#: gitk:2186 gitk:4481 gitk:4585 gitk:6384
+#: gitk:2251 gitk:4563 gitk:4677 gitk:6492
 msgid "Regexp"
 msgstr "Reg.uttr."
 
-#: gitk:2188 gitk:2189 gitk:4606 gitk:4636 gitk:4643 gitk:6512 gitk:6580
+#: gitk:2253 gitk:2254 gitk:4699 gitk:4729 gitk:4736 gitk:6621 gitk:6689
 msgid "All fields"
 msgstr "Alla fält"
 
-#: gitk:2189 gitk:4604 gitk:4636 gitk:6451
+#: gitk:2254 gitk:4696 gitk:4729 gitk:6559
 msgid "Headline"
 msgstr "Rubrik"
 
-#: gitk:2190 gitk:4604 gitk:6451 gitk:6580 gitk:7013
+#: gitk:2255 gitk:4696 gitk:6559 gitk:6689 gitk:7126
 msgid "Comments"
 msgstr "Kommentarer"
 
-#: gitk:2190 gitk:4604 gitk:4608 gitk:4643 gitk:6451 gitk:6948 gitk:8307
-#: gitk:8322
+#: gitk:2255 gitk:4696 gitk:4701 gitk:4736 gitk:6559 gitk:7061 gitk:8505
+#: gitk:8520
 msgid "Author"
 msgstr "Författare"
 
-#: gitk:2190 gitk:4604 gitk:6451 gitk:6950
+#: gitk:2255 gitk:4696 gitk:6559 gitk:7063
 msgid "Committer"
 msgstr "Incheckare"
 
-#: gitk:2221
+#: gitk:2286
 msgid "Search"
 msgstr "Sök"
 
-#: gitk:2229
+#: gitk:2294
 msgid "Diff"
 msgstr "Diff"
 
-#: gitk:2231
+#: gitk:2296
 msgid "Old version"
 msgstr "Gammal version"
 
-#: gitk:2233
+#: gitk:2298
 msgid "New version"
 msgstr "Ny version"
 
-#: gitk:2235
+#: gitk:2300
 msgid "Lines of context"
 msgstr "Rader sammanhang"
 
-#: gitk:2245
+#: gitk:2310
 msgid "Ignore space change"
 msgstr "Ignorera Ã¤ndringar i blanksteg"
 
-#: gitk:2304
+#: gitk:2314 gitk:2316 gitk:7646 gitk:7874
+msgid "Line diff"
+msgstr "Rad-diff"
+
+#: gitk:2379
 msgid "Patch"
 msgstr "Patch"
 
-#: gitk:2306
+#: gitk:2381
 msgid "Tree"
 msgstr "Träd"
 
-#: gitk:2463 gitk:2480
+#: gitk:2540 gitk:2559
 msgid "Diff this -> selected"
 msgstr "Diff denna -> markerad"
 
-#: gitk:2464 gitk:2481
+#: gitk:2541 gitk:2560
 msgid "Diff selected -> this"
 msgstr "Diff markerad -> denna"
 
-#: gitk:2465 gitk:2482
+#: gitk:2542 gitk:2561
 msgid "Make patch"
 msgstr "Skapa patch"
 
-#: gitk:2466 gitk:8715
+#: gitk:2543 gitk:8929
 msgid "Create tag"
 msgstr "Skapa tagg"
 
-#: gitk:2467 gitk:8831
+#: gitk:2544 gitk:9045
 msgid "Write commit to file"
 msgstr "Skriv incheckning till fil"
 
-#: gitk:2468 gitk:8888
+#: gitk:2545 gitk:9102
 msgid "Create new branch"
 msgstr "Skapa ny gren"
 
-#: gitk:2469
+#: gitk:2546
 msgid "Cherry-pick this commit"
 msgstr "Plocka denna incheckning"
 
-#: gitk:2470
+#: gitk:2547
 msgid "Reset HEAD branch to here"
 msgstr "Ã…terställ HEAD-grenen hit"
 
-#: gitk:2471
+#: gitk:2548
 msgid "Mark this commit"
 msgstr "Markera denna incheckning"
 
-#: gitk:2472
+#: gitk:2549
 msgid "Return to mark"
 msgstr "Ã…tergÃ¥ till markering"
 
-#: gitk:2473
+#: gitk:2550
 msgid "Find descendant of this and mark"
 msgstr "Hitta efterföljare till denna och markera"
 
-#: gitk:2474
+#: gitk:2551
 msgid "Compare with marked commit"
 msgstr "Jämför med markerad incheckning"
 
-#: gitk:2488
+#: gitk:2552 gitk:2562
+msgid "Diff this -> marked commit"
+msgstr "Diff denna -> markerad incheckning"
+
+#: gitk:2553 gitk:2563
+msgid "Diff marked commit -> this"
+msgstr "Diff markerad incheckning -> denna"
+
+#: gitk:2569
 msgid "Check out this branch"
 msgstr "Checka ut denna gren"
 
-#: gitk:2489
+#: gitk:2570
 msgid "Remove this branch"
 msgstr "Ta bort denna gren"
 
-#: gitk:2496
+#: gitk:2577
 msgid "Highlight this too"
 msgstr "Markera Ã¤ven detta"
 
-#: gitk:2497
+#: gitk:2578
 msgid "Highlight this only"
 msgstr "Markera bara detta"
 
-#: gitk:2498
+#: gitk:2579
 msgid "External diff"
 msgstr "Extern diff"
 
-#: gitk:2499
+#: gitk:2580
 msgid "Blame parent commit"
 msgstr "Klandra föräldraincheckning"
 
-#: gitk:2506
+#: gitk:2587
 msgid "Show origin of this line"
 msgstr "Visa ursprunget för den här raden"
 
-#: gitk:2507
+#: gitk:2588
 msgid "Run git gui blame on this line"
 msgstr "Kör git gui blame pÃ¥ den här raden"
 
-#: gitk:2789
+#: gitk:2871
 msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright Â©9 2005-2010 Paul Mackerras\n"
+"Copyright Â©9 2005-2011 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 Â©9 2005-2010 Paul Mackerras\n"
+"Copyright Â©9 2005-2011 Paul Mackerras\n"
 "\n"
 "Använd och vidareförmedla enligt villkoren i GNU General Public License"
 
-#: gitk:2797 gitk:2862 gitk:9253
+#: gitk:2879 gitk:2944 gitk:9468
 msgid "Close"
 msgstr "Stäng"
 
-#: gitk:2818
+#: gitk:2900
 msgid "Gitk key bindings"
 msgstr "Tangentbordsbindningar för Gitk"
 
-#: gitk:2821
+#: gitk:2903
 msgid "Gitk key bindings:"
 msgstr "Tangentbordsbindningar för Gitk:"
 
-#: gitk:2823
+#: gitk:2905
 #, tcl-format
 msgid "<%s-Q>\t\tQuit"
 msgstr "<%s-Q>\t\tAvsluta"
 
-#: gitk:2824
+#: gitk:2906
 #, tcl-format
 msgid "<%s-W>\t\tClose window"
 msgstr "<%s-W>\t\tStäng fönster"
 
-#: gitk:2825
+#: gitk:2907
 msgid "<Home>\t\tMove to first commit"
 msgstr "<Home>\t\tGÃ¥ till första incheckning"
 
-#: gitk:2826
+#: gitk:2908
 msgid "<End>\t\tMove to last commit"
 msgstr "<End>\t\tGÃ¥ till sista incheckning"
 
-#: gitk:2827
-msgid "<Up>, p, i\tMove up one commit"
-msgstr "<Upp>, p, i\tGÃ¥ en incheckning upp"
+#: gitk:2909
+msgid "<Up>, p, k\tMove up one commit"
+msgstr "<Upp>, p, k\tGÃ¥ en incheckning upp"
 
-#: gitk:2828
-msgid "<Down>, n, k\tMove down one commit"
-msgstr "<Ned>, n, k\tGÃ¥ en incheckning ned"
+#: gitk:2910
+msgid "<Down>, n, j\tMove down one commit"
+msgstr "<Ned>, n, j\tGÃ¥ en incheckning ned"
 
-#: gitk:2829
-msgid "<Left>, z, j\tGo back in history list"
-msgstr "<Vänster>, z, j\tGÃ¥ bakÃ¥t i historiken"
+#: gitk:2911
+msgid "<Left>, z, h\tGo back in history list"
+msgstr "<Vänster>, z, h\tGÃ¥ bakÃ¥t i historiken"
 
-#: gitk:2830
+#: gitk:2912
 msgid "<Right>, x, l\tGo forward in history list"
 msgstr "<Höger>, x, l\tGÃ¥ framÃ¥t i historiken"
 
-#: gitk:2831
+#: gitk:2913
 msgid "<PageUp>\tMove up one page in commit list"
 msgstr "<PageUp>\tGÃ¥ upp en sida i incheckningslistan"
 
-#: gitk:2832
+#: gitk:2914
 msgid "<PageDown>\tMove down one page in commit list"
 msgstr "<PageDown>\tGÃ¥ ned en sida i incheckningslistan"
 
-#: gitk:2833
+#: gitk:2915
 #, tcl-format
 msgid "<%s-Home>\tScroll to top of commit list"
 msgstr "<%s-Home>\tRulla till början av incheckningslistan"
 
-#: gitk:2834
+#: gitk:2916
 #, tcl-format
 msgid "<%s-End>\tScroll to bottom of commit list"
 msgstr "<%s-End>\tRulla till slutet av incheckningslistan"
 
-#: gitk:2835
+#: gitk:2917
 #, tcl-format
 msgid "<%s-Up>\tScroll commit list up one line"
 msgstr "<%s-Upp>\tRulla incheckningslistan upp ett steg"
 
-#: gitk:2836
+#: gitk:2918
 #, tcl-format
 msgid "<%s-Down>\tScroll commit list down one line"
 msgstr "<%s-Ned>\tRulla incheckningslistan ned ett steg"
 
-#: gitk:2837
+#: gitk:2919
 #, tcl-format
 msgid "<%s-PageUp>\tScroll commit list up one page"
 msgstr "<%s-PageUp>\tRulla incheckningslistan upp en sida"
 
-#: gitk:2838
+#: gitk:2920
 #, tcl-format
 msgid "<%s-PageDown>\tScroll commit list down one page"
 msgstr "<%s-PageDown>\tRulla incheckningslistan ned en sida"
 
-#: gitk:2839
+#: gitk:2921
 msgid "<Shift-Up>\tFind backwards (upwards, later commits)"
 msgstr "<Skift-Upp>\tSök bakÃ¥t (uppÃ¥t, senare incheckningar)"
 
-#: gitk:2840
+#: gitk:2922
 msgid "<Shift-Down>\tFind forwards (downwards, earlier commits)"
 msgstr "<Skift-Ned>\tSök framÃ¥t (nedÃ¥t, tidigare incheckningar)"
 
-#: gitk:2841
+#: gitk:2923
 msgid "<Delete>, b\tScroll diff view up one page"
 msgstr "<Delete>, b\tRulla diffvisningen upp en sida"
 
-#: gitk:2842
+#: gitk:2924
 msgid "<Backspace>\tScroll diff view up one page"
 msgstr "<Baksteg>\tRulla diffvisningen upp en sida"
 
-#: gitk:2843
+#: gitk:2925
 msgid "<Space>\t\tScroll diff view down one page"
 msgstr "<Blanksteg>\tRulla diffvisningen ned en sida"
 
-#: gitk:2844
+#: gitk:2926
 msgid "u\t\tScroll diff view up 18 lines"
 msgstr "u\t\tRulla diffvisningen upp 18 rader"
 
-#: gitk:2845
+#: gitk:2927
 msgid "d\t\tScroll diff view down 18 lines"
 msgstr "d\t\tRulla diffvisningen ned 18 rader"
 
-#: gitk:2846
+#: gitk:2928
 #, tcl-format
 msgid "<%s-F>\t\tFind"
 msgstr "<%s-F>\t\tSök"
 
-#: gitk:2847
+#: gitk:2929
 #, tcl-format
 msgid "<%s-G>\t\tMove to next find hit"
 msgstr "<%s-G>\t\tGÃ¥ till nästa sökträff"
 
-#: gitk:2848
+#: gitk:2930
 msgid "<Return>\tMove to next find hit"
 msgstr "<Return>\t\tGÃ¥ till nästa sökträff"
 
-#: gitk:2849
+#: gitk:2931
 msgid "/\t\tFocus the search box"
 msgstr "/\t\tFokusera sökrutan"
 
-#: gitk:2850
+#: gitk:2932
 msgid "?\t\tMove to previous find hit"
 msgstr "?\t\tGÃ¥ till föregÃ¥ende sökträff"
 
-#: gitk:2851
+#: gitk:2933
 msgid "f\t\tScroll diff view to next file"
 msgstr "f\t\tRulla diffvisningen till nästa fil"
 
-#: gitk:2852
+#: gitk:2934
 #, tcl-format
 msgid "<%s-S>\t\tSearch for next hit in diff view"
 msgstr "<%s-S>\t\tGÃ¥ till nästa sökträff i diffvisningen"
 
-#: gitk:2853
+#: gitk:2935
 #, tcl-format
 msgid "<%s-R>\t\tSearch for previous hit in diff view"
 msgstr "<%s-R>\t\tGÃ¥ till föregÃ¥ende sökträff i diffvisningen"
 
-#: gitk:2854
+#: gitk:2936
 #, tcl-format
 msgid "<%s-KP+>\tIncrease font size"
 msgstr "<%s-Num+>\tÖka teckenstorlek"
 
-#: gitk:2855
+#: gitk:2937
 #, tcl-format
 msgid "<%s-plus>\tIncrease font size"
 msgstr "<%s-plus>\tÖka teckenstorlek"
 
-#: gitk:2856
+#: gitk:2938
 #, tcl-format
 msgid "<%s-KP->\tDecrease font size"
 msgstr "<%s-Num->\tMinska teckenstorlek"
 
-#: gitk:2857
+#: gitk:2939
 #, tcl-format
 msgid "<%s-minus>\tDecrease font size"
 msgstr "<%s-minus>\tMinska teckenstorlek"
 
-#: gitk:2858
+#: gitk:2940
 msgid "<F5>\t\tUpdate"
 msgstr "<F5>\t\tUppdatera"
 
-#: gitk:3313 gitk:3322
+#: gitk:3395 gitk:3404
 #, tcl-format
 msgid "Error creating temporary directory %s:"
 msgstr "Fel vid skapande av temporär katalog %s:"
 
-#: gitk:3335
+#: gitk:3417
 #, tcl-format
 msgid "Error getting \"%s\" from %s:"
 msgstr "Fel vid hämtning av  \"%s\" frÃ¥n %s:"
 
-#: gitk:3398
+#: gitk:3480
 msgid "command failed:"
 msgstr "kommando misslyckades:"
 
-#: gitk:3547
+#: gitk:3629
 msgid "No such commit"
 msgstr "Incheckning saknas"
 
-#: gitk:3561
+#: gitk:3643
 msgid "git gui blame: command failed:"
 msgstr "git gui blame: kommando misslyckades:"
 
-#: gitk:3592
+#: gitk:3674
 #, tcl-format
 msgid "Couldn't read merge head: %s"
 msgstr "Kunde inte läsa sammanslagningshuvud: %s"
 
-#: gitk:3600
+#: gitk:3682
 #, tcl-format
 msgid "Error reading index: %s"
 msgstr "Fel vid läsning av index: %s"
 
-#: gitk:3625
+#: gitk:3707
 #, tcl-format
 msgid "Couldn't start git blame: %s"
 msgstr "Kunde inte starta git blame: %s"
 
-#: gitk:3628 gitk:6419
+#: gitk:3710 gitk:6527
 msgid "Searching"
 msgstr "Söker"
 
-#: gitk:3660
+#: gitk:3742
 #, tcl-format
 msgid "Error running git blame: %s"
 msgstr "Fel vid körning av git blame: %s"
 
-#: gitk:3688
+#: gitk:3770
 #, tcl-format
 msgid "That line comes from commit %s,  which is not in this view"
 msgstr "Raden kommer frÃ¥n incheckningen %s, som inte finns i denna vy"
 
-#: gitk:3702
+#: gitk:3784
 msgid "External diff viewer failed:"
 msgstr "Externt diff-verktyg misslyckades:"
 
-#: gitk:3820
+#: gitk:3902
 msgid "Gitk view definition"
 msgstr "Definition av Gitk-vy"
 
-#: gitk:3824
+#: gitk:3906
 msgid "Remember this view"
 msgstr "Spara denna vy"
 
-#: gitk:3825
+#: gitk:3907
 msgid "References (space separated list):"
 msgstr "Referenser (blankstegsavdelad lista):"
 
-#: gitk:3826
+#: gitk:3908
 msgid "Branches & tags:"
 msgstr "Grenar & taggar:"
 
-#: gitk:3827
+#: gitk:3909
 msgid "All refs"
 msgstr "Alla referenser"
 
-#: gitk:3828
+#: gitk:3910
 msgid "All (local) branches"
 msgstr "Alla (lokala) grenar"
 
-#: gitk:3829
+#: gitk:3911
 msgid "All tags"
 msgstr "Alla taggar"
 
-#: gitk:3830
+#: gitk:3912
 msgid "All remote-tracking branches"
 msgstr "Alla fjärrspÃ¥rande grenar"
 
-#: gitk:3831
+#: gitk:3913
 msgid "Commit Info (regular expressions):"
 msgstr "Incheckningsinfo (reguljära uttryck):"
 
-#: gitk:3832
+#: gitk:3914
 msgid "Author:"
 msgstr "Författare:"
 
-#: gitk:3833
+#: gitk:3915
 msgid "Committer:"
 msgstr "Incheckare:"
 
-#: gitk:3834
+#: gitk:3916
 msgid "Commit Message:"
 msgstr "Incheckningsmeddelande:"
 
-#: gitk:3835
+#: gitk:3917
 msgid "Matches all Commit Info criteria"
 msgstr "Motsvarar alla kriterier för incheckningsinfo"
 
-#: gitk:3836
+#: gitk:3918
 msgid "Changes to Files:"
 msgstr "Ändringar av filer:"
 
-#: gitk:3837
+#: gitk:3919
 msgid "Fixed String"
 msgstr "Fast sträng"
 
-#: gitk:3838
+#: gitk:3920
 msgid "Regular Expression"
 msgstr "Reguljärt uttryck"
 
-#: gitk:3839
+#: gitk:3921
 msgid "Search string:"
 msgstr "Söksträng:"
 
-#: gitk:3840
+#: gitk:3922
 msgid ""
 "Commit Dates (\"2 weeks ago\", \"2009-03-17 15:27:38\", \"March 17, 2009 "
 "15:27:38\"):"
@@ -648,201 +670,197 @@ msgstr ""
 "Incheckingsdatum (\"2 weeks ago\", \"2009-03-17 15:27:38\", \"March 17, 2009 "
 "15:27:38\"):"
 
-#: gitk:3841
+#: gitk:3923
 msgid "Since:"
 msgstr "FrÃ¥n:"
 
-#: gitk:3842
+#: gitk:3924
 msgid "Until:"
 msgstr "Till:"
 
-#: gitk:3843
+#: gitk:3925
 msgid "Limit and/or skip a number of revisions (positive integer):"
 msgstr "Begränsa och/eller hoppa Ã¶ver ett antal revisioner (positivt heltal):"
 
-#: gitk:3844
+#: gitk:3926
 msgid "Number to show:"
 msgstr "Antal att visa:"
 
-#: gitk:3845
+#: gitk:3927
 msgid "Number to skip:"
 msgstr "Antal att hoppa Ã¶ver:"
 
-#: gitk:3846
+#: gitk:3928
 msgid "Miscellaneous options:"
 msgstr "Diverse alternativ:"
 
-#: gitk:3847
+#: gitk:3929
 msgid "Strictly sort by date"
 msgstr "Strikt datumsortering"
 
-#: gitk:3848
+#: gitk:3930
 msgid "Mark branch sides"
 msgstr "Markera sidogrenar"
 
-#: gitk:3849
+#: gitk:3931
 msgid "Limit to first parent"
 msgstr "Begränsa till första förälder"
 
-#: gitk:3850
+#: gitk:3932
 msgid "Simple history"
 msgstr "Enkel historik"
 
-#: gitk:3851
+#: gitk:3933
 msgid "Additional arguments to git log:"
 msgstr "Ytterligare argument till git log:"
 
-#: gitk:3852
+#: gitk:3934
 msgid "Enter files and directories to include, one per line:"
 msgstr "Ange filer och kataloger att ta med, en per rad:"
 
-#: gitk:3853
+#: gitk:3935
 msgid "Command to generate more commits to include:"
 msgstr "Kommando för att generera fler incheckningar att ta med:"
 
-#: gitk:3977
+#: gitk:4059
 msgid "Gitk: edit view"
 msgstr "Gitk: redigera vy"
 
-#: gitk:3985
+#: gitk:4067
 msgid "-- criteria for selecting revisions"
 msgstr " - kriterier för val av revisioner"
 
-#: gitk:3990
+#: gitk:4072
 msgid "View Name"
 msgstr "Namn pÃ¥ vy"
 
-#: gitk:4065
+#: gitk:4147
 msgid "Apply (F5)"
 msgstr "Använd (F5)"
 
-#: gitk:4103
+#: gitk:4185
 msgid "Error in commit selection arguments:"
 msgstr "Fel i argument för val av incheckningar:"
 
-#: gitk:4156 gitk:4208 gitk:4656 gitk:4670 gitk:5931 gitk:11551 gitk:11552
+#: gitk:4238 gitk:4290 gitk:4749 gitk:4763 gitk:6027 gitk:11849 gitk:11850
 msgid "None"
 msgstr "Inget"
 
-#: gitk:4604 gitk:6451 gitk:8309 gitk:8324
-msgid "Date"
-msgstr "Datum"
-
-#: gitk:4604 gitk:6451
-msgid "CDate"
-msgstr "Skapat datum"
-
-#: gitk:4753 gitk:4758
+#: gitk:4846 gitk:4851
 msgid "Descendant"
 msgstr "Avkomling"
 
-#: gitk:4754
+#: gitk:4847
 msgid "Not descendant"
 msgstr "Inte avkomling"
 
-#: gitk:4761 gitk:4766
+#: gitk:4854 gitk:4859
 msgid "Ancestor"
 msgstr "Förfader"
 
-#: gitk:4762
+#: gitk:4855
 msgid "Not ancestor"
 msgstr "Inte förfader"
 
-#: gitk:5052
+#: gitk:5145
 msgid "Local changes checked in to index but not committed"
 msgstr "Lokala Ã¤ndringar sparade i indexet men inte incheckade"
 
-#: gitk:5088
+#: gitk:5181
 msgid "Local uncommitted changes, not checked in to index"
 msgstr "Lokala Ã¤ndringar, ej sparade i indexet"
 
-#: gitk:6769
+#: gitk:6882
 msgid "many"
 msgstr "mÃ¥nga"
 
-#: gitk:6952
+#: gitk:7065
 msgid "Tags:"
 msgstr "Taggar:"
 
-#: gitk:6969 gitk:6975 gitk:8302
+#: gitk:7082 gitk:7088 gitk:8500
 msgid "Parent"
 msgstr "Förälder"
 
-#: gitk:6980
+#: gitk:7093
 msgid "Child"
 msgstr "Barn"
 
-#: gitk:6989
+#: gitk:7102
 msgid "Branch"
 msgstr "Gren"
 
-#: gitk:6992
+#: gitk:7105
 msgid "Follows"
 msgstr "Följer"
 
-#: gitk:6995
+#: gitk:7108
 msgid "Precedes"
 msgstr "FöregÃ¥r"
 
-#: gitk:7532
+#: gitk:7653
 #, tcl-format
 msgid "Error getting diffs: %s"
 msgstr "Fel vid hämtning av diff: %s"
 
-#: gitk:8130
+#: gitk:8328
 msgid "Goto:"
 msgstr "GÃ¥ till:"
 
-#: gitk:8151
+#: gitk:8349
 #, tcl-format
 msgid "Short SHA1 id %s is ambiguous"
 msgstr "Förkortat SHA1-id %s Ã¤r tvetydigt"
 
-#: gitk:8158
+#: gitk:8356
 #, tcl-format
 msgid "Revision %s is not known"
 msgstr "Revisionen %s Ã¤r inte känd"
 
-#: gitk:8168
+#: gitk:8366
 #, tcl-format
 msgid "SHA1 id %s is not known"
 msgstr "SHA-id:t %s Ã¤r inte känt"
 
-#: gitk:8170
+#: gitk:8368
 #, tcl-format
 msgid "Revision %s is not in the current view"
 msgstr "Revisionen %s finns inte i den nuvarande vyn"
 
-#: gitk:8312
+#: gitk:8507 gitk:8522
+msgid "Date"
+msgstr "Datum"
+
+#: gitk:8510
 msgid "Children"
 msgstr "Barn"
 
-#: gitk:8370
+#: gitk:8573
 #, tcl-format
 msgid "Reset %s branch to here"
 msgstr "Ã…terställ grenen %s hit"
 
-#: gitk:8372
+#: gitk:8575
 msgid "Detached head: can't reset"
 msgstr "FrÃ¥nkopplad head: kan inte Ã¥terställa"
 
-#: gitk:8481 gitk:8487
+#: gitk:8680 gitk:8686
 msgid "Skipping merge commit "
 msgstr "Hoppar Ã¶ver sammanslagningsincheckning "
 
-#: gitk:8496 gitk:8501
+#: gitk:8695 gitk:8700
 msgid "Error getting patch ID for "
 msgstr "Fel vid hämtning av patch-id för "
 
-#: gitk:8497 gitk:8502
+#: gitk:8696 gitk:8701
 msgid " - stopping\n"
 msgstr " - stannar\n"
 
-#: gitk:8507 gitk:8510 gitk:8518 gitk:8532 gitk:8541
+#: gitk:8706 gitk:8709 gitk:8717 gitk:8731 gitk:8740
 msgid "Commit "
 msgstr "Incheckning "
 
-#: gitk:8511
+#: gitk:8710
 msgid ""
 " is the same patch as\n"
 "       "
@@ -850,7 +868,7 @@ msgstr ""
 " Ã¤r samma patch som\n"
 "       "
 
-#: gitk:8519
+#: gitk:8718
 msgid ""
 " differs from\n"
 "       "
@@ -858,7 +876,7 @@ msgstr ""
 " skiljer sig frÃ¥n\n"
 "       "
 
-#: gitk:8521
+#: gitk:8720
 msgid ""
 "Diff of commits:\n"
 "\n"
@@ -866,131 +884,131 @@ msgstr ""
 "Skillnad mellan incheckningar:\n"
 "\n"
 
-#: gitk:8533 gitk:8542
+#: gitk:8732 gitk:8741
 #, tcl-format
 msgid " has %s children - stopping\n"
 msgstr " har %s barn - stannar\n"
 
-#: gitk:8561
+#: gitk:8760
 #, tcl-format
 msgid "Error writing commit to file: %s"
 msgstr "Fel vid skrivning av incheckning till fil: %s"
 
-#: gitk:8567
+#: gitk:8766
 #, tcl-format
 msgid "Error diffing commits: %s"
 msgstr "Fel vid jämförelse av incheckningar: %s"
 
-#: gitk:8598
+#: gitk:8812
 msgid "Top"
 msgstr "Topp"
 
-#: gitk:8599
+#: gitk:8813
 msgid "From"
 msgstr "FrÃ¥n"
 
-#: gitk:8604
+#: gitk:8818
 msgid "To"
 msgstr "Till"
 
-#: gitk:8628
+#: gitk:8842
 msgid "Generate patch"
 msgstr "Generera patch"
 
-#: gitk:8630
+#: gitk:8844
 msgid "From:"
 msgstr "FrÃ¥n:"
 
-#: gitk:8639
+#: gitk:8853
 msgid "To:"
 msgstr "Till:"
 
-#: gitk:8648
+#: gitk:8862
 msgid "Reverse"
 msgstr "Vänd"
 
-#: gitk:8650 gitk:8845
+#: gitk:8864 gitk:9059
 msgid "Output file:"
 msgstr "Utdatafil:"
 
-#: gitk:8656
+#: gitk:8870
 msgid "Generate"
 msgstr "Generera"
 
-#: gitk:8694
+#: gitk:8908
 msgid "Error creating patch:"
 msgstr "Fel vid generering av patch:"
 
-#: gitk:8717 gitk:8833 gitk:8890
+#: gitk:8931 gitk:9047 gitk:9104
 msgid "ID:"
 msgstr "Id:"
 
-#: gitk:8726
+#: gitk:8940
 msgid "Tag name:"
 msgstr "Taggnamn:"
 
-#: gitk:8729
+#: gitk:8943
 msgid "Tag message is optional"
 msgstr "Taggmeddelandet Ã¤r valfritt"
 
-#: gitk:8731
+#: gitk:8945
 msgid "Tag message:"
 msgstr "Taggmeddelande:"
 
-#: gitk:8735 gitk:8899
+#: gitk:8949 gitk:9113
 msgid "Create"
 msgstr "Skapa"
 
-#: gitk:8753
+#: gitk:8967
 msgid "No tag name specified"
 msgstr "Inget taggnamn angavs"
 
-#: gitk:8757
+#: gitk:8971
 #, tcl-format
 msgid "Tag \"%s\" already exists"
 msgstr "Taggen \"%s\" finns redan"
 
-#: gitk:8767
+#: gitk:8981
 msgid "Error creating tag:"
 msgstr "Fel vid skapande av tagg:"
 
-#: gitk:8842
+#: gitk:9056
 msgid "Command:"
 msgstr "Kommando:"
 
-#: gitk:8850
+#: gitk:9064
 msgid "Write"
 msgstr "Skriv"
 
-#: gitk:8868
+#: gitk:9082
 msgid "Error writing commit:"
 msgstr "Fel vid skrivning av incheckning:"
 
-#: gitk:8895
+#: gitk:9109
 msgid "Name:"
 msgstr "Namn:"
 
-#: gitk:8918
+#: gitk:9132
 msgid "Please specify a name for the new branch"
 msgstr "Ange ett namn för den nya grenen"
 
-#: gitk:8923
+#: gitk:9137
 #, tcl-format
 msgid "Branch '%s' already exists. Overwrite?"
 msgstr "Grenen \"%s\" finns redan. Skriva Ã¶ver?"
 
-#: gitk:8989
+#: gitk:9204
 #, tcl-format
 msgid "Commit %s is already included in branch %s -- really re-apply it?"
 msgstr ""
 "Incheckningen %s finns redan pÃ¥ grenen %s -- skall den verkligen appliceras "
 "pÃ¥ nytt?"
 
-#: gitk:8994
+#: gitk:9209
 msgid "Cherry-picking"
 msgstr "Plockar"
 
-#: gitk:9003
+#: gitk:9218
 #, tcl-format
 msgid ""
 "Cherry-pick failed because of local changes to file '%s'.\n"
@@ -1000,7 +1018,7 @@ msgstr ""
 "Checka in, Ã¥terställ eller spara undan (stash) dina Ã¤ndringar och försök "
 "igen."
 
-#: gitk:9009
+#: gitk:9224
 msgid ""
 "Cherry-pick failed because of merge conflict.\n"
 "Do you wish to run git citool to resolve it?"
@@ -1008,32 +1026,32 @@ msgstr ""
 "Cherry-pick misslyckades pÃ¥ grund av en sammanslagningskonflikt.\n"
 "Vill du köra git citool för att lösa den?"
 
-#: gitk:9025
+#: gitk:9240
 msgid "No changes committed"
 msgstr "Inga Ã¤ndringar incheckade"
 
-#: gitk:9051
+#: gitk:9266
 msgid "Confirm reset"
 msgstr "Bekräfta Ã¥terställning"
 
-#: gitk:9053
+#: gitk:9268
 #, tcl-format
 msgid "Reset branch %s to %s?"
 msgstr "Ã…terställa grenen %s till %s?"
 
-#: gitk:9055
+#: gitk:9270
 msgid "Reset type:"
 msgstr "Typ av Ã¥terställning:"
 
-#: gitk:9058
+#: gitk:9273
 msgid "Soft: Leave working tree and index untouched"
 msgstr "Mjuk: Rör inte utcheckning och index"
 
-#: gitk:9061
+#: gitk:9276
 msgid "Mixed: Leave working tree untouched, reset index"
 msgstr "Blandad: Rör inte utcheckning, Ã¥terställ index"
 
-#: gitk:9064
+#: gitk:9279
 msgid ""
 "Hard: Reset working tree and index\n"
 "(discard ALL local changes)"
@@ -1041,19 +1059,19 @@ msgstr ""
 "HÃ¥rd: Ã…terställ utcheckning och index\n"
 "(förkastar ALLA lokala Ã¤ndringar)"
 
-#: gitk:9081
+#: gitk:9296
 msgid "Resetting"
 msgstr "Ã…terställer"
 
-#: gitk:9141
+#: gitk:9356
 msgid "Checking out"
 msgstr "Checkar ut"
 
-#: gitk:9194
+#: gitk:9409
 msgid "Cannot delete the currently checked-out branch"
 msgstr "Kan inte ta bort den just nu utcheckade grenen"
 
-#: gitk:9200
+#: gitk:9415
 #, tcl-format
 msgid ""
 "The commits on branch %s aren't on any other branch.\n"
@@ -1062,16 +1080,16 @@ msgstr ""
 "Incheckningarna pÃ¥ grenen %s existerar inte pÃ¥ nÃ¥gon annan gren.\n"
 "Vill du verkligen ta bort grenen %s?"
 
-#: gitk:9231
+#: gitk:9446
 #, tcl-format
 msgid "Tags and heads: %s"
 msgstr "Taggar och huvuden: %s"
 
-#: gitk:9246
+#: gitk:9461
 msgid "Filter"
 msgstr "Filter"
 
-#: gitk:9541
+#: gitk:9757
 msgid ""
 "Error reading commit topology information; branch and preceding/following "
 "tag information will be incomplete."
@@ -1079,206 +1097,219 @@ msgstr ""
 "Fel vid läsning av information om incheckningstopologi; information om "
 "grenar och föregÃ¥ende/senare taggar kommer inte vara komplett."
 
-#: gitk:10527
+#: gitk:10744
 msgid "Tag"
 msgstr "Tagg"
 
-#: gitk:10527
+#: gitk:10744
 msgid "Id"
 msgstr "Id"
 
-#: gitk:10576
+#: gitk:10793
 msgid "Gitk font chooser"
 msgstr "Teckensnittsväljare för Gitk"
 
-#: gitk:10593
+#: gitk:10810
 msgid "B"
 msgstr "F"
 
-#: gitk:10596
+#: gitk:10813
 msgid "I"
 msgstr "K"
 
-#: gitk:10714
-msgid "Gitk preferences"
-msgstr "Inställningar för Gitk"
-
-#: gitk:10716
+#: gitk:10931
 msgid "Commit list display options"
 msgstr "Alternativ för incheckningslistvy"
 
-#: gitk:10719
+#: gitk:10934
 msgid "Maximum graph width (lines)"
 msgstr "Maximal grafbredd (rader)"
 
-#: gitk:10722
+#: gitk:10937
 #, tcl-format
 msgid "Maximum graph width (% of pane)"
 msgstr "Maximal grafbredd (% av ruta)"
 
-#: gitk:10725
+#: gitk:10940
 msgid "Show local changes"
 msgstr "Visa lokala Ã¤ndringar"
 
-#: gitk:10728
-msgid "Auto-select SHA1"
-msgstr "Välj SHA1 automatiskt"
+#: gitk:10943
+msgid "Auto-select SHA1 (length)"
+msgstr "Välj SHA1 (längd) automatiskt"
 
-#: gitk:10731
+#: gitk:10947
 msgid "Hide remote refs"
 msgstr "Dölj fjärr-referenser"
 
-#: gitk:10735
+#: gitk:10951
 msgid "Diff display options"
 msgstr "Alternativ för diffvy"
 
-#: gitk:10737
+#: gitk:10953
 msgid "Tab spacing"
 msgstr "Blanksteg för tabulatortecken"
 
-#: gitk:10740
+#: gitk:10956
 msgid "Display nearby tags"
 msgstr "Visa närliggande taggar"
 
-#: gitk:10743
+#: gitk:10959
 msgid "Limit diffs to listed paths"
 msgstr "Begränsa diff till listade sökvägar"
 
-#: gitk:10746
+#: gitk:10962
 msgid "Support per-file encodings"
 msgstr "Stöd för filspecifika teckenkodningar"
 
-#: gitk:10752 gitk:10832
+#: gitk:10968 gitk:11115
 msgid "External diff tool"
 msgstr "Externt diff-verktyg"
 
-#: gitk:10753
+#: gitk:10969
 msgid "Choose..."
 msgstr "Välj..."
 
-#: gitk:10758
+#: gitk:10974
 msgid "General options"
 msgstr "Allmänna inställningar"
 
-#: gitk:10761
+#: gitk:10977
 msgid "Use themed widgets"
 msgstr "Använd tema pÃ¥ fönsterelement"
 
-#: gitk:10763
+#: gitk:10979
 msgid "(change requires restart)"
 msgstr "(ändringen kräver omstart)"
 
-#: gitk:10765
+#: gitk:10981
 msgid "(currently unavailable)"
 msgstr "(för närvarande inte tillgängligt)"
 
-#: gitk:10769
+#: gitk:10992
 msgid "Colors: press to choose"
 msgstr "Färger: tryck för att välja"
 
-#: gitk:10772
+#: gitk:10995
 msgid "Interface"
 msgstr "Gränssnitt"
 
-#: gitk:10773
+#: gitk:10996
 msgid "interface"
 msgstr "gränssnitt"
 
-#: gitk:10776
+#: gitk:10999
 msgid "Background"
 msgstr "Bakgrund"
 
-#: gitk:10777 gitk:10807
+#: gitk:11000 gitk:11030
 msgid "background"
 msgstr "bakgrund"
 
-#: gitk:10780
+#: gitk:11003
 msgid "Foreground"
 msgstr "Förgrund"
 
-#: gitk:10781
+#: gitk:11004
 msgid "foreground"
 msgstr "förgrund"
 
-#: gitk:10784
+#: gitk:11007
 msgid "Diff: old lines"
 msgstr "Diff: gamla rader"
 
-#: gitk:10785
+#: gitk:11008
 msgid "diff old lines"
 msgstr "diff gamla rader"
 
-#: gitk:10789
+#: gitk:11012
 msgid "Diff: new lines"
 msgstr "Diff: nya rader"
 
-#: gitk:10790
+#: gitk:11013
 msgid "diff new lines"
 msgstr "diff nya rader"
 
-#: gitk:10794
+#: gitk:11017
 msgid "Diff: hunk header"
 msgstr "Diff: delhuvud"
 
-#: gitk:10796
+#: gitk:11019
 msgid "diff hunk header"
 msgstr "diff delhuvud"
 
-#: gitk:10800
+#: gitk:11023
 msgid "Marked line bg"
 msgstr "Markerad rad bakgrund"
 
-#: gitk:10802
+#: gitk:11025
 msgid "marked line background"
 msgstr "markerad rad bakgrund"
 
-#: gitk:10806
+#: gitk:11029
 msgid "Select bg"
 msgstr "Markerad bakgrund"
 
-#: gitk:10810
+#: gitk:11038
 msgid "Fonts: press to choose"
 msgstr "Teckensnitt: tryck för att välja"
 
-#: gitk:10812
+#: gitk:11040
 msgid "Main font"
 msgstr "Huvudteckensnitt"
 
-#: gitk:10813
+#: gitk:11041
 msgid "Diff display font"
 msgstr "Teckensnitt för diffvisning"
 
-#: gitk:10814
+#: gitk:11042
 msgid "User interface font"
 msgstr "Teckensnitt för användargränssnitt"
 
-#: gitk:10842
+#: gitk:11064
+msgid "Gitk preferences"
+msgstr "Inställningar för Gitk"
+
+#: gitk:11073
+msgid "General"
+msgstr "Allmänt"
+
+#: gitk:11074
+msgid "Colors"
+msgstr "Färger"
+
+#: gitk:11075
+msgid "Fonts"
+msgstr "Teckensnitt"
+
+#: gitk:11125
 #, tcl-format
 msgid "Gitk: choose color for %s"
 msgstr "Gitk: välj färg för %s"
 
-#: gitk:11445
+#: gitk:11745
 msgid "Cannot find a git repository here."
 msgstr "Hittar inget git-arkiv här."
 
-#: gitk:11449
-#, tcl-format
-msgid "Cannot find the git directory \"%s\"."
-msgstr "Hittar inte git-katalogen \"%s\"."
-
-#: gitk:11496
+#: gitk:11792
 #, tcl-format
 msgid "Ambiguous argument '%s': both revision and filename"
 msgstr "Tvetydigt argument \"%s\": bÃ¥de revision och filnamn"
 
-#: gitk:11508
+#: gitk:11804
 msgid "Bad arguments to gitk:"
 msgstr "Felaktiga argument till gitk:"
 
-#: gitk:11604
+#: gitk:11907
 msgid "Command line"
 msgstr "Kommandorad"
 
+#~ msgid "CDate"
+#~ msgstr "Skapat datum"
+
+#~ msgid "Cannot find the git directory \"%s\"."
+#~ msgstr "Hittar inte git-katalogen \"%s\"."
+
 #~ msgid "SHA1 ID: "
 #~ msgstr "SHA1-id: "
 
index 0f207f2e20b0c3c30e62c1fd6f0526d38868776f..c6bafe6ead815ece2e820d303e442270749c5c4b 100755 (executable)
@@ -1556,7 +1556,7 @@ sub sanitize {
        return undef unless defined $str;
 
        $str = to_utf8($str);
-       $str =~ s|([[:cntrl:]])|($1 =~ /[\t\n\r]/ ? $1 : quot_cec($1))|eg;
+       $str =~ s|([[:cntrl:]])|(index("\t\n\r", $1) != -1 ? $1 : quot_cec($1))|eg;
        return $str;
 }
 
@@ -5528,23 +5528,30 @@ sub fill_project_list_info {
 
 sub sort_projects_list {
        my ($projlist, $order) = @_;
-       my @projects;
 
-       my %order_info = (
-               project => { key => 'path', type => 'str' },
-               descr => { key => 'descr_long', type => 'str' },
-               owner => { key => 'owner', type => 'str' },
-               age => { key => 'age', type => 'num' }
-       );
-       my $oi = $order_info{$order};
-       return @$projlist unless defined $oi;
-       if ($oi->{'type'} eq 'str') {
-               @projects = sort {$a->{$oi->{'key'}} cmp $b->{$oi->{'key'}}} @$projlist;
-       } else {
-               @projects = sort {$a->{$oi->{'key'}} <=> $b->{$oi->{'key'}}} @$projlist;
+       sub order_str {
+               my $key = shift;
+               return sub { $a->{$key} cmp $b->{$key} };
        }
 
-       return @projects;
+       sub order_num_then_undef {
+               my $key = shift;
+               return sub {
+                       defined $a->{$key} ?
+                               (defined $b->{$key} ? $a->{$key} <=> $b->{$key} : -1) :
+                               (defined $b->{$key} ? 1 : 0)
+               };
+       }
+
+       my %orderings = (
+               project => order_str('path'),
+               descr => order_str('descr_long'),
+               owner => order_str('owner'),
+               age => order_num_then_undef('age'),
+       );
+
+       my $ordering = $orderings{$order};
+       return defined $ordering ? sort $ordering @$projlist : @$projlist;
 }
 
 # returns a hash of categories, containing the list of project
diff --git a/graph.c b/graph.c
index e864fe2c6a21379398e454e60627e78a63a09462..391a712e5eafbc05b8d4b739d96aaca0dd481460 100644 (file)
--- a/graph.c
+++ b/graph.c
@@ -1227,7 +1227,7 @@ void graph_show_commit(struct git_graph *graph)
        if (!graph)
                return;
 
-       while (!shown_commit_line) {
+       while (!shown_commit_line && !graph_is_commit_finished(graph)) {
                shown_commit_line = graph_next_line(graph, &msgbuf);
                fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
                if (!shown_commit_line)
index 8701c1215d21cd0413c1d69be91b309984cf6b1f..9923441a4ec74cfdfd3c36b1be41762c04697bdd 100644 (file)
@@ -172,28 +172,7 @@ enum dav_header_flag {
 static char *xml_entities(const char *s)
 {
        struct strbuf buf = STRBUF_INIT;
-       while (*s) {
-               size_t len = strcspn(s, "\"<>&");
-               strbuf_add(&buf, s, len);
-               s += len;
-               switch (*s) {
-               case '"':
-                       strbuf_addstr(&buf, "&quot;");
-                       break;
-               case '<':
-                       strbuf_addstr(&buf, "&lt;");
-                       break;
-               case '>':
-                       strbuf_addstr(&buf, "&gt;");
-                       break;
-               case '&':
-                       strbuf_addstr(&buf, "&amp;");
-                       break;
-               case 0:
-                       return strbuf_detach(&buf, NULL);
-               }
-               s++;
-       }
+       strbuf_addstr_xml_quoted(&buf, s);
        return strbuf_detach(&buf, NULL);
 }
 
diff --git a/http.c b/http.c
index 0a8abf3be369a18fae8e743d4cc9b5f2c2f63f03..44f35256e44ffdda2ffb0ce67825008bef89700f 100644 (file)
--- a/http.c
+++ b/http.c
@@ -236,6 +236,7 @@ static int has_cert_password(void)
                return 0;
        if (!cert_auth.password) {
                cert_auth.protocol = xstrdup("cert");
+               cert_auth.username = xstrdup("");
                cert_auth.path = xstrdup(ssl_cert);
                credential_fill(&cert_auth);
        }
index d42e4712972794f055aec6630ba86797d7e5343c..21dc20b57d392c5789043968d28a3b958b2b50c7 100644 (file)
@@ -33,47 +33,6 @@ typedef void *SSL;
 #include <openssl/hmac.h>
 #endif
 
-struct store_conf {
-       char *name;
-       const char *path; /* should this be here? its interpretation is driver-specific */
-       char *map_inbox;
-       char *trash;
-       unsigned max_size; /* off_t is overkill */
-       unsigned trash_remote_new:1, trash_only_new:1;
-};
-
-/* For message->status */
-#define M_RECENT       (1<<0) /* unsyncable flag; maildir_* depend on this being 1<<0 */
-#define M_DEAD         (1<<1) /* expunged */
-#define M_FLAGS        (1<<2) /* flags fetched */
-
-struct message {
-       struct message *next;
-       size_t size; /* zero implies "not fetched" */
-       int uid;
-       unsigned char flags, status;
-};
-
-struct store {
-       struct store_conf *conf; /* foreign */
-
-       /* currently open mailbox */
-       const char *name; /* foreign! maybe preset? */
-       char *path; /* own */
-       struct message *msgs; /* own */
-       int uidvalidity;
-       unsigned char opts; /* maybe preset? */
-       /* note that the following do _not_ reflect stats from msgs, but mailbox totals */
-       int count; /* # of messages */
-       int recent; /* # of recent messages - don't trust this beyond the initial read */
-};
-
-struct msg_data {
-       char *data;
-       int len;
-       unsigned char flags;
-};
-
 static const char imap_send_usage[] = "git imap-send < <mbox>";
 
 #undef DRV_OK
@@ -91,8 +50,6 @@ static void imap_warn(const char *, ...);
 
 static char *next_arg(char **);
 
-static void free_generic_messages(struct message *);
-
 __attribute__((format (printf, 3, 4)))
 static int nfsnprintf(char *buf, int blen, const char *fmt, ...);
 
@@ -136,20 +93,6 @@ static struct imap_server_conf server = {
        NULL,   /* auth_method */
 };
 
-struct imap_store_conf {
-       struct store_conf gen;
-       struct imap_server_conf *server;
-};
-
-#define NIL    (void *)0x1
-#define LIST   (void *)0x2
-
-struct imap_list {
-       struct imap_list *next, *child;
-       char *val;
-       int len;
-};
-
 struct imap_socket {
        int fd[2];
        SSL *ssl;
@@ -166,7 +109,6 @@ struct imap_cmd;
 
 struct imap {
        int uidnext; /* from SELECT responses */
-       struct imap_list *ns_personal, *ns_other, *ns_shared; /* NAMESPACE info */
        unsigned caps, rcaps; /* CAPABILITY results */
        /* command queue */
        int nexttag, num_in_progress, literal_pending;
@@ -175,11 +117,11 @@ struct imap {
 };
 
 struct imap_store {
-       struct store gen;
+       /* currently open mailbox */
+       const char *name; /* foreign! maybe preset? */
        int uidvalidity;
        struct imap *imap;
        const char *prefix;
-       unsigned /*currentnc:1,*/ trashnc:1;
 };
 
 struct imap_cmd_cb {
@@ -226,14 +168,6 @@ static const char *cap_list[] = {
 static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd);
 
 
-static const char *Flags[] = {
-       "Draft",
-       "Flagged",
-       "Answered",
-       "Seen",
-       "Deleted",
-};
-
 #ifndef NO_OPENSSL
 static void ssl_socket_perror(const char *func)
 {
@@ -477,16 +411,6 @@ static char *next_arg(char **s)
        return ret;
 }
 
-static void free_generic_messages(struct message *msgs)
-{
-       struct message *tmsg;
-
-       for (; msgs; msgs = tmsg) {
-               tmsg = msgs->next;
-               free(msgs);
-       }
-}
-
 static int nfsnprintf(char *buf, int blen, const char *fmt, ...)
 {
        int ret;
@@ -614,35 +538,9 @@ static int imap_exec_m(struct imap_store *ctx, struct imap_cmd_cb *cb,
        }
 }
 
-static int is_atom(struct imap_list *list)
-{
-       return list && list->val && list->val != NIL && list->val != LIST;
-}
-
-static int is_list(struct imap_list *list)
+static int skip_imap_list_l(char **sp, int level)
 {
-       return list && list->val == LIST;
-}
-
-static void free_list(struct imap_list *list)
-{
-       struct imap_list *tmp;
-
-       for (; list; list = tmp) {
-               tmp = list->next;
-               if (is_list(list))
-                       free_list(list->child);
-               else if (is_atom(list))
-                       free(list->val);
-               free(list);
-       }
-}
-
-static int parse_imap_list_l(struct imap *imap, char **sp, struct imap_list **curp, int level)
-{
-       struct imap_list *cur;
-       char *s = *sp, *p;
-       int n, bytes;
+       char *s = *sp;
 
        for (;;) {
                while (isspace((unsigned char)*s))
@@ -651,68 +549,23 @@ static int parse_imap_list_l(struct imap *imap, char **sp, struct imap_list **cu
                        s++;
                        break;
                }
-               *curp = cur = xmalloc(sizeof(*cur));
-               curp = &cur->next;
-               cur->val = NULL; /* for clean bail */
                if (*s == '(') {
                        /* sublist */
                        s++;
-                       cur->val = LIST;
-                       if (parse_imap_list_l(imap, &s, &cur->child, level + 1))
-                               goto bail;
-               } else if (imap && *s == '{') {
-                       /* literal */
-                       bytes = cur->len = strtol(s + 1, &s, 10);
-                       if (*s != '}')
-                               goto bail;
-
-                       s = cur->val = xmalloc(cur->len);
-
-                       /* dump whats left over in the input buffer */
-                       n = imap->buf.bytes - imap->buf.offset;
-
-                       if (n > bytes)
-                               /* the entire message fit in the buffer */
-                               n = bytes;
-
-                       memcpy(s, imap->buf.buf + imap->buf.offset, n);
-                       s += n;
-                       bytes -= n;
-
-                       /* mark that we used part of the buffer */
-                       imap->buf.offset += n;
-
-                       /* now read the rest of the message */
-                       while (bytes > 0) {
-                               if ((n = socket_read(&imap->buf.sock, s, bytes)) <= 0)
-                                       goto bail;
-                               s += n;
-                               bytes -= n;
-                       }
-
-                       if (buffer_gets(&imap->buf, &s))
+                       if (skip_imap_list_l(&s, level + 1))
                                goto bail;
                } else if (*s == '"') {
                        /* quoted string */
                        s++;
-                       p = s;
                        for (; *s != '"'; s++)
                                if (!*s)
                                        goto bail;
-                       cur->len = s - p;
                        s++;
-                       cur->val = xmemdupz(p, cur->len);
                } else {
                        /* atom */
-                       p = s;
                        for (; *s && !isspace((unsigned char)*s); s++)
                                if (level && *s == ')')
                                        break;
-                       cur->len = s - p;
-                       if (cur->len == 3 && !memcmp("NIL", p, 3))
-                               cur->val = NIL;
-                       else
-                               cur->val = xmemdupz(p, cur->len);
                }
 
                if (!level)
@@ -721,27 +574,15 @@ static int parse_imap_list_l(struct imap *imap, char **sp, struct imap_list **cu
                        goto bail;
        }
        *sp = s;
-       *curp = NULL;
        return 0;
 
 bail:
-       *curp = NULL;
        return -1;
 }
 
-static struct imap_list *parse_imap_list(struct imap *imap, char **sp)
+static void skip_list(char **sp)
 {
-       struct imap_list *head;
-
-       if (!parse_imap_list_l(imap, sp, &head, 0))
-               return head;
-       free_list(head);
-       return NULL;
-}
-
-static struct imap_list *parse_list(char **sp)
-{
-       return parse_imap_list(NULL, sp);
+       skip_imap_list_l(sp, 0);
 }
 
 static void parse_capability(struct imap *imap, char *cmd)
@@ -773,7 +614,7 @@ static int parse_response_code(struct imap_store *ctx, struct imap_cmd_cb *cb,
        *p++ = 0;
        arg = next_arg(&s);
        if (!strcmp("UIDVALIDITY", arg)) {
-               if (!(arg = next_arg(&s)) || !(ctx->gen.uidvalidity = atoi(arg))) {
+               if (!(arg = next_arg(&s)) || !(ctx->uidvalidity = atoi(arg))) {
                        fprintf(stderr, "IMAP error: malformed UIDVALIDITY status\n");
                        return RESP_BAD;
                }
@@ -791,7 +632,7 @@ static int parse_response_code(struct imap_store *ctx, struct imap_cmd_cb *cb,
                for (; isspace((unsigned char)*p); p++);
                fprintf(stderr, "*** IMAP ALERT *** %s\n", p);
        } else if (cb && cb->ctx && !strcmp("APPENDUID", arg)) {
-               if (!(arg = next_arg(&s)) || !(ctx->gen.uidvalidity = atoi(arg)) ||
+               if (!(arg = next_arg(&s)) || !(ctx->uidvalidity = atoi(arg)) ||
                    !(arg = next_arg(&s)) || !(*(int *)cb->ctx = atoi(arg))) {
                        fprintf(stderr, "IMAP error: malformed APPENDUID status\n");
                        return RESP_BAD;
@@ -820,20 +661,28 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
                        }
 
                        if (!strcmp("NAMESPACE", arg)) {
-                               imap->ns_personal = parse_list(&cmd);
-                               imap->ns_other = parse_list(&cmd);
-                               imap->ns_shared = parse_list(&cmd);
+                               /* rfc2342 NAMESPACE response. */
+                               skip_list(&cmd); /* Personal mailboxes */
+                               skip_list(&cmd); /* Others' mailboxes */
+                               skip_list(&cmd); /* Shared mailboxes */
                        } else if (!strcmp("OK", arg) || !strcmp("BAD", arg) ||
                                   !strcmp("NO", arg) || !strcmp("BYE", arg)) {
                                if ((resp = parse_response_code(ctx, NULL, cmd)) != RESP_OK)
                                        return resp;
-                       } else if (!strcmp("CAPABILITY", arg))
+                       } else if (!strcmp("CAPABILITY", arg)) {
                                parse_capability(imap, cmd);
-                       else if ((arg1 = next_arg(&cmd))) {
-                               if (!strcmp("EXISTS", arg1))
-                                       ctx->gen.count = atoi(arg);
-                               else if (!strcmp("RECENT", arg1))
-                                       ctx->gen.recent = atoi(arg);
+                       } else if ((arg1 = next_arg(&cmd))) {
+                               ; /*
+                                  * Unhandled response-data with at least two words.
+                                  * Ignore it.
+                                  *
+                                  * NEEDSWORK: Previously this case handled '<num> EXISTS'
+                                  * and '<num> RECENT' but as a probably-unintended side
+                                  * effect it ignores other unrecognized two-word
+                                  * responses.  imap-send doesn't ever try to read
+                                  * messages or mailboxes these days, so consider
+                                  * eliminating this case.
+                                  */
                        } else {
                                fprintf(stderr, "IMAP error: unable to parse untagged response\n");
                                return RESP_BAD;
@@ -935,16 +784,12 @@ static void imap_close_server(struct imap_store *ictx)
                imap_exec(ictx, NULL, "LOGOUT");
                socket_shutdown(&imap->buf.sock);
        }
-       free_list(imap->ns_personal);
-       free_list(imap->ns_other);
-       free_list(imap->ns_shared);
        free(imap);
 }
 
-static void imap_close_store(struct store *ctx)
+static void imap_close_store(struct imap_store *ctx)
 {
-       imap_close_server((struct imap_store *)ctx);
-       free_generic_messages(ctx->msgs);
+       imap_close_server(ctx);
        free(ctx);
 }
 
@@ -1029,7 +874,7 @@ static int auth_cram_md5(struct imap_store *ctx, struct imap_cmd *cmd, const cha
        return 0;
 }
 
-static struct store *imap_open_store(struct imap_server_conf *srvc)
+static struct imap_store *imap_open_store(struct imap_server_conf *srvc)
 {
        struct imap_store *ctx;
        struct imap *imap;
@@ -1239,173 +1084,113 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
        } /* !preauth */
 
        ctx->prefix = "";
-       ctx->trashnc = 1;
-       return (struct store *)ctx;
+       return ctx;
 
 bail:
-       imap_close_store(&ctx->gen);
+       imap_close_store(ctx);
        return NULL;
 }
 
-static int imap_make_flags(int flags, char *buf)
-{
-       const char *s;
-       unsigned i, d;
-
-       for (i = d = 0; i < ARRAY_SIZE(Flags); i++)
-               if (flags & (1 << i)) {
-                       buf[d++] = ' ';
-                       buf[d++] = '\\';
-                       for (s = Flags[i]; *s; s++)
-                               buf[d++] = *s;
-               }
-       buf[0] = '(';
-       buf[d++] = ')';
-       return d;
-}
-
-static void lf_to_crlf(struct msg_data *msg)
+/*
+ * Insert CR characters as necessary in *msg to ensure that every LF
+ * character in *msg is preceded by a CR.
+ */
+static void lf_to_crlf(struct strbuf *msg)
 {
        char *new;
-       int i, j, lfnum = 0;
-
-       if (msg->data[0] == '\n')
-               lfnum++;
-       for (i = 1; i < msg->len; i++) {
-               if (msg->data[i - 1] != '\r' && msg->data[i] == '\n')
-                       lfnum++;
+       size_t i, j;
+       char lastc;
+
+       /* First pass: tally, in j, the size of the new string: */
+       for (i = j = 0, lastc = '\0'; i < msg->len; i++) {
+               if (msg->buf[i] == '\n' && lastc != '\r')
+                       j++; /* a CR will need to be added here */
+               lastc = msg->buf[i];
+               j++;
        }
 
-       new = xmalloc(msg->len + lfnum);
-       if (msg->data[0] == '\n') {
-               new[0] = '\r';
-               new[1] = '\n';
-               i = 1;
-               j = 2;
-       } else {
-               new[0] = msg->data[0];
-               i = 1;
-               j = 1;
-       }
-       for ( ; i < msg->len; i++) {
-               if (msg->data[i] != '\n') {
-                       new[j++] = msg->data[i];
-                       continue;
-               }
-               if (msg->data[i - 1] != '\r')
+       new = xmalloc(j + 1);
+
+       /*
+        * Second pass: write the new string.  Note that this loop is
+        * otherwise identical to the first pass.
+        */
+       for (i = j = 0, lastc = '\0'; i < msg->len; i++) {
+               if (msg->buf[i] == '\n' && lastc != '\r')
                        new[j++] = '\r';
-               /* otherwise it already had CR before */
-               new[j++] = '\n';
+               lastc = new[j++] = msg->buf[i];
        }
-       msg->len += lfnum;
-       free(msg->data);
-       msg->data = new;
+       strbuf_attach(msg, new, j, j + 1);
 }
 
-static int imap_store_msg(struct store *gctx, struct msg_data *data)
+/*
+ * Store msg to IMAP.  Also detach and free the data from msg->data,
+ * leaving msg->data empty.
+ */
+static int imap_store_msg(struct imap_store *ctx, struct strbuf *msg)
 {
-       struct imap_store *ctx = (struct imap_store *)gctx;
        struct imap *imap = ctx->imap;
        struct imap_cmd_cb cb;
        const char *prefix, *box;
-       int ret, d;
-       char flagstr[128];
+       int ret;
 
-       lf_to_crlf(data);
+       lf_to_crlf(msg);
        memset(&cb, 0, sizeof(cb));
 
-       cb.dlen = data->len;
-       cb.data = xmalloc(cb.dlen);
-       memcpy(cb.data, data->data, data->len);
-
-       d = 0;
-       if (data->flags) {
-               d = imap_make_flags(data->flags, flagstr);
-               flagstr[d++] = ' ';
-       }
-       flagstr[d] = 0;
+       cb.dlen = msg->len;
+       cb.data = strbuf_detach(msg, NULL);
 
-       box = gctx->name;
+       box = ctx->name;
        prefix = !strcmp(box, "INBOX") ? "" : ctx->prefix;
        cb.create = 0;
-       ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" %s", prefix, box, flagstr);
+       ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" ", prefix, box);
        imap->caps = imap->rcaps;
        if (ret != DRV_OK)
                return ret;
-       gctx->count++;
 
        return DRV_OK;
 }
 
-static void encode_html_chars(struct strbuf *p)
-{
-       int i;
-       for (i = 0; i < p->len; i++) {
-               if (p->buf[i] == '&')
-                       strbuf_splice(p, i, 1, "&amp;", 5);
-               if (p->buf[i] == '<')
-                       strbuf_splice(p, i, 1, "&lt;", 4);
-               if (p->buf[i] == '>')
-                       strbuf_splice(p, i, 1, "&gt;", 4);
-               if (p->buf[i] == '"')
-                       strbuf_splice(p, i, 1, "&quot;", 6);
-       }
-}
-static void wrap_in_html(struct msg_data *msg)
+static void wrap_in_html(struct strbuf *msg)
 {
        struct strbuf buf = STRBUF_INIT;
-       struct strbuf **lines;
-       struct strbuf **p;
        static char *content_type = "Content-Type: text/html;\n";
        static char *pre_open = "<pre>\n";
        static char *pre_close = "</pre>\n";
-       int added_header = 0;
-
-       strbuf_attach(&buf, msg->data, msg->len, msg->len);
-       lines = strbuf_split(&buf, '\n');
-       strbuf_release(&buf);
-       for (p = lines; *p; p++) {
-               if (! added_header) {
-                       if ((*p)->len == 1 && *((*p)->buf) == '\n') {
-                               strbuf_addstr(&buf, content_type);
-                               strbuf_addbuf(&buf, *p);
-                               strbuf_addstr(&buf, pre_open);
-                               added_header = 1;
-                               continue;
-                       }
-               }
-               else
-                       encode_html_chars(*p);
-               strbuf_addbuf(&buf, *p);
-       }
+       const char *body = strstr(msg->buf, "\n\n");
+
+       if (!body)
+               return; /* Headers but no body; no wrapping needed */
+
+       body += 2;
+
+       strbuf_add(&buf, msg->buf, body - msg->buf - 1);
+       strbuf_addstr(&buf, content_type);
+       strbuf_addch(&buf, '\n');
+       strbuf_addstr(&buf, pre_open);
+       strbuf_addstr_xml_quoted(&buf, body);
        strbuf_addstr(&buf, pre_close);
-       strbuf_list_free(lines);
-       msg->len  = buf.len;
-       msg->data = strbuf_detach(&buf, NULL);
+
+       strbuf_release(msg);
+       *msg = buf;
 }
 
 #define CHUNKSIZE 0x1000
 
-static int read_message(FILE *f, struct msg_data *msg)
+static int read_message(FILE *f, struct strbuf *all_msgs)
 {
-       struct strbuf buf = STRBUF_INIT;
-
-       memset(msg, 0, sizeof(*msg));
-
        do {
-               if (strbuf_fread(&buf, CHUNKSIZE, f) <= 0)
+               if (strbuf_fread(all_msgs, CHUNKSIZE, f) <= 0)
                        break;
        } while (!feof(f));
 
-       msg->len  = buf.len;
-       msg->data = strbuf_detach(&buf, NULL);
-       return msg->len;
+       return ferror(f) ? -1 : 0;
 }
 
-static int count_messages(struct msg_data *msg)
+static int count_messages(struct strbuf *all_msgs)
 {
        int count = 0;
-       char *p = msg->data;
+       char *p = all_msgs->buf;
 
        while (1) {
                if (!prefixcmp(p, "From ")) {
@@ -1426,34 +1211,39 @@ static int count_messages(struct msg_data *msg)
        return count;
 }
 
-static int split_msg(struct msg_data *all_msgs, struct msg_data *msg, int *ofs)
+/*
+ * Copy the next message from all_msgs, starting at offset *ofs, to
+ * msg.  Update *ofs to the start of the following message.  Return
+ * true iff a message was successfully copied.
+ */
+static int split_msg(struct strbuf *all_msgs, struct strbuf *msg, int *ofs)
 {
        char *p, *data;
+       size_t len;
 
-       memset(msg, 0, sizeof *msg);
        if (*ofs >= all_msgs->len)
                return 0;
 
-       data = &all_msgs->data[*ofs];
-       msg->len = all_msgs->len - *ofs;
+       data = &all_msgs->buf[*ofs];
+       len = all_msgs->len - *ofs;
 
-       if (msg->len < 5 || prefixcmp(data, "From "))
+       if (len < 5 || prefixcmp(data, "From "))
                return 0;
 
        p = strchr(data, '\n');
        if (p) {
-               p = &p[1];
-               msg->len -= p-data;
-               *ofs += p-data;
+               p++;
+               len -= p - data;
+               *ofs += p - data;
                data = p;
        }
 
        p = strstr(data, "\nFrom ");
        if (p)
-               msg->len = &p[1] - data;
+               len = &p[1] - data;
 
-       msg->data = xmemdupz(data, msg->len);
-       *ofs += msg->len;
+       strbuf_add(msg, data, len);
+       *ofs += len;
        return 1;
 }
 
@@ -1504,8 +1294,9 @@ static int git_imap_config(const char *key, const char *val, void *cb)
 
 int main(int argc, char **argv)
 {
-       struct msg_data all_msgs, msg;
-       struct store *ctx = NULL;
+       struct strbuf all_msgs = STRBUF_INIT;
+       struct strbuf msg = STRBUF_INIT;
+       struct imap_store *ctx = NULL;
        int ofs = 0;
        int r;
        int total, n = 0;
@@ -1537,7 +1328,12 @@ int main(int argc, char **argv)
        }
 
        /* read the messages */
-       if (!read_message(stdin, &all_msgs)) {
+       if (read_message(stdin, &all_msgs)) {
+               fprintf(stderr, "error reading input\n");
+               return 1;
+       }
+
+       if (all_msgs.len == 0) {
                fprintf(stderr, "nothing to send\n");
                return 1;
        }
@@ -1559,6 +1355,7 @@ int main(int argc, char **argv)
        ctx->name = imap_folder;
        while (1) {
                unsigned percent = n * 100 / total;
+
                fprintf(stderr, "%4u%% (%d/%d) done\r", percent, n, total);
                if (!split_msg(&all_msgs, &msg, &ofs))
                        break;
index 4f86defe324bac8374585df5d9e8ef7b5f9a3524..5dc45c4812bdfd0d7a6b71d529eaa37df8178186 100644 (file)
@@ -299,26 +299,34 @@ static unsigned int digits_in_number(unsigned int number)
        return result;
 }
 
-void get_patch_filename(struct commit *commit, const char *subject, int nr,
-                       const char *suffix, struct strbuf *buf)
+void fmt_output_subject(struct strbuf *filename,
+                       const char *subject,
+                       struct rev_info *info)
 {
-       int suffix_len = strlen(suffix) + 1;
-       int start_len = buf->len;
-
-       strbuf_addf(buf, commit || subject ? "%04d-" : "%d", nr);
-       if (commit || subject) {
-               int max_len = start_len + FORMAT_PATCH_NAME_MAX - suffix_len;
-               struct pretty_print_context ctx = {0};
-
-               if (subject)
-                       strbuf_addstr(buf, subject);
-               else if (commit)
-                       format_commit_message(commit, "%f", buf, &ctx);
-
-               if (max_len < buf->len)
-                       strbuf_setlen(buf, max_len);
-               strbuf_addstr(buf, suffix);
-       }
+       const char *suffix = info->patch_suffix;
+       int nr = info->nr;
+       int start_len = filename->len;
+       int max_len = start_len + FORMAT_PATCH_NAME_MAX - (strlen(suffix) + 1);
+
+       if (0 < info->reroll_count)
+               strbuf_addf(filename, "v%d-", info->reroll_count);
+       strbuf_addf(filename, "%04d-%s", nr, subject);
+
+       if (max_len < filename->len)
+               strbuf_setlen(filename, max_len);
+       strbuf_addstr(filename, suffix);
+}
+
+void fmt_output_commit(struct strbuf *filename,
+                      struct commit *commit,
+                      struct rev_info *info)
+{
+       struct pretty_print_context ctx = {0};
+       struct strbuf subject = STRBUF_INIT;
+
+       format_commit_message(commit, "%f", &subject, &ctx);
+       fmt_output_subject(filename, subject.buf, info);
+       strbuf_release(&subject);
 }
 
 void log_write_email_headers(struct rev_info *opt, struct commit *commit,
@@ -387,8 +395,10 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
                         mime_boundary_leader, opt->mime_boundary);
                extra_headers = subject_buffer;
 
-               get_patch_filename(opt->numbered_files ? NULL : commit, NULL,
-                                  opt->nr, opt->patch_suffix, &filename);
+               if (opt->numbered_files)
+                       strbuf_addf(&filename, "%d", opt->nr);
+               else
+                       fmt_output_commit(&filename, commit, opt);
                snprintf(buffer, sizeof(buffer) - 1,
                         "\n--%s%s\n"
                         "Content-Type: text/x-patch;"
@@ -671,6 +681,8 @@ void show_log(struct rev_info *opt)
        ctx.preserve_subject = opt->preserve_subject;
        ctx.reflog_info = opt->reflog_info;
        ctx.fmt = opt->commit_format;
+       ctx.mailmap = opt->mailmap;
+       ctx.color = opt->diffopt.use_color;
        pretty_print_commit(&ctx, commit, &msgbuf);
 
        if (opt->add_signoff)
index f5ac238bba478851bb10b09f32ea75da05475267..9140f48216be10085c9a1aea7ef1d210817c3332 100644 (file)
@@ -21,7 +21,7 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
 void load_ref_decorations(int flags);
 
 #define FORMAT_PATCH_NAME_MAX 64
-void get_patch_filename(struct commit *commit, const char *subject, int nr,
-                       const char *suffix, struct strbuf *buf);
+void fmt_output_commit(struct strbuf *, struct commit *, struct rev_info *);
+void fmt_output_subject(struct strbuf *, const char *subject, struct rev_info *);
 
 #endif
index ea4b471edeb5ca9b29a8138f6f831a5e6a15a9e8..2a7b36628cb5623eb0ffb95bfb54e52a6dd300f4 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -10,6 +10,7 @@ static inline void debug_mm(const char *format, ...) {}
 #endif
 
 const char *git_mailmap_file;
+const char *git_mailmap_blob;
 
 struct mailmap_info {
        char *name;
@@ -129,54 +130,120 @@ static char *parse_name_and_email(char *buffer, char **name,
        return (*right == '\0' ? NULL : right);
 }
 
-static int read_single_mailmap(struct string_list *map, const char *filename, char **repo_abbrev)
+static void read_mailmap_line(struct string_list *map, char *buffer,
+                             char **repo_abbrev)
+{
+       char *name1 = NULL, *email1 = NULL, *name2 = NULL, *email2 = NULL;
+       if (buffer[0] == '#') {
+               static const char abbrev[] = "# repo-abbrev:";
+               int abblen = sizeof(abbrev) - 1;
+               int len = strlen(buffer);
+
+               if (!repo_abbrev)
+                       return;
+
+               if (len && buffer[len - 1] == '\n')
+                       buffer[--len] = 0;
+               if (!strncmp(buffer, abbrev, abblen)) {
+                       char *cp;
+
+                       if (repo_abbrev)
+                               free(*repo_abbrev);
+                       *repo_abbrev = xmalloc(len);
+
+                       for (cp = buffer + abblen; isspace(*cp); cp++)
+                               ; /* nothing */
+                       strcpy(*repo_abbrev, cp);
+               }
+               return;
+       }
+       if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)) != NULL)
+               parse_name_and_email(name2, &name2, &email2, 1);
+
+       if (email1)
+               add_mapping(map, name1, email1, name2, email2);
+}
+
+static int read_mailmap_file(struct string_list *map, const char *filename,
+                            char **repo_abbrev)
 {
        char buffer[1024];
-       FILE *f = (filename == NULL ? NULL : fopen(filename, "r"));
+       FILE *f;
 
-       if (f == NULL)
-               return 1;
-       while (fgets(buffer, sizeof(buffer), f) != NULL) {
-               char *name1 = NULL, *email1 = NULL, *name2 = NULL, *email2 = NULL;
-               if (buffer[0] == '#') {
-                       static const char abbrev[] = "# repo-abbrev:";
-                       int abblen = sizeof(abbrev) - 1;
-                       int len = strlen(buffer);
-
-                       if (!repo_abbrev)
-                               continue;
-
-                       if (len && buffer[len - 1] == '\n')
-                               buffer[--len] = 0;
-                       if (!strncmp(buffer, abbrev, abblen)) {
-                               char *cp;
-
-                               if (repo_abbrev)
-                                       free(*repo_abbrev);
-                               *repo_abbrev = xmalloc(len);
-
-                               for (cp = buffer + abblen; isspace(*cp); cp++)
-                                       ; /* nothing */
-                               strcpy(*repo_abbrev, cp);
-                       }
-                       continue;
-               }
-               if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)) != NULL)
-                       parse_name_and_email(name2, &name2, &email2, 1);
+       if (!filename)
+               return 0;
 
-               if (email1)
-                       add_mapping(map, name1, email1, name2, email2);
+       f = fopen(filename, "r");
+       if (!f) {
+               if (errno == ENOENT)
+                       return 0;
+               return error("unable to open mailmap at %s: %s",
+                            filename, strerror(errno));
        }
+
+       while (fgets(buffer, sizeof(buffer), f) != NULL)
+               read_mailmap_line(map, buffer, repo_abbrev);
        fclose(f);
        return 0;
 }
 
+static void read_mailmap_buf(struct string_list *map,
+                            const char *buf, unsigned long len,
+                            char **repo_abbrev)
+{
+       while (len) {
+               const char *end = strchrnul(buf, '\n');
+               unsigned long linelen = end - buf + 1;
+               char *line = xmemdupz(buf, linelen);
+
+               read_mailmap_line(map, line, repo_abbrev);
+
+               free(line);
+               buf += linelen;
+               len -= linelen;
+       }
+}
+
+static int read_mailmap_blob(struct string_list *map,
+                            const char *name,
+                            char **repo_abbrev)
+{
+       unsigned char sha1[20];
+       char *buf;
+       unsigned long size;
+       enum object_type type;
+
+       if (!name)
+               return 0;
+       if (get_sha1(name, sha1) < 0)
+               return 0;
+
+       buf = read_sha1_file(sha1, &type, &size);
+       if (!buf)
+               return error("unable to read mailmap object at %s", name);
+       if (type != OBJ_BLOB)
+               return error("mailmap is not a blob: %s", name);
+
+       read_mailmap_buf(map, buf, size, repo_abbrev);
+
+       free(buf);
+       return 0;
+}
+
 int read_mailmap(struct string_list *map, char **repo_abbrev)
 {
+       int err = 0;
+
        map->strdup_strings = 1;
-       /* each failure returns 1, so >1 means both calls failed */
-       return read_single_mailmap(map, ".mailmap", repo_abbrev) +
-              read_single_mailmap(map, git_mailmap_file, repo_abbrev) > 1;
+       map->cmp = strcasecmp;
+
+       if (!git_mailmap_blob && is_bare_repository())
+               git_mailmap_blob = "HEAD:.mailmap";
+
+       err |= read_mailmap_file(map, ".mailmap", repo_abbrev);
+       err |= read_mailmap_blob(map, git_mailmap_blob, repo_abbrev);
+       err |= read_mailmap_file(map, git_mailmap_file, repo_abbrev);
+       return err;
 }
 
 void clear_mailmap(struct string_list *map)
@@ -187,60 +254,95 @@ void clear_mailmap(struct string_list *map)
        debug_mm("mailmap: cleared\n");
 }
 
+/*
+ * Look for an entry in map that match string[0:len]; string[len]
+ * does not have to be NUL (but it could be).
+ */
+static struct string_list_item *lookup_prefix(struct string_list *map,
+                                             const char *string, size_t len)
+{
+       int i = string_list_find_insert_index(map, string, 1);
+       if (i < 0) {
+               /* exact match */
+               i = -1 - i;
+               if (!string[len])
+                       return &map->items[i];
+               /*
+                * that map entry matches exactly to the string, including
+                * the cruft at the end beyond "len".  That is not a match
+                * with string[0:len] that we are looking for.
+                */
+       } else if (!string[len]) {
+               /*
+                * asked with the whole string, and got nothing.  No
+                * matching entry can exist in the map.
+                */
+               return NULL;
+       }
+
+       /*
+        * i is at the exact match to an overlong key, or location the
+        * overlong key would be inserted, which must come after the
+        * real location of the key if one exists.
+        */
+       while (0 <= --i && i < map->nr) {
+               int cmp = strncasecmp(map->items[i].string, string, len);
+               if (cmp < 0)
+                       /*
+                        * "i" points at a key definitely below the prefix;
+                        * the map does not have string[0:len] in it.
+                        */
+                       break;
+               else if (!cmp && !map->items[i].string[len])
+                       /* found it */
+                       return &map->items[i];
+               /*
+                * otherwise, the string at "i" may be string[0:len]
+                * followed by a string that sorts later than string[len:];
+                * keep trying.
+                */
+       }
+       return NULL;
+}
+
 int map_user(struct string_list *map,
-            char *email, int maxlen_email, char *name, int maxlen_name)
+                        const char **email, size_t *emaillen,
+                        const char **name, size_t *namelen)
 {
-       char *end_of_email;
        struct string_list_item *item;
        struct mailmap_entry *me;
-       char buf[1024], *mailbuf;
-       int i;
-
-       /* figure out space requirement for email */
-       end_of_email = strchr(email, '>');
-       if (!end_of_email) {
-               /* email passed in might not be wrapped in <>, but end with a \0 */
-               end_of_email = memchr(email, '\0', maxlen_email);
-               if (!end_of_email)
-                       return 0;
-       }
-       if (end_of_email - email + 1 < sizeof(buf))
-               mailbuf = buf;
-       else
-               mailbuf = xmalloc(end_of_email - email + 1);
-
-       /* downcase the email address */
-       for (i = 0; i < end_of_email - email; i++)
-               mailbuf[i] = tolower(email[i]);
-       mailbuf[i] = 0;
-
-       debug_mm("map_user: map '%s' <%s>\n", name, mailbuf);
-       item = string_list_lookup(map, mailbuf);
+
+       debug_mm("map_user: map '%.*s' <%.*s>\n",
+                *name, *namelen, *emaillen, *email);
+
+       item = lookup_prefix(map, *email, *emaillen);
        if (item != NULL) {
                me = (struct mailmap_entry *)item->util;
                if (me->namemap.nr) {
                        /* The item has multiple items, so we'll look up on name too */
                        /* If the name is not found, we choose the simple entry      */
-                       struct string_list_item *subitem = string_list_lookup(&me->namemap, name);
+                       struct string_list_item *subitem;
+                       subitem = lookup_prefix(&me->namemap, *name, *namelen);
                        if (subitem)
                                item = subitem;
                }
        }
-       if (mailbuf != buf)
-               free(mailbuf);
        if (item != NULL) {
                struct mailmap_info *mi = (struct mailmap_info *)item->util;
-               if (mi->name == NULL && (mi->email == NULL || maxlen_email == 0)) {
+               if (mi->name == NULL && mi->email == NULL) {
                        debug_mm("map_user:  -- (no simple mapping)\n");
                        return 0;
                }
-               if (maxlen_email && mi->email)
-                       strlcpy(email, mi->email, maxlen_email);
-               else
-                       *end_of_email = '\0';
-               if (maxlen_name && mi->name)
-                       strlcpy(name, mi->name, maxlen_name);
-               debug_mm("map_user:  to '%s' <%s>\n", name, mi->email ? mi->email : "");
+               if (mi->email) {
+                               *email = mi->email;
+                               *emaillen = strlen(*email);
+               }
+               if (mi->name) {
+                               *name = mi->name;
+                               *namelen = strlen(*name);
+               }
+               debug_mm("map_user:  to '%.*s' <.*%s>\n", *namelen, *name,
+                                *emaillen, *email);
                return 1;
        }
        debug_mm("map_user:  --\n");
index d5c3664322023d6552cb24006d833aa08224ff6f..ed7c93b05c3cc904c3052bae199346a698eec1e6 100644 (file)
--- a/mailmap.h
+++ b/mailmap.h
@@ -4,7 +4,7 @@
 int read_mailmap(struct string_list *map, char **repo_abbrev);
 void clear_mailmap(struct string_list *map);
 
-int map_user(struct string_list *mailmap,
-            char *email, int maxlen_email, char *name, int maxlen_name);
+int map_user(struct string_list *map,
+                        const char **email, size_t *emaillen, const char **name, size_t *namelen);
 
 #endif
similarity index 94%
rename from merge-file.c
rename to merge-blobs.c
index 7845528e88eea6a42f914b5bf596473eb33dea40..57211bccb7d0a5aad8538906bcb2f4ad2900f008 100644 (file)
@@ -3,7 +3,7 @@
 #include "xdiff-interface.h"
 #include "ll-merge.h"
 #include "blob.h"
-#include "merge-file.h"
+#include "merge-blobs.h"
 
 static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
 {
@@ -80,7 +80,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
        return xdi_diff(f1, f2, &xpp, &xecfg, &ecb);
 }
 
-void *merge_file(const char *path, struct blob *base, struct blob *our, struct blob *their, unsigned long *size)
+void *merge_blobs(const char *path, struct blob *base, struct blob *our, struct blob *their, unsigned long *size)
 {
        void *res = NULL;
        mmfile_t f1, f2, common;
diff --git a/merge-blobs.h b/merge-blobs.h
new file mode 100644 (file)
index 0000000..62b569e
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef MERGE_BLOBS_H
+#define MERGE_BLOBS_H
+
+#include "blob.h"
+
+extern void *merge_blobs(const char *, struct blob *, struct blob *, struct blob *, unsigned long *);
+
+#endif /* MERGE_BLOBS_H */
diff --git a/merge-file.h b/merge-file.h
deleted file mode 100644 (file)
index 9b3b83a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef MERGE_FILE_H
-#define MERGE_FILE_H
-
-extern void *merge_file(const char *path, struct blob *base, struct blob *our,
-                       struct blob *their, unsigned long *size);
-
-#endif
index d8820604ca3535ce25796012412fe69f1cbdd37b..33ba5dc07c86a81f0989927b9a6167833815533f 100644 (file)
@@ -976,7 +976,7 @@ merge_file_special_markers(struct merge_options *o,
        return mfi;
 }
 
-static struct merge_file_info merge_file(struct merge_options *o,
+static struct merge_file_info merge_file_one(struct merge_options *o,
                                         const char *path,
                                         const unsigned char *o_sha, int o_mode,
                                         const unsigned char *a_sha, int a_mode,
@@ -1166,7 +1166,7 @@ static void conflict_rename_rename_1to2(struct merge_options *o,
                struct merge_file_info mfi;
                struct diff_filespec other;
                struct diff_filespec *add;
-               mfi = merge_file(o, one->path,
+               mfi = merge_file_one(o, one->path,
                                 one->sha1, one->mode,
                                 a->sha1, a->mode,
                                 b->sha1, b->mode,
@@ -1450,7 +1450,7 @@ static int process_renames(struct merge_options *o,
                                       ren1_dst, branch2);
                                if (o->call_depth) {
                                        struct merge_file_info mfi;
-                                       mfi = merge_file(o, ren1_dst, null_sha1, 0,
+                                       mfi = merge_file_one(o, ren1_dst, null_sha1, 0,
                                                         ren1->pair->two->sha1, ren1->pair->two->mode,
                                                         dst_other.sha1, dst_other.mode,
                                                         branch1, branch2);
index 295361a8aa7d075bbb9fdb8173858e37f9a43211..52f7c8f70578929432becdd58a7fb423398f8de8 100644 (file)
@@ -1,29 +1,21 @@
 diff_cmd () {
+       empty_file=
+
        # p4merge does not like /dev/null
-       rm_local=
-       rm_remote=
        if test "/dev/null" = "$LOCAL"
        then
-               LOCAL="./p4merge-dev-null.LOCAL.$$"
-               >"$LOCAL"
-               rm_local=true
+               LOCAL="$(create_empty_file)"
        fi
        if test "/dev/null" = "$REMOTE"
        then
-               REMOTE="./p4merge-dev-null.REMOTE.$$"
-               >"$REMOTE"
-               rm_remote=true
+               REMOTE="$(create_empty_file)"
        fi
 
        "$merge_tool_path" "$LOCAL" "$REMOTE"
 
-       if test -n "$rm_local"
-       then
-               rm -f "$LOCAL"
-       fi
-       if test -n "$rm_remote"
+       if test -n "$empty_file"
        then
-               rm -f "$REMOTE"
+               rm -f "$empty_file"
        fi
 }
 
@@ -33,3 +25,10 @@ merge_cmd () {
        "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
        check_unchanged
 }
+
+create_empty_file () {
+       empty_file="${TMPDIR:-/tmp}/git-difftool-p4merge-empty-file.$$"
+       >"$empty_file"
+
+       printf "$empty_file"
+}
diff --git a/path.c b/path.c
index cbbdf7d6ba68160a3a9936976e53d773d181ceac..d3d3f8b8ad75b9817df3014296aabc34b6a4eb14 100644 (file)
--- a/path.c
+++ b/path.c
@@ -12,6 +12,7 @@
  */
 #include "cache.h"
 #include "strbuf.h"
+#include "string-list.h"
 
 static char bad_path[] = "/bad-path/";
 
@@ -569,43 +570,38 @@ int normalize_path_copy(char *dst, const char *src)
 
 /*
  * path = Canonical absolute path
- * prefix_list = Colon-separated list of absolute paths
+ * prefixes = string_list containing normalized, absolute paths without
+ * trailing slashes (except for the root directory, which is denoted by "/").
  *
- * Determines, for each path in prefix_list, whether the "prefix" really
+ * Determines, for each path in prefixes, whether the "prefix"
  * is an ancestor directory of path.  Returns the length of the longest
  * ancestor directory, excluding any trailing slashes, or -1 if no prefix
- * is an ancestor.  (Note that this means 0 is returned if prefix_list is
- * "/".) "/foo" is not considered an ancestor of "/foobar".  Directories
+ * is an ancestor.  (Note that this means 0 is returned if prefixes is
+ * ["/"].) "/foo" is not considered an ancestor of "/foobar".  Directories
  * are not considered to be their own ancestors.  path must be in a
  * canonical form: empty components, or "." or ".." components are not
- * allowed.  prefix_list may be null, which is like "".
+ * allowed.
  */
-int longest_ancestor_length(const char *path, const char *prefix_list)
+int longest_ancestor_length(const char *path, struct string_list *prefixes)
 {
-       char buf[PATH_MAX+1];
-       const char *ceil, *colon;
-       int len, max_len = -1;
+       int i, max_len = -1;
 
-       if (prefix_list == NULL || !strcmp(path, "/"))
+       if (!strcmp(path, "/"))
                return -1;
 
-       for (colon = ceil = prefix_list; *colon; ceil = colon+1) {
-               for (colon = ceil; *colon && *colon != PATH_SEP; colon++);
-               len = colon - ceil;
-               if (len == 0 || len > PATH_MAX || !is_absolute_path(ceil))
-                       continue;
-               strlcpy(buf, ceil, len+1);
-               if (normalize_path_copy(buf, buf) < 0)
-                       continue;
-               len = strlen(buf);
-               if (len > 0 && buf[len-1] == '/')
-                       buf[--len] = '\0';
+       for (i = 0; i < prefixes->nr; i++) {
+               const char *ceil = prefixes->items[i].string;
+               int len = strlen(ceil);
 
-               if (!strncmp(path, buf, len) &&
-                   path[len] == '/' &&
-                   len > max_len) {
+               if (len == 1 && ceil[0] == '/')
+                       len = 0; /* root matches anything, with length 0 */
+               else if (!strncmp(path, ceil, len) && path[len] == '/')
+                       ; /* match of length len */
+               else
+                       continue; /* no match */
+
+               if (len > max_len)
                        max_len = len;
-               }
        }
 
        return max_len;
index 497f420178a73061901393f8c21a9feb17054b6d..931047c51da22cddefe0eab08d0fdaa595daefef 100644 (file)
@@ -58,7 +58,7 @@ require Exporter;
                 command_output_pipe command_input_pipe command_close_pipe
                 command_bidi_pipe command_close_bidi_pipe
                 version exec_path html_path hash_object git_cmd_try
-                remote_refs
+                remote_refs prompt
                 temp_acquire temp_release temp_reset temp_path);
 
 
@@ -511,6 +511,58 @@ C<git --html-path>). Useful mostly only internally.
 
 sub html_path { command_oneline('--html-path') }
 
+=item prompt ( PROMPT , ISPASSWORD  )
+
+Query user C<PROMPT> and return answer from user.
+
+Honours GIT_ASKPASS and SSH_ASKPASS environment variables for querying
+the user. If no *_ASKPASS variable is set or an error occoured,
+the terminal is tried as a fallback.
+If C<ISPASSWORD> is set and true, the terminal disables echo.
+
+=cut
+
+sub prompt {
+       my ($prompt, $isPassword) = @_;
+       my $ret;
+       if (exists $ENV{'GIT_ASKPASS'}) {
+               $ret = _prompt($ENV{'GIT_ASKPASS'}, $prompt);
+       }
+       if (!defined $ret && exists $ENV{'SSH_ASKPASS'}) {
+               $ret = _prompt($ENV{'SSH_ASKPASS'}, $prompt);
+       }
+       if (!defined $ret) {
+               print STDERR $prompt;
+               STDERR->flush;
+               if (defined $isPassword && $isPassword) {
+                       require Term::ReadKey;
+                       Term::ReadKey::ReadMode('noecho');
+                       $ret = '';
+                       while (defined(my $key = Term::ReadKey::ReadKey(0))) {
+                               last if $key =~ /[\012\015]/; # \n\r
+                               $ret .= $key;
+                       }
+                       Term::ReadKey::ReadMode('restore');
+                       print STDERR "\n";
+                       STDERR->flush;
+               } else {
+                       chomp($ret = <STDIN>);
+               }
+       }
+       return $ret;
+}
+
+sub _prompt {
+       my ($askpass, $prompt) = @_;
+       return unless length $askpass;
+       $prompt =~ s/\n/ /g;
+       my $ret;
+       open my $fh, "-|", $askpass, $prompt or return;
+       $ret = <$fh>;
+       $ret =~ s/[\015\012]//g; # strip \r\n, chomp does not work on all systems (i.e. windows) as expected
+       close ($fh);
+       return $ret;
+}
 
 =item repo_path ()
 
index 3bbc20a054576b75e77a15faffd82c46e553fef8..3db152155c62fb43b6243c10ce25cc193895afe3 100644 (file)
@@ -145,7 +145,8 @@ sub repo_path {
 sub url_path {
        my ($self, $path) = @_;
        if ($self->{url} =~ m#^https?://#) {
-               $path =~ s!([^~a-zA-Z0-9_./-])!uc sprintf("%%%02x",ord($1))!eg;
+               # characters are taken from subversion/libsvn_subr/path.c
+               $path =~ s#([^~a-zA-Z0-9_./!$&'()*+,-])#uc sprintf("%%%02x",ord($1))#eg;
        }
        $self->{url} . '/' . $self->repo_path($path);
 }
@@ -358,12 +359,12 @@ sub T {
                        mode_a => $m->{mode_a}, mode_b => '000000',
                        sha1_a => $m->{sha1_a}, sha1_b => '0' x 40,
                        chg => 'D', file_b => $m->{file_b}
-               });
+               }, $deletions);
                $self->A({
                        mode_a => '000000', mode_b => $m->{mode_b},
                        sha1_a => '0' x 40, sha1_b => $m->{sha1_b},
                        chg => 'A', file_b => $m->{file_b}
-               });
+               }, $deletions);
                return;
        }
 
index 3a6f8af0d9849c5f2fc886f8fc3ac9a8575e271e..74daa7a597fcf55a649a4e90367b1e783a74fcd5 100644 (file)
@@ -62,16 +62,16 @@ sub ssl_server_trust {
                                       issuer_dname fingerprint);
        my $choice;
 prompt:
-       print STDERR $may_save ?
+       my $options = $may_save ?
              "(R)eject, accept (t)emporarily or accept (p)ermanently? " :
              "(R)eject or accept (t)emporarily? ";
        STDERR->flush;
-       $choice = lc(substr(<STDIN> || 'R', 0, 1));
-       if ($choice =~ /^t$/i) {
+       $choice = lc(substr(Git::prompt("Certificate problem.\n" . $options) || 'R', 0, 1));
+       if ($choice eq 't') {
                $cred->may_save(undef);
-       } elsif ($choice =~ /^r$/i) {
+       } elsif ($choice eq 'r') {
                return -1;
-       } elsif ($may_save && $choice =~ /^p$/i) {
+       } elsif ($may_save && $choice eq 'p') {
                $cred->may_save($may_save);
        } else {
                goto prompt;
@@ -109,9 +109,7 @@ sub username {
        if (defined $_username) {
                $username = $_username;
        } else {
-               print STDERR "Username: ";
-               STDERR->flush;
-               chomp($username = <STDIN>);
+               $username = Git::prompt("Username: ");
        }
        $cred->username($username);
        $cred->may_save($may_save);
@@ -120,25 +118,7 @@ sub username {
 
 sub _read_password {
        my ($prompt, $realm) = @_;
-       my $password = '';
-       if (exists $ENV{GIT_ASKPASS}) {
-               open(PH, "-|", $ENV{GIT_ASKPASS}, $prompt);
-               $password = <PH>;
-               $password =~ s/[\012\015]//; # \n\r
-               close(PH);
-       } else {
-               print STDERR $prompt;
-               STDERR->flush;
-               require Term::ReadKey;
-               Term::ReadKey::ReadMode('noecho');
-               while (defined(my $key = Term::ReadKey::ReadKey(0))) {
-                       last if $key =~ /[\012\015]/; # \n\r
-                       $password .= $key;
-               }
-               Term::ReadKey::ReadMode('restore');
-               print STDERR "\n";
-               STDERR->flush;
-       }
+       my $password = Git::prompt($prompt, 1);
        $password;
 }
 
index 8b8cf3755c268e03ef334534092bcd7959070cd2..3d1a0933a2eb27dc123730c67470be503e91bf93 100644 (file)
@@ -155,7 +155,7 @@ sub _canonicalize_url_path {
 
        my @parts;
        foreach my $part (split m{/+}, $uri_path) {
-               $part =~ s/([^~\w.%+-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg;
+               $part =~ s/([^!\$%&'()*+,.\/\w:=\@_`~-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg;
                push @parts, $part;
        }
 
index 0e8ed5437af275a4bb41a67debefe04bdc07a88e..c8ad2f01c91b2349bc0e778b3dff0da26070c00a 100644 (file)
--- a/po/de.po
+++ b/po/de.po
@@ -33,10 +33,10 @@ msgid ""
 "appropriate to mark resolution and make a commit,\n"
 "or use 'git commit -a'."
 msgstr ""
-"Korrigiere dies im Arbeitsbaum,\n"
-"und benutze dann 'git add/rm <Datei>'\n"
+"Korrigieren Sie dies im Arbeitsbaum,\n"
+"und benutzen Sie dann 'git add/rm <Datei>'\n"
 "um die Auflösung entsprechend zu markieren und einzutragen,\n"
-"oder benutze 'git commit -a'."
+"oder benutzen Sie 'git commit -a'."
 
 #: archive.c:10
 msgid "git archive [options] <tree-ish> [<path>...]"
@@ -131,7 +131,7 @@ msgid ""
 "Use '\\!' for literal leading exclamation."
 msgstr ""
 "Verneinende Muster sind in Git-Attributen verboten.\n"
-"Benutze '\\!' für führende Ausrufezeichen."
+"Benutzen Sie '\\!' für führende Ausrufezeichen."
 
 #: bundle.c:36
 #, c-format
@@ -381,7 +381,7 @@ msgstr "Vorhandene Git-Kommandos in '%s'"
 
 #: help.c:219
 msgid "git commands available from elsewhere on your $PATH"
-msgstr "Vorhandene Git-Kommandos irgendwo in deinem $PATH"
+msgstr "Vorhandene Git-Kommandos irgendwo in Ihrem $PATH"
 
 #: help.c:275
 #, c-format
@@ -394,7 +394,7 @@ msgstr ""
 
 #: help.c:332
 msgid "Uh oh. Your system reports no Git commands at all."
-msgstr "Uh oh. Keine Git-Kommandos auf deinem System vorhanden."
+msgstr "Uh oh. Keine Git-Kommandos auf Ihrem System vorhanden."
 
 #: help.c:354
 #, c-format
@@ -402,8 +402,8 @@ msgid ""
 "WARNING: You called a Git command named '%s', which does not exist.\n"
 "Continuing under the assumption that you meant '%s'"
 msgstr ""
-"Warnung: Du hast das nicht existierende Git-Kommando '%s' ausgeführt.\n"
-"Setze fort unter der Annahme das du '%s' gemeint hast"
+"Warnung: Sie haben das nicht existierende Git-Kommando '%s' ausgeführt.\n"
+"Setze fort unter der Annahme, dass Sie '%s' gemeint haben"
 
 #: help.c:359
 #, c-format
@@ -424,10 +424,10 @@ msgid_plural ""
 "Did you mean one of these?"
 msgstr[0] ""
 "\n"
-"Hast du das gemeint?"
+"Haben Sie das gemeint?"
 msgstr[1] ""
 "\n"
-"Hast du eines von diesen gemeint?"
+"Haben Sie eines von diesen gemeint?"
 
 #: merge.c:56
 msgid "failed to read the cache"
@@ -721,12 +721,12 @@ msgstr "    %s"
 #, c-format
 msgid "Your branch is ahead of '%s' by %d commit.\n"
 msgid_plural "Your branch is ahead of '%s' by %d commits.\n"
-msgstr[0] "Dein Zweig ist vor '%s' um %d Version.\n"
-msgstr[1] "Dein Zweig ist vor '%s' um %d Versionen.\n"
+msgstr[0] "Ihr Zweig ist vor '%s' um %d Version.\n"
+msgstr[1] "Ihr Zweig ist vor '%s' um %d Versionen.\n"
 
 #: remote.c:1637
 msgid "  (use \"git push\" to publish your local commits)\n"
-msgstr "  (benutze \"git push\" um deine lokalen Versionen herauszubringen)\n"
+msgstr "  (benutzen Sie \"git push\" um lokalen Versionen herauszubringen)\n"
 
 #: remote.c:1640
 #, c-format
@@ -734,15 +734,15 @@ msgid "Your branch is behind '%s' by %d commit, and can be fast-forwarded.\n"
 msgid_plural ""
 "Your branch is behind '%s' by %d commits, and can be fast-forwarded.\n"
 msgstr[0] ""
-"Dein Zweig ist zu '%s' um %d Version hinterher, und kann vorgespult werden.\n"
+"Ihr Zweig ist zu '%s' um %d Version hinterher, und kann vorgespult werden.\n"
 msgstr[1] ""
-"Dein Zweig ist zu '%s' um %d Versionen hinterher, und kann vorgespult "
+"Ihr Zweig ist zu '%s' um %d Versionen hinterher, und kann vorgespult "
 "werden.\n"
 
 #: remote.c:1647
 msgid "  (use \"git pull\" to update your local branch)\n"
 msgstr ""
-"  (benutze \"git pull\" um deinen lokalen Zweig zu aktualisieren)\n"
+"  (benutzen Sie \"git pull\" um Ihren lokalen Zweig zu aktualisieren)\n"
 
 #: remote.c:1650
 #, c-format
@@ -753,16 +753,16 @@ msgid_plural ""
 "Your branch and '%s' have diverged,\n"
 "and have %d and %d different commits each, respectively.\n"
 msgstr[0] ""
-"Dein Zweig und '%s' sind divergiert,\n"
+"Ihr Zweig und '%s' sind divergiert,\n"
 "und haben jeweils %d und %d unterschiedliche Versionen.\n"
 msgstr[1] ""
-"Dein Zweig und '%s' sind divergiert,\n"
+"Ihr Zweig und '%s' sind divergiert,\n"
 "und haben jeweils %d und %d unterschiedliche Versionen.\n"
 
 #: remote.c:1659
 msgid "  (use \"git pull\" to merge the remote branch into yours)\n"
 msgstr ""
-"  (benutze \"git pull\" um deinen Zweig mit dem externen zusammenzuführen)\n"
+"  (benutzen Sie \"git pull\" um Ihren Zweig mit dem externen zusammenzuführen)\n"
 
 #: sequencer.c:123 builtin/merge.c:761 builtin/merge.c:874 builtin/merge.c:984
 #: builtin/merge.c:994
@@ -781,7 +781,7 @@ msgid ""
 "after resolving the conflicts, mark the corrected paths\n"
 "with 'git add <paths>' or 'git rm <paths>'"
 msgstr ""
-"nach Auflösung der Konflikte, markiere die korrigierten Pfade\n"
+"nach Auflösung der Konflikte, markieren Sie die korrigierten Pfade\n"
 "mit 'git add <Pfade>' oder 'git rm <Pfade>'"
 
 #: sequencer.c:149
@@ -790,9 +790,9 @@ msgid ""
 "with 'git add <paths>' or 'git rm <paths>'\n"
 "and commit the result with 'git commit'"
 msgstr ""
-"nach Auflösung der Konflikte, markiere die korrigierten Pfade\n"
-"mit 'git add <Pfade>' oder 'git rm <Pfade>'und trage das Ergebnis ein mit "
-"'git commit'"
+"nach Auflösung der Konflikte, markieren Sie die korrigierten Pfade\n"
+"mit 'git add <Pfade>' oder 'git rm <Pfade>'und tragen Sie das Ergebnis mit\n"
+"'git commit' ein"
 
 #: sequencer.c:162 sequencer.c:770 sequencer.c:853
 #, c-format
@@ -807,15 +807,15 @@ msgstr "Fehler bei Nachbereitung von %s"
 #: sequencer.c:180
 msgid "Your local changes would be overwritten by cherry-pick."
 msgstr ""
-"Deine lokalen Ã„nderungen würden von \"cherry-pick\" Ã¼berschrieben werden."
+"Ihre lokalen Ã„nderungen würden von \"cherry-pick\" Ã¼berschrieben werden."
 
 #: sequencer.c:182
 msgid "Your local changes would be overwritten by revert."
-msgstr "Deine lokalen Ã„nderungen würden von \"revert\" Ã¼berschrieben werden."
+msgstr "Ihre lokalen Ã„nderungen würden von \"revert\" Ã¼berschrieben werden."
 
 #: sequencer.c:185
 msgid "Commit your changes or stash them to proceed."
-msgstr "Trage deine Ã„nderungen ein oder benutze \"stash\" um fortzufahren."
+msgstr "Tragen Sie Ihre Ã„nderungen ein oder benutzen Sie \"stash\" um fortzufahren."
 
 #. TRANSLATORS: %s will be "revert" or "cherry-pick"
 #: sequencer.c:235
@@ -843,11 +843,11 @@ msgstr "Konnte Elternversion %s nicht parsen\n"
 
 #: sequencer.c:403
 msgid "Your index file is unmerged."
-msgstr "Deine Bereitstellungsdatei ist nicht zusammengeführt."
+msgstr "Ihre Bereitstellungsdatei ist nicht zusammengeführt."
 
 #: sequencer.c:406
 msgid "You do not have a valid HEAD"
-msgstr "Du hast keine gültige Zweigspitze (HEAD)"
+msgstr "Sie haben keine gültige Zweigspitze (HEAD)"
 
 #: sequencer.c:421
 #, c-format
@@ -953,7 +953,7 @@ msgstr "\"cherry-pick\" oder \"revert\" ist bereits im Gang"
 
 #: sequencer.c:752
 msgid "try \"git cherry-pick (--continue | --quit | --abort)\""
-msgstr "versuche \"git cherry-pick (--continue | --quit | --abort)\""
+msgstr "versuchen Sie \"git cherry-pick (--continue | --quit | --abort)\""
 
 #: sequencer.c:756
 #, c-format
@@ -1053,28 +1053,28 @@ msgstr "Nicht zusammengeführte Pfade:"
 #, c-format
 msgid "  (use \"git reset %s <file>...\" to unstage)"
 msgstr ""
-"  (benutze \"git reset %s <Datei>...\" zum Herausnehmen aus der "
+"  (benutzen Sie \"git reset %s <Datei>...\" zum Herausnehmen aus der "
 "Bereitstellung)"
 
 #: wt-status.c:169 wt-status.c:196
 msgid "  (use \"git rm --cached <file>...\" to unstage)"
 msgstr ""
-"  (benutze \"git rm --cached <Datei>...\" zum Herausnehmen aus der "
+"  (benutzen Sie \"git rm --cached <Datei>...\" zum Herausnehmen aus der "
 "Bereitstellung)"
 
 #: wt-status.c:173
 msgid "  (use \"git add <file>...\" to mark resolution)"
-msgstr "  (benutze \"git add/rm <Datei>...\" um die Auflösung zu markieren)"
+msgstr "  (benutzen Sie \"git add/rm <Datei>...\" um die Auflösung zu markieren)"
 
 #: wt-status.c:175 wt-status.c:179
 msgid "  (use \"git add/rm <file>...\" as appropriate to mark resolution)"
 msgstr ""
-"  (benutze \"git add/rm <Datei>...\" um die Auflösung entsprechend zu "
+"  (benutzen Sie \"git add/rm <Datei>...\" um die Auflösung entsprechend zu "
 "markieren)"
 
 #: wt-status.c:177
 msgid "  (use \"git rm <file>...\" to mark resolution)"
-msgstr "  (benutze \"git add/rm <Datei>...\" um die Auflösung zu markieren)"
+msgstr "  (benutzen Sie \"git add/rm <Datei>...\" um die Auflösung zu markieren)"
 
 #: wt-status.c:188
 msgid "Changes to be committed:"
@@ -1086,29 +1086,29 @@ msgstr "Änderungen, die nicht zum Eintragen bereitgestellt sind:"
 
 #: wt-status.c:210
 msgid "  (use \"git add <file>...\" to update what will be committed)"
-msgstr "  (benutze \"git add <Datei>...\" zum Bereitstellen)"
+msgstr "  (benutzen Sie \"git add <Datei>...\" zum Bereitstellen)"
 
 #: wt-status.c:212
 msgid "  (use \"git add/rm <file>...\" to update what will be committed)"
-msgstr "  (benutze \"git add/rm <Datei>...\" zum Bereitstellen)"
+msgstr "  (benutzen Sie \"git add/rm <Datei>...\" zum Bereitstellen)"
 
 #: wt-status.c:213
 msgid ""
 "  (use \"git checkout -- <file>...\" to discard changes in working directory)"
 msgstr ""
-"  (benutze \"git checkout -- <Datei>...\" um die Ã„nderungen im "
+"  (benutzen Sie \"git checkout -- <Datei>...\" um die Ã„nderungen im "
 "Arbeitsverzeichnis zu verwerfen)"
 
 #: wt-status.c:215
 msgid "  (commit or discard the untracked or modified content in submodules)"
 msgstr ""
-"  (trage ein oder verwerfe den unbeobachteten oder geänderten Inhalt in den "
+"  (tragen Sie ein oder verwerfen Sie den unbeobachteten oder geänderten Inhalt in den "
 "Unterprojekten)"
 
 #: wt-status.c:227
 #, c-format
 msgid "  (use \"git %s <file>...\" to include in what will be committed)"
-msgstr "  (benutze \"git %s <Datei>...\" zum Einfügen in die Eintragung)"
+msgstr "  (benutzen Sie \"git %s <Datei>...\" zum Einfügen in die Eintragung)"
 
 #: wt-status.c:244
 msgid "bug"
@@ -1201,20 +1201,20 @@ msgstr "Fehler: unbehandelter Differenz-Status %c"
 
 #: wt-status.c:785
 msgid "You have unmerged paths."
-msgstr "Du hast nicht zusammengeführte Pfade."
+msgstr "Sie haben nicht zusammengeführte Pfade."
 
 #: wt-status.c:788 wt-status.c:912
 msgid "  (fix conflicts and run \"git commit\")"
-msgstr " (behebe die Konflikte und führe \"git commit\" aus)"
+msgstr " (beheben Sie die Konflikte und führen Sie \"git commit\" aus)"
 
 #: wt-status.c:791
 msgid "All conflicts fixed but you are still merging."
 msgstr ""
-"Alle Konflikte sind behoben, aber du bist immer noch beim Zusammenführen."
+"Alle Konflikte sind behoben, aber Sie sind immer noch beim Zusammenführen."
 
 #: wt-status.c:794
 msgid "  (use \"git commit\" to conclude merge)"
-msgstr "  (benutze \"git commit\" um die Zusammenführung abzuschließen)"
+msgstr "  (benutzen Sie \"git commit\" um die Zusammenführung abzuschließen)"
 
 #: wt-status.c:804
 msgid "You are in the middle of an am session."
@@ -1226,80 +1226,80 @@ msgstr "Der aktuelle Patch ist leer."
 
 #: wt-status.c:811
 msgid "  (fix conflicts and then run \"git am --resolved\")"
-msgstr "  (behebe die Konflikte und führe dann \"git am --resolved\" aus)"
+msgstr "  (beheben Sie die Konflikte und führen Sie dann \"git am --resolved\" aus)"
 
 #: wt-status.c:813
 msgid "  (use \"git am --skip\" to skip this patch)"
-msgstr " (benutze \"git am --skip\" um diesen Patch auszulassen)"
+msgstr " (benutzen Sie \"git am --skip\" um diesen Patch auszulassen)"
 
 #: wt-status.c:815
 msgid "  (use \"git am --abort\" to restore the original branch)"
 msgstr ""
-"  (benutze \"git am --abort\" um den ursprünglichen Zweig wiederherzustellen)"
+"  (benutzen Sie \"git am --abort\" um den ursprünglichen Zweig wiederherzustellen)"
 
 #: wt-status.c:873 wt-status.c:883
 msgid "You are currently rebasing."
-msgstr "Du bist gerade beim Neuaufbau."
+msgstr "Sie sind gerade beim Neuaufbau."
 
 #: wt-status.c:876
 msgid "  (fix conflicts and then run \"git rebase --continue\")"
-msgstr "  (behebe die Konflikte und führe dann \"git rebase --continue\" aus)"
+msgstr "  (beheben Sie die Konflikte und führen Sie dann \"git rebase --continue\" aus)"
 
 #: wt-status.c:878
 msgid "  (use \"git rebase --skip\" to skip this patch)"
-msgstr "  (benutze \"git rebase --skip\" um diesen Patch auszulassen)"
+msgstr "  (benutzen Sie \"git rebase --skip\" um diesen Patch auszulassen)"
 
 #: wt-status.c:880
 msgid "  (use \"git rebase --abort\" to check out the original branch)"
 msgstr ""
-"  (benutze \"git rebase --abort\" um den ursprünglichen Zweig auszuchecken)"
+"  (benutzen Sie \"git rebase --abort\" um den ursprünglichen Zweig auszuchecken)"
 
 #: wt-status.c:886
 msgid "  (all conflicts fixed: run \"git rebase --continue\")"
-msgstr "  (alle Konflikte behoben: führe \"git rebase --continue\" aus)"
+msgstr "  (alle Konflikte behoben: führen Sie \"git rebase --continue\" aus)"
 
 #: wt-status.c:888
 msgid "You are currently splitting a commit during a rebase."
-msgstr "Du teilst gerade eine Version während eines Neuaufbaus auf."
+msgstr "Sie teilen gerade eine Version während eines Neuaufbaus auf."
 
 #: wt-status.c:891
 msgid "  (Once your working directory is clean, run \"git rebase --continue\")"
 msgstr ""
-"  (Sobald dein Arbeitsverzeichnis sauber ist, führe \"git rebase --continue"
+"  (Sobald Ihr Arbeitsverzeichnis sauber ist, führen Sie \"git rebase --continue"
 "\" aus)"
 
 #: wt-status.c:893
 msgid "You are currently editing a commit during a rebase."
-msgstr "Du editierst gerade eine Version während eines Neuaufbaus."
+msgstr "Sie editieren gerade eine Version während eines Neuaufbaus."
 
 #: wt-status.c:896
 msgid "  (use \"git commit --amend\" to amend the current commit)"
 msgstr ""
-"  (benutze \"git commit --amend\" um die aktuelle Version nachzubessern)"
+"  (benutzen Sie \"git commit --amend\" um die aktuelle Version nachzubessern)"
 
 #: wt-status.c:898
 msgid ""
 "  (use \"git rebase --continue\" once you are satisfied with your changes)"
 msgstr ""
-"  (benutze \"git rebase --continue\" sobald deine Ã„nderungen abgeschlossen "
+"  (benutzen Sie \"git rebase --continue\" sobald Ihre Ã„nderungen abgeschlossen "
 "sind)"
 
 #: wt-status.c:908
 msgid "You are currently cherry-picking."
-msgstr "Du führst gerade \"cherry-pick\" aus."
+msgstr "Sie führen gerade \"cherry-pick\" aus."
 
 #: wt-status.c:915
 msgid "  (all conflicts fixed: run \"git commit\")"
-msgstr "  (alle Konflikte behoben: führe \"git commit\" aus)"
+msgstr "  (alle Konflikte behoben: führen Sie \"git commit\" aus)"
 
 #: wt-status.c:924
 msgid "You are currently bisecting."
-msgstr "Du bist gerade beim Halbieren."
+msgstr "Sie sind gerade beim Halbieren."
 
 #: wt-status.c:927
 msgid "  (use \"git bisect reset\" to get back to the original branch)"
 msgstr ""
-"  (benutze \"git bisect reset\" um zum ursprünglichen Zweig zurückzukehren)"
+"  (benutzen Sie \"git bisect reset\" um zum ursprünglichen Zweig zurückzukehren)"
 
 #: wt-status.c:978
 msgid "On branch "
@@ -1328,7 +1328,7 @@ msgstr "Unbeobachtete Dateien nicht aufgelistet%s"
 
 #: wt-status.c:1017
 msgid " (use -u option to show untracked files)"
-msgstr " (benutze die Option -u um unbeobachteten Dateien anzuzeigen)"
+msgstr " (benutzen Sie die Option -u um unbeobachteten Dateien anzuzeigen)"
 
 #: wt-status.c:1023
 msgid "No changes"
@@ -1338,7 +1338,7 @@ msgstr "Keine Ã„nderungen"
 #, c-format
 msgid "no changes added to commit (use \"git add\" and/or \"git commit -a\")\n"
 msgstr ""
-"keine Ã„nderungen zum Eintragen hinzugefügt (benutze \"git add\" und/oder "
+"keine Ã„nderungen zum Eintragen hinzugefügt (benutzen Sie \"git add\" und/oder "
 "\"git commit -a\")\n"
 
 #: wt-status.c:1031
@@ -1353,7 +1353,7 @@ msgid ""
 "track)\n"
 msgstr ""
 "nichts zum Eintragen hinzugefügt, aber es gibt unbeobachtete Dateien "
-"(benutze \"git add\" zum Beobachten)\n"
+"(benutzen Sie \"git add\" zum Beobachten)\n"
 
 #: wt-status.c:1037
 #, c-format
@@ -1364,8 +1364,8 @@ msgstr "nichts zum Eintragen hinzugefügt, aber es gibt unbeobachtete Dateien\n"
 #, c-format
 msgid "nothing to commit (create/copy files and use \"git add\" to track)\n"
 msgstr ""
-"nichts einzutragen (Erstelle/Kopiere Dateien und benutze \"git add\" zum "
-"Beobachten)\n"
+"nichts einzutragen (Erstellen/Kopieren Sie Dateien und benutzen Sie \"git add\" "
+"zum Beobachten)\n"
 
 #: wt-status.c:1043 wt-status.c:1048
 #, c-format
@@ -1376,7 +1376,7 @@ msgstr "nichts einzutragen\n"
 #, c-format
 msgid "nothing to commit (use -u to show untracked files)\n"
 msgstr ""
-"nichts einzutragen (benutze die Option -u, um unbeobachtete Dateien "
+"nichts einzutragen (benutzen Sie die Option -u, um unbeobachtete Dateien "
 "anzuzeigen)\n"
 
 #: wt-status.c:1050
@@ -1477,7 +1477,7 @@ msgstr "Konnte '%s' nicht anwenden."
 #: builtin/add.c:313
 msgid "The following paths are ignored by one of your .gitignore files:\n"
 msgstr ""
-"Die folgenden Pfade werden durch eine deiner \".gitignore\" Dateien "
+"Die folgenden Pfade werden durch eine Ihrer \".gitignore\" Dateien "
 "ignoriert:\n"
 
 #: builtin/add.c:319 builtin/clean.c:52 builtin/fetch.c:78 builtin/mv.c:63
@@ -1538,7 +1538,7 @@ msgstr "prüft ob - auch fehlende - Dateien im Probelauf ignoriert werden"
 #: builtin/add.c:353
 #, c-format
 msgid "Use -f if you really want to add them.\n"
-msgstr "Verwende -f wenn du diese wirklich hinzufügen möchtest.\n"
+msgstr "Verwenden Sie -f wenn Sie diese wirklich hinzufügen möchten.\n"
 
 #: builtin/add.c:354
 msgid "no files added"
@@ -1565,7 +1565,7 @@ msgstr "Nichts spezifiziert, nichts hinzugefügt.\n"
 #: builtin/add.c:415
 #, c-format
 msgid "Maybe you wanted to say 'git add .'?\n"
-msgstr "Wolltest du vielleicht 'git add .' sagen?\n"
+msgstr "Wollten Sie vielleicht 'git add .' sagen?\n"
 
 #: builtin/add.c:421 builtin/clean.c:95 builtin/commit.c:291 builtin/mv.c:82
 #: builtin/rm.c:235
@@ -2269,7 +2269,7 @@ msgid ""
 "If you are sure you want to delete it, run 'git branch -D %s'."
 msgstr ""
 "Der Zweig '%s' ist nicht vollständig zusammengeführt.\n"
-"Wenn du sicher bist diesen Zweig zu entfernen, führe 'git branch -D %s' aus."
+"Wenn Sie sicher sind diesen Zweig zu entfernen, führen Sie 'git branch -D %s' aus."
 
 #: builtin/branch.c:180
 msgid "Update of config-file failed"
@@ -2287,7 +2287,7 @@ msgstr "Konnte Versionsobjekt für Zweigspitze (HEAD) nicht nachschlagen."
 #, c-format
 msgid "Cannot delete the branch '%s' which you are currently on."
 msgstr ""
-"Kann Zweig '%s' nicht entfernen, da du dich gerade auf diesem befindest."
+"Kann Zweig '%s' nicht entfernen, da Sie sich gerade auf diesem befinden."
 
 #: builtin/branch.c:235
 #, c-format
@@ -2365,7 +2365,7 @@ msgstr "Konnte einige Referenzen nicht lesen"
 #: builtin/branch.c:638
 msgid "cannot rename the current branch while not on any."
 msgstr ""
-"Kann aktuellen Zweig nicht umbenennen, solange du dich auf keinem befindest."
+"Kann aktuellen Zweig nicht umbenennen, solange Sie sich auf keinem befinden."
 
 #: builtin/branch.c:648
 #, c-format
@@ -2527,8 +2527,8 @@ msgid ""
 "The --set-upstream flag is deprecated and will be removed. Consider using --"
 "track or --set-upstream-to\n"
 msgstr ""
-"Die --set-upstream Option ist veraltet und wird entfernt. Benutze --track "
-"oder --set-upstream-to\n"
+"Die --set-upstream Option ist veraltet und wird entfernt. Benutzen Sie "
+"--track oder --set-upstream-to\n"
 
 #: builtin/branch.c:934
 #, c-format
@@ -2538,8 +2538,8 @@ msgid ""
 "\n"
 msgstr ""
 "\n"
-"Wenn du wolltest, dass '%s' den Zweig '%s' als externen Ãœbernahmezweig hat, "
-"führe aus:\n"
+"Wenn Sie wollten, dass '%s' den Zweig '%s' als externen Ãœbernahmezweig hat, "
+"führen Sie aus:\n"
 
 #: builtin/branch.c:935
 #, c-format
@@ -2743,7 +2743,7 @@ msgstr "Pfad '%s' ist nicht zusammengeführt."
 
 #: builtin/checkout.c:448
 msgid "you need to resolve your current index first"
-msgstr "Du musst zuerst deine aktuelle Bereitstellung auflösen."
+msgstr "Sie müssen zuerst Ihre aktuelle Bereitstellung auflösen."
 
 #: builtin/checkout.c:569
 #, c-format
@@ -2798,13 +2798,13 @@ msgid_plural ""
 "\n"
 "%s\n"
 msgstr[0] ""
-"Warnung: Du bist um %d Version hinterher, nicht verbunden zu\n"
-"einem deiner Zweige:\n"
+"Warnung: Sie sind um %d Version hinterher, nicht verbunden zu\n"
+"einem Ihrer Zweige:\n"
 "\n"
 "%s\n"
 msgstr[1] ""
-"Warnung: Du bist um %d Versionen hinterher, nicht verbunden zu\n"
-"einem deiner Zweige:\n"
+"Warnung: Sie sind um %d Versionen hinterher, nicht verbunden zu\n"
+"einem Ihrer Zweige:\n"
 "\n"
 "%s\n"
 
@@ -2817,7 +2817,7 @@ msgid ""
 " git branch new_branch_name %s\n"
 "\n"
 msgstr ""
-"Wenn du diese durch einen neuen Zweig behalten möchtest, dann könnte jetzt\n"
+"Wenn Sie diese durch einen neuen Zweig behalten möchten, dann könnte jetzt\n"
 "ein guter Zeitpunkt sein dies zu tun mit:\n"
 "\n"
 " git branch neuer_zweig_name %s\n"
@@ -2833,7 +2833,7 @@ msgstr "Vorherige Position der Zweigspitze (HEAD) war"
 
 #: builtin/checkout.c:761 builtin/checkout.c:950
 msgid "You are on a branch yet to be born"
-msgstr "du bist auf einem Zweig, der noch geboren wird"
+msgstr "Sie sind auf einem Zweig, der noch geboren wird"
 
 #. case (1)
 #: builtin/checkout.c:886
@@ -2946,7 +2946,7 @@ msgstr "--track benötigt einen Zweignamen"
 
 #: builtin/checkout.c:1081
 msgid "Missing branch name; try -b"
-msgstr "Vermisse Zweignamen; versuche -b"
+msgstr "Vermisse Zweignamen; versuchen Sie -b"
 
 #: builtin/checkout.c:1116
 msgid "invalid path specification"
@@ -2959,7 +2959,7 @@ msgid ""
 "Did you intend to checkout '%s' which can not be resolved as commit?"
 msgstr ""
 "Kann nicht gleichzeitig Pfade aktualisieren und zu Zweig '%s' wechseln.\n"
-"Hast du beabsichtigt '%s' auszuchecken, welcher nicht als Version aufgelöst "
+"Haben Sie beabsichtigt '%s' auszuchecken, welcher nicht als Version aufgelöst "
 "werden kann?"
 
 #: builtin/checkout.c:1128
@@ -2973,7 +2973,7 @@ msgid ""
 "checking out of the index."
 msgstr ""
 "git checkout: --ours/--theirs, --force und --merge sind inkompatibel wenn\n"
-"du aus der Bereitstellung auscheckst."
+"Sie aus der Bereitstellung auschecken."
 
 #: builtin/clean.c:19
 msgid "git clean [-d] [-f] [-n] [-q] [-e <pattern>] [-x | -X] [--] <paths>..."
@@ -3203,7 +3203,7 @@ msgstr "Zu viele Argumente."
 
 #: builtin/clone.c:694
 msgid "You must specify a repository to clone."
-msgstr "Du musst ein Projektarchiv zum Klonen angeben."
+msgstr "Sie müssen ein Projektarchiv zum Klonen angeben."
 
 #: builtin/clone.c:705
 #, c-format
@@ -3217,7 +3217,7 @@ msgstr "Projektarchiv '%s' existiert nicht."
 
 #: builtin/clone.c:724
 msgid "--depth is ignored in local clones; use file:// instead."
-msgstr "--depth wird in lokalen Klonen ignoriert; benutze stattdessen file://."
+msgstr "--depth wird in lokalen Klonen ignoriert; benutzen Sie stattdessen file://."
 
 #: builtin/clone.c:734
 #, c-format
@@ -3261,7 +3261,7 @@ msgstr "externer Zweig %s nicht im anderen Projektarchiv %s gefunden"
 
 #: builtin/clone.c:879
 msgid "You appear to have cloned an empty repository."
-msgstr "Du scheinst ein leeres Projektarchiv geklont zu haben."
+msgstr "Sie scheinen ein leeres Projektarchiv geklont zu haben."
 
 #: builtin/column.c:9
 msgid "git column [options]"
@@ -3316,15 +3316,15 @@ msgid ""
 "\n"
 "    git commit --amend --reset-author\n"
 msgstr ""
-"Dein Name und E-Mail Adresse wurden automatisch auf Basis\n"
-"deines Benutzer- und Rechnernamens konfiguriert. Bitte prüfe, dass diese\n"
-"zutreffend sind. Du kannst diese Meldung unterdrücken, indem du diese\n"
-"explizit setzt:\n"
+"Ihr Name und E-Mail Adresse wurden automatisch auf Basis\n"
+"Ihres Benutzer- und Rechnernamens konfiguriert. Bitte prüfen Sie, dass\n"
+"diese zutreffend sind. Sie können diese Meldung unterdrücken, indem Sie\n"
+"diese explizit setzen:\n"
 "\n"
-"    git config --global user.name \"Dein Name\"\n"
-"    git config --global user.email deine@emailadresse.de\n"
+"    git config --global user.name \"Ihr Name\"\n"
+"    git config --global user.email ihre@emailadresse.de\n"
 "\n"
-"Nachdem du das getan hast, kannst du deine Identität für diese Version "
+"Nachdem Sie das getan hast, können Sie Ihre Identität für diese Version "
 "ändern mit:\n"
 "\n"
 "    git commit --amend --reset-author\n"
@@ -3335,8 +3335,8 @@ msgid ""
 "it empty. You can repeat your command with --allow-empty, or you can\n"
 "remove the commit entirely with \"git reset HEAD^\".\n"
 msgstr ""
-"Du fragtest die jüngste Version nachzubessern, aber das würde diese leer\n"
-"machen. Du kannst Dein Kommando mit --allow-empty wiederholen, oder die\n"
+"Sie fragten die jüngste Version nachzubessern, aber das würde diese leer\n"
+"machen. Sie können Ihr Kommando mit --allow-empty wiederholen, oder die\n"
 "Version mit \"git reset HEAD^\" vollständig entfernen.\n"
 
 #: builtin/commit.c:61
@@ -3350,11 +3350,11 @@ msgid ""
 msgstr ""
 "Der letzte \"cherry-pick\" ist jetzt leer, möglicherweise durch eine "
 "Konfliktauflösung.\n"
-"Wenn du dies trotzdem eintragen willst, benutze:\n"
+"Wenn Sie dies trotzdem eintragen wollen, benutzen Sie:\n"
 "\n"
 "    git commit --allow-empty\n"
 "\n"
-"Andernfalls benutze bitte 'git reset'\n"
+"Andernfalls benutzen Sie bitte 'git reset'\n"
 
 #: builtin/commit.c:258
 msgid "failed to unpack HEAD tree object"
@@ -3456,10 +3456,10 @@ msgid ""
 "and try again.\n"
 msgstr ""
 "\n"
-"Es sieht so aus, als trägst du eine Zusammenführung ein.\n"
-"Falls das nicht korrekt ist, lösche bitte die Datei\n"
+"Es sieht so aus, als tragen Sie eine Zusammenführung ein.\n"
+"Falls das nicht korrekt ist, löschen Sie bitte die Datei\n"
 "\t%s\n"
-"und versuche es erneut.\n"
+"und versuchen Sie es erneut.\n"
 
 #: builtin/commit.c:723
 #, c-format
@@ -3471,17 +3471,17 @@ msgid ""
 "and try again.\n"
 msgstr ""
 "\n"
-"Es sieht so aus, als trägst du ein \"cherry-pick\" ein.\n"
-"Falls das nicht korrekt ist, lösche bitte die Datei\n"
+"Es sieht so aus, als tragen Sie ein \"cherry-pick\" ein.\n"
+"Falls das nicht korrekt ist, löschen Sie bitte die Datei\n"
 "\t%s\n"
-"und versuche es erneut.\n"
+"und versuchen Sie es erneut.\n"
 
 #: builtin/commit.c:735
 msgid ""
 "Please enter the commit message for your changes. Lines starting\n"
 "with '#' will be ignored, and an empty message aborts the commit.\n"
 msgstr ""
-"Bitte gebe eine Versionsbeschreibung für deine Ã„nderungen ein. Zeilen,\n"
+"Bitte geben Sie eine Versionsbeschreibung für Ihre Ã„nderungen ein. Zeilen,\n"
 "die mit '#' beginnen, werden ignoriert, und eine leere Versionsbeschreibung\n"
 "bricht die Eintragung ab.\n"
 
@@ -3491,8 +3491,8 @@ msgid ""
 "with '#' will be kept; you may remove them yourself if you want to.\n"
 "An empty message aborts the commit.\n"
 msgstr ""
-"Bitte gebe eine Versionsbeschreibung für deine Ã„nderungen ein. Zeilen, die\n"
-"mit '#' beginnen, werden beibehalten; wenn du möchtest, kannst du diese "
+"Bitte geben Sie eine Versionsbeschreibung für Ihre Ã„nderungen ein. Zeilen, die\n"
+"mit '#' beginnen, werden beibehalten; wenn Sie möchten, können Sie diese "
 "entfernen.\n"
 "Eine leere Versionsbeschreibung bricht die Eintragung ab.\n"
 
@@ -3535,7 +3535,7 @@ msgstr "Verwendung von --reset-author und --author macht keinen Sinn."
 
 #: builtin/commit.c:995
 msgid "You have nothing to amend."
-msgstr "Du hast nichts zum nachbessern."
+msgstr "Sie haben nichts zum nachbessern."
 
 #: builtin/commit.c:998
 msgid "You are in the middle of a merge -- cannot amend."
@@ -3726,7 +3726,7 @@ msgstr ""
 
 #: builtin/commit.c:1380
 msgid "the commit is authored by me now (used with -C/-c/--amend)"
-msgstr "Setze mich als Autor der Version (benutzt mit -C/-c/--amend)"
+msgstr "Setzt Sie als Autor der Version (benutzt mit -C/-c/--amend)"
 
 #: builtin/commit.c:1381 builtin/log.c:1073 builtin/revert.c:109
 msgid "add Signed-off-by:"
@@ -3836,7 +3836,7 @@ msgstr "Konnte Versionsbeschreibung nicht lesen: %s"
 #: builtin/commit.c:1534
 #, c-format
 msgid "Aborting commit; you did not edit the message.\n"
-msgstr "Eintragung abgebrochen; du hast die Beschreibung nicht editiert.\n"
+msgstr "Eintragung abgebrochen; Sie haben die Beschreibung nicht editiert.\n"
 
 #: builtin/commit.c:1539
 #, c-format
@@ -3862,8 +3862,8 @@ msgid ""
 "not exceeded, and then \"git reset HEAD\" to recover."
 msgstr ""
 "Das Projektarchiv wurde aktualisiert, aber die \"new_index\"-Datei\n"
-"konnte nicht geschrieben werden. Prüfe, dass deine Festplatte nicht\n"
-"voll und Dein Kontingent nicht aufgebraucht ist und führe\n"
+"konnte nicht geschrieben werden. Prüfen Sie, dass Ihre Festplatte nicht\n"
+"voll und Ihr Kontingent nicht aufgebraucht ist und führen Sie\n"
 "anschließend \"git reset HEAD\" zu Wiederherstellung aus."
 
 #: builtin/config.c:7
@@ -4041,7 +4041,7 @@ msgid ""
 "However, there were unannotated tags: try --tags."
 msgstr ""
 "Keine annotierten Markierungen können '%s' beschreiben.\n"
-"Jedoch gab es nicht annotierte Markierungen: versuche --tags."
+"Jedoch gab es nicht annotierte Markierungen: versuchen Sie --tags."
 
 #: builtin/describe.c:357
 #, c-format
@@ -4050,7 +4050,7 @@ msgid ""
 "Try --always, or create some tags."
 msgstr ""
 "Keine Markierungen können '%s' beschreiben.\n"
-"Versuche --always oder erstelle einige Markierungen."
+"Versuchen Sie --always oder erstellen Sie einige Markierungen."
 
 #: builtin/describe.c:378
 #, c-format
@@ -4354,7 +4354,7 @@ msgid ""
 "some local refs could not be updated; try running\n"
 " 'git remote prune %s' to remove any old, conflicting branches"
 msgstr ""
-"Einige lokale Referenzen konnten nicht aktualisiert werden; versuche\n"
+"Einige lokale Referenzen konnten nicht aktualisiert werden; versuchen Sie\n"
 "'git remote prune %s' um jeden Ã¤lteren, widersprüchlichen Zweig zu löschen."
 
 #: builtin/fetch.c:549
@@ -4412,13 +4412,13 @@ msgid ""
 "No remote repository specified.  Please, specify either a URL or a\n"
 "remote name from which new revisions should be fetched."
 msgstr ""
-"Kein externes Projektarchiv angegeben. Bitte gebe entweder eine URL\n"
+"Kein externes Projektarchiv angegeben. Bitte geben Sie entweder eine URL\n"
 "oder den Namen des externen Archivs an, von welchem neue\n"
 "Versionen angefordert werden sollen."
 
 #: builtin/fetch.c:932
 msgid "You need to specify a tag name."
-msgstr "Du musst den Namen der Markierung angeben."
+msgstr "Sie müssen den Namen der Markierung angeben."
 
 #: builtin/fetch.c:984
 msgid "fetch --all does not take a repository argument"
@@ -4587,15 +4587,15 @@ msgid ""
 "run \"git gc\" manually. See \"git help gc\" for more information.\n"
 msgstr ""
 "Die Datenbank des Projektarchivs wird für eine optimale Performance\n"
-"komprimiert. Du kannst auch \"git gc\" manuell ausführen.\n"
+"komprimiert. Sie können auch \"git gc\" manuell ausführen.\n"
 "Siehe \"git help gc\" für weitere Informationen.\n"
 
 #: builtin/gc.c:249
 msgid ""
 "There are too many unreachable loose objects; run 'git prune' to remove them."
 msgstr ""
-"Es gibt zu viele unerreichbare lose Objekte; führe 'git prune' aus, um diese "
-"zu löschen."
+"Es gibt zu viele unerreichbare lose Objekte; führen Sie 'git prune' aus, um "
+"diese zu löschen."
 
 #: builtin/grep.c:22
 msgid "git grep [options] [-e] <pattern> [<rev>...] [[--] <path>...]"
@@ -4918,7 +4918,7 @@ msgid ""
 "Please consider using 'man.<tool>.cmd' instead."
 msgstr ""
 "'%s': Pfad für nicht unterstützten Handbuchbetrachter.\n"
-"Du könntest stattdessen 'man.<Werkzeug>.cmd' benutzen."
+"Sie könnten stattdessen 'man.<Werkzeug>.cmd' benutzen."
 
 #: builtin/help.c:229
 #, c-format
@@ -4927,7 +4927,7 @@ msgid ""
 "Please consider using 'man.<tool>.path' instead."
 msgstr ""
 "'%s': Kommando für unterstützten Handbuchbetrachter.\n"
-"Du könntest stattdessen 'man.<Werkzeug>.path' benutzen."
+"Sie könnten stattdessen 'man.<Werkzeug>.path' benutzen."
 
 #: builtin/help.c:299
 msgid "The most commonly used git commands are:"
@@ -5636,8 +5636,8 @@ msgstr "git cherry [-v] [<Ãœbernahmezweig> [<Arbeitszweig> [<Limit>]]]"
 msgid ""
 "Could not find a tracked remote branch, please specify <upstream> manually.\n"
 msgstr ""
-"Konnte gefolgten, externen Zweig nicht finden, bitte gebe <upstream> manuell "
-"an.\n"
+"Konnte gefolgten, externen Zweig nicht finden, bitte geben Sie <upstream> "
+"manuell an.\n"
 
 #: builtin/log.c:1517 builtin/log.c:1519 builtin/log.c:1531
 #, c-format
@@ -5956,7 +5956,7 @@ msgstr "konnte nicht von '%s' lesen"
 #, c-format
 msgid "Not committing merge; use 'git commit' to complete the merge.\n"
 msgstr ""
-"Zusammenführung wurde nicht eingetragen; benutze 'git commit' um die "
+"Zusammenführung wurde nicht eingetragen; benutzen Sie 'git commit' um die "
 "Zusammenführung abzuschließen.\n"
 
 #: builtin/merge.c:788
@@ -5967,7 +5967,7 @@ msgid ""
 "Lines starting with '#' will be ignored, and an empty message aborts\n"
 "the commit.\n"
 msgstr ""
-"Bitte gebe eine Versionsbeschreibung ein um zu erklären, warum diese "
+"Bitte geben Sie eine Versionsbeschreibung ein um zu erklären, warum diese "
 "Zusammenführung erforderlich ist,\n"
 "insbesondere wenn es einen aktualisierten, externen Zweig mit einem Thema-"
 "Zweig zusammenführt.\n"
@@ -5988,8 +5988,8 @@ msgstr "Wunderbar.\n"
 #, c-format
 msgid "Automatic merge failed; fix conflicts and then commit the result.\n"
 msgstr ""
-"Automatische Zusammenführung fehlgeschlagen; behebe die Konflikte und trage "
-"dann das Ergebnis ein.\n"
+"Automatische Zusammenführung fehlgeschlagen; beheben Sie die Konflikte und tragen "
+"Sie dann das Ergebnis ein.\n"
 
 #: builtin/merge.c:905
 #, c-format
@@ -5998,7 +5998,7 @@ msgstr "'%s' ist keine Version"
 
 #: builtin/merge.c:946
 msgid "No current branch."
-msgstr "Du befindest dich auf keinem Zweig."
+msgstr "Sie befinden sich auf keinem Zweig."
 
 #: builtin/merge.c:948
 msgid "No remote for the current branch."
@@ -6029,34 +6029,34 @@ msgid ""
 "You have not concluded your merge (MERGE_HEAD exists).\n"
 "Please, commit your changes before you can merge."
 msgstr ""
-"Du hast deine Zusammenführung nicht abgeschlossen (MERGE_HEAD existiert).\n"
-"Bitte trage deine Ã„nderungen ein, bevor du zusammenführen kannst."
+"Sie haben Ihre Zusammenführung nicht abgeschlossen (MERGE_HEAD existiert).\n"
+"Bitte tragen Sie Ihre Ã„nderungen ein, bevor Sie zusammenführen können."
 
 #: builtin/merge.c:1129 git-pull.sh:34
 msgid "You have not concluded your merge (MERGE_HEAD exists)."
 msgstr ""
-"Du hast deine Zusammenführung nicht abgeschlossen (MERGE_HEAD existiert)."
+"Sie haben Ihre Zusammenführung nicht abgeschlossen (MERGE_HEAD existiert)."
 
 #: builtin/merge.c:1133
 msgid ""
 "You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\n"
 "Please, commit your changes before you can merge."
 msgstr ""
-"Du hast \"cherry-pick\" nicht abgeschlossen (CHERRY_PICK_HEAD existiert).\n"
-"Bitte trage deine Ã„nderungen ein, bevor du zusammenführen kannst."
+"Sie haben \"cherry-pick\" nicht abgeschlossen (CHERRY_PICK_HEAD existiert).\n"
+"Bitte tragen Sie Ihre Ã„nderungen ein, bevor Sie zusammenführen können."
 
 #: builtin/merge.c:1136
 msgid "You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists)."
 msgstr ""
-"Du hast \"cherry-pick\" nicht abgeschlossen (CHERRY_PICK_HEAD existiert)."
+"Sie haben \"cherry-pick\" nicht abgeschlossen (CHERRY_PICK_HEAD existiert)."
 
 #: builtin/merge.c:1145
 msgid "You cannot combine --squash with --no-ff."
-msgstr "Du kannst --squash nicht mit --no-ff kombinieren."
+msgstr "Sie können --squash nicht mit --no-ff kombinieren."
 
 #: builtin/merge.c:1150
 msgid "You cannot combine --no-ff with --ff-only."
-msgstr "Du kannst --no-ff nicht mit --ff--only kombinieren."
+msgstr "Sie können --no-ff nicht mit --ff--only kombinieren."
 
 #: builtin/merge.c:1157
 msgid "No commit specified and merge.defaultToUpstream not set."
@@ -6116,7 +6116,7 @@ msgstr "Zusammenführung mit Strategie %s fehlgeschlagen.\n"
 #: builtin/merge.c:1491
 #, c-format
 msgid "Using the %s to prepare resolving by hand.\n"
-msgstr "Benutze \"%s\" um die Auflösung per Hand vorzubereiten.\n"
+msgstr "Benutzen Sie \"%s\" um die Auflösung per Hand vorzubereiten.\n"
 
 #: builtin/merge.c:1503
 #, c-format
@@ -6461,7 +6461,7 @@ msgstr "konnte Datei '%s' nicht erstellen"
 
 #: builtin/notes.c:192
 msgid "Please supply the note contents using either -m or -F option"
-msgstr "Bitte liefere den Notiz-Inhalt unter Verwendung der Option -m oder -F."
+msgstr "Bitte liefern Sie den Notiz-Inhalt unter Verwendung der Option -m oder -F."
 
 #: builtin/notes.c:213 builtin/notes.c:976
 #, c-format
@@ -6575,7 +6575,7 @@ msgid ""
 "existing notes"
 msgstr ""
 "Konnte Notizen nicht hinzufügen. Existierende Notizen für Objekt %s "
-"gefunden. Verwende '-f' um die existierenden Notizen zu Ã¼berschreiben."
+"gefunden. Verwenden Sie '-f' um die existierenden Notizen zu Ã¼berschreiben."
 
 #: builtin/notes.c:588 builtin/notes.c:665
 #, c-format
@@ -6603,7 +6603,7 @@ msgid ""
 "existing notes"
 msgstr ""
 "Kann Notizen nicht kopieren. Existierende Notizen für Objekt %s gefunden. "
-"Verwende '-f' um die existierenden Notizen zu Ã¼berschreiben."
+"Verwenden Sie '-f' um die existierenden Notizen zu Ã¼berschreiben."
 
 #: builtin/notes.c:671
 #, c-format
@@ -6617,7 +6617,7 @@ msgid ""
 "Please use 'git notes add -f -m/-F/-c/-C' instead.\n"
 msgstr ""
 "Die Optionen -m/-F/-c/-C sind für das Unterkommando 'edit' veraltet.\n"
-"Bitte benutze stattdessen 'git notes add -f -m/-F/-c/-C'.\n"
+"Bitte benutzen Sie stattdessen 'git notes add -f -m/-F/-c/-C'.\n"
 
 #: builtin/notes.c:867
 msgid "General options"
@@ -6908,14 +6908,14 @@ msgid ""
 "    git push %s %s\n"
 "%s"
 msgstr ""
-"Der Name des externen Ãœbernahmezweiges stimmt nicht mit dem Namen deines\n"
+"Der Name des externen Ãœbernahmezweiges stimmt nicht mit dem Namen Ihres\n"
 "aktuellen Zweiges Ã¼berein. Um auf den Ãœbernahmezweig in dem externen\n"
-"Projektarchiv zu versenden, benutze:\n"
+"Projektarchiv zu versenden, benutzen Sie:\n"
 "\n"
 "    git push %s HEAD:%s\n"
 "\n"
 "Um auf den Zweig mit dem selben Namen in dem externen Projekarchiv\n"
-"zu versenden, benutze:\n"
+"zu versenden, benutzen Sie:\n"
 "\n"
 "    git push %s %s\n"
 "%s"
@@ -6929,9 +6929,9 @@ msgid ""
 "\n"
 "    git push %s HEAD:<name-of-remote-branch>\n"
 msgstr ""
-"Du befindest dich sich im Moment auf keinem Zweig.\n"
+"Sie befinden sich im Moment auf keinem Zweig.\n"
 "Um die Historie, führend zum aktuellen (freistehende Zweigspitze (HEAD))\n"
-"Status zu versenden, benutze\n"
+"Status zu versenden, benutzen Sie\n"
 "\n"
 "    git push %s HEAD:<Name-des-externen-Zweiges>\n"
 
@@ -6945,7 +6945,7 @@ msgid ""
 msgstr ""
 "Der aktuelle Zweig %s hat keinen Zweig im externen Projektarchiv.\n"
 "Um den aktuellen Zweig zu versenden und das Fernarchiv als externes\n"
-"Projektarchiv zu verwenden, benutze\n"
+"Projektarchiv zu verwenden, benutzen Sie\n"
 "\n"
 "    git push --set-upstream %s %s\n"
 
@@ -6961,7 +6961,7 @@ msgid ""
 "your current branch '%s', without telling me what to push\n"
 "to update which remote branch."
 msgstr ""
-"Du versendest nach '%s', welches kein externes Projektarchiv deines\n"
+"Sie versenden nach '%s', welches kein externes Projektarchiv Ihres\n"
 "aktuellen Zweiges '%s' ist, ohne mir mitzuteilen, was ich versenden\n"
 "soll, um welchen externen Zweig zu aktualisieren."
 
@@ -6985,26 +6985,25 @@ msgstr ""
 "'push.default' ist nicht gesetzt; der implizit gesetzte Wert\n"
 "wird in Git 2.0 von 'matching' nach 'simple' geändert. Um diese Meldung zu\n"
 "unterdrücken und das aktuelle Verhalten nach Ã„nderung des Standardwertes\n"
-"beizubehalten, benutze:\n"
+"beizubehalten, benutzen Sie:\n"
 "  git config --global push.default matching\n"
 "\n"
 "Um diese Meldung zu unterdrücken und das neue Verhalten jetzt zu "
-"übernehmen,\n"
-"benutze:\n"
+"übernehmen, benutzen Sie:\n"
 "\n"
 "  git config --global push.default simple\n"
 "\n"
-"Führe 'git help config' aus und suche nach 'push.default' für weitere "
-"Informationen.\n"
+"Führen Sie 'git help config' aus und suchen Sie nach 'push.default' für "
+"weitere Informationen.\n"
 "(Der Modus 'simple' wurde in Git 1.7.11 eingeführt. Benutze den Ã¤hnlichen "
-"Modus 'current' anstatt 'simple', falls du gelegentlich Ã¤ltere Versionen von "
-"Git benutzt.)"
+"Modus 'current' anstatt 'simple', falls Sie gelegentlich Ã¤ltere Versionen von "
+"Git benutzen.)"
 
 #: builtin/push.c:199
 msgid ""
 "You didn't specify any refspecs to push, and push.default is \"nothing\"."
 msgstr ""
-"Du hast keine Referenzspezifikationen zum Versenden angegeben, und push."
+"Sie haben keine Referenzspezifikationen zum Versenden angegeben, und push."
 "default ist \"nothing\"."
 
 #: builtin/push.c:206
@@ -7014,9 +7013,10 @@ msgid ""
 "before pushing again.\n"
 "See the 'Note about fast-forwards' in 'git push --help' for details."
 msgstr ""
-"Aktualisierungen wurden zurückgewiesen, weil die Spitze deines aktuellen\n"
-"Zweiges hinter seinem externen Gegenstück zurückgefallen ist. Führe die\n"
-"externen Ã„nderungen zusammen (z.B. 'git pull') bevor du erneut versendest.\n"
+"Aktualisierungen wurden zurückgewiesen, weil die Spitze Ihres aktuellen\n"
+"Zweiges hinter seinem externen Gegenstück zurückgefallen ist. Führen Sie\n"
+"die externen Ã„nderungen zusammen (z.B. 'git pull') bevor Sie erneut\n"
+"versenden.\n"
 "Siehe auch die Sektion 'Note about fast-forwards' in 'git push --help'\n"
 "für weitere Details."
 
@@ -7028,8 +7028,8 @@ msgid ""
 "to 'simple', 'current' or 'upstream' to push only the current branch."
 msgstr ""
 "Aktualisierungen wurden zurückgewiesen, weil die Spitze eines versendeten\n"
-"Zweiges hinter seinem externen Gegenstück zurückgefallen ist. Wenn du nicht\n"
-"beabsichtigt hast, diesen Zweig zu versenden, kannst du auch den zu "
+"Zweiges hinter seinem externen Gegenstück zurückgefallen ist. Wenn Sie nicht\n"
+"beabsichtigt haben, diesen Zweig zu versenden, können Sie auch den zu "
 "versendenden\n"
 "Zweig spezifizieren oder die Konfigurationsvariable 'push.default' zu "
 "'simple', 'current'\n"
@@ -7043,9 +7043,9 @@ msgid ""
 "See the 'Note about fast-forwards' in 'git push --help' for details."
 msgstr ""
 "Aktualisierungen wurden zurückgewiesen, weil die Spitze eines versendeten\n"
-"Zweiges hinter seinem externen Gegenstück zurückgefallen ist. Checke diesen\n"
-"Zweig aus und führe die externen Ã„nderungen zusammen (z.B. 'git pull')\n"
-"bevor du erneut versendest.\n"
+"Zweiges hinter seinem externen Gegenstück zurückgefallen ist. Checken Sie\n"
+"diesen Zweig aus und führen Sie die externen Ã„nderungen zusammen\n"
+"(z.B. 'git pull') bevor Sie erneut versenden.\n"
 "Siehe auch die Sektion 'Note about fast-forwards' in 'git push --help'\n"
 "für weitere Details."
 
@@ -7077,12 +7077,12 @@ msgid ""
 "    git push <name>\n"
 msgstr ""
 "Kein Ziel zum Versenden konfiguriert.\n"
-"Entweder spezifizierst du die URL von der Kommandozeile oder konfigurierst "
+"Entweder spezifizieren Sie die URL von der Kommandozeile oder konfigurieren "
 "ein externes Projektarchiv unter Benutzung von\n"
 "\n"
 "    git remote add <Name> <URL>\n"
 "\n"
-"und versendest dann unter Benutzung dieses Namens\n"
+"und versenden dann unter Benutzung dieses Namens\n"
 "\n"
 "    git push <Name>\n"
 
@@ -7331,7 +7331,7 @@ msgid ""
 "\t use --mirror=fetch or --mirror=push instead"
 msgstr ""
 "--mirror ist gefährlich und veraltet; bitte\n"
-"\t benutze stattdessen --mirror=fetch oder --mirror=push"
+"\t benutzen Sie stattdessen --mirror=fetch oder --mirror=push"
 
 #: builtin/remote.c:147
 #, c-format
@@ -7440,7 +7440,7 @@ msgstr ""
 "Keine Aktualisierung der nicht standardmäßigen Referenzspezifikation zum "
 "Abholen\n"
 "\t%s\n"
-"\tBitte aktualisiere, falls notwendig, die Konfiguration manuell."
+"\tBitte aktualisieren Sie, falls notwendig, die Konfiguration manuell."
 
 #: builtin/remote.c:683
 #, c-format
@@ -7477,11 +7477,11 @@ msgid_plural ""
 msgstr[0] ""
 "Hinweis: Ein Zweig außerhalb der /refs/remotes/ Hierachie wurde nicht "
 "gelöscht;\n"
-"um diesen zu löschen, benutze:"
+"um diesen zu löschen, benutzen Sie:"
 msgstr[1] ""
 "Hinweis: Einige Zweige außer der /refs/remotes/ Hierarchie wurden nicht "
 "entfernt;\n"
-"um diese zu entfernen, benutze:"
+"um diese zu entfernen, benutzen Sie:"
 
 #: builtin/remote.c:943
 #, c-format
@@ -7494,7 +7494,7 @@ msgstr " gefolgt"
 
 #: builtin/remote.c:948
 msgid " stale (use 'git remote prune' to remove)"
-msgstr " veraltet (benutze 'git remote prune' zum Löschen)"
+msgstr " veraltet (benutzen Sie 'git remote prune' zum Löschen)"
 
 #: builtin/remote.c:950
 msgid " ???"
@@ -7647,8 +7647,8 @@ msgstr "Kann Hauptzweig des externen Projektarchivs nicht bestimmen"
 #: builtin/remote.c:1218
 msgid "Multiple remote HEAD branches. Please choose one explicitly with:"
 msgstr ""
-"Mehrere Hauptzweige im externen Projektarchiv. Bitte wähle explizit einen "
-"aus mit:"
+"Mehrere Hauptzweige im externen Projektarchiv. Bitte wählen Sie explizit "
+"einen aus mit:"
 
 #: builtin/remote.c:1228
 #, c-format
@@ -7814,7 +7814,7 @@ msgstr "keep"
 
 #: builtin/reset.c:77
 msgid "You do not have a valid HEAD."
-msgstr "Du hast keine gültige Zweigspitze (HEAD)."
+msgstr "Sie haben keine gültige Zweigspitze (HEAD)."
 
 #: builtin/reset.c:79
 msgid "Failed to find tree of HEAD."
@@ -7881,7 +7881,8 @@ msgstr "--patch ist inkompatibel mit --{hard,mixed,soft}"
 #: builtin/reset.c:317
 msgid "--mixed with paths is deprecated; use 'git reset -- <paths>' instead."
 msgstr ""
-"--mixed mit Pfaden ist veraltet; benutze stattdessen 'git reset -- <Pfade>'."
+"--mixed mit Pfaden ist veraltet; benutzen Sie stattdessen "
+"'git reset -- <Pfade>'."
 
 #: builtin/reset.c:319
 #, c-format
@@ -7922,7 +7923,7 @@ msgstr ""
 "   oder: git rev-parse --sq-quote [<Argumente>...]\n"
 "   oder: git rev-parse [Optionen] [<Argumente>...]\n"
 "\n"
-"Führe \"git rev-parse --parseopt -h\" für weitere Informationen bei erster "
+"Führen Sie \"git rev-parse --parseopt -h\" für weitere Informationen bei erster "
 "Verwendung aus."
 
 #: builtin/revert.c:22
@@ -8025,8 +8026,8 @@ msgid ""
 "(use 'rm -rf' if you really want to remove it including all of its history)"
 msgstr ""
 "Unterprojekt '%s' (oder ein geschachteltes Unterprojekt hiervon) verwendet\n"
-"ein .git-Verzeichnis (benutze 'rm -rf' wenn du dieses wirklich mitsamt\n"
-"seiner Historie löschen möchtest)"
+"ein .git-Verzeichnis (benutzen Sie 'rm -rf' wenn Sie dieses wirklich mitsamt\n"
+"seiner Historie löschen möchten)"
 
 #: builtin/rm.c:174
 #, c-format
@@ -8035,7 +8036,7 @@ msgid ""
 "(use -f to force removal)"
 msgstr ""
 "'%s' hat bereitgestellten Inhalt unterschiedlich zu der Datei und der\n"
-"Zweigspitze (HEAD) (benutze -f um die Entfernung zu erzwingen)"
+"Zweigspitze (HEAD) (benutzen Sie -f um die Entfernung zu erzwingen)"
 
 #: builtin/rm.c:180
 #, c-format
@@ -8044,7 +8045,7 @@ msgid ""
 "(use --cached to keep the file, or -f to force removal)"
 msgstr ""
 "'%s' hat Ã„nderungen in der Bereitstellung\n"
-"(benutze --cached um die Datei zu behalten, oder -f um die Entfernung zu "
+"(benutzen Sie --cached um die Datei zu behalten, oder -f um die Entfernung zu "
 "erzwingen)"
 
 #: builtin/rm.c:191
@@ -8054,7 +8055,7 @@ msgid ""
 "(use --cached to keep the file, or -f to force removal)"
 msgstr ""
 "'%s' hat lokale Modifikationen\n"
-"(benutze --cached um die Datei zu behalten, oder -f um die Entfernung zu "
+"(benutzen Sie --cached um die Datei zu behalten, oder -f um die Entfernung zu "
 "erzwingen)"
 
 #: builtin/rm.c:207
@@ -8334,7 +8335,7 @@ msgid ""
 msgstr ""
 "\n"
 "#\n"
-"# Gebe eine Markierungsbeschreibung ein\n"
+"# Geben Sie eine Markierungsbeschreibung ein.\n"
 "# Zeilen, die mit '#' beginnen, werden ignoriert.\n"
 "#\n"
 
@@ -8349,9 +8350,9 @@ msgid ""
 msgstr ""
 "\n"
 "#\n"
-"# Gebe eine Markierungsbeschreibung ein\n"
-"# Zeilen, die mit '#' beginnen, werden behalten; du darfst diese\n"
-"# selbst entfernen wenn du möchtest.\n"
+"# Geben Sie eine Markierungsbeschreibung ein.\n"
+"# Zeilen, die mit '#' beginnen, werden behalten; Sie dürfen diese\n"
+"# selbst entfernen wenn Sie möchten.\n"
 "#\n"
 
 #: builtin/tag.c:298
@@ -8790,14 +8791,14 @@ msgstr ""
 
 #: git-am.sh:50
 msgid "You need to set your committer info first"
-msgstr "Du musst zuerst die Informationen des Eintragenden setzen."
+msgstr "Sie müssen zuerst die Informationen des Eintragenden setzen."
 
 #: git-am.sh:95
 msgid ""
 "You seem to have moved HEAD since the last 'am' failure.\n"
 "Not rewinding to ORIG_HEAD"
 msgstr ""
-"Du scheinst seit dem letzten gescheiterten 'am' die Zweigspitze (HEAD)\n"
+"Sie scheinen seit dem letzten gescheiterten 'am' die Zweigspitze (HEAD)\n"
 "geändert zu haben.\n"
 "Keine Zurücksetzung zu ORIG_HEAD."
 
@@ -8808,12 +8809,11 @@ msgid ""
 "If you prefer to skip this patch, run \"$cmdline --skip\" instead.\n"
 "To restore the original branch and stop patching, run \"$cmdline --abort\"."
 msgstr ""
-"Wenn du das Problem gelöst hast, führe \"$cmdline --resolved\" aus.\n"
-"Falls du diesen Patch auslassen möchtest, führe stattdessen \"$cmdline --skip"
-"\" aus.\n"
-"Um den ursprünglichen Zweig wiederherzustellen und die Anwendung der "
-"Patches\n"
-"abzubrechen, führe \"$cmdline --abort\" aus."
+"Wenn Sie das Problem gelöst haben, führen Sie \"$cmdline --resolved\" aus.\n"
+"Falls Sie diesen Patch auslassen möchten, führen Sie stattdessen\n"
+"\"$cmdline --skip\" aus.\n"
+"Um den ursprünglichen Zweig wiederherzustellen und die Anwendung der\n"
+"Patches abzubrechen, führen Sie \"$cmdline --abort\" aus."
 
 #: git-am.sh:121
 msgid "Cannot fall back to three-way merge."
@@ -8836,7 +8836,7 @@ msgid ""
 "Did you hand edit your patch?\n"
 "It does not apply to blobs recorded in its index."
 msgstr ""
-"Hast du den Patch per Hand editiert?\n"
+"Haben Sie den Patch per Hand editiert?\n"
 "Er kann nicht auf die Blobs in seiner 'index' Zeile angewendet werden."
 
 #: git-am.sh:163
@@ -8877,7 +8877,7 @@ msgstr ""
 
 #: git-am.sh:482
 msgid "Please make up your mind. --skip or --abort?"
-msgstr "Bitte werde dir klar. --skip oder --abort?"
+msgstr "Bitte werden Sie sich klar. --skip oder --abort?"
 
 #: git-am.sh:509
 msgid "Resolve operation not in progress, we are not resuming."
@@ -8897,11 +8897,11 @@ msgid ""
 "To restore the original branch and stop patching run \"$cmdline --abort\"."
 msgstr ""
 "Patch ist leer. Wurde er falsch aufgeteilt?\n"
-"Wenn du diesen Patch auslassen möchtest, führe stattdessen \"$cmdline --skip"
-"\" aus.\n"
+"Wenn Sie diesen Patch auslassen möchten, führen Sie stattdessen\n"
+"\"$cmdline --skip\" aus.\n"
 "Um den ursprünglichen Zweig wiederherzustellen und die Anwendung der "
 "Patches\n"
-"abzubrechen, führe \"$cmdline --abort\" aus."
+"abzubrechen, führen Sie \"$cmdline --abort\" aus."
 
 #: git-am.sh:706
 msgid "Patch does not have a valid e-mail address."
@@ -8935,9 +8935,9 @@ msgid ""
 "If there is nothing left to stage, chances are that something else\n"
 "already introduced the same changes; you might want to skip this patch."
 msgstr ""
-"Keine Ã„nderungen - hast du vergessen 'git add' zu benutzen?\n"
+"Keine Ã„nderungen - haben Sie vergessen 'git add' zu benutzen?\n"
 "Wenn keine Ã„nderungen mehr zum Bereitstellen vorhanden sind, könnten\n"
-"diese bereits anderweitig eingefügt worden sein; du könntest diesen Patch\n"
+"diese bereits anderweitig eingefügt worden sein; Sie könnten diesen Patch\n"
 "auslassen."
 
 #: git-am.sh:829
@@ -8945,8 +8945,8 @@ msgid ""
 "You still have unmerged paths in your index\n"
 "did you forget to use 'git add'?"
 msgstr ""
-"Du hast immer noch nicht zusammengeführte Pfade in der Bereitstellung.\n"
-"Hast du vergessen 'git add' zu benutzen?"
+"Sie haben immer noch nicht zusammengeführte Pfade in der Bereitstellung.\n"
+"Haben Sie vergessen 'git add' zu benutzen?"
 
 #: git-am.sh:845
 msgid "No changes -- Patch already applied."
@@ -8972,14 +8972,14 @@ msgstr "wende zu leerer Historie an"
 
 #: git-bisect.sh:48
 msgid "You need to start by \"git bisect start\""
-msgstr "Du musst mit \"git bisect start\" beginnen."
+msgstr "Sie müssen mit \"git bisect start\" beginnen."
 
 #. TRANSLATORS: Make sure to include [Y] and [n] in your
 #. translation. The program will only accept English input
 #. at this point.
 #: git-bisect.sh:54
 msgid "Do you want me to do it for you [Y/n]? "
-msgstr "Willst du, dass ich es für dich mache [Y/n]? "
+msgstr "Wollen Sie, dass ich es für Sie mache [Y/n]? "
 
 #: git-bisect.sh:95
 #, sh-format
@@ -9000,7 +9000,7 @@ msgstr "Ungültige Zweigspitze (HEAD) - Zweigspitze (HEAD) wird benötigt"
 msgid ""
 "Checking out '$start_head' failed. Try 'git bisect reset <validbranch>'."
 msgstr ""
-"Auschecken von '$start_head' fehlgeschlagen. Versuche 'git bisect reset "
+"Auschecken von '$start_head' fehlgeschlagen. Versuchen Sie 'git bisect reset "
 "<gueltigerzweig>'."
 
 #: git-bisect.sh:140
@@ -9023,7 +9023,7 @@ msgstr "Ungültige Referenz-Eingabe: $arg"
 
 #: git-bisect.sh:232
 msgid "Please call 'bisect_state' with at least one argument."
-msgstr "Bitte rufe 'bisect_state' mit mindestens einem Argument auf."
+msgstr "Bitte rufen Sie 'bisect_state' mit mindestens einem Argument auf."
 
 #: git-bisect.sh:244
 #, sh-format
@@ -9045,15 +9045,15 @@ msgstr "Warnung: halbiere nur mit einer fehlerhaften Version"
 #. at this point.
 #: git-bisect.sh:279
 msgid "Are you sure [Y/n]? "
-msgstr "Bist du sicher [Y/n]? "
+msgstr "Sind Sie sicher [Y/n]? "
 
 #: git-bisect.sh:289
 msgid ""
 "You need to give me at least one good and one bad revisions.\n"
 "(You can use \"git bisect bad\" and \"git bisect good\" for that.)"
 msgstr ""
-"Du musst mindestens eine korrekte und eine fehlerhafte Version angeben.\n"
-"(Du kannst dafür \"git bisect bad\" und \"git bisect good\" benutzen.)"
+"Sie müssen mindestens eine korrekte und eine fehlerhafte Version angeben.\n"
+"(Sie können dafür \"git bisect bad\" und \"git bisect good\" benutzen.)"
 
 #: git-bisect.sh:292
 msgid ""
@@ -9061,10 +9061,10 @@ msgid ""
 "You then need to give me at least one good and one bad revisions.\n"
 "(You can use \"git bisect bad\" and \"git bisect good\" for that.)"
 msgstr ""
-"Du musst mit \"git bisect start\" beginnen.\n"
-"Danach musst du mindestens eine korrekte und eine fehlerhafte Version "
+"Sie müssen mit \"git bisect start\" beginnen.\n"
+"Danach müssen Sie mindestens eine korrekte und eine fehlerhafte Version "
 "angeben.\n"
-"(Du kannst dafür \"git bisect bad\" und \"git bisect good\" benutzen.)"
+"(Sie können dafür \"git bisect bad\" und \"git bisect good\" benutzen.)"
 
 #: git-bisect.sh:347 git-bisect.sh:474
 msgid "We are not bisecting."
@@ -9082,7 +9082,7 @@ msgid ""
 "Try 'git bisect reset <commit>'."
 msgstr ""
 "Konnte die ursprüngliche Zweigspitze (HEAD) '$branch' nicht auschecken.\n"
-"Versuche 'git bisect reset <Version>'."
+"Versuchen Sie 'git bisect reset <Version>'."
 
 #: git-bisect.sh:390
 msgid "No logfile given"
@@ -9095,7 +9095,7 @@ msgstr "kann $file nicht für das Abspielen lesen"
 
 #: git-bisect.sh:408
 msgid "?? what are you talking about?"
-msgstr "?? Was redest du da?"
+msgstr "?? Was reden Sie da?"
 
 #: git-bisect.sh:420
 #, sh-format
@@ -9134,14 +9134,14 @@ msgid ""
 "Please, fix them up in the work tree, and then use 'git add/rm <file>'\n"
 "as appropriate to mark resolution, or use 'git commit -a'."
 msgstr ""
-"\"pull\" ist nicht möglich, weil du nicht zusammengeführte Dateien hast.\n"
-"Bitte korrigiere dies im Arbeitsbaum und benutze dann 'git add/rm <Datei>'\n"
-"um die Auflösung entsprechend zu markieren, oder benutze 'git commit -a'."
+"\"pull\" ist nicht möglich, weil Sie nicht zusammengeführte Dateien haben.\n"
+"Bitte korrigieren Sie dies im Arbeitsbaum und benutzen Sie dann 'git add/rm <Datei>'\n"
+"um die Auflösung entsprechend zu markieren, oder benutzen Sie 'git commit -a'."
 
 #: git-pull.sh:25
 msgid "Pull is not possible because you have unmerged files."
 msgstr ""
-"\"pull\" ist nicht möglich, weil du nicht zusammengeführte Dateien hast."
+"\"pull\" ist nicht möglich, weil Sie nicht zusammengeführte Dateien haben."
 
 #: git-pull.sh:197
 msgid "updating an unborn branch with changes added to the index"
@@ -9161,7 +9161,7 @@ msgid ""
 "Warning: commit $orig_head."
 msgstr ""
 "Warnung: Die Anforderung aktualisierte die Spitze des aktuellen Zweiges.\n"
-"Warnung: Spule deinen Arbeitszweig von Version $orig_head vor."
+"Warnung: Spule Ihren Arbeitszweig von Version $orig_head vor."
 
 #: git-pull.sh:254
 msgid "Cannot merge multiple branches into empty head"
@@ -9178,12 +9178,12 @@ msgid ""
 "To check out the original branch and stop rebasing, run \"git rebase --abort"
 "\"."
 msgstr ""
-"Wenn du das Problem aufgelöst hast, führe \"git rebase --continue\" aus.\n"
-"Falls du diesen Patch auslassen möchtest, führe stattdessen \"git rebase --"
+"Wenn Sie das Problem aufgelöst haben, führen Sie \"git rebase --continue\" aus.\n"
+"Falls Sie diesen Patch auslassen möchten, führen Sie stattdessen \"git rebase --"
 "skip\" aus.\n"
 "Um den ursprünglichen Zweig wiederherzustellen und den Neuaufbau "
 "abzubrechen,\n"
-"führe \"git rebase --abort\" aus."
+"führen Sie \"git rebase --abort\" aus."
 
 #: git-rebase.sh:160
 msgid "The pre-rebase hook refused to rebase."
@@ -9215,7 +9215,7 @@ msgid ""
 "You must edit all merge conflicts and then\n"
 "mark them as resolved using git add"
 msgstr ""
-"Du musst alle Zusammenführungskonflikte editieren und diese dann\n"
+"Sie müssen alle Zusammenführungskonflikte editieren und diese dann\n"
 "mittels \"git add\" als aufgelöst markieren"
 
 #: git-rebase.sh:340
@@ -9237,11 +9237,11 @@ msgid ""
 msgstr ""
 "Es sieht so aus, als ob es das Verzeichnis $state_dir_base bereits gibt\n"
 "und es könnte ein anderer Neuaufbau im Gange sein. Wenn das der Fall ist,\n"
-"probiere bitte\n"
+"probieren Sie bitte\n"
 "\t$cmd_live_rebase\n"
-"Wenn das nicht der Fall ist, probiere bitte\n"
+"Wenn das nicht der Fall ist, probieren Sie bitte\n"
 "\t$cmd_clear_stale_rebase\n"
-"und führe dieses Kommando nochmal aus. Es wird angehalten, falls noch\n"
+"und führen Sie dieses Kommando nochmal aus. Es wird angehalten, falls noch\n"
 "etwas Schützenswertes vorhanden ist."
 
 #: git-rebase.sh:404
@@ -9271,7 +9271,7 @@ msgstr "fatal: Zweig $branch_name nicht gefunden"
 
 #: git-rebase.sh:483
 msgid "Please commit or stash them."
-msgstr "Bitte trage die Ã„nderungen ein oder benutze \"stash\"."
+msgstr "Bitte tragen Sie die Ã„nderungen ein oder benutzen Sie \"stash\"."
 
 #: git-rebase.sh:501
 #, sh-format
@@ -9293,7 +9293,7 @@ msgstr "Änderungen von $mb zu $onto:"
 #: git-rebase.sh:524
 msgid "First, rewinding head to replay your work on top of it..."
 msgstr ""
-"Zunächst wird die Zweigspitze zurückgespult, um deine Ã„nderungen\n"
+"Zunächst wird die Zweigspitze zurückgespult, um Ihre Ã„nderungen\n"
 "darauf neu anzuwenden..."
 
 #: git-rebase.sh:532
@@ -9307,7 +9307,7 @@ msgstr "git stash clear mit Parametern ist nicht implementiert"
 
 #: git-stash.sh:74
 msgid "You do not have the initial commit yet"
-msgstr "Du hast bisher noch keine initiale Version"
+msgstr "Sie haben bisher noch keine initiale Version"
 
 #: git-stash.sh:89
 msgid "Cannot save the current index state"
@@ -9346,7 +9346,7 @@ msgid ""
 "       To provide a message, use git stash save -- '$option'"
 msgstr ""
 "Fehler: unbekannte Option für 'stash save': $option\n"
-"        Um eine Beschreibung anzugeben, benutze \"git stash save -- "
+"        Um eine Beschreibung anzugeben, benutzen Sie \"git stash save -- "
 "'$option'\""
 
 #: git-stash.sh:223
@@ -9400,7 +9400,7 @@ msgstr ""
 
 #: git-stash.sh:424
 msgid "Conflicts in index. Try without --index."
-msgstr "Konflikte in der Bereitstellung. Versuche es ohne --index."
+msgstr "Konflikte in der Bereitstellung. Versuchen Sie es ohne --index."
 
 #: git-stash.sh:426
 msgid "Could not save index tree"
@@ -9430,7 +9430,7 @@ msgstr "Kein Zweigname spezifiziert"
 
 #: git-stash.sh:571
 msgid "(To restore them type \"git stash apply\")"
-msgstr "(Zur Wiederherstellung gebe \"git stash apply\" ein)"
+msgstr "(Zur Wiederherstellung geben Sie \"git stash apply\" ein)"
 
 #: git-submodule.sh:89
 #, sh-format
@@ -9471,9 +9471,9 @@ msgid ""
 "$sm_path\n"
 "Use -f if you really want to add it."
 msgstr ""
-"Der folgende Pfad wird durch eine deiner \".gitignore\" Dateien ignoriert:\n"
+"Der folgende Pfad wird durch eine Ihrer \".gitignore\" Dateien ignoriert:\n"
 "$sm_path\n"
-"Benutze -f wenn du diesen wirklich hinzufügen möchtest."
+"Benutzen Sie -f wenn Sie diesen wirklich hinzufügen möchten."
 
 #: git-submodule.sh:355
 #, sh-format
@@ -9497,7 +9497,7 @@ msgstr "Ein Git-Verzeichnis für '$sm_name' wurde lokal gefunden mit den "
 msgid ""
 "If you want to reuse this local git directory instead of cloning again from"
 msgstr ""
-"Wenn du dieses lokale Git-Verzeichnis wiederverwenden möchtest, anstatt "
+"Wenn Sie dieses lokale Git-Verzeichnis wiederverwenden möchtest, anstatt "
 "erneut zu klonen"
 
 #: git-submodule.sh:369
@@ -9505,7 +9505,7 @@ msgstr ""
 msgid ""
 "use the '--force' option. If the local git directory is not the correct repo"
 msgstr ""
-"benutze die Option '--force'. Wenn das lokale Git-Verzeichnis nicht das "
+"benutzen Sie die Option '--force'. Wenn das lokale Git-Verzeichnis nicht das "
 "korrekte Projektarchiv ist"
 
 #: git-submodule.sh:370
@@ -9514,8 +9514,8 @@ msgid ""
 "or you are unsure what this means choose another name with the '--name' "
 "option."
 msgstr ""
-"oder du dir unsicher bist, was das bedeutet, wähle einen anderen Namen mit "
-"der Option '--name'."
+"oder Sie sich unsicher sind, was das bedeutet, wählen Sie einen anderen Namen"
+"mit der Option '--name'."
 
 #: git-submodule.sh:372
 #, sh-format
@@ -9576,7 +9576,7 @@ msgid ""
 "Maybe you want to use 'update --init'?"
 msgstr ""
 "Unterprojekt-Pfad '$sm_path' ist nicht initialisiert\n"
-"Vielleicht möchtest du 'update --init' benutzen?"
+"Vielleicht möchten Sie 'update --init' benutzen?"
 
 #: git-submodule.sh:627
 #, sh-format
index 5bdc2e70bcd1e8fc0c7e625c3eac26397d8c96d2..07fc0628656c5e37eaf04c969a7273455a391f8d 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -387,56 +387,79 @@ void pp_user_info(const struct pretty_print_context *pp,
                  const char *what, struct strbuf *sb,
                  const char *line, const char *encoding)
 {
+       struct strbuf name;
+       struct strbuf mail;
+       struct ident_split ident;
+       int linelen;
+       char *line_end, *date;
+       const char *mailbuf, *namebuf;
+       size_t namelen, maillen;
        int max_length = 78; /* per rfc2822 */
-       char *date;
-       int namelen;
        unsigned long time;
        int tz;
 
        if (pp->fmt == CMIT_FMT_ONELINE)
                return;
-       date = strchr(line, '>');
-       if (!date)
+
+       line_end = strchr(line, '\n');
+       if (!line_end) {
+               line_end = strchr(line, '\0');
+               if (!line_end)
+                       return;
+       }
+
+       linelen = ++line_end - line;
+       if (split_ident_line(&ident, line, linelen))
                return;
-       namelen = ++date - line;
-       time = strtoul(date, &date, 10);
+
+
+       mailbuf = ident.mail_begin;
+       maillen = ident.mail_end - ident.mail_begin;
+       namebuf = ident.name_begin;
+       namelen = ident.name_end - ident.name_begin;
+
+       if (pp->mailmap)
+               map_user(pp->mailmap, &mailbuf, &maillen, &namebuf, &namelen);
+
+       strbuf_init(&mail, 0);
+       strbuf_init(&name, 0);
+
+       strbuf_add(&mail, mailbuf, maillen);
+       strbuf_add(&name, namebuf, namelen);
+
+       namelen = name.len + mail.len + 3; /* ' ' + '<' + '>' */
+       time = strtoul(ident.date_begin, &date, 10);
        tz = strtol(date, NULL, 10);
 
        if (pp->fmt == CMIT_FMT_EMAIL) {
-               char *name_tail = strchr(line, '<');
-               int display_name_length;
-               if (!name_tail)
-                       return;
-               while (line < name_tail && isspace(name_tail[-1]))
-                       name_tail--;
-               display_name_length = name_tail - line;
                strbuf_addstr(sb, "From: ");
-               if (needs_rfc2047_encoding(line, display_name_length, RFC2047_ADDRESS)) {
-                       add_rfc2047(sb, line, display_name_length,
-                                               encoding, RFC2047_ADDRESS);
+               if (needs_rfc2047_encoding(name.buf, name.len, RFC2047_ADDRESS)) {
+                       add_rfc2047(sb, name.buf, name.len,
+                                   encoding, RFC2047_ADDRESS);
                        max_length = 76; /* per rfc2047 */
-               } else if (needs_rfc822_quoting(line, display_name_length)) {
+               } else if (needs_rfc822_quoting(name.buf, name.len)) {
                        struct strbuf quoted = STRBUF_INIT;
-                       add_rfc822_quoted(&quoted, line, display_name_length);
+                       add_rfc822_quoted(&quoted, name.buf, name.len);
                        strbuf_add_wrapped_bytes(sb, quoted.buf, quoted.len,
                                                        -6, 1, max_length);
                        strbuf_release(&quoted);
                } else {
-                       strbuf_add_wrapped_bytes(sb, line, display_name_length,
-                                                       -6, 1, max_length);
+                       strbuf_add_wrapped_bytes(sb, name.buf, name.len,
+                                                -6, 1, max_length);
                }
-               if (namelen - display_name_length + last_line_length(sb) > max_length) {
+               if (namelen - name.len + last_line_length(sb) > max_length)
                        strbuf_addch(sb, '\n');
-                       if (!isspace(name_tail[0]))
-                               strbuf_addch(sb, ' ');
-               }
-               strbuf_add(sb, name_tail, namelen - display_name_length);
-               strbuf_addch(sb, '\n');
+
+               strbuf_addf(sb, " <%s>\n", mail.buf);
        } else {
-               strbuf_addf(sb, "%s: %.*s%.*s\n", what,
+               strbuf_addf(sb, "%s: %.*s%s <%s>\n", what,
                              (pp->fmt == CMIT_FMT_FULLER) ? 4 : 0,
-                             "    ", namelen, line);
+                             "    ", name.buf, mail.buf);
        }
+
+       strbuf_release(&mail);
+       strbuf_release(&name);
+
        switch (pp->fmt) {
        case CMIT_FMT_MEDIUM:
                strbuf_addf(sb, "Date:   %s\n", show_date(time, tz, pp->date_mode));
@@ -567,7 +590,7 @@ char *logmsg_reencode(const struct commit *commit,
        char *encoding;
        char *out;
 
-       if (!*output_encoding)
+       if (!output_encoding || !*output_encoding)
                return NULL;
        encoding = get_header(commit, "encoding");
        use_encoding = encoding ? encoding : utf8;
@@ -586,7 +609,8 @@ char *logmsg_reencode(const struct commit *commit,
        return out;
 }
 
-static int mailmap_name(char *email, int email_len, char *name, int name_len)
+static int mailmap_name(const char **email, size_t *email_len,
+                       const char **name, size_t *name_len)
 {
        static struct string_list *mail_map;
        if (!mail_map) {
@@ -603,36 +627,26 @@ static size_t format_person_part(struct strbuf *sb, char part,
        const int placeholder_len = 2;
        int tz;
        unsigned long date = 0;
-       char person_name[1024];
-       char person_mail[1024];
        struct ident_split s;
-       const char *name_start, *name_end, *mail_start, *mail_end;
+       const char *name, *mail;
+       size_t maillen, namelen;
 
        if (split_ident_line(&s, msg, len) < 0)
                goto skip;
 
-       name_start = s.name_begin;
-       name_end = s.name_end;
-       mail_start = s.mail_begin;
-       mail_end = s.mail_end;
-
-       if (part == 'N' || part == 'E') { /* mailmap lookup */
-               snprintf(person_name, sizeof(person_name), "%.*s",
-                        (int)(name_end - name_start), name_start);
-               snprintf(person_mail, sizeof(person_mail), "%.*s",
-                        (int)(mail_end - mail_start), mail_start);
-               mailmap_name(person_mail, sizeof(person_mail), person_name, sizeof(person_name));
-               name_start = person_name;
-               name_end = name_start + strlen(person_name);
-               mail_start = person_mail;
-               mail_end = mail_start +  strlen(person_mail);
-       }
+       name = s.name_begin;
+       namelen = s.name_end - s.name_begin;
+       mail = s.mail_begin;
+       maillen = s.mail_end - s.mail_begin;
+
+       if (part == 'N' || part == 'E') /* mailmap lookup */
+               mailmap_name(&mail, &maillen, &name, &namelen);
        if (part == 'n' || part == 'N') {       /* name */
-               strbuf_add(sb, name_start, name_end-name_start);
+               strbuf_add(sb, name, namelen);
                return placeholder_len;
        }
        if (part == 'e' || part == 'E') {       /* email */
-               strbuf_add(sb, mail_start, mail_end-mail_start);
+               strbuf_add(sb, mail, maillen);
                return placeholder_len;
        }
 
@@ -960,12 +974,19 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
        switch (placeholder[0]) {
        case 'C':
                if (placeholder[1] == '(') {
-                       const char *end = strchr(placeholder + 2, ')');
+                       const char *begin = placeholder + 2;
+                       const char *end = strchr(begin, ')');
                        char color[COLOR_MAXLEN];
+
                        if (!end)
                                return 0;
-                       color_parse_mem(placeholder + 2,
-                                       end - (placeholder + 2),
+                       if (!prefixcmp(begin, "auto,")) {
+                               if (!want_color(c->pretty_ctx->color))
+                                       return end - placeholder + 1;
+                               begin += 5;
+                       }
+                       color_parse_mem(begin,
+                                       end - begin,
                                        "--pretty format", color);
                        strbuf_addstr(sb, color);
                        return end - placeholder + 1;
@@ -1250,23 +1271,15 @@ void format_commit_message(const struct commit *commit,
                           const struct pretty_print_context *pretty_ctx)
 {
        struct format_commit_context context;
-       static const char utf8[] = "UTF-8";
        const char *output_enc = pretty_ctx->output_encoding;
 
        memset(&context, 0, sizeof(context));
        context.commit = commit;
        context.pretty_ctx = pretty_ctx;
        context.wrap_start = sb->len;
-       context.message = commit->buffer;
-       if (output_enc) {
-               char *enc = get_header(commit, "encoding");
-               if (strcmp(enc ? enc : utf8, output_enc)) {
-                       context.message = logmsg_reencode(commit, output_enc);
-                       if (!context.message)
-                               context.message = commit->buffer;
-               }
-               free(enc);
-       }
+       context.message = logmsg_reencode(commit, output_enc);
+       if (!context.message)
+               context.message = commit->buffer;
 
        strbuf_expand(sb, format, format_commit_item, &context);
        rewrap_message_tail(sb, &context, 0, 0, 0);
@@ -1302,7 +1315,7 @@ static void pp_header(const struct pretty_print_context *pp,
                        continue;
                }
 
-               if (!memcmp(line, "parent ", 7)) {
+               if (!prefixcmp(line, "parent ")) {
                        if (linelen != 48)
                                die("bad parent line in commit");
                        continue;
@@ -1326,11 +1339,11 @@ static void pp_header(const struct pretty_print_context *pp,
                 * FULL shows both authors but not dates.
                 * FULLER shows both authors and dates.
                 */
-               if (!memcmp(line, "author ", 7)) {
+               if (!prefixcmp(line, "author ")) {
                        strbuf_grow(sb, linelen + 80);
                        pp_user_info(pp, "Author", sb, line + 7, encoding);
                }
-               if (!memcmp(line, "committer ", 10) &&
+               if (!prefixcmp(line, "committer ") &&
                    (pp->fmt == CMIT_FMT_FULL || pp->fmt == CMIT_FMT_FULLER)) {
                        strbuf_grow(sb, linelen + 80);
                        pp_user_info(pp, "Commit", sb, line + 10, encoding);
diff --git a/refs.c b/refs.c
index 6cec1c8bdf70589a41c2ace4ba4f21f4035e4ed4..541fec20658082f13ef4b73b621787512b300ba6 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1744,7 +1744,8 @@ static struct lock_file packlock;
 static int repack_without_ref(const char *refname)
 {
        struct repack_without_ref_sb data;
-       struct ref_dir *packed = get_packed_refs(get_ref_cache(NULL));
+       struct ref_cache *refs = get_ref_cache(NULL);
+       struct ref_dir *packed = get_packed_refs(refs);
        if (find_ref(packed, refname) == NULL)
                return 0;
        data.refname = refname;
@@ -1753,6 +1754,8 @@ static int repack_without_ref(const char *refname)
                unable_to_lock_error(git_path("packed-refs"), errno);
                return error("cannot delete '%s' from packed refs", refname);
        }
+       clear_packed_ref_cache(refs);
+       packed = get_packed_refs(refs);
        do_for_each_ref_in_dir(packed, 0, "", repack_without_ref_fn, 0, 0, &data);
        return commit_lock_file(&packlock);
 }
index 6aa49c03df13245486b20b04315437811b260882..9e21b1d78755cec7b30224f10c7f8ecbef3c9a49 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1285,6 +1285,8 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
        struct ref *ref;
 
        for (ref = remote_refs; ref; ref = ref->next) {
+               int force_ref_update = ref->force || force_update;
+
                if (ref->peer_ref)
                        hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
                else if (!send_mirror)
@@ -1297,34 +1299,46 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
                        continue;
                }
 
-               /* This part determines what can overwrite what.
-                * The rules are:
-                *
-                * (0) you can always use --force or +A:B notation to
-                *     selectively force individual ref pairs.
+               /*
+                * Decide whether an individual refspec A:B can be
+                * pushed.  The push will succeed if any of the
+                * following are true:
                 *
-                * (1) if the old thing does not exist, it is OK.
+                * (1) the remote reference B does not exist
                 *
-                * (2) if you do not have the old thing, you are not allowed
-                *     to overwrite it; you would not know what you are losing
-                *     otherwise.
+                * (2) the remote reference B is being removed (i.e.,
+                *     pushing :B where no source is specified)
                 *
-                * (3) if both new and old are commit-ish, and new is a
-                *     descendant of old, it is OK.
+                * (3) the destination is not under refs/tags/, and
+                *     if the old and new value is a commit, the new
+                *     is a descendant of the old.
                 *
-                * (4) regardless of all of the above, removing :B is
-                *     always allowed.
+                * (4) it is forced using the +A:B notation, or by
+                *     passing the --force argument
                 */
 
-               ref->nonfastforward =
+               ref->update =
                        !ref->deletion &&
-                       !is_null_sha1(ref->old_sha1) &&
-                       (!has_sha1_file(ref->old_sha1)
-                         || !ref_newer(ref->new_sha1, ref->old_sha1));
-
-               if (ref->nonfastforward && !ref->force && !force_update) {
-                       ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
-                       continue;
+                       !is_null_sha1(ref->old_sha1);
+
+               if (ref->update) {
+                       ref->nonfastforward =
+                               !has_sha1_file(ref->old_sha1)
+                                 || !ref_newer(ref->new_sha1, ref->old_sha1);
+
+                       if (!prefixcmp(ref->name, "refs/tags/")) {
+                               ref->requires_force = 1;
+                               if (!force_ref_update) {
+                                       ref->status = REF_STATUS_REJECT_ALREADY_EXISTS;
+                                       continue;
+                               }
+                       } else if (ref->nonfastforward) {
+                               ref->requires_force = 1;
+                               if (!force_ref_update) {
+                                       ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
+                                       continue;
+                               }
+                       }
                }
        }
 }
@@ -1370,6 +1384,16 @@ int branch_merge_matches(struct branch *branch,
        return refname_match(branch->merge[i]->src, refname, ref_fetch_rules);
 }
 
+static int ignore_symref_update(const char *refname)
+{
+       unsigned char sha1[20];
+       int flag;
+
+       if (!resolve_ref_unsafe(refname, sha1, 0, &flag))
+               return 0; /* non-existing refs are OK */
+       return (flag & REF_ISSYMREF);
+}
+
 static struct ref *get_expanded_map(const struct ref *remote_refs,
                                    const struct refspec *refspec)
 {
@@ -1383,7 +1407,8 @@ static struct ref *get_expanded_map(const struct ref *remote_refs,
                if (strchr(ref->name, '^'))
                        continue; /* a dereference item */
                if (match_name_with_pattern(refspec->src, ref->name,
-                                           refspec->dst, &expn_name)) {
+                                           refspec->dst, &expn_name) &&
+                   !ignore_symref_update(expn_name)) {
                        struct ref *cpy = copy_ref(ref);
 
                        cpy->peer_ref = alloc_ref(expn_name);
index 95d21e6472921ab993373ef1848357379440d46e..d7562ee5004379774c6fe1a74b0c503475a34ab5 100644 (file)
@@ -13,6 +13,7 @@
 #include "decorate.h"
 #include "log-tree.h"
 #include "string-list.h"
+#include "mailmap.h"
 
 volatile show_early_output_fn_t show_early_output;
 
@@ -2219,6 +2220,51 @@ static int rewrite_parents(struct rev_info *revs, struct commit *commit)
        return 0;
 }
 
+static int commit_rewrite_person(struct strbuf *buf, const char *what, struct string_list *mailmap)
+{
+       char *person, *endp;
+       size_t len, namelen, maillen;
+       const char *name;
+       const char *mail;
+       struct ident_split ident;
+
+       person = strstr(buf->buf, what);
+       if (!person)
+               return 0;
+
+       person += strlen(what);
+       endp = strchr(person, '\n');
+       if (!endp)
+               return 0;
+
+       len = endp - person;
+
+       if (split_ident_line(&ident, person, len))
+               return 0;
+
+       mail = ident.mail_begin;
+       maillen = ident.mail_end - ident.mail_begin;
+       name = ident.name_begin;
+       namelen = ident.name_end - ident.name_begin;
+
+       if (map_user(mailmap, &mail, &maillen, &name, &namelen)) {
+               struct strbuf namemail = STRBUF_INIT;
+
+               strbuf_addf(&namemail, "%.*s <%.*s>",
+                           (int)namelen, name, (int)maillen, mail);
+
+               strbuf_splice(buf, ident.name_begin - buf->buf,
+                             ident.mail_end - ident.name_begin + 1,
+                             namemail.buf, namemail.len);
+
+               strbuf_release(&namemail);
+
+               return 1;
+       }
+
+       return 0;
+}
+
 static int commit_match(struct commit *commit, struct rev_info *opt)
 {
        int retval;
@@ -2237,6 +2283,14 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
        if (buf.len)
                strbuf_addstr(&buf, commit->buffer);
 
+       if (opt->grep_filter.header_list && opt->mailmap) {
+               if (!buf.len)
+                       strbuf_addstr(&buf, commit->buffer);
+
+               commit_rewrite_person(&buf, "\nauthor ", opt->mailmap);
+               commit_rewrite_person(&buf, "\ncommitter ", opt->mailmap);
+       }
+
        /* Append "fake" message parts as needed */
        if (opt->show_notes) {
                if (!buf.len)
index 059bfff812da8033681aa11c5a9ca9085881747e..5da09ee3efa976b503cba5d13e347aad0f6c764c 100644 (file)
@@ -135,6 +135,7 @@ struct rev_info {
        const char      *mime_boundary;
        const char      *patch_suffix;
        int             numbered_files;
+       int             reroll_count;
        char            *message_id;
        struct string_list *ref_message_ids;
        const char      *add_signoff;
@@ -143,6 +144,7 @@ struct rev_info {
        const char      *subject_prefix;
        int             no_inline;
        int             show_log_size;
+       struct string_list *mailmap;
 
        /* Filter by commit log message */
        struct grep_opt grep_filter;
index 3b982e4d55274ebe87c5751fa198bee53e371d9b..04712191e8acfbf000c526a5b1b0a80541e8e174 100644 (file)
@@ -226,7 +226,7 @@ static inline void set_cloexec(int fd)
                fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
 }
 
-static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
+static int wait_or_whine(pid_t pid, const char *argv0)
 {
        int status, code = -1;
        pid_t waiting;
@@ -242,13 +242,14 @@ static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
                error("waitpid is confused (%s)", argv0);
        } else if (WIFSIGNALED(status)) {
                code = WTERMSIG(status);
-               error("%s died of signal %d", argv0, code);
+               if (code != SIGINT && code != SIGQUIT)
+                       error("%s died of signal %d", argv0, code);
                /*
                 * This return value is chosen so that code & 0xff
                 * mimics the exit code that a POSIX shell would report for
                 * a program that died from this signal.
                 */
-               code -= 128;
+               code += 128;
        } else if (WIFEXITED(status)) {
                code = WEXITSTATUS(status);
                /*
@@ -432,8 +433,7 @@ fail_pipe:
                 * At this point we know that fork() succeeded, but execvp()
                 * failed. Errors have been reported to our stderr.
                 */
-               wait_or_whine(cmd->pid, cmd->argv[0],
-                             cmd->silent_exec_failure);
+               wait_or_whine(cmd->pid, cmd->argv[0]);
                failed_errno = errno;
                cmd->pid = -1;
        }
@@ -538,7 +538,7 @@ fail_pipe:
 
 int finish_command(struct child_process *cmd)
 {
-       return wait_or_whine(cmd->pid, cmd->argv[0], cmd->silent_exec_failure);
+       return wait_or_whine(cmd->pid, cmd->argv[0]);
 }
 
 int run_command(struct child_process *cmd)
@@ -725,7 +725,7 @@ error:
 int finish_async(struct async *async)
 {
 #ifdef NO_PTHREADS
-       return wait_or_whine(async->pid, "child process", 0);
+       return wait_or_whine(async->pid, "child process");
 #else
        void *ret = (void *)(intptr_t)(-1);
 
index f50dfd9f488821e6b052affb19c0048afd11109c..1c375f0a28c6417f1f6cb48afbde681f458c544d 100644 (file)
@@ -229,6 +229,7 @@ int send_pack(struct send_pack_args *args,
                /* Check for statuses set by set_ref_status_for_push() */
                switch (ref->status) {
                case REF_STATUS_REJECT_NONFASTFORWARD:
+               case REF_STATUS_REJECT_ALREADY_EXISTS:
                case REF_STATUS_UPTODATE:
                        continue;
                default:
index 22604902aa4c4dd146f562c4841c344a773a9bda..aef5e8a0170c5b337f1aa3ac7a35be3b54957729 100644 (file)
@@ -186,14 +186,15 @@ static int error_dirty_index(struct replay_opts *opts)
        return -1;
 }
 
-static int fast_forward_to(const unsigned char *to, const unsigned char *from)
+static int fast_forward_to(const unsigned char *to, const unsigned char *from,
+                          int unborn)
 {
        struct ref_lock *ref_lock;
 
        read_cache();
        if (checkout_fast_forward(from, to, 1))
                exit(1); /* the callee should have complained already */
-       ref_lock = lock_any_ref_for_update("HEAD", from, 0);
+       ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from, 0);
        return write_ref_sha1(ref_lock, to, "cherry-pick");
 }
 
@@ -390,7 +391,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
        struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };
        char *defmsg = NULL;
        struct strbuf msgbuf = STRBUF_INIT;
-       int res;
+       int res, unborn = 0;
 
        if (opts->no_commit) {
                /*
@@ -402,9 +403,10 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
                if (write_cache_as_tree(head, 0, NULL))
                        die (_("Your index file is unmerged."));
        } else {
-               if (get_sha1("HEAD", head))
-                       return error(_("You do not have a valid HEAD"));
-               if (index_differs_from("HEAD", 0))
+               unborn = get_sha1("HEAD", head);
+               if (unborn)
+                       hashcpy(head, EMPTY_TREE_SHA1_BIN);
+               if (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : "HEAD", 0))
                        return error_dirty_index(opts);
        }
        discard_cache();
@@ -435,8 +437,10 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
        else
                parent = commit->parents->item;
 
-       if (opts->allow_ff && parent && !hashcmp(parent->object.sha1, head))
-               return fast_forward_to(commit->object.sha1, head);
+       if (opts->allow_ff &&
+           ((parent && !hashcmp(parent->object.sha1, head)) ||
+            (!parent && unborn)))
+            return fast_forward_to(commit->object.sha1, head, unborn);
 
        if (parent && parse_commit(parent) < 0)
                /* TRANSLATORS: The first %s will be "revert" or
diff --git a/setup.c b/setup.c
index 3a1b2fd45580cad7ecd55efa755872efc81075ad..f108c4b990c0e4f6a98c1fe34d3031040c84195a 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "dir.h"
+#include "string-list.h"
 
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
@@ -620,6 +621,27 @@ static dev_t get_device_or_die(const char *path, const char *prefix, int prefix_
        return buf.st_dev;
 }
 
+/*
+ * A "string_list_each_func_t" function that canonicalizes an entry
+ * from GIT_CEILING_DIRECTORIES using real_path_if_valid(), or
+ * discards it if unusable.
+ */
+static int canonicalize_ceiling_entry(struct string_list_item *item,
+                                     void *unused)
+{
+       char *ceil = item->string;
+       const char *real_path;
+
+       if (!*ceil || !is_absolute_path(ceil))
+               return 0;
+       real_path = real_path_if_valid(ceil);
+       if (!real_path)
+               return 0;
+       free(item->string);
+       item->string = xstrdup(real_path);
+       return 1;
+}
+
 /*
  * We cannot decide in this function whether we are in the work tree or
  * not, since the config can only be read _after_ this function was called.
@@ -627,10 +649,11 @@ static dev_t get_device_or_die(const char *path, const char *prefix, int prefix_
 static const char *setup_git_directory_gently_1(int *nongit_ok)
 {
        const char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);
+       struct string_list ceiling_dirs = STRING_LIST_INIT_DUP;
        static char cwd[PATH_MAX+1];
        const char *gitdirenv, *ret;
        char *gitfile;
-       int len, offset, offset_parent, ceil_offset;
+       int len, offset, offset_parent, ceil_offset = -1;
        dev_t current_device = 0;
        int one_filesystem = 1;
 
@@ -655,7 +678,14 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
        if (gitdirenv)
                return setup_explicit_git_dir(gitdirenv, cwd, len, nongit_ok);
 
-       ceil_offset = longest_ancestor_length(cwd, env_ceiling_dirs);
+       if (env_ceiling_dirs) {
+               string_list_split(&ceiling_dirs, env_ceiling_dirs, PATH_SEP, -1);
+               filter_string_list(&ceiling_dirs, 0,
+                                  canonicalize_ceiling_entry, NULL);
+               ceil_offset = longest_ancestor_length(cwd, &ceiling_dirs);
+               string_list_clear(&ceiling_dirs, 0);
+       }
+
        if (ceil_offset < 0 && has_dos_drive_prefix(cwd))
                ceil_offset = 1;
 
index 05d0693eba1eba4e2f21057388368c0890e668fe..9a373bef70b7fdd434c02d1ca753fcc8f799ecc2 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -425,6 +425,32 @@ void strbuf_add_lines(struct strbuf *out, const char *prefix,
        strbuf_complete_line(out);
 }
 
+void strbuf_addstr_xml_quoted(struct strbuf *buf, const char *s)
+{
+       while (*s) {
+               size_t len = strcspn(s, "\"<>&");
+               strbuf_add(buf, s, len);
+               s += len;
+               switch (*s) {
+               case '"':
+                       strbuf_addstr(buf, "&quot;");
+                       break;
+               case '<':
+                       strbuf_addstr(buf, "&lt;");
+                       break;
+               case '>':
+                       strbuf_addstr(buf, "&gt;");
+                       break;
+               case '&':
+                       strbuf_addstr(buf, "&amp;");
+                       break;
+               case 0:
+                       return;
+               }
+               s++;
+       }
+}
+
 static int is_rfc3986_reserved(char ch)
 {
        switch (ch) {
index aa386c6074ec0006acbd1067b561a9b2695e29f0..ecae4e215f6377702c2b33e78ca1a0e454ebd819 100644 (file)
--- a/strbuf.h
+++ b/strbuf.h
@@ -136,6 +136,12 @@ extern void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
 
 extern void strbuf_add_lines(struct strbuf *sb, const char *prefix, const char *buf, size_t size);
 
+/*
+ * Append s to sb, with the characters '<', '>', '&' and '"' converted
+ * into XML entities.
+ */
+extern void strbuf_addstr_xml_quoted(struct strbuf *sb, const char *s);
+
 static inline void strbuf_complete_line(struct strbuf *sb)
 {
        if (sb->len && sb->buf[sb->len - 1] != '\n')
index 397e6cfa7db82bdb17f7cdbe4662a1607c0773af..aabb25ef4c1040dde015d6ac37b8213d9bc958ea 100644 (file)
@@ -7,10 +7,11 @@ static int get_entry_index(const struct string_list *list, const char *string,
                int *exact_match)
 {
        int left = -1, right = list->nr;
+       compare_strings_fn cmp = list->cmp ? list->cmp : strcmp;
 
        while (left + 1 < right) {
                int middle = (left + right) / 2;
-               int compare = strcmp(string, list->items[middle].string);
+               int compare = cmp(string, list->items[middle].string);
                if (compare < 0)
                        right = middle;
                else if (compare > 0)
@@ -96,8 +97,9 @@ void string_list_remove_duplicates(struct string_list *list, int free_util)
 {
        if (list->nr > 1) {
                int src, dst;
+               compare_strings_fn cmp = list->cmp ? list->cmp : strcmp;
                for (src = dst = 1; src < list->nr; src++) {
-                       if (!strcmp(list->items[dst - 1].string, list->items[src].string)) {
+                       if (!cmp(list->items[dst - 1].string, list->items[src].string)) {
                                if (list->strdup_strings)
                                        free(list->items[src].string);
                                if (free_util)
@@ -145,26 +147,6 @@ void string_list_remove_empty_items(struct string_list *list, int free_util) {
        filter_string_list(list, free_util, item_is_not_empty, NULL);
 }
 
-char *string_list_longest_prefix(const struct string_list *prefixes,
-                                const char *string)
-{
-       int i, max_len = -1;
-       char *retval = NULL;
-
-       for (i = 0; i < prefixes->nr; i++) {
-               char *prefix = prefixes->items[i].string;
-               if (!prefixcmp(string, prefix)) {
-                       int len = strlen(prefix);
-                       if (len > max_len) {
-                               retval = prefix;
-                               max_len = len;
-                       }
-               }
-       }
-
-       return retval;
-}
-
 void string_list_clear(struct string_list *list, int free_util)
 {
        if (list->items) {
@@ -230,15 +212,20 @@ struct string_list_item *string_list_append(struct string_list *list,
                        list->strdup_strings ? xstrdup(string) : (char *)string);
 }
 
+/* Yuck */
+static compare_strings_fn compare_for_qsort;
+
+/* Only call this from inside sort_string_list! */
 static int cmp_items(const void *a, const void *b)
 {
        const struct string_list_item *one = a;
        const struct string_list_item *two = b;
-       return strcmp(one->string, two->string);
+       return compare_for_qsort(one->string, two->string);
 }
 
 void sort_string_list(struct string_list *list)
 {
+       compare_for_qsort = list->cmp ? list->cmp : strcmp;
        qsort(list->items, list->nr, sizeof(*list->items), cmp_items);
 }
 
@@ -246,8 +233,10 @@ struct string_list_item *unsorted_string_list_lookup(struct string_list *list,
                                                     const char *string)
 {
        int i;
+       compare_strings_fn cmp = list->cmp ? list->cmp : strcmp;
+
        for (i = 0; i < list->nr; i++)
-               if (!strcmp(string, list->items[i].string))
+               if (!cmp(string, list->items[i].string))
                        return list->items + i;
        return NULL;
 }
index c50b0d0deac086cd5a50a5c021103a5f5e76c1cd..de6769c92dd109791c872b8d320c2caeee9f2b8d 100644 (file)
@@ -5,10 +5,14 @@ struct string_list_item {
        char *string;
        void *util;
 };
+
+typedef int (*compare_strings_fn)(const char *, const char *);
+
 struct string_list {
        struct string_list_item *items;
        unsigned int nr, alloc;
        unsigned int strdup_strings:1;
+       compare_strings_fn cmp; /* NULL uses strcmp() */
 };
 
 #define STRING_LIST_INIT_NODUP { NULL, 0, 0, 0 }
@@ -45,15 +49,6 @@ void filter_string_list(struct string_list *list, int free_util,
  */
 void string_list_remove_empty_items(struct string_list *list, int free_util);
 
-/*
- * Return the longest string in prefixes that is a prefix (in the
- * sense of prefixcmp()) of string, or NULL if no such prefix exists.
- * This function does not require the string_list to be sorted (it
- * does a linear search).
- */
-char *string_list_longest_prefix(const struct string_list *prefixes, const char *string);
-
-
 /* Use these functions only on sorted lists: */
 int string_list_has_string(const struct string_list *list, const char *string);
 int string_list_find_insert_index(const struct string_list *list, const char *string,
index 3025418ff57c8c16cd11dd0db4f9d442743118fa..1923cc104bc71e5a696676232d6f42b47a19de25 100644 (file)
@@ -13,9 +13,11 @@ TAR ?= $(TAR)
 RM ?= rm -f
 PROVE ?= prove
 DEFAULT_TEST_TARGET ?= test
+TEST_LINT ?= test-lint-duplicates test-lint-executable
 
 # Shell quote;
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
+PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
 
 T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
 TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
@@ -43,7 +45,7 @@ clean-except-prove-cache:
 clean: clean-except-prove-cache
        $(RM) .prove
 
-test-lint: test-lint-duplicates test-lint-executable
+test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax
 
 test-lint-duplicates:
        @dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
@@ -55,6 +57,9 @@ test-lint-executable:
                test -z "$$bad" || { \
                echo >&2 "non-executable tests:" $$bad; exit 1; }
 
+test-lint-shell-syntax:
+       @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T)
+
 aggregate-results-and-cleanup: $(T)
        $(MAKE) aggregate-results
        $(MAKE) clean
@@ -87,7 +92,7 @@ test-results:
        mkdir -p test-results
 
 test-results/git-smoke.tar.gz: test-results
-       $(PERL_PATH) ./harness \
+       '$(PERL_PATH_SQ)' ./harness \
                --archive="test-results/git-smoke.tar.gz" \
                $(T)
 
diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl
new file mode 100755 (executable)
index 0000000..8b5a71d
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+
+# Test t0000..t9999.sh for non portable shell scripts
+# This script can be called with one or more filenames as parameters
+
+use strict;
+use warnings;
+
+my $exit_code=0;
+
+sub err {
+       my $msg = shift;
+       print "$ARGV:$.: error: $msg: $_\n";
+       $exit_code = 1;
+}
+
+while (<>) {
+       chomp;
+       /^\s*sed\s+-i/ and err 'sed -i is not portable';
+       /^\s*echo\s+-n/ and err 'echo -n is not portable (please use printf)';
+       /^\s*declare\s+/ and err 'arrays/declare not portable';
+       /^\s*[^#]\s*which\s/ and err 'which is not portable (please use type)';
+       /test\s+[^=]*==/ and err '"test a == b" is not portable (please use =)';
+       # this resets our $. for each file
+       close ARGV if eof;
+}
+exit $exit_code;
index 0f76f6cdc06b88c3e099c64cab76bfe7a019f8db..ae8883a07514c47b0568c9323698e879b38703e5 100644 (file)
@@ -14,12 +14,14 @@ export GIT_TEXTDOMAINDIR GIT_PO_PATH
 if test_have_prereq GETTEXT && ! test_have_prereq GETTEXT_POISON
 then
        # is_IS.UTF-8 on Solaris and FreeBSD, is_IS.utf8 on Debian
-       is_IS_locale=$(locale -a | sed -n '/^is_IS\.[uU][tT][fF]-*8$/{
+       is_IS_locale=$(locale -a 2>/dev/null |
+               sed -n '/^is_IS\.[uU][tT][fF]-*8$/{
                p
                q
        }')
        # is_IS.ISO8859-1 on Solaris and FreeBSD, is_IS.iso88591 on Debian
-       is_IS_iso_locale=$(locale -a | sed -n '/^is_IS\.[iI][sS][oO]8859-*1$/{
+       is_IS_iso_locale=$(locale -a 2>/dev/null |
+               sed -n '/^is_IS\.[iI][sS][oO]8859-*1$/{
                p
                q
        }')
index 562cf41cad7b0532ab4a15625950720c71549742..cefe33d6d1976e4017569507a6f76ad89c83e4ff 100755 (executable)
@@ -45,39 +45,176 @@ test_expect_failure 'pretend we have a known breakage' '
        false
 '
 
-test_expect_success 'pretend we have fixed a known breakage (run in sub test-lib)' "
-       mkdir passing-todo &&
-       (cd passing-todo &&
-       cat >passing-todo.sh <<-EOF &&
-       #!$SHELL_PATH
-
-       test_description='A passing TODO test
+run_sub_test_lib_test () {
+       name="$1" descr="$2" # stdin is the body of the test code
+       mkdir "$name" &&
+       (
+               cd "$name" &&
+               cat >"$name.sh" <<-EOF &&
+               #!$SHELL_PATH
+
+               test_description='$descr (run in sub test-lib)
+
+               This is run in a sub test-lib so that we do not get incorrect
+               passing metrics
+               '
+
+               # Point to the t/test-lib.sh, which isn't in ../ as usual
+               . "\$TEST_DIRECTORY"/test-lib.sh
+               EOF
+               cat >>"$name.sh" &&
+               chmod +x "$name.sh" &&
+               export TEST_DIRECTORY &&
+               ./"$name.sh" >out 2>err
+       )
+}
 
-       This is run in a sub test-lib so that we do not get incorrect
-       passing metrics
-       '
+check_sub_test_lib_test () {
+       name="$1" # stdin is the expected output from the test
+       (
+               cd "$name" &&
+               ! test -s err &&
+               sed -e 's/^> //' -e 's/Z$//' >expect &&
+               test_cmp expect out
+       )
+}
+
+test_expect_success 'pretend we have a fully passing test suite' "
+       run_sub_test_lib_test full-pass '3 passing tests' <<-\\EOF &&
+       for i in 1 2 3
+       do
+               test_expect_success \"passing test #\$i\" 'true'
+       done
+       test_done
+       EOF
+       check_sub_test_lib_test full-pass <<-\\EOF
+       > ok 1 - passing test #1
+       > ok 2 - passing test #2
+       > ok 3 - passing test #3
+       > # passed all 3 test(s)
+       > 1..3
+       EOF
+"
 
-       # Point to the t/test-lib.sh, which isn't in ../ as usual
-       TEST_DIRECTORY=\"$TEST_DIRECTORY\"
-       . \"\$TEST_DIRECTORY\"/test-lib.sh
+test_expect_success 'pretend we have a partially passing test suite' "
+       test_must_fail run_sub_test_lib_test \
+               partial-pass '2/3 tests passing' <<-\\EOF &&
+       test_expect_success 'passing test #1' 'true'
+       test_expect_success 'failing test #2' 'false'
+       test_expect_success 'passing test #3' 'true'
+       test_done
+       EOF
+       check_sub_test_lib_test partial-pass <<-\\EOF
+       > ok 1 - passing test #1
+       > not ok 2 - failing test #2
+       #       false
+       > ok 3 - passing test #3
+       > # failed 1 among 3 test(s)
+       > 1..3
+       EOF
+"
 
-       test_expect_failure 'pretend we have fixed a known breakage' '
-               :
-       '
+test_expect_success 'pretend we have a known breakage' "
+       run_sub_test_lib_test failing-todo 'A failing TODO test' <<-\\EOF &&
+       test_expect_success 'passing test' 'true'
+       test_expect_failure 'pretend we have a known breakage' 'false'
+       test_done
+       EOF
+       check_sub_test_lib_test failing-todo <<-\\EOF
+       > ok 1 - passing test
+       > not ok 2 - pretend we have a known breakage # TODO known breakage
+       > # still have 1 known breakage(s)
+       > # passed all remaining 1 test(s)
+       > 1..2
+       EOF
+"
 
+test_expect_success 'pretend we have fixed a known breakage' "
+       run_sub_test_lib_test passing-todo 'A passing TODO test' <<-\\EOF &&
+       test_expect_failure 'pretend we have fixed a known breakage' 'true'
        test_done
        EOF
-       chmod +x passing-todo.sh &&
-       ./passing-todo.sh >out 2>err &&
-       ! test -s err &&
-       sed -e 's/^> //' >expect <<-\\EOF &&
-       > ok 1 - pretend we have fixed a known breakage # TODO known breakage
-       > # fixed 1 known breakage(s)
-       > # passed all 1 test(s)
+       check_sub_test_lib_test passing-todo <<-\\EOF
+       > ok 1 - pretend we have fixed a known breakage # TODO known breakage vanished
+       > # 1 known breakage(s) vanished; please update test(s)
        > 1..1
        EOF
-       test_cmp expect out)
 "
+
+test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' "
+       run_sub_test_lib_test partially-passing-todos \
+               '2 TODO tests, one passing' <<-\\EOF &&
+       test_expect_failure 'pretend we have a known breakage' 'false'
+       test_expect_success 'pretend we have a passing test' 'true'
+       test_expect_failure 'pretend we have fixed another known breakage' 'true'
+       test_done
+       EOF
+       check_sub_test_lib_test partially-passing-todos <<-\\EOF
+       > not ok 1 - pretend we have a known breakage # TODO known breakage
+       > ok 2 - pretend we have a passing test
+       > ok 3 - pretend we have fixed another known breakage # TODO known breakage vanished
+       > # 1 known breakage(s) vanished; please update test(s)
+       > # still have 1 known breakage(s)
+       > # passed all remaining 1 test(s)
+       > 1..3
+       EOF
+"
+
+test_expect_success 'pretend we have a pass, fail, and known breakage' "
+       test_must_fail run_sub_test_lib_test \
+               mixed-results1 'mixed results #1' <<-\\EOF &&
+       test_expect_success 'passing test' 'true'
+       test_expect_success 'failing test' 'false'
+       test_expect_failure 'pretend we have a known breakage' 'false'
+       test_done
+       EOF
+       check_sub_test_lib_test mixed-results1 <<-\\EOF
+       > ok 1 - passing test
+       > not ok 2 - failing test
+       > #     false
+       > not ok 3 - pretend we have a known breakage # TODO known breakage
+       > # still have 1 known breakage(s)
+       > # failed 1 among remaining 2 test(s)
+       > 1..3
+       EOF
+"
+
+test_expect_success 'pretend we have a mix of all possible results' "
+       test_must_fail run_sub_test_lib_test \
+               mixed-results2 'mixed results #2' <<-\\EOF &&
+       test_expect_success 'passing test' 'true'
+       test_expect_success 'passing test' 'true'
+       test_expect_success 'passing test' 'true'
+       test_expect_success 'passing test' 'true'
+       test_expect_success 'failing test' 'false'
+       test_expect_success 'failing test' 'false'
+       test_expect_success 'failing test' 'false'
+       test_expect_failure 'pretend we have a known breakage' 'false'
+       test_expect_failure 'pretend we have a known breakage' 'false'
+       test_expect_failure 'pretend we have fixed a known breakage' 'true'
+       test_done
+       EOF
+       check_sub_test_lib_test mixed-results2 <<-\\EOF
+       > ok 1 - passing test
+       > ok 2 - passing test
+       > ok 3 - passing test
+       > ok 4 - passing test
+       > not ok 5 - failing test
+       > #     false
+       > not ok 6 - failing test
+       > #     false
+       > not ok 7 - failing test
+       > #     false
+       > not ok 8 - pretend we have a known breakage # TODO known breakage
+       > not ok 9 - pretend we have a known breakage # TODO known breakage
+       > ok 10 - pretend we have fixed a known breakage # TODO known breakage vanished
+       > # 1 known breakage(s) vanished; please update test(s)
+       > # still have 2 known breakage(s)
+       > # failed 3 among remaining 7 test(s)
+       > 1..10
+       EOF
+"
+
 test_set_prereq HAVEIT
 haveit=no
 test_expect_success HAVEIT 'test runs if prerequisite is satisfied' '
@@ -159,19 +296,8 @@ then
 fi
 
 test_expect_success 'tests clean up even on failures' "
-       mkdir failing-cleanup &&
-       (
-       cd failing-cleanup &&
-
-       cat >failing-cleanup.sh <<-EOF &&
-       #!$SHELL_PATH
-
-       test_description='Failing tests with cleanup commands'
-
-       # Point to the t/test-lib.sh, which isn't in ../ as usual
-       TEST_DIRECTORY=\"$TEST_DIRECTORY\"
-       . \"\$TEST_DIRECTORY\"/test-lib.sh
-
+       test_must_fail run_sub_test_lib_test \
+               failing-cleanup 'Failing tests with cleanup commands' <<-\\EOF &&
        test_expect_success 'tests clean up even after a failure' '
                touch clean-after-failure &&
                test_when_finished rm clean-after-failure &&
@@ -181,29 +307,21 @@ test_expect_success 'tests clean up even on failures' "
                test_when_finished \"(exit 2)\"
        '
        test_done
-
        EOF
-
-       chmod +x failing-cleanup.sh &&
-       test_must_fail ./failing-cleanup.sh >out 2>err &&
-       ! test -s err &&
-       ! test -f \"trash directory.failing-cleanup/clean-after-failure\" &&
-       sed -e 's/Z$//' -e 's/^> //' >expect <<-\\EOF &&
-       > not ok - 1 tests clean up even after a failure
+       check_sub_test_lib_test failing-cleanup <<-\\EOF
+       > not ok 1 - tests clean up even after a failure
        > #     Z
        > #     touch clean-after-failure &&
        > #     test_when_finished rm clean-after-failure &&
        > #     (exit 1)
        > #     Z
-       > not ok - 2 failure to clean up causes the test to fail
+       > not ok 2 - failure to clean up causes the test to fail
        > #     Z
        > #     test_when_finished \"(exit 2)\"
        > #     Z
        > # failed 2 among 2 test(s)
        > 1..2
        EOF
-       test_cmp expect out
-       )
 "
 
 ################################################################
index 807b8b88e215df5ce39504b1858be8694499727d..43b25137e9878e41557fd7d095cc991c27efdfc7 100755 (executable)
@@ -206,6 +206,43 @@ test_expect_success 'patterns starting with exclamation' '
        attr_check "!f" foo
 '
 
+test_expect_success '"**" test' '
+       echo "**/f foo=bar" >.gitattributes &&
+       cat <<\EOF >expect &&
+f: foo: bar
+a/f: foo: bar
+a/b/f: foo: bar
+a/b/c/f: foo: bar
+EOF
+       git check-attr foo -- "f" >actual 2>err &&
+       git check-attr foo -- "a/f" >>actual 2>>err &&
+       git check-attr foo -- "a/b/f" >>actual 2>>err &&
+       git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
+       test_cmp expect actual &&
+       test_line_count = 0 err
+'
+
+test_expect_success '"**" with no slashes test' '
+       echo "a**f foo=bar" >.gitattributes &&
+       git check-attr foo -- "f" >actual &&
+       cat <<\EOF >expect &&
+f: foo: unspecified
+af: foo: bar
+axf: foo: bar
+a/f: foo: unspecified
+a/b/f: foo: unspecified
+a/b/c/f: foo: unspecified
+EOF
+       git check-attr foo -- "f" >actual 2>err &&
+       git check-attr foo -- "af" >>actual 2>err &&
+       git check-attr foo -- "axf" >>actual 2>err &&
+       git check-attr foo -- "a/f" >>actual 2>>err &&
+       git check-attr foo -- "a/b/f" >>actual 2>>err &&
+       git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
+       test_cmp expect actual &&
+       test_line_count = 0 err
+'
+
 test_expect_success 'setup bare' '
        git clone --bare . bare.git &&
        cd bare.git
index ec6c1b3f8a7eac0e1734883a0ad2f2d68f11bf96..5378787e1b23bf18796c28c33533f677b389289c 100755 (executable)
@@ -3,7 +3,12 @@
 test_description='respect crlf in git archive'
 
 . ./test-lib.sh
-UNZIP=${UNZIP:-unzip}
+GIT_UNZIP=${GIT_UNZIP:-unzip}
+
+test_lazy_prereq UNZIP '
+       "$GIT_UNZIP" -v
+       test $? -ne 127
+'
 
 test_expect_success setup '
 
@@ -26,18 +31,11 @@ test_expect_success 'tar archive' '
 
 '
 
-"$UNZIP" -v >/dev/null 2>&1
-if [ $? -eq 127 ]; then
-       say "Skipping ZIP test, because unzip was not found"
-else
-       test_set_prereq UNZIP
-fi
-
 test_expect_success UNZIP 'zip archive' '
 
        git archive --format=zip HEAD >test.zip &&
 
-       ( mkdir unzipped && cd unzipped && unzip ../test.zip ) &&
+       ( mkdir unzipped && cd unzipped && "$GIT_UNZIP" ../test.zip ) &&
 
        test_cmp sample unzipped/sample
 
index 4ef2345982fe0e0c175ed67edcb20b04c81b9680..09a42a428e1d286c5ab9e1003d49481ef6df3e44 100755 (executable)
@@ -93,47 +93,32 @@ norm_path /d1/s1//../s2/../../d2 /d2 POSIX
 norm_path /d1/.../d2 /d1/.../d2 POSIX
 norm_path /d1/..././../d2 /d1/d2 POSIX
 
-ancestor / "" -1
 ancestor / / -1
-ancestor /foo "" -1
-ancestor /foo : -1
-ancestor /foo ::. -1
-ancestor /foo ::..:: -1
 ancestor /foo / 0
 ancestor /foo /fo -1
 ancestor /foo /foo -1
-ancestor /foo /foo/ -1
 ancestor /foo /bar -1
-ancestor /foo /bar/ -1
 ancestor /foo /foo/bar -1
-ancestor /foo /foo:/bar/ -1
-ancestor /foo /foo/:/bar/ -1
-ancestor /foo /foo::/bar/ -1
-ancestor /foo /:/foo:/bar/ 0
-ancestor /foo /foo:/:/bar/ 0
-ancestor /foo /:/bar/:/foo 0
-ancestor /foo/bar "" -1
+ancestor /foo /foo:/bar -1
+ancestor /foo /:/foo:/bar 0
+ancestor /foo /foo:/:/bar 0
+ancestor /foo /:/bar:/foo 0
 ancestor /foo/bar / 0
 ancestor /foo/bar /fo -1
-ancestor /foo/bar foo -1
 ancestor /foo/bar /foo 4
-ancestor /foo/bar /foo/ 4
 ancestor /foo/bar /foo/ba -1
 ancestor /foo/bar /:/fo 0
 ancestor /foo/bar /foo:/foo/ba 4
 ancestor /foo/bar /bar -1
-ancestor /foo/bar /bar/ -1
-ancestor /foo/bar /fo: -1
-ancestor /foo/bar :/fo -1
-ancestor /foo/bar /foo:/bar/ 4
-ancestor /foo/bar /:/foo:/bar/ 4
-ancestor /foo/bar /foo:/:/bar/ 4
-ancestor /foo/bar /:/bar/:/fo 0
-ancestor /foo/bar /:/bar/ 0
-ancestor /foo/bar .:/foo/. 4
-ancestor /foo/bar .:/foo/.:.: 4
-ancestor /foo/bar /foo/./:.:/bar 4
-ancestor /foo/bar .:/bar -1
+ancestor /foo/bar /fo -1
+ancestor /foo/bar /foo:/bar 4
+ancestor /foo/bar /:/foo:/bar 4
+ancestor /foo/bar /foo:/:/bar 4
+ancestor /foo/bar /:/bar:/fo 0
+ancestor /foo/bar /:/bar 0
+ancestor /foo/bar /foo 4
+ancestor /foo/bar /foo:/bar 4
+ancestor /foo/bar /bar -1
 
 test_expect_success 'strip_path_suffix' '
        test c:/msysgit = $(test-path-utils strip_path_suffix \
index 41c8826a74db9a5c34ad3365f4875f6317a5bca0..dbfc05ebdc3990bf4ea5b0163afb4c6a9e698fa7 100755 (executable)
@@ -17,14 +17,6 @@ test_split () {
        "
 }
 
-test_longest_prefix () {
-       test "$(test-string-list longest_prefix "$1" "$2")" = "$3"
-}
-
-test_no_longest_prefix () {
-       test_must_fail test-string-list longest_prefix "$1" "$2"
-}
-
 test_split "foo:bar:baz" ":" "-1" <<EOF
 3
 [0]: "foo"
@@ -96,26 +88,4 @@ test_expect_success "test remove_duplicates" '
        test a:b:c = "$(test-string-list remove_duplicates a:a:a:b:b:b:c:c:c)"
 '
 
-test_expect_success "test longest_prefix" '
-       test_no_longest_prefix - '' &&
-       test_no_longest_prefix - x &&
-       test_longest_prefix "" x "" &&
-       test_longest_prefix x x x &&
-       test_longest_prefix "" foo "" &&
-       test_longest_prefix : foo "" &&
-       test_longest_prefix f foo f &&
-       test_longest_prefix foo foobar foo &&
-       test_longest_prefix foo foo foo &&
-       test_no_longest_prefix bar foo &&
-       test_no_longest_prefix bar:bar foo &&
-       test_no_longest_prefix foobar foo &&
-       test_longest_prefix foo:bar foo foo &&
-       test_longest_prefix foo:bar bar bar &&
-       test_longest_prefix foo::bar foo foo &&
-       test_longest_prefix foo:foobar foo foo &&
-       test_longest_prefix foobar:foo foo foo &&
-       test_longest_prefix foo: bar "" &&
-       test_longest_prefix :foo bar ""
-'
-
 test_done
index e23ac0e69da8d3dba32f0d256a249a987356e825..1e2945ec7e397cf6b2e3b00bee0ca1df40a0e6a9 100755 (executable)
@@ -111,19 +111,19 @@ test_expect_success 'read-tree' '
 
 test_expect_success 'alias expansion' '
        (
-               git config alias.ss status &&
+               git config alias.test-status-alias status &&
                cd dir &&
                git status &&
-               git ss
+               git test-status-alias
        )
 '
 
 test_expect_success NOT_MINGW '!alias expansion' '
        pwd >expect &&
        (
-               git config alias.test !pwd &&
+               git config alias.test-alias-directory !pwd &&
                cd dir &&
-               git test >../actual
+               git test-alias-directory >../actual
        ) &&
        test_cmp expect actual
 '
@@ -131,9 +131,9 @@ test_expect_success NOT_MINGW '!alias expansion' '
 test_expect_success 'GIT_PREFIX for !alias' '
        printf "dir/" >expect &&
        (
-               git config alias.test "!sh -c \"printf \$GIT_PREFIX\"" &&
+               git config alias.test-alias-directory "!sh -c \"printf \$GIT_PREFIX\"" &&
                cd dir &&
-               git test >../actual
+               git test-alias-directory >../actual
        ) &&
        test_cmp expect actual
 '
index 1ae4d87c929ec55a66d44bb23aecea8a2aea4346..1a5a5f39fd94f9eb98824b3d84983782b9ff71bb 100755 (executable)
@@ -11,7 +11,8 @@ valid_ref() {
                prereq=$1
                shift
        esac
-       test_expect_success $prereq "ref name '$1' is valid${2:+ with options $2}" "
+       desc="ref name '$1' is valid${2:+ with options $2}"
+       test_expect_success $prereq "$desc" "
                git check-ref-format $2 '$1'
        "
 }
@@ -22,7 +23,8 @@ invalid_ref() {
                prereq=$1
                shift
        esac
-       test_expect_success $prereq "ref name '$1' is invalid${2:+ with options $2}" "
+       desc="ref name '$1' is invalid${2:+ with options $2}"
+       test_expect_success $prereq "$desc" "
                test_must_fail git check-ref-format $2 '$1'
        "
 }
index 08aa24ca15a377826b9e1cdad73fb232853aea7f..d730734fde8e4de69fdf2662915bc67342198fc8 100755 (executable)
@@ -237,4 +237,35 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
        )
 '
 
+test_expect_success 'fsck notices "." and ".." in trees' '
+       (
+               git init dots &&
+               cd dots &&
+               blob=$(echo foo | git hash-object -w --stdin) &&
+               tab=$(printf "\\t") &&
+               git mktree <<-EOF &&
+               100644 blob $blob$tab.
+               100644 blob $blob$tab..
+               EOF
+               git fsck 2>out &&
+               cat out &&
+               grep "warning.*\\." out
+       )
+'
+
+test_expect_success 'fsck notices ".git" in trees' '
+       (
+               git init dotgit &&
+               cd dotgit &&
+               blob=$(echo foo | git hash-object -w --stdin) &&
+               tab=$(printf "\\t") &&
+               git mktree <<-EOF &&
+               100644 blob $blob$tab.git
+               EOF
+               git fsck 2>out &&
+               cat out &&
+               grep "warning.*\\.git" out
+       )
+'
+
 test_done
index d709ecf8df136539a746ef1873821baee6fab428..4969edb31441c81cf2e63385d07d780a52faa53b 100755 (executable)
@@ -32,32 +32,24 @@ test_expect_success 'setup' '
 #
 # and 'side' should be the last branch
 
-test_rev_equivalent () {
-
-       git rev-parse "$1" > expect &&
-       git rev-parse "$2" > output &&
-       test_cmp expect output
-
-}
-
 test_expect_success '@{-1} works' '
-       test_rev_equivalent side @{-1}
+       test_cmp_rev side @{-1}
 '
 
 test_expect_success '@{-1}~2 works' '
-       test_rev_equivalent side~2 @{-1}~2
+       test_cmp_rev side~2 @{-1}~2
 '
 
 test_expect_success '@{-1}^2 works' '
-       test_rev_equivalent side^2 @{-1}^2
+       test_cmp_rev side^2 @{-1}^2
 '
 
 test_expect_success '@{-1}@{1} works' '
-       test_rev_equivalent side@{1} @{-1}@{1}
+       test_cmp_rev side@{1} @{-1}@{1}
 '
 
 test_expect_success '@{-2} works' '
-       test_rev_equivalent master @{-2}
+       test_cmp_rev master @{-2}
 '
 
 test_expect_success '@{-3} fails' '
index 70edbb33e26c0ee6d5cec81d2417c8a830d6fab1..06b18f8bc1e2991170736254bf3c558ab4673d13 100755 (executable)
@@ -23,7 +23,7 @@ test_expect_success '"reset <submodule>" updates the index' '
        git update-index --refresh &&
        git diff-files --quiet &&
        git diff-index --quiet --cached HEAD &&
-       test_must_fail git reset HEAD^ submodule &&
+       git reset HEAD^ submodule &&
        test_must_fail git diff-files --quiet &&
        git reset submodule &&
        git diff-files --quiet
index ec35409f9cbe9bcdd3d21a6a5a15996b165d2fff..2a4a749b4fa3b07963a18b645d29ef774c01bbd1 100755 (executable)
@@ -62,5 +62,25 @@ test_expect_success 'can "commit -a" with an i-t-a entry' '
        git commit -a -m all
 '
 
+test_expect_success 'cache-tree invalidates i-t-a paths' '
+       git reset --hard &&
+       mkdir dir &&
+       : >dir/foo &&
+       git add dir/foo &&
+       git commit -m foo &&
+
+       : >dir/bar &&
+       git add -N dir/bar &&
+       git diff --cached --name-only >actual &&
+       echo dir/bar >expect &&
+       test_cmp expect actual &&
+
+       git write-tree >/dev/null &&
+
+       git diff --cached --name-only >actual &&
+       echo dir/bar >expect &&
+       test_cmp expect actual
+'
+
 test_done
 
index dc2f0458fd0e74a3dcb4769517f5cde2606eb6f2..efb7ebc91f2f46b38e0c02f4dd11e2224678baea 100755 (executable)
@@ -220,4 +220,22 @@ test_expect_success 'pattern matches prefix completely' '
        test_cmp expect actual
 '
 
+test_expect_success 'ls-files with "**" patterns' '
+       cat <<\EOF >expect &&
+a.1
+one/a.1
+one/two/a.1
+three/a.1
+EOF
+       git ls-files -o -i --exclude "**/a.1" >actual
+       test_cmp expect actual
+'
+
+
+test_expect_success 'ls-files with "**" patterns and no slashes' '
+       : >expect &&
+       git ls-files -o -i --exclude "one**a.1" >actual &&
+       test_cmp expect actual
+'
+
 test_done
diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh
new file mode 100755 (executable)
index 0000000..af54c83
--- /dev/null
@@ -0,0 +1,195 @@
+#!/bin/sh
+
+test_description='wildmatch tests'
+
+. ./test-lib.sh
+
+match() {
+    if [ $1 = 1 ]; then
+       test_expect_success "wildmatch:    match '$3' '$4'" "
+           test-wildmatch wildmatch '$3' '$4'
+       "
+    else
+       test_expect_success "wildmatch: no match '$3' '$4'" "
+           ! test-wildmatch wildmatch '$3' '$4'
+       "
+    fi
+    if [ $2 = 1 ]; then
+       test_expect_success "fnmatch:      match '$3' '$4'" "
+           test-wildmatch fnmatch '$3' '$4'
+       "
+    elif [ $2 = 0 ]; then
+       test_expect_success "fnmatch:   no match '$3' '$4'" "
+           ! test-wildmatch fnmatch '$3' '$4'
+       "
+#    else
+#      test_expect_success BROKEN_FNMATCH "fnmatch:       '$3' '$4'" "
+#          ! test-wildmatch fnmatch '$3' '$4'
+#      "
+    fi
+}
+
+# Basic wildmat features
+match 1 1 foo foo
+match 0 0 foo bar
+match 1 1 '' ""
+match 1 1 foo '???'
+match 0 0 foo '??'
+match 1 1 foo '*'
+match 1 1 foo 'f*'
+match 0 0 foo '*f'
+match 1 1 foo '*foo*'
+match 1 1 foobar '*ob*a*r*'
+match 1 1 aaaaaaabababab '*ab'
+match 1 1 'foo*' 'foo\*'
+match 0 0 foobar 'foo\*bar'
+match 1 1 'f\oo' 'f\\oo'
+match 1 1 ball '*[al]?'
+match 0 0 ten '[ten]'
+match 0 1 ten '**[!te]'
+match 0 0 ten '**[!ten]'
+match 1 1 ten 't[a-g]n'
+match 0 0 ten 't[!a-g]n'
+match 1 1 ton 't[!a-g]n'
+match 1 1 ton 't[^a-g]n'
+match 1 x 'a]b' 'a[]]b'
+match 1 x a-b 'a[]-]b'
+match 1 x 'a]b' 'a[]-]b'
+match 0 x aab 'a[]-]b'
+match 1 x aab 'a[]a-]b'
+match 1 1 ']' ']'
+
+# Extended slash-matching features
+match 0 0 'foo/baz/bar' 'foo*bar'
+match 0 0 'foo/baz/bar' 'foo**bar'
+match 0 1 'foobazbar' 'foo**bar'
+match 1 1 'foo/baz/bar' 'foo/**/bar'
+match 1 0 'foo/baz/bar' 'foo/**/**/bar'
+match 1 0 'foo/b/a/z/bar' 'foo/**/bar'
+match 1 0 'foo/b/a/z/bar' 'foo/**/**/bar'
+match 1 0 'foo/bar' 'foo/**/bar'
+match 1 0 'foo/bar' 'foo/**/**/bar'
+match 0 0 'foo/bar' 'foo?bar'
+match 0 0 'foo/bar' 'foo[/]bar'
+match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
+match 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
+match 1 0 'foo' '**/foo'
+match 1 x 'XXX/foo' '**/foo'
+match 1 0 'bar/baz/foo' '**/foo'
+match 0 0 'bar/baz/foo' '*/foo'
+match 0 0 'foo/bar/baz' '**/bar*'
+match 1 0 'deep/foo/bar/baz' '**/bar/*'
+match 0 0 'deep/foo/bar/baz/' '**/bar/*'
+match 1 0 'deep/foo/bar/baz/' '**/bar/**'
+match 0 0 'deep/foo/bar' '**/bar/*'
+match 1 0 'deep/foo/bar/' '**/bar/**'
+match 0 0 'foo/bar/baz' '**/bar**'
+match 1 0 'foo/bar/baz/x' '*/bar/**'
+match 0 0 'deep/foo/bar/baz/x' '*/bar/**'
+match 1 0 'deep/foo/bar/baz/x' '**/bar/*/*'
+
+# Various additional tests
+match 0 0 'acrt' 'a[c-c]st'
+match 1 1 'acrt' 'a[c-c]rt'
+match 0 0 ']' '[!]-]'
+match 1 x 'a' '[!]-]'
+match 0 0 '' '\'
+match 0 x '\' '\'
+match 0 x 'XXX/\' '*/\'
+match 1 x 'XXX/\' '*/\\'
+match 1 1 'foo' 'foo'
+match 1 1 '@foo' '@foo'
+match 0 0 'foo' '@foo'
+match 1 1 '[ab]' '\[ab]'
+match 1 1 '[ab]' '[[]ab]'
+match 1 x '[ab]' '[[:]ab]'
+match 0 x '[ab]' '[[::]ab]'
+match 1 x '[ab]' '[[:digit]ab]'
+match 1 x '[ab]' '[\[:]ab]'
+match 1 1 '?a?b' '\??\?b'
+match 1 1 'abc' '\a\b\c'
+match 0 0 'foo' ''
+match 1 0 'foo/bar/baz/to' '**/t[o]'
+
+# Character class tests
+match 1 x 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'
+match 0 x 'a' '[[:digit:][:upper:][:space:]]'
+match 1 x 'A' '[[:digit:][:upper:][:space:]]'
+match 1 x '1' '[[:digit:][:upper:][:space:]]'
+match 0 x '1' '[[:digit:][:upper:][:spaci:]]'
+match 1 x ' ' '[[:digit:][:upper:][:space:]]'
+match 0 x '.' '[[:digit:][:upper:][:space:]]'
+match 1 x '.' '[[:digit:][:punct:][:space:]]'
+match 1 x '5' '[[:xdigit:]]'
+match 1 x 'f' '[[:xdigit:]]'
+match 1 x 'D' '[[:xdigit:]]'
+match 1 x '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'
+match 1 x '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'
+match 1 x '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'
+match 1 x '5' '[a-c[:digit:]x-z]'
+match 1 x 'b' '[a-c[:digit:]x-z]'
+match 1 x 'y' '[a-c[:digit:]x-z]'
+match 0 x 'q' '[a-c[:digit:]x-z]'
+
+# Additional tests, including some malformed wildmats
+match 1 x ']' '[\\-^]'
+match 0 0 '[' '[\\-^]'
+match 1 x '-' '[\-_]'
+match 1 x ']' '[\]]'
+match 0 0 '\]' '[\]]'
+match 0 0 '\' '[\]]'
+match 0 0 'ab' 'a[]b'
+match 0 x 'a[]b' 'a[]b'
+match 0 x 'ab[' 'ab['
+match 0 0 'ab' '[!'
+match 0 0 'ab' '[-'
+match 1 1 '-' '[-]'
+match 0 0 '-' '[a-'
+match 0 0 '-' '[!a-'
+match 1 x '-' '[--A]'
+match 1 x '5' '[--A]'
+match 1 1 ' ' '[ --]'
+match 1 1 '$' '[ --]'
+match 1 1 '-' '[ --]'
+match 0 0 '0' '[ --]'
+match 1 x '-' '[---]'
+match 1 x '-' '[------]'
+match 0 0 'j' '[a-e-n]'
+match 1 x '-' '[a-e-n]'
+match 1 x 'a' '[!------]'
+match 0 0 '[' '[]-a]'
+match 1 x '^' '[]-a]'
+match 0 0 '^' '[!]-a]'
+match 1 x '[' '[!]-a]'
+match 1 1 '^' '[a^bc]'
+match 1 x '-b]' '[a-]b]'
+match 0 0 '\' '[\]'
+match 1 1 '\' '[\\]'
+match 0 0 '\' '[!\\]'
+match 1 1 'G' '[A-\\]'
+match 0 0 'aaabbb' 'b*a'
+match 0 0 'aabcaa' '*ba*'
+match 1 1 ',' '[,]'
+match 1 1 ',' '[\\,]'
+match 1 1 '\' '[\\,]'
+match 1 1 '-' '[,-.]'
+match 0 0 '+' '[,-.]'
+match 0 0 '-.]' '[,-.]'
+match 1 1 '2' '[\1-\3]'
+match 1 1 '3' '[\1-\3]'
+match 0 0 '4' '[\1-\3]'
+match 1 1 '\' '[[-\]]'
+match 1 1 '[' '[[-\]]'
+match 1 1 ']' '[[-\]]'
+match 0 0 '-' '[[-\]]'
+
+# Test recursion and the abort code (use "wildtest -i" to see iteration counts)
+match 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
+match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
+match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
+match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
+match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
+match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'
+match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'
+
+test_done
index 32fdc9938e1dc29d9a1c6c1dd54379ee33644561..8462be1db6a0fe4f9e28cd1662be604196141055 100755 (executable)
@@ -29,12 +29,6 @@ Initial setup:
 
 . "$TEST_DIRECTORY"/lib-rebase.sh
 
-test_cmp_rev () {
-       git rev-parse --verify "$1" >expect.rev &&
-       git rev-parse --verify "$2" >actual.rev &&
-       test_cmp expect.rev actual.rev
-}
-
 set_fake_editor
 
 # WARNING: Modifications to the initial repository can change the SHA ID used
index 34c86e5de69468fe7618383e556d1711cc49b0bb..6f489e20eecb48c6e1a2dc2b1fe90e47e7b3e7ad 100755 (executable)
@@ -100,4 +100,13 @@ test_expect_success 'revert forbidden on dirty working tree' '
 
 '
 
+test_expect_success 'chery-pick on unborn branch' '
+       git checkout --orphan unborn &&
+       git rm --cached -r . &&
+       rm -rf * &&
+       git cherry-pick initial &&
+       git diff --quiet initial &&
+       ! test_cmp_rev initial HEAD
+'
+
 test_done
index 51ca391e472441d2d503e721795d609bfaad1100..373aad623c8f02f6f9753eb38c6393a69c027001 100755 (executable)
@@ -105,4 +105,12 @@ test_expect_success 'cherry pick a root commit with --ff' '
        test "$(git rev-parse --verify HEAD)" = "1df192cd8bc58a2b275d842cede4d221ad9000d1"
 '
 
+test_expect_success 'chery-pick --ff on unborn branch' '
+       git checkout --orphan unborn &&
+       git rm --cached -r . &&
+       rm -rf * &&
+       git cherry-pick --ff first &&
+       test_cmp_rev first HEAD
+'
+
 test_done
index c82f7210c4ca10e35d9d2000aa8da2d10194a6c6..223b98433c502b03c4ba70550cb32d42a5f6295b 100755 (executable)
@@ -11,12 +11,6 @@ test_description='test cherry-pick and revert with conflicts
 
 . ./test-lib.sh
 
-test_cmp_rev () {
-       git rev-parse --verify "$1" >expect.rev &&
-       git rev-parse --verify "$2" >actual.rev &&
-       test_cmp expect.rev actual.rev
-}
-
 pristine_detach () {
        git checkout -f "$1^0" &&
        git read-tree -u --reset HEAD &&
index 340afc760de030879fff496dca3db8432a6b992b..4e7136b83775946a07678119c7c9897bb0f2b709 100755 (executable)
@@ -5,15 +5,11 @@ test_description='test cherry-picking many commits'
 . ./test-lib.sh
 
 check_head_differs_from() {
-       head=$(git rev-parse --verify HEAD) &&
-       arg=$(git rev-parse --verify "$1") &&
-       test "$head" != "$arg"
+       ! test_cmp_rev HEAD "$1"
 }
 
 check_head_equals() {
-       head=$(git rev-parse --verify HEAD) &&
-       arg=$(git rev-parse --verify "$1") &&
-       test "$head" = "$arg"
+       test_cmp_rev HEAD "$1"
 }
 
 test_expect_success setup '
index b5fb527b2e686d158a6e7d53d6246b9e66f80a7b..7b7a89dbd5ce578e0a722345a00f247e383689ef 100755 (executable)
@@ -24,12 +24,6 @@ pristine_detach () {
        git clean -d -f -f -q -x
 }
 
-test_cmp_rev () {
-       git rev-parse --verify "$1" >expect.rev &&
-       git rev-parse --verify "$2" >actual.rev &&
-       test_cmp expect.rev actual.rev
-}
-
 test_expect_success setup '
        git config advice.detachedhead false &&
        echo unrelated >unrelated &&
index 06f63848eab384ae33eacd1fb46d5dc048143721..37bf5f13b07a632cb8e96e865a75b51f1b7844aa 100755 (executable)
@@ -474,7 +474,7 @@ test_expect_success 'rm of a conflicted populated submodule with a .git director
        git submodule update &&
        (cd submod &&
                rm .git &&
-               cp -a ../.git/modules/sub .git &&
+               cp -R ../.git/modules/sub .git &&
                GIT_WORK_TREE=. git config --unset core.worktree
        ) &&
        test_must_fail git merge conflict2 &&
@@ -508,7 +508,7 @@ test_expect_success 'rm of a populated submodule with a .git directory fails eve
        git submodule update &&
        (cd submod &&
                rm .git &&
-               cp -a ../.git/modules/sub .git &&
+               cp -R ../.git/modules/sub .git &&
                GIT_WORK_TREE=. git config --unset core.worktree
        ) &&
        test_must_fail git rm submod &&
@@ -606,7 +606,7 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
        git submodule update --recursive &&
        (cd submod/subsubmod &&
                rm .git &&
-               cp -a ../../.git/modules/sub/modules/sub .git &&
+               cp -R ../../.git/modules/sub/modules/sub .git &&
                GIT_WORK_TREE=. git config --unset core.worktree
        ) &&
        test_must_fail git rm submod &&
index 16a4ca1d6061122cf7ed3abd68390e27794f79b0..7fa3647514b616b1a40b233b23123a00c4d3ff6c 100755 (executable)
@@ -155,7 +155,7 @@ test_expect_failure 'additional command line cc (rfc822)' '
        git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&
        git format-patch --cc="S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
        grep "^Cc: R E Cipient <rcipient@example.com>,\$" patch5 &&
-       grep "^ *"S. E. Cipient" <scipient@example.com>\$" patch5
+       grep "^ *\"S. E. Cipient\" <scipient@example.com>\$" patch5
 '
 
 test_expect_success 'command line headers' '
@@ -183,7 +183,7 @@ test_expect_success 'command line To: header (ascii)' '
 test_expect_failure 'command line To: header (rfc822)' '
 
        git format-patch --to="R. E. Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-       grep "^To: "R. E. Cipient" <rcipient@example.com>\$" patch8
+       grep "^To: \"R. E. Cipient\" <rcipient@example.com>\$" patch8
 '
 
 test_expect_failure 'command line To: header (rfc2047)' '
@@ -203,7 +203,7 @@ test_expect_failure 'configuration To: header (rfc822)' '
 
        git config format.to "R. E. Cipient <rcipient@example.com>" &&
        git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-       grep "^To: "R. E. Cipient" <rcipient@example.com>\$" patch9
+       grep "^To: \"R. E. Cipient\" <rcipient@example.com>\$" patch9
 '
 
 test_expect_failure 'configuration To: header (rfc2047)' '
@@ -271,6 +271,22 @@ test_expect_success 'multiple files' '
        ls patches/0001-Side-changes-1.patch patches/0002-Side-changes-2.patch patches/0003-Side-changes-3-with-n-backslash-n-in-it.patch
 '
 
+test_expect_success 'reroll count' '
+       rm -fr patches &&
+       git format-patch -o patches --cover-letter --reroll-count 4 master..side >list &&
+       ! grep -v "^patches/v4-000[0-3]-" list &&
+       sed -n -e "/^Subject: /p" $(cat list) >subjects &&
+       ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects
+'
+
+test_expect_success 'reroll count (-v)' '
+       rm -fr patches &&
+       git format-patch -o patches --cover-letter -v4 master..side >list &&
+       ! grep -v "^patches/v4-000[0-3]-" list &&
+       sed -n -e "/^Subject: /p" $(cat list) >subjects &&
+       ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects
+'
+
 check_threading () {
        expect="$1" &&
        shift &&
@@ -963,4 +979,46 @@ test_expect_success 'format patch ignores color.ui' '
        test_cmp expect actual
 '
 
+test_expect_success 'cover letter using branch description (1)' '
+       git checkout rebuild-1 &&
+       test_config branch.rebuild-1.description hello &&
+       git format-patch --stdout --cover-letter master >actual &&
+       grep hello actual >/dev/null
+'
+
+test_expect_success 'cover letter using branch description (2)' '
+       git checkout rebuild-1 &&
+       test_config branch.rebuild-1.description hello &&
+       git format-patch --stdout --cover-letter rebuild-1~2..rebuild-1 >actual &&
+       grep hello actual >/dev/null
+'
+
+test_expect_success 'cover letter using branch description (3)' '
+       git checkout rebuild-1 &&
+       test_config branch.rebuild-1.description hello &&
+       git format-patch --stdout --cover-letter ^master rebuild-1 >actual &&
+       grep hello actual >/dev/null
+'
+
+test_expect_success 'cover letter using branch description (4)' '
+       git checkout rebuild-1 &&
+       test_config branch.rebuild-1.description hello &&
+       git format-patch --stdout --cover-letter master.. >actual &&
+       grep hello actual >/dev/null
+'
+
+test_expect_success 'cover letter using branch description (5)' '
+       git checkout rebuild-1 &&
+       test_config branch.rebuild-1.description hello &&
+       git format-patch --stdout --cover-letter -2 HEAD >actual &&
+       grep hello actual >/dev/null
+'
+
+test_expect_success 'cover letter using branch description (6)' '
+       git checkout rebuild-1 &&
+       test_config branch.rebuild-1.description hello &&
+       git format-patch --stdout --cover-letter -2 >actual &&
+       grep hello actual >/dev/null
+'
+
 test_done
index 6872ba1a42ce289c0983b1ed62f05defb493bf49..5493500ef15d2f561bd14ca0bdf5f519ec6f49be 100755 (executable)
@@ -120,6 +120,30 @@ test_expect_success 'shortlog from non-git directory' '
        test_cmp expect out
 '
 
+test_expect_success 'shortlog should add newline when input line matches wraplen' '
+       cat >expect <<\EOF &&
+A U Thor (2):
+      bbbbbbbbbbbbbbbbbb: bbbbbbbb bbb bbbb bbbbbbb bb bbbb bbb bbbbb bbbbbb
+      aaaaaaaaaaaaaaaaaaaaaa: aaaaaa aaaaaaaaaa aaaa aaaaaaaa aa aaaa aa aaa
+
+EOF
+       git shortlog -w >out <<\EOF &&
+commit 0000000000000000000000000000000000000001
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:14:13 2005 -0700
+
+    aaaaaaaaaaaaaaaaaaaaaa: aaaaaa aaaaaaaaaa aaaa aaaaaaaa aa aaaa aa aaa
+
+commit 0000000000000000000000000000000000000002
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:14:13 2005 -0700
+
+    bbbbbbbbbbbbbbbbbb: bbbbbbbb bbb bbbb bbbbbbb bb bbbb bbb bbbbb bbbbbb
+
+EOF
+       test_cmp expect out
+'
+
 iconvfromutf8toiso88591() {
        printf "%s" "$*" | iconv -f UTF-8 -t ISO8859-1
 }
index a343bf6c629f8e6acaf7559d3168a97fcce9d286..fa686b887d6b49ab8e6d30893501744645f72a91 100755 (executable)
@@ -280,6 +280,16 @@ test_expect_success 'log --graph with merge' '
        test_cmp expect actual
 '
 
+test_expect_success 'log --raw --graph -m with merge' '
+       git log --raw --graph --oneline -m master | head -n 500 >actual &&
+       grep "initial" actual
+'
+
+test_expect_success 'diff-tree --graph' '
+       git diff-tree --graph master^ | head -n 500 >actual &&
+       grep "one" actual
+'
+
 cat > expect <<\EOF
 *   commit master
 |\  Merge: A B
index 1f182f612c7e2376b503cf0b9cf7389e37903239..842b7549ec3ed6b1fa268a96d085048d2f0b7793 100755 (executable)
@@ -149,6 +149,104 @@ test_expect_success 'No mailmap files, but configured' '
        test_cmp expect actual
 '
 
+test_expect_success 'setup mailmap blob tests' '
+       git checkout -b map &&
+       test_when_finished "git checkout master" &&
+       cat >just-bugs <<-\EOF &&
+       Blob Guy <bugs@company.xx>
+       EOF
+       cat >both <<-\EOF &&
+       Blob Guy <author@example.com>
+       Blob Guy <bugs@company.xx>
+       EOF
+       git add just-bugs both &&
+       git commit -m "my mailmaps" &&
+       echo "Repo Guy <author@example.com>" >.mailmap &&
+       echo "Internal Guy <author@example.com>" >internal.map
+'
+
+test_expect_success 'mailmap.blob set' '
+       cat >expect <<-\EOF &&
+       Blob Guy (1):
+             second
+
+       Repo Guy (1):
+             initial
+
+       EOF
+       git -c mailmap.blob=map:just-bugs shortlog HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'mailmap.blob overrides .mailmap' '
+       cat >expect <<-\EOF &&
+       Blob Guy (2):
+             initial
+             second
+
+       EOF
+       git -c mailmap.blob=map:both shortlog HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'mailmap.file overrides mailmap.blob' '
+       cat >expect <<-\EOF &&
+       Blob Guy (1):
+             second
+
+       Internal Guy (1):
+             initial
+
+       EOF
+       git \
+         -c mailmap.blob=map:both \
+         -c mailmap.file=internal.map \
+         shortlog HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'mailmap.blob can be missing' '
+       cat >expect <<-\EOF &&
+       Repo Guy (1):
+             initial
+
+       nick1 (1):
+             second
+
+       EOF
+       git -c mailmap.blob=map:nonexistent shortlog HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'mailmap.blob defaults to off in non-bare repo' '
+       git init non-bare &&
+       (
+               cd non-bare &&
+               test_commit one .mailmap "Fake Name <author@example.com>" &&
+               echo "     1    Fake Name" >expect &&
+               git shortlog -ns HEAD >actual &&
+               test_cmp expect actual &&
+               rm .mailmap &&
+               echo "     1    A U Thor" >expect &&
+               git shortlog -ns HEAD >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'mailmap.blob defaults to HEAD:.mailmap in bare repo' '
+       git clone --bare non-bare bare &&
+       (
+               cd bare &&
+               echo "     1    Fake Name" >expect &&
+               git shortlog -ns HEAD >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'cleanup after mailmap.blob tests' '
+       rm -f .mailmap
+'
+
 # Extended mailmap configurations should give us the following output for shortlog
 cat >expect <<\EOF
 A U Thor <author@example.com> (1):
@@ -239,6 +337,62 @@ test_expect_success 'Log output (complex mapping)' '
        test_cmp expect actual
 '
 
+cat >expect <<\EOF
+Author: CTO <cto@company.xx>
+Author: Santa Claus <santa.claus@northpole.xx>
+Author: Santa Claus <santa.claus@northpole.xx>
+Author: Other Author <other@author.xx>
+Author: Other Author <other@author.xx>
+Author: Some Dude <some@dude.xx>
+Author: A U Thor <author@example.com>
+EOF
+
+test_expect_success 'Log output with --use-mailmap' '
+       git log --use-mailmap | grep Author >actual &&
+       test_cmp expect actual
+'
+
+cat >expect <<\EOF
+Author: CTO <cto@company.xx>
+Author: Santa Claus <santa.claus@northpole.xx>
+Author: Santa Claus <santa.claus@northpole.xx>
+Author: Other Author <other@author.xx>
+Author: Other Author <other@author.xx>
+Author: Some Dude <some@dude.xx>
+Author: A U Thor <author@example.com>
+EOF
+
+test_expect_success 'Log output with log.mailmap' '
+       git -c log.mailmap=True log | grep Author >actual &&
+       test_cmp expect actual
+'
+
+cat >expect <<\EOF
+Author: Santa Claus <santa.claus@northpole.xx>
+Author: Santa Claus <santa.claus@northpole.xx>
+EOF
+
+test_expect_success 'Grep author with --use-mailmap' '
+       git log --use-mailmap --author Santa | grep Author >actual &&
+       test_cmp expect actual
+'
+cat >expect <<\EOF
+Author: Santa Claus <santa.claus@northpole.xx>
+Author: Santa Claus <santa.claus@northpole.xx>
+EOF
+
+test_expect_success 'Grep author with log.mailmap' '
+       git -c log.mailmap=True log --author Santa | grep Author >actual &&
+       test_cmp expect actual
+'
+
+>expect
+
+test_expect_success 'Only grep replaced author with --use-mailmap' '
+       git log --use-mailmap --author "<cto@coompany.xx>" >actual &&
+       test_cmp expect actual
+'
+
 # git blame
 cat >expect <<\EOF
 ^OBJI (A U Thor     DATE 1) one
index 46c3fe76d3867be394c6b9089a4aa9a1f3f6bba0..d0b2a457b8bf30fc7ab472ff6b2576ff319432f7 100755 (executable)
@@ -254,4 +254,48 @@ EXPECTED
        test_cmp expected actual
 '
 
+test_expect_success 'turn file to tree' '
+       git reset --hard initial &&
+       rm initial-file &&
+       mkdir initial-file &&
+       test_commit "turn-file-to-tree" "initial-file/ONE" "CCC" &&
+       git merge-tree initial initial turn-file-to-tree >actual &&
+       cat >expect <<-\EOF &&
+       added in remote
+         their  100644 43aa4fdec31eb92e1fdc2f0ce6ea9ddb7c32bcf7 initial-file/ONE
+       @@ -0,0 +1 @@
+       +CCC
+       removed in remote
+         base   100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
+         our    100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
+       @@ -1 +0,0 @@
+       -initial
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'turn tree to file' '
+       git reset --hard initial &&
+       mkdir dir &&
+       test_commit "add-tree" "dir/path" "AAA" &&
+       test_commit "add-another-tree" "dir/another" "BBB" &&
+       rm -fr dir &&
+       test_commit "make-file" "dir" "CCC" &&
+       git merge-tree add-tree add-another-tree make-file >actual &&
+       cat >expect <<-\EOF &&
+       added in local
+         our    100644 ba629238ca89489f2b350e196ca445e09d8bb834 dir/another
+       removed in remote
+         base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d dir/path
+         our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d dir/path
+       @@ -1 +0,0 @@
+       -AAA
+       added in remote
+         their  100644 43aa4fdec31eb92e1fdc2f0ce6ea9ddb7c32bcf7 dir
+       @@ -0,0 +1 @@
+       +CCC
+       EOF
+       test_cmp expect actual
+'
+
 test_done
index ecf00edab2079099e201237c1936cf715148a684..e7c240fc1f8333c933f22bc1af6bf57eb9ae27cb 100755 (executable)
@@ -25,32 +25,11 @@ commit id embedding:
 '
 
 . ./test-lib.sh
-UNZIP=${UNZIP:-unzip}
 GZIP=${GZIP:-gzip}
 GUNZIP=${GUNZIP:-gzip -d}
 
 SUBSTFORMAT=%H%n
 
-check_zip() {
-       zipfile=$1.zip
-       listfile=$1.lst
-       dir=$1
-       dir_with_prefix=$dir/$2
-
-       test_expect_success UNZIP " extract ZIP archive" "
-               (mkdir $dir && cd $dir && $UNZIP ../$zipfile)
-       "
-
-       test_expect_success UNZIP " validate filenames" "
-               (cd ${dir_with_prefix}a && find .) | sort >$listfile &&
-               test_cmp a.lst $listfile
-       "
-
-       test_expect_success UNZIP " validate file contents" "
-               diff -r a ${dir_with_prefix}a
-       "
-}
-
 test_expect_success \
     'populate workdir' \
     'mkdir a b c &&
@@ -201,61 +180,11 @@ test_expect_success \
       test_cmp a/substfile2 g/prefix/a/substfile2
 '
 
-$UNZIP -v >/dev/null 2>&1
-if [ $? -eq 127 ]; then
-       say "Skipping ZIP tests, because unzip was not found"
-else
-       test_set_prereq UNZIP
-fi
-
-test_expect_success \
-    'git archive --format=zip' \
-    'git archive --format=zip HEAD >d.zip'
-
-check_zip d
-
-test_expect_success \
-    'git archive --format=zip in a bare repo' \
-    '(cd bare.git && git archive --format=zip HEAD) >d1.zip'
-
-test_expect_success \
-    'git archive --format=zip vs. the same in a bare repo' \
-    'test_cmp d.zip d1.zip'
-
-test_expect_success 'git archive --format=zip with --output' \
-    'git archive --format=zip --output=d2.zip HEAD &&
-    test_cmp d.zip d2.zip'
-
-test_expect_success 'git archive with --output, inferring format' '
-       git archive --output=d3.zip HEAD &&
-       test_cmp d.zip d3.zip
-'
-
 test_expect_success 'git archive with --output, override inferred format' '
        git archive --format=tar --output=d4.zip HEAD &&
        test_cmp b.tar d4.zip
 '
 
-test_expect_success \
-    'git archive --format=zip with prefix' \
-    'git archive --format=zip --prefix=prefix/ HEAD >e.zip'
-
-check_zip e prefix/
-
-test_expect_success 'git archive -0 --format=zip on large files' '
-       test_config core.bigfilethreshold 1 &&
-       git archive -0 --format=zip HEAD >large.zip
-'
-
-check_zip large
-
-test_expect_success 'git archive --format=zip on large files' '
-       test_config core.bigfilethreshold 1 &&
-       git archive --format=zip HEAD >large-compressed.zip
-'
-
-check_zip large-compressed
-
 test_expect_success \
     'git archive --list outside of a git repo' \
     'GIT_DIR=some/non-existing/directory git archive --list'
diff --git a/t/t5002-archive-attr-pattern.sh b/t/t5002-archive-attr-pattern.sh
new file mode 100755 (executable)
index 0000000..0c847fb
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+test_description='git archive attribute pattern tests'
+
+. ./test-lib.sh
+
+test_expect_exists() {
+       test_expect_success " $1 exists" "test -e $1"
+}
+
+test_expect_missing() {
+       test_expect_success " $1 does not exist" "test ! -e $1"
+}
+
+test_expect_success 'setup' '
+       echo ignored >ignored &&
+       echo ignored export-ignore >>.git/info/attributes &&
+       git add ignored &&
+
+       mkdir not-ignored-dir &&
+       echo ignored-in-tree >not-ignored-dir/ignored &&
+       echo not-ignored-in-tree >not-ignored-dir/ignored-only-if-dir &&
+       git add not-ignored-dir &&
+
+       mkdir ignored-only-if-dir &&
+       echo ignored by ignored dir >ignored-only-if-dir/ignored-by-ignored-dir &&
+       echo ignored-only-if-dir/ export-ignore >>.git/info/attributes &&
+       git add ignored-only-if-dir &&
+
+
+       mkdir -p one-level-lower/two-levels-lower/ignored-only-if-dir &&
+       echo ignored by ignored dir >one-level-lower/two-levels-lower/ignored-only-if-dir/ignored-by-ignored-dir &&
+       git add one-level-lower &&
+
+       git commit -m. &&
+
+       git clone --bare . bare &&
+       cp .git/info/attributes bare/info/attributes
+'
+
+test_expect_success 'git archive' '
+       git archive HEAD >archive.tar &&
+       (mkdir archive && cd archive && "$TAR" xf -) <archive.tar
+'
+
+test_expect_missing    archive/ignored
+test_expect_missing    archive/not-ignored-dir/ignored
+test_expect_exists     archive/not-ignored-dir/ignored-only-if-dir
+test_expect_exists     archive/not-ignored-dir/
+test_expect_missing    archive/ignored-only-if-dir/
+test_expect_missing    archive/ignored-ony-if-dir/ignored-by-ignored-dir
+test_expect_exists     archive/one-level-lower/
+test_expect_missing    archive/one-level-lower/two-levels-lower/ignored-only-if-dir/
+test_expect_missing    archive/one-level-lower/two-levels-lower/ignored-ony-if-dir/ignored-by-ignored-dir
+
+
+test_done
diff --git a/t/t5003-archive-zip.sh b/t/t5003-archive-zip.sh
new file mode 100755 (executable)
index 0000000..7cfe9ca
--- /dev/null
@@ -0,0 +1,131 @@
+#!/bin/sh
+
+test_description='git archive --format=zip test'
+
+. ./test-lib.sh
+GIT_UNZIP=${GIT_UNZIP:-unzip}
+
+SUBSTFORMAT=%H%n
+
+test_lazy_prereq UNZIP '
+       "$GIT_UNZIP" -v
+       test $? -ne 127
+'
+
+test_lazy_prereq UNZIP_SYMLINKS '
+       (
+               mkdir unzip-symlinks &&
+               cd unzip-symlinks &&
+               "$GIT_UNZIP" "$TEST_DIRECTORY"/t5003/infozip-symlinks.zip &&
+               test -h symlink
+       )
+'
+
+check_zip() {
+       zipfile=$1.zip
+       listfile=$1.lst
+       dir=$1
+       dir_with_prefix=$dir/$2
+
+       test_expect_success UNZIP " extract ZIP archive" '
+               (mkdir $dir && cd $dir && "$GIT_UNZIP" ../$zipfile)
+       '
+
+       test_expect_success UNZIP " validate filenames" "
+               (cd ${dir_with_prefix}a && find .) | sort >$listfile &&
+               test_cmp a.lst $listfile
+       "
+
+       test_expect_success UNZIP " validate file contents" "
+               diff -r a ${dir_with_prefix}a
+       "
+}
+
+test_expect_success \
+    'populate workdir' \
+    'mkdir a b c &&
+     echo simple textfile >a/a &&
+     mkdir a/bin &&
+     cp /bin/sh a/bin &&
+     printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
+     printf "A not substituted O" >a/substfile2 &&
+     (p=long_path_to_a_file && cd a &&
+      for depth in 1 2 3 4 5; do mkdir $p && cd $p; done &&
+      echo text >file_with_long_path)
+'
+
+test_expect_success SYMLINKS,UNZIP_SYMLINKS 'add symlink' '
+       ln -s a a/symlink_to_a
+'
+
+test_expect_success 'prepare file list' '
+       (cd a && find .) | sort >a.lst
+'
+
+test_expect_success \
+    'add ignored file' \
+    'echo ignore me >a/ignored &&
+     echo ignored export-ignore >.git/info/attributes'
+
+test_expect_success \
+    'add files to repository' \
+    'find a -type f | xargs git update-index --add &&
+     find a -type l | xargs git update-index --add &&
+     treeid=`git write-tree` &&
+     echo $treeid >treeid &&
+     git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
+     git commit-tree $treeid </dev/null)'
+
+test_expect_success \
+    'create bare clone' \
+    'git clone --bare . bare.git &&
+     cp .git/info/attributes bare.git/info/attributes'
+
+test_expect_success \
+    'remove ignored file' \
+    'rm a/ignored'
+
+test_expect_success \
+    'git archive --format=zip' \
+    'git archive --format=zip HEAD >d.zip'
+
+check_zip d
+
+test_expect_success \
+    'git archive --format=zip in a bare repo' \
+    '(cd bare.git && git archive --format=zip HEAD) >d1.zip'
+
+test_expect_success \
+    'git archive --format=zip vs. the same in a bare repo' \
+    'test_cmp d.zip d1.zip'
+
+test_expect_success 'git archive --format=zip with --output' \
+    'git archive --format=zip --output=d2.zip HEAD &&
+    test_cmp d.zip d2.zip'
+
+test_expect_success 'git archive with --output, inferring format' '
+       git archive --output=d3.zip HEAD &&
+       test_cmp d.zip d3.zip
+'
+
+test_expect_success \
+    'git archive --format=zip with prefix' \
+    'git archive --format=zip --prefix=prefix/ HEAD >e.zip'
+
+check_zip e prefix/
+
+test_expect_success 'git archive -0 --format=zip on large files' '
+       test_config core.bigfilethreshold 1 &&
+       git archive -0 --format=zip HEAD >large.zip
+'
+
+check_zip large
+
+test_expect_success 'git archive --format=zip on large files' '
+       test_config core.bigfilethreshold 1 &&
+       git archive --format=zip HEAD >large-compressed.zip
+'
+
+check_zip large-compressed
+
+test_done
diff --git a/t/t5003/infozip-symlinks.zip b/t/t5003/infozip-symlinks.zip
new file mode 100644 (file)
index 0000000..065728c
Binary files /dev/null and b/t/t5003/infozip-symlinks.zip differ
index b5417cc951b1cecbbde613fa572387f362e889d1..8f024a08f0b175c12747c33ac0a07cacb73937d9 100755 (executable)
@@ -368,7 +368,7 @@ test_expect_success 'push with colon-less refspec (2)' '
                git branch -D frotz
        fi &&
        git tag -f frotz &&
-       git push testrepo frotz &&
+       git push -f testrepo frotz &&
        check_push_result $the_commit tags/frotz &&
        check_push_result $the_first_commit heads/frotz
 
@@ -929,6 +929,27 @@ test_expect_success 'push into aliased refs (inconsistent)' '
        )
 '
 
+test_expect_success 'push requires --force to update lightweight tag' '
+       mk_test heads/master &&
+       mk_child child1 &&
+       mk_child child2 &&
+       (
+               cd child1 &&
+               git tag Tag &&
+               git push ../child2 Tag &&
+               git push ../child2 Tag &&
+               >file1 &&
+               git add file1 &&
+               git commit -m "file1" &&
+               git tag -f Tag &&
+               test_must_fail git push ../child2 Tag &&
+               git push --force ../child2 Tag &&
+               git tag -f Tag &&
+               test_must_fail git push ../child2 Tag HEAD~ &&
+               git push --force ../child2 Tag
+       )
+'
+
 test_expect_success 'push --porcelain' '
        mk_empty &&
        echo >.git/foo  "To testrepo" &&
diff --git a/t/t5535-fetch-push-symref.sh b/t/t5535-fetch-push-symref.sh
new file mode 100755 (executable)
index 0000000..8ed58d2
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+test_description='avoiding conflicting update thru symref aliasing'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+       test_commit one &&
+       git clone . src &&
+       git clone src dst1 &&
+       git clone src dst2 &&
+       test_commit two &&
+       ( cd src && git pull )
+'
+
+test_expect_success 'push' '
+       (
+               cd src &&
+               git push ../dst1 "refs/remotes/*:refs/remotes/*"
+       ) &&
+       git ls-remote src "refs/remotes/*" >expect &&
+       git ls-remote dst1 "refs/remotes/*" >actual &&
+       test_cmp expect actual &&
+       ( cd src && git symbolic-ref refs/remotes/origin/HEAD ) >expect &&
+       ( cd dst1 && git symbolic-ref refs/remotes/origin/HEAD ) >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'fetch' '
+       (
+               cd dst2 &&
+               git fetch ../src "refs/remotes/*:refs/remotes/*"
+       ) &&
+       git ls-remote src "refs/remotes/*" >expect &&
+       git ls-remote dst2 "refs/remotes/*" >actual &&
+       test_cmp expect actual &&
+       ( cd src && git symbolic-ref refs/remotes/origin/HEAD ) >expect &&
+       ( cd dst2 && git symbolic-ref refs/remotes/origin/HEAD ) >actual &&
+       test_cmp expect actual
+'
+
+test_done
index ee06d2864949de71b000402fda4378c9b483fe72..4435693bb2ca48d053003c87fccd8f8612d8b4a9 100755 (executable)
@@ -37,6 +37,16 @@ test_expect_success \
 
 test_expect_success \
     'successful clone must leave the directory' \
-    'cd bar'
+    'test -d bar'
+
+test_expect_success 'failed clone --separate-git-dir should not leave any directories' '
+       mkdir foo/.git/objects.bak/ &&
+       mv foo/.git/objects/* foo/.git/objects.bak/ &&
+       test_must_fail git clone --separate-git-dir gitdir foo worktree &&
+       test_must_fail test -e gitdir &&
+       test_must_fail test -e worktree &&
+       mv foo/.git/objects.bak/* foo/.git/objects/ &&
+       rmdir foo/.git/objects.bak
+'
 
 test_done
similarity index 74%
rename from t/t5800-remote-helpers.sh
rename to t/t5800-remote-testpy.sh
index e7dc668cef22719a778fb0447534466b88aaa245..1e683d42203c4a7077481c1ffc262a493612d4bf 100755 (executable)
@@ -3,12 +3,12 @@
 # Copyright (c) 2010 Sverre Rabbelier
 #
 
-test_description='Test remote-helper import and export commands'
+test_description='Test python remote-helper framework'
 
 . ./test-lib.sh
 
 if ! test_have_prereq PYTHON ; then
-       skip_all='skipping git-remote-hg tests, python not available'
+       skip_all='skipping python remote-helper tests, python not available'
        test_done
 fi
 
@@ -17,7 +17,7 @@ import sys
 if sys.hexversion < 0x02040000:
     sys.exit(1)
 ' || {
-       skip_all='skipping git-remote-hg tests, python version < 2.4'
+       skip_all='skipping python remote-helper tests, python version < 2.4'
        test_done
 }
 
@@ -38,12 +38,12 @@ test_expect_success 'setup repository' '
 '
 
 test_expect_success 'cloning from local repo' '
-       git clone "testgit::${PWD}/server" localclone &&
+       git clone "testpy::${PWD}/server" localclone &&
        test_cmp public/file localclone/file
 '
 
 test_expect_success 'cloning from remote repo' '
-       git clone "testgit::file://${PWD}/server" clone &&
+       git clone "testpy::file://${PWD}/server" clone &&
        test_cmp public/file clone/file
 '
 
@@ -73,11 +73,11 @@ test_expect_success 'pushing to local repo' '
 '
 
 # Generally, skip this test.  It demonstrates a now-fixed race in
-# git-remote-testgit, but is too slow to leave in for general use.
+# git-remote-testpy, but is too slow to leave in for general use.
 : test_expect_success 'racily pushing to local repo' '
        test_when_finished "rm -rf server2 localclone2" &&
        cp -R server server2 &&
-       git clone "testgit::${PWD}/server2" localclone2 &&
+       git clone "testpy::${PWD}/server2" localclone2 &&
        (cd localclone2 &&
        echo content >>file &&
        git commit -a -m three &&
@@ -145,4 +145,25 @@ test_expect_failure 'push new branch with old:new refspec' '
        compare_refs clone HEAD server refs/heads/new-refspec
 '
 
+test_expect_success 'proper failure checks for fetching' '
+       (GIT_REMOTE_TESTGIT_FAILURE=1 &&
+       export GIT_REMOTE_TESTGIT_FAILURE &&
+       cd localclone &&
+       test_must_fail git fetch 2>&1 | \
+               grep "Error while running fast-import"
+       )
+'
+
+# We sleep to give fast-export a chance to catch the SIGPIPE
+test_expect_failure 'proper failure checks for pushing' '
+       (GIT_REMOTE_TESTGIT_FAILURE=1 &&
+       export GIT_REMOTE_TESTGIT_FAILURE &&
+       GIT_REMOTE_TESTGIT_SLEEPY=1 &&
+       export GIT_REMOTE_TESTGIT_SLEEPY &&
+       cd localclone &&
+       test_must_fail git push --all 2>&1 | \
+               grep "Error while running fast-export"
+       )
+'
+
 test_done
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
new file mode 100755 (executable)
index 0000000..f387027
--- /dev/null
@@ -0,0 +1,169 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Sverre Rabbelier
+#
+
+test_description='Test remote-helper import and export commands'
+
+. ./test-lib.sh
+
+if ! type "${BASH-bash}" >/dev/null 2>&1; then
+       skip_all='skipping remote-testgit tests, bash not available'
+       test_done
+fi
+
+compare_refs() {
+       git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
+       git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
+       test_cmp expect actual
+}
+
+test_expect_success 'setup repository' '
+       git init server &&
+       (cd server &&
+        echo content >file &&
+        git add file &&
+        git commit -m one)
+'
+
+test_expect_success 'cloning from local repo' '
+       git clone "testgit::${PWD}/server" local &&
+       test_cmp server/file local/file
+'
+
+test_expect_success 'create new commit on remote' '
+       (cd server &&
+        echo content >>file &&
+        git commit -a -m two)
+'
+
+test_expect_success 'pulling from local repo' '
+       (cd local && git pull) &&
+       test_cmp server/file local/file
+'
+
+test_expect_success 'pushing to local repo' '
+       (cd local &&
+       echo content >>file &&
+       git commit -a -m three &&
+       git push) &&
+       compare_refs local HEAD server HEAD
+'
+
+test_expect_success 'fetch new branch' '
+       (cd server &&
+        git reset --hard &&
+        git checkout -b new &&
+        echo content >>file &&
+        git commit -a -m five
+       ) &&
+       (cd local &&
+        git fetch origin new
+       ) &&
+       compare_refs server HEAD local FETCH_HEAD
+'
+
+test_expect_success 'fetch multiple branches' '
+       (cd local &&
+        git fetch
+       ) &&
+       compare_refs server master local refs/remotes/origin/master &&
+       compare_refs server new local refs/remotes/origin/new
+'
+
+test_expect_success 'push when remote has extra refs' '
+       (cd local &&
+        git reset --hard origin/master &&
+        echo content >>file &&
+        git commit -a -m six &&
+        git push
+       ) &&
+       compare_refs local master server master
+'
+
+test_expect_success 'push new branch by name' '
+       (cd local &&
+        git checkout -b new-name  &&
+        echo content >>file &&
+        git commit -a -m seven &&
+        git push origin new-name
+       ) &&
+       compare_refs local HEAD server refs/heads/new-name
+'
+
+test_expect_failure 'push new branch with old:new refspec' '
+       (cd local &&
+        git push origin new-name:new-refspec
+       ) &&
+       compare_refs local HEAD server refs/heads/new-refspec
+'
+
+test_expect_success 'cloning without refspec' '
+       GIT_REMOTE_TESTGIT_REFSPEC="" \
+       git clone "testgit::${PWD}/server" local2 &&
+       compare_refs local2 HEAD server HEAD
+'
+
+test_expect_success 'pulling without refspecs' '
+       (cd local2 &&
+       git reset --hard &&
+       GIT_REMOTE_TESTGIT_REFSPEC="" git pull) &&
+       compare_refs local2 HEAD server HEAD
+'
+
+test_expect_failure 'pushing without refspecs' '
+       test_when_finished "(cd local2 && git reset --hard origin)" &&
+       (cd local2 &&
+       echo content >>file &&
+       git commit -a -m ten &&
+       GIT_REMOTE_TESTGIT_REFSPEC="" git push) &&
+       compare_refs local2 HEAD server HEAD
+'
+
+test_expect_success 'pulling with straight refspec' '
+       (cd local2 &&
+       GIT_REMOTE_TESTGIT_REFSPEC="*:*" git pull) &&
+       compare_refs local2 HEAD server HEAD
+'
+
+test_expect_failure 'pushing with straight refspec' '
+       test_when_finished "(cd local2 && git reset --hard origin)" &&
+       (cd local2 &&
+       echo content >>file &&
+       git commit -a -m eleven &&
+       GIT_REMOTE_TESTGIT_REFSPEC="*:*" git push) &&
+       compare_refs local2 HEAD server HEAD
+'
+
+test_expect_success 'pulling without marks' '
+       (cd local2 &&
+       GIT_REMOTE_TESTGIT_NO_MARKS=1 git pull) &&
+       compare_refs local2 HEAD server HEAD
+'
+
+test_expect_failure 'pushing without marks' '
+       test_when_finished "(cd local2 && git reset --hard origin)" &&
+       (cd local2 &&
+       echo content >>file &&
+       git commit -a -m twelve &&
+       GIT_REMOTE_TESTGIT_NO_MARKS=1 git push) &&
+       compare_refs local2 HEAD server HEAD
+'
+
+test_expect_success 'push all with existing object' '
+       (cd local &&
+       git branch dup2 master &&
+       git push origin --all
+       ) &&
+       compare_refs local dup2 server dup2
+'
+
+test_expect_success 'push ref with existing object' '
+       (cd local &&
+       git branch dup master &&
+       git push origin dup
+       ) &&
+       compare_refs local dup server dup
+'
+
+test_done
index f94f0c48e6337f6bd718b4fc6859a52411e09326..3fc3b74c8efa4e5092e36e6a6fbd2a15bc862d77 100755 (executable)
@@ -3,6 +3,7 @@
 test_description='git rev-list --pretty=format test'
 
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_tick
 test_expect_success 'setup' '
@@ -11,12 +12,24 @@ touch foo && git add foo && git commit -m "added foo" &&
 '
 
 # usage: test_format name format_string <expected_output
-test_format() {
+test_format () {
        cat >expect.$1
        test_expect_success "format $1" "
-git rev-list --pretty=format:'$2' master >output.$1 &&
-test_cmp expect.$1 output.$1
-"
+               git rev-list --pretty=format:'$2' master >output.$1 &&
+               test_cmp expect.$1 output.$1
+       "
+}
+
+# Feed to --format to provide predictable colored sequences.
+AUTO_COLOR='%C(auto,red)foo%C(auto,reset)'
+has_color () {
+       printf '\033[31mfoo\033[m\n' >expect &&
+       test_cmp expect "$1"
+}
+
+has_no_color () {
+       echo foo >expect &&
+       test_cmp expect "$1"
 }
 
 test_format percent %%h <<'EOF'
@@ -124,6 +137,48 @@ commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
 \e[1;31;43mfoo\e[m
 EOF
 
+test_expect_success '%C(auto) does not enable color by default' '
+       git log --format=$AUTO_COLOR -1 >actual &&
+       has_no_color actual
+'
+
+test_expect_success '%C(auto) enables colors for color.diff' '
+       git -c color.diff=always log --format=$AUTO_COLOR -1 >actual &&
+       has_color actual
+'
+
+test_expect_success '%C(auto) enables colors for color.ui' '
+       git -c color.ui=always log --format=$AUTO_COLOR -1 >actual &&
+       has_color actual
+'
+
+test_expect_success '%C(auto) respects --color' '
+       git log --format=$AUTO_COLOR -1 --color >actual &&
+       has_color actual
+'
+
+test_expect_success '%C(auto) respects --no-color' '
+       git -c color.ui=always log --format=$AUTO_COLOR -1 --no-color >actual &&
+       has_no_color actual
+'
+
+test_expect_success TTY '%C(auto) respects --color=auto (stdout is tty)' '
+       (
+               TERM=vt100 && export TERM &&
+               test_terminal \
+                       git log --format=$AUTO_COLOR -1 --color=auto >actual &&
+               has_color actual
+       )
+'
+
+test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
+       (
+               TERM=vt100 && export TERM &&
+               git log --format=$AUTO_COLOR -1 --color=auto >actual &&
+               has_no_color actual
+       )
+'
+
 cat >commit-msg <<'EOF'
 Test printing of complex bodies
 
index 72e28ee5350926f3c4f27e2c99f8323a3eb8e57c..3e0e15fb3e0b92ab7e95789d27db34d9a1fa423c 100755 (executable)
@@ -676,9 +676,7 @@ test_expect_success 'bisect fails if tree is broken on trial commit' '
 check_same()
 {
        echo "Checking $1 is the same as $2" &&
-       git rev-parse "$1" > expected.same &&
-       git rev-parse "$2" > expected.actual &&
-       test_cmp expected.same expected.actual
+       test_cmp_rev "$1" "$2"
 }
 
 test_expect_success 'bisect: --no-checkout - start commit bad' '
diff --git a/t/t6130-pathspec-noglob.sh b/t/t6130-pathspec-noglob.sh
new file mode 100755 (executable)
index 0000000..39ef619
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+test_description='test globbing (and noglob) of pathspec limiting'
+. ./test-lib.sh
+
+test_expect_success 'create commits with glob characters' '
+       test_commit unrelated bar &&
+       test_commit vanilla foo &&
+       # insert file "f*" in the commit, but in a way that avoids
+       # the name "f*" in the worktree, because it is not allowed
+       # on Windows (the tests below do not depend on the presence
+       # of the file in the worktree)
+       git update-index --add --cacheinfo 100644 "$(git rev-parse HEAD:foo)" "f*" &&
+       test_tick &&
+       git commit -m star &&
+       test_commit bracket "f[o][o]"
+'
+
+test_expect_success 'vanilla pathspec matches literally' '
+       echo vanilla >expect &&
+       git log --format=%s -- foo >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'star pathspec globs' '
+       cat >expect <<-\EOF &&
+       bracket
+       star
+       vanilla
+       EOF
+       git log --format=%s -- "f*" >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'bracket pathspec globs and matches literal brackets' '
+       cat >expect <<-\EOF &&
+       bracket
+       vanilla
+       EOF
+       git log --format=%s -- "f[o][o]" >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'no-glob option matches literally (vanilla)' '
+       echo vanilla >expect &&
+       git --literal-pathspecs log --format=%s -- foo >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'no-glob option matches literally (star)' '
+       echo star >expect &&
+       git --literal-pathspecs log --format=%s -- "f*" >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'no-glob option matches literally (bracket)' '
+       echo bracket >expect &&
+       git --literal-pathspecs log --format=%s -- "f[o][o]" >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'no-glob environment variable works' '
+       echo star >expect &&
+       GIT_LITERAL_PATHSPECS=1 git log --format=%s -- "f*" >actual &&
+       test_cmp expect actual
+'
+
+test_done
index 518944653477225da94db0826d77936eaa0d249a..f5a79b13aecf4020b8a453f5f27568ce4f88bbbc 100755 (executable)
@@ -1066,12 +1066,12 @@ test_expect_success GPG \
 '
 
 # usage with rfc1991 signatures
-echo "rfc1991" > gpghome/gpg.conf
 get_tag_header rfc1991-signed-tag $commit commit $time >expect
 echo "RFC1991 signed tag" >>expect
 echo '-----BEGIN PGP MESSAGE-----' >>expect
 test_expect_success GPG \
        'creating a signed tag with rfc1991' '
+       echo "rfc1991" >gpghome/gpg.conf &&
        git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit &&
        get_tag_msg rfc1991-signed-tag >actual &&
        test_cmp expect actual
@@ -1085,6 +1085,7 @@ chmod +x fakeeditor
 
 test_expect_success GPG \
        'reediting a signed tag body omits signature' '
+       echo "rfc1991" >gpghome/gpg.conf &&
        echo "RFC1991 signed tag" >expect &&
        GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
        test_cmp expect actual
@@ -1092,11 +1093,13 @@ test_expect_success GPG \
 
 test_expect_success GPG \
        'verifying rfc1991 signature' '
+       echo "rfc1991" >gpghome/gpg.conf &&
        git tag -v rfc1991-signed-tag
 '
 
 test_expect_success GPG \
        'list tag with rfc1991 signature' '
+       echo "rfc1991" >gpghome/gpg.conf &&
        echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
        git tag -l -n1 rfc1991-signed-tag >actual &&
        test_cmp expect actual &&
diff --git a/t/t7061-wtstatus-ignore.sh b/t/t7061-wtstatus-ignore.sh
new file mode 100755 (executable)
index 0000000..0da1214
--- /dev/null
@@ -0,0 +1,146 @@
+#!/bin/sh
+
+test_description='git-status ignored files'
+
+. ./test-lib.sh
+
+cat >expected <<\EOF
+?? .gitignore
+?? actual
+?? expected
+?? untracked/
+EOF
+
+test_expect_success 'status untracked directory with --ignored' '
+       echo "ignored" >.gitignore &&
+       mkdir untracked &&
+       : >untracked/ignored &&
+       : >untracked/uncommitted &&
+       git status --porcelain --ignored >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+?? .gitignore
+?? actual
+?? expected
+?? untracked/uncommitted
+!! untracked/ignored
+EOF
+
+test_expect_success 'status untracked directory with --ignored -u' '
+       git status --porcelain --ignored -u >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+?? .gitignore
+?? actual
+?? expected
+!! ignored/
+EOF
+
+test_expect_success 'status ignored directory with --ignore' '
+       rm -rf untracked &&
+       mkdir ignored &&
+       : >ignored/uncommitted &&
+       git status --porcelain --ignored >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+?? .gitignore
+?? actual
+?? expected
+!! ignored/uncommitted
+EOF
+
+test_expect_success 'status ignored directory with --ignore -u' '
+       git status --porcelain --ignored -u >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+?? .gitignore
+?? actual
+?? expected
+!! untracked-ignored/
+EOF
+
+test_expect_success 'status untracked directory with ignored files with --ignore' '
+       rm -rf ignored &&
+       mkdir untracked-ignored &&
+       mkdir untracked-ignored/test &&
+       : >untracked-ignored/ignored &&
+       : >untracked-ignored/test/ignored &&
+       git status --porcelain --ignored >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+?? .gitignore
+?? actual
+?? expected
+!! untracked-ignored/ignored
+!! untracked-ignored/test/ignored
+EOF
+
+test_expect_success 'status untracked directory with ignored files with --ignore -u' '
+       git status --porcelain --ignored -u >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+?? .gitignore
+?? actual
+?? expected
+EOF
+
+test_expect_success 'status ignored tracked directory with --ignore' '
+       rm -rf untracked-ignored &&
+       mkdir tracked &&
+       : >tracked/committed &&
+       git add tracked/committed &&
+       git commit -m. &&
+       echo "tracked" >.gitignore &&
+       git status --porcelain --ignored >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+?? .gitignore
+?? actual
+?? expected
+EOF
+
+test_expect_success 'status ignored tracked directory with --ignore -u' '
+       git status --porcelain --ignored -u >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+?? .gitignore
+?? actual
+?? expected
+!! tracked/
+EOF
+
+test_expect_success 'status ignored tracked directory and uncommitted file with --ignore' '
+       : >tracked/uncommitted &&
+       git status --porcelain --ignored >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+?? .gitignore
+?? actual
+?? expected
+!! tracked/uncommitted
+EOF
+
+test_expect_success 'status ignored tracked directory and uncommitted file with --ignore -u' '
+       git status --porcelain --ignored -u >actual &&
+       test_cmp expected actual
+'
+
+test_done
index b096dc88c2f4caf28887cf8fea5d700f0132f5a3..1fa2a5fc23da25643552cdf43408cb75480194ff 100755 (executable)
@@ -388,7 +388,8 @@ test_expect_success 'test --mixed <paths>' '
        echo 4 > file4 &&
        echo 5 > file1 &&
        git add file1 file3 file4 &&
-       test_must_fail git reset HEAD -- file1 file2 file3 &&
+       git reset HEAD -- file1 file2 file3 &&
+       test_must_fail git diff --quiet &&
        git diff > output &&
        test_cmp output expect &&
        git diff --cached > output &&
@@ -402,7 +403,8 @@ test_expect_success 'test resetting the index at give paths' '
        >sub/file2 &&
        git update-index --add sub/file1 sub/file2 &&
        T=$(git write-tree) &&
-       test_must_fail git reset HEAD sub/file2 &&
+       git reset HEAD sub/file2 &&
+       test_must_fail git diff --quiet &&
        U=$(git write-tree) &&
        echo "$T" &&
        echo "$U" &&
@@ -440,7 +442,8 @@ test_expect_success 'resetting specific path that is unmerged' '
                echo "100644 $F3 3      file2"
        } | git update-index --index-info &&
        git ls-files -u &&
-       test_must_fail git reset HEAD file2 &&
+       git reset HEAD file2 &&
+       test_must_fail git diff --quiet &&
        git diff-index --exit-code --cached HEAD
 '
 
@@ -449,7 +452,8 @@ test_expect_success 'disambiguation (1)' '
        git reset --hard &&
        >secondfile &&
        git add secondfile &&
-       test_must_fail git reset secondfile &&
+       git reset secondfile &&
+       test_must_fail git diff --quiet -- secondfile &&
        test -z "$(git diff --cached --name-only)" &&
        test -f secondfile &&
        test ! -s secondfile
@@ -474,7 +478,8 @@ test_expect_success 'disambiguation (3)' '
        >secondfile &&
        git add secondfile &&
        rm -f secondfile &&
-       test_must_fail git reset HEAD secondfile &&
+       git reset HEAD secondfile &&
+       test_must_fail git diff --quiet &&
        test -z "$(git diff --cached --name-only)" &&
        test ! -f secondfile
 
@@ -486,9 +491,18 @@ test_expect_success 'disambiguation (4)' '
        >secondfile &&
        git add secondfile &&
        rm -f secondfile &&
-       test_must_fail git reset -- secondfile &&
+       git reset -- secondfile &&
+       test_must_fail git diff --quiet &&
        test -z "$(git diff --cached --name-only)" &&
        test ! -f secondfile
 '
 
+test_expect_success 'reset with paths accepts tree' '
+       # for simpler tests, drop last commit containing added files
+       git reset --hard HEAD^ &&
+       git reset HEAD^^{tree} -- . &&
+       git diff --cached HEAD^ --exit-code &&
+       git diff HEAD --exit-code
+'
+
 test_done
diff --git a/t/t7106-reset-unborn-branch.sh b/t/t7106-reset-unborn-branch.sh
new file mode 100755 (executable)
index 0000000..8062cf5
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+test_description='git reset should work on unborn branch'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+       echo a >a &&
+       echo b >b
+'
+
+test_expect_success 'reset' '
+       git add a b &&
+       git reset &&
+       test "$(git ls-files)" = ""
+'
+
+test_expect_success 'reset HEAD' '
+       rm .git/index &&
+       git add a b &&
+       test_must_fail git reset HEAD
+'
+
+test_expect_success 'reset $file' '
+       rm .git/index &&
+       git add a b &&
+       git reset a &&
+       test "$(git ls-files)" = "b"
+'
+
+test_expect_success 'reset -p' '
+       rm .git/index &&
+       git add a &&
+       echo y | git reset -p &&
+       test "$(git ls-files)" = ""
+'
+
+test_expect_success 'reset --soft is a no-op' '
+       rm .git/index &&
+       git add a &&
+       git reset --soft
+       test "$(git ls-files)" = "a"
+'
+
+test_expect_success 'reset --hard' '
+       rm .git/index &&
+       git add a &&
+       git reset --hard &&
+       test "$(git ls-files)" = "" &&
+       test_path_is_missing a
+'
+
+test_done
index de7d45352e001d3c1b2c7f24361dc38dd9e0ea0a..2683cba7e3f0ba7fbb7ea1752a39a6068fc91718 100755 (executable)
@@ -133,6 +133,7 @@ test_expect_success 'submodule add --branch' '
        (
                cd addtest &&
                git submodule add -b initial "$submodurl" submod-branch &&
+               test "initial" = "$(git config -f .gitmodules submodule.submod-branch.branch)" &&
                git submodule init
        ) &&
 
index feaec6cdf4b8c7eac348ea1de61887c93c69244d..4975ec07ce614c8473f7f5638a008d7058730f06 100755 (executable)
@@ -135,6 +135,37 @@ test_expect_success 'submodule update --force forcibly checks out submodules' '
        )
 '
 
+test_expect_success 'submodule update --remote should fetch upstream changes' '
+       (cd submodule &&
+        echo line4 >> file &&
+        git add file &&
+        test_tick &&
+        git commit -m "upstream line4"
+       ) &&
+       (cd super &&
+        git submodule update --remote --force submodule &&
+        cd submodule &&
+        test "$(git log -1 --oneline)" = "$(GIT_DIR=../../submodule/.git git log -1 --oneline)"
+       )
+'
+
+test_expect_success 'local config should override .gitmodules branch' '
+       (cd submodule &&
+        git checkout -b test-branch &&
+        echo line5 >> file &&
+        git add file &&
+        test_tick &&
+        git commit -m "upstream line5" &&
+        git checkout master
+       ) &&
+       (cd super &&
+        git config submodule.submodule.branch test-branch &&
+        git submodule update --remote --force submodule &&
+        cd submodule &&
+        test "$(git log -1 --oneline)" = "$(GIT_DIR=../../submodule/.git git log -1 --oneline test-branch)"
+       )
+'
+
 test_expect_success 'submodule update --rebase staying on master' '
        (cd super/submodule &&
          git checkout master
diff --git a/t/t7500/add-content-and-comment b/t/t7500/add-content-and-comment
new file mode 100755 (executable)
index 0000000..c4dccff
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+echo "commit message" >> "$1"
+echo "# comment" >> "$1"
+exit 0
+
index 1a5cb6983c527b6d3e1ad6fad427d3513e8704b1..b1c76483866f55b4429fc76e7035e65984e7b4c2 100755 (executable)
@@ -4,6 +4,15 @@ test_description='git commit porcelain-ish'
 
 . ./test-lib.sh
 
+commit_msg_is () {
+       expect=commit_msg_is.expect
+       actual=commit_msg_is.actual
+
+       printf "%s" "$(git log --pretty=format:%s%b -1)" >$actual &&
+       printf "%s" "$1" >$expect &&
+       test_i18ncmp $expect $actual
+}
+
 # Arguments: [<prefix] [<commit message>] [<commit options>]
 check_summary_oneline() {
        test_tick &&
@@ -168,7 +177,7 @@ test_expect_success 'verbose respects diff config' '
        git config --unset color.diff
 '
 
-test_expect_success 'cleanup commit messages (verbatim,-t)' '
+test_expect_success 'cleanup commit messages (verbatim option,-t)' '
 
        echo >>negative &&
        { echo;echo "# text";echo; } >expect &&
@@ -178,7 +187,7 @@ test_expect_success 'cleanup commit messages (verbatim,-t)' '
 
 '
 
-test_expect_success 'cleanup commit messages (verbatim,-F)' '
+test_expect_success 'cleanup commit messages (verbatim option,-F)' '
 
        echo >>negative &&
        git commit --cleanup=verbatim -F expect -a &&
@@ -187,7 +196,7 @@ test_expect_success 'cleanup commit messages (verbatim,-F)' '
 
 '
 
-test_expect_success 'cleanup commit messages (verbatim,-m)' '
+test_expect_success 'cleanup commit messages (verbatim option,-m)' '
 
        echo >>negative &&
        git commit --cleanup=verbatim -m "$(cat expect)" -a &&
@@ -196,7 +205,7 @@ test_expect_success 'cleanup commit messages (verbatim,-m)' '
 
 '
 
-test_expect_success 'cleanup commit messages (whitespace,-F)' '
+test_expect_success 'cleanup commit messages (whitespace option,-F)' '
 
        echo >>negative &&
        { echo;echo "# text";echo; } >text &&
@@ -207,7 +216,7 @@ test_expect_success 'cleanup commit messages (whitespace,-F)' '
 
 '
 
-test_expect_success 'cleanup commit messages (strip,-F)' '
+test_expect_success 'cleanup commit messages (strip option,-F)' '
 
        echo >>negative &&
        { echo;echo "# text";echo sample;echo; } >text &&
@@ -218,7 +227,7 @@ test_expect_success 'cleanup commit messages (strip,-F)' '
 
 '
 
-test_expect_success 'cleanup commit messages (strip,-F,-e)' '
+test_expect_success 'cleanup commit messages (strip option,-F,-e)' '
 
        echo >>negative &&
        { echo;echo sample;echo; } >text &&
@@ -231,10 +240,71 @@ echo "sample
 # Please enter the commit message for your changes. Lines starting
 # with '#' will be ignored, and an empty message aborts the commit." >expect
 
-test_expect_success 'cleanup commit messages (strip,-F,-e): output' '
+test_expect_success 'cleanup commit messages (strip option,-F,-e): output' '
        test_i18ncmp expect actual
 '
 
+test_expect_success 'cleanup commit message (fail on invalid cleanup mode option)' '
+       test_must_fail git commit --cleanup=non-existent
+'
+
+test_expect_success 'cleanup commit message (fail on invalid cleanup mode configuration)' '
+       test_must_fail git -c commit.cleanup=non-existent commit
+'
+
+test_expect_success 'cleanup commit message (no config and no option uses default)' '
+       echo content >>file &&
+       git add file &&
+       test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
+       git commit --no-status &&
+       commit_msg_is "commit message"
+'
+
+test_expect_success 'cleanup commit message (option overrides default)' '
+       echo content >>file &&
+       git add file &&
+       test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
+       git commit --cleanup=whitespace --no-status &&
+       commit_msg_is "commit message # comment"
+'
+
+test_expect_success 'cleanup commit message (config overrides default)' '
+       echo content >>file &&
+       git add file &&
+       test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
+       git -c commit.cleanup=whitespace commit --no-status &&
+       commit_msg_is "commit message # comment"
+'
+
+test_expect_success 'cleanup commit message (option overrides config)' '
+       echo content >>file &&
+       git add file &&
+       test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
+       git -c commit.cleanup=whitespace commit --cleanup=default &&
+       commit_msg_is "commit message"
+'
+
+test_expect_success 'cleanup commit message (default, -m)' '
+       echo content >>file &&
+       git add file &&
+       git commit -m "message #comment " &&
+       commit_msg_is "message #comment"
+'
+
+test_expect_success 'cleanup commit message (whitespace option, -m)' '
+       echo content >>file &&
+       git add file &&
+       git commit --cleanup=whitespace --no-status -m "message #comment " &&
+       commit_msg_is "message #comment"
+'
+
+test_expect_success 'cleanup commit message (whitespace config, -m)' '
+       echo content >>file &&
+       git add file &&
+       git -c commit.cleanup=whitespace commit --no-status -m "message #comment " &&
+       commit_msg_is "message #comment"
+'
+
 test_expect_success 'message shows author when it is not equal to committer' '
        echo >>negative &&
        git commit -e -m "sample" -a &&
index 5b4b694f1801f5c2284346f882cb496df9e7d74e..357375151d79d03d11275875dd10ceea42a3ba47 100755 (executable)
@@ -167,5 +167,19 @@ test_expect_success 'with failing hook (--no-verify)' '
 
 '
 
+test_expect_success 'with failing hook (merge)' '
+
+       git checkout -B other HEAD@{1} &&
+       echo "more" >> file &&
+       git add file &&
+       rm -f "$HOOK" &&
+       git commit -m other &&
+       write_script "$HOOK" <<-EOF
+       exit 1
+       EOF
+       git checkout - &&
+       test_must_fail git merge other
+
+'
 
 test_done
index 4f2dfe0e3d00010679c77e66c81b3ab4509e2522..2d2f016f6f8b151f10b08e4419dc6d3bdef3d0a8 100755 (executable)
@@ -12,9 +12,13 @@ then
        test_done
 fi
 
-# We override svnrdump by placing a symlink to the svnrdump-emulator in .
-export PATH="$HOME:$PATH"
-ln -sf $GIT_BUILD_DIR/contrib/svn-fe/svnrdump_sim.py "$HOME/svnrdump"
+# Override svnrdump with our simulator
+PATH="$HOME:$PATH"
+export PATH PYTHON_PATH GIT_BUILD_DIR
+
+write_script "$HOME/svnrdump" <<\EOF
+exec "$PYTHON_PATH" "$GIT_BUILD_DIR/contrib/svn-fe/svnrdump_sim.py" "$@"
+EOF
 
 init_git () {
        rm -fr .git &&
@@ -32,8 +36,8 @@ fi
 
 test_debug '
        git --version
-       which git
-       which svnrdump
+       type git
+       type svnrdump
 '
 
 test_expect_success REMOTE_SVN 'simple fetch' '
index 69934b2e775c8591ca209c9275abc40b921ecab6..3fb3368903686c8588c51e881beaee1f29808575 100755 (executable)
@@ -25,8 +25,9 @@ GIT_DIR=$PWD/.git
 export CVSROOT CVSWORK GIT_DIR
 
 rm -rf "$CVSROOT" "$CVSWORK"
-mkdir "$CVSROOT" &&
+
 cvs init &&
+test -d "$CVSROOT" &&
 cvs -Q co -d "$CVSWORK" . &&
 echo >empty &&
 git add empty &&
index 3e821f958bf10afc739e014ed854254a625affd9..9320b4f94c25bf376a004c2c0d4451c0fd96f969 100755 (executable)
@@ -303,7 +303,7 @@ 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
+       test_cmp expected output
 )
 '
 
@@ -320,7 +320,7 @@ 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
+       test_cmp expected output
 )
 '
 
@@ -351,7 +351,7 @@ test_expect_failure 'no exact-ref revisions included' '
        (
                cd limit-by-paths &&
                git fast-export master~2..master~1 > output &&
-               test_cmp output expected
+               test_cmp expected output
        )
 '
 
@@ -440,4 +440,63 @@ test_expect_success 'fast-export quotes pathnames' '
        )
 '
 
+test_expect_success 'test bidirectionality' '
+       >marks-cur &&
+       >marks-new &&
+       git init marks-test &&
+       git fast-export --export-marks=marks-cur --import-marks=marks-cur --branches | \
+       git --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks=marks-new &&
+       (cd marks-test &&
+       git reset --hard &&
+       echo Wohlauf > file &&
+       git commit -a -m "back in time") &&
+       git --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks=marks-new --branches | \
+       git fast-import --export-marks=marks-cur --import-marks=marks-cur
+'
+
+cat > expected << EOF
+blob
+mark :13
+data 5
+bump
+
+commit refs/heads/master
+mark :14
+author A U Thor <author@example.com> 1112912773 -0700
+committer C O Mitter <committer@example.com> 1112912773 -0700
+data 5
+bump
+from :12
+M 100644 :13 file
+
+EOF
+
+test_expect_success 'avoid uninteresting refs' '
+       > tmp-marks &&
+       git fast-export --import-marks=tmp-marks \
+               --export-marks=tmp-marks master > /dev/null &&
+       git tag v1.0 &&
+       git branch uninteresting &&
+       echo bump > file &&
+       git commit -a -m bump &&
+       git fast-export --import-marks=tmp-marks \
+               --export-marks=tmp-marks ^uninteresting ^v1.0 master > actual &&
+       test_cmp expected actual
+'
+
+cat > expected << EOF
+reset refs/heads/master
+from :14
+
+EOF
+
+test_expect_success 'refs are updated even if no commits need to be exported' '
+       > tmp-marks &&
+       git fast-export --import-marks=tmp-marks \
+               --export-marks=tmp-marks master > /dev/null &&
+       git fast-export --import-marks=tmp-marks \
+               --export-marks=tmp-marks master > actual &&
+       test_cmp expected actual
+'
+
 test_done
diff --git a/t/t9402-git-cvsserver-refs.sh b/t/t9402-git-cvsserver-refs.sh
new file mode 100755 (executable)
index 0000000..735a018
--- /dev/null
@@ -0,0 +1,551 @@
+#!/bin/sh
+
+test_description='git-cvsserver and git refspecs
+
+tests ability for git-cvsserver to switch between and compare
+tags, branches and other git refspecs'
+
+. ./test-lib.sh
+
+#########
+
+check_start_tree() {
+       rm -f "$WORKDIR/list.expected"
+       echo "start $1" >>"${WORKDIR}/check.log"
+}
+
+check_file() {
+       sandbox="$1"
+       file="$2"
+       ver="$3"
+       GIT_DIR=$SERVERDIR git show "${ver}:${file}" \
+               >"$WORKDIR/check.got" 2>"$WORKDIR/check.stderr"
+       test_cmp "$WORKDIR/check.got" "$sandbox/$file"
+       stat=$?
+       echo "check_file $sandbox $file $ver : $stat" >>"$WORKDIR/check.log"
+       echo "$file" >>"$WORKDIR/list.expected"
+       return $stat
+}
+
+check_end_tree() {
+       sandbox="$1" &&
+       find "$sandbox" -name CVS -prune -o -type f -print >"$WORKDIR/list.actual" &&
+       sort <"$WORKDIR/list.expected" >expected &&
+       sort <"$WORKDIR/list.actual" | sed -e "s%cvswork/%%" >actual &&
+       test_cmp expected actual &&
+       rm expected actual
+}
+
+check_end_full_tree() {
+       sandbox="$1" &&
+       sort <"$WORKDIR/list.expected" >expected &&
+       find "$sandbox" -name CVS -prune -o -type f -print |
+       sed -e "s%$sandbox/%%" | sort >act1 &&
+       test_cmp expected act1 &&
+       git ls-tree --name-only -r "$2" | sort >act2 &&
+       test_cmp expected act2 &&
+       rm expected act1 act2
+}
+
+#########
+
+check_diff() {
+       diffFile="$1"
+       vOld="$2"
+       vNew="$3"
+       rm -rf diffSandbox
+       git clone -q -n . diffSandbox &&
+       (
+               cd diffSandbox &&
+               git checkout "$vOld" &&
+               git apply -p0 --index <"../$diffFile" &&
+               git diff --exit-code "$vNew"
+       ) >check_diff_apply.out 2>&1
+}
+
+#########
+
+cvs >/dev/null 2>&1
+if test $? -ne 1
+then
+       skip_all='skipping git-cvsserver tests, cvs not found'
+       test_done
+fi
+if ! test_have_prereq PERL
+then
+       skip_all='skipping git-cvsserver tests, perl not available'
+       test_done
+fi
+"$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
+       skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
+       test_done
+}
+
+unset GIT_DIR GIT_CONFIG
+WORKDIR=$(pwd)
+SERVERDIR=$(pwd)/gitcvs.git
+git_config="$SERVERDIR/config"
+CVSROOT=":fork:$SERVERDIR"
+CVSWORK="$(pwd)/cvswork"
+CVS_SERVER=git-cvsserver
+export CVSROOT CVS_SERVER
+
+rm -rf "$CVSWORK" "$SERVERDIR"
+test_expect_success 'setup v1, b1' '
+       echo "Simple text file" >textfile.c &&
+       echo "t2" >t2 &&
+       mkdir adir &&
+       echo "adir/afile line1" >adir/afile &&
+       echo "adir/afile line2" >>adir/afile &&
+       echo "adir/afile line3" >>adir/afile &&
+       echo "adir/afile line4" >>adir/afile &&
+       echo "adir/a2file" >>adir/a2file &&
+       mkdir adir/bdir &&
+       echo "adir/bdir/bfile line 1" >adir/bdir/bfile &&
+       echo "adir/bdir/bfile line 2" >>adir/bdir/bfile &&
+       echo "adir/bdir/b2file" >adir/bdir/b2file &&
+       git add textfile.c t2 adir &&
+       git commit -q -m "First Commit (v1)" &&
+       git tag v1 &&
+       git branch b1 &&
+       git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
+       GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
+       GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log"
+'
+
+rm -rf cvswork
+test_expect_success 'cvs co v1' '
+       cvs -f -Q co -r v1 -d cvswork master >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1 &&
+       check_file cvswork t2 v1 &&
+       check_file cvswork adir/afile v1 &&
+       check_file cvswork adir/a2file v1 &&
+       check_file cvswork adir/bdir/bfile v1 &&
+       check_file cvswork adir/bdir/b2file v1 &&
+       check_end_tree cvswork
+'
+
+rm -rf cvswork
+test_expect_success 'cvs co b1' '
+       cvs -f co -r b1 -d cvswork master >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1 &&
+       check_file cvswork t2 v1 &&
+       check_file cvswork adir/afile v1 &&
+       check_file cvswork adir/a2file v1 &&
+       check_file cvswork adir/bdir/bfile v1 &&
+       check_file cvswork adir/bdir/b2file v1 &&
+       check_end_tree cvswork
+'
+
+test_expect_success 'cvs co b1 [cvswork3]' '
+       cvs -f co -r b1 -d cvswork3 master >cvs.log 2>&1 &&
+       check_start_tree cvswork3 &&
+       check_file cvswork3 textfile.c v1 &&
+       check_file cvswork3 t2 v1 &&
+       check_file cvswork3 adir/afile v1 &&
+       check_file cvswork3 adir/a2file v1 &&
+       check_file cvswork3 adir/bdir/bfile v1 &&
+       check_file cvswork3 adir/bdir/b2file v1 &&
+       check_end_full_tree cvswork3 v1
+'
+
+test_expect_success 'edit cvswork3 and save diff' '
+       (
+               cd cvswork3 &&
+               sed -e "s/line1/line1 - data/" adir/afile >adir/afileNEW &&
+               mv -f adir/afileNEW adir/afile &&
+               echo "afile5" >adir/afile5 &&
+               rm t2 &&
+               cvs -f add adir/afile5 &&
+               cvs -f rm t2 &&
+               ! cvs -f diff -N -u >"$WORKDIR/cvswork3edit.diff"
+       )
+'
+
+test_expect_success 'setup v1.2 on b1' '
+       git checkout b1 &&
+       echo "new v1.2" >t3 &&
+       rm t2 &&
+       sed -e "s/line3/line3 - more data/" adir/afile >adir/afileNEW &&
+       mv -f adir/afileNEW adir/afile &&
+       rm adir/a2file &&
+       echo "a3file" >>adir/a3file &&
+       echo "bfile line 3" >>adir/bdir/bfile &&
+       rm adir/bdir/b2file &&
+       echo "b3file" >adir/bdir/b3file &&
+       mkdir cdir &&
+       echo "cdir/cfile" >cdir/cfile &&
+       git add -A cdir adir t3 t2 &&
+       git commit -q -m 'v1.2' &&
+       git tag v1.2 &&
+       git push --tags gitcvs.git b1:b1
+'
+
+test_expect_success 'cvs -f up (on b1 adir)' '
+       ( cd cvswork/adir && cvs -f up -d ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1 &&
+       check_file cvswork t2 v1 &&
+       check_file cvswork adir/afile v1.2 &&
+       check_file cvswork adir/a3file v1.2 &&
+       check_file cvswork adir/bdir/bfile v1.2 &&
+       check_file cvswork adir/bdir/b3file v1.2 &&
+       check_end_tree cvswork
+'
+
+test_expect_success 'cvs up (on b1 /)' '
+       ( cd cvswork && cvs -f up -d ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1.2 &&
+       check_file cvswork t3 v1.2 &&
+       check_file cvswork adir/afile v1.2 &&
+       check_file cvswork adir/a3file v1.2 &&
+       check_file cvswork adir/bdir/bfile v1.2 &&
+       check_file cvswork adir/bdir/b3file v1.2 &&
+       check_file cvswork cdir/cfile v1.2 &&
+       check_end_tree cvswork
+'
+
+# Make sure "CVS/Tag" files didn't get messed up:
+test_expect_success 'cvs up (on b1 /) (again; check CVS/Tag files)' '
+       ( cd cvswork && cvs -f up -d ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1.2 &&
+       check_file cvswork t3 v1.2 &&
+       check_file cvswork adir/afile v1.2 &&
+       check_file cvswork adir/a3file v1.2 &&
+       check_file cvswork adir/bdir/bfile v1.2 &&
+       check_file cvswork adir/bdir/b3file v1.2 &&
+       check_file cvswork cdir/cfile v1.2 &&
+       check_end_tree cvswork
+'
+
+# update to another version:
+test_expect_success 'cvs up -r v1' '
+       ( cd cvswork && cvs -f up -r v1 ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1 &&
+       check_file cvswork t2 v1 &&
+       check_file cvswork adir/afile v1 &&
+       check_file cvswork adir/a2file v1 &&
+       check_file cvswork adir/bdir/bfile v1 &&
+       check_file cvswork adir/bdir/b2file v1 &&
+       check_end_tree cvswork
+'
+
+test_expect_success 'cvs up' '
+       ( cd cvswork && cvs -f up ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1 &&
+       check_file cvswork t2 v1 &&
+       check_file cvswork adir/afile v1 &&
+       check_file cvswork adir/a2file v1 &&
+       check_file cvswork adir/bdir/bfile v1 &&
+       check_file cvswork adir/bdir/b2file v1 &&
+       check_end_tree cvswork
+'
+
+test_expect_success 'cvs up (again; check CVS/Tag files)' '
+       ( cd cvswork && cvs -f up -d ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1 &&
+       check_file cvswork t2 v1 &&
+       check_file cvswork adir/afile v1 &&
+       check_file cvswork adir/a2file v1 &&
+       check_file cvswork adir/bdir/bfile v1 &&
+       check_file cvswork adir/bdir/b2file v1 &&
+       check_end_tree cvswork
+'
+
+test_expect_success 'setup simple b2' '
+       git branch b2 v1 &&
+       git push --tags gitcvs.git b2:b2
+'
+
+test_expect_success 'cvs co b2 [into cvswork2]' '
+       cvs -f co -r b2 -d cvswork2 master >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1 &&
+       check_file cvswork t2 v1 &&
+       check_file cvswork adir/afile v1 &&
+       check_file cvswork adir/a2file v1 &&
+       check_file cvswork adir/bdir/bfile v1 &&
+       check_file cvswork adir/bdir/b2file v1 &&
+       check_end_tree cvswork
+'
+
+test_expect_success 'root dir edit [cvswork2]' '
+       (
+               cd cvswork2 && echo "Line 2" >>textfile.c &&
+               ! cvs -f diff -u >"$WORKDIR/cvsEdit1.diff" &&
+               cvs -f commit -m "edit textfile.c" textfile.c
+       ) >cvsEdit1.log 2>&1
+'
+
+test_expect_success 'root dir rm file [cvswork2]' '
+       (
+               cd cvswork2 &&
+               cvs -f rm -f t2 &&
+               cvs -f diff -u >../cvsEdit2-empty.diff &&
+               ! cvs -f diff -N -u >"$WORKDIR/cvsEdit2-N.diff" &&
+               cvs -f commit -m "rm t2"
+       ) >cvsEdit2.log 2>&1
+'
+
+test_expect_success 'subdir edit/add/rm files [cvswork2]' '
+       (
+               cd cvswork2 &&
+               sed -e "s/line 1/line 1 (v2)/" adir/bdir/bfile >adir/bdir/bfileNEW &&
+               mv -f adir/bdir/bfileNEW adir/bdir/bfile &&
+               rm adir/bdir/b2file &&
+               cd adir &&
+               cvs -f rm bdir/b2file &&
+               echo "4th file" >bdir/b4file &&
+               cvs -f add bdir/b4file &&
+               ! cvs -f diff -N -u >"$WORKDIR/cvsEdit3.diff" &&
+               git fetch gitcvs.git b2:b2 &&
+               (
+                 cd .. &&
+                 ! cvs -f diff -u -N -r v1.2 >"$WORKDIR/cvsEdit3-v1.2.diff" &&
+                 ! cvs -f diff -u -N -r v1.2 -r v1 >"$WORKDIR/cvsEdit3-v1.2-v1.diff"
+               ) &&
+               cvs -f commit -m "various add/rm/edit"
+       ) >cvs.log 2>&1
+'
+
+test_expect_success 'validate result of edits [cvswork2]' '
+       git fetch gitcvs.git b2:b2 &&
+       git tag v2 b2 &&
+       git push --tags gitcvs.git b2:b2 &&
+       check_start_tree cvswork2 &&
+       check_file cvswork2 textfile.c v2 &&
+       check_file cvswork2 adir/afile v2 &&
+       check_file cvswork2 adir/a2file v2 &&
+       check_file cvswork2 adir/bdir/bfile v2 &&
+       check_file cvswork2 adir/bdir/b4file v2 &&
+       check_end_full_tree cvswork2 v2
+'
+
+test_expect_success 'validate basic diffs saved during above cvswork2 edits' '
+       test $(grep Index: cvsEdit1.diff | wc -l) = 1 &&
+       test ! -s cvsEdit2-empty.diff &&
+       test $(grep Index: cvsEdit2-N.diff | wc -l) = 1 &&
+       test $(grep Index: cvsEdit3.diff | wc -l) = 3 &&
+       rm -rf diffSandbox &&
+       git clone -q -n . diffSandbox &&
+       (
+               cd diffSandbox &&
+               git checkout v1 &&
+               git apply -p0 --index <"$WORKDIR/cvsEdit1.diff" &&
+               git apply -p0 --index <"$WORKDIR/cvsEdit2-N.diff" &&
+               git apply -p0 --directory=adir --index <"$WORKDIR/cvsEdit3.diff" &&
+               git diff --exit-code v2
+       ) >"check_diff_apply.out" 2>&1
+'
+
+test_expect_success 'validate v1.2 diff saved during last cvswork2 edit' '
+       test $(grep Index: cvsEdit3-v1.2.diff | wc -l) = 9 &&
+       check_diff cvsEdit3-v1.2.diff v1.2 v2
+'
+
+test_expect_success 'validate v1.2 v1 diff saved during last cvswork2 edit' '
+       test $(grep Index: cvsEdit3-v1.2-v1.diff | wc -l) = 9 &&
+       check_diff cvsEdit3-v1.2-v1.diff v1.2 v1
+'
+
+test_expect_success 'cvs up [cvswork2]' '
+       ( cd cvswork2 && cvs -f up ) >cvs.log 2>&1 &&
+       check_start_tree cvswork2 &&
+       check_file cvswork2 textfile.c v2 &&
+       check_file cvswork2 adir/afile v2 &&
+       check_file cvswork2 adir/a2file v2 &&
+       check_file cvswork2 adir/bdir/bfile v2 &&
+       check_file cvswork2 adir/bdir/b4file v2 &&
+       check_end_full_tree cvswork2 v2
+'
+
+test_expect_success 'cvs up -r b2 [back to cvswork]' '
+       ( cd cvswork && cvs -f up -r b2 ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v2 &&
+       check_file cvswork adir/afile v2 &&
+       check_file cvswork adir/a2file v2 &&
+       check_file cvswork adir/bdir/bfile v2 &&
+       check_file cvswork adir/bdir/b4file v2 &&
+       check_end_full_tree cvswork v2
+'
+
+test_expect_success 'cvs up -r b1' '
+       ( cd cvswork && cvs -f up -r b1 ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1.2 &&
+       check_file cvswork t3 v1.2 &&
+       check_file cvswork adir/afile v1.2 &&
+       check_file cvswork adir/a3file v1.2 &&
+       check_file cvswork adir/bdir/bfile v1.2 &&
+       check_file cvswork adir/bdir/b3file v1.2 &&
+       check_file cvswork cdir/cfile v1.2 &&
+       check_end_full_tree cvswork v1.2
+'
+
+test_expect_success 'cvs up -A' '
+       ( cd cvswork && cvs -f up -A ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1 &&
+       check_file cvswork t2 v1 &&
+       check_file cvswork adir/afile v1 &&
+       check_file cvswork adir/a2file v1 &&
+       check_file cvswork adir/bdir/bfile v1 &&
+       check_file cvswork adir/bdir/b2file v1 &&
+       check_end_full_tree cvswork v1
+'
+
+test_expect_success 'cvs up (check CVS/Tag files)' '
+       ( cd cvswork && cvs -f up ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1 &&
+       check_file cvswork t2 v1 &&
+       check_file cvswork adir/afile v1 &&
+       check_file cvswork adir/a2file v1 &&
+       check_file cvswork adir/bdir/bfile v1 &&
+       check_file cvswork adir/bdir/b2file v1 &&
+       check_end_full_tree cvswork v1
+'
+
+# This is not really legal CVS, but it seems to work anyway:
+test_expect_success 'cvs up -r heads/b1' '
+       ( cd cvswork && cvs -f up -r heads/b1 ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1.2 &&
+       check_file cvswork t3 v1.2 &&
+       check_file cvswork adir/afile v1.2 &&
+       check_file cvswork adir/a3file v1.2 &&
+       check_file cvswork adir/bdir/bfile v1.2 &&
+       check_file cvswork adir/bdir/b3file v1.2 &&
+       check_file cvswork cdir/cfile v1.2 &&
+       check_end_full_tree cvswork v1.2
+'
+
+# But this should work even if CVS client checks -r more carefully:
+test_expect_success 'cvs up -r heads_-s-b2 (cvsserver escape mechanism)' '
+       ( cd cvswork && cvs -f up -r heads_-s-b2 ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v2 &&
+       check_file cvswork adir/afile v2 &&
+       check_file cvswork adir/a2file v2 &&
+       check_file cvswork adir/bdir/bfile v2 &&
+       check_file cvswork adir/bdir/b4file v2 &&
+       check_end_full_tree cvswork v2
+'
+
+v1hash=$(git rev-parse v1)
+test_expect_success 'cvs up -r $(git rev-parse v1)' '
+       test -n "$v1hash" &&
+       ( cd cvswork && cvs -f up -r "$v1hash" ) >cvs.log 2>&1 &&
+       check_start_tree cvswork &&
+       check_file cvswork textfile.c v1 &&
+       check_file cvswork t2 v1 &&
+       check_file cvswork adir/afile v1 &&
+       check_file cvswork adir/a2file v1 &&
+       check_file cvswork adir/bdir/bfile v1 &&
+       check_file cvswork adir/bdir/b2file v1 &&
+       check_end_full_tree cvswork v1
+'
+
+test_expect_success 'cvs diff -r v1 -u' '
+       ( cd cvswork && cvs -f diff -r v1 -u ) >cvsDiff.out 2>cvs.log &&
+       test ! -s cvsDiff.out &&
+       test ! -s cvs.log
+'
+
+test_expect_success 'cvs diff -N -r v2 -u' '
+       ( cd cvswork && ! cvs -f diff -N -r v2 -u ) >cvsDiff.out 2>cvs.log &&
+       test ! -s cvs.log &&
+       test -s cvsDiff.out &&
+       check_diff cvsDiff.out v2 v1 >check_diff.out 2>&1
+'
+
+test_expect_success 'cvs diff -N -r v2 -r v1.2' '
+       ( cd cvswork && ! cvs -f diff -N -r v2 -r v1.2 -u ) >cvsDiff.out 2>cvs.log &&
+       test ! -s cvs.log &&
+       test -s cvsDiff.out &&
+       check_diff cvsDiff.out v2 v1.2 >check_diff.out 2>&1
+'
+
+test_expect_success 'apply early [cvswork3] diff to b3' '
+       git clone -q . gitwork3 &&
+       (
+               cd gitwork3 &&
+               git checkout -b b3 v1 &&
+               git apply -p0 --index <"$WORKDIR/cvswork3edit.diff" &&
+               git commit -m "cvswork3 edits applied"
+       ) &&
+       git fetch gitwork3 b3:b3 &&
+       git tag v3 b3
+'
+
+test_expect_success 'check [cvswork3] diff' '
+       ( cd cvswork3 && ! cvs -f diff -N -u ) >"$WORKDIR/cvsDiff.out" 2>cvs.log &&
+       test ! -s cvs.log &&
+       test -s cvsDiff.out &&
+       test $(grep Index: cvsDiff.out | wc -l) = 3 &&
+       test_cmp cvsDiff.out cvswork3edit.diff &&
+       check_diff cvsDiff.out v1 v3 >check_diff.out 2>&1
+'
+
+test_expect_success 'merge early [cvswork3] b3 with b1' '
+       ( cd gitwork3 && git merge "message" HEAD b1 ) &&
+       git fetch gitwork3 b3:b3 &&
+       git tag v3merged b3 &&
+       git push --tags gitcvs.git b3:b3
+'
+
+# This test would fail if cvsserver properly created a ".#afile"* file
+# for the merge.
+# TODO: Validate that the .# file was saved properly, and then
+#   delete/ignore it when checking the tree.
+test_expect_success 'cvs up dirty [cvswork3]' '
+       (
+               cd cvswork3 &&
+               cvs -f up &&
+               ! cvs -f diff -N -u >"$WORKDIR/cvsDiff.out"
+       ) >cvs.log 2>&1 &&
+       test -s cvsDiff.out &&
+       test $(grep Index: cvsDiff.out | wc -l) = 2 &&
+       check_start_tree cvswork3 &&
+       check_file cvswork3 textfile.c v3merged &&
+       check_file cvswork3 t3 v3merged &&
+       check_file cvswork3 adir/afile v3merged &&
+       check_file cvswork3 adir/a3file v3merged &&
+       check_file cvswork3 adir/afile5 v3merged &&
+       check_file cvswork3 adir/bdir/bfile v3merged &&
+       check_file cvswork3 adir/bdir/b3file v3merged &&
+       check_file cvswork3 cdir/cfile v3merged &&
+       check_end_full_tree cvswork3 v3merged
+'
+
+# TODO: test cvs status
+
+test_expect_success 'cvs commit [cvswork3]' '
+       (
+               cd cvswork3 &&
+               cvs -f commit -m "dirty sandbox after auto-merge"
+       ) >cvs.log 2>&1 &&
+       check_start_tree cvswork3 &&
+       check_file cvswork3 textfile.c v3merged &&
+       check_file cvswork3 t3 v3merged &&
+       check_file cvswork3 adir/afile v3merged &&
+       check_file cvswork3 adir/a3file v3merged &&
+       check_file cvswork3 adir/afile5 v3merged &&
+       check_file cvswork3 adir/bdir/bfile v3merged &&
+       check_file cvswork3 adir/bdir/b3file v3merged &&
+       check_file cvswork3 cdir/cfile v3merged &&
+       check_end_full_tree cvswork3 v3merged &&
+       git fetch gitcvs.git b3:b4 &&
+       git tag v4.1 b4 &&
+       git diff --exit-code v4.1 v3merged >check_diff_apply.out 2>&1
+'
+
+test_done
index 3a8e7d3f5aa1dc6a4d13467babd96a293ee1bb6e..86dfee2e4f93750aa72c0b24df57c77faa091aa7 100755 (executable)
@@ -40,7 +40,7 @@ check_snapshot () {
        echo "basename=$basename"
        grep "filename=.*$basename.tar" gitweb.headers >/dev/null 2>&1 &&
        "$TAR" tf gitweb.body >file_list &&
-       ! grep -v "^$prefix/" file_list
+       ! grep -v -e "^$prefix$" -e "^$prefix/" -e "^pax_global_header$" file_list
 }
 
 test_expect_success setup '
index 8c5979647ffceeb6614f0cdb58ae06170afac7c4..166e75209fb561f975a4c01f800f845e15ababae 100755 (executable)
@@ -160,9 +160,12 @@ test_expect_success 'clone --bare should make a bare repository' '
        test_when_finished cleanup_git &&
        (
                cd "$git" &&
-               test ! -d .git &&
-               bare=`git config --get core.bare` &&
-               test "$bare" = true
+               test_path_is_missing .git &&
+               git config --get --bool core.bare true &&
+               git rev-parse --verify refs/remotes/p4/master &&
+               git rev-parse --verify refs/remotes/p4/HEAD &&
+               git rev-parse --verify refs/heads/master &&
+               git rev-parse --verify HEAD
        )
 '
 
index fa40cc8bb59a4e785681013e1dc676709d808410..4f077eeca86946aa897f15e9f1729f9d0588cfb9 100755 (executable)
@@ -27,14 +27,102 @@ test_expect_success 'clone no --git-dir' '
        test_must_fail git p4 clone --git-dir=xx //depot
 '
 
-test_expect_success 'clone --branch' '
+test_expect_success 'clone --branch should checkout master' '
        git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot &&
        test_when_finished cleanup_git &&
        (
                cd "$git" &&
-               git ls-files >files &&
-               test_line_count = 0 files &&
-               test_path_is_file .git/refs/remotes/p4/sb
+               git rev-parse refs/remotes/p4/sb >sb &&
+               git rev-parse refs/heads/master >master &&
+               test_cmp sb master &&
+               git rev-parse HEAD >head &&
+               test_cmp sb head
+       )
+'
+
+test_expect_success 'sync when no master branch prints a nice error' '
+       test_when_finished cleanup_git &&
+       git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot@2 &&
+       (
+               cd "$git" &&
+               test_must_fail git p4 sync 2>err &&
+               grep "Error: no branch refs/remotes/p4/master" err
+       )
+'
+
+test_expect_success 'sync --branch builds the full ref name correctly' '
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git init &&
+
+               git p4 sync --branch=b1 //depot &&
+               git rev-parse --verify refs/remotes/p4/b1 &&
+               git p4 sync --branch=p4/b2 //depot &&
+               git rev-parse --verify refs/remotes/p4/b2 &&
+
+               git p4 sync --import-local --branch=h1 //depot &&
+               git rev-parse --verify refs/heads/p4/h1 &&
+               git p4 sync --import-local --branch=p4/h2 //depot &&
+               git rev-parse --verify refs/heads/p4/h2 &&
+
+               git p4 sync --branch=refs/stuff //depot &&
+               git rev-parse --verify refs/stuff
+       )
+'
+
+# engages --detect-branches code, which will do filename filtering so
+# no sync to either b1 or b2
+test_expect_success 'sync when two branches but no master should noop' '
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git init &&
+               git p4 sync --branch=refs/remotes/p4/b1 //depot@2 &&
+               git p4 sync --branch=refs/remotes/p4/b2 //depot@2 &&
+               git p4 sync &&
+               git show -s --format=%s refs/remotes/p4/b1 >show &&
+               grep "Initial import" show &&
+               git show -s --format=%s refs/remotes/p4/b2 >show &&
+               grep "Initial import" show
+       )
+'
+
+test_expect_success 'sync --branch updates specific branch, no detection' '
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git init &&
+               git p4 sync --branch=b1 //depot@2 &&
+               git p4 sync --branch=b2 //depot@2 &&
+               git p4 sync --branch=b2 &&
+               git show -s --format=%s refs/remotes/p4/b1 >show &&
+               grep "Initial import" show &&
+               git show -s --format=%s refs/remotes/p4/b2 >show &&
+               grep "change 3" show
+       )
+'
+
+# allows using the refname "p4" as a short name for p4/master
+test_expect_success 'clone creates HEAD symbolic reference' '
+       git p4 clone --dest="$git" //depot &&
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git rev-parse --verify refs/remotes/p4/master >master &&
+               git rev-parse --verify p4 >p4 &&
+               test_cmp master p4
+       )
+'
+
+test_expect_success 'clone --branch creates HEAD symbolic reference' '
+       git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot &&
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git rev-parse --verify refs/remotes/p4/sb >sb &&
+               git rev-parse --verify p4 >p4 &&
+               test_cmp sb p4
        )
 '
 
@@ -138,9 +226,11 @@ test_expect_success 'clone --use-client-spec' '
                View: //depot/sub/... //client2/bus/...
                EOF
        ) &&
-       P4CLIENT=client2 &&
        test_when_finished cleanup_git &&
-       git p4 clone --dest="$git" --use-client-spec //depot/... &&
+       (
+               P4CLIENT=client2 &&
+               git p4 clone --dest="$git" --use-client-spec //depot/...
+       ) &&
        (
                cd "$git" &&
                test_path_is_file bus/dir/f4 &&
@@ -153,6 +243,7 @@ test_expect_success 'clone --use-client-spec' '
                cd "$git" &&
                git init &&
                git config git-p4.useClientSpec true &&
+               P4CLIENT=client2 &&
                git p4 sync //depot/... &&
                git checkout -b master p4/master &&
                test_path_is_file bus/dir/f4 &&
@@ -160,6 +251,31 @@ test_expect_success 'clone --use-client-spec' '
        )
 '
 
+test_expect_success 'submit works with no p4/master' '
+       test_when_finished cleanup_git &&
+       git p4 clone --branch=b1 //depot@1,2 --destination="$git" &&
+       (
+               cd "$git" &&
+               test_commit submit-1-branch &&
+               git config git-p4.skipSubmitEdit true &&
+               git p4 submit --branch=b1
+       )
+'
+
+# The sync/rebase part post-submit will engage detect-branches
+# machinery which will not do anything in this particular test.
+test_expect_success 'submit works with two branches' '
+       test_when_finished cleanup_git &&
+       git p4 clone --branch=b1 //depot@1,2 --destination="$git" &&
+       (
+               cd "$git" &&
+               git p4 sync --branch=b2 //depot@1,3 &&
+               test_commit submit-2-branches &&
+               git config git-p4.skipSubmitEdit true &&
+               git p4 submit
+       )
+'
+
 test_expect_success 'kill p4d' '
        kill_p4d
 '
index 0c2fc3ea1a28268e216a3a93ed12b09f0cf55ef2..34fbc900055d9bbaa9e533063b7c69e384e07e5a 100755 (executable)
@@ -26,10 +26,8 @@ test_expect_success 'init depot' '
                line7
                line8
                EOF
-               cp filek fileko &&
-               sed -i "s/Revision/Revision: do not scrub me/" fileko
-               cp fileko file_text &&
-               sed -i "s/Id/Id: do not scrub me/" file_text
+               sed "s/Revision/Revision: do not scrub me/" <filek >fileko &&
+               sed "s/Id/Id: do not scrub me/" <fileko >file_text &&
                p4 add -t text+k filek &&
                p4 submit -d "filek" &&
                p4 add -t text+ko fileko &&
@@ -88,7 +86,8 @@ test_expect_success 'edit far away from RCS lines' '
        (
                cd "$git" &&
                git config git-p4.skipSubmitEdit true &&
-               sed -i "s/^line7/line7 edit/" filek &&
+               sed "s/^line7/line7 edit/" <filek >filek.tmp &&
+               mv -f filek.tmp filek &&
                git commit -m "filek line7 edit" filek &&
                git p4 submit &&
                scrub_k_check filek
@@ -105,7 +104,8 @@ test_expect_success 'edit near RCS lines' '
                cd "$git" &&
                git config git-p4.skipSubmitEdit true &&
                git config git-p4.attemptRCSCleanup true &&
-               sed -i "s/^line4/line4 edit/" filek &&
+               sed "s/^line4/line4 edit/" <filek >filek.tmp &&
+               mv -f filek.tmp filek &&
                git commit -m "filek line4 edit" filek &&
                git p4 submit &&
                scrub_k_check filek
@@ -122,7 +122,8 @@ test_expect_success 'edit keyword lines' '
                cd "$git" &&
                git config git-p4.skipSubmitEdit true &&
                git config git-p4.attemptRCSCleanup true &&
-               sed -i "/Revision/d" filek &&
+               sed "/Revision/d" <filek >filek.tmp &&
+               mv -f filek.tmp filek &&
                git commit -m "filek remove Revision line" filek &&
                git p4 submit &&
                scrub_k_check filek
@@ -139,7 +140,8 @@ test_expect_success 'scrub ko files differently' '
                cd "$git" &&
                git config git-p4.skipSubmitEdit true &&
                git config git-p4.attemptRCSCleanup true &&
-               sed -i "s/^line4/line4 edit/" fileko &&
+               sed "s/^line4/line4 edit/" <fileko >fileko.tmp &&
+               mv -f fileko.tmp fileko &&
                git commit -m "fileko line4 edit" fileko &&
                git p4 submit &&
                scrub_ko_check fileko &&
@@ -189,12 +191,14 @@ test_expect_success 'do not scrub plain text' '
                cd "$git" &&
                git config git-p4.skipSubmitEdit true &&
                git config git-p4.attemptRCSCleanup true &&
-               sed -i "s/^line4/line4 edit/" file_text &&
+               sed "s/^line4/line4 edit/" <file_text >file_text.tmp &&
+               mv -f file_text.tmp file_text &&
                git commit -m "file_text line4 edit" file_text &&
                (
                        cd "$cli" &&
                        p4 open file_text &&
-                       sed -i "s/^line5/line5 p4 edit/" file_text &&
+                       sed "s/^line5/line5 p4 edit/" <file_text >file_text.tmp &&
+                       mv -f file_text.tmp file_text &&
                        p4 submit -d "file5 p4 edit"
                ) &&
                echo s | test_expect_code 1 git p4 submit &&
index 22a4f8fb64a4e8084139fc148e8e7dd4aa73d684..fa62d010f68e3ee97e6754687ad4d08564d3c96b 100644 (file)
@@ -602,6 +602,13 @@ test_cmp() {
        $GIT_TEST_CMP "$@"
 }
 
+# Tests that its two parameters refer to the same revision
+test_cmp_rev () {
+       git rev-parse --verify "$1" >expect.rev &&
+       git rev-parse --verify "$2" >actual.rev &&
+       test_cmp expect.rev actual.rev
+}
+
 # Print a sequence of numbers or letters in increasing order.  This is
 # similar to GNU seq(1), but the latter might not be available
 # everywhere (and does not do letters).  It may be used like:
index f50f8341d40c6ec87565d01a263d97209fb68680..1a6c4ab08cd5adb56869855913272ec42eceb45f 100644 (file)
@@ -85,7 +85,8 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e '
                .*_TEST
                PROVE
                VALGRIND
-               PERF_AGGREGATING_LATER
+               UNZIP
+               PERF_
        ));
        my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
        print join("\n", @vars);
@@ -128,6 +129,7 @@ fi
 unset CDPATH
 
 unset GREP_OPTIONS
+unset UNZIP
 
 case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
 1|2|true)
@@ -212,11 +214,13 @@ then
                error)
                        tput bold; tput setaf 1;; # bold red
                skip)
-                       tput bold; tput setaf 2;; # bold green
+                       tput setaf 4;; # blue
+               warn)
+                       tput setaf 3;; # brown/yellow
                pass)
-                       tput setaf 2;;            # green
+                       tput setaf 2;; # green
                info)
-                       tput setaf 3;;            # brown
+                       tput setaf 6;; # cyan
                *)
                        test -n "$quiet" && return;;
                esac
@@ -298,7 +302,7 @@ test_ok_ () {
 
 test_failure_ () {
        test_failure=$(($test_failure + 1))
-       say_color error "not ok - $test_count $1"
+       say_color error "not ok $test_count - $1"
        shift
        echo "$@" | sed -e 's/^/#       /'
        test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
@@ -306,12 +310,12 @@ test_failure_ () {
 
 test_known_broken_ok_ () {
        test_fixed=$(($test_fixed+1))
-       say_color "" "ok $test_count - $@ # TODO known breakage"
+       say_color error "ok $test_count - $@ # TODO known breakage vanished"
 }
 
 test_known_broken_failure_ () {
        test_broken=$(($test_broken+1))
-       say_color skip "not ok $test_count - $@ # TODO known breakage"
+       say_color warn "not ok $test_count - $@ # TODO known breakage"
 }
 
 test_debug () {
@@ -404,13 +408,18 @@ test_done () {
 
        if test "$test_fixed" != 0
        then
-               say_color pass "# fixed $test_fixed known breakage(s)"
+               say_color error "# $test_fixed known breakage(s) vanished; please update test(s)"
        fi
        if test "$test_broken" != 0
        then
-               say_color error "# still have $test_broken known breakage(s)"
-               msg="remaining $(($test_count-$test_broken)) test(s)"
+               say_color warn "# still have $test_broken known breakage(s)"
+       fi
+       if test "$test_broken" != 0 || test "$test_fixed" != 0
+       then
+               test_remaining=$(( $test_count - $test_broken - $test_fixed ))
+               msg="remaining $test_remaining test(s)"
        else
+               test_remaining=$test_count
                msg="$test_count test(s)"
        fi
        case "$test_failure" in
@@ -424,7 +433,7 @@ test_done () {
 
                if test $test_external_has_tap -eq 0
                then
-                       if test $test_count -gt 0
+                       if test $test_remaining -gt 0
                        then
                                say_color pass "# passed all $msg"
                        fi
@@ -615,7 +624,7 @@ for skp in $GIT_SKIP_TESTS
 do
        case "$this_test" in
        $skp)
-               say_color skip >&3 "skipping test $this_test altogether"
+               say_color info >&3 "skipping test $this_test altogether"
                skip_all="skip all tests in $this_test"
                test_done
        esac
index 10172aee18292b50aa24b3a8694b5383c1cfd98e..1fb373f25bac42648a0779ffd42f1ae0eaec359a 100755 (executable)
@@ -31,7 +31,7 @@ sub finish_child {
        } elsif ($? & 127) {
                my $code = $? & 127;
                warn "died of signal $code";
-               return $code - 128;
+               return $code + 128;
        } else {
                return $? >> 8;
        }
index 3bc20e91da561f4edd5c3eddb0988735759234e4..0092cbf3540e2fdfd2e882461ba39ba2a833b672 100644 (file)
@@ -1,4 +1,32 @@
 #include "cache.h"
+#include "string-list.h"
+
+/*
+ * A "string_list_each_func_t" function that normalizes an entry from
+ * GIT_CEILING_DIRECTORIES.  If the path is unusable for some reason,
+ * die with an explanation.
+ */
+static int normalize_ceiling_entry(struct string_list_item *item, void *unused)
+{
+       const char *ceil = item->string;
+       int len = strlen(ceil);
+       char buf[PATH_MAX+1];
+
+       if (len == 0)
+               die("Empty path is not supported");
+       if (len > PATH_MAX)
+               die("Path \"%s\" is too long", ceil);
+       if (!is_absolute_path(ceil))
+               die("Path \"%s\" is not absolute", ceil);
+       if (normalize_path_copy(buf, ceil) < 0)
+               die("Path \"%s\" could not be normalized", ceil);
+       len = strlen(buf);
+       if (len > 1 && buf[len-1] == '/')
+               die("Normalized path \"%s\" ended with slash", buf);
+       free(item->string);
+       item->string = xstrdup(buf);
+       return 1;
+}
 
 int main(int argc, char **argv)
 {
@@ -30,7 +58,28 @@ int main(int argc, char **argv)
        }
 
        if (argc == 4 && !strcmp(argv[1], "longest_ancestor_length")) {
-               int len = longest_ancestor_length(argv[2], argv[3]);
+               int len;
+               struct string_list ceiling_dirs = STRING_LIST_INIT_DUP;
+               char *path = xstrdup(argv[2]);
+
+               /*
+                * We have to normalize the arguments because under
+                * Windows, bash mangles arguments that look like
+                * absolute POSIX paths or colon-separate lists of
+                * absolute POSIX paths into DOS paths (e.g.,
+                * "/foo:/foo/bar" might be converted to
+                * "D:\Src\msysgit\foo;D:\Src\msysgit\foo\bar"),
+                * whereas longest_ancestor_length() requires paths
+                * that use forward slashes.
+                */
+               if (normalize_path_copy(path, path))
+                       die("Path \"%s\" could not be normalized", argv[2]);
+               string_list_split(&ceiling_dirs, argv[3], PATH_SEP, -1);
+               filter_string_list(&ceiling_dirs, 0,
+                                  normalize_ceiling_entry, NULL);
+               len = longest_ancestor_length(path, &ceiling_dirs);
+               string_list_clear(&ceiling_dirs, 0);
+               free(path);
                printf("%d\n", len);
                return 0;
        }
index 4693295a98ca713fa65eb9b67d50113ec97ecf71..00ce6c9a129674c1922e0c388366592c5ae7c8c7 100644 (file)
@@ -97,26 +97,6 @@ int main(int argc, char **argv)
                return 0;
        }
 
-       if (argc == 4 && !strcmp(argv[1], "longest_prefix")) {
-               /* arguments: <colon-separated-prefixes>|- <string> */
-               struct string_list prefixes = STRING_LIST_INIT_DUP;
-               int retval;
-               const char *prefix_string = argv[2];
-               const char *string = argv[3];
-               const char *match;
-
-               parse_string_list(&prefixes, prefix_string);
-               match = string_list_longest_prefix(&prefixes, string);
-               if (match) {
-                       printf("%s\n", match);
-                       retval = 0;
-               }
-               else
-                       retval = 1;
-               string_list_clear(&prefixes, 0);
-               return retval;
-       }
-
        fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
                argv[1] ? argv[1] : "(there was none)");
        return 1;
diff --git a/test-wildmatch.c b/test-wildmatch.c
new file mode 100644 (file)
index 0000000..e384c8e
--- /dev/null
@@ -0,0 +1,22 @@
+#include "cache.h"
+#include "wildmatch.h"
+
+int main(int argc, char **argv)
+{
+       int i;
+       for (i = 2; i < argc; i++) {
+               if (argv[i][0] == '/')
+                       die("Forward slash is not allowed at the beginning of the\n"
+                           "pattern because Windows does not like it. Use `XXX/' instead.");
+               else if (!strncmp(argv[i], "XXX/", 4))
+                       argv[i] += 3;
+       }
+       if (!strcmp(argv[1], "wildmatch"))
+               return !!wildmatch(argv[3], argv[2], 0);
+       else if (!strcmp(argv[1], "iwildmatch"))
+               return !!wildmatch(argv[3], argv[2], FNM_CASEFOLD);
+       else if (!strcmp(argv[1], "fnmatch"))
+               return !!fnmatch(argv[3], argv[2], FNM_PATHNAME);
+       else
+               return 1;
+}
index 4713b6930248d961824c9f867b10340e6278132f..965b778cb3bb6fdd8068dbc7f9603cf9815c028d 100644 (file)
@@ -661,6 +661,11 @@ static void push_update_ref_status(struct strbuf *buf,
                        free(msg);
                        msg = NULL;
                }
+               else if (!strcmp(msg, "already exists")) {
+                       status = REF_STATUS_REJECT_ALREADY_EXISTS;
+                       free(msg);
+                       msg = NULL;
+               }
        }
 
        if (*ref)
@@ -720,6 +725,7 @@ static int push_refs_with_push(struct transport *transport,
                /* Check for statuses set by set_ref_status_for_push() */
                switch (ref->status) {
                case REF_STATUS_REJECT_NONFASTFORWARD:
+               case REF_STATUS_REJECT_ALREADY_EXISTS:
                case REF_STATUS_UPTODATE:
                        continue;
                default:
index 9932f402dfee2605dbb498b120813aebaa3961f8..2673d273ff3aa5530ee57e8a3916bbbbc802466d 100644 (file)
@@ -659,7 +659,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
                const char *msg;
 
                strcpy(quickref, status_abbrev(ref->old_sha1));
-               if (ref->nonfastforward) {
+               if (ref->requires_force) {
                        strcat(quickref, "...");
                        type = '+';
                        msg = "forced update";
@@ -695,6 +695,10 @@ static int print_one_push_status(struct ref *ref, const char *dest, int count, i
                print_ref_status('!', "[rejected]", ref, ref->peer_ref,
                                                 "non-fast-forward", porcelain);
                break;
+       case REF_STATUS_REJECT_ALREADY_EXISTS:
+               print_ref_status('!', "[rejected]", ref, ref->peer_ref,
+                                                "already exists", porcelain);
+               break;
        case REF_STATUS_REMOTE_REJECT:
                print_ref_status('!', "[remote rejected]", ref,
                                                 ref->deletion ? NULL : ref->peer_ref,
@@ -714,7 +718,7 @@ static int print_one_push_status(struct ref *ref, const char *dest, int count, i
 }
 
 void transport_print_push_status(const char *dest, struct ref *refs,
-                                 int verbose, int porcelain, int *nonfastforward)
+                                 int verbose, int porcelain, unsigned int *reject_reasons)
 {
        struct ref *ref;
        int n = 0;
@@ -733,18 +737,19 @@ void transport_print_push_status(const char *dest, struct ref *refs,
                if (ref->status == REF_STATUS_OK)
                        n += print_one_push_status(ref, dest, n, porcelain);
 
-       *nonfastforward = 0;
+       *reject_reasons = 0;
        for (ref = refs; ref; ref = ref->next) {
                if (ref->status != REF_STATUS_NONE &&
                    ref->status != REF_STATUS_UPTODATE &&
                    ref->status != REF_STATUS_OK)
                        n += print_one_push_status(ref, dest, n, porcelain);
-               if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD &&
-                   *nonfastforward != NON_FF_HEAD) {
+               if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD) {
                        if (!strcmp(head, ref->name))
-                               *nonfastforward = NON_FF_HEAD;
+                               *reject_reasons |= REJECT_NON_FF_HEAD;
                        else
-                               *nonfastforward = NON_FF_OTHER;
+                               *reject_reasons |= REJECT_NON_FF_OTHER;
+               } else if (ref->status == REF_STATUS_REJECT_ALREADY_EXISTS) {
+                       *reject_reasons |= REJECT_ALREADY_EXISTS;
                }
        }
 }
@@ -1031,9 +1036,9 @@ static void die_with_unpushed_submodules(struct string_list *needs_pushing)
 
 int transport_push(struct transport *transport,
                   int refspec_nr, const char **refspec, int flags,
-                  int *nonfastforward)
+                  unsigned int *reject_reasons)
 {
-       *nonfastforward = 0;
+       *reject_reasons = 0;
        transport_verify_remote_names(refspec_nr, refspec);
 
        if (transport->push) {
@@ -1099,7 +1104,7 @@ int transport_push(struct transport *transport,
                if (!quiet || err)
                        transport_print_push_status(transport->url, remote_refs,
                                        verbose | porcelain, porcelain,
-                                       nonfastforward);
+                                       reject_reasons);
 
                if (flags & TRANSPORT_PUSH_SET_UPSTREAM)
                        set_upstreams(transport, remote_refs, pretend);
index 4a61c0c3f2d9efa8daf228b20f5d57d96e72e261..bfd2df5823aac55e4ce8674b7980cccabf0fed5f 100644 (file)
@@ -140,11 +140,13 @@ int transport_set_option(struct transport *transport, const char *name,
 void transport_set_verbosity(struct transport *transport, int verbosity,
        int force_progress);
 
-#define NON_FF_HEAD 1
-#define NON_FF_OTHER 2
+#define REJECT_NON_FF_HEAD     0x01
+#define REJECT_NON_FF_OTHER    0x02
+#define REJECT_ALREADY_EXISTS  0x04
+
 int transport_push(struct transport *connection,
                   int refspec_nr, const char **refspec, int flags,
-                  int * nonfastforward);
+                  unsigned int * reject_reasons);
 
 const struct ref *transport_get_remote_refs(struct transport *transport);
 
@@ -170,7 +172,7 @@ void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int v
 int transport_refs_pushed(struct ref *ref);
 
 void transport_print_push_status(const char *dest, struct ref *refs,
-                 int verbose, int porcelain, int *nonfastforward);
+                 int verbose, int porcelain, unsigned int *reject_reasons);
 
 typedef void alternate_ref_fn(const struct ref *, void *);
 extern void for_each_alternate_ref(alternate_ref_fn, void *);
index 3f54c02d7624c26632e3a0f81b8bb970c6ac307f..6e30ef9d048c62c11a92aa5b0ee6df2d227776e6 100644 (file)
@@ -572,6 +572,54 @@ static int match_dir_prefix(const char *base,
        return 0;
 }
 
+/*
+ * Perform matching on the leading non-wildcard part of
+ * pathspec. item->nowildcard_len must be greater than zero. Return
+ * non-zero if base is matched.
+ */
+static int match_wildcard_base(const struct pathspec_item *item,
+                              const char *base, int baselen,
+                              int *matched)
+{
+       const char *match = item->match;
+       /* the wildcard part is not considered in this function */
+       int matchlen = item->nowildcard_len;
+
+       if (baselen) {
+               int dirlen;
+               /*
+                * Return early if base is longer than the
+                * non-wildcard part but it does not match.
+                */
+               if (baselen >= matchlen) {
+                       *matched = matchlen;
+                       return !strncmp(base, match, matchlen);
+               }
+
+               dirlen = matchlen;
+               while (dirlen && match[dirlen - 1] != '/')
+                       dirlen--;
+
+               /*
+                * Return early if base is shorter than the
+                * non-wildcard part but it does not match. Note that
+                * base ends with '/' so we are sure it really matches
+                * directory
+                */
+               if (strncmp(base, match, baselen))
+                       return 0;
+               *matched = baselen;
+       } else
+               *matched = 0;
+       /*
+        * we could have checked entry against the non-wildcard part
+        * that is not in base and does similar never_interesting
+        * optimization as in match_entry. For now just be happy with
+        * base comparison.
+        */
+       return entry_interesting;
+}
+
 /*
  * Is a tree entry interesting given the pathspec we have?
  *
@@ -602,7 +650,7 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
                const struct pathspec_item *item = ps->items+i;
                const char *match = item->match;
                const char *base_str = base->buf + base_offset;
-               int matchlen = item->len;
+               int matchlen = item->len, matched = 0;
 
                if (baselen >= matchlen) {
                        /* If it doesn't match, move along... */
@@ -626,8 +674,10 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
                                        &never_interesting))
                                return entry_interesting;
 
-                       if (item->use_wildcard) {
-                               if (!fnmatch(match + baselen, entry->path, 0))
+                       if (item->nowildcard_len < item->len) {
+                               if (!git_fnmatch(match + baselen, entry->path,
+                                                item->flags & PATHSPEC_ONESTAR ? GFNM_ONESTAR : 0,
+                                                item->nowildcard_len - baselen))
                                        return entry_interesting;
 
                                /*
@@ -642,17 +692,34 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
                }
 
 match_wildcards:
-               if (!item->use_wildcard)
+               if (item->nowildcard_len == item->len)
                        continue;
 
+               if (item->nowildcard_len &&
+                   !match_wildcard_base(item, base_str, baselen, &matched))
+                       return entry_not_interesting;
+
                /*
                 * Concatenate base and entry->path into one and do
                 * fnmatch() on it.
+                *
+                * While we could avoid concatenation in certain cases
+                * [1], which saves a memcpy and potentially a
+                * realloc, it turns out not worth it. Measurement on
+                * linux-2.6 does not show any clear improvements,
+                * partly because of the nowildcard_len optimization
+                * in git_fnmatch(). Avoid micro-optimizations here.
+                *
+                * [1] if match_wildcard_base() says the base
+                * directory is already matched, we only need to match
+                * the rest, which is shorter so _in theory_ faster.
                 */
 
                strbuf_add(base, entry->path, pathlen);
 
-               if (!fnmatch(match, base->buf + base_offset, 0)) {
+               if (!git_fnmatch(match, base->buf + base_offset,
+                                item->flags & PATHSPEC_ONESTAR ? GFNM_ONESTAR : 0,
+                                item->nowildcard_len)) {
                        strbuf_setlen(base, base_offset + baselen);
                        return entry_interesting;
                }
index 6d9636623a2cbb5d5a38eb58d625ef0164d953c0..0e1a196ace33110e2bb74cde90d6f62358413ead 100644 (file)
@@ -837,7 +837,8 @@ static int clear_ce_flags_dir(struct cache_entry **cache, int nr,
 {
        struct cache_entry **cache_end;
        int dtype = DT_DIR;
-       int ret = excluded_from_list(prefix, prefix_len, basename, &dtype, el);
+       int ret = is_excluded_from_list(prefix, prefix_len,
+                                       basename, &dtype, el);
 
        prefix[prefix_len++] = '/';
 
@@ -856,7 +857,7 @@ static int clear_ce_flags_dir(struct cache_entry **cache, int nr,
         * with ret (iow, we know in advance the incl/excl
         * decision for the entire directory), clear flag here without
         * calling clear_ce_flags_1(). That function will call
-        * the expensive excluded_from_list() on every entry.
+        * the expensive is_excluded_from_list() on every entry.
         */
        return clear_ce_flags_1(cache, cache_end - cache,
                                prefix, prefix_len,
@@ -939,7 +940,8 @@ static int clear_ce_flags_1(struct cache_entry **cache, int nr,
 
                /* Non-directory */
                dtype = ce_to_dtype(ce);
-               ret = excluded_from_list(ce->name, ce_namelen(ce), name, &dtype, el);
+               ret = is_excluded_from_list(ce->name, ce_namelen(ce),
+                                           name, &dtype, el);
                if (ret < 0)
                        ret = defval;
                if (ret > 0)
@@ -1152,7 +1154,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
                *o->dst_index = o->result;
 
 done:
-       free_excludes(&el);
+       clear_exclude_list(&el);
        if (o->path_exclude_check) {
                path_exclude_check_clear(o->path_exclude_check);
                free(o->path_exclude_check);
@@ -1373,7 +1375,7 @@ static int check_ok_to_remove(const char *name, int len, int dtype,
                return 0;
 
        if (o->dir &&
-           path_excluded(o->path_exclude_check, name, -1, &dtype))
+           is_path_excluded(o->path_exclude_check, name, -1, &dtype))
                /*
                 * ce->name is explicitly excluded, so it is Ok to
                 * overwrite it.
@@ -1834,7 +1836,7 @@ int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o)
 
        if (old && same(old, a)) {
                int update = 0;
-               if (o->reset && !ce_uptodate(old) && !ce_skip_worktree(old)) {
+               if (o->reset && o->update && !ce_uptodate(old) && !ce_skip_worktree(old)) {
                        struct stat st;
                        if (lstat(old->name, &st) ||
                            ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE))
index 6142421ea1172f7fe6b57486a4f41b81d92bab85..95d83135ae95b2fa7980c69cbd7b49e3a6ff2d0a 100644 (file)
@@ -603,6 +603,8 @@ static void receive_needs(void)
                        object = parse_object(sha1);
                        if (!object)
                                die("did not find object for %s", line);
+                       if (object->type != OBJ_COMMIT)
+                               die("invalid shallow object %s", sha1_to_hex(sha1));
                        object->flags |= CLIENT_SHALLOW;
                        add_object_array(object, NULL, &shallows);
                        continue;
diff --git a/utf8.c b/utf8.c
index 5c61bbe1131e7bbdd939c8b815bd5222b872e3fb..a4ee6650ef6c4c487c083aabf0a950b8ec317b09 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -323,7 +323,7 @@ static size_t display_mode_esc_sequence_len(const char *s)
  * If indent is negative, assume that already -indent columns have been
  * consumed (and no extra indent is necessary for the first line).
  */
-int strbuf_add_wrapped_text(struct strbuf *buf,
+void strbuf_add_wrapped_text(struct strbuf *buf,
                const char *text, int indent1, int indent2, int width)
 {
        int indent, w, assume_utf8 = 1;
@@ -332,7 +332,7 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
 
        if (width <= 0) {
                strbuf_add_indented_text(buf, text, indent1, indent2);
-               return 1;
+               return;
        }
 
 retry:
@@ -356,14 +356,14 @@ retry:
                        if (w <= width || !space) {
                                const char *start = bol;
                                if (!c && text == start)
-                                       return w;
+                                       return;
                                if (space)
                                        start = space;
                                else
                                        strbuf_addchars(buf, ' ', indent);
                                strbuf_add(buf, start, text - start);
                                if (!c)
-                                       return w;
+                                       return;
                                space = text;
                                if (c == '\t')
                                        w |= 0x07;
@@ -405,13 +405,12 @@ new_line:
        }
 }
 
-int strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
+void strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
                             int indent, int indent2, int width)
 {
        char *tmp = xstrndup(data, len);
-       int r = strbuf_add_wrapped_text(buf, tmp, indent, indent2, width);
+       strbuf_add_wrapped_text(buf, tmp, indent, indent2, width);
        free(tmp);
-       return r;
 }
 
 int is_encoding_utf8(const char *name)
diff --git a/utf8.h b/utf8.h
index 93ef60042c2fad93184b573f30e771ecddc842be..a214238bdd70c6b4eb41edf6626c5b396489ab50 100644 (file)
--- a/utf8.h
+++ b/utf8.h
@@ -9,9 +9,9 @@ int is_utf8(const char *text);
 int is_encoding_utf8(const char *name);
 int same_encoding(const char *, const char *);
 
-int strbuf_add_wrapped_text(struct strbuf *buf,
+void strbuf_add_wrapped_text(struct strbuf *buf,
                const char *text, int indent, int indent2, int width);
-int strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
+void strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
                             int indent, int indent2, int width);
 
 #ifndef NO_ICONV
diff --git a/wildmatch.c b/wildmatch.c
new file mode 100644 (file)
index 0000000..2d3ed84
--- /dev/null
@@ -0,0 +1,235 @@
+/*
+**  Do shell-style pattern matching for ?, \, [], and * characters.
+**  It is 8bit clean.
+**
+**  Written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986.
+**  Rich $alz is now <rsalz@bbn.com>.
+**
+**  Modified by Wayne Davison to special-case '/' matching, to make '**'
+**  work differently than '*', and to fix the character-class code.
+*/
+
+#include "cache.h"
+#include "wildmatch.h"
+
+typedef unsigned char uchar;
+
+/* What character marks an inverted character class? */
+#define NEGATE_CLASS   '!'
+#define NEGATE_CLASS2  '^'
+
+#define FALSE 0
+#define TRUE 1
+
+#define CC_EQ(class, len, litmatch) ((len) == sizeof (litmatch)-1 \
+                                   && *(class) == *(litmatch) \
+                                   && strncmp((char*)class, litmatch, len) == 0)
+
+#if defined STDC_HEADERS || !defined isascii
+# define ISASCII(c) 1
+#else
+# define ISASCII(c) isascii(c)
+#endif
+
+#ifdef isblank
+# define ISBLANK(c) (ISASCII(c) && isblank(c))
+#else
+# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
+#endif
+
+#ifdef isgraph
+# define ISGRAPH(c) (ISASCII(c) && isgraph(c))
+#else
+# define ISGRAPH(c) (ISASCII(c) && isprint(c) && !isspace(c))
+#endif
+
+#define ISPRINT(c) (ISASCII(c) && isprint(c))
+#define ISDIGIT(c) (ISASCII(c) && isdigit(c))
+#define ISALNUM(c) (ISASCII(c) && isalnum(c))
+#define ISALPHA(c) (ISASCII(c) && isalpha(c))
+#define ISCNTRL(c) (ISASCII(c) && iscntrl(c))
+#define ISLOWER(c) (ISASCII(c) && islower(c))
+#define ISPUNCT(c) (ISASCII(c) && ispunct(c))
+#define ISSPACE(c) (ISASCII(c) && isspace(c))
+#define ISUPPER(c) (ISASCII(c) && isupper(c))
+#define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
+
+/* Match pattern "p" against "text" */
+static int dowild(const uchar *p, const uchar *text, int force_lower_case)
+{
+       uchar p_ch;
+       const uchar *pattern = p;
+
+       for ( ; (p_ch = *p) != '\0'; text++, p++) {
+               int matched, match_slash, negated;
+               uchar t_ch, prev_ch;
+               if ((t_ch = *text) == '\0' && p_ch != '*')
+                       return ABORT_ALL;
+               if (force_lower_case && ISUPPER(t_ch))
+                       t_ch = tolower(t_ch);
+               if (force_lower_case && ISUPPER(p_ch))
+                       p_ch = tolower(p_ch);
+               switch (p_ch) {
+               case '\\':
+                       /* Literal match with following character.  Note that the test
+                        * in "default" handles the p[1] == '\0' failure case. */
+                       p_ch = *++p;
+                       /* FALLTHROUGH */
+               default:
+                       if (t_ch != p_ch)
+                               return NOMATCH;
+                       continue;
+               case '?':
+                       /* Match anything but '/'. */
+                       if (t_ch == '/')
+                               return NOMATCH;
+                       continue;
+               case '*':
+                       if (*++p == '*') {
+                               const uchar *prev_p = p - 2;
+                               while (*++p == '*') {}
+                               if ((prev_p < pattern || *prev_p == '/') &&
+                                   (*p == '\0' || *p == '/' ||
+                                    (p[0] == '\\' && p[1] == '/'))) {
+                                       /*
+                                        * Assuming we already match 'foo/' and are at
+                                        * <star star slash>, just assume it matches
+                                        * nothing and go ahead match the rest of the
+                                        * pattern with the remaining string. This
+                                        * helps make foo/<*><*>/bar (<> because
+                                        * otherwise it breaks C comment syntax) match
+                                        * both foo/bar and foo/a/bar.
+                                        */
+                                       if (p[0] == '/' &&
+                                           dowild(p + 1, text, force_lower_case) == MATCH)
+                                               return MATCH;
+                                       match_slash = TRUE;
+                               } else
+                                       return ABORT_MALFORMED;
+                       } else
+                               match_slash = FALSE;
+                       if (*p == '\0') {
+                               /* Trailing "**" matches everything.  Trailing "*" matches
+                                * only if there are no more slash characters. */
+                               if (!match_slash) {
+                                       if (strchr((char*)text, '/') != NULL)
+                                               return NOMATCH;
+                               }
+                               return MATCH;
+                       }
+                       while (1) {
+                               if (t_ch == '\0')
+                                       break;
+                               if ((matched = dowild(p, text,  force_lower_case)) != NOMATCH) {
+                                       if (!match_slash || matched != ABORT_TO_STARSTAR)
+                                               return matched;
+                               } else if (!match_slash && t_ch == '/')
+                                       return ABORT_TO_STARSTAR;
+                               t_ch = *++text;
+                       }
+                       return ABORT_ALL;
+               case '[':
+                       p_ch = *++p;
+#ifdef NEGATE_CLASS2
+                       if (p_ch == NEGATE_CLASS2)
+                               p_ch = NEGATE_CLASS;
+#endif
+                       /* Assign literal TRUE/FALSE because of "matched" comparison. */
+                       negated = p_ch == NEGATE_CLASS? TRUE : FALSE;
+                       if (negated) {
+                               /* Inverted character class. */
+                               p_ch = *++p;
+                       }
+                       prev_ch = 0;
+                       matched = FALSE;
+                       do {
+                               if (!p_ch)
+                                       return ABORT_ALL;
+                               if (p_ch == '\\') {
+                                       p_ch = *++p;
+                                       if (!p_ch)
+                                               return ABORT_ALL;
+                                       if (t_ch == p_ch)
+                                               matched = TRUE;
+                               } else if (p_ch == '-' && prev_ch && p[1] && p[1] != ']') {
+                                       p_ch = *++p;
+                                       if (p_ch == '\\') {
+                                               p_ch = *++p;
+                                               if (!p_ch)
+                                                       return ABORT_ALL;
+                                       }
+                                       if (t_ch <= p_ch && t_ch >= prev_ch)
+                                               matched = TRUE;
+                                       p_ch = 0; /* This makes "prev_ch" get set to 0. */
+                               } else if (p_ch == '[' && p[1] == ':') {
+                                       const uchar *s;
+                                       int i;
+                                       for (s = p += 2; (p_ch = *p) && p_ch != ']'; p++) {} /*SHARED ITERATOR*/
+                                       if (!p_ch)
+                                               return ABORT_ALL;
+                                       i = p - s - 1;
+                                       if (i < 0 || p[-1] != ':') {
+                                               /* Didn't find ":]", so treat like a normal set. */
+                                               p = s - 2;
+                                               p_ch = '[';
+                                               if (t_ch == p_ch)
+                                                       matched = TRUE;
+                                               continue;
+                                       }
+                                       if (CC_EQ(s,i, "alnum")) {
+                                               if (ISALNUM(t_ch))
+                                                       matched = TRUE;
+                                       } else if (CC_EQ(s,i, "alpha")) {
+                                               if (ISALPHA(t_ch))
+                                                       matched = TRUE;
+                                       } else if (CC_EQ(s,i, "blank")) {
+                                               if (ISBLANK(t_ch))
+                                                       matched = TRUE;
+                                       } else if (CC_EQ(s,i, "cntrl")) {
+                                               if (ISCNTRL(t_ch))
+                                                       matched = TRUE;
+                                       } else if (CC_EQ(s,i, "digit")) {
+                                               if (ISDIGIT(t_ch))
+                                                       matched = TRUE;
+                                       } else if (CC_EQ(s,i, "graph")) {
+                                               if (ISGRAPH(t_ch))
+                                                       matched = TRUE;
+                                       } else if (CC_EQ(s,i, "lower")) {
+                                               if (ISLOWER(t_ch))
+                                                       matched = TRUE;
+                                       } else if (CC_EQ(s,i, "print")) {
+                                               if (ISPRINT(t_ch))
+                                                       matched = TRUE;
+                                       } else if (CC_EQ(s,i, "punct")) {
+                                               if (ISPUNCT(t_ch))
+                                                       matched = TRUE;
+                                       } else if (CC_EQ(s,i, "space")) {
+                                               if (ISSPACE(t_ch))
+                                                       matched = TRUE;
+                                       } else if (CC_EQ(s,i, "upper")) {
+                                               if (ISUPPER(t_ch))
+                                                       matched = TRUE;
+                                       } else if (CC_EQ(s,i, "xdigit")) {
+                                               if (ISXDIGIT(t_ch))
+                                                       matched = TRUE;
+                                       } else /* malformed [:class:] string */
+                                               return ABORT_ALL;
+                                       p_ch = 0; /* This makes "prev_ch" get set to 0. */
+                               } else if (t_ch == p_ch)
+                                       matched = TRUE;
+                       } while (prev_ch = p_ch, (p_ch = *++p) != ']');
+                       if (matched == negated || t_ch == '/')
+                               return NOMATCH;
+                       continue;
+               }
+       }
+
+       return *text ? NOMATCH : MATCH;
+}
+
+/* Match the "pattern" against the "text" string. */
+int wildmatch(const char *pattern, const char *text, int flags)
+{
+       return dowild((const uchar*)pattern, (const uchar*)text,
+                     flags & FNM_CASEFOLD ? 1 :0);
+}
diff --git a/wildmatch.h b/wildmatch.h
new file mode 100644 (file)
index 0000000..984a38c
--- /dev/null
@@ -0,0 +1,9 @@
+/* wildmatch.h */
+
+#define ABORT_MALFORMED 2
+#define NOMATCH 1
+#define MATCH 0
+#define ABORT_ALL -1
+#define ABORT_TO_STARSTAR -2
+
+int wildmatch(const char *pattern, const char *text, int flags);
index 68739aaa3b9e9e1a1bbbd43c75c9b5c244fb6c3e..bac59d2c41bae7441038b30728c696b6280f4c2d 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -229,7 +229,7 @@ int xmkstemp(char *template)
                int saved_errno = errno;
                const char *nonrelative_template;
 
-               if (!template[0])
+               if (strlen(template) != strlen(origtemplate))
                        template = origtemplate;
 
                nonrelative_template = absolute_path(template);
@@ -411,11 +411,19 @@ void warn_on_inaccessible(const char *path)
 int access_or_warn(const char *path, int mode)
 {
        int ret = access(path, mode);
-       if (ret && errno != ENOENT)
+       if (ret && errno != ENOENT && errno != ENOTDIR)
                warn_on_inaccessible(path);
        return ret;
 }
 
+int access_or_die(const char *path, int mode)
+{
+       int ret = access(path, mode);
+       if (ret && errno != ENOENT && errno != ENOTDIR)
+               die_errno(_("unable to access '%s'"), path);
+       return ret;
+}
+
 struct passwd *xgetpwuid_self(void)
 {
        struct passwd *pw;
index 2a9658bad4c5035893e9363b51985f285dd3b34c..d7cfe8f31cd3d2b4b8bdc18c5da2449255b0531b 100644 (file)
@@ -516,7 +516,9 @@ static void wt_status_collect_untracked(struct wt_status *s)
 
        if (s->show_ignored_files) {
                dir.nr = 0;
-               dir.flags = DIR_SHOW_IGNORED | DIR_SHOW_OTHER_DIRECTORIES;
+               dir.flags = DIR_SHOW_IGNORED;
+               if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)
+                       dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;
                fill_directory(&dir, s->pathspec);
                for (i = 0; i < dir.nr; i++) {
                        struct dir_entry *ent = dir.entries[i];