aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Documentation/RelNotes-1.7.1.1.txt46
-rw-r--r--Documentation/RelNotes-1.7.2.txt89
-rw-r--r--Documentation/SubmittingPatches89
-rw-r--r--Documentation/blame-options.txt10
-rw-r--r--Documentation/config.txt49
-rw-r--r--Documentation/diff-options.txt48
-rw-r--r--Documentation/git-add.txt6
-rw-r--r--Documentation/git-checkout.txt24
-rw-r--r--Documentation/git-commit.txt9
-rw-r--r--Documentation/git-cvsserver.txt37
-rw-r--r--Documentation/git-for-each-ref.txt1
-rw-r--r--Documentation/git-gc.txt10
-rw-r--r--Documentation/git-instaweb.txt2
-rw-r--r--Documentation/git-log.txt44
-rw-r--r--Documentation/git-mailinfo.txt8
-rw-r--r--Documentation/git-merge.txt7
-rw-r--r--Documentation/git-notes.txt186
-rw-r--r--Documentation/git-rebase.txt5
-rw-r--r--Documentation/git-remote.txt21
-rw-r--r--Documentation/git-shortlog.txt15
-rw-r--r--Documentation/git-status.txt10
-rw-r--r--Documentation/git-submodule.txt6
-rw-r--r--Documentation/git-update-index.txt2
-rw-r--r--Documentation/git.txt17
-rw-r--r--Documentation/gitattributes.txt2
-rw-r--r--Documentation/gitdiffcore.txt4
-rw-r--r--Documentation/gitignore.txt14
-rw-r--r--Documentation/pretty-formats.txt11
-rw-r--r--Documentation/pretty-options.txt5
-rw-r--r--Makefile71
-rw-r--r--builtin.h1
-rw-r--r--builtin/blame.c4
-rw-r--r--builtin/checkout.c15
-rw-r--r--builtin/clone.c19
-rw-r--r--builtin/commit.c34
-rw-r--r--builtin/config.c6
-rw-r--r--builtin/describe.c49
-rw-r--r--builtin/fmt-merge-msg.c76
-rw-r--r--builtin/for-each-ref.c7
-rw-r--r--builtin/grep.c10
-rw-r--r--builtin/index-pack.c89
-rw-r--r--builtin/ls-remote.c10
-rw-r--r--builtin/merge-file.c2
-rw-r--r--builtin/merge-tree.c2
-rw-r--r--builtin/merge.c20
-rw-r--r--builtin/notes.c15
-rw-r--r--builtin/pack-objects.c15
-rw-r--r--builtin/patch-id.c107
-rw-r--r--builtin/receive-pack.c128
-rw-r--r--builtin/reflog.c69
-rw-r--r--builtin/remote.c123
-rw-r--r--builtin/rerere.c2
-rw-r--r--builtin/shortlog.c3
-rw-r--r--builtin/show-branch.c3
-rw-r--r--cache.h6
-rw-r--r--color.c28
-rw-r--r--color.h1
-rw-r--r--combine-diff.c2
-rw-r--r--compat/mingw.c17
-rw-r--r--compat/mingw.h5
-rw-r--r--compat/win32/pthread.h8
-rw-r--r--compat/win32mmap.c6
-rw-r--r--config.c60
-rw-r--r--config.mak.in1
-rw-r--r--configure.ac6
-rw-r--r--connect.c8
-rwxr-xr-xcontrib/completion/git-completion.bash1
-rwxr-xr-xcontrib/examples/git-fetch.sh4
-rwxr-xr-xcontrib/git-resurrect.sh1
-rwxr-xr-xcontrib/hooks/post-receive-email7
-rw-r--r--convert.c28
-rw-r--r--date.c3
-rw-r--r--diff-no-index.c6
-rw-r--r--diff.c233
-rw-r--r--diff.h10
-rw-r--r--diffcore-break.c6
-rw-r--r--diffcore-pickaxe.c3
-rw-r--r--diffcore-rename.c3
-rw-r--r--diffcore.h7
-rw-r--r--dir.c9
-rw-r--r--exec_cmd.c2
-rw-r--r--fast-import.c2
-rw-r--r--fsck.c45
-rwxr-xr-xgit-add--interactive.perl6
-rwxr-xr-xgit-am.sh2
-rw-r--r--git-compat-util.h12
-rwxr-xr-xgit-cvsserver.perl94
-rwxr-xr-xgit-instaweb.sh251
-rwxr-xr-xgit-pull.sh7
-rw-r--r--git-remote-testgit.py235
-rwxr-xr-xgit-request-pull.sh1
-rwxr-xr-xgit-stash.sh2
-rwxr-xr-xgit-submodule.sh2
-rwxr-xr-xgit-svn.perl7
-rw-r--r--git.c9
-rw-r--r--git_remote_helpers/git/exporter.py51
-rw-r--r--git_remote_helpers/git/importer.py38
-rw-r--r--git_remote_helpers/git/non_local.py61
-rw-r--r--git_remote_helpers/git/repo.py70
-rw-r--r--gitweb/INSTALL33
-rw-r--r--gitweb/Makefile60
-rw-r--r--gitweb/README14
-rwxr-xr-xgitweb/gitweb.perl155
-rw-r--r--gitweb/static/git-favicon.png (renamed from gitweb/git-favicon.png)bin115 -> 115 bytes
-rw-r--r--gitweb/static/git-logo.png (renamed from gitweb/git-logo.png)bin207 -> 207 bytes
-rw-r--r--gitweb/static/gitweb.css (renamed from gitweb/gitweb.css)18
-rw-r--r--gitweb/static/gitweb.js (renamed from gitweb/gitweb.js)0
-rw-r--r--grep.c98
-rw-r--r--grep.h2
-rw-r--r--http-backend.c59
-rw-r--r--http-walker.c2
-rw-r--r--http.c135
-rw-r--r--http.h2
-rw-r--r--merge-file.c2
-rw-r--r--notes.c7
-rw-r--r--notes.h5
-rw-r--r--object.c4
-rw-r--r--pack-check.c15
-rw-r--r--pack.h1
-rw-r--r--pretty.c161
-rw-r--r--remote.c4
-rw-r--r--run-command.c2
-rw-r--r--setup.c35
-rw-r--r--sha1_file.c49
-rw-r--r--shortlog.h1
-rw-r--r--t/README6
-rw-r--r--t/gitweb-lib.sh6
-rw-r--r--t/lib-t6000.sh (renamed from t/t6000lib.sh)0
-rwxr-xr-xt/t0021-conversion.sh16
-rwxr-xr-xt/t1300-repo-config.sh8
-rwxr-xr-xt/t1450-fsck.sh36
-rwxr-xr-xt/t1501-worktree.sh12
-rwxr-xr-xt/t2007-checkout-symlink.sh6
-rwxr-xr-xt/t2017-checkout-orphan.sh90
-rwxr-xr-xt/t2106-update-index-assume-unchanged.sh24
-rwxr-xr-xt/t3030-merge-recursive.sh29
-rwxr-xr-xt/t3306-notes-prune.sh48
-rwxr-xr-xt/t3307-notes-man.sh38
-rwxr-xr-xt/t3903-stash.sh150
-rwxr-xr-xt/t4034-diff-words.sh122
-rwxr-xr-xt/t4201-shortlog.sh116
-rwxr-xr-xt/t4204-patch-id.sh28
-rwxr-xr-xt/t4205-log-pretty-formats.sh74
-rwxr-xr-xt/t4206-log-follow-harder-copies.sh56
-rwxr-xr-xt/t5150-request-pull.sh228
-rwxr-xr-xt/t5505-remote.sh151
-rwxr-xr-xt/t5512-ls-remote.sh24
-rwxr-xr-xt/t5516-fetch-push.sh120
-rwxr-xr-xt/t5550-http-fetch.sh37
-rwxr-xr-xt/t5601-clone.sh12
-rwxr-xr-xt/t5704-bundle.sh16
-rwxr-xr-xt/t5705-clone-2gb.sh12
-rwxr-xr-xt/t5800-remote-helpers.sh76
-rwxr-xr-xt/t6002-rev-list-bisect.sh2
-rwxr-xr-xt/t6003-rev-list-topo-order.sh2
-rwxr-xr-xt/t6006-rev-list-format.sh31
-rwxr-xr-xt/t6101-rev-parse-parents.sh2
-rwxr-xr-xt/t6120-describe.sh8
-rwxr-xr-xt/t6300-for-each-ref.sh9
-rwxr-xr-xt/t7006-pager.sh149
-rwxr-xr-xt/t7008-grep-binary.sh102
-rwxr-xr-xt/t7400-submodule-basic.sh331
-rwxr-xr-xt/t7407-submodule-foreach.sh10
-rwxr-xr-xt/t7502-commit.sh2
-rwxr-xr-xt/t7508-status.sh92
-rwxr-xr-xt/t7509-commit.sh46
-rwxr-xr-xt/t7604-merge-custom-message.sh24
-rwxr-xr-xt/t7700-repack.sh9
-rwxr-xr-xt/t7701-repack-unpack-unreachable.sh13
-rwxr-xr-xt/t9400-git-cvsserver-server.sh16
-rwxr-xr-xt/t9500-gitweb-standalone-no-errors.sh29
-rw-r--r--t/test-lib.sh19
-rw-r--r--tag.c71
-rw-r--r--tag.h2
-rw-r--r--thread-utils.c16
-rw-r--r--thread-utils.h1
-rw-r--r--trace.c6
-rw-r--r--transport-helper.c137
-rw-r--r--transport.c51
-rw-r--r--tree-diff.c2
-rw-r--r--unpack-trees.c2
-rw-r--r--url.c118
-rw-r--r--url.h10
-rw-r--r--userdiff.c4
-rw-r--r--wrapper.c22
-rw-r--r--wt-status.c152
-rw-r--r--wt-status.h9
188 files changed, 5728 insertions, 1200 deletions
diff --git a/.gitignore b/.gitignore
index dbf1b90c6..14e2b6bde 100644
--- a/.gitignore
+++ b/.gitignore
@@ -112,6 +112,7 @@
/git-remote-https
/git-remote-ftp
/git-remote-ftps
+/git-remote-testgit
/git-repack
/git-replace
/git-repo-config
diff --git a/Documentation/RelNotes-1.7.1.1.txt b/Documentation/RelNotes-1.7.1.1.txt
new file mode 100644
index 000000000..2eef0380e
--- /dev/null
+++ b/Documentation/RelNotes-1.7.1.1.txt
@@ -0,0 +1,46 @@
+Git v1.7.1.1 Release Notes (draft)
+==================================
+
+Fixes since v1.7.1
+------------------
+
+ * Authentication over http transport can now be made lazily, in that the
+ request can first go to a URL without username, get a 401 response and
+ then the client will ask for the username to use.
+
+ * We used to mistakenly think "../work" is a subdirectory of the current
+ directory when we are in "../work-xyz".
+
+ * The attribute mechanism now allows an entry that uses an attribute
+ macro that set/unset one attribute, immediately followed by an
+ overriding setting; this makes attribute macros much easier to use.
+
+ * "git am -3" did not show diagnosis when the patch in the message was corrupt.
+
+ * "git bundle --stdin" segfaulted.
+
+ * "git describe" did not tie-break tags that point at the same commit
+ correctly; newer ones are preferred by paying attention to the
+ tagger date now.
+
+ * "git fetch" over HTTP verifies the downloaded packfiles more robustly.
+
+ * The memory usage by "git index-pack" (run during "git fetch" and "git
+ push") got leaner.
+
+ * "GIT_DIR=foo.git git init --bare bar.git" created foo.git instead of bar.git.
+
+ * "git log --abbrev=$num --format='%h' ignored --abbrev=$num.
+
+ * "git send-email" lacked a way to specify the domainname used in the
+ EHLO/HELO exchange, causing rejected connection from picky servers.
+ It learned --smtp-domain option to solve this issue.
+
+ * "git stash" incorrectly lost paths in the working tree that were
+ previously removed from the index.
+
+ * "git status" stopped refreshing the index by mistake in 1.7.1.
+
+ * "git status" showed excess "hints" even when advice.statusHints is set to false.
+
+And other minor fixes and documentation updates.
diff --git a/Documentation/RelNotes-1.7.2.txt b/Documentation/RelNotes-1.7.2.txt
index 37781b4f1..1df22be12 100644
--- a/Documentation/RelNotes-1.7.2.txt
+++ b/Documentation/RelNotes-1.7.2.txt
@@ -4,37 +4,104 @@ Git v1.7.2 Release Notes (draft)
Updates since v1.7.1
--------------------
+ * The whitespace rules used in "git apply --whitespace" and "git diff"
+ gained a new member in the family (tab-in-indent) to help projects with
+ policy to indent only with spaces.
+
+ * When working from a subdirectory, by default, git does not look for its
+ metadirectory ".git" across filesystems, primarily to help people who
+ have invocations of git in their custom PS1 prompts, as being outside
+ of a git repository would look for ".git" all the way up to the root
+ directory, and NFS mounts are often slow. DISCOVERY_ACROSS_FILESYSTEM
+ environment variable can be used to tell git not to stop at a
+ filesystem boundary.
+
+ * "git" wrapper learned "-c name=value" option to override configuration
+ variable from the command line.
+
* After "git apply --whitespace=fix" removed trailing blank lines in an
patch in a patch series, it failed to apply later patches that depend
on the presense of such blank lines.
+ * "git checkout --orphan newbranch" is similar to "-b newbranch" but
+ prepares to create a root commit that is not connected to any existing
+ commit.
+
+ * "git commit --amend" on a commit with an invalid author-name line that
+ lacks the display name didn't work (fb7749e4).
+
+ * "git cvsserver" can be told to use pserver; its password file can be
+ stored outside the repository.
+
* The output from the textconv filter used by "git diff" can be cached to
speed up their reuse.
- * "git send-email" learned --smtp-domain option to specify the domainname
- used in the EHLO/HELO exchange.
+ * "git diff --color" did not paint extended diff headers per line
+ (i.e. the coloring escape sequence didn't end at the end of line),
+ which confused "less -R".
+
+ * "git diff --word-diff=<mode>" extends the existing "--color-words"
+ option, making it more useful in color-challenged environments.
+
+ * The regexp to detect function headers used by "git diff" for PHP has
+ been enhanced for visibility modifiers (public, protected, etc.) to
+ better support PHP5.
+
+ * "git for-each-ref" learned "%(objectname:short)" that gives the object
+ name abbreviated.
+
+ * Various options to "git grep" (e.g. --count, --name-only) work better
+ with binary files.
+
+ * "git log --follow <path>" follows across copies (it used to only follow
+ renames). This may make the processing more expensive.
+
+ * "git notes prune" learned "-n" (dry-run) and "-v" options, similar to
+ what "git prune" has.
+
+ * "git patch-id" can be fed a mbox without getting confused by the
+ signature line in the format-patch output.
* "git revert" learned --strategy option to specify the merge strategy.
- * The whitespace rules used in "git apply --whitespace" and "git diff"
- gained a new member in the family (tab-in-indent) to help projects with
- policy to indent only with spaces.
+ * "git status [-s] --ignored" can be used to list ignored paths.
- * Authentication over http transport can now be made lazily, in that the
- request can first go to a URL without username, get a 401 response and
- then the client will ask for the username to use.
+ * Various "gitweb" enhancements and clean-ups, including syntax
+ highlighting.
Fixes since v1.7.1
------------------
- * In 1.7.1, "git status" stopped refreshing the index by mistake.
-
All of the fixes in v1.7.1.X maintenance series are included in this
release, unless otherwise noted.
+ * We didn't recognize timezone "Z" as a synonym for "UTC" (75b37e70).
+
+ * "git checkout" and "git rebase" overwrote paths that are marked "assume
+ unchanged" (aecda37c).
+
+ * "git clone/fetch/pull" issued an incorrect error message when a ref and
+ a symref that points to the ref were updated at the same time. This
+ obviously would update them to the same value, and should not result in
+ an error condition (7223dcaf).
+
+ * "git clone" did not configure remote.origin.url correctly for bare
+ clones (df61c889).
+
+ * "git diff" used to tell underlying xdiff machinery to work very hard to
+ minimize the output, but this often was spending too many extra cycles
+ for very little gain (582aa00).
+
+ * "git pull" accepted "--dry-run", gave it to underlying "git fetch" but
+ ignored the option itself, resulting in a bogus attempt to merge
+ unrelated commit (29609e68).
+
+ * "git reset --hard" started from a wrong directory and a working tree in
+ a nonstandard location is in use got confused (560fb6a1).
+
--
exec >/var/tmp/1
-O=v1.7.1-77-gb751157
+O=v1.7.1-336-g0925c02
echo O=$(git describe master)
git shortlog --no-merges master ^maint ^$O
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches
index abc65de94..eb53e0636 100644
--- a/Documentation/SubmittingPatches
+++ b/Documentation/SubmittingPatches
@@ -41,6 +41,7 @@ Checklist (and a short version for the impatient):
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:
@@ -53,6 +54,34 @@ 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.
+(0) Decide what to base your work on.
+
+In general, always base your work on the oldest branch that your
+change is relevant to.
+
+ - A bugfix should be based on 'maint' in general. If the bug is not
+ present in 'maint', base it on 'master'. For a bug that's not yet
+ in 'master', find the topic that introduces the regression, and
+ base your work on the tip of the topic.
+
+ - A new feature should be based on 'master' in general. If the new
+ feature depends on a topic that is in 'pu', but not in 'master',
+ base your work on the tip of that topic.
+
+ - Corrections and enhancements to a topic not yet in 'master' should
+ be based on the tip of that topic. If the topic has not been merged
+ to 'next', it's alright to add a note to squash minor corrections
+ into the series.
+
+ - In the exceptional case that a new feature depends on several topics
+ not in 'master', start working on 'next' or 'pu' privately and send
+ out patches for discussion. Before the final merge, you may have to
+ wait until some of the dependent topics graduate to 'master', and
+ rebase your work.
+
+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.
(1) Make separate commits for logically separate changes.
@@ -170,17 +199,16 @@ 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.
-Note that your maintainer does not necessarily read everything
-on the git mailing list. If your patch is for discussion first,
-send it "To:" the mailing list, and optionally "cc:" him. If it
-is trivially correct or after the list reached a consensus, send
-it "To:" the maintainer and optionally "cc:" the list for
-inclusion.
-
-Also note that your maintainer does not actively involve himself in
-maintaining what are in contrib/ hierarchy. When you send fixes and
-enhancements to them, do not forget to "cc: " the person who primarily
-worked on that hierarchy in contrib/.
+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
+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.
(4) Sign your work
@@ -519,9 +547,27 @@ Gmail
GMail does not appear to have any way to turn off line wrapping in the web
interface, so this will mangle any emails that you send. You can however
-use any IMAP email client to connect to the google imap server, and forward
+use "git send-email" and send your patches through the GMail SMTP server, or
+use any IMAP email client to connect to the google IMAP server and forward
the emails through that.
+To use "git send-email" and send your patches through the GMail SMTP server,
+edit ~/.gitconfig to specify your account settings:
+
+[sendemail]
+ smtpencryption = tls
+ smtpserver = smtp.gmail.com
+ smtpuser = user@gmail.com
+ smtppass = p4ssw0rd
+ smtpserverport = 587
+
+Once your commits are ready to be sent to the mailing list, run the
+following commands:
+
+ $ git format-patch --cover-letter -M origin/master -o outgoing/
+ $ edit outgoing/0000-*
+ $ git send-email outgoing/*
+
To submit using the IMAP interface, first, edit your ~/.gitconfig to specify your
account settings:
@@ -537,8 +583,7 @@ You might need to instead use: folder = "[Google Mail]/Drafts" if you get an err
that the "Folder doesn't exist".
Once your commits are ready to be sent to the mailing list, run the
-following command to send the patch emails to your Gmail Drafts
-folder.
+following commands:
$ git format-patch --cover-letter -M --stdout origin/master | git imap-send
@@ -546,19 +591,3 @@ Just make sure to disable line wrapping in the email client (GMail web
interface will line wrap no matter what, so you need to use a real
IMAP client).
-Alternatively, you can use "git send-email" and send your patches
-through the GMail SMTP server. edit ~/.gitconfig to specify your
-account settings:
-
-[sendemail]
- smtpencryption = tls
- smtpserver = smtp.gmail.com
- smtpuser = user@gmail.com
- smtppass = p4ssw0rd
- smtpserverport = 587
-
-Once your commits are ready to be sent to the mailing list, run the
-following commands:
-
- $ git format-patch --cover-letter -M origin/master -o outgoing/
- $ git send-email outgoing/*
diff --git a/Documentation/blame-options.txt b/Documentation/blame-options.txt
index d8205691c..16e3c6857 100644
--- a/Documentation/blame-options.txt
+++ b/Documentation/blame-options.txt
@@ -90,9 +90,9 @@ of lines before or after the line given by <start>.
running extra passes of inspection.
+
<num> is optional but it is the lower bound on the number of
-alphanumeric characters that git must detect as moving
+alphanumeric characters that git must detect as moving/copying
within a file for it to associate those lines with the parent
-commit.
+commit. The default value is 20.
-C|<num>|::
In addition to `-M`, detect lines moved or copied from other
@@ -105,9 +105,11 @@ commit.
looks for copies from other files in any commit.
+
<num> is optional but it is the lower bound on the number of
-alphanumeric characters that git must detect as moving
+alphanumeric characters that git must detect as moving/copying
between files for it to associate those lines with the parent
-commit.
+commit. And the default value is 40. If there are more than one
+`-C` options given, the <num> argument of the last `-C` will
+take effect.
-h::
--help::
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 93ab49772..7afd0a333 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -520,18 +520,12 @@ check that makes sure that existing object files will not get overwritten.
core.notesRef::
When showing commit messages, also show notes which are stored in
- the given ref. This ref is expected to contain files named
- after the full SHA-1 of the commit they annotate. The ref
- must be fully qualified.
+ the given ref. The ref must be fully qualified. If the given
+ ref does not exist, it is not an error but means that no
+ notes should be printed.
+
-If such a file exists in the given ref, the referenced blob is read, and
-appended to the commit message, separated by a "Notes (<refname>):"
-line (shortened to "Notes:" in the case of "refs/notes/commits"). If the
-given ref itself does not exist, it is not an error, but means that no
-notes should be printed.
-+
-This setting defaults to "refs/notes/commits", and can be overridden by
-the `GIT_NOTES_REF` environment variable.
+This setting defaults to "refs/notes/commits", and it can be overridden by
+the 'GIT_NOTES_REF' environment variable. See linkgit:git-notes[1].
core.sparseCheckout::
Enable "sparse checkout" feature. See section "Sparse checkout" in
@@ -948,13 +942,19 @@ gc.pruneexpire::
unreachable objects immediately.
gc.reflogexpire::
+gc.<pattern>.reflogexpire::
'git reflog expire' removes reflog entries older than
- this time; defaults to 90 days.
+ this time; defaults to 90 days. With "<pattern>" (e.g.
+ "refs/stash") in the middle the setting applies only to
+ the refs that match the <pattern>.
gc.reflogexpireunreachable::
+gc.<ref>.reflogexpireunreachable::
'git reflog expire' removes reflog entries older than
this time and are not reachable from the current tip;
- defaults to 30 days.
+ defaults to 30 days. With "<pattern>" (e.g. "refs/stash")
+ in the middle, the setting applies only to the refs that
+ match the <pattern>.
gc.rerereresolved::
Records of conflicted merge you resolved earlier are
@@ -1477,6 +1477,16 @@ pager.<cmd>::
it takes precedence over this option. To disable pagination for
all commands, set `core.pager` or `GIT_PAGER` to `cat`.
+pretty.<name>::
+ Alias for a --pretty= format string, as specified in
+ linkgit:git-log[1]. Any aliases defined here can be used just
+ as the built-in pretty formats could. For example,
+ running `git config pretty.changelog "format:{asterisk} %H %s"`
+ would cause the invocation `git log --pretty=changelog`
+ to be equivalent to running `git log "--pretty=format:{asterisk} %H %s"`.
+ Note that an alias with the same name as a built-in format
+ will be silently ignored.
+
pull.octopus::
The default merge strategy to use when pulling multiple branches
at once.
@@ -1527,7 +1537,7 @@ receive.denyDeletes::
the ref. Use this to prevent such a ref deletion via a push.
receive.denyCurrentBranch::
- If set to true or "refuse", receive-pack will deny a ref update
+ If set to true or "refuse", git-receive-pack will deny a ref update
to the currently checked out branch of a non-bare repository.
Such a push is potentially dangerous because it brings the HEAD
out of sync with the index and working tree. If set to "warn",
@@ -1589,7 +1599,9 @@ remote.<name>.uploadpack::
remote.<name>.tagopt::
Setting this value to \--no-tags disables automatic tag following when
- fetching from remote <name>
+ fetching from remote <name>. Setting it to \--tags will fetch every
+ tag from remote <name>, even if they are not reachable from remote
+ branch heads.
remote.<name>.vcs::
Setting this to a value <vcs> will cause git to interact with
@@ -1693,6 +1705,13 @@ If this variable is not specified, it defaults to 'normal'.
This variable can be overridden with the -u|--untracked-files option
of linkgit:git-status[1] and linkgit:git-commit[1].
+status.submodulesummary::
+ Defaults to false.
+ If this is set to a non zero number or true (identical to -1 or an
+ unlimited number), the submodule summary will be enabled and a
+ summary of commits for modified submodules will be shown (see
+ --summary-limit option of linkgit:git-submodule[1]).
+
tar.umask::
This variable can be used to restrict the permission bits of
tar archive entries. The default is 0002, which turns off the
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index c9c6c2b1c..e745a3ccd 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -21,6 +21,7 @@ endif::git-format-patch[]
ifndef::git-format-patch[]
-p::
-u::
+--patch::
Generate patch (see section on generating patches).
{git-diff? This is the default.}
endif::git-format-patch[]
@@ -126,11 +127,39 @@ any of those replacements occurred.
gives the default to color output.
Same as `--color=never`.
---color-words[=<regex>]::
- Show colored word diff, i.e., color words which have changed.
- By default, words are separated by whitespace.
+--word-diff[=<mode>]::
+ Show a word diff, using the <mode> to delimit changed words.
+ By default, words are delimited by whitespace; see
+ `--word-diff-regex` below. The <mode> defaults to 'plain', and
+ must be one of:
++
+--
+color::
+ Highlight changed words using only colors. Implies `--color`.
+plain::
+ Show words as `[-removed-]` and `{+added+}`. Makes no
+ attempts to escape the delimiters if they appear in the input,
+ so the output may be ambiguous.
+porcelain::
+ Use a special line-based format intended for script
+ consumption. Added/removed/unchanged runs are printed in the
+ usual unified diff format, starting with a `+`/`-`/` `
+ character at the beginning of the line and extending to the
+ end of the line. Newlines in the input are represented by a
+ tilde `~` on a line of its own.
+none::
+ Disable word diff again.
+--
+
-When a <regex> is specified, every non-overlapping match of the
+Note that despite the name of the first mode, color is used to
+highlight the changed parts in all modes if enabled.
+
+--word-diff-regex=<regex>::
+ Use <regex> to decide what a word is, instead of considering
+ runs of non-whitespace to be a word. Also implies
+ `--word-diff` unless it was already enabled.
++
+Every non-overlapping match of the
<regex> is considered a word. Anything between these matches is
considered whitespace and ignored(!) for the purposes of finding
differences. You may want to append `|[^[:space:]]` to your regular
@@ -142,6 +171,10 @@ The regex can also be set via a diff driver or configuration option, see
linkgit:gitattributes[1] or linkgit:git-config[1]. Giving it explicitly
overrides any diff driver or configuration setting. Diff drivers
override configuration settings.
+
+--color-words[=<regex>]::
+ Equivalent to `--word-diff=color` plus (if a regex was
+ specified) `--word-diff-regex=<regex>`.
endif::git-format-patch[]
--no-renames::
@@ -177,7 +210,14 @@ endif::git-format-patch[]
Break complete rewrite changes into pairs of delete and create.
-M::
+ifndef::git-log[]
Detect renames.
+endif::git-log[]
+ifdef::git-log[]
+ If generating diffs, detect and report renames for each commit.
+ For following files across renames while traversing history, see
+ `--follow`.
+endif::git-log[]
-C::
Detect copies as well as renames. See also `--find-copies-harder`.
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 51cbeb703..74741a42f 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -266,9 +266,9 @@ patch::
y - stage this hunk
n - do not stage this hunk
- q - quit, do not stage this hunk nor any of the remaining ones
- a - stage this and all the remaining hunks in the file
- d - do not stage this hunk nor any of the remaining hunks in the file
+ q - quit; do not stage this hunk nor any of the remaining ones
+ a - stage this hunk and all later hunks in the file
+ d - do not stage this hunk nor any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 37c1810e3..afda5c36b 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -9,7 +9,7 @@ SYNOPSIS
--------
[verse]
'git checkout' [-q] [-f] [-m] [<branch>]
-'git checkout' [-q] [-f] [-m] [-b <new_branch>] [<start_point>]
+'git checkout' [-q] [-f] [-m] [[-b|--orphan] <new_branch>] [<start_point>]
'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>...
'git checkout' --patch [<tree-ish>] [--] [<paths>...]
@@ -90,6 +90,24 @@ explicitly give a name with '-b' in such a case.
Create the new branch's reflog; see linkgit:git-branch[1] for
details.
+--orphan::
+ Create a new branch named <new_branch>, unparented to any other
+ branch. The new branch you switch to does not have any commit
+ and after the first one it will become the root of a new history
+ completely unconnected from all the other branches.
++
+When you use "--orphan", the index and the working tree are kept intact.
+This allows you to start a new history that records set of paths similar
+to that of the start-point commit, which is useful when you want to keep
+different branches for different audiences you are working to like when
+you have an open source and commercial versions of a software, for example.
++
+If you want to start a disconnected history that records set of paths
+totally different from the original branch, you may want to first clear
+the index and the working tree, by running "git rm -rf ." from the
+top-level of the working tree, before preparing your files (by copying
+from elsewhere, extracting a tarball, etc.) in the working tree.
+
-m::
--merge::
When switching branches,
@@ -136,6 +154,10 @@ edits from your current working tree.
As a special case, the `"@\{-N\}"` syntax for the N-th last branch
checks out the branch (instead of detaching). You may also specify
`-` which is synonymous with `"@\{-1\}"`.
++
+As a further special case, you may use `"A...B"` as a shortcut for the
+merge base of `A` and `B` if there is exactly one merge base. You can
+leave out at most one of `A` and `B`, in which case it defaults to `HEAD`.
<new_branch>::
Name for the new branch.
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 32c482f33..c28603ecf 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -95,10 +95,11 @@ OPTIONS
read the message from the standard input.
--author=<author>::
- Override the author name used in the commit. You can use the
- standard `A U Thor <author@example.com>` format. Otherwise,
- an existing commit that matches the given string and its author
- name is used.
+ Override the commit author. Specify an explicit author using the
+ standard `A U Thor <author@example.com>` format. Otherwise <author>
+ is assumed to be a pattern and is used to search for an existing
+ commit by that author (i.e. rev-list --all -i --author=<author>);
+ the commit author is then copied from the first such commit found.
--date=<date>::
Override the author date used in the commit.
diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt
index dbb053ee1..c27ca4350 100644
--- a/Documentation/git-cvsserver.txt
+++ b/Documentation/git-cvsserver.txt
@@ -72,9 +72,6 @@ plugin. Most functionality works fine with both of these clients.
LIMITATIONS
-----------
-Currently cvsserver works over SSH connections for read/write clients, and
-over pserver for anonymous CVS access.
-
CVS clients cannot tag, branch or perform GIT merges.
'git-cvsserver' maps GIT branches to CVS modules. This is very different
@@ -84,7 +81,7 @@ one or more directories.
INSTALLATION
------------
-1. If you are going to offer anonymous CVS access via pserver, add a line in
+1. If you are going to offer CVS access via pserver, add a line in
/etc/inetd.conf like
+
--
@@ -101,6 +98,38 @@ looks like
cvspserver stream tcp nowait nobody /usr/bin/git-cvsserver git-cvsserver pserver
------
+
+Only anonymous access is provided by pserve by default. To commit you
+will have to create pserver accounts, simply add a gitcvs.authdb
+setting in the config file of the repositories you want the cvsserver
+to allow writes to, for example:
+
+------
+
+ [gitcvs]
+ authdb = /etc/cvsserver/passwd
+
+------
+The format of these files is username followed by the crypted password,
+for example:
+
+------
+ myuser:$1Oyx5r9mdGZ2
+ myuser:$1$BA)@$vbnMJMDym7tA32AamXrm./
+------
+You can use the 'htpasswd' facility that comes with Apache to make these
+files, but Apache's MD5 crypt method differs from the one used by most C
+library's crypt() function, so don't use the -m option.
+
+Alternatively you can produce the password with perl's crypt() operator:
+-----
+ perl -e 'my ($user, $pass) = @ARGV; printf "%s:%s\n", $user, crypt($user, $pass)' $USER password
+-----
+
+Then provide your password via the pserver method, for example:
+------
+ cvs -d:pserver:someuser:somepassword <at> server/path/repo.git co <HEAD_name>
+------
No special setup is needed for SSH access, other than having GIT tools
in the PATH. If you have clients that do not accept the CVS_SERVER
environment variable, you can rename 'git-cvsserver' to `cvs`.
diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt
index 7e83288d1..390d85cca 100644
--- a/Documentation/git-for-each-ref.txt
+++ b/Documentation/git-for-each-ref.txt
@@ -86,6 +86,7 @@ objectsize::
objectname::
The object name (aka SHA-1).
+ For a non-ambiguous abbreviation of the object name append `:short`.
upstream::
The name of a local ref which can be considered ``upstream''
diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt
index 189573a3b..a9e0882e9 100644
--- a/Documentation/git-gc.txt
+++ b/Documentation/git-gc.txt
@@ -88,6 +88,16 @@ commits prior to the amend or rebase occurring. Since these changes
are not part of the current project most users will want to expire
them sooner. This option defaults to '30 days'.
+The above two configuration variables can be given to a pattern. For
+example, this sets non-default expiry values only to remote tracking
+branches:
+
+------------
+[gc "refs/remotes/*"]
+ reflogExpire = never
+ reflogexpireUnreachable = 3 days
+------------
+
The optional configuration variable 'gc.rerereresolved' indicates
how long records of conflicted merge you resolved earlier are
kept. This defaults to 60 days.
diff --git a/Documentation/git-instaweb.txt b/Documentation/git-instaweb.txt
index a1f17df07..2c3c4d299 100644
--- a/Documentation/git-instaweb.txt
+++ b/Documentation/git-instaweb.txt
@@ -29,7 +29,7 @@ OPTIONS
The HTTP daemon command-line that will be executed.
Command-line options may be specified here, and the
configuration file will be added at the end of the command-line.
- Currently apache2, lighttpd, mongoose and webrick are supported.
+ Currently apache2, lighttpd, mongoose, plackup and webrick are supported.
(Default: lighttpd)
-m::
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index 57aa57467..0e6ff3182 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -57,7 +57,7 @@ include::diff-options.txt[]
commits, and doesn't limit diff for those commits.
--follow::
- Continue listing the history of a file beyond renames.
+ Continue listing the history of a file beyond renames/copies.
--log-size::
Before the log message print out its size in bytes. Intended
@@ -133,6 +133,48 @@ Discussion
include::i18n.txt[]
+Configuration
+-------------
+
+See linkgit:git-config[1] for core variables and linkgit:git-diff[1]
+for settings related to diff generation.
+
+format.pretty::
+ Default for the `--format` option. (See "PRETTY FORMATS" above.)
+ Defaults to "medium".
+
+i18n.logOutputEncoding::
+ Encoding to use when displaying logs. (See "Discussion", above.)
+ Defaults to the value of `i18n.commitEncoding` if set, UTF-8
+ otherwise.
+
+log.date::
+ Default format for human-readable dates. (Compare the
+ `--date` option.) Defaults to "default", which means to write
+ dates like `Sat May 8 19:35:34 2010 -0500`.
+
+log.showroot::
+ If `false`, 'git log' and related commands will not treat the
+ initial commit as a big creation event. Any root commits in
+ `git log -p` output would be shown without a diff attached.
+ The default is `true`.
+
+mailmap.file::
+ See linkgit:git-shortlog[1].
+
+notes.displayRef::
+ Which refs, in addition to the default set by `core.notesRef`
+ or 'GIT_NOTES_REF', to read notes from when showing commit
+ messages with the 'log' family of commands. See
+ linkgit:git-notes[1].
++
+May be an unabbreviated ref name or a glob and may be specified
+multiple times. A warning will be issued for refs that do not exist,
+but a glob that does not match any refs is silently ignored.
++
+This setting can be disabled by the `--no-standard-notes` option,
+overridden by the 'GIT_NOTES_DISPLAY_REF' environment variable,
+and supplemented by the `--show-notes` option.
Author
------
diff --git a/Documentation/git-mailinfo.txt b/Documentation/git-mailinfo.txt
index e3d58cbac..3ea5aad56 100644
--- a/Documentation/git-mailinfo.txt
+++ b/Documentation/git-mailinfo.txt
@@ -40,16 +40,16 @@ OPTIONS
-u::
The commit log message, author name and author email are
taken from the e-mail, and after minimally decoding MIME
- transfer encoding, re-coded in UTF-8 by transliterating
+ transfer encoding, re-coded in the charset specified by
+ i18n.commitencoding (defaulting to UTF-8) by transliterating
them. This used to be optional but now it is the default.
+
Note that the patch is always used as-is without charset
conversion, even with this flag.
--encoding=<encoding>::
- Similar to -u but if the local convention is different
- from what is specified by i18n.commitencoding, this flag
- can be used to override it.
+ Similar to -u. But when re-coding, the charset specified here is
+ used instead of the one specified by i18n.commitencoding or UTF-8.
-n::
Disable all charset re-coding of the metadata.
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index c2325ef90..84043cc5b 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -58,7 +58,12 @@ include::merge-options.txt[]
-m <msg>::
Set the commit message to be used for the merge commit (in
- case one is created). The 'git fmt-merge-msg' command can be
+ case one is created).
+
+ If `--log` is specified, a shortlog of the commits being merged
+ will be appended to the specified message.
+
+ The 'git fmt-merge-msg' command can be
used to give a good default for automated 'git merge'
invocations.
diff --git a/Documentation/git-notes.txt b/Documentation/git-notes.txt
index 4e5113b83..5540af5d1 100644
--- a/Documentation/git-notes.txt
+++ b/Documentation/git-notes.txt
@@ -3,7 +3,7 @@ git-notes(1)
NAME
----
-git-notes - Add/inspect object notes
+git-notes - Add or inspect object notes
SYNOPSIS
--------
@@ -15,29 +15,31 @@ SYNOPSIS
'git notes' edit [<object>]
'git notes' show [<object>]
'git notes' remove [<object>]
-'git notes' prune
+'git notes' prune [-n | -v]
DESCRIPTION
-----------
-This command allows you to add/remove notes to/from objects, without
-changing the objects themselves.
+Adds, removes, or reads notes attached to objects, without touching
+the objects themselves.
-A typical use of notes is to extend a commit message without having
-to change the commit itself. Such commit notes can be shown by `git log`
-along with the original commit message. To discern these notes from the
+By default, notes are saved to and read from `refs/notes/commits`, but
+this default can be overridden. See the OPTIONS, CONFIGURATION, and
+ENVIRONMENT sections below. If this ref does not exist, it will be
+quietly created when it is first needed to store a note.
+
+A typical use of notes is to supplement a commit message without
+changing the commit itself. Notes can be shown by 'git log' along with
+the original commit message. To distinguish these notes from the
message stored in the commit object, the notes are indented like the
message, after an unindented line saying "Notes (<refname>):" (or
-"Notes:" for the default setting).
+"Notes:" for `refs/notes/commits`).
-This command always manipulates the notes specified in "core.notesRef"
-(see linkgit:git-config[1]), which can be overridden by GIT_NOTES_REF.
-To change which notes are shown by 'git-log', see the
-"notes.displayRef" configuration.
+To change which notes are shown by 'git log', see the
+"notes.displayRef" configuration in linkgit:git-log[1].
-See the description of "notes.rewrite.<command>" in
-linkgit:git-config[1] for a way of carrying your notes across commands
-that rewrite commits.
+See the "notes.rewrite.<command>" configuration for a way to carry
+notes across commands that rewrite commits.
SUBCOMMANDS
@@ -101,15 +103,20 @@ OPTIONS
Use the given note message (instead of prompting).
If multiple `-m` options are given, their values
are concatenated as separate paragraphs.
+ Lines starting with `#` and empty lines other than a
+ single line between paragraphs will be stripped out.
-F <file>::
--file=<file>::
Take the note message from the given file. Use '-' to
read the note message from the standard input.
+ Lines starting with `#` and empty lines other than a
+ single line between paragraphs will be stripped out.
-C <object>::
--reuse-message=<object>::
- Reuse the note message from the given note object.
+ Take the note message from the given blob object (for
+ example, another note).
-c <object>::
--reedit-message=<object>::
@@ -117,22 +124,151 @@ OPTIONS
the user can further edit the note message.
--ref <ref>::
- Manipulate the notes tree in <ref>. This overrides both
- GIT_NOTES_REF and the "core.notesRef" configuration. The ref
+ Manipulate the notes tree in <ref>. This overrides
+ 'GIT_NOTES_REF' and the "core.notesRef" configuration. The ref
is taken to be in `refs/notes/` if it is not qualified.
+-n::
+ Do not remove anything; just report the object names whose notes
+ would be removed.
+
+-v::
+ Report all object names whose notes are removed.
+
+
+DISCUSSION
+----------
-NOTES
------
+Commit notes are blobs containing extra information about an object
+(usually information to supplement a commit's message). These blobs
+are taken from notes refs. A notes ref is usually a branch which
+contains "files" whose paths are the object names for the objects
+they describe, with some directory separators included for performance
+reasons footnote:[Permitted pathnames have the form
+'ab'`/`'cd'`/`'ef'`/`'...'`/`'abcdef...': a sequence of directory
+names of two hexadecimal digits each followed by a filename with the
+rest of the object ID.].
Every notes change creates a new commit at the specified notes ref.
You can therefore inspect the history of the notes by invoking, e.g.,
-`git log -p notes/commits`.
+`git log -p notes/commits`. Currently the commit message only records
+which operation triggered the update, and the commit authorship is
+determined according to the usual rules (see linkgit:git-commit[1]).
+These details may change in the future.
+
+It is also permitted for a notes ref to point directly to a tree
+object, in which case the history of the notes can be read with
+`git log -p -g <refname>`.
+
+
+EXAMPLES
+--------
+
+You can use notes to add annotations with information that was not
+available at the time a commit was written.
+
+------------
+$ git notes add -m 'Tested-by: Johannes Sixt <j6t@kdbg.org>' 72a144e2
+$ git show -s 72a144e
+[...]
+ Signed-off-by: Junio C Hamano <gitster@pobox.com>
+
+Notes:
+ Tested-by: Johannes Sixt <j6t@kdbg.org>
+------------
+
+In principle, a note is a regular Git blob, and any kind of
+(non-)format is accepted. You can binary-safely create notes from
+arbitrary files using 'git hash-object':
+
+------------
+$ cc *.c
+$ blob=$(git hash-object -w a.out)
+$ git notes --ref=built add -C "$blob" HEAD
+------------
+
+Of course, it doesn't make much sense to display non-text-format notes
+with 'git log', so if you use such notes, you'll probably need to write
+some special-purpose tools to do something useful with them.
+
+
+CONFIGURATION
+-------------
-Currently the commit message only records which operation triggered
-the update, and the commit authorship is determined according to the
-usual rules (see linkgit:git-commit[1]). These details may change in
-the future.
+core.notesRef::
+ Notes ref to read and manipulate instead of
+ `refs/notes/commits`. Must be an unabbreviated ref name.
+ This setting can be overridden through the environment and
+ command line.
+
+notes.displayRef::
+ Which ref (or refs, if a glob or specified more than once), in
+ addition to the default set by `core.notesRef` or
+ 'GIT_NOTES_REF', to read notes from when showing commit
+ messages with the 'git log' family of commands.
+ This setting can be overridden on the command line or by the
+ 'GIT_NOTES_DISPLAY_REF' environment variable.
+ See linkgit:git-log[1].
+
+notes.rewrite.<command>::
+ When rewriting commits with <command> (currently `amend` or
+ `rebase`), if this variable is `false`, git will not copy
+ notes from the original to the rewritten commit. Defaults to
+ `true`. See also "`notes.rewriteRef`" below.
++
+This setting can be overridden by the 'GIT_NOTES_REWRITE_REF'
+environment variable.
+
+notes.rewriteMode::
+ When copying notes during a rewrite, what to do if the target
+ commit already has a note. Must be one of `overwrite`,
+ `concatenate`, and `ignore`. Defaults to `concatenate`.
++
+This setting can be overridden with the `GIT_NOTES_REWRITE_MODE`
+environment variable.
+
+notes.rewriteRef::
+ When copying notes during a rewrite, specifies the (fully
+ qualified) ref whose notes should be copied. May be a glob,
+ in which case notes in all matching refs will be copied. You
+ may also specify this configuration several times.
++
+Does not have a default value; you must configure this variable to
+enable note rewriting.
++
+Can be overridden with the 'GIT_NOTES_REWRITE_REF' environment variable.
+
+
+ENVIRONMENT
+-----------
+
+'GIT_NOTES_REF'::
+ Which ref to manipulate notes from, instead of `refs/notes/commits`.
+ This overrides the `core.notesRef` setting.
+
+'GIT_NOTES_DISPLAY_REF'::
+ Colon-delimited list of refs or globs indicating which refs,
+ in addition to the default from `core.notesRef` or
+ 'GIT_NOTES_REF', to read notes from when showing commit
+ messages.
+ This overrides the `notes.displayRef` setting.
++
+A warning will be issued for refs that do not exist, but a glob that
+does not match any refs is silently ignored.
+
+'GIT_NOTES_REWRITE_MODE'::
+ When copying notes during a rewrite, what to do if the target
+ commit already has a note.
+ Must be one of `overwrite`, `concatenate`, and `ignore`.
+ This overrides the `core.rewriteMode` setting.
+
+'GIT_NOTES_REWRITE_REF'::
+ When rewriting commits, which notes to copy from the original
+ to the rewritten commit. Must be a colon-delimited list of
+ refs or globs.
++
+If not set in the environment, the list of notes to copy depends
+on the `notes.rewrite.<command>` and `notes.rewriteRef` settings.
Author
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 0d07b1b20..50ba2e469 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -206,6 +206,10 @@ OPTIONS
--onto option is not specified, the starting point is
<upstream>. May be any valid commit, and not just an
existing branch name.
++
+As a special case, you may use "A...B" as a shortcut for the
+merge base of A and B if there is exactly one merge base. You can
+leave out at most one of A and B, in which case it defaults to HEAD.
<upstream>::
Upstream branch to compare against. May be any valid commit,
@@ -295,6 +299,7 @@ link:howto/revert-a-faulty-merge.txt[revert-a-faulty-merge How-To] for details).
--ignore-date::
These flags are passed to 'git am' to easily change the dates
of the rebased commits (see linkgit:git-am[1]).
+ Incompatible with the --interactive option.
-i::
--interactive::
diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index 3fc599c0c..aa021b0cb 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -10,10 +10,11 @@ SYNOPSIS
--------
[verse]
'git remote' [-v | --verbose]
-'git remote add' [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>
+'git remote add' [-t <branch>] [-m <master>] [-f] [--tags|--no-tags] [--mirror] <name> <url>
'git remote rename' <old> <new>
'git remote rm' <name>
'git remote set-head' <name> (-a | -d | <branch>)
+'git remote set-branches' <name> [--add] <branch>...
'git remote set-url' [--push] <name> <newurl> [<oldurl>]
'git remote set-url --add' [--push] <name> <newurl>
'git remote set-url --delete' [--push] <name> <url>
@@ -51,6 +52,12 @@ update remote-tracking branches <name>/<branch>.
With `-f` option, `git fetch <name>` is run immediately after
the remote information is set up.
+
+With `--tags` option, `git fetch <name>` imports every tag from the
+remote repository.
++
+With `--no-tags` option, `git fetch <name>` does not import tags from
+the remote repository.
++
With `-t <branch>` option, instead of the default glob
refspec for the remote to track all branches under
`$GIT_DIR/remotes/<name>/`, a refspec to track only `<branch>`
@@ -104,6 +111,18 @@ remote set-head origin master" will set `$GIT_DIR/refs/remotes/origin/HEAD` to
`refs/remotes/origin/master` already exists; if not it must be fetched first.
+
+'set-branches'::
+
+Changes the list of branches tracked by the named remote.
+This can be used to track a subset of the available remote branches
+after the initial setup for a remote.
++
+The named branches will be interpreted as if specified with the
+`-t` option on the 'git remote add' command line.
++
+With `--add`, instead of replacing the list of currently tracked
+branches, adds to that list.
+
'set-url'::
Changes URL remote points to. Sets first URL remote points to matching
diff --git a/Documentation/git-shortlog.txt b/Documentation/git-shortlog.txt
index dfd4d0c22..bc1ac7749 100644
--- a/Documentation/git-shortlog.txt
+++ b/Documentation/git-shortlog.txt
@@ -9,7 +9,7 @@ SYNOPSIS
--------
[verse]
git log --pretty=short | 'git shortlog' [-h] [-n] [-s] [-e] [-w]
-'git shortlog' [-n|--numbered] [-s|--summary] [-e|--email] [-w[<width>[,<indent1>[,<indent2>]]]] [<committish>...]
+'git shortlog' [-n|--numbered] [-s|--summary] [-e|--email] [-w[<width>[,<indent1>[,<indent2>]]]] <commit>...
DESCRIPTION
-----------
@@ -19,6 +19,11 @@ the first line of the commit message will be shown.
Additionally, "[PATCH]" will be stripped from the commit description.
+If no revisions are passed on the command line and either standard input
+is not a terminal or there is no current branch, 'git shortlog' will
+output a summary of the log read from standard input, without
+reference to the current repository.
+
OPTIONS
-------
@@ -39,6 +44,14 @@ OPTIONS
--email::
Show the email address of each author.
+--format[='<format>']::
+ Instead of the commit subject, use some other information to
+ describe each commit. '<format>' can be any string accepted
+ by the `--format` option of 'git log', such as '{asterisk} [%h] %s'.
+ (See the "PRETTY FORMATS" section of linkgit:git-log[1].)
+
+ Each pretty-printed commit will be rewrapped before it is shown.
+
-w[<width>[,<indent1>[,<indent2>]]]::
Linewrap the output by wrapping each line at `width`. The first
line of each entry is indented by `indent1` spaces, and the second
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index 2d4bbfcaf..fd0fe7cb5 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -27,6 +27,10 @@ OPTIONS
--short::
Give the output in the short-format.
+-b::
+--branch::
+ Show the branch and tracking info even in short-format.
+
--porcelain::
Give the output in a stable, easy-to-parse format for scripts.
Currently this is identical to --short output, but is guaranteed
@@ -120,6 +124,10 @@ Ignored files are not listed.
? ? untracked
-------------------------------------------------
+If -b is used the short-format status is preceded by a line
+
+## branchname tracking info
+
There is an alternate -z format recommended for machine parsing. In
that format, the status field is the same, but some other things
change. First, the '->' is omitted from rename entries and the field
@@ -128,7 +136,7 @@ order is reversed (e.g 'from -> to' becomes 'to from'). Second, a NUL
and the terminating newline (but a space still separates the status
field from the first filename). Third, filenames containing special
characters are not specially formatted; no quoting or
-backslash-escaping is performed.
+backslash-escaping is performed. Fourth, there is no branch line.
CONFIGURATION
-------------
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 2502531a3..cdabfd29a 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -145,10 +145,12 @@ summary::
foreach::
Evaluates an arbitrary shell command in each checked out submodule.
- The command has access to the variables $name, $path and $sha1:
+ The command has access to the variables $name, $path, $sha1 and
+ $toplevel:
$name is the name of the relevant submodule section in .gitmodules,
$path is the name of the submodule directory relative to the
- superproject, and $sha1 is the commit as recorded in the superproject.
+ superproject, $sha1 is the commit as recorded in the superproject,
+ and $toplevel is the absolute path to the top-level of the superproject.
Any submodules defined in the superproject but not checked out are
ignored by this command. Unless given --quiet, foreach prints the name
of each submodule before evaluating the command.
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index 68dc1879f..765d4b312 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -93,8 +93,6 @@ OPTIONS
This option can be also used as a coarse file-level mechanism
to ignore uncommitted changes in tracked files (akin to what
`.gitignore` does for untracked files).
-You should remember that an explicit 'git add' operation will
-still cause the file to be refreshed from the working tree.
Git will fail (gracefully) in case it needs to modify this file
in the index e.g. when merging in a commit;
thus, in case the assumed-untracked file is changed upstream,
diff --git a/Documentation/git.txt b/Documentation/git.txt
index c4024d0ed..bec6348da 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -12,6 +12,7 @@ SYNOPSIS
'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]
[-p|--paginate|--no-pager] [--no-replace-objects]
[--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
+ [-c name=value]
[--help] COMMAND [ARGS]
DESCRIPTION
@@ -228,6 +229,12 @@ displayed. See linkgit:git-help[1] for more information,
because `git --help ...` is converted internally into `git
help ...`.
+-c <name>=<value>::
+ Pass a configuration parameter to the command. The value
+ given will override values from configuration files.
+ The <name> is expected in the same format as listed by
+ 'git config' (subkeys separated by dots).
+
--exec-path::
Path to wherever your core git programs are installed.
This can also be controlled by setting the GIT_EXEC_PATH
@@ -538,6 +545,16 @@ git so take care if using Cogito etc.
a GIT_DIR set on the command line or in the environment.
(Useful for excluding slow-loading network directories.)
+'GIT_DISCOVERY_ACROSS_FILESYSTEM'::
+ When run in a directory that does not have ".git" repository
+ directory, git tries to find such a directory in the parent
+ directories to find the top of the working tree, but by default it
+ does not cross filesystem boundaries. This environment variable
+ can be set to true to tell git not to stop at filesystem
+ boundaries. Like 'GIT_CEILING_DIRECTORIES', this will not affect
+ an explicit repository directory set via 'GIT_DIR' or on the
+ command line.
+
git Commits
~~~~~~~~~~~
'GIT_AUTHOR_NAME'::
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index a8500d177..0523a5769 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -360,7 +360,7 @@ patterns are available:
Customizing word diff
^^^^^^^^^^^^^^^^^^^^^
-You can customize the rules that `git diff --color-words` uses to
+You can customize the rules that `git diff --word-diff` uses to
split words in a line, by specifying an appropriate regular expression
in the "diff.*.wordRegex" configuration variable. For example, in TeX
a backslash followed by a sequence of letters forms a command, but
diff --git a/Documentation/gitdiffcore.txt b/Documentation/gitdiffcore.txt
index 9de8caf5d..5d91a7e5b 100644
--- a/Documentation/gitdiffcore.txt
+++ b/Documentation/gitdiffcore.txt
@@ -227,8 +227,8 @@ changes that touch a specified string, and is controlled by the
commands.
When diffcore-pickaxe is in use, it checks if there are
-filepairs whose "original" side has the specified string and
-whose "result" side does not. Such a filepair represents "the
+filepairs whose "result" side has the specified string and
+whose "origin" side does not. Such a filepair represents "the
string appeared in this changeset". It also checks for the
opposite case that loses the specified string.
diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
index 98c459dc8..e10fa88b8 100644
--- a/Documentation/gitignore.txt
+++ b/Documentation/gitignore.txt
@@ -83,16 +83,20 @@ Patterns have the following format:
- If the pattern does not contain a slash '/', git treats it as
a shell glob pattern and checks for a match against the
- pathname without leading directories.
+ pathname relative to the location of the `.gitignore` file
+ (relative to the toplevel of the work tree if not from a
+ `.gitignore` file).
- Otherwise, git treats the pattern as a shell glob suitable
for consumption by fnmatch(3) with the FNM_PATHNAME flag:
wildcards in the pattern will not match a / in the pathname.
For example, "Documentation/\*.html" matches
- "Documentation/git.html" but not
- "Documentation/ppc/ppc.html". A leading slash matches the
- beginning of the pathname; for example, "/*.c" matches
- "cat-file.c" but not "mozilla-sha1/sha1.c".
+ "Documentation/git.html" but not "Documentation/ppc/ppc.html"
+ or "tools/perf/Documentation/perf.html".
+
+ - A leading slash matches the beginning of the pathname.
+ For example, "/*.c" matches "cat-file.c" but not
+ "mozilla-sha1/sha1.c".
An example:
diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index bd760d3bd..8c68ce94f 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -11,7 +11,12 @@ have limited your view of history: for example, if you are
only interested in changes related to a certain directory or
file.
-Here are some additional details for each format:
+There are several built-in formats, and you can define
+additional formats by setting a pretty.<name>
+config option to either another format name, or a
+'format:' string, as described below (see
+linkgit:git-config[1]). Here are the details of the
+built-in formats:
* 'oneline'
@@ -76,9 +81,9 @@ displayed in full, regardless of whether --abbrev or
true parent commits, without taking grafts nor history
simplification into account.
-* 'format:'
+* 'format:<string>'
+
-The 'format:' format allows you to specify which information
+The 'format:<string>' format allows you to specify which information
you want to show. It works a little bit like printf format,
with the notable exception that you get a newline with '%n'
instead of '\n'.
diff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt
index af6d2b995..d78e121c7 100644
--- a/Documentation/pretty-options.txt
+++ b/Documentation/pretty-options.txt
@@ -3,8 +3,9 @@
Pretty-print the contents of the commit logs in a given format,
where '<format>' can be one of 'oneline', 'short', 'medium',
- 'full', 'fuller', 'email', 'raw' and 'format:<string>'.
- When omitted, the format defaults to 'medium'.
+ 'full', 'fuller', 'email', 'raw' and 'format:<string>'. See
+ the "PRETTY FORMATS" section for some additional details for each
+ format. When omitted, the format defaults to 'medium'.
+
Note: you can specify the default pretty format in the repository
configuration (see linkgit:git-config[1]).
diff --git a/Makefile b/Makefile
index 4f7224a59..0a8dff3a1 100644
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,9 @@ all::
# Define EXPATDIR=/foo/bar if your expat header and library files are in
# /foo/bar/include and /foo/bar/lib directories.
#
+# Define HAVE_PATHS_H if you have paths.h and want to use the default PATH
+# it specifies.
+#
# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
#
# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
@@ -269,6 +272,7 @@ mandir = share/man
infodir = share/info
gitexecdir = libexec/git-core
sharedir = $(prefix)/share
+gitwebdir = $(sharedir)/gitweb
template_dir = share/git-core/templates
htmldir = share/doc/git-doc
ifeq ($(prefix),/usr)
@@ -366,6 +370,8 @@ SCRIPT_PERL += git-relink.perl
SCRIPT_PERL += git-send-email.perl
SCRIPT_PERL += git-svn.perl
+SCRIPT_PYTHON += git-remote-testgit.py
+
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
$(patsubst %.perl,%,$(SCRIPT_PERL)) \
$(patsubst %.py,%,$(SCRIPT_PYTHON)) \
@@ -622,6 +628,7 @@ LIB_OBJS += tree-diff.o
LIB_OBJS += tree.o
LIB_OBJS += tree-walk.o
LIB_OBJS += unpack-trees.o
+LIB_OBJS += url.o
LIB_OBJS += usage.o
LIB_OBJS += userdiff.o
LIB_OBJS += utf8.o
@@ -737,10 +744,12 @@ EXTLIBS =
ifeq ($(uname_S),Linux)
NO_STRLCPY = YesPlease
NO_MKSTEMPS = YesPlease
+ HAVE_PATHS_H = YesPlease
endif
ifeq ($(uname_S),GNU/kFreeBSD)
NO_STRLCPY = YesPlease
NO_MKSTEMPS = YesPlease
+ HAVE_PATHS_H = YesPlease
endif
ifeq ($(uname_S),UnixWare)
CC = cc
@@ -869,6 +878,7 @@ ifeq ($(uname_S),FreeBSD)
NO_STRTOUMAX = YesPlease
endif
PYTHON_PATH = /usr/local/bin/python
+ HAVE_PATHS_H = YesPlease
endif
ifeq ($(uname_S),OpenBSD)
NO_STRCASESTR = YesPlease
@@ -877,6 +887,7 @@ ifeq ($(uname_S),OpenBSD)
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)
@@ -886,8 +897,10 @@ ifeq ($(uname_S),NetBSD)
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
@@ -906,6 +919,7 @@ ifeq ($(uname_S),GNU)
# GNU/Hurd
NO_STRLCPY=YesPlease
NO_MKSTEMPS = YesPlease
+ HAVE_PATHS_H = YesPlease
endif
ifeq ($(uname_S),IRIX)
NO_SETENV = YesPlease
@@ -1028,7 +1042,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))
NO_STRTOUMAX = YesPlease
NO_MKDTEMP = YesPlease
NO_MKSTEMPS = YesPlease
- SNPRINTF_RETURNS_BOGUS = YesPlease
NO_SVN_TESTS = YesPlease
NO_PERL_MAKEMAKER = YesPlease
RUNTIME_PREFIX = YesPlease
@@ -1065,6 +1078,7 @@ endif
-include config.mak
ifdef CHECK_HEADER_DEPENDENCIES
+COMPUTE_HEADER_DEPENDENCIES =
USE_COMPUTED_HEADER_DEPENDENCIES =
endif
@@ -1355,6 +1369,10 @@ else
LIB_OBJS += thread-utils.o
endif
+ifdef HAVE_PATHS_H
+ BASIC_CFLAGS += -DHAVE_PATHS_H
+endif
+
ifdef DIR_HAS_BSD_GROUP_SEMANTICS
COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
endif
@@ -1427,6 +1445,7 @@ gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
template_dir_SQ = $(subst ','\'',$(template_dir))
htmldir_SQ = $(subst ','\'',$(htmldir))
prefix_SQ = $(subst ','\'',$(prefix))
+gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
@@ -1563,45 +1582,38 @@ gitweb:
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all
ifdef JSMIN
-GITWEB_PROGRAMS += gitweb/gitweb.min.js
-GITWEB_JS = gitweb/gitweb.min.js
+GITWEB_PROGRAMS += gitweb/static/gitweb.min.js
+GITWEB_JS = gitweb/static/gitweb.min.js
else
-GITWEB_JS = gitweb/gitweb.js
+GITWEB_JS = gitweb/static/gitweb.js
endif
ifdef CSSMIN
-GITWEB_PROGRAMS += gitweb/gitweb.min.css
-GITWEB_CSS = gitweb/gitweb.min.css
+GITWEB_PROGRAMS += gitweb/static/gitweb.min.css
+GITWEB_CSS = gitweb/static/gitweb.min.css
else
-GITWEB_CSS = gitweb/gitweb.css
+GITWEB_CSS = gitweb/static/gitweb.css
endif
OTHER_PROGRAMS += gitweb/gitweb.cgi $(GITWEB_PROGRAMS)
gitweb/gitweb.cgi: gitweb/gitweb.perl $(GITWEB_PROGRAMS)
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
ifdef JSMIN
-gitweb/gitweb.min.js: gitweb/gitweb.js
+gitweb/static/gitweb.min.js: gitweb/static/gitweb.js
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
endif # JSMIN
ifdef CSSMIN
-gitweb/gitweb.min.css: gitweb/gitweb.css
+gitweb/static/gitweb.min.css: gitweb/static/gitweb.css
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
endif # CSSMIN
-git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.js
+git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/static/gitweb.css gitweb/static/gitweb.js
$(QUIET_GEN)$(RM) $@ $@+ && \
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
- -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
- -e '/@@GITWEB_CGI@@/d' \
- -e '/@@GITWEB_CSS@@/r $(GITWEB_CSS)' \
- -e '/@@GITWEB_CSS@@/d' \
- -e '/@@GITWEB_JS@@/r $(GITWEB_JS)' \
- -e '/@@GITWEB_JS@@/d' \
+ -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
-e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
- -e 's|@@GITWEB_CSS_NAME@@|$(GITWEB_CSS)|' \
- -e 's|@@GITWEB_JS_NAME@@|$(GITWEB_JS)|' \
$@.sh > $@+ && \
chmod +x $@+ && \
mv $@+ $@
@@ -1622,13 +1634,8 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
--no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \
instlibdir` && \
- sed -e '1{' \
- -e ' s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
- -e '}' \
- -e 's|^import sys.*|&; \\\
- import os; \\\
- sys.path.insert(0, os.getenv("GITPYTHONLIB",\
- "@@INSTLIBDIR@@"));|' \
+ sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
+ -e 's|\(os\.getenv("GITPYTHONLIB"\)[^)]*)|\1,"@@INSTLIBDIR@@")|' \
-e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
$@.py >$@+ && \
chmod +x $@+ && \
@@ -1658,7 +1665,10 @@ git.o git.spec \
TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
- git.o http.o http-walker.o remote-curl.o
+ git.o
+ifndef NO_CURL
+ GIT_OBJS += http.o http-walker.o remote-curl.o
+endif
XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
xdiff/xmerge.o xdiff/xpatience.o
OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
@@ -1973,6 +1983,7 @@ install: all
$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
ifndef NO_PERL
$(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
+ $(MAKE) -C gitweb gitwebdir=$(gitwebdir_SQ) install
endif
ifndef NO_PYTHON
$(MAKE) -C git_remote_helpers prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
@@ -1998,14 +2009,18 @@ endif
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
done; } && \
- { for p in $(REMOTE_CURL_ALIASES); do \
+ { test x"$(REMOTE_CURL_ALIASES)" = x || \
+ { for p in $(REMOTE_CURL_ALIASES); do \
$(RM) "$$execdir/$$p" && \
ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
- done; } && \
+ done; } ; } && \
./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
+install-gitweb:
+ $(MAKE) -C gitweb install
+
install-doc:
$(MAKE) -C Documentation install
diff --git a/builtin.h b/builtin.h
index 5c887ef61..b614d12b9 100644
--- a/builtin.h
+++ b/builtin.h
@@ -16,6 +16,7 @@ extern const char *help_unknown_cmd(const char *cmd);
extern void prune_packed_objects(int);
extern int fmt_merge_msg(int merge_summary, struct strbuf *in,
struct strbuf *out);
+extern int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out);
extern int commit_notes(struct notes_tree *t, const char *msg);
struct notes_rewrite_cfg {
diff --git a/builtin/blame.c b/builtin/blame.c
index fc1586350..8506286dd 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -39,7 +39,7 @@ static int show_root;
static int reverse;
static int blank_boundary;
static int incremental;
-static int xdl_opts = XDF_NEED_MINIMAL;
+static int xdl_opts;
static enum date_mode blame_date_mode = DATE_ISO8601;
static size_t blame_date_width;
@@ -1589,7 +1589,7 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)
strcpy(hex, sha1_to_hex(suspect->commit->object.sha1));
printf("%s%c%d %d %d\n",
hex,
- ent->guilty ? ' ' : '*', // purely for debugging
+ ent->guilty ? ' ' : '*', /* purely for debugging */
ent->s_lno + 1,
ent->lno + 1,
ent->num_lines);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 88b1f43e0..c3825219c 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -33,6 +33,7 @@ struct checkout_opts {
int writeout_error;
const char *new_branch;
+ const char *new_orphan_branch;
int new_branch_log;
enum branch_track track;
};
@@ -492,8 +493,9 @@ static void update_refs_for_switch(struct checkout_opts *opts,
struct strbuf msg = STRBUF_INIT;
const char *old_desc;
if (opts->new_branch) {
- create_branch(old->name, opts->new_branch, new->name, 0,
- opts->new_branch_log, opts->track);
+ if (!opts->new_orphan_branch)
+ create_branch(old->name, opts->new_branch, new->name, 0,
+ opts->new_branch_log, opts->track);
new->name = opts->new_branch;
setup_branch_path(new);
}
@@ -633,6 +635,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
OPT_BOOLEAN('l', NULL, &opts.new_branch_log, "log for new branch"),
OPT_SET_INT('t', "track", &opts.track, "track",
BRANCH_TRACK_EXPLICIT),
+ OPT_STRING(0, "orphan", &opts.new_orphan_branch, "new branch", "new unparented branch"),
OPT_SET_INT('2', "ours", &opts.writeout_stage, "stage",
2),
OPT_SET_INT('3', "theirs", &opts.writeout_stage, "stage",
@@ -678,6 +681,14 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
opts.new_branch = argv0 + 1;
}
+ if (opts.new_orphan_branch) {
+ if (opts.new_branch)
+ die("--orphan and -b are mutually exclusive");
+ if (opts.track > 0 || opts.new_branch_log)
+ die("--orphan cannot be used with -t or -l");
+ opts.new_branch = opts.new_orphan_branch;
+ }
+
if (conflict_style) {
opts.merge = 1; /* implied */
git_xmerge_config("merge.conflictstyle", conflict_style, NULL);
diff --git a/builtin/clone.c b/builtin/clone.c
index 0bedde41f..efb1e6faa 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -464,7 +464,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
set_git_dir(make_absolute_path(git_dir));
if (0 <= option_verbosity)
- printf("Cloning into %s...\n", get_git_dir());
+ printf("Cloning into %s%s...\n",
+ option_bare ? "bare repository " : "", dir);
init_db(option_template, INIT_DB_QUIET);
/*
@@ -474,9 +475,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
*/
unsetenv(CONFIG_ENVIRONMENT);
- if (option_reference)
- setup_reference(git_dir);
-
git_config(git_default_config, NULL);
if (option_bare) {
@@ -502,12 +500,15 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
git_config_set(key.buf, "true");
strbuf_reset(&key);
}
-
- strbuf_addf(&key, "remote.%s.url", option_origin);
- git_config_set(key.buf, repo);
- strbuf_reset(&key);
}
+ strbuf_addf(&key, "remote.%s.url", option_origin);
+ git_config_set(key.buf, repo);
+ strbuf_reset(&key);
+
+ if (option_reference)
+ setup_reference(git_dir);
+
fetch_pattern = value.buf;
refspec = parse_fetch_refspec(1, &fetch_pattern);
@@ -517,7 +518,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
refs = clone_local(path, git_dir);
mapped_refs = wanted_peer_refs(refs, refspec);
} else {
- struct remote *remote = remote_get(argv[0]);
+ struct remote *remote = remote_get(option_origin);
transport = transport_get(remote, remote->url[0]);
if (!transport->get_refs_list || !transport->fetch)
diff --git a/builtin/commit.c b/builtin/commit.c
index 017b8a553..a86168664 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -83,6 +83,7 @@ static enum {
static char *cleanup_arg;
static int use_editor = 1, initial_commit, in_merge, include_status = 1;
+static int show_ignored_in_status;
static const char *only_include_assumed;
static struct strbuf message;
@@ -92,6 +93,7 @@ static enum {
STATUS_FORMAT_SHORT,
STATUS_FORMAT_PORCELAIN,
} status_format = STATUS_FORMAT_LONG;
+static int status_show_branch;
static int opt_parse_m(const struct option *opt, const char *arg, int unset)
{
@@ -133,6 +135,7 @@ static struct option builtin_commit_options[] = {
OPT_BOOLEAN(0, "dry-run", &dry_run, "show what would be committed"),
OPT_SET_INT(0, "short", &status_format, "show status concisely",
STATUS_FORMAT_SHORT),
+ OPT_BOOLEAN(0, "branch", &status_show_branch, "show branch information"),
OPT_SET_INT(0, "porcelain", &status_format,
"show porcelain output format", STATUS_FORMAT_PORCELAIN),
OPT_BOOLEAN('z', "null", &null_termination,
@@ -423,7 +426,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
switch (status_format) {
case STATUS_FORMAT_SHORT:
- wt_shortstatus_print(s, null_termination);
+ wt_shortstatus_print(s, null_termination, status_show_branch);
break;
case STATUS_FORMAT_PORCELAIN:
wt_porcelain_print(s, null_termination);
@@ -461,15 +464,21 @@ static void determine_author_info(void)
if (!a)
die("invalid commit: %s", use_message);
- lb = strstr(a + 8, " <");
- rb = strstr(a + 8, "> ");
- eol = strchr(a + 8, '\n');
- if (!lb || !rb || !eol)
+ lb = strchrnul(a + strlen("\nauthor "), '<');
+ rb = strchrnul(lb, '>');
+ eol = strchrnul(rb, '\n');
+ if (!*lb || !*rb || !*eol)
die("invalid commit: %s", use_message);
- name = xstrndup(a + 8, lb - (a + 8));
- email = xstrndup(lb + 2, rb - (lb + 2));
- date = xstrndup(rb + 2, eol - (rb + 2));
+ if (lb == a + strlen("\nauthor "))
+ /* \nauthor <foo@example.com> */
+ name = xcalloc(1, 1);
+ else
+ name = xmemdupz(a + strlen("\nauthor "),
+ (lb - strlen(" ") -
+ (a + strlen("\nauthor "))));
+ email = xmemdupz(lb + strlen("<"), rb - (lb + strlen("<")));
+ date = xmemdupz(rb + strlen("> "), eol - (rb + strlen("> ")));
}
if (force_author) {
@@ -1029,6 +1038,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
OPT__VERBOSE(&verbose),
OPT_SET_INT('s', "short", &status_format,
"show status concisely", STATUS_FORMAT_SHORT),
+ OPT_BOOLEAN('b', "branch", &status_show_branch,
+ "show branch information"),
OPT_SET_INT(0, "porcelain", &status_format,
"show porcelain output format",
STATUS_FORMAT_PORCELAIN),
@@ -1038,6 +1049,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
"mode",
"show untracked files, optional modes: all, normal, no. (Default: all)",
PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
+ OPT_BOOLEAN(0, "ignored", &show_ignored_in_status,
+ "show ignored files"),
OPT_END(),
};
@@ -1051,7 +1064,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
builtin_status_options,
builtin_status_usage, 0);
handle_untracked_files_arg(&s);
-
+ if (show_ignored_in_status)
+ s.show_ignored_files = 1;
if (*argv)
s.pathspec = get_pathspec(prefix, argv);
@@ -1078,7 +1092,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
switch (status_format) {
case STATUS_FORMAT_SHORT:
- wt_shortstatus_print(&s, null_termination);
+ wt_shortstatus_print(&s, null_termination, status_show_branch);
break;
case STATUS_FORMAT_PORCELAIN:
wt_porcelain_print(&s, null_termination);
diff --git a/builtin/config.c b/builtin/config.c
index 4bc46b15f..f3d1660d0 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -197,7 +197,11 @@ static int get_value(const char *key_, const char *regex_)
git_config_from_file(show_config, system_wide, NULL);
if (do_all && global)
git_config_from_file(show_config, global, NULL);
- git_config_from_file(show_config, local, NULL);
+ if (do_all)
+ git_config_from_file(show_config, local, NULL);
+ git_config_from_parameters(show_config, NULL);
+ if (!do_all && !seen)
+ git_config_from_file(show_config, local, NULL);
if (!do_all && !seen && global)
git_config_from_file(show_config, global, NULL);
if (!do_all && !seen && system_wide)
diff --git a/builtin/describe.c b/builtin/describe.c
index 71be2a936..43caff2ff 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -35,7 +35,8 @@ static const char *diff_index_args[] = {
struct commit_name {
struct tag *tag;
- int prio; /* annotated tag = 2, tag = 1, head = 0 */
+ unsigned prio:2; /* annotated tag = 2, tag = 1, head = 0 */
+ unsigned name_checked:1;
unsigned char sha1[20];
char path[FLEX_ARRAY]; /* more */
};
@@ -43,18 +44,53 @@ static const char *prio_names[] = {
"head", "lightweight", "annotated",
};
+static int replace_name(struct commit_name *e,
+ int prio,
+ const unsigned char *sha1,
+ struct tag **tag)
+{
+ if (!e || e->prio < prio)
+ return 1;
+
+ if (e->prio == 2 && prio == 2) {
+ /* Multiple annotated tags point to the same commit.
+ * Select one to keep based upon their tagger date.
+ */
+ struct tag *t;
+
+ if (!e->tag) {
+ t = lookup_tag(e->sha1);
+ if (!t || parse_tag(t))
+ return 1;
+ e->tag = t;
+ }
+
+ t = lookup_tag(sha1);
+ if (!t || parse_tag(t))
+ return 0;
+ *tag = t;
+
+ if (e->tag->date < t->date)
+ return 1;
+ }
+
+ return 0;
+}
+
static void add_to_known_names(const char *path,
struct commit *commit,
int prio,
const unsigned char *sha1)
{
struct commit_name *e = commit->util;
- if (!e || e->prio < prio) {
+ struct tag *tag = NULL;
+ if (replace_name(e, prio, sha1, &tag)) {
size_t len = strlen(path)+1;
free(e);
e = xmalloc(sizeof(struct commit_name) + len);
- e->tag = NULL;
+ e->tag = tag;
e->prio = prio;
+ e->name_checked = 0;
hashcpy(e->sha1, sha1);
memcpy(e->path, path, len);
commit->util = e;
@@ -165,10 +201,15 @@ static void display_name(struct commit_name *n)
{
if (n->prio == 2 && !n->tag) {
n->tag = lookup_tag(n->sha1);
- if (!n->tag || parse_tag(n->tag) || !n->tag->tag)
+ if (!n->tag || parse_tag(n->tag))
die("annotated tag %s not available", n->path);
+ }
+ if (n->tag && !n->name_checked) {
+ if (!n->tag->tag)
+ die("annotated tag %s has no embedded name", n->path);
if (strcmp(n->tag->tag, all ? n->path + 5 : n->path))
warning("tag '%s' is really '%s' here", n->tag->tag, n->path);
+ n->name_checked = 1;
}
if (n->tag)
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 379a03131..44204257c 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -202,35 +202,10 @@ static void shortlog(const char *name, unsigned char *sha1,
string_list_clear(&subjects, 0);
}
-int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
- int limit = 20, i = 0, pos = 0;
+static void do_fmt_merge_msg_title(struct strbuf *out,
+ const char *current_branch) {
+ int i = 0;
char *sep = "";
- unsigned char head_sha1[20];
- const char *current_branch;
-
- /* get current branch */
- current_branch = resolve_ref("HEAD", head_sha1, 1, NULL);
- if (!current_branch)
- die("No current branch");
- if (!prefixcmp(current_branch, "refs/heads/"))
- current_branch += 11;
-
- /* get a line */
- while (pos < in->len) {
- int len;
- char *newline, *p = in->buf + pos;
-
- newline = strchr(p, '\n');
- len = newline ? newline - p : strlen(p);
- pos += len + !!newline;
- i++;
- p[len] = 0;
- if (handle_line(p))
- die ("Error in line %d: %.*s", i, len, p);
- }
-
- if (!srcs.nr)
- return 0;
strbuf_addstr(out, "Merge ");
for (i = 0; i < srcs.nr; i++) {
@@ -278,6 +253,40 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
strbuf_addch(out, '\n');
else
strbuf_addf(out, " into %s\n", current_branch);
+}
+
+static int do_fmt_merge_msg(int merge_title, int merge_summary,
+ struct strbuf *in, struct strbuf *out) {
+ int limit = 20, i = 0, pos = 0;
+ unsigned char head_sha1[20];
+ const char *current_branch;
+
+ /* get current branch */
+ current_branch = resolve_ref("HEAD", head_sha1, 1, NULL);
+ if (!current_branch)
+ die("No current branch");
+ if (!prefixcmp(current_branch, "refs/heads/"))
+ current_branch += 11;
+
+ /* get a line */
+ while (pos < in->len) {
+ int len;
+ char *newline, *p = in->buf + pos;
+
+ newline = strchr(p, '\n');
+ len = newline ? newline - p : strlen(p);
+ pos += len + !!newline;
+ i++;
+ p[len] = 0;
+ if (handle_line(p))
+ die ("Error in line %d: %.*s", i, len, p);
+ }
+
+ if (!srcs.nr)
+ return 0;
+
+ if (merge_title)
+ do_fmt_merge_msg_title(out, current_branch);
if (merge_summary) {
struct commit *head;
@@ -289,6 +298,9 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
rev.ignore_merges = 1;
rev.limited = 1;
+ if (suffixcmp(out->buf, "\n"))
+ strbuf_addch(out, '\n');
+
for (i = 0; i < origins.nr; i++)
shortlog(origins.items[i].string, origins.items[i].util,
head, &rev, limit, out);
@@ -296,6 +308,14 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
return 0;
}
+int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
+ return do_fmt_merge_msg(1, merge_summary, in, out);
+}
+
+int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out) {
+ return do_fmt_merge_msg(0, 1, in, out);
+}
+
int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
{
const char *inpath = NULL;
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 62be1bbfd..a2b28c696 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -227,6 +227,9 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
strcpy(s, sha1_to_hex(obj->sha1));
v->s = s;
}
+ else if (!strcmp(name, "objectname:short")) {
+ v->s = find_unique_abbrev(obj->sha1, DEFAULT_ABBREV);
+ }
}
}
@@ -549,10 +552,10 @@ static void grab_values(struct atom_value *val, int deref, struct object *obj, v
grab_person("committer", val, deref, obj, buf, sz);
break;
case OBJ_TREE:
- // grab_tree_values(val, deref, obj, buf, sz);
+ /* grab_tree_values(val, deref, obj, buf, sz); */
break;
case OBJ_BLOB:
- // grab_blob_values(val, deref, obj, buf, sz);
+ /* grab_blob_values(val, deref, obj, buf, sz); */
break;
default:
die("Eh? Object of type %d?", obj->type);
diff --git a/builtin/grep.c b/builtin/grep.c
index 8e928e217..d0a73da07 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -17,8 +17,8 @@
#include "dir.h"
#ifndef NO_PTHREADS
-#include "thread-utils.h"
#include <pthread.h>
+#include "thread-utils.h"
#endif
static char const * const grep_usage[] = {
@@ -724,11 +724,15 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
if (!patterns)
die_errno("cannot open '%s'", arg);
while (strbuf_getline(&sb, patterns, '\n') == 0) {
+ char *s;
+ size_t len;
+
/* ignore empty line like grep does */
if (sb.len == 0)
continue;
- append_grep_pattern(grep_opt, strbuf_detach(&sb, NULL), arg,
- ++lno, GREP_PATTERN);
+
+ s = strbuf_detach(&sb, &len);
+ append_grep_pat(grep_opt, s, len, arg, ++lno, GREP_PATTERN);
}
fclose(patterns);
strbuf_release(&sb);
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 03d0cd2f4..a89ae831d 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -266,26 +266,23 @@ static void unlink_base_data(struct base_data *c)
static void *unpack_entry_data(unsigned long offset, unsigned long size)
{
+ int status;
z_stream stream;
void *buf = xmalloc(size);
memset(&stream, 0, sizeof(stream));
+ git_inflate_init(&stream);
stream.next_out = buf;
stream.avail_out = size;
- stream.next_in = fill(1);
- stream.avail_in = input_len;
- git_inflate_init(&stream);
- for (;;) {
- int ret = git_inflate(&stream, 0);
- use(input_len - stream.avail_in);
- if (stream.total_out == size && ret == Z_STREAM_END)
- break;
- if (ret != Z_OK)
- bad_object(offset, "inflate returned %d", ret);
+ do {
stream.next_in = fill(1);
stream.avail_in = input_len;
- }
+ status = git_inflate(&stream, 0);
+ use(input_len - stream.avail_in);
+ } while (status == Z_OK);
+ if (stream.total_out != size || status != Z_STREAM_END)
+ bad_object(offset, "inflate returned %d", status);
git_inflate_end(&stream);
return buf;
}
@@ -359,34 +356,38 @@ static void *get_data_from_pack(struct object_entry *obj)
{
off_t from = obj[0].idx.offset + obj[0].hdr_size;
unsigned long len = obj[1].idx.offset - from;
- unsigned long rdy = 0;
- unsigned char *src, *data;
+ unsigned char *data, *inbuf;
z_stream stream;
- int st;
+ int status;
- src = xmalloc(len);
- data = src;
- do {
- ssize_t n = pread(pack_fd, data + rdy, len - rdy, from + rdy);
- if (n < 0)
- die_errno("cannot pread pack file");
- if (!n)
- die("premature end of pack file, %lu bytes missing",
- len - rdy);
- rdy += n;
- } while (rdy < len);
data = xmalloc(obj->size);
+ inbuf = xmalloc((len < 64*1024) ? len : 64*1024);
+
memset(&stream, 0, sizeof(stream));
+ git_inflate_init(&stream);
stream.next_out = data;
stream.avail_out = obj->size;
- stream.next_in = src;
- stream.avail_in = len;
- git_inflate_init(&stream);
- while ((st = git_inflate(&stream, Z_FINISH)) == Z_OK);
- git_inflate_end(&stream);
- if (st != Z_STREAM_END || stream.total_out != obj->size)
+
+ do {
+ ssize_t n = (len < 64*1024) ? len : 64*1024;
+ n = pread(pack_fd, inbuf, n, from);
+ if (n < 0)
+ die_errno("cannot pread pack file");
+ if (!n)
+ die("premature end of pack file, %lu bytes missing", len);
+ from += n;
+ len -= n;
+ stream.next_in = inbuf;
+ stream.avail_in = n;
+ status = git_inflate(&stream, 0);
+ } while (len && status == Z_OK && !stream.avail_in);
+
+ /* This has been inflated OK when first encountered, so... */
+ if (status != Z_STREAM_END || stream.total_out != obj->size)
die("serious inflate inconsistency");
- free(src);
+
+ git_inflate_end(&stream);
+ free(inbuf);
return data;
}
@@ -668,25 +669,25 @@ static void parse_pack_objects(unsigned char *sha1)
static int write_compressed(struct sha1file *f, void *in, unsigned int size)
{
z_stream stream;
- unsigned long maxsize;
- void *out;
+ int status;
+ unsigned char outbuf[4096];
memset(&stream, 0, sizeof(stream));
deflateInit(&stream, zlib_compression_level);
- maxsize = deflateBound(&stream, size);
- out = xmalloc(maxsize);
-
- /* Compress it */
stream.next_in = in;
stream.avail_in = size;
- stream.next_out = out;
- stream.avail_out = maxsize;
- while (deflate(&stream, Z_FINISH) == Z_OK);
- deflateEnd(&stream);
+ do {
+ stream.next_out = outbuf;
+ stream.avail_out = sizeof(outbuf);
+ status = deflate(&stream, Z_FINISH);
+ sha1write(f, outbuf, sizeof(outbuf) - stream.avail_out);
+ } while (status == Z_OK);
+
+ if (status != Z_STREAM_END)
+ die("unable to deflate appended object (%d)", status);
size = stream.total_out;
- sha1write(f, out, size);
- free(out);
+ deflateEnd(&stream);
return size;
}
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 8ee91eb54..34480cfad 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -5,7 +5,7 @@
static const char ls_remote_usage[] =
"git ls-remote [--heads] [--tags] [-u <exec> | --upload-pack <exec>]\n"
-" [<repository> [<refs>...]]";
+" [-q|--quiet] [<repository> [<refs>...]]";
/*
* Is there one among the list of patterns that match the tail part
@@ -34,6 +34,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
const char *dest = NULL;
int nongit;
unsigned flags = 0;
+ int quiet = 0;
const char *uploadpack = NULL;
const char **pattern = NULL;
@@ -67,6 +68,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
flags |= REF_NORMAL;
continue;
}
+ if (!strcmp("--quiet", arg) || !strcmp("-q", arg)) {
+ quiet = 1;
+ continue;
+ }
usage(ls_remote_usage);
}
dest = arg;
@@ -99,6 +104,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
ref = transport_get_remote_refs(transport);
if (transport_disconnect(transport))
return 1;
+
+ if (!dest && !quiet)
+ fprintf(stderr, "From %s\n", *remote->url);
for ( ; ref; ref = ref->next) {
if (!check_ref_type(ref, flags))
continue;
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 610849a65..b8e9e5ba0 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -25,7 +25,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
const char *names[3] = { NULL, NULL, NULL };
mmfile_t mmfs[3];
mmbuffer_t result = {NULL, 0};
- xmparam_t xmp = {{XDF_NEED_MINIMAL}};
+ xmparam_t xmp = {{0}};
int ret = 0, i = 0, to_stdout = 0;
int quiet = 0;
int nongit;
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index a4a4f2ce4..fc00d794d 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -106,7 +106,7 @@ static void show_diff(struct merge_list *entry)
xdemitconf_t xecfg;
xdemitcb_t ecb;
- xpp.flags = XDF_NEED_MINIMAL;
+ xpp.flags = 0;
memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = 3;
ecb.outf = show_outf;
diff --git a/builtin/merge.c b/builtin/merge.c
index 37d414b3b..37ce4f589 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -982,7 +982,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
reset_hard(remote_head->sha1, 0);
return 0;
} else {
- struct strbuf msg = STRBUF_INIT;
+ struct strbuf merge_names = STRBUF_INIT;
/* We are invoked directly as the first-class UI. */
head_arg = "HEAD";
@@ -995,13 +995,17 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* codepath so we discard the error in this
* loop.
*/
- if (!have_message) {
- for (i = 0; i < argc; i++)
- merge_name(argv[i], &msg);
- fmt_merge_msg(option_log, &msg, &merge_msg);
- if (merge_msg.len)
- strbuf_setlen(&merge_msg, merge_msg.len-1);
- }
+ for (i = 0; i < argc; i++)
+ merge_name(argv[i], &merge_names);
+
+ if (have_message && option_log)
+ fmt_merge_msg_shortlog(&merge_names, &merge_msg);
+ else if (!have_message)
+ fmt_merge_msg(option_log, &merge_names, &merge_msg);
+
+
+ if (!(have_message && !option_log) && merge_msg.len)
+ strbuf_setlen(&merge_msg, merge_msg.len-1);
}
if (head_invalid || !argc)
diff --git a/builtin/notes.c b/builtin/notes.c
index 52b72fca6..648033c27 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -26,7 +26,7 @@ static const char * const git_notes_usage[] = {
"git notes [--ref <notes_ref>] edit [<object>]",
"git notes [--ref <notes_ref>] show [<object>]",
"git notes [--ref <notes_ref>] remove [<object>]",
- "git notes [--ref <notes_ref>] prune",
+ "git notes [--ref <notes_ref>] prune [-n | -v]",
NULL
};
@@ -67,7 +67,7 @@ static const char * const git_notes_remove_usage[] = {
};
static const char * const git_notes_prune_usage[] = {
- "git notes prune",
+ "git notes prune [<options>]",
NULL
};
@@ -416,7 +416,7 @@ int notes_copy_from_stdin(int force, const char *rewrite_cmd)
{
struct strbuf buf = STRBUF_INIT;
struct notes_rewrite_cfg *c = NULL;
- struct notes_tree *t;
+ struct notes_tree *t = NULL;
int ret = 0;
if (rewrite_cmd) {
@@ -792,7 +792,10 @@ static int remove_cmd(int argc, const char **argv, const char *prefix)
static int prune(int argc, const char **argv, const char *prefix)
{
struct notes_tree *t;
+ int show_only = 0, verbose = 0;
struct option options[] = {
+ OPT_BOOLEAN('n', NULL, &show_only, "do not remove, show only"),
+ OPT_BOOLEAN('v', NULL, &verbose, "report pruned notes"),
OPT_END()
};
@@ -806,8 +809,10 @@ static int prune(int argc, const char **argv, const char *prefix)
t = init_notes_check("prune");
- prune_notes(t);
- commit_notes(t, "Notes removed by 'git notes prune'");
+ prune_notes(t, (verbose ? NOTES_PRUNE_VERBOSE : 0) |
+ (show_only ? NOTES_PRUNE_VERBOSE|NOTES_PRUNE_DRYRUN : 0) );
+ if (!show_only)
+ commit_notes(t, "Notes removed by 'git notes prune'");
free_notes(t);
return 0;
}
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 97802585e..0e8167311 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -18,8 +18,8 @@
#include "refs.h"
#ifndef NO_PTHREADS
-#include "thread-utils.h"
#include <pthread.h>
+#include "thread-utils.h"
#endif
static const char pack_usage[] =
@@ -1522,6 +1522,15 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
#ifndef NO_PTHREADS
+static void try_to_free_from_threads(size_t size)
+{
+ read_lock();
+ release_pack_memory(size, -1);
+ read_unlock();
+}
+
+try_to_free_t old_try_to_free_routine;
+
/*
* The main thread waits on the condition that (at least) one of the workers
* has stopped working (which is indicated in the .working member of
@@ -1552,14 +1561,16 @@ static pthread_cond_t progress_cond;
*/
static void init_threaded_search(void)
{
- pthread_mutex_init(&read_mutex, NULL);
+ init_recursive_mutex(&read_mutex);
pthread_mutex_init(&cache_mutex, NULL);
pthread_mutex_init(&progress_mutex, NULL);
pthread_cond_init(&progress_cond, NULL);
+ old_try_to_free_routine = set_try_to_free_routine(try_to_free_from_threads);
}
static void cleanup_threaded_search(void)
{
+ set_try_to_free_routine(old_try_to_free_routine);
pthread_cond_destroy(&progress_cond);
pthread_mutex_destroy(&read_mutex);
pthread_mutex_destroy(&cache_mutex);
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index af0911e4b..512530022 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -28,16 +28,42 @@ static int remove_space(char *line)
return dst - line;
}
-static void generate_id_list(void)
+static int scan_hunk_header(const char *p, int *p_before, int *p_after)
+{
+ static const char digits[] = "0123456789";
+ const char *q, *r;
+ int n;
+
+ q = p + 4;
+ n = strspn(q, digits);
+ if (q[n] == ',') {
+ q += n + 1;
+ n = strspn(q, digits);
+ }
+ if (n == 0 || q[n] != ' ' || q[n+1] != '+')
+ return 0;
+
+ r = q + n + 2;
+ n = strspn(r, digits);
+ if (r[n] == ',') {
+ r += n + 1;
+ n = strspn(r, digits);
+ }
+ if (n == 0)
+ return 0;
+
+ *p_before = atoi(q);
+ *p_after = atoi(r);
+ return 1;
+}
+
+int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)
{
- static unsigned char sha1[20];
static char line[1000];
- git_SHA_CTX ctx;
- int patchlen = 0;
+ int patchlen = 0, found_next = 0;
+ int before = -1, after = -1;
- git_SHA1_Init(&ctx);
while (fgets(line, sizeof(line), stdin) != NULL) {
- unsigned char n[20];
char *p = line;
int len;
@@ -45,32 +71,75 @@ static void generate_id_list(void)
p += 10;
else if (!memcmp(line, "commit ", 7))
p += 7;
+ else if (!memcmp(line, "From ", 5))
+ p += 5;
- if (!get_sha1_hex(p, n)) {
- flush_current_id(patchlen, sha1, &ctx);
- hashcpy(sha1, n);
- patchlen = 0;
- continue;
+ if (!get_sha1_hex(p, next_sha1)) {
+ found_next = 1;
+ break;
}
/* Ignore commit comments */
if (!patchlen && memcmp(line, "diff ", 5))
continue;
- /* Ignore git-diff index header */
- if (!memcmp(line, "index ", 6))
- continue;
+ /* Parsing diff header? */
+ if (before == -1) {
+ if (!memcmp(line, "index ", 6))
+ continue;
+ else if (!memcmp(line, "--- ", 4))
+ before = after = 1;
+ else if (!isalpha(line[0]))
+ break;
+ }
- /* Ignore line numbers when computing the SHA1 of the patch */
- if (!memcmp(line, "@@ -", 4))
- continue;
+ /* Looking for a valid hunk header? */
+ if (before == 0 && after == 0) {
+ if (!memcmp(line, "@@ -", 4)) {
+ /* Parse next hunk, but ignore line numbers. */
+ scan_hunk_header(line, &before, &after);
+ continue;
+ }
+
+ /* Split at the end of the patch. */
+ if (memcmp(line, "diff ", 5))
+ break;
+
+ /* Else we're parsing another header. */
+ before = after = -1;
+ }
+
+ /* If we get here, we're inside a hunk. */
+ if (line[0] == '-' || line[0] == ' ')
+ before--;
+ if (line[0] == '+' || line[0] == ' ')
+ after--;
/* Compute the sha without whitespace */
len = remove_space(line);
patchlen += len;
- git_SHA1_Update(&ctx, line, len);
+ git_SHA1_Update(ctx, line, len);
+ }
+
+ if (!found_next)
+ hashclr(next_sha1);
+
+ return patchlen;
+}
+
+static void generate_id_list(void)
+{
+ unsigned char sha1[20], n[20];
+ git_SHA_CTX ctx;
+ int patchlen;
+
+ git_SHA1_Init(&ctx);
+ hashclr(sha1);
+ while (!feof(stdin)) {
+ patchlen = get_one_patchid(n, &ctx);
+ flush_current_id(patchlen, sha1, &ctx);
+ hashcpy(sha1, n);
}
- flush_current_id(patchlen, sha1, &ctx);
}
static const char patch_id_usage[] = "git patch-id < patch";
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 0559fcc87..bb34757d2 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -9,6 +9,7 @@
#include "object.h"
#include "remote.h"
#include "transport.h"
+#include "string-list.h"
static const char receive_pack_usage[] = "git receive-pack <git-dir>";
@@ -129,13 +130,12 @@ static void write_head_info(void)
struct command {
struct command *next;
const char *error_string;
+ unsigned int skip_update;
unsigned char old_sha1[20];
unsigned char new_sha1[20];
char ref_name[FLEX_ARRAY]; /* more */
};
-static struct command *commands;
-
static const char pre_receive_hook[] = "hooks/pre-receive";
static const char post_receive_hook[] = "hooks/post-receive";
@@ -188,7 +188,7 @@ static int copy_to_sideband(int in, int out, void *arg)
return 0;
}
-static int run_receive_hook(const char *hook_name)
+static int run_receive_hook(struct command *commands, const char *hook_name)
{
static char buf[sizeof(commands->old_sha1) * 2 + PATH_MAX + 4];
struct command *cmd;
@@ -447,15 +447,15 @@ static const char *update(struct command *cmd)
static char update_post_hook[] = "hooks/post-update";
-static void run_update_post_hook(struct command *cmd)
+static void run_update_post_hook(struct command *commands)
{
- struct command *cmd_p;
+ struct command *cmd;
int argc;
const char **argv;
struct child_process proc;
- for (argc = 0, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {
- if (cmd_p->error_string)
+ for (argc = 0, cmd = commands; cmd; cmd = cmd->next) {
+ if (cmd->error_string)
continue;
argc++;
}
@@ -464,12 +464,12 @@ static void run_update_post_hook(struct command *cmd)
argv = xmalloc(sizeof(*argv) * (2 + argc));
argv[0] = update_post_hook;
- for (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {
+ for (argc = 1, cmd = commands; cmd; cmd = cmd->next) {
char *p;
- if (cmd_p->error_string)
+ if (cmd->error_string)
continue;
- p = xmalloc(strlen(cmd_p->ref_name) + 1);
- strcpy(p, cmd_p->ref_name);
+ p = xmalloc(strlen(cmd->ref_name) + 1);
+ strcpy(p, cmd->ref_name);
argv[argc] = p;
argc++;
}
@@ -488,37 +488,92 @@ static void run_update_post_hook(struct command *cmd)
}
}
-static void execute_commands(const char *unpacker_error)
+static void check_aliased_update(struct command *cmd, struct string_list *list)
+{
+ struct string_list_item *item;
+ struct command *dst_cmd;
+ unsigned char sha1[20];
+ char cmd_oldh[41], cmd_newh[41], dst_oldh[41], dst_newh[41];
+ int flag;
+
+ const char *dst_name = resolve_ref(cmd->ref_name, sha1, 0, &flag);
+
+ if (!(flag & REF_ISSYMREF))
+ return;
+
+ if ((item = string_list_lookup(dst_name, list)) == NULL)
+ return;
+
+ cmd->skip_update = 1;
+
+ dst_cmd = (struct command *) item->util;
+
+ if (!hashcmp(cmd->old_sha1, dst_cmd->old_sha1) &&
+ !hashcmp(cmd->new_sha1, dst_cmd->new_sha1))
+ return;
+
+ dst_cmd->skip_update = 1;
+
+ strcpy(cmd_oldh, find_unique_abbrev(cmd->old_sha1, DEFAULT_ABBREV));
+ strcat(cmd_newh, find_unique_abbrev(cmd->new_sha1, DEFAULT_ABBREV));
+ strcpy(dst_oldh, find_unique_abbrev(dst_cmd->old_sha1, DEFAULT_ABBREV));
+ strcat(dst_newh, find_unique_abbrev(dst_cmd->new_sha1, DEFAULT_ABBREV));
+ rp_error("refusing inconsistent update between symref '%s' (%s..%s) and"
+ " its target '%s' (%s..%s)",
+ cmd->ref_name, cmd_oldh, cmd_newh,
+ dst_cmd->ref_name, dst_oldh, dst_newh);
+
+ cmd->error_string = dst_cmd->error_string =
+ "inconsistent aliased update";
+}
+
+static void check_aliased_updates(struct command *commands)
+{
+ struct command *cmd;
+ struct string_list ref_list = { NULL, 0, 0, 0 };
+
+ for (cmd = commands; cmd; cmd = cmd->next) {
+ struct string_list_item *item =
+ string_list_append(cmd->ref_name, &ref_list);
+ item->util = (void *)cmd;
+ }
+ sort_string_list(&ref_list);
+
+ for (cmd = commands; cmd; cmd = cmd->next)
+ check_aliased_update(cmd, &ref_list);
+
+ string_list_clear(&ref_list, 0);
+}
+
+static void execute_commands(struct command *commands, const char *unpacker_error)
{
- struct command *cmd = commands;
+ struct command *cmd;
unsigned char sha1[20];
if (unpacker_error) {
- while (cmd) {
+ for (cmd = commands; cmd; cmd = cmd->next)
cmd->error_string = "n/a (unpacker error)";
- cmd = cmd->next;
- }
return;
}
- if (run_receive_hook(pre_receive_hook)) {
- while (cmd) {
+ if (run_receive_hook(commands, pre_receive_hook)) {
+ for (cmd = commands; cmd; cmd = cmd->next)
cmd->error_string = "pre-receive hook declined";
- cmd = cmd->next;
- }
return;
}
+ check_aliased_updates(commands);
+
head_name = resolve_ref("HEAD", sha1, 0, NULL);
- while (cmd) {
- cmd->error_string = update(cmd);
- cmd = cmd->next;
- }
+ for (cmd = commands; cmd; cmd = cmd->next)
+ if (!cmd->skip_update)
+ cmd->error_string = update(cmd);
}
-static void read_head_info(void)
+static struct command *read_head_info(void)
{
+ struct command *commands = NULL;
struct command **p = &commands;
for (;;) {
static char line[1000];
@@ -548,15 +603,14 @@ static void read_head_info(void)
if (strstr(refname + reflen + 1, "side-band-64k"))
use_sideband = LARGE_PACKET_MAX;
}
- cmd = xmalloc(sizeof(struct command) + len - 80);
+ cmd = xcalloc(1, sizeof(struct command) + len - 80);
hashcpy(cmd->old_sha1, old_sha1);
hashcpy(cmd->new_sha1, new_sha1);
memcpy(cmd->ref_name, line + 82, len - 81);
- cmd->error_string = NULL;
- cmd->next = NULL;
*p = cmd;
p = &cmd->next;
}
+ return commands;
}
static const char *parse_pack_header(struct pack_header *hdr)
@@ -643,7 +697,7 @@ static const char *unpack(void)
}
}
-static void report(const char *unpack_status)
+static void report(struct command *commands, const char *unpack_status)
{
struct command *cmd;
struct strbuf buf = STRBUF_INIT;
@@ -667,12 +721,12 @@ static void report(const char *unpack_status)
strbuf_release(&buf);
}
-static int delete_only(struct command *cmd)
+static int delete_only(struct command *commands)
{
- while (cmd) {
+ struct command *cmd;
+ for (cmd = commands; cmd; cmd = cmd->next) {
if (!is_null_sha1(cmd->new_sha1))
return 0;
- cmd = cmd->next;
}
return 1;
}
@@ -722,6 +776,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
int stateless_rpc = 0;
int i;
char *dir = NULL;
+ struct command *commands;
argv++;
for (i = 1; i < argc; i++) {
@@ -772,18 +827,17 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
if (advertise_refs)
return 0;
- read_head_info();
- if (commands) {
+ if ((commands = read_head_info()) != NULL) {
const char *unpack_status = NULL;
if (!delete_only(commands))
unpack_status = unpack();
- execute_commands(unpack_status);
+ execute_commands(commands, unpack_status);
if (pack_lockfile)
unlink_or_warn(pack_lockfile);
if (report_status)
- report(unpack_status);
- run_receive_hook(post_receive_hook);
+ report(commands, unpack_status);
+ run_receive_hook(commands, post_receive_hook);
run_update_post_hook(commands);
if (auto_gc) {
const char *argv_gc_auto[] = {
diff --git a/builtin/reflog.c b/builtin/reflog.c
index f73215686..ebf610e64 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -34,8 +34,11 @@ struct cmd_reflog_expire_cb {
struct expire_reflog_cb {
FILE *newlog;
- const char *ref;
- struct commit *ref_commit;
+ enum {
+ UE_NORMAL,
+ UE_ALWAYS,
+ UE_HEAD
+ } unreachable_expire_kind;
struct commit_list *mark_list;
unsigned long mark_limit;
struct cmd_reflog_expire_cb *cmd;
@@ -305,7 +308,7 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
goto prune;
if (timestamp < cb->cmd->expire_unreachable) {
- if (!cb->ref_commit)
+ if (cb->unreachable_expire_kind == UE_ALWAYS)
goto prune;
if (unreachable(cb, old, osha1) || unreachable(cb, new, nsha1))
goto prune;
@@ -332,12 +335,27 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
return 0;
}
+static int push_tip_to_list(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
+{
+ struct commit_list **list = cb_data;
+ struct commit *tip_commit;
+ if (flags & REF_ISSYMREF)
+ return 0;
+ tip_commit = lookup_commit_reference_gently(sha1, 1);
+ if (!tip_commit)
+ return 0;
+ commit_list_insert(tip_commit, list);
+ return 0;
+}
+
static int expire_reflog(const char *ref, const unsigned char *sha1, int unused, void *cb_data)
{
struct cmd_reflog_expire_cb *cmd = cb_data;
struct expire_reflog_cb cb;
struct ref_lock *lock;
char *log_file, *newlog_path = NULL;
+ struct commit *tip_commit;
+ struct commit_list *tips;
int status = 0;
memset(&cb, 0, sizeof(cb));
@@ -357,18 +375,49 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
cb.newlog = fopen(newlog_path, "w");
}
- cb.ref_commit = lookup_commit_reference_gently(sha1, 1);
- cb.ref = ref;
cb.cmd = cmd;
- if (cb.ref_commit) {
- cb.mark_list = NULL;
- commit_list_insert(cb.ref_commit, &cb.mark_list);
+
+ if (!cmd->expire_unreachable || !strcmp(ref, "HEAD")) {
+ tip_commit = NULL;
+ cb.unreachable_expire_kind = UE_HEAD;
+ } else {
+ tip_commit = lookup_commit_reference_gently(sha1, 1);
+ if (!tip_commit)
+ cb.unreachable_expire_kind = UE_ALWAYS;
+ else
+ cb.unreachable_expire_kind = UE_NORMAL;
+ }
+
+ if (cmd->expire_unreachable <= cmd->expire_total)
+ cb.unreachable_expire_kind = UE_ALWAYS;
+
+ cb.mark_list = NULL;
+ tips = NULL;
+ if (cb.unreachable_expire_kind != UE_ALWAYS) {
+ if (cb.unreachable_expire_kind == UE_HEAD) {
+ struct commit_list *elem;
+ for_each_ref(push_tip_to_list, &tips);
+ for (elem = tips; elem; elem = elem->next)
+ commit_list_insert(elem->item, &cb.mark_list);
+ } else {
+ commit_list_insert(tip_commit, &cb.mark_list);
+ }
cb.mark_limit = cmd->expire_total;
mark_reachable(&cb);
}
+
for_each_reflog_ent(ref, expire_reflog_ent, &cb);
- if (cb.ref_commit)
- clear_commit_marks(cb.ref_commit, REACHABLE);
+
+ if (cb.unreachable_expire_kind != UE_ALWAYS) {
+ if (cb.unreachable_expire_kind == UE_HEAD) {
+ struct commit_list *elem;
+ for (elem = tips; elem; elem = elem->next)
+ clear_commit_marks(tip_commit, REACHABLE);
+ free_commit_list(tips);
+ } else {
+ clear_commit_marks(tip_commit, REACHABLE);
+ }
+ }
finish:
if (cb.newlog) {
if (fclose(cb.newlog)) {
diff --git a/builtin/remote.c b/builtin/remote.c
index 277765b86..4745957b9 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -16,6 +16,7 @@ static const char * const builtin_remote_usage[] = {
"git remote [-v | --verbose] show [-n] <name>",
"git remote prune [-n | --dry-run] <name>",
"git remote [-v | --verbose] update [-p | --prune] [group | remote]",
+ "git remote set-branches <name> [--add] <branch>...",
"git remote set-url <name> <newurl> [<oldurl>]",
"git remote set-url --add <name> <newurl>",
"git remote set-url --delete <name> <url>",
@@ -42,6 +43,12 @@ static const char * const builtin_remote_sethead_usage[] = {
NULL
};
+static const char * const builtin_remote_setbranches_usage[] = {
+ "git remote set-branches <name> <branch>...",
+ "git remote set-branches --add <name> <branch>...",
+ NULL
+};
+
static const char * const builtin_remote_show_usage[] = {
"git remote show [<options>] <name>",
NULL
@@ -104,9 +111,29 @@ static int fetch_remote(const char *name)
return 0;
}
+enum {
+ TAGS_UNSET = 0,
+ TAGS_DEFAULT = 1,
+ TAGS_SET = 2
+};
+
+static int add_branch(const char *key, const char *branchname,
+ const char *remotename, int mirror, struct strbuf *tmp)
+{
+ strbuf_reset(tmp);
+ strbuf_addch(tmp, '+');
+ if (mirror)
+ strbuf_addf(tmp, "refs/%s:refs/%s",
+ branchname, branchname);
+ else
+ strbuf_addf(tmp, "refs/heads/%s:refs/remotes/%s/%s",
+ branchname, remotename, branchname);
+ return git_config_set_multivar(key, tmp->buf, "^$", 0);
+}
+
static int add(int argc, const char **argv)
{
- int fetch = 0, mirror = 0;
+ int fetch = 0, mirror = 0, fetch_tags = TAGS_DEFAULT;
struct string_list track = { NULL, 0, 0 };
const char *master = NULL;
struct remote *remote;
@@ -116,6 +143,11 @@ static int add(int argc, const char **argv)
struct option options[] = {
OPT_BOOLEAN('f', "fetch", &fetch, "fetch the remote branches"),
+ OPT_SET_INT(0, "tags", &fetch_tags,
+ "import all tags and associated objects when fetching",
+ TAGS_SET),
+ OPT_SET_INT(0, NULL, &fetch_tags,
+ "or do not fetch any tag at all (--no-tags)", TAGS_UNSET),
OPT_CALLBACK('t', "track", &track, "branch",
"branch(es) to track", opt_parse_track),
OPT_STRING('m', "master", &master, "branch", "master branch"),
@@ -151,17 +183,8 @@ static int add(int argc, const char **argv)
if (track.nr == 0)
string_list_append("*", &track);
for (i = 0; i < track.nr; i++) {
- struct string_list_item *item = track.items + i;
-
- strbuf_reset(&buf2);
- strbuf_addch(&buf2, '+');
- if (mirror)
- strbuf_addf(&buf2, "refs/%s:refs/%s",
- item->string, item->string);
- else
- strbuf_addf(&buf2, "refs/heads/%s:refs/remotes/%s/%s",
- item->string, name, item->string);
- if (git_config_set_multivar(buf.buf, buf2.buf, "^$", 0))
+ if (add_branch(buf.buf, track.items[i].string,
+ name, mirror, &buf2))
return 1;
}
@@ -172,6 +195,14 @@ static int add(int argc, const char **argv)
return 1;
}
+ if (fetch_tags != TAGS_DEFAULT) {
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "remote.%s.tagopt", name);
+ if (git_config_set(buf.buf,
+ fetch_tags == TAGS_SET ? "--tags" : "--no-tags"))
+ return 1;
+ }
+
if (fetch && fetch_remote(name))
return 1;
@@ -1265,6 +1296,72 @@ static int update(int argc, const char **argv)
return run_command_v_opt(fetch_argv, RUN_GIT_CMD);
}
+static int remove_all_fetch_refspecs(const char *remote, const char *key)
+{
+ return git_config_set_multivar(key, NULL, NULL, 1);
+}
+
+static int add_branches(struct remote *remote, const char **branches,
+ const char *key)
+{
+ const char *remotename = remote->name;
+ int mirror = remote->mirror;
+ struct strbuf refspec = STRBUF_INIT;
+
+ for (; *branches; branches++)
+ if (add_branch(key, *branches, remotename, mirror, &refspec)) {
+ strbuf_release(&refspec);
+ return 1;
+ }
+
+ strbuf_release(&refspec);
+ return 0;
+}
+
+static int set_remote_branches(const char *remotename, const char **branches,
+ int add_mode)
+{
+ struct strbuf key = STRBUF_INIT;
+ struct remote *remote;
+
+ strbuf_addf(&key, "remote.%s.fetch", remotename);
+
+ if (!remote_is_configured(remotename))
+ die("No such remote '%s'", remotename);
+ remote = remote_get(remotename);
+
+ if (!add_mode && remove_all_fetch_refspecs(remotename, key.buf)) {
+ strbuf_release(&key);
+ return 1;
+ }
+ if (add_branches(remote, branches, key.buf)) {
+ strbuf_release(&key);
+ return 1;
+ }
+
+ strbuf_release(&key);
+ return 0;
+}
+
+static int set_branches(int argc, const char **argv)
+{
+ int add_mode = 0;
+ struct option options[] = {
+ OPT_BOOLEAN('\0', "add", &add_mode, "add branch"),
+ OPT_END()
+ };
+
+ argc = parse_options(argc, argv, NULL, options,
+ builtin_remote_setbranches_usage, 0);
+ if (argc == 0) {
+ error("no remote specified");
+ usage_with_options(builtin_remote_seturl_usage, options);
+ }
+ argv[argc] = NULL;
+
+ return set_remote_branches(argv[0], argv + 1, add_mode);
+}
+
static int set_url(int argc, const char **argv)
{
int i, push_mode = 0, add_mode = 0, delete_mode = 0;
@@ -1430,6 +1527,8 @@ int cmd_remote(int argc, const char **argv, const char *prefix)
result = rm(argc, argv);
else if (!strcmp(argv[0], "set-head"))
result = set_head(argc, argv);
+ else if (!strcmp(argv[0], "set-branches"))
+ result = set_branches(argc, argv);
else if (!strcmp(argv[0], "set-url"))
result = set_url(argc, argv);
else if (!strcmp(argv[0], "show"))
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 34f9acee9..0048f9ef7 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -89,7 +89,7 @@ static int diff_two(const char *file1, const char *label1,
printf("--- a/%s\n+++ b/%s\n", label1, label2);
fflush(stdout);
memset(&xpp, 0, sizeof(xpp));
- xpp.flags = XDF_NEED_MINIMAL;
+ xpp.flags = 0;
memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = 3;
ecb.outf = outf;
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 06320f528..508950280 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -162,7 +162,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
sha1_to_hex(commit->object.sha1));
if (log->user_format) {
struct pretty_print_context ctx = {0};
- ctx.abbrev = DEFAULT_ABBREV;
+ ctx.abbrev = log->abbrev;
ctx.subject = "";
ctx.after_subject = "";
ctx.date_mode = DATE_NORMAL;
@@ -290,6 +290,7 @@ parse_done:
}
log.user_format = rev.commit_format == CMIT_FMT_USERFORMAT;
+ log.abbrev = rev.abbrev;
/* assume HEAD if from a tty */
if (!nongit && !rev.pending.nr && isatty(0))
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index e20fcf3e9..e8719aa9e 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -313,7 +313,8 @@ static void show_one_commit(struct commit *commit, int no_name)
}
else
printf("[%s] ",
- find_unique_abbrev(commit->object.sha1, 7));
+ find_unique_abbrev(commit->object.sha1,
+ DEFAULT_ABBREV));
}
puts(pretty_str);
strbuf_release(&pretty);
diff --git a/cache.h b/cache.h
index 0f4263c09..c96602305 100644
--- a/cache.h
+++ b/cache.h
@@ -907,7 +907,7 @@ struct extra_have_objects {
extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match, unsigned int flags, struct extra_have_objects *);
extern int server_supports(const char *feature);
-extern struct packed_git *parse_pack_index(unsigned char *sha1);
+extern struct packed_git *parse_pack_index(unsigned char *sha1, const char *idx_path);
extern void prepare_packed_git(void);
extern void reprepare_packed_git(void);
@@ -918,6 +918,7 @@ extern struct packed_git *find_sha1_pack(const unsigned char *sha1,
extern void pack_report(void);
extern int open_pack_index(struct packed_git *);
+extern void close_pack_index(struct packed_git *);
extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned int *);
extern void close_pack_windows(struct packed_git *);
extern void unuse_pack(struct pack_window **);
@@ -938,6 +939,8 @@ extern int update_server_info(int);
typedef int (*config_fn_t)(const char *, const char *, void *);
extern int git_default_config(const char *, const char *, void *);
extern int git_config_from_file(config_fn_t fn, const char *, void *);
+extern int git_config_parse_parameter(const char *text);
+extern int git_config_from_parameters(config_fn_t fn, void *data);
extern int git_config(config_fn_t fn, void *);
extern int git_parse_ulong(const char *, unsigned long *);
extern int git_config_int(const char *, const char *);
@@ -952,6 +955,7 @@ extern int git_config_set_multivar(const char *, const char *, const char *, int
extern int git_config_rename_section(const char *, const char *);
extern const char *git_etc_gitconfig(void);
extern int check_repository_format_version(const char *var, const char *value, void *cb);
+extern int git_env_bool(const char *, int);
extern int git_config_system(void);
extern int git_config_global(void);
extern int config_error_nonbool(const char *);
diff --git a/color.c b/color.c
index bcf4e2c19..1b00554dd 100644
--- a/color.c
+++ b/color.c
@@ -211,31 +211,3 @@ int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...)
va_end(args);
return r;
}
-
-/*
- * This function splits the buffer by newlines and colors the lines individually.
- *
- * Returns 0 on success.
- */
-int color_fwrite_lines(FILE *fp, const char *color,
- size_t count, const char *buf)
-{
- if (!*color)
- return fwrite(buf, count, 1, fp) != 1;
- while (count) {
- char *p = memchr(buf, '\n', count);
- if (p != buf && (fputs(color, fp) < 0 ||
- fwrite(buf, p ? p - buf : count, 1, fp) != 1 ||
- fputs(GIT_COLOR_RESET, fp) < 0))
- return -1;
- if (!p)
- return 0;
- if (fputc('\n', fp) < 0)
- return -1;
- count -= p + 1 - buf;
- buf = p + 1;
- }
- return 0;
-}
-
-
diff --git a/color.h b/color.h
index 5c264b0ce..03ca06474 100644
--- a/color.h
+++ b/color.h
@@ -61,6 +61,5 @@ __attribute__((format (printf, 3, 4)))
int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
__attribute__((format (printf, 3, 4)))
int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
-int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf);
#endif /* COLOR_H */
diff --git a/combine-diff.c b/combine-diff.c
index 7557136c8..655fa89d8 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -220,7 +220,7 @@ static void combine_diff(const unsigned char *parent, unsigned int mode,
parent_file.ptr = grab_blob(parent, mode, &sz);
parent_file.size = sz;
memset(&xpp, 0, sizeof(xpp));
- xpp.flags = XDF_NEED_MINIMAL;
+ xpp.flags = 0;
memset(&xecfg, 0, sizeof(xecfg));
memset(&state, 0, sizeof(state));
state.nmask = nmask;
diff --git a/compat/mingw.c b/compat/mingw.c
index f90a114b0..9a8e33658 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -140,6 +140,23 @@ int mingw_open (const char *filename, int oflags, ...)
return fd;
}
+#undef write
+ssize_t mingw_write(int fd, const void *buf, size_t count)
+{
+ /*
+ * While write() calls to a file on a local disk are translated
+ * into WriteFile() calls with a maximum size of 64KB on Windows
+ * XP and 256KB on Vista, no such cap is placed on writes to
+ * files over the network on Windows XP. Unfortunately, there
+ * seems to be a limit of 32MB-28KB on X64 and 64MB-32KB on x86;
+ * bigger writes fail on Windows XP.
+ * So we cap to a nice 31MB here to avoid write failures over
+ * the net without changing the number of WriteFile() calls in
+ * the local case.
+ */
+ return write(fd, buf, min(count, 31 * 1024 * 1024));
+}
+
#undef fopen
FILE *mingw_fopen (const char *filename, const char *otype)
{
diff --git a/compat/mingw.h b/compat/mingw.h
index 7c2ab64cb..f465566b7 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -80,7 +80,7 @@ static inline int fork(void)
static inline unsigned int alarm(unsigned int seconds)
{ return 0; }
static inline int fsync(int fd)
-{ return 0; }
+{ return _commit(fd); }
static inline int getppid(void)
{ return 1; }
static inline void sync(void)
@@ -170,6 +170,9 @@ int link(const char *oldpath, const char *newpath);
int mingw_open (const char *filename, int oflags, ...);
#define open mingw_open
+ssize_t mingw_write(int fd, const void *buf, size_t count);
+#define write mingw_write
+
FILE *mingw_fopen (const char *filename, const char *otype);
#define fopen mingw_fopen
diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
index c72f100f4..a45f8d66d 100644
--- a/compat/win32/pthread.h
+++ b/compat/win32/pthread.h
@@ -18,11 +18,17 @@
*/
#define pthread_mutex_t CRITICAL_SECTION
-#define pthread_mutex_init(a,b) InitializeCriticalSection((a))
+#define pthread_mutex_init(a,b) (InitializeCriticalSection((a)), 0)
#define pthread_mutex_destroy(a) DeleteCriticalSection((a))
#define pthread_mutex_lock EnterCriticalSection
#define pthread_mutex_unlock LeaveCriticalSection
+typedef int pthread_mutexattr_t;
+#define pthread_mutexattr_init(a) (*(a) = 0)
+#define pthread_mutexattr_destroy(a) do {} while (0)
+#define pthread_mutexattr_settype(a, t) 0
+#define PTHREAD_MUTEX_RECURSIVE 0
+
/*
* Implement simple condition variable for Windows threads, based on ACE
* implementation.
diff --git a/compat/win32mmap.c b/compat/win32mmap.c
index 1c5a14922..b58aa69fa 100644
--- a/compat/win32mmap.c
+++ b/compat/win32mmap.c
@@ -4,19 +4,19 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of
{
HANDLE hmap;
void *temp;
- size_t len;
+ off_t len;
struct stat st;
uint64_t o = offset;
uint32_t l = o & 0xFFFFFFFF;
uint32_t h = (o >> 32) & 0xFFFFFFFF;
if (!fstat(fd, &st))
- len = xsize_t(st.st_size);
+ len = st.st_size;
else
die("mmap: could not determine filesize");
if ((length + offset) > len)
- length = len - offset;
+ length = xsize_t(len - offset);
if (!(flags & MAP_PRIVATE))
die("Invalid usage of mmap when built with USE_WIN32_MMAP");
diff --git a/config.c b/config.c
index 64e41bea2..9b6b1df21 100644
--- a/config.c
+++ b/config.c
@@ -7,6 +7,7 @@
*/
#include "cache.h"
#include "exec_cmd.h"
+#include "strbuf.h"
#define MAXNAME (256)
@@ -18,6 +19,48 @@ static int zlib_compression_seen;
const char *config_exclusive_filename = NULL;
+struct config_item
+{
+ struct config_item *next;
+ char *name;
+ char *value;
+};
+static struct config_item *config_parameters;
+static struct config_item **config_parameters_tail = &config_parameters;
+
+static void lowercase(char *p)
+{
+ for (; *p; p++)
+ *p = tolower(*p);
+}
+
+int git_config_parse_parameter(const char *text)
+{
+ struct config_item *ct;
+ struct strbuf tmp = STRBUF_INIT;
+ struct strbuf **pair;
+ strbuf_addstr(&tmp, text);
+ pair = strbuf_split(&tmp, '=');
+ if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=')
+ strbuf_setlen(pair[0], pair[0]->len - 1);
+ strbuf_trim(pair[0]);
+ if (!pair[0]->len) {
+ strbuf_list_free(pair);
+ return -1;
+ }
+ ct = xcalloc(1, sizeof(struct config_item));
+ ct->name = strbuf_detach(pair[0], NULL);
+ if (pair[1]) {
+ strbuf_trim(pair[1]);
+ ct->value = strbuf_detach(pair[1], NULL);
+ }
+ strbuf_list_free(pair);
+ lowercase(ct->name);
+ *config_parameters_tail = ct;
+ config_parameters_tail = &ct->next;
+ return 0;
+}
+
static int get_next_char(void)
{
int c;
@@ -696,7 +739,7 @@ const char *git_etc_gitconfig(void)
return system_wide;
}
-static int git_env_bool(const char *k, int def)
+int git_env_bool(const char *k, int def)
{
const char *v = getenv(k);
return v ? git_config_bool(k, v) : def;
@@ -712,6 +755,15 @@ int git_config_global(void)
return !git_env_bool("GIT_CONFIG_NOGLOBAL", 0);
}
+int git_config_from_parameters(config_fn_t fn, void *data)
+{
+ const struct config_item *ct;
+ for (ct = config_parameters; ct; ct = ct->next)
+ if (fn(ct->name, ct->value, data) < 0)
+ return -1;
+ return 0;
+}
+
int git_config(config_fn_t fn, void *data)
{
int ret = 0, found = 0;
@@ -743,6 +795,12 @@ int git_config(config_fn_t fn, void *data)
found += 1;
}
free(repo_config);
+
+ if (config_parameters) {
+ ret += git_config_from_parameters(fn, data);
+ found += 1;
+ }
+
if (found == 0)
return -1;
return ret;
diff --git a/config.mak.in b/config.mak.in
index 6008ac9f1..0d4b64d07 100644
--- a/config.mak.in
+++ b/config.mak.in
@@ -31,6 +31,7 @@ NO_OPENSSL=@NO_OPENSSL@
NO_CURL=@NO_CURL@
NO_EXPAT=@NO_EXPAT@
NO_LIBGEN_H=@NO_LIBGEN_H@
+HAVE_PATHS_H=@HAVE_PATHS_H@
NEEDS_LIBICONV=@NEEDS_LIBICONV@
NEEDS_SOCKET=@NEEDS_SOCKET@
NEEDS_RESOLV=@NEEDS_RESOLV@
diff --git a/configure.ac b/configure.ac
index f4d7372ef..71038fcf1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -724,6 +724,12 @@ AC_CHECK_HEADER([libgen.h],
[NO_LIBGEN_H=YesPlease])
AC_SUBST(NO_LIBGEN_H)
#
+# Define HAVE_PATHS_H if you have paths.h.
+AC_CHECK_HEADER([paths.h],
+[HAVE_PATHS_H=YesPlease],
+[HAVE_PATHS_H=])
+AC_SUBST(HAVE_PATHS_H)
+#
# Define NO_STRCASESTR if you don't have strcasestr.
GIT_CHECK_FUNC(strcasestr,
[NO_STRCASESTR=],
diff --git a/connect.c b/connect.c
index 9ae991ac4..0119bd377 100644
--- a/connect.c
+++ b/connect.c
@@ -5,6 +5,7 @@
#include "refs.h"
#include "run-command.h"
#include "remote.h"
+#include "url.h"
static char *server_capabilities;
@@ -450,7 +451,7 @@ static struct child_process no_fork;
struct child_process *git_connect(int fd[2], const char *url_orig,
const char *prog, int flags)
{
- char *url = xstrdup(url_orig);
+ char *url;
char *host, *path;
char *end;
int c;
@@ -466,6 +467,11 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
*/
signal(SIGCHLD, SIG_DFL);
+ if (is_url(url_orig))
+ url = url_decode(url_orig);
+ else
+ url = xstrdup(url_orig);
+
host = strstr(url, "://");
if (host) {
*host = '\0';
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 545bd4b38..57245a8c0 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -797,6 +797,7 @@ _git_branch ()
__gitcomp "
--color --no-color --verbose --abbrev= --no-abbrev
--track --no-track --contains --merged --no-merged
+ --set-upstream
"
;;
*)
diff --git a/contrib/examples/git-fetch.sh b/contrib/examples/git-fetch.sh
index e44af2c86..a314273bd 100755
--- a/contrib/examples/git-fetch.sh
+++ b/contrib/examples/git-fetch.sh
@@ -127,10 +127,12 @@ then
orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
fi
-# Allow --notags from remote.$1.tagopt
+# Allow --tags/--notags from remote.$1.tagopt
case "$tags$no_tags" in
'')
case "$(git config --get "remote.$1.tagopt")" in
+ --tags)
+ tags=t ;;
--no-tags)
no_tags=t ;;
esac
diff --git a/contrib/git-resurrect.sh b/contrib/git-resurrect.sh
index c364dda69..a4ed4c3c6 100755
--- a/contrib/git-resurrect.sh
+++ b/contrib/git-resurrect.sh
@@ -9,6 +9,7 @@ other/Merge <other> into <name> (respectively) commit subjects, which
is rather slow but allows you to resurrect other people's topic
branches."
+OPTIONS_KEEPDASHDASH=
OPTIONS_SPEC="\
git resurrect $USAGE
--
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index 58a35c828..30ae63d74 100755
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -23,6 +23,13 @@
# possible for the email to be from someone other than the person doing the
# push.
#
+# To help with debugging and use on pre-v1.5.1 git servers, this script will
+# also obey the interface of hooks/update, taking its arguments on the
+# command line. Unfortunately, hooks/update is called once for each ref.
+# To avoid firing one email per ref, this script just prints its output to
+# the screen when used in this mode. The output can then be redirected if
+# wanted.
+#
# Config
# ------
# hooks.mailinglist
diff --git a/convert.c b/convert.c
index 4f8fcb7bb..5a0b7fbca 100644
--- a/convert.c
+++ b/convert.c
@@ -425,6 +425,8 @@ static int count_ident(const char *cp, unsigned long size)
cnt++;
break;
}
+ if (ch == '\n')
+ break;
}
}
return cnt;
@@ -455,6 +457,11 @@ static int ident_to_git(const char *path, const char *src, size_t len,
dollar = memchr(src + 3, '$', len - 3);
if (!dollar)
break;
+ if (memchr(src + 3, '\n', dollar - src - 3)) {
+ /* Line break before the next dollar. */
+ continue;
+ }
+
memcpy(dst, "Id$", 3);
dst += 3;
len -= dollar + 1 - src;
@@ -470,7 +477,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
struct strbuf *buf, int ident)
{
unsigned char sha1[20];
- char *to_free = NULL, *dollar;
+ char *to_free = NULL, *dollar, *spc;
int cnt;
if (!ident)
@@ -506,7 +513,10 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
} else if (src[2] == ':') {
/*
* It's possible that an expanded Id has crept its way into the
- * repository, we cope with that by stripping the expansion out
+ * repository, we cope with that by stripping the expansion out.
+ * This is probably not a good idea, since it will cause changes
+ * on checkout, which won't go away by stash, but let's keep it
+ * for git-style ids.
*/
dollar = memchr(src + 3, '$', len - 3);
if (!dollar) {
@@ -514,6 +524,20 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
break;
}
+ if (memchr(src + 3, '\n', dollar - src - 3)) {
+ /* Line break before the next dollar. */
+ continue;
+ }
+
+ spc = memchr(src + 4, ' ', dollar - src - 4);
+ if (spc && spc < dollar-1) {
+ /* There are spaces in unexpected places.
+ * This is probably an id from some other
+ * versioning system. Keep it for now.
+ */
+ continue;
+ }
+
len -= dollar + 1 - src;
src = dollar + 1;
} else {
diff --git a/date.c b/date.c
index 002aa3c8d..6bae49ca3 100644
--- a/date.c
+++ b/date.c
@@ -229,6 +229,7 @@ static const struct {
{ "GMT", 0, 0, }, /* Greenwich Mean */
{ "UTC", 0, 0, }, /* Universal (Coordinated) */
+ { "Z", 0, 0, }, /* Zulu, alias for UTC */
{ "WET", 0, 0, }, /* Western European */
{ "BST", 0, 1, }, /* British Summer */
@@ -305,7 +306,7 @@ static int match_alpha(const char *date, struct tm *tm, int *offset)
for (i = 0; i < ARRAY_SIZE(timezone_names); i++) {
int match = match_string(date, timezone_names[i].name);
- if (match >= 3) {
+ if (match >= 3 || match == strlen(timezone_names[i].name)) {
int off = timezone_names[i].offset;
/* This is bogus, but we like summer */
diff --git a/diff-no-index.c b/diff-no-index.c
index aae8e7acc..4cd9dacbe 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -150,16 +150,14 @@ static int queue_diff(struct diff_options *o,
static int path_outside_repo(const char *path)
{
- /*
- * We have already done setup_git_directory_gently() so we
- * know we are inside a git work tree already.
- */
const char *work_tree;
size_t len;
if (!is_absolute_path(path))
return 0;
work_tree = get_git_work_tree();
+ if (!work_tree)
+ return 1;
len = strlen(work_tree);
if (strncmp(path, work_tree, len) ||
(path[len] != '\0' && path[len] != '/'))
diff --git a/diff.c b/diff.c
index 6d9928cb9..c82b605a9 100644
--- a/diff.c
+++ b/diff.c
@@ -565,16 +565,68 @@ static void diff_words_append(char *line, unsigned long len,
buffer->text.ptr[buffer->text.size] = '\0';
}
+struct diff_words_style_elem
+{
+ const char *prefix;
+ const char *suffix;
+ const char *color; /* NULL; filled in by the setup code if
+ * color is enabled */
+};
+
+struct diff_words_style
+{
+ enum diff_words_type type;
+ struct diff_words_style_elem new, old, ctx;
+ const char *newline;
+};
+
+struct diff_words_style diff_words_styles[] = {
+ { DIFF_WORDS_PORCELAIN, {"+", "\n"}, {"-", "\n"}, {" ", "\n"}, "~\n" },
+ { DIFF_WORDS_PLAIN, {"{+", "+}"}, {"[-", "-]"}, {"", ""}, "\n" },
+ { DIFF_WORDS_COLOR, {"", ""}, {"", ""}, {"", ""}, "\n" }
+};
+
struct diff_words_data {
struct diff_words_buffer minus, plus;
const char *current_plus;
FILE *file;
regex_t *word_regex;
+ enum diff_words_type type;
+ struct diff_words_style *style;
};
+static int fn_out_diff_words_write_helper(FILE *fp,
+ struct diff_words_style_elem *st_el,
+ const char *newline,
+ size_t count, const char *buf)
+{
+ while (count) {
+ char *p = memchr(buf, '\n', count);
+ if (p != buf) {
+ if (st_el->color && fputs(st_el->color, fp) < 0)
+ return -1;
+ if (fputs(st_el->prefix, fp) < 0 ||
+ fwrite(buf, p ? p - buf : count, 1, fp) != 1 ||
+ fputs(st_el->suffix, fp) < 0)
+ return -1;
+ if (st_el->color && *st_el->color
+ && fputs(GIT_COLOR_RESET, fp) < 0)
+ return -1;
+ }
+ if (!p)
+ return 0;
+ if (fputs(newline, fp) < 0)
+ return -1;
+ count -= p + 1 - buf;
+ buf = p + 1;
+ }
+ return 0;
+}
+
static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)
{
struct diff_words_data *diff_words = priv;
+ struct diff_words_style *style = diff_words->style;
int minus_first, minus_len, plus_first, plus_len;
const char *minus_begin, *minus_end, *plus_begin, *plus_end;
@@ -598,16 +650,17 @@ static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)
plus_begin = plus_end = diff_words->plus.orig[plus_first].end;
if (diff_words->current_plus != plus_begin)
- fwrite(diff_words->current_plus,
- plus_begin - diff_words->current_plus, 1,
- diff_words->file);
+ fn_out_diff_words_write_helper(diff_words->file,
+ &style->ctx, style->newline,
+ plus_begin - diff_words->current_plus,
+ diff_words->current_plus);
if (minus_begin != minus_end)
- color_fwrite_lines(diff_words->file,
- diff_get_color(1, DIFF_FILE_OLD),
+ fn_out_diff_words_write_helper(diff_words->file,
+ &style->old, style->newline,
minus_end - minus_begin, minus_begin);
if (plus_begin != plus_end)
- color_fwrite_lines(diff_words->file,
- diff_get_color(1, DIFF_FILE_NEW),
+ fn_out_diff_words_write_helper(diff_words->file,
+ &style->new, style->newline,
plus_end - plus_begin, plus_begin);
diff_words->current_plus = plus_end;
@@ -689,11 +742,12 @@ static void diff_words_show(struct diff_words_data *diff_words)
xpparam_t xpp;
xdemitconf_t xecfg;
mmfile_t minus, plus;
+ struct diff_words_style *style = diff_words->style;
/* special case: only removal */
if (!diff_words->plus.text.size) {
- color_fwrite_lines(diff_words->file,
- diff_get_color(1, DIFF_FILE_OLD),
+ fn_out_diff_words_write_helper(diff_words->file,
+ &style->old, style->newline,
diff_words->minus.text.size, diff_words->minus.text.ptr);
diff_words->minus.text.size = 0;
return;
@@ -705,7 +759,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
memset(&xecfg, 0, sizeof(xecfg));
diff_words_fill(&diff_words->minus, &minus, diff_words->word_regex);
diff_words_fill(&diff_words->plus, &plus, diff_words->word_regex);
- xpp.flags = XDF_NEED_MINIMAL;
+ xpp.flags = 0;
/* as only the hunk header will be parsed, we need a 0-context */
xecfg.ctxlen = 0;
xdi_diff_outf(&minus, &plus, fn_out_diff_words_aux, diff_words,
@@ -714,10 +768,10 @@ static void diff_words_show(struct diff_words_data *diff_words)
free(plus.ptr);
if (diff_words->current_plus != diff_words->plus.text.ptr +
diff_words->plus.text.size)
- fwrite(diff_words->current_plus,
+ fn_out_diff_words_write_helper(diff_words->file,
+ &style->ctx, style->newline,
diff_words->plus.text.ptr + diff_words->plus.text.size
- - diff_words->current_plus, 1,
- diff_words->file);
+ - diff_words->current_plus, diff_words->current_plus);
diff_words->minus.text.size = diff_words->plus.text.size = 0;
}
@@ -829,6 +883,9 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
if (len < 1) {
emit_line(ecbdata->file, reset, reset, line, len);
+ if (ecbdata->diff_words
+ && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)
+ fputs("~\n", ecbdata->file);
return;
}
@@ -843,9 +900,13 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
return;
}
diff_words_flush(ecbdata);
- line++;
- len--;
- emit_line(ecbdata->file, plain, reset, line, len);
+ if (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {
+ emit_line(ecbdata->file, plain, reset, line, len);
+ fputs("~\n", ecbdata->file);
+ } else {
+ /* don't print the prefix character */
+ emit_line(ecbdata->file, plain, reset, line+1, len-1);
+ }
return;
}
@@ -1650,21 +1711,21 @@ static void builtin_diff(const char *name_a,
if (lbl[0][0] == '/') {
/* /dev/null */
strbuf_addf(&header, "%snew file mode %06o%s\n", set, two->mode, reset);
- if (xfrm_msg && xfrm_msg[0])
- strbuf_addf(&header, "%s%s%s\n", set, xfrm_msg, reset);
+ if (xfrm_msg)
+ strbuf_addstr(&header, xfrm_msg);
}
else if (lbl[1][0] == '/') {
strbuf_addf(&header, "%sdeleted file mode %06o%s\n", set, one->mode, reset);
- if (xfrm_msg && xfrm_msg[0])
- strbuf_addf(&header, "%s%s%s\n", set, xfrm_msg, reset);
+ if (xfrm_msg)
+ strbuf_addstr(&header, xfrm_msg);
}
else {
if (one->mode != two->mode) {
strbuf_addf(&header, "%sold mode %06o%s\n", set, one->mode, reset);
strbuf_addf(&header, "%snew mode %06o%s\n", set, two->mode, reset);
}
- if (xfrm_msg && xfrm_msg[0])
- strbuf_addf(&header, "%s%s%s\n", set, xfrm_msg, reset);
+ if (xfrm_msg)
+ strbuf_addstr(&header, xfrm_msg);
/*
* we do not run diff between different kind
@@ -1733,7 +1794,7 @@ static void builtin_diff(const char *name_a,
check_blank_at_eof(&mf1, &mf2, &ecbdata);
ecbdata.file = o->file;
ecbdata.header = header.len ? &header : NULL;
- xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
+ xpp.flags = o->xdl_opts;
xecfg.ctxlen = o->context;
xecfg.interhunkctxlen = o->interhunkcontext;
xecfg.flags = XDL_EMIT_FUNCNAMES;
@@ -1745,10 +1806,13 @@ static void builtin_diff(const char *name_a,
xecfg.ctxlen = strtoul(diffopts + 10, NULL, 10);
else if (!prefixcmp(diffopts, "-u"))
xecfg.ctxlen = strtoul(diffopts + 2, NULL, 10);
- if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS)) {
+ if (o->word_diff) {
+ int i;
+
ecbdata.diff_words =
xcalloc(1, sizeof(struct diff_words_data));
ecbdata.diff_words->file = o->file;
+ ecbdata.diff_words->type = o->word_diff;
if (!o->word_regex)
o->word_regex = userdiff_word_regex(one);
if (!o->word_regex)
@@ -1764,10 +1828,23 @@ static void builtin_diff(const char *name_a,
die ("Invalid regular expression: %s",
o->word_regex);
}
+ for (i = 0; i < ARRAY_SIZE(diff_words_styles); i++) {
+ if (o->word_diff == diff_words_styles[i].type) {
+ ecbdata.diff_words->style =
+ &diff_words_styles[i];
+ break;
+ }
+ }
+ if (DIFF_OPT_TST(o, COLOR_DIFF)) {
+ struct diff_words_style *st = ecbdata.diff_words->style;
+ st->old.color = diff_get_color_opt(o, DIFF_FILE_OLD);
+ st->new.color = diff_get_color_opt(o, DIFF_FILE_NEW);
+ st->ctx.color = diff_get_color_opt(o, DIFF_PLAIN);
+ }
}
xdi_diff_outf(&mf1, &mf2, fn_out_consume, &ecbdata,
&xpp, &xecfg);
- if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))
+ if (o->word_diff)
free_diff_words_data(&ecbdata);
if (textconv_one)
free(mf1.ptr);
@@ -1822,7 +1899,7 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
memset(&xpp, 0, sizeof(xpp));
memset(&xecfg, 0, sizeof(xecfg));
- xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
+ xpp.flags = o->xdl_opts;
xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
&xpp, &xecfg);
}
@@ -1870,7 +1947,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
memset(&xpp, 0, sizeof(xpp));
memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = 1; /* at least one context line */
- xpp.flags = XDF_NEED_MINIMAL;
+ xpp.flags = 0;
xdi_diff_outf(&mf1, &mf2, checkdiff_consume, &data,
&xpp, &xecfg);
@@ -2307,30 +2384,36 @@ static void fill_metainfo(struct strbuf *msg,
struct diff_filespec *one,
struct diff_filespec *two,
struct diff_options *o,
- struct diff_filepair *p)
+ struct diff_filepair *p,
+ int use_color)
{
+ const char *set = diff_get_color(use_color, DIFF_METAINFO);
+ const char *reset = diff_get_color(use_color, DIFF_RESET);
+
strbuf_init(msg, PATH_MAX * 2 + 300);
switch (p->status) {
case DIFF_STATUS_COPIED:
- strbuf_addf(msg, "similarity index %d%%", similarity_index(p));
- strbuf_addstr(msg, "\ncopy from ");
+ strbuf_addf(msg, "%ssimilarity index %d%%",
+ set, similarity_index(p));
+ strbuf_addf(msg, "%s\n%scopy from ", reset, set);
quote_c_style(name, msg, NULL, 0);
- strbuf_addstr(msg, "\ncopy to ");
+ strbuf_addf(msg, "%s\n%scopy to ", reset, set);
quote_c_style(other, msg, NULL, 0);
- strbuf_addch(msg, '\n');
+ strbuf_addf(msg, "%s\n", reset);
break;
case DIFF_STATUS_RENAMED:
- strbuf_addf(msg, "similarity index %d%%", similarity_index(p));
- strbuf_addstr(msg, "\nrename from ");
+ strbuf_addf(msg, "%ssimilarity index %d%%",
+ set, similarity_index(p));
+ strbuf_addf(msg, "%s\n%srename from ", reset, set);
quote_c_style(name, msg, NULL, 0);
- strbuf_addstr(msg, "\nrename to ");
+ strbuf_addf(msg, "%s\n%srename to ", reset, set);
quote_c_style(other, msg, NULL, 0);
- strbuf_addch(msg, '\n');
+ strbuf_addf(msg, "%s\n", reset);
break;
case DIFF_STATUS_MODIFIED:
if (p->score) {
- strbuf_addf(msg, "dissimilarity index %d%%\n",
- similarity_index(p));
+ strbuf_addf(msg, "%sdissimilarity index %d%%%s\n",
+ set, similarity_index(p), reset);
break;
}
/* fallthru */
@@ -2347,15 +2430,13 @@ static void fill_metainfo(struct strbuf *msg,
(!fill_mmfile(&mf, two) && diff_filespec_is_binary(two)))
abbrev = 40;
}
- strbuf_addf(msg, "index %.*s..%.*s",
+ strbuf_addf(msg, "%sindex %.*s..%.*s", set,
abbrev, sha1_to_hex(one->sha1),
abbrev, sha1_to_hex(two->sha1));
if (one->mode == two->mode)
strbuf_addf(msg, " %06o", one->mode);
- strbuf_addch(msg, '\n');
+ strbuf_addf(msg, "%s\n", reset);
}
- if (msg->len)
- strbuf_setlen(msg, msg->len - 1);
}
static void run_diff_cmd(const char *pgm,
@@ -2371,11 +2452,6 @@ static void run_diff_cmd(const char *pgm,
const char *xfrm_msg = NULL;
int complete_rewrite = (p->status == DIFF_STATUS_MODIFIED) && p->score;
- if (msg) {
- fill_metainfo(msg, name, other, one, two, o, p);
- xfrm_msg = msg->len ? msg->buf : NULL;
- }
-
if (!DIFF_OPT_TST(o, ALLOW_EXTERNAL))
pgm = NULL;
else {
@@ -2384,6 +2460,16 @@ static void run_diff_cmd(const char *pgm,
pgm = drv->external;
}
+ if (msg) {
+ /*
+ * don't use colors when the header is intended for an
+ * external diff driver
+ */
+ fill_metainfo(msg, name, other, one, two, o, p,
+ DIFF_OPT_TST(o, COLOR_DIFF) && !pgm);
+ xfrm_msg = msg->len ? msg->buf : NULL;
+ }
+
if (pgm) {
run_external_diff(pgm, name, other, one, two, xfrm_msg,
complete_rewrite);
@@ -2528,6 +2614,7 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
void diff_setup(struct diff_options *options)
{
memset(options, 0, sizeof(*options));
+ memset(&diff_queued_diff, 0, sizeof(diff_queued_diff));
options->file = stdout;
@@ -2708,7 +2795,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
const char *arg = av[0];
/* Output format options */
- if (!strcmp(arg, "-p") || !strcmp(arg, "-u"))
+ if (!strcmp(arg, "-p") || !strcmp(arg, "-u") || !strcmp(arg, "--patch"))
options->output_format |= DIFF_FORMAT_PATCH;
else if (opt_arg(arg, 'U', "unified", &options->context))
options->output_format |= DIFF_FORMAT_PATCH;
@@ -2836,13 +2923,37 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
DIFF_OPT_CLR(options, COLOR_DIFF);
else if (!strcmp(arg, "--color-words")) {
DIFF_OPT_SET(options, COLOR_DIFF);
- DIFF_OPT_SET(options, COLOR_DIFF_WORDS);
+ options->word_diff = DIFF_WORDS_COLOR;
}
else if (!prefixcmp(arg, "--color-words=")) {
DIFF_OPT_SET(options, COLOR_DIFF);
- DIFF_OPT_SET(options, COLOR_DIFF_WORDS);
+ options->word_diff = DIFF_WORDS_COLOR;
options->word_regex = arg + 14;
}
+ else if (!strcmp(arg, "--word-diff")) {
+ if (options->word_diff == DIFF_WORDS_NONE)
+ options->word_diff = DIFF_WORDS_PLAIN;
+ }
+ else if (!prefixcmp(arg, "--word-diff=")) {
+ const char *type = arg + 12;
+ if (!strcmp(type, "plain"))
+ options->word_diff = DIFF_WORDS_PLAIN;
+ else if (!strcmp(type, "color")) {
+ DIFF_OPT_SET(options, COLOR_DIFF);
+ options->word_diff = DIFF_WORDS_COLOR;
+ }
+ else if (!strcmp(type, "porcelain"))
+ options->word_diff = DIFF_WORDS_PORCELAIN;
+ else if (!strcmp(type, "none"))
+ options->word_diff = DIFF_WORDS_NONE;
+ else
+ die("bad --word-diff argument: %s", type);
+ }
+ else if (!prefixcmp(arg, "--word-diff-regex=")) {
+ if (options->word_diff == DIFF_WORDS_NONE)
+ options->word_diff = DIFF_WORDS_PLAIN;
+ options->word_regex = arg + 18;
+ }
else if (!strcmp(arg, "--exit-code"))
DIFF_OPT_SET(options, EXIT_WITH_STATUS);
else if (!strcmp(arg, "--quiet"))
@@ -3426,7 +3537,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
len2, p->two->path);
git_SHA1_Update(&ctx, buffer, len1);
- xpp.flags = XDF_NEED_MINIMAL;
+ xpp.flags = 0;
xecfg.ctxlen = 3;
xecfg.flags = XDL_EMIT_FUNCNAMES;
xdi_diff_outf(&mf1, &mf2, patch_id_consume, &data,
@@ -3447,8 +3558,7 @@ int diff_flush_patch_id(struct diff_options *options, unsigned char *sha1)
diff_free_filepair(q->queue[i]);
free(q->queue);
- q->queue = NULL;
- q->nr = q->alloc = 0;
+ DIFF_QUEUE_CLEAR(q);
return result;
}
@@ -3576,8 +3686,7 @@ void diff_flush(struct diff_options *options)
diff_free_filepair(q->queue[i]);
free_queue:
free(q->queue);
- q->queue = NULL;
- q->nr = q->alloc = 0;
+ DIFF_QUEUE_CLEAR(q);
if (options->close_file)
fclose(options->file);
@@ -3599,8 +3708,7 @@ static void diffcore_apply_filter(const char *filter)
int i;
struct diff_queue_struct *q = &diff_queued_diff;
struct diff_queue_struct outq;
- outq.queue = NULL;
- outq.nr = outq.alloc = 0;
+ DIFF_QUEUE_CLEAR(&outq);
if (!filter)
return;
@@ -3668,8 +3776,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
int i;
struct diff_queue_struct *q = &diff_queued_diff;
struct diff_queue_struct outq;
- outq.queue = NULL;
- outq.nr = outq.alloc = 0;
+ DIFF_QUEUE_CLEAR(&outq);
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
@@ -3730,6 +3837,12 @@ void diffcore_fix_diff_index(struct diff_options *options)
void diffcore_std(struct diff_options *options)
{
+ /* We never run this function more than one time, because the
+ * rename/copy detection logic can only run once.
+ */
+ if (diff_queued_diff.run)
+ return;
+
if (options->skip_stat_unmatch)
diffcore_skip_stat_unmatch(options);
if (options->break_opt != -1)
@@ -3749,6 +3862,8 @@ void diffcore_std(struct diff_options *options)
DIFF_OPT_SET(options, HAS_CHANGES);
else
DIFF_OPT_CLR(options, HAS_CHANGES);
+
+ diff_queued_diff.run = 1;
}
int diff_result_code(struct diff_options *opt, int status)
diff --git a/diff.h b/diff.h
index 6a71013dc..9ace08cba 100644
--- a/diff.h
+++ b/diff.h
@@ -54,7 +54,7 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
#define DIFF_OPT_FIND_COPIES_HARDER (1 << 6)
#define DIFF_OPT_FOLLOW_RENAMES (1 << 7)
#define DIFF_OPT_COLOR_DIFF (1 << 8)
-#define DIFF_OPT_COLOR_DIFF_WORDS (1 << 9)
+/* (1 << 9) unused */
#define DIFF_OPT_HAS_CHANGES (1 << 10)
#define DIFF_OPT_QUICK (1 << 11)
#define DIFF_OPT_NO_INDEX (1 << 12)
@@ -79,6 +79,13 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
#define DIFF_XDL_SET(opts, flag) ((opts)->xdl_opts |= XDF_##flag)
#define DIFF_XDL_CLR(opts, flag) ((opts)->xdl_opts &= ~XDF_##flag)
+enum diff_words_type {
+ DIFF_WORDS_NONE = 0,
+ DIFF_WORDS_PORCELAIN,
+ DIFF_WORDS_PLAIN,
+ DIFF_WORDS_COLOR
+};
+
struct diff_options {
const char *filter;
const char *orderfile;
@@ -108,6 +115,7 @@ struct diff_options {
int stat_width;
int stat_name_width;
const char *word_regex;
+ enum diff_words_type word_diff;
/* this is set by diffcore for DIFF_FORMAT_PATCH */
int found_changes;
diff --git a/diffcore-break.c b/diffcore-break.c
index 3a7b60a03..44f8678d2 100644
--- a/diffcore-break.c
+++ b/diffcore-break.c
@@ -162,8 +162,7 @@ void diffcore_break(int break_score)
if (!merge_score)
merge_score = DEFAULT_MERGE_SCORE;
- outq.nr = outq.alloc = 0;
- outq.queue = NULL;
+ DIFF_QUEUE_CLEAR(&outq);
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
@@ -256,8 +255,7 @@ void diffcore_merge_broken(void)
struct diff_queue_struct outq;
int i, j;
- outq.nr = outq.alloc = 0;
- outq.queue = NULL;
+ DIFF_QUEUE_CLEAR(&outq);
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index d0ef83970..929de15aa 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -55,8 +55,7 @@ void diffcore_pickaxe(const char *needle, int opts)
int i, has_changes;
regex_t regex, *regexp = NULL;
struct diff_queue_struct outq;
- outq.queue = NULL;
- outq.nr = outq.alloc = 0;
+ DIFF_QUEUE_CLEAR(&outq);
if (opts & DIFF_PICKAXE_REGEX) {
int err;
diff --git a/diffcore-rename.c b/diffcore-rename.c
index d6fd3cacd..df41be56d 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -569,8 +569,7 @@ void diffcore_rename(struct diff_options *options)
/* At this point, we have found some renames and copies and they
* are recorded in rename_dst. The original list is still in *q.
*/
- outq.queue = NULL;
- outq.nr = outq.alloc = 0;
+ DIFF_QUEUE_CLEAR(&outq);
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
struct diff_filepair *pair_to_free = NULL;
diff --git a/diffcore.h b/diffcore.h
index fcd00bf27..491bea0b4 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -91,7 +91,14 @@ struct diff_queue_struct {
struct diff_filepair **queue;
int alloc;
int nr;
+ int run;
};
+#define DIFF_QUEUE_CLEAR(q) \
+ do { \
+ (q)->queue = NULL; \
+ (q)->nr = (q)->alloc = 0; \
+ (q)->run = 0; \
+ } while(0);
extern struct diff_queue_struct diff_queued_diff;
extern struct diff_filepair *diff_queue(struct diff_queue_struct *,
diff --git a/dir.c b/dir.c
index cb83332a2..5615f33af 100644
--- a/dir.c
+++ b/dir.c
@@ -958,9 +958,14 @@ char *get_relative_cwd(char *buffer, int size, const char *dir)
}
if (*dir)
return NULL;
- if (*cwd == '/')
+ switch (*cwd) {
+ case '\0':
+ return cwd;
+ case '/':
return cwd + 1;
- return cwd;
+ default:
+ return NULL;
+ }
}
int is_inside_dir(const char *dir)
diff --git a/exec_cmd.c b/exec_cmd.c
index b2c07c70c..bf225706e 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -107,7 +107,7 @@ void setup_path(void)
if (old_path)
strbuf_addstr(&new_path, old_path);
else
- strbuf_addstr(&new_path, "/usr/local/bin:/usr/bin:/bin");
+ strbuf_addstr(&new_path, _PATH_DEFPATH);
setenv("PATH", new_path.buf, 1);
diff --git a/fast-import.c b/fast-import.c
index 309f2c58a..129a78683 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2707,6 +2707,7 @@ static void option_import_marks(const char *marks, int from_stream)
}
import_marks_file = make_fast_import_path(marks);
+ safe_create_leading_directories_const(import_marks_file);
import_marks_file_from_stream = from_stream;
}
@@ -2737,6 +2738,7 @@ static void option_active_branches(const char *branches)
static void option_export_marks(const char *marks)
{
export_marks_file = make_fast_import_path(marks);
+ safe_create_leading_directories_const(export_marks_file);
}
static void option_export_pack_edges(const char *edges)
diff --git a/fsck.c b/fsck.c
index 89278c145..3d05d4a79 100644
--- a/fsck.c
+++ b/fsck.c
@@ -222,12 +222,47 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
return retval;
}
+static int fsck_ident(char **ident, struct object *obj, fsck_error error_func)
+{
+ if (**ident == '<' || **ident == '\n')
+ return error_func(obj, FSCK_ERROR, "invalid author/committer line - missing space before email");
+ *ident += strcspn(*ident, "<\n");
+ if ((*ident)[-1] != ' ')
+ return error_func(obj, FSCK_ERROR, "invalid author/committer line - missing space before email");
+ if (**ident != '<')
+ return error_func(obj, FSCK_ERROR, "invalid author/committer line - missing email");
+ (*ident)++;
+ *ident += strcspn(*ident, "<>\n");
+ if (**ident != '>')
+ return error_func(obj, FSCK_ERROR, "invalid author/committer line - bad email");
+ (*ident)++;
+ if (**ident != ' ')
+ return error_func(obj, FSCK_ERROR, "invalid author/committer line - missing space before date");
+ (*ident)++;
+ if (**ident == '0' && (*ident)[1] != ' ')
+ return error_func(obj, FSCK_ERROR, "invalid author/committer line - zero-padded date");
+ *ident += strspn(*ident, "0123456789");
+ if (**ident != ' ')
+ return error_func(obj, FSCK_ERROR, "invalid author/committer line - bad date");
+ (*ident)++;
+ if ((**ident != '+' && **ident != '-') ||
+ !isdigit((*ident)[1]) ||
+ !isdigit((*ident)[2]) ||
+ !isdigit((*ident)[3]) ||
+ !isdigit((*ident)[4]) ||
+ ((*ident)[5] != '\n'))
+ return error_func(obj, FSCK_ERROR, "invalid author/committer line - bad time zone");
+ (*ident) += 6;
+ return 0;
+}
+
static int fsck_commit(struct commit *commit, fsck_error error_func)
{
char *buffer = commit->buffer;
unsigned char tree_sha1[20], sha1[20];
struct commit_graft *graft;
int parents = 0;
+ int err;
if (commit->date == ULONG_MAX)
return error_func(&commit->object, FSCK_ERROR, "invalid author/committer line");
@@ -266,6 +301,16 @@ static int fsck_commit(struct commit *commit, fsck_error error_func)
}
if (memcmp(buffer, "author ", 7))
return error_func(&commit->object, FSCK_ERROR, "invalid format - expected 'author' line");
+ buffer += 7;
+ err = fsck_ident(&buffer, &commit->object, error_func);
+ if (err)
+ return err;
+ if (memcmp(buffer, "committer ", strlen("committer ")))
+ return error_func(&commit->object, FSCK_ERROR, "invalid format - expected 'committer' line");
+ buffer += strlen("committer ");
+ err = fsck_ident(&buffer, &commit->object, error_func);
+ if (err)
+ return err;
if (!commit->tree)
return error_func(&commit->object, FSCK_ERROR, "could not load commit's tree %s", sha1_to_hex(tree_sha1));
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 21f1330a5..27fc79347 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1111,9 +1111,9 @@ sub help_patch_cmd {
print colored $help_color, <<EOF ;
y - $verb this hunk$target
n - do not $verb this hunk$target
-q - quit, do not $verb this hunk nor any of the remaining ones
-a - $verb this and all the remaining hunks in the file
-d - do not $verb this hunk nor any of the remaining hunks in the file
+q - quit; do not $verb this hunk nor any of the remaining ones
+a - $verb this hunk and all later hunks in the file
+d - do not $verb this hunk nor any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
diff --git a/git-am.sh b/git-am.sh
index 105607554..87ffae252 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -740,7 +740,7 @@ do
;;
esac
- if test $apply_status = 1 && test "$threeway" = t
+ if test $apply_status != 0 && test "$threeway" = t
then
if (fall_back_3way)
then
diff --git a/git-compat-util.h b/git-compat-util.h
index 6e2597728..81ceb7f90 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -56,7 +56,7 @@
# define _XOPEN_SOURCE 500
# endif
#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && \
- !defined(_M_UNIX) && !defined(sgi) && !defined(__DragonFly__)
+ !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__)
#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
#endif
@@ -164,6 +164,13 @@ extern char *gitbasename(char *);
#define PATH_SEP ':'
#endif
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
+#ifndef _PATH_DEFPATH
+#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin"
+#endif
+
#ifndef STRIP_EXTENSION
#define STRIP_EXTENSION ""
#endif
@@ -356,6 +363,9 @@ static inline void *gitmempcpy(void *dest, const void *src, size_t n)
extern void release_pack_memory(size_t, int);
+typedef void (*try_to_free_t)(size_t);
+extern try_to_free_t set_try_to_free_routine(try_to_free_t);
+
extern char *xstrdup(const char *str);
extern void *xmalloc(size_t size);
extern void *xmallocz(size_t size);
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 13751db88..3833beeef 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -183,12 +183,58 @@ if ($state->{method} eq 'pserver') {
exit 1;
}
$line = <STDIN>; chomp $line;
- unless ($line eq 'anonymous') {
- print "E Only anonymous user allowed via pserver\n";
- print "I HATE YOU\n";
- exit 1;
+ my $user = $line;
+ $line = <STDIN>; chomp $line;
+ my $password = $line;
+
+ if ($user eq 'anonymous') {
+ # "A" will be 1 byte, use length instead in case the
+ # encryption method ever changes (yeah, right!)
+ if (length($password) > 1 ) {
+ print "E Don't supply a password for the `anonymous' user\n";
+ print "I HATE YOU\n";
+ exit 1;
+ }
+
+ # Fall through to LOVE
+ } else {
+ # Trying to authenticate a user
+ if (not exists $cfg->{gitcvs}->{authdb}) {
+ print "E the repo config file needs a [gitcvs] section with an 'authdb' parameter set to the filename of the authentication database\n";
+ print "I HATE YOU\n";
+ exit 1;
+ }
+
+ my $authdb = $cfg->{gitcvs}->{authdb};
+
+ unless (-e $authdb) {
+ print "E The authentication database specified in [gitcvs.authdb] does not exist\n";
+ print "I HATE YOU\n";
+ exit 1;
+ }
+
+ my $auth_ok;
+ open my $passwd, "<", $authdb or die $!;
+ while (<$passwd>) {
+ if (m{^\Q$user\E:(.*)}) {
+ if (crypt($user, descramble($password)) eq $1) {
+ $auth_ok = 1;
+ }
+ };
+ }
+ close $passwd;
+
+ unless ($auth_ok) {
+ print "I HATE YOU\n";
+ exit 1;
+ }
+
+ # Fall through to LOVE
}
- $line = <STDIN>; chomp $line; # validate the password?
+
+ # For checking whether the user is anonymous on commit
+ $state->{user} = $user;
+
$line = <STDIN>; chomp $line;
unless ($line eq "END $request REQUEST") {
die "E Do not understand $line -- expecting END $request REQUEST\n";
@@ -1271,9 +1317,9 @@ sub req_ci
$log->info("req_ci : " . ( defined($data) ? $data : "[NULL]" ));
- if ( $state->{method} eq 'pserver')
+ if ( $state->{method} eq 'pserver' and $state->{user} eq 'anonymous' )
{
- print "error 1 pserver access cannot commit\n";
+ print "error 1 anonymous user cannot commit via pserver\n";
cleanupWorkTree();
exit;
}
@@ -2586,6 +2632,40 @@ sub cvs_author
$author;
}
+
+sub descramble
+{
+ # This table is from src/scramble.c in the CVS source
+ my @SHIFTS = (
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 114,120, 53, 79, 96,109, 72,108, 70, 64, 76, 67,116, 74, 68, 87,
+ 111, 52, 75,119, 49, 34, 82, 81, 95, 65,112, 86,118,110,122,105,
+ 41, 57, 83, 43, 46,102, 40, 89, 38,103, 45, 50, 42,123, 91, 35,
+ 125, 55, 54, 66,124,126, 59, 47, 92, 71,115, 78, 88,107,106, 56,
+ 36,121,117,104,101,100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48,
+ 58,113, 32, 90, 44, 98, 60, 51, 33, 97, 62, 77, 84, 80, 85,223,
+ 225,216,187,166,229,189,222,188,141,249,148,200,184,136,248,190,
+ 199,170,181,204,138,232,218,183,255,234,220,247,213,203,226,193,
+ 174,172,228,252,217,201,131,230,197,211,145,238,161,179,160,212,
+ 207,221,254,173,202,146,224,151,140,196,205,130,135,133,143,246,
+ 192,159,244,239,185,168,215,144,139,165,180,157,147,186,214,176,
+ 227,231,219,169,175,156,206,198,129,164,150,210,154,177,134,127,
+ 182,128,158,208,162,132,167,209,149,241,153,251,237,236,171,195,
+ 243,233,253,240,194,250,191,155,142,137,245,235,163,242,178,152
+ );
+ my ($str) = @_;
+
+ # This should never happen, the same password format (A) bas been
+ # used by CVS since the beginning of time
+ die "invalid password format $1" unless substr($str, 0, 1) eq 'A';
+
+ my @str = unpack "C*", substr($str, 1);
+ my $ret = join '', map { chr $SHIFTS[$_] } @str;
+ return $ret;
+}
+
+
package GITCVS::log;
####
diff --git a/git-instaweb.sh b/git-instaweb.sh
index f6080149c..6635fbefd 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -24,6 +24,7 @@ restart restart the web server
fqgitdir="$GIT_DIR"
local="$(git config --bool --get instaweb.local)"
httpd="$(git config --get instaweb.httpd)"
+root="$(git config --get instaweb.gitwebdir)"
port=$(git config --get instaweb.port)
module_path="$(git config --get instaweb.modulepath)"
@@ -34,6 +35,9 @@ conf="$GIT_DIR/gitweb/httpd.conf"
# if installed, it doesn't need further configuration (module_path)
test -z "$httpd" && httpd='lighttpd -f'
+# Default is @@GITWEBDIR@@
+test -z "$root" && root='@@GITWEBDIR@@'
+
# any untaken local port will do...
test -z "$port" && port=1234
@@ -46,6 +50,12 @@ resolve_full_httpd () {
httpd="$httpd -f"
fi
;;
+ *plackup*)
+ # server is started by running via generated gitweb.psgi in $fqgitdir/gitweb
+ full_httpd="$fqgitdir/gitweb/gitweb.psgi"
+ httpd_only="${httpd%% *}" # cut on first space
+ return
+ ;;
esac
httpd_only="$(echo $httpd | cut -f1 -d' ')"
@@ -57,7 +67,7 @@ resolve_full_httpd () {
# these days and those are not in most users $PATHs
# in addition, we may have generated a server script
# in $fqgitdir/gitweb.
- for i in /usr/local/sbin /usr/sbin "$fqgitdir/gitweb"
+ for i in /usr/local/sbin /usr/sbin "$root" "$fqgitdir/gitweb"
do
if test -x "$i/$httpd_only"
then
@@ -83,8 +93,8 @@ start_httpd () {
# don't quote $full_httpd, there can be arguments to it (-f)
case "$httpd" in
- *mongoose*)
- #The mongoose server doesn't have a daemon mode so we'll have to fork it
+ *mongoose*|*plackup*)
+ #These servers don't have a daemon mode so we'll have to fork it
$full_httpd "$fqgitdir/gitweb/httpd.conf" &
#Save the pid before doing anything else (we'll print it later)
pid=$!
@@ -110,6 +120,20 @@ EOF
stop_httpd () {
test -f "$fqgitdir/pid" && kill $(cat "$fqgitdir/pid")
+ rm -f "$fqgitdir/pid"
+}
+
+httpd_is_ready () {
+ "$PERL" -MIO::Socket::INET -e "
+local \$| = 1; # turn on autoflush
+exit if (IO::Socket::INET->new('127.0.0.1:$port'));
+print 'Waiting for \'$httpd\' to start ..';
+do {
+ print '.';
+ sleep(1);
+} until (IO::Socket::INET->new('127.0.0.1:$port'));
+print qq! (done)\n!;
+"
}
while test $# != 0
@@ -159,8 +183,8 @@ done
mkdir -p "$GIT_DIR/gitweb/tmp"
GIT_EXEC_PATH="$(git --exec-path)"
GIT_DIR="$fqgitdir"
-export GIT_EXEC_PATH GIT_DIR
-
+GITWEB_CONFIG="$fqgitdir/gitweb/gitweb_config.perl"
+export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
webrick_conf () {
# generate a standalone server script in $fqgitdir/gitweb.
@@ -192,7 +216,7 @@ EOF
cat >"$conf" <<EOF
:Port: $port
-:DocumentRoot: "$fqgitdir/gitweb"
+:DocumentRoot: "$root"
:DirectoryIndex: ["gitweb.cgi"]
:PidFile: "$fqgitdir/pid"
EOF
@@ -201,18 +225,18 @@ EOF
lighttpd_conf () {
cat > "$conf" <<EOF
-server.document-root = "$fqgitdir/gitweb"
+server.document-root = "$root"
server.port = $port
server.modules = ( "mod_setenv", "mod_cgi" )
server.indexfiles = ( "gitweb.cgi" )
server.pid-file = "$fqgitdir/pid"
-server.errorlog = "$fqgitdir/gitweb/error.log"
+server.errorlog = "$fqgitdir/gitweb/$httpd_only/error.log"
# to enable, add "mod_access", "mod_accesslog" to server.modules
# variable above and uncomment this
-#accesslog.filename = "$fqgitdir/gitweb/access.log"
+#accesslog.filename = "$fqgitdir/gitweb/$httpd_only/access.log"
-setenv.add-environment = ( "PATH" => env.PATH )
+setenv.add-environment = ( "PATH" => env.PATH, "GITWEB_CONFIG" => env.GITWEB_CONFIG )
cgi.assign = ( ".cgi" => "" )
@@ -277,14 +301,15 @@ EOF
apache2_conf () {
test -z "$module_path" && module_path=/usr/lib/apache2/modules
- mkdir -p "$GIT_DIR/gitweb/logs"
bind=
test x"$local" = xtrue && bind='127.0.0.1:'
echo 'text/css css' > "$fqgitdir/mime.types"
cat > "$conf" <<EOF
ServerName "git-instaweb"
-ServerRoot "$fqgitdir/gitweb"
-DocumentRoot "$fqgitdir/gitweb"
+ServerRoot "$root"
+DocumentRoot "$root"
+ErrorLog "$fqgitdir/gitweb/$httpd_only/error.log"
+CustomLog "$fqgitdir/gitweb/$httpd_only/access.log" combined
PidFile "$fqgitdir/pid"
Listen $bind$port
EOF
@@ -303,13 +328,14 @@ EOF
# check to see if Dennis Stosberg's mod_perl compatibility patch
# (<20060621130708.Gcbc6e5c@leonov.stosberg.net>) has been applied
if test -f "$module_path/mod_perl.so" &&
- sane_grep 'MOD_PERL' "$GIT_DIR/gitweb/gitweb.cgi" >/dev/null
+ sane_grep 'MOD_PERL' "$root/gitweb.cgi" >/dev/null
then
# favor mod_perl if available
cat >> "$conf" <<EOF
LoadModule perl_module $module_path/mod_perl.so
PerlPassEnv GIT_DIR
PerlPassEnv GIT_EXEC_DIR
+PerlPassEnv GITWEB_CONFIG
<Location /gitweb.cgi>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
@@ -353,15 +379,15 @@ mongoose_conf() {
# For detailed description of every option, visit
# http://code.google.com/p/mongoose/wiki/MongooseManual
-root $fqgitdir/gitweb
+root $root
ports $port
index_files gitweb.cgi
#ssl_cert $fqgitdir/gitweb/ssl_cert.pem
-error_log $fqgitdir/gitweb/error.log
-access_log $fqgitdir/gitweb/access.log
+error_log $fqgitdir/gitweb/$httpd_only/error.log
+access_log $fqgitdir/gitweb/$httpd_only/access.log
#cgi setup
-cgi_env PATH=$PATH,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH
+cgi_env PATH=$PATH,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH,GITWEB_CONFIG=$GITWEB_CONFIG
cgi_interp $PERL
cgi_ext cgi,pl
@@ -370,41 +396,165 @@ mime_types .gz=application/x-gzip,.tar.gz=application/x-tgz,.tgz=application/x-t
EOF
}
-
-script='
-s#^(my|our) \$projectroot =.*#$1 \$projectroot = "'$(dirname "$fqgitdir")'";#;
-s#(my|our) \$gitbin =.*#$1 \$gitbin = "'$GIT_EXEC_PATH'";#;
-s#(my|our) \$projects_list =.*#$1 \$projects_list = \$projectroot;#;
-s#(my|our) \$git_temp =.*#$1 \$git_temp = "'$fqgitdir/gitweb/tmp'";#;'
-
-gitweb_cgi () {
- cat > "$1.tmp" <<\EOFGITWEB
-@@GITWEB_CGI@@
-EOFGITWEB
- # Use the configured full path to perl to match the generated
- # scripts' 'hashpling' line
- "$PERL" -p -e "$script" "$1.tmp" > "$1"
- chmod +x "$1"
- rm -f "$1.tmp"
+plackup_conf () {
+ # generate a standalone 'plackup' server script in $fqgitdir/gitweb
+ # with embedded configuration; it does not use "$conf" file
+ cat > "$fqgitdir/gitweb/gitweb.psgi" <<EOF
+#!$PERL
+
+# gitweb - simple web interface to track changes in git repositories
+# PSGI wrapper and server starter (see http://plackperl.org)
+
+use strict;
+
+use IO::Handle;
+use Plack::MIME;
+use Plack::Builder;
+use Plack::App::WrapCGI;
+use CGI::Emulate::PSGI 0.07; # minimum version required to work with gitweb
+
+# mimetype mapping (from lighttpd_conf)
+Plack::MIME->add_type(
+ ".pdf" => "application/pdf",
+ ".sig" => "application/pgp-signature",
+ ".spl" => "application/futuresplash",
+ ".class" => "application/octet-stream",
+ ".ps" => "application/postscript",
+ ".torrent" => "application/x-bittorrent",
+ ".dvi" => "application/x-dvi",
+ ".gz" => "application/x-gzip",
+ ".pac" => "application/x-ns-proxy-autoconfig",
+ ".swf" => "application/x-shockwave-flash",
+ ".tar.gz" => "application/x-tgz",
+ ".tgz" => "application/x-tgz",
+ ".tar" => "application/x-tar",
+ ".zip" => "application/zip",
+ ".mp3" => "audio/mpeg",
+ ".m3u" => "audio/x-mpegurl",
+ ".wma" => "audio/x-ms-wma",
+ ".wax" => "audio/x-ms-wax",
+ ".ogg" => "application/ogg",
+ ".wav" => "audio/x-wav",
+ ".gif" => "image/gif",
+ ".jpg" => "image/jpeg",
+ ".jpeg" => "image/jpeg",
+ ".png" => "image/png",
+ ".xbm" => "image/x-xbitmap",
+ ".xpm" => "image/x-xpixmap",
+ ".xwd" => "image/x-xwindowdump",
+ ".css" => "text/css",
+ ".html" => "text/html",
+ ".htm" => "text/html",
+ ".js" => "text/javascript",
+ ".asc" => "text/plain",
+ ".c" => "text/plain",
+ ".cpp" => "text/plain",
+ ".log" => "text/plain",
+ ".conf" => "text/plain",
+ ".text" => "text/plain",
+ ".txt" => "text/plain",
+ ".dtd" => "text/xml",
+ ".xml" => "text/xml",
+ ".mpeg" => "video/mpeg",
+ ".mpg" => "video/mpeg",
+ ".mov" => "video/quicktime",
+ ".qt" => "video/quicktime",
+ ".avi" => "video/x-msvideo",
+ ".asf" => "video/x-ms-asf",
+ ".asx" => "video/x-ms-asf",
+ ".wmv" => "video/x-ms-wmv",
+ ".bz2" => "application/x-bzip",
+ ".tbz" => "application/x-bzip-compressed-tar",
+ ".tar.bz2" => "application/x-bzip-compressed-tar",
+ "" => "text/plain"
+);
+
+my \$app = builder {
+ # to be able to override \$SIG{__WARN__} to log build time warnings
+ use CGI::Carp; # it sets \$SIG{__WARN__} itself
+
+ my \$logdir = "$fqgitdir/gitweb/$httpd_only";
+ open my \$access_log_fh, '>>', "\$logdir/access.log"
+ or die "Couldn't open access log '\$logdir/access.log': \$!";
+ open my \$error_log_fh, '>>', "\$logdir/error.log"
+ or die "Couldn't open error log '\$logdir/error.log': \$!";
+
+ \$access_log_fh->autoflush(1);
+ \$error_log_fh->autoflush(1);
+
+ # redirect build time warnings to error.log
+ \$SIG{'__WARN__'} = sub {
+ my \$msg = shift;
+ # timestamp warning like in CGI::Carp::warn
+ my \$stamp = CGI::Carp::stamp();
+ \$msg =~ s/^/\$stamp/gm;
+ print \$error_log_fh \$msg;
+ };
+
+ # write errors to error.log, access to access.log
+ enable 'AccessLog',
+ format => "combined",
+ logger => sub { print \$access_log_fh @_; };
+ enable sub {
+ my \$app = shift;
+ sub {
+ my \$env = shift;
+ \$env->{'psgi.errors'} = \$error_log_fh;
+ \$app->(\$env);
+ }
+ };
+ # gitweb currently doesn't work with $SIG{CHLD} set to 'IGNORE',
+ # because it uses 'close $fd or die...' on piped filehandle $fh
+ # (which causes the parent process to wait for child to finish).
+ enable_if { \$SIG{'CHLD'} eq 'IGNORE' } sub {
+ my \$app = shift;
+ sub {
+ my \$env = shift;
+ local \$SIG{'CHLD'} = 'DEFAULT';
+ local \$SIG{'CLD'} = 'DEFAULT';
+ \$app->(\$env);
+ }
+ };
+ # serve static files, i.e. stylesheet, images, script
+ enable 'Static',
+ path => sub { m!\.(js|css|png)\$! && s!^/gitweb/!! },
+ root => "$root/",
+ encoding => 'utf-8'; # encoding for 'text/plain' files
+ # convert CGI application to PSGI app
+ Plack::App::WrapCGI->new(script => "$root/gitweb.cgi")->to_app;
+};
+
+# make it runnable as standalone app,
+# like it would be run via 'plackup' utility
+if (__FILE__ eq \$0) {
+ require Plack::Runner;
+
+ my \$runner = Plack::Runner->new();
+ \$runner->parse_options(qw(--env deployment --port $port),
+ "$local" ? qw(--host 127.0.0.1) : ());
+ \$runner->run(\$app);
}
+__END__
+EOF
-gitweb_css () {
- cat > "$1" <<\EOFGITWEB
-@@GITWEB_CSS@@
-
-EOFGITWEB
+ chmod a+x "$fqgitdir/gitweb/gitweb.psgi"
+ # configuration is embedded in server script file, gitweb.psgi
+ rm -f "$conf"
}
-gitweb_js () {
- cat > "$1" <<\EOFGITWEB
-@@GITWEB_JS@@
-
-EOFGITWEB
+gitweb_conf() {
+ cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
+#!/usr/bin/perl
+our \$projectroot = "$(dirname "$fqgitdir")";
+our \$git_temp = "$fqgitdir/gitweb/tmp";
+our \$projects_list = \$projectroot;
+EOF
}
-gitweb_cgi "$GIT_DIR/gitweb/gitweb.cgi"
-gitweb_css "$GIT_DIR/@@GITWEB_CSS_NAME@@"
-gitweb_js "$GIT_DIR/@@GITWEB_JS_NAME@@"
+gitweb_conf
+
+resolve_full_httpd
+mkdir -p "$fqgitdir/gitweb/$httpd_only"
case "$httpd" in
*lighttpd*)
@@ -419,6 +569,9 @@ webrick)
*mongoose*)
mongoose_conf
;;
+*plackup*)
+ plackup_conf
+ ;;
*)
echo "Unknown httpd specified: $httpd"
exit 1
@@ -429,7 +582,7 @@ start_httpd
url=http://127.0.0.1:$port
if test -n "$browser"; then
- git web--browse -b "$browser" $url || echo $url
+ httpd_is_ready && git web--browse -b "$browser" $url || echo $url
else
- git web--browse -c "instaweb.browser" $url || echo $url
+ httpd_is_ready && git web--browse -c "instaweb.browser" $url || echo $url
fi
diff --git a/git-pull.sh b/git-pull.sh
index 1a4729f7b..a09a44ec4 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -43,6 +43,7 @@ merge_args=
curr_branch=$(git symbolic-ref -q HEAD)
curr_branch_short="${curr_branch#refs/heads/}"
rebase=$(git config --bool branch.$curr_branch_short.rebase)
+dry_run=
while :
do
case "$1" in
@@ -104,6 +105,9 @@ do
--no-r|--no-re|--no-reb|--no-reba|--no-rebas|--no-rebase)
rebase=false
;;
+ --d|--dr|--dry|--dry-|--dry-r|--dry-ru|--dry-run)
+ dry_run=--dry-run
+ ;;
-h|--h|--he|--hel|--help)
usage
;;
@@ -216,7 +220,8 @@ test true = "$rebase" && {
done
}
orig_head=$(git rev-parse -q --verify HEAD)
-git fetch $verbosity $progress --update-head-ok "$@" || exit 1
+git fetch $verbosity $progress $dry_run --update-head-ok "$@" || exit 1
+test -z "$dry_run" || exit 0
curr_head=$(git rev-parse -q --verify HEAD)
if test -n "$orig_head" && test "$curr_head" != "$orig_head"
diff --git a/git-remote-testgit.py b/git-remote-testgit.py
new file mode 100644
index 000000000..92539222c
--- /dev/null
+++ b/git-remote-testgit.py
@@ -0,0 +1,235 @@
+#!/usr/bin/env python
+
+import hashlib
+import sys
+import os
+sys.path.insert(0, os.getenv("GITPYTHONLIB","."))
+
+from git_remote_helpers.util import die, debug, warn
+from git_remote_helpers.git.repo import GitRepo
+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
+
+def get_repo(alias, url):
+ """Returns a git repository object initialized for usage.
+ """
+
+ repo = GitRepo(url)
+ repo.get_revs()
+ repo.get_head()
+
+ hasher = hashlib.sha1()
+ hasher.update(repo.path)
+ repo.hash = hasher.hexdigest()
+
+ repo.get_base_path = lambda base: os.path.join(
+ base, 'info', 'fast-import', repo.hash)
+
+ prefix = 'refs/testgit/%s/' % alias
+ debug("prefix: '%s'", prefix)
+
+ repo.gitdir = ""
+ repo.alias = alias
+ repo.prefix = prefix
+
+ repo.exporter = GitExporter(repo)
+ repo.importer = GitImporter(repo)
+ repo.non_local = NonLocalGit(repo)
+
+ return repo
+
+
+def local_repo(repo, path):
+ """Returns a git repository object initalized for usage.
+ """
+
+ local = GitRepo(path)
+
+ local.non_local = None
+ local.gitdir = repo.gitdir
+ local.alias = repo.alias
+ local.prefix = repo.prefix
+ local.hash = repo.hash
+ local.get_base_path = repo.get_base_path
+ local.exporter = GitExporter(local)
+ local.importer = GitImporter(local)
+
+ return local
+
+
+def do_capabilities(repo, args):
+ """Prints the supported capabilities.
+ """
+
+ print "import"
+ print "export"
+ print "gitdir"
+ print "refspec refs/heads/*:%s*" % repo.prefix
+
+ print # end capabilities
+
+
+def do_list(repo, args):
+ """Lists all known references.
+
+ Bug: This will always set the remote head to master for non-local
+ repositories, since we have no way of determining what the remote
+ head is at clone time.
+ """
+
+ for ref in repo.revs:
+ debug("? refs/heads/%s", ref)
+ print "? refs/heads/%s" % ref
+
+ if repo.head:
+ debug("@refs/heads/%s HEAD" % repo.head)
+ print "@refs/heads/%s HEAD" % repo.head
+ else:
+ debug("@refs/heads/master HEAD")
+ print "@refs/heads/master HEAD"
+
+ print # end list
+
+
+def update_local_repo(repo):
+ """Updates (or clones) a local repo.
+ """
+
+ if repo.local:
+ return repo
+
+ path = repo.non_local.clone(repo.gitdir)
+ repo.non_local.update(repo.gitdir)
+ repo = local_repo(repo, path)
+ return repo
+
+
+def do_import(repo, args):
+ """Exports a fast-import stream from testgit for git to import.
+ """
+
+ if len(args) != 1:
+ die("Import needs exactly one ref")
+
+ if not repo.gitdir:
+ die("Need gitdir to import")
+
+ repo = update_local_repo(repo)
+ repo.exporter.export_repo(repo.gitdir)
+
+
+def do_export(repo, args):
+ """Imports a fast-import stream from git to testgit.
+ """
+
+ if not repo.gitdir:
+ die("Need gitdir to export")
+
+ dirname = repo.get_base_path(repo.gitdir)
+
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+
+ path = os.path.join(dirname, 'testgit.marks')
+ print path
+ print path if os.path.exists(path) else ""
+ sys.stdout.flush()
+
+ update_local_repo(repo)
+ repo.importer.do_import(repo.gitdir)
+ repo.non_local.push(repo.gitdir)
+
+
+def do_gitdir(repo, args):
+ """Stores the location of the gitdir.
+ """
+
+ if not args:
+ die("gitdir needs an argument")
+
+ repo.gitdir = ' '.join(args)
+
+
+COMMANDS = {
+ 'capabilities': do_capabilities,
+ 'list': do_list,
+ 'import': do_import,
+ 'export': do_export,
+ 'gitdir': do_gitdir,
+}
+
+
+def sanitize(value):
+ """Cleans up the url.
+ """
+
+ if value.startswith('testgit::'):
+ value = value[9:]
+
+ return value
+
+
+def read_one_line(repo):
+ """Reads and processes one command.
+ """
+
+ line = sys.stdin.readline()
+
+ cmdline = line
+
+ if not cmdline:
+ warn("Unexpected EOF")
+ return False
+
+ cmdline = cmdline.strip().split()
+ if not cmdline:
+ # Blank line means we're about to quit
+ return False
+
+ cmd = cmdline.pop(0)
+ debug("Got command '%s' with args '%s'", cmd, ' '.join(cmdline))
+
+ if cmd not in COMMANDS:
+ die("Unknown command, %s", cmd)
+
+ func = COMMANDS[cmd]
+ func(repo, cmdline)
+ sys.stdout.flush()
+
+ return True
+
+
+def main(args):
+ """Starts a new remote helper for the specified repository.
+ """
+
+ if len(args) != 3:
+ die("Expecting exactly three arguments.")
+ sys.exit(1)
+
+ if os.getenv("GIT_DEBUG_TESTGIT"):
+ import git_remote_helpers.util
+ git_remote_helpers.util.DEBUG = True
+
+ alias = sanitize(args[1])
+ url = sanitize(args[2])
+
+ if not alias.isalnum():
+ warn("non-alnum alias '%s'", alias)
+ alias = "tmp"
+
+ args[1] = alias
+ args[2] = url
+
+ repo = get_repo(alias, url)
+
+ debug("Got arguments %s", args[1:])
+
+ more = True
+
+ while (more):
+ more = read_one_line(repo)
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/git-request-pull.sh b/git-request-pull.sh
index 8fd15f6df..74238b031 100755
--- a/git-request-pull.sh
+++ b/git-request-pull.sh
@@ -8,6 +8,7 @@ USAGE='<start> <url> [<end>]'
LONG_USAGE='Summarizes the changes between two commits to the standard output,
and includes the given URL in the generated summary.'
SUBDIRECTORY_OK='Yes'
+OPTIONS_KEEPDASHDASH=
OPTIONS_SPEC='git request-pull [options] start url [end]
--
p show patch text as well
diff --git a/git-stash.sh b/git-stash.sh
index 908aab265..1d95447d0 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -86,7 +86,7 @@ create_stash () {
GIT_INDEX_FILE="$TMP-index" &&
export GIT_INDEX_FILE &&
git read-tree -m $i_tree &&
- git add -u &&
+ git diff --name-only -z HEAD | git update-index -z --add --remove --stdin &&
git write-tree &&
rm -f "$TMP-index"
) ) ||
diff --git a/git-submodule.sh b/git-submodule.sh
index 8175cb279..8c562a72e 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -271,6 +271,8 @@ cmd_foreach()
shift
done
+ toplevel=$(pwd)
+
module_list |
while read mode sha1 stage path
do
diff --git a/git-svn.perl b/git-svn.perl
index b3b6964f9..19d6848d0 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -963,6 +963,7 @@ sub cmd_multi_init {
}
do_git_init_db();
if (defined $_trunk) {
+ $_trunk =~ s#^/+##;
my $trunk_ref = 'refs/remotes/' . $_prefix . 'trunk';
# try both old-style and new-style lookups:
my $gs_trunk = eval { Git::SVN->new($trunk_ref) };
@@ -2054,6 +2055,9 @@ sub new {
"\":$ref_id\$\" in config\n";
($self->{path}, undef) = split(/\s*:\s*/, $fetch);
}
+ $self->{path} =~ s{/+}{/}g;
+ $self->{path} =~ s{\A/}{};
+ $self->{path} =~ s{/\z}{};
$self->{url} = command_oneline('config', '--get',
"svn-remote.$repo_id.url") or
die "Failed to read \"svn-remote.$repo_id.url\" in config\n";
@@ -2836,8 +2840,9 @@ sub mkemptydirs {
foreach my $d (sort keys %empty_dirs) {
$d = uri_decode($d);
$d =~ s/$strip//;
+ next unless length($d);
next if -d $d;
- if (-e _) {
+ if (-e $d) {
warn "$d exists but is not a directory\n";
} else {
print "creating empty directory: $d\n";
diff --git a/git.c b/git.c
index 6bae30545..99f036302 100644
--- a/git.c
+++ b/git.c
@@ -8,6 +8,7 @@ const char git_usage_string[] =
"git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]\n"
" [-p|--paginate|--no-pager] [--no-replace-objects]\n"
" [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]\n"
+ " [-c name=value\n"
" [--help] COMMAND [ARGS]";
const char git_more_info_string[] =
@@ -130,6 +131,14 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 0);
if (envchanged)
*envchanged = 1;
+ } else if (!strcmp(cmd, "-c")) {
+ if (*argc < 2) {
+ fprintf(stderr, "-c expects a configuration string\n" );
+ usage(git_usage_string);
+ }
+ git_config_parse_parameter((*argv)[1]);
+ (*argv)++;
+ (*argc)--;
} else {
fprintf(stderr, "Unknown option: %s\n", cmd);
usage(git_usage_string);
diff --git a/git_remote_helpers/git/exporter.py b/git_remote_helpers/git/exporter.py
new file mode 100644
index 000000000..dfaab00b5
--- /dev/null
+++ b/git_remote_helpers/git/exporter.py
@@ -0,0 +1,51 @@
+import os
+import subprocess
+import sys
+
+
+class GitExporter(object):
+ """An exporter for testgit repositories.
+
+ The exporter simply delegates to git fast-export.
+ """
+
+ def __init__(self, repo):
+ """Creates a new exporter for the specified repo.
+ """
+
+ self.repo = repo
+
+ def export_repo(self, base):
+ """Exports a fast-export stream for the given directory.
+
+ Simply delegates to git fast-epxort and pipes it through sed
+ to make the refs show up under the prefix rather than the
+ default refs/heads. This is to demonstrate how the export
+ data can be stored under it's own ref (using the refspec
+ capability).
+ """
+
+ dirname = self.repo.get_base_path(base)
+ path = os.path.abspath(os.path.join(dirname, 'testgit.marks'))
+
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+
+ print "feature relative-marks"
+ if os.path.exists(os.path.join(dirname, 'git.marks')):
+ print "feature import-marks=%s/git.marks" % self.repo.hash
+ print "feature export-marks=%s/git.marks" % self.repo.hash
+ sys.stdout.flush()
+
+ args = ["git", "--git-dir=" + self.repo.gitpath, "fast-export", "--export-marks=" + path]
+
+ if os.path.exists(path):
+ args.append("--import-marks=" + path)
+
+ args.append("HEAD")
+
+ p1 = subprocess.Popen(args, stdout=subprocess.PIPE)
+
+ args = ["sed", "s_refs/heads/_" + self.repo.prefix + "_g"]
+
+ subprocess.check_call(args, stdin=p1.stdout)
diff --git a/git_remote_helpers/git/importer.py b/git_remote_helpers/git/importer.py
new file mode 100644
index 000000000..af2919d92
--- /dev/null
+++ b/git_remote_helpers/git/importer.py
@@ -0,0 +1,38 @@
+import os
+import subprocess
+
+
+class GitImporter(object):
+ """An importer for testgit repositories.
+
+ This importer simply delegates to git fast-import.
+ """
+
+ def __init__(self, repo):
+ """Creates a new importer for the specified repo.
+ """
+
+ self.repo = repo
+
+ def do_import(self, base):
+ """Imports a fast-import stream to the given directory.
+
+ Simply delegates to git fast-import.
+ """
+
+ dirname = self.repo.get_base_path(base)
+ if self.repo.local:
+ gitdir = self.repo.gitpath
+ else:
+ gitdir = os.path.abspath(os.path.join(dirname, '.git'))
+ path = os.path.abspath(os.path.join(dirname, 'git.marks'))
+
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+
+ args = ["git", "--git-dir=" + gitdir, "fast-import", "--quiet", "--export-marks=" + path]
+
+ if os.path.exists(path):
+ args.append("--import-marks=" + path)
+
+ subprocess.check_call(args)
diff --git a/git_remote_helpers/git/non_local.py b/git_remote_helpers/git/non_local.py
new file mode 100644
index 000000000..d75ef8f21
--- /dev/null
+++ b/git_remote_helpers/git/non_local.py
@@ -0,0 +1,61 @@
+import os
+import subprocess
+
+from git_remote_helpers.util import die, warn
+
+
+class NonLocalGit(object):
+ """Handler to interact with non-local repos.
+ """
+
+ def __init__(self, repo):
+ """Creates a new non-local handler for the specified repo.
+ """
+
+ self.repo = repo
+
+ def clone(self, base):
+ """Clones the non-local repo to base.
+
+ Does nothing if a clone already exists.
+ """
+
+ path = os.path.join(self.repo.get_base_path(base), '.git')
+
+ # already cloned
+ if os.path.exists(path):
+ return path
+
+ os.makedirs(path)
+ args = ["git", "clone", "--bare", "--quiet", self.repo.gitpath, path]
+
+ subprocess.check_call(args)
+
+ return path
+
+ def update(self, base):
+ """Updates checkout of the non-local repo in base.
+ """
+
+ path = os.path.join(self.repo.get_base_path(base), '.git')
+
+ if not os.path.exists(path):
+ die("could not find repo at %s", path)
+
+ args = ["git", "--git-dir=" + path, "fetch", "--quiet", self.repo.gitpath]
+ subprocess.check_call(args)
+
+ args = ["git", "--git-dir=" + path, "update-ref", "refs/heads/master", "FETCH_HEAD"]
+ subprocess.check_call(args)
+
+ def push(self, base):
+ """Pushes from the non-local repo to base.
+ """
+
+ path = os.path.join(self.repo.get_base_path(base), '.git')
+
+ if not os.path.exists(path):
+ die("could not find repo at %s", path)
+
+ args = ["git", "--git-dir=" + path, "push", "--quiet", self.repo.gitpath]
+ subprocess.check_call(args)
diff --git a/git_remote_helpers/git/repo.py b/git_remote_helpers/git/repo.py
new file mode 100644
index 000000000..82d5f78c7
--- /dev/null
+++ b/git_remote_helpers/git/repo.py
@@ -0,0 +1,70 @@
+import os
+import subprocess
+
+def sanitize(rev, sep='\t'):
+ """Converts a for-each-ref line to a name/value pair.
+ """
+
+ splitrev = rev.split(sep)
+ branchval = splitrev[0]
+ branchname = splitrev[1].strip()
+ if branchname.startswith("refs/heads/"):
+ branchname = branchname[11:]
+
+ return branchname, branchval
+
+def is_remote(url):
+ """Checks whether the specified value is a remote url.
+ """
+
+ prefixes = ["http", "file", "git"]
+
+ return any(url.startswith(i) for i in prefixes)
+
+class GitRepo(object):
+ """Repo object representing a repo.
+ """
+
+ def __init__(self, path):
+ """Initializes a new repo at the given path.
+ """
+
+ self.path = path
+ self.head = None
+ self.revmap = {}
+ self.local = not is_remote(self.path)
+
+ if(self.path.endswith('.git')):
+ self.gitpath = self.path
+ else:
+ self.gitpath = os.path.join(self.path, '.git')
+
+ if self.local and not os.path.exists(self.gitpath):
+ os.makedirs(self.gitpath)
+
+ def get_revs(self):
+ """Fetches all revs from the remote.
+ """
+
+ args = ["git", "ls-remote", self.gitpath]
+ path = ".cached_revs"
+ ofile = open(path, "w")
+
+ subprocess.check_call(args, stdout=ofile)
+ output = open(path).readlines()
+ self.revmap = dict(sanitize(i) for i in output)
+ if "HEAD" in self.revmap:
+ del self.revmap["HEAD"]
+ self.revs = self.revmap.keys()
+ ofile.close()
+
+ def get_head(self):
+ """Determines the head of a local repo.
+ """
+
+ if not self.local:
+ return
+
+ path = os.path.join(self.gitpath, "HEAD")
+ head = open(path).readline()
+ self.head, _ = sanitize(head, ' ')
diff --git a/gitweb/INSTALL b/gitweb/INSTALL
index cbdc13647..823053173 100644
--- a/gitweb/INSTALL
+++ b/gitweb/INSTALL
@@ -2,12 +2,13 @@ GIT web Interface (gitweb) Installation
=======================================
First you have to generate gitweb.cgi from gitweb.perl using
-"make gitweb", then copy appropriate files (gitweb.cgi, gitweb.js,
-gitweb.css, git-logo.png and git-favicon.png) to their destination.
-For example if git was (or is) installed with /usr prefix, you can do
+"make gitweb", then "make install-gitweb" appropriate files
+(gitweb.cgi, gitweb.js, gitweb.css, git-logo.png and git-favicon.png)
+to their destination. For example if git was (or is) installed with
+/usr prefix and gitwebdir is /var/www/cgi-bin, you can do
- $ make prefix=/usr gitweb ;# as yourself
- # cp gitweb/git* /var/www/cgi-bin/ ;# as root
+ $ make prefix=/usr gitweb ;# as yourself
+ # make gitwebdir=/var/www/cgi-bin install-gitweb ;# as root
Alternatively you can use autoconf generated ./configure script to
set up path to git binaries (via config.mak.autogen), so you can write
@@ -16,7 +17,8 @@ instead
$ make configure ;# as yourself
$ ./configure --prefix=/usr ;# as yourself
$ make gitweb ;# as yourself
- # cp gitweb/git* /var/www/cgi-bin/ ;# as root
+ # make gitwebdir=/var/www/cgi-bin \
+ install-gitweb ;# as root
The above example assumes that your web server is configured to run
[executable] files in /var/www/cgi-bin/ as server scripts (as CGI
@@ -74,21 +76,20 @@ file for gitweb (in gitweb/README).
Build example
~~~~~~~~~~~~~
-- To install gitweb to /var/www/cgi-bin/gitweb/ when git wrapper
- is installed at /usr/local/bin/git and the repositories (projects)
- we want to display are under /home/local/scm, you can do
+- To install gitweb to /var/www/cgi-bin/gitweb/, when git wrapper
+ is installed at /usr/local/bin/git, the repositories (projects)
+ we want to display are under /home/local/scm, and you do not use
+ minifiers, you can do
make GITWEB_PROJECTROOT="/home/local/scm" \
- GITWEB_JS="/gitweb/gitweb.js" \
- GITWEB_CSS="/gitweb/gitweb.css" \
- GITWEB_LOGO="/gitweb/git-logo.png" \
- GITWEB_FAVICON="/gitweb/git-favicon.png" \
+ GITWEB_JS="gitweb/static/gitweb.js" \
+ GITWEB_CSS="gitweb/static/gitweb.css" \
+ GITWEB_LOGO="gitweb/static/git-logo.png" \
+ GITWEB_FAVICON="gitweb/static/git-favicon.png" \
bindir=/usr/local/bin \
gitweb
- cp -fv ~/git/gitweb/gitweb.{cgi,js,css} \
- ~/git/gitweb/git-{favicon,logo}.png \
- /var/www/cgi-bin/gitweb/
+ make gitwebdir=/var/www/cgi-bin/gitweb install-gitweb
Gitweb config file
diff --git a/gitweb/Makefile b/gitweb/Makefile
index f2e1d92fb..d2584fedd 100644
--- a/gitweb/Makefile
+++ b/gitweb/Makefile
@@ -4,15 +4,18 @@ all::
# Define V=1 to have a more verbose compile.
#
# Define JSMIN to point to JavaScript minifier that functions as
-# a filter to have gitweb.js minified.
+# a filter to have static/gitweb.js minified.
#
# Define CSSMIN to point to a CSS minifier in order to generate a minified
-# version of gitweb.css
+# version of static/gitweb.css
#
prefix ?= $(HOME)
bindir ?= $(prefix)/bin
+gitwebdir ?= /var/www/cgi-bin
+
RM ?= rm -f
+INSTALL ?= install
# default configuration for gitweb
GITWEB_CONFIG = gitweb_config.perl
@@ -26,10 +29,10 @@ GITWEB_STRICT_EXPORT =
GITWEB_BASE_URL =
GITWEB_LIST =
GITWEB_HOMETEXT = indextext.html
-GITWEB_CSS = gitweb.css
-GITWEB_LOGO = git-logo.png
-GITWEB_FAVICON = git-favicon.png
-GITWEB_JS = gitweb.js
+GITWEB_CSS = static/gitweb.css
+GITWEB_LOGO = static/git-logo.png
+GITWEB_FAVICON = static/git-favicon.png
+GITWEB_JS = static/gitweb.js
GITWEB_SITE_HEADER =
GITWEB_SITE_FOOTER =
@@ -49,9 +52,12 @@ SHELL_PATH ?= $(SHELL)
PERL_PATH ?= /usr/bin/perl
# Shell quote;
-bindir_SQ = $(subst ','\'',$(bindir)) #'
-SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) #'
-PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) #'
+bindir_SQ = $(subst ','\'',$(bindir))#'
+gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
+gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#'
+SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
+PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))#'
+DESTDIR_SQ = $(subst ','\'',$(DESTDIR))#'
# Quiet generation (unless V=1)
QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
@@ -80,20 +86,30 @@ endif
all:: gitweb.cgi
+GITWEB_PROGRAMS = gitweb.cgi
+
ifdef JSMIN
-GITWEB_JS = gitweb.min.js
-all:: gitweb.min.js
-gitweb.min.js: gitweb.js GITWEB-BUILD-OPTIONS
+GITWEB_FILES += static/gitweb.min.js
+GITWEB_JS = static/gitweb.min.js
+all:: static/gitweb.min.js
+static/gitweb.min.js: static/gitweb.js GITWEB-BUILD-OPTIONS
$(QUIET_GEN)$(JSMIN) <$< >$@
+else
+GITWEB_FILES += static/gitweb.js
endif
ifdef CSSMIN
-GITWEB_CSS = gitweb.min.css
-all:: gitweb.min.css
-gitweb.min.css: gitweb.css GITWEB-BUILD-OPTIONS
+GITWEB_FILES += static/gitweb.min.css
+GITWEB_CSS = static/gitweb.min.css
+all:: static/gitweb.min.css
+static/gitweb.min.css: static/gitweb.css GITWEB-BUILD-OPTIONS
$(QUIET_GEN)$(CSSMIN) <$ >$@
+else
+GITWEB_FILES += static/gitweb.css
endif
+GITWEB_FILES += static/git-logo.png static/git-favicon.png
+
GITWEB_REPLACE = \
-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
-e 's|++GIT_BINDIR++|$(bindir)|g' \
@@ -127,8 +143,18 @@ gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
chmod +x $@+ && \
mv $@+ $@
+### Installation rules
+
+install: all
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
+ $(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
+ $(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
+
+### Cleaning rules
+
clean:
- $(RM) gitweb.cgi gitweb.min.js gitweb.min.css GITWEB-BUILD-OPTIONS
+ $(RM) gitweb.cgi static/gitweb.min.js static/gitweb.min.css GITWEB-BUILD-OPTIONS
-.PHONY: all clean .FORCE-GIT-VERSION-FILE FORCE
+.PHONY: all clean install .FORCE-GIT-VERSION-FILE FORCE
diff --git a/gitweb/README b/gitweb/README
index 71742b335..0e19be8d2 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -80,24 +80,26 @@ You can specify the following configuration variables when building GIT:
Points to the location where you put gitweb.css on your web server
(or to be more generic, the URI of gitweb stylesheet). Relative to the
base URI of gitweb. Note that you can setup multiple stylesheets from
- the gitweb config file. [Default: gitweb.css (or gitweb.min.css if the
- CSSMIN variable is defined / CSS minifier is used)]
+ the gitweb config file. [Default: static/gitweb.css (or
+ static/gitweb.min.css if the CSSMIN variable is defined / CSS minifier
+ is used)]
* GITWEB_LOGO
Points to the location where you put git-logo.png on your web server
(or to be more generic URI of logo, 72x27 size, displayed in top right
corner of each gitweb page, and used as logo for Atom feed). Relative
- to base URI of gitweb. [Default: git-logo.png]
+ to base URI of gitweb. [Default: static/git-logo.png]
* GITWEB_FAVICON
Points to the location where you put git-favicon.png on your web server
(or to be more generic URI of favicon, assumed to be image/png type;
web browsers that support favicons (website icons) may display them
in the browser's URL bar and next to site name in bookmarks). Relative
- to base URI of gitweb. [Default: git-favicon.png]
+ to base URI of gitweb. [Default: static/git-favicon.png]
* GITWEB_JS
Points to the localtion where you put gitweb.js on your web server
(or to be more generic URI of JavaScript code used by gitweb).
- Relative to base URI of gitweb. [Default: gitweb.js (or gitweb.min.js
- if JSMIN build variable is defined / JavaScript minifier is used)]
+ Relative to base URI of gitweb. [Default: static/gitweb.js (or
+ static/gitweb.min.js if JSMIN build variable is defined / JavaScript
+ minifier is used)]
* GITWEB_CONFIG
This Perl file will be loaded using 'do' and can be used to override any
of the options above as well as some other options -- see the "Runtime
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index c356e95f1..2365311d9 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -11,7 +11,7 @@ use strict;
use warnings;
use CGI qw(:standard :escapeHTML -nosticky);
use CGI::Util qw(unescape);
-use CGI::Carp qw(fatalsToBrowser);
+use CGI::Carp qw(fatalsToBrowser set_message);
use Encode;
use Fcntl ':mode';
use File::Find qw();
@@ -445,6 +445,19 @@ our %feature = (
'javascript-actions' => {
'override' => 0,
'default' => [0]},
+
+ # Syntax highlighting support. This is based on Daniel Svensson's
+ # and Sham Chukoury's work in gitweb-xmms2.git.
+ # It requires the 'highlight' program present in $PATH,
+ # and therefore is disabled by default.
+
+ # To enable system wide have in $GITWEB_CONFIG
+ # $feature{'highlight'}{'default'} = [1];
+
+ 'highlight' => {
+ 'sub' => sub { feature_bool('highlight', @_) },
+ 'override' => 0,
+ 'default' => [0]},
);
sub gitweb_get_feature {
@@ -952,6 +965,21 @@ if ($git_avatar eq 'gravatar') {
$git_avatar = '';
}
+# custom error handler: 'die <message>' is Internal Server Error
+sub handle_errors_html {
+ my $msg = shift; # it is already HTML escaped
+
+ # to avoid infinite loop where error occurs in die_error,
+ # change handler to default handler, disabling handle_errors_html
+ set_message("Error occured when inside die_error:\n$msg");
+
+ # you cannot jump out of die_error when called as error handler;
+ # the subroutine set via CGI::Carp::set_message is called _after_
+ # HTTP headers are already written, so it cannot write them itself
+ die_error(undef, undef, $msg, -error_handler => 1, -no_http_header => 1);
+}
+set_message(\&handle_errors_html);
+
# dispatch
if (!defined $action) {
if (defined $hash) {
@@ -972,11 +1000,16 @@ if ($action !~ m/^(?:opml|project_list|project_index)$/ &&
die_error(400, "Project needed");
}
$actions{$action}->();
-exit;
+DONE_GITWEB:
+1;
## ======================================================================
## action links
+# possible values of extra options
+# -full => 0|1 - use absolute/full URL ($my_uri/$my_url as base)
+# -replay => 1 - start from a current view (replay with modifications)
+# -path_info => 0|1 - don't use/use path_info URL (if possible)
sub href {
my %params = @_;
# default is to use -absolute url() i.e. $my_uri
@@ -993,7 +1026,8 @@ sub href {
}
my $use_pathinfo = gitweb_check_feature('pathinfo');
- if ($use_pathinfo and defined $params{'project'}) {
+ if (defined $params{'project'} &&
+ (exists $params{-path_info} ? $params{-path_info} : $use_pathinfo)) {
# try to put as many parameters as possible in PATH_INFO:
# - project name
# - action
@@ -2420,6 +2454,9 @@ sub git_get_projects_list {
follow_skip => 2, # ignore duplicates
dangling_symlinks => 0, # ignore dangling symlinks, silently
wanted => sub {
+ # global variables
+ our $project_maxdepth;
+ our $projectroot;
# skip project-list toplevel, if we get it.
return if (m!^[/.]$!);
# only directories can be git repositories
@@ -3155,26 +3192,88 @@ sub blob_contenttype {
return $type;
}
+# guess file syntax for syntax highlighting; return undef if no highlighting
+# the name of syntax can (in the future) depend on syntax highlighter used
+sub guess_file_syntax {
+ my ($highlight, $mimetype, $file_name) = @_;
+ return undef unless ($highlight && defined $file_name);
+
+ # configuration for 'highlight' (http://www.andre-simon.de/)
+ # match by basename
+ my %highlight_basename = (
+ #'Program' => 'py',
+ #'Library' => 'py',
+ 'SConstruct' => 'py', # SCons equivalent of Makefile
+ 'Makefile' => 'make',
+ );
+ # match by extension
+ my %highlight_ext = (
+ # main extensions, defining name of syntax;
+ # see files in /usr/share/highlight/langDefs/ directory
+ map { $_ => $_ }
+ qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),
+ # alternate extensions, see /etc/highlight/filetypes.conf
+ 'h' => 'c',
+ map { $_ => 'cpp' } qw(cxx c++ cc),
+ map { $_ => 'php' } qw(php3 php4),
+ map { $_ => 'pl' } qw(perl pm), # perhaps also 'cgi'
+ 'mak' => 'make',
+ map { $_ => 'xml' } qw(xhtml html htm),
+ );
+
+ my $basename = basename($file_name, '.in');
+ return $highlight_basename{$basename}
+ if exists $highlight_basename{$basename};
+
+ $basename =~ /\.([^.]*)$/;
+ my $ext = $1 or return undef;
+ return $highlight_ext{$ext}
+ if exists $highlight_ext{$ext};
+
+ return undef;
+}
+
+# run highlighter and return FD of its output,
+# or return original FD if no highlighting
+sub run_highlighter {
+ my ($fd, $highlight, $syntax) = @_;
+ return $fd unless ($highlight && defined $syntax);
+
+ close $fd
+ or die_error(404, "Reading blob failed");
+ open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ".
+ "highlight --xhtml --fragment --syntax $syntax |"
+ or die_error(500, "Couldn't open file or run syntax highlighter");
+ return $fd;
+}
+
## ======================================================================
## functions printing HTML: header, footer, error page
+sub get_page_title {
+ my $title = to_utf8($site_name);
+
+ return $title unless (defined $project);
+ $title .= " - " . to_utf8($project);
+
+ return $title unless (defined $action);
+ $title .= "/$action"; # $action is US-ASCII (7bit ASCII)
+
+ return $title unless (defined $file_name);
+ $title .= " - " . esc_path($file_name);
+ if ($action eq "tree" && $file_name !~ m|/$|) {
+ $title .= "/";
+ }
+
+ return $title;
+}
+
sub git_header_html {
my $status = shift || "200 OK";
my $expires = shift;
+ my %opts = @_;
- my $title = "$site_name";
- if (defined $project) {
- $title .= " - " . to_utf8($project);
- if (defined $action) {
- $title .= "/$action";
- if (defined $file_name) {
- $title .= " - " . esc_path($file_name);
- if ($action eq "tree" && $file_name !~ m|/$|) {
- $title .= "/";
- }
- }
- }
- }
+ my $title = get_page_title();
my $content_type;
# require explicit support from the UA if we are to send the page as
# 'application/xhtml+xml', otherwise send it as plain old 'text/html'.
@@ -3188,7 +3287,8 @@ sub git_header_html {
$content_type = 'text/html';
}
print $cgi->header(-type=>$content_type, -charset => 'utf-8',
- -status=> $status, -expires => $expires);
+ -status=> $status, -expires => $expires)
+ unless ($opts{'-no_http_header'});
my $mod_perl_version = $ENV{'MOD_PERL'} ? " $ENV{'MOD_PERL'}" : '';
print <<EOF;
<?xml version="1.0" encoding="utf-8"?>
@@ -3405,6 +3505,7 @@ sub die_error {
my $status = shift || 500;
my $error = esc_html(shift) || "Internal Server Error";
my $extra = shift;
+ my %opts = @_;
my %http_responses = (
400 => '400 Bad Request',
@@ -3413,7 +3514,7 @@ sub die_error {
500 => '500 Internal Server Error',
503 => '503 Service Unavailable',
);
- git_header_html($http_responses{$status});
+ git_header_html($http_responses{$status}, undef, %opts);
print <<EOF;
<div class="page_body">
<br /><br />
@@ -3427,7 +3528,8 @@ EOF
print "</div>\n";
git_footer_html();
- exit;
+ goto DONE_GITWEB
+ unless ($opts{'-error_handler'});
}
## ----------------------------------------------------------------------
@@ -5346,6 +5448,7 @@ sub git_blob {
open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
or die_error(500, "Couldn't cat $file_name, $hash");
my $mimetype = blob_mimetype($fd, $file_name);
+ # use 'blob_plain' (aka 'raw') view for files that cannot be displayed
if ($mimetype !~ m!^(?:text/|image/(?:gif|png|jpeg)$)! && -B $fd) {
close $fd;
return git_blob_plain($mimetype);
@@ -5353,6 +5456,11 @@ sub git_blob {
# we can have blame only for text/* mimetype
$have_blame &&= ($mimetype =~ m!^text/!);
+ my $highlight = gitweb_check_feature('highlight');
+ my $syntax = guess_file_syntax($highlight, $mimetype, $file_name);
+ $fd = run_highlighter($fd, $highlight, $syntax)
+ if $syntax;
+
git_header_html(undef, $expires);
my $formats_nav = '';
if (defined $hash_base && (my %co = parse_commit($hash_base))) {
@@ -5402,9 +5510,8 @@ sub git_blob {
chomp $line;
$nr++;
$line = untabify($line);
- printf "<div class=\"pre\"><a id=\"l%i\" href=\"" . href(-replay => 1)
- . "#l%i\" class=\"linenr\">%4i</a> %s</div>\n",
- $nr, $nr, $nr, esc_html($line, -nbsp=>1);
+ printf qq!<div class="pre"><a id="l%i" href="%s#l%i" class="linenr">%4i</a> %s</div>\n!,
+ $nr, href(-replay => 1), $nr, $nr, $syntax ? $line : esc_html($line, -nbsp=>1);
}
}
close $fd
@@ -6117,8 +6224,8 @@ sub git_commitdiff {
}
push @commit_spec, '--root', $hash;
}
- open $fd, "-|", git_cmd(), "format-patch", '--encoding=utf8',
- '--stdout', @commit_spec
+ open $fd, "-|", git_cmd(), "format-patch", @diff_opts,
+ '--encoding=utf8', '--stdout', @commit_spec
or die_error(500, "Open git-format-patch failed");
} else {
die_error(400, "Unknown commitdiff format");
diff --git a/gitweb/git-favicon.png b/gitweb/static/git-favicon.png
index aae35a70e..aae35a70e 100644
--- a/gitweb/git-favicon.png
+++ b/gitweb/static/git-favicon.png
Binary files differ
diff --git a/gitweb/git-logo.png b/gitweb/static/git-logo.png
index f4ede2e94..f4ede2e94 100644
--- a/gitweb/git-logo.png
+++ b/gitweb/static/git-logo.png
Binary files differ
diff --git a/gitweb/gitweb.css b/gitweb/static/gitweb.css
index 50067f2e0..4132aabcd 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/static/gitweb.css
@@ -572,3 +572,21 @@ span.match {
div.binary {
font-style: italic;
}
+
+/* Style definition generated by highlight 2.4.5, http://www.andre-simon.de/ */
+
+/* Highlighting theme definition: */
+
+.num { color:#2928ff; }
+.esc { color:#ff00ff; }
+.str { color:#ff0000; }
+.dstr { color:#818100; }
+.slc { color:#838183; font-style:italic; }
+.com { color:#838183; font-style:italic; }
+.dir { color:#008200; }
+.sym { color:#000000; }
+.line { color:#555555; }
+.kwa { color:#000000; font-weight:bold; }
+.kwb { color:#830000; }
+.kwc { color:#000000; font-weight:bold; }
+.kwd { color:#010181; }
diff --git a/gitweb/gitweb.js b/gitweb/static/gitweb.js
index 9c66928c4..9c66928c4 100644
--- a/gitweb/gitweb.js
+++ b/gitweb/static/gitweb.js
diff --git a/grep.c b/grep.c
index 543b1d537..82fb349be 100644
--- a/grep.c
+++ b/grep.c
@@ -7,6 +7,7 @@ void append_header_grep_pattern(struct grep_opt *opt, enum grep_header_field fie
{
struct grep_pat *p = xcalloc(1, sizeof(*p));
p->pattern = pat;
+ p->patternlen = strlen(pat);
p->origin = "header";
p->no = 0;
p->token = GREP_PATTERN_HEAD;
@@ -19,8 +20,15 @@ void append_header_grep_pattern(struct grep_opt *opt, enum grep_header_field fie
void append_grep_pattern(struct grep_opt *opt, const char *pat,
const char *origin, int no, enum grep_pat_token t)
{
+ append_grep_pat(opt, pat, strlen(pat), origin, no, t);
+}
+
+void append_grep_pat(struct grep_opt *opt, const char *pat, size_t patlen,
+ const char *origin, int no, enum grep_pat_token t)
+{
struct grep_pat *p = xcalloc(1, sizeof(*p));
p->pattern = pat;
+ p->patternlen = patlen;
p->origin = origin;
p->no = no;
p->token = t;
@@ -44,8 +52,8 @@ struct grep_opt *grep_opt_dup(const struct grep_opt *opt)
append_header_grep_pattern(ret, pat->field,
pat->pattern);
else
- append_grep_pattern(ret, pat->pattern, pat->origin,
- pat->no, pat->token);
+ append_grep_pat(ret, pat->pattern, pat->patternlen,
+ pat->origin, pat->no, pat->token);
}
return ret;
@@ -329,14 +337,21 @@ static void show_name(struct grep_opt *opt, const char *name)
opt->output(opt, opt->null_following_name ? "\0" : "\n", 1);
}
-
-static int fixmatch(const char *pattern, char *line, int ignore_case, regmatch_t *match)
+static int fixmatch(struct grep_pat *p, char *line, char *eol,
+ regmatch_t *match)
{
char *hit;
- if (ignore_case)
- hit = strcasestr(line, pattern);
- else
- hit = strstr(line, pattern);
+
+ if (p->ignore_case) {
+ char *s = line;
+ do {
+ hit = strcasestr(s, p->pattern);
+ if (hit)
+ break;
+ s += strlen(s) + 1;
+ } while (s < eol);
+ } else
+ hit = memmem(line, eol - line, p->pattern, p->patternlen);
if (!hit) {
match->rm_so = match->rm_eo = -1;
@@ -344,11 +359,22 @@ static int fixmatch(const char *pattern, char *line, int ignore_case, regmatch_t
}
else {
match->rm_so = hit - line;
- match->rm_eo = match->rm_so + strlen(pattern);
+ match->rm_eo = match->rm_so + p->patternlen;
return 0;
}
}
+static int regmatch(const regex_t *preg, char *line, char *eol,
+ regmatch_t *match, int eflags)
+{
+#ifdef REG_STARTEND
+ match->rm_so = 0;
+ match->rm_eo = eol - line;
+ eflags |= REG_STARTEND;
+#endif
+ return regexec(preg, line, 1, match, eflags);
+}
+
static int strip_timestamp(char *bol, char **eol_p)
{
char *eol = *eol_p;
@@ -399,9 +425,9 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
again:
if (p->fixed)
- hit = !fixmatch(p->pattern, bol, p->ignore_case, pmatch);
+ hit = !fixmatch(p, bol, eol, pmatch);
else
- hit = !regexec(&p->regexp, bol, 1, pmatch, eflags);
+ hit = !regmatch(&p->regexp, bol, eol, pmatch, eflags);
if (hit && p->word_regexp) {
if ((pmatch[0].rm_so < 0) ||
@@ -726,16 +752,9 @@ static int look_ahead(struct grep_opt *opt,
regmatch_t m;
if (p->fixed)
- hit = !fixmatch(p->pattern, bol, p->ignore_case, &m);
- else {
-#ifdef REG_STARTEND
- m.rm_so = 0;
- m.rm_eo = *left_p;
- hit = !regexec(&p->regexp, bol, 1, &m, REG_STARTEND);
-#else
- hit = !regexec(&p->regexp, bol, 1, &m, 0);
-#endif
- }
+ hit = !fixmatch(p, bol, bol + *left_p, &m);
+ else
+ hit = !regmatch(&p->regexp, bol, bol + *left_p, &m, 0);
if (!hit || m.rm_so < 0 || m.rm_eo < 0)
continue;
if (earliest < 0 || m.rm_so < earliest)
@@ -800,17 +819,19 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
opt->show_hunk_mark = 1;
opt->last_shown = 0;
- if (buffer_is_binary(buf, size)) {
- switch (opt->binary) {
- case GREP_BINARY_DEFAULT:
+ switch (opt->binary) {
+ case GREP_BINARY_DEFAULT:
+ if (buffer_is_binary(buf, size))
binary_match_only = 1;
- break;
- case GREP_BINARY_NOMATCH:
+ break;
+ case GREP_BINARY_NOMATCH:
+ if (buffer_is_binary(buf, size))
return 0; /* Assume unmatch */
- break;
- default:
- break;
- }
+ break;
+ case GREP_BINARY_TEXT:
+ break;
+ default:
+ die("bug: unknown binary handling mode");
}
memset(&xecfg, 0, sizeof(xecfg));
@@ -871,6 +892,12 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
count++;
if (opt->status_only)
return 1;
+ if (opt->name_only) {
+ show_name(opt, name);
+ return 1;
+ }
+ if (opt->count)
+ goto next_line;
if (binary_match_only) {
opt->output(opt, "Binary file ", 12);
output_color(opt, name, strlen(name),
@@ -878,22 +905,14 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
opt->output(opt, " matches\n", 9);
return 1;
}
- if (opt->name_only) {
- show_name(opt, name);
- return 1;
- }
/* Hit at this line. If we haven't shown the
* pre-context lines, we would need to show them.
- * When asked to do "count", this still show
- * the context which is nonsense, but the user
- * deserves to get that ;-).
*/
if (opt->pre_context)
show_pre_context(opt, name, buf, bol, lno);
else if (opt->funcname)
show_funcname_line(opt, name, buf, bol, lno);
- if (!opt->count)
- show_line(opt, bol, eol, name, lno, ':');
+ show_line(opt, bol, eol, name, lno, ':');
last_hit = lno;
}
else if (last_hit &&
@@ -937,6 +956,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
output_sep(opt, ':');
snprintf(buf, sizeof(buf), "%u\n", count);
opt->output(opt, buf, strlen(buf));
+ return 1;
}
return !!last_hit;
}
diff --git a/grep.h b/grep.h
index 89342e5b4..0aebebd96 100644
--- a/grep.h
+++ b/grep.h
@@ -29,6 +29,7 @@ struct grep_pat {
int no;
enum grep_pat_token token;
const char *pattern;
+ size_t patternlen;
enum grep_header_field field;
regex_t regexp;
unsigned fixed:1;
@@ -104,6 +105,7 @@ struct grep_opt {
void *output_priv;
};
+extern void append_grep_pat(struct grep_opt *opt, const char *pat, size_t patlen, const char *origin, int no, enum grep_pat_token t);
extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
extern void compile_grep_patterns(struct grep_opt *opt);
diff --git a/http-backend.c b/http-backend.c
index d1e83d090..f0e787e37 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -6,6 +6,7 @@
#include "exec_cmd.h"
#include "run-command.h"
#include "string-list.h"
+#include "url.h"
static const char content_type[] = "Content-Type";
static const char content_length[] = "Content-Length";
@@ -25,60 +26,6 @@ static struct rpc_service rpc_service[] = {
{ "receive-pack", "receivepack", -1 },
};
-static int decode_char(const char *q)
-{
- int i;
- unsigned char val = 0;
- for (i = 0; i < 2; i++) {
- unsigned char c = *q++;
- val <<= 4;
- if (c >= '0' && c <= '9')
- val += c - '0';
- else if (c >= 'a' && c <= 'f')
- val += c - 'a' + 10;
- else if (c >= 'A' && c <= 'F')
- val += c - 'A' + 10;
- else
- return -1;
- }
- return val;
-}
-
-static char *decode_parameter(const char **query, int is_name)
-{
- const char *q = *query;
- struct strbuf out;
-
- strbuf_init(&out, 16);
- do {
- unsigned char c = *q;
-
- if (!c)
- break;
- if (c == '&' || (is_name && c == '=')) {
- q++;
- break;
- }
-
- if (c == '%') {
- int val = decode_char(q + 1);
- if (0 <= val) {
- strbuf_addch(&out, val);
- q += 3;
- continue;
- }
- }
-
- if (c == '+')
- strbuf_addch(&out, ' ');
- else
- strbuf_addch(&out, c);
- q++;
- } while (1);
- *query = q;
- return strbuf_detach(&out, NULL);
-}
-
static struct string_list *get_parameters(void)
{
if (!query_params) {
@@ -86,8 +33,8 @@ static struct string_list *get_parameters(void)
query_params = xcalloc(1, sizeof(*query_params));
while (query && *query) {
- char *name = decode_parameter(&query, 1);
- char *value = decode_parameter(&query, 0);
+ char *name = url_decode_parameter_name(&query);
+ char *value = url_decode_parameter_value(&query);
struct string_list_item *i;
i = string_list_lookup(name, query_params);
diff --git a/http-walker.c b/http-walker.c
index ef99ae647..8ca76d050 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -510,7 +510,7 @@ static int fetch_object(struct walker *walker, struct alt_base *repo, unsigned c
ret = error("File %s has bad hash", hex);
} else if (req->rename < 0) {
ret = error("unable to write sha1 filename %s",
- req->filename);
+ sha1_file_name(req->sha1));
}
release_http_object_request(req);
diff --git a/http.c b/http.c
index 07a03fd79..1320c50e3 100644
--- a/http.c
+++ b/http.c
@@ -1,6 +1,7 @@
#include "http.h"
#include "pack.h"
#include "sideband.h"
+#include "run-command.h"
int data_received;
int active_requests;
@@ -914,47 +915,67 @@ int http_fetch_ref(const char *base, struct ref *ref)
}
/* Helpers for fetching packs */
-static int fetch_pack_index(unsigned char *sha1, const char *base_url)
+static char *fetch_pack_index(unsigned char *sha1, const char *base_url)
{
- int ret = 0;
- char *hex = xstrdup(sha1_to_hex(sha1));
- char *filename;
- char *url = NULL;
+ char *url, *tmp;
struct strbuf buf = STRBUF_INIT;
- if (has_pack_index(sha1)) {
- ret = 0;
- goto cleanup;
- }
-
if (http_is_verbose)
- fprintf(stderr, "Getting index for pack %s\n", hex);
+ fprintf(stderr, "Getting index for pack %s\n", sha1_to_hex(sha1));
end_url_with_slash(&buf, base_url);
- strbuf_addf(&buf, "objects/pack/pack-%s.idx", hex);
+ strbuf_addf(&buf, "objects/pack/pack-%s.idx", sha1_to_hex(sha1));
url = strbuf_detach(&buf, NULL);
- filename = sha1_pack_index_name(sha1);
- if (http_get_file(url, filename, 0) != HTTP_OK)
- ret = error("Unable to get pack index %s\n", url);
+ strbuf_addf(&buf, "%s.temp", sha1_pack_index_name(sha1));
+ tmp = strbuf_detach(&buf, NULL);
+
+ if (http_get_file(url, tmp, 0) != HTTP_OK) {
+ error("Unable to get pack index %s\n", url);
+ free(tmp);
+ tmp = NULL;
+ }
-cleanup:
- free(hex);
free(url);
- return ret;
+ return tmp;
}
static int fetch_and_setup_pack_index(struct packed_git **packs_head,
unsigned char *sha1, const char *base_url)
{
struct packed_git *new_pack;
+ char *tmp_idx = NULL;
+ int ret;
- if (fetch_pack_index(sha1, base_url))
+ if (has_pack_index(sha1)) {
+ new_pack = parse_pack_index(sha1, NULL);
+ if (!new_pack)
+ return -1; /* parse_pack_index() already issued error message */
+ goto add_pack;
+ }
+
+ tmp_idx = fetch_pack_index(sha1, base_url);
+ if (!tmp_idx)
return -1;
- new_pack = parse_pack_index(sha1);
- if (!new_pack)
+ new_pack = parse_pack_index(sha1, tmp_idx);
+ if (!new_pack) {
+ unlink(tmp_idx);
+ free(tmp_idx);
+
return -1; /* parse_pack_index() already issued error message */
+ }
+
+ ret = verify_pack_index(new_pack);
+ if (!ret) {
+ close_pack_index(new_pack);
+ ret = move_temp_to_file(tmp_idx, sha1_pack_index_name(sha1));
+ }
+ free(tmp_idx);
+ if (ret)
+ return -1;
+
+add_pack:
new_pack->next = *packs_head;
*packs_head = new_pack;
return 0;
@@ -1018,37 +1039,62 @@ void release_http_pack_request(struct http_pack_request *preq)
int finish_http_pack_request(struct http_pack_request *preq)
{
- int ret;
struct packed_git **lst;
+ struct packed_git *p = preq->target;
+ char *tmp_idx;
+ struct child_process ip;
+ const char *ip_argv[8];
- preq->target->pack_size = ftell(preq->packfile);
+ close_pack_index(p);
- if (preq->packfile != NULL) {
- fclose(preq->packfile);
- preq->packfile = NULL;
- preq->slot->local = NULL;
- }
-
- ret = move_temp_to_file(preq->tmpfile, preq->filename);
- if (ret)
- return ret;
+ fclose(preq->packfile);
+ preq->packfile = NULL;
+ preq->slot->local = NULL;
lst = preq->lst;
- while (*lst != preq->target)
+ while (*lst != p)
lst = &((*lst)->next);
*lst = (*lst)->next;
- if (verify_pack(preq->target))
+ tmp_idx = xstrdup(preq->tmpfile);
+ strcpy(tmp_idx + strlen(tmp_idx) - strlen(".pack.temp"),
+ ".idx.temp");
+
+ ip_argv[0] = "index-pack";
+ ip_argv[1] = "-o";
+ ip_argv[2] = tmp_idx;
+ ip_argv[3] = preq->tmpfile;
+ ip_argv[4] = NULL;
+
+ memset(&ip, 0, sizeof(ip));
+ ip.argv = ip_argv;
+ ip.git_cmd = 1;
+ ip.no_stdin = 1;
+ ip.no_stdout = 1;
+
+ if (run_command(&ip)) {
+ unlink(preq->tmpfile);
+ unlink(tmp_idx);
+ free(tmp_idx);
+ return -1;
+ }
+
+ unlink(sha1_pack_index_name(p->sha1));
+
+ if (move_temp_to_file(preq->tmpfile, sha1_pack_name(p->sha1))
+ || move_temp_to_file(tmp_idx, sha1_pack_index_name(p->sha1))) {
+ free(tmp_idx);
return -1;
- install_packed_git(preq->target);
+ }
+ install_packed_git(p);
+ free(tmp_idx);
return 0;
}
struct http_pack_request *new_http_pack_request(
struct packed_git *target, const char *base_url)
{
- char *filename;
long prev_posn = 0;
char range[RANGE_HEADER_SIZE];
struct strbuf buf = STRBUF_INIT;
@@ -1063,9 +1109,8 @@ struct http_pack_request *new_http_pack_request(
sha1_to_hex(target->sha1));
preq->url = strbuf_detach(&buf, NULL);
- filename = sha1_pack_name(target->sha1);
- snprintf(preq->filename, sizeof(preq->filename), "%s", filename);
- snprintf(preq->tmpfile, sizeof(preq->tmpfile), "%s.temp", filename);
+ snprintf(preq->tmpfile, sizeof(preq->tmpfile), "%s.temp",
+ sha1_pack_name(target->sha1));
preq->packfile = fopen(preq->tmpfile, "a");
if (!preq->packfile) {
error("Unable to open local file %s for pack",
@@ -1100,7 +1145,6 @@ struct http_pack_request *new_http_pack_request(
return preq;
abort:
- free(filename);
free(preq->url);
free(preq);
return NULL;
@@ -1155,7 +1199,6 @@ struct http_object_request *new_http_object_request(const char *base_url,
freq->localfile = -1;
filename = sha1_file_name(sha1);
- snprintf(freq->filename, sizeof(freq->filename), "%s", filename);
snprintf(freq->tmpfile, sizeof(freq->tmpfile),
"%s.temp", filename);
@@ -1184,8 +1227,8 @@ struct http_object_request *new_http_object_request(const char *base_url,
}
if (freq->localfile < 0) {
- error("Couldn't create temporary file %s for %s: %s",
- freq->tmpfile, freq->filename, strerror(errno));
+ error("Couldn't create temporary file %s: %s",
+ freq->tmpfile, strerror(errno));
goto abort;
}
@@ -1232,8 +1275,8 @@ struct http_object_request *new_http_object_request(const char *base_url,
prev_posn = 0;
lseek(freq->localfile, 0, SEEK_SET);
if (ftruncate(freq->localfile, 0) < 0) {
- error("Couldn't truncate temporary file %s for %s: %s",
- freq->tmpfile, freq->filename, strerror(errno));
+ error("Couldn't truncate temporary file %s: %s",
+ freq->tmpfile, strerror(errno));
goto abort;
}
}
@@ -1309,7 +1352,7 @@ int finish_http_object_request(struct http_object_request *freq)
return -1;
}
freq->rename =
- move_temp_to_file(freq->tmpfile, freq->filename);
+ move_temp_to_file(freq->tmpfile, sha1_file_name(freq->sha1));
return freq->rename;
}
diff --git a/http.h b/http.h
index 37a6a6a3b..a0b590159 100644
--- a/http.h
+++ b/http.h
@@ -155,7 +155,6 @@ struct http_pack_request
struct packed_git *target;
struct packed_git **lst;
FILE *packfile;
- char filename[PATH_MAX];
char tmpfile[PATH_MAX];
struct curl_slist *range_header;
struct active_request_slot *slot;
@@ -170,7 +169,6 @@ extern void release_http_pack_request(struct http_pack_request *preq);
struct http_object_request
{
char *url;
- char filename[PATH_MAX];
char tmpfile[PATH_MAX];
int localfile;
CURLcode curl_result;
diff --git a/merge-file.c b/merge-file.c
index c336c93c0..db4d0d50d 100644
--- a/merge-file.c
+++ b/merge-file.c
@@ -66,7 +66,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
xdemitcb_t ecb;
memset(&xpp, 0, sizeof(xpp));
- xpp.flags = XDF_NEED_MINIMAL;
+ xpp.flags = 0;
memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = 3;
xecfg.flags = XDL_EMIT_COMMON;
diff --git a/notes.c b/notes.c
index e425e1982..6ee04e79e 100644
--- a/notes.c
+++ b/notes.c
@@ -1083,7 +1083,7 @@ int write_notes_tree(struct notes_tree *t, unsigned char *result)
return ret;
}
-void prune_notes(struct notes_tree *t)
+void prune_notes(struct notes_tree *t, int flags)
{
struct note_delete_list *l = NULL;
@@ -1094,7 +1094,10 @@ void prune_notes(struct notes_tree *t)
for_each_note(t, 0, prune_notes_helper, &l);
while (l) {
- remove_note(t, l->sha1);
+ if (flags & NOTES_PRUNE_VERBOSE)
+ printf("%s\n", sha1_to_hex(l->sha1));
+ if (!(flags & NOTES_PRUNE_DRYRUN))
+ remove_note(t, l->sha1);
l = l->next;
}
}
diff --git a/notes.h b/notes.h
index 9f59277c5..cc2dff22a 100644
--- a/notes.h
+++ b/notes.h
@@ -171,6 +171,9 @@ int for_each_note(struct notes_tree *t, int flags, each_note_fn fn,
*/
int write_notes_tree(struct notes_tree *t, unsigned char *result);
+/* Flags controlling the operation of prune */
+#define NOTES_PRUNE_VERBOSE 1
+#define NOTES_PRUNE_DRYRUN 2
/*
* Remove all notes annotating non-existing objects from the given notes tree
*
@@ -181,7 +184,7 @@ int write_notes_tree(struct notes_tree *t, unsigned char *result);
* structure are not persistent until a subsequent call to write_notes_tree()
* returns zero.
*/
-void prune_notes(struct notes_tree *t);
+void prune_notes(struct notes_tree *t, int flags);
/*
* Free (and de-initialize) the given notes_tree structure
diff --git a/object.c b/object.c
index 3ca92c4c4..277b3ddba 100644
--- a/object.c
+++ b/object.c
@@ -252,10 +252,10 @@ void add_object_array_with_mode(struct object *obj, const char *name, struct obj
void object_array_remove_duplicates(struct object_array *array)
{
- int ref, src, dst;
+ unsigned int ref, src, dst;
struct object_array_entry *objects = array->objects;
- for (ref = 0; ref < array->nr - 1; ref++) {
+ for (ref = 0; ref + 1 < array->nr; ref++) {
for (src = ref + 1, dst = src;
src < array->nr;
src++) {
diff --git a/pack-check.c b/pack-check.c
index 166ca703c..395fb9527 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -133,14 +133,13 @@ static int verify_packfile(struct packed_git *p,
return err;
}
-int verify_pack(struct packed_git *p)
+int verify_pack_index(struct packed_git *p)
{
off_t index_size;
const unsigned char *index_base;
git_SHA_CTX ctx;
unsigned char sha1[20];
int err = 0;
- struct pack_window *w_curs = NULL;
if (open_pack_index(p))
return error("packfile %s index not opened", p->pack_name);
@@ -154,8 +153,18 @@ int verify_pack(struct packed_git *p)
if (hashcmp(sha1, index_base + index_size - 20))
err = error("Packfile index for %s SHA1 mismatch",
p->pack_name);
+ return err;
+}
+
+int verify_pack(struct packed_git *p)
+{
+ int err = 0;
+ struct pack_window *w_curs = NULL;
+
+ err |= verify_pack_index(p);
+ if (!p->index_data)
+ return -1;
- /* Verify pack file */
err |= verify_packfile(p, &w_curs);
unuse_pack(&w_curs);
diff --git a/pack.h b/pack.h
index d268c014c..bb275762b 100644
--- a/pack.h
+++ b/pack.h
@@ -57,6 +57,7 @@ struct pack_idx_entry {
extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1);
extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr);
+extern int verify_pack_index(struct packed_git *);
extern int verify_pack(struct packed_git *);
extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t, unsigned char *, off_t);
extern char *index_pack_lockfile(int fd);
diff --git a/pretty.c b/pretty.c
index 742b48bbd..8b18efda9 100644
--- a/pretty.c
+++ b/pretty.c
@@ -11,6 +11,17 @@
#include "reflog-walk.h"
static char *user_format;
+static struct cmt_fmt_map {
+ const char *name;
+ enum cmit_fmt format;
+ int is_tformat;
+ int is_alias;
+ const char *user_format;
+} *commit_formats;
+static size_t builtin_formats_len;
+static size_t commit_formats_len;
+static size_t commit_formats_alloc;
+static struct cmt_fmt_map *find_commit_format(const char *sought);
static void save_user_format(struct rev_info *rev, const char *cp, int is_tformat)
{
@@ -21,22 +32,118 @@ static void save_user_format(struct rev_info *rev, const char *cp, int is_tforma
rev->commit_format = CMIT_FMT_USERFORMAT;
}
-void get_commit_format(const char *arg, struct rev_info *rev)
+static int git_pretty_formats_config(const char *var, const char *value, void *cb)
{
+ struct cmt_fmt_map *commit_format = NULL;
+ const char *name;
+ const char *fmt;
int i;
- static struct cmt_fmt_map {
- const char *n;
- size_t cmp_len;
- enum cmit_fmt v;
- } cmt_fmts[] = {
- { "raw", 1, CMIT_FMT_RAW },
- { "medium", 1, CMIT_FMT_MEDIUM },
- { "short", 1, CMIT_FMT_SHORT },
- { "email", 1, CMIT_FMT_EMAIL },
- { "full", 5, CMIT_FMT_FULL },
- { "fuller", 5, CMIT_FMT_FULLER },
- { "oneline", 1, CMIT_FMT_ONELINE },
+
+ if (prefixcmp(var, "pretty."))
+ return 0;
+
+ name = var + strlen("pretty.");
+ for (i = 0; i < builtin_formats_len; i++) {
+ if (!strcmp(commit_formats[i].name, name))
+ return 0;
+ }
+
+ for (i = builtin_formats_len; i < commit_formats_len; i++) {
+ if (!strcmp(commit_formats[i].name, name)) {
+ commit_format = &commit_formats[i];
+ break;
+ }
+ }
+
+ if (!commit_format) {
+ ALLOC_GROW(commit_formats, commit_formats_len+1,
+ commit_formats_alloc);
+ commit_format = &commit_formats[commit_formats_len];
+ memset(commit_format, 0, sizeof(*commit_format));
+ commit_formats_len++;
+ }
+
+ commit_format->name = xstrdup(name);
+ commit_format->format = CMIT_FMT_USERFORMAT;
+ git_config_string(&fmt, var, value);
+ if (!prefixcmp(fmt, "format:") || !prefixcmp(fmt, "tformat:")) {
+ commit_format->is_tformat = fmt[0] == 't';
+ fmt = strchr(fmt, ':') + 1;
+ } else if (strchr(fmt, '%'))
+ commit_format->is_tformat = 1;
+ else
+ commit_format->is_alias = 1;
+ commit_format->user_format = fmt;
+
+ return 0;
+}
+
+static void setup_commit_formats(void)
+{
+ struct cmt_fmt_map builtin_formats[] = {
+ { "raw", CMIT_FMT_RAW, 0 },
+ { "medium", CMIT_FMT_MEDIUM, 0 },
+ { "short", CMIT_FMT_SHORT, 0 },
+ { "email", CMIT_FMT_EMAIL, 0 },
+ { "fuller", CMIT_FMT_FULLER, 0 },
+ { "full", CMIT_FMT_FULL, 0 },
+ { "oneline", CMIT_FMT_ONELINE, 1 }
};
+ commit_formats_len = ARRAY_SIZE(builtin_formats);
+ builtin_formats_len = commit_formats_len;
+ ALLOC_GROW(commit_formats, commit_formats_len, commit_formats_alloc);
+ memcpy(commit_formats, builtin_formats,
+ sizeof(*builtin_formats)*ARRAY_SIZE(builtin_formats));
+
+ git_config(git_pretty_formats_config, NULL);
+}
+
+static struct cmt_fmt_map *find_commit_format_recursive(const char *sought,
+ const char *original,
+ int num_redirections)
+{
+ struct cmt_fmt_map *found = NULL;
+ size_t found_match_len = 0;
+ int i;
+
+ if (num_redirections >= commit_formats_len)
+ die("invalid --pretty format: "
+ "'%s' references an alias which points to itself",
+ original);
+
+ for (i = 0; i < commit_formats_len; i++) {
+ size_t match_len;
+
+ if (prefixcmp(commit_formats[i].name, sought))
+ continue;
+
+ match_len = strlen(commit_formats[i].name);
+ if (found == NULL || found_match_len > match_len) {
+ found = &commit_formats[i];
+ found_match_len = match_len;
+ }
+ }
+
+ if (found && found->is_alias) {
+ found = find_commit_format_recursive(found->user_format,
+ original,
+ num_redirections+1);
+ }
+
+ return found;
+}
+
+static struct cmt_fmt_map *find_commit_format(const char *sought)
+{
+ if (!commit_formats)
+ setup_commit_formats();
+
+ return find_commit_format_recursive(sought, sought, 0);
+}
+
+void get_commit_format(const char *arg, struct rev_info *rev)
+{
+ struct cmt_fmt_map *commit_format;
rev->use_terminator = 0;
if (!arg || !*arg) {
@@ -47,21 +154,22 @@ void get_commit_format(const char *arg, struct rev_info *rev)
save_user_format(rev, strchr(arg, ':') + 1, arg[0] == 't');
return;
}
- for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
- if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
- !strncmp(arg, cmt_fmts[i].n, strlen(arg))) {
- if (cmt_fmts[i].v == CMIT_FMT_ONELINE)
- rev->use_terminator = 1;
- rev->commit_format = cmt_fmts[i].v;
- return;
- }
- }
+
if (strchr(arg, '%')) {
save_user_format(rev, arg, 1);
return;
}
- die("invalid --pretty format: %s", arg);
+ commit_format = find_commit_format(arg);
+ if (!commit_format)
+ die("invalid --pretty format: %s", arg);
+
+ rev->commit_format = commit_format->format;
+ rev->use_terminator = commit_format->is_tformat;
+ if (commit_format->format == CMIT_FMT_USERFORMAT) {
+ save_user_format(rev, commit_format->user_format,
+ commit_format->is_tformat);
+ }
}
/*
@@ -716,7 +824,7 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
if (add_again(sb, &c->abbrev_commit_hash))
return 1;
strbuf_addstr(sb, find_unique_abbrev(commit->object.sha1,
- DEFAULT_ABBREV));
+ c->pretty_ctx->abbrev));
c->abbrev_commit_hash.len = sb->len - c->abbrev_commit_hash.off;
return 1;
case 'T': /* tree hash */
@@ -726,7 +834,7 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
if (add_again(sb, &c->abbrev_tree_hash))
return 1;
strbuf_addstr(sb, find_unique_abbrev(commit->tree->object.sha1,
- DEFAULT_ABBREV));
+ c->pretty_ctx->abbrev));
c->abbrev_tree_hash.len = sb->len - c->abbrev_tree_hash.off;
return 1;
case 'P': /* parent hashes */
@@ -743,7 +851,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
if (p != commit->parents)
strbuf_addch(sb, ' ');
strbuf_addstr(sb, find_unique_abbrev(
- p->item->object.sha1, DEFAULT_ABBREV));
+ p->item->object.sha1,
+ c->pretty_ctx->abbrev));
}
c->abbrev_parent_hashes.len = sb->len -
c->abbrev_parent_hashes.off;
diff --git a/remote.c b/remote.c
index c70181cdc..ea2323bac 100644
--- a/remote.c
+++ b/remote.c
@@ -443,6 +443,8 @@ static int handle_config(const char *key, const char *value, void *cb)
} else if (!strcmp(subkey, ".tagopt")) {
if (!strcmp(value, "--no-tags"))
remote->fetch_tags = -1;
+ else if (!strcmp(value, "--tags"))
+ remote->fetch_tags = 2;
} else if (!strcmp(subkey, ".proxy")) {
return git_config_string((const char **)&remote->http_proxy,
key, value);
@@ -476,7 +478,7 @@ static void read_config(void)
unsigned char sha1[20];
const char *head_ref;
int flag;
- if (default_remote_name) // did this already
+ if (default_remote_name) /* did this already */
return;
default_remote_name = xstrdup("origin");
current_branch = NULL;
diff --git a/run-command.c b/run-command.c
index eb5c57562..c7793f50f 100644
--- a/run-command.c
+++ b/run-command.c
@@ -383,6 +383,8 @@ fail_pipe:
close(cmd->out);
if (need_err)
close_pair(fderr);
+ else if (cmd->err)
+ close(cmd->err);
errno = failed_errno;
return -1;
}
diff --git a/setup.c b/setup.c
index 5716d90b5..7e0460205 100644
--- a/setup.c
+++ b/setup.c
@@ -323,6 +323,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
const char *gitdirenv;
const char *gitfile_dir;
int len, offset, ceil_offset, root_len;
+ int current_device = 0, one_filesystem = 1;
+ struct stat buf;
/*
* Let's assume that we are in a git repository.
@@ -390,6 +392,12 @@ const char *setup_git_directory_gently(int *nongit_ok)
* etc.
*/
offset = len = strlen(cwd);
+ one_filesystem = !git_env_bool("GIT_DISCOVERY_ACROSS_FILESYSTEM", 0);
+ if (one_filesystem) {
+ if (stat(".", &buf))
+ die_errno("failed to stat '.'");
+ current_device = buf.st_dev;
+ }
for (;;) {
gitfile_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
if (gitfile_dir) {
@@ -422,8 +430,27 @@ const char *setup_git_directory_gently(int *nongit_ok)
}
die("Not a git repository (or any of the parent directories): %s", DEFAULT_GIT_DIR_ENVIRONMENT);
}
- if (chdir(".."))
+ if (one_filesystem) {
+ if (stat("..", &buf)) {
+ cwd[offset] = '\0';
+ die_errno("failed to stat '%s/..'", cwd);
+ }
+ if (buf.st_dev != current_device) {
+ if (nongit_ok) {
+ if (chdir(cwd))
+ die_errno("Cannot come back to cwd");
+ *nongit_ok = 1;
+ return NULL;
+ }
+ cwd[offset] = '\0';
+ die("Not a git repository (or any parent up to mount parent %s)\n"
+ "Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).", cwd);
+ }
+ }
+ if (chdir("..")) {
+ cwd[offset] = '\0';
die_errno("Cannot change to '%s/..'", cwd);
+ }
}
inside_git_dir = 0;
@@ -519,6 +546,12 @@ int check_repository_format(void)
return check_repository_format_gently(NULL);
}
+/*
+ * Returns the "prefix", a path to the current working directory
+ * relative to the work tree root, or NULL, if the current working
+ * directory is not a strict subdirectory of the work tree root. The
+ * prefix always ends with a '/' character.
+ */
const char *setup_git_directory(void)
{
const char *retval = setup_git_directory_gently(NULL);
diff --git a/sha1_file.c b/sha1_file.c
index 28c056e07..e42ef96d4 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -102,20 +102,22 @@ static void fill_sha1_path(char *pathbuf, const unsigned char *sha1)
*/
char *sha1_file_name(const unsigned char *sha1)
{
- static char *name, *base;
+ static char buf[PATH_MAX];
+ const char *objdir;
+ int len;
- if (!base) {
- const char *sha1_file_directory = get_object_directory();
- int len = strlen(sha1_file_directory);
- base = xmalloc(len + 60);
- memcpy(base, sha1_file_directory, len);
- memset(base+len, 0, 60);
- base[len] = '/';
- base[len+3] = '/';
- name = base + len + 1;
- }
- fill_sha1_path(name, sha1);
- return base;
+ objdir = get_object_directory();
+ len = strlen(objdir);
+
+ /* '/' + sha1(2) + '/' + sha1(38) + '\0' */
+ if (len + 43 > PATH_MAX)
+ die("insanely long object directory %s", objdir);
+ memcpy(buf, objdir, len);
+ buf[len] = '/';
+ buf[len+3] = '/';
+ buf[len+42] = '\0';
+ fill_sha1_path(buf + len + 1, sha1);
+ return buf;
}
static char *sha1_get_pack_name(const unsigned char *sha1,
@@ -599,6 +601,14 @@ void unuse_pack(struct pack_window **w_cursor)
}
}
+void close_pack_index(struct packed_git *p)
+{
+ if (p->index_data) {
+ munmap((void *)p->index_data, p->index_size);
+ p->index_data = NULL;
+ }
+}
+
/*
* This is used by git-repack in case a newly created pack happens to
* contain the same set of objects as an existing one. In that case
@@ -620,8 +630,7 @@ void free_pack_by_name(const char *pack_name)
close_pack_windows(p);
if (p->pack_fd != -1)
close(p->pack_fd);
- if (p->index_data)
- munmap((void *)p->index_data, p->index_size);
+ close_pack_index(p);
free(p->bad_object_sha1);
*pp = p->next;
free(p);
@@ -831,9 +840,8 @@ struct packed_git *add_packed_git(const char *path, int path_len, int local)
return p;
}
-struct packed_git *parse_pack_index(unsigned char *sha1)
+struct packed_git *parse_pack_index(unsigned char *sha1, const char *idx_path)
{
- const char *idx_path = sha1_pack_index_name(sha1);
const char *path = sha1_pack_name(sha1);
struct packed_git *p = alloc_packed_git(strlen(path) + 1);
@@ -2448,6 +2456,8 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
else
ret = -1;
strbuf_release(&sbuf);
+ } else if (!size) {
+ ret = index_mem(sha1, NULL, size, write_object, type, path);
} else if (size <= SMALL_FILE_SIZE) {
char *buf = xmalloc(size);
if (size == read_in_full(fd, buf, size))
@@ -2456,12 +2466,11 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
else
ret = error("short read %s", strerror(errno));
free(buf);
- } else if (size) {
+ } else {
void *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
ret = index_mem(sha1, buf, size, write_object, type, path);
munmap(buf, size);
- } else
- ret = index_mem(sha1, NULL, size, write_object, type, path);
+ }
close(fd);
return ret;
}
diff --git a/shortlog.h b/shortlog.h
index bc02cc29e..de4f86fb9 100644
--- a/shortlog.h
+++ b/shortlog.h
@@ -12,6 +12,7 @@ struct shortlog {
int in1;
int in2;
int user_format;
+ int abbrev;
char *common_repo_prefix;
int email;
diff --git a/t/README b/t/README
index dcd3ebb5f..0e4e8d886 100644
--- a/t/README
+++ b/t/README
@@ -84,6 +84,12 @@ appropriately before running "make".
implied by other options like --valgrind and
GIT_TEST_INSTALLED.
+--root=<directory>::
+ Create "trash" directories used to store all temporary data during
+ testing under <directory>, instead of the t/ directory.
+ Using this option with a RAM-based filesystem (such as tmpfs)
+ can massively speed up the test suite.
+
You can also set the GIT_TEST_INSTALLED environment variable to
the bindir of an existing git installation to test that installation.
You still need to have built this git sandbox, from which various
diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh
index 5a734b1b7..b70b891b6 100644
--- a/t/gitweb-lib.sh
+++ b/t/gitweb-lib.sh
@@ -19,9 +19,9 @@ our \$site_name = '[localhost]';
our \$site_header = '';
our \$site_footer = '';
our \$home_text = 'indextext.html';
-our @stylesheets = ('file:///$TEST_DIRECTORY/../gitweb/gitweb.css');
-our \$logo = 'file:///$TEST_DIRECTORY/../gitweb/git-logo.png';
-our \$favicon = 'file:///$TEST_DIRECTORY/../gitweb/git-favicon.png';
+our @stylesheets = ('file:///$TEST_DIRECTORY/../gitweb/static/gitweb.css');
+our \$logo = 'file:///$TEST_DIRECTORY/../gitweb/static/git-logo.png';
+our \$favicon = 'file:///$TEST_DIRECTORY/../gitweb/static/git-favicon.png';
our \$projects_list = '';
our \$export_ok = '';
our \$strict_export = '';
diff --git a/t/t6000lib.sh b/t/lib-t6000.sh
index 985d517a1..985d517a1 100644
--- a/t/t6000lib.sh
+++ b/t/lib-t6000.sh
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index 6cb8d60ea..828e35baf 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -65,17 +65,21 @@ test_expect_success expanded_in_repo '
echo "\$Id:NoSpaceAtFront \$"
echo "\$Id:NoSpaceAtEitherEnd\$"
echo "\$Id: NoTerminatingSymbol"
+ echo "\$Id: Foreign Commit With Spaces \$"
+ echo "\$Id: NoTerminatingSymbolAtEOF"
} > expanded-keywords &&
{
echo "File with expanded keywords"
- echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
- echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
- echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
- echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
- echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
- echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
+ echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
+ echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
+ echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
+ echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
+ echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
+ echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
echo "\$Id: NoTerminatingSymbol"
+ echo "\$Id: Foreign Commit With Spaces \$"
+ echo "\$Id: NoTerminatingSymbolAtEOF"
} > expected-output &&
git add expanded-keywords &&
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index f11f98c3c..64f05080b 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -824,4 +824,12 @@ test_expect_success 'check split_cmdline return' "
test_must_fail git merge master
"
+test_expect_success 'git -c "key=value" support' '
+ test "z$(git -c name=value config name)" = zvalue &&
+ test "z$(git -c core.name=value config core.name)" = zvalue &&
+ test "z$(git -c CamelCase=value config camelcase)" = zvalue &&
+ test "z$(git -c flag config --bool flag)" = ztrue &&
+ test_must_fail git -c core.name=value config name
+'
+
test_done
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 49cae3ed5..759cf12e1 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -5,7 +5,9 @@ test_description='git fsck random collection of tests'
. ./test-lib.sh
test_expect_success setup '
+ git config i18n.commitencoding ISO-8859-1 &&
test_commit A fileA one &&
+ git config --unset i18n.commitencoding &&
git checkout HEAD^0 &&
test_commit B fileB two &&
git tag -d A B &&
@@ -28,6 +30,12 @@ test_expect_success 'loose objects borrowed from alternate are not missing' '
)
'
+test_expect_success 'valid objects appear valid' '
+ { git fsck 2>out; true; } &&
+ ! grep error out &&
+ ! grep fatal out
+'
+
# Corruption tests follow. Make sure to remove all traces of the
# specific corruption you test afterwards, lest a later test trip over
# it.
@@ -57,6 +65,34 @@ test_expect_success 'branch pointing to non-commit' '
git update-ref -d refs/heads/invalid
'
+new=nothing
+test_expect_success 'email without @ is okay' '
+ git cat-file commit HEAD >basis &&
+ sed "s/@/AT/" basis >okay &&
+ new=$(git hash-object -t commit -w --stdin <okay) &&
+ echo "$new" &&
+ git update-ref refs/heads/bogus "$new" &&
+ git fsck 2>out &&
+ cat out &&
+ ! grep "error in commit $new" out
+'
+git update-ref -d refs/heads/bogus
+rm -f ".git/objects/$new"
+
+new=nothing
+test_expect_success 'email with embedded > is not okay' '
+ git cat-file commit HEAD >basis &&
+ sed "s/@[a-z]/&>/" basis >bad-email &&
+ new=$(git hash-object -t commit -w --stdin <bad-email) &&
+ echo "$new" &&
+ git update-ref refs/heads/bogus "$new" &&
+ git fsck 2>out &&
+ cat out &&
+ grep "error in commit $new" out
+'
+git update-ref -d refs/heads/bogus
+rm -f ".git/objects/$new"
+
cat > invalid-tag <<EOF
object ffffffffffffffffffffffffffffffffffffffff
type commit
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
index 9df301211..bd8b60732 100755
--- a/t/t1501-worktree.sh
+++ b/t/t1501-worktree.sh
@@ -30,6 +30,7 @@ test_rev_parse() {
EMPTY_TREE=$(git write-tree)
mkdir -p work/sub/dir || exit 1
+mkdir -p work2 || exit 1
mv .git repo.git || exit 1
say "core.worktree = relative path"
@@ -54,7 +55,9 @@ GIT_DIR=$(pwd)/repo.git
GIT_CONFIG=$GIT_DIR/config
git config core.worktree "$(pwd)/work"
test_rev_parse 'outside' false false false
-cd work || exit 1
+cd work2
+test_rev_parse 'outside2' false false false
+cd ../work || exit 1
test_rev_parse 'inside' false false true ''
cd sub/dir || exit 1
test_rev_parse 'subdirectory' false false true sub/dir/
@@ -67,7 +70,9 @@ git config core.worktree non-existent
GIT_WORK_TREE=work
export GIT_WORK_TREE
test_rev_parse 'outside' false false false
-cd work || exit 1
+cd work2
+test_rev_parse 'outside' false false false
+cd ../work || exit 1
GIT_WORK_TREE=.
test_rev_parse 'inside' false false true ''
cd sub/dir || exit 1
@@ -76,6 +81,7 @@ test_rev_parse 'subdirectory' false false true sub/dir/
cd ../../.. || exit 1
mv work repo.git/work
+mv work2 repo.git/work2
say "GIT_WORK_TREE=absolute path, work tree below git dir"
GIT_DIR=$(pwd)/repo.git
@@ -86,6 +92,8 @@ cd repo.git || exit 1
test_rev_parse 'in repo.git' false true false
cd objects || exit 1
test_rev_parse 'in repo.git/objects' false true false
+cd ../work2 || exit 1
+test_rev_parse 'in repo.git/work2' false true false
cd ../work || exit 1
test_rev_parse 'in repo.git/work' false true true ''
cd sub/dir || exit 1
diff --git a/t/t2007-checkout-symlink.sh b/t/t2007-checkout-symlink.sh
index 20f33436d..27e2127af 100755
--- a/t/t2007-checkout-symlink.sh
+++ b/t/t2007-checkout-symlink.sh
@@ -44,8 +44,10 @@ test_expect_success 'switch from symlink to dir' '
'
-rm -fr frotz xyzzy nitfol &&
-git checkout -f master || exit
+test_expect_success 'Remove temporary directories & switch to master' '
+ rm -fr frotz xyzzy nitfol &&
+ git checkout -f master
+'
test_expect_success 'switch from dir to symlink' '
diff --git a/t/t2017-checkout-orphan.sh b/t/t2017-checkout-orphan.sh
new file mode 100755
index 000000000..a8297c61b
--- /dev/null
+++ b/t/t2017-checkout-orphan.sh
@@ -0,0 +1,90 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Erick Mattos
+#
+
+test_description='git checkout --orphan
+
+Main Tests for --orphan functionality.'
+
+. ./test-lib.sh
+
+TEST_FILE=foo
+
+test_expect_success 'Setup' '
+ echo "Initial" >"$TEST_FILE" &&
+ git add "$TEST_FILE" &&
+ git commit -m "First Commit"
+ test_tick &&
+ echo "State 1" >>"$TEST_FILE" &&
+ git add "$TEST_FILE" &&
+ test_tick &&
+ git commit -m "Second Commit"
+'
+
+test_expect_success '--orphan creates a new orphan branch from HEAD' '
+ git checkout --orphan alpha &&
+ test_must_fail git rev-parse --verify HEAD &&
+ test "refs/heads/alpha" = "$(git symbolic-ref HEAD)" &&
+ test_tick &&
+ git commit -m "Third Commit" &&
+ test_must_fail git rev-parse --verify HEAD^ &&
+ git diff-tree --quiet master alpha
+'
+
+test_expect_success '--orphan creates a new orphan branch from <start_point>' '
+ git checkout master &&
+ git checkout --orphan beta master^ &&
+ test_must_fail git rev-parse --verify HEAD &&
+ test "refs/heads/beta" = "$(git symbolic-ref HEAD)" &&
+ test_tick &&
+ git commit -m "Fourth Commit" &&
+ test_must_fail git rev-parse --verify HEAD^ &&
+ git diff-tree --quiet master^ beta
+'
+
+test_expect_success '--orphan must be rejected with -b' '
+ git checkout master &&
+ test_must_fail git checkout --orphan new -b newer &&
+ test refs/heads/master = "$(git symbolic-ref HEAD)"
+'
+
+test_expect_success '--orphan is rejected with an existing name' '
+ git checkout master &&
+ test_must_fail git checkout --orphan master &&
+ test refs/heads/master = "$(git symbolic-ref HEAD)"
+'
+
+test_expect_success '--orphan refuses to switch if a merge is needed' '
+ git checkout master &&
+ git reset --hard &&
+ echo local >>"$TEST_FILE" &&
+ cat "$TEST_FILE" >"$TEST_FILE.saved" &&
+ test_must_fail git checkout --orphan gamma master^ &&
+ test refs/heads/master = "$(git symbolic-ref HEAD)" &&
+ test_cmp "$TEST_FILE" "$TEST_FILE.saved" &&
+ git diff-index --quiet --cached HEAD &&
+ git reset --hard
+'
+
+test_expect_success '--orphan does not mix well with -t' '
+ git checkout master &&
+ test_must_fail git checkout -t master --orphan gamma &&
+ test refs/heads/master = "$(git symbolic-ref HEAD)"
+'
+
+test_expect_success '--orphan ignores branch.autosetupmerge' '
+ git checkout -f master &&
+ git config branch.autosetupmerge always &&
+ git checkout --orphan delta &&
+ test -z "$(git config branch.delta.merge)" &&
+ test refs/heads/delta = "$(git symbolic-ref HEAD)" &&
+ test_must_fail git rev-parse --verify HEAD^
+'
+
+test_expect_success '--orphan does not mix well with -l' '
+ git checkout -f master &&
+ test_must_fail git checkout -l --orphan gamma
+'
+
+test_done
diff --git a/t/t2106-update-index-assume-unchanged.sh b/t/t2106-update-index-assume-unchanged.sh
new file mode 100755
index 000000000..99d858c6b
--- /dev/null
+++ b/t/t2106-update-index-assume-unchanged.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+test_description='git update-index --assume-unchanged test.
+'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' \
+ ': >file &&
+ git add file &&
+ git commit -m initial &&
+ git branch other &&
+ echo upstream >file &&
+ git add file &&
+ git commit -m upstream'
+
+test_expect_success 'do not switch branches with dirty file' \
+ 'git reset --hard &&
+ git checkout other &&
+ echo dirt >file &&
+ git update-index --assume-unchanged file &&
+ test_must_fail git checkout master'
+
+test_done
diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh
index 9929f8202..d54154453 100755
--- a/t/t3030-merge-recursive.sh
+++ b/t/t3030-merge-recursive.sh
@@ -22,6 +22,7 @@ test_expect_success 'setup 1' '
git branch df-2 &&
git branch df-3 &&
git branch remove &&
+ git branch submod &&
echo hello >>a &&
cp a d/e &&
@@ -236,6 +237,17 @@ test_expect_success 'setup 6' '
test_cmp expected actual
'
+test_expect_success 'setup 7' '
+
+ git checkout submod &&
+ git rm d/e &&
+ test_tick &&
+ git commit -m "remove d/e" &&
+ git update-index --add --cacheinfo 160000 $c1 d &&
+ test_tick &&
+ git commit -m "make d/ a submodule"
+'
+
test_expect_success 'merge-recursive simple' '
rm -fr [abcd] &&
@@ -551,4 +563,21 @@ test_expect_success 'merge removes empty directories' '
test_must_fail test -d d
'
+test_expect_failure 'merge-recursive simple w/submodule' '
+
+ git checkout submod &&
+ git merge remove
+'
+
+test_expect_failure 'merge-recursive simple w/submodule result' '
+
+ git ls-files -s >actual &&
+ (
+ echo "100644 $o5 0 a"
+ echo "100644 $o0 0 c"
+ echo "160000 $c1 0 d"
+ ) >expected &&
+ test_cmp expected actual
+'
+
test_done
diff --git a/t/t3306-notes-prune.sh b/t/t3306-notes-prune.sh
index a0ed0353e..b4554041b 100755
--- a/t/t3306-notes-prune.sh
+++ b/t/t3306-notes-prune.sh
@@ -60,7 +60,7 @@ test_expect_success 'verify commits and notes' '
test_expect_success 'remove some commits' '
- git reset --hard HEAD~2 &&
+ git reset --hard HEAD~1 &&
git reflog expire --expire=now HEAD &&
git gc --prune=now
'
@@ -68,7 +68,7 @@ test_expect_success 'remove some commits' '
test_expect_success 'verify that commits are gone' '
! git cat-file -p 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
- ! git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 &&
+ git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 &&
git cat-file -p ab5f302035f2e7aaf04265f08b42034c23256e1f
'
@@ -79,6 +79,26 @@ test_expect_success 'verify that notes are still present' '
git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
'
+test_expect_success 'prune -n does not remove notes' '
+
+ git notes list > expect &&
+ git notes prune -n &&
+ git notes list > actual &&
+ test_cmp expect actual
+'
+
+cat > expect <<EOF
+5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29
+EOF
+
+test_expect_success 'prune -n lists prunable notes' '
+
+
+ git notes prune -n > actual &&
+ test_cmp expect actual
+'
+
+
test_expect_success 'prune notes' '
git notes prune
@@ -87,6 +107,30 @@ test_expect_success 'prune notes' '
test_expect_success 'verify that notes are gone' '
! git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
+ git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
+ git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
+'
+
+test_expect_success 'remove some commits' '
+
+ git reset --hard HEAD~1 &&
+ git reflog expire --expire=now HEAD &&
+ git gc --prune=now
+'
+
+cat > expect <<EOF
+08341ad9e94faa089d60fd3f523affb25c6da189
+EOF
+
+test_expect_success 'prune -v notes' '
+
+ git notes prune -v > actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'verify that notes are gone' '
+
+ ! git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
! git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
'
diff --git a/t/t3307-notes-man.sh b/t/t3307-notes-man.sh
new file mode 100755
index 000000000..3269f2eeb
--- /dev/null
+++ b/t/t3307-notes-man.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='Examples from the git-notes man page
+
+Make sure the manual is not full of lies.'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ test_commit A &&
+ test_commit B &&
+ test_commit C
+'
+
+test_expect_success 'example 1: notes to add an Acked-by line' '
+ cat <<-\EOF >expect &&
+ B
+
+ Notes:
+ Acked-by: A C Ker <acker@example.com>
+ EOF
+ git notes add -m "Acked-by: A C Ker <acker@example.com>" B &&
+ git show -s B^{commit} >log &&
+ tail -n 4 log >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'example 2: binary notes' '
+ cp "$TEST_DIRECTORY"/test4012.png .
+ git checkout B &&
+ blob=$(git hash-object -w test4012.png) &&
+ git notes --ref=logo add -C "$blob" &&
+ git notes --ref=logo copy B C &&
+ git notes --ref=logo show C >actual &&
+ test_cmp test4012.png actual
+'
+
+test_done
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 476e5ec03..8fe14ccc5 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -228,4 +228,154 @@ test_expect_success 'stash --invalid-option' '
test bar,bar2 = $(cat file),$(cat file2)
'
+test_expect_success 'stash an added file' '
+ git reset --hard &&
+ echo new >file3 &&
+ git add file3 &&
+ git stash save "added file" &&
+ ! test -r file3 &&
+ git stash apply &&
+ test new = "$(cat file3)"
+'
+
+test_expect_success 'stash rm then recreate' '
+ git reset --hard &&
+ git rm file &&
+ echo bar7 >file &&
+ git stash save "rm then recreate" &&
+ test bar = "$(cat file)" &&
+ git stash apply &&
+ test bar7 = "$(cat file)"
+'
+
+test_expect_success 'stash rm and ignore' '
+ git reset --hard &&
+ git rm file &&
+ echo file >.gitignore &&
+ git stash save "rm and ignore" &&
+ test bar = "$(cat file)" &&
+ test file = "$(cat .gitignore)"
+ git stash apply &&
+ ! test -r file &&
+ test file = "$(cat .gitignore)"
+'
+
+test_expect_success 'stash rm and ignore (stage .gitignore)' '
+ git reset --hard &&
+ git rm file &&
+ echo file >.gitignore &&
+ git add .gitignore &&
+ git stash save "rm and ignore (stage .gitignore)" &&
+ test bar = "$(cat file)" &&
+ ! test -r .gitignore
+ git stash apply &&
+ ! test -r file &&
+ test file = "$(cat .gitignore)"
+'
+
+test_expect_success SYMLINKS 'stash file to symlink' '
+ git reset --hard &&
+ rm file &&
+ ln -s file2 file &&
+ git stash save "file to symlink" &&
+ test -f file &&
+ test bar = "$(cat file)" &&
+ git stash apply &&
+ case "$(ls -l file)" in *" file -> file2") :;; *) false;; esac
+'
+
+test_expect_success SYMLINKS 'stash file to symlink (stage rm)' '
+ git reset --hard &&
+ git rm file &&
+ ln -s file2 file &&
+ git stash save "file to symlink (stage rm)" &&
+ test -f file &&
+ test bar = "$(cat file)" &&
+ git stash apply &&
+ case "$(ls -l file)" in *" file -> file2") :;; *) false;; esac
+'
+
+test_expect_success SYMLINKS 'stash file to symlink (full stage)' '
+ git reset --hard &&
+ rm file &&
+ ln -s file2 file &&
+ git add file &&
+ git stash save "file to symlink (full stage)" &&
+ test -f file &&
+ test bar = "$(cat file)" &&
+ git stash apply &&
+ case "$(ls -l file)" in *" file -> file2") :;; *) false;; esac
+'
+
+# This test creates a commit with a symlink used for the following tests
+
+test_expect_success SYMLINKS 'stash symlink to file' '
+ git reset --hard &&
+ ln -s file filelink &&
+ git add filelink &&
+ git commit -m "Add symlink" &&
+ rm filelink &&
+ cp file filelink &&
+ git stash save "symlink to file" &&
+ test -h filelink &&
+ case "$(ls -l filelink)" in *" filelink -> file") :;; *) false;; esac &&
+ git stash apply &&
+ ! test -h filelink &&
+ test bar = "$(cat file)"
+'
+
+test_expect_success SYMLINKS 'stash symlink to file (stage rm)' '
+ git reset --hard &&
+ git rm filelink &&
+ cp file filelink &&
+ git stash save "symlink to file (stage rm)" &&
+ test -h filelink &&
+ case "$(ls -l filelink)" in *" filelink -> file") :;; *) false;; esac &&
+ git stash apply &&
+ ! test -h filelink &&
+ test bar = "$(cat file)"
+'
+
+test_expect_success SYMLINKS 'stash symlink to file (full stage)' '
+ git reset --hard &&
+ rm filelink &&
+ cp file filelink &&
+ git add filelink &&
+ git stash save "symlink to file (full stage)" &&
+ test -h filelink &&
+ case "$(ls -l filelink)" in *" filelink -> file") :;; *) false;; esac &&
+ git stash apply &&
+ ! test -h filelink &&
+ test bar = "$(cat file)"
+'
+
+test_expect_failure 'stash directory to file' '
+ git reset --hard &&
+ mkdir dir &&
+ echo foo >dir/file &&
+ git add dir/file &&
+ git commit -m "Add file in dir" &&
+ rm -fr dir &&
+ echo bar >dir &&
+ git stash save "directory to file" &&
+ test -d dir &&
+ test foo = "$(cat dir/file)" &&
+ test_must_fail git stash apply &&
+ test bar = "$(cat dir)" &&
+ git reset --soft HEAD^
+'
+
+test_expect_failure 'stash file to directory' '
+ git reset --hard &&
+ rm file &&
+ mkdir file &&
+ echo foo >file/file &&
+ git stash save "file to directory" &&
+ test -f file &&
+ test bar = "$(cat file)" &&
+ git stash apply &&
+ test -f file/file &&
+ test foo = "$(cat file/file)"
+'
+
test_done
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 2e2e103b3..6f7548c3a 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -55,6 +55,93 @@ test_expect_success 'word diff with runs of whitespace' '
'
+test_expect_success '--word-diff=color' '
+
+ word_diff --word-diff=color
+
+'
+
+test_expect_success '--color --word-diff=color' '
+
+ word_diff --color --word-diff=color
+
+'
+
+sed 's/#.*$//' > expect <<EOF
+diff --git a/pre b/post
+index 330b04f..5ed8eff 100644
+--- a/pre
++++ b/post
+@@ -1,3 +1,7 @@
+-h(4)
++h(4),hh[44]
+~
+ # significant space
+~
+ a = b + c
+~
+~
++aa = a
+~
+~
++aeff = aeff * ( aaa )
+~
+EOF
+
+test_expect_success '--word-diff=porcelain' '
+
+ word_diff --word-diff=porcelain
+
+'
+
+cat > expect <<EOF
+diff --git a/pre b/post
+index 330b04f..5ed8eff 100644
+--- a/pre
++++ b/post
+@@ -1,3 +1,7 @@
+[-h(4)-]{+h(4),hh[44]+}
+
+a = b + c
+
+{+aa = a+}
+
+{+aeff = aeff * ( aaa )+}
+EOF
+
+test_expect_success '--word-diff=plain' '
+
+ word_diff --word-diff=plain
+
+'
+
+test_expect_success '--word-diff=plain --no-color' '
+
+ word_diff --word-diff=plain --no-color
+
+'
+
+cat > expect <<EOF
+<WHITE>diff --git a/pre b/post<RESET>
+<WHITE>index 330b04f..5ed8eff 100644<RESET>
+<WHITE>--- a/pre<RESET>
+<WHITE>+++ b/post<RESET>
+<CYAN>@@ -1,3 +1,7 @@<RESET>
+<RED>[-h(4)-]<RESET><GREEN>{+h(4),hh[44]+}<RESET>
+
+a = b + c<RESET>
+
+<GREEN>{+aa = a+}<RESET>
+
+<GREEN>{+aeff = aeff * ( aaa )+}<RESET>
+EOF
+
+test_expect_success '--word-diff=plain --color' '
+
+ word_diff --word-diff=plain --color
+
+'
+
cat > expect <<\EOF
<WHITE>diff --git a/pre b/post<RESET>
<WHITE>index 330b04f..5ed8eff 100644<RESET>
@@ -143,6 +230,25 @@ test_expect_success 'command-line overrides config' '
word_diff --color-words="[a-z]+"
'
+cat > expect <<\EOF
+<WHITE>diff --git a/pre b/post<RESET>
+<WHITE>index 330b04f..5ed8eff 100644<RESET>
+<WHITE>--- a/pre<RESET>
+<WHITE>+++ b/post<RESET>
+<CYAN>@@ -1,3 +1,7 @@<RESET>
+h(4),<GREEN>{+hh+}<RESET>[44]
+
+a = b + c<RESET>
+
+<GREEN>{+aa = a+}<RESET>
+
+<GREEN>{+aeff = aeff * ( aaa+}<RESET> )
+EOF
+
+test_expect_success 'command-line overrides config: --word-diff-regex' '
+ word_diff --color --word-diff-regex="[a-z]+"
+'
+
cp expect.non-whitespace-is-word expect
test_expect_success '.gitattributes override config' '
@@ -209,4 +315,20 @@ test_expect_success 'test when words are only removed at the end' '
'
+cat > expect <<\EOF
+diff --git a/pre b/post
+index 289cb9d..2d06f37 100644
+--- a/pre
++++ b/post
+@@ -1 +1 @@
+-(:
++(
+EOF
+
+test_expect_success '--word-diff=none' '
+
+ word_diff --word-diff=plain --word-diff=none
+
+'
+
test_done
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
index a01e55bf6..cdb70b4b3 100755
--- a/t/t4201-shortlog.sh
+++ b/t/t4201-shortlog.sh
@@ -8,30 +8,93 @@ test_description='git shortlog
. ./test-lib.sh
-echo 1 > a1
-git add a1
-tree=$(git write-tree)
-commit=$( (echo "Test"; echo) | git commit-tree $tree )
-git update-ref HEAD $commit
+test_expect_success 'setup' '
+ echo 1 >a1 &&
+ git add a1 &&
+ tree=$(git write-tree) &&
+ commit=$(printf "%s\n" "Test" "" | git commit-tree "$tree") &&
+ git update-ref HEAD "$commit" &&
+
+ echo 2 >a1 &&
+ git commit --quiet -m "This is a very, very long first line for the commit message to see if it is wrapped correctly" a1 &&
+
+ # test if the wrapping is still valid
+ # when replacing all is by treble clefs.
+ echo 3 >a1 &&
+ git commit --quiet -m "$(
+ echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" |
+ sed "s/i/1234/g" |
+ tr 1234 "\360\235\204\236")" a1 &&
+
+ # now fsck up the utf8
+ git config i18n.commitencoding non-utf-8 &&
+ echo 4 >a1 &&
+ git commit --quiet -m "$(
+ echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" |
+ sed "s/i/1234/g" |
+ tr 1234 "\370\235\204\236")" a1 &&
+
+ echo 5 >a1 &&
+ git commit --quiet -m "a 12 34 56 78" a1
+
+ echo 6 >a1 &&
+ git commit --quiet -m "Commit by someone else" \
+ --author="Someone else <not!me>" a1 &&
+
+ cat >expect.template <<-\EOF
+ A U Thor (5):
+ SUBJECT
+ SUBJECT
+ SUBJECT
+ SUBJECT
+ SUBJECT
+
+ Someone else (1):
+ SUBJECT
+
+ EOF
+'
-echo 2 > a1
-git commit --quiet -m "This is a very, very long first line for the commit message to see if it is wrapped correctly" a1
+fuzz() {
+ file=$1 &&
+ sed "
+ s/$_x40/OBJECT_NAME/g
+ s/$_x05/OBJID/g
+ s/^ \{6\}[CTa].*/ SUBJECT/g
+ s/^ \{8\}[^ ].*/ CONTINUATION/g
+ " <"$file" >"$file.fuzzy" &&
+ sed "/CONTINUATION/ d" <"$file.fuzzy"
+}
-# test if the wrapping is still valid when replacing all i's by treble clefs.
-echo 3 > a1
-git commit --quiet -m "$(echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" | sed "s/i/1234/g" | tr 1234 '\360\235\204\236')" a1
+test_expect_success 'default output format' '
+ git shortlog HEAD >log &&
+ fuzz log >log.predictable &&
+ test_cmp expect.template log.predictable
+'
-# now fsck up the utf8
-git config i18n.commitencoding non-utf-8
-echo 4 > a1
-git commit --quiet -m "$(echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" | sed "s/i/1234/g" | tr 1234 '\370\235\204\236')" a1
+test_expect_success 'pretty format' '
+ sed s/SUBJECT/OBJECT_NAME/ expect.template >expect &&
+ git shortlog --format="%H" HEAD >log &&
+ fuzz log >log.predictable &&
+ test_cmp expect log.predictable
+'
-echo 5 > a1
-git commit --quiet -m "a 12 34 56 78" a1
+test_expect_success '--abbrev' '
+ sed s/SUBJECT/OBJID/ expect.template >expect &&
+ git shortlog --format="%h" --abbrev=5 HEAD >log &&
+ fuzz log >log.predictable &&
+ test_cmp expect log.predictable
+'
-git shortlog -w HEAD > out
+test_expect_success 'output from user-defined format is re-wrapped' '
+ sed "s/SUBJECT/two lines/" expect.template >expect &&
+ git shortlog --format="two%nlines" HEAD >log &&
+ fuzz log >log.predictable &&
+ test_cmp expect log.predictable
+'
-cat > expect << EOF
+test_expect_success 'shortlog wrapping' '
+ cat >expect <<\EOF &&
A U Thor (5):
Test
This is a very, very long first line for the commit message to see if
@@ -43,14 +106,19 @@ A U Thor (5):
a 12 34
56 78
-EOF
-
-test_expect_success 'shortlog wrapping' 'test_cmp expect out'
+Someone else (1):
+ Commit by someone else
-git log HEAD > log
-GIT_DIR=non-existing git shortlog -w < log > out
+EOF
+ git shortlog -w HEAD >out &&
+ test_cmp expect out
+'
-test_expect_success 'shortlog from non-git directory' 'test_cmp expect out'
+test_expect_success 'shortlog from non-git directory' '
+ git log HEAD >log &&
+ GIT_DIR=non-existing git shortlog -w <log >out &&
+ test_cmp expect out
+'
iconvfromutf8toiso88591() {
printf "%s" "$*" | iconv -f UTF-8 -t ISO8859-1
diff --git a/t/t4204-patch-id.sh b/t/t4204-patch-id.sh
index 04f7bae85..68e265281 100755
--- a/t/t4204-patch-id.sh
+++ b/t/t4204-patch-id.sh
@@ -18,6 +18,11 @@ test_expect_success 'patch-id output is well-formed' '
grep "^[a-f0-9]\{40\} $(git rev-parse HEAD)$" output
'
+calc_patch_id () {
+ git patch-id |
+ sed "s# .*##" > patch-id_"$1"
+}
+
get_patch_id () {
git log -p -1 "$1" | git patch-id |
sed "s# .*##" > patch-id_"$1"
@@ -35,4 +40,27 @@ test_expect_success 'patch-id detects inequality' '
! test_cmp patch-id_master patch-id_notsame
'
+test_expect_success 'patch-id supports git-format-patch output' '
+ get_patch_id master &&
+ git checkout same &&
+ git format-patch -1 --stdout | calc_patch_id same &&
+ test_cmp patch-id_master patch-id_same &&
+ set `git format-patch -1 --stdout | git patch-id` &&
+ test "$2" = `git rev-parse HEAD`
+'
+
+test_expect_success 'whitespace is irrelevant in footer' '
+ get_patch_id master &&
+ git checkout same &&
+ git format-patch -1 --stdout | sed "s/ \$//" | calc_patch_id same &&
+ test_cmp patch-id_master patch-id_same
+'
+
+test_expect_success 'patch-id supports git-format-patch MIME output' '
+ get_patch_id master &&
+ git checkout same &&
+ git format-patch -1 --attach --stdout | calc_patch_id same &&
+ test_cmp patch-id_master patch-id_same
+'
+
test_done
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
new file mode 100755
index 000000000..cb9f2bdd2
--- /dev/null
+++ b/t/t4205-log-pretty-formats.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+#
+# Copyright (c) 2010, Will Palmer
+#
+
+test_description='Test pretty formats'
+. ./test-lib.sh
+
+test_expect_success 'set up basic repos' '
+ >foo &&
+ >bar &&
+ git add foo &&
+ test_tick &&
+ git commit -m initial &&
+ git add bar &&
+ test_tick &&
+ git commit -m "add bar"
+'
+
+test_expect_success 'alias builtin format' '
+ git log --pretty=oneline >expected &&
+ git config pretty.test-alias oneline &&
+ git log --pretty=test-alias >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'alias masking builtin format' '
+ git log --pretty=oneline >expected &&
+ git config pretty.oneline "%H" &&
+ git log --pretty=oneline >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'alias user-defined format' '
+ git log --pretty="format:%h" >expected &&
+ git config pretty.test-alias "format:%h" &&
+ git log --pretty=test-alias >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'alias user-defined tformat' '
+ git log --pretty="tformat:%h" >expected &&
+ git config pretty.test-alias "tformat:%h" &&
+ git log --pretty=test-alias >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'alias non-existant format' '
+ git config pretty.test-alias format-that-will-never-exist &&
+ test_must_fail git log --pretty=test-alias
+'
+
+test_expect_success 'alias of an alias' '
+ git log --pretty="tformat:%h" >expected &&
+ git config pretty.test-foo "tformat:%h" &&
+ git config pretty.test-bar test-foo &&
+ git log --pretty=test-bar >actual && test_cmp expected actual
+'
+
+test_expect_success 'alias masking an alias' '
+ git log --pretty=format:"Two %H" >expected &&
+ git config pretty.duplicate "format:One %H" &&
+ git config --add pretty.duplicate "format:Two %H" &&
+ git log --pretty=duplicate >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'alias loop' '
+ git config pretty.test-foo test-bar &&
+ git config pretty.test-bar test-foo &&
+ test_must_fail git log --pretty=test-foo
+'
+
+test_done
diff --git a/t/t4206-log-follow-harder-copies.sh b/t/t4206-log-follow-harder-copies.sh
new file mode 100755
index 000000000..ad29e65fc
--- /dev/null
+++ b/t/t4206-log-follow-harder-copies.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Bo Yang
+#
+
+test_description='Test --follow should always find copies hard in git log.
+
+'
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/diff-lib.sh
+
+echo >path0 'Line 1
+Line 2
+Line 3
+'
+
+test_expect_success \
+ 'add a file path0 and commit.' \
+ 'git add path0 &&
+ git commit -m "Add path0"'
+
+echo >path0 'New line 1
+New line 2
+New line 3
+'
+test_expect_success \
+ 'Change path0.' \
+ 'git add path0 &&
+ git commit -m "Change path0"'
+
+cat <path0 >path1
+test_expect_success \
+ 'copy path0 to path1.' \
+ 'git add path1 &&
+ git commit -m "Copy path1 from path0"'
+
+test_expect_success \
+ 'find the copy path0 -> path1 harder' \
+ 'git log --follow --name-status --pretty="format:%s" path1 > current'
+
+cat >expected <<\EOF
+Copy path1 from path0
+C100 path0 path1
+
+Change path0
+M path0
+
+Add path0
+A path0
+EOF
+
+test_expect_success \
+ 'validate the output.' \
+ 'compare_diff_patch current expected'
+
+test_done
diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh
new file mode 100755
index 000000000..169d3ea37
--- /dev/null
+++ b/t/t5150-request-pull.sh
@@ -0,0 +1,228 @@
+#!/bin/sh
+
+test_description='Test workflows involving pull request.'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+
+ git init --bare upstream.git &&
+ git init --bare downstream.git &&
+ git clone upstream.git upstream-private &&
+ git clone downstream.git local &&
+
+ trash_url="file://$TRASH_DIRECTORY" &&
+ downstream_url="$trash_url/downstream.git/" &&
+ upstream_url="$trash_url/upstream.git/" &&
+
+ (
+ cd upstream-private &&
+ cat <<-\EOT >mnemonic.txt &&
+ Thirtey days hath November,
+ Aprile, June, and September:
+ EOT
+ git add mnemonic.txt &&
+ test_tick &&
+ git commit -m "\"Thirty days\", a reminder of month lengths" &&
+ git tag -m "version 1" -a initial &&
+ git push --tags origin master
+ ) &&
+ (
+ cd local &&
+ git remote add upstream "$trash_url/upstream.git" &&
+ git fetch upstream &&
+ git pull upstream master &&
+ cat <<-\EOT >>mnemonic.txt &&
+ Of twyecescore-eightt is but eine,
+ And all the remnante be thrycescore-eine.
+ O’course Leap yare comes an’pynes,
+ Ev’rie foure yares, gote it ryghth.
+ An’twyecescore-eight is but twyecescore-nyne.
+ EOT
+ git add mnemonic.txt &&
+ test_tick &&
+ git commit -m "More detail" &&
+ git tag -m "version 2" -a full &&
+ git checkout -b simplify HEAD^ &&
+ mv mnemonic.txt mnemonic.standard &&
+ cat <<-\EOT >mnemonic.clarified &&
+ Thirty days has September,
+ All the rest I can’t remember.
+ EOT
+ git add -N mnemonic.standard mnemonic.clarified &&
+ git commit -a -m "Adapt to use modern, simpler English
+
+But keep the old version, too, in case some people prefer it." &&
+ git checkout master
+ )
+
+'
+
+test_expect_success 'setup: two scripts for reading pull requests' '
+
+ downstream_url_for_sed=$(
+ printf "%s\n" "$downstream_url" |
+ sed -e '\''s/\\/\\\\/g'\'' -e '\''s/[[/.*^$]/\\&/g'\''
+ ) &&
+
+ cat <<-\EOT >read-request.sed &&
+ #!/bin/sed -nf
+ / in the git repository at:$/! d
+ n
+ /^$/ n
+ s/^[ ]*\(.*\) \([^ ]*\)/please pull\
+ \1\
+ \2/p
+ q
+ EOT
+
+ cat <<-EOT >fuzz.sed
+ #!/bin/sed -nf
+ s/$_x40/OBJECT_NAME/g
+ s/A U Thor/AUTHOR/g
+ s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g
+ s/ [^ ].*/ SUBJECT/g
+ s/ [^ ].* (DATE)/ SUBJECT (DATE)/g
+ s/$downstream_url_for_sed/URL/g
+ s/for-upstream/BRANCH/g
+ s/mnemonic.txt/FILENAME/g
+ /^ FILENAME | *[0-9]* [-+]*\$/ b diffstat
+ /^AUTHOR ([0-9]*):\$/ b shortlog
+ p
+ b
+ : diffstat
+ n
+ / [0-9]* files changed/ {
+ a\\
+ DIFFSTAT
+ b
+ }
+ b diffstat
+ : shortlog
+ /^ [a-zA-Z]/ n
+ /^[a-zA-Z]* ([0-9]*):\$/ n
+ /^\$/ N
+ /^\n[a-zA-Z]* ([0-9]*):\$/! {
+ a\\
+ SHORTLOG
+ D
+ }
+ n
+ b shortlog
+ EOT
+
+'
+
+test_expect_success 'pull request when forgot to push' '
+
+ rm -fr downstream.git &&
+ git init --bare downstream.git &&
+ (
+ cd local &&
+ git checkout initial &&
+ git merge --ff-only master &&
+ test_must_fail git request-pull initial "$downstream_url" \
+ 2>../err
+ ) &&
+ grep "No branch of.*is at:\$" err &&
+ grep "Are you sure you pushed" err
+
+'
+
+test_expect_success 'pull request after push' '
+
+ rm -fr downstream.git &&
+ git init --bare downstream.git &&
+ (
+ cd local &&
+ git checkout initial &&
+ git merge --ff-only master &&
+ git push origin master:for-upstream &&
+ git request-pull initial origin >../request
+ ) &&
+ sed -nf read-request.sed <request >digest &&
+ cat digest &&
+ {
+ read task &&
+ read repository &&
+ read branch
+ } <digest &&
+ (
+ cd upstream-private &&
+ git checkout initial &&
+ git pull --ff-only "$repository" "$branch"
+ ) &&
+ test "$branch" = for-upstream &&
+ test_cmp local/mnemonic.txt upstream-private/mnemonic.txt
+
+'
+
+test_expect_success 'request names an appropriate branch' '
+
+ rm -fr downstream.git &&
+ git init --bare downstream.git &&
+ (
+ cd local &&
+ git checkout initial &&
+ git merge --ff-only master &&
+ git push --tags origin master simplify &&
+ git push origin master:for-upstream &&
+ git request-pull initial "$downstream_url" >../request
+ ) &&
+ sed -nf read-request.sed <request >digest &&
+ cat digest &&
+ {
+ read task &&
+ read repository &&
+ read branch
+ } <digest &&
+ {
+ test "$branch" = master ||
+ test "$branch" = for-upstream
+ }
+
+'
+
+test_expect_success 'pull request format' '
+
+ rm -fr downstream.git &&
+ git init --bare downstream.git &&
+ cat <<-\EOT >expect &&
+ The following changes since commit OBJECT_NAME:
+
+ SUBJECT (DATE)
+
+ are available in the git repository at:
+ URL BRANCH
+
+ SHORTLOG
+
+ DIFFSTAT
+ EOT
+ (
+ cd local &&
+ git checkout initial &&
+ git merge --ff-only master &&
+ git push origin master:for-upstream &&
+ git request-pull initial "$downstream_url" >../request
+ ) &&
+ <request sed -nf fuzz.sed >request.fuzzy &&
+ test_cmp expect request.fuzzy
+
+'
+
+test_expect_success 'request-pull ignores OPTIONS_KEEPDASHDASH poison' '
+
+ (
+ cd local &&
+ OPTIONS_KEEPDASHDASH=Yes &&
+ export OPTIONS_KEEPDASHDASH &&
+ git checkout initial &&
+ git merge --ff-only master &&
+ git push origin master:for-upstream &&
+ git request-pull -- initial "$downstream_url" >../request
+ )
+
+'
+
+test_done
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 230c0cd78..4c498b190 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -320,6 +320,69 @@ test_expect_success 'add alt && prune' '
git rev-parse --verify refs/remotes/origin/side2)
'
+cat >test/expect <<\EOF
+some-tag
+EOF
+
+test_expect_success 'add with reachable tags (default)' '
+ (cd one &&
+ >foobar &&
+ git add foobar &&
+ git commit -m "Foobar" &&
+ git tag -a -m "Foobar tag" foobar-tag &&
+ git reset --hard HEAD~1 &&
+ git tag -a -m "Some tag" some-tag) &&
+ (mkdir add-tags &&
+ cd add-tags &&
+ git init &&
+ git remote add -f origin ../one &&
+ git tag -l some-tag >../test/output &&
+ git tag -l foobar-tag >>../test/output &&
+ test_must_fail git config remote.origin.tagopt) &&
+ test_cmp test/expect test/output
+'
+
+cat >test/expect <<\EOF
+some-tag
+foobar-tag
+--tags
+EOF
+
+test_expect_success 'add --tags' '
+ (rm -rf add-tags &&
+ mkdir add-tags &&
+ cd add-tags &&
+ git init &&
+ git remote add -f --tags origin ../one &&
+ git tag -l some-tag >../test/output &&
+ git tag -l foobar-tag >>../test/output &&
+ git config remote.origin.tagopt >>../test/output) &&
+ test_cmp test/expect test/output
+'
+
+cat >test/expect <<\EOF
+--no-tags
+EOF
+
+test_expect_success 'add --no-tags' '
+ (rm -rf add-tags &&
+ mkdir add-no-tags &&
+ cd add-no-tags &&
+ git init &&
+ git remote add -f --no-tags origin ../one &&
+ git tag -l some-tag >../test/output &&
+ git tag -l foobar-tag >../test/output &&
+ git config remote.origin.tagopt >>../test/output) &&
+ (cd one &&
+ git tag -d some-tag foobar-tag) &&
+ test_cmp test/expect test/output
+'
+
+test_expect_success 'reject --no-no-tags' '
+ (cd add-no-tags &&
+ test_must_fail git remote add -f --no-no-tags neworigin ../one)
+'
+
cat > one/expect << EOF
apis/master
apis/side
@@ -534,6 +597,94 @@ test_expect_success 'show empty remote' '
)
'
+test_expect_success 'remote set-branches requires a remote' '
+ test_must_fail git remote set-branches &&
+ test_must_fail git remote set-branches --add
+'
+
+test_expect_success 'remote set-branches' '
+ echo "+refs/heads/*:refs/remotes/scratch/*" >expect.initial &&
+ sort <<-\EOF >expect.add &&
+ +refs/heads/*:refs/remotes/scratch/*
+ +refs/heads/other:refs/remotes/scratch/other
+ EOF
+ sort <<-\EOF >expect.replace &&
+ +refs/heads/maint:refs/remotes/scratch/maint
+ +refs/heads/master:refs/remotes/scratch/master
+ +refs/heads/next:refs/remotes/scratch/next
+ EOF
+ sort <<-\EOF >expect.add-two &&
+ +refs/heads/maint:refs/remotes/scratch/maint
+ +refs/heads/master:refs/remotes/scratch/master
+ +refs/heads/next:refs/remotes/scratch/next
+ +refs/heads/pu:refs/remotes/scratch/pu
+ +refs/heads/t/topic:refs/remotes/scratch/t/topic
+ EOF
+ sort <<-\EOF >expect.setup-ffonly &&
+ refs/heads/master:refs/remotes/scratch/master
+ +refs/heads/next:refs/remotes/scratch/next
+ EOF
+ sort <<-\EOF >expect.respect-ffonly &&
+ refs/heads/master:refs/remotes/scratch/master
+ +refs/heads/next:refs/remotes/scratch/next
+ +refs/heads/pu:refs/remotes/scratch/pu
+ EOF
+
+ git clone .git/ setbranches &&
+ (
+ cd setbranches &&
+ git remote rename origin scratch &&
+ git config --get-all remote.scratch.fetch >config-result &&
+ sort <config-result >../actual.initial &&
+
+ git remote set-branches scratch --add other &&
+ git config --get-all remote.scratch.fetch >config-result &&
+ sort <config-result >../actual.add &&
+
+ git remote set-branches scratch maint master next &&
+ git config --get-all remote.scratch.fetch >config-result &&
+ sort <config-result >../actual.replace &&
+
+ git remote set-branches --add scratch pu t/topic &&
+ git config --get-all remote.scratch.fetch >config-result &&
+ sort <config-result >../actual.add-two &&
+
+ git config --unset-all remote.scratch.fetch &&
+ git config remote.scratch.fetch \
+ refs/heads/master:refs/remotes/scratch/master &&
+ git config --add remote.scratch.fetch \
+ +refs/heads/next:refs/remotes/scratch/next &&
+ git config --get-all remote.scratch.fetch >config-result &&
+ sort <config-result >../actual.setup-ffonly &&
+
+ git remote set-branches --add scratch pu &&
+ git config --get-all remote.scratch.fetch >config-result &&
+ sort <config-result >../actual.respect-ffonly
+ ) &&
+ test_cmp expect.initial actual.initial &&
+ test_cmp expect.add actual.add &&
+ test_cmp expect.replace actual.replace &&
+ test_cmp expect.add-two actual.add-two &&
+ test_cmp expect.setup-ffonly actual.setup-ffonly &&
+ test_cmp expect.respect-ffonly actual.respect-ffonly
+'
+
+test_expect_success 'remote set-branches with --mirror' '
+ echo "+refs/*:refs/*" >expect.initial &&
+ echo "+refs/heads/master:refs/heads/master" >expect.replace &&
+ git clone --mirror .git/ setbranches-mirror &&
+ (
+ cd setbranches-mirror &&
+ git remote rename origin scratch &&
+ git config --get-all remote.scratch.fetch >../actual.initial &&
+
+ git remote set-branches scratch heads/master &&
+ git config --get-all remote.scratch.fetch >../actual.replace
+ ) &&
+ test_cmp expect.initial actual.initial &&
+ test_cmp expect.replace actual.replace
+'
+
test_expect_success 'new remote' '
git remote add someremote foo &&
echo foo >expect &&
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index 3cf1b3da4..d1912351d 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -57,12 +57,24 @@ test_expect_success 'dies when no remote specified and no default remotes found'
test_expect_success 'use "origin" when no remote specified' '
- git remote add origin "$(pwd)/.git" &&
- git ls-remote >actual &&
+ URL="$(pwd)/.git" &&
+ echo "From $URL" >exp_err &&
+
+ git remote add origin "$URL" &&
+ git ls-remote 2>actual_err >actual &&
+
+ test_cmp exp_err actual_err &&
test_cmp expected.all actual
'
+test_expect_success 'suppress "From <url>" with -q' '
+
+ git ls-remote -q 2>actual_err &&
+ test_must_fail test_cmp exp_err actual_err
+
+'
+
test_expect_success 'use branch.<name>.remote if possible' '
#
@@ -78,10 +90,14 @@ test_expect_success 'use branch.<name>.remote if possible' '
git show-ref | sed -e "s/ / /"
) >exp &&
- git remote add other other.git &&
+ URL="other.git" &&
+ echo "From $URL" >exp_err &&
+
+ git remote add other $URL &&
git config branch.master.remote other &&
- git ls-remote >actual &&
+ git ls-remote 2>actual_err >actual &&
+ test_cmp exp_err actual_err &&
test_cmp exp actual
'
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 2de98e656..b11da79c9 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -64,13 +64,13 @@ check_push_result () {
test_expect_success setup '
- : >path1 &&
+ >path1 &&
git add path1 &&
test_tick &&
git commit -a -m repo &&
the_first_commit=$(git show-ref -s --verify refs/heads/master) &&
- : >path2 &&
+ >path2 &&
git add path2 &&
test_tick &&
git commit -a -m second &&
@@ -483,8 +483,10 @@ git config --remove-section remote.there
test_expect_success 'push with dry-run' '
mk_test heads/master &&
- (cd testrepo &&
- old_commit=$(git show-ref -s --verify refs/heads/master)) &&
+ (
+ cd testrepo &&
+ old_commit=$(git show-ref -s --verify refs/heads/master)
+ ) &&
git push --dry-run testrepo &&
check_push_result $old_commit heads/master
'
@@ -493,10 +495,13 @@ test_expect_success 'push updates local refs' '
mk_test heads/master &&
mk_child child &&
- (cd child &&
+ (
+ cd child &&
git pull .. master &&
git push &&
- test $(git rev-parse master) = $(git rev-parse remotes/origin/master))
+ test $(git rev-parse master) = \
+ $(git rev-parse remotes/origin/master)
+ )
'
@@ -506,10 +511,13 @@ test_expect_success 'push updates up-to-date local refs' '
mk_child child1 &&
mk_child child2 &&
(cd child1 && git pull .. master && git push) &&
- (cd child2 &&
+ (
+ cd child2 &&
git pull ../child1 master &&
git push &&
- test $(git rev-parse master) = $(git rev-parse remotes/origin/master))
+ test $(git rev-parse master) = \
+ $(git rev-parse remotes/origin/master)
+ )
'
@@ -517,9 +525,11 @@ test_expect_success 'push preserves up-to-date packed refs' '
mk_test heads/master &&
mk_child child &&
- (cd child &&
+ (
+ cd child &&
git push &&
- ! test -f .git/refs/remotes/origin/master)
+ ! test -f .git/refs/remotes/origin/master
+ )
'
@@ -528,13 +538,15 @@ test_expect_success 'push does not update local refs on failure' '
mk_test heads/master &&
mk_child child &&
mkdir testrepo/.git/hooks &&
- echo exit 1 >testrepo/.git/hooks/pre-receive &&
+ echo "#!/no/frobnication/today" >testrepo/.git/hooks/pre-receive &&
chmod +x testrepo/.git/hooks/pre-receive &&
- (cd child &&
+ (
+ cd child &&
git pull .. master
test_must_fail git push &&
test $(git rev-parse master) != \
- $(git rev-parse remotes/origin/master))
+ $(git rev-parse remotes/origin/master)
+ )
'
@@ -575,34 +587,41 @@ test_expect_success 'push --delete refuses src:dest refspecs' '
test_expect_success 'warn on push to HEAD of non-bare repository' '
mk_test heads/master
- (cd testrepo &&
+ (
+ cd testrepo &&
git checkout master &&
- git config receive.denyCurrentBranch warn) &&
+ git config receive.denyCurrentBranch warn
+ ) &&
git push testrepo master 2>stderr &&
grep "warning: updating the current branch" stderr
'
test_expect_success 'deny push to HEAD of non-bare repository' '
mk_test heads/master
- (cd testrepo &&
+ (
+ cd testrepo &&
git checkout master &&
- git config receive.denyCurrentBranch true) &&
+ git config receive.denyCurrentBranch true
+ ) &&
test_must_fail git push testrepo master
'
test_expect_success 'allow push to HEAD of bare repository (bare)' '
mk_test heads/master
- (cd testrepo &&
+ (
+ cd testrepo &&
git checkout master &&
git config receive.denyCurrentBranch true &&
- git config core.bare true) &&
+ git config core.bare true
+ ) &&
git push testrepo master 2>stderr &&
! grep "warning: updating the current branch" stderr
'
test_expect_success 'allow push to HEAD of non-bare repository (config)' '
mk_test heads/master
- (cd testrepo &&
+ (
+ cd testrepo &&
git checkout master &&
git config receive.denyCurrentBranch false
) &&
@@ -615,7 +634,8 @@ test_expect_success 'fetch with branches' '
git branch second $the_first_commit &&
git checkout second &&
echo ".." > testrepo/.git/branches/branch1 &&
- (cd testrepo &&
+ (
+ cd testrepo &&
git fetch branch1 &&
r=$(git show-ref -s --verify refs/heads/branch1) &&
test "z$r" = "z$the_commit" &&
@@ -627,7 +647,8 @@ test_expect_success 'fetch with branches' '
test_expect_success 'fetch with branches containing #' '
mk_empty &&
echo "..#second" > testrepo/.git/branches/branch2 &&
- (cd testrepo &&
+ (
+ cd testrepo &&
git fetch branch2 &&
r=$(git show-ref -s --verify refs/heads/branch2) &&
test "z$r" = "z$the_first_commit" &&
@@ -641,7 +662,8 @@ test_expect_success 'push with branches' '
git checkout second &&
echo "testrepo" > .git/branches/branch1 &&
git push branch1 &&
- (cd testrepo &&
+ (
+ cd testrepo &&
r=$(git show-ref -s --verify refs/heads/master) &&
test "z$r" = "z$the_first_commit" &&
test 1 = $(git for-each-ref refs/heads | wc -l)
@@ -652,7 +674,8 @@ test_expect_success 'push with branches containing #' '
mk_empty &&
echo "testrepo#branch3" > .git/branches/branch2 &&
git push branch2 &&
- (cd testrepo &&
+ (
+ cd testrepo &&
r=$(git show-ref -s --verify refs/heads/branch3) &&
test "z$r" = "z$the_first_commit" &&
test 1 = $(git for-each-ref refs/heads | wc -l)
@@ -660,6 +683,55 @@ test_expect_success 'push with branches containing #' '
git checkout master
'
+test_expect_success 'push into aliased refs (consistent)' '
+ mk_test heads/master &&
+ mk_child child1 &&
+ mk_child child2 &&
+ (
+ cd child1 &&
+ git branch foo &&
+ git symbolic-ref refs/heads/bar refs/heads/foo
+ git config receive.denyCurrentBranch false
+ ) &&
+ (
+ cd child2 &&
+ >path2 &&
+ git add path2 &&
+ test_tick &&
+ git commit -a -m child2 &&
+ git branch foo &&
+ git branch bar &&
+ git push ../child1 foo bar
+ )
+'
+
+test_expect_success 'push into aliased refs (inconsistent)' '
+ mk_test heads/master &&
+ mk_child child1 &&
+ mk_child child2 &&
+ (
+ cd child1 &&
+ git branch foo &&
+ git symbolic-ref refs/heads/bar refs/heads/foo
+ git config receive.denyCurrentBranch false
+ ) &&
+ (
+ cd child2 &&
+ >path2 &&
+ git add path2 &&
+ test_tick &&
+ git commit -a -m child2 &&
+ git branch foo &&
+ >path3 &&
+ git add path3 &&
+ test_tick &&
+ git commit -a -m child2 &&
+ git branch bar &&
+ test_must_fail git push ../child1 foo bar 2>stderr &&
+ grep "refusing inconsistent update" stderr
+ )
+'
+
test_expect_success 'push --porcelain' '
mk_empty &&
echo >.git/foo "To testrepo" &&
diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh
index 8cfce969b..fc675b50a 100755
--- a/t/t5550-http-fetch.sh
+++ b/t/t5550-http-fetch.sh
@@ -55,12 +55,43 @@ test_expect_success 'http remote detects correct HEAD' '
test_expect_success 'fetch packed objects' '
cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
- cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
- git --bare repack &&
- git --bare prune-packed &&
+ (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
+ git --bare repack &&
+ git --bare prune-packed
+ ) &&
git clone $HTTPD_URL/dumb/repo_pack.git
'
+test_expect_success 'fetch notices corrupt pack' '
+ cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
+ (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
+ p=`ls objects/pack/pack-*.pack` &&
+ chmod u+w $p &&
+ printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
+ ) &&
+ mkdir repo_bad1.git &&
+ (cd repo_bad1.git &&
+ git --bare init &&
+ test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad1.git &&
+ test 0 = `ls objects/pack/pack-*.pack | wc -l`
+ )
+'
+
+test_expect_success 'fetch notices corrupt idx' '
+ cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
+ (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
+ p=`ls objects/pack/pack-*.idx` &&
+ chmod u+w $p &&
+ printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
+ ) &&
+ mkdir repo_bad2.git &&
+ (cd repo_bad2.git &&
+ git --bare init &&
+ test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad2.git &&
+ test 0 = `ls objects/pack | wc -l`
+ )
+'
+
test_expect_success 'did not use upload-pack service' '
grep '/git-upload-pack' <"$HTTPD_ROOT_PATH"/access.log >act
: >exp
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 678cee502..8abb71afc 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -176,4 +176,16 @@ test_expect_success 'clone respects global branch.autosetuprebase' '
)
'
+test_expect_success 'respect url-encoding of file://' '
+ git init x+y &&
+ test_must_fail git clone "file://$PWD/x+y" xy-url &&
+ git clone "file://$PWD/x%2By" xy-url
+'
+
+test_expect_success 'do not respect url-encoding of non-url path' '
+ git init x+y &&
+ test_must_fail git clone x%2By xy-regular &&
+ git clone x+y xy-regular
+'
+
test_done
diff --git a/t/t5704-bundle.sh b/t/t5704-bundle.sh
index a8f4419e6..ddc3dc52f 100755
--- a/t/t5704-bundle.sh
+++ b/t/t5704-bundle.sh
@@ -30,4 +30,20 @@ test_expect_success 'tags can be excluded by rev-list options' '
'
+test_expect_failure 'bundle --stdin' '
+
+ echo master | git bundle create stdin-bundle.bdl --stdin &&
+ git ls-remote stdin-bundle.bdl >output &&
+ grep master output
+
+'
+
+test_expect_failure 'bundle --stdin <rev-list options>' '
+
+ echo master | git bundle create hybrid-bundle.bdl --stdin tag &&
+ git ls-remote hybrid-bundle.bdl >output &&
+ grep master output
+
+'
+
test_done
diff --git a/t/t5705-clone-2gb.sh b/t/t5705-clone-2gb.sh
index adfaae8c5..8afbdd4de 100755
--- a/t/t5705-clone-2gb.sh
+++ b/t/t5705-clone-2gb.sh
@@ -12,7 +12,7 @@ test_expect_success 'setup' '
git config pack.compression 0 &&
git config pack.depth 0 &&
- blobsize=$((20*1024*1024)) &&
+ blobsize=$((100*1024*1024)) &&
blobcount=$((2*1024*1024*1024/$blobsize+1)) &&
i=1 &&
(while test $i -le $blobcount
@@ -36,9 +36,15 @@ test_expect_success 'setup' '
'
-test_expect_success 'clone' '
+test_expect_success 'clone - bare' '
- git clone --bare --no-hardlinks . clone
+ git clone --bare --no-hardlinks . clone-bare
+
+'
+
+test_expect_success 'clone - with worktree, file:// protocol' '
+
+ git clone file://. clone-wt
'
diff --git a/t/t5800-remote-helpers.sh b/t/t5800-remote-helpers.sh
new file mode 100755
index 000000000..75a0163c0
--- /dev/null
+++ b/t/t5800-remote-helpers.sh
@@ -0,0 +1,76 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Sverre Rabbelier
+#
+
+test_description='Test remote-helper import and export commands'
+
+. ./test-lib.sh
+
+if ! test_have_prereq PYTHON
+then
+ say 'skipping git remote-testgit tests: requires Python support'
+ test_done
+fi
+
+test_expect_success 'setup repository' '
+ git init --bare server/.git &&
+ git clone server public &&
+ (cd public &&
+ echo content >file &&
+ git add file &&
+ git commit -m one &&
+ git push origin master)
+'
+
+test_expect_success 'cloning from local repo' '
+ git clone "testgit::${PWD}/server" localclone &&
+ test_cmp public/file localclone/file
+'
+
+test_expect_success 'cloning from remote repo' '
+ git clone "testgit::file://${PWD}/server" clone &&
+ test_cmp public/file clone/file
+'
+
+test_expect_success 'create new commit on remote' '
+ (cd public &&
+ echo content >>file &&
+ git commit -a -m two &&
+ git push)
+'
+
+test_expect_success 'pulling from local repo' '
+ (cd localclone && git pull) &&
+ test_cmp public/file localclone/file
+'
+
+test_expect_success 'pulling from remote remote' '
+ (cd clone && git pull) &&
+ test_cmp public/file clone/file
+'
+
+test_expect_success 'pushing to local repo' '
+ (cd localclone &&
+ echo content >>file &&
+ git commit -a -m three &&
+ git push) &&
+ HEAD=$(git --git-dir=localclone/.git rev-parse --verify HEAD) &&
+ test $HEAD = $(git --git-dir=server/.git rev-parse --verify HEAD)
+'
+
+test_expect_success 'synch with changes from localclone' '
+ (cd clone &&
+ git pull)
+'
+
+test_expect_success 'pushing remote local repo' '
+ (cd clone &&
+ echo content >>file &&
+ git commit -a -m four &&
+ git push) &&
+ HEAD=$(git --git-dir=clone/.git rev-parse --verify HEAD) &&
+ test $HEAD = $(git --git-dir=server/.git rev-parse --verify HEAD)
+'
+
+test_done
diff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh
index b4e8fbaa5..fb07536a0 100755
--- a/t/t6002-rev-list-bisect.sh
+++ b/t/t6002-rev-list-bisect.sh
@@ -5,7 +5,7 @@
test_description='Tests git rev-list --bisect functionality'
. ./test-lib.sh
-. "$TEST_DIRECTORY"/t6000lib.sh # t6xxx specific functions
+. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions
# usage: test_bisection max-diff bisect-option head ^prune...
#
diff --git a/t/t6003-rev-list-topo-order.sh b/t/t6003-rev-list-topo-order.sh
index 2c73f2da7..e4c52b021 100755
--- a/t/t6003-rev-list-topo-order.sh
+++ b/t/t6003-rev-list-topo-order.sh
@@ -6,7 +6,7 @@
test_description='Tests git rev-list --topo-order functionality'
. ./test-lib.sh
-. "$TEST_DIRECTORY"/t6000lib.sh # t6xxx specific functions
+. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions
list_duplicates()
{
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 9992be69f..9b77073df 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -200,6 +200,31 @@ test_expect_success 'add LF before non-empty (2)' '
grep "^$" actual
'
+test_expect_success '--abbrev' '
+ echo SHORT SHORT SHORT >expect2 &&
+ echo LONG LONG LONG >expect3 &&
+ git log -1 --format="%h %h %h" HEAD >actual1 &&
+ git log -1 --abbrev=5 --format="%h %h %h" HEAD >actual2 &&
+ git log -1 --abbrev=5 --format="%H %H %H" HEAD >actual3 &&
+ sed -e "s/$_x40/LONG/g" -e "s/$_x05/SHORT/g" <actual2 >fuzzy2 &&
+ sed -e "s/$_x40/LONG/g" -e "s/$_x05/SHORT/g" <actual3 >fuzzy3 &&
+ test_cmp expect2 fuzzy2 &&
+ test_cmp expect3 fuzzy3 &&
+ ! test_cmp actual1 actual2
+'
+
+test_expect_success '%H is not affected by --abbrev-commit' '
+ git log -1 --format=%H --abbrev-commit --abbrev=20 HEAD >actual &&
+ len=$(wc -c <actual) &&
+ test $len = 41
+'
+
+test_expect_success '%h is not affected by --abbrev-commit' '
+ git log -1 --format=%h --abbrev-commit --abbrev=20 HEAD >actual &&
+ len=$(wc -c <actual) &&
+ test $len = 21
+'
+
test_expect_success '"%h %gD: %gs" is same as git-reflog' '
git reflog >expect &&
git log -g --format="%h %gD: %gs" >actual &&
@@ -212,6 +237,12 @@ test_expect_success '"%h %gD: %gs" is same as git-reflog (with date)' '
test_cmp expect actual
'
+test_expect_success '"%h %gD: %gs" is same as git-reflog (with --abbrev)' '
+ git reflog --abbrev=13 --date=raw >expect &&
+ git log -g --abbrev=13 --format="%h %gD: %gs" --date=raw >actual &&
+ test_cmp expect actual
+'
+
test_expect_success '%gd shortens ref name' '
echo "master@{0}" >expect.gd-short &&
git log -g -1 --format=%gd refs/heads/master >actual.gd-short &&
diff --git a/t/t6101-rev-parse-parents.sh b/t/t6101-rev-parse-parents.sh
index f105fab98..e673c25e9 100755
--- a/t/t6101-rev-parse-parents.sh
+++ b/t/t6101-rev-parse-parents.sh
@@ -6,7 +6,7 @@
test_description='Test git rev-parse with different parent options'
. ./test-lib.sh
-. "$TEST_DIRECTORY"/t6000lib.sh # t6xxx specific functions
+. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions
date >path0
git update-index --add path0
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index 065deadc2..876d1ab74 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -8,7 +8,7 @@ test_description='test describe
o----o----o----o----o----. /
\ A c /
.------------o---o---o
- D e
+ D,R e
'
. ./test-lib.sh
@@ -68,6 +68,8 @@ test_expect_success setup '
echo D >another && git add another && git commit -m D &&
test_tick &&
git tag -a -m D D &&
+ test_tick &&
+ git tag -a -m R R &&
test_tick &&
echo DD >another && git commit -a -m another &&
@@ -89,10 +91,10 @@ test_expect_success setup '
check_describe A-* HEAD
check_describe A-* HEAD^
-check_describe D-* HEAD^^
+check_describe R-* HEAD^^
check_describe A-* HEAD^^2
check_describe B HEAD^^2^
-check_describe D-* HEAD^^^
+check_describe R-* HEAD^^^
check_describe c-* --tags HEAD
check_describe c-* --tags HEAD^
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 8052c86ad..7dc8a510c 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -295,6 +295,15 @@ test_expect_success 'Check short upstream format' '
test_cmp expected actual
'
+cat >expected <<EOF
+67a36f1
+EOF
+
+test_expect_success 'Check short objectname format' '
+ git for-each-ref --format="%(objectname:short)" refs/heads >actual &&
+ test_cmp expected actual
+'
+
test_expect_success 'Check for invalid refname format' '
test_must_fail git for-each-ref --format="%(refname:INVALID)"
'
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index d9202d5af..3bc7a2a79 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -4,17 +4,24 @@ test_description='Test automatic use of a pager.'
. ./test-lib.sh
-rm -f stdout_is_tty
+cleanup_fail() {
+ echo >&2 cleanup failed
+ (exit 1)
+}
+
test_expect_success 'set up terminal for tests' '
+ rm -f stdout_is_tty ||
+ cleanup_fail &&
+
if test -t 1
then
- : > stdout_is_tty
+ >stdout_is_tty
elif
test_have_prereq PERL &&
"$PERL_PATH" "$TEST_DIRECTORY"/t7006/test-terminal.perl \
sh -c "test -t 1"
then
- : > test_terminal_works
+ >test_terminal_works
fi
'
@@ -32,53 +39,68 @@ else
say no usable terminal, so skipping some tests
fi
-unset GIT_PAGER GIT_PAGER_IN_USE
-git config --unset core.pager
-PAGER='cat > paginated.out'
-export PAGER
-
test_expect_success 'setup' '
+ unset GIT_PAGER GIT_PAGER_IN_USE &&
+ test_might_fail git config --unset core.pager &&
+
+ PAGER="cat >paginated.out" &&
+ export PAGER &&
+
test_commit initial
'
-rm -f paginated.out
test_expect_success TTY 'some commands use a pager' '
+ rm -f paginated.out ||
+ cleanup_fail &&
+
test_terminal git log &&
test -e paginated.out
'
-rm -f paginated.out
test_expect_success TTY 'some commands do not use a pager' '
+ rm -f paginated.out ||
+ cleanup_fail &&
+
test_terminal git rev-list HEAD &&
! test -e paginated.out
'
-rm -f paginated.out
test_expect_success 'no pager when stdout is a pipe' '
+ rm -f paginated.out ||
+ cleanup_fail &&
+
git log | cat &&
! test -e paginated.out
'
-rm -f paginated.out
test_expect_success 'no pager when stdout is a regular file' '
- git log > file &&
+ rm -f paginated.out ||
+ cleanup_fail &&
+
+ git log >file &&
! test -e paginated.out
'
-rm -f paginated.out
test_expect_success TTY 'git --paginate rev-list uses a pager' '
+ rm -f paginated.out ||
+ cleanup_fail &&
+
test_terminal git --paginate rev-list HEAD &&
test -e paginated.out
'
-rm -f file paginated.out
test_expect_success 'no pager even with --paginate when stdout is a pipe' '
+ rm -f file paginated.out ||
+ cleanup_fail &&
+
git --paginate log | cat &&
! test -e paginated.out
'
-rm -f paginated.out
test_expect_success TTY 'no pager with --no-pager' '
+ rm -f paginated.out ||
+ cleanup_fail &&
+
test_terminal git --no-pager log &&
! test -e paginated.out
'
@@ -86,88 +108,119 @@ test_expect_success TTY 'no pager with --no-pager' '
# A colored commit log will begin with an appropriate ANSI escape
# for the first color; the text "commit" comes later.
colorful() {
- read firstline < $1
+ read firstline <$1
! expr "$firstline" : "^[a-zA-Z]" >/dev/null
}
-rm -f colorful.log colorless.log
test_expect_success 'tests can detect color' '
- git log --no-color > colorless.log &&
- git log --color > colorful.log &&
+ rm -f colorful.log colorless.log ||
+ cleanup_fail &&
+
+ git log --no-color >colorless.log &&
+ git log --color >colorful.log &&
! colorful colorless.log &&
colorful colorful.log
'
-rm -f colorless.log
-git config color.ui auto
test_expect_success 'no color when stdout is a regular file' '
- git log > colorless.log &&
+ rm -f colorless.log &&
+ git config color.ui auto ||
+ cleanup_fail &&
+
+ git log >colorless.log &&
! colorful colorless.log
'
-rm -f paginated.out
-git config color.ui auto
test_expect_success TTY 'color when writing to a pager' '
- TERM=vt100 test_terminal git log &&
+ rm -f paginated.out &&
+ git config color.ui auto ||
+ cleanup_fail &&
+
+ (
+ TERM=vt100 &&
+ export TERM &&
+ test_terminal git log
+ ) &&
colorful paginated.out
'
-rm -f colorful.log
-git config color.ui auto
test_expect_success 'color when writing to a file intended for a pager' '
- TERM=vt100 GIT_PAGER_IN_USE=true git log > colorful.log &&
+ rm -f colorful.log &&
+ git config color.ui auto ||
+ cleanup_fail &&
+
+ (
+ TERM=vt100 &&
+ GIT_PAGER_IN_USE=true &&
+ export TERM GIT_PAGER_IN_USE &&
+ git log >colorful.log
+ ) &&
colorful colorful.log
'
-unset PAGER GIT_PAGER
-git config --unset core.pager
test_expect_success 'determine default pager' '
+ unset PAGER GIT_PAGER &&
+ test_might_fail git config --unset core.pager ||
+ cleanup_fail &&
+
less=$(git var GIT_PAGER) &&
test -n "$less"
'
-if expr "$less" : '^[a-z]*$' > /dev/null && test_have_prereq TTY
+if expr "$less" : '^[a-z][a-z]*$' >/dev/null && test_have_prereq TTY
then
test_set_prereq SIMPLEPAGER
fi
-unset PAGER GIT_PAGER
-git config --unset core.pager
-rm -f default_pager_used
test_expect_success SIMPLEPAGER 'default pager is used by default' '
- cat > $less <<-EOF &&
- #!$SHELL_PATH
- wc > default_pager_used
+ unset PAGER GIT_PAGER &&
+ test_might_fail git config --unset core.pager &&
+ rm -f default_pager_used ||
+ cleanup_fail &&
+
+ cat >$less <<-\EOF &&
+ #!/bin/sh
+ wc >default_pager_used
EOF
chmod +x $less &&
- PATH=.:$PATH test_terminal git log &&
+ (
+ PATH=.:$PATH &&
+ export PATH &&
+ test_terminal git log
+ ) &&
test -e default_pager_used
'
-unset GIT_PAGER
-git config --unset core.pager
-rm -f PAGER_used
test_expect_success TTY 'PAGER overrides default pager' '
- PAGER="wc > PAGER_used" &&
+ unset GIT_PAGER &&
+ test_might_fail git config --unset core.pager &&
+ rm -f PAGER_used ||
+ cleanup_fail &&
+
+ PAGER="wc >PAGER_used" &&
export PAGER &&
test_terminal git log &&
test -e PAGER_used
'
-unset GIT_PAGER
-rm -f core.pager_used
test_expect_success TTY 'core.pager overrides PAGER' '
+ unset GIT_PAGER &&
+ rm -f core.pager_used ||
+ cleanup_fail &&
+
PAGER=wc &&
export PAGER &&
- git config core.pager "wc > core.pager_used" &&
+ git config core.pager "wc >core.pager_used" &&
test_terminal git log &&
test -e core.pager_used
'
-rm -f GIT_PAGER_used
test_expect_success TTY 'GIT_PAGER overrides core.pager' '
+ rm -f GIT_PAGER_used ||
+ cleanup_fail &&
+
git config core.pager wc &&
- GIT_PAGER="wc > GIT_PAGER_used" &&
+ GIT_PAGER="wc >GIT_PAGER_used" &&
export GIT_PAGER &&
test_terminal git log &&
test -e GIT_PAGER_used
diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh
new file mode 100755
index 000000000..eb8ca88cc
--- /dev/null
+++ b/t/t7008-grep-binary.sh
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+test_description='git grep in binary files'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' "
+ printf 'binary\000file\n' >a &&
+ git add a &&
+ git commit -m.
+"
+
+test_expect_success 'git grep ina a' '
+ echo Binary file a matches >expect &&
+ git grep ina a >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git grep -ah ina a' '
+ git grep -ah ina a >actual &&
+ test_cmp a actual
+'
+
+test_expect_success 'git grep -I ina a' '
+ : >expect &&
+ test_must_fail git grep -I ina a >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git grep -c ina a' '
+ echo a:1 >expect &&
+ git grep -c ina a >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git grep -l ina a' '
+ echo a >expect &&
+ git grep -l ina a >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git grep -L bar a' '
+ echo a >expect &&
+ git grep -L bar a >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git grep -q ina a' '
+ : >expect &&
+ git grep -q ina a >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git grep -F ile a' '
+ git grep -F ile a
+'
+
+test_expect_success 'git grep -Fi iLE a' '
+ git grep -Fi iLE a
+'
+
+# This test actually passes on platforms where regexec() supports the
+# flag REG_STARTEND.
+test_expect_failure 'git grep ile a' '
+ git grep ile a
+'
+
+test_expect_failure 'git grep .fi a' '
+ git grep .fi a
+'
+
+test_expect_success 'git grep -F y<NUL>f a' "
+ printf 'y\000f' >f &&
+ git grep -f f -F a
+"
+
+test_expect_success 'git grep -F y<NUL>x a' "
+ printf 'y\000x' >f &&
+ test_must_fail git grep -f f -F a
+"
+
+test_expect_success 'git grep -Fi Y<NUL>f a' "
+ printf 'Y\000f' >f &&
+ git grep -f f -Fi a
+"
+
+test_expect_failure 'git grep -Fi Y<NUL>x a' "
+ printf 'Y\000x' >f &&
+ test_must_fail git grep -f f -Fi a
+"
+
+test_expect_success 'git grep y<NUL>f a' "
+ printf 'y\000f' >f &&
+ git grep -f f a
+"
+
+test_expect_failure 'git grep y<NUL>x a' "
+ printf 'y\000x' >f &&
+ test_must_fail git grep -f f a
+"
+
+test_done
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 1a4dc5f89..97ff074da 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -11,226 +11,292 @@ subcommands of git submodule.
. ./test-lib.sh
-#
-# Test setup:
-# -create a repository in directory init
-# -add a couple of files
-# -add directory init to 'superproject', this creates a DIRLINK entry
-# -add a couple of regular files to enable testing of submodule filtering
-# -mv init subrepo
-# -add an entry to .gitmodules for submodule 'example'
-#
-test_expect_success 'Prepare submodule testing' '
- : > t &&
+test_expect_success 'setup - initial commit' '
+ >t &&
git add t &&
git commit -m "initial commit" &&
- git branch initial HEAD &&
+ git branch initial
+'
+
+test_expect_success 'setup - repository in init subdirectory' '
mkdir init &&
- cd init &&
- git init &&
- echo a >a &&
- git add a &&
- git commit -m "submodule commit 1" &&
- git tag -a -m "rev-1" rev-1 &&
- rev1=$(git rev-parse HEAD) &&
- if test -z "$rev1"
- then
- echo "[OOPS] submodule git rev-parse returned nothing"
- false
- fi &&
- cd .. &&
+ (
+ cd init &&
+ git init &&
+ echo a >a &&
+ git add a &&
+ git commit -m "submodule commit 1" &&
+ git tag -a -m "rev-1" rev-1
+ )
+'
+
+test_expect_success 'setup - commit with gitlink' '
echo a >a &&
echo z >z &&
git add a init z &&
- git commit -m "super commit 1" &&
- mv init .subrepo &&
- GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
+ git commit -m "super commit 1"
+'
+
+test_expect_success 'setup - hide init subdirectory' '
+ mv init .subrepo
+'
+
+test_expect_success 'setup - repository to add submodules to' '
+ git init addtest
'
-test_expect_success 'Prepare submodule add testing' '
- submodurl=$(pwd)
+# The 'submodule add' tests need some repository to add as a submodule.
+# The trash directory is a good one as any.
+submodurl=$TRASH_DIRECTORY
+
+listbranches() {
+ git for-each-ref --format='%(refname)' 'refs/heads/*'
+}
+
+inspect() {
+ dir=$1 &&
+ dotdot="${2:-..}" &&
+
(
- mkdir addtest &&
- cd addtest &&
- git init
+ cd "$dir" &&
+ listbranches >"$dotdot/heads" &&
+ { git symbolic-ref HEAD || :; } >"$dotdot/head" &&
+ git rev-parse HEAD >"$dotdot/head-sha1" &&
+ git update-index --refresh &&
+ git diff-files --exit-code &&
+ git clean -n -d -x >"$dotdot/untracked"
)
-'
+}
test_expect_success 'submodule add' '
+ echo "refs/heads/master" >expect &&
+ >empty &&
+
(
cd addtest &&
git submodule add "$submodurl" submod &&
git submodule init
- )
+ ) &&
+
+ rm -f heads head untracked &&
+ inspect addtest/submod ../.. &&
+ test_cmp expect heads &&
+ test_cmp expect head &&
+ test_cmp empty untracked
'
test_expect_success 'submodule add --branch' '
+ echo "refs/heads/initial" >expect-head &&
+ cat <<-\EOF >expect-heads &&
+ refs/heads/initial
+ refs/heads/master
+ EOF
+ >empty &&
+
(
cd addtest &&
git submodule add -b initial "$submodurl" submod-branch &&
- git submodule init &&
- cd submod-branch &&
- git branch | grep initial
- )
+ git submodule init
+ ) &&
+
+ rm -f heads head untracked &&
+ inspect addtest/submod-branch ../.. &&
+ test_cmp expect-heads heads &&
+ test_cmp expect-head head &&
+ test_cmp empty untracked
'
test_expect_success 'submodule add with ./ in path' '
+ echo "refs/heads/master" >expect &&
+ >empty &&
+
(
cd addtest &&
git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
git submodule init
- )
+ ) &&
+
+ rm -f heads head untracked &&
+ inspect addtest/dotsubmod/frotz ../../.. &&
+ test_cmp expect heads &&
+ test_cmp expect head &&
+ test_cmp empty untracked
'
test_expect_success 'submodule add with // in path' '
+ echo "refs/heads/master" >expect &&
+ >empty &&
+
(
cd addtest &&
git submodule add "$submodurl" slashslashsubmod///frotz// &&
git submodule init
- )
+ ) &&
+
+ rm -f heads head untracked &&
+ inspect addtest/slashslashsubmod/frotz ../../.. &&
+ test_cmp expect heads &&
+ test_cmp expect head &&
+ test_cmp empty untracked
'
test_expect_success 'submodule add with /.. in path' '
+ echo "refs/heads/master" >expect &&
+ >empty &&
+
(
cd addtest &&
git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
git submodule init
- )
+ ) &&
+
+ rm -f heads head untracked &&
+ inspect addtest/realsubmod ../.. &&
+ test_cmp expect heads &&
+ test_cmp expect head &&
+ test_cmp empty untracked
'
test_expect_success 'submodule add with ./, /.. and // in path' '
+ echo "refs/heads/master" >expect &&
+ >empty &&
+
(
cd addtest &&
git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. &&
git submodule init
- )
+ ) &&
+
+ rm -f heads head untracked &&
+ inspect addtest/realsubmod2 ../.. &&
+ test_cmp expect heads &&
+ test_cmp expect head &&
+ test_cmp empty untracked
+'
+
+test_expect_success 'setup - add an example entry to .gitmodules' '
+ GIT_CONFIG=.gitmodules \
+ git config submodule.example.url git://example.com/init.git
'
test_expect_success 'status should fail for unmapped paths' '
- if git submodule status
- then
- echo "[OOPS] submodule status succeeded"
- false
- elif ! GIT_CONFIG=.gitmodules git config submodule.example.path init
- then
- echo "[OOPS] git config failed to update .gitmodules"
- false
- fi
+ test_must_fail git submodule status
+'
+
+test_expect_success 'setup - map path in .gitmodules' '
+ cat <<\EOF >expect &&
+[submodule "example"]
+ url = git://example.com/init.git
+ path = init
+EOF
+
+ GIT_CONFIG=.gitmodules git config submodule.example.path init &&
+
+ test_cmp expect .gitmodules
'
test_expect_success 'status should only print one line' '
- lines=$(git submodule status | wc -l) &&
- test $lines = 1
+ git submodule status >lines &&
+ test $(wc -l <lines) = 1
+'
+
+test_expect_success 'setup - fetch commit name from submodule' '
+ rev1=$(cd .subrepo && git rev-parse HEAD) &&
+ printf "rev1: %s\n" "$rev1" &&
+ test -n "$rev1"
'
test_expect_success 'status should initially be "missing"' '
- git submodule status | grep "^-$rev1"
+ git submodule status >lines &&
+ grep "^-$rev1" lines
'
test_expect_success 'init should register submodule url in .git/config' '
+ echo git://example.com/init.git >expect &&
+
git submodule init &&
- url=$(git config submodule.example.url) &&
- if test "$url" != "git://example.com/init.git"
- then
- echo "[OOPS] init succeeded but submodule url is wrong"
- false
- elif test_must_fail git config submodule.example.url ./.subrepo
- then
- echo "[OOPS] init succeeded but update of url failed"
- false
- fi
+ git config submodule.example.url >url &&
+ git config submodule.example.url ./.subrepo &&
+
+ test_cmp expect url
'
test_expect_success 'update should fail when path is used by a file' '
+ echo hello >expect &&
+
echo "hello" >init &&
- if git submodule update
- then
- echo "[OOPS] update should have failed"
- false
- elif test "$(cat init)" != "hello"
- then
- echo "[OOPS] update failed but init file was molested"
- false
- else
- rm init
- fi
+ test_must_fail git submodule update &&
+
+ test_cmp expect init
'
test_expect_success 'update should fail when path is used by a nonempty directory' '
+ echo hello >expect &&
+
+ rm -fr init &&
mkdir init &&
echo "hello" >init/a &&
- if git submodule update
- then
- echo "[OOPS] update should have failed"
- false
- elif test "$(cat init/a)" != "hello"
- then
- echo "[OOPS] update failed but init/a was molested"
- false
- else
- rm init/a
- fi
+
+ test_must_fail git submodule update &&
+
+ test_cmp expect init/a
'
test_expect_success 'update should work when path is an empty dir' '
- rm -rf init &&
+ rm -fr init &&
+ rm -f head-sha1 &&
+ echo "$rev1" >expect &&
+
mkdir init &&
git submodule update &&
- head=$(cd init && git rev-parse HEAD) &&
- if test -z "$head"
- then
- echo "[OOPS] Failed to obtain submodule head"
- false
- elif test "$head" != "$rev1"
- then
- echo "[OOPS] Submodule head is $head but should have been $rev1"
- false
- fi
+
+ inspect init &&
+ test_cmp expect head-sha1
'
test_expect_success 'status should be "up-to-date" after update' '
- git submodule status | grep "^ $rev1"
+ git submodule status >list &&
+ grep "^ $rev1" list
'
test_expect_success 'status should be "modified" after submodule commit' '
- cd init &&
- echo b >b &&
- git add b &&
- git commit -m "submodule commit 2" &&
- rev2=$(git rev-parse HEAD) &&
- cd .. &&
- if test -z "$rev2"
- then
- echo "[OOPS] submodule git rev-parse returned nothing"
- false
- fi &&
- git submodule status | grep "^+$rev2"
+ (
+ cd init &&
+ echo b >b &&
+ git add b &&
+ git commit -m "submodule commit 2"
+ ) &&
+
+ rev2=$(cd init && git rev-parse HEAD) &&
+ test -n "$rev2" &&
+ git submodule status >list &&
+
+ grep "^+$rev2" list
'
test_expect_success 'the --cached sha1 should be rev1' '
- git submodule --cached status | grep "^+$rev1"
+ git submodule --cached status >list &&
+ grep "^+$rev1" list
'
test_expect_success 'git diff should report the SHA1 of the new submodule commit' '
- git diff | grep "^+Subproject commit $rev2"
+ git diff >diff &&
+ grep "^+Subproject commit $rev2" diff
'
test_expect_success 'update should checkout rev1' '
+ rm -f head-sha1 &&
+ echo "$rev1" >expect &&
+
git submodule update init &&
- head=$(cd init && git rev-parse HEAD) &&
- if test -z "$head"
- then
- echo "[OOPS] submodule git rev-parse returned nothing"
- false
- elif test "$head" != "$rev1"
- then
- echo "[OOPS] init did not checkout correct head"
- false
- fi
+ inspect init &&
+
+ test_cmp expect head-sha1
'
test_expect_success 'status should be "up-to-date" after update' '
- git submodule status | grep "^ $rev1"
+ git submodule status >list &&
+ grep "^ $rev1" list
'
test_expect_success 'checkout superproject with subproject already present' '
@@ -239,6 +305,8 @@ test_expect_success 'checkout superproject with subproject already present' '
'
test_expect_success 'apply submodule diff' '
+ >empty &&
+
git branch second &&
(
cd init &&
@@ -251,21 +319,24 @@ test_expect_success 'apply submodule diff' '
git format-patch -1 --stdout >P.diff &&
git checkout second &&
git apply --index P.diff &&
- D=$(git diff --cached master) &&
- test -z "$D"
+
+ git diff --cached master >staged &&
+ test_cmp empty staged
'
test_expect_success 'update --init' '
-
mv init init2 &&
git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
- git config --remove-section submodule.example
+ git config --remove-section submodule.example &&
+ test_must_fail git config submodule.example.url &&
+
git submodule update init > update.out &&
+ cat update.out &&
grep "not initialized" update.out &&
- test ! -d init/.git &&
+ ! test -d init/.git &&
+
git submodule update --init init &&
test -d init/.git
-
'
test_expect_success 'do not add files from a submodule' '
diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
index 2a527750c..db9365b64 100755
--- a/t/t7407-submodule-foreach.sh
+++ b/t/t7407-submodule-foreach.sh
@@ -59,11 +59,13 @@ test_expect_success 'setup a submodule tree' '
sub1sha1=$(cd super/sub1 && git rev-parse HEAD)
sub3sha1=$(cd super/sub3 && git rev-parse HEAD)
+pwd=$(pwd)
+
cat > expect <<EOF
Entering 'sub1'
-foo1-sub1-$sub1sha1
+$pwd/clone-foo1-sub1-$sub1sha1
Entering 'sub3'
-foo3-sub3-$sub3sha1
+$pwd/clone-foo3-sub3-$sub3sha1
EOF
test_expect_success 'test basic "submodule foreach" usage' '
@@ -71,7 +73,9 @@ test_expect_success 'test basic "submodule foreach" usage' '
(
cd clone &&
git submodule update --init -- sub1 sub3 &&
- git submodule foreach "echo \$name-\$path-\$sha1" > ../actual
+ git submodule foreach "echo \$toplevel-\$name-\$path-\$sha1" > ../actual &&
+ git config foo.bar zar &&
+ git submodule foreach "git config --file \"\$toplevel/.git/config\" foo.bar"
) &&
test_cmp expect actual
'
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 844fb43c6..95044668e 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -35,7 +35,7 @@ test_expect_success 'partial' '
'
-test_expect_success 'partial modification in a subdirecotry' '
+test_expect_success 'partial modification in a subdirectory' '
test_tick &&
git commit -m "partial commit to subdirectory" not &&
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index a9df7ff7b..9e081073f 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -69,6 +69,34 @@ test_expect_success 'status (2)' '
'
cat >expect <<\EOF
+# On branch master
+# Changes to be committed:
+# new file: dir2/added
+#
+# Changed but not updated:
+# modified: dir1/modified
+#
+# Untracked files:
+# dir1/untracked
+# dir2/modified
+# dir2/untracked
+# expect
+# output
+# untracked
+EOF
+
+git config advice.statusHints false
+
+test_expect_success 'status (advice.statusHints false)' '
+
+ git status >output &&
+ test_cmp expect output
+
+'
+
+git config --unset advice.statusHints
+
+cat >expect <<\EOF
M dir1/modified
A dir2/added
?? dir1/untracked
@@ -79,13 +107,32 @@ A dir2/added
?? untracked
EOF
-test_expect_success 'status -s (2)' '
+test_expect_success 'status -s' '
git status -s >output &&
test_cmp expect output
'
+cat >expect <<\EOF
+## master
+ M dir1/modified
+A dir2/added
+?? dir1/untracked
+?? dir2/modified
+?? dir2/untracked
+?? expect
+?? output
+?? untracked
+EOF
+
+test_expect_success 'status -s -b' '
+
+ git status -s -b >output &&
+ test_cmp expect output
+
+'
+
cat >expect <<EOF
# On branch master
# Changes to be committed:
@@ -115,6 +162,23 @@ test_expect_success 'status (status.showUntrackedFiles no)' '
test_cmp expect output
'
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+# new file: dir2/added
+#
+# Changed but not updated:
+# modified: dir1/modified
+#
+# Untracked files not listed
+EOF
+git config advice.statusHints false
+test_expect_success 'status -uno (advice.statusHints false)' '
+ git status -uno >output &&
+ test_cmp expect output
+'
+git config --unset advice.statusHints
+
cat >expect << EOF
M dir1/modified
A dir2/added
@@ -392,6 +456,25 @@ test_expect_success 'status -s with color.status' '
'
cat >expect <<\EOF
+## <GREEN>master<RESET>
+ <RED>M<RESET> dir1/modified
+<GREEN>A<RESET> dir2/added
+<BLUE>??<RESET> dir1/untracked
+<BLUE>??<RESET> dir2/modified
+<BLUE>??<RESET> dir2/untracked
+<BLUE>??<RESET> expect
+<BLUE>??<RESET> output
+<BLUE>??<RESET> untracked
+EOF
+
+test_expect_success 'status -s -b with color.status' '
+
+ git status -s -b | test_decode_color >output &&
+ test_cmp expect output
+
+'
+
+cat >expect <<\EOF
M dir1/modified
A dir2/added
?? dir1/untracked
@@ -424,6 +507,13 @@ test_expect_success 'status --porcelain ignores color.status' '
git config --unset color.status
git config --unset color.ui
+test_expect_success 'status --porcelain ignores -b' '
+
+ git status --porcelain -b >output &&
+ test_cmp expect output
+
+'
+
cat >expect <<\EOF
# On branch master
# Changes to be committed:
diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh
index d52c060b0..3ea33db6c 100755
--- a/t/t7509-commit.sh
+++ b/t/t7509-commit.sh
@@ -83,6 +83,52 @@ test_expect_success '--amend option copies authorship' '
test_cmp expect actual
'
+sha1_file() {
+ echo "$*" | sed "s#..#.git/objects/&/#"
+}
+remove_object() {
+ rm -f $(sha1_file "$*")
+}
+no_reflog() {
+ cp .git/config .git/config.saved &&
+ echo "[core] logallrefupdates = false" >>.git/config &&
+ test_when_finished "mv -f .git/config.saved .git/config" &&
+
+ if test -e .git/logs
+ then
+ mv .git/logs . &&
+ test_when_finished "mv logs .git/"
+ fi
+}
+
+test_expect_success '--amend option with empty author' '
+ git cat-file commit Initial >tmp &&
+ sed "s/author [^<]* </author </" tmp >empty-author &&
+ no_reflog &&
+ sha=$(git hash-object -t commit -w empty-author) &&
+ test_when_finished "remove_object $sha" &&
+ git checkout $sha &&
+ test_when_finished "git checkout Initial" &&
+ echo "Empty author test" >>foo &&
+ test_tick &&
+ ! git commit -a -m "empty author" --amend 2>err &&
+ grep "empty ident" err
+'
+
+test_expect_success '--amend option with missing author' '
+ git cat-file commit Initial >tmp &&
+ sed "s/author [^<]* </author </" tmp >malformed &&
+ no_reflog &&
+ sha=$(git hash-object -t commit -w malformed) &&
+ test_when_finished "remove_object $sha" &&
+ git checkout $sha &&
+ test_when_finished "git checkout Initial" &&
+ echo "Missing author test" >>foo &&
+ test_tick &&
+ ! git commit -a -m "malformed author" --amend 2>err &&
+ grep "empty ident" err
+'
+
test_expect_success '--reset-author makes the commit ours even with --amend option' '
git checkout Initial &&
echo "Test 6" >>foo &&
diff --git a/t/t7604-merge-custom-message.sh b/t/t7604-merge-custom-message.sh
index 269cfdf26..9114785ef 100755
--- a/t/t7604-merge-custom-message.sh
+++ b/t/t7604-merge-custom-message.sh
@@ -6,6 +6,15 @@ Testing merge when using a custom message for the merge commit.'
. ./test-lib.sh
+create_merge_msgs() {
+ echo >exp.subject "custom message"
+
+ cp exp.subject exp.log &&
+ echo >>exp.log "" &&
+ echo >>exp.log "* commit 'c2':" &&
+ echo >>exp.log " c2"
+}
+
test_expect_success 'setup' '
echo c0 > c0.c &&
git add c0.c &&
@@ -19,16 +28,23 @@ test_expect_success 'setup' '
echo c2 > c2.c &&
git add c2.c &&
git commit -m c2 &&
- git tag c2
+ git tag c2 &&
+ create_merge_msgs
'
test_expect_success 'merge c2 with a custom message' '
git reset --hard c1 &&
- echo >expected "custom message" &&
- git merge -m "custom message" c2 &&
+ git merge -m "$(cat exp.subject)" c2 &&
+ git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
+ test_cmp exp.subject actual
+'
+
+test_expect_success 'merge --log appends to custom message' '
+ git reset --hard c1 &&
+ git merge --log -m "$(cat exp.subject)" c2 &&
git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
- test_cmp expected actual
+ test_cmp exp.log actual
'
test_done
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index f4aa05475..c2f66ff17 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -8,6 +8,7 @@ test_expect_success 'objects in packs marked .keep are not repacked' '
echo content1 > file1 &&
echo content2 > file2 &&
git add . &&
+ test_tick &&
git commit -m initial_commit &&
# Create two packs
# The first pack will contain all of the objects except one
@@ -40,6 +41,7 @@ test_expect_success 'loose objects in alternate ODB are not repacked' '
echo content3 > file3 &&
objsha1=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) &&
git add file3 &&
+ test_tick &&
git commit -m commit_file3 &&
git repack -a -d -l &&
git prune-packed &&
@@ -73,6 +75,7 @@ test_expect_success 'packed obs in alt ODB are repacked when local repo has pack
rm -f .git/objects/pack/* &&
echo new_content >> file1 &&
git add file1 &&
+ test_tick &&
git commit -m more_content &&
git repack &&
git repack -a -d &&
@@ -118,8 +121,8 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' '
mv .git/objects/pack/* alt_objects/pack/ &&
csha1=$(git rev-parse HEAD^{commit}) &&
git reset --hard HEAD^ &&
- sleep 1 &&
- git reflog expire --expire=now --expire-unreachable=now --all &&
+ test_tick &&
+ git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all &&
# The pack-objects call on the next line is equivalent to
# git repack -A -d without the call to prune-packed
git pack-objects --honor-pack-keep --non-empty --all --reflog \
@@ -156,7 +159,7 @@ test_expect_success 'objects made unreachable by grafts only are kept' '
H1=$(git rev-parse HEAD^) &&
H2=$(git rev-parse HEAD^^) &&
echo "$H0 $H2" > .git/info/grafts &&
- git reflog expire --expire=now --expire-unreachable=now --all &&
+ git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all &&
git repack -a -d &&
git cat-file -t $H1
'
diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh
index 5babdf26e..200ab6127 100755
--- a/t/t7701-repack-unpack-unreachable.sh
+++ b/t/t7701-repack-unpack-unreachable.sh
@@ -11,17 +11,20 @@ tsha1=
test_expect_success '-A with -d option leaves unreachable objects unpacked' '
echo content > file1 &&
git add . &&
+ test_tick &&
git commit -m initial_commit &&
# create a transient branch with unique content
git checkout -b transient_branch &&
echo more content >> file1 &&
# record the objects created in the database for file, commit, tree
fsha1=$(git hash-object file1) &&
+ test_tick &&
git commit -a -m more_content &&
csha1=$(git rev-parse HEAD^{commit}) &&
tsha1=$(git rev-parse HEAD^{tree}) &&
git checkout master &&
echo even more content >> file1 &&
+ test_tick &&
git commit -a -m even_more_content &&
# delete the transient branch
git branch -D transient_branch &&
@@ -34,9 +37,11 @@ test_expect_success '-A with -d option leaves unreachable objects unpacked' '
git show $fsha1 &&
git show $csha1 &&
git show $tsha1 &&
- # now expire the reflog
- sleep 1 &&
- git reflog expire --expire-unreachable=now --all &&
+ # now expire the reflog, while keeping reachable ones but expiring
+ # unreachables immediately
+ test_tick &&
+ sometimeago=$(( $test_tick - 10000 )) &&
+ git reflog expire --expire=$sometimeago --expire-unreachable=$test_tick --all &&
# and repack
git repack -A -d -l &&
# verify objects are retained unpacked
@@ -71,7 +76,7 @@ test_expect_success '-A without -d option leaves unreachable objects packed' '
test 1 = $(ls -1 .git/objects/pack/pack-*.pack | wc -l) &&
packfile=$(ls .git/objects/pack/pack-*.pack) &&
git branch -D transient_branch &&
- sleep 1 &&
+ test_tick &&
git repack -A -l &&
test ! -f "$fsha1path" &&
test ! -f "$csha1path" &&
diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index daef2d6c2..437e9b811 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -48,7 +48,9 @@ test_expect_success 'setup' '
git pull secondroot master &&
git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
- GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log"
+ GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" &&
+ GIT_DIR="$SERVERDIR" git config gitcvs.authdb "$SERVERDIR/auth.db" &&
+ echo cvsuser:cvGVEarMLnhlA > "$SERVERDIR/auth.db"
'
# note that cvs doesn't accept absolute pathnames
@@ -94,6 +96,14 @@ git
END VERIFICATION REQUEST
EOF
+cat >login-git-ok <<EOF
+BEGIN VERIFICATION REQUEST
+$SERVERDIR
+cvsuser
+Ah<Z:yZZ30 e
+END VERIFICATION REQUEST
+EOF
+
test_expect_success 'pserver authentication' \
'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
sed -ne \$p log | grep "^I LOVE YOU\$"'
@@ -107,6 +117,10 @@ test_expect_success 'pserver authentication failure (non-anonymous user)' \
fi &&
sed -ne \$p log | grep "^I HATE YOU\$"'
+test_expect_success 'pserver authentication success (non-anonymous user with password)' \
+ 'cat login-git-ok | git-cvsserver pserver >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU\$"'
+
test_expect_success 'pserver authentication (login)' \
'cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
sed -ne \$p log | grep "^I LOVE YOU\$"'
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index 63b6b060e..4f2b9b062 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -647,4 +647,33 @@ test_expect_success \
gitweb_run "p=.git;a=summary"'
test_debug 'cat gitweb.log'
+# ----------------------------------------------------------------------
+# syntax highlighting
+
+cat >>gitweb_config.perl <<\EOF
+$feature{'highlight'}{'override'} = 1;
+EOF
+
+highlight --version >/dev/null 2>&1
+if [ $? -eq 127 ]; then
+ say "Skipping syntax highlighting test, because 'highlight' was not found"
+else
+ test_set_prereq HIGHLIGHT
+fi
+
+test_expect_success HIGHLIGHT \
+ 'syntax highlighting (no highlight)' \
+ 'git config gitweb.highlight yes &&
+ gitweb_run "p=.git;a=blob;f=file"'
+test_debug 'cat gitweb.log'
+
+test_expect_success HIGHLIGHT \
+ 'syntax highlighting (highlighted)' \
+ 'git config gitweb.highlight yes &&
+ echo "#!/usr/bin/sh" > test.sh &&
+ git add test.sh &&
+ git commit -m "Add test.sh" &&
+ gitweb_run "p=.git;a=blob;f=test.sh"'
+test_debug 'cat gitweb.log'
+
test_done
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 7422bba47..454880ac7 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -473,6 +473,9 @@ test_external () {
# Announce the script to reduce confusion about the
# test output that follows.
say_color "" " run $test_count: $descr ($*)"
+ # Export TEST_DIRECTORY, TRASH_DIRECTORY and GIT_TEST_LONG
+ # to be able to use them in script
+ export TEST_DIRECTORY TRASH_DIRECTORY GIT_TEST_LONG
# Run command; redirect its stderr to &4 as in
# test_run_, but keep its stdout on our stdout even in
# non-verbose mode.
@@ -530,6 +533,22 @@ test_must_fail () {
test $? -gt 0 -a $? -le 129 -o $? -gt 192
}
+# Similar to test_must_fail, but tolerates success, too. This is
+# meant to be used in contexts like:
+#
+# test_expect_success 'some command works without configuration' '
+# test_might_fail git config --unset all.configuration &&
+# do something
+# '
+#
+# Writing "git config --unset all.configuration || :" would be wrong,
+# because we want to notice if it fails due to segv.
+
+test_might_fail () {
+ "$@"
+ test $? -ge 0 -a $? -le 129 -o $? -gt 192
+}
+
# test_cmp is a helper function to compare actual and expected output.
# You can use it like:
#
diff --git a/tag.c b/tag.c
index 4470d2bf7..85607c219 100644
--- a/tag.c
+++ b/tag.c
@@ -36,43 +36,50 @@ struct tag *lookup_tag(const unsigned char *sha1)
return (struct tag *) obj;
}
+static unsigned long parse_tag_date(const char *buf, const char *tail)
+{
+ const char *dateptr;
+
+ while (buf < tail && *buf++ != '>')
+ /* nada */;
+ if (buf >= tail)
+ return 0;
+ dateptr = buf;
+ while (buf < tail && *buf++ != '\n')
+ /* nada */;
+ if (buf >= tail)
+ return 0;
+ /* dateptr < buf && buf[-1] == '\n', so strtoul will stop at buf-1 */
+ return strtoul(dateptr, NULL, 10);
+}
+
int parse_tag_buffer(struct tag *item, void *data, unsigned long size)
{
- int typelen, taglen;
unsigned char sha1[20];
- const char *type_line, *tag_line, *sig_line;
char type[20];
- const char *start = data;
+ const char *bufptr = data;
+ const char *tail = bufptr + size;
+ const char *nl;
- if (item->object.parsed)
- return 0;
- item->object.parsed = 1;
+ if (item->object.parsed)
+ return 0;
+ item->object.parsed = 1;
if (size < 64)
return -1;
- if (memcmp("object ", data, 7) || get_sha1_hex((char *) data + 7, sha1))
+ if (memcmp("object ", bufptr, 7) || get_sha1_hex(bufptr + 7, sha1) || bufptr[47] != '\n')
return -1;
+ bufptr += 48; /* "object " + sha1 + "\n" */
- type_line = (char *) data + 48;
- if (memcmp("\ntype ", type_line-1, 6))
+ if (prefixcmp(bufptr, "type "))
return -1;
-
- tag_line = memchr(type_line, '\n', size - (type_line - start));
- if (!tag_line || memcmp("tag ", ++tag_line, 4))
+ bufptr += 5;
+ nl = memchr(bufptr, '\n', tail - bufptr);
+ if (!nl || sizeof(type) <= (nl - bufptr))
return -1;
-
- sig_line = memchr(tag_line, '\n', size - (tag_line - start));
- if (!sig_line)
- return -1;
- sig_line++;
-
- typelen = tag_line - type_line - strlen("type \n");
- if (typelen >= 20)
- return -1;
- memcpy(type, type_line + 5, typelen);
- type[typelen] = '\0';
- taglen = sig_line - tag_line - strlen("tag \n");
- item->tag = xmemdupz(tag_line + 4, taglen);
+ strncpy(type, bufptr, nl - bufptr);
+ type[nl - bufptr] = '\0';
+ bufptr = nl + 1;
if (!strcmp(type, blob_type)) {
item->tagged = &lookup_blob(sha1)->object;
@@ -87,6 +94,20 @@ int parse_tag_buffer(struct tag *item, void *data, unsigned long size)
item->tagged = NULL;
}
+ if (prefixcmp(bufptr, "tag "))
+ return -1;
+ bufptr += 4;
+ nl = memchr(bufptr, '\n', tail - bufptr);
+ if (!nl)
+ return -1;
+ item->tag = xmemdupz(bufptr, nl - bufptr);
+ bufptr = nl + 1;
+
+ if (!prefixcmp(bufptr, "tagger "))
+ item->date = parse_tag_date(bufptr, tail);
+ else
+ item->date = 0;
+
return 0;
}
diff --git a/tag.h b/tag.h
index 7a0cb0070..47662724a 100644
--- a/tag.h
+++ b/tag.h
@@ -9,7 +9,7 @@ struct tag {
struct object object;
struct object *tagged;
char *tag;
- char *signature; /* not actually implemented */
+ unsigned long date;
};
extern struct tag *lookup_tag(const unsigned char *sha1);
diff --git a/thread-utils.c b/thread-utils.c
index 4f9c829c2..589f838f8 100644
--- a/thread-utils.c
+++ b/thread-utils.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include <pthread.h>
#if defined(hpux) || defined(__hpux) || defined(_hpux)
# include <sys/pstat.h>
@@ -43,3 +44,18 @@ int online_cpus(void)
return 1;
}
+
+int init_recursive_mutex(pthread_mutex_t *m)
+{
+ pthread_mutexattr_t a;
+ int ret;
+
+ ret = pthread_mutexattr_init(&a);
+ if (!ret) {
+ ret = pthread_mutexattr_settype(&a, PTHREAD_MUTEX_RECURSIVE);
+ if (!ret)
+ ret = pthread_mutex_init(m, &a);
+ pthread_mutexattr_destroy(&a);
+ }
+ return ret;
+}
diff --git a/thread-utils.h b/thread-utils.h
index cce4b77bd..1727a0333 100644
--- a/thread-utils.h
+++ b/thread-utils.h
@@ -2,5 +2,6 @@
#define THREAD_COMPAT_H
extern int online_cpus(void);
+extern int init_recursive_mutex(pthread_mutex_t*);
#endif /* THREAD_COMPAT_H */
diff --git a/trace.c b/trace.c
index 4229ae123..1e560cb0b 100644
--- a/trace.c
+++ b/trace.c
@@ -25,6 +25,10 @@
#include "cache.h"
#include "quote.h"
+void do_nothing(size_t unused)
+{
+}
+
/* Get a trace file descriptor from GIT_TRACE env variable. */
static int get_trace_fd(int *need_close)
{
@@ -72,6 +76,7 @@ void trace_printf(const char *fmt, ...)
if (!fd)
return;
+ set_try_to_free_routine(do_nothing); /* is never reset */
strbuf_init(&buf, 64);
va_start(ap, fmt);
len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
@@ -103,6 +108,7 @@ void trace_argv_printf(const char **argv, const char *fmt, ...)
if (!fd)
return;
+ set_try_to_free_routine(do_nothing); /* is never reset */
strbuf_init(&buf, 64);
va_start(ap, fmt);
len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
diff --git a/transport-helper.c b/transport-helper.c
index 2638781c5..0381de536 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -7,6 +7,7 @@
#include "revision.h"
#include "quote.h"
#include "remote.h"
+#include "string-list.h"
static int debug;
@@ -17,6 +18,7 @@ struct helper_data
FILE *out;
unsigned fetch : 1,
import : 1,
+ export : 1,
option : 1,
push : 1,
connect : 1,
@@ -163,6 +165,8 @@ static struct child_process *get_helper(struct transport *transport)
data->push = 1;
else if (!strcmp(capname, "import"))
data->import = 1;
+ else if (!strcmp(capname, "export"))
+ data->export = 1;
else if (!data->refspecs && !prefixcmp(capname, "refspec ")) {
ALLOC_GROW(refspecs,
refspec_nr + 1,
@@ -170,6 +174,11 @@ static struct child_process *get_helper(struct transport *transport)
refspecs[refspec_nr++] = strdup(buf.buf + strlen("refspec "));
} else if (!strcmp(capname, "connect")) {
data->connect = 1;
+ } else if (!strcmp(buf.buf, "gitdir")) {
+ struct strbuf gitdir = STRBUF_INIT;
+ strbuf_addf(&gitdir, "gitdir %s\n", get_git_dir());
+ sendline(data, &gitdir);
+ strbuf_release(&gitdir);
} else if (mandatory) {
die("Unknown mandatory capability %s. This remote "
"helper probably needs newer version of Git.\n",
@@ -351,6 +360,33 @@ static int get_importer(struct transport *transport, struct child_process *fasti
return start_command(fastimport);
}
+static int get_exporter(struct transport *transport,
+ struct child_process *fastexport,
+ const char *export_marks,
+ const char *import_marks,
+ struct string_list *revlist_args)
+{
+ struct child_process *helper = get_helper(transport);
+ int argc = 0, i;
+ memset(fastexport, 0, sizeof(*fastexport));
+
+ /* we need to duplicate helper->in because we want to use it after
+ * fastexport is done with it. */
+ fastexport->out = dup(helper->in);
+ fastexport->argv = xcalloc(4 + revlist_args->nr, sizeof(*fastexport->argv));
+ fastexport->argv[argc++] = "fast-export";
+ if (export_marks)
+ fastexport->argv[argc++] = export_marks;
+ if (import_marks)
+ fastexport->argv[argc++] = import_marks;
+
+ for (i = 0; i < revlist_args->nr; i++)
+ fastexport->argv[argc++] = revlist_args->items[i].string;
+
+ fastexport->git_cmd = 1;
+ return start_command(fastexport);
+}
+
static int fetch_with_import(struct transport *transport,
int nr_heads, struct ref **to_fetch)
{
@@ -518,7 +554,7 @@ static int fetch(struct transport *transport,
return -1;
}
-static int push_refs(struct transport *transport,
+static int push_refs_with_push(struct transport *transport,
struct ref *remote_refs, int flags)
{
int force_all = flags & TRANSPORT_PUSH_FORCE;
@@ -528,17 +564,6 @@ static int push_refs(struct transport *transport,
struct child_process *helper;
struct ref *ref;
- if (process_connect(transport, 1)) {
- do_take_over(transport);
- return transport->push_refs(transport, remote_refs, flags);
- }
-
- if (!remote_refs) {
- fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
- "Perhaps you should specify a branch such as 'master'.\n");
- return 0;
- }
-
helper = get_helper(transport);
if (!data->push)
return 1;
@@ -657,6 +682,94 @@ static int push_refs(struct transport *transport,
return 0;
}
+static int push_refs_with_export(struct transport *transport,
+ struct ref *remote_refs, int flags)
+{
+ struct ref *ref;
+ struct child_process *helper, exporter;
+ struct helper_data *data = transport->data;
+ char *export_marks = NULL, *import_marks = NULL;
+ struct string_list revlist_args = { NULL, 0, 0 };
+ struct strbuf buf = STRBUF_INIT;
+
+ helper = get_helper(transport);
+
+ write_constant(helper->in, "export\n");
+
+ recvline(data, &buf);
+ if (debug)
+ fprintf(stderr, "Debug: Got export_marks '%s'\n", buf.buf);
+ if (buf.len) {
+ struct strbuf arg = STRBUF_INIT;
+ strbuf_addstr(&arg, "--export-marks=");
+ strbuf_addbuf(&arg, &buf);
+ export_marks = strbuf_detach(&arg, NULL);
+ }
+
+ recvline(data, &buf);
+ if (debug)
+ fprintf(stderr, "Debug: Got import_marks '%s'\n", buf.buf);
+ if (buf.len) {
+ struct strbuf arg = STRBUF_INIT;
+ strbuf_addstr(&arg, "--import-marks=");
+ strbuf_addbuf(&arg, &buf);
+ import_marks = strbuf_detach(&arg, NULL);
+ }
+
+ strbuf_reset(&buf);
+
+ for (ref = remote_refs; ref; ref = ref->next) {
+ char *private;
+ unsigned char sha1[20];
+
+ if (!data->refspecs)
+ continue;
+ private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
+ if (private && !get_sha1(private, sha1)) {
+ strbuf_addf(&buf, "^%s", private);
+ string_list_append(strbuf_detach(&buf, NULL), &revlist_args);
+ }
+
+ string_list_append(ref->name, &revlist_args);
+
+ }
+
+ if (get_exporter(transport, &exporter,
+ export_marks, import_marks, &revlist_args))
+ die("Couldn't run fast-export");
+
+ data->no_disconnect_req = 1;
+ finish_command(&exporter);
+ disconnect_helper(transport);
+ return 0;
+}
+
+static int push_refs(struct transport *transport,
+ struct ref *remote_refs, int flags)
+{
+ struct helper_data *data = transport->data;
+
+ if (process_connect(transport, 1)) {
+ do_take_over(transport);
+ return transport->push_refs(transport, remote_refs, flags);
+ }
+
+ if (!remote_refs) {
+ fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
+ "Perhaps you should specify a branch such as 'master'.\n");
+ return 0;
+ }
+
+ if (data->push)
+ return push_refs_with_push(transport, remote_refs, flags);
+
+ if (data->export)
+ return push_refs_with_export(transport, remote_refs, flags);
+
+ return -1;
+}
+
+
static int has_attribute(const char *attrs, const char *attr) {
int len;
if (!attrs)
diff --git a/transport.c b/transport.c
index 8ce39364a..4dba6f881 100644
--- a/transport.c
+++ b/transport.c
@@ -9,6 +9,7 @@
#include "dir.h"
#include "refs.h"
#include "branch.h"
+#include "url.h"
/* rsync support */
@@ -871,54 +872,6 @@ static int is_file(const char *url)
return S_ISREG(buf.st_mode);
}
-static int isurlschemechar(int first_flag, int ch)
-{
- /*
- * The set of valid URL schemes, as per STD66 (RFC3986) is
- * '[A-Za-z][A-Za-z0-9+.-]*'. But use sightly looser check
- * of '[A-Za-z0-9][A-Za-z0-9+.-]*' because earlier version
- * of check used '[A-Za-z0-9]+' so not to break any remote
- * helpers.
- */
- int alphanumeric, special;
- alphanumeric = ch > 0 && isalnum(ch);
- special = ch == '+' || ch == '-' || ch == '.';
- return alphanumeric || (!first_flag && special);
-}
-
-static int is_url(const char *url)
-{
- const char *url2, *first_slash;
-
- if (!url)
- return 0;
- url2 = url;
- first_slash = strchr(url, '/');
-
- /* Input with no slash at all or slash first can't be URL. */
- if (!first_slash || first_slash == url)
- return 0;
- /* Character before must be : and next must be /. */
- if (first_slash[-1] != ':' || first_slash[1] != '/')
- return 0;
- /* There must be something before the :// */
- if (first_slash == url + 1)
- return 0;
- /*
- * Check all characters up to first slash - 1. Only alphanum
- * is allowed.
- */
- url2 = url;
- while (url2 < first_slash - 1) {
- if (!isurlschemechar(url2 == url, (unsigned char)*url2))
- return 0;
- url2++;
- }
-
- /* Valid enough. */
- return 1;
-}
-
static int external_specification_len(const char *url)
{
return strchr(url, ':') - url;
@@ -946,7 +899,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
if (url) {
const char *p = url;
- while (isurlschemechar(p == url, *p))
+ while (is_urlschemechar(p == url, *p))
p++;
if (!prefixcmp(p, "::"))
helper = xstrndup(url, p - url);
diff --git a/tree-diff.c b/tree-diff.c
index fe9f52c47..1fb3e9461 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -346,7 +346,7 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
diff_setup(&diff_opts);
DIFF_OPT_SET(&diff_opts, RECURSIVE);
- diff_opts.detect_rename = DIFF_DETECT_RENAME;
+ DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
diff_opts.single_follow = opt->paths[0];
diff_opts.break_opt = opt->break_opt;
diff --git a/unpack-trees.c b/unpack-trees.c
index c29a9e067..490cd5f6f 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -854,7 +854,7 @@ static int verify_uptodate_1(struct cache_entry *ce,
{
struct stat st;
- if (o->index_only || (!ce_skip_worktree(ce) && (o->reset || ce_uptodate(ce))))
+ if (o->index_only || (!((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) && (o->reset || ce_uptodate(ce))))
return 0;
if (!lstat(ce->name, &st)) {
diff --git a/url.c b/url.c
new file mode 100644
index 000000000..cd32b927a
--- /dev/null
+++ b/url.c
@@ -0,0 +1,118 @@
+#include "cache.h"
+
+int is_urlschemechar(int first_flag, int ch)
+{
+ /*
+ * The set of valid URL schemes, as per STD66 (RFC3986) is
+ * '[A-Za-z][A-Za-z0-9+.-]*'. But use sightly looser check
+ * of '[A-Za-z0-9][A-Za-z0-9+.-]*' because earlier version
+ * of check used '[A-Za-z0-9]+' so not to break any remote
+ * helpers.
+ */
+ int alphanumeric, special;
+ alphanumeric = ch > 0 && isalnum(ch);
+ special = ch == '+' || ch == '-' || ch == '.';
+ return alphanumeric || (!first_flag && special);
+}
+
+int is_url(const char *url)
+{
+ const char *url2, *first_slash;
+
+ if (!url)
+ return 0;
+ url2 = url;
+ first_slash = strchr(url, '/');
+
+ /* Input with no slash at all or slash first can't be URL. */
+ if (!first_slash || first_slash == url)
+ return 0;
+ /* Character before must be : and next must be /. */
+ if (first_slash[-1] != ':' || first_slash[1] != '/')
+ return 0;
+ /* There must be something before the :// */
+ if (first_slash == url + 1)
+ return 0;
+ /*
+ * Check all characters up to first slash - 1. Only alphanum
+ * is allowed.
+ */
+ url2 = url;
+ while (url2 < first_slash - 1) {
+ if (!is_urlschemechar(url2 == url, (unsigned char)*url2))
+ return 0;
+ url2++;
+ }
+
+ /* Valid enough. */
+ return 1;
+}
+
+static int url_decode_char(const char *q)
+{
+ int i;
+ unsigned char val = 0;
+ for (i = 0; i < 2; i++) {
+ unsigned char c = *q++;
+ val <<= 4;
+ if (c >= '0' && c <= '9')
+ val += c - '0';
+ else if (c >= 'a' && c <= 'f')
+ val += c - 'a' + 10;
+ else if (c >= 'A' && c <= 'F')
+ val += c - 'A' + 10;
+ else
+ return -1;
+ }
+ return val;
+}
+
+static char *url_decode_internal(const char **query, const char *stop_at)
+{
+ const char *q = *query;
+ struct strbuf out;
+
+ strbuf_init(&out, 16);
+ do {
+ unsigned char c = *q;
+
+ if (!c)
+ break;
+ if (stop_at && strchr(stop_at, c)) {
+ q++;
+ break;
+ }
+
+ if (c == '%') {
+ int val = url_decode_char(q + 1);
+ if (0 <= val) {
+ strbuf_addch(&out, val);
+ q += 3;
+ continue;
+ }
+ }
+
+ if (c == '+')
+ strbuf_addch(&out, ' ');
+ else
+ strbuf_addch(&out, c);
+ q++;
+ } while (1);
+ *query = q;
+ return strbuf_detach(&out, NULL);
+}
+
+char *url_decode(const char *url)
+{
+ return url_decode_internal(&url, NULL);
+}
+
+char *url_decode_parameter_name(const char **query)
+{
+ return url_decode_internal(query, "&=");
+}
+
+char *url_decode_parameter_value(const char **query)
+{
+ return url_decode_internal(query, "&");
+}
diff --git a/url.h b/url.h
new file mode 100644
index 000000000..15817f8f9
--- /dev/null
+++ b/url.h
@@ -0,0 +1,10 @@
+#ifndef URL_H
+#define URL_H
+
+extern int is_url(const char *url);
+extern int is_urlschemechar(int first_flag, int ch);
+extern char *url_decode(const char *url);
+extern char *url_decode_parameter_name(const char **query);
+extern char *url_decode_parameter_value(const char **query);
+
+#endif /* URL_H */
diff --git a/userdiff.c b/userdiff.c
index 67003fbb2..c49cc1b67 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -45,7 +45,9 @@ PATTERNS("pascal",
"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
"|<>|<=|>=|:=|\\.\\."
"|[^[:space:]]|[\x80-\xff]+"),
-PATTERNS("php", "^[\t ]*((function|class).*)",
+PATTERNS("php",
+ "^[\t ]*(((public|protected|private|static)[\t ]+)*function.*)$\n"
+ "^[\t ]*(class.*)$",
/* -- */
"[a-zA-Z_][a-zA-Z0-9_]*"
"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
diff --git a/wrapper.c b/wrapper.c
index 10a675079..afb4f6f77 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -3,11 +3,25 @@
*/
#include "cache.h"
+static void try_to_free_builtin(size_t size)
+{
+ release_pack_memory(size, -1);
+}
+
+static void (*try_to_free_routine)(size_t size) = try_to_free_builtin;
+
+try_to_free_t set_try_to_free_routine(try_to_free_t routine)
+{
+ try_to_free_t old = try_to_free_routine;
+ try_to_free_routine = routine;
+ return old;
+}
+
char *xstrdup(const char *str)
{
char *ret = strdup(str);
if (!ret) {
- release_pack_memory(strlen(str) + 1, -1);
+ try_to_free_routine(strlen(str) + 1);
ret = strdup(str);
if (!ret)
die("Out of memory, strdup failed");
@@ -21,7 +35,7 @@ void *xmalloc(size_t size)
if (!ret && !size)
ret = malloc(1);
if (!ret) {
- release_pack_memory(size, -1);
+ try_to_free_routine(size);
ret = malloc(size);
if (!ret && !size)
ret = malloc(1);
@@ -67,7 +81,7 @@ void *xrealloc(void *ptr, size_t size)
if (!ret && !size)
ret = realloc(ptr, 1);
if (!ret) {
- release_pack_memory(size, -1);
+ try_to_free_routine(size);
ret = realloc(ptr, size);
if (!ret && !size)
ret = realloc(ptr, 1);
@@ -83,7 +97,7 @@ void *xcalloc(size_t nmemb, size_t size)
if (!ret && (!nmemb || !size))
ret = calloc(1, 1);
if (!ret) {
- release_pack_memory(nmemb * size, -1);
+ try_to_free_routine(nmemb * size);
ret = calloc(nmemb, size);
if (!ret && (!nmemb || !size))
ret = calloc(1, 1);
diff --git a/wt-status.c b/wt-status.c
index 8ca59a2d2..636ecdd89 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -9,6 +9,7 @@
#include "quote.h"
#include "run-command.h"
#include "remote.h"
+#include "refs.h"
static char default_wt_status_colors[][COLOR_MAXLEN] = {
GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */
@@ -17,6 +18,8 @@ static char default_wt_status_colors[][COLOR_MAXLEN] = {
GIT_COLOR_RED, /* WT_STATUS_UNTRACKED */
GIT_COLOR_RED, /* WT_STATUS_NOBRANCH */
GIT_COLOR_RED, /* WT_STATUS_UNMERGED */
+ GIT_COLOR_GREEN, /* WT_STATUS_LOCAL_BRANCH */
+ GIT_COLOR_RED, /* WT_STATUS_REMOTE_BRANCH */
};
static const char *color(int slot, struct wt_status *s)
@@ -42,6 +45,7 @@ void wt_status_prepare(struct wt_status *s)
s->index_file = get_index_file();
s->change.strdup_strings = 1;
s->untracked.strdup_strings = 1;
+ s->ignored.strdup_strings = 1;
}
static void wt_status_print_unmerged_header(struct wt_status *s)
@@ -96,13 +100,15 @@ static void wt_status_print_dirty_header(struct wt_status *s,
color_fprintf_ln(s->fp, c, "#");
}
-static void wt_status_print_untracked_header(struct wt_status *s)
+static void wt_status_print_other_header(struct wt_status *s,
+ const char *what,
+ const char *how)
{
const char *c = color(WT_STATUS_HEADER, s);
- color_fprintf_ln(s->fp, c, "# Untracked files:");
+ color_fprintf_ln(s->fp, c, "# %s files:", what);
if (!advice_status_hints)
return;
- color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to include in what will be committed)");
+ color_fprintf_ln(s->fp, c, "# (use \"git %s <file>...\" to include in what will be committed)", how);
color_fprintf_ln(s->fp, c, "#");
}
@@ -378,9 +384,26 @@ static void wt_status_collect_untracked(struct wt_status *s)
continue;
if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
continue;
- s->workdir_untracked = 1;
string_list_insert(ent->name, &s->untracked);
+ free(ent);
}
+
+ if (s->show_ignored_files) {
+ dir.nr = 0;
+ dir.flags = DIR_SHOW_IGNORED | DIR_SHOW_OTHER_DIRECTORIES;
+ fill_directory(&dir, s->pathspec);
+ for (i = 0; i < dir.nr; i++) {
+ struct dir_entry *ent = dir.entries[i];
+ if (!cache_name_is_other(ent->name, ent->len))
+ continue;
+ if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
+ continue;
+ string_list_insert(ent->name, &s->ignored);
+ free(ent);
+ }
+ }
+
+ free(dir.entries);
}
void wt_status_collect(struct wt_status *s)
@@ -523,7 +546,10 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
run_command(&sm_summary);
}
-static void wt_status_print_untracked(struct wt_status *s)
+static void wt_status_print_other(struct wt_status *s,
+ struct string_list *l,
+ const char *what,
+ const char *how)
{
int i;
struct strbuf buf = STRBUF_INIT;
@@ -531,10 +557,11 @@ static void wt_status_print_untracked(struct wt_status *s)
if (!s->untracked.nr)
return;
- wt_status_print_untracked_header(s);
- for (i = 0; i < s->untracked.nr; i++) {
+ wt_status_print_other_header(s, what, how);
+
+ for (i = 0; i < l->nr; i++) {
struct string_list_item *it;
- it = &(s->untracked.items[i]);
+ it = &(l->items[i]);
color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED, s), "%s",
quote_path(it->string, strlen(it->string),
@@ -622,10 +649,14 @@ void wt_status_print(struct wt_status *s)
wt_status_print_submodule_summary(s, 0); /* staged */
wt_status_print_submodule_summary(s, 1); /* unstaged */
}
- if (s->show_untracked_files)
- wt_status_print_untracked(s);
- else if (s->commitable)
- fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
+ if (s->show_untracked_files) {
+ wt_status_print_other(s, &s->untracked, "Untracked", "add");
+ if (s->show_ignored_files)
+ wt_status_print_other(s, &s->ignored, "Ignored", "add -f");
+ } else if (s->commitable)
+ fprintf(s->fp, "# Untracked files not listed%s\n",
+ advice_status_hints
+ ? " (use -u option to show untracked files)" : "");
if (s->verbose)
wt_status_print_verbose(s);
@@ -635,15 +666,22 @@ void wt_status_print(struct wt_status *s)
else if (s->nowarn)
; /* nothing */
else if (s->workdir_dirty)
- printf("no changes added to commit (use \"git add\" and/or \"git commit -a\")\n");
+ printf("no changes added to commit%s\n",
+ advice_status_hints
+ ? " (use \"git add\" and/or \"git commit -a\")" : "");
else if (s->untracked.nr)
- printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
+ printf("nothing added to commit but untracked files present%s\n",
+ advice_status_hints
+ ? " (use \"git add\" to track)" : "");
else if (s->is_initial)
- printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
+ printf("nothing to commit%s\n", advice_status_hints
+ ? " (create/copy files and use \"git add\" to track)" : "");
else if (!s->show_untracked_files)
- printf("nothing to commit (use -u to show untracked files)\n");
+ printf("nothing to commit%s\n", advice_status_hints
+ ? " (use -u to show untracked files)" : "");
else
- printf("nothing to commit (working directory clean)\n");
+ printf("nothing to commit%s\n", advice_status_hints
+ ? " (working directory clean)" : "");
}
}
@@ -706,24 +744,84 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item
}
}
-static void wt_shortstatus_untracked(int null_termination, struct string_list_item *it,
- struct wt_status *s)
+static void wt_shortstatus_other(int null_termination, struct string_list_item *it,
+ struct wt_status *s, const char *sign)
{
if (null_termination) {
- fprintf(stdout, "?? %s%c", it->string, 0);
+ fprintf(stdout, "%s %s%c", sign, it->string, 0);
} else {
struct strbuf onebuf = STRBUF_INIT;
const char *one;
one = quote_path(it->string, -1, &onebuf, s->prefix);
- color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "??");
+ color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "%s", sign);
printf(" %s\n", one);
strbuf_release(&onebuf);
}
}
-void wt_shortstatus_print(struct wt_status *s, int null_termination)
+static void wt_shortstatus_print_tracking(struct wt_status *s)
+{
+ struct branch *branch;
+ const char *header_color = color(WT_STATUS_HEADER, s);
+ const char *branch_color_local = color(WT_STATUS_LOCAL_BRANCH, s);
+ const char *branch_color_remote = color(WT_STATUS_REMOTE_BRANCH, s);
+
+ const char *base;
+ const char *branch_name;
+ int num_ours, num_theirs;
+
+ color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "## ");
+
+ if (!s->branch)
+ return;
+ branch_name = s->branch;
+
+ if (!prefixcmp(branch_name, "refs/heads/"))
+ branch_name += 11;
+ else if (!strcmp(branch_name, "HEAD")) {
+ branch_name = "HEAD (no branch)";
+ branch_color_local = color(WT_STATUS_NOBRANCH, s);
+ }
+
+ branch = branch_get(s->branch + 11);
+ if (s->is_initial)
+ color_fprintf(s->fp, header_color, "Initial commit on ");
+ if (!stat_tracking_info(branch, &num_ours, &num_theirs)) {
+ color_fprintf_ln(s->fp, branch_color_local,
+ "%s", branch_name);
+ return;
+ }
+
+ base = branch->merge[0]->dst;
+ base = shorten_unambiguous_ref(base, 0);
+ color_fprintf(s->fp, branch_color_local, "%s", branch_name);
+ color_fprintf(s->fp, header_color, "...");
+ color_fprintf(s->fp, branch_color_remote, "%s", base);
+
+ color_fprintf(s->fp, header_color, " [");
+ if (!num_ours) {
+ color_fprintf(s->fp, header_color, "behind ");
+ color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
+ } else if (!num_theirs) {
+ color_fprintf(s->fp, header_color, "ahead ");
+ color_fprintf(s->fp, branch_color_local, "%d", num_ours);
+ } else {
+ color_fprintf(s->fp, header_color, "ahead ");
+ color_fprintf(s->fp, branch_color_local, "%d", num_ours);
+ color_fprintf(s->fp, header_color, ", behind ");
+ color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
+ }
+
+ color_fprintf_ln(s->fp, header_color, "]");
+}
+
+void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_branch)
{
int i;
+
+ if (show_branch)
+ wt_shortstatus_print_tracking(s);
+
for (i = 0; i < s->change.nr; i++) {
struct wt_status_change_data *d;
struct string_list_item *it;
@@ -739,7 +837,13 @@ void wt_shortstatus_print(struct wt_status *s, int null_termination)
struct string_list_item *it;
it = &(s->untracked.items[i]);
- wt_shortstatus_untracked(null_termination, it, s);
+ wt_shortstatus_other(null_termination, it, s, "??");
+ }
+ for (i = 0; i < s->ignored.nr; i++) {
+ struct string_list_item *it;
+
+ it = &(s->ignored.items[i]);
+ wt_shortstatus_other(null_termination, it, s, "!!");
}
}
@@ -748,5 +852,5 @@ void wt_porcelain_print(struct wt_status *s, int null_termination)
s->use_color = 0;
s->relative_paths = 0;
s->prefix = NULL;
- wt_shortstatus_print(s, null_termination);
+ wt_shortstatus_print(s, null_termination, 0);
}
diff --git a/wt-status.h b/wt-status.h
index 91206739f..4f190454e 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -12,6 +12,8 @@ enum color_wt_status {
WT_STATUS_UNTRACKED,
WT_STATUS_NOBRANCH,
WT_STATUS_UNMERGED,
+ WT_STATUS_LOCAL_BRANCH,
+ WT_STATUS_REMOTE_BRANCH,
};
enum untracked_status_type {
@@ -41,25 +43,26 @@ struct wt_status {
int use_color;
int relative_paths;
int submodule_summary;
+ int show_ignored_files;
enum untracked_status_type show_untracked_files;
- char color_palette[WT_STATUS_UNMERGED+1][COLOR_MAXLEN];
+ char color_palette[WT_STATUS_REMOTE_BRANCH+1][COLOR_MAXLEN];
/* These are computed during processing of the individual sections */
int commitable;
int workdir_dirty;
- int workdir_untracked;
const char *index_file;
FILE *fp;
const char *prefix;
struct string_list change;
struct string_list untracked;
+ struct string_list ignored;
};
void wt_status_prepare(struct wt_status *s);
void wt_status_print(struct wt_status *s);
void wt_status_collect(struct wt_status *s);
-void wt_shortstatus_print(struct wt_status *s, int null_termination);
+void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_branch);
void wt_porcelain_print(struct wt_status *s, int null_termination);
#endif /* STATUS_H */