Merge branch 'jt/imap-send-message-fix'
Update some error messages from "git imap-send".
* jt/imap-send-message-fix:
imap-send: improve error messages with configuration hints
imap-send: fix confusing 'store' terminology in error message
diff --git a/Documentation/BreakingChanges.adoc b/Documentation/BreakingChanges.adoc
index 61bdd58..c6bd949 100644
--- a/Documentation/BreakingChanges.adoc
+++ b/Documentation/BreakingChanges.adoc
@@ -183,6 +183,14 @@
timeframe, in preference to its synonym "--annotate-stdin". Git 3.0
removes the support for "--stdin" altogether.
+* The git-whatchanged(1) command has outlived its usefulness more than
+ 10 years ago, and takes more keystrokes to type than its rough
+ equivalent `git log --raw`. We have nominated the command for
+ removal, have changed the command to refuse to work unless the
+ `--i-still-use-this` option is given, and asked the users to report
+ when they do so. So far there hasn't been a single complaint.
++
+The command will be removed.
== Superseded features that will not be deprecated
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index c1046ab..6350949 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -315,6 +315,9 @@
encouraged to have a blank line between the end of the declarations
and the first statement in the block.
+ - Do not explicitly initialize global variables to 0 or NULL;
+ instead, let BSS take care of the zero initialization.
+
- NULL pointers shall be written as NULL, not as 0.
- When declaring pointers, the star sides with the variable
@@ -877,6 +880,17 @@
As a side effect, backquoted placeholders are correctly typeset, but
this style is not recommended.
+ When documenting multiple related `git config` variables, place them on
+ a separate line instead of separating them by commas. For example, do
+ not write this:
+ `core.var1`, `core.var2`::
+ Description common to `core.var1` and `core.var2`.
+
+Instead write this:
+ `core.var1`::
+ `core.var2`::
+ Description common to `core.var1` and `core.var2`.
+
Synopsis Syntax
The synopsis (a paragraph with [synopsis] attribute) is automatically
diff --git a/Documentation/Makefile b/Documentation/Makefile
index b109d25..df2ce18 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -510,7 +510,12 @@
awk "/^manpages = {$$/ {flag=1 ; next } /^}$$/ { flag=0 } flag { gsub(/^ \047/, \"\"); gsub(/\047 : [157],\$$/, \"\"); print }" meson.build | \
grep -v -e '#' -e '^$$' | \
sort >tmp-meson-diff/meson.adoc && \
- ls git*.adoc scalar.adoc | grep -v -e git-bisect-lk2009.adoc -e git-pack-redundant.adoc -e git-tools.adoc >tmp-meson-diff/actual.adoc && \
+ ls git*.adoc scalar.adoc | \
+ grep -v -e git-bisect-lk2009.adoc \
+ -e git-pack-redundant.adoc \
+ -e git-tools.adoc \
+ -e git-whatchanged.adoc \
+ >tmp-meson-diff/actual.adoc && \
if ! cmp tmp-meson-diff/meson.adoc tmp-meson-diff/actual.adoc; then \
echo "Meson man pages differ from actual man pages:"; \
diff -u tmp-meson-diff/meson.adoc tmp-meson-diff/actual.adoc; \
diff --git a/Documentation/MyFirstObjectWalk.adoc b/Documentation/MyFirstObjectWalk.adoc
index bfe8f5f..413a9fd 100644
--- a/Documentation/MyFirstObjectWalk.adoc
+++ b/Documentation/MyFirstObjectWalk.adoc
@@ -43,7 +43,7 @@
#include "builtin.h"
#include "trace.h"
-int cmd_walken(int argc, const char **argv, const char *prefix)
+int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo)
{
trace_printf(_("cmd_walken incoming...\n"));
return 0;
@@ -83,23 +83,36 @@
}
----
-Also add the relevant line in `builtin.h` near `cmd_whatchanged()`:
+Also add the relevant line in `builtin.h` near `cmd_version()`:
----
-int cmd_walken(int argc, const char **argv, const char *prefix);
+int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo);
----
-Include the command in `git.c` in `commands[]` near the entry for `whatchanged`,
+Include the command in `git.c` in `commands[]` near the entry for `version`,
maintaining alphabetical ordering:
----
{ "walken", cmd_walken, RUN_SETUP },
----
-Add it to the `Makefile` near the line for `builtin/worktree.o`:
+Add an entry for the new command in the both the Make and Meson build system,
+before the entry for `worktree`:
+- In the `Makefile`:
----
+...
BUILTIN_OBJS += builtin/walken.o
+...
+----
+
+- In the `meson.build` file:
+----
+builtin_sources = [
+ ...
+ 'builtin/walken.c',
+ ...
+]
----
Build and test out your command, without forgetting to ensure the `DEVELOPER`
@@ -193,7 +206,7 @@
Next, we should have a look at any relevant configuration settings (i.e.,
settings readable and settable from `git config`). This is done by providing a
-callback to `git_config()`; within that callback, you can also invoke methods
+callback to `repo_config()`; within that callback, you can also invoke methods
from other components you may need that need to intercept these options. Your
callback will be invoked once per each configuration value which Git knows about
(global, local, worktree, etc.).
@@ -221,14 +234,14 @@
}
----
-Make sure to invoke `git_config()` with it in your `cmd_walken()`:
+Make sure to invoke `repo_config()` with it in your `cmd_walken()`:
----
-int cmd_walken(int argc, const char **argv, const char *prefix)
+int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo)
{
...
- git_config(git_walken_config, NULL);
+ repo_config(repo, git_walken_config, NULL);
...
}
@@ -250,14 +263,14 @@
...
-int cmd_walken(int argc, const char **argv, const char *prefix)
+int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo)
{
/* This can go wherever you like in your declarations.*/
struct rev_info rev;
...
- /* This should go after the git_config() call. */
- repo_init_revisions(the_repository, &rev, prefix);
+ /* This should go after the repo_config() call. */
+ repo_init_revisions(repo, &rev, prefix);
...
}
@@ -305,7 +318,7 @@
`repo_init_revisions()`:
----
-int cmd_walken(int argc, const char **argv, const char *prefix)
+int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo)
{
...
diff --git a/Documentation/RelNotes/2.51.0.adoc b/Documentation/RelNotes/2.51.0.adoc
new file mode 100644
index 0000000..199cc01
--- /dev/null
+++ b/Documentation/RelNotes/2.51.0.adoc
@@ -0,0 +1,109 @@
+Git v2.51 Release Notes
+=======================
+
+UI, Workflows & Features
+------------------------
+
+ * Userdiff patterns for the R language have been added.
+
+ * Documentation for "git send-email" has been updated with a bit more
+ credential helper and OAuth information.
+
+ * "git cat-file --batch" learns to understand %(objectmode) atom to
+ allow the caller to tell missing objects (due to repository
+ corruption) and submodules (whose commit objects are OK to be
+ missing) apart.
+
+ * "git diff --no-index dirA dirB" can limit the comparison with
+ pathspec at the end of the command line, just like normal "git
+ diff".
+
+ * "git subtree" (in contrib/) learned to grok GPG signing its commits.
+
+ * "git whatchanged" that is longer to type than "git log --raw"
+ which is its modern rough equivalent has outlived its usefulness
+ more than 10 years ago. Plan to deprecate and remove it.
+
+ * An interchange format for stash entries is defined, and subcommand
+ of "git stash" to import/export has been added.
+
+ * "git merge/pull" has been taught the "--compact-summary" option to
+ use the compact-summary format, intead of diffstat, when showing
+ the summary of the incoming changes.
+
+
+Performance, Internal Implementation, Development Support etc.
+--------------------------------------------------------------
+
+ * "git pack-objects" learned to find delta bases from blobs at the
+ same path, using the --path-walk API.
+
+ * CodingGuidelines update.
+
+ * Add settings for Solaris 10 & 11.
+
+ * Meson-based build/test framework now understands TAP output
+ generated by our tests.
+
+ * "Do not explicitly initialize to zero" rule has been clarified in
+ the CodingGuidelines document.
+
+ * A test helper "test_seq" function learned the "-f <fmt>" option,
+ which allowed us to simplify a lot of test scripts.
+
+
+Fixes since v2.50
+-----------------
+
+ * A memory-leak in an error code path has been plugged.
+ (merge 7082da85cb ly/commit-graph-graph-write-leakfix later to maint).
+
+ * A memory-leak in an error code path has been plugged.
+ (merge aedebdb6b9 ly/fetch-pack-leakfix later to maint).
+
+ * Some leftover references to documentation source files that no
+ longer exist, due to recent ".txt" -> ".adoc" renaming, have been
+ corrected.
+ (merge 3717a5775a jw/doc-txt-to-adoc-refs later to maint).
+
+ * "git stash -p <pathspec>" improvements.
+ (merge 468817bab2 pw/stash-p-pathspec-fixes later to maint).
+
+ * "git send-email" incremented its internal message counter when a
+ message was edited, which made logic that treats the first message
+ specially misbehave, which has been corrected.
+ (merge 2cc27b3501 ag/send-email-edit-threading-fix later to maint).
+
+ * "git stash" recorded a wrong branch name when submodules are
+ present in the current checkout, which has been corrected.
+ (merge ffb36c64f2 kj/stash-onbranch-submodule-fix later to maint).
+
+ * When asking to apply mailmap to both author and committer field
+ while showing a commit object, the field that appears later was not
+ correctly parsed and replaced, which has been corrected.
+ (merge abf94a283f sa/multi-mailmap-fix later to maint).
+
+ * "git maintenance" lacked the care "git gc" had to avoid holding
+ onto the repository lock for too long during packing refs, which
+ has been remedied.
+ (merge 1b5074e614 ps/maintenance-ref-lock later to maint).
+
+ * Avoid regexp_constraint and instead use comparison_constraint when
+ listing functions to exclude from application of coccinelle rules,
+ as spatch can be built with different regexp engine X-<.
+ (merge f2ad545813 jc/cocci-avoid-regexp-constraint later to maint).
+
+ * Other code cleanup, docfix, build fix, etc.
+ (merge b257adb571 lo/my-first-ow-doc-update later to maint).
+ (merge 8b34b6a220 ly/sequencer-update-squash-is-fixup-only later to maint).
+ (merge 5dceb8bd05 ly/do-not-localize-bug-messages later to maint).
+ (merge 61372dd613 ly/commit-buffer-reencode-leakfix later to maint).
+ (merge 81cd1eef7d ly/pack-bitmap-root-leakfix later to maint).
+ (merge bfc9f9cc64 ly/submodule-update-failure-leakfix later to maint).
+ (merge 65dff89c6b ma/doc-diff-cc-headers later to maint).
+ (merge efb61591ee jm/bundle-uri-debug-output-to-fp later to maint).
+ (merge a3d278bb64 ly/prepare-show-merge-leakfix later to maint).
+ (merge 1fde1c5daf ac/preload-index-wo-the-repository later to maint).
+ (merge 855cfc65ae rm/t2400-modernize later to maint).
+ (merge 2939494284 ly/run-builtin-use-passed-in-repo later to maint).
+ (merge ff73f375bb jg/mailinfo-leakfix later to maint).
diff --git a/Documentation/config/feature.adoc b/Documentation/config/feature.adoc
index f061b64..cb49ff2 100644
--- a/Documentation/config/feature.adoc
+++ b/Documentation/config/feature.adoc
@@ -20,6 +20,10 @@
+
* `pack.allowPackReuse=multi` may improve the time it takes to create a pack by
reusing objects from multiple packs instead of just one.
++
+* `pack.usePathWalk` may speed up packfile creation and make the packfiles be
+significantly smaller in the presence of certain filename collisions with Git's
+default name-hash.
feature.manyFiles::
Enable config options that optimize for repos with many files in the
diff --git a/Documentation/config/format.adoc b/Documentation/config/format.adoc
index 7410e93..ab0710e 100644
--- a/Documentation/config/format.adoc
+++ b/Documentation/config/format.adoc
@@ -68,9 +68,15 @@
Defaults to true.
format.pretty::
+ifndef::with-breaking-changes[]
The default pretty format for log/show/whatchanged command.
See linkgit:git-log[1], linkgit:git-show[1],
linkgit:git-whatchanged[1].
+endif::with-breaking-changes[]
+ifdef::with-breaking-changes[]
+ The default pretty format for log/show command.
+ See linkgit:git-log[1], linkgit:git-show[1].
+endif::with-breaking-changes[]
format.thread::
The default threading style for 'git format-patch'. Can be
diff --git a/Documentation/config/log.adoc b/Documentation/config/log.adoc
index 9003a82..a9b160e 100644
--- a/Documentation/config/log.adoc
+++ b/Documentation/config/log.adoc
@@ -1,6 +1,13 @@
log.abbrevCommit::
- If true, makes linkgit:git-log[1], linkgit:git-show[1], and
- linkgit:git-whatchanged[1] assume `--abbrev-commit`. You may
+ If true, makes
+ifndef::with-breaking-changes[]
+ linkgit:git-log[1], linkgit:git-show[1], and
+ linkgit:git-whatchanged[1]
+endif::with-breaking-changes[]
+ifdef::with-breaking-changes[]
+ linkgit:git-log[1] and linkgit:git-show[1]
+endif::with-breaking-changes[]
+ assume `--abbrev-commit`. You may
override this option with `--no-abbrev-commit`.
log.date::
diff --git a/Documentation/config/merge.adoc b/Documentation/config/merge.adoc
index 86359f6..15a4c14 100644
--- a/Documentation/config/merge.adoc
+++ b/Documentation/config/merge.adoc
@@ -81,8 +81,18 @@
attributes" in linkgit:gitattributes[5].
`merge.stat`::
- Whether to print the diffstat between `ORIG_HEAD` and the merge result
- at the end of the merge. True by default.
+ What, if anything, to print between `ORIG_HEAD` and the merge result
+ at the end of the merge. Possible values are:
++
+--
+`false`;; Show nothing.
+`true`;; Show `git diff --diffstat --summary ORIG_HEAD`.
+`compact`;; Show `git diff --compact-summary ORIG_HEAD`.
+--
++
+but any unrecognised value (e.g., a value added by a future version of
+Git) is taken as `true` instead of triggering an error. Defaults to
+`true`.
`merge.autoStash`::
When set to `true`, automatically create a temporary stash entry
diff --git a/Documentation/config/pack.adoc b/Documentation/config/pack.adoc
index da52737..75402d5 100644
--- a/Documentation/config/pack.adoc
+++ b/Documentation/config/pack.adoc
@@ -155,6 +155,10 @@
commits contain certain types of direct renames. Default is
`true`.
+pack.usePathWalk::
+ Enable the `--path-walk` option by default for `git pack-objects`
+ processes. See linkgit:git-pack-objects[1] for full details.
+
pack.preferBitmapTips::
When selecting which commits will receive bitmaps, prefer a
commit at the tip of any reference that is a suffix of any value
diff --git a/Documentation/config/sendemail.adoc b/Documentation/config/sendemail.adoc
index 5ffcfc9..54f1248 100644
--- a/Documentation/config/sendemail.adoc
+++ b/Documentation/config/sendemail.adoc
@@ -1,32 +1,32 @@
sendemail.identity::
A configuration identity. When given, causes values in the
- 'sendemail.<identity>' subsection to take precedence over
- values in the 'sendemail' section. The default identity is
+ `sendemail.<identity>` subsection to take precedence over
+ values in the `sendemail` section. The default identity is
the value of `sendemail.identity`.
sendemail.smtpEncryption::
See linkgit:git-send-email[1] for description. Note that this
- setting is not subject to the 'identity' mechanism.
+ setting is not subject to the `identity` mechanism.
sendemail.smtpSSLCertPath::
Path to ca-certificates (either a directory or a single file).
Set it to an empty string to disable certificate verification.
sendemail.<identity>.*::
- Identity-specific versions of the 'sendemail.*' parameters
+ Identity-specific versions of the `sendemail.*` parameters
found below, taking precedence over those when this
identity is selected, through either the command-line or
`sendemail.identity`.
sendemail.multiEdit::
- If true (default), a single editor instance will be spawned to edit
+ If `true` (default), a single editor instance will be spawned to edit
files you have to edit (patches when `--annotate` is used, and the
- summary when `--compose` is used). If false, files will be edited one
+ summary when `--compose` is used). If `false`, files will be edited one
after the other, spawning a new editor each time.
sendemail.confirm::
Sets the default for whether to confirm before sending. Must be
- one of 'always', 'never', 'cc', 'compose', or 'auto'. See `--confirm`
+ one of `always`, `never`, `cc`, `compose`, or `auto`. See `--confirm`
in the linkgit:git-send-email[1] documentation for the meaning of these
values.
@@ -51,7 +51,7 @@
sendemail.aliasFileType::
Format of the file(s) specified in sendemail.aliasesFile. Must be
- one of 'mutt', 'mailrc', 'pine', 'elm', 'gnus', or 'sendmail'.
+ one of `mutt`, `mailrc`, `pine`, `elm`, `gnus`, or `sendmail`.
+
What an alias file in each format looks like can be found in
the documentation of the email program of the same name. The
@@ -101,7 +101,7 @@
sendemail.smtpBatchSize::
Number of messages to be sent per connection, after that a relogin
- will happen. If the value is 0 or undefined, send all messages in
+ will happen. If the value is `0` or undefined, send all messages in
one connection.
See also the `--batch-size` option of linkgit:git-send-email[1].
@@ -111,5 +111,5 @@
sendemail.forbidSendmailVariables::
To avoid common misconfiguration mistakes, linkgit:git-send-email[1]
- will abort with a warning if any configuration options for "sendmail"
+ will abort with a warning if any configuration options for `sendmail`
exist. Set this variable to bypass the check.
diff --git a/Documentation/diff-generate-patch.adoc b/Documentation/diff-generate-patch.adoc
index e5c813c..7b6cdd1 100644
--- a/Documentation/diff-generate-patch.adoc
+++ b/Documentation/diff-generate-patch.adoc
@@ -138,7 +138,7 @@
+
[synopsis]
index <hash>,<hash>..<hash>
-mode <mode>,<mode>`..`<mode>
+mode <mode>,<mode>..<mode>
new file mode <mode>
deleted file mode <mode>,<mode>
+
diff --git a/Documentation/git-cat-file.adoc b/Documentation/git-cat-file.adoc
index cde79ad..180d1ad 100644
--- a/Documentation/git-cat-file.adoc
+++ b/Documentation/git-cat-file.adoc
@@ -307,6 +307,11 @@
`objecttype`::
The type of the object (the same as `cat-file -t` reports).
+`objectmode`::
+ If the specified object has mode information (such as a tree or
+ index entry), the mode expressed as an octal integer. Otherwise,
+ empty string.
+
`objectsize`::
The size, in bytes, of the object (the same as `cat-file -s`
reports).
@@ -368,6 +373,14 @@
<object> SP ambiguous LF
------------
+If a name is specified that refers to a submodule entry in a tree and the
+target object does not exist in the repository, then `cat-file` will ignore
+any custom format and print (with the object ID of the submodule):
+
+------------
+<oid> SP submodule LF
+------------
+
If `--follow-symlinks` is used, and a symlink in the repository points
outside the repository, then `cat-file` will ignore any custom format
and print:
diff --git a/Documentation/git-diff.adoc b/Documentation/git-diff.adoc
index dec173a..272331a 100644
--- a/Documentation/git-diff.adoc
+++ b/Documentation/git-diff.adoc
@@ -14,7 +14,7 @@
git diff [<options>] [--merge-base] <commit> [<commit>...] <commit> [--] [<path>...]
git diff [<options>] <commit>...<commit> [--] [<path>...]
git diff [<options>] <blob> <blob>
-git diff [<options>] --no-index [--] <path> <path>
+git diff [<options>] --no-index [--] <path> <path> [<pathspec>...]
DESCRIPTION
-----------
@@ -31,14 +31,18 @@
further add to the index but you still haven't. You can
stage these changes by using linkgit:git-add[1].
-`git diff [<options>] --no-index [--] <path> <path>`::
+`git diff [<options>] --no-index [--] <path> <path> [<pathspec>...]`::
This form is to compare the given two paths on the
filesystem. You can omit the `--no-index` option when
running the command in a working tree controlled by Git and
at least one of the paths points outside the working tree,
or when running the command outside a working tree
- controlled by Git. This form implies `--exit-code`.
+ controlled by Git. This form implies `--exit-code`. If both
+ paths point to directories, additional pathspecs may be
+ provided. These will limit the files included in the
+ difference. All such pathspecs must be relative as they
+ apply to both sides of the diff.
`git diff [<options>] --cached [--merge-base] [<commit>] [--] [<path>...]`::
diff --git a/Documentation/git-merge.adoc b/Documentation/git-merge.adoc
index 12aa859..d53923c 100644
--- a/Documentation/git-merge.adoc
+++ b/Documentation/git-merge.adoc
@@ -9,7 +9,7 @@
SYNOPSIS
--------
[synopsis]
-git merge [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
+git merge [-n] [--stat] [--compact-summary] [--no-commit] [--squash] [--[no-]edit]
[--no-verify] [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
[--[no-]allow-unrelated-histories]
[--[no-]rerere-autoupdate] [-m <msg>] [-F <file>]
diff --git a/Documentation/git-pack-objects.adoc b/Documentation/git-pack-objects.adoc
index 7f69ae4..b1c5aa2 100644
--- a/Documentation/git-pack-objects.adoc
+++ b/Documentation/git-pack-objects.adoc
@@ -10,13 +10,13 @@
--------
[verse]
'git pack-objects' [-q | --progress | --all-progress] [--all-progress-implied]
- [--no-reuse-delta] [--delta-base-offset] [--non-empty]
- [--local] [--incremental] [--window=<n>] [--depth=<n>]
- [--revs [--unpacked | --all]] [--keep-pack=<pack-name>]
- [--cruft] [--cruft-expiration=<time>]
- [--stdout [--filter=<filter-spec>] | <base-name>]
- [--shallow] [--keep-true-parents] [--[no-]sparse]
- [--name-hash-version=<n>] < <object-list>
+ [--no-reuse-delta] [--delta-base-offset] [--non-empty]
+ [--local] [--incremental] [--window=<n>] [--depth=<n>]
+ [--revs [--unpacked | --all]] [--keep-pack=<pack-name>]
+ [--cruft] [--cruft-expiration=<time>]
+ [--stdout [--filter=<filter-spec>] | <base-name>]
+ [--shallow] [--keep-true-parents] [--[no-]sparse]
+ [--name-hash-version=<n>] [--path-walk] < <object-list>
DESCRIPTION
@@ -375,6 +375,17 @@
when writing reachability bitmap files with `--write-bitmap-index` and it
will be automatically changed to version `1`.
+--path-walk::
+ Perform compression by first organizing objects by path, then a
+ second pass that compresses across paths as normal. This has the
+ potential to improve delta compression especially in the presence
+ of filenames that cause collisions in Git's default name-hash
+ algorithm.
++
+Incompatible with `--delta-islands`, `--shallow`, or `--filter`. The
+`--use-bitmap-index` option will be ignored in the presence of
+`--path-walk.`
+
DELTA ISLANDS
-------------
diff --git a/Documentation/git-repack.adoc b/Documentation/git-repack.adoc
index e1cd75e..d12c498 100644
--- a/Documentation/git-repack.adoc
+++ b/Documentation/git-repack.adoc
@@ -11,7 +11,7 @@
[verse]
'git repack' [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-b] [-m]
[--window=<n>] [--depth=<n>] [--threads=<n>] [--keep-pack=<pack-name>]
- [--write-midx] [--name-hash-version=<n>]
+ [--write-midx] [--name-hash-version=<n>] [--path-walk]
DESCRIPTION
-----------
@@ -258,6 +258,9 @@
Provide this argument to the underlying `git pack-objects` process.
See linkgit:git-pack-objects[1] for full details.
+--path-walk::
+ Pass the `--path-walk` option to the underlying `git pack-objects`
+ process. See linkgit:git-pack-objects[1] for full details.
CONFIGURATION
-------------
diff --git a/Documentation/git-send-email.adoc b/Documentation/git-send-email.adoc
index 26fda63..7bd09c2 100644
--- a/Documentation/git-send-email.adoc
+++ b/Documentation/git-send-email.adoc
@@ -21,7 +21,7 @@
Patches can be specified as files, directories (which will send all
files in the directory), or directly as a revision list. In the
last case, any format accepted by linkgit:git-format-patch[1] can
-be passed to git send-email, as well as options understood by
+be passed to `git send-email`, as well as options understood by
linkgit:git-format-patch[1].
The header of the email is configurable via command-line options. If not
@@ -35,11 +35,11 @@
This is what linkgit:git-format-patch[1] generates. Most headers and MIME
formatting are ignored.
-2. The original format used by Greg Kroah-Hartman's 'send_lots_of_email.pl'
+2. The original format used by Greg Kroah-Hartman's `send_lots_of_email.pl`
script
+
-This format expects the first line of the file to contain the "Cc:" value
-and the "Subject:" of the message as the second line.
+This format expects the first line of the file to contain the `Cc:` value
+and the `Subject:` of the message as the second line.
OPTIONS
@@ -54,13 +54,13 @@
`sendemail.multiEdit`.
--bcc=<address>,...::
- Specify a "Bcc:" value for each email. Default is the value of
+ Specify a `Bcc:` value for each email. Default is the value of
`sendemail.bcc`.
+
This option may be specified multiple times.
--cc=<address>,...::
- Specify a starting "Cc:" value for each email.
+ Specify a starting `Cc:` value for each email.
Default is the value of `sendemail.cc`.
+
This option may be specified multiple times.
@@ -69,14 +69,14 @@
Invoke a text editor (see GIT_EDITOR in linkgit:git-var[1])
to edit an introductory message for the patch series.
+
-When `--compose` is used, git send-email will use the From, To, Cc, Bcc,
-Subject, Reply-To, and In-Reply-To headers specified in the message. If
-the body of the message (what you type after the headers and a blank
-line) only contains blank (or Git: prefixed) lines, the summary won't be
+When `--compose` is used, `git send-email` will use the `From`, `To`, `Cc`,
+`Bcc`, `Subject`, `Reply-To`, and `In-Reply-To` headers specified in the
+message. If the body of the message (what you type after the headers and a
+blank line) only contains blank (or `Git:` prefixed) lines, the summary won't be
sent, but the headers mentioned above will be used unless they are
removed.
+
-Missing From or In-Reply-To headers will be prompted for.
+Missing `From` or `In-Reply-To` headers will be prompted for.
+
See the CONFIGURATION section for `sendemail.multiEdit`.
@@ -85,13 +85,13 @@
the value of the `sendemail.from` configuration option is used. If
neither the command-line option nor `sendemail.from` are set, then the
user will be prompted for the value. The default for the prompt will be
- the value of GIT_AUTHOR_IDENT, or GIT_COMMITTER_IDENT if that is not
- set, as returned by "git var -l".
+ the value of `GIT_AUTHOR_IDENT`, or `GIT_COMMITTER_IDENT` if that is not
+ set, as returned by `git var -l`.
--reply-to=<address>::
Specify the address where replies from recipients should go to.
Use this if replies to messages should go to another address than what
- is specified with the --from parameter.
+ is specified with the `--from` parameter.
--in-reply-to=<identifier>::
Make the first mail (or all the mails with `--no-thread`) appear as a
@@ -112,14 +112,14 @@
[PATCH v2 2/3] New tests
[PATCH v2 3/3] Implementation
+
-Only necessary if --compose is also set. If --compose
+Only necessary if `--compose` is also set. If `--compose`
is not set, this will be prompted for.
--[no-]outlook-id-fix::
Microsoft Outlook SMTP servers discard the Message-ID sent via email and
assign a new random Message-ID, thus breaking threads.
+
-With `--outlook-id-fix`, 'git send-email' uses a mechanism specific to
+With `--outlook-id-fix`, `git send-email` uses a mechanism specific to
Outlook servers to learn the Message-ID the server assigned to fix the
threading. Use it only when you know that the server reports the
rewritten Message-ID the same way as Outlook servers do.
@@ -130,14 +130,14 @@
--subject=<string>::
Specify the initial subject of the email thread.
- Only necessary if --compose is also set. If --compose
+ Only necessary if `--compose` is also set. If `--compose`
is not set, this will be prompted for.
--to=<address>,...::
Specify the primary recipient of the emails generated. Generally, this
will be the upstream maintainer of the project involved. Default is the
value of the `sendemail.to` configuration value; if that is unspecified,
- and --to-cmd is not specified, this will be prompted for.
+ and `--to-cmd` is not specified, this will be prompted for.
+
This option may be specified multiple times.
@@ -145,30 +145,30 @@
When encountering a non-ASCII message or subject that does not
declare its encoding, add headers/quoting to indicate it is
encoded in <encoding>. Default is the value of the
- 'sendemail.assume8bitEncoding'; if that is unspecified, this
+ `sendemail.assume8bitEncoding`; if that is unspecified, this
will be prompted for if any non-ASCII files are encountered.
+
Note that no attempts whatsoever are made to validate the encoding.
--compose-encoding=<encoding>::
Specify encoding of compose message. Default is the value of the
- 'sendemail.composeEncoding'; if that is unspecified, UTF-8 is assumed.
+ `sendemail.composeEncoding`; if that is unspecified, UTF-8 is assumed.
--transfer-encoding=(7bit|8bit|quoted-printable|base64|auto)::
Specify the transfer encoding to be used to send the message over SMTP.
- 7bit will fail upon encountering a non-ASCII message. quoted-printable
+ `7bit` will fail upon encountering a non-ASCII message. `quoted-printable`
can be useful when the repository contains files that contain carriage
- returns, but makes the raw patch email file (as saved from a MUA) much
- harder to inspect manually. base64 is even more fool proof, but also
- even more opaque. auto will use 8bit when possible, and quoted-printable
- otherwise.
+ returns, but makes the raw patch email file (as saved from an MUA) much
+ harder to inspect manually. `base64` is even more fool proof, but also
+ even more opaque. `auto` will use `8bit` when possible, and
+ `quoted-printable` otherwise.
+
Default is the value of the `sendemail.transferEncoding` configuration
value; if that is unspecified, default to `auto`.
--xmailer::
--no-xmailer::
- Add (or prevent adding) the "X-Mailer:" header. By default,
+ Add (or prevent adding) the `X-Mailer:` header. By default,
the header is added, but it can be turned off by setting the
`sendemail.xmailer` configuration variable to `false`.
@@ -178,9 +178,9 @@
--envelope-sender=<address>::
Specify the envelope sender used to send the emails.
This is useful if your default address is not the address that is
- subscribed to a list. In order to use the 'From' address, set the
- value to "auto". If you use the sendmail binary, you must have
- suitable privileges for the -f parameter. Default is the value of the
+ subscribed to a list. In order to use the `From` address, set the
+ value to `auto`. If you use the `sendmail` binary, you must have
+ suitable privileges for the `-f` parameter. Default is the value of the
`sendemail.envelopeSender` configuration variable; if that is
unspecified, choosing the envelope sender is left to your MTA.
@@ -189,27 +189,27 @@
be sendmail-like; specifically, it must support the `-i` option.
The command will be executed in the shell if necessary. Default
is the value of `sendemail.sendmailCmd`. If unspecified, and if
- --smtp-server is also unspecified, git-send-email will search
- for `sendmail` in `/usr/sbin`, `/usr/lib` and $PATH.
+ `--smtp-server` is also unspecified, `git send-email` will search
+ for `sendmail` in `/usr/sbin`, `/usr/lib` and `$PATH`.
--smtp-encryption=<encryption>::
Specify in what way encrypting begins for the SMTP connection.
- Valid values are 'ssl' and 'tls'. Any other value reverts to plain
+ Valid values are `ssl` and `tls`. Any other value reverts to plain
(unencrypted) SMTP, which defaults to port 25.
Despite the names, both values will use the same newer version of TLS,
- but for historic reasons have these names. 'ssl' refers to "implicit"
+ but for historic reasons have these names. `ssl` refers to "implicit"
encryption (sometimes called SMTPS), that uses port 465 by default.
- 'tls' refers to "explicit" encryption (often known as STARTTLS),
+ `tls` refers to "explicit" encryption (often known as STARTTLS),
that uses port 25 by default. Other ports might be used by the SMTP
server, which are not the default. Commonly found alternative port for
- 'tls' and unencrypted is 587. You need to check your provider's
+ `tls` and unencrypted is 587. You need to check your provider's
documentation or your server configuration to make sure
for your own case. Default is the value of `sendemail.smtpEncryption`.
--smtp-domain=<FQDN>::
Specifies the Fully Qualified Domain Name (FQDN) used in the
HELO/EHLO command to the SMTP server. Some servers require the
- FQDN to match your IP address. If not set, git send-email attempts
+ FQDN to match your IP address. If not set, `git send-email` attempts
to determine your FQDN automatically. Default is the value of
`sendemail.smtpDomain`.
@@ -223,10 +223,10 @@
+
If at least one of the specified mechanisms matches the ones advertised by the
SMTP server and if it is supported by the utilized SASL library, the mechanism
-is used for authentication. If neither 'sendemail.smtpAuth' nor `--smtp-auth`
+is used for authentication. If neither `sendemail.smtpAuth` nor `--smtp-auth`
is specified, all mechanisms supported by the SASL library can be used. The
-special value 'none' maybe specified to completely disable authentication
-independently of `--smtp-user`
+special value `none` maybe specified to completely disable authentication
+independently of `--smtp-user`.
--smtp-pass[=<password>]::
Password for SMTP-AUTH. The argument is optional: If no
@@ -238,16 +238,16 @@
or on the command line. If a username has been specified (with
`--smtp-user` or a `sendemail.smtpUser`), but no password has been
specified (with `--smtp-pass` or `sendemail.smtpPass`), then
-a password is obtained using 'git-credential'.
+a password is obtained using linkgit:git-credential[1].
--no-smtp-auth::
- Disable SMTP authentication. Short hand for `--smtp-auth=none`
+ Disable SMTP authentication. Short hand for `--smtp-auth=none`.
--smtp-server=<host>::
If set, specifies the outgoing SMTP server to use (e.g.
`smtp.example.com` or a raw IP address). If unspecified, and if
`--sendmail-cmd` is also unspecified, the default is to search
- for `sendmail` in `/usr/sbin`, `/usr/lib` and $PATH if such a
+ for `sendmail` in `/usr/sbin`, `/usr/lib` and `$PATH` if such a
program is available, falling back to `localhost` otherwise.
+
For backward compatibility, this option can also specify a full pathname
@@ -260,7 +260,7 @@
Specifies a port different from the default port (SMTP
servers typically listen to smtp port 25, but may also listen to
submission port 587, or the common SSL smtp port 465);
- symbolic port names (e.g. "submission" instead of 587)
+ symbolic port names (e.g. `submission` instead of 587)
are also accepted. The port can also be set with the
`sendemail.smtpServerPort` configuration variable.
@@ -269,17 +269,17 @@
Default value can be specified by the `sendemail.smtpServerOption`
configuration option.
+
-The --smtp-server-option option must be repeated for each option you want
+The `--smtp-server-option` option must be repeated for each option you want
to pass to the server. Likewise, different lines in the configuration files
must be used for each option.
--smtp-ssl::
- Legacy alias for '--smtp-encryption ssl'.
+ Legacy alias for `--smtp-encryption ssl`.
--smtp-ssl-cert-path::
Path to a store of trusted CA certificates for SMTP SSL/TLS
certificate validation (either a directory that has been processed
- by 'c_rehash', or a single file containing one or more PEM format
+ by `c_rehash`, or a single file containing one or more PEM format
certificates concatenated together: see verify(1) -CAfile and
-CApath for more information on these). Set it to an empty string
to disable certificate verification. Defaults to the value of the
@@ -298,18 +298,18 @@
connection and authentication problems.
--batch-size=<num>::
- Some email servers (e.g. smtp.163.com) limit the number emails to be
+ Some email servers (e.g. 'smtp.163.com') limit the number of emails to be
sent per session (connection) and this will lead to a failure when
sending many messages. With this option, send-email will disconnect after
- sending $<num> messages and wait for a few seconds (see --relogin-delay)
- and reconnect, to work around such a limit. You may want to
- use some form of credential helper to avoid having to retype
- your password every time this happens. Defaults to the
+ sending _<num>_ messages and wait for a few seconds
+ (see `--relogin-delay`) and reconnect, to work around such a limit.
+ You may want to use some form of credential helper to avoid having to
+ retype your password every time this happens. Defaults to the
`sendemail.smtpBatchSize` configuration variable.
--relogin-delay=<int>::
- Waiting $<int> seconds before reconnecting to SMTP server. Used together
- with --batch-size option. Defaults to the `sendemail.smtpReloginDelay`
+ Waiting _<int>_ seconds before reconnecting to SMTP server. Used together
+ with `--batch-size` option. Defaults to the `sendemail.smtpReloginDelay`
configuration variable.
Automating
@@ -318,7 +318,7 @@
--no-to::
--no-cc::
--no-bcc::
- Clears any list of "To:", "Cc:", "Bcc:" addresses previously
+ Clears any list of `To:`, `Cc:`, `Bcc:` addresses previously
set via config.
--no-identity::
@@ -327,13 +327,13 @@
--to-cmd=<command>::
Specify a command to execute once per patch file which
- should generate patch file specific "To:" entries.
+ should generate patch file specific `To:` entries.
Output of this command must be single email address per line.
- Default is the value of 'sendemail.toCmd' configuration value.
+ Default is the value of `sendemail.toCmd` configuration value.
--cc-cmd=<command>::
Specify a command to execute once per patch file which
- should generate patch file specific "Cc:" entries.
+ should generate patch file specific `Cc:` entries.
Output of this command must be single email address per line.
Default is the value of `sendemail.ccCmd` configuration value.
@@ -341,7 +341,7 @@
Specify a command that is executed once per outgoing message
and output RFC 2822 style header lines to be inserted into
them. When the `sendemail.headerCmd` configuration variable is
- set, its value is always used. When --header-cmd is provided
+ set, its value is always used. When `--header-cmd` is provided
at the command line, its value takes precedence over the
`sendemail.headerCmd` configuration variable.
@@ -350,7 +350,7 @@
--[no-]chain-reply-to::
If this is set, each email will be sent as a reply to the previous
- email sent. If disabled with "--no-chain-reply-to", all emails after
+ email sent. If disabled with `--no-chain-reply-to`, all emails after
the first will be sent as replies to the first email sent. When using
this, it is recommended that the first file given be an overview of the
entire patch series. Disabled by default, but the `sendemail.chainReplyTo`
@@ -358,79 +358,80 @@
--identity=<identity>::
A configuration identity. When given, causes values in the
- 'sendemail.<identity>' subsection to take precedence over
- values in the 'sendemail' section. The default identity is
+ `sendemail.<identity>` subsection to take precedence over
+ values in the `sendemail` section. The default identity is
the value of `sendemail.identity`.
--[no-]signed-off-by-cc::
- If this is set, add emails found in the `Signed-off-by` trailer or Cc: lines to the
- cc list. Default is the value of `sendemail.signedOffByCc` configuration
- value; if that is unspecified, default to --signed-off-by-cc.
+ If this is set, add emails found in the `Signed-off-by` trailer or `Cc:`
+ lines to the cc list. Default is the value of `sendemail.signedOffByCc`
+ configuration value; if that is unspecified, default to
+ `--signed-off-by-cc`.
--[no-]cc-cover::
- If this is set, emails found in Cc: headers in the first patch of
+ If this is set, emails found in `Cc:` headers in the first patch of
the series (typically the cover letter) are added to the cc list
- for each email set. Default is the value of 'sendemail.ccCover'
- configuration value; if that is unspecified, default to --no-cc-cover.
+ for each email set. Default is the value of `sendemail.ccCover`
+ configuration value; if that is unspecified, default to `--no-cc-cover`.
--[no-]to-cover::
- If this is set, emails found in To: headers in the first patch of
+ If this is set, emails found in `To:` headers in the first patch of
the series (typically the cover letter) are added to the to list
- for each email set. Default is the value of 'sendemail.toCover'
- configuration value; if that is unspecified, default to --no-to-cover.
+ for each email set. Default is the value of `sendemail.toCover`
+ configuration value; if that is unspecified, default to `--no-to-cover`.
--suppress-cc=<category>::
Specify an additional category of recipients to suppress the
auto-cc of:
+
--
-- 'author' will avoid including the patch author.
-- 'self' will avoid including the sender.
-- 'cc' will avoid including anyone mentioned in Cc lines in the patch header
- except for self (use 'self' for that).
-- 'bodycc' will avoid including anyone mentioned in Cc lines in the
- patch body (commit message) except for self (use 'self' for that).
-- 'sob' will avoid including anyone mentioned in the Signed-off-by trailers except
- for self (use 'self' for that).
-- 'misc-by' will avoid including anyone mentioned in Acked-by,
+- `author` will avoid including the patch author.
+- `self` will avoid including the sender.
+- `cc` will avoid including anyone mentioned in Cc lines in the patch header
+ except for self (use `self` for that).
+- `bodycc` will avoid including anyone mentioned in Cc lines in the
+ patch body (commit message) except for self (use `self` for that).
+- `sob` will avoid including anyone mentioned in the Signed-off-by trailers except
+ for self (use `self` for that).
+- `misc-by` will avoid including anyone mentioned in Acked-by,
Reviewed-by, Tested-by and other "-by" lines in the patch body,
- except Signed-off-by (use 'sob' for that).
-- 'cccmd' will avoid running the --cc-cmd.
-- 'body' is equivalent to 'sob' + 'bodycc' + 'misc-by'.
-- 'all' will suppress all auto cc values.
+ except Signed-off-by (use `sob` for that).
+- `cccmd` will avoid running the --cc-cmd.
+- `body` is equivalent to `sob` + `bodycc` + `misc-by`.
+- `all` will suppress all auto cc values.
--
+
Default is the value of `sendemail.suppressCc` configuration value; if
-that is unspecified, default to 'self' if --suppress-from is
-specified, as well as 'body' if --no-signed-off-cc is specified.
+that is unspecified, default to `self` if `--suppress-from` is
+specified, as well as `body` if `--no-signed-off-cc` is specified.
--[no-]suppress-from::
- If this is set, do not add the From: address to the cc: list.
+ If this is set, do not add the `From:` address to the `Cc:` list.
Default is the value of `sendemail.suppressFrom` configuration
- value; if that is unspecified, default to --no-suppress-from.
+ value; if that is unspecified, default to `--no-suppress-from`.
--[no-]thread::
- If this is set, the In-Reply-To and References headers will be
+ If this is set, the `In-Reply-To` and `References` headers will be
added to each email sent. Whether each mail refers to the
- previous email (`deep` threading per 'git format-patch'
+ previous email (`deep` threading per `git format-patch`
wording) or to the first email (`shallow` threading) is
- governed by "--[no-]chain-reply-to".
+ governed by `--[no-]chain-reply-to`.
+
-If disabled with "--no-thread", those headers will not be added
-(unless specified with --in-reply-to). Default is the value of the
+If disabled with `--no-thread`, those headers will not be added
+(unless specified with `--in-reply-to`). Default is the value of the
`sendemail.thread` configuration value; if that is unspecified,
-default to --thread.
+default to `--thread`.
+
It is up to the user to ensure that no In-Reply-To header already
-exists when 'git send-email' is asked to add it (especially note that
-'git format-patch' can be configured to do the threading itself).
+exists when `git send-email` is asked to add it (especially note that
+`git format-patch` can be configured to do the threading itself).
Failure to do so may not produce the expected result in the
recipient's MUA.
--[no-]mailmap::
Use the mailmap file (see linkgit:gitmailmap[5]) to map all
addresses to their canonical real name and email address. Additional
- mailmap data specific to git-send-email may be provided using the
+ mailmap data specific to `git send-email` may be provided using the
`sendemail.mailmap.file` or `sendemail.mailmap.blob` configuration
values. Defaults to `sendemail.mailmap`.
@@ -441,17 +442,17 @@
Confirm just before sending:
+
--
-- 'always' will always confirm before sending
-- 'never' will never confirm before sending
-- 'cc' will confirm before sending when send-email has automatically
- added addresses from the patch to the Cc list
-- 'compose' will confirm before sending the first message when using --compose.
-- 'auto' is equivalent to 'cc' + 'compose'
+- `always` will always confirm before sending.
+- `never` will never confirm before sending.
+- `cc` will confirm before sending when send-email has automatically
+ added addresses from the patch to the Cc list.
+- `compose` will confirm before sending the first message when using --compose.
+- `auto` is equivalent to `cc` + `compose`.
--
+
Default is the value of `sendemail.confirm` configuration value; if that
-is unspecified, default to 'auto' unless any of the suppress options
-have been specified, in which case default to 'compose'.
+is unspecified, default to `auto` unless any of the suppress options
+have been specified, in which case default to `compose`.
--dry-run::
Do everything except actually send the emails.
@@ -460,10 +461,10 @@
When an argument may be understood either as a reference or as a file name,
choose to understand it as a format-patch argument (`--format-patch`)
or as a file name (`--no-format-patch`). By default, when such a conflict
- occurs, git send-email will fail.
+ occurs, `git send-email` will fail.
--quiet::
- Make git-send-email less verbose. One line per email should be
+ Make `git send-email` less verbose. One line per email should be
all that is output.
--[no-]validate::
@@ -474,7 +475,7 @@
* Invoke the sendemail-validate hook if present (see linkgit:githooks[5]).
* Warn of patches that contain lines longer than
998 characters unless a suitable transfer encoding
- ('auto', 'base64', or 'quoted-printable') is used;
+ (`auto`, `base64`, or `quoted-printable`) is used;
this is due to SMTP limits as described by
https://www.ietf.org/rfc/rfc5322.txt.
--
@@ -493,13 +494,13 @@
Instead of the normal operation, dump the shorthand alias names from
the configured alias file(s), one per line in alphabetical order. Note
that this only includes the alias name and not its expanded email addresses.
- See 'sendemail.aliasesFile' for more information about aliases.
+ See `sendemail.aliasesFile` for more information about aliases.
--translate-aliases::
Instead of the normal operation, read from standard input and
interpret each line as an email alias. Translate it according to the
configured alias file(s). Output each translated name and email
- address to standard output, one per line. See 'sendemail.aliasFile'
+ address to standard output, one per line. See `sendemail.aliasFile`
for more information about aliases.
CONFIGURATION
@@ -524,15 +525,18 @@
smtpServerPort = 587
----
+Gmail does not allow using your regular password for `git send-email`.
If you have multi-factor authentication set up on your Gmail account, you can
-generate an app-specific password for use with 'git send-email'. Visit
+generate an app-specific password for use with `git send-email`. Visit
https://security.google.com/settings/security/apppasswords to create it.
-You can also use OAuth2.0 authentication with Gmail. `OAUTHBEARER` and
-`XOAUTH2` are common methods used for this type of authentication. Gmail
-supports both of them. As an example, if you want to use `OAUTHBEARER`, edit
-your `~/.gitconfig` file and add `smtpAuth = OAUTHBEARER` to your account
-settings:
+Alternatively, instead of using an app-specific password, you can use
+OAuth2.0 authentication with Gmail. OAuth2.0 is more secure than
+app-specific passwords, and works regardless of whether you have multi-factor
+authentication set up. `OAUTHBEARER` and `XOAUTH2` are common mechanisms used
+for this type of authentication. Gmail supports both of them. As an example,
+if you want to use `OAUTHBEARER`, edit your `~/.gitconfig` file and add
+`smtpAuth = OAUTHBEARER` to your account settings:
----
[sendemail]
@@ -543,11 +547,15 @@
smtpAuth = OAUTHBEARER
----
+Another alternative is using a tool developed by Google known as
+https://github.com/google/gmail-oauth2-tools/tree/master/go/sendgmail[sendgmail]
+to send emails using `git send-email`.
+
Use Microsoft Outlook as the SMTP Server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unlike Gmail, Microsoft Outlook no longer supports app-specific passwords.
Therefore, OAuth2.0 authentication must be used for Outlook. Also, it only
-supports `XOAUTH2` authentication method.
+supports `XOAUTH2` authentication mechanism.
Edit `~/.gitconfig` to specify your account settings for Outlook and use its
SMTP server with `git send-email`:
@@ -579,8 +587,7 @@
If you are using OAuth2.0 authentication, you need to use an access token in
place of a password when prompted. Various OAuth2.0 token generators are
-available online. Community maintained credential helpers for Gmail and Outlook
-are also available:
+available online. Community maintained credential helpers are also available:
- https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail]
(cross platform, dedicated helper for authenticating Gmail accounts)
@@ -588,14 +595,24 @@
- https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook]
(cross platform, dedicated helper for authenticating Microsoft Outlook accounts)
+ - https://github.com/AdityaGarg8/git-credential-email[git-credential-yahoo]
+ (cross platform, dedicated helper for authenticating Yahoo accounts)
+
You can also see linkgit:gitcredentials[7] for more OAuth based authentication
helpers.
Note: the following core Perl modules that may be installed with your
distribution of Perl are required:
-MIME::Base64, MIME::QuotedPrint, Net::Domain and Net::SMTP.
+
+https://metacpan.org/pod/MIME::Base64[MIME::Base64],
+https://metacpan.org/pod/MIME::QuotedPrint[MIME::QuotedPrint],
+https://metacpan.org/pod/Net::Domain[Net::Domain] and
+https://metacpan.org/pod/Net::SMTP[Net::SMTP].
+
These additional Perl modules are also required:
-Authen::SASL and Mail::Address.
+
+https://metacpan.org/pod/Authen::SASL[Authen::SASL] and
+https://metacpan.org/pod/Mail::Address[Mail::Address].
SEE ALSO
diff --git a/Documentation/git-stash.adoc b/Documentation/git-stash.adoc
index 1a5177f..e5e6c9d 100644
--- a/Documentation/git-stash.adoc
+++ b/Documentation/git-stash.adoc
@@ -23,6 +23,8 @@
'git stash' clear
'git stash' create [<message>]
'git stash' store [(-m | --message) <message>] [-q | --quiet] <commit>
+'git stash' export (--print | --to-ref <ref>) [<stash>...]
+'git stash' import <commit>
DESCRIPTION
-----------
@@ -154,6 +156,18 @@
reflog. This is intended to be useful for scripts. It is
probably not the command you want to use; see "push" above.
+export ( --print | --to-ref <ref> ) [<stash>...]::
+
+ Export the specified stashes, or all of them if none are specified, to
+ a chain of commits which can be transferred using the normal fetch and
+ push mechanisms, then imported using the `import` subcommand.
+
+import <commit>::
+
+ Import the specified stashes from the specified commit, which must have been
+ created by `export`, and add them to the list of stashes. To replace the
+ existing stashes, use `clear` first.
+
OPTIONS
-------
-a::
@@ -242,6 +256,19 @@
+
Quiet, suppress feedback messages.
+--print::
+ This option is only valid for the `export` command.
++
+Create the chain of commits representing the exported stashes without
+storing it anywhere in the ref namespace and print the object ID to
+standard output. This is designed for scripts.
+
+--to-ref::
+ This option is only valid for the `export` command.
++
+Create the chain of commits representing the exported stashes and store
+it to the specified ref.
+
\--::
This option is only valid for `push` command.
+
@@ -259,7 +286,7 @@
<stash>::
This option is only valid for `apply`, `branch`, `drop`, `pop`,
- `show` commands.
+ `show`, and `export` commands.
+
A reference of the form `stash@{<revision>}`. When no `<stash>` is
given, the latest stash is assumed (that is, `stash@{0}`).
diff --git a/Documentation/git-whatchanged.adoc b/Documentation/git-whatchanged.adoc
index 8e55e0b..d214840 100644
--- a/Documentation/git-whatchanged.adoc
+++ b/Documentation/git-whatchanged.adoc
@@ -8,8 +8,14 @@
SYNOPSIS
--------
-[verse]
-'git whatchanged' <option>...
+[synopsis]
+git whatchanged <option>...
+
+WARNING
+-------
+`git whatchanged` has been deprecated and is scheduled for removal in
+a future version of Git, as it is merely `git log` with different
+default; `whatchanged` is not even shorter to type than `log --raw`.
DESCRIPTION
-----------
diff --git a/Documentation/gitcredentials.adoc b/Documentation/gitcredentials.adoc
index b49923d..3337bb4 100644
--- a/Documentation/gitcredentials.adoc
+++ b/Documentation/gitcredentials.adoc
@@ -133,10 +133,6 @@
- https://github.com/hickford/git-credential-oauth[git-credential-oauth] (cross platform, included in many Linux distributions)
- - https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail] (cross platform, dedicated helper to authenticate Gmail accounts for linkgit:git-send-email[1])
-
- - https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook] (cross platform, dedicated helper to authenticate Microsoft Outlook accounts for linkgit:git-send-email[1])
-
CREDENTIAL CONTEXTS
-------------------
diff --git a/Documentation/gitprotocol-v2.adoc b/Documentation/gitprotocol-v2.adoc
index 5598c93..9a57005 100644
--- a/Documentation/gitprotocol-v2.adoc
+++ b/Documentation/gitprotocol-v2.adoc
@@ -54,7 +54,7 @@
`version=2` through the respective side-channel for the transport being
used which inevitably sets `GIT_PROTOCOL`. More information can be
found in linkgit:gitprotocol-pack[5] and linkgit:gitprotocol-http[5], as well as the
-`GIT_PROTOCOL` definition in `git.txt`. In all cases the
+`GIT_PROTOCOL` definition in linkgit:git[1]. In all cases the
response from the server is the capability advertisement.
Git Transport
@@ -99,7 +99,7 @@
linkgit:git-upload-pack[1].
The server may need to be configured to pass this header's contents via
-the `GIT_PROTOCOL` variable. See the discussion in `git-http-backend.txt`.
+the `GIT_PROTOCOL` variable. See the discussion in linkgit:git-http-backend[1].
Capability Advertisement
------------------------
diff --git a/Documentation/merge-options.adoc b/Documentation/merge-options.adoc
index 078f4f6..95ef491 100644
--- a/Documentation/merge-options.adoc
+++ b/Documentation/merge-options.adoc
@@ -113,6 +113,9 @@
With `-n` or `--no-stat` do not show a diffstat at the end of the
merge.
+`--compact-summary`::
+ Show a compact-summary at the end of the merge.
+
`--squash`::
`--no-squash`::
Produce the working tree and index state as if a real merge
diff --git a/Documentation/meson.build b/Documentation/meson.build
index 1433acf..2fe1a13 100644
--- a/Documentation/meson.build
+++ b/Documentation/meson.build
@@ -158,7 +158,6 @@
'git-verify-tag.adoc' : 1,
'git-version.adoc' : 1,
'git-web--browse.adoc' : 1,
- 'git-whatchanged.adoc' : 1,
'git-worktree.adoc' : 1,
'git-write-tree.adoc' : 1,
'git.adoc' : 1,
@@ -207,6 +206,7 @@
manpages_breaking_changes = {
'git-pack-redundant.adoc' : 1,
+ 'git-whatchanged.adoc' : 1,
}
if not get_option('breaking_changes')
diff --git a/Documentation/pretty-options.adoc b/Documentation/pretty-options.adoc
index 23888cd..b36e96a 100644
--- a/Documentation/pretty-options.adoc
+++ b/Documentation/pretty-options.adoc
@@ -62,7 +62,12 @@
--notes[=<ref>]::
Show the notes (see linkgit:git-notes[1]) that annotate the
commit, when showing the commit log message. This is the default
+ifndef::with-breaking-changes[]
for `git log`, `git show` and `git whatchanged` commands when
+endif::with-breaking-changes[]
+ifdef::with-breaking-changes[]
+ for `git log` and `git show` commands when
+endif::with-breaking-changes[]
there is no `--pretty`, `--format`, or `--oneline` option given
on the command line.
+
diff --git a/Documentation/rev-list-options.adoc b/Documentation/rev-list-options.adoc
index d38875e..ae87656 100644
--- a/Documentation/rev-list-options.adoc
+++ b/Documentation/rev-list-options.adoc
@@ -1100,8 +1100,13 @@
ifdef::git-rev-list[]
Using these options, linkgit:git-rev-list[1] will act similar to the
-more specialized family of commit log tools: linkgit:git-log[1],
-linkgit:git-show[1], and linkgit:git-whatchanged[1]
+more specialized family of commit log tools:
+ifndef::with-breaking-changes[]
+linkgit:git-log[1], linkgit:git-show[1], and linkgit:git-whatchanged[1].
+endif::with-breaking-changes[]
+ifdef::with-breaking-changes[]
+linkgit:git-log[1] and linkgit:git-show[1].
+endif::with-breaking-changes[]
endif::git-rev-list[]
include::pretty-options.adoc[]
diff --git a/Documentation/technical/api-path-walk.adoc b/Documentation/technical/api-path-walk.adoc
index 3e08921..34c905e 100644
--- a/Documentation/technical/api-path-walk.adoc
+++ b/Documentation/technical/api-path-walk.adoc
@@ -56,6 +56,14 @@
the revision walk so that the walk emits commits marked with the
`UNINTERESTING` flag.
+`edge_aggressive`::
+ For performance reasons, usually only the boundary commits are
+ explored to find UNINTERESTING objects. However, in the case of
+ shallow clones it can be helpful to mark all trees and blobs
+ reachable from UNINTERESTING tip commits as UNINTERESTING. This
+ matches the behavior of `--objects-edge-aggressive` in the
+ revision API.
+
`pl`::
This pattern list pointer allows focusing the path-walk search to
a set of patterns, only emitting paths that match the given
@@ -69,4 +77,5 @@
See example usages in:
`t/helper/test-path-walk.c`,
+ `builtin/pack-objects.c`,
`builtin/backfill.c`
diff --git a/Documentation/technical/build-systems.adoc b/Documentation/technical/build-systems.adoc
index d9dafb4..3c5237b 100644
--- a/Documentation/technical/build-systems.adoc
+++ b/Documentation/technical/build-systems.adoc
@@ -32,7 +32,10 @@
- OpenBSD
The platforms which must be supported by the tool should be aligned with our
-[platform support policy](platform-support.txt).
+platform support policy (see platform-support.adoc).
+// once we lose AsciiDoc compatibility, we can start writing the above as:
+// xref:platform-support.adoc#platform-support-policy[platform support policy]
+// or something like that, but until then....
=== Auto-detection of supported features
diff --git a/Documentation/technical/sparse-checkout.adoc b/Documentation/technical/sparse-checkout.adoc
index 8202172..0f750ef 100644
--- a/Documentation/technical/sparse-checkout.adoc
+++ b/Documentation/technical/sparse-checkout.adoc
@@ -440,7 +440,7 @@
* blame (only matters when one or more -C flags are passed)
* and annotate
* log
- * whatchanged
+ * whatchanged (may not exist anymore)
* ls-files
* diff-index
* diff-tree
diff --git a/Documentation/user-manual.adoc b/Documentation/user-manual.adoc
index d2b478a..7124345 100644
--- a/Documentation/user-manual.adoc
+++ b/Documentation/user-manual.adoc
@@ -4240,7 +4240,7 @@
- an entry in `BUILTIN_OBJECTS` in the `Makefile`.
Sometimes, more than one builtin is contained in one source file. For
-example, `cmd_whatchanged()` and `cmd_log()` both reside in `builtin/log.c`,
+example, `cmd_show()` and `cmd_log()` both reside in `builtin/log.c`,
since they share quite a bit of code. In that case, the commands which are
_not_ named like the `.c` file in which they live have to be listed in
`BUILT_INS` in the `Makefile`.
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 5d17e1e..63463c8 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,6 +1,6 @@
#!/bin/sh
-DEF_VER=v2.50.0
+DEF_VER=v2.50.GIT
LF='
'
diff --git a/RelNotes b/RelNotes
index eaaaf87..48f1577 120000
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes/2.50.0.adoc
\ No newline at end of file
+Documentation/RelNotes/2.51.0.adoc
\ No newline at end of file
diff --git a/builtin/am.c b/builtin/am.c
index e32a3b4..a800003 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1000,7 +1000,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
if (!patch_format) {
fprintf_ln(stderr, _("Patch format detection failed."));
- exit(128);
+ die(NULL);
}
if (mkdir(state->dir, 0777) < 0 && errno != EEXIST)
@@ -1178,7 +1178,7 @@ static void NORETURN die_user_resolve(const struct am_state *state)
strbuf_release(&sb);
}
- exit(128);
+ die(NULL);
}
/**
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 67a5ff2..4b23fce 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -275,6 +275,7 @@ struct expand_data {
struct object_id oid;
enum object_type type;
unsigned long size;
+ unsigned short mode;
off_t disk_size;
const char *rest;
struct object_id delta_base_oid;
@@ -306,6 +307,7 @@ struct expand_data {
*/
unsigned skip_object_info : 1;
};
+#define EXPAND_DATA_INIT { .mode = S_IFINVALID }
static int is_atom(const char *atom, const char *s, int slen)
{
@@ -345,6 +347,9 @@ static int expand_atom(struct strbuf *sb, const char *atom, int len,
else
strbuf_addstr(sb,
oid_to_hex(&data->delta_base_oid));
+ } else if (is_atom("objectmode", atom, len)) {
+ if (!data->mark_query && !(S_IFINVALID == data->mode))
+ strbuf_addf(sb, "%06o", data->mode);
} else
return 0;
return 1;
@@ -491,7 +496,10 @@ static void batch_object_write(const char *obj_name,
&data->oid, &data->info,
OBJECT_INFO_LOOKUP_REPLACE);
if (ret < 0) {
- report_object_status(opt, obj_name, &data->oid, "missing");
+ if (data->mode == S_IFGITLINK)
+ report_object_status(opt, oid_to_hex(&data->oid), &data->oid, "submodule");
+ else
+ report_object_status(opt, obj_name, &data->oid, "missing");
return;
}
@@ -613,6 +621,7 @@ static void batch_one_object(const char *obj_name,
goto out;
}
+ data->mode = ctx.mode;
batch_object_write(obj_name, scratch, opt, data, NULL, 0);
out:
@@ -866,7 +875,7 @@ static int batch_objects(struct batch_options *opt)
{
struct strbuf input = STRBUF_INIT;
struct strbuf output = STRBUF_INIT;
- struct expand_data data;
+ struct expand_data data = EXPAND_DATA_INIT;
int save_warning;
int retval = 0;
@@ -875,7 +884,6 @@ static int batch_objects(struct batch_options *opt)
* object_info to be handed to oid_object_info_extended for each
* object.
*/
- memset(&data, 0, sizeof(data));
data.mark_query = 1;
expand_format(&output,
opt->format ? opt->format : DEFAULT_FORMAT,
diff --git a/builtin/checkout.c b/builtin/checkout.c
index d185982..536192d 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -838,7 +838,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
init_tree_desc(&trees[0], &tree->object.oid,
tree->buffer, tree->size);
if (parse_tree(new_tree) < 0)
- exit(128);
+ die(NULL);
tree = new_tree;
init_tree_desc(&trees[1], &tree->object.oid,
tree->buffer, tree->size);
@@ -913,7 +913,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
work,
old_tree);
if (ret < 0)
- exit(128);
+ die(NULL);
ret = reset_tree(new_tree,
opts, 0,
writeout_error, new_branch_info);
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index a783a86..ee48980 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -311,6 +311,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,
while (strbuf_getline(&buf, stdin) != EOF) {
if (read_one_commit(&commits, progress, buf.buf)) {
result = 1;
+ stop_progress(&progress);
goto cleanup;
}
}
diff --git a/builtin/diff.c b/builtin/diff.c
index fa96380..c6231ed 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -35,7 +35,7 @@ static const char builtin_diff_usage[] =
" or: git diff [<options>] [--merge-base] <commit> [<commit>...] <commit> [--] [<path>...]\n"
" or: git diff [<options>] <commit>...<commit> [--] [<path>...]\n"
" or: git diff [<options>] <blob> <blob>\n"
-" or: git diff [<options>] --no-index [--] <path> <path>"
+" or: git diff [<options>] --no-index [--] <path> <path> [<pathspec>...]"
"\n"
COMMON_DIFF_OPTIONS_HELP;
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index d07eec9..d9e42ba 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -274,8 +274,10 @@ int cmd_fetch_pack(int argc,
}
close(fd[0]);
close(fd[1]);
- if (finish_connect(conn))
- return 1;
+ if (finish_connect(conn)) {
+ ret = 1;
+ goto cleanup;
+ }
ret = !fetched_refs;
@@ -291,6 +293,7 @@ int cmd_fetch_pack(int argc,
printf("%s %s\n",
oid_to_hex(&ref->old_oid), ref->name);
+cleanup:
for (size_t i = 0; i < nr_sought; i++)
free_one_ref(sought_to_free[i]);
free(sought_to_free);
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 40a0e8d..d48262b 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -992,7 +992,7 @@ static int update_local_ref(struct ref *ref,
fast_forward = repo_in_merge_bases(the_repository, current,
updated);
if (fast_forward < 0)
- exit(128);
+ die(NULL);
forced_updates_ms += (getnanotime() - t_before) / 1000000;
} else {
fast_forward = 1;
diff --git a/builtin/gc.c b/builtin/gc.c
index 7dc94f2..845876f 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -251,7 +251,24 @@ static enum schedule_priority parse_schedule(const char *value)
return SCHEDULE_NONE;
}
+enum maintenance_task_label {
+ TASK_PREFETCH,
+ TASK_LOOSE_OBJECTS,
+ TASK_INCREMENTAL_REPACK,
+ TASK_GC,
+ TASK_COMMIT_GRAPH,
+ TASK_PACK_REFS,
+ TASK_REFLOG_EXPIRE,
+ TASK_WORKTREE_PRUNE,
+ TASK_RERERE_GC,
+
+ /* Leave as final value */
+ TASK__COUNT
+};
+
struct maintenance_run_opts {
+ enum maintenance_task_label *tasks;
+ size_t tasks_nr, tasks_alloc;
int auto_flag;
int detach;
int quiet;
@@ -261,6 +278,11 @@ struct maintenance_run_opts {
.detach = -1, \
}
+static void maintenance_run_opts_release(struct maintenance_run_opts *opts)
+{
+ free(opts->tasks);
+}
+
static int pack_refs_condition(UNUSED struct gc_config *cfg)
{
/*
@@ -796,22 +818,14 @@ static int report_last_gc_error(void)
return ret;
}
-static void gc_before_repack(struct maintenance_run_opts *opts,
- struct gc_config *cfg)
+static int gc_foreground_tasks(struct maintenance_run_opts *opts,
+ struct gc_config *cfg)
{
- /*
- * We may be called twice, as both the pre- and
- * post-daemonized phases will call us, but running these
- * commands more than once is pointless and wasteful.
- */
- static int done = 0;
- if (done++)
- return;
-
if (cfg->pack_refs && maintenance_task_pack_refs(opts, cfg))
- die(FAILED_RUN, "pack-refs");
+ return error(FAILED_RUN, "pack-refs");
if (cfg->prune_reflogs && maintenance_task_reflog_expire(opts, cfg))
- die(FAILED_RUN, "reflog");
+ return error(FAILED_RUN, "reflog");
+ return 0;
}
int cmd_gc(int argc,
@@ -820,12 +834,12 @@ int cmd_gc(int argc,
struct repository *repo UNUSED)
{
int aggressive = 0;
- int quiet = 0;
int force = 0;
const char *name;
pid_t pid;
int daemonized = 0;
int keep_largest_pack = -1;
+ int skip_foreground_tasks = 0;
timestamp_t dummy;
struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT;
struct gc_config cfg = GC_CONFIG_INIT;
@@ -833,7 +847,7 @@ int cmd_gc(int argc,
const char *prune_expire_arg = prune_expire_sentinel;
int ret;
struct option builtin_gc_options[] = {
- OPT__QUIET(&quiet, N_("suppress progress reporting")),
+ OPT__QUIET(&opts.quiet, N_("suppress progress reporting")),
{
.type = OPTION_STRING,
.long_name = "prune",
@@ -858,6 +872,8 @@ int cmd_gc(int argc,
N_("repack all other packs except the largest pack")),
OPT_STRING(0, "expire-to", &cfg.repack_expire_to, N_("dir"),
N_("pack prefix to store a pack containing pruned objects")),
+ OPT_HIDDEN_BOOL(0, "skip-foreground-tasks", &skip_foreground_tasks,
+ N_("skip maintenance tasks typically done in the foreground")),
OPT_END()
};
@@ -893,7 +909,7 @@ int cmd_gc(int argc,
if (cfg.aggressive_window > 0)
strvec_pushf(&repack, "--window=%d", cfg.aggressive_window);
}
- if (quiet)
+ if (opts.quiet)
strvec_push(&repack, "-q");
if (opts.auto_flag) {
@@ -908,7 +924,7 @@ int cmd_gc(int argc,
goto out;
}
- if (!quiet) {
+ if (!opts.quiet) {
if (opts.detach > 0)
fprintf(stderr, _("Auto packing the repository in background for optimum performance.\n"));
else
@@ -941,13 +957,16 @@ int cmd_gc(int argc,
goto out;
}
- if (lock_repo_for_gc(force, &pid)) {
- ret = 0;
- goto out;
- }
+ if (!skip_foreground_tasks) {
+ if (lock_repo_for_gc(force, &pid)) {
+ ret = 0;
+ goto out;
+ }
- gc_before_repack(&opts, &cfg); /* dies on failure */
- delete_tempfile(&pidfile);
+ if (gc_foreground_tasks(&opts, &cfg) < 0)
+ die(NULL);
+ delete_tempfile(&pidfile);
+ }
/*
* failure to daemonize is ok, we'll continue
@@ -976,7 +995,8 @@ int cmd_gc(int argc,
free(path);
}
- gc_before_repack(&opts, &cfg);
+ if (opts.detach <= 0 && !skip_foreground_tasks)
+ gc_foreground_tasks(&opts, &cfg);
if (!repository_format_precious_objects) {
struct child_process repack_cmd = CHILD_PROCESS_INIT;
@@ -993,7 +1013,7 @@ int cmd_gc(int argc,
strvec_pushl(&prune_cmd.args, "prune", "--expire", NULL);
/* run `git prune` even if using cruft packs */
strvec_push(&prune_cmd.args, cfg.prune_expire);
- if (quiet)
+ if (opts.quiet)
strvec_push(&prune_cmd.args, "--no-progress");
if (repo_has_promisor_remote(the_repository))
strvec_push(&prune_cmd.args,
@@ -1021,7 +1041,7 @@ int cmd_gc(int argc,
if (the_repository->settings.gc_write_commit_graph == 1)
write_commit_graph_reachable(the_repository->objects->odb,
- !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
+ !opts.quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
NULL);
if (opts.auto_flag && too_many_loose_objects(&cfg))
@@ -1035,6 +1055,7 @@ int cmd_gc(int argc,
}
out:
+ maintenance_run_opts_release(&opts);
gc_config_release(&cfg);
return 0;
}
@@ -1211,8 +1232,14 @@ static int maintenance_task_prefetch(struct maintenance_run_opts *opts,
return 0;
}
-static int maintenance_task_gc(struct maintenance_run_opts *opts,
- struct gc_config *cfg UNUSED)
+static int maintenance_task_gc_foreground(struct maintenance_run_opts *opts,
+ struct gc_config *cfg)
+{
+ return gc_foreground_tasks(opts, cfg);
+}
+
+static int maintenance_task_gc_background(struct maintenance_run_opts *opts,
+ struct gc_config *cfg UNUSED)
{
struct child_process child = CHILD_PROCESS_INIT;
@@ -1226,6 +1253,7 @@ static int maintenance_task_gc(struct maintenance_run_opts *opts,
else
strvec_push(&child.args, "--no-quiet");
strvec_push(&child.args, "--no-detach");
+ strvec_push(&child.args, "--skip-foreground-tasks");
return run_command(&child);
}
@@ -1513,103 +1541,116 @@ static int maintenance_task_incremental_repack(struct maintenance_run_opts *opts
return 0;
}
-typedef int maintenance_task_fn(struct maintenance_run_opts *opts,
- struct gc_config *cfg);
-
-/*
- * An auto condition function returns 1 if the task should run
- * and 0 if the task should NOT run. See needs_to_gc() for an
- * example.
- */
-typedef int maintenance_auto_fn(struct gc_config *cfg);
+typedef int (*maintenance_task_fn)(struct maintenance_run_opts *opts,
+ struct gc_config *cfg);
+typedef int (*maintenance_auto_fn)(struct gc_config *cfg);
struct maintenance_task {
const char *name;
- maintenance_task_fn *fn;
- maintenance_auto_fn *auto_condition;
- unsigned enabled:1;
- enum schedule_priority schedule;
+ /*
+ * Work that will be executed before detaching. This should not include
+ * tasks that may run for an extended amount of time as it does cause
+ * auto-maintenance to block until foreground tasks have been run.
+ */
+ maintenance_task_fn foreground;
- /* -1 if not selected. */
- int selected_order;
+ /*
+ * Work that will be executed after detaching. When not detaching the
+ * work will be run in the foreground, as well.
+ */
+ maintenance_task_fn background;
+
+ /*
+ * An auto condition function returns 1 if the task should run and 0 if
+ * the task should NOT run. See needs_to_gc() for an example.
+ */
+ maintenance_auto_fn auto_condition;
};
-enum maintenance_task_label {
- TASK_PREFETCH,
- TASK_LOOSE_OBJECTS,
- TASK_INCREMENTAL_REPACK,
- TASK_GC,
- TASK_COMMIT_GRAPH,
- TASK_PACK_REFS,
- TASK_REFLOG_EXPIRE,
- TASK_WORKTREE_PRUNE,
- TASK_RERERE_GC,
-
- /* Leave as final value */
- TASK__COUNT
-};
-
-static struct maintenance_task tasks[] = {
+static const struct maintenance_task tasks[] = {
[TASK_PREFETCH] = {
- "prefetch",
- maintenance_task_prefetch,
+ .name = "prefetch",
+ .background = maintenance_task_prefetch,
},
[TASK_LOOSE_OBJECTS] = {
- "loose-objects",
- maintenance_task_loose_objects,
- loose_object_auto_condition,
+ .name = "loose-objects",
+ .background = maintenance_task_loose_objects,
+ .auto_condition = loose_object_auto_condition,
},
[TASK_INCREMENTAL_REPACK] = {
- "incremental-repack",
- maintenance_task_incremental_repack,
- incremental_repack_auto_condition,
+ .name = "incremental-repack",
+ .background = maintenance_task_incremental_repack,
+ .auto_condition = incremental_repack_auto_condition,
},
[TASK_GC] = {
- "gc",
- maintenance_task_gc,
- need_to_gc,
- 1,
+ .name = "gc",
+ .foreground = maintenance_task_gc_foreground,
+ .background = maintenance_task_gc_background,
+ .auto_condition = need_to_gc,
},
[TASK_COMMIT_GRAPH] = {
- "commit-graph",
- maintenance_task_commit_graph,
- should_write_commit_graph,
+ .name = "commit-graph",
+ .background = maintenance_task_commit_graph,
+ .auto_condition = should_write_commit_graph,
},
[TASK_PACK_REFS] = {
- "pack-refs",
- maintenance_task_pack_refs,
- pack_refs_condition,
+ .name = "pack-refs",
+ .foreground = maintenance_task_pack_refs,
+ .auto_condition = pack_refs_condition,
},
[TASK_REFLOG_EXPIRE] = {
- "reflog-expire",
- maintenance_task_reflog_expire,
- reflog_expire_condition,
+ .name = "reflog-expire",
+ .foreground = maintenance_task_reflog_expire,
+ .auto_condition = reflog_expire_condition,
},
[TASK_WORKTREE_PRUNE] = {
- "worktree-prune",
- maintenance_task_worktree_prune,
- worktree_prune_condition,
+ .name = "worktree-prune",
+ .background = maintenance_task_worktree_prune,
+ .auto_condition = worktree_prune_condition,
},
[TASK_RERERE_GC] = {
- "rerere-gc",
- maintenance_task_rerere_gc,
- rerere_gc_condition,
+ .name = "rerere-gc",
+ .background = maintenance_task_rerere_gc,
+ .auto_condition = rerere_gc_condition,
},
};
-static int compare_tasks_by_selection(const void *a_, const void *b_)
-{
- const struct maintenance_task *a = a_;
- const struct maintenance_task *b = b_;
+enum task_phase {
+ TASK_PHASE_FOREGROUND,
+ TASK_PHASE_BACKGROUND,
+};
- return b->selected_order - a->selected_order;
+static int maybe_run_task(const struct maintenance_task *task,
+ struct repository *repo,
+ struct maintenance_run_opts *opts,
+ struct gc_config *cfg,
+ enum task_phase phase)
+{
+ int foreground = (phase == TASK_PHASE_FOREGROUND);
+ maintenance_task_fn fn = foreground ? task->foreground : task->background;
+ const char *region = foreground ? "maintenance foreground" : "maintenance";
+ int ret = 0;
+
+ if (!fn)
+ return 0;
+ if (opts->auto_flag &&
+ (!task->auto_condition || !task->auto_condition(cfg)))
+ return 0;
+
+ trace2_region_enter(region, task->name, repo);
+ if (fn(opts, cfg)) {
+ error(_("task '%s' failed"), task->name);
+ ret = 1;
+ }
+ trace2_region_leave(region, task->name, repo);
+
+ return ret;
}
static int maintenance_run_tasks(struct maintenance_run_opts *opts,
struct gc_config *cfg)
{
- int i, found_selected = 0;
int result = 0;
struct lock_file lk;
struct repository *r = the_repository;
@@ -1631,6 +1672,11 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,
}
free(lock_path);
+ for (size_t i = 0; i < opts->tasks_nr; i++)
+ if (maybe_run_task(&tasks[opts->tasks[i]], r, opts, cfg,
+ TASK_PHASE_FOREGROUND))
+ result = 1;
+
/* Failure to daemonize is ok, we'll continue in foreground. */
if (opts->detach > 0) {
trace2_region_enter("maintenance", "detach", the_repository);
@@ -1638,120 +1684,138 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,
trace2_region_leave("maintenance", "detach", the_repository);
}
- for (i = 0; !found_selected && i < TASK__COUNT; i++)
- found_selected = tasks[i].selected_order >= 0;
-
- if (found_selected)
- QSORT(tasks, TASK__COUNT, compare_tasks_by_selection);
-
- for (i = 0; i < TASK__COUNT; i++) {
- if (found_selected && tasks[i].selected_order < 0)
- continue;
-
- if (!found_selected && !tasks[i].enabled)
- continue;
-
- if (opts->auto_flag &&
- (!tasks[i].auto_condition ||
- !tasks[i].auto_condition(cfg)))
- continue;
-
- if (opts->schedule && tasks[i].schedule < opts->schedule)
- continue;
-
- trace2_region_enter("maintenance", tasks[i].name, r);
- if (tasks[i].fn(opts, cfg)) {
- error(_("task '%s' failed"), tasks[i].name);
+ for (size_t i = 0; i < opts->tasks_nr; i++)
+ if (maybe_run_task(&tasks[opts->tasks[i]], r, opts, cfg,
+ TASK_PHASE_BACKGROUND))
result = 1;
- }
- trace2_region_leave("maintenance", tasks[i].name, r);
- }
rollback_lock_file(&lk);
return result;
}
-static void initialize_maintenance_strategy(void)
+struct maintenance_strategy {
+ struct {
+ int enabled;
+ enum schedule_priority schedule;
+ } tasks[TASK__COUNT];
+};
+
+static const struct maintenance_strategy none_strategy = { 0 };
+static const struct maintenance_strategy default_strategy = {
+ .tasks = {
+ [TASK_GC].enabled = 1,
+ },
+};
+static const struct maintenance_strategy incremental_strategy = {
+ .tasks = {
+ [TASK_COMMIT_GRAPH].enabled = 1,
+ [TASK_COMMIT_GRAPH].schedule = SCHEDULE_HOURLY,
+ [TASK_PREFETCH].enabled = 1,
+ [TASK_PREFETCH].schedule = SCHEDULE_HOURLY,
+ [TASK_INCREMENTAL_REPACK].enabled = 1,
+ [TASK_INCREMENTAL_REPACK].schedule = SCHEDULE_DAILY,
+ [TASK_LOOSE_OBJECTS].enabled = 1,
+ [TASK_LOOSE_OBJECTS].schedule = SCHEDULE_DAILY,
+ [TASK_PACK_REFS].enabled = 1,
+ [TASK_PACK_REFS].schedule = SCHEDULE_WEEKLY,
+ },
+};
+
+static void initialize_task_config(struct maintenance_run_opts *opts,
+ const struct string_list *selected_tasks)
{
+ struct strbuf config_name = STRBUF_INIT;
+ struct maintenance_strategy strategy;
const char *config_str;
- if (git_config_get_string_tmp("maintenance.strategy", &config_str))
+ /*
+ * In case the user has asked us to run tasks explicitly we only use
+ * those specified tasks. Specifically, we do _not_ want to consult the
+ * config or maintenance strategy.
+ */
+ if (selected_tasks->nr) {
+ for (size_t i = 0; i < selected_tasks->nr; i++) {
+ enum maintenance_task_label label = (intptr_t)selected_tasks->items[i].util;;
+ ALLOC_GROW(opts->tasks, opts->tasks_nr + 1, opts->tasks_alloc);
+ opts->tasks[opts->tasks_nr++] = label;
+ }
+
return;
-
- if (!strcasecmp(config_str, "incremental")) {
- tasks[TASK_GC].schedule = SCHEDULE_NONE;
- tasks[TASK_COMMIT_GRAPH].enabled = 1;
- tasks[TASK_COMMIT_GRAPH].schedule = SCHEDULE_HOURLY;
- tasks[TASK_PREFETCH].enabled = 1;
- tasks[TASK_PREFETCH].schedule = SCHEDULE_HOURLY;
- tasks[TASK_INCREMENTAL_REPACK].enabled = 1;
- tasks[TASK_INCREMENTAL_REPACK].schedule = SCHEDULE_DAILY;
- tasks[TASK_LOOSE_OBJECTS].enabled = 1;
- tasks[TASK_LOOSE_OBJECTS].schedule = SCHEDULE_DAILY;
- tasks[TASK_PACK_REFS].enabled = 1;
- tasks[TASK_PACK_REFS].schedule = SCHEDULE_WEEKLY;
}
-}
-static void initialize_task_config(int schedule)
-{
- int i;
- struct strbuf config_name = STRBUF_INIT;
+ /*
+ * Otherwise, the strategy depends on whether we run as part of a
+ * scheduled job or not:
+ *
+ * - Scheduled maintenance does not perform any housekeeping by
+ * default, but requires the user to pick a maintenance strategy.
+ *
+ * - Unscheduled maintenance uses our default strategy.
+ *
+ * Both of these are affected by the gitconfig though, which may
+ * override specific aspects of our strategy.
+ */
+ if (opts->schedule) {
+ strategy = none_strategy;
- if (schedule)
- initialize_maintenance_strategy();
+ if (!git_config_get_string_tmp("maintenance.strategy", &config_str)) {
+ if (!strcasecmp(config_str, "incremental"))
+ strategy = incremental_strategy;
+ }
+ } else {
+ strategy = default_strategy;
+ }
- for (i = 0; i < TASK__COUNT; i++) {
+ for (size_t i = 0; i < TASK__COUNT; i++) {
int config_value;
- char *config_str;
strbuf_reset(&config_name);
strbuf_addf(&config_name, "maintenance.%s.enabled",
tasks[i].name);
-
if (!git_config_get_bool(config_name.buf, &config_value))
- tasks[i].enabled = config_value;
+ strategy.tasks[i].enabled = config_value;
+ if (!strategy.tasks[i].enabled)
+ continue;
- strbuf_reset(&config_name);
- strbuf_addf(&config_name, "maintenance.%s.schedule",
- tasks[i].name);
-
- if (!git_config_get_string(config_name.buf, &config_str)) {
- tasks[i].schedule = parse_schedule(config_str);
- free(config_str);
+ if (opts->schedule) {
+ strbuf_reset(&config_name);
+ strbuf_addf(&config_name, "maintenance.%s.schedule",
+ tasks[i].name);
+ if (!git_config_get_string_tmp(config_name.buf, &config_str))
+ strategy.tasks[i].schedule = parse_schedule(config_str);
+ if (strategy.tasks[i].schedule < opts->schedule)
+ continue;
}
+
+ ALLOC_GROW(opts->tasks, opts->tasks_nr + 1, opts->tasks_alloc);
+ opts->tasks[opts->tasks_nr++] = i;
}
strbuf_release(&config_name);
}
-static int task_option_parse(const struct option *opt UNUSED,
+static int task_option_parse(const struct option *opt,
const char *arg, int unset)
{
- int i, num_selected = 0;
- struct maintenance_task *task = NULL;
+ struct string_list *selected_tasks = opt->value;
+ size_t i;
BUG_ON_OPT_NEG(unset);
- for (i = 0; i < TASK__COUNT; i++) {
- if (tasks[i].selected_order >= 0)
- num_selected++;
- if (!strcasecmp(tasks[i].name, arg)) {
- task = &tasks[i];
- }
- }
-
- if (!task) {
+ for (i = 0; i < TASK__COUNT; i++)
+ if (!strcasecmp(tasks[i].name, arg))
+ break;
+ if (i >= TASK__COUNT) {
error(_("'%s' is not a valid task"), arg);
return 1;
}
- if (task->selected_order >= 0) {
+ if (unsorted_string_list_has_string(selected_tasks, arg)) {
error(_("task '%s' cannot be selected multiple times"), arg);
return 1;
}
- task->selected_order = num_selected + 1;
+ string_list_append(selected_tasks, arg)->util = (void *)(intptr_t)i;
return 0;
}
@@ -1759,8 +1823,8 @@ static int task_option_parse(const struct option *opt UNUSED,
static int maintenance_run(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
- int i;
struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT;
+ struct string_list selected_tasks = STRING_LIST_INIT_DUP;
struct gc_config cfg = GC_CONFIG_INIT;
struct option builtin_maintenance_run_options[] = {
OPT_BOOL(0, "auto", &opts.auto_flag,
@@ -1772,7 +1836,7 @@ static int maintenance_run(int argc, const char **argv, const char *prefix,
maintenance_opt_schedule),
OPT_BOOL(0, "quiet", &opts.quiet,
N_("do not report progress or other information over stderr")),
- OPT_CALLBACK_F(0, "task", NULL, N_("task"),
+ OPT_CALLBACK_F(0, "task", &selected_tasks, N_("task"),
N_("run a specific task"),
PARSE_OPT_NONEG, task_option_parse),
OPT_END()
@@ -1781,25 +1845,27 @@ static int maintenance_run(int argc, const char **argv, const char *prefix,
opts.quiet = !isatty(2);
- for (i = 0; i < TASK__COUNT; i++)
- tasks[i].selected_order = -1;
-
argc = parse_options(argc, argv, prefix,
builtin_maintenance_run_options,
builtin_maintenance_run_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
- if (opts.auto_flag && opts.schedule)
- die(_("use at most one of --auto and --schedule=<frequency>"));
+ die_for_incompatible_opt2(opts.auto_flag, "--auto",
+ opts.schedule, "--schedule=");
+ die_for_incompatible_opt2(selected_tasks.nr, "--task=",
+ opts.schedule, "--schedule=");
gc_config(&cfg);
- initialize_task_config(opts.schedule);
+ initialize_task_config(&opts, &selected_tasks);
if (argc != 0)
usage_with_options(builtin_maintenance_run_usage,
builtin_maintenance_run_options);
ret = maintenance_run_tasks(&opts, &cfg);
+
+ string_list_clear(&selected_tasks, 0);
+ maintenance_run_opts_release(&opts);
gc_config_release(&cfg);
return ret;
}
diff --git a/builtin/log.c b/builtin/log.c
index b450cd3..49cec11 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -113,6 +113,15 @@ struct log_config {
int fmt_patch_name_max;
char *fmt_pretty;
char *default_date_mode;
+
+#ifndef WITH_BREAKING_CHANGES
+ /*
+ * Note: git_log_config() does not touch this member and that
+ * is very deliberate. This member is only to be used to
+ * resurrect whatchanged that is deprecated.
+ */
+ int i_still_use_this;
+#endif
};
static void log_config_init(struct log_config *cfg)
@@ -267,6 +276,10 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
OPT__QUIET(&quiet, N_("suppress diff output")),
OPT_BOOL(0, "source", &source, N_("show source")),
OPT_BOOL(0, "use-mailmap", &mailmap, N_("use mail map file")),
+#ifndef WITH_BREAKING_CHANGES
+ OPT_HIDDEN_BOOL(0, "i-still-use-this", &cfg->i_still_use_this,
+ "<use this deprecated command>"),
+#endif
OPT_ALIAS(0, "mailmap", "use-mailmap"),
OPT_CALLBACK_F(0, "clear-decorations", NULL, NULL,
N_("clear all previously-defined decoration filters"),
@@ -633,6 +646,7 @@ static int git_log_config(const char *var, const char *value,
return git_diff_ui_config(var, value, ctx, cb);
}
+#ifndef WITH_BREAKING_CHANGES
int cmd_whatchanged(int argc,
const char **argv,
const char *prefix,
@@ -656,6 +670,10 @@ int cmd_whatchanged(int argc,
opt.def = "HEAD";
opt.revarg_opt = REVARG_COMMITTISH;
cmd_log_init(argc, argv, prefix, &rev, &opt, &cfg);
+
+ if (!cfg.i_still_use_this)
+ you_still_use_that("git whatchanged");
+
if (!rev.diffopt.output_format)
rev.diffopt.output_format = DIFF_FORMAT_RAW;
@@ -665,6 +683,7 @@ int cmd_whatchanged(int argc,
log_config_release(&cfg);
return ret;
}
+#endif
static void show_tagger(const char *buf, struct rev_info *rev)
{
diff --git a/builtin/merge.c b/builtin/merge.c
index ce90e52..18b22c0a 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -69,7 +69,10 @@ static const char * const builtin_merge_usage[] = {
NULL
};
-static int show_diffstat = 1, shortlog_len = -1, squash;
+#define MERGE_SHOW_DIFFSTAT 1
+#define MERGE_SHOW_COMPACTSUMMARY 2
+
+static int show_diffstat = MERGE_SHOW_DIFFSTAT, shortlog_len = -1, squash;
static int option_commit = -1;
static int option_edit = -1;
static int allow_trivial = 1, have_message, verify_signatures;
@@ -243,12 +246,28 @@ static int option_parse_strategy(const struct option *opt UNUSED,
return 0;
}
+static int option_parse_compact_summary(const struct option *opt,
+ const char *name UNUSED, int unset)
+{
+ int *setting = opt->value;
+
+ if (unset)
+ *setting = 0;
+ else
+ *setting = MERGE_SHOW_COMPACTSUMMARY;
+ return 0;
+}
+
static struct option builtin_merge_options[] = {
OPT_SET_INT('n', NULL, &show_diffstat,
N_("do not show a diffstat at the end of the merge"), 0),
OPT_BOOL(0, "stat", &show_diffstat,
N_("show a diffstat at the end of the merge")),
OPT_BOOL(0, "summary", &show_diffstat, N_("(synonym to --stat)")),
+ OPT_CALLBACK_F(0, "compact-summary", &show_diffstat, N_("compact-summary"),
+ N_("show a compact-summary at the end of the merge"),
+ PARSE_OPT_NOARG,
+ option_parse_compact_summary),
{
.type = OPTION_INTEGER,
.long_name = "log",
@@ -494,8 +513,19 @@ static void finish(struct commit *head_commit,
struct diff_options opts;
repo_diff_setup(the_repository, &opts);
init_diffstat_widths(&opts);
- opts.output_format |=
- DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
+
+ switch (show_diffstat) {
+ case MERGE_SHOW_DIFFSTAT: /* 1 */
+ opts.output_format |=
+ DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
+ break;
+ case MERGE_SHOW_COMPACTSUMMARY: /* 2 */
+ opts.output_format |= DIFF_FORMAT_DIFFSTAT;
+ opts.flags.stat_with_summary = 1;
+ break;
+ default:
+ break;
+ }
opts.detect_rename = DIFF_DETECT_RENAME;
diff_setup_done(&opts);
diff_tree_oid(head, new_head, "", &opts);
@@ -643,7 +673,35 @@ static int git_merge_config(const char *k, const char *v,
}
if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat")) {
- show_diffstat = git_config_bool(k, v);
+ int val = git_parse_maybe_bool_text(v);
+ switch (val) {
+ case 0:
+ show_diffstat = 0;
+ break;
+ case 1:
+ show_diffstat = MERGE_SHOW_DIFFSTAT;
+ break;
+ default:
+ if (!strcmp(v, "compact"))
+ show_diffstat = MERGE_SHOW_COMPACTSUMMARY;
+ /*
+ * We do not need to have an explicit
+ *
+ * else if (!strcmp(v, "diffstat"))
+ * show_diffstat = MERGE_SHOW_DIFFSTAT;
+ *
+ * here, because the catch-all uses the
+ * diffstat style anyway.
+ */
+ else
+ /*
+ * A setting from a future? It is not an
+ * error grave enough to fail the command.
+ * proceed using the default one.
+ */
+ show_diffstat = MERGE_SHOW_DIFFSTAT;
+ break;
+ }
} else if (!strcmp(k, "merge.verifysignatures")) {
verify_signatures = git_config_bool(k, v);
} else if (!strcmp(k, "pull.twohead")) {
diff --git a/builtin/mktag.c b/builtin/mktag.c
index 7ac11c4..1b1dc02 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -41,7 +41,7 @@ static int mktag_fsck_error_func(struct fsck_options *o UNUSED,
fprintf_ln(stderr, _("error: tag input does not pass fsck: %s"), message);
return 1;
default:
- BUG(_("%d (FSCK_IGNORE?) should never trigger this callback"),
+ BUG("%d (FSCK_IGNORE?) should never trigger this callback",
msg_type);
}
}
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 8b33edc..67941c8 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -41,6 +41,10 @@
#include "promisor-remote.h"
#include "pack-mtimes.h"
#include "parse-options.h"
+#include "blob.h"
+#include "tree.h"
+#include "path-walk.h"
+#include "trace2.h"
/*
* Objects we are going to pack are collected in the `to_pack` structure.
@@ -184,8 +188,14 @@ static inline void oe_set_delta_size(struct packing_data *pack,
#define SET_DELTA_SIBLING(obj, val) oe_set_delta_sibling(&to_pack, obj, val)
static const char *const pack_usage[] = {
- N_("git pack-objects --stdout [<options>] [< <ref-list> | < <object-list>]"),
- N_("git pack-objects [<options>] <base-name> [< <ref-list> | < <object-list>]"),
+ N_("git pack-objects [-q | --progress | --all-progress] [--all-progress-implied]\n"
+ " [--no-reuse-delta] [--delta-base-offset] [--non-empty]\n"
+ " [--local] [--incremental] [--window=<n>] [--depth=<n>]\n"
+ " [--revs [--unpacked | --all]] [--keep-pack=<pack-name>]\n"
+ " [--cruft] [--cruft-expiration=<time>]\n"
+ " [--stdout [--filter=<filter-spec>] | <base-name>]\n"
+ " [--shallow] [--keep-true-parents] [--[no-]sparse]\n"
+ " [--name-hash-version=<n>] [--path-walk] < <object-list>"),
NULL
};
@@ -200,6 +210,7 @@ static int keep_unreachable, unpack_unreachable, include_tag;
static timestamp_t unpack_unreachable_expiration;
static int pack_loose_unreachable;
static int cruft;
+static int shallow = 0;
static timestamp_t cruft_expiration;
static int local;
static int have_non_local_packs;
@@ -218,6 +229,7 @@ static int delta_search_threads;
static int pack_to_stdout;
static int sparse;
static int thin;
+static int path_walk = -1;
static int num_preferred_base;
static struct progress *progress_state;
@@ -3041,6 +3053,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
struct thread_params {
pthread_t thread;
struct object_entry **list;
+ struct packing_region *regions;
unsigned list_size;
unsigned remaining;
int window;
@@ -3283,6 +3296,242 @@ static int add_ref_tag(const char *tag UNUSED, const char *referent UNUSED, cons
return 0;
}
+static int should_attempt_deltas(struct object_entry *entry)
+{
+ if (DELTA(entry))
+ /* This happens if we decided to reuse existing
+ * delta from a pack. "reuse_delta &&" is implied.
+ */
+ return 0;
+
+ if (!entry->type_valid ||
+ oe_size_less_than(&to_pack, entry, 50))
+ return 0;
+
+ if (entry->no_try_delta)
+ return 0;
+
+ if (!entry->preferred_base) {
+ if (oe_type(entry) < 0)
+ die(_("unable to get type of object %s"),
+ oid_to_hex(&entry->idx.oid));
+ } else if (oe_type(entry) < 0) {
+ /*
+ * This object is not found, but we
+ * don't have to include it anyway.
+ */
+ return 0;
+ }
+
+ return 1;
+}
+
+static void find_deltas_for_region(struct object_entry *list,
+ struct packing_region *region,
+ unsigned int *processed)
+{
+ struct object_entry **delta_list;
+ unsigned int delta_list_nr = 0;
+
+ ALLOC_ARRAY(delta_list, region->nr);
+ for (size_t i = 0; i < region->nr; i++) {
+ struct object_entry *entry = list + region->start + i;
+ if (should_attempt_deltas(entry))
+ delta_list[delta_list_nr++] = entry;
+ }
+
+ QSORT(delta_list, delta_list_nr, type_size_sort);
+ find_deltas(delta_list, &delta_list_nr, window, depth, processed);
+ free(delta_list);
+}
+
+static void find_deltas_by_region(struct object_entry *list,
+ struct packing_region *regions,
+ size_t start, size_t nr)
+{
+ unsigned int processed = 0;
+ size_t progress_nr;
+
+ if (!nr)
+ return;
+
+ progress_nr = regions[nr - 1].start + regions[nr - 1].nr;
+
+ if (progress)
+ progress_state = start_progress(the_repository,
+ _("Compressing objects by path"),
+ progress_nr);
+
+ while (nr--)
+ find_deltas_for_region(list,
+ ®ions[start++],
+ &processed);
+
+ display_progress(progress_state, progress_nr);
+ stop_progress(&progress_state);
+}
+
+static void *threaded_find_deltas_by_path(void *arg)
+{
+ struct thread_params *me = arg;
+
+ progress_lock();
+ while (me->remaining) {
+ while (me->remaining) {
+ progress_unlock();
+ find_deltas_for_region(to_pack.objects,
+ me->regions,
+ me->processed);
+ progress_lock();
+ me->remaining--;
+ me->regions++;
+ }
+
+ me->working = 0;
+ pthread_cond_signal(&progress_cond);
+ progress_unlock();
+
+ /*
+ * We must not set ->data_ready before we wait on the
+ * condition because the main thread may have set it to 1
+ * before we get here. In order to be sure that new
+ * work is available if we see 1 in ->data_ready, it
+ * was initialized to 0 before this thread was spawned
+ * and we reset it to 0 right away.
+ */
+ pthread_mutex_lock(&me->mutex);
+ while (!me->data_ready)
+ pthread_cond_wait(&me->cond, &me->mutex);
+ me->data_ready = 0;
+ pthread_mutex_unlock(&me->mutex);
+
+ progress_lock();
+ }
+ progress_unlock();
+ /* leave ->working 1 so that this doesn't get more work assigned */
+ return NULL;
+}
+
+static void ll_find_deltas_by_region(struct object_entry *list,
+ struct packing_region *regions,
+ uint32_t start, uint32_t nr)
+{
+ struct thread_params *p;
+ int i, ret, active_threads = 0;
+ unsigned int processed = 0;
+ uint32_t progress_nr;
+ init_threaded_search();
+
+ if (!nr)
+ return;
+
+ progress_nr = regions[nr - 1].start + regions[nr - 1].nr;
+ if (delta_search_threads <= 1) {
+ find_deltas_by_region(list, regions, start, nr);
+ cleanup_threaded_search();
+ return;
+ }
+
+ if (progress > pack_to_stdout)
+ fprintf_ln(stderr,
+ Q_("Path-based delta compression using up to %d thread",
+ "Path-based delta compression using up to %d threads",
+ delta_search_threads),
+ delta_search_threads);
+ CALLOC_ARRAY(p, delta_search_threads);
+
+ if (progress)
+ progress_state = start_progress(the_repository,
+ _("Compressing objects by path"),
+ progress_nr);
+ /* Partition the work amongst work threads. */
+ for (i = 0; i < delta_search_threads; i++) {
+ unsigned sub_size = nr / (delta_search_threads - i);
+
+ p[i].window = window;
+ p[i].depth = depth;
+ p[i].processed = &processed;
+ p[i].working = 1;
+ p[i].data_ready = 0;
+
+ p[i].regions = regions;
+ p[i].list_size = sub_size;
+ p[i].remaining = sub_size;
+
+ regions += sub_size;
+ nr -= sub_size;
+ }
+
+ /* Start work threads. */
+ for (i = 0; i < delta_search_threads; i++) {
+ if (!p[i].list_size)
+ continue;
+ pthread_mutex_init(&p[i].mutex, NULL);
+ pthread_cond_init(&p[i].cond, NULL);
+ ret = pthread_create(&p[i].thread, NULL,
+ threaded_find_deltas_by_path, &p[i]);
+ if (ret)
+ die(_("unable to create thread: %s"), strerror(ret));
+ active_threads++;
+ }
+
+ /*
+ * Now let's wait for work completion. Each time a thread is done
+ * with its work, we steal half of the remaining work from the
+ * thread with the largest number of unprocessed objects and give
+ * it to that newly idle thread. This ensure good load balancing
+ * until the remaining object list segments are simply too short
+ * to be worth splitting anymore.
+ */
+ while (active_threads) {
+ struct thread_params *target = NULL;
+ struct thread_params *victim = NULL;
+ unsigned sub_size = 0;
+
+ progress_lock();
+ for (;;) {
+ for (i = 0; !target && i < delta_search_threads; i++)
+ if (!p[i].working)
+ target = &p[i];
+ if (target)
+ break;
+ pthread_cond_wait(&progress_cond, &progress_mutex);
+ }
+
+ for (i = 0; i < delta_search_threads; i++)
+ if (p[i].remaining > 2*window &&
+ (!victim || victim->remaining < p[i].remaining))
+ victim = &p[i];
+ if (victim) {
+ sub_size = victim->remaining / 2;
+ target->regions = victim->regions + victim->remaining - sub_size;
+ victim->list_size -= sub_size;
+ victim->remaining -= sub_size;
+ }
+ target->list_size = sub_size;
+ target->remaining = sub_size;
+ target->working = 1;
+ progress_unlock();
+
+ pthread_mutex_lock(&target->mutex);
+ target->data_ready = 1;
+ pthread_cond_signal(&target->cond);
+ pthread_mutex_unlock(&target->mutex);
+
+ if (!sub_size) {
+ pthread_join(target->thread, NULL);
+ pthread_cond_destroy(&target->cond);
+ pthread_mutex_destroy(&target->mutex);
+ active_threads--;
+ }
+ }
+ cleanup_threaded_search();
+ free(p);
+
+ display_progress(progress_state, progress_nr);
+ stop_progress(&progress_state);
+}
+
static void prepare_pack(int window, int depth)
{
struct object_entry **delta_list;
@@ -3307,39 +3556,21 @@ static void prepare_pack(int window, int depth)
if (!to_pack.nr_objects || !window || !depth)
return;
+ if (path_walk)
+ ll_find_deltas_by_region(to_pack.objects, to_pack.regions,
+ 0, to_pack.nr_regions);
+
ALLOC_ARRAY(delta_list, to_pack.nr_objects);
nr_deltas = n = 0;
for (i = 0; i < to_pack.nr_objects; i++) {
struct object_entry *entry = to_pack.objects + i;
- if (DELTA(entry))
- /* This happens if we decided to reuse existing
- * delta from a pack. "reuse_delta &&" is implied.
- */
+ if (!should_attempt_deltas(entry))
continue;
- if (!entry->type_valid ||
- oe_size_less_than(&to_pack, entry, 50))
- continue;
-
- if (entry->no_try_delta)
- continue;
-
- if (!entry->preferred_base) {
+ if (!entry->preferred_base)
nr_deltas++;
- if (oe_type(entry) < 0)
- die(_("unable to get type of object %s"),
- oid_to_hex(&entry->idx.oid));
- } else {
- if (oe_type(entry) < 0) {
- /*
- * This object is not found, but we
- * don't have to include it anyway.
- */
- continue;
- }
- }
delta_list[n++] = entry;
}
@@ -4272,6 +4503,93 @@ static void mark_bitmap_preferred_tips(void)
}
}
+static inline int is_oid_uninteresting(struct repository *repo,
+ struct object_id *oid)
+{
+ struct object *o = lookup_object(repo, oid);
+ return !o || (o->flags & UNINTERESTING);
+}
+
+static int add_objects_by_path(const char *path,
+ struct oid_array *oids,
+ enum object_type type,
+ void *data)
+{
+ size_t oe_start = to_pack.nr_objects;
+ size_t oe_end;
+ unsigned int *processed = data;
+
+ /*
+ * First, add all objects to the packing data, including the ones
+ * marked UNINTERESTING (translated to 'exclude') as they can be
+ * used as delta bases.
+ */
+ for (size_t i = 0; i < oids->nr; i++) {
+ int exclude;
+ struct object_info oi = OBJECT_INFO_INIT;
+ struct object_id *oid = &oids->oid[i];
+
+ /* Skip objects that do not exist locally. */
+ if ((exclude_promisor_objects || arg_missing_action != MA_ERROR) &&
+ oid_object_info_extended(the_repository, oid, &oi,
+ OBJECT_INFO_FOR_PREFETCH) < 0)
+ continue;
+
+ exclude = is_oid_uninteresting(the_repository, oid);
+
+ if (exclude && !thin)
+ continue;
+
+ add_object_entry(oid, type, path, exclude);
+ }
+
+ oe_end = to_pack.nr_objects;
+
+ /* We can skip delta calculations if it is a no-op. */
+ if (oe_end == oe_start || !window)
+ return 0;
+
+ ALLOC_GROW(to_pack.regions,
+ to_pack.nr_regions + 1,
+ to_pack.nr_regions_alloc);
+
+ to_pack.regions[to_pack.nr_regions].start = oe_start;
+ to_pack.regions[to_pack.nr_regions].nr = oe_end - oe_start;
+ to_pack.nr_regions++;
+
+ *processed += oids->nr;
+ display_progress(progress_state, *processed);
+
+ return 0;
+}
+
+static void get_object_list_path_walk(struct rev_info *revs)
+{
+ struct path_walk_info info = PATH_WALK_INFO_INIT;
+ unsigned int processed = 0;
+ int result;
+
+ info.revs = revs;
+ info.path_fn = add_objects_by_path;
+ info.path_fn_data = &processed;
+
+ /*
+ * Allow the --[no-]sparse option to be interesting here, if only
+ * for testing purposes. Paths with no interesting objects will not
+ * contribute to the resulting pack, but only create noisy preferred
+ * base objects.
+ */
+ info.prune_all_uninteresting = sparse;
+ info.edge_aggressive = shallow;
+
+ trace2_region_enter("pack-objects", "path-walk", revs->repo);
+ result = walk_objects_by_path(&info);
+ trace2_region_leave("pack-objects", "path-walk", revs->repo);
+
+ if (result)
+ die(_("failed to pack objects via path-walk"));
+}
+
static void get_object_list(struct rev_info *revs, int ac, const char **av)
{
struct setup_revision_opt s_r_opt = {
@@ -4327,15 +4645,19 @@ static void get_object_list(struct rev_info *revs, int ac, const char **av)
if (write_bitmap_index)
mark_bitmap_preferred_tips();
- if (prepare_revision_walk(revs))
- die(_("revision walk setup failed"));
- mark_edges_uninteresting(revs, show_edge, sparse);
-
if (!fn_show_object)
fn_show_object = show_object;
- traverse_commit_list(revs,
- show_commit, fn_show_object,
- NULL);
+
+ if (path_walk) {
+ get_object_list_path_walk(revs);
+ } else {
+ if (prepare_revision_walk(revs))
+ die(_("revision walk setup failed"));
+ mark_edges_uninteresting(revs, show_edge, sparse);
+ traverse_commit_list(revs,
+ show_commit, fn_show_object,
+ NULL);
+ }
if (unpack_unreachable_expiration) {
revs->ignore_missing_links = 1;
@@ -4464,7 +4786,6 @@ int cmd_pack_objects(int argc,
struct repository *repo UNUSED)
{
int use_internal_rev_list = 0;
- int shallow = 0;
int all_progress_implied = 0;
struct strvec rp = STRVEC_INIT;
int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0;
@@ -4545,6 +4866,8 @@ int cmd_pack_objects(int argc,
N_("use the sparse reachability algorithm")),
OPT_BOOL(0, "thin", &thin,
N_("create thin packs")),
+ OPT_BOOL(0, "path-walk", &path_walk,
+ N_("use the path-walk API to walk objects when possible")),
OPT_BOOL(0, "shallow", &shallow,
N_("create packs suitable for shallow fetches")),
OPT_BOOL(0, "honor-pack-keep", &ignore_packed_keep_on_disk,
@@ -4614,6 +4937,17 @@ int cmd_pack_objects(int argc,
if (pack_to_stdout != !base_name || argc)
usage_with_options(pack_usage, pack_objects_options);
+ if (path_walk < 0) {
+ if (use_bitmap_index > 0 ||
+ !use_internal_rev_list)
+ path_walk = 0;
+ else if (the_repository->gitdir &&
+ the_repository->settings.pack_use_path_walk)
+ path_walk = 1;
+ else
+ path_walk = git_env_bool("GIT_TEST_PACK_PATH_WALK", 0);
+ }
+
if (depth < 0)
depth = 0;
if (depth >= (1 << OE_DEPTH_BITS)) {
@@ -4630,7 +4964,28 @@ int cmd_pack_objects(int argc,
window = 0;
strvec_push(&rp, "pack-objects");
- if (thin) {
+
+ if (path_walk) {
+ const char *option = NULL;
+ if (filter_options.choice)
+ option = "--filter";
+ else if (use_delta_islands)
+ option = "--delta-islands";
+
+ if (option) {
+ warning(_("cannot use %s with %s"),
+ option, "--path-walk");
+ path_walk = 0;
+ }
+ }
+ if (path_walk) {
+ strvec_push(&rp, "--boundary");
+ /*
+ * We must disable the bitmaps because we are removing
+ * the --objects / --objects-edge[-aggressive] options.
+ */
+ use_bitmap_index = 0;
+ } else if (thin) {
use_internal_rev_list = 1;
strvec_push(&rp, shallow
? "--objects-edge-aggressive"
diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c
index 5d1fc78..4138b52 100644
--- a/builtin/pack-redundant.c
+++ b/builtin/pack-redundant.c
@@ -625,14 +625,8 @@ int cmd_pack_redundant(int argc, const char **argv, const char *prefix UNUSED, s
break;
}
- if (!i_still_use_this) {
- fputs(_("'git pack-redundant' is nominated for removal.\n"
- "If you still use this command, please add an extra\n"
- "option, '--i-still-use-this', on the command line\n"
- "and let us know you still use it by sending an e-mail\n"
- "to <git@vger.kernel.org>. Thanks.\n"), stderr);
- die(_("refusing to run without --i-still-use-this"));
- }
+ if (!i_still_use_this)
+ you_still_use_that("git pack-redundant");
if (load_all_packs)
load_all();
diff --git a/builtin/pull.c b/builtin/pull.c
index a1ebc6a..6e72a2e 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -143,6 +143,9 @@ static struct option pull_options[] = {
OPT_PASSTHRU(0, "summary", &opt_diffstat, NULL,
N_("(synonym to --stat)"),
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN),
+ OPT_PASSTHRU(0, "compact-summary", &opt_diffstat, NULL,
+ N_("show a compact-summary at the end of the merge"),
+ PARSE_OPT_NOARG),
OPT_PASSTHRU(0, "log", &opt_log, N_("n"),
N_("add (at most <n>) entries from shortlog to merge commit message"),
PARSE_OPT_OPTARG),
diff --git a/builtin/repack.c b/builtin/repack.c
index 59214db..5ddc6e7 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -43,7 +43,7 @@ static char *packdir, *packtmp_name, *packtmp;
static const char *const git_repack_usage[] = {
N_("git repack [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-b] [-m]\n"
"[--window=<n>] [--depth=<n>] [--threads=<n>] [--keep-pack=<pack-name>]\n"
- "[--write-midx] [--name-hash-version=<n>]"),
+ "[--write-midx] [--name-hash-version=<n>] [--path-walk]"),
NULL
};
@@ -63,6 +63,7 @@ struct pack_objects_args {
int quiet;
int local;
int name_hash_version;
+ int path_walk;
struct list_objects_filter_options filter_options;
};
@@ -313,6 +314,8 @@ static void prepare_pack_objects(struct child_process *cmd,
strvec_pushf(&cmd->args, "--no-reuse-object");
if (args->name_hash_version)
strvec_pushf(&cmd->args, "--name-hash-version=%d", args->name_hash_version);
+ if (args->path_walk)
+ strvec_pushf(&cmd->args, "--path-walk");
if (args->local)
strvec_push(&cmd->args, "--local");
if (args->quiet)
@@ -1184,6 +1187,8 @@ int cmd_repack(int argc,
N_("pass --no-reuse-object to git-pack-objects")),
OPT_INTEGER(0, "name-hash-version", &po_args.name_hash_version,
N_("specify the name hash version to use for grouping similar objects by path")),
+ OPT_BOOL(0, "path-walk", &po_args.path_walk,
+ N_("pass --path-walk to git-pack-objects")),
OPT_NEGBIT('n', NULL, &run_update_server_info,
N_("do not run git-update-server-info"), 1),
OPT__QUIET(&po_args.quiet, N_("be quiet")),
diff --git a/builtin/replay.c b/builtin/replay.c
index 225cef0..6172c8a 100644
--- a/builtin/replay.c
+++ b/builtin/replay.c
@@ -84,6 +84,7 @@ static struct commit *create_commit(struct repository *repo,
obj = parse_object(repo, &ret);
out:
+ repo_unuse_commit_buffer(the_repository, based_on, message);
free_commit_extra_headers(extra);
free_commit_list(parents);
strbuf_release(&msg);
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 30075b6..fe15e11 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -187,7 +187,7 @@ static void insert_records_from_trailers(struct shortlog *log,
ctx->output_encoding);
body = strstr(commit_buffer, "\n\n");
if (!body)
- return;
+ goto out;
trailer_iterator_init(&iter, body);
while (trailer_iterator_advance(&iter)) {
@@ -206,6 +206,7 @@ static void insert_records_from_trailers(struct shortlog *log,
}
trailer_iterator_release(&iter);
+out:
strbuf_release(&ident);
repo_unuse_commit_buffer(the_repository, commit, commit_buffer);
}
diff --git a/builtin/stash.c b/builtin/stash.c
index cfbd928..e2f95cc 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -28,7 +28,10 @@
#include "log-tree.h"
#include "diffcore.h"
#include "reflog.h"
+#include "reflog-walk.h"
#include "add-interactive.h"
+#include "oid-array.h"
+#include "commit.h"
#define INCLUDE_ALL_FILES 2
@@ -56,6 +59,10 @@
" [-u | --include-untracked] [-a | --all] [<message>]")
#define BUILTIN_STASH_CREATE_USAGE \
N_("git stash create [<message>]")
+#define BUILTIN_STASH_EXPORT_USAGE \
+ N_("git stash export (--print | --to-ref <ref>) [<stash>...]")
+#define BUILTIN_STASH_IMPORT_USAGE \
+ N_("git stash import <commit>")
#define BUILTIN_STASH_CLEAR_USAGE \
"git stash clear"
@@ -71,6 +78,8 @@ static const char * const git_stash_usage[] = {
BUILTIN_STASH_CLEAR_USAGE,
BUILTIN_STASH_CREATE_USAGE,
BUILTIN_STASH_STORE_USAGE,
+ BUILTIN_STASH_EXPORT_USAGE,
+ BUILTIN_STASH_IMPORT_USAGE,
NULL
};
@@ -124,6 +133,16 @@ static const char * const git_stash_save_usage[] = {
NULL
};
+static const char * const git_stash_export_usage[] = {
+ BUILTIN_STASH_EXPORT_USAGE,
+ NULL
+};
+
+static const char * const git_stash_import_usage[] = {
+ BUILTIN_STASH_IMPORT_USAGE,
+ NULL
+};
+
static const char ref_stash[] = "refs/stash";
static struct strbuf stash_index_path = STRBUF_INIT;
@@ -132,6 +151,7 @@ static struct strbuf stash_index_path = STRBUF_INIT;
* b_commit is set to the base commit
* i_commit is set to the commit containing the index tree
* u_commit is set to the commit containing the untracked files tree
+ * c_commit is set to the first parent (chain commit) when importing and is otherwise unset
* w_tree is set to the working tree
* b_tree is set to the base tree
* i_tree is set to the index tree
@@ -142,6 +162,7 @@ struct stash_info {
struct object_id b_commit;
struct object_id i_commit;
struct object_id u_commit;
+ struct object_id c_commit;
struct object_id w_tree;
struct object_id b_tree;
struct object_id i_tree;
@@ -160,6 +181,33 @@ static void free_stash_info(struct stash_info *info)
strbuf_release(&info->revision);
}
+static int check_stash_topology(struct repository *r, struct commit *stash)
+{
+ struct commit *p1, *p2, *p3 = NULL;
+
+ /* stash must have two or three parents */
+ if (!stash->parents || !stash->parents->next ||
+ (stash->parents->next->next && stash->parents->next->next->next))
+ return -1;
+ p1 = stash->parents->item;
+ p2 = stash->parents->next->item;
+ if (stash->parents->next->next)
+ p3 = stash->parents->next->next->item;
+ if (repo_parse_commit(r, p1) || repo_parse_commit(r, p2) ||
+ (p3 && repo_parse_commit(r, p3)))
+ return -1;
+ /* p2 must have a single parent, p3 must have no parents */
+ if (!p2->parents || p2->parents->next || (p3 && p3->parents))
+ return -1;
+ if (repo_parse_commit(r, p2->parents->item))
+ return -1;
+ /* p2^1 must equal p1 */
+ if (!oideq(&p1->object.oid, &p2->parents->item->object.oid))
+ return -1;
+
+ return 0;
+}
+
static void assert_stash_like(struct stash_info *info, const char *revision)
{
if (get_oidf(&info->b_commit, "%s^1", revision) ||
@@ -169,6 +217,25 @@ static void assert_stash_like(struct stash_info *info, const char *revision)
die(_("'%s' is not a stash-like commit"), revision);
}
+static int parse_stash_revision(struct strbuf *revision, const char *commit, int quiet)
+{
+ strbuf_reset(revision);
+ if (!commit) {
+ if (!refs_ref_exists(get_main_ref_store(the_repository), ref_stash)) {
+ if (!quiet)
+ fprintf_ln(stderr, _("No stash entries found."));
+ return -1;
+ }
+
+ strbuf_addf(revision, "%s@{0}", ref_stash);
+ } else if (strspn(commit, "0123456789") == strlen(commit)) {
+ strbuf_addf(revision, "%s@{%s}", ref_stash, commit);
+ } else {
+ strbuf_addstr(revision, commit);
+ }
+ return 0;
+}
+
static int get_stash_info(struct stash_info *info, int argc, const char **argv)
{
int ret;
@@ -196,17 +263,9 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
if (argc == 1)
commit = argv[0];
- if (!commit) {
- if (!refs_ref_exists(get_main_ref_store(the_repository), ref_stash)) {
- fprintf_ln(stderr, _("No stash entries found."));
- return -1;
- }
-
- strbuf_addf(&info->revision, "%s@{0}", ref_stash);
- } else if (strspn(commit, "0123456789") == strlen(commit)) {
- strbuf_addf(&info->revision, "%s@{%s}", ref_stash, commit);
- } else {
- strbuf_addstr(&info->revision, commit);
+ strbuf_init(&info->revision, 0);
+ if (parse_stash_revision(&info->revision, commit, 0)) {
+ return -1;
}
revision = info->revision.buf;
@@ -1372,6 +1431,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
const char *head_short_sha1 = NULL;
const char *branch_ref = NULL;
const char *branch_name = "(no branch)";
+ char *branch_name_buf = NULL;
struct commit *head_commit = NULL;
struct commit_list *parents = NULL;
struct strbuf msg = STRBUF_INIT;
@@ -1404,8 +1464,12 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
branch_ref = refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
"HEAD", 0, NULL, &flags);
- if (flags & REF_ISSYMREF)
- skip_prefix(branch_ref, "refs/heads/", &branch_name);
+
+ if (flags & REF_ISSYMREF) {
+ if (skip_prefix(branch_ref, "refs/heads/", &branch_name))
+ branch_name = branch_name_buf = xstrdup(branch_name);
+ }
+
head_short_sha1 = repo_find_unique_abbrev(the_repository,
&head_commit->object.oid,
DEFAULT_ABBREV);
@@ -1495,6 +1559,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
strbuf_release(&msg);
strbuf_release(&untracked_files);
free_commit_list(parents);
+ free(branch_name_buf);
return ret;
}
@@ -1789,11 +1854,15 @@ static int push_stash(int argc, const char **argv, const char *prefix,
int ret;
if (argc) {
- force_assume = !strcmp(argv[0], "-p");
+ int flags = PARSE_OPT_KEEP_DASHDASH;
+
+ if (push_assumed)
+ flags |= PARSE_OPT_STOP_AT_NON_OPTION;
+
argc = parse_options(argc, argv, prefix, options,
push_assumed ? git_stash_usage :
- git_stash_push_usage,
- PARSE_OPT_KEEP_DASHDASH);
+ git_stash_push_usage, flags);
+ force_assume |= patch_mode;
}
if (argc) {
@@ -1884,6 +1953,383 @@ static int save_stash(int argc, const char **argv, const char *prefix,
return ret;
}
+static int write_commit_with_parents(struct repository *r,
+ struct object_id *out,
+ const struct object_id *oid,
+ struct commit_list *parents)
+{
+ size_t author_len, committer_len;
+ struct commit *this;
+ const char *orig_author, *orig_committer;
+ char *author = NULL, *committer = NULL;
+ const char *buffer;
+ unsigned long bufsize;
+ const char *p;
+ struct strbuf msg = STRBUF_INIT;
+ int ret = 0;
+ struct ident_split id;
+
+ this = lookup_commit_reference(r, oid);
+ buffer = repo_get_commit_buffer(r, this, &bufsize);
+ orig_author = find_commit_header(buffer, "author", &author_len);
+ orig_committer = find_commit_header(buffer, "committer", &committer_len);
+
+ if (!orig_author || !orig_committer) {
+ ret = error(_("cannot parse commit %s"), oid_to_hex(oid));
+ goto out;
+ }
+
+ if (split_ident_line(&id, orig_author, author_len) < 0 ||
+ split_ident_line(&id, orig_committer, committer_len) < 0) {
+ ret = error(_("invalid author or committer for %s"), oid_to_hex(oid));
+ goto out;
+ }
+
+ p = strstr(buffer, "\n\n");
+ strbuf_addstr(&msg, "git stash: ");
+
+ if (p)
+ strbuf_add(&msg, p + 2, bufsize - (p + 2 - buffer));
+ strbuf_complete_line(&msg);
+
+ author = xmemdupz(orig_author, author_len);
+ committer = xmemdupz(orig_committer, committer_len);
+
+ if (commit_tree_extended(msg.buf, msg.len,
+ r->hash_algo->empty_tree, parents,
+ out, author, committer,
+ NULL, NULL)) {
+ ret = error(_("could not write commit"));
+ goto out;
+ }
+out:
+ strbuf_release(&msg);
+ repo_unuse_commit_buffer(r, this, buffer);
+ free(author);
+ free(committer);
+ return ret;
+}
+
+static int do_import_stash(struct repository *r, const char *rev)
+{
+ struct object_id chain;
+ int res = 0;
+ const char *buffer = NULL;
+ unsigned long bufsize;
+ struct commit *this = NULL;
+ struct commit_list *items = NULL, *cur;
+ char *msg = NULL;
+
+ if (repo_get_oid(r, rev, &chain))
+ return error(_("not a valid revision: %s"), rev);
+
+ this = lookup_commit_reference(r, &chain);
+ if (!this)
+ return error(_("not a commit: %s"), rev);
+
+ /*
+ * Walk the commit history, finding each stash entry, and load data into
+ * the array.
+ */
+ for (;;) {
+ const char *author, *committer;
+ size_t author_len, committer_len;
+ const char *p;
+ const char *expected = "git stash <git@stash> 1000684800 +0000";
+ const char *prefix = "git stash: ";
+ struct commit *stash;
+ struct tree *tree = repo_get_commit_tree(r, this);
+
+ if (!tree ||
+ !oideq(&tree->object.oid, r->hash_algo->empty_tree) ||
+ (this->parents &&
+ (!this->parents->next || this->parents->next->next))) {
+ res = error(_("%s is not a valid exported stash commit"),
+ oid_to_hex(&this->object.oid));
+ goto out;
+ }
+
+ buffer = repo_get_commit_buffer(r, this, &bufsize);
+
+ if (!this->parents) {
+ /*
+ * We don't have any parents. Make sure this is our
+ * root commit.
+ */
+ author = find_commit_header(buffer, "author", &author_len);
+ committer = find_commit_header(buffer, "committer", &committer_len);
+
+ if (!author || !committer) {
+ error(_("cannot parse commit %s"), oid_to_hex(&this->object.oid));
+ goto out;
+ }
+
+ if (author_len != strlen(expected) ||
+ committer_len != strlen(expected) ||
+ memcmp(author, expected, author_len) ||
+ memcmp(committer, expected, committer_len)) {
+ res = error(_("found root commit %s with invalid data"), oid_to_hex(&this->object.oid));
+ goto out;
+ }
+ break;
+ }
+
+ p = strstr(buffer, "\n\n");
+ if (!p) {
+ res = error(_("cannot parse commit %s"), oid_to_hex(&this->object.oid));
+ goto out;
+ }
+
+ p += 2;
+ if (((size_t)(bufsize - (p - buffer)) < strlen(prefix)) ||
+ memcmp(prefix, p, strlen(prefix))) {
+ res = error(_("found stash commit %s without expected prefix"), oid_to_hex(&this->object.oid));
+ goto out;
+ }
+
+ stash = this->parents->next->item;
+
+ if (repo_parse_commit(r, this->parents->item) ||
+ repo_parse_commit(r, stash)) {
+ res = error(_("cannot parse parents of commit: %s"),
+ oid_to_hex(&this->object.oid));
+ goto out;
+ }
+
+ if (check_stash_topology(r, stash)) {
+ res = error(_("%s does not look like a stash commit"),
+ oid_to_hex(&stash->object.oid));
+ goto out;
+ }
+
+ repo_unuse_commit_buffer(r, this, buffer);
+ buffer = NULL;
+ items = commit_list_insert(stash, &items);
+ this = this->parents->item;
+ }
+
+ /*
+ * Now, walk each entry, adding it to the stash as a normal stash
+ * commit.
+ */
+ for (cur = items; cur; cur = cur->next) {
+ const char *p;
+ struct object_id *oid;
+
+ this = cur->item;
+ oid = &this->object.oid;
+ buffer = repo_get_commit_buffer(r, this, &bufsize);
+ if (!buffer) {
+ res = error(_("cannot read commit buffer for %s"), oid_to_hex(oid));
+ goto out;
+ }
+
+ p = strstr(buffer, "\n\n");
+ if (!p) {
+ res = error(_("cannot parse commit %s"), oid_to_hex(oid));
+ goto out;
+ }
+
+ p += 2;
+ msg = xmemdupz(p, bufsize - (p - buffer));
+ repo_unuse_commit_buffer(r, this, buffer);
+ buffer = NULL;
+
+ if (do_store_stash(oid, msg, 1)) {
+ res = error(_("cannot save the stash for %s"), oid_to_hex(oid));
+ goto out;
+ }
+ FREE_AND_NULL(msg);
+ }
+out:
+ if (this && buffer)
+ repo_unuse_commit_buffer(r, this, buffer);
+ free_commit_list(items);
+ free(msg);
+
+ return res;
+}
+
+static int import_stash(int argc, const char **argv, const char *prefix,
+ struct repository *repo)
+{
+ struct option options[] = {
+ OPT_END()
+ };
+
+ argc = parse_options(argc, argv, prefix, options,
+ git_stash_import_usage,
+ PARSE_OPT_KEEP_DASHDASH);
+
+ if (argc != 1)
+ usage_msg_opt("a revision is required", git_stash_import_usage, options);
+
+ return do_import_stash(repo, argv[0]);
+}
+
+struct stash_entry_data {
+ struct repository *r;
+ struct commit_list **items;
+ size_t count;
+};
+
+static int collect_stash_entries(struct object_id *old_oid UNUSED,
+ struct object_id *new_oid,
+ const char *committer UNUSED,
+ timestamp_t timestamp UNUSED,
+ int tz UNUSED, const char *msg UNUSED,
+ void *cb_data)
+{
+ struct stash_entry_data *data = cb_data;
+ struct commit *stash;
+
+ data->count++;
+ stash = lookup_commit_reference(data->r, new_oid);
+ if (!stash || check_stash_topology(data->r, stash)) {
+ return error(_("%s does not look like a stash commit"),
+ oid_to_hex(new_oid));
+ }
+ data->items = commit_list_append(stash, data->items);
+ return 0;
+}
+
+static int do_export_stash(struct repository *r,
+ const char *ref,
+ int argc,
+ const char **argv)
+{
+ struct object_id base;
+ struct object_context unused;
+ struct commit *prev;
+ struct commit_list *items = NULL, **iter = &items, *cur;
+ int res = 0;
+ int i;
+ struct strbuf revision = STRBUF_INIT;
+ const char *author, *committer;
+
+ /*
+ * This is an arbitrary, fixed date, specifically the one used by git
+ * format-patch. The goal is merely to produce reproducible output.
+ */
+ prepare_fallback_ident("git stash", "git@stash");
+ author = fmt_ident("git stash", "git@stash", WANT_BLANK_IDENT,
+ "2001-09-17T00:00:00Z", 0);
+ committer = fmt_ident("git stash", "git@stash", WANT_BLANK_IDENT,
+ "2001-09-17T00:00:00Z", 0);
+
+ /* First, we create a single empty commit. */
+ if (commit_tree_extended("", 0, r->hash_algo->empty_tree, NULL,
+ &base, author, committer, NULL, NULL))
+ return error(_("unable to write base commit"));
+
+ prev = lookup_commit_reference(r, &base);
+
+ if (argc) {
+ /*
+ * Find each specified stash, and load data into the array.
+ */
+ for (i = 0; i < argc; i++) {
+ struct object_id oid;
+ struct commit *stash;
+
+ if (parse_stash_revision(&revision, argv[i], 1) ||
+ get_oid_with_context(r, revision.buf,
+ GET_OID_QUIETLY | GET_OID_GENTLY,
+ &oid, &unused)) {
+ res = error(_("unable to find stash entry %s"), argv[i]);
+ goto out;
+ }
+
+ stash = lookup_commit_reference(r, &oid);
+ if (!stash || check_stash_topology(r, stash)) {
+ res = error(_("%s does not look like a stash commit"),
+ revision.buf);
+ goto out;
+ }
+ iter = commit_list_append(stash, iter);
+ }
+ } else {
+ /*
+ * Walk the reflog, finding each stash entry, and load data into the
+ * array.
+ */
+ struct stash_entry_data cb_data = {
+ .r = r, .items = iter,
+ };
+ if (refs_for_each_reflog_ent_reverse(get_main_ref_store(r),
+ "refs/stash",
+ collect_stash_entries,
+ &cb_data) && cb_data.count)
+ goto out;
+ }
+
+ /*
+ * Now, create a set of commits identical to the regular stash commits,
+ * but where their first parents form a chain to our original empty
+ * base commit.
+ */
+ items = reverse_commit_list(items);
+ for (cur = items; cur; cur = cur->next) {
+ struct commit_list *parents = NULL;
+ struct commit_list **next = &parents;
+ struct object_id out;
+ struct commit *stash = cur->item;
+
+ next = commit_list_append(prev, next);
+ next = commit_list_append(stash, next);
+ res = write_commit_with_parents(r, &out, &stash->object.oid, parents);
+ free_commit_list(parents);
+ if (res)
+ goto out;
+ prev = lookup_commit_reference(r, &out);
+ }
+ if (ref)
+ refs_update_ref(get_main_ref_store(r), NULL, ref,
+ &prev->object.oid, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
+ else
+ puts(oid_to_hex(&prev->object.oid));
+out:
+ strbuf_release(&revision);
+ free_commit_list(items);
+
+ return res;
+}
+
+enum export_action {
+ ACTION_NONE,
+ ACTION_PRINT,
+ ACTION_TO_REF,
+};
+
+static int export_stash(int argc,
+ const char **argv,
+ const char *prefix,
+ struct repository *repo)
+{
+ const char *ref = NULL;
+ enum export_action action = ACTION_NONE;
+ struct option options[] = {
+ OPT_CMDMODE(0, "print", &action,
+ N_("print the object ID instead of writing it to a ref"),
+ ACTION_PRINT),
+ OPT_STRING(0, "to-ref", &ref, "ref",
+ N_("save the data to the given ref")),
+ OPT_END()
+ };
+
+ argc = parse_options(argc, argv, prefix, options,
+ git_stash_export_usage,
+ PARSE_OPT_KEEP_DASHDASH);
+
+ if (ref && action == ACTION_NONE)
+ action = ACTION_TO_REF;
+
+ if (action == ACTION_NONE || (ref && action == ACTION_PRINT))
+ return error(_("exactly one of --print and --to-ref is required"));
+
+ return do_export_stash(repo, ref, argc, argv);
+}
+
int cmd_stash(int argc,
const char **argv,
const char *prefix,
@@ -1904,6 +2350,8 @@ int cmd_stash(int argc,
OPT_SUBCOMMAND("store", &fn, store_stash),
OPT_SUBCOMMAND("create", &fn, create_stash),
OPT_SUBCOMMAND("push", &fn, push_stash_unassumed),
+ OPT_SUBCOMMAND("export", &fn, export_stash),
+ OPT_SUBCOMMAND("import", &fn, import_stash),
OPT_SUBCOMMAND_F("save", &fn, save_stash, PARSE_OPT_NOCOMPLETE),
OPT_END()
};
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 53da211..afef77a 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -303,7 +303,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
char *displaypath;
if (validate_submodule_path(path) < 0)
- exit(128);
+ die(NULL);
displaypath = get_submodule_displaypath(path, info->prefix,
info->super_prefix);
@@ -643,7 +643,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
};
if (validate_submodule_path(path) < 0)
- exit(128);
+ die(NULL);
if (!submodule_from_path(the_repository, null_oid(the_hash_algo), path))
die(_("no submodule mapping found in .gitmodules for path '%s'"),
@@ -1257,7 +1257,7 @@ static void sync_submodule(const char *path, const char *prefix,
return;
if (validate_submodule_path(path) < 0)
- exit(128);
+ die(NULL);
sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
@@ -1402,7 +1402,7 @@ static void deinit_submodule(const char *path, const char *prefix,
char *sub_git_dir = xstrfmt("%s/.git", path);
if (validate_submodule_path(path) < 0)
- exit(128);
+ die(NULL);
sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
@@ -1724,7 +1724,7 @@ static int clone_submodule(const struct module_clone_data *clone_data,
char *to_free = NULL;
if (validate_submodule_path(clone_data_path) < 0)
- exit(128);
+ die(NULL);
if (!is_absolute_path(clone_data->path))
clone_data_path = to_free = xstrfmt("%s/%s", repo_get_work_tree(the_repository),
@@ -2660,8 +2660,10 @@ static int update_submodule(struct update_data *update_data)
if (code)
return code;
code = remote_submodule_branch(update_data->sm_path, &branch);
- if (code)
+ if (code) {
+ free(remote_name);
return code;
+ }
remote_ref = xstrfmt("refs/remotes/%s/%s", remote_name, branch);
free(remote_name);
@@ -3524,7 +3526,7 @@ static int module_add(int argc, const char **argv, const char *prefix,
strip_dir_trailing_slashes(add_data.sm_path);
if (validate_submodule_path(add_data.sm_path) < 0)
- exit(128);
+ die(NULL);
die_on_index_match(add_data.sm_path, force);
die_on_repo_without_commits(add_data.sm_path);
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 88a36ea..2dceeee 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -621,7 +621,7 @@ static void print_preparing_worktree_line(int detach,
else {
struct commit *commit = lookup_commit_reference_by_name(branch);
if (!commit)
- BUG(_("unreachable: invalid reference: %s"), branch);
+ BUG("unreachable: invalid reference: %s", branch);
fprintf_ln(stderr, _("Preparing worktree (detached HEAD %s)"),
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
}
diff --git a/bundle-uri.c b/bundle-uri.c
index 9accf15..c9d65aa 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -122,7 +122,7 @@ void print_bundle_list(FILE *fp, struct bundle_list *list)
int i;
for (i = 0; i < BUNDLE_HEURISTIC__COUNT; i++) {
if (heuristics[i].heuristic == list->heuristic) {
- printf("\theuristic = %s\n",
+ fprintf(fp, "\theuristic = %s\n",
heuristics[list->heuristic].name);
break;
}
diff --git a/config.c b/config.c
index b18b561..eb60c29 100644
--- a/config.c
+++ b/config.c
@@ -1595,11 +1595,6 @@ static int git_default_core_config(const char *var, const char *value,
return 0;
}
- if (!strcmp(var, "core.preloadindex")) {
- core_preload_index = git_config_bool(var, value);
- return 0;
- }
-
if (!strcmp(var, "core.createobject")) {
if (!value)
return config_error_nonbool(var);
diff --git a/config.mak.uname b/config.mak.uname
index 3e26bb0..b1c5c4d 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -190,9 +190,6 @@
SHELL_PATH = /bin/bash
SANE_TOOL_PATH = /usr/xpg6/bin:/usr/xpg4/bin
HAVE_ALLOCA_H = YesPlease
- NO_STRCASESTR = YesPlease
- NO_MEMMEM = YesPlease
- NO_MKDTEMP = YesPlease
NO_REGEX = YesPlease
NO_MSGFMT_EXTENDED_OPTIONS = YesPlease
HAVE_DEV_TTY = YesPlease
@@ -202,7 +199,10 @@
NO_IPV6 = YesPlease
NO_SOCKADDR_STORAGE = YesPlease
NO_UNSETENV = YesPlease
+ NO_MKDTEMP = YesPlease
+ NO_MEMMEM = YesPlease
NO_SETENV = YesPlease
+ NO_STRCASESTR = YesPlease
NO_STRLCPY = YesPlease
NO_STRTOUMAX = YesPlease
GIT_TEST_CMP = cmp
@@ -212,23 +212,45 @@
NO_IPV6 = YesPlease
NO_SOCKADDR_STORAGE = YesPlease
NO_UNSETENV = YesPlease
+ NO_MKDTEMP = YesPlease
+ NO_MEMMEM = YesPlease
NO_SETENV = YesPlease
+ NO_STRCASESTR = YesPlease
NO_STRLCPY = YesPlease
NO_STRTOUMAX = YesPlease
GIT_TEST_CMP = cmp
endif
ifeq ($(uname_R),5.8)
NO_UNSETENV = YesPlease
+ NO_MKDTEMP = YesPlease
+ NO_MEMMEM = YesPlease
NO_SETENV = YesPlease
+ NO_STRCASESTR = YesPlease
NO_STRTOUMAX = YesPlease
GIT_TEST_CMP = cmp
endif
ifeq ($(uname_R),5.9)
NO_UNSETENV = YesPlease
+ NO_MKDTEMP = YesPlease
+ NO_MEMMEM = YesPlease
NO_SETENV = YesPlease
+ NO_STRCASESTR = YesPlease
NO_STRTOUMAX = YesPlease
GIT_TEST_CMP = cmp
endif
+ ifeq ($(uname_R),5.10)
+ NO_UNSETENV = YesPlease
+ NO_MKDTEMP = YesPlease
+ NO_MEMMEM = YesPlease
+ NO_SETENV = YesPlease
+ NO_STRCASESTR = YesPlease
+ GIT_TEST_CMP = cmp
+ endif
+ ifeq ($(uname_R),5.11)
+ NO_UNSETENV = YesPlease
+ NO_SETENV = YesPlease
+ GIT_TEST_CMP = cmp
+ endif
INSTALL = /usr/ucb/install
TAR = gtar
BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__
diff --git a/contrib/coccinelle/commit.cocci b/contrib/coccinelle/commit.cocci
index af6dd4c..c528460 100644
--- a/contrib/coccinelle/commit.cocci
+++ b/contrib/coccinelle/commit.cocci
@@ -25,7 +25,8 @@
// functions, then the recommended transformation will be bogus with
// repo_get_commit_tree() on the LHS.
@@
-identifier f !~ "^(repo_get_commit_tree|get_commit_tree_in_graph_one|load_tree_for_commit|set_commit_tree)$";
+identifier f != { repo_get_commit_tree, get_commit_tree_in_graph_one,
+ load_tree_for_commit, set_commit_tree };
expression c;
@@
f(...) {<...
diff --git a/contrib/credential/netrc/meson.build b/contrib/credential/netrc/meson.build
index 3d74547..16fa69e 100644
--- a/contrib/credential/netrc/meson.build
+++ b/contrib/credential/netrc/meson.build
@@ -17,6 +17,6 @@
workdir: meson.current_source_dir(),
env: credential_netrc_testenv,
depends: test_dependencies + bin_wrappers + [credential_netrc],
- timeout: 0,
+ kwargs: test_kwargs,
)
endif
diff --git a/contrib/emacs/README b/contrib/emacs/README
deleted file mode 100644
index 977a16f..0000000
--- a/contrib/emacs/README
+++ /dev/null
@@ -1,33 +0,0 @@
-This directory used to contain various modules for Emacs support.
-
-These were added shortly after Git was first released. Since then
-Emacs's own support for Git got better than what was offered by these
-modes. There are also popular 3rd-party Git modes such as Magit which
-offer replacements for these.
-
-The following modules were available, and can be dug up from the Git
-history:
-
-* git.el:
-
- Wrapper for "git status" that provided access to other git commands.
-
- Modern alternatives to this include Magit, and VC mode that ships
- with Emacs.
-
-* git-blame.el:
-
- A wrapper for "git blame" written before Emacs's own vc-annotate
- mode learned to invoke git-blame, which can be done via C-x v g.
-
-* vc-git.el:
-
- This file used to contain the VC-mode backend for git, but it is no
- longer distributed with git. It is now maintained as part of Emacs
- and included in standard Emacs distributions starting from version
- 22.2.
-
- If you have an earlier Emacs version, upgrading to Emacs 22 is
- recommended, since the VC mode in older Emacs is not generic enough
- to be able to support git in a reasonable manner, and no attempt has
- been made to backport vc-git.el.
diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el
deleted file mode 100644
index 6a8a2b8..0000000
--- a/contrib/emacs/git-blame.el
+++ /dev/null
@@ -1,6 +0,0 @@
-(error "git-blame.el no longer ships with git. It's recommended
-to replace its use with Emacs's own vc-annotate. See
-contrib/emacs/README in git's
-sources (https://github.com/git/git/blob/master/contrib/emacs/README)
-for more info on suggested alternatives and for why this
-happened.")
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
deleted file mode 100644
index 03f9262..0000000
--- a/contrib/emacs/git.el
+++ /dev/null
@@ -1,6 +0,0 @@
-(error "git.el no longer ships with git. It's recommended to
-replace its use with Magit, or simply delete references to git.el
-in your initialization file(s). See contrib/emacs/README in git's
-sources (https://github.com/git/git/blob/master/contrib/emacs/README)
-for suggested alternatives and for why this happened. Emacs's own
-VC mode and Magit are viable alternatives.")
diff --git a/contrib/examples/README b/contrib/examples/README
deleted file mode 100644
index 18bc60b..0000000
--- a/contrib/examples/README
+++ /dev/null
@@ -1,20 +0,0 @@
-This directory used to contain scripted implementations of builtins
-that have since been rewritten in C.
-
-They have now been removed, but can be retrieved from an older commit
-that removed them from this directory.
-
-They're interesting for their reference value to any aspiring plumbing
-users who want to learn how pieces can be fit together, but in many
-cases have drifted enough from the actual implementations Git uses to
-be instructive.
-
-Other things that can be useful:
-
- * Some commands such as git-gc wrap other commands, and what they're
- doing behind the scenes can be seen by running them under
- GIT_TRACE=1
-
- * Doing `git log` on paths matching '*--helper.c' will show
- incremental effort in the direction of moving existing shell
- scripts to C.
diff --git a/contrib/git-resurrect.sh b/contrib/git-resurrect.sh
deleted file mode 100755
index d843df3..0000000
--- a/contrib/git-resurrect.sh
+++ /dev/null
@@ -1,181 +0,0 @@
-#!/bin/sh
-
-USAGE="[-a] [-r] [-m] [-t] [-n] [-b <newname>] <name>"
-LONG_USAGE="git-resurrect attempts to find traces of a branch tip
-called <name>, and tries to resurrect it. Currently, the reflog is
-searched for checkout messages, and with -r also merge messages. With
--m and -t, the history of all refs is scanned for Merge <name> into
-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_STUCKLONG=
-OPTIONS_SPEC="\
-git resurrect $USAGE
---
-b,branch= save branch as <newname> instead of <name>
-a,all same as -l -r -m -t
-k,keep-going full rev-list scan (instead of first match)
-l,reflog scan reflog for checkouts (enabled by default)
-r,reflog-merges scan for merges recorded in reflog
-m,merges scan for merges into other branches (slow)
-t,merge-targets scan for merges of other branches into <name>
-n,dry-run don't recreate the branch"
-
-. git-sh-setup
-
-search_reflog () {
- sed -ne 's~^\([^ ]*\) .* checkout: moving from '"$1"' .*~\1~p' \
- < "$GIT_DIR"/logs/HEAD
-}
-
-search_reflog_merges () {
- git rev-parse $(
- sed -ne 's~^[^ ]* \([^ ]*\) .* merge '"$1"':.*~\1^2~p' \
- < "$GIT_DIR"/logs/HEAD
- )
-}
-
-oid_pattern=$(git hash-object --stdin </dev/null | sed -e 's/./[0-9a-f]/g')
-
-search_merges () {
- git rev-list --all --grep="Merge branch '$1'" \
- --pretty=tformat:"%P %s" |
- sed -ne "/^$oid_pattern \($oid_pattern\) Merge .*/ {s//\1/p;$early_exit}"
-}
-
-search_merge_targets () {
- git rev-list --all --grep="Merge branch '[^']*' into $branch\$" \
- --pretty=tformat:"%H %s" --all |
- sed -ne "/^\($oid_pattern\) Merge .*/ {s//\1/p;$early_exit} "
-}
-
-dry_run=
-early_exit=q
-scan_reflog=t
-scan_reflog_merges=
-scan_merges=
-scan_merge_targets=
-new_name=
-
-while test "$#" != 0; do
- case "$1" in
- -b|--branch)
- shift
- new_name="$1"
- ;;
- -n|--dry-run)
- dry_run=t
- ;;
- --no-dry-run)
- dry_run=
- ;;
- -k|--keep-going)
- early_exit=
- ;;
- --no-keep-going)
- early_exit=q
- ;;
- -m|--merges)
- scan_merges=t
- ;;
- --no-merges)
- scan_merges=
- ;;
- -l|--reflog)
- scan_reflog=t
- ;;
- --no-reflog)
- scan_reflog=
- ;;
- -r|--reflog_merges)
- scan_reflog_merges=t
- ;;
- --no-reflog_merges)
- scan_reflog_merges=
- ;;
- -t|--merge-targets)
- scan_merge_targets=t
- ;;
- --no-merge-targets)
- scan_merge_targets=
- ;;
- -a|--all)
- scan_reflog=t
- scan_reflog_merges=t
- scan_merges=t
- scan_merge_targets=t
- ;;
- --)
- shift
- break
- ;;
- *)
- usage
- ;;
- esac
- shift
-done
-
-test "$#" = 1 || usage
-
-all_strategies="$scan_reflog$scan_reflog_merges$scan_merges$scan_merge_targets"
-if test -z "$all_strategies"; then
- die "must enable at least one of -lrmt"
-fi
-
-branch="$1"
-test -z "$new_name" && new_name="$branch"
-
-if test ! -z "$scan_reflog"; then
- if test -r "$GIT_DIR"/logs/HEAD; then
- candidates="$(search_reflog $branch)"
- else
- die 'reflog scanning requested, but' \
- '$GIT_DIR/logs/HEAD not readable'
- fi
-fi
-if test ! -z "$scan_reflog_merges"; then
- if test -r "$GIT_DIR"/logs/HEAD; then
- candidates="$candidates $(search_reflog_merges $branch)"
- else
- die 'reflog scanning requested, but' \
- '$GIT_DIR/logs/HEAD not readable'
- fi
-fi
-if test ! -z "$scan_merges"; then
- candidates="$candidates $(search_merges $branch)"
-fi
-if test ! -z "$scan_merge_targets"; then
- candidates="$candidates $(search_merge_targets $branch)"
-fi
-
-candidates="$(git rev-parse $candidates | sort -u)"
-
-if test -z "$candidates"; then
- hint=
- test "z$all_strategies" != "ztttt" \
- && hint=" (maybe try again with -a)"
- die "no candidates for $branch found$hint"
-fi
-
-echo "** Candidates for $branch **"
-for cmt in $candidates; do
- git --no-pager log --pretty=tformat:"%ct:%h [%cr] %s" --abbrev-commit -1 $cmt
-done \
-| sort -n | cut -d: -f2-
-
-newest="$(git rev-list -1 $candidates)"
-if test ! -z "$dry_run"; then
- printf "** Most recent: "
- git --no-pager log -1 --pretty=tformat:"%h %s" $newest
-elif ! git rev-parse --verify --quiet $new_name >/dev/null; then
- printf "** Restoring $new_name to "
- git --no-pager log -1 --pretty=tformat:"%h %s" $newest
- git branch $new_name $newest
-else
- printf "Most recent: "
- git --no-pager log -1 --pretty=tformat:"%h %s" $newest
- echo "** $new_name already exists, doing nothing"
-fi
diff --git a/contrib/hooks/multimail/README.Git b/contrib/hooks/multimail/README.Git
deleted file mode 100644
index c427efc..0000000
--- a/contrib/hooks/multimail/README.Git
+++ /dev/null
@@ -1,7 +0,0 @@
-git-multimail is developed as an independent project at the following
-website:
-
- https://github.com/git-multimail/git-multimail
-
-Please refer to that project page for information about how to report
-bugs or contribute to git-multimail.
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
deleted file mode 100755
index ff565eb..0000000
--- a/contrib/hooks/post-receive-email
+++ /dev/null
@@ -1,759 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2007 Andy Parkins
-#
-# An example hook script to mail out commit update information.
-#
-# NOTE: This script is no longer under active development. There
-# is another script, git-multimail, which is more capable and
-# configurable and is largely backwards-compatible with this script;
-# please see "contrib/hooks/multimail/". For instructions on how to
-# migrate from post-receive-email to git-multimail, please see
-# "README.migrate-from-post-receive-email" in that directory.
-#
-# This hook sends emails listing new revisions to the repository
-# introduced by the change being reported. The rule is that (for
-# branch updates) each commit will appear on one email and one email
-# only.
-#
-# This hook is stored in the contrib/hooks directory. Your distribution
-# will have put this somewhere standard. You should make this script
-# executable then link to it in the repository you would like to use it in.
-# For example, on debian the hook is stored in
-# /usr/share/git-core/contrib/hooks/post-receive-email:
-#
-# cd /path/to/your/repository.git
-# ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive
-#
-# This hook script assumes it is enabled on the central repository of a
-# project, with all users pushing only to it and not between each other. It
-# will still work if you don't operate in that style, but it would become
-# 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
-# This is the list that all pushes will go to; leave it blank to not send
-# emails for every ref update.
-# hooks.announcelist
-# This is the list that all pushes of annotated tags will go to. Leave it
-# blank to default to the mailinglist field. The announce emails lists
-# the short log summary of the changes since the last annotated tag.
-# hooks.envelopesender
-# If set then the -f option is passed to sendmail to allow the envelope
-# sender address to be set
-# hooks.emailprefix
-# All emails have their subjects prefixed with this prefix, or "[SCM]"
-# if emailprefix is unset, to aid filtering
-# hooks.showrev
-# The shell command used to format each revision in the email, with
-# "%s" replaced with the commit id. Defaults to "git rev-list -1
-# --pretty %s", displaying the commit id, author, date and log
-# message. To list full patches separated by a blank line, you
-# could set this to "git show -C %s; echo".
-# To list a gitweb/cgit URL *and* a full patch for each change set, use this:
-# "t=%s; printf 'http://.../?id=%%s' \$t; echo;echo; git show -C \$t; echo"
-# Be careful if "..." contains things that will be expanded by shell "eval"
-# or printf.
-# hooks.emailmaxlines
-# The maximum number of lines that should be included in the generated
-# email body. If not specified, there is no limit.
-# Lines beyond the limit are suppressed and counted, and a final
-# line is added indicating the number of suppressed lines.
-# hooks.diffopts
-# Alternate options for the git diff-tree invocation that shows changes.
-# Default is "--stat --summary --find-copies-harder". Add -p to those
-# options to include a unified diff of changes in addition to the usual
-# summary output.
-#
-# Notes
-# -----
-# All emails include the headers "X-Git-Refname", "X-Git-Oldrev",
-# "X-Git-Newrev", and "X-Git-Reftype" to enable fine tuned filtering and
-# give information for debugging.
-#
-
-# ---------------------------- Functions
-
-#
-# Function to prepare for email generation. This decides what type
-# of update this is and whether an email should even be generated.
-#
-prep_for_email()
-{
- # --- Arguments
- oldrev=$(git rev-parse $1)
- newrev=$(git rev-parse $2)
- refname="$3"
-
- # --- Interpret
- # 0000->1234 (create)
- # 1234->2345 (update)
- # 2345->0000 (delete)
- if expr "$oldrev" : '0*$' >/dev/null
- then
- change_type="create"
- else
- if expr "$newrev" : '0*$' >/dev/null
- then
- change_type="delete"
- else
- change_type="update"
- fi
- fi
-
- # --- Get the revision types
- newrev_type=$(git cat-file -t $newrev 2> /dev/null)
- oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null)
- case "$change_type" in
- create|update)
- rev="$newrev"
- rev_type="$newrev_type"
- ;;
- delete)
- rev="$oldrev"
- rev_type="$oldrev_type"
- ;;
- esac
-
- # The revision type tells us what type the commit is, combined with
- # the location of the ref we can decide between
- # - working branch
- # - tracking branch
- # - unannoted tag
- # - annotated tag
- case "$refname","$rev_type" in
- refs/tags/*,commit)
- # un-annotated tag
- refname_type="tag"
- short_refname=${refname##refs/tags/}
- ;;
- refs/tags/*,tag)
- # annotated tag
- refname_type="annotated tag"
- short_refname=${refname##refs/tags/}
- # change recipients
- if [ -n "$announcerecipients" ]; then
- recipients="$announcerecipients"
- fi
- ;;
- refs/heads/*,commit)
- # branch
- refname_type="branch"
- short_refname=${refname##refs/heads/}
- ;;
- refs/remotes/*,commit)
- # tracking branch
- refname_type="tracking branch"
- short_refname=${refname##refs/remotes/}
- echo >&2 "*** Push-update of tracking branch, $refname"
- echo >&2 "*** - no email generated."
- return 1
- ;;
- *)
- # Anything else (is there anything else?)
- echo >&2 "*** Unknown type of update to $refname ($rev_type)"
- echo >&2 "*** - no email generated"
- return 1
- ;;
- esac
-
- # Check if we've got anyone to send to
- if [ -z "$recipients" ]; then
- case "$refname_type" in
- "annotated tag")
- config_name="hooks.announcelist"
- ;;
- *)
- config_name="hooks.mailinglist"
- ;;
- esac
- echo >&2 "*** $config_name is not set so no email will be sent"
- echo >&2 "*** for $refname update $oldrev->$newrev"
- return 1
- fi
-
- return 0
-}
-
-#
-# Top level email generation function. This calls the appropriate
-# body-generation routine after outputting the common header.
-#
-# Note this function doesn't actually generate any email output, that is
-# taken care of by the functions it calls:
-# - generate_email_header
-# - generate_create_XXXX_email
-# - generate_update_XXXX_email
-# - generate_delete_XXXX_email
-# - generate_email_footer
-#
-# Note also that this function cannot 'exit' from the script; when this
-# function is running (in hook script mode), the send_mail() function
-# is already executing in another process, connected via a pipe, and
-# if this function exits without, whatever has been generated to that
-# point will be sent as an email... even if nothing has been generated.
-#
-generate_email()
-{
- # Email parameters
- # The email subject will contain the best description of the ref
- # that we can build from the parameters
- describe=$(git describe $rev 2>/dev/null)
- if [ -z "$describe" ]; then
- describe=$rev
- fi
-
- generate_email_header
-
- # Call the correct body generation function
- fn_name=general
- case "$refname_type" in
- "tracking branch"|branch)
- fn_name=branch
- ;;
- "annotated tag")
- fn_name=atag
- ;;
- esac
-
- if [ -z "$maxlines" ]; then
- generate_${change_type}_${fn_name}_email
- else
- generate_${change_type}_${fn_name}_email | limit_lines $maxlines
- fi
-
- generate_email_footer
-}
-
-generate_email_header()
-{
- # --- Email (all stdout will be the email)
- # Generate header
- cat <<-EOF
- To: $recipients
- Subject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe
- MIME-Version: 1.0
- Content-Type: text/plain; charset=utf-8
- Content-Transfer-Encoding: 8bit
- X-Git-Refname: $refname
- X-Git-Reftype: $refname_type
- X-Git-Oldrev: $oldrev
- X-Git-Newrev: $newrev
- Auto-Submitted: auto-generated
-
- This is an automated email from the git hooks/post-receive script. It was
- generated because a ref change was pushed to the repository containing
- the project "$projectdesc".
-
- The $refname_type, $short_refname has been ${change_type}d
- EOF
-}
-
-generate_email_footer()
-{
- SPACE=" "
- cat <<-EOF
-
-
- hooks/post-receive
- --${SPACE}
- $projectdesc
- EOF
-}
-
-# --------------- Branches
-
-#
-# Called for the creation of a branch
-#
-generate_create_branch_email()
-{
- # This is a new branch and so oldrev is not valid
- echo " at $newrev ($newrev_type)"
- echo ""
-
- echo $LOGBEGIN
- show_new_revisions
- echo $LOGEND
-}
-
-#
-# Called for the change of a pre-existing branch
-#
-generate_update_branch_email()
-{
- # Consider this:
- # 1 --- 2 --- O --- X --- 3 --- 4 --- N
- #
- # O is $oldrev for $refname
- # N is $newrev for $refname
- # X is a revision pointed to by some other ref, for which we may
- # assume that an email has already been generated.
- # In this case we want to issue an email containing only revisions
- # 3, 4, and N. Given (almost) by
- #
- # git rev-list N ^O --not --all
- #
- # The reason for the "almost", is that the "--not --all" will take
- # precedence over the "N", and effectively will translate to
- #
- # git rev-list N ^O ^X ^N
- #
- # So, we need to build up the list more carefully. git rev-parse
- # will generate a list of revs that may be fed into git rev-list.
- # We can get it to make the "--not --all" part and then filter out
- # the "^N" with:
- #
- # git rev-parse --not --all | grep -v N
- #
- # Then, using the --stdin switch to git rev-list we have effectively
- # manufactured
- #
- # git rev-list N ^O ^X
- #
- # This leaves a problem when someone else updates the repository
- # while this script is running. Their new value of the ref we're
- # working on would be included in the "--not --all" output; and as
- # our $newrev would be an ancestor of that commit, it would exclude
- # all of our commits. What we really want is to exclude the current
- # value of $refname from the --not list, rather than N itself. So:
- #
- # git rev-parse --not --all | grep -v $(git rev-parse $refname)
- #
- # Gets us to something pretty safe (apart from the small time
- # between refname being read, and git rev-parse running - for that,
- # I give up)
- #
- #
- # Next problem, consider this:
- # * --- B --- * --- O ($oldrev)
- # \
- # * --- X --- * --- N ($newrev)
- #
- # That is to say, there is no guarantee that oldrev is a strict
- # subset of newrev (it would have required a --force, but that's
- # allowed). So, we can't simply say rev-list $oldrev..$newrev.
- # Instead we find the common base of the two revs and list from
- # there.
- #
- # As above, we need to take into account the presence of X; if
- # another branch is already in the repository and points at some of
- # the revisions that we are about to output - we don't want them.
- # The solution is as before: git rev-parse output filtered.
- #
- # Finally, tags: 1 --- 2 --- O --- T --- 3 --- 4 --- N
- #
- # Tags pushed into the repository generate nice shortlog emails that
- # summarise the commits between them and the previous tag. However,
- # those emails don't include the full commit messages that we output
- # for a branch update. Therefore we still want to output revisions
- # that have been output on a tag email.
- #
- # Luckily, git rev-parse includes just the tool. Instead of using
- # "--all" we use "--branches"; this has the added benefit that
- # "remotes/" will be ignored as well.
-
- # List all of the revisions that were removed by this update, in a
- # fast-forward update, this list will be empty, because rev-list O
- # ^N is empty. For a non-fast-forward, O ^N is the list of removed
- # revisions
- fast_forward=""
- rev=""
- for rev in $(git rev-list $newrev..$oldrev)
- do
- revtype=$(git cat-file -t "$rev")
- echo " discards $rev ($revtype)"
- done
- if [ -z "$rev" ]; then
- fast_forward=1
- fi
-
- # List all the revisions from baserev to newrev in a kind of
- # "table-of-contents"; note this list can include revisions that
- # have already had notification emails and is present to show the
- # full detail of the change from rolling back the old revision to
- # the base revision and then forward to the new revision
- for rev in $(git rev-list $oldrev..$newrev)
- do
- revtype=$(git cat-file -t "$rev")
- echo " via $rev ($revtype)"
- done
-
- if [ "$fast_forward" ]; then
- echo " from $oldrev ($oldrev_type)"
- else
- # 1. Existing revisions were removed. In this case newrev
- # is a subset of oldrev - this is the reverse of a
- # fast-forward, a rewind
- # 2. New revisions were added on top of an old revision,
- # this is a rewind and addition.
-
- # (1) certainly happened, (2) possibly. When (2) hasn't
- # happened, we set a flag to indicate that no log printout
- # is required.
-
- echo ""
-
- # Find the common ancestor of the old and new revisions and
- # compare it with newrev
- baserev=$(git merge-base $oldrev $newrev)
- rewind_only=""
- if [ "$baserev" = "$newrev" ]; then
- echo "This update discarded existing revisions and left the branch pointing at"
- echo "a previous point in the repository history."
- echo ""
- echo " * -- * -- N ($newrev)"
- echo " \\"
- echo " O -- O -- O ($oldrev)"
- echo ""
- echo "The removed revisions are not necessarily gone - if another reference"
- echo "still refers to them they will stay in the repository."
- rewind_only=1
- else
- echo "This update added new revisions after undoing existing revisions. That is"
- echo "to say, the old revision is not a strict subset of the new revision. This"
- echo "situation occurs when you --force push a change and generate a repository"
- echo "containing something like this:"
- echo ""
- echo " * -- * -- B -- O -- O -- O ($oldrev)"
- echo " \\"
- echo " N -- N -- N ($newrev)"
- echo ""
- echo "When this happens we assume that you've already had alert emails for all"
- echo "of the O revisions, and so we here report only the revisions in the N"
- echo "branch from the common base, B."
- fi
- fi
-
- echo ""
- if [ -z "$rewind_only" ]; then
- echo "Those revisions listed above that are new to this repository have"
- echo "not appeared on any other notification email; so we list those"
- echo "revisions in full, below."
-
- echo ""
- echo $LOGBEGIN
- show_new_revisions
-
- # XXX: Need a way of detecting whether git rev-list actually
- # outputted anything, so that we can issue a "no new
- # revisions added by this update" message
-
- echo $LOGEND
- else
- echo "No new revisions were added by this update."
- fi
-
- # The diffstat is shown from the old revision to the new revision.
- # This is to show the truth of what happened in this change.
- # There's no point showing the stat from the base to the new
- # revision because the base is effectively a random revision at this
- # point - the user will be interested in what this revision changed
- # - including the undoing of previous revisions in the case of
- # non-fast-forward updates.
- echo ""
- echo "Summary of changes:"
- git diff-tree $diffopts $oldrev..$newrev
-}
-
-#
-# Called for the deletion of a branch
-#
-generate_delete_branch_email()
-{
- echo " was $oldrev"
- echo ""
- echo $LOGBEGIN
- git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
- echo $LOGEND
-}
-
-# --------------- Annotated tags
-
-#
-# Called for the creation of an annotated tag
-#
-generate_create_atag_email()
-{
- echo " at $newrev ($newrev_type)"
-
- generate_atag_email
-}
-
-#
-# Called for the update of an annotated tag (this is probably a rare event
-# and may not even be allowed)
-#
-generate_update_atag_email()
-{
- echo " to $newrev ($newrev_type)"
- echo " from $oldrev (which is now obsolete)"
-
- generate_atag_email
-}
-
-#
-# Called when an annotated tag is created or changed
-#
-generate_atag_email()
-{
- # Use git for-each-ref to pull out the individual fields from the
- # tag
- eval $(git for-each-ref --shell --format='
- tagobject=%(*objectname)
- tagtype=%(*objecttype)
- tagger=%(taggername)
- tagged=%(taggerdate)' $refname
- )
-
- echo " tagging $tagobject ($tagtype)"
- case "$tagtype" in
- commit)
-
- # If the tagged object is a commit, then we assume this is a
- # release, and so we calculate which tag this tag is
- # replacing
- prevtag=$(git describe --abbrev=0 $newrev^ 2>/dev/null)
-
- if [ -n "$prevtag" ]; then
- echo " replaces $prevtag"
- fi
- ;;
- *)
- echo " length $(git cat-file -s $tagobject) bytes"
- ;;
- esac
- echo " tagged by $tagger"
- echo " on $tagged"
-
- echo ""
- echo $LOGBEGIN
-
- # Show the content of the tag message; this might contain a change
- # log or release notes so is worth displaying.
- git cat-file tag $newrev | sed -e '1,/^$/d'
-
- echo ""
- case "$tagtype" in
- commit)
- # Only commit tags make sense to have rev-list operations
- # performed on them
- if [ -n "$prevtag" ]; then
- # Show changes since the previous release
- git shortlog "$prevtag..$newrev"
- else
- # No previous tag, show all the changes since time
- # began
- git shortlog $newrev
- fi
- ;;
- *)
- # XXX: Is there anything useful we can do for non-commit
- # objects?
- ;;
- esac
-
- echo $LOGEND
-}
-
-#
-# Called for the deletion of an annotated tag
-#
-generate_delete_atag_email()
-{
- echo " was $oldrev"
- echo ""
- echo $LOGBEGIN
- git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
- echo $LOGEND
-}
-
-# --------------- General references
-
-#
-# Called when any other type of reference is created (most likely a
-# non-annotated tag)
-#
-generate_create_general_email()
-{
- echo " at $newrev ($newrev_type)"
-
- generate_general_email
-}
-
-#
-# Called when any other type of reference is updated (most likely a
-# non-annotated tag)
-#
-generate_update_general_email()
-{
- echo " to $newrev ($newrev_type)"
- echo " from $oldrev"
-
- generate_general_email
-}
-
-#
-# Called for creation or update of any other type of reference
-#
-generate_general_email()
-{
- # Unannotated tags are more about marking a point than releasing a
- # version; therefore we don't do the shortlog summary that we do for
- # annotated tags above - we simply show that the point has been
- # marked, and print the log message for the marked point for
- # reference purposes
- #
- # Note this section also catches any other reference type (although
- # there aren't any) and deals with them in the same way.
-
- echo ""
- if [ "$newrev_type" = "commit" ]; then
- echo $LOGBEGIN
- git diff-tree -s --always --encoding=UTF-8 --pretty=medium $newrev
- echo $LOGEND
- else
- # What can we do here? The tag marks an object that is not
- # a commit, so there is no log for us to display. It's
- # probably not wise to output git cat-file as it could be a
- # binary blob. We'll just say how big it is
- echo "$newrev is a $newrev_type, and is $(git cat-file -s $newrev) bytes long."
- fi
-}
-
-#
-# Called for the deletion of any other type of reference
-#
-generate_delete_general_email()
-{
- echo " was $oldrev"
- echo ""
- echo $LOGBEGIN
- git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
- echo $LOGEND
-}
-
-
-# --------------- Miscellaneous utilities
-
-#
-# Show new revisions as the user would like to see them in the email.
-#
-show_new_revisions()
-{
- # This shows all log entries that are not already covered by
- # another ref - i.e. commits that are now accessible from this
- # ref that were previously not accessible
- # (see generate_update_branch_email for the explanation of this
- # command)
-
- # Revision range passed to rev-list differs for new vs. updated
- # branches.
- if [ "$change_type" = create ]
- then
- # Show all revisions exclusive to this (new) branch.
- revspec=$newrev
- else
- # Branch update; show revisions not part of $oldrev.
- revspec=$oldrev..$newrev
- fi
-
- other_branches=$(git for-each-ref --format='%(refname)' refs/heads/ |
- grep -F -v $refname)
- git rev-parse --not $other_branches |
- if [ -z "$custom_showrev" ]
- then
- git rev-list --pretty --stdin $revspec
- else
- git rev-list --stdin $revspec |
- while read onerev
- do
- eval $(printf "$custom_showrev" $onerev)
- done
- fi
-}
-
-
-limit_lines()
-{
- lines=0
- skipped=0
- while IFS="" read -r line; do
- lines=$((lines + 1))
- if [ $lines -gt $1 ]; then
- skipped=$((skipped + 1))
- else
- printf "%s\n" "$line"
- fi
- done
- if [ $skipped -ne 0 ]; then
- echo "... $skipped lines suppressed ..."
- fi
-}
-
-
-send_mail()
-{
- if [ -n "$envelopesender" ]; then
- /usr/sbin/sendmail -t -f "$envelopesender"
- else
- /usr/sbin/sendmail -t
- fi
-}
-
-# ---------------------------- main()
-
-# --- Constants
-LOGBEGIN="- Log -----------------------------------------------------------------"
-LOGEND="-----------------------------------------------------------------------"
-
-# --- Config
-# Set GIT_DIR either from the working directory, or from the environment
-# variable.
-GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
-if [ -z "$GIT_DIR" ]; then
- echo >&2 "fatal: post-receive: GIT_DIR not set"
- exit 1
-fi
-
-projectdesc=$(sed -ne '1p' "$GIT_DIR/description" 2>/dev/null)
-# Check if the description is unchanged from it's default, and shorten it to
-# a more manageable length if it is
-if expr "$projectdesc" : "Unnamed repository.*$" >/dev/null
-then
- projectdesc="UNNAMED PROJECT"
-fi
-
-recipients=$(git config hooks.mailinglist)
-announcerecipients=$(git config hooks.announcelist)
-envelopesender=$(git config hooks.envelopesender)
-emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
-custom_showrev=$(git config hooks.showrev)
-maxlines=$(git config hooks.emailmaxlines)
-diffopts=$(git config hooks.diffopts)
-: ${diffopts:="--stat --summary --find-copies-harder"}
-
-# --- Main loop
-# Allow dual mode: run from the command line just like the update hook, or
-# if no arguments are given then run as a hook script
-if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
- # Output to the terminal in command line mode - if someone wanted to
- # resend an email; they could redirect the output to sendmail
- # themselves
- prep_for_email $2 $3 $1 && PAGER= generate_email
-else
- while read oldrev newrev refname
- do
- prep_for_email $oldrev $newrev $refname || continue
- generate_email $maxlines | send_mail
- done
-fi
diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery
deleted file mode 100755
index 7ba78c4..0000000
--- a/contrib/hooks/pre-auto-gc-battery
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/sh
-#
-# An example hook script to verify if you are on battery, in case you
-# are running Linux or OS X. Called by git-gc --auto with no arguments.
-# The hook should exit with non-zero status after issuing an appropriate
-# message if it wants to stop the auto repacking.
-#
-# This hook is stored in the contrib/hooks directory. Your distribution
-# may have put this somewhere else. If you want to use this hook, you
-# should make this script executable then link to it in the repository
-# you would like to use it in.
-#
-# For example, if the hook is stored in
-# /usr/share/git-core/contrib/hooks/pre-auto-gc-battery:
-#
-# cd /path/to/your/repository.git
-# ln -sf /usr/share/git-core/contrib/hooks/pre-auto-gc-battery \
-# hooks/pre-auto-gc
-
-if test -x /sbin/on_ac_power && (/sbin/on_ac_power;test $? -ne 1)
-then
- exit 0
-elif test "$(cat /sys/class/power_supply/AC/online 2>/dev/null)" = 1
-then
- exit 0
-elif grep -q 'on-line' /proc/acpi/ac_adapter/AC/state 2>/dev/null
-then
- exit 0
-elif grep -q '0x01$' /proc/apm 2>/dev/null
-then
- exit 0
-elif grep -q "AC Power \+: 1" /proc/pmu/info 2>/dev/null
-then
- exit 0
-elif test -x /usr/bin/pmset && /usr/bin/pmset -g batt |
- grep -q "drawing from 'AC Power'"
-then
- exit 0
-fi
-
-echo "Auto packing deferred; not on AC"
-exit 1
diff --git a/contrib/hooks/setgitperms.perl b/contrib/hooks/setgitperms.perl
deleted file mode 100755
index 2770a1b..0000000
--- a/contrib/hooks/setgitperms.perl
+++ /dev/null
@@ -1,214 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) 2006 Josh England
-#
-# This script can be used to save/restore full permissions and ownership data
-# within a git working tree.
-#
-# To save permissions/ownership data, place this script in your .git/hooks
-# directory and enable a `pre-commit` hook with the following lines:
-# #!/bin/sh
-# SUBDIRECTORY_OK=1 . git-sh-setup
-# $GIT_DIR/hooks/setgitperms.perl -r
-#
-# To restore permissions/ownership data, place this script in your .git/hooks
-# directory and enable a `post-merge` and `post-checkout` hook with the
-# following lines:
-# #!/bin/sh
-# SUBDIRECTORY_OK=1 . git-sh-setup
-# $GIT_DIR/hooks/setgitperms.perl -w
-#
-use strict;
-use Getopt::Long;
-use File::Find;
-use File::Basename;
-
-my $usage =
-"usage: setgitperms.perl [OPTION]... <--read|--write>
-This program uses a file `.gitmeta` to store/restore permissions and uid/gid
-info for all files/dirs tracked by git in the repository.
-
----------------------------------Read Mode-------------------------------------
--r, --read Reads perms/etc from working dir into a .gitmeta file
--s, --stdout Output to stdout instead of .gitmeta
--d, --diff Show unified diff of perms file (XOR with --stdout)
-
----------------------------------Write Mode------------------------------------
--w, --write Modify perms/etc in working dir to match the .gitmeta file
--v, --verbose Be verbose
-
-\n";
-
-my ($stdout, $showdiff, $verbose, $read_mode, $write_mode);
-
-if ((@ARGV < 0) || !GetOptions(
- "stdout", \$stdout,
- "diff", \$showdiff,
- "read", \$read_mode,
- "write", \$write_mode,
- "verbose", \$verbose,
- )) { die $usage; }
-die $usage unless ($read_mode xor $write_mode);
-
-my $topdir = `git rev-parse --show-cdup` or die "\n"; chomp $topdir;
-my $gitdir = $topdir . '.git';
-my $gitmeta = $topdir . '.gitmeta';
-
-if ($write_mode) {
- # Update the working dir permissions/ownership based on data from .gitmeta
- open (IN, "<$gitmeta") or die "Could not open $gitmeta for reading: $!\n";
- while (defined ($_ = <IN>)) {
- chomp;
- if (/^(.*) mode=(\S+)\s+uid=(\d+)\s+gid=(\d+)/) {
- # Compare recorded perms to actual perms in the working dir
- my ($path, $mode, $uid, $gid) = ($1, $2, $3, $4);
- my $fullpath = $topdir . $path;
- my (undef,undef,$wmode,undef,$wuid,$wgid) = lstat($fullpath);
- $wmode = sprintf "%04o", $wmode & 07777;
- if ($mode ne $wmode) {
- $verbose && print "Updating permissions on $path: old=$wmode, new=$mode\n";
- chmod oct($mode), $fullpath;
- }
- if ($uid != $wuid || $gid != $wgid) {
- if ($verbose) {
- # Print out user/group names instead of uid/gid
- my $pwname = getpwuid($uid);
- my $grpname = getgrgid($gid);
- my $wpwname = getpwuid($wuid);
- my $wgrpname = getgrgid($wgid);
- $pwname = $uid if !defined $pwname;
- $grpname = $gid if !defined $grpname;
- $wpwname = $wuid if !defined $wpwname;
- $wgrpname = $wgid if !defined $wgrpname;
-
- print "Updating uid/gid on $path: old=$wpwname/$wgrpname, new=$pwname/$grpname\n";
- }
- chown $uid, $gid, $fullpath;
- }
- }
- else {
- warn "Invalid input format in $gitmeta:\n\t$_\n";
- }
- }
- close IN;
-}
-elsif ($read_mode) {
- # Handle merge conflicts in the .gitperms file
- if (-e "$gitdir/MERGE_MSG") {
- if (`grep ====== $gitmeta`) {
- # Conflict not resolved -- abort the commit
- print "PERMISSIONS/OWNERSHIP CONFLICT\n";
- print " Resolve the conflict in the $gitmeta file and then run\n";
- print " `.git/hooks/setgitperms.perl --write` to reconcile.\n";
- exit 1;
- }
- elsif (`grep $gitmeta $gitdir/MERGE_MSG`) {
- # A conflict in .gitmeta has been manually resolved. Verify that
- # the working dir perms matches the current .gitmeta perms for
- # each file/dir that conflicted.
- # This is here because a `setgitperms.perl --write` was not
- # performed due to a merge conflict, so permissions/ownership
- # may not be consistent with the manually merged .gitmeta file.
- my @conflict_diff = `git show \$(cat $gitdir/MERGE_HEAD)`;
- my @conflict_files;
- my $metadiff = 0;
-
- # Build a list of files that conflicted from the .gitmeta diff
- foreach my $line (@conflict_diff) {
- if ($line =~ m|^diff --git a/$gitmeta b/$gitmeta|) {
- $metadiff = 1;
- }
- elsif ($line =~ /^diff --git/) {
- $metadiff = 0;
- }
- elsif ($metadiff && $line =~ /^\+(.*) mode=/) {
- push @conflict_files, $1;
- }
- }
-
- # Verify that each conflict file now has permissions consistent
- # with the .gitmeta file
- foreach my $file (@conflict_files) {
- my $absfile = $topdir . $file;
- my $gm_entry = `grep "^$file mode=" $gitmeta`;
- if ($gm_entry =~ /mode=(\d+) uid=(\d+) gid=(\d+)/) {
- my ($gm_mode, $gm_uid, $gm_gid) = ($1, $2, $3);
- my (undef,undef,$mode,undef,$uid,$gid) = lstat("$absfile");
- $mode = sprintf("%04o", $mode & 07777);
- if (($gm_mode ne $mode) || ($gm_uid != $uid)
- || ($gm_gid != $gid)) {
- print "PERMISSIONS/OWNERSHIP CONFLICT\n";
- print " Mismatch found for file: $file\n";
- print " Run `.git/hooks/setgitperms.perl --write` to reconcile.\n";
- exit 1;
- }
- }
- else {
- print "Warning! Permissions/ownership no longer being tracked for file: $file\n";
- }
- }
- }
- }
-
- # No merge conflicts -- write out perms/ownership data to .gitmeta file
- unless ($stdout) {
- open (OUT, ">$gitmeta.tmp") or die "Could not open $gitmeta.tmp for writing: $!\n";
- }
-
- my @files = `git ls-files`;
- my %dirs;
-
- foreach my $path (@files) {
- chomp $path;
- # We have to manually add stats for parent directories
- my $parent = dirname($path);
- while (!exists $dirs{$parent}) {
- $dirs{$parent} = 1;
- next if $parent eq '.';
- printstats($parent);
- $parent = dirname($parent);
- }
- # Now the git-tracked file
- printstats($path);
- }
-
- # diff the temporary metadata file to see if anything has changed
- # If no metadata has changed, don't overwrite the real file
- # This is just so `git commit -a` doesn't try to commit a bogus update
- unless ($stdout) {
- if (! -e $gitmeta) {
- rename "$gitmeta.tmp", $gitmeta;
- }
- else {
- my $diff = `diff -U 0 $gitmeta $gitmeta.tmp`;
- if ($diff ne '') {
- rename "$gitmeta.tmp", $gitmeta;
- }
- else {
- unlink "$gitmeta.tmp";
- }
- if ($showdiff) {
- print $diff;
- }
- }
- close OUT;
- }
- # Make sure the .gitmeta file is tracked
- system("git add $gitmeta");
-}
-
-
-sub printstats {
- my $path = $_[0];
- $path =~ s/@/\@/g;
- my (undef,undef,$mode,undef,$uid,$gid) = lstat($path);
- $path =~ s/%/\%/g;
- if ($stdout) {
- print $path;
- printf " mode=%04o uid=$uid gid=$gid\n", $mode & 07777;
- }
- else {
- print OUT $path;
- printf OUT " mode=%04o uid=$uid gid=$gid\n", $mode & 07777;
- }
-}
diff --git a/contrib/hooks/update-paranoid b/contrib/hooks/update-paranoid
deleted file mode 100755
index 0092d67..0000000
--- a/contrib/hooks/update-paranoid
+++ /dev/null
@@ -1,421 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use File::Spec;
-
-$ENV{PATH} = '/opt/git/bin';
-my $acl_git = '/vcs/acls.git';
-my $acl_branch = 'refs/heads/master';
-my $debug = 0;
-
-=doc
-Invoked as: update refname old-sha1 new-sha1
-
-This script is run by git-receive-pack once for each ref that the
-client is trying to modify. If we exit with a non-zero exit value
-then the update for that particular ref is denied, but updates for
-other refs in the same run of receive-pack may still be allowed.
-
-We are run after the objects have been uploaded, but before the
-ref is actually modified. We take advantage of that fact when we
-look for "new" commits and tags (the new objects won't show up in
-`rev-list --all`).
-
-This script loads and parses the content of the config file
-"users/$this_user.acl" from the $acl_branch commit of $acl_git ODB.
-The acl file is a git-config style file, but uses a slightly more
-restricted syntax as the Perl parser contained within this script
-is not nearly as permissive as git-config.
-
-Example:
-
- [user]
- committer = John Doe <john.doe@example.com>
- committer = John R. Doe <john.doe@example.com>
-
- [repository "acls"]
- allow = heads/master
- allow = CDUR for heads/jd/
- allow = C for ^tags/v\\d+$
-
-For all new commit or tag objects the committer (or tagger) line
-within the object must exactly match one of the user.committer
-values listed in the acl file ("HEAD:users/$this_user.acl").
-
-For a branch to be modified an allow line within the matching
-repository section must be matched for both the refname and the
-opcode.
-
-Repository sections are matched on the basename of the repository
-(after removing the .git suffix).
-
-The opcode abbreviations are:
-
- C: create new ref
- D: delete existing ref
- U: fast-forward existing ref (no commit loss)
- R: rewind/rebase existing ref (commit loss)
-
-if no opcodes are listed before the "for" keyword then "U" (for
-fast-forward update only) is assumed as this is the most common
-usage.
-
-Refnames are matched by always assuming a prefix of "refs/".
-This hook forbids pushing or deleting anything not under "refs/".
-
-Refnames that start with ^ are Perl regular expressions, and the ^
-is kept as part of the regexp. \\ is needed to get just one \, so
-\\d expands to \d in Perl. The 3rd allow line above is an example.
-
-Refnames that don't start with ^ but that end with / are prefix
-matches (2nd allow line above); all other refnames are strict
-equality matches (1st allow line).
-
-Anything pushed to "heads/" (ok, really "refs/heads/") must be
-a commit. Tags are not permitted here.
-
-Anything pushed to "tags/" (err, really "refs/tags/") must be an
-annotated tag. Commits, blobs, trees, etc. are not permitted here.
-Annotated tag signatures aren't checked, nor are they required.
-
-The special subrepository of 'info/new-commit-check' can
-be created and used to allow users to push new commits and
-tags from another local repository to this one, even if they
-aren't the committer/tagger of those objects. In a nut shell
-the info/new-commit-check directory is a Git repository whose
-objects/info/alternates file lists this repository and all other
-possible sources, and whose refs subdirectory contains symlinks
-to this repository's refs subdirectory, and to all other possible
-sources refs subdirectories. Yes, this means that you cannot
-use packed-refs in those repositories as they won't be resolved
-correctly.
-
-=cut
-
-my $git_dir = $ENV{GIT_DIR};
-my $new_commit_check = "$git_dir/info/new-commit-check";
-my $ref = $ARGV[0];
-my $old = $ARGV[1];
-my $new = $ARGV[2];
-my $new_type;
-my ($this_user) = getpwuid $<; # REAL_USER_ID
-my $repository_name;
-my %user_committer;
-my @allow_rules;
-my @path_rules;
-my %diff_cache;
-
-sub deny ($) {
- print STDERR "-Deny- $_[0]\n" if $debug;
- print STDERR "\ndenied: $_[0]\n\n";
- exit 1;
-}
-
-sub grant ($) {
- print STDERR "-Grant- $_[0]\n" if $debug;
- exit 0;
-}
-
-sub info ($) {
- print STDERR "-Info- $_[0]\n" if $debug;
-}
-
-sub git_value (@) {
- open(T,'-|','git',@_); local $_ = <T>; chop; close T; $_;
-}
-
-sub match_string ($$) {
- my ($acl_n, $ref) = @_;
- ($acl_n eq $ref)
- || ($acl_n =~ m,/$, && substr($ref,0,length $acl_n) eq $acl_n)
- || ($acl_n =~ m,^\^, && $ref =~ m:$acl_n:);
-}
-
-sub parse_config ($$$$) {
- my $data = shift;
- local $ENV{GIT_DIR} = shift;
- my $br = shift;
- my $fn = shift;
- return unless git_value('rev-list','--max-count=1',$br,'--',$fn);
- info "Loading $br:$fn";
- open(I,'-|','git','cat-file','blob',"$br:$fn");
- my $section = '';
- while (<I>) {
- chomp;
- if (/^\s*$/ || /^\s*#/) {
- } elsif (/^\[([a-z]+)\]$/i) {
- $section = lc $1;
- } elsif (/^\[([a-z]+)\s+"(.*)"\]$/i) {
- $section = join('.',lc $1,$2);
- } elsif (/^\s*([a-z][a-z0-9]+)\s*=\s*(.*?)\s*$/i) {
- push @{$data->{join('.',$section,lc $1)}}, $2;
- } else {
- deny "bad config file line $. in $br:$fn";
- }
- }
- close I;
-}
-
-sub all_new_committers () {
- local $ENV{GIT_DIR} = $git_dir;
- $ENV{GIT_DIR} = $new_commit_check if -d $new_commit_check;
-
- info "Getting committers of new commits.";
- my %used;
- open(T,'-|','git','rev-list','--pretty=raw',$new,'--not','--all');
- while (<T>) {
- next unless s/^committer //;
- chop;
- s/>.*$/>/;
- info "Found $_." unless $used{$_}++;
- }
- close T;
- info "No new commits." unless %used;
- keys %used;
-}
-
-sub all_new_taggers () {
- my %exists;
- open(T,'-|','git','for-each-ref','--format=%(objectname)','refs/tags');
- while (<T>) {
- chop;
- $exists{$_} = 1;
- }
- close T;
-
- info "Getting taggers of new tags.";
- my %used;
- my $obj = $new;
- my $obj_type = $new_type;
- while ($obj_type eq 'tag') {
- last if $exists{$obj};
- $obj_type = '';
- open(T,'-|','git','cat-file','tag',$obj);
- while (<T>) {
- chop;
- if (/^object ([a-z0-9]{40})$/) {
- $obj = $1;
- } elsif (/^type (.+)$/) {
- $obj_type = $1;
- } elsif (s/^tagger //) {
- s/>.*$/>/;
- info "Found $_." unless $used{$_}++;
- last;
- }
- }
- close T;
- }
- info "No new tags." unless %used;
- keys %used;
-}
-
-sub check_committers (@) {
- my @bad;
- foreach (@_) { push @bad, $_ unless $user_committer{$_}; }
- if (@bad) {
- print STDERR "\n";
- print STDERR "You are not $_.\n" foreach (sort @bad);
- deny "You cannot push changes not committed by you.";
- }
-}
-
-sub load_diff ($) {
- my $base = shift;
- my $d = $diff_cache{$base};
- unless ($d) {
- local $/ = "\0";
- my %this_diff;
- if ($base =~ /^0{40}$/) {
- # Don't load the diff at all; we are making the
- # branch and have no base to compare to in this
- # case. A file level ACL makes no sense in this
- # context. Having an empty diff will allow the
- # branch creation.
- #
- } else {
- open(T,'-|','git','diff-tree',
- '-r','--name-status','-z',
- $base,$new) or return undef;
- while (<T>) {
- my $op = $_;
- chop $op;
-
- my $path = <T>;
- chop $path;
-
- $this_diff{$path} = $op;
- }
- close T or return undef;
- }
- $d = \%this_diff;
- $diff_cache{$base} = $d;
- }
- return $d;
-}
-
-deny "No GIT_DIR inherited from caller" unless $git_dir;
-deny "Need a ref name" unless $ref;
-deny "Refusing funny ref $ref" unless $ref =~ s,^refs/,,;
-deny "Bad old value $old" unless $old =~ /^[a-z0-9]{40}$/;
-deny "Bad new value $new" unless $new =~ /^[a-z0-9]{40}$/;
-deny "Cannot determine who you are." unless $this_user;
-grant "No change requested." if $old eq $new;
-
-$repository_name = File::Spec->rel2abs($git_dir);
-$repository_name =~ m,/([^/]+)(?:\.git|/\.git)$,;
-$repository_name = $1;
-info "Updating in '$repository_name'.";
-
-my $op;
-if ($old =~ /^0{40}$/) { $op = 'C'; }
-elsif ($new =~ /^0{40}$/) { $op = 'D'; }
-else { $op = 'R'; }
-
-# This is really an update (fast-forward) if the
-# merge base of $old and $new is $old.
-#
-$op = 'U' if ($op eq 'R'
- && $ref =~ m,^heads/,
- && $old eq git_value('merge-base',$old,$new));
-
-# Load the user's ACL file. Expand groups (user.memberof) one level.
-{
- my %data = ('user.committer' => []);
- parse_config(\%data,$acl_git,$acl_branch,"external/$repository_name.acl");
-
- %data = (
- 'user.committer' => $data{'user.committer'},
- 'user.memberof' => [],
- );
- parse_config(\%data,$acl_git,$acl_branch,"users/$this_user.acl");
-
- %user_committer = map {$_ => $_} @{$data{'user.committer'}};
- my $rule_key = "repository.$repository_name.allow";
- my $rules = $data{$rule_key} || [];
-
- foreach my $group (@{$data{'user.memberof'}}) {
- my %g;
- parse_config(\%g,$acl_git,$acl_branch,"groups/$group.acl");
- my $group_rules = $g{$rule_key};
- push @$rules, @$group_rules if $group_rules;
- }
-
-RULE:
- foreach (@$rules) {
- while (/\${user\.([a-z][a-zA-Z0-9]+)}/) {
- my $k = lc $1;
- my $v = $data{"user.$k"};
- next RULE unless defined $v;
- next RULE if @$v != 1;
- next RULE unless defined $v->[0];
- s/\${user\.$k}/$v->[0]/g;
- }
-
- if (/^([AMD ]+)\s+of\s+([^\s]+)\s+for\s+([^\s]+)\s+diff\s+([^\s]+)$/) {
- my ($ops, $pth, $ref, $bst) = ($1, $2, $3, $4);
- $ops =~ s/ //g;
- $pth =~ s/\\\\/\\/g;
- $ref =~ s/\\\\/\\/g;
- push @path_rules, [$ops, $pth, $ref, $bst];
- } elsif (/^([AMD ]+)\s+of\s+([^\s]+)\s+for\s+([^\s]+)$/) {
- my ($ops, $pth, $ref) = ($1, $2, $3);
- $ops =~ s/ //g;
- $pth =~ s/\\\\/\\/g;
- $ref =~ s/\\\\/\\/g;
- push @path_rules, [$ops, $pth, $ref, $old];
- } elsif (/^([CDRU ]+)\s+for\s+([^\s]+)$/) {
- my $ops = $1;
- my $ref = $2;
- $ops =~ s/ //g;
- $ref =~ s/\\\\/\\/g;
- push @allow_rules, [$ops, $ref];
- } elsif (/^for\s+([^\s]+)$/) {
- # Mentioned, but nothing granted?
- } elsif (/^[^\s]+$/) {
- s/\\\\/\\/g;
- push @allow_rules, ['U', $_];
- }
- }
-}
-
-if ($op ne 'D') {
- $new_type = git_value('cat-file','-t',$new);
-
- if ($ref =~ m,^heads/,) {
- deny "$ref must be a commit." unless $new_type eq 'commit';
- } elsif ($ref =~ m,^tags/,) {
- deny "$ref must be an annotated tag." unless $new_type eq 'tag';
- }
-
- check_committers (all_new_committers);
- check_committers (all_new_taggers) if $new_type eq 'tag';
-}
-
-info "$this_user wants $op for $ref";
-foreach my $acl_entry (@allow_rules) {
- my ($acl_ops, $acl_n) = @$acl_entry;
- next unless $acl_ops =~ /^[CDRU]+$/; # Uhh.... shouldn't happen.
- next unless $acl_n;
- next unless $op =~ /^[$acl_ops]$/;
- next unless match_string $acl_n, $ref;
-
- # Don't test path rules on branch deletes.
- #
- grant "Allowed by: $acl_ops for $acl_n" if $op eq 'D';
-
- # Aggregate matching path rules; allow if there aren't
- # any matching this ref.
- #
- my %pr;
- foreach my $p_entry (@path_rules) {
- my ($p_ops, $p_n, $p_ref, $p_bst) = @$p_entry;
- next unless $p_ref;
- push @{$pr{$p_bst}}, $p_entry if match_string $p_ref, $ref;
- }
- grant "Allowed by: $acl_ops for $acl_n" unless %pr;
-
- # Allow only if all changes against a single base are
- # allowed by file path rules.
- #
- my @bad;
- foreach my $p_bst (keys %pr) {
- my $diff_ref = load_diff $p_bst;
- deny "Cannot difference trees." unless ref $diff_ref;
-
- my %fd = %$diff_ref;
- foreach my $p_entry (@{$pr{$p_bst}}) {
- my ($p_ops, $p_n, $p_ref, $p_bst) = @$p_entry;
- next unless $p_ops =~ /^[AMD]+$/;
- next unless $p_n;
-
- foreach my $f_n (keys %fd) {
- my $f_op = $fd{$f_n};
- next unless $f_op;
- next unless $f_op =~ /^[$p_ops]$/;
- delete $fd{$f_n} if match_string $p_n, $f_n;
- }
- last unless %fd;
- }
-
- if (%fd) {
- push @bad, [$p_bst, \%fd];
- } else {
- # All changes relative to $p_bst were allowed.
- #
- grant "Allowed by: $acl_ops for $acl_n diff $p_bst";
- }
- }
-
- foreach my $bad_ref (@bad) {
- my ($p_bst, $fd) = @$bad_ref;
- print STDERR "\n";
- print STDERR "Not allowed to make the following changes:\n";
- print STDERR "(base: $p_bst)\n";
- foreach my $f_n (sort keys %$fd) {
- print STDERR " $fd->{$f_n} $f_n\n";
- }
- }
- deny "You are not permitted to $op $ref";
-}
-close A;
-deny "You are not permitted to $op $ref";
diff --git a/contrib/mw-to-git/.gitignore b/contrib/mw-to-git/.gitignore
deleted file mode 100644
index ae545b0..0000000
--- a/contrib/mw-to-git/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-git-remote-mediawiki
-git-mw
diff --git a/contrib/mw-to-git/.perlcriticrc b/contrib/mw-to-git/.perlcriticrc
deleted file mode 100644
index b733326..0000000
--- a/contrib/mw-to-git/.perlcriticrc
+++ /dev/null
@@ -1,28 +0,0 @@
-# These 3 rules demand to add the s, m and x flag to *every* regexp. This is
-# overkill and would be harmful for readability.
-[-RegularExpressions::RequireExtendedFormatting]
-[-RegularExpressions::RequireDotMatchAnything]
-[-RegularExpressions::RequireLineBoundaryMatching]
-
-# This rule says that builtin functions should not be called with parentheses
-# e.g.: (taken from CPAN's documentation)
-# open($handle, '>', $filename); #not ok
-# open $handle, '>', $filename; #ok
-# Applying such a rule would mean modifying a huge number of lines for a
-# question of style.
-[-CodeLayout::ProhibitParensWithBuiltins]
-
-# This rule states that each system call should have its return value checked
-# The problem is that it includes the print call. Checking every print call's
-# return value would be harmful to the code readability.
-# This configuration keeps all default function but print.
-[InputOutput::RequireCheckedSyscalls]
-functions = open say close
-
-# This rule demands to add a dependency for the Readonly module. This is not
-# wished.
-[-ValuesAndExpressions::ProhibitConstantPragma]
-
-# This rule is not really useful (rather a question of style) and produces many
-# warnings among the code.
-[-ValuesAndExpressions::ProhibitNoisyQuotes]
diff --git a/contrib/mw-to-git/Git/Mediawiki.pm b/contrib/mw-to-git/Git/Mediawiki.pm
deleted file mode 100644
index 629c0ce..0000000
--- a/contrib/mw-to-git/Git/Mediawiki.pm
+++ /dev/null
@@ -1,101 +0,0 @@
-package Git::Mediawiki;
-
-require v5.26;
-use strict;
-use POSIX;
-use Git;
-
-BEGIN {
-
-our ($VERSION, @ISA, @EXPORT, @EXPORT_OK);
-
-# Totally unstable API.
-$VERSION = '0.01';
-
-require Exporter;
-
-@ISA = qw(Exporter);
-
-@EXPORT = ();
-
-# Methods which can be called as standalone functions as well:
-@EXPORT_OK = qw(clean_filename smudge_filename connect_maybe
- EMPTY HTTP_CODE_OK HTTP_CODE_PAGE_NOT_FOUND);
-}
-
-# Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced
-use constant SLASH_REPLACEMENT => '%2F';
-
-# Used to test for empty strings
-use constant EMPTY => q{};
-
-# HTTP codes
-use constant HTTP_CODE_OK => 200;
-use constant HTTP_CODE_PAGE_NOT_FOUND => 404;
-
-sub clean_filename {
- my $filename = shift;
- $filename =~ s{@{[SLASH_REPLACEMENT]}}{/}g;
- # [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.
- # Do a variant of URL-encoding, i.e. looks like URL-encoding,
- # but with _ added to prevent MediaWiki from thinking this is
- # an actual special character.
- $filename =~ s/[\[\]\{\}\|]/sprintf("_%%_%x", ord($&))/ge;
- # If we use the uri escape before
- # we should unescape here, before anything
-
- return $filename;
-}
-
-sub smudge_filename {
- my $filename = shift;
- $filename =~ s{/}{@{[SLASH_REPLACEMENT]}}g;
- $filename =~ s/ /_/g;
- # Decode forbidden characters encoded in clean_filename
- $filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf('%c', hex($1))/ge;
- return substr($filename, 0, NAME_MAX-length('.mw'));
-}
-
-sub connect_maybe {
- my $wiki = shift;
- if ($wiki) {
- return $wiki;
- }
-
- my $remote_name = shift;
- my $remote_url = shift;
- my ($wiki_login, $wiki_password, $wiki_domain);
-
- $wiki_login = Git::config("remote.${remote_name}.mwLogin");
- $wiki_password = Git::config("remote.${remote_name}.mwPassword");
- $wiki_domain = Git::config("remote.${remote_name}.mwDomain");
-
- $wiki = MediaWiki::API->new;
- $wiki->{config}->{api_url} = "${remote_url}/api.php";
- if ($wiki_login) {
- my %credential = (
- 'url' => $remote_url,
- 'username' => $wiki_login,
- 'password' => $wiki_password
- );
- Git::credential(\%credential);
- my $request = {lgname => $credential{username},
- lgpassword => $credential{password},
- lgdomain => $wiki_domain};
- if ($wiki->login($request)) {
- Git::credential(\%credential, 'approve');
- print {*STDERR} qq(Logged in mediawiki user "$credential{username}".\n);
- } else {
- print {*STDERR} qq(Failed to log in mediawiki user "$credential{username}" on ${remote_url}\n);
- print {*STDERR} ' (error ' .
- $wiki->{error}->{code} . ': ' .
- $wiki->{error}->{details} . ")\n";
- Git::credential(\%credential, 'reject');
- exit 1;
- }
- }
-
- return $wiki;
-}
-
-1; # Famous last words
diff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile
deleted file mode 100644
index 497ac43..0000000
--- a/contrib/mw-to-git/Makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-#
-# Copyright (C) 2013
-# Matthieu Moy <Matthieu.Moy@imag.fr>
-#
-# To build and test:
-#
-# make
-# bin-wrapper/git mw preview Some_page.mw
-# bin-wrapper/git clone mediawiki::http://example.com/wiki/
-#
-# To install, run Git's toplevel 'make install' then run:
-#
-# make install
-
-# The default target of this Makefile is...
-all::
-
-GIT_MEDIAWIKI_PM=Git/Mediawiki.pm
-SCRIPT_PERL=git-remote-mediawiki.perl
-SCRIPT_PERL+=git-mw.perl
-GIT_ROOT_DIR=../..
-HERE=contrib/mw-to-git/
-
-INSTALL = install
-
-SCRIPT_PERL_FULL=$(patsubst %,$(HERE)/%,$(SCRIPT_PERL))
-INSTLIBDIR=$(shell $(MAKE) -C $(GIT_ROOT_DIR)/ \
- -s --no-print-directory prefix=$(prefix) \
- perllibdir=$(perllibdir) perllibdir)
-DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
-INSTLIBDIR_SQ = $(subst ','\'',$(INSTLIBDIR))
-
-all:: build
-
-test: all
- $(MAKE) -C t
-
-check: perlcritic test
-
-install_pm:
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(INSTLIBDIR_SQ)/Git'
- $(INSTALL) -m 644 $(GIT_MEDIAWIKI_PM) \
- '$(DESTDIR_SQ)$(INSTLIBDIR_SQ)/$(GIT_MEDIAWIKI_PM)'
-
-build:
- $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL="$(SCRIPT_PERL_FULL)" \
- build-perl-script
-
-install: install_pm
- $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL="$(SCRIPT_PERL_FULL)" \
- install-perl-script
-
-clean:
- $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL="$(SCRIPT_PERL_FULL)" \
- clean-perl-script
-
-perlcritic:
- perlcritic -5 $(SCRIPT_PERL)
- -perlcritic -2 $(SCRIPT_PERL)
-
-.PHONY: all test check install_pm install clean perlcritic
diff --git a/contrib/mw-to-git/bin-wrapper/git b/contrib/mw-to-git/bin-wrapper/git
deleted file mode 100755
index 6663ae5..0000000
--- a/contrib/mw-to-git/bin-wrapper/git
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-# git executable wrapper script for Git-Mediawiki to run tests without
-# installing all the scripts and perl packages.
-
-GIT_ROOT_DIR=../../..
-GIT_EXEC_PATH=$(cd "$(dirname "$0")" && cd ${GIT_ROOT_DIR} && pwd)
-
-GITPERLLIB="$GIT_EXEC_PATH"'/contrib/mw-to-git'"${GITPERLLIB:+:$GITPERLLIB}"
-PATH="$GIT_EXEC_PATH"'/contrib/mw-to-git:'"$PATH"
-
-export GITPERLLIB PATH
-
-exec "${GIT_EXEC_PATH}/bin-wrappers/git" "$@"
diff --git a/contrib/mw-to-git/git-mw.perl b/contrib/mw-to-git/git-mw.perl
deleted file mode 100755
index eb52a53..0000000
--- a/contrib/mw-to-git/git-mw.perl
+++ /dev/null
@@ -1,368 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2013
-# Benoit Person <benoit.person@ensimag.imag.fr>
-# Celestin Matte <celestin.matte@ensimag.imag.fr>
-# License: GPL v2 or later
-
-# Set of tools for git repo with a mediawiki remote.
-# Documentation & bugtracker: https://github.com/Git-Mediawiki/Git-Mediawiki
-
-use strict;
-use warnings;
-
-use Getopt::Long;
-use URI::URL qw(url);
-use LWP::UserAgent;
-use HTML::TreeBuilder;
-
-use Git;
-use MediaWiki::API;
-use Git::Mediawiki qw(clean_filename connect_maybe
- EMPTY HTTP_CODE_PAGE_NOT_FOUND);
-
-# By default, use UTF-8 to communicate with Git and the user
-binmode STDERR, ':encoding(UTF-8)';
-binmode STDOUT, ':encoding(UTF-8)';
-
-# Global parameters
-my $verbose = 0;
-sub v_print {
- if ($verbose) {
- return print {*STDERR} @_;
- }
- return;
-}
-
-# Preview parameters
-my $file_name = EMPTY;
-my $remote_name = EMPTY;
-my $preview_file_name = EMPTY;
-my $autoload = 0;
-sub file {
- $file_name = shift;
- return $file_name;
-}
-
-my %commands = (
- 'help' =>
- [\&help, {}, \&help],
- 'preview' =>
- [\&preview, {
- '<>' => \&file,
- 'output|o=s' => \$preview_file_name,
- 'remote|r=s' => \$remote_name,
- 'autoload|a' => \$autoload
- }, \&preview_help]
-);
-
-# Search for sub-command
-my $cmd = $commands{'help'};
-for (0..@ARGV-1) {
- if (defined $commands{$ARGV[$_]}) {
- $cmd = $commands{$ARGV[$_]};
- splice @ARGV, $_, 1;
- last;
- }
-};
-GetOptions( %{$cmd->[1]},
- 'help|h' => \&{$cmd->[2]},
- 'verbose|v' => \$verbose);
-
-# Launch command
-&{$cmd->[0]};
-
-############################# Preview Functions ################################
-
-sub preview_help {
- print {*STDOUT} <<'END';
-USAGE: git mw preview [--remote|-r <remote name>] [--autoload|-a]
- [--output|-o <output filename>] [--verbose|-v]
- <blob> | <filename>
-
-DESCRIPTION:
-Preview is an utiliy to preview local content of a mediawiki repo as if it was
-pushed on the remote.
-
-For that, preview searches for the remote name of the current branch's
-upstream if --remote is not set. If that remote is not found or if it
-is not a mediawiki, it lists all mediawiki remotes configured and asks
-you to replay your command with the --remote option set properly.
-
-Then, it searches for a file named 'filename'. If it's not found in
-the current dir, it will assume it's a blob.
-
-The content retrieved in the file (or in the blob) will then be parsed
-by the remote mediawiki and combined with a template retrieved from
-the mediawiki.
-
-Finally, preview will save the HTML result in a file. and autoload it
-in your default web browser if the option --autoload is present.
-
-OPTIONS:
- -r <remote name>, --remote <remote name>
- If the remote is a mediawiki, the template and the parse engine
- used for the preview will be those of that remote.
- If not, a list of valid remotes will be shown.
-
- -a, --autoload
- Try to load the HTML output in a new tab (or new window) of your
- default web browser.
-
- -o <output filename>, --output <output filename>
- Change the HTML output filename. Default filename is based on the
- input filename with its extension replaced by '.html'.
-
- -v, --verbose
- Show more information on what's going on under the hood.
-END
- exit;
-}
-
-sub preview {
- my $wiki;
- my ($remote_url, $wiki_page_name);
- my ($new_content, $template);
- my $file_content;
-
- if ($file_name eq EMPTY) {
- die "Missing file argument, see `git mw help`\n";
- }
-
- v_print("### Selecting remote\n");
- if ($remote_name eq EMPTY) {
- $remote_name = find_upstream_remote_name();
- if ($remote_name) {
- $remote_url = mediawiki_remote_url_maybe($remote_name);
- }
-
- if (! $remote_url) {
- my @valid_remotes = find_mediawiki_remotes();
-
- if ($#valid_remotes == 0) {
- print {*STDERR} "No mediawiki remote in this repo. \n";
- exit 1;
- } else {
- my $remotes_list = join("\n\t", @valid_remotes);
- print {*STDERR} <<"MESSAGE";
-There are multiple mediawiki remotes, which of:
- ${remotes_list}
-do you want ? Use the -r option to specify the remote.
-MESSAGE
- }
-
- exit 1;
- }
- } else {
- if (!is_valid_remote($remote_name)) {
- die "${remote_name} is not a remote\n";
- }
-
- $remote_url = mediawiki_remote_url_maybe($remote_name);
- if (! $remote_url) {
- die "${remote_name} is not a mediawiki remote\n";
- }
- }
- v_print("selected remote:\n\tname: ${remote_name}\n\turl: ${remote_url}\n");
-
- $wiki = connect_maybe($wiki, $remote_name, $remote_url);
-
- # Read file content
- if (! -e $file_name) {
- $file_content = git_cmd_try {
- Git::command('cat-file', 'blob', $file_name); }
- "%s failed w/ code %d";
-
- if ($file_name =~ /(.+):(.+)/) {
- $file_name = $2;
- }
- } else {
- open my $read_fh, "<", $file_name
- or die "could not open ${file_name}: $!\n";
- $file_content = do { local $/ = undef; <$read_fh> };
- close $read_fh
- or die "unable to close: $!\n";
- }
-
- v_print("### Retrieving template\n");
- ($wiki_page_name = clean_filename($file_name)) =~ s/\.[^.]+$//;
- $template = get_template($remote_url, $wiki_page_name);
-
- v_print("### Parsing local content\n");
- $new_content = $wiki->api({
- action => 'parse',
- text => $file_content,
- title => $wiki_page_name
- }, {
- skip_encoding => 1
- }) or die "No response from remote mediawiki\n";
- $new_content = $new_content->{'parse'}->{'text'}->{'*'};
-
- v_print("### Merging contents\n");
- if ($preview_file_name eq EMPTY) {
- ($preview_file_name = $file_name) =~ s/\.[^.]+$/.html/;
- }
- open(my $save_fh, '>:encoding(UTF-8)', $preview_file_name)
- or die "Could not open: $!\n";
- print {$save_fh} merge_contents($template, $new_content, $remote_url);
- close($save_fh)
- or die "Could not close: $!\n";
-
- v_print("### Results\n");
- if ($autoload) {
- v_print("Launching browser w/ file: ${preview_file_name}");
- system('git', 'web--browse', $preview_file_name);
- } else {
- print {*STDERR} "Preview file saved as: ${preview_file_name}\n";
- }
-
- exit;
-}
-
-# uses global scope variable: $remote_name
-sub merge_contents {
- my $template = shift;
- my $content = shift;
- my $remote_url = shift;
- my ($content_tree, $html_tree, $mw_content_text);
- my $template_content_id = 'bodyContent';
-
- $html_tree = HTML::TreeBuilder->new;
- $html_tree->parse($template);
-
- $content_tree = HTML::TreeBuilder->new;
- $content_tree->parse($content);
-
- $template_content_id = Git::config("remote.${remote_name}.mwIDcontent")
- || $template_content_id;
- v_print("Using '${template_content_id}' as the content ID\n");
-
- $mw_content_text = $html_tree->look_down('id', $template_content_id);
- if (!defined $mw_content_text) {
- print {*STDERR} <<"CONFIG";
-Could not combine the new content with the template. You might want to
-configure `mediawiki.IDContent` in your config:
- git config --add remote.${remote_name}.mwIDcontent <id>
-and re-run the command afterward.
-CONFIG
- exit 1;
- }
- $mw_content_text->delete_content();
- $mw_content_text->push_content($content_tree);
-
- make_links_absolute($html_tree, $remote_url);
-
- return $html_tree->as_HTML;
-}
-
-sub make_links_absolute {
- my $html_tree = shift;
- my $remote_url = shift;
- for (@{ $html_tree->extract_links() }) {
- my ($link, $element, $attr) = @{ $_ };
- my $url = url($link)->canonical;
- if ($url !~ /#/) {
- $element->attr($attr, URI->new_abs($url, $remote_url));
- }
- }
- return $html_tree;
-}
-
-sub is_valid_remote {
- my $remote = shift;
- my @remotes = git_cmd_try {
- Git::command('remote') }
- "%s failed w/ code %d";
- my $found_remote = 0;
- foreach my $remote (@remotes) {
- if ($remote eq $remote) {
- $found_remote = 1;
- last;
- }
- }
- return $found_remote;
-}
-
-sub find_mediawiki_remotes {
- my @remotes = git_cmd_try {
- Git::command('remote'); }
- "%s failed w/ code %d";
- my $remote_url;
- my @valid_remotes = ();
- foreach my $remote (@remotes) {
- $remote_url = mediawiki_remote_url_maybe($remote);
- if ($remote_url) {
- push(@valid_remotes, $remote);
- }
- }
- return @valid_remotes;
-}
-
-sub find_upstream_remote_name {
- my $current_branch = git_cmd_try {
- Git::command_oneline('symbolic-ref', '--short', 'HEAD') }
- "%s failed w/ code %d";
- return Git::config("branch.${current_branch}.remote");
-}
-
-sub mediawiki_remote_url_maybe {
- my $remote = shift;
-
- # Find remote url
- my $remote_url = Git::config("remote.${remote}.url");
- if ($remote_url =~ s/mediawiki::(.*)/$1/) {
- return url($remote_url)->canonical;
- }
-
- return;
-}
-
-sub get_template {
- my $url = shift;
- my $page_name = shift;
- my ($req, $res, $code, $url_after);
-
- $req = LWP::UserAgent->new;
- if ($verbose) {
- $req->show_progress(1);
- }
-
- $res = $req->get("${url}/index.php?title=${page_name}");
- if (!$res->is_success) {
- $code = $res->code;
- $url_after = $res->request()->uri(); # resolve all redirections
- if ($code == HTTP_CODE_PAGE_NOT_FOUND) {
- if ($verbose) {
- print {*STDERR} <<"WARNING";
-Warning: Failed to retrieve '$page_name'. Create it on the mediawiki if you want
-all the links to work properly.
-Trying to use the mediawiki homepage as a fallback template ...
-WARNING
- }
-
- # LWP automatically redirects GET request
- $res = $req->get("${url}/index.php");
- if (!$res->is_success) {
- $url_after = $res->request()->uri(); # resolve all redirections
- die "Failed to get homepage @ ${url_after} w/ code ${code}\n";
- }
- } else {
- die "Failed to get '${page_name}' @ ${url_after} w/ code ${code}\n";
- }
- }
-
- return $res->decoded_content;
-}
-
-############################## Help Functions ##################################
-
-sub help {
- print {*STDOUT} <<'END';
-usage: git mw <command> <args>
-
-git mw commands are:
- help Display help information about git mw
- preview Parse and render local file into HTML
-END
- exit;
-}
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
deleted file mode 100755
index a562441..0000000
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ /dev/null
@@ -1,1390 +0,0 @@
-#! /usr/bin/perl
-
-# Copyright (C) 2011
-# Jérémie Nikaes <jeremie.nikaes@ensimag.imag.fr>
-# Arnaud Lacurie <arnaud.lacurie@ensimag.imag.fr>
-# Claire Fousse <claire.fousse@ensimag.imag.fr>
-# David Amouyal <david.amouyal@ensimag.imag.fr>
-# Matthieu Moy <matthieu.moy@grenoble-inp.fr>
-# License: GPL v2 or later
-
-# Gateway between Git and MediaWiki.
-# Documentation & bugtracker: https://github.com/Git-Mediawiki/Git-Mediawiki
-
-use strict;
-use MediaWiki::API;
-use Git;
-use Git::Mediawiki qw(clean_filename smudge_filename connect_maybe
- EMPTY HTTP_CODE_OK);
-use DateTime::Format::ISO8601;
-use warnings;
-
-# By default, use UTF-8 to communicate with Git and the user
-binmode STDERR, ':encoding(UTF-8)';
-binmode STDOUT, ':encoding(UTF-8)';
-
-use URI::Escape;
-
-# It's not always possible to delete pages (may require some
-# privileges). Deleted pages are replaced with this content.
-use constant DELETED_CONTENT => "[[Category:Deleted]]\n";
-
-# It's not possible to create empty pages. New empty files in Git are
-# sent with this content instead.
-use constant EMPTY_CONTENT => "<!-- empty page -->\n";
-
-# used to reflect file creation or deletion in diff.
-use constant NULL_SHA1 => '0000000000000000000000000000000000000000';
-
-# Used on Git's side to reflect empty edit messages on the wiki
-use constant EMPTY_MESSAGE => '*Empty MediaWiki Message*';
-
-# Number of pages taken into account at once in submodule get_mw_page_list
-use constant SLICE_SIZE => 50;
-
-# Number of linked mediafile to get at once in get_linked_mediafiles
-# The query is split in small batches because of the MW API limit of
-# the number of links to be returned (500 links max).
-use constant BATCH_SIZE => 10;
-
-if (@ARGV != 2) {
- exit_error_usage();
-}
-
-my $remotename = $ARGV[0];
-my $url = $ARGV[1];
-
-# Accept both space-separated and multiple keys in config file.
-# Spaces should be written as _ anyway because we'll use chomp.
-my @tracked_pages = split(/[ \n]/, run_git_quoted(["config", "--get-all", "remote.${remotename}.pages"]));
-chomp(@tracked_pages);
-
-# Just like @tracked_pages, but for MediaWiki categories.
-my @tracked_categories = split(/[ \n]/, run_git_quoted(["config", "--get-all", "remote.${remotename}.categories"]));
-chomp(@tracked_categories);
-
-# Just like @tracked_categories, but for MediaWiki namespaces.
-my @tracked_namespaces = split(/[ \n]/, run_git_quoted(["config", "--get-all", "remote.${remotename}.namespaces"]));
-for (@tracked_namespaces) { s/_/ /g; }
-chomp(@tracked_namespaces);
-
-# Import media files on pull
-my $import_media = run_git_quoted(["config", "--get", "--bool", "remote.${remotename}.mediaimport"]);
-chomp($import_media);
-$import_media = ($import_media eq 'true');
-
-# Export media files on push
-my $export_media = run_git_quoted(["config", "--get", "--bool", "remote.${remotename}.mediaexport"]);
-chomp($export_media);
-$export_media = !($export_media eq 'false');
-
-my $wiki_login = run_git_quoted(["config", "--get", "remote.${remotename}.mwLogin"]);
-# Note: mwPassword is discouraged. Use the credential system instead.
-my $wiki_passwd = run_git_quoted(["config", "--get", "remote.${remotename}.mwPassword"]);
-my $wiki_domain = run_git_quoted(["config", "--get", "remote.${remotename}.mwDomain"]);
-chomp($wiki_login);
-chomp($wiki_passwd);
-chomp($wiki_domain);
-
-# Import only last revisions (both for clone and fetch)
-my $shallow_import = run_git_quoted(["config", "--get", "--bool", "remote.${remotename}.shallow"]);
-chomp($shallow_import);
-$shallow_import = ($shallow_import eq 'true');
-
-# Fetch (clone and pull) by revisions instead of by pages. This behavior
-# is more efficient when we have a wiki with lots of pages and we fetch
-# the revisions quite often so that they concern only few pages.
-# Possible values:
-# - by_rev: perform one query per new revision on the remote wiki
-# - by_page: query each tracked page for new revision
-my $fetch_strategy = run_git_quoted(["config", "--get", "remote.${remotename}.fetchStrategy"]);
-if (!$fetch_strategy) {
- $fetch_strategy = run_git_quoted(["config", "--get", "mediawiki.fetchStrategy"]);
-}
-chomp($fetch_strategy);
-if (!$fetch_strategy) {
- $fetch_strategy = 'by_page';
-}
-
-# Remember the timestamp corresponding to a revision id.
-my %basetimestamps;
-
-# Dumb push: don't update notes and mediawiki ref to reflect the last push.
-#
-# Configurable with mediawiki.dumbPush, or per-remote with
-# remote.<remotename>.dumbPush.
-#
-# This means the user will have to re-import the just-pushed
-# revisions. On the other hand, this means that the Git revisions
-# corresponding to MediaWiki revisions are all imported from the wiki,
-# regardless of whether they were initially created in Git or from the
-# web interface, hence all users will get the same history (i.e. if
-# the push from Git to MediaWiki loses some information, everybody
-# will get the history with information lost). If the import is
-# deterministic, this means everybody gets the same sha1 for each
-# MediaWiki revision.
-my $dumb_push = run_git_quoted(["config", "--get", "--bool", "remote.${remotename}.dumbPush"]);
-if (!$dumb_push) {
- $dumb_push = run_git_quoted(["config", "--get", "--bool", "mediawiki.dumbPush"]);
-}
-chomp($dumb_push);
-$dumb_push = ($dumb_push eq 'true');
-
-my $wiki_name = $url;
-$wiki_name =~ s{[^/]*://}{};
-# If URL is like http://user:password@example.com/, we clearly don't
-# want the password in $wiki_name. While we're there, also remove user
-# and '@' sign, to avoid author like MWUser@HTTPUser@host.com
-$wiki_name =~ s/^.*@//;
-
-# Commands parser
-while (<STDIN>) {
- chomp;
-
- if (!parse_command($_)) {
- last;
- }
-
- BEGIN { $| = 1 } # flush STDOUT, to make sure the previous
- # command is fully processed.
-}
-
-########################## Functions ##############################
-
-## error handling
-sub exit_error_usage {
- die "ERROR: git-remote-mediawiki module was not called with a correct number of\n" .
- "parameters\n" .
- "You may obtain this error because you attempted to run the git-remote-mediawiki\n" .
- "module directly.\n" .
- "This module can be used the following way:\n" .
- "\tgit clone mediawiki://<address of a mediawiki>\n" .
- "Then, use git commit, push and pull as with every normal git repository.\n";
-}
-
-sub parse_command {
- my ($line) = @_;
- my @cmd = split(/ /, $line);
- if (!defined $cmd[0]) {
- return 0;
- }
- if ($cmd[0] eq 'capabilities') {
- die("Too many arguments for capabilities\n")
- if (defined($cmd[1]));
- mw_capabilities();
- } elsif ($cmd[0] eq 'list') {
- die("Too many arguments for list\n") if (defined($cmd[2]));
- mw_list($cmd[1]);
- } elsif ($cmd[0] eq 'import') {
- die("Invalid argument for import\n")
- if ($cmd[1] eq EMPTY);
- die("Too many arguments for import\n")
- if (defined($cmd[2]));
- mw_import($cmd[1]);
- } elsif ($cmd[0] eq 'option') {
- die("Invalid arguments for option\n")
- if ($cmd[1] eq EMPTY || $cmd[2] eq EMPTY);
- die("Too many arguments for option\n")
- if (defined($cmd[3]));
- mw_option($cmd[1],$cmd[2]);
- } elsif ($cmd[0] eq 'push') {
- mw_push($cmd[1]);
- } else {
- print {*STDERR} "Unknown command. Aborting...\n";
- return 0;
- }
- return 1;
-}
-
-# MediaWiki API instance, created lazily.
-my $mediawiki;
-
-sub fatal_mw_error {
- my $action = shift;
- print STDERR "fatal: could not $action.\n";
- print STDERR "fatal: '$url' does not appear to be a mediawiki\n";
- if ($url =~ /^https/) {
- print STDERR "fatal: make sure '$url/api.php' is a valid page\n";
- print STDERR "fatal: and the SSL certificate is correct.\n";
- } else {
- print STDERR "fatal: make sure '$url/api.php' is a valid page.\n";
- }
- print STDERR "fatal: (error " .
- $mediawiki->{error}->{code} . ': ' .
- $mediawiki->{error}->{details} . ")\n";
- exit 1;
-}
-
-## Functions for listing pages on the remote wiki
-sub get_mw_tracked_pages {
- my $pages = shift;
- get_mw_page_list(\@tracked_pages, $pages);
- return;
-}
-
-sub get_mw_page_list {
- my $page_list = shift;
- my $pages = shift;
- my @some_pages = @{$page_list};
- while (@some_pages) {
- my $last_page = SLICE_SIZE;
- if ($#some_pages < $last_page) {
- $last_page = $#some_pages;
- }
- my @slice = @some_pages[0..$last_page];
- get_mw_first_pages(\@slice, $pages);
- @some_pages = @some_pages[(SLICE_SIZE + 1)..$#some_pages];
- }
- return;
-}
-
-sub get_mw_tracked_categories {
- my $pages = shift;
- foreach my $category (@tracked_categories) {
- if (index($category, ':') < 0) {
- # Mediawiki requires the Category
- # prefix, but let's not force the user
- # to specify it.
- $category = "Category:${category}";
- }
- my $mw_pages = $mediawiki->list( {
- action => 'query',
- list => 'categorymembers',
- cmtitle => $category,
- cmlimit => 'max' } )
- || die $mediawiki->{error}->{code} . ': '
- . $mediawiki->{error}->{details} . "\n";
- foreach my $page (@{$mw_pages}) {
- $pages->{$page->{title}} = $page;
- }
- }
- return;
-}
-
-sub get_mw_tracked_namespaces {
- my $pages = shift;
- foreach my $local_namespace (sort @tracked_namespaces) {
- my $namespace_id;
- if ($local_namespace eq "(Main)") {
- $namespace_id = 0;
- } else {
- $namespace_id = get_mw_namespace_id($local_namespace);
- }
- # virtual namespaces don't support allpages
- next if !defined($namespace_id) || $namespace_id < 0;
- my $mw_pages = $mediawiki->list( {
- action => 'query',
- list => 'allpages',
- apnamespace => $namespace_id,
- aplimit => 'max' } )
- || die $mediawiki->{error}->{code} . ': '
- . $mediawiki->{error}->{details} . "\n";
- print {*STDERR} "$#{$mw_pages} found in namespace $local_namespace ($namespace_id)\n";
- foreach my $page (@{$mw_pages}) {
- $pages->{$page->{title}} = $page;
- }
- }
- return;
-}
-
-sub get_mw_all_pages {
- my $pages = shift;
- # No user-provided list, get the list of pages from the API.
- my $mw_pages = $mediawiki->list({
- action => 'query',
- list => 'allpages',
- aplimit => 'max'
- });
- if (!defined($mw_pages)) {
- fatal_mw_error("get the list of wiki pages");
- }
- foreach my $page (@{$mw_pages}) {
- $pages->{$page->{title}} = $page;
- }
- return;
-}
-
-# queries the wiki for a set of pages. Meant to be used within a loop
-# querying the wiki for slices of page list.
-sub get_mw_first_pages {
- my $some_pages = shift;
- my @some_pages = @{$some_pages};
-
- my $pages = shift;
-
- # pattern 'page1|page2|...' required by the API
- my $titles = join('|', @some_pages);
-
- my $mw_pages = $mediawiki->api({
- action => 'query',
- titles => $titles,
- });
- if (!defined($mw_pages)) {
- fatal_mw_error("query the list of wiki pages");
- }
- while (my ($id, $page) = each(%{$mw_pages->{query}->{pages}})) {
- if ($id < 0) {
- print {*STDERR} "Warning: page $page->{title} not found on wiki\n";
- } else {
- $pages->{$page->{title}} = $page;
- }
- }
- return;
-}
-
-# Get the list of pages to be fetched according to configuration.
-sub get_mw_pages {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
-
- print {*STDERR} "Listing pages on remote wiki...\n";
-
- my %pages; # hash on page titles to avoid duplicates
- my $user_defined;
- if (@tracked_pages) {
- $user_defined = 1;
- # The user provided a list of pages titles, but we
- # still need to query the API to get the page IDs.
- get_mw_tracked_pages(\%pages);
- }
- if (@tracked_categories) {
- $user_defined = 1;
- get_mw_tracked_categories(\%pages);
- }
- if (@tracked_namespaces) {
- $user_defined = 1;
- get_mw_tracked_namespaces(\%pages);
- }
- if (!$user_defined) {
- get_mw_all_pages(\%pages);
- }
- if ($import_media) {
- print {*STDERR} "Getting media files for selected pages...\n";
- if ($user_defined) {
- get_linked_mediafiles(\%pages);
- } else {
- get_all_mediafiles(\%pages);
- }
- }
- print {*STDERR} (scalar keys %pages) . " pages found.\n";
- return %pages;
-}
-
-# usage: $out = run_git_quoted(["command", "args", ...]);
-# $out = run_git_quoted(["command", "args", ...], "raw"); # don't interpret output as UTF-8.
-# $out = run_git_quoted_nostderr(["command", "args", ...]); # discard stderr
-# $out = run_git_quoted_nostderr(["command", "args", ...], "raw"); # ditto but raw instead of UTF-8 as above
-sub _run_git {
- my $args = shift;
- my $encoding = (shift || 'encoding(UTF-8)');
- open(my $git, "-|:${encoding}", @$args)
- or die "Unable to fork: $!\n";
- my $res = do {
- local $/ = undef;
- <$git>
- };
- close($git);
-
- return $res;
-}
-
-sub run_git_quoted {
- _run_git(["git", @{$_[0]}], $_[1]);
-}
-
-sub run_git_quoted_nostderr {
- _run_git(['sh', '-c', 'git "$@" 2>/dev/null', '--', @{$_[0]}], $_[1]);
-}
-
-sub get_all_mediafiles {
- my $pages = shift;
- # Attach list of all pages for media files from the API,
- # they are in a different namespace, only one namespace
- # can be queried at the same moment
- my $mw_pages = $mediawiki->list({
- action => 'query',
- list => 'allpages',
- apnamespace => get_mw_namespace_id('File'),
- aplimit => 'max'
- });
- if (!defined($mw_pages)) {
- print {*STDERR} "fatal: could not get the list of pages for media files.\n";
- print {*STDERR} "fatal: '$url' does not appear to be a mediawiki\n";
- print {*STDERR} "fatal: make sure '$url/api.php' is a valid page.\n";
- exit 1;
- }
- foreach my $page (@{$mw_pages}) {
- $pages->{$page->{title}} = $page;
- }
- return;
-}
-
-sub get_linked_mediafiles {
- my $pages = shift;
- my @titles = map { $_->{title} } values(%{$pages});
-
- my $batch = BATCH_SIZE;
- while (@titles) {
- if ($#titles < $batch) {
- $batch = $#titles;
- }
- my @slice = @titles[0..$batch];
-
- # pattern 'page1|page2|...' required by the API
- my $mw_titles = join('|', @slice);
-
- # Media files could be included or linked from
- # a page, get all related
- my $query = {
- action => 'query',
- prop => 'links|images',
- titles => $mw_titles,
- plnamespace => get_mw_namespace_id('File'),
- pllimit => 'max'
- };
- my $result = $mediawiki->api($query);
-
- while (my ($id, $page) = each(%{$result->{query}->{pages}})) {
- my @media_titles;
- if (defined($page->{links})) {
- my @link_titles
- = map { $_->{title} } @{$page->{links}};
- push(@media_titles, @link_titles);
- }
- if (defined($page->{images})) {
- my @image_titles
- = map { $_->{title} } @{$page->{images}};
- push(@media_titles, @image_titles);
- }
- if (@media_titles) {
- get_mw_page_list(\@media_titles, $pages);
- }
- }
-
- @titles = @titles[($batch+1)..$#titles];
- }
- return;
-}
-
-sub get_mw_mediafile_for_page_revision {
- # Name of the file on Wiki, with the prefix.
- my $filename = shift;
- my $timestamp = shift;
- my %mediafile;
-
- # Search if on a media file with given timestamp exists on
- # MediaWiki. In that case download the file.
- my $query = {
- action => 'query',
- prop => 'imageinfo',
- titles => "File:${filename}",
- iistart => $timestamp,
- iiend => $timestamp,
- iiprop => 'timestamp|archivename|url',
- iilimit => 1
- };
- my $result = $mediawiki->api($query);
-
- my ($fileid, $file) = each( %{$result->{query}->{pages}} );
- # If not defined it means there is no revision of the file for
- # given timestamp.
- if (defined($file->{imageinfo})) {
- $mediafile{title} = $filename;
-
- my $fileinfo = pop(@{$file->{imageinfo}});
- $mediafile{timestamp} = $fileinfo->{timestamp};
- # Mediawiki::API's download function doesn't support https URLs
- # and can't download old versions of files.
- print {*STDERR} "\tDownloading file $mediafile{title}, version $mediafile{timestamp}\n";
- $mediafile{content} = download_mw_mediafile($fileinfo->{url});
- }
- return %mediafile;
-}
-
-sub download_mw_mediafile {
- my $download_url = shift;
-
- my $response = $mediawiki->{ua}->get($download_url);
- if ($response->code == HTTP_CODE_OK) {
- # It is tempting to return
- # $response->decoded_content({charset => "none"}), but
- # when doing so, utf8::downgrade($content) fails with
- # "Wide character in subroutine entry".
- $response->decode();
- return $response->content();
- } else {
- print {*STDERR} "Error downloading mediafile from :\n";
- print {*STDERR} "URL: ${download_url}\n";
- print {*STDERR} 'Server response: ' . $response->code . q{ } . $response->message . "\n";
- exit 1;
- }
-}
-
-sub get_last_local_revision {
- # Get note regarding last mediawiki revision.
- my $note = run_git_quoted_nostderr(["notes", "--ref=${remotename}/mediawiki",
- "show", "refs/mediawiki/${remotename}/master"]);
- my @note_info = split(/ /, $note);
-
- my $lastrevision_number;
- if (!(defined($note_info[0]) && $note_info[0] eq 'mediawiki_revision:')) {
- print {*STDERR} 'No previous mediawiki revision found';
- $lastrevision_number = 0;
- } else {
- # Notes are formatted : mediawiki_revision: #number
- $lastrevision_number = $note_info[1];
- chomp($lastrevision_number);
- print {*STDERR} "Last local mediawiki revision found is ${lastrevision_number}";
- }
- return $lastrevision_number;
-}
-
-# Get the last remote revision without taking in account which pages are
-# tracked or not. This function makes a single request to the wiki thus
-# avoid a loop onto all tracked pages. This is useful for the fetch-by-rev
-# option.
-sub get_last_global_remote_rev {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
-
- my $query = {
- action => 'query',
- list => 'recentchanges',
- prop => 'revisions',
- rclimit => '1',
- rcdir => 'older',
- };
- my $result = $mediawiki->api($query);
- return $result->{query}->{recentchanges}[0]->{revid};
-}
-
-# Get the last remote revision concerning the tracked pages and the tracked
-# categories.
-sub get_last_remote_revision {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
-
- my %pages_hash = get_mw_pages();
- my @pages = values(%pages_hash);
-
- my $max_rev_num = 0;
-
- print {*STDERR} "Getting last revision id on tracked pages...\n";
-
- foreach my $page (@pages) {
- my $id = $page->{pageid};
-
- my $query = {
- action => 'query',
- prop => 'revisions',
- rvprop => 'ids|timestamp',
- pageids => $id,
- };
-
- my $result = $mediawiki->api($query);
-
- my $lastrev = pop(@{$result->{query}->{pages}->{$id}->{revisions}});
-
- $basetimestamps{$lastrev->{revid}} = $lastrev->{timestamp};
-
- $max_rev_num = ($lastrev->{revid} > $max_rev_num ? $lastrev->{revid} : $max_rev_num);
- }
-
- print {*STDERR} "Last remote revision found is $max_rev_num.\n";
- return $max_rev_num;
-}
-
-# Clean content before sending it to MediaWiki
-sub mediawiki_clean {
- my $string = shift;
- my $page_created = shift;
- # Mediawiki does not allow blank space at the end of a page and ends with a single \n.
- # This function right trims a string and adds a \n at the end to follow this rule
- $string =~ s/\s+$//;
- if ($string eq EMPTY && $page_created) {
- # Creating empty pages is forbidden.
- $string = EMPTY_CONTENT;
- }
- return $string."\n";
-}
-
-# Filter applied on MediaWiki data before adding them to Git
-sub mediawiki_smudge {
- my $string = shift;
- if ($string eq EMPTY_CONTENT) {
- $string = EMPTY;
- }
- # This \n is important. This is due to mediawiki's way to handle end of files.
- return "${string}\n";
-}
-
-sub literal_data {
- my ($content) = @_;
- print {*STDOUT} 'data ', bytes::length($content), "\n", $content;
- return;
-}
-
-sub literal_data_raw {
- # Output possibly binary content.
- my ($content) = @_;
- # Avoid confusion between size in bytes and in characters
- utf8::downgrade($content);
- binmode STDOUT, ':raw';
- print {*STDOUT} 'data ', bytes::length($content), "\n", $content;
- binmode STDOUT, ':encoding(UTF-8)';
- return;
-}
-
-sub mw_capabilities {
- # Revisions are imported to the private namespace
- # refs/mediawiki/$remotename/ by the helper and fetched into
- # refs/remotes/$remotename later by fetch.
- print {*STDOUT} "refspec refs/heads/*:refs/mediawiki/${remotename}/*\n";
- print {*STDOUT} "import\n";
- print {*STDOUT} "list\n";
- print {*STDOUT} "push\n";
- if ($dumb_push) {
- print {*STDOUT} "no-private-update\n";
- }
- print {*STDOUT} "\n";
- return;
-}
-
-sub mw_list {
- # MediaWiki do not have branches, we consider one branch arbitrarily
- # called master, and HEAD pointing to it.
- print {*STDOUT} "? refs/heads/master\n";
- print {*STDOUT} "\@refs/heads/master HEAD\n";
- print {*STDOUT} "\n";
- return;
-}
-
-sub mw_option {
- print {*STDERR} "remote-helper command 'option $_[0]' not yet implemented\n";
- print {*STDOUT} "unsupported\n";
- return;
-}
-
-sub fetch_mw_revisions_for_page {
- my $page = shift;
- my $id = shift;
- my $fetch_from = shift;
- my @page_revs = ();
- my $query = {
- action => 'query',
- prop => 'revisions',
- rvprop => 'ids',
- rvdir => 'newer',
- rvstartid => $fetch_from,
- rvlimit => 500,
- pageids => $id,
-
- # Let MediaWiki know that we support the latest API.
- continue => '',
- };
-
- my $revnum = 0;
- # Get 500 revisions at a time due to the mediawiki api limit
- while (1) {
- my $result = $mediawiki->api($query);
-
- # Parse each of those 500 revisions
- foreach my $revision (@{$result->{query}->{pages}->{$id}->{revisions}}) {
- my $page_rev_ids;
- $page_rev_ids->{pageid} = $page->{pageid};
- $page_rev_ids->{revid} = $revision->{revid};
- push(@page_revs, $page_rev_ids);
- $revnum++;
- }
-
- if ($result->{'query-continue'}) { # For legacy APIs
- $query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};
- } elsif ($result->{continue}) { # For newer APIs
- $query->{rvstartid} = $result->{continue}->{rvcontinue};
- $query->{continue} = $result->{continue}->{continue};
- } else {
- last;
- }
- }
- if ($shallow_import && @page_revs) {
- print {*STDERR} " Found 1 revision (shallow import).\n";
- @page_revs = sort {$b->{revid} <=> $a->{revid}} (@page_revs);
- return $page_revs[0];
- }
- print {*STDERR} " Found ${revnum} revision(s).\n";
- return @page_revs;
-}
-
-sub fetch_mw_revisions {
- my $pages = shift; my @pages = @{$pages};
- my $fetch_from = shift;
-
- my @revisions = ();
- my $n = 1;
- foreach my $page (@pages) {
- my $id = $page->{pageid};
- print {*STDERR} "page ${n}/", scalar(@pages), ': ', $page->{title}, "\n";
- $n++;
- my @page_revs = fetch_mw_revisions_for_page($page, $id, $fetch_from);
- @revisions = (@page_revs, @revisions);
- }
-
- return ($n, @revisions);
-}
-
-sub fe_escape_path {
- my $path = shift;
- $path =~ s/\\/\\\\/g;
- $path =~ s/"/\\"/g;
- $path =~ s/\n/\\n/g;
- return qq("${path}");
-}
-
-sub import_file_revision {
- my $commit = shift;
- my %commit = %{$commit};
- my $full_import = shift;
- my $n = shift;
- my $mediafile = shift;
- my %mediafile;
- if ($mediafile) {
- %mediafile = %{$mediafile};
- }
-
- my $title = $commit{title};
- my $comment = $commit{comment};
- my $content = $commit{content};
- my $author = $commit{author};
- my $date = $commit{date};
-
- print {*STDOUT} "commit refs/mediawiki/${remotename}/master\n";
- print {*STDOUT} "mark :${n}\n";
- print {*STDOUT} "committer ${author} <${author}\@${wiki_name}> " . $date->epoch . " +0000\n";
- literal_data($comment);
-
- # If it's not a clone, we need to know where to start from
- if (!$full_import && $n == 1) {
- print {*STDOUT} "from refs/mediawiki/${remotename}/master^0\n";
- }
- if ($content ne DELETED_CONTENT) {
- print {*STDOUT} 'M 644 inline ' .
- fe_escape_path("${title}.mw") . "\n";
- literal_data($content);
- if (%mediafile) {
- print {*STDOUT} 'M 644 inline '
- . fe_escape_path($mediafile{title}) . "\n";
- literal_data_raw($mediafile{content});
- }
- print {*STDOUT} "\n\n";
- } else {
- print {*STDOUT} 'D ' . fe_escape_path("${title}.mw") . "\n";
- }
-
- # mediawiki revision number in the git note
- if ($full_import && $n == 1) {
- print {*STDOUT} "reset refs/notes/${remotename}/mediawiki\n";
- }
- print {*STDOUT} "commit refs/notes/${remotename}/mediawiki\n";
- print {*STDOUT} "committer ${author} <${author}\@${wiki_name}> " . $date->epoch . " +0000\n";
- literal_data('Note added by git-mediawiki during import');
- if (!$full_import && $n == 1) {
- print {*STDOUT} "from refs/notes/${remotename}/mediawiki^0\n";
- }
- print {*STDOUT} "N inline :${n}\n";
- literal_data("mediawiki_revision: $commit{mw_revision}");
- print {*STDOUT} "\n\n";
- return;
-}
-
-# parse a sequence of
-# <cmd> <arg1>
-# <cmd> <arg2>
-# \n
-# (like batch sequence of import and sequence of push statements)
-sub get_more_refs {
- my $cmd = shift;
- my @refs;
- while (1) {
- my $line = <STDIN>;
- if ($line =~ /^$cmd (.*)$/) {
- push(@refs, $1);
- } elsif ($line eq "\n") {
- return @refs;
- } else {
- die("Invalid command in a '$cmd' batch: $_\n");
- }
- }
- return;
-}
-
-sub mw_import {
- # multiple import commands can follow each other.
- my @refs = (shift, get_more_refs('import'));
- my $processedRefs;
- foreach my $ref (@refs) {
- next if $processedRefs->{$ref}; # skip duplicates: "import refs/heads/master" being issued twice; TODO: why?
- $processedRefs->{$ref} = 1;
- mw_import_ref($ref);
- }
- print {*STDOUT} "done\n";
- return;
-}
-
-sub mw_import_ref {
- my $ref = shift;
- # The remote helper will call "import HEAD" and
- # "import refs/heads/master".
- # Since HEAD is a symbolic ref to master (by convention,
- # followed by the output of the command "list" that we gave),
- # we don't need to do anything in this case.
- if ($ref eq 'HEAD') {
- return;
- }
-
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
-
- print {*STDERR} "Searching revisions...\n";
- my $last_local = get_last_local_revision();
- my $fetch_from = $last_local + 1;
- if ($fetch_from == 1) {
- print {*STDERR} ", fetching from beginning.\n";
- } else {
- print {*STDERR} ", fetching from here.\n";
- }
-
- my $n = 0;
- if ($fetch_strategy eq 'by_rev') {
- print {*STDERR} "Fetching & writing export data by revs...\n";
- $n = mw_import_ref_by_revs($fetch_from);
- } elsif ($fetch_strategy eq 'by_page') {
- print {*STDERR} "Fetching & writing export data by pages...\n";
- $n = mw_import_ref_by_pages($fetch_from);
- } else {
- print {*STDERR} qq(fatal: invalid fetch strategy "${fetch_strategy}".\n);
- print {*STDERR} "Check your configuration variables remote.${remotename}.fetchStrategy and mediawiki.fetchStrategy\n";
- exit 1;
- }
-
- if ($fetch_from == 1 && $n == 0) {
- print {*STDERR} "You appear to have cloned an empty MediaWiki.\n";
- # Something has to be done remote-helper side. If nothing is done, an error is
- # thrown saying that HEAD is referring to unknown object 0000000000000000000
- # and the clone fails.
- }
- return;
-}
-
-sub mw_import_ref_by_pages {
-
- my $fetch_from = shift;
- my %pages_hash = get_mw_pages();
- my @pages = values(%pages_hash);
-
- my ($n, @revisions) = fetch_mw_revisions(\@pages, $fetch_from);
-
- @revisions = sort {$a->{revid} <=> $b->{revid}} @revisions;
- my @revision_ids = map { $_->{revid} } @revisions;
-
- return mw_import_revids($fetch_from, \@revision_ids, \%pages_hash);
-}
-
-sub mw_import_ref_by_revs {
-
- my $fetch_from = shift;
- my %pages_hash = get_mw_pages();
-
- my $last_remote = get_last_global_remote_rev();
- my @revision_ids = $fetch_from..$last_remote;
- return mw_import_revids($fetch_from, \@revision_ids, \%pages_hash);
-}
-
-# Import revisions given in second argument (array of integers).
-# Only pages appearing in the third argument (hash indexed by page titles)
-# will be imported.
-sub mw_import_revids {
- my $fetch_from = shift;
- my $revision_ids = shift;
- my $pages = shift;
-
- my $n = 0;
- my $n_actual = 0;
- my $last_timestamp = 0; # Placeholder in case $rev->timestamp is undefined
-
- foreach my $pagerevid (@{$revision_ids}) {
- # Count page even if we skip it, since we display
- # $n/$total and $total includes skipped pages.
- $n++;
-
- # fetch the content of the pages
- my $query = {
- action => 'query',
- prop => 'revisions',
- rvprop => 'content|timestamp|comment|user|ids',
- revids => $pagerevid,
- };
-
- my $result = $mediawiki->api($query);
-
- if (!$result) {
- die "Failed to retrieve modified page for revision $pagerevid\n";
- }
-
- if (defined($result->{query}->{badrevids}->{$pagerevid})) {
- # The revision id does not exist on the remote wiki.
- next;
- }
-
- if (!defined($result->{query}->{pages})) {
- die "Invalid revision ${pagerevid}.\n";
- }
-
- my @result_pages = values(%{$result->{query}->{pages}});
- my $result_page = $result_pages[0];
- my $rev = $result_pages[0]->{revisions}->[0];
-
- my $page_title = $result_page->{title};
-
- if (!exists($pages->{$page_title})) {
- print {*STDERR} "${n}/", scalar(@{$revision_ids}),
- ": Skipping revision #$rev->{revid} of ${page_title}\n";
- next;
- }
-
- $n_actual++;
-
- my %commit;
- $commit{author} = $rev->{user} || 'Anonymous';
- $commit{comment} = $rev->{comment} || EMPTY_MESSAGE;
- $commit{title} = smudge_filename($page_title);
- $commit{mw_revision} = $rev->{revid};
- $commit{content} = mediawiki_smudge($rev->{'*'});
-
- if (!defined($rev->{timestamp})) {
- $last_timestamp++;
- } else {
- $last_timestamp = $rev->{timestamp};
- }
- $commit{date} = DateTime::Format::ISO8601->parse_datetime($last_timestamp);
-
- # Differentiates classic pages and media files.
- my ($namespace, $filename) = $page_title =~ /^([^:]*):(.*)$/;
- my %mediafile;
- if ($namespace) {
- my $id = get_mw_namespace_id($namespace);
- if ($id && $id == get_mw_namespace_id('File')) {
- %mediafile = get_mw_mediafile_for_page_revision($filename, $rev->{timestamp});
- }
- }
- # If this is a revision of the media page for new version
- # of a file do one common commit for both file and media page.
- # Else do commit only for that page.
- print {*STDERR} "${n}/", scalar(@{$revision_ids}), ": Revision #$rev->{revid} of $commit{title}\n";
- import_file_revision(\%commit, ($fetch_from == 1), $n_actual, \%mediafile);
- }
-
- return $n_actual;
-}
-
-sub error_non_fast_forward {
- my $advice = run_git_quoted(["config", "--bool", "advice.pushNonFastForward"]);
- chomp($advice);
- if ($advice ne 'false') {
- # Native git-push would show this after the summary.
- # We can't ask it to display it cleanly, so print it
- # ourselves before.
- print {*STDERR} "To prevent you from losing history, non-fast-forward updates were rejected\n";
- print {*STDERR} "Merge the remote changes (e.g. 'git pull') before pushing again. See the\n";
- print {*STDERR} "'Note about fast-forwards' section of 'git push --help' for details.\n";
- }
- print {*STDOUT} qq(error $_[0] "non-fast-forward"\n);
- return 0;
-}
-
-sub mw_upload_file {
- my $complete_file_name = shift;
- my $new_sha1 = shift;
- my $extension = shift;
- my $file_deleted = shift;
- my $summary = shift;
- my $newrevid;
- my $path = "File:${complete_file_name}";
- my %hashFiles = get_allowed_file_extensions();
- if (!exists($hashFiles{$extension})) {
- print {*STDERR} "${complete_file_name} is not a permitted file on this wiki.\n";
- print {*STDERR} "Check the configuration of file uploads in your mediawiki.\n";
- return $newrevid;
- }
- # Deleting and uploading a file requires a privileged user
- if ($file_deleted) {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
- my $query = {
- action => 'delete',
- title => $path,
- reason => $summary
- };
- if (!$mediawiki->edit($query)) {
- print {*STDERR} "Failed to delete file on remote wiki\n";
- print {*STDERR} "Check your permissions on the remote site. Error code:\n";
- print {*STDERR} $mediawiki->{error}->{code} . ':' . $mediawiki->{error}->{details};
- exit 1;
- }
- } else {
- # Don't let perl try to interpret file content as UTF-8 => use "raw"
- my $content = run_git_quoted(["cat-file", "blob", $new_sha1], 'raw');
- if ($content ne EMPTY) {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
- $mediawiki->{config}->{upload_url} =
- "${url}/index.php/Special:Upload";
- $mediawiki->edit({
- action => 'upload',
- filename => $complete_file_name,
- comment => $summary,
- file => [undef,
- $complete_file_name,
- Content => $content],
- ignorewarnings => 1,
- }, {
- skip_encoding => 1
- } ) || die $mediawiki->{error}->{code} . ':'
- . $mediawiki->{error}->{details} . "\n";
- my $last_file_page = $mediawiki->get_page({title => $path});
- $newrevid = $last_file_page->{revid};
- print {*STDERR} "Pushed file: ${new_sha1} - ${complete_file_name}.\n";
- } else {
- print {*STDERR} "Empty file ${complete_file_name} not pushed.\n";
- }
- }
- return $newrevid;
-}
-
-sub mw_push_file {
- my $diff_info = shift;
- # $diff_info contains a string in this format:
- # 100644 100644 <sha1_of_blob_before_commit> <sha1_of_blob_now> <status>
- my @diff_info_split = split(/[ \t]/, $diff_info);
-
- # Filename, including .mw extension
- my $complete_file_name = shift;
- # Commit message
- my $summary = shift;
- # MediaWiki revision number. Keep the previous one by default,
- # in case there's no edit to perform.
- my $oldrevid = shift;
- my $newrevid;
-
- if ($summary eq EMPTY_MESSAGE) {
- $summary = EMPTY;
- }
-
- my $new_sha1 = $diff_info_split[3];
- my $old_sha1 = $diff_info_split[2];
- my $page_created = ($old_sha1 eq NULL_SHA1);
- my $page_deleted = ($new_sha1 eq NULL_SHA1);
- $complete_file_name = clean_filename($complete_file_name);
-
- my ($title, $extension) = $complete_file_name =~ /^(.*)\.([^\.]*)$/;
- if (!defined($extension)) {
- $extension = EMPTY;
- }
- if ($extension eq 'mw') {
- my $ns = get_mw_namespace_id_for_page($complete_file_name);
- if ($ns && $ns == get_mw_namespace_id('File') && (!$export_media)) {
- print {*STDERR} "Ignoring media file related page: ${complete_file_name}\n";
- return ($oldrevid, 'ok');
- }
- my $file_content;
- if ($page_deleted) {
- # Deleting a page usually requires
- # special privileges. A common
- # convention is to replace the page
- # with this content instead:
- $file_content = DELETED_CONTENT;
- } else {
- $file_content = run_git_quoted(["cat-file", "blob", $new_sha1]);
- }
-
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
-
- my $result = $mediawiki->edit( {
- action => 'edit',
- summary => $summary,
- title => $title,
- basetimestamp => $basetimestamps{$oldrevid},
- text => mediawiki_clean($file_content, $page_created),
- }, {
- skip_encoding => 1 # Helps with names with accentuated characters
- });
- if (!$result) {
- if ($mediawiki->{error}->{code} == 3) {
- # edit conflicts, considered as non-fast-forward
- print {*STDERR} 'Warning: Error ' .
- $mediawiki->{error}->{code} .
- ' from mediawiki: ' . $mediawiki->{error}->{details} .
- ".\n";
- return ($oldrevid, 'non-fast-forward');
- } else {
- # Other errors. Shouldn't happen => just die()
- die 'Fatal: Error ' .
- $mediawiki->{error}->{code} .
- ' from mediawiki: ' . $mediawiki->{error}->{details} . "\n";
- }
- }
- $newrevid = $result->{edit}->{newrevid};
- print {*STDERR} "Pushed file: ${new_sha1} - ${title}\n";
- } elsif ($export_media) {
- $newrevid = mw_upload_file($complete_file_name, $new_sha1,
- $extension, $page_deleted,
- $summary);
- } else {
- print {*STDERR} "Ignoring media file ${title}\n";
- }
- $newrevid = ($newrevid or $oldrevid);
- return ($newrevid, 'ok');
-}
-
-sub mw_push {
- # multiple push statements can follow each other
- my @refsspecs = (shift, get_more_refs('push'));
- my $pushed;
- for my $refspec (@refsspecs) {
- my ($force, $local, $remote) = $refspec =~ /^(\+)?([^:]*):([^:]*)$/
- or die("Invalid refspec for push. Expected <src>:<dst> or +<src>:<dst>\n");
- if ($force) {
- print {*STDERR} "Warning: forced push not allowed on a MediaWiki.\n";
- }
- if ($local eq EMPTY) {
- print {*STDERR} "Cannot delete remote branch on a MediaWiki\n";
- print {*STDOUT} "error ${remote} cannot delete\n";
- next;
- }
- if ($remote ne 'refs/heads/master') {
- print {*STDERR} "Only push to the branch 'master' is supported on a MediaWiki\n";
- print {*STDOUT} "error ${remote} only master allowed\n";
- next;
- }
- if (mw_push_revision($local, $remote)) {
- $pushed = 1;
- }
- }
-
- # Notify Git that the push is done
- print {*STDOUT} "\n";
-
- if ($pushed && $dumb_push) {
- print {*STDERR} "Just pushed some revisions to MediaWiki.\n";
- print {*STDERR} "The pushed revisions now have to be re-imported, and your current branch\n";
- print {*STDERR} "needs to be updated with these re-imported commits. You can do this with\n";
- print {*STDERR} "\n";
- print {*STDERR} " git pull --rebase\n";
- print {*STDERR} "\n";
- }
- return;
-}
-
-sub mw_push_revision {
- my $local = shift;
- my $remote = shift; # actually, this has to be "refs/heads/master" at this point.
- my $last_local_revid = get_last_local_revision();
- print {*STDERR} ".\n"; # Finish sentence started by get_last_local_revision()
- my $last_remote_revid = get_last_remote_revision();
- my $mw_revision = $last_remote_revid;
-
- # Get sha1 of commit pointed by local HEAD
- my $HEAD_sha1 = run_git_quoted_nostderr(["rev-parse", $local]);
- chomp($HEAD_sha1);
- # Get sha1 of commit pointed by remotes/$remotename/master
- my $remoteorigin_sha1 = run_git_quoted_nostderr(["rev-parse", "refs/remotes/${remotename}/master"]);
- chomp($remoteorigin_sha1);
-
- if ($last_local_revid > 0 &&
- $last_local_revid < $last_remote_revid) {
- return error_non_fast_forward($remote);
- }
-
- if ($HEAD_sha1 eq $remoteorigin_sha1) {
- # nothing to push
- return 0;
- }
-
- # Get every commit in between HEAD and refs/remotes/origin/master,
- # including HEAD and refs/remotes/origin/master
- my @commit_pairs = ();
- if ($last_local_revid > 0) {
- my $parsed_sha1 = $remoteorigin_sha1;
- # Find a path from last MediaWiki commit to pushed commit
- print {*STDERR} "Computing path from local to remote ...\n";
- my @local_ancestry = split(/\n/, run_git_quoted(["rev-list", "--boundary", "--parents", $local, "^${parsed_sha1}"]));
- my %local_ancestry;
- foreach my $line (@local_ancestry) {
- if (my ($child, $parents) = $line =~ /^-?([a-f0-9]+) ([a-f0-9 ]+)/) {
- foreach my $parent (split(/ /, $parents)) {
- $local_ancestry{$parent} = $child;
- }
- } elsif (!$line =~ /^([a-f0-9]+)/) {
- die "Unexpected output from git rev-list: ${line}\n";
- }
- }
- while ($parsed_sha1 ne $HEAD_sha1) {
- my $child = $local_ancestry{$parsed_sha1};
- if (!$child) {
- print {*STDERR} "Cannot find a path in history from remote commit to last commit\n";
- return error_non_fast_forward($remote);
- }
- push(@commit_pairs, [$parsed_sha1, $child]);
- $parsed_sha1 = $child;
- }
- } else {
- # No remote mediawiki revision. Export the whole
- # history (linearized with --first-parent)
- print {*STDERR} "Warning: no common ancestor, pushing complete history\n";
- my $history = run_git_quoted(["rev-list", "--first-parent", "--children", $local]);
- my @history = split(/\n/, $history);
- @history = @history[1..$#history];
- foreach my $line (reverse @history) {
- my @commit_info_split = split(/[ \n]/, $line);
- push(@commit_pairs, \@commit_info_split);
- }
- }
-
- foreach my $commit_info_split (@commit_pairs) {
- my $sha1_child = @{$commit_info_split}[0];
- my $sha1_commit = @{$commit_info_split}[1];
- my $diff_infos = run_git_quoted(["diff-tree", "-r", "--raw", "-z", $sha1_child, $sha1_commit]);
- # TODO: we could detect rename, and encode them with a #redirect on the wiki.
- # TODO: for now, it's just a delete+add
- my @diff_info_list = split(/\0/, $diff_infos);
- # Keep the subject line of the commit message as mediawiki comment for the revision
- my $commit_msg = run_git_quoted(["log", "--no-walk", '--format="%s"', $sha1_commit]);
- chomp($commit_msg);
- # Push every blob
- while (@diff_info_list) {
- my $status;
- # git diff-tree -z gives an output like
- # <metadata>\0<filename1>\0
- # <metadata>\0<filename2>\0
- # and we've split on \0.
- my $info = shift(@diff_info_list);
- my $file = shift(@diff_info_list);
- ($mw_revision, $status) = mw_push_file($info, $file, $commit_msg, $mw_revision);
- if ($status eq 'non-fast-forward') {
- # we may already have sent part of the
- # commit to MediaWiki, but it's too
- # late to cancel it. Stop the push in
- # the middle, but still give an
- # accurate error message.
- return error_non_fast_forward($remote);
- }
- if ($status ne 'ok') {
- die("Unknown error from mw_push_file()\n");
- }
- }
- if (!$dumb_push) {
- run_git_quoted(["notes", "--ref=${remotename}/mediawiki",
- "add", "-f", "-m",
- "mediawiki_revision: ${mw_revision}",
- $sha1_commit]);
- }
- }
-
- print {*STDOUT} "ok ${remote}\n";
- return 1;
-}
-
-sub get_allowed_file_extensions {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
-
- my $query = {
- action => 'query',
- meta => 'siteinfo',
- siprop => 'fileextensions'
- };
- my $result = $mediawiki->api($query);
- my @file_extensions = map { $_->{ext}} @{$result->{query}->{fileextensions}};
- my %hashFile = map { $_ => 1 } @file_extensions;
-
- return %hashFile;
-}
-
-# In memory cache for MediaWiki namespace ids.
-my %namespace_id;
-
-# Namespaces whose id is cached in the configuration file
-# (to avoid duplicates)
-my %cached_mw_namespace_id;
-
-# Return MediaWiki id for a canonical namespace name.
-# Ex.: "File", "Project".
-sub get_mw_namespace_id {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
- my $name = shift;
-
- if (!exists $namespace_id{$name}) {
- # Look at configuration file, if the record for that namespace is
- # already cached. Namespaces are stored in form:
- # "Name_of_namespace:Id_namespace", ex.: "File:6".
- my @temp = split(/\n/,
- run_git_quoted(["config", "--get-all", "remote.${remotename}.namespaceCache"]));
- chomp(@temp);
- foreach my $ns (@temp) {
- my ($n, $id) = split(/:/, $ns);
- if ($id eq 'notANameSpace') {
- $namespace_id{$n} = {is_namespace => 0};
- } else {
- $namespace_id{$n} = {is_namespace => 1, id => $id};
- }
- $cached_mw_namespace_id{$n} = 1;
- }
- }
-
- if (!exists $namespace_id{$name}) {
- print {*STDERR} "Namespace ${name} not found in cache, querying the wiki ...\n";
- # NS not found => get namespace id from MW and store it in
- # configuration file.
- my $query = {
- action => 'query',
- meta => 'siteinfo',
- siprop => 'namespaces'
- };
- my $result = $mediawiki->api($query);
-
- while (my ($id, $ns) = each(%{$result->{query}->{namespaces}})) {
- if (defined($ns->{id}) && defined($ns->{canonical})) {
- $namespace_id{$ns->{canonical}} = {is_namespace => 1, id => $ns->{id}};
- if ($ns->{'*'}) {
- # alias (e.g. french Fichier: as alias for canonical File:)
- $namespace_id{$ns->{'*'}} = {is_namespace => 1, id => $ns->{id}};
- }
- }
- }
- }
-
- my $ns = $namespace_id{$name};
- my $id;
-
- if (!defined $ns) {
- my @namespaces = map { s/ /_/g; $_; } sort keys %namespace_id;
- print {*STDERR} "No such namespace ${name} on MediaWiki, known namespaces: @namespaces\n";
- $ns = {is_namespace => 0};
- $namespace_id{$name} = $ns;
- }
-
- if ($ns->{is_namespace}) {
- $id = $ns->{id};
- }
-
- # Store "notANameSpace" as special value for inexisting namespaces
- my $store_id = ($id || 'notANameSpace');
-
- # Store explicitly requested namespaces on disk
- if (!exists $cached_mw_namespace_id{$name}) {
- run_git_quoted(["config", "--add", "remote.${remotename}.namespaceCache", "${name}:${store_id}"]);
- $cached_mw_namespace_id{$name} = 1;
- }
- return $id;
-}
-
-sub get_mw_namespace_id_for_page {
- my $namespace = shift;
- if ($namespace =~ /^([^:]*):/) {
- return get_mw_namespace_id($namespace);
- } else {
- return;
- }
-}
diff --git a/contrib/mw-to-git/git-remote-mediawiki.txt b/contrib/mw-to-git/git-remote-mediawiki.txt
deleted file mode 100644
index 5da825f..0000000
--- a/contrib/mw-to-git/git-remote-mediawiki.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-Git-Mediawiki is a project which aims the creation of a gate
-between git and mediawiki, allowing git users to push and pull
-objects from mediawiki just as one would do with a classic git
-repository thanks to remote-helpers.
-
-For more information, visit the wiki at
-https://github.com/Git-Mediawiki/Git-Mediawiki
diff --git a/contrib/mw-to-git/t/.gitignore b/contrib/mw-to-git/t/.gitignore
deleted file mode 100644
index 2b8dc30..0000000
--- a/contrib/mw-to-git/t/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-WEB/
-mediawiki/
-trash directory.t*/
-test-results/
diff --git a/contrib/mw-to-git/t/Makefile b/contrib/mw-to-git/t/Makefile
deleted file mode 100644
index 6c9f377..0000000
--- a/contrib/mw-to-git/t/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-#
-## Test git-remote-mediawiki
-
-# The default target of this Makefile is...
-all:: test
-
--include ../../../config.mak.autogen
--include ../../../config.mak
-
-T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
-
-.PHONY: help test clean all
-
-help:
- @echo 'Run "$(MAKE) test" to launch test scripts'
- @echo 'Run "$(MAKE) clean" to remove trash folders'
-
-test:
- @for t in $(T); do \
- echo "$$t"; \
- "./$$t" || exit 1; \
- done
-
-clean:
- $(RM) -r 'trash directory'.*
diff --git a/contrib/mw-to-git/t/README b/contrib/mw-to-git/t/README
deleted file mode 100644
index 72c4889..0000000
--- a/contrib/mw-to-git/t/README
+++ /dev/null
@@ -1,124 +0,0 @@
-Tests for Mediawiki-to-Git
-==========================
-
-Introduction
-------------
-This manual describes how to install the git-remote-mediawiki test
-environment on a machine with git installed on it.
-
-Prerequisite
-------------
-
-In order to run this test environment correctly, you will need to
-install the following packages (Debian/Ubuntu names, may need to be
-adapted for another distribution):
-
-* lighttpd
-* php
-* php-cgi
-* php-cli
-* php-curl
-* php-sqlite
-
-Principles and Technical Choices
---------------------------------
-
-The test environment makes it easy to install and manipulate one or
-several MediaWiki instances. To allow developers to run the testsuite
-easily, the environment does not require root privilege (except to
-install the required packages if needed). It starts a webserver
-instance on the user's account (using lighttpd greatly helps for
-that), and does not need a separate database daemon (thanks to the use
-of sqlite).
-
-Run the test environment
-------------------------
-
-Install a new wiki
-~~~~~~~~~~~~~~~~~~
-
-Once you have all the prerequisite, you need to install a MediaWiki
-instance on your machine. If you already have one, it is still
-strongly recommended to install one with the script provided. Here's
-how to work it:
-
-a. change directory to contrib/mw-to-git/t/
-b. if needed, edit test.config to choose your installation parameters
-c. run `./install-wiki.sh install`
-d. check on your favourite web browser if your wiki is correctly
- installed.
-
-Remove an existing wiki
-~~~~~~~~~~~~~~~~~~~~~~~
-
-Edit the file test.config to fit the wiki you want to delete, and then
-execute the command `./install-wiki.sh delete` from the
-contrib/mw-to-git/t directory.
-
-Run the existing tests
-~~~~~~~~~~~~~~~~~~~~~~
-
-The provided tests are currently in the `contrib/mw-to-git/t` directory.
-The files are all the t936[0-9]-*.sh shell scripts.
-
-a. Run all tests:
-To do so, run "make test" from the contrib/mw-to-git/ directory.
-
-b. Run a specific test:
-To run a given test <test_name>, run ./<test_name> from the
-contrib/mw-to-git/t directory.
-
-How to create new tests
------------------------
-
-Available functions
-~~~~~~~~~~~~~~~~~~~
-
-The test environment of git-remote-mediawiki provides some functions
-useful to test its behaviour. for more details about the functions'
-parameters, please refer to the `test-gitmw-lib.sh` and
-`test-gitmw.pl` files.
-
-** `test_check_wiki_precond`:
-Check if the tests must be skipped or not. Please use this function
-at the beginning of each new test file.
-
-** `wiki_getpage`:
-Fetch a given page from the wiki and puts its content in the
-directory in parameter.
-
-** `wiki_delete_page`:
-Delete a given page from the wiki.
-
-** `wiki_edit_page`:
-Create or modify a given page in the wiki. You can specify several
-parameters like a summary for the page edition, or add the page to a
-given category.
-See test-gitmw.pl for more details.
-
-** `wiki_getallpage`:
-Fetch all pages from the wiki into a given directory. The directory
-is created if it does not exists.
-
-** `test_diff_directories`:
-Compare the content of two directories. The content must be the same.
-Use this function to compare the content of a git directory and a wiki
-one created by wiki_getallpage.
-
-** `test_contains_N_files`:
-Check if the given directory contains a given number of file.
-
-** `wiki_page_exists`:
-Tests if a given page exists on the wiki.
-
-** `wiki_reset`:
-Reset the wiki, i.e. flush the database. Use this function at the
-beginning of each new test, except if the test re-uses the same wiki
-(and history) as the previous test.
-
-How to write a new test
-~~~~~~~~~~~~~~~~~~~~~~~
-
-Please, follow the standards given by git. See git/t/README.
-New file should be named as t936[0-9]-*.sh.
-Be sure to reset your wiki regularly with the function `wiki_reset`.
diff --git a/contrib/mw-to-git/t/install-wiki.sh b/contrib/mw-to-git/t/install-wiki.sh
deleted file mode 100755
index c215213..0000000
--- a/contrib/mw-to-git/t/install-wiki.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/sh
-
-# This script installs or deletes a MediaWiki on your computer.
-# It requires a web server with PHP and SQLite running. In addition, if you
-# do not have MediaWiki sources on your computer, the option 'install'
-# downloads them for you.
-# Please set the CONFIGURATION VARIABLES in ./test-gitmw-lib.sh
-
-WIKI_TEST_DIR=$(cd "$(dirname "$0")" && pwd)
-
-if test -z "$WIKI_TEST_DIR"
-then
- WIKI_TEST_DIR=.
-fi
-
-. "$WIKI_TEST_DIR"/test-gitmw-lib.sh
-usage () {
- echo "usage: "
- echo " ./install-wiki.sh <install | delete | --help>"
- echo " install | -i : Install a wiki on your computer."
- echo " delete | -d : Delete the wiki and all its pages and "
- echo " content."
- echo " start | -s : Start the previously configured lighttpd daemon"
- echo " stop : Stop lighttpd daemon."
-}
-
-
-# Argument: install, delete, --help | -h
-case "$1" in
- "install" | "-i")
- wiki_install
- exit 0
- ;;
- "delete" | "-d")
- wiki_delete
- exit 0
- ;;
- "start" | "-s")
- start_lighttpd
- exit
- ;;
- "stop")
- stop_lighttpd
- exit
- ;;
- "--help" | "-h")
- usage
- exit 0
- ;;
- *)
- echo "Invalid argument: $1"
- usage
- exit 1
- ;;
-esac
diff --git a/contrib/mw-to-git/t/push-pull-tests.sh b/contrib/mw-to-git/t/push-pull-tests.sh
deleted file mode 100644
index 9da2dc5..0000000
--- a/contrib/mw-to-git/t/push-pull-tests.sh
+++ /dev/null
@@ -1,144 +0,0 @@
-test_push_pull () {
-
- test_expect_success 'Git pull works after adding a new wiki page' '
- wiki_reset &&
-
- git clone mediawiki::'"$WIKI_URL"' mw_dir_1 &&
- wiki_editpage Foo "page created after the git clone" false &&
-
- (
- cd mw_dir_1 &&
- git pull
- ) &&
-
- wiki_getallpage ref_page_1 &&
- test_diff_directories mw_dir_1 ref_page_1
- '
-
- test_expect_success 'Git pull works after editing a wiki page' '
- wiki_reset &&
-
- wiki_editpage Foo "page created before the git clone" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_2 &&
- wiki_editpage Foo "new line added on the wiki" true &&
-
- (
- cd mw_dir_2 &&
- git pull
- ) &&
-
- wiki_getallpage ref_page_2 &&
- test_diff_directories mw_dir_2 ref_page_2
- '
-
- test_expect_success 'git pull works on conflict handled by auto-merge' '
- wiki_reset &&
-
- wiki_editpage Foo "1 init
-3
-5
- " false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_3 &&
-
- wiki_editpage Foo "1 init
-2 content added on wiki after clone
-3
-5
- " false &&
-
- (
- cd mw_dir_3 &&
- echo "1 init
-3
-4 content added on git after clone
-5
-" >Foo.mw &&
- git commit -am "conflicting change on foo" &&
- git pull &&
- git push
- )
- '
-
- test_expect_success 'Git push works after adding a file .mw' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_4 &&
- wiki_getallpage ref_page_4 &&
- (
- cd mw_dir_4 &&
- test_path_is_missing Foo.mw &&
- touch Foo.mw &&
- echo "hello world" >>Foo.mw &&
- git add Foo.mw &&
- git commit -m "Foo" &&
- git push
- ) &&
- wiki_getallpage ref_page_4 &&
- test_diff_directories mw_dir_4 ref_page_4
- '
-
- test_expect_success 'Git push works after editing a file .mw' '
- wiki_reset &&
- wiki_editpage "Foo" "page created before the git clone" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_5 &&
-
- (
- cd mw_dir_5 &&
- echo "new line added in the file Foo.mw" >>Foo.mw &&
- git commit -am "edit file Foo.mw" &&
- git push
- ) &&
-
- wiki_getallpage ref_page_5 &&
- test_diff_directories mw_dir_5 ref_page_5
- '
-
- test_expect_failure 'Git push works after deleting a file' '
- wiki_reset &&
- wiki_editpage Foo "wiki page added before git clone" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_6 &&
-
- (
- cd mw_dir_6 &&
- git rm Foo.mw &&
- git commit -am "page Foo.mw deleted" &&
- git push
- ) &&
-
- test_must_fail wiki_page_exist Foo
- '
-
- test_expect_success 'Merge conflict expected and solving it' '
- wiki_reset &&
-
- git clone mediawiki::'"$WIKI_URL"' mw_dir_7 &&
- wiki_editpage Foo "1 conflict
-3 wiki
-4" false &&
-
- (
- cd mw_dir_7 &&
- echo "1 conflict
-2 git
-4" >Foo.mw &&
- git add Foo.mw &&
- git commit -m "conflict created" &&
- test_must_fail git pull &&
- "$PERL_PATH" -pi -e "s/[<=>].*//g" Foo.mw &&
- git commit -am "merge conflict solved" &&
- git push
- )
- '
-
- test_expect_failure 'git pull works after deleting a wiki page' '
- wiki_reset &&
- wiki_editpage Foo "wiki page added before the git clone" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_8 &&
-
- wiki_delete_page Foo &&
- (
- cd mw_dir_8 &&
- git pull &&
- test_path_is_missing Foo.mw
- )
- '
-}
diff --git a/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
deleted file mode 100755
index f08890d..0000000
--- a/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
+++ /dev/null
@@ -1,257 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-#
-# License: GPL v2 or later
-
-
-test_description='Test the Git Mediawiki remote helper: git clone'
-
-. ./test-gitmw-lib.sh
-. $TEST_DIRECTORY/test-lib.sh
-
-
-test_check_precond
-
-
-test_expect_success 'Git clone creates the expected git log with one file' '
- wiki_reset &&
- wiki_editpage foo "this is not important" false -c cat -s "this must be the same" &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_1 &&
- (
- cd mw_dir_1 &&
- git log --format=%s HEAD^..HEAD >log.tmp
- ) &&
- echo "this must be the same" >msg.tmp &&
- test_cmp msg.tmp mw_dir_1/log.tmp
-'
-
-
-test_expect_success 'Git clone creates the expected git log with multiple files' '
- wiki_reset &&
- wiki_editpage daddy "this is not important" false -s="this must be the same" &&
- wiki_editpage daddy "neither is this" true -s="this must also be the same" &&
- wiki_editpage daddy "neither is this" true -s="same same same" &&
- wiki_editpage dj "dont care" false -s="identical" &&
- wiki_editpage dj "dont care either" true -s="identical too" &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_2 &&
- (
- cd mw_dir_2 &&
- git log --format=%s Daddy.mw >logDaddy.tmp &&
- git log --format=%s Dj.mw >logDj.tmp
- ) &&
- echo "same same same" >msgDaddy.tmp &&
- echo "this must also be the same" >>msgDaddy.tmp &&
- echo "this must be the same" >>msgDaddy.tmp &&
- echo "identical too" >msgDj.tmp &&
- echo "identical" >>msgDj.tmp &&
- test_cmp msgDaddy.tmp mw_dir_2/logDaddy.tmp &&
- test_cmp msgDj.tmp mw_dir_2/logDj.tmp
-'
-
-
-test_expect_success 'Git clone creates only Main_Page.mw with an empty wiki' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_3 &&
- test_contains_N_files mw_dir_3 1 &&
- test_path_is_file mw_dir_3/Main_Page.mw
-'
-
-test_expect_success 'Git clone does not fetch a deleted page' '
- wiki_reset &&
- wiki_editpage foo "this page must be deleted before the clone" false &&
- wiki_delete_page foo &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_4 &&
- test_contains_N_files mw_dir_4 1 &&
- test_path_is_file mw_dir_4/Main_Page.mw &&
- test_path_is_missing mw_dir_4/Foo.mw
-'
-
-test_expect_success 'Git clone works with page added' '
- wiki_reset &&
- wiki_editpage foo " I will be cloned" false &&
- wiki_editpage bar "I will be cloned" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_5 &&
- wiki_getallpage ref_page_5 &&
- test_diff_directories mw_dir_5 ref_page_5 &&
- wiki_delete_page foo &&
- wiki_delete_page bar
-'
-
-test_expect_success 'Git clone works with an edited page ' '
- wiki_reset &&
- wiki_editpage foo "this page will be edited" \
- false -s "first edition of page foo" &&
- wiki_editpage foo "this page has been edited and must be on the clone " true &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_6 &&
- test_path_is_file mw_dir_6/Foo.mw &&
- test_path_is_file mw_dir_6/Main_Page.mw &&
- wiki_getallpage mw_dir_6/page_ref_6 &&
- test_diff_directories mw_dir_6 mw_dir_6/page_ref_6 &&
- (
- cd mw_dir_6 &&
- git log --format=%s HEAD^ Foo.mw > ../Foo.log
- ) &&
- echo "first edition of page foo" > FooExpect.log &&
- diff FooExpect.log Foo.log
-'
-
-
-test_expect_success 'Git clone works with several pages and some deleted ' '
- wiki_reset &&
- wiki_editpage foo "this page will not be deleted" false &&
- wiki_editpage bar "I must not be erased" false &&
- wiki_editpage namnam "I will not be there at the end" false &&
- wiki_editpage nyancat "nyan nyan nyan delete me" false &&
- wiki_delete_page namnam &&
- wiki_delete_page nyancat &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_7 &&
- test_path_is_file mw_dir_7/Foo.mw &&
- test_path_is_file mw_dir_7/Bar.mw &&
- test_path_is_missing mw_dir_7/Namnam.mw &&
- test_path_is_missing mw_dir_7/Nyancat.mw &&
- wiki_getallpage mw_dir_7/page_ref_7 &&
- test_diff_directories mw_dir_7 mw_dir_7/page_ref_7
-'
-
-
-test_expect_success 'Git clone works with one specific page cloned ' '
- wiki_reset &&
- wiki_editpage foo "I will not be cloned" false &&
- wiki_editpage bar "Do not clone me" false &&
- wiki_editpage namnam "I will be cloned :)" false -s="this log must stay" &&
- wiki_editpage nyancat "nyan nyan nyan you cant clone me" false &&
- git clone -c remote.origin.pages=namnam \
- mediawiki::'"$WIKI_URL"' mw_dir_8 &&
- test_contains_N_files mw_dir_8 1 &&
- test_path_is_file mw_dir_8/Namnam.mw &&
- test_path_is_missing mw_dir_8/Main_Page.mw &&
- (
- cd mw_dir_8 &&
- echo "this log must stay" >msg.tmp &&
- git log --format=%s >log.tmp &&
- test_cmp msg.tmp log.tmp
- ) &&
- wiki_check_content mw_dir_8/Namnam.mw Namnam
-'
-
-test_expect_success 'Git clone works with multiple specific page cloned ' '
- wiki_reset &&
- wiki_editpage foo "I will be there" false &&
- wiki_editpage bar "I will not disappear" false &&
- wiki_editpage namnam "I be erased" false &&
- wiki_editpage nyancat "nyan nyan nyan you will not erase me" false &&
- wiki_delete_page namnam &&
- git clone -c remote.origin.pages="foo bar nyancat namnam" \
- mediawiki::'"$WIKI_URL"' mw_dir_9 &&
- test_contains_N_files mw_dir_9 3 &&
- test_path_is_missing mw_dir_9/Namnam.mw &&
- test_path_is_file mw_dir_9/Foo.mw &&
- test_path_is_file mw_dir_9/Nyancat.mw &&
- test_path_is_file mw_dir_9/Bar.mw &&
- wiki_check_content mw_dir_9/Foo.mw Foo &&
- wiki_check_content mw_dir_9/Bar.mw Bar &&
- wiki_check_content mw_dir_9/Nyancat.mw Nyancat
-'
-
-test_expect_success 'Mediawiki-clone of several specific pages on wiki' '
- wiki_reset &&
- wiki_editpage foo "foo 1" false &&
- wiki_editpage bar "bar 1" false &&
- wiki_editpage dummy "dummy 1" false &&
- wiki_editpage cloned_1 "cloned_1 1" false &&
- wiki_editpage cloned_2 "cloned_2 2" false &&
- wiki_editpage cloned_3 "cloned_3 3" false &&
- mkdir -p ref_page_10 &&
- wiki_getpage cloned_1 ref_page_10 &&
- wiki_getpage cloned_2 ref_page_10 &&
- wiki_getpage cloned_3 ref_page_10 &&
- git clone -c remote.origin.pages="cloned_1 cloned_2 cloned_3" \
- mediawiki::'"$WIKI_URL"' mw_dir_10 &&
- test_diff_directories mw_dir_10 ref_page_10
-'
-
-test_expect_success 'Git clone works with the shallow option' '
- wiki_reset &&
- wiki_editpage foo "1st revision, should be cloned" false &&
- wiki_editpage bar "1st revision, should be cloned" false &&
- wiki_editpage nyan "1st revision, should not be cloned" false &&
- wiki_editpage nyan "2nd revision, should be cloned" false &&
- git -c remote.origin.shallow=true clone \
- mediawiki::'"$WIKI_URL"' mw_dir_11 &&
- test_contains_N_files mw_dir_11 4 &&
- test_path_is_file mw_dir_11/Nyan.mw &&
- test_path_is_file mw_dir_11/Foo.mw &&
- test_path_is_file mw_dir_11/Bar.mw &&
- test_path_is_file mw_dir_11/Main_Page.mw &&
- (
- cd mw_dir_11 &&
- test $(git log --oneline Nyan.mw | wc -l) -eq 1 &&
- test $(git log --oneline Foo.mw | wc -l) -eq 1 &&
- test $(git log --oneline Bar.mw | wc -l) -eq 1 &&
- test $(git log --oneline Main_Page.mw | wc -l ) -eq 1
- ) &&
- wiki_check_content mw_dir_11/Nyan.mw Nyan &&
- wiki_check_content mw_dir_11/Foo.mw Foo &&
- wiki_check_content mw_dir_11/Bar.mw Bar &&
- wiki_check_content mw_dir_11/Main_Page.mw Main_Page
-'
-
-test_expect_success 'Git clone works with the shallow option with a delete page' '
- wiki_reset &&
- wiki_editpage foo "1st revision, will be deleted" false &&
- wiki_editpage bar "1st revision, should be cloned" false &&
- wiki_editpage nyan "1st revision, should not be cloned" false &&
- wiki_editpage nyan "2nd revision, should be cloned" false &&
- wiki_delete_page foo &&
- git -c remote.origin.shallow=true clone \
- mediawiki::'"$WIKI_URL"' mw_dir_12 &&
- test_contains_N_files mw_dir_12 3 &&
- test_path_is_file mw_dir_12/Nyan.mw &&
- test_path_is_missing mw_dir_12/Foo.mw &&
- test_path_is_file mw_dir_12/Bar.mw &&
- test_path_is_file mw_dir_12/Main_Page.mw &&
- (
- cd mw_dir_12 &&
- test $(git log --oneline Nyan.mw | wc -l) -eq 1 &&
- test $(git log --oneline Bar.mw | wc -l) -eq 1 &&
- test $(git log --oneline Main_Page.mw | wc -l ) -eq 1
- ) &&
- wiki_check_content mw_dir_12/Nyan.mw Nyan &&
- wiki_check_content mw_dir_12/Bar.mw Bar &&
- wiki_check_content mw_dir_12/Main_Page.mw Main_Page
-'
-
-test_expect_success 'Test of fetching a category' '
- wiki_reset &&
- wiki_editpage Foo "I will be cloned" false -c=Category &&
- wiki_editpage Bar "Meet me on the repository" false -c=Category &&
- wiki_editpage Dummy "I will not come" false &&
- wiki_editpage BarWrong "I will stay online only" false -c=NotCategory &&
- git clone -c remote.origin.categories="Category" \
- mediawiki::'"$WIKI_URL"' mw_dir_13 &&
- wiki_getallpage ref_page_13 Category &&
- test_diff_directories mw_dir_13 ref_page_13
-'
-
-test_expect_success 'Test of resistance to modification of category on wiki for clone' '
- wiki_reset &&
- wiki_editpage Tobedeleted "this page will be deleted" false -c=Catone &&
- wiki_editpage Tobeedited "this page will be modified" false -c=Catone &&
- wiki_editpage Normalone "this page wont be modified and will be on git" false -c=Catone &&
- wiki_editpage Notconsidered "this page will not appear on local" false &&
- wiki_editpage Othercategory "this page will not appear on local" false -c=Cattwo &&
- wiki_editpage Tobeedited "this page have been modified" true -c=Catone &&
- wiki_delete_page Tobedeleted &&
- git clone -c remote.origin.categories="Catone" \
- mediawiki::'"$WIKI_URL"' mw_dir_14 &&
- wiki_getallpage ref_page_14 Catone &&
- test_diff_directories mw_dir_14 ref_page_14
-'
-
-test_done
diff --git a/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh b/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh
deleted file mode 100755
index 9ea2014..0000000
--- a/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-#
-# License: GPL v2 or later
-
-# tests for git-remote-mediawiki
-
-test_description='Test the Git Mediawiki remote helper: git push and git pull simple test cases'
-
-. ./test-gitmw-lib.sh
-. ./push-pull-tests.sh
-. $TEST_DIRECTORY/test-lib.sh
-
-test_check_precond
-
-test_push_pull
-
-test_done
diff --git a/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
deleted file mode 100755
index 526d928..0000000
--- a/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
+++ /dev/null
@@ -1,347 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-#
-# License: GPL v2 or later
-
-# tests for git-remote-mediawiki
-
-test_description='Test git-mediawiki with special characters in filenames'
-
-. ./test-gitmw-lib.sh
-. $TEST_DIRECTORY/test-lib.sh
-
-
-test_check_precond
-
-
-test_expect_success 'Git clone works for a wiki with accents in the page names' '
- wiki_reset &&
- wiki_editpage féé "This page must be délétéd before clone" false &&
- wiki_editpage kèè "This page must be deleted before clone" false &&
- wiki_editpage hàà "This page must be deleted before clone" false &&
- wiki_editpage kîî "This page must be deleted before clone" false &&
- wiki_editpage foo "This page must be deleted before clone" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_1 &&
- wiki_getallpage ref_page_1 &&
- test_diff_directories mw_dir_1 ref_page_1
-'
-
-
-test_expect_success 'Git pull works with a wiki with accents in the pages names' '
- wiki_reset &&
- wiki_editpage kîî "this page must be cloned" false &&
- wiki_editpage foo "this page must be cloned" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_2 &&
- wiki_editpage éàîôû "This page must be pulled" false &&
- (
- cd mw_dir_2 &&
- git pull
- ) &&
- wiki_getallpage ref_page_2 &&
- test_diff_directories mw_dir_2 ref_page_2
-'
-
-
-test_expect_success 'Cloning a chosen page works with accents' '
- wiki_reset &&
- wiki_editpage kîî "this page must be cloned" false &&
- git clone -c remote.origin.pages=kîî \
- mediawiki::'"$WIKI_URL"' mw_dir_3 &&
- wiki_check_content mw_dir_3/Kîî.mw Kîî &&
- test_path_is_file mw_dir_3/Kîî.mw &&
- rm -rf mw_dir_3
-'
-
-
-test_expect_success 'The shallow option works with accents' '
- wiki_reset &&
- wiki_editpage néoà "1st revision, should not be cloned" false &&
- wiki_editpage néoà "2nd revision, should be cloned" false &&
- git -c remote.origin.shallow=true clone \
- mediawiki::'"$WIKI_URL"' mw_dir_4 &&
- test_contains_N_files mw_dir_4 2 &&
- test_path_is_file mw_dir_4/Néoà.mw &&
- test_path_is_file mw_dir_4/Main_Page.mw &&
- (
- cd mw_dir_4 &&
- test $(git log --oneline Néoà.mw | wc -l) -eq 1 &&
- test $(git log --oneline Main_Page.mw | wc -l ) -eq 1
- ) &&
- wiki_check_content mw_dir_4/Néoà.mw Néoà &&
- wiki_check_content mw_dir_4/Main_Page.mw Main_Page
-'
-
-
-test_expect_success 'Cloning works when page name first letter has an accent' '
- wiki_reset &&
- wiki_editpage îî "this page must be cloned" false &&
- git clone -c remote.origin.pages=îî \
- mediawiki::'"$WIKI_URL"' mw_dir_5 &&
- test_path_is_file mw_dir_5/Îî.mw &&
- wiki_check_content mw_dir_5/Îî.mw Îî
-'
-
-
-test_expect_success 'Git push works with a wiki with accents' '
- wiki_reset &&
- wiki_editpage féé "lots of accents : éèàÖ" false &&
- wiki_editpage foo "this page must be cloned" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_6 &&
- (
- cd mw_dir_6 &&
- echo "A wild Pîkächû appears on the wiki" >Pîkächû.mw &&
- git add Pîkächû.mw &&
- git commit -m "A new page appears" &&
- git push
- ) &&
- wiki_getallpage ref_page_6 &&
- test_diff_directories mw_dir_6 ref_page_6
-'
-
-test_expect_success 'Git clone works with accentsand spaces' '
- wiki_reset &&
- wiki_editpage "é à î" "this page must be délété before the clone" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_7 &&
- wiki_getallpage ref_page_7 &&
- test_diff_directories mw_dir_7 ref_page_7
-'
-
-test_expect_success 'character $ in page name (mw -> git)' '
- wiki_reset &&
- wiki_editpage file_\$_foo "expect to be called file_$_foo" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_8 &&
- test_path_is_file mw_dir_8/File_\$_foo.mw &&
- wiki_getallpage ref_page_8 &&
- test_diff_directories mw_dir_8 ref_page_8
-'
-
-
-
-test_expect_success 'character $ in file name (git -> mw) ' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_9 &&
- (
- cd mw_dir_9 &&
- echo "this file is called File_\$_foo.mw" >File_\$_foo.mw &&
- git add . &&
- git commit -am "file File_\$_foo.mw" &&
- git pull &&
- git push
- ) &&
- wiki_getallpage ref_page_9 &&
- test_diff_directories mw_dir_9 ref_page_9
-'
-
-
-test_expect_failure 'capital at the beginning of file names' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_10 &&
- (
- cd mw_dir_10 &&
- echo "my new file foo" >foo.mw &&
- echo "my new file Foo... Finger crossed" >Foo.mw &&
- git add . &&
- git commit -am "file foo.mw" &&
- git pull &&
- git push
- ) &&
- wiki_getallpage ref_page_10 &&
- test_diff_directories mw_dir_10 ref_page_10
-'
-
-
-test_expect_failure 'special character at the beginning of file name from mw to git' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_11 &&
- wiki_editpage {char_1 "expect to be renamed {char_1" false &&
- wiki_editpage [char_2 "expect to be renamed [char_2" false &&
- (
- cd mw_dir_11 &&
- git pull
- ) &&
- test_path_is_file mw_dir_11/{char_1 &&
- test_path_is_file mw_dir_11/[char_2
-'
-
-test_expect_success 'Pull page with title containing ":" other than namespace separator' '
- wiki_editpage Foo:Bar content false &&
- (
- cd mw_dir_11 &&
- git pull
- ) &&
- test_path_is_file mw_dir_11/Foo:Bar.mw
-'
-
-test_expect_success 'Push page with title containing ":" other than namespace separator' '
- (
- cd mw_dir_11 &&
- echo content >NotANameSpace:Page.mw &&
- git add NotANameSpace:Page.mw &&
- git commit -m "add page with colon" &&
- git push
- ) &&
- wiki_page_exist NotANameSpace:Page
-'
-
-test_expect_success 'test of correct formatting for file name from mw to git' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_12 &&
- wiki_editpage char_%_7b_1 "expect to be renamed char{_1" false &&
- wiki_editpage char_%_5b_2 "expect to be renamed char{_2" false &&
- (
- cd mw_dir_12 &&
- git pull
- ) &&
- test_path_is_file mw_dir_12/Char\{_1.mw &&
- test_path_is_file mw_dir_12/Char\[_2.mw &&
- wiki_getallpage ref_page_12 &&
- mv ref_page_12/Char_%_7b_1.mw ref_page_12/Char\{_1.mw &&
- mv ref_page_12/Char_%_5b_2.mw ref_page_12/Char\[_2.mw &&
- test_diff_directories mw_dir_12 ref_page_12
-'
-
-
-test_expect_failure 'test of correct formatting for file name beginning with special character' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_13 &&
- (
- cd mw_dir_13 &&
- echo "my new file {char_1" >\{char_1.mw &&
- echo "my new file [char_2" >\[char_2.mw &&
- git add . &&
- git commit -am "committing some exotic file name..." &&
- git push &&
- git pull
- ) &&
- wiki_getallpage ref_page_13 &&
- test_path_is_file ref_page_13/{char_1.mw &&
- test_path_is_file ref_page_13/[char_2.mw &&
- test_diff_directories mw_dir_13 ref_page_13
-'
-
-
-test_expect_success 'test of correct formatting for file name from git to mw' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_14 &&
- (
- cd mw_dir_14 &&
- echo "my new file char{_1" >Char\{_1.mw &&
- echo "my new file char[_2" >Char\[_2.mw &&
- git add . &&
- git commit -m "committing some exotic file name..." &&
- git push
- ) &&
- wiki_getallpage ref_page_14 &&
- mv mw_dir_14/Char\{_1.mw mw_dir_14/Char_%_7b_1.mw &&
- mv mw_dir_14/Char\[_2.mw mw_dir_14/Char_%_5b_2.mw &&
- test_diff_directories mw_dir_14 ref_page_14
-'
-
-
-test_expect_success 'git clone with /' '
- wiki_reset &&
- wiki_editpage \/fo\/o "this is not important" false -c=Deleted &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_15 &&
- test_path_is_file mw_dir_15/%2Ffo%2Fo.mw &&
- wiki_check_content mw_dir_15/%2Ffo%2Fo.mw \/fo\/o
-'
-
-
-test_expect_success 'git push with /' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_16 &&
- echo "I will be on the wiki" >mw_dir_16/%2Ffo%2Fo.mw &&
- (
- cd mw_dir_16 &&
- git add %2Ffo%2Fo.mw &&
- git commit -m " %2Ffo%2Fo added" &&
- git push
- ) &&
- wiki_page_exist \/fo\/o &&
- wiki_check_content mw_dir_16/%2Ffo%2Fo.mw \/fo\/o
-
-'
-
-
-test_expect_success 'git clone with \' '
- wiki_reset &&
- wiki_editpage \\ko\\o "this is not important" false -c=Deleted &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_17 &&
- test_path_is_file mw_dir_17/\\ko\\o.mw &&
- wiki_check_content mw_dir_17/\\ko\\o.mw \\ko\\o
-'
-
-
-test_expect_success 'git push with \' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_18 &&
- echo "I will be on the wiki" >mw_dir_18/\\ko\\o.mw &&
- (
- cd mw_dir_18 &&
- git add \\ko\\o.mw &&
- git commit -m " \\ko\\o added" &&
- git push
- ) &&
- wiki_page_exist \\ko\\o &&
- wiki_check_content mw_dir_18/\\ko\\o.mw \\ko\\o
-
-'
-
-test_expect_success 'git clone with \ in format control' '
- wiki_reset &&
- wiki_editpage \\no\\o "this is not important" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_19 &&
- test_path_is_file mw_dir_19/\\no\\o.mw &&
- wiki_check_content mw_dir_19/\\no\\o.mw \\no\\o
-'
-
-
-test_expect_success 'git push with \ in format control' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_20 &&
- echo "I will be on the wiki" >mw_dir_20/\\fo\\o.mw &&
- (
- cd mw_dir_20 &&
- git add \\fo\\o.mw &&
- git commit -m " \\fo\\o added" &&
- git push
- ) &&
- wiki_page_exist \\fo\\o &&
- wiki_check_content mw_dir_20/\\fo\\o.mw \\fo\\o
-
-'
-
-
-test_expect_success 'fast-import meta-characters in page name (mw -> git)' '
- wiki_reset &&
- wiki_editpage \"file\"_\\_foo "expect to be called \"file\"_\\_foo" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_21 &&
- test_path_is_file mw_dir_21/\"file\"_\\_foo.mw &&
- wiki_getallpage ref_page_21 &&
- test_diff_directories mw_dir_21 ref_page_21
-'
-
-
-test_expect_success 'fast-import meta-characters in page name (git -> mw) ' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_22 &&
- (
- cd mw_dir_22 &&
- echo "this file is called \"file\"_\\_foo.mw" >\"file\"_\\_foo &&
- git add . &&
- git commit -am "file \"file\"_\\_foo" &&
- git pull &&
- git push
- ) &&
- wiki_getallpage ref_page_22 &&
- test_diff_directories mw_dir_22 ref_page_22
-'
-
-
-test_done
diff --git a/contrib/mw-to-git/t/t9363-mw-to-git-export-import.sh b/contrib/mw-to-git/t/t9363-mw-to-git-export-import.sh
deleted file mode 100755
index 7139995..0000000
--- a/contrib/mw-to-git/t/t9363-mw-to-git-export-import.sh
+++ /dev/null
@@ -1,218 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-#
-# License: GPL v2 or later
-
-# tests for git-remote-mediawiki
-
-test_description='Test the Git Mediawiki remote helper: git push and git pull simple test cases'
-
-. ./test-gitmw-lib.sh
-. $TEST_DIRECTORY/test-lib.sh
-
-
-test_check_precond
-
-
-test_git_reimport () {
- git -c remote.origin.dumbPush=true push &&
- git -c remote.origin.mediaImport=true pull --rebase
-}
-
-# Don't bother with permissions, be administrator by default
-test_expect_success 'setup config' '
- git config --global remote.origin.mwLogin "$WIKI_ADMIN" &&
- git config --global remote.origin.mwPassword "$WIKI_PASSW" &&
- test_might_fail git config --global --unset remote.origin.mediaImport
-'
-
-test_expect_failure 'git push can upload media (File:) files' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- (
- cd mw_dir &&
- echo "hello world" >Foo.txt &&
- git add Foo.txt &&
- git commit -m "add a text file" &&
- git push &&
- "$PERL_PATH" -e "print STDOUT \"binary content: \".chr(255);" >Foo.txt &&
- git add Foo.txt &&
- git commit -m "add a text file with binary content" &&
- git push
- )
-'
-
-test_expect_failure 'git clone works on previously created wiki with media files' '
- test_when_finished "rm -rf mw_dir mw_dir_clone" &&
- git clone -c remote.origin.mediaimport=true \
- mediawiki::'"$WIKI_URL"' mw_dir_clone &&
- test_cmp mw_dir_clone/Foo.txt mw_dir/Foo.txt &&
- (cd mw_dir_clone && git checkout HEAD^) &&
- (cd mw_dir && git checkout HEAD^) &&
- test_path_is_file mw_dir_clone/Foo.txt &&
- test_cmp mw_dir_clone/Foo.txt mw_dir/Foo.txt
-'
-
-test_expect_success 'git push can upload media (File:) files containing valid UTF-8' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- (
- cd mw_dir &&
- "$PERL_PATH" -e "print STDOUT \"UTF-8 content: éèàéê€.\";" >Bar.txt &&
- git add Bar.txt &&
- git commit -m "add a text file with UTF-8 content" &&
- git push
- )
-'
-
-test_expect_success 'git clone works on previously created wiki with media files containing valid UTF-8' '
- test_when_finished "rm -rf mw_dir mw_dir_clone" &&
- git clone -c remote.origin.mediaimport=true \
- mediawiki::'"$WIKI_URL"' mw_dir_clone &&
- test_cmp mw_dir_clone/Bar.txt mw_dir/Bar.txt
-'
-
-test_expect_success 'git push & pull work with locally renamed media files' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- test_when_finished "rm -fr mw_dir" &&
- (
- cd mw_dir &&
- echo "A File" >Foo.txt &&
- git add Foo.txt &&
- git commit -m "add a file" &&
- git mv Foo.txt Bar.txt &&
- git commit -m "Rename a file" &&
- test_git_reimport &&
- echo "A File" >expect &&
- test_cmp expect Bar.txt &&
- test_path_is_missing Foo.txt
- )
-'
-
-test_expect_success 'git push can propagate local page deletion' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- test_when_finished "rm -fr mw_dir" &&
- (
- cd mw_dir &&
- test_path_is_missing Foo.mw &&
- echo "hello world" >Foo.mw &&
- git add Foo.mw &&
- git commit -m "Add the page Foo" &&
- git push &&
- rm -f Foo.mw &&
- git commit -am "Delete the page Foo" &&
- test_git_reimport &&
- test_path_is_missing Foo.mw
- )
-'
-
-test_expect_success 'git push can propagate local media file deletion' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- test_when_finished "rm -fr mw_dir" &&
- (
- cd mw_dir &&
- echo "hello world" >Foo.txt &&
- git add Foo.txt &&
- git commit -m "Add the text file Foo" &&
- git rm Foo.txt &&
- git commit -m "Delete the file Foo" &&
- test_git_reimport &&
- test_path_is_missing Foo.txt
- )
-'
-
-# test failure: the file is correctly uploaded, and then deleted but
-# as no page link to it, the import (which looks at page revisions)
-# doesn't notice the file deletion on the wiki. We fetch the list of
-# files from the wiki, but as the file is deleted, it doesn't appear.
-test_expect_failure 'git pull correctly imports media file deletion when no page link to it' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- test_when_finished "rm -fr mw_dir" &&
- (
- cd mw_dir &&
- echo "hello world" >Foo.txt &&
- git add Foo.txt &&
- git commit -m "Add the text file Foo" &&
- git push &&
- git rm Foo.txt &&
- git commit -m "Delete the file Foo" &&
- test_git_reimport &&
- test_path_is_missing Foo.txt
- )
-'
-
-test_expect_success 'git push properly warns about insufficient permissions' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- test_when_finished "rm -fr mw_dir" &&
- (
- cd mw_dir &&
- echo "A File" >foo.forbidden &&
- git add foo.forbidden &&
- git commit -m "add a file" &&
- git push 2>actual &&
- test_grep "foo.forbidden is not a permitted file" actual
- )
-'
-
-test_expect_success 'setup a repository with media files' '
- wiki_reset &&
- wiki_editpage testpage "I am linking a file [[File:File.txt]]" false &&
- echo "File content" >File.txt &&
- wiki_upload_file File.txt &&
- echo "Another file content" >AnotherFile.txt &&
- wiki_upload_file AnotherFile.txt
-'
-
-test_expect_success 'git clone works with one specific page cloned and mediaimport=true' '
- git clone -c remote.origin.pages=testpage \
- -c remote.origin.mediaimport=true \
- mediawiki::'"$WIKI_URL"' mw_dir_15 &&
- test_when_finished "rm -rf mw_dir_15" &&
- test_contains_N_files mw_dir_15 3 &&
- test_path_is_file mw_dir_15/Testpage.mw &&
- test_path_is_file mw_dir_15/File:File.txt.mw &&
- test_path_is_file mw_dir_15/File.txt &&
- test_path_is_missing mw_dir_15/Main_Page.mw &&
- test_path_is_missing mw_dir_15/File:AnotherFile.txt.mw &&
- test_path_is_missing mw_dir_15/AnothetFile.txt &&
- wiki_check_content mw_dir_15/Testpage.mw Testpage &&
- test_cmp mw_dir_15/File.txt File.txt
-'
-
-test_expect_success 'git clone works with one specific page cloned and mediaimport=false' '
- test_when_finished "rm -rf mw_dir_16" &&
- git clone -c remote.origin.pages=testpage \
- mediawiki::'"$WIKI_URL"' mw_dir_16 &&
- test_contains_N_files mw_dir_16 1 &&
- test_path_is_file mw_dir_16/Testpage.mw &&
- test_path_is_missing mw_dir_16/File:File.txt.mw &&
- test_path_is_missing mw_dir_16/File.txt &&
- test_path_is_missing mw_dir_16/Main_Page.mw &&
- wiki_check_content mw_dir_16/Testpage.mw Testpage
-'
-
-# should behave like mediaimport=false
-test_expect_success 'git clone works with one specific page cloned and mediaimport unset' '
- test_when_finished "rm -fr mw_dir_17" &&
- git clone -c remote.origin.pages=testpage \
- mediawiki::'"$WIKI_URL"' mw_dir_17 &&
- test_contains_N_files mw_dir_17 1 &&
- test_path_is_file mw_dir_17/Testpage.mw &&
- test_path_is_missing mw_dir_17/File:File.txt.mw &&
- test_path_is_missing mw_dir_17/File.txt &&
- test_path_is_missing mw_dir_17/Main_Page.mw &&
- wiki_check_content mw_dir_17/Testpage.mw Testpage
-'
-
-test_done
diff --git a/contrib/mw-to-git/t/t9364-pull-by-rev.sh b/contrib/mw-to-git/t/t9364-pull-by-rev.sh
deleted file mode 100755
index 5c22457..0000000
--- a/contrib/mw-to-git/t/t9364-pull-by-rev.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-test_description='Test the Git Mediawiki remote helper: git pull by revision'
-
-. ./test-gitmw-lib.sh
-. ./push-pull-tests.sh
-. $TEST_DIRECTORY/test-lib.sh
-
-test_check_precond
-
-test_expect_success 'configuration' '
- git config --global mediawiki.fetchStrategy by_rev
-'
-
-test_push_pull
-
-test_done
diff --git a/contrib/mw-to-git/t/t9365-continuing-queries.sh b/contrib/mw-to-git/t/t9365-continuing-queries.sh
deleted file mode 100755
index d3e7312..0000000
--- a/contrib/mw-to-git/t/t9365-continuing-queries.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-test_description='Test the Git Mediawiki remote helper: queries w/ more than 500 results'
-
-. ./test-gitmw-lib.sh
-. $TEST_DIRECTORY/test-lib.sh
-
-test_check_precond
-
-test_expect_success 'creating page w/ >500 revisions' '
- wiki_reset &&
- for i in $(test_seq 501)
- do
- echo "creating revision $i" &&
- wiki_editpage foo "revision $i<br/>" true || return 1
- done
-'
-
-test_expect_success 'cloning page w/ >500 revisions' '
- git clone mediawiki::'"$WIKI_URL"' mw_dir
-'
-
-test_done
diff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh
deleted file mode 100755
index 64e46c1..0000000
--- a/contrib/mw-to-git/t/test-gitmw-lib.sh
+++ /dev/null
@@ -1,432 +0,0 @@
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-# License: GPL v2 or later
-
-#
-# CONFIGURATION VARIABLES
-# You might want to change these ones
-#
-
-. ./test.config
-
-WIKI_BASE_URL=http://$SERVER_ADDR:$PORT
-WIKI_URL=$WIKI_BASE_URL/$WIKI_DIR_NAME
-CURR_DIR=$(pwd)
-TEST_OUTPUT_DIRECTORY=$(pwd)
-TEST_DIRECTORY="$CURR_DIR"/../../../t
-
-export TEST_OUTPUT_DIRECTORY TEST_DIRECTORY CURR_DIR
-
-if test "$LIGHTTPD" = "false" ; then
- PORT=80
-else
- WIKI_DIR_INST="$CURR_DIR/$WEB_WWW"
-fi
-
-wiki_upload_file () {
- "$CURR_DIR"/test-gitmw.pl upload_file "$@"
-}
-
-wiki_getpage () {
- "$CURR_DIR"/test-gitmw.pl get_page "$@"
-}
-
-wiki_delete_page () {
- "$CURR_DIR"/test-gitmw.pl delete_page "$@"
-}
-
-wiki_editpage () {
- "$CURR_DIR"/test-gitmw.pl edit_page "$@"
-}
-
-die () {
- die_with_status 1 "$@"
-}
-
-die_with_status () {
- status=$1
- shift
- echo >&2 "$*"
- exit "$status"
-}
-
-
-# Check the preconditions to run git-remote-mediawiki's tests
-test_check_precond () {
- if ! test_have_prereq PERL
- then
- skip_all='skipping gateway git-mw tests, perl not available'
- test_done
- fi
-
- GIT_EXEC_PATH=$(cd "$(dirname "$0")" && cd "../.." && pwd)
- PATH="$GIT_EXEC_PATH"'/bin-wrapper:'"$PATH"
-
- if ! test -d "$WIKI_DIR_INST/$WIKI_DIR_NAME"
- then
- skip_all='skipping gateway git-mw tests, no mediawiki found'
- test_done
- fi
-}
-
-# test_diff_directories <dir_git> <dir_wiki>
-#
-# Compare the contents of directories <dir_git> and <dir_wiki> with diff
-# and errors if they do not match. The program will
-# not look into .git in the process.
-# Warning: the first argument MUST be the directory containing the git data
-test_diff_directories () {
- rm -rf "$1_tmp"
- mkdir -p "$1_tmp"
- cp "$1"/*.mw "$1_tmp"
- diff -r -b "$1_tmp" "$2"
-}
-
-# $1=<dir>
-# $2=<N>
-#
-# Check that <dir> contains exactly <N> files
-test_contains_N_files () {
- if test $(ls -- "$1" | wc -l) -ne "$2"; then
- echo "directory $1 should contain $2 files"
- echo "it contains these files:"
- ls "$1"
- false
- fi
-}
-
-
-# wiki_check_content <file_name> <page_name>
-#
-# Compares the contents of the file <file_name> and the wiki page
-# <page_name> and exits with error 1 if they do not match.
-wiki_check_content () {
- mkdir -p wiki_tmp
- wiki_getpage "$2" wiki_tmp
- # replacement of forbidden character in file name
- page_name=$(printf "%s\n" "$2" | sed -e "s/\//%2F/g")
-
- diff -b "$1" wiki_tmp/"$page_name".mw
- if test $? -ne 0
- then
- rm -rf wiki_tmp
- error "ERROR: file $2 not found on wiki"
- fi
- rm -rf wiki_tmp
-}
-
-# wiki_page_exist <page_name>
-#
-# Check the existence of the page <page_name> on the wiki and exits
-# with error if it is absent from it.
-wiki_page_exist () {
- mkdir -p wiki_tmp
- wiki_getpage "$1" wiki_tmp
- page_name=$(printf "%s\n" "$1" | sed "s/\//%2F/g")
- if test -f wiki_tmp/"$page_name".mw ; then
- rm -rf wiki_tmp
- else
- rm -rf wiki_tmp
- error "test failed: file $1 not found on wiki"
- fi
-}
-
-# wiki_getallpagename
-#
-# Fetch the name of each page on the wiki.
-wiki_getallpagename () {
- "$CURR_DIR"/test-gitmw.pl getallpagename
-}
-
-# wiki_getallpagecategory <category>
-#
-# Fetch the name of each page belonging to <category> on the wiki.
-wiki_getallpagecategory () {
- "$CURR_DIR"/test-gitmw.pl getallpagename "$@"
-}
-
-# wiki_getallpage <dest_dir> [<category>]
-#
-# Fetch all the pages from the wiki and place them in the directory
-# <dest_dir>.
-# If <category> is define, then wiki_getallpage fetch the pages included
-# in <category>.
-wiki_getallpage () {
- if test -z "$2";
- then
- wiki_getallpagename
- else
- wiki_getallpagecategory "$2"
- fi
- mkdir -p "$1"
- while read -r line; do
- wiki_getpage "$line" $1;
- done < all.txt
-}
-
-# ================= Install part =================
-
-error () {
- echo "$@" >&2
- exit 1
-}
-
-# config_lighttpd
-#
-# Create the configuration files and the folders necessary to start lighttpd.
-# Overwrite any existing file.
-config_lighttpd () {
- mkdir -p $WEB
- mkdir -p $WEB_TMP
- mkdir -p $WEB_WWW
- cat > $WEB/lighttpd.conf <<EOF
- server.document-root = "$CURR_DIR/$WEB_WWW"
- server.port = $PORT
- server.pid-file = "$CURR_DIR/$WEB_TMP/pid"
-
- server.modules = (
- "mod_rewrite",
- "mod_redirect",
- "mod_access",
- "mod_accesslog",
- "mod_fastcgi"
- )
-
- index-file.names = ("index.php" , "index.html")
-
- mimetype.assign = (
- ".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"
- )
-
- fastcgi.server = ( ".php" =>
- ("localhost" =>
- ( "socket" => "$CURR_DIR/$WEB_TMP/php.socket",
- "bin-path" => "$PHP_DIR/php-cgi -c $CURR_DIR/$WEB/php.ini"
-
- )
- )
- )
-EOF
-
- cat > $WEB/php.ini <<EOF
- session.save_path ='$CURR_DIR/$WEB_TMP'
-EOF
-}
-
-# start_lighttpd
-#
-# Start or restart daemon lighttpd. If restart, rewrite configuration files.
-start_lighttpd () {
- if test -f "$WEB_TMP/pid"; then
- echo "Instance already running. Restarting..."
- stop_lighttpd
- fi
- config_lighttpd
- "$LIGHTTPD_DIR"/lighttpd -f "$WEB"/lighttpd.conf
-
- if test $? -ne 0 ; then
- echo "Could not execute http daemon lighttpd"
- exit 1
- fi
-}
-
-# stop_lighttpd
-#
-# Kill daemon lighttpd and removes files and folders associated.
-stop_lighttpd () {
- test -f "$WEB_TMP/pid" && kill $(cat "$WEB_TMP/pid")
-}
-
-wiki_delete_db () {
- rm -rf \
- "$FILES_FOLDER_DB"/* || error "Couldn't delete $FILES_FOLDER_DB/"
-}
-
-wiki_delete_db_backup () {
- rm -rf \
- "$FILES_FOLDER_POST_INSTALL_DB"/* || error "Couldn't delete $FILES_FOLDER_POST_INSTALL_DB/"
-}
-
-# Install MediaWiki using its install.php script. If the database file
-# already exists, it will be deleted.
-install_mediawiki () {
-
- localsettings="$WIKI_DIR_INST/$WIKI_DIR_NAME/LocalSettings.php"
- if test -f "$localsettings"
- then
- error "We already installed the wiki, since $localsettings exists" \
- "perhaps you wanted to run 'delete' first?"
- fi
-
- wiki_delete_db
- wiki_delete_db_backup
- mkdir \
- "$FILES_FOLDER_DB/" \
- "$FILES_FOLDER_POST_INSTALL_DB/"
-
- install_script="$WIKI_DIR_INST/$WIKI_DIR_NAME/maintenance/install.php"
- echo "Installing MediaWiki using $install_script. This may take some time ..."
-
- php "$WIKI_DIR_INST/$WIKI_DIR_NAME/maintenance/install.php" \
- --server $WIKI_BASE_URL \
- --scriptpath /wiki \
- --lang en \
- --dbtype sqlite \
- --dbpath $PWD/$FILES_FOLDER_DB/ \
- --pass "$WIKI_PASSW" \
- Git-MediaWiki-Test \
- "$WIKI_ADMIN" ||
- error "Couldn't run $install_script, see errors above. Try to run ./install-wiki.sh delete first."
- cat <<-'EOF' >>$localsettings
-# Custom settings added by test-gitmw-lib.sh
-#
-# Uploading text files is needed for
-# t9363-mw-to-git-export-import.sh
-$wgEnableUploads = true;
-$wgFileExtensions[] = 'txt';
-EOF
-
- # Copy the initially generated database file into our backup
- # folder
- cp -R "$FILES_FOLDER_DB/"* "$FILES_FOLDER_POST_INSTALL_DB/" ||
- error "Unable to copy $FILES_FOLDER_DB/* to $FILES_FOLDER_POST_INSTALL_DB/*"
-}
-
-# Install a wiki in your web server directory.
-wiki_install () {
- if test $LIGHTTPD = "true" ; then
- start_lighttpd
- fi
-
- # In this part, we change directory to $TMP in order to download,
- # unpack and copy the files of MediaWiki
- (
- mkdir -p "$WIKI_DIR_INST/$WIKI_DIR_NAME"
- if ! test -d "$WIKI_DIR_INST/$WIKI_DIR_NAME"
- then
- error "Folder $WIKI_DIR_INST/$WIKI_DIR_NAME doesn't exist.
- Please create it and launch the script again."
- fi
-
- # Fetch MediaWiki's archive if not already present in the
- # download directory
- mkdir -p "$FILES_FOLDER_DOWNLOAD"
- MW_FILENAME="mediawiki-$MW_VERSION_MAJOR.$MW_VERSION_MINOR.tar.gz"
- cd "$FILES_FOLDER_DOWNLOAD"
- if ! test -f $MW_FILENAME
- then
- echo "Downloading $MW_VERSION_MAJOR.$MW_VERSION_MINOR sources ..."
- wget "http://download.wikimedia.org/mediawiki/$MW_VERSION_MAJOR/$MW_FILENAME" ||
- error "Unable to download "\
- "http://download.wikimedia.org/mediawiki/$MW_VERSION_MAJOR/"\
- "$MW_FILENAME. "\
- "Please fix your connection and launch the script again."
- echo "$MW_FILENAME downloaded in $(pwd)/;" \
- "you can delete it later if you want."
- else
- echo "Reusing existing $MW_FILENAME downloaded in $(pwd)/"
- fi
- archive_abs_path=$(pwd)/$MW_FILENAME
- cd "$WIKI_DIR_INST/$WIKI_DIR_NAME/" ||
- error "can't cd to $WIKI_DIR_INST/$WIKI_DIR_NAME/"
- tar xzf "$archive_abs_path" --strip-components=1 ||
- error "Unable to extract WikiMedia's files from $archive_abs_path to "\
- "$WIKI_DIR_INST/$WIKI_DIR_NAME"
- ) || exit 1
- echo Extracted in "$WIKI_DIR_INST/$WIKI_DIR_NAME"
-
- install_mediawiki
-
- echo "Your wiki has been installed. You can check it at
- $WIKI_URL"
-}
-
-# Reset the database of the wiki and the password of the admin
-#
-# Warning: This function must be called only in a subdirectory of t/ directory
-wiki_reset () {
- # Copy initial database of the wiki
- if ! test -d "../$FILES_FOLDER_DB"
- then
- error "No wiki database at ../$FILES_FOLDER_DB, not installed yet?"
- fi
- if ! test -d "../$FILES_FOLDER_POST_INSTALL_DB"
- then
- error "No wiki backup database at ../$FILES_FOLDER_POST_INSTALL_DB, failed installation?"
- fi
- wiki_delete_db
- cp -R "../$FILES_FOLDER_POST_INSTALL_DB/"* "../$FILES_FOLDER_DB/" ||
- error "Can't copy ../$FILES_FOLDER_POST_INSTALL_DB/* to ../$FILES_FOLDER_DB/*"
- echo "File $FILES_FOLDER_DB/* has been reset"
-}
-
-# Delete the wiki created in the web server's directory and all its content
-# saved in the database.
-wiki_delete () {
- if test $LIGHTTPD = "true"; then
- stop_lighttpd
- rm -fr "$WEB"
- else
- # Delete the wiki's directory.
- rm -rf "$WIKI_DIR_INST/$WIKI_DIR_NAME" ||
- error "Wiki's directory $WIKI_DIR_INST/" \
- "$WIKI_DIR_NAME could not be deleted"
- fi
- wiki_delete_db
- wiki_delete_db_backup
-}
diff --git a/contrib/mw-to-git/t/test-gitmw.pl b/contrib/mw-to-git/t/test-gitmw.pl
deleted file mode 100755
index c5d687f..0000000
--- a/contrib/mw-to-git/t/test-gitmw.pl
+++ /dev/null
@@ -1,223 +0,0 @@
-#!/usr/bin/perl -w -s
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-# License: GPL v2 or later
-
-# Usage:
-# ./test-gitmw.pl <command> [argument]*
-# Execute in terminal using the name of the function to call as first
-# parameter, and the function's arguments as following parameters
-#
-# Example:
-# ./test-gitmw.pl "get_page" foo .
-# will call <wiki_getpage> with arguments <foo> and <.>
-#
-# Available functions are:
-# "get_page"
-# "delete_page"
-# "edit_page"
-# "getallpagename"
-
-use MediaWiki::API;
-use Getopt::Long;
-use DateTime::Format::ISO8601;
-use constant SLASH_REPLACEMENT => "%2F";
-
-#Parsing of the config file
-
-my $configfile = "$ENV{'CURR_DIR'}/test.config";
-my %config;
-open my $CONFIG, "<", $configfile or die "can't open $configfile: $!";
-while (<$CONFIG>)
-{
- chomp;
- s/#.*//;
- s/^\s+//;
- s/\s+$//;
- next unless length;
- my ($key, $value) = split (/\s*=\s*/,$_, 2);
- $config{$key} = $value;
- last if ($key eq 'LIGHTTPD' and $value eq 'false');
- last if ($key eq 'PORT');
-}
-close $CONFIG or die "can't close $configfile: $!";
-
-my $wiki_address = "http://$config{'SERVER_ADDR'}".":"."$config{'PORT'}";
-my $wiki_url = "$wiki_address/$config{'WIKI_DIR_NAME'}/api.php";
-my $wiki_admin = "$config{'WIKI_ADMIN'}";
-my $wiki_admin_pass = "$config{'WIKI_PASSW'}";
-my $mw = MediaWiki::API->new;
-$mw->{config}->{api_url} = $wiki_url;
-
-
-# wiki_login <name> <password>
-#
-# Logs the user with <name> and <password> in the global variable
-# of the mediawiki $mw
-sub wiki_login {
- $mw->login( { lgname => "$_[0]",lgpassword => "$_[1]" } )
- || die "getpage: login failed";
-}
-
-# wiki_getpage <wiki_page> <dest_path>
-#
-# fetch a page <wiki_page> from the wiki referenced in the global variable
-# $mw and copies its content in directory dest_path
-sub wiki_getpage {
- my $pagename = $_[0];
- my $destdir = $_[1];
-
- my $page = $mw->get_page( { title => $pagename } );
- if (!defined($page)) {
- die "getpage: wiki does not exist";
- }
-
- my $content = $page->{'*'};
- if (!defined($content)) {
- die "getpage: page does not exist";
- }
-
- $pagename=$page->{'title'};
- # Replace spaces by underscore in the page name
- $pagename =~ s/ /_/g;
- $pagename =~ s/\//%2F/g;
- open(my $file, ">:encoding(UTF-8)", "$destdir/$pagename.mw");
- print $file "$content";
- close ($file);
-
-}
-
-# wiki_delete_page <page_name>
-#
-# delete the page with name <page_name> from the wiki referenced
-# in the global variable $mw
-sub wiki_delete_page {
- my $pagename = $_[0];
-
- my $exist=$mw->get_page({title => $pagename});
-
- if (defined($exist->{'*'})){
- $mw->edit({ action => 'delete',
- title => $pagename})
- || die $mw->{error}->{code} . ": " . $mw->{error}->{details};
- } else {
- die "no page with such name found: $pagename\n";
- }
-}
-
-# wiki_editpage <wiki_page> <wiki_content> <wiki_append> [-c=<category>] [-s=<summary>]
-#
-# Edit a page named <wiki_page> with content <wiki_content> on the wiki
-# referenced with the global variable $mw
-# If <wiki_append> == true : append <wiki_content> at the end of the actual
-# content of the page <wiki_page>
-# If <wik_page> doesn't exist, that page is created with the <wiki_content>
-sub wiki_editpage {
- my $wiki_page = $_[0];
- my $wiki_content = $_[1];
- my $wiki_append = $_[2];
- my $summary = "";
- my ($summ, $cat) = ();
- GetOptions('s=s' => \$summ, 'c=s' => \$cat);
-
- my $append = 0;
- if (defined($wiki_append) && $wiki_append eq 'true') {
- $append=1;
- }
-
- my $previous_text ="";
-
- if ($append) {
- my $ref = $mw->get_page( { title => $wiki_page } );
- $previous_text = $ref->{'*'};
- }
-
- my $text = $wiki_content;
- if (defined($previous_text)) {
- $text="$previous_text$text";
- }
-
- # Eventually, add this page to a category.
- if (defined($cat)) {
- my $category_name="[[Category:$cat]]";
- $text="$text\n $category_name";
- }
- if(defined($summ)){
- $summary=$summ;
- }
-
- $mw->edit( { action => 'edit', title => $wiki_page, summary => $summary, text => "$text"} );
-}
-
-# wiki_getallpagename [<category>]
-#
-# Fetch all pages of the wiki referenced by the global variable $mw
-# and print the names of each one in the file all.txt with a new line
-# ("\n") between these.
-# If the argument <category> is defined, then this function get only the pages
-# belonging to <category>.
-sub wiki_getallpagename {
- # fetch the pages of the wiki
- if (defined($_[0])) {
- my $mw_pages = $mw->list ( { action => 'query',
- list => 'categorymembers',
- cmtitle => "Category:$_[0]",
- cmnamespace => 0,
- cmlimit => 500 },
- )
- || die $mw->{error}->{code}.": ".$mw->{error}->{details};
- open(my $file, ">:encoding(UTF-8)", "all.txt");
- foreach my $page (@{$mw_pages}) {
- print $file "$page->{title}\n";
- }
- close ($file);
-
- } else {
- my $mw_pages = $mw->list({
- action => 'query',
- list => 'allpages',
- aplimit => 500,
- })
- || die $mw->{error}->{code}.": ".$mw->{error}->{details};
- open(my $file, ">:encoding(UTF-8)", "all.txt");
- foreach my $page (@{$mw_pages}) {
- print $file "$page->{title}\n";
- }
- close ($file);
- }
-}
-
-sub wiki_upload_file {
- my $file_name = $_[0];
- my $resultat = $mw->edit ( {
- action => 'upload',
- filename => $file_name,
- comment => 'upload a file',
- file => [ $file_name ],
- ignorewarnings=>1,
- }, {
- skip_encoding => 1
- } ) || die $mw->{error}->{code} . ' : ' . $mw->{error}->{details};
-}
-
-
-
-# Main part of this script: parse the command line arguments
-# and select which function to execute
-my $fct_to_call = shift;
-
-wiki_login($wiki_admin, $wiki_admin_pass);
-
-my %functions_to_call = (
- upload_file => \&wiki_upload_file,
- get_page => \&wiki_getpage,
- delete_page => \&wiki_delete_page,
- edit_page => \&wiki_editpage,
- getallpagename => \&wiki_getallpagename,
-);
-die "$0 ERROR: wrong argument" unless exists $functions_to_call{$fct_to_call};
-$functions_to_call{$fct_to_call}->(map { utf8::decode($_); $_ } @ARGV);
diff --git a/contrib/mw-to-git/t/test.config b/contrib/mw-to-git/t/test.config
deleted file mode 100644
index ed10b3e..0000000
--- a/contrib/mw-to-git/t/test.config
+++ /dev/null
@@ -1,40 +0,0 @@
-# Name of the web server's directory dedicated to the wiki is WIKI_DIR_NAME
-WIKI_DIR_NAME=wiki
-
-# Login and password of the wiki's admin
-WIKI_ADMIN=WikiAdmin
-WIKI_PASSW=AdminPass1
-
-# Address of the web server
-SERVER_ADDR=localhost
-
-# If LIGHTTPD is not set to true, the script will use the default
-# web server running in WIKI_DIR_INST.
-WIKI_DIR_INST=/var/www
-
-# If LIGHTTPD is set to true, the script will use Lighttpd to run
-# the wiki.
-LIGHTTPD=true
-
-# The variables below are useful only if LIGHTTPD is set to true.
-PORT=1234
-PHP_DIR=/usr/bin
-LIGHTTPD_DIR=/usr/sbin
-WEB=WEB
-WEB_TMP=$WEB/tmp
-WEB_WWW=$WEB/www
-
-# Where our configuration for the wiki is located
-FILES_FOLDER=mediawiki
-FILES_FOLDER_DOWNLOAD=$FILES_FOLDER/download
-FILES_FOLDER_DB=$FILES_FOLDER/db
-FILES_FOLDER_POST_INSTALL_DB=$FILES_FOLDER/post-install-db
-
-# The variables below are used by the script to install a wiki.
-# You should not modify these unless you are modifying the script itself.
-# tested versions: 1.19.X -> 1.21.1 -> 1.34.2
-#
-# See https://www.mediawiki.org/wiki/Download for what the latest
-# version is.
-MW_VERSION_MAJOR=1.34
-MW_VERSION_MINOR=2
diff --git a/contrib/persistent-https/LICENSE b/contrib/persistent-https/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/contrib/persistent-https/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/contrib/persistent-https/Makefile b/contrib/persistent-https/Makefile
deleted file mode 100644
index 691737e..0000000
--- a/contrib/persistent-https/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2012 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# The default target of this Makefile is...
-all::
-
-BUILD_LABEL=$(shell cut -d" " -f3 ../../GIT-VERSION-FILE)
-TAR_OUT=$(shell go env GOOS)_$(shell go env GOARCH).tar.gz
-
-all:: git-remote-persistent-https git-remote-persistent-https--proxy \
- git-remote-persistent-http
-
-git-remote-persistent-https--proxy: git-remote-persistent-https
- ln -f -s git-remote-persistent-https git-remote-persistent-https--proxy
-
-git-remote-persistent-http: git-remote-persistent-https
- ln -f -s git-remote-persistent-https git-remote-persistent-http
-
-git-remote-persistent-https:
- case $$(go version) in \
- "go version go"1.[0-5].*) EQ=" " ;; *) EQ="=" ;; esac && \
- go build -o git-remote-persistent-https \
- -ldflags "-X main._BUILD_EMBED_LABEL$${EQ}$(BUILD_LABEL)"
-
-clean:
- rm -f git-remote-persistent-http* *.tar.gz
-
-tar: clean all
- @chmod 555 git-remote-persistent-https
- @tar -czf $(TAR_OUT) git-remote-persistent-http* README LICENSE
- @echo
- @echo "Created $(TAR_OUT)"
diff --git a/contrib/persistent-https/README b/contrib/persistent-https/README
deleted file mode 100644
index 7c4cd8d..0000000
--- a/contrib/persistent-https/README
+++ /dev/null
@@ -1,72 +0,0 @@
-git-remote-persistent-https
-
-The git-remote-persistent-https binary speeds up SSL operations
-by running a daemon job (git-remote-persistent-https--proxy) that
-keeps a connection open to a server.
-
-
-PRE-BUILT BINARIES
-
-Darwin amd64:
-https://commondatastorage.googleapis.com/git-remote-persistent-https/darwin_amd64.tar.gz
-
-Linux amd64:
-https://commondatastorage.googleapis.com/git-remote-persistent-https/linux_amd64.tar.gz
-
-
-INSTALLING
-
-Move all of the git-remote-persistent-http* binaries to a directory
-in PATH.
-
-
-USAGE
-
-HTTPS requests can be delegated to the proxy by using the
-"persistent-https" scheme, e.g.
-
-git clone persistent-https://kernel.googlesource.com/pub/scm/git/git
-
-Likewise, .gitconfig can be updated as follows to rewrite https urls
-to use persistent-https:
-
-[url "persistent-https"]
- insteadof = https
-[url "persistent-http"]
- insteadof = http
-
-You may also want to allow the use of the persistent-https helper for
-submodule URLs (since any https URLs pointing to submodules will be
-rewritten, and Git's out-of-the-box defaults forbid submodules from
-using unknown remote helpers):
-
-[protocol "persistent-https"]
- allow = always
-[protocol "persistent-http"]
- allow = always
-
-
-#####################################################################
-# BUILDING FROM SOURCE
-#####################################################################
-
-LOCATION
-
-The source is available in the contrib/persistent-https directory of
-the Git source repository. The Git source repository is available at
-git://git.kernel.org/pub/scm/git/git.git/
-https://kernel.googlesource.com/pub/scm/git/git
-
-
-PREREQUISITES
-
-The code is written in Go (http://golang.org/) and the Go compiler is
-required. Currently, the compiler must be built and installed from tip
-of source, in order to include a fix in the reverse http proxy:
-http://code.google.com/p/go/source/detail?r=a615b796570a2cd8591884767a7d67ede74f6648
-
-
-BUILDING
-
-Run "make" to build the binaries. See the section on
-INSTALLING above.
diff --git a/contrib/persistent-https/client.go b/contrib/persistent-https/client.go
deleted file mode 100644
index 71125b5..0000000
--- a/contrib/persistent-https/client.go
+++ /dev/null
@@ -1,189 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "bufio"
- "errors"
- "fmt"
- "net"
- "net/url"
- "os"
- "os/exec"
- "strings"
- "syscall"
- "time"
-)
-
-type Client struct {
- ProxyBin string
- Args []string
-
- insecure bool
-}
-
-func (c *Client) Run() error {
- if err := c.resolveArgs(); err != nil {
- return fmt.Errorf("resolveArgs() got error: %v", err)
- }
-
- // Connect to the proxy.
- uconn, hconn, addr, err := c.connect()
- if err != nil {
- return fmt.Errorf("connect() got error: %v", err)
- }
- // Keep the unix socket connection open for the duration of the request.
- defer uconn.Close()
- // Keep a connection to the HTTP server open, so no other user can
- // bind on the same address so long as the process is running.
- defer hconn.Close()
-
- // Start the git-remote-http subprocess.
- cargs := []string{"-c", fmt.Sprintf("http.proxy=%v", addr), "remote-http"}
- cargs = append(cargs, c.Args...)
- cmd := exec.Command("git", cargs...)
-
- for _, v := range os.Environ() {
- if !strings.HasPrefix(v, "GIT_PERSISTENT_HTTPS_SECURE=") {
- cmd.Env = append(cmd.Env, v)
- }
- }
- // Set the GIT_PERSISTENT_HTTPS_SECURE environment variable when
- // the proxy is using a SSL connection. This allows credential helpers
- // to identify secure proxy connections, despite being passed an HTTP
- // scheme.
- if !c.insecure {
- cmd.Env = append(cmd.Env, "GIT_PERSISTENT_HTTPS_SECURE=1")
- }
-
- cmd.Stdin = os.Stdin
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- if err := cmd.Run(); err != nil {
- if eerr, ok := err.(*exec.ExitError); ok {
- if stat, ok := eerr.ProcessState.Sys().(syscall.WaitStatus); ok && stat.ExitStatus() != 0 {
- os.Exit(stat.ExitStatus())
- }
- }
- return fmt.Errorf("git-remote-http subprocess got error: %v", err)
- }
- return nil
-}
-
-func (c *Client) connect() (uconn net.Conn, hconn net.Conn, addr string, err error) {
- uconn, err = DefaultSocket.Dial()
- if err != nil {
- if e, ok := err.(*net.OpError); ok && (os.IsNotExist(e.Err) || e.Err == syscall.ECONNREFUSED) {
- if err = c.startProxy(); err == nil {
- uconn, err = DefaultSocket.Dial()
- }
- }
- if err != nil {
- return
- }
- }
-
- if addr, err = c.readAddr(uconn); err != nil {
- return
- }
-
- // Open a tcp connection to the proxy.
- if hconn, err = net.Dial("tcp", addr); err != nil {
- return
- }
-
- // Verify the address hasn't changed ownership.
- var addr2 string
- if addr2, err = c.readAddr(uconn); err != nil {
- return
- } else if addr != addr2 {
- err = fmt.Errorf("address changed after connect. got %q, want %q", addr2, addr)
- return
- }
- return
-}
-
-func (c *Client) readAddr(conn net.Conn) (string, error) {
- conn.SetDeadline(time.Now().Add(5 * time.Second))
- data := make([]byte, 100)
- n, err := conn.Read(data)
- if err != nil {
- return "", fmt.Errorf("error reading unix socket: %v", err)
- } else if n == 0 {
- return "", errors.New("empty data response")
- }
- conn.Write([]byte{1}) // Ack
-
- var addr string
- if addrs := strings.Split(string(data[:n]), "\n"); len(addrs) != 2 {
- return "", fmt.Errorf("got %q, wanted 2 addresses", data[:n])
- } else if c.insecure {
- addr = addrs[1]
- } else {
- addr = addrs[0]
- }
- return addr, nil
-}
-
-func (c *Client) startProxy() error {
- cmd := exec.Command(c.ProxyBin)
- cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
- stdout, err := cmd.StdoutPipe()
- if err != nil {
- return err
- }
- defer stdout.Close()
- if err := cmd.Start(); err != nil {
- return err
- }
- result := make(chan error)
- go func() {
- bytes, _, err := bufio.NewReader(stdout).ReadLine()
- if line := string(bytes); err == nil && line != "OK" {
- err = fmt.Errorf("proxy returned %q, want \"OK\"", line)
- }
- result <- err
- }()
- select {
- case err := <-result:
- return err
- case <-time.After(5 * time.Second):
- return errors.New("timeout waiting for proxy to start")
- }
- panic("not reachable")
-}
-
-func (c *Client) resolveArgs() error {
- if nargs := len(c.Args); nargs == 0 {
- return errors.New("remote needed")
- } else if nargs > 2 {
- return fmt.Errorf("want at most 2 args, got %v", c.Args)
- }
-
- // Rewrite the url scheme to be http.
- idx := len(c.Args) - 1
- rawurl := c.Args[idx]
- rurl, err := url.Parse(rawurl)
- if err != nil {
- return fmt.Errorf("invalid remote: %v", err)
- }
- c.insecure = rurl.Scheme == "persistent-http"
- rurl.Scheme = "http"
- c.Args[idx] = rurl.String()
- if idx != 0 && c.Args[0] == rawurl {
- c.Args[0] = c.Args[idx]
- }
- return nil
-}
diff --git a/contrib/persistent-https/main.go b/contrib/persistent-https/main.go
deleted file mode 100644
index fd1b107..0000000
--- a/contrib/persistent-https/main.go
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// The git-remote-persistent-https binary speeds up SSL operations by running
-// a daemon job that keeps a connection open to a Git server. This ensures the
-// git-remote-persistent-https--proxy is running and delegating execution
-// to the git-remote-http binary with the http_proxy set to the daemon job.
-// A unix socket is used to authenticate the proxy and discover the
-// HTTP address. Note, both the client and proxy are included in the same
-// binary.
-package main
-
-import (
- "flag"
- "fmt"
- "log"
- "os"
- "strings"
- "time"
-)
-
-var (
- forceProxy = flag.Bool("proxy", false, "Whether to start the binary in proxy mode")
- proxyBin = flag.String("proxy_bin", "git-remote-persistent-https--proxy", "Path to the proxy binary")
- printLabel = flag.Bool("print_label", false, "Prints the build label for the binary")
-
- // Variable that should be defined through the -X linker flag.
- _BUILD_EMBED_LABEL string
-)
-
-const (
- defaultMaxIdleDuration = 24 * time.Hour
- defaultPollUpdateInterval = 15 * time.Minute
-)
-
-func main() {
- flag.Parse()
- if *printLabel {
- // Short circuit execution to print the build label
- fmt.Println(buildLabel())
- return
- }
-
- var err error
- if *forceProxy || strings.HasSuffix(os.Args[0], "--proxy") {
- log.SetPrefix("git-remote-persistent-https--proxy: ")
- proxy := &Proxy{
- BuildLabel: buildLabel(),
- MaxIdleDuration: defaultMaxIdleDuration,
- PollUpdateInterval: defaultPollUpdateInterval,
- }
- err = proxy.Run()
- } else {
- log.SetPrefix("git-remote-persistent-https: ")
- client := &Client{
- ProxyBin: *proxyBin,
- Args: flag.Args(),
- }
- err = client.Run()
- }
- if err != nil {
- log.Fatalln(err)
- }
-}
-
-func buildLabel() string {
- if _BUILD_EMBED_LABEL == "" {
- log.Println(`unlabeled build; build with "make" to label`)
- }
- return _BUILD_EMBED_LABEL
-}
diff --git a/contrib/persistent-https/proxy.go b/contrib/persistent-https/proxy.go
deleted file mode 100644
index bb0cdba..0000000
--- a/contrib/persistent-https/proxy.go
+++ /dev/null
@@ -1,190 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "fmt"
- "log"
- "net"
- "net/http"
- "net/http/httputil"
- "os"
- "os/exec"
- "os/signal"
- "sync"
- "syscall"
- "time"
-)
-
-type Proxy struct {
- BuildLabel string
- MaxIdleDuration time.Duration
- PollUpdateInterval time.Duration
-
- ul net.Listener
- httpAddr string
- httpsAddr string
-}
-
-func (p *Proxy) Run() error {
- hl, err := net.Listen("tcp", "127.0.0.1:0")
- if err != nil {
- return fmt.Errorf("http listen failed: %v", err)
- }
- defer hl.Close()
-
- hsl, err := net.Listen("tcp", "127.0.0.1:0")
- if err != nil {
- return fmt.Errorf("https listen failed: %v", err)
- }
- defer hsl.Close()
-
- p.ul, err = DefaultSocket.Listen()
- if err != nil {
- c, derr := DefaultSocket.Dial()
- if derr == nil {
- c.Close()
- fmt.Println("OK\nA proxy is already running... exiting")
- return nil
- } else if e, ok := derr.(*net.OpError); ok && e.Err == syscall.ECONNREFUSED {
- // Nothing is listening on the socket, unlink it and try again.
- syscall.Unlink(DefaultSocket.Path())
- p.ul, err = DefaultSocket.Listen()
- }
- if err != nil {
- return fmt.Errorf("unix listen failed on %v: %v", DefaultSocket.Path(), err)
- }
- }
- defer p.ul.Close()
- go p.closeOnSignal()
- go p.closeOnUpdate()
-
- p.httpAddr = hl.Addr().String()
- p.httpsAddr = hsl.Addr().String()
- fmt.Printf("OK\nListening on unix socket=%v http=%v https=%v\n",
- p.ul.Addr(), p.httpAddr, p.httpsAddr)
-
- result := make(chan error, 2)
- go p.serveUnix(result)
- go func() {
- result <- http.Serve(hl, &httputil.ReverseProxy{
- FlushInterval: 500 * time.Millisecond,
- Director: func(r *http.Request) {},
- })
- }()
- go func() {
- result <- http.Serve(hsl, &httputil.ReverseProxy{
- FlushInterval: 500 * time.Millisecond,
- Director: func(r *http.Request) {
- r.URL.Scheme = "https"
- },
- })
- }()
- return <-result
-}
-
-type socketContext struct {
- sync.WaitGroup
- mutex sync.Mutex
- last time.Time
-}
-
-func (sc *socketContext) Done() {
- sc.mutex.Lock()
- defer sc.mutex.Unlock()
- sc.last = time.Now()
- sc.WaitGroup.Done()
-}
-
-func (p *Proxy) serveUnix(result chan<- error) {
- sockCtx := &socketContext{}
- go p.closeOnIdle(sockCtx)
-
- var err error
- for {
- var uconn net.Conn
- uconn, err = p.ul.Accept()
- if err != nil {
- err = fmt.Errorf("accept failed: %v", err)
- break
- }
- sockCtx.Add(1)
- go p.handleUnixConn(sockCtx, uconn)
- }
- sockCtx.Wait()
- result <- err
-}
-
-func (p *Proxy) handleUnixConn(sockCtx *socketContext, uconn net.Conn) {
- defer sockCtx.Done()
- defer uconn.Close()
- data := []byte(fmt.Sprintf("%v\n%v", p.httpsAddr, p.httpAddr))
- uconn.SetDeadline(time.Now().Add(5 * time.Second))
- for i := 0; i < 2; i++ {
- if n, err := uconn.Write(data); err != nil {
- log.Printf("error sending http addresses: %+v\n", err)
- return
- } else if n != len(data) {
- log.Printf("sent %d data bytes, wanted %d\n", n, len(data))
- return
- }
- if _, err := uconn.Read([]byte{0, 0, 0, 0}); err != nil {
- log.Printf("error waiting for Ack: %+v\n", err)
- return
- }
- }
- // Wait without a deadline for the client to finish via EOF
- uconn.SetDeadline(time.Time{})
- uconn.Read([]byte{0, 0, 0, 0})
-}
-
-func (p *Proxy) closeOnIdle(sockCtx *socketContext) {
- for d := p.MaxIdleDuration; d > 0; {
- time.Sleep(d)
- sockCtx.Wait()
- sockCtx.mutex.Lock()
- if d = sockCtx.last.Add(p.MaxIdleDuration).Sub(time.Now()); d <= 0 {
- log.Println("graceful shutdown from idle timeout")
- p.ul.Close()
- }
- sockCtx.mutex.Unlock()
- }
-}
-
-func (p *Proxy) closeOnUpdate() {
- for {
- time.Sleep(p.PollUpdateInterval)
- if out, err := exec.Command(os.Args[0], "--print_label").Output(); err != nil {
- log.Printf("error polling for updated binary: %v\n", err)
- } else if s := string(out[:len(out)-1]); p.BuildLabel != s {
- log.Printf("graceful shutdown from updated binary: %q --> %q\n", p.BuildLabel, s)
- p.ul.Close()
- break
- }
- }
-}
-
-func (p *Proxy) closeOnSignal() {
- ch := make(chan os.Signal, 10)
- signal.Notify(ch, os.Interrupt, os.Kill, os.Signal(syscall.SIGTERM), os.Signal(syscall.SIGHUP))
- sig := <-ch
- p.ul.Close()
- switch sig {
- case os.Signal(syscall.SIGHUP):
- log.Printf("graceful shutdown from signal: %v\n", sig)
- default:
- log.Fatalf("exiting from signal: %v\n", sig)
- }
-}
diff --git a/contrib/persistent-https/socket.go b/contrib/persistent-https/socket.go
deleted file mode 100644
index 193b911..0000000
--- a/contrib/persistent-https/socket.go
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "fmt"
- "log"
- "net"
- "os"
- "path/filepath"
- "syscall"
-)
-
-// A Socket is a wrapper around a Unix socket that verifies directory
-// permissions.
-type Socket struct {
- Dir string
-}
-
-func defaultDir() string {
- sockPath := ".git-credential-cache"
- if home := os.Getenv("HOME"); home != "" {
- return filepath.Join(home, sockPath)
- }
- log.Printf("socket: cannot find HOME path. using relative directory %q for socket", sockPath)
- return sockPath
-}
-
-// DefaultSocket is a Socket in the $HOME/.git-credential-cache directory.
-var DefaultSocket = Socket{Dir: defaultDir()}
-
-// Listen announces the local network address of the unix socket. The
-// permissions on the socket directory are verified before attempting
-// the actual listen.
-func (s Socket) Listen() (net.Listener, error) {
- network, addr := "unix", s.Path()
- if err := s.mkdir(); err != nil {
- return nil, &net.OpError{Op: "listen", Net: network, Addr: &net.UnixAddr{Name: addr, Net: network}, Err: err}
- }
- return net.Listen(network, addr)
-}
-
-// Dial connects to the unix socket. The permissions on the socket directory
-// are verified before attempting the actual dial.
-func (s Socket) Dial() (net.Conn, error) {
- network, addr := "unix", s.Path()
- if err := s.checkPermissions(); err != nil {
- return nil, &net.OpError{Op: "dial", Net: network, Addr: &net.UnixAddr{Name: addr, Net: network}, Err: err}
- }
- return net.Dial(network, addr)
-}
-
-// Path returns the fully specified file name of the unix socket.
-func (s Socket) Path() string {
- return filepath.Join(s.Dir, "persistent-https-proxy-socket")
-}
-
-func (s Socket) mkdir() error {
- if err := s.checkPermissions(); err == nil {
- return nil
- } else if !os.IsNotExist(err) {
- return err
- }
- if err := os.MkdirAll(s.Dir, 0700); err != nil {
- return err
- }
- return s.checkPermissions()
-}
-
-func (s Socket) checkPermissions() error {
- fi, err := os.Stat(s.Dir)
- if err != nil {
- return err
- }
- if !fi.IsDir() {
- return fmt.Errorf("socket: got file, want directory for %q", s.Dir)
- }
- if fi.Mode().Perm() != 0700 {
- return fmt.Errorf("socket: got perm %o, want 700 for %q", fi.Mode().Perm(), s.Dir)
- }
- if st := fi.Sys().(*syscall.Stat_t); int(st.Uid) != os.Getuid() {
- return fmt.Errorf("socket: got uid %d, want %d for %q", st.Uid, os.Getuid(), s.Dir)
- }
- return nil
-}
diff --git a/contrib/remote-helpers/README b/contrib/remote-helpers/README
deleted file mode 100644
index ac72332..0000000
--- a/contrib/remote-helpers/README
+++ /dev/null
@@ -1,15 +0,0 @@
-The remote-helper bridges to access data stored in Mercurial and
-Bazaar are maintained outside the git.git tree in the repositories
-of their primary author:
-
- https://github.com/felipec/git-remote-hg (for Mercurial)
- https://github.com/felipec/git-remote-bzr (for Bazaar)
-
-You can pick a directory on your $PATH and download them from these
-repositories, e.g.:
-
- $ wget -O $HOME/bin/git-remote-hg \
- https://raw.github.com/felipec/git-remote-hg/master/git-remote-hg
- $ wget -O $HOME/bin/git-remote-bzr \
- https://raw.github.com/felipec/git-remote-bzr/master/git-remote-bzr
- $ chmod +x $HOME/bin/git-remote-hg $HOME/bin/git-remote-bzr
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
deleted file mode 100755
index 1c3d87f..0000000
--- a/contrib/remote-helpers/git-remote-bzr
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-cat >&2 <<'EOT'
-WARNING: git-remote-bzr is now maintained independently.
-WARNING: For more information visit https://github.com/felipec/git-remote-bzr
-WARNING:
-WARNING: You can pick a directory on your $PATH and download it, e.g.:
-WARNING: $ wget -O $HOME/bin/git-remote-bzr \
-WARNING: https://raw.github.com/felipec/git-remote-bzr/master/git-remote-bzr
-WARNING: $ chmod +x $HOME/bin/git-remote-bzr
-EOT
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
deleted file mode 100755
index 8e91883..0000000
--- a/contrib/remote-helpers/git-remote-hg
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-cat >&2 <<'EOT'
-WARNING: git-remote-hg is now maintained independently.
-WARNING: For more information visit https://github.com/felipec/git-remote-hg
-WARNING:
-WARNING: You can pick a directory on your $PATH and download it, e.g.:
-WARNING: $ wget -O $HOME/bin/git-remote-hg \
-WARNING: https://raw.github.com/felipec/git-remote-hg/master/git-remote-hg
-WARNING: $ chmod +x $HOME/bin/git-remote-hg
-EOT
diff --git a/contrib/remotes2config.sh b/contrib/remotes2config.sh
deleted file mode 100755
index 1cda19f..0000000
--- a/contrib/remotes2config.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-# Use this tool to rewrite your .git/remotes/ files into the config.
-
-. git-sh-setup
-
-if [ -d "$GIT_DIR"/remotes ]; then
- echo "Rewriting $GIT_DIR/remotes" >&2
- error=0
- # rewrite into config
- {
- cd "$GIT_DIR"/remotes
- ls | while read f; do
- name=$(printf "$f" | tr -c "A-Za-z0-9-" ".")
- sed -n \
- -e "s/^URL:[ ]*\(.*\)$/remote.$name.url \1 ./p" \
- -e "s/^Pull:[ ]*\(.*\)$/remote.$name.fetch \1 ^$ /p" \
- -e "s/^Push:[ ]*\(.*\)$/remote.$name.push \1 ^$ /p" \
- < "$f"
- done
- echo done
- } | while read key value regex; do
- case $key in
- done)
- if [ $error = 0 ]; then
- mv "$GIT_DIR"/remotes "$GIT_DIR"/remotes.old
- fi ;;
- *)
- echo "git config $key "$value" $regex"
- git config $key "$value" $regex || error=1 ;;
- esac
- done
-fi
diff --git a/contrib/stats/git-common-hash b/contrib/stats/git-common-hash
deleted file mode 100755
index e27fd08..0000000
--- a/contrib/stats/git-common-hash
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-
-# This script displays the distribution of longest common hash prefixes.
-# This can be used to determine the minimum prefix length to use
-# for object names to be unique.
-
-git rev-list --objects --all | sort | perl -lne '
- substr($_, 40) = "";
- # uncomment next line for a distribution of bits instead of hex chars
- # $_ = unpack("B*",pack("H*",$_));
- if (defined $p) {
- ($p ^ $_) =~ /^(\0*)/;
- $common = length $1;
- if (defined $pcommon) {
- $count[$pcommon > $common ? $pcommon : $common]++;
- } else {
- $count[$common]++; # first item
- }
- }
- $p = $_;
- $pcommon = $common;
- END {
- $count[$common]++; # last item
- print "$_: $count[$_]" for 0..$#count;
- }
-'
diff --git a/contrib/stats/mailmap.pl b/contrib/stats/mailmap.pl
deleted file mode 100755
index 9513f5e..0000000
--- a/contrib/stats/mailmap.pl
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/perl
-
-use warnings 'all';
-use strict;
-use Getopt::Long;
-
-my $match_emails;
-my $match_names;
-my $order_by = 'count';
-Getopt::Long::Configure(qw(bundling));
-GetOptions(
- 'emails|e!' => \$match_emails,
- 'names|n!' => \$match_names,
- 'count|c' => sub { $order_by = 'count' },
- 'time|t' => sub { $order_by = 'stamp' },
-) or exit 1;
-$match_emails = 1 unless $match_names;
-
-my $email = {};
-my $name = {};
-
-open(my $fh, '-|', "git log --format='%at <%aE> %aN'");
-while(<$fh>) {
- my ($t, $e, $n) = /(\S+) <(\S+)> (.*)/;
- mark($email, $e, $n, $t);
- mark($name, $n, $e, $t);
-}
-close($fh);
-
-if ($match_emails) {
- foreach my $e (dups($email)) {
- foreach my $n (vals($email->{$e})) {
- show($n, $e, $email->{$e}->{$n});
- }
- print "\n";
- }
-}
-if ($match_names) {
- foreach my $n (dups($name)) {
- foreach my $e (vals($name->{$n})) {
- show($n, $e, $name->{$n}->{$e});
- }
- print "\n";
- }
-}
-exit 0;
-
-sub mark {
- my ($h, $k, $v, $t) = @_;
- my $e = $h->{$k}->{$v} ||= { count => 0, stamp => 0 };
- $e->{count}++;
- $e->{stamp} = $t unless $t < $e->{stamp};
-}
-
-sub dups {
- my $h = shift;
- return grep { keys($h->{$_}) > 1 } keys($h);
-}
-
-sub vals {
- my $h = shift;
- return sort {
- $h->{$b}->{$order_by} <=> $h->{$a}->{$order_by}
- } keys($h);
-}
-
-sub show {
- my ($n, $e, $h) = @_;
- print "$n <$e> ($h->{$order_by})\n";
-}
diff --git a/contrib/subtree/README b/contrib/subtree/README
index c686b4a..65d167b 100644
--- a/contrib/subtree/README
+++ b/contrib/subtree/README
@@ -1,5 +1,5 @@
-Please read git-subtree.txt for documentation.
+Please read git-subtree.adoc for documentation.
Please don't contact me using github mail; it's slow, ugly, and worst of
all, redundant. Email me instead at apenwarr@gmail.com and I'll be happy to
diff --git a/contrib/subtree/git-subtree.adoc b/contrib/subtree/git-subtree.adoc
index 004abf4..b2bcbca 100644
--- a/contrib/subtree/git-subtree.adoc
+++ b/contrib/subtree/git-subtree.adoc
@@ -9,14 +9,14 @@
SYNOPSIS
--------
[verse]
-'git subtree' [<options>] -P <prefix> add <local-commit>
-'git subtree' [<options>] -P <prefix> add <repository> <remote-ref>
-'git subtree' [<options>] -P <prefix> merge <local-commit> [<repository>]
-'git subtree' [<options>] -P <prefix> split [<local-commit>]
+'git subtree' [<options>] -P <prefix> [-S[<keyid>]] add <local-commit>
+'git subtree' [<options>] -P <prefix> [-S[<keyid>]] add <repository> <remote-ref>
+'git subtree' [<options>] -P <prefix> [-S[<keyid>]] merge <local-commit> [<repository>]
+'git subtree' [<options>] -P <prefix> [-S[<keyid>]] split [<local-commit>]
[verse]
-'git subtree' [<options>] -P <prefix> pull <repository> <remote-ref>
-'git subtree' [<options>] -P <prefix> push <repository> <refspec>
+'git subtree' [<options>] -P <prefix> [-S[<keyid>]] pull <repository> <remote-ref>
+'git subtree' [<options>] -P <prefix> [-S[<keyid>]] push <repository> <refspec>
DESCRIPTION
-----------
@@ -149,6 +149,13 @@
want to manipulate. This option is mandatory
for all commands.
+-S[<keyid>]::
+--gpg-sign[=<keyid>]::
+--no-gpg-sign::
+ GPG-sign commits. The `keyid` argument is optional and
+ defaults to the committer identity; `--no-gpg-sign` is useful to
+ countermand a `--gpg-sign` option given earlier on the command line.
+
OPTIONS FOR 'add' AND 'merge' (ALSO: 'pull', 'split --rejoin', AND 'push --rejoin')
-----------------------------------------------------------------------------------
These options for 'add' and 'merge' may also be given to 'pull' (which
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 15ae86d..3fddba7 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -26,12 +26,12 @@
fi
OPTS_SPEC="\
-git subtree add --prefix=<prefix> <commit>
-git subtree add --prefix=<prefix> <repository> <ref>
-git subtree merge --prefix=<prefix> <commit>
-git subtree split --prefix=<prefix> [<commit>]
-git subtree pull --prefix=<prefix> <repository> <ref>
-git subtree push --prefix=<prefix> <repository> <refspec>
+git subtree add --prefix=<prefix> [-S[=<key-id>]] <commit>
+git subtree add --prefix=<prefix> [-S[=<key-id>]] <repository> <ref>
+git subtree merge --prefix=<prefix> [-S[=<key-id>]] <commit>
+git subtree split --prefix=<prefix> [-S[=<key-id>]] [<commit>]
+git subtree pull --prefix=<prefix> [-S[=<key-id>]] <repository> <ref>
+git subtree push --prefix=<prefix> [-S[=<key-id>]] <repository> <refspec>
--
h,help! show the help
q,quiet! quiet
@@ -46,6 +46,7 @@
options for 'add' and 'merge' (also: 'pull', 'split --rejoin', and 'push --rejoin')
squash merge subtree changes as a single commit
m,message!= use the given message as the commit message for the merge commit
+S,gpg-sign?key-id GPG-sign commits. The keyid argument is optional and defaults to the committer identity
"
indent=0
@@ -115,7 +116,7 @@
then
set -- -h
fi
- set_args="$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"
+ set_args="$(echo "$OPTS_SPEC" | git rev-parse --parseopt --stuck-long -- "$@" || echo exit $?)"
eval "$set_args"
. git-sh-setup
require_work_tree
@@ -131,9 +132,6 @@
opt="$1"
shift
case "$opt" in
- --annotate|-b|-P|-m|--onto)
- shift
- ;;
--rejoin)
arg_split_rejoin=1
;;
@@ -171,48 +169,44 @@
arg_split_annotate=
arg_addmerge_squash=
arg_addmerge_message=
+ arg_gpg_sign=
while test $# -gt 0
do
opt="$1"
shift
case "$opt" in
- -q)
+ --quiet)
arg_quiet=1
;;
- -d)
+ --debug)
arg_debug=1
;;
- --annotate)
+ --annotate=*)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
- arg_split_annotate="$1"
- shift
+ arg_split_annotate="${opt#*=}"
;;
--no-annotate)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
arg_split_annotate=
;;
- -b)
+ --branch=*)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
- arg_split_branch="$1"
- shift
+ arg_split_branch="${opt#*=}"
;;
- -P)
- arg_prefix="${1%/}"
- shift
+ --prefix=*)
+ arg_prefix="${opt#*=}"
;;
- -m)
+ --message=*)
test -n "$allow_addmerge" || die_incompatible_opt "$opt" "$arg_command"
- arg_addmerge_message="$1"
- shift
+ arg_addmerge_message="${opt#*=}"
;;
--no-prefix)
arg_prefix=
;;
- --onto)
+ --onto=*)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
- arg_split_onto="$1"
- shift
+ arg_split_onto="${opt#*=}"
;;
--no-onto)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
@@ -240,6 +234,9 @@
test -n "$allow_addmerge" || die_incompatible_opt "$opt" "$arg_command"
arg_addmerge_squash=
;;
+ --gpg-sign=* | --gpg-sign | --no-gpg-sign)
+ arg_gpg_sign="$opt"
+ ;;
--)
break
;;
@@ -272,6 +269,7 @@
debug "quiet: {$arg_quiet}"
debug "dir: {$dir}"
debug "opts: {$*}"
+ debug "gpg-sign: {$arg_gpg_sign}"
debug
"cmd_$arg_command" "$@"
@@ -537,7 +535,7 @@
printf "%s" "$arg_split_annotate"
cat
) |
- git commit-tree "$2" $3 # reads the rest of stdin
+ git commit-tree $arg_gpg_sign "$2" $3 # reads the rest of stdin
) || die "fatal: can't copy commit $1"
}
@@ -683,10 +681,10 @@
if test -n "$old"
then
squash_msg "$dir" "$oldsub" "$newsub" |
- git commit-tree "$tree" -p "$old" || exit $?
+ git commit-tree $arg_gpg_sign "$tree" -p "$old" || exit $?
else
squash_msg "$dir" "" "$newsub" |
- git commit-tree "$tree" || exit $?
+ git commit-tree $arg_gpg_sign "$tree" || exit $?
fi
}
@@ -925,11 +923,11 @@
then
rev=$(new_squash_commit "" "" "$rev") || exit $?
commit=$(add_squashed_msg "$rev" "$dir" |
- git commit-tree "$tree" $headp -p "$rev") || exit $?
+ git commit-tree $arg_gpg_sign "$tree" $headp -p "$rev") || exit $?
else
revp=$(peel_committish "$rev") || exit $?
commit=$(add_msg "$dir" $headrev "$rev" |
- git commit-tree "$tree" $headp -p "$revp") || exit $?
+ git commit-tree $arg_gpg_sign "$tree" $headp -p "$revp") || exit $?
fi
git reset "$commit" || exit $?
@@ -1080,9 +1078,9 @@
if test -n "$arg_addmerge_message"
then
git merge --no-ff -Xsubtree="$arg_prefix" \
- --message="$arg_addmerge_message" "$rev"
+ --message="$arg_addmerge_message" $arg_gpg_sign "$rev"
else
- git merge --no-ff -Xsubtree="$arg_prefix" $rev
+ git merge --no-ff -Xsubtree="$arg_prefix" $arg_gpg_sign $rev
fi
}
diff --git a/contrib/subtree/meson.build b/contrib/subtree/meson.build
index 6371416..98dd8e0 100644
--- a/contrib/subtree/meson.build
+++ b/contrib/subtree/meson.build
@@ -21,7 +21,7 @@
env: subtree_test_environment,
workdir: meson.current_source_dir() / 't',
depends: test_dependencies + bin_wrappers + [ git_subtree ],
- timeout: 0,
+ kwargs: test_kwargs,
)
endif
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 3c6103f..3edbb33 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -11,6 +11,7 @@
TEST_DIRECTORY=$(pwd)/../../../t
. "$TEST_DIRECTORY"/test-lib.sh
+. "$TEST_DIRECTORY"/lib-gpg.sh
# Use our own wrapper around test-lib.sh's test_create_repo, in order
# to set log.date=relative. `git subtree` parses the output of `git
@@ -1563,4 +1564,116 @@
)
'
+test_expect_success GPG 'add subproj with GPG signing using -S flag' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" -S FETCH_HEAD &&
+ git verify-commit HEAD &&
+ test "$(last_commit_subject)" = "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
+test_expect_success GPG 'add subproj with GPG signing using --gpg-sign flag' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" --gpg-sign FETCH_HEAD &&
+ git verify-commit HEAD &&
+ test "$(last_commit_subject)" = "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
+test_expect_success GPG 'add subproj with GPG signing using specific key ID' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" -S"$GIT_COMMITTER_EMAIL" FETCH_HEAD &&
+ git verify-commit HEAD &&
+ test "$(last_commit_subject)" = "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
+test_expect_success GPG 'merge with GPG signing' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/sub proj" sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree merge --prefix="sub dir" -S FETCH_HEAD &&
+ git verify-commit HEAD
+ )
+'
+
+test_expect_success GPG 'split with GPG signing and --rejoin' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" "sub dir/main-sub1" &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix="sub dir" --rejoin -S &&
+ git verify-commit HEAD
+ )
+'
+
+test_expect_success GPG 'add with --squash and GPG signing' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" --squash -S FETCH_HEAD &&
+ git verify-commit HEAD &&
+ # With --squash, the commit subject should reference the squash commit (first parent of merge)
+ squash_commit=$(git rev-parse HEAD^2) &&
+ test "$(last_commit_subject)" = "Merge commit '\''$squash_commit'\'' as '\''sub dir'\''"
+ )
+'
+
+test_expect_success GPG 'pull with GPG signing' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git subtree add --prefix="sub dir" ./"sub proj" HEAD
+ ) &&
+ test_create_commit "$test_count/sub proj" sub2 &&
+ (
+ cd "$test_count" &&
+ git subtree pull --prefix="sub dir" -S ./"sub proj" HEAD &&
+ git verify-commit HEAD
+ )
+'
+
test_done
diff --git a/contrib/thunderbird-patch-inline/README b/contrib/thunderbird-patch-inline/README
deleted file mode 100644
index 000147b..0000000
--- a/contrib/thunderbird-patch-inline/README
+++ /dev/null
@@ -1,20 +0,0 @@
-appp.sh is a script that is supposed to be used together with ExternalEditor
-for Mozilla Thunderbird. It will let you include patches inline in e-mails
-in an easy way.
-
-Usage:
-- Generate the patch with git format-patch.
-- Start writing a new e-mail in Thunderbird.
-- Press the external editor button (or Ctrl-E) to run appp.sh
-- Select the previously generated patch file.
-- Finish editing the e-mail.
-
-Any text that is entered into the message editor before appp.sh is called
-will be moved to the section between the --- and the diffstat.
-
-All S-O-B:s and Cc:s in the patch will be added to the CC list.
-
-To set it up, just install External Editor and tell it to use appp.sh as the
-editor.
-
-Zenity is a required dependency.
diff --git a/contrib/thunderbird-patch-inline/appp.sh b/contrib/thunderbird-patch-inline/appp.sh
deleted file mode 100755
index fdcc948..0000000
--- a/contrib/thunderbird-patch-inline/appp.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/sh
-# Copyright 2008 Lukas Sandström <luksan@gmail.com>
-#
-# AppendPatch - A script to be used together with ExternalEditor
-# for Mozilla Thunderbird to properly include patches inline in e-mails.
-
-# ExternalEditor can be downloaded at http://globs.org/articles.php?lng=en&pg=2
-
-CONFFILE=~/.appprc
-
-SEP="-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-"
-if [ -e "$CONFFILE" ] ; then
- LAST_DIR=$(grep -m 1 "^LAST_DIR=" "${CONFFILE}"|sed -e 's/^LAST_DIR=//')
- cd "${LAST_DIR}"
-else
- cd > /dev/null
-fi
-
-PATCH=$(zenity --file-selection)
-
-if [ "$?" != "0" ] ; then
- #zenity --error --text "No patchfile given."
- exit 1
-fi
-
-cd - > /dev/null
-
-SUBJECT=$(sed -n -e '/^Subject: /p' "${PATCH}")
-HEADERS=$(sed -e '/^'"${SEP}"'$/,$d' $1)
-BODY=$(sed -e "1,/${SEP}/d" $1)
-CMT_MSG=$(sed -e '1,/^$/d' -e '/^---$/,$d' "${PATCH}")
-DIFF=$(sed -e '1,/^---$/d' "${PATCH}")
-
-CCS=$(printf '%s\n%s\n' "$CMT_MSG" "$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \
- -e 's/^Signed-off-by: \(.*\)/\1,/gp')
-
-echo "$SUBJECT" > $1
-echo "Cc: $CCS" >> $1
-echo "$HEADERS" | sed -e '/^Subject: /d' -e '/^Cc: /d' >> $1
-echo "$SEP" >> $1
-
-echo "$CMT_MSG" >> $1
-echo "---" >> $1
-if [ "x${BODY}x" != "xx" ] ; then
- echo >> $1
- echo "$BODY" >> $1
- echo >> $1
-fi
-echo "$DIFF" >> $1
-
-LAST_DIR=$(dirname "${PATCH}")
-
-grep -v "^LAST_DIR=" "${CONFFILE}" > "${CONFFILE}_"
-echo "LAST_DIR=${LAST_DIR}" >> "${CONFFILE}_"
-mv "${CONFFILE}_" "${CONFFILE}"
diff --git a/contrib/workdir/.gitattributes b/contrib/workdir/.gitattributes
deleted file mode 100644
index 1f78c5d..0000000
--- a/contrib/workdir/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-/git-new-workdir eol=lf
diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir
deleted file mode 100755
index 989197a..0000000
--- a/contrib/workdir/git-new-workdir
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/bin/sh
-
-usage () {
- echo "usage:" $@
- exit 127
-}
-
-die () {
- echo $@
- exit 128
-}
-
-failed () {
- die "unable to create new workdir '$new_workdir'!"
-}
-
-if test $# -lt 2 || test $# -gt 3
-then
- usage "$0 <repository> <new_workdir> [<branch>]"
-fi
-
-orig_git=$1
-new_workdir=$2
-branch=$3
-
-# want to make sure that what is pointed to has a .git directory ...
-git_dir=$(cd "$orig_git" 2>/dev/null &&
- git rev-parse --git-dir 2>/dev/null) ||
- die "Not a git repository: \"$orig_git\""
-
-case "$git_dir" in
-.git)
- git_dir="$orig_git/.git"
- ;;
-.)
- git_dir=$orig_git
- ;;
-esac
-
-# don't link to a configured bare repository
-isbare=$(git --git-dir="$git_dir" config --bool --get core.bare)
-if test ztrue = "z$isbare"
-then
- die "\"$git_dir\" has core.bare set to true," \
- " remove from \"$git_dir/config\" to use $0"
-fi
-
-# don't link to a workdir
-if test -h "$git_dir/config"
-then
- die "\"$orig_git\" is a working directory only, please specify" \
- "a complete repository."
-fi
-
-# make sure the links in the workdir have full paths to the original repo
-git_dir=$(cd "$git_dir" && pwd) || exit 1
-
-# don't recreate a workdir over an existing directory, unless it's empty
-if test -d "$new_workdir"
-then
- if test $(ls -a1 "$new_workdir/." | wc -l) -ne 2
- then
- die "destination directory '$new_workdir' is not empty."
- fi
- cleandir="$new_workdir/.git"
-else
- cleandir="$new_workdir"
-fi
-
-mkdir -p "$new_workdir/.git" || failed
-cleandir=$(cd "$cleandir" && pwd) || failed
-
-cleanup () {
- rm -rf "$cleandir"
-}
-siglist="0 1 2 15"
-trap cleanup $siglist
-
-# create the links to the original repo. explicitly exclude index, HEAD and
-# logs/HEAD from the list since they are purely related to the current working
-# directory, and should not be shared.
-for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache svn reftable
-do
- # create a containing directory if needed
- case $x in
- */*)
- mkdir -p "$new_workdir/.git/${x%/*}"
- ;;
- esac
-
- ln -s "$git_dir/$x" "$new_workdir/.git/$x" || failed
-done
-
-# commands below this are run in the context of the new workdir
-cd "$new_workdir" || failed
-
-# copy the HEAD from the original repository as a default branch
-cp "$git_dir/HEAD" .git/HEAD || failed
-
-# the workdir is set up. if the checkout fails, the user can fix it.
-trap - $siglist
-
-# checkout the branch (either the same as HEAD from the original repository,
-# or the one that was asked for)
-git checkout -f $branch
diff --git a/diff-no-index.c b/diff-no-index.c
index 9739b2b..88ae4ce 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -15,20 +15,57 @@
#include "gettext.h"
#include "revision.h"
#include "parse-options.h"
+#include "pathspec.h"
#include "string-list.h"
#include "dir.h"
-static int read_directory_contents(const char *path, struct string_list *list)
+static int read_directory_contents(const char *path, struct string_list *list,
+ const struct pathspec *pathspec,
+ int skip)
{
+ struct strbuf match = STRBUF_INIT;
+ int len;
DIR *dir;
struct dirent *e;
if (!(dir = opendir(path)))
return error("Could not open directory %s", path);
- while ((e = readdir_skip_dot_and_dotdot(dir)))
- string_list_insert(list, e->d_name);
+ if (pathspec) {
+ strbuf_addstr(&match, path);
+ strbuf_complete(&match, '/');
+ strbuf_remove(&match, 0, skip);
+ len = match.len;
+ }
+
+ while ((e = readdir_skip_dot_and_dotdot(dir))) {
+ if (pathspec) {
+ int is_dir = 0;
+
+ strbuf_setlen(&match, len);
+ strbuf_addstr(&match, e->d_name);
+ if (NOT_CONSTANT(DTYPE(e)) != DT_UNKNOWN) {
+ is_dir = (DTYPE(e) == DT_DIR);
+ } else {
+ struct strbuf pathbuf = STRBUF_INIT;
+
+ strbuf_addstr(&pathbuf, path);
+ strbuf_complete(&pathbuf, '/');
+ is_dir = get_dtype(e, &pathbuf, 0) == DT_DIR;
+ strbuf_release(&pathbuf);
+ }
+
+ if (!match_leading_pathspec(NULL, pathspec,
+ match.buf, match.len,
+ 0, NULL, is_dir))
+ continue;
+ }
+
+ string_list_insert(list, e->d_name);
+ }
+
+ strbuf_release(&match);
closedir(dir);
return 0;
}
@@ -131,7 +168,8 @@ static struct diff_filespec *noindex_filespec(const struct git_hash_algo *algop,
}
static int queue_diff(struct diff_options *o, const struct git_hash_algo *algop,
- const char *name1, const char *name2, int recursing)
+ const char *name1, const char *name2, int recursing,
+ const struct pathspec *ps, int skip1, int skip2)
{
int mode1 = 0, mode2 = 0;
enum special special1 = SPECIAL_NONE, special2 = SPECIAL_NONE;
@@ -171,9 +209,9 @@ static int queue_diff(struct diff_options *o, const struct git_hash_algo *algop,
int i1, i2, ret = 0;
size_t len1 = 0, len2 = 0;
- if (name1 && read_directory_contents(name1, &p1))
+ if (name1 && read_directory_contents(name1, &p1, ps, skip1))
return -1;
- if (name2 && read_directory_contents(name2, &p2)) {
+ if (name2 && read_directory_contents(name2, &p2, ps, skip2)) {
string_list_clear(&p1, 0);
return -1;
}
@@ -218,7 +256,7 @@ static int queue_diff(struct diff_options *o, const struct git_hash_algo *algop,
n2 = buffer2.buf;
}
- ret = queue_diff(o, algop, n1, n2, 1);
+ ret = queue_diff(o, algop, n1, n2, 1, ps, skip1, skip2);
}
string_list_clear(&p1, 0);
string_list_clear(&p2, 0);
@@ -258,8 +296,10 @@ static void append_basename(struct strbuf *path, const char *dir, const char *fi
* DWIM "diff D F" into "diff D/F F" and "diff F D" into "diff F D/F"
* Note that we append the basename of F to D/, so "diff a/b/file D"
* becomes "diff a/b/file D/file", not "diff a/b/file D/a/b/file".
+ *
+ * Return 1 if both paths are directories, 0 otherwise.
*/
-static void fixup_paths(const char **path, struct strbuf *replacement)
+static int fixup_paths(const char **path, struct strbuf *replacement)
{
struct stat st;
unsigned int isdir0 = 0, isdir1 = 0;
@@ -282,26 +322,31 @@ static void fixup_paths(const char **path, struct strbuf *replacement)
if ((isdir0 && ispipe1) || (ispipe0 && isdir1))
die(_("cannot compare a named pipe to a directory"));
- if (isdir0 == isdir1)
- return;
+ /* if both paths are directories, we will enable pathspecs */
+ if (isdir0 && isdir1)
+ return 1;
+
if (isdir0) {
append_basename(replacement, path[0], path[1]);
path[0] = replacement->buf;
- } else {
+ } else if (isdir1) {
append_basename(replacement, path[1], path[0]);
path[1] = replacement->buf;
}
+
+ return 0;
}
static const char * const diff_no_index_usage[] = {
- N_("git diff --no-index [<options>] <path> <path>"),
+ N_("git diff --no-index [<options>] <path> <path> [<pathspec>...]"),
NULL
};
int diff_no_index(struct rev_info *revs, const struct git_hash_algo *algop,
int implicit_no_index, int argc, const char **argv)
{
- int i, no_index;
+ struct pathspec pathspec, *ps = NULL;
+ int i, no_index, skip1 = 0, skip2 = 0;
int ret = 1;
const char *paths[2];
char *to_free[ARRAY_SIZE(paths)] = { 0 };
@@ -317,13 +362,12 @@ int diff_no_index(struct rev_info *revs, const struct git_hash_algo *algop,
options = add_diff_options(no_index_options, &revs->diffopt);
argc = parse_options(argc, argv, revs->prefix, options,
diff_no_index_usage, 0);
- if (argc != 2) {
+ if (argc < 2) {
if (implicit_no_index)
warning(_("Not a git repository. Use --no-index to "
"compare two paths outside a working tree"));
usage_with_options(diff_no_index_usage, options);
}
- FREE_AND_NULL(options);
for (i = 0; i < 2; i++) {
const char *p = argv[i];
if (!strcmp(p, "-"))
@@ -337,7 +381,23 @@ int diff_no_index(struct rev_info *revs, const struct git_hash_algo *algop,
paths[i] = p;
}
- fixup_paths(paths, &replacement);
+ if (fixup_paths(paths, &replacement)) {
+ parse_pathspec(&pathspec, PATHSPEC_FROMTOP | PATHSPEC_ATTR,
+ PATHSPEC_PREFER_FULL | PATHSPEC_NO_REPOSITORY,
+ NULL, &argv[2]);
+ if (pathspec.nr)
+ ps = &pathspec;
+
+ skip1 = strlen(paths[0]);
+ skip1 += paths[0][skip1] == '/' ? 0 : 1;
+ skip2 = strlen(paths[1]);
+ skip2 += paths[1][skip2] == '/' ? 0 : 1;
+ } else if (argc > 2) {
+ warning(_("Limiting comparison with pathspecs is only "
+ "supported if both paths are directories."));
+ usage_with_options(diff_no_index_usage, options);
+ }
+ FREE_AND_NULL(options);
revs->diffopt.skip_stat_unmatch = 1;
if (!revs->diffopt.output_format)
@@ -354,7 +414,8 @@ int diff_no_index(struct rev_info *revs, const struct git_hash_algo *algop,
setup_diff_pager(&revs->diffopt);
revs->diffopt.flags.exit_with_status = 1;
- if (queue_diff(&revs->diffopt, algop, paths[0], paths[1], 0))
+ if (queue_diff(&revs->diffopt, algop, paths[0], paths[1], 0, ps,
+ skip1, skip2))
goto out;
diff_set_mnemonic_prefix(&revs->diffopt, "1/", "2/");
diffcore_std(&revs->diffopt);
@@ -370,5 +431,7 @@ int diff_no_index(struct rev_info *revs, const struct git_hash_algo *algop,
for (i = 0; i < ARRAY_SIZE(to_free); i++)
free(to_free[i]);
strbuf_release(&replacement);
+ if (ps)
+ clear_pathspec(ps);
return ret;
}
diff --git a/dir.c b/dir.c
index a374972..c8c869f 100644
--- a/dir.c
+++ b/dir.c
@@ -397,9 +397,12 @@ static int match_pathspec_item(struct index_state *istate,
strncmp(item->match, name - prefix, item->prefix))
return 0;
- if (item->attr_match_nr &&
- !match_pathspec_attrs(istate, name - prefix, namelen + prefix, item))
- return 0;
+ if (item->attr_match_nr) {
+ if (!istate)
+ BUG("magic PATHSPEC_ATTR requires an index");
+ if (!match_pathspec_attrs(istate, name - prefix, namelen + prefix, item))
+ return 0;
+ }
/* If the match was just the prefix, we matched */
if (!*match)
@@ -577,6 +580,16 @@ int match_pathspec(struct index_state *istate,
prefix, seen, flags);
}
+int match_leading_pathspec(struct index_state *istate,
+ const struct pathspec *ps,
+ const char *name, int namelen,
+ int prefix, char *seen, int is_dir)
+{
+ unsigned flags = is_dir ? DO_MATCH_DIRECTORY | DO_MATCH_LEADING_PATHSPEC : 0;
+ return match_pathspec_with_flags(istate, ps, name, namelen,
+ prefix, seen, flags);
+}
+
/**
* Check if a submodule is a superset of the pathspec
*/
diff --git a/environment.c b/environment.c
index c61d773..7bf0390 100644
--- a/environment.c
+++ b/environment.c
@@ -113,9 +113,6 @@ const char *comment_line_str = "#";
char *comment_line_str_to_free;
int auto_comment_line_char;
-/* Parallel index stat data preload? */
-int core_preload_index = 1;
-
/* This is set by setup_git_directory_gently() and/or git_default_config() */
char *git_work_tree_cfg;
diff --git a/environment.h b/environment.h
index 3d98461..9a3d05d 100644
--- a/environment.h
+++ b/environment.h
@@ -155,7 +155,6 @@ extern int pack_compression_level;
extern unsigned long pack_size_limit_cfg;
extern int max_allowed_tree_depth;
-extern int core_preload_index;
extern int precomposed_unicode;
extern int protect_hfs;
extern int protect_ntfs;
diff --git a/git-compat-util.h b/git-compat-util.h
index 4678e21..5bd69ec 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -460,6 +460,8 @@ void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
void show_usage_if_asked(int ac, const char **av, const char *err);
+NORETURN void you_still_use_that(const char *command_name);
+
#ifndef NO_OPENSSL
#ifdef APPLE_COMMON_CRYPTO
#include "compat/apple-common-crypto.h"
diff --git a/git-send-email.perl b/git-send-email.perl
index 659e6c5..cb6dca2 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1653,8 +1653,18 @@
default => $ask_default);
die __("Send this email reply required") unless defined $_;
if (/^n/i) {
+ # If we are skipping a message, we should make sure that
+ # the next message is treated as the successor to the
+ # previously sent message, and not the skipped message.
+ $message_num--;
return 0;
} elsif (/^e/i) {
+ # Since the same message will be sent again, we need to
+ # decrement the message number to the previous message.
+ # Otherwise, the edited message will be treated as a
+ # different message sent after the original non-edited
+ # message.
+ $message_num--;
return -1;
} elsif (/^q/i) {
cleanup_compose_files();
@@ -1778,7 +1788,8 @@
if (is_outlook($smtp_server)) {
if ($smtp->message =~ /<([^>]+)>/) {
$message_id = "<$1>";
- printf __("Outlook reassigned Message-ID to: %s\n"), $message_id;
+ $header =~ s/^(Message-ID:\s*).*\n/${1}$message_id\n/m;
+ printf __("Outlook reassigned Message-ID to: %s\n"), $message_id if $smtp->debug;
} else {
warn __("Warning: Could not retrieve Message-ID from server response.\n");
}
diff --git a/git.c b/git.c
index 77c4359..07a5fe3 100644
--- a/git.c
+++ b/git.c
@@ -462,12 +462,12 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct
precompose_argv_prefix(argc, argv, NULL);
if (use_pager == -1 && run_setup &&
!(p->option & DELAY_PAGER_CONFIG))
- use_pager = check_pager_config(the_repository, p->cmd);
+ use_pager = check_pager_config(repo, p->cmd);
if (use_pager == -1 && p->option & USE_PAGER)
use_pager = 1;
if (run_setup && startup_info->have_repository)
/* get_git_dir() may set up repo, avoid that */
- trace_repo_setup(the_repository);
+ trace_repo_setup(repo);
commit_pager_choice();
if (!help && p->option & NEED_WORK_TREE)
@@ -646,7 +646,9 @@ static struct cmd_struct commands[] = {
{ "verify-pack", cmd_verify_pack },
{ "verify-tag", cmd_verify_tag, RUN_SETUP },
{ "version", cmd_version },
+#ifndef WITH_BREAKING_CHANGES
{ "whatchanged", cmd_whatchanged, RUN_SETUP },
+#endif
{ "worktree", cmd_worktree, RUN_SETUP },
{ "write-tree", cmd_write_tree, RUN_SETUP },
};
diff --git a/hash.h b/hash.h
index d6422dd..ec594c6 100644
--- a/hash.h
+++ b/hash.h
@@ -216,6 +216,7 @@ struct object_id {
#define GET_OID_REQUIRE_PATH 010000
#define GET_OID_HASH_ANY 020000
#define GET_OID_SKIP_AMBIGUITY_CHECK 040000
+#define GET_OID_GENTLY 0100000
#define GET_OID_DISAMBIGUATORS \
(GET_OID_COMMIT | GET_OID_COMMITTISH | \
diff --git a/ident.c b/ident.c
index 967895d..281e830 100644
--- a/ident.c
+++ b/ident.c
@@ -412,6 +412,10 @@ void apply_mailmap_to_header(struct strbuf *buf, const char **header,
found_header = 1;
buf_offset += endp - line;
buf_offset += rewrite_ident_line(person, endp - person, buf, mailmap);
+ /* Recompute endp after potential buffer reallocation */
+ endp = buf->buf + buf_offset;
+ if (*endp == '\n')
+ buf_offset++;
break;
}
diff --git a/mailinfo.c b/mailinfo.c
index ee4597d..b4e815b 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -266,6 +266,8 @@ static void handle_content_type(struct mailinfo *mi, struct strbuf *line)
error("Too many boundaries to handle");
mi->input_error = -1;
mi->content_top = &mi->content[MAX_BOUNDARIES] - 1;
+ strbuf_release(boundary);
+ free(boundary);
return;
}
*(mi->content_top) = boundary;
diff --git a/mergetools/vimdiff b/mergetools/vimdiff
index 7871085..fca1044 100644
--- a/mergetools/vimdiff
+++ b/mergetools/vimdiff
@@ -274,8 +274,8 @@
# definition.
#
# The syntax of the "layout definitions" is explained in "Documentation/
- # mergetools/vimdiff.txt" but you can already intuitively understand how
- # it works by knowing that...
+ # mergetools/vimdiff.adoc" but you can already intuitively understand
+ # how it works by knowing that...
#
# * "+" means "a new vim tab"
# * "/" means "a new vim horizontal split"
diff --git a/meson.build b/meson.build
index 596f5ac..7fea4a3 100644
--- a/meson.build
+++ b/meson.build
@@ -2054,6 +2054,18 @@
# can properly set up test dependencies. The bin-wrappers themselves are set up
# at configuration time, so these are fine.
if get_option('tests')
+ test_kwargs = {
+ 'timeout': 0,
+ }
+
+ # The TAP protocol was already understood by previous versions of Meson, but
+ # it was incompatible with the `meson test --interactive` flag.
+ if meson.version().version_compare('>=1.8.0')
+ test_kwargs += {
+ 'protocol': 'tap',
+ }
+ endif
+
subdir('t')
endif
diff --git a/object-name.c b/object-name.c
index 9288b2d..8518589 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1081,13 +1081,17 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
* still fill in the oid with the "old" value,
* which we can use.
*/
- } else {
+ } else if (!(flags & GET_OID_GENTLY)) {
if (flags & GET_OID_QUIETLY) {
exit(128);
}
die(_("log for '%.*s' only has %d entries"),
len, str, co_cnt);
}
+ if (flags & GET_OID_GENTLY) {
+ free(real_ref);
+ return -1;
+ }
}
}
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 7f400ee..56960e6 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -1087,7 +1087,7 @@ void bitmap_writer_finish(struct bitmap_writer *writer,
oid_access);
if (commit_pos < 0)
- BUG(_("trying to write commit not in index"));
+ BUG("trying to write commit not in index");
stored->commit_pos = commit_pos + base_objects;
}
diff --git a/pack-bitmap.c b/pack-bitmap.c
index ac6d62b..8727f31 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1363,8 +1363,8 @@ static struct bitmap *find_boundary_objects(struct bitmap_index *bitmap_git,
bitmap_set(roots_bitmap, pos);
}
- if (!cascade_pseudo_merges_1(bitmap_git, cb.base, roots_bitmap))
- bitmap_free(roots_bitmap);
+ cascade_pseudo_merges_1(bitmap_git, cb.base, roots_bitmap);
+ bitmap_free(roots_bitmap);
}
/*
diff --git a/pack-objects.h b/pack-objects.h
index 475a2d6..b1c3e70 100644
--- a/pack-objects.h
+++ b/pack-objects.h
@@ -120,11 +120,23 @@ struct object_entry {
unsigned ext_base:1; /* delta_idx points outside packlist */
};
+/**
+ * A packing region is a section of the packing_data.objects array
+ * as given by a starting index and a number of elements.
+ */
+struct packing_region {
+ size_t start;
+ size_t nr;
+};
+
struct packing_data {
struct repository *repo;
struct object_entry *objects;
uint32_t nr_objects, nr_alloc;
+ struct packing_region *regions;
+ size_t nr_regions, nr_regions_alloc;
+
int32_t *index;
uint32_t index_size;
diff --git a/path-walk.c b/path-walk.c
index 341bdd2..2d4ddba 100644
--- a/path-walk.c
+++ b/path-walk.c
@@ -503,7 +503,11 @@ int walk_objects_by_path(struct path_walk_info *info)
if (prepare_revision_walk(info->revs))
die(_("failed to setup revision walk"));
- /* Walk trees to mark them as UNINTERESTING. */
+ /*
+ * Walk trees to mark them as UNINTERESTING.
+ * This is particularly important when 'edge_aggressive' is set.
+ */
+ info->revs->edge_hint_aggressive = info->edge_aggressive;
edge_repo = info->revs->repo;
edge_tree_list = root_tree_list;
mark_edges_uninteresting(info->revs, show_edge,
diff --git a/path-walk.h b/path-walk.h
index 473ee9d..5ef5a84 100644
--- a/path-walk.h
+++ b/path-walk.h
@@ -51,6 +51,13 @@ struct path_walk_info {
int prune_all_uninteresting;
/**
+ * When 'edge_aggressive' is set, then the revision walk will use
+ * the '--object-edge-aggressive' option to mark even more objects
+ * as uninteresting.
+ */
+ int edge_aggressive;
+
+ /**
* Specify a sparse-checkout definition to match our paths to. Do not
* walk outside of this sparse definition. If the patterns are in
* cone mode, then the search may prune directories that are outside
diff --git a/pathspec.c b/pathspec.c
index 2b4e434..a3ddd70 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -492,7 +492,7 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,
if (!match) {
const char *hint_path;
- if (!have_git_dir())
+ if ((flags & PATHSPEC_NO_REPOSITORY) || !have_git_dir())
die(_("'%s' is outside the directory tree"),
copyfrom);
hint_path = repo_get_work_tree(the_repository);
@@ -614,6 +614,10 @@ void parse_pathspec(struct pathspec *pathspec,
(flags & PATHSPEC_PREFER_FULL))
BUG("PATHSPEC_PREFER_CWD and PATHSPEC_PREFER_FULL are incompatible");
+ if ((flags & PATHSPEC_NO_REPOSITORY) &&
+ (~magic_mask & (PATHSPEC_ATTR | PATHSPEC_FROMTOP)))
+ BUG("PATHSPEC_NO_REPOSITORY is incompatible with PATHSPEC_ATTR and PATHSPEC_FROMTOP");
+
/* No arguments with prefix -> prefix pathspec */
if (!entry) {
if (flags & PATHSPEC_PREFER_FULL)
diff --git a/pathspec.h b/pathspec.h
index de537cf..5e3a6f1 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -76,6 +76,11 @@ struct pathspec {
* allowed, then it will automatically set for every pathspec.
*/
#define PATHSPEC_LITERAL_PATH (1<<6)
+/*
+ * For git diff --no-index, indicate that we are operating without
+ * a repository or index.
+ */
+#define PATHSPEC_NO_REPOSITORY (1<<7)
/**
* Given command line arguments and a prefix, convert the input to
@@ -184,6 +189,12 @@ int match_pathspec(struct index_state *istate,
const char *name, int namelen,
int prefix, char *seen, int is_dir);
+/* Set both DO_MATCH_DIRECTORY and DO_MATCH_LEADING_PATHSPEC if is_dir true */
+int match_leading_pathspec(struct index_state *istate,
+ const struct pathspec *ps,
+ const char *name, int namelen,
+ int prefix, char *seen, int is_dir);
+
/*
* Determine whether a pathspec will match only entire index entries (non-sparse
* files and/or entire sparse directories). If the pathspec has the potential to
diff --git a/preload-index.c b/preload-index.c
index 40ab2ab..b222821 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -2,7 +2,6 @@
* Copyright (C) 2008 Linus Torvalds
*/
-#define USE_THE_REPOSITORY_VARIABLE
#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
@@ -19,6 +18,7 @@
#include "repository.h"
#include "symlinks.h"
#include "trace2.h"
+#include "config.h"
/*
* Mostly randomly chosen maximum thread counts: we
@@ -111,6 +111,9 @@ void preload_index(struct index_state *index,
struct thread_data data[MAX_PARALLEL];
struct progress_data pd;
int t2_sum_lstat = 0;
+ int core_preload_index = 1;
+
+ repo_config_get_bool(index->repo, "core.preloadindex", &core_preload_index);
if (!HAVE_THREADS || !core_preload_index)
return;
@@ -132,7 +135,7 @@ void preload_index(struct index_state *index,
memset(&pd, 0, sizeof(pd));
if (refresh_flags & REFRESH_PROGRESS && isatty(2)) {
- pd.progress = start_delayed_progress(the_repository,
+ pd.progress = start_delayed_progress(index->repo,
_("Refreshing index"),
index->cache_nr);
pthread_mutex_init(&pd.mutex, NULL);
diff --git a/repo-settings.c b/repo-settings.c
index 4129f8f..195c24e 100644
--- a/repo-settings.c
+++ b/repo-settings.c
@@ -54,11 +54,13 @@ void prepare_repo_settings(struct repository *r)
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
r->settings.pack_use_bitmap_boundary_traversal = 1;
r->settings.pack_use_multi_pack_reuse = 1;
+ r->settings.pack_use_path_walk = 1;
}
if (manyfiles) {
r->settings.index_version = 4;
r->settings.index_skip_hash = 1;
r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE;
+ r->settings.pack_use_path_walk = 1;
}
/* Commit graph config or default, does not cascade (simple) */
@@ -73,6 +75,7 @@ void prepare_repo_settings(struct repository *r)
/* Boolean config or default, does not cascade (simple) */
repo_cfg_bool(r, "pack.usesparse", &r->settings.pack_use_sparse, 1);
+ repo_cfg_bool(r, "pack.usepathwalk", &r->settings.pack_use_path_walk, 0);
repo_cfg_bool(r, "core.multipackindex", &r->settings.core_multi_pack_index, 1);
repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0);
repo_cfg_bool(r, "index.skiphash", &r->settings.index_skip_hash, r->settings.index_skip_hash);
diff --git a/repo-settings.h b/repo-settings.h
index 2bf24b2..d477885 100644
--- a/repo-settings.h
+++ b/repo-settings.h
@@ -56,6 +56,7 @@ struct repo_settings {
enum untracked_cache_setting core_untracked_cache;
int pack_use_sparse;
+ int pack_use_path_walk;
enum fetch_negotiation_setting fetch_negotiation_algorithm;
int core_multi_pack_index;
diff --git a/revision.c b/revision.c
index 2c36a9c..afee111 100644
--- a/revision.c
+++ b/revision.c
@@ -2060,6 +2060,7 @@ static void prepare_show_merge(struct rev_info *revs)
parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
PATHSPEC_PREFER_FULL | PATHSPEC_LITERAL_PATH, "", prune);
revs->limited = 1;
+ free(prune);
}
static int dotdot_missing(const char *arg, char *dotdot,
diff --git a/scalar.c b/scalar.c
index 355baf7..0dc79fa 100644
--- a/scalar.c
+++ b/scalar.c
@@ -170,6 +170,7 @@ static int set_recommended_config(int reconfigure)
{ "core.autoCRLF", "false" },
{ "core.safeCRLF", "false" },
{ "fetch.showForcedUpdates", "false" },
+ { "pack.usePathWalk", "true" },
{ NULL, NULL },
};
int i;
diff --git a/sequencer.c b/sequencer.c
index 1ee0abb..9456ca6 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2067,6 +2067,9 @@ static int update_squash_messages(struct repository *r,
const char *message, *body;
const char *encoding = get_commit_output_encoding();
+ if (!is_fixup(command))
+ BUG("not a FIXUP or SQUASH %d", command);
+
if (ctx->current_fixup_count > 0) {
struct strbuf header = STRBUF_INIT;
char *eol;
@@ -2134,8 +2137,7 @@ static int update_squash_messages(struct repository *r,
strbuf_addstr(&buf, "\n\n");
strbuf_add_commented_lines(&buf, body, strlen(body),
comment_line_str);
- } else
- return error(_("unknown command: %d"), command);
+ }
repo_unuse_commit_buffer(r, commit, message);
if (!res)
diff --git a/sub-process.h b/sub-process.h
index 6a61638..bfc3959 100644
--- a/sub-process.h
+++ b/sub-process.h
@@ -73,7 +73,7 @@ static inline struct child_process *subprocess_get_child_process(
/*
* Perform the version and capability negotiation as described in the
- * "Handshake" section of long-running-process-protocol.txt using the
+ * "Handshake" section of long-running-process-protocol.adoc using the
* given requested versions and capabilities. The "versions" and "capabilities"
* parameters are arrays terminated by a 0 or blank struct.
*
diff --git a/t/README b/t/README
index e9ffd9a..adbbd9a 100644
--- a/t/README
+++ b/t/README
@@ -415,6 +415,10 @@
builtin to use the non-sparse object walk. This can still be overridden by
the --sparse command-line argument.
+GIT_TEST_PACK_PATH_WALK=<boolean> if enabled will default the pack-objects
+builtin to use the path-walk API for the object walk. This can still be
+overridden by the --no-path-walk command-line argument.
+
GIT_TEST_PRELOAD_INDEX=<boolean> exercises the preload-index code path
by overriding the minimum number of cache entries required per thread.
diff --git a/t/helper/test-path-walk.c b/t/helper/test-path-walk.c
index 61e845e..fe63002 100644
--- a/t/helper/test-path-walk.c
+++ b/t/helper/test-path-walk.c
@@ -82,6 +82,8 @@ int cmd__path_walk(int argc, const char **argv)
N_("toggle inclusion of tree objects")),
OPT_BOOL(0, "prune", &info.prune_all_uninteresting,
N_("toggle pruning of uninteresting paths")),
+ OPT_BOOL(0, "edge-aggressive", &info.edge_aggressive,
+ N_("toggle aggressive edge walk")),
OPT_BOOL(0, "stdin-pl", &stdin_pl,
N_("read a pattern list over stdin")),
OPT_END(),
diff --git a/t/meson.build b/t/meson.build
index d052fc3..6d7fe6b 100644
--- a/t/meson.build
+++ b/t/meson.build
@@ -51,7 +51,7 @@
sources: clar_sources + clar_test_suites,
dependencies: [libgit_commonmain],
)
-test('unit-tests', clar_unit_tests)
+test('unit-tests', clar_unit_tests, kwargs: test_kwargs)
unit_test_programs = [
'unit-tests/t-reftable-basics.c',
@@ -76,7 +76,7 @@
)
test(unit_test_name, unit_test,
workdir: meson.current_source_dir(),
- timeout: 0,
+ kwargs: test_kwargs,
)
endforeach
@@ -178,7 +178,6 @@
't1015-read-index-unmerged.sh',
't1016-compatObjectFormat.sh',
't1020-subdirectory.sh',
- 't1021-rerere-in-workdir.sh',
't1022-read-tree-partial-clone.sh',
't1050-large.sh',
't1051-large-conversion.sh',
@@ -1212,7 +1211,7 @@
workdir: meson.current_source_dir(),
env: test_environment,
depends: test_dependencies + bin_wrappers,
- timeout: 0,
+ kwargs: test_kwargs,
)
endforeach
diff --git a/t/perf/p5313-pack-objects.sh b/t/perf/p5313-pack-objects.sh
index 786a2c1..46a6cd3 100755
--- a/t/perf/p5313-pack-objects.sh
+++ b/t/perf/p5313-pack-objects.sh
@@ -22,46 +22,53 @@
EOF
'
-for version in 1 2
-do
- export version
+test_all_with_args () {
+ parameter=$1
+ export parameter
- test_perf "thin pack with version $version" '
+ test_perf "thin pack with $parameter" '
git pack-objects --thin --stdout --revs --sparse \
- --name-hash-version=$version <in-thin >out
+ $parameter <in-thin >out
'
- test_size "thin pack size with version $version" '
+ test_size "thin pack size with $parameter" '
test_file_size out
'
- test_perf "big pack with version $version" '
+ test_perf "big pack with $parameter" '
git pack-objects --stdout --revs --sparse \
- --name-hash-version=$version <in-big >out
+ $parameter <in-big >out
'
- test_size "big pack size with version $version" '
+ test_size "big pack size with $parameter" '
test_file_size out
'
- test_perf "shallow fetch pack with version $version" '
+ test_perf "shallow fetch pack with $parameter" '
git pack-objects --stdout --revs --sparse --shallow \
- --name-hash-version=$version <in-shallow >out
+ $parameter <in-shallow >out
'
- test_size "shallow pack size with version $version" '
+ test_size "shallow pack size with $parameter" '
test_file_size out
'
- test_perf "repack with version $version" '
- git repack -adf --name-hash-version=$version
+ test_perf "repack with $parameter" '
+ git repack -adf $parameter
'
- test_size "repack size with version $version" '
+ test_size "repack size with $parameter" '
gitdir=$(git rev-parse --git-dir) &&
pack=$(ls $gitdir/objects/pack/pack-*.pack) &&
test_file_size "$pack"
'
+}
+
+for version in 1 2
+do
+ test_all_with_args --name-hash-version=$version
done
+test_all_with_args --path-walk
+
test_done
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 35c5c2b..2b63e1c 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -130,7 +130,7 @@
'
test_expect_success 'subtest: a passing TODO test' '
- write_and_run_sub_test_lib_test passing-todo <<-\EOF &&
+ write_and_run_sub_test_lib_test_err passing-todo <<-\EOF &&
test_expect_failure "pretend we have fixed a known breakage" "true"
test_done
EOF
@@ -142,7 +142,7 @@
'
test_expect_success 'subtest: 2 TODO tests, one passin' '
- write_and_run_sub_test_lib_test partially-passing-todos <<-\EOF &&
+ write_and_run_sub_test_lib_test_err partially-passing-todos <<-\EOF &&
test_expect_failure "pretend we have a known breakage" "false"
test_expect_success "pretend we have a passing test" "true"
test_expect_failure "pretend we have fixed another known breakage" "true"
@@ -219,41 +219,44 @@
test_expect_success "failing test" false
test_done
EOF
- mv t1234-verbose/out t1234-verbose/out+ &&
- grep -v "^Initialized empty" t1234-verbose/out+ >t1234-verbose/out &&
- check_sub_test_lib_test t1234-verbose <<-\EOF
- > expecting success of 1234.1 '\''passing test'\'': true
+ mv t1234-verbose/err t1234-verbose/err+ &&
+ grep -v "^Initialized empty" t1234-verbose/err+ >t1234-verbose/err &&
+ check_sub_test_lib_test_err t1234-verbose \
+ <<-\EOF_OUT 3<<-\EOF_ERR
> ok 1 - passing test
+ > ok 2 - test with output
+ > not ok 3 - failing test
+ > # false
+ > # failed 1 among 3 test(s)
+ > 1..3
+ EOF_OUT
+ > expecting success of 1234.1 '\''passing test'\'': true
> Z
> expecting success of 1234.2 '\''test with output'\'': echo foo
> foo
- > ok 2 - test with output
> Z
> expecting success of 1234.3 '\''failing test'\'': false
- > not ok 3 - failing test
- > # false
> Z
- > # failed 1 among 3 test(s)
- > 1..3
- EOF
+ EOF_ERR
'
test_expect_success 'subtest: --verbose-only option' '
run_sub_test_lib_test_err \
t1234-verbose \
--verbose-only=2 &&
- check_sub_test_lib_test t1234-verbose <<-\EOF
+ check_sub_test_lib_test_err t1234-verbose <<-\EOF_OUT 3<<-\EOF_ERR
> ok 1 - passing test
- > Z
- > expecting success of 1234.2 '\''test with output'\'': echo foo
- > foo
> ok 2 - test with output
- > Z
> not ok 3 - failing test
> # false
> # failed 1 among 3 test(s)
> 1..3
- EOF
+ EOF_OUT
+ > Z
+ > expecting success of 1234.2 '\''test with output'\'': echo foo
+ > foo
+ > Z
+ EOF_ERR
'
test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index bf10d25..f0d50d7 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -281,7 +281,7 @@
test_expect_success 'filtering large input to small output should use little memory' '
test_config filter.devnull.clean "cat >/dev/null" &&
test_config filter.devnull.required true &&
- for i in $(test_seq 1 30); do printf "%1048576d" 1 || return 1; done >30MB &&
+ test_seq -f "%1048576d" 1 30 >30MB &&
echo "30MB filter=devnull" >.gitattributes &&
GIT_MMAP_LIMIT=1m GIT_ALLOC_LIMIT=1m git add 30MB
'
@@ -299,7 +299,7 @@
test_expect_success EXPENSIVE 'filter large file' '
test_config filter.largefile.smudge cat &&
test_config filter.largefile.clean cat &&
- for i in $(test_seq 1 2048); do printf "%1048576d" 1 || return 1; done >2GB &&
+ test_seq -f "%1048576d" 1 2048 >2GB &&
echo "2GB filter=largefile" >.gitattributes &&
git add 2GB 2>err &&
test_must_be_empty err &&
diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh
index 5c9dc90..ca85680 100755
--- a/t/t0050-filesystem.sh
+++ b/t/t0050-filesystem.sh
@@ -10,53 +10,35 @@
auml=$(printf '\303\244')
aumlcdiar=$(printf '\141\314\210')
-if test_have_prereq CASE_INSENSITIVE_FS
-then
- say "will test on a case insensitive filesystem"
- test_case=test_expect_failure
-else
- test_case=test_expect_success
-fi
-
if test_have_prereq UTF8_NFD_TO_NFC
then
- say "will test on a unicode corrupting filesystem"
test_unicode=test_expect_failure
else
test_unicode=test_expect_success
fi
-test_have_prereq SYMLINKS ||
- say "will test on a filesystem lacking symbolic links"
-
-if test_have_prereq CASE_INSENSITIVE_FS
-then
-test_expect_success "detection of case insensitive filesystem during repo init" '
+test_expect_success CASE_INSENSITIVE_FS "detection of case insensitive filesystem during repo init" '
test $(git config --bool core.ignorecase) = true
'
-else
-test_expect_success "detection of case insensitive filesystem during repo init" '
+
+test_expect_success !CASE_INSENSITIVE_FS "detection of case insensitive filesystem during repo init" '
{
test_must_fail git config --bool core.ignorecase >/dev/null ||
test $(git config --bool core.ignorecase) = false
}
'
-fi
-if test_have_prereq SYMLINKS
-then
-test_expect_success "detection of filesystem w/o symlink support during repo init" '
+test_expect_success SYMLINKS "detection of filesystem w/o symlink support during repo init" '
{
test_must_fail git config --bool core.symlinks ||
test "$(git config --bool core.symlinks)" = true
}
'
-else
-test_expect_success "detection of filesystem w/o symlink support during repo init" '
+
+test_expect_success !SYMLINKS "detection of filesystem w/o symlink support during repo init" '
v=$(git config --bool core.symlinks) &&
test "$v" = false
'
-fi
test_expect_success "setup case tests" '
git config core.ignorecase true &&
diff --git a/t/t0411-clone-from-partial.sh b/t/t0411-clone-from-partial.sh
index 196fc61..9e6bca5 100755
--- a/t/t0411-clone-from-partial.sh
+++ b/t/t0411-clone-from-partial.sh
@@ -59,6 +59,12 @@
test_expect_success 'clone from promisor remote does not lazy-fetch by default' '
rm -f script-executed &&
+
+ # The --path-walk feature of "git pack-objects" is not
+ # compatible with this kind of fetch from an incomplete repo.
+ GIT_TEST_PACK_PATH_WALK=0 &&
+ export GIT_TEST_PACK_PATH_WALK &&
+
test_must_fail git clone evil no-lazy 2>err &&
test_grep "lazy fetching disabled" err &&
test_path_is_missing script-executed
diff --git a/t/t0450/adoc-help-mismatches b/t/t0450/adoc-help-mismatches
index c4a15fd..06b469b 100644
--- a/t/t0450/adoc-help-mismatches
+++ b/t/t0450/adoc-help-mismatches
@@ -38,7 +38,6 @@
multi-pack-index
name-rev
notes
-pack-objects
push
range-diff
rebase
diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh
index 1be534a..3ea5d51 100755
--- a/t/t0610-reftable-basics.sh
+++ b/t/t0610-reftable-basics.sh
@@ -477,11 +477,7 @@
test_commit --no-tag initial &&
head=$(git rev-parse HEAD) &&
- for i in $(test_seq 100)
- do
- printf "%s commit\trefs/heads/branch-%s\n" "$head" "$i" ||
- return 1
- done >expect &&
+ test_seq -f "$head commit\trefs/heads/branch-%d" 100 >expect &&
printf "%s commit\trefs/heads/main\n" "$head" >>expect &&
for i in $(test_seq 100)
diff --git a/t/t0612-reftable-jgit-compatibility.sh b/t/t0612-reftable-jgit-compatibility.sh
index d0d7e80..7df2ad5 100755
--- a/t/t0612-reftable-jgit-compatibility.sh
+++ b/t/t0612-reftable-jgit-compatibility.sh
@@ -112,14 +112,11 @@
cd repo &&
test_commit A &&
- awk "
- BEGIN {
- print \"start\";
- for (i = 0; i < 10000; i++)
- printf \"create refs/heads/branch-%d HEAD\n\", i;
- print \"commit\";
- }
- " >input &&
+ {
+ echo start &&
+ test_seq -f "create refs/heads/branch-%d HEAD" 10000 &&
+ echo commit
+ } >input &&
git update-ref --stdin <input &&
test_same_refs &&
diff --git a/t/t0613-reftable-write-options.sh b/t/t0613-reftable-write-options.sh
index 6447920..d77e601 100755
--- a/t/t0613-reftable-write-options.sh
+++ b/t/t0613-reftable-write-options.sh
@@ -66,11 +66,7 @@
(
cd repo &&
test_commit initial &&
- for i in $(test_seq 200)
- do
- printf "update refs/heads/branch-%d HEAD\n" "$i" ||
- return 1
- done >input &&
+ test_seq -f "update refs/heads/branch-%d HEAD" 200 >input &&
git update-ref --stdin <input &&
git pack-refs &&
@@ -180,11 +176,7 @@
(
cd repo &&
test_commit initial &&
- for i in $(test_seq 10)
- do
- printf "update refs/heads/branch-%d HEAD\n" "$i" ||
- return 1
- done >input &&
+ test_seq -f "update refs/heads/branch-%d HEAD" 10 >input &&
git update-ref --stdin <input &&
git -c reftable.restartInterval=1 pack-refs &&
@@ -224,11 +216,7 @@
(
cd repo &&
test_commit initial &&
- for i in $(test_seq 5)
- do
- printf "update refs/heads/branch-%d HEAD\n" "$i" ||
- return 1
- done >input &&
+ test_seq -f "update refs/heads/branch-%d HEAD" 5 >input &&
git update-ref --stdin <input &&
git -c reftable.blockSize=100 pack-refs &&
@@ -263,11 +251,7 @@
(
cd repo &&
test_commit initial &&
- for i in $(test_seq 5)
- do
- printf "update refs/heads/branch-%d HEAD\n" "$i" ||
- return 1
- done >input &&
+ test_seq -f "update refs/heads/branch-%d HEAD" 5 >input &&
git update-ref --stdin <input &&
git -c reftable.blockSize=100 -c reftable.indexObjects=false pack-refs &&
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 317da68..f123ef1 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -113,53 +113,55 @@
run_tests () {
type=$1
- oid=$2
- size=$3
- content=$4
- pretty_content=$5
+ object_name="$2"
+ mode=$3
+ size=$4
+ content=$5
+ pretty_content=$6
+ oid=${7:-"$object_name"}
batch_output="$oid $type $size
$content"
test_expect_success "$type exists" '
- git cat-file -e $oid
+ git cat-file -e "$object_name"
'
test_expect_success "Type of $type is correct" '
echo $type >expect &&
- git cat-file -t $oid >actual &&
+ git cat-file -t "$object_name" >actual &&
test_cmp expect actual
'
test_expect_success "Size of $type is correct" '
echo $size >expect &&
- git cat-file -s $oid >actual &&
+ git cat-file -s "$object_name" >actual &&
test_cmp expect actual
'
test -z "$content" ||
test_expect_success "Content of $type is correct" '
echo_without_newline "$content" >expect &&
- git cat-file $type $oid >actual &&
+ git cat-file $type "$object_name" >actual &&
test_cmp expect actual
'
test_expect_success "Pretty content of $type is correct" '
echo_without_newline "$pretty_content" >expect &&
- git cat-file -p $oid >actual &&
+ git cat-file -p "$object_name" >actual &&
test_cmp expect actual
'
test -z "$content" ||
test_expect_success "--batch output of $type is correct" '
echo "$batch_output" >expect &&
- echo $oid | git cat-file --batch >actual &&
+ echo "$object_name" | git cat-file --batch >actual &&
test_cmp expect actual
'
test_expect_success "--batch-check output of $type is correct" '
echo "$oid $type $size" >expect &&
- echo_without_newline $oid | git cat-file --batch-check >actual &&
+ echo_without_newline "$object_name" | git cat-file --batch-check >actual &&
test_cmp expect actual
'
@@ -168,13 +170,13 @@
test -z "$content" ||
test_expect_success "--batch-command $opt output of $type content is correct" '
echo "$batch_output" >expect &&
- test_write_lines "contents $oid" | git cat-file --batch-command $opt >actual &&
+ test_write_lines "contents $object_name" | git cat-file --batch-command $opt >actual &&
test_cmp expect actual
'
test_expect_success "--batch-command $opt output of $type info is correct" '
echo "$oid $type $size" >expect &&
- test_write_lines "info $oid" |
+ test_write_lines "info $object_name" |
git cat-file --batch-command $opt >actual &&
test_cmp expect actual
'
@@ -182,30 +184,45 @@
test_expect_success "custom --batch-check format" '
echo "$type $oid" >expect &&
- echo $oid | git cat-file --batch-check="%(objecttype) %(objectname)" >actual &&
+ echo "$object_name" | git cat-file --batch-check="%(objecttype) %(objectname)" >actual &&
test_cmp expect actual
'
test_expect_success "custom --batch-command format" '
echo "$type $oid" >expect &&
- echo "info $oid" | git cat-file --batch-command="%(objecttype) %(objectname)" >actual &&
+ echo "info $object_name" | git cat-file --batch-command="%(objecttype) %(objectname)" >actual &&
test_cmp expect actual
'
- test_expect_success '--batch-check with %(rest)' '
+ # FIXME: %(rest) is incompatible with object names that include whitespace,
+ # e.g. HEAD:path/to/a/file with spaces. Use the resolved OID as input to
+ # test this instead of the raw object name.
+ if echo "$object_name" | grep " "; then
+ test_rest=test_expect_failure
+ else
+ test_rest=test_expect_success
+ fi
+
+ $test_rest '--batch-check with %(rest)' '
echo "$type this is some extra content" >expect &&
- echo "$oid this is some extra content" |
+ echo "$object_name this is some extra content" |
git cat-file --batch-check="%(objecttype) %(rest)" >actual &&
test_cmp expect actual
'
+ test_expect_success '--batch-check with %(objectmode)' '
+ echo "$mode $oid" >expect &&
+ echo $object_name | git cat-file --batch-check="%(objectmode) %(objectname)" >actual &&
+ test_cmp expect actual
+ '
+
test -z "$content" ||
test_expect_success "--batch without type ($type)" '
{
echo "$size" &&
echo "$content"
} >expect &&
- echo $oid | git cat-file --batch="%(objectsize)" >actual &&
+ echo "$object_name" | git cat-file --batch="%(objectsize)" >actual &&
test_cmp expect actual
'
@@ -215,7 +232,7 @@
echo "$type" &&
echo "$content"
} >expect &&
- echo $oid | git cat-file --batch="%(objecttype)" >actual &&
+ echo "$object_name" | git cat-file --batch="%(objecttype)" >actual &&
test_cmp expect actual
'
}
@@ -230,13 +247,14 @@
git config extensions.compatobjectformat $test_compat_hash_algo &&
echo_without_newline "$hello_content" > hello &&
git update-index --add hello &&
+ echo_without_newline "$hello_content" > "path with spaces" &&
+ git update-index --add --chmod=+x "path with spaces" &&
git commit -m "add hello file"
'
run_blob_tests () {
oid=$1
-
- run_tests 'blob' $oid $hello_size "$hello_content" "$hello_content"
+ run_tests 'blob' $oid "" $hello_size "$hello_content" "$hello_content"
test_expect_success '--batch-command --buffer with flush for blob info' '
echo "$oid blob $hello_size" >expect &&
@@ -269,13 +287,17 @@
tree_oid=$(git write-tree)
tree_compat_oid=$(git rev-parse --output-object-format=$test_compat_hash_algo $tree_oid)
-tree_size=$(($(test_oid rawsz) + 13))
-tree_compat_size=$(($(test_oid --hash=compat rawsz) + 13))
-tree_pretty_content="100644 blob $hello_oid hello${LF}"
-tree_compat_pretty_content="100644 blob $hello_compat_oid hello${LF}"
+tree_size=$((2 * $(test_oid rawsz) + 13 + 24))
+tree_compat_size=$((2 * $(test_oid --hash=compat rawsz) + 13 + 24))
+tree_pretty_content="100644 blob $hello_oid hello${LF}100755 blob $hello_oid path with spaces${LF}"
+tree_compat_pretty_content="100644 blob $hello_compat_oid hello${LF}100755 blob $hello_compat_oid path with spaces${LF}"
-run_tests 'tree' $tree_oid $tree_size "" "$tree_pretty_content"
-run_tests 'tree' $tree_compat_oid $tree_compat_size "" "$tree_compat_pretty_content"
+run_tests 'tree' $tree_oid "" $tree_size "" "$tree_pretty_content"
+run_tests 'tree' $tree_compat_oid "" $tree_compat_size "" "$tree_compat_pretty_content"
+run_tests 'blob' "$tree_oid:hello" "100644" $hello_size "" "$hello_content" $hello_oid
+run_tests 'blob' "$tree_compat_oid:hello" "100644" $hello_size "" "$hello_content" $hello_compat_oid
+run_tests 'blob' "$tree_oid:path with spaces" "100755" $hello_size "" "$hello_content" $hello_oid
+run_tests 'blob' "$tree_compat_oid:path with spaces" "100755" $hello_size "" "$hello_content" $hello_compat_oid
commit_message="Initial commit"
commit_oid=$(echo_without_newline "$commit_message" | git commit-tree $tree_oid)
@@ -294,8 +316,8 @@
$commit_message"
-run_tests 'commit' $commit_oid $commit_size "$commit_content" "$commit_content"
-run_tests 'commit' $commit_compat_oid $commit_compat_size "$commit_compat_content" "$commit_compat_content"
+run_tests 'commit' $commit_oid "" $commit_size "$commit_content" "$commit_content"
+run_tests 'commit' $commit_compat_oid "" $commit_compat_size "$commit_compat_content" "$commit_compat_content"
tag_header_without_oid="type blob
tag hellotag
@@ -318,8 +340,8 @@
tag_compat_oid=$(git rev-parse --output-object-format=$test_compat_hash_algo $tag_oid)
tag_compat_size=$(strlen "$tag_compat_content")
-run_tests 'tag' $tag_oid $tag_size "$tag_content" "$tag_content"
-run_tests 'tag' $tag_compat_oid $tag_compat_size "$tag_compat_content" "$tag_compat_content"
+run_tests 'tag' $tag_oid "" $tag_size "$tag_content" "$tag_content"
+run_tests 'tag' $tag_compat_oid "" $tag_compat_size "$tag_compat_content" "$tag_compat_content"
test_expect_success "Reach a blob from a tag pointing to it" '
echo_without_newline "$hello_content" >expect &&
@@ -1198,6 +1220,31 @@
test_cmp expect actual
'
+test_expect_success 'batch-check with a submodule' '
+ # FIXME: this call to mktree is incompatible with compatObjectFormat
+ # because the submodule OID cannot be mapped to the compat hash algo.
+ test_unconfig extensions.compatobjectformat &&
+ printf "160000 commit $(test_oid deadbeef)\tsub\n" >tree-with-sub &&
+ tree=$(git mktree <tree-with-sub) &&
+ test_config extensions.compatobjectformat $test_compat_hash_algo &&
+
+ git cat-file --batch-check >actual <<-EOF &&
+ $tree:sub
+ EOF
+ printf "$(test_oid deadbeef) submodule\n" >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'batch-check with a submodule, object exists' '
+ printf "160000 commit $commit_oid\tsub\n" >tree-with-sub &&
+ tree=$(git mktree <tree-with-sub) &&
+ git cat-file --batch-check >actual <<-EOF &&
+ $tree:sub
+ EOF
+ printf "$commit_oid commit $commit_size\n" >expect &&
+ test_cmp expect actual
+'
+
# Pull the entry for object with oid "$1" out of the output of
# "cat-file --batch", including its object content (which requires
# parsing and reading a set amount of bytes, hence perl).
diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
index dbbe9fb..64658b3 100755
--- a/t/t1007-hash-object.sh
+++ b/t/t1007-hash-object.sh
@@ -30,7 +30,7 @@
test_repo=test
push_repo() {
- test_create_repo $test_repo
+ git init --quiet $test_repo
cd $test_repo
setup_repo
diff --git a/t/t1021-rerere-in-workdir.sh b/t/t1021-rerere-in-workdir.sh
deleted file mode 100755
index 0b89289..0000000
--- a/t/t1021-rerere-in-workdir.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/sh
-
-test_description='rerere run in a workdir'
-GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
-export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
-
-. ./test-lib.sh
-
-test_expect_success SYMLINKS setup '
- git config rerere.enabled true &&
- >world &&
- git add world &&
- test_tick &&
- git commit -m initial &&
-
- echo hello >world &&
- test_tick &&
- git commit -a -m hello &&
-
- git checkout -b side HEAD^ &&
- echo goodbye >world &&
- test_tick &&
- git commit -a -m goodbye &&
-
- git checkout main
-'
-
-test_expect_success SYMLINKS 'rerere in workdir' '
- rm -rf .git/rr-cache &&
- "$SHELL_PATH" "$TEST_DIRECTORY/../contrib/workdir/git-new-workdir" . work &&
- (
- cd work &&
- test_must_fail git merge side &&
- git rerere status >actual &&
- echo world >expect &&
- test_cmp expect actual
- )
-'
-
-# This fails because we don't resolve relative symlink in mkdir_in_gitdir()
-# For the purpose of helping contrib/workdir/git-new-workdir users, we do not
-# have to support relative symlinks, but it might be nicer to make this work
-# with a relative symbolic link someday.
-test_expect_failure SYMLINKS 'rerere in workdir (relative)' '
- rm -rf .git/rr-cache &&
- "$SHELL_PATH" "$TEST_DIRECTORY/../contrib/workdir/git-new-workdir" . krow &&
- (
- cd krow &&
- rm -f .git/rr-cache &&
- ln -s ../.git/rr-cache .git/rr-cache &&
- test_must_fail git merge side &&
- git rerere status >actual &&
- echo world >expect &&
- test_cmp expect actual
- )
-'
-
-test_done
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index d29d23c..e373d91 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -1380,10 +1380,7 @@
test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction creating branches does not burst open file limit' '
(
- for i in $(test_seq 33)
- do
- echo "create refs/heads/$i HEAD" || exit 1
- done >large_input &&
+ test_seq -f "create refs/heads/%d HEAD" 33 >large_input &&
run_with_limited_open_files git update-ref --stdin <large_input &&
git rev-parse --verify -q refs/heads/33
)
@@ -1391,10 +1388,7 @@
test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction deleting branches does not burst open file limit' '
(
- for i in $(test_seq 33)
- do
- echo "delete refs/heads/$i HEAD" || exit 1
- done >large_input &&
+ test_seq -f "delete refs/heads/%d HEAD" 33 >large_input &&
run_with_limited_open_files git update-ref --stdin <large_input &&
test_must_fail git rev-parse --verify -q refs/heads/33
)
diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
index 90638fa..023e130 100755
--- a/t/t2400-worktree-add.sh
+++ b/t/t2400-worktree-add.sh
@@ -42,8 +42,8 @@
test_expect_success '"add" refuses to checkout locked branch' '
test_must_fail git worktree add zere main &&
- ! test -d zere &&
- ! test -d .git/worktrees/zere
+ test_path_is_missing zere &&
+ test_path_is_missing .git/worktrees/zere
'
test_expect_success 'checking out paths not complaining about linked checkouts' '
@@ -70,14 +70,14 @@
test_expect_success '"add" worktree with lock' '
git worktree add --detach --lock here-with-lock main &&
test_when_finished "git worktree unlock here-with-lock || :" &&
- test -f .git/worktrees/here-with-lock/locked
+ test_path_is_file .git/worktrees/here-with-lock/locked
'
test_expect_success '"add" worktree with lock and reason' '
lock_reason="why not" &&
git worktree add --detach --lock --reason "$lock_reason" here-with-lock-reason main &&
test_when_finished "git worktree unlock here-with-lock-reason || :" &&
- test -f .git/worktrees/here-with-lock-reason/locked &&
+ test_path_is_file .git/worktrees/here-with-lock-reason/locked &&
echo "$lock_reason" >expect &&
test_cmp expect .git/worktrees/here-with-lock-reason/locked
'
@@ -412,14 +412,14 @@
test_expect_success '"add" worktree with orphan branch and lock' '
git worktree add --lock --orphan -b orphanbr orphan-with-lock &&
test_when_finished "git worktree unlock orphan-with-lock || :" &&
- test -f .git/worktrees/orphan-with-lock/locked
+ test_path_is_file .git/worktrees/orphan-with-lock/locked
'
test_expect_success '"add" worktree with orphan branch, lock, and reason' '
lock_reason="why not" &&
git worktree add --detach --lock --reason "$lock_reason" orphan-with-lock-reason main &&
test_when_finished "git worktree unlock orphan-with-lock-reason || :" &&
- test -f .git/worktrees/orphan-with-lock-reason/locked &&
+ test_path_is_file .git/worktrees/orphan-with-lock-reason/locked &&
echo "$lock_reason" >expect &&
test_cmp expect .git/worktrees/orphan-with-lock-reason/locked
'
@@ -474,7 +474,7 @@
test_expect_success '"add" worktree with --no-checkout' '
git worktree add --no-checkout -b swamp swamp &&
- ! test -e swamp/init.t &&
+ test_path_is_missing swamp/init.t &&
git -C swamp reset --hard &&
test_cmp init.t swamp/init.t
'
@@ -497,7 +497,7 @@
test_expect_success 'add a worktree, checking out a rebased branch' '
test_must_fail git worktree add new-rebase under-rebase &&
- ! test -d new-rebase
+ test_path_is_missing new-rebase
'
test_expect_success 'checking out a rebased branch from another worktree' '
@@ -535,7 +535,7 @@
git worktree list >actual &&
grep "under-bisect.*detached HEAD" actual &&
test_must_fail git worktree add new-bisect under-bisect &&
- ! test -d new-bisect
+ test_path_is_missing new-bisect
)
'
@@ -1165,7 +1165,7 @@
test_expect_success FUNNYNAMES 'sanitize generated worktree name' '
git worktree add --detach ". weird*..?.lock.lock" &&
- test -d .git/worktrees/---weird-.-
+ test_path_is_dir .git/worktrees/---weird-.-
'
test_expect_success '"add" should not fail because of another bad worktree' '
diff --git a/t/t3000-ls-files-others.sh b/t/t3000-ls-files-others.sh
index 13f66fd..b41e7f0 100755
--- a/t/t3000-ls-files-others.sh
+++ b/t/t3000-ls-files-others.sh
@@ -73,25 +73,6 @@
test_cmp expected1 output
'
-test_expect_success SYMLINKS 'ls-files --others with symlinked submodule' '
- git init super &&
- git init sub &&
- (
- cd sub &&
- >a &&
- git add a &&
- git commit -m sub &&
- git pack-refs --all
- ) &&
- (
- cd super &&
- "$SHELL_PATH" "$TEST_DIRECTORY/../contrib/workdir/git-new-workdir" ../sub sub &&
- git ls-files --others --exclude-standard >../actual
- ) &&
- echo sub/ >expect &&
- test_cmp expect actual
-'
-
test_expect_success 'setup nested pathspec search' '
test_create_repo nested &&
(
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 98259e2..1f16e6b 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -17,11 +17,6 @@
git commit -m "add normal files"
'
-if test_have_prereq !FUNNYNAMES
-then
- say 'Your filesystem does not allow tabs in filenames.'
-fi
-
test_expect_success FUNNYNAMES 'add files with funny names' '
touch -- "tab embedded" "newline${LF}embedded" &&
git add -- "tab embedded" "newline${LF}embedded" &&
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 74666ff..c58ccb1 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -11,6 +11,13 @@
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-unique-files.sh
+test_expect_success 'setup' '
+ test_oid_cache <<-EOF
+ export_base sha1:73c9bab443d1f88ac61aa533d2eeaaa15451239c
+ export_base sha256:f210fa6346e3e2ce047bdb570426b17075980c1ac01fec8fc4b75bd3ab4bcfe4
+ EOF
+'
+
test_expect_success 'usage on cmd and subcommand invalid option' '
test_expect_code 129 git stash --invalid-option 2>usage &&
grep "or: git stash" usage &&
@@ -1177,6 +1184,28 @@
test_path_is_file bar
'
+test_expect_success 'stash --patch <pathspec> stash and restores the file' '
+ test_write_lines b c >file &&
+ git commit -m "add a few lines" file &&
+ test_write_lines a b c d >file &&
+ test_write_lines b c d >expect-file &&
+ echo changed-other-file >other-file &&
+ test_write_lines s y n | git stash -m "stash bar" --patch file &&
+ test_cmp expect-file file &&
+ echo changed-other-file >expect &&
+ test_cmp expect other-file &&
+ git checkout HEAD -- file &&
+ git stash pop &&
+ test_cmp expect other-file &&
+ test_write_lines a b c >expect &&
+ test_cmp expect file
+'
+
+test_expect_success 'stash <pathspec> -p is rejected' '
+ test_must_fail git stash file -p 2>err &&
+ test_grep "subcommand wasn${SQ}t specified; ${SQ}push${SQ} can${SQ}t be assumed due to unexpected token ${SQ}file${SQ}" err
+'
+
test_expect_success 'stash -- <pathspec> stashes in subdirectory' '
mkdir sub &&
>foo &&
@@ -1412,6 +1441,100 @@
)
'
+test_expect_success 'stash export and import round-trip stashes' '
+ git reset &&
+ >untracked &&
+ >tracked1 &&
+ >tracked2 &&
+ git add tracked* &&
+ git stash -- &&
+ >subdir/untracked &&
+ >subdir/tracked1 &&
+ >subdir/tracked2 &&
+ git add subdir/tracked* &&
+ git stash --include-untracked -- subdir/ &&
+ git tag t-stash0 stash@{0} &&
+ git tag t-stash1 stash@{1} &&
+ simple=$(git stash export --print) &&
+ git stash clear &&
+ git stash import "$simple" &&
+ test_cmp_rev stash@{0} t-stash0 &&
+ test_cmp_rev stash@{1} t-stash1 &&
+ git stash export --to-ref refs/heads/foo &&
+ test_cmp_rev "$(test_oid empty_tree)" foo: &&
+ test_cmp_rev "$(test_oid empty_tree)" foo^: &&
+ test_cmp_rev t-stash0 foo^2 &&
+ test_cmp_rev t-stash1 foo^^2 &&
+ git log --first-parent --format="%s" refs/heads/foo >log &&
+ grep "^git stash: " log >log2 &&
+ test_line_count = 13 log2 &&
+ git stash clear &&
+ git stash import foo &&
+ test_cmp_rev stash@{0} t-stash0 &&
+ test_cmp_rev stash@{1} t-stash1
+'
+
+test_expect_success 'stash import appends commits' '
+ git log --format=oneline -g refs/stash >out &&
+ cat out out >out2 &&
+ git stash import refs/heads/foo &&
+ git log --format=oneline -g refs/stash >actual &&
+ test_line_count = $(wc -l <out2) actual
+'
+
+test_expect_success 'stash export can accept specified stashes' '
+ git stash clear &&
+ git stash import foo &&
+ git stash export --to-ref refs/heads/bar stash@{1} stash@{0} &&
+ git stash clear &&
+ git stash import refs/heads/bar &&
+ test_cmp_rev stash@{1} t-stash0 &&
+ test_cmp_rev stash@{0} t-stash1 &&
+ git log --format=oneline -g refs/stash >actual &&
+ test_line_count = 2 actual
+'
+
+test_expect_success 'stash export rejects invalid arguments' '
+ test_must_fail git stash export --print --to-ref refs/heads/invalid 2>err &&
+ grep "exactly one of --print and --to-ref is required" err &&
+ test_must_fail git stash export 2>err2 &&
+ grep "exactly one of --print and --to-ref is required" err2
+'
+
+test_expect_success 'stash can import and export zero stashes' '
+ git stash clear &&
+ git stash export --to-ref refs/heads/baz &&
+ test_cmp_rev "$(test_oid empty_tree)" baz: &&
+ test_cmp_rev "$(test_oid export_base)" baz &&
+ test_must_fail git rev-parse baz^1 &&
+ git stash import baz &&
+ test_must_fail git rev-parse refs/stash
+'
+
+test_expect_success 'stash rejects invalid attempts to import commits' '
+ git stash import foo &&
+ test_must_fail git stash import HEAD 2>output &&
+ oid=$(git rev-parse HEAD) &&
+ grep "$oid is not a valid exported stash commit" output &&
+ test_cmp_rev stash@{0} t-stash0 &&
+
+ git checkout --orphan orphan &&
+ git commit-tree $(test_oid empty_tree) -p "$oid" -p "$oid^" -m "" >fake-commit &&
+ git update-ref refs/heads/orphan "$(cat fake-commit)" &&
+ oid=$(git rev-parse HEAD) &&
+ test_must_fail git stash import orphan 2>output &&
+ grep "found stash commit $oid without expected prefix" output &&
+ test_cmp_rev stash@{0} t-stash0 &&
+
+ git checkout --orphan orphan2 &&
+ git commit-tree $(test_oid empty_tree) -m "" >fake-commit &&
+ git update-ref refs/heads/orphan2 "$(cat fake-commit)" &&
+ oid=$(git rev-parse HEAD) &&
+ test_must_fail git stash import orphan2 2>output &&
+ grep "found root commit $oid with invalid data" output &&
+ test_cmp_rev stash@{0} t-stash0
+'
+
test_expect_success 'stash apply should succeed with unmodified file' '
echo base >file &&
git add file &&
@@ -1592,4 +1715,36 @@
)
'
+test_expect_success 'submodules does not affect the branch recorded in stash message' '
+ git init sub_project &&
+ (
+ cd sub_project &&
+ echo "Initial content in sub_project" >sub_file.txt &&
+ git add sub_file.txt &&
+ git commit -m "Initial commit in sub_project"
+ ) &&
+
+ git init main_project &&
+ (
+ cd main_project &&
+ echo "Initial content in main_project" >main_file.txt &&
+ git add main_file.txt &&
+ git commit -m "Initial commit in main_project" &&
+
+ git -c protocol.file.allow=always submodule add ../sub_project sub &&
+ git commit -m "Added submodule sub_project" &&
+
+ git checkout -b feature_main &&
+ git -C sub checkout -b feature_sub &&
+
+ git checkout -b work_branch &&
+ echo "Important work to be stashed" >work_item.txt &&
+ git add work_item.txt &&
+ git stash push -m "custom stash for work_branch" &&
+
+ git stash list >../actual_stash_list.txt &&
+ grep "On work_branch: custom stash for work_branch" ../actual_stash_list.txt
+ )
+'
+
test_done
diff --git a/t/t4000-diff-format.sh b/t/t4000-diff-format.sh
index a51f881..32b14e3 100755
--- a/t/t4000-diff-format.sh
+++ b/t/t4000-diff-format.sh
@@ -36,7 +36,7 @@
# that's as far as it comes
if [ "$(git config --get core.filemode)" = false ]
then
- say 'filemode disabled on the filesystem'
+ skip_all='filemode disabled on the filesystem'
test_done
fi
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index 782d97f..8ebd170 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -206,14 +206,30 @@
expect="$TEST_DIRECTORY/t4013/diff.$test"
actual="$pfx-diff.$test"
- test_expect_success "git $cmd # magic is ${magic:-(not used)}" '
+ case "$cmd" in
+ whatchanged | whatchanged" "*)
+ prereq=!WITH_BREAKING_CHANGES
+ ;;
+ *)
+ prereq=;;
+ esac
+
+ test_expect_success $prereq "git $cmd # magic is ${magic:-(not used)}" '
{
echo "$ git $cmd"
+
+ case "$cmd" in
+ whatchanged | whatchanged" "*)
+ run="whatchanged --i-still-use-this"
+ run="$run ${cmd#whatchanged}" ;;
+ *)
+ run=$cmd ;;
+ esac &&
case "$magic" in
"")
- GIT_PRINT_SHA1_ELLIPSIS=yes git $cmd ;;
+ GIT_PRINT_SHA1_ELLIPSIS=yes git $run ;;
noellipses)
- git $cmd ;;
+ git $run ;;
esac |
sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
-e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
@@ -460,6 +476,11 @@
diff-tree -R --stat --compact-summary initial mode
EOF
+test_expect_success !WITH_BREAKING_CHANGES 'whatchanged needs --i-still-use-this' '
+ test_must_fail git whatchanged >message 2>&1 &&
+ test_grep "nominated for removal" message
+'
+
test_expect_success 'log -m matches pure log' '
git log master >result &&
process_diffs result >expected &&
diff --git a/t/t4018/r-indent b/t/t4018/r-indent
new file mode 100644
index 0000000..9df440f
--- /dev/null
+++ b/t/t4018/r-indent
@@ -0,0 +1,6 @@
+RIGHT <- function(a, b) {
+ c = mean(a, b)
+ d = c + 2
+ ChangeMe()
+ return (d)
+}
diff --git a/t/t4018/r-indent-nested b/t/t4018/r-indent-nested
new file mode 100644
index 0000000..30412e6
--- /dev/null
+++ b/t/t4018/r-indent-nested
@@ -0,0 +1,10 @@
+LEFT = function(a, b) {
+ c = mean(a, b)
+ RIGHT = function(d, e) {
+ f = var(d, e)
+ g = f + 1
+ ChangeMe()
+ return (g)
+ }
+ return (RIGHT(2, 3))
+}
diff --git a/t/t4018/r-noindent b/t/t4018/r-noindent
new file mode 100644
index 0000000..6d9b01f
--- /dev/null
+++ b/t/t4018/r-noindent
@@ -0,0 +1,6 @@
+RIGHT <- function(a, b) {
+c = mean(a, b)
+d = c + 2
+ChangeMe()
+return (c)
+}
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 28f9d83..4d4aa16 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -48,11 +48,12 @@
git commit "$@" -m "Commit $*" >/dev/null
}
-test_create_repo sm1 &&
-add_file . foo >/dev/null
-
-head1=$(add_file sm1 foo1 foo2)
-fullhead1=$(cd sm1; git rev-parse --verify HEAD)
+test_expect_success 'setup submodule' '
+ git init sm1 &&
+ add_file . foo &&
+ head1=$(add_file sm1 foo1 foo2) &&
+ fullhead1=$(cd sm1 && git rev-parse --verify HEAD)
+'
test_expect_success 'added submodule' '
git add sm1 &&
@@ -235,10 +236,13 @@
test_cmp expected actual
'
-rm -f sm1 &&
-test_create_repo sm1 &&
-head6=$(add_file sm1 foo6 foo7)
-fullhead6=$(cd sm1; git rev-parse --verify HEAD)
+test_expect_success 'setup submodule anew' '
+ rm -f sm1 &&
+ git init sm1 &&
+ head6=$(add_file sm1 foo6 foo7) &&
+ fullhead6=$(cd sm1 && git rev-parse --verify HEAD)
+'
+
test_expect_success 'nonexistent commit' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
diff --git a/t/t4053-diff-no-index.sh b/t/t4053-diff-no-index.sh
index 5e5bad6..01db924 100755
--- a/t/t4053-diff-no-index.sh
+++ b/t/t4053-diff-no-index.sh
@@ -295,4 +295,79 @@
test_cmp expect actual
'
+test_expect_success 'diff --no-index F F rejects pathspecs' '
+ test_must_fail git diff --no-index -- a/1 a/2 a 2>actual.err &&
+ test_grep "usage: git diff --no-index" actual.err
+'
+
+test_expect_success 'diff --no-index D F rejects pathspecs' '
+ test_must_fail git diff --no-index -- a a/2 a 2>actual.err &&
+ test_grep "usage: git diff --no-index" actual.err
+'
+
+test_expect_success 'diff --no-index F D rejects pathspecs' '
+ test_must_fail git diff --no-index -- a/1 b b 2>actual.err &&
+ test_grep "usage: git diff --no-index" actual.err
+'
+
+test_expect_success 'diff --no-index rejects absolute pathspec' '
+ test_must_fail git diff --no-index -- a b $(pwd)/a/1
+'
+
+test_expect_success 'diff --no-index with pathspec' '
+ test_expect_code 1 git diff --name-status --no-index a b 1 >actual &&
+ cat >expect <<-EOF &&
+ D a/1
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'diff --no-index with pathspec no matches' '
+ test_expect_code 0 git diff --name-status --no-index a b missing
+'
+
+test_expect_success 'diff --no-index with negative pathspec' '
+ test_expect_code 1 git diff --name-status --no-index a b ":!2" >actual &&
+ cat >expect <<-EOF &&
+ D a/1
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'setup nested' '
+ mkdir -p c/1/2 &&
+ mkdir -p d/1/2 &&
+ echo 1 >c/1/2/a &&
+ echo 2 >c/1/2/b
+'
+
+test_expect_success 'diff --no-index with pathspec nested negative pathspec' '
+ test_expect_code 0 git diff --no-index c d ":!1"
+'
+
+test_expect_success 'diff --no-index with pathspec nested pathspec' '
+ test_expect_code 1 git diff --name-status --no-index c d 1/2 >actual &&
+ cat >expect <<-EOF &&
+ D c/1/2/a
+ D c/1/2/b
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'diff --no-index with pathspec glob' '
+ test_expect_code 1 git diff --name-status --no-index c d ":(glob)**/a" >actual &&
+ cat >expect <<-EOF &&
+ D c/1/2/a
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'diff --no-index with pathspec glob and exclude' '
+ test_expect_code 1 git diff --name-status --no-index c d ":(glob,exclude)**/a" >actual &&
+ cat >expect <<-EOF &&
+ D c/1/2/b
+ EOF
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh
index 76b8310..dbfeb74 100755
--- a/t/t4060-diff-submodule-option-diff-format.sh
+++ b/t/t4060-diff-submodule-option-diff-format.sh
@@ -363,9 +363,12 @@
diff_cmp expected actual
'
-rm -f sm1 &&
-test_create_repo sm1 &&
-head6=$(add_file sm1 foo6 foo7)
+test_expect_success 'setup' '
+ rm -f sm1 &&
+ git init sm1 &&
+ head6=$(add_file sm1 foo6 foo7)
+'
+
test_expect_success 'nonexistent commit' '
git diff-index -p --submodule=diff HEAD >actual &&
cat >expected <<-EOF &&
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 51f7beb..4a6c4df 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -486,10 +486,16 @@
)
'
-for cmd in show whatchanged reflog format-patch
+cmds="show reflog format-patch"
+if test_have_prereq !WITH_BREAKING_CHANGES
+then
+ cmds="$cmds whatchanged"
+fi
+for cmd in $cmds
do
case "$cmd" in
format-patch) myarg="HEAD~.." ;;
+ whatchanged) myarg=--i-still-use-this ;;
*) myarg= ;;
esac
@@ -1201,20 +1207,27 @@
test_cmp expect actual
'
-test_expect_success 'whatchanged is expected format' '
+test_expect_success !WITH_BREAKING_CHANGES 'whatchanged is expected format' '
+ whatchanged="whatchanged --i-still-use-this" &&
git log --no-merges --raw >expect &&
- git whatchanged >actual &&
+ git $whatchanged >actual &&
test_cmp expect actual
'
test_expect_success 'log.abbrevCommit configuration' '
+ whatchanged="whatchanged --i-still-use-this" &&
+
git log --abbrev-commit >expect.log.abbrev &&
git log --no-abbrev-commit >expect.log.full &&
git log --pretty=raw >expect.log.raw &&
git reflog --abbrev-commit >expect.reflog.abbrev &&
git reflog --no-abbrev-commit >expect.reflog.full &&
- git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
- git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
+
+ if test_have_prereq !WITH_BREAKING_CHANGES
+ then
+ git $whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
+ git $whatchanged --no-abbrev-commit >expect.whatchanged.full
+ fi &&
test_config log.abbrevCommit true &&
@@ -1231,10 +1244,13 @@
git reflog --no-abbrev-commit >actual &&
test_cmp expect.reflog.full actual &&
- git whatchanged >actual &&
- test_cmp expect.whatchanged.abbrev actual &&
- git whatchanged --no-abbrev-commit >actual &&
- test_cmp expect.whatchanged.full actual
+ if test_have_prereq !WITH_BREAKING_CHANGES
+ then
+ git $whatchanged >actual &&
+ test_cmp expect.whatchanged.abbrev actual &&
+ git $whatchanged --no-abbrev-commit >actual &&
+ test_cmp expect.whatchanged.full actual
+ fi
'
test_expect_success '--abbrev-commit with core.abbrev=false' '
diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 4a6242f..74b7ddc 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -1133,4 +1133,37 @@
test_cmp expect actual
'
+test_expect_success 'git cat-file --mailmap works with different author and committer' '
+ test_when_finished "rm .mailmap" &&
+ cat >.mailmap <<-\EOF &&
+ Mailmapped User <mailmapped-user@gitlab.com> C O Mitter <committer@example.com>
+ EOF
+ git commit --allow-empty -m "different author/committer" \
+ --author="Different Author <different@example.com>" &&
+ cat >expect <<-\EOF &&
+ author Different Author <different@example.com>
+ committer Mailmapped User <mailmapped-user@gitlab.com>
+ EOF
+ git cat-file --mailmap commit HEAD >log &&
+ sed -n -e "/^author /s/>.*/>/p" -e "/^committer /s/>.*/>/p" log >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git cat-file --mailmap maps both author and committer when both need mapping' '
+ test_when_finished "rm .mailmap" &&
+ cat >.mailmap <<-\EOF &&
+ Mapped Author <mapped-author@example.com> <different@example.com>
+ Mapped Committer <mapped-committer@example.com> C O Mitter <committer@example.com>
+ EOF
+ git commit --allow-empty -m "both author and committer mapped" \
+ --author="Different Author <different@example.com>" &&
+ cat >expect <<-\EOF &&
+ author Mapped Author <mapped-author@example.com>
+ committer Mapped Committer <mapped-committer@example.com>
+ EOF
+ git cat-file --mailmap commit HEAD >log &&
+ sed -n -e "/^author /s/>.*/>/p" -e "/^committer /s/>.*/>/p" log >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh
index 5174995..027dedd 100755
--- a/t/t5004-archive-corner-cases.sh
+++ b/t/t5004-archive-corner-cases.sh
@@ -176,10 +176,7 @@
blob=$(echo $s | git hash-object -w --stdin) &&
# create tree containing 65500 entries of that blob
- for i in $(test_seq 1 65500)
- do
- echo "100644 blob $blob $i" || return 1
- done >tree &&
+ test_seq -f "100644 blob $blob\t%d" 1 65500 >tree &&
tree=$(git mktree <tree) &&
# zip it, creating an archive a bit bigger than 4GB
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index a5932b6..ae72158 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -723,4 +723,23 @@
! test_grep "currently, --write-bitmap-index requires --name-hash-version=1" err
'
+test_expect_success '--path-walk pack everything' '
+ git -C server rev-parse HEAD >in &&
+ GIT_PROGRESS_DELAY=0 git -C server pack-objects \
+ --stdout --revs --path-walk --progress <in >out.pack 2>err &&
+ grep "Compressing objects by path" err &&
+ git -C server index-pack --stdin <out.pack
+'
+
+test_expect_success '--path-walk thin pack' '
+ cat >in <<-EOF &&
+ $(git -C server rev-parse HEAD)
+ ^$(git -C server rev-parse HEAD~2)
+ EOF
+ GIT_PROGRESS_DELAY=0 git -C server pack-objects \
+ --thin --stdout --revs --path-walk --progress <in >out.pack 2>err &&
+ grep "Compressing objects by path" err &&
+ git -C server index-pack --fix-thin --stdin <out.pack
+'
+
test_done
diff --git a/t/t5306-pack-nobase.sh b/t/t5306-pack-nobase.sh
index 805d60f..609399d 100755
--- a/t/t5306-pack-nobase.sh
+++ b/t/t5306-pack-nobase.sh
@@ -59,6 +59,11 @@
git pull ../.git &&
test $(git rev-parse HEAD) = $B &&
+ # The --path-walk feature of "git pack-objects" is not
+ # compatible with this kind of fetch from an incomplete repo.
+ GIT_TEST_PACK_PATH_WALK=0 &&
+ export GIT_TEST_PACK_PATH_WALK &&
+
git pull ../patch_clone/.git &&
test $(git rev-parse HEAD) = $C
)
diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh
index a62b463..b6926f1 100755
--- a/t/t5310-pack-bitmaps.sh
+++ b/t/t5310-pack-bitmaps.sh
@@ -158,8 +158,9 @@
ls .git/objects/pack/ | grep bitmap >output &&
test_line_count = 1 output &&
# verify equivalent packs are generated with/without using bitmap index
- packasha1=$(git pack-objects --no-use-bitmap-index --all packa </dev/null) &&
- packbsha1=$(git pack-objects --use-bitmap-index --all packb </dev/null) &&
+ # Be careful to not use the path-walk option in either case.
+ packasha1=$(git pack-objects --no-use-bitmap-index --no-path-walk --all packa </dev/null) &&
+ packbsha1=$(git pack-objects --use-bitmap-index --no-path-walk --all packb </dev/null) &&
list_packed_objects packa-$packasha1.idx >packa.objects &&
list_packed_objects packb-$packbsha1.idx >packb.objects &&
test_cmp packa.objects packb.objects
@@ -388,6 +389,14 @@
git init --bare client.git &&
(
cd client.git &&
+
+ # This test relies on reusing a delta, but if the
+ # path-walk machinery is engaged, the base object
+ # is considered too small to use during the
+ # dynamic computation, so is not used.
+ GIT_TEST_PACK_PATH_WALK=0 &&
+ export GIT_TEST_PACK_PATH_WALK &&
+
git config transfer.unpackLimit 1 &&
git fetch .. delta-reuse-old:delta-reuse-old &&
git fetch .. delta-reuse-new:delta-reuse-new &&
diff --git a/t/t5316-pack-delta-depth.sh b/t/t5316-pack-delta-depth.sh
index defaa06d..03dfb7a 100755
--- a/t/t5316-pack-delta-depth.sh
+++ b/t/t5316-pack-delta-depth.sh
@@ -89,15 +89,18 @@
# adjusted (or scrapped if the heuristics have become too unreliable)
test_expect_success 'packing produces a long delta' '
# Use --window=0 to make sure we are seeing reused deltas,
- # not computing a new long chain.
- pack=$(git pack-objects --all --window=0 </dev/null pack) &&
+ # not computing a new long chain. (Also avoid the --path-walk
+ # option as it may break delta chains.)
+ pack=$(git pack-objects --all --window=0 --no-path-walk </dev/null pack) &&
echo 9 >expect &&
max_chain pack-$pack.pack >actual &&
test_cmp expect actual
'
test_expect_success '--depth limits depth' '
- pack=$(git pack-objects --all --depth=5 </dev/null pack) &&
+ # Avoid --path-walk to avoid breaking delta chains across path
+ # boundaries.
+ pack=$(git pack-objects --all --depth=5 --no-path-walk </dev/null pack) &&
echo 5 >expect &&
max_chain pack-$pack.pack >actual &&
test_cmp expect actual
diff --git a/t/t5323-pack-redundant.sh b/t/t5323-pack-redundant.sh
index bc30bc9..2d96afd 100755
--- a/t/t5323-pack-redundant.sh
+++ b/t/t5323-pack-redundant.sh
@@ -45,6 +45,11 @@
main_repo=main.git
shared_repo=shared.git
+test_expect_success 'pack-redundant needs --i-still-use-this' '
+ test_must_fail git pack-redundant >message 2>&1 &&
+ test_grep "nominated for removal" message
+'
+
git_pack_redundant='git pack-redundant --i-still-use-this'
# Create commits in <repo> and assign each commit's oid to shell variables
diff --git a/t/t5332-multi-pack-reuse.sh b/t/t5332-multi-pack-reuse.sh
index 57cad77..395d094 100755
--- a/t/t5332-multi-pack-reuse.sh
+++ b/t/t5332-multi-pack-reuse.sh
@@ -7,6 +7,13 @@
GIT_TEST_MULTI_PACK_INDEX=0
GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL=0
+
+# The --path-walk option does not consider the preferred pack
+# at all for reusing deltas, so this variable changes the
+# behavior of this test, if enabled.
+GIT_TEST_PACK_PATH_WALK=0
+export GIT_TEST_PACK_PATH_WALK
+
objdir=.git/objects
packdir=$objdir/pack
diff --git a/t/t5333-pseudo-merge-bitmaps.sh b/t/t5333-pseudo-merge-bitmaps.sh
index 56674db..ba5ae6a 100755
--- a/t/t5333-pseudo-merge-bitmaps.sh
+++ b/t/t5333-pseudo-merge-bitmaps.sh
@@ -445,4 +445,21 @@
)
'
+test_expect_success 'use pseudo-merge in boundary traversal' '
+ git init pseudo-merge-boundary-traversal &&
+ (
+ cd pseudo-merge-boundary-traversal &&
+
+ git config bitmapPseudoMerge.test.pattern refs/ &&
+ git config pack.useBitmapBoundaryTraversal true &&
+
+ test_commit A &&
+ git repack -adb &&
+ test_commit B &&
+
+ nr=$(git rev-list --count --use-bitmap-index HEAD~1..HEAD) &&
+ test 1 -eq "$nr"
+ )
+'
+
test_done
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index dabcc5f..782f5f9 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1909,4 +1909,14 @@
--thin --delta-base-offset -q --no-use-bitmap-index <false
'
+test_expect_success 'push with config pack.usePathWalk=true' '
+ mk_test testrepo heads/main &&
+ git checkout main &&
+ test_config pack.usePathWalk true &&
+ GIT_TRACE2_EVENT="$(pwd)/path-walk.txt" \
+ git push --quiet testrepo main:test &&
+
+ test_region pack-objects path-walk path-walk.txt
+'
+
test_done
diff --git a/t/t5538-push-shallow.sh b/t/t5538-push-shallow.sh
index e91fcc1..dc0e972 100755
--- a/t/t5538-push-shallow.sh
+++ b/t/t5538-push-shallow.sh
@@ -123,4 +123,45 @@
git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
)
'
+
+test_expect_success 'push new commit from shallow clone has correct object count' '
+ git init origin &&
+ test_commit -C origin a &&
+ test_commit -C origin b &&
+
+ git clone --depth=1 "file://$(pwd)/origin" client &&
+ git -C client checkout -b topic &&
+ git -C client commit --allow-empty -m "empty" &&
+ GIT_PROGRESS_DELAY=0 git -C client push --progress origin topic 2>err &&
+ test_grep "Enumerating objects: 1, done." err
+'
+
+test_expect_success 'push new commit from shallow clone has good deltas' '
+ git init base &&
+ test_seq 1 999 >base/a &&
+ test_commit -C base initial &&
+ git -C base add a &&
+ git -C base commit -m "big a" &&
+
+ git clone --depth=1 "file://$(pwd)/base" deltas &&
+ git -C deltas checkout -b deltas &&
+ test_seq 1 1000 >deltas/a &&
+ git -C deltas commit -a -m "bigger a" &&
+ GIT_PROGRESS_DELAY=0 git -C deltas push --progress origin deltas 2>err &&
+
+ test_grep "Enumerating objects: 5, done" err &&
+
+ # If the delta base is found, then this message uses "bytes".
+ # If the delta base is not found, then this message uses "KiB".
+ test_grep "Writing objects: .* bytes" err &&
+
+ git -C deltas commit --amend -m "changed message" &&
+ GIT_TRACE2_EVENT="$(pwd)/config-push.txt" \
+ GIT_PROGRESS_DELAY=0 git -C deltas -c pack.usePathWalk=true \
+ push --progress -f origin deltas 2>err &&
+
+ test_grep "Enumerating objects: 1, done" err &&
+ test_region pack-objects path-walk config-push.txt
+'
+
test_done
diff --git a/t/t6422-merge-rename-corner-cases.sh b/t/t6422-merge-rename-corner-cases.sh
index 9cbe7ca..f14c0fb 100755
--- a/t/t6422-merge-rename-corner-cases.sh
+++ b/t/t6422-merge-rename-corner-cases.sh
@@ -1146,10 +1146,7 @@
cd simple_${sideL}_${sideR} &&
# Create some related files now
- for i in $(test_seq 1 10)
- do
- echo Random base content line $i
- done >file_v1 &&
+ test_seq -f "Random base content line %d" 1 10 >file_v1 &&
cp file_v1 file_v2 &&
echo modification >>file_v2 &&
@@ -1293,10 +1290,7 @@
cd nested_conflicts_from_rename_rename &&
# Create some related files now
- for i in $(test_seq 1 10)
- do
- echo Random base content line $i
- done >file_v1 &&
+ test_seq -f "Random base content line %d" 1 10 >file_v1 &&
cp file_v1 file_v2 &&
cp file_v1 file_v3 &&
diff --git a/t/t6601-path-walk.sh b/t/t6601-path-walk.sh
index 8d187f7..56bd1e3 100755
--- a/t/t6601-path-walk.sh
+++ b/t/t6601-path-walk.sh
@@ -376,6 +376,26 @@
test_cmp_sorted expect out
'
+test_expect_success 'topic, not base, --edge-aggressive with pruning' '
+ test-tool path-walk --prune --edge-aggressive -- topic --not base >out &&
+
+ cat >expect <<-EOF &&
+ 0:commit::$(git rev-parse topic)
+ 1:tree::$(git rev-parse topic^{tree})
+ 1:tree::$(git rev-parse base^{tree}):UNINTERESTING
+ 2:tree:right/:$(git rev-parse topic:right)
+ 2:tree:right/:$(git rev-parse base:right):UNINTERESTING
+ 3:blob:right/c:$(git rev-parse base:right/c):UNINTERESTING
+ 3:blob:right/c:$(git rev-parse topic:right/c)
+ blobs:2
+ commits:1
+ tags:0
+ trees:4
+ EOF
+
+ test_cmp_sorted expect out
+'
+
test_expect_success 'trees are reported exactly once' '
test_when_finished "rm -rf unique-trees" &&
test_create_repo unique-trees &&
diff --git a/t/t7007-show.sh b/t/t7007-show.sh
index d6cc69e..2d322b5 100755
--- a/t/t7007-show.sh
+++ b/t/t7007-show.sh
@@ -167,4 +167,28 @@
test_must_fail git show --graph HEAD
'
+test_expect_success 'show unmerged index' '
+ git reset --hard &&
+
+ git switch -C base &&
+ echo "base" >conflicting &&
+ git add conflicting &&
+ git commit -m "base" &&
+
+ git branch hello &&
+ git branch goodbye &&
+
+ git switch hello &&
+ echo "hello" >conflicting &&
+ git commit -am "hello" &&
+
+ git switch goodbye &&
+ echo "goodbye" >conflicting &&
+ git commit -am "goodbye" &&
+
+ git switch hello &&
+ test_must_fail git merge goodbye &&
+ git show --merge HEAD
+'
+
test_done
diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
index 9c3cc4c..66c3ec2 100755
--- a/t/t7401-submodule-summary.sh
+++ b/t/t7401-submodule-summary.sh
@@ -38,10 +38,11 @@
git commit "$@" -m "Commit $*" >/dev/null
}
-test_create_repo sm1 &&
-add_file . foo >/dev/null
-
-head1=$(add_file sm1 foo1 foo2)
+test_expect_success 'setup submodule' '
+ git init sm1 &&
+ add_file . foo &&
+ head1=$(add_file sm1 foo1 foo2)
+'
test_expect_success 'added submodule' "
git add sm1 &&
@@ -214,9 +215,12 @@
test_cmp expected actual
"
-rm -f sm1 &&
-test_create_repo sm1 &&
-head6=$(add_file sm1 foo6 foo7)
+test_expect_success 'setup submodule' '
+ rm -f sm1 &&
+ git init sm1 &&
+ head6=$(add_file sm1 foo6 foo7)
+'
+
test_expect_success 'nonexistent commit' "
git submodule summary >actual &&
cat >expected <<-EOF &&
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index c562bad..ab76d4b 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -1095,12 +1095,15 @@
(cd super5 &&
# This test var can mess with the stderr output checked in this test.
GIT_TEST_NAME_HASH_VERSION=1 \
+ GIT_TEST_PACK_PATH_WALK=0 \
git submodule update --quiet --init --depth=1 submodule3 >out 2>err &&
test_must_be_empty out &&
test_must_be_empty err
) &&
git clone super4 super6 &&
(cd super6 &&
+ # This test variable will create a "warning" message to stderr
+ GIT_TEST_PACK_PATH_WALK=0 \
git submodule update --init --depth=1 submodule3 >out 2>err &&
test_file_not_empty out &&
test_file_not_empty err
diff --git a/t/t7422-submodule-output.sh b/t/t7422-submodule-output.sh
index 023a5cb..aea1ddf 100755
--- a/t/t7422-submodule-output.sh
+++ b/t/t7422-submodule-output.sh
@@ -180,17 +180,14 @@
COMMIT=$(git rev-parse HEAD) &&
for i in $(test_seq 2000)
do
- printf "[submodule \"sm-$i\"]\npath = recursive-submodule-path-$i\n" "$i" ||
+ echo "[submodule \"sm-$i\"]" &&
+ echo "path = recursive-submodule-path-$i" ||
return 1
done >gitmodules &&
BLOB=$(git hash-object -w --stdin <gitmodules) &&
printf "100644 blob $BLOB\t.gitmodules\n" >tree &&
- for i in $(test_seq 2000)
- do
- printf "160000 commit $COMMIT\trecursive-submodule-path-%d\n" "$i" ||
- return 1
- done >>tree &&
+ test_seq -f "160000 commit $COMMIT\trecursive-submodule-path-%d" 2000 >>tree &&
TREE=$(git mktree <tree) &&
COMMIT=$(git commit-tree "$TREE") &&
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 2a8df29..9838094 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -185,8 +185,19 @@
test_expect_success 'merge c0 with c1' '
echo "OBJID HEAD@{0}: merge c1: Fast-forward" >reflog.expected &&
+ cat >expect <<-\EOF &&
+ Updating FROM..TO
+ Fast-forward
+ file | 2 +-
+ other | 9 +++++++++
+ 2 files changed, 10 insertions(+), 1 deletion(-)
+ create mode 100644 other
+ EOF
+
git reset --hard c0 &&
- git merge c1 &&
+ git merge c1 >out &&
+ sed -e "1s/^Updating [0-9a-f.]*/Updating FROM..TO/" out >actual &&
+ test_cmp expect actual &&
verify_merge file result.1 &&
verify_head "$c1" &&
@@ -205,6 +216,67 @@
verify_head "$c1"
'
+test_expect_success 'the same merge with merge.stat=diffstat' '
+ cat >expect <<-\EOF &&
+ Updating FROM..TO
+ Fast-forward
+ file | 2 +-
+ other | 9 +++++++++
+ 2 files changed, 10 insertions(+), 1 deletion(-)
+ create mode 100644 other
+ EOF
+
+ git reset --hard c0 &&
+ git -c merge.stat=diffstat merge c1 >out &&
+ sed -e "1s/^Updating [0-9a-f.]*/Updating FROM..TO/" out >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'the same merge with compact summary' '
+ cat >expect <<-\EOF &&
+ Updating FROM..TO
+ Fast-forward
+ file | 2 +-
+ other (new) | 9 +++++++++
+ 2 files changed, 10 insertions(+), 1 deletion(-)
+ EOF
+
+ git reset --hard c0 &&
+ git merge --compact-summary c1 >out &&
+ sed -e "1s/^Updating [0-9a-f.]*/Updating FROM..TO/" out >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'the same merge with compact summary' '
+ cat >expect <<-\EOF &&
+ Updating FROM..TO
+ Fast-forward
+ file | 2 +-
+ other (new) | 9 +++++++++
+ 2 files changed, 10 insertions(+), 1 deletion(-)
+ EOF
+
+ git reset --hard c0 &&
+ git merge --compact-summary c1 >out &&
+ sed -e "1s/^Updating [0-9a-f.]*/Updating FROM..TO/" out >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'the same merge with merge.stat=compact' '
+ cat >expect <<-\EOF &&
+ Updating FROM..TO
+ Fast-forward
+ file | 2 +-
+ other (new) | 9 +++++++++
+ 2 files changed, 10 insertions(+), 1 deletion(-)
+ EOF
+
+ git reset --hard c0 &&
+ git -c merge.stat=compact merge c1 >out &&
+ sed -e "1s/^Updating [0-9a-f.]*/Updating FROM..TO/" out >actual &&
+ test_cmp expect actual
+'
+
test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge from unborn branch' '
diff --git a/t/t7815-grep-binary.sh b/t/t7815-grep-binary.sh
index b7d83f9..55d5e6d 100755
--- a/t/t7815-grep-binary.sh
+++ b/t/t7815-grep-binary.sh
@@ -63,7 +63,7 @@
git grep ile a
'
-test_expect_failure !CYGWIN 'git grep .fi a' '
+test_expect_failure !CYGWIN,!MACOS 'git grep .fi a' '
git grep .fi a
'
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index 8cf89e2..ddd273d 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -49,9 +49,9 @@
git maintenance run --auto 2>/dev/null &&
GIT_TRACE2_EVENT="$(pwd)/run-no-quiet.txt" \
git maintenance run --no-quiet 2>/dev/null &&
- test_subcommand git gc --quiet --no-detach <run-no-auto.txt &&
- test_subcommand ! git gc --auto --quiet --no-detach <run-auto.txt &&
- test_subcommand git gc --no-quiet --no-detach <run-no-quiet.txt
+ test_subcommand git gc --quiet --no-detach --skip-foreground-tasks <run-no-auto.txt &&
+ test_subcommand ! git gc --auto --quiet --no-detach --skip-foreground-tasks <run-auto.txt &&
+ test_subcommand git gc --no-quiet --no-detach --skip-foreground-tasks <run-no-quiet.txt
'
test_expect_success 'maintenance.auto config option' '
@@ -154,9 +154,9 @@
git maintenance run --task=commit-graph 2>/dev/null &&
GIT_TRACE2_EVENT="$(pwd)/run-both.txt" \
git maintenance run --task=commit-graph --task=gc 2>/dev/null &&
- test_subcommand ! git gc --quiet --no-detach <run-commit-graph.txt &&
- test_subcommand git gc --quiet --no-detach <run-gc.txt &&
- test_subcommand git gc --quiet --no-detach <run-both.txt &&
+ test_subcommand ! git gc --quiet --no-detach --skip-foreground-tasks <run-commit-graph.txt &&
+ test_subcommand git gc --quiet --no-detach --skip-foreground-tasks <run-gc.txt &&
+ test_subcommand git gc --quiet --no-detach --skip-foreground-tasks <run-both.txt &&
test_subcommand git commit-graph write --split --reachable --no-progress <run-commit-graph.txt &&
test_subcommand ! git commit-graph write --split --reachable --no-progress <run-gc.txt &&
test_subcommand git commit-graph write --split --reachable --no-progress <run-both.txt
@@ -610,7 +610,12 @@
test_expect_success '--auto and --schedule incompatible' '
test_must_fail git maintenance run --auto --schedule=daily 2>err &&
- test_grep "at most one" err
+ test_grep "cannot be used together" err
+'
+
+test_expect_success '--task and --schedule incompatible' '
+ test_must_fail git maintenance run --task=pack-refs --schedule=daily 2>err &&
+ test_grep "cannot be used together" err
'
test_expect_success 'invalid --schedule value' '
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index b258dbf..4dc3d64 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -120,7 +120,7 @@
INPUT_END
git fast-import --export-marks=marks.out <input &&
- git whatchanged main
+ git log --raw main
'
test_expect_success 'A: verify pack' '
@@ -279,7 +279,7 @@
INPUT_END
git fast-import --import-marks=marks.out <input &&
- git whatchanged verify--import-marks
+ git log --raw verify--import-marks
'
test_expect_success 'A: verify pack' '
@@ -652,7 +652,7 @@
INPUT_END
git fast-import <input &&
- git whatchanged branch
+ git log --raw branch
'
test_expect_success 'C: verify pack' '
@@ -715,7 +715,7 @@
INPUT_END
git fast-import <input &&
- git whatchanged branch
+ git log --raw branch
'
test_expect_success 'D: verify pack' '
@@ -882,7 +882,7 @@
INPUT_END
git fast-import <input &&
- git whatchanged H
+ git log --raw H
'
test_expect_success 'H: verify pack' '
@@ -2066,7 +2066,7 @@
INPUT_END
git fast-import <input &&
- git whatchanged notes-test
+ git log --raw notes-test
'
test_expect_success 'Q: verify pack' '
diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh
index 1ae4d7c..e62173c 100755
--- a/t/t9301-fast-import-notes.sh
+++ b/t/t9301-fast-import-notes.sh
@@ -76,7 +76,7 @@
test_expect_success 'set up main branch' '
git fast-import <input &&
- git whatchanged main
+ git log --raw main
'
commit4=$(git rev-parse refs/heads/main)
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index 7679780..578d6c8 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -700,19 +700,17 @@
# ----------------------------------------------------------------------
# syntax highlighting
+test_lazy_prereq HIGHLIGHT '
+ highlight_version=$(highlight --version </dev/null 2>/dev/null) &&
+ test -n "$highlight_version"
+'
-highlight_version=$(highlight --version </dev/null 2>/dev/null)
-if [ $? -eq 127 ]; then
- say "Skipping syntax highlighting tests: 'highlight' not found"
-elif test -z "$highlight_version"; then
- say "Skipping syntax highlighting tests: incorrect 'highlight' found"
-else
- test_set_prereq HIGHLIGHT
+test_expect_success HIGHLIGHT '
cat >>gitweb_config.perl <<-\EOF
our $highlight_bin = "highlight";
- $feature{'highlight'}{'override'} = 1;
+ $feature{"highlight"}{"override"} = 1;
EOF
-fi
+'
test_expect_success HIGHLIGHT \
'syntax highlighting (no highlight, unknown syntax)' \
diff --git a/t/t9822-git-p4-path-encoding.sh b/t/t9822-git-p4-path-encoding.sh
index 572d395..e6e07fa 100755
--- a/t/t9822-git-p4-path-encoding.sh
+++ b/t/t9822-git-p4-path-encoding.sh
@@ -7,12 +7,17 @@
UTF8_ESCAPED="a-\303\244_o-\303\266_u-\303\274.txt"
ISO8859_ESCAPED="a-\344_o-\366_u-\374.txt"
-ISO8859="$(printf "$ISO8859_ESCAPED")" &&
-echo content123 >"$ISO8859" &&
-rm "$ISO8859" || {
+test_lazy_prereq FS_ACCEPTS_ISO_8859_1 '
+ ISO8859="$(printf "$ISO8859_ESCAPED")" &&
+ echo content123 >"$ISO8859" &&
+ rm "$ISO8859"
+'
+
+if ! test_have_prereq FS_ACCEPTS_ISO_8859_1
+then
skip_all="fs does not accept ISO-8859-1 filenames"
test_done
-}
+fi
test_expect_success 'start p4d' '
start_p4d
diff --git a/t/t9835-git-p4-metadata-encoding-python2.sh b/t/t9835-git-p4-metadata-encoding-python2.sh
index 6116f80..b969c7e 100755
--- a/t/t9835-git-p4-metadata-encoding-python2.sh
+++ b/t/t9835-git-p4-metadata-encoding-python2.sh
@@ -12,23 +12,25 @@
## SECTION REPEATED IN t9836 ##
###############################
+EXTRA_PATH="$(pwd)/temp_python"
+mkdir "$EXTRA_PATH"
+PATH="$EXTRA_PATH:$PATH"
+export PATH
+
# These tests are specific to Python 2. Write a custom script that executes
# git-p4 directly with the Python 2 interpreter to ensure that we use that
# version even if Git was compiled with Python 3.
-python_target_binary=$(which python2)
-if test -n "$python_target_binary"
-then
- mkdir temp_python
- PATH="$(pwd)/temp_python:$PATH"
- export PATH
-
- write_script temp_python/git-p4-python2 <<-EOF
+test_lazy_prereq P4_PYTHON2 '
+ python_target_binary=$(which python2) &&
+ test -n "$python_target_binary" &&
+ write_script "$EXTRA_PATH"/git-p4-python2 <<-EOF &&
exec "$python_target_binary" "$(git --exec-path)/git-p4" "\$@"
EOF
-fi
+ ( git p4-python2 || true ) >err &&
+ test_grep "valid commands" err
+'
-git p4-python2 >err
-if ! grep 'valid commands' err
+if ! test_have_prereq P4_PYTHON2
then
skip_all="skipping python2 git p4 tests; python2 not available"
test_done
diff --git a/t/t9836-git-p4-metadata-encoding-python3.sh b/t/t9836-git-p4-metadata-encoding-python3.sh
index 5e5217a..da6669b 100755
--- a/t/t9836-git-p4-metadata-encoding-python3.sh
+++ b/t/t9836-git-p4-metadata-encoding-python3.sh
@@ -12,23 +12,25 @@
## SECTION REPEATED IN t9835 ##
###############################
+EXTRA_PATH="$(pwd)/temp_python"
+mkdir "$EXTRA_PATH"
+PATH="$EXTRA_PATH:$PATH"
+export PATH
+
# These tests are specific to Python 3. Write a custom script that executes
# git-p4 directly with the Python 3 interpreter to ensure that we use that
# version even if Git was compiled with Python 2.
-python_target_binary=$(which python3)
-if test -n "$python_target_binary"
-then
- mkdir temp_python
- PATH="$(pwd)/temp_python:$PATH"
- export PATH
-
- write_script temp_python/git-p4-python3 <<-EOF
+test_lazy_prereq P4_PYTHON3 '
+ python_target_binary=$(which python3) &&
+ test -n "$python_target_binary" &&
+ write_script "$EXTRA_PATH"/git-p4-python3 <<-EOF &&
exec "$python_target_binary" "$(git --exec-path)/git-p4" "\$@"
EOF
-fi
+ ( git p4-python3 || true ) >err &&
+ test_grep "valid commands" err
+'
-git p4-python3 >err
-if ! grep 'valid commands' err
+if ! test_have_prereq P4_PYTHON3
then
skip_all="skipping python3 git p4 tests; python3 not available"
test_done
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index d667dda..637a6f1 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -66,10 +66,6 @@
test_cmp expected "$actual"
'
-if test_have_prereq !FUNNYNAMES; then
- say 'Your filesystem does not allow newlines in filenames.'
-fi
-
test_expect_success FUNNYNAMES 'prompt - with newline in path' '
repo_with_newline="repo
with
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index bee4a2c..6230746 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1451,9 +1451,21 @@
# test_seq 1 5 -- outputs 1 2 3 4 5 one line at a time
#
# or with one argument (end), in which case it starts counting
-# from 1.
+# from 1. In addition to the start/end arguments, you can pass an optional
+# printf format. For example:
+#
+# test_seq -f "line %d" 1 5
+#
+# would print 5 lines, "line 1" through "line 5".
test_seq () {
+ local fmt="%d"
+ case "$1" in
+ -f)
+ fmt="$2"
+ shift 2
+ ;;
+ esac
case $# in
1) set 1 "$@" ;;
2) ;;
@@ -1462,7 +1474,7 @@
test_seq_counter__=$1
while test "$test_seq_counter__" -le "$2"
do
- echo "$test_seq_counter__"
+ printf "$fmt\n" "$test_seq_counter__"
test_seq_counter__=$(( $test_seq_counter__ + 1 ))
done
}
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 92d0db1..51370a2 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -470,7 +470,7 @@
then
: Executed by a Bash version supporting BASH_XTRACEFD. Good.
else
- echo >&2 "warning: ignoring -x; '$0' is untraceable without BASH_XTRACEFD"
+ echo >&2 "# warning: ignoring -x; '$0' is untraceable without BASH_XTRACEFD"
trace=
fi
fi
@@ -707,7 +707,7 @@
exec 3>>"$GIT_TEST_TEE_OUTPUT_FILE" 4>&3
elif test "$verbose" = "t"
then
- exec 4>&2 3>&1
+ exec 4>&2 3>&2
else
exec 4>/dev/null 3>/dev/null
fi
@@ -949,7 +949,7 @@
test -z "$verbose_only" && return
if match_pattern_list $test_count "$verbose_only"
then
- exec 4>&2 3>&1
+ exec 4>&2 3>&2
# Emit a delimiting blank line when going from
# non-verbose to verbose. Within verbose mode the
# delimiter is printed by test_expect_*. The choice
@@ -1272,7 +1272,14 @@
check_test_results_san_file_ "$test_failure"
- if test -z "$skip_all" && test -n "$invert_exit_code"
+ if test "$test_fixed" != 0
+ then
+ if test -z "$invert_exit_code"
+ then
+ GIT_EXIT_OK=t
+ exit 1
+ fi
+ elif test -z "$skip_all" && test -n "$invert_exit_code"
then
say_color warn "# faking up non-zero exit with --invert-exit-code"
GIT_EXIT_OK=t
@@ -1638,6 +1645,12 @@
# Fix some commands on Windows, and other OS-specific things
uname_s=$(uname -s)
case $uname_s in
+Darwin)
+ test_set_prereq MACOS
+ test_set_prereq POSIXPERM
+ test_set_prereq BSLASHPSPEC
+ test_set_prereq EXECKEEPSPID
+ ;;
*MINGW*)
# Windows has its own (incompatible) sort and find
sort () {
diff --git a/usage.c b/usage.c
index 38b46bb..8191323 100644
--- a/usage.c
+++ b/usage.c
@@ -67,6 +67,8 @@ static NORETURN void usage_builtin(const char *err, va_list params)
static void die_message_builtin(const char *err, va_list params)
{
+ if (!err)
+ return;
trace2_cmd_error_va(err, params);
vreportf(_("fatal: "), err, params);
}
@@ -372,3 +374,15 @@ void bug_fl(const char *file, int line, const char *fmt, ...)
trace2_cmd_error_va(fmt, ap);
va_end(ap);
}
+
+NORETURN void you_still_use_that(const char *command_name)
+{
+ fprintf(stderr,
+ _("'%s' is nominated for removal.\n"
+ "If you still use this command, please add an extra\n"
+ "option, '--i-still-use-this', on the command line\n"
+ "and let us know you still use it by sending an e-mail\n"
+ "to <git@vger.kernel.org>. Thanks.\n"),
+ command_name);
+ die(_("refusing to run without --i-still-use-this"));
+}
diff --git a/userdiff.c b/userdiff.c
index 05776cc..fe710a6 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -327,6 +327,10 @@ PATTERNS("python",
"|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?"
"|[-+*/<>%&^|=!]=|//=?|<<=?|>>=?|\\*\\*=?"),
/* -- */
+PATTERNS("r",
+ "^[ \t]*([a-zA-z][a-zA-Z0-9_.]*[ \t]*(<-|=)[ \t]*function.*)$",
+ /* -- */
+ "[^ \t]+"),
PATTERNS("ruby",
"^[ \t]*((class|module|def)[ \t].*)$",
/* -- */