aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/main.yml2
-rw-r--r--.gitlab-ci.yml1
-rw-r--r--Documentation/MyFirstContribution.adoc55
-rw-r--r--Documentation/RelNotes/2.50.0.adoc51
-rw-r--r--Documentation/config/commit.adoc7
-rw-r--r--Documentation/fsck-msgids.adoc6
-rw-r--r--Documentation/git-cat-file.adoc6
-rw-r--r--Documentation/git-daemon.adoc181
-rw-r--r--Documentation/git-merge-tree.adoc6
-rw-r--r--Documentation/git-multi-pack-index.adoc11
-rw-r--r--Documentation/git-notes.adoc54
-rw-r--r--Documentation/git-receive-pack.adoc12
-rw-r--r--Documentation/git-stripspace.adoc3
-rw-r--r--Documentation/git-var.adoc46
-rw-r--r--Documentation/git-verify-commit.adoc16
-rw-r--r--Documentation/git-verify-pack.adoc28
-rw-r--r--Documentation/git-verify-tag.adoc16
-rw-r--r--Documentation/git-write-tree.adoc18
-rw-r--r--Documentation/scalar.adoc31
-rwxr-xr-xGIT-VERSION-GEN2
-rw-r--r--Makefile1
-rw-r--r--apply.c2
-rw-r--r--builtin/add.c7
-rw-r--r--builtin/apply.c7
-rw-r--r--builtin/cat-file.c31
-rw-r--r--builtin/commit.c2
-rw-r--r--builtin/fetch.c3
-rw-r--r--builtin/fsck.c13
-rw-r--r--builtin/hash-object.c69
-rw-r--r--builtin/merge-tree.c18
-rw-r--r--builtin/receive-pack.c40
-rw-r--r--builtin/replay.c65
-rw-r--r--builtin/reset.c6
-rw-r--r--bundle-uri.c12
-rw-r--r--commit-graph.c150
-rw-r--r--configure.ac25
-rw-r--r--fsck.h1
-rw-r--r--git-compat-util.h16
-rwxr-xr-xgit-cvsserver.perl27
-rw-r--r--git-gui/.gitattributes1
-rw-r--r--git-gui/.gitignore2
-rw-r--r--git-gui/GIT-GUI-BUILD-OPTIONS.in7
-rwxr-xr-xgit-gui/GIT-VERSION-GEN44
-rw-r--r--git-gui/Makefile115
-rwxr-xr-xgit-gui/generate-git-gui.sh29
-rwxr-xr-xgit-gui/generate-macos-app.sh30
-rwxr-xr-xgit-gui/generate-macos-wrapper.sh35
-rwxr-xr-xgit-gui/generate-tclindex.sh32
-rw-r--r--git-gui/lib/meson.build74
-rw-r--r--git-gui/meson.build148
-rw-r--r--git-gui/po/meson.build38
-rwxr-xr-xgit-send-email.perl16
-rw-r--r--gitk-git/Makefile2
-rwxr-xr-xgitk-git/gitk10
-rw-r--r--help.c2
-rw-r--r--json-writer.c4
-rw-r--r--json-writer.h171
-rw-r--r--mailinfo.c42
-rw-r--r--merge-ort.c38
-rw-r--r--merge-ort.h1
-rw-r--r--meson.build44
-rw-r--r--meson_options.txt8
-rw-r--r--midx-write.c22
-rw-r--r--name-hash.c6
-rw-r--r--object-file.c142
-rw-r--r--object-file.h17
-rw-r--r--object-store.c17
-rw-r--r--object-store.h3
-rw-r--r--pack-bitmap.c8
-rw-r--r--packfile.c7
-rw-r--r--perl/Git/SVN/Memoize/meson.build2
-rw-r--r--read-cache.c55
-rw-r--r--refs/packed-backend.c73
-rw-r--r--reftable/basics.h4
-rw-r--r--scalar.c65
-rw-r--r--sequencer.c33
-rw-r--r--streaming.c2
-rw-r--r--t/helper/meson.build1
-rw-r--r--t/helper/test-tool.c1
-rw-r--r--t/helper/test-tool.h1
-rw-r--r--t/helper/test-zlib.c62
-rw-r--r--t/lib-loose.sh30
-rw-r--r--t/meson.build2
-rwxr-xr-xt/perf/p2000-sparse-operations.sh3
-rwxr-xr-xt/perf/p5313-pack-objects.sh3
-rwxr-xr-xt/perf/p5314-name-hash.sh3
-rwxr-xr-xt/t0602-reffiles-fsck.sh17
-rwxr-xr-xt/t1006-cat-file.sh216
-rwxr-xr-xt/t1007-hash-object.sh11
-rwxr-xr-xt/t1092-sparse-checkout-compatibility.sh151
-rwxr-xr-xt/t1450-fsck.sh32
-rwxr-xr-xt/t1512-rev-parse-disambiguation.sh5
-rwxr-xr-xt/t3404-rebase-interactive.sh54
-rwxr-xr-xt/t3415-rebase-autosquash.sh14
-rwxr-xr-xt/t3430-rebase-merges.sh10
-rw-r--r--t/t4018/bash-bashism-style-complete-line-capture4
-rw-r--r--t/t4018/bash-posix-style-complete-line-capture4
-rw-r--r--t/t4018/bash-posix-style-single-command-function3
-rwxr-xr-xt/t4034-diff-words.sh1
-rw-r--r--t/t4034/bash/expect36
-rw-r--r--t/t4034/bash/post31
-rw-r--r--t/t4034/bash/pre31
-rwxr-xr-xt/t4129-apply-samemode.sh231
-rwxr-xr-xt/t4301-merge-tree-write-tree.sh38
-rwxr-xr-xt/t5410-receive-pack-alternates.sh44
-rwxr-xr-xt/t5410-receive-pack.sh87
-rwxr-xr-xt/t5520-pull.sh2
-rwxr-xr-xt/t6601-path-walk.sh2
-rwxr-xr-xt/t7512-status-help.sh86
-rwxr-xr-xt/t9210-scalar.sh26
-rwxr-xr-xt/t9211-scalar-clone.sh11
-rw-r--r--trace2/tr2_tmr.c24
-rw-r--r--transport-helper.c2
-rw-r--r--upload-pack.c34
-rw-r--r--userdiff.c26
115 files changed, 2453 insertions, 1282 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 49bcd0a2a9..7dbf9f7f12 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -265,7 +265,7 @@ jobs:
run: pip install meson ninja
- name: Setup
shell: pwsh
- run: meson setup build --vsenv -Dperl=disabled -Dcredential_helpers=wincred
+ run: meson setup build --vsenv -Dbuildtype=release -Dperl=disabled -Dcredential_helpers=wincred
- name: Compile
shell: pwsh
run: meson compile -C build
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4798b28374..bb6d5b976c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -173,7 +173,6 @@ build:msvc-meson:
test:msvc-meson:
extends: .msvc-meson
stage: test
- when: manual
timeout: 6h
needs:
- job: "build:msvc-meson"
diff --git a/Documentation/MyFirstContribution.adoc b/Documentation/MyFirstContribution.adoc
index ca1d688c9b..aca7212cfe 100644
--- a/Documentation/MyFirstContribution.adoc
+++ b/Documentation/MyFirstContribution.adoc
@@ -40,14 +40,6 @@ the list by sending an email to <git+subscribe@vger.kernel.org>
The https://lore.kernel.org/git[archive] of this mailing list is
available to view in a browser.
-==== https://groups.google.com/forum/#!forum/git-mentoring[git-mentoring@googlegroups.com]
-
-This mailing list is targeted to new contributors and was created as a place to
-post questions and receive answers outside of the public eye of the main list.
-Veteran contributors who are especially interested in helping mentor newcomers
-are present on the list. In order to avoid search indexers, group membership is
-required to view messages; anyone can join and no approval is required.
-
==== https://web.libera.chat/#git-devel[#git-devel] on Libera Chat
This IRC channel is for conversations between Git contributors. If someone is
@@ -150,15 +142,31 @@ command in `builtin/psuh.c`. Create that file, and within it, write the entry
point for your command in a function matching the style and signature:
----
-int cmd_psuh(int argc, const char **argv, const char *prefix)
+int cmd_psuh(int argc UNUSED, const char **argv UNUSED,
+ const char *prefix UNUSED, struct repository *repo UNUSED)
----
+A few things to note:
+
+* A subcommand implementation takes its command line arguments
+ in `int argc` + `const char **argv`, like `main()` would.
+
+* It also takes two extra parameters, `prefix` and `repo`. What
+ they mean will not be discussed until much later.
+
+* Because this first example will not use any of the parameters,
+ your compiler will give warnings on unused parameters. As the
+ list of these four parameters is mandated by the API to add
+ new built-in commands, you cannot omit them. Instead, you add
+ `UNUSED` to each of them to tell the compiler that you *know*
+ you are not (yet) using it.
+
We'll also need to add the declaration of psuh; open up `builtin.h`, find the
declaration for `cmd_pull`, and add a new line for `psuh` immediately before it,
in order to keep the declarations alphabetically sorted:
----
-int cmd_psuh(int argc, const char **argv, const char *prefix);
+int cmd_psuh(int argc, const char **argv, const char *prefix, struct repository *repo);
----
Be sure to `#include "builtin.h"` in your `psuh.c`. You'll also need to
@@ -174,7 +182,8 @@ Throughout the tutorial, we will mark strings for translation as necessary; you
should also do so when writing your user-facing commands in the future.
----
-int cmd_psuh(int argc, const char **argv, const char *prefix)
+int cmd_psuh(int argc UNUSED, const char **argv UNUSED,
+ const char *prefix UNUSED, struct repository *repo UNUSED)
{
printf(_("Pony saying hello goes here.\n"));
return 0;
@@ -287,8 +296,9 @@ on the reference implementation linked at the top of this document.
It's probably useful to do at least something besides printing out a string.
Let's start by having a look at everything we get.
-Modify your `cmd_psuh` implementation to dump the args you're passed, keeping
-existing `printf()` calls in place:
+Modify your `cmd_psuh` implementation to dump the args you're passed,
+keeping existing `printf()` calls in place; because the args are now
+used, remove the `UNUSED` macro from them:
----
int i;
@@ -312,7 +322,8 @@ on the command line, including the name of our command. (If `prefix` is empty
for you, try `cd Documentation/ && ../bin-wrappers/git psuh`). That's not so
helpful. So what other context can we get?
-Add a line to `#include "config.h"`. Then, add the following bits to the
+Add a line to `#include "config.h"` and `#include "repository.h"`.
+Then, add the following bits to the function body:
function body:
----
@@ -320,18 +331,18 @@ function body:
...
- git_config(git_default_config, NULL);
- if (git_config_get_string_tmp("user.name", &cfg_name) > 0)
+ repo_config(repo, git_default_config, NULL);
+ if (repo_config_get_string_tmp(repo, "user.name", &cfg_name))
printf(_("No name is found in config\n"));
else
printf(_("Your name: %s\n"), cfg_name);
----
-`git_config()` will grab the configuration from config files known to Git and
-apply standard precedence rules. `git_config_get_string_tmp()` will look up
+`repo_config()` will grab the configuration from config files known to Git and
+apply standard precedence rules. `repo_config_get_string_tmp()` will look up
a specific key ("user.name") and give you the value. There are a number of
single-key lookup functions like this one; you can see them all (and more info
-about how to use `git_config()`) in `Documentation/technical/api-config.adoc`.
+about how to use `repo_config()`) in `Documentation/technical/api-config.adoc`.
You should see that the name printed matches the one you see when you run:
@@ -364,7 +375,7 @@ status_init_config(&s, git_status_config);
----
But as we drill down, we can find that `status_init_config()` wraps a call
-to `git_config()`. Let's modify the code we wrote in the previous commit.
+to `repo_config()`. Let's modify the code we wrote in the previous commit.
Be sure to include the header to allow you to use `struct wt_status`:
@@ -380,8 +391,8 @@ prepare it, and print its contents:
...
- wt_status_prepare(the_repository, &status);
- git_config(git_default_config, &status);
+ wt_status_prepare(repo, &status);
+ repo_config(repo, git_default_config, &status);
...
diff --git a/Documentation/RelNotes/2.50.0.adoc b/Documentation/RelNotes/2.50.0.adoc
index bf73de114e..c6c34d1a1d 100644
--- a/Documentation/RelNotes/2.50.0.adoc
+++ b/Documentation/RelNotes/2.50.0.adoc
@@ -72,6 +72,23 @@ UI, Workflows & Features
* The `send-email` documentation has been updated with OAuth2.0
related examples.
+ * Two of the "scalar" subcommands that add a repository that hasn't
+ been under "scalar"'s control are taught an option not to enable the
+ scheduled maintenance on it.
+
+ * The userdiff pattern for shell scripts has been updated to cope
+ with more bash-isms.
+
+ * "git merge-tree" learned an option to see if it resolves cleanly
+ without actually creating a result.
+
+ * The commit title in the "rebase -i" todo file are now prefixed with
+ '#', just like a merge commit being replayed.
+
+ * "git receive-pack" optionally learns not to care about connectivity
+ check, which can be useful when the repository arranges to ensure
+ connectivity by some other means.
+
Performance, Internal Implementation, Development Support etc.
--------------------------------------------------------------
@@ -157,6 +174,25 @@ Performance, Internal Implementation, Development Support etc.
* Build performance fix.
+ * Teach "git send-email" to also consult `hostname -f` for mail
+ domain to compute the identity given to SMTP servers.
+
+ * The dependency on the_repository variable has been reduced from the
+ code paths in "git replay".
+
+ * Support to create a loose object file with unknown object type has
+ been dropped.
+
+ * The code path to access the "packed-refs" file while "fsck" is
+ taught to mmap the file, instead of reading the whole file in the
+ memory.
+
+ * Assorted fixes for issues found with CodeQL.
+
+ * Remove the leftover hints to the test framework to mark tests that
+ do not pass the leak checker tests, as they should no longer be
+ needed.
+
Fixes since v2.49
-----------------
@@ -306,6 +342,19 @@ Fixes since v2.49
* Use-after-free fix in the sequencer.
(merge 5dbaec628d pw/sequencer-reflog-use-after-free later to maint).
+ * win+Meson CI pipeline, unlike other pipelines for Windows,
+ used to build artifacts in develper mode, which has been changed to
+ build them in release mode for consistency.
+ (merge 184abdcf05 js/ci-build-win-in-release-mode later to maint).
+
+ * CI settings at GitLab has been updated to run MSVC based Meson job
+ automatically (as opposed to be done only upon manual request).
+ (merge 6389579b2f ps/ci-gitlab-enable-msvc-meson-job later to maint).
+
+ * "git apply" and "git add -i/-p" code paths no longer unnecessarily
+ expand sparse-index while working.
+ (merge ecf9ba20e3 ds/sparse-apply-add-p later to maint).
+
* Other code cleanup, docfix, build fix, etc.
(merge 227c4f33a0 ja/doc-block-delimiter-markup-fix later to maint).
(merge 2bfd3b3685 ab/decorate-code-cleanup later to maint).
@@ -336,3 +385,5 @@ Fixes since v2.49
(merge e5dd0a05ed ly/am-split-stgit-leakfix later to maint).
(merge bac220e154 rc/t1001-test-path-is-file later to maint).
(merge 91db6c735d ly/reftable-writer-leakfix later to maint).
+ (merge 20e4e9ad0b jc/doc-synopsis-option-markup later to maint).
+ (merge cddcee7f64 es/meson-configure-build-options-fix later to maint).
diff --git a/Documentation/config/commit.adoc b/Documentation/config/commit.adoc
index d3f4624fd2..208ae76c81 100644
--- a/Documentation/config/commit.adoc
+++ b/Documentation/config/commit.adoc
@@ -8,10 +8,11 @@ endif::git-commit[]
This setting overrides the default of the `--cleanup` option in
`git commit`. {see-git-commit} Changing the default can be useful
when you always want to keep lines that begin
- with the comment character `#` in your log message, in which case you
+ with the comment character (`core.commentChar`, default `#`)
+ in your log message, in which case you
would do `git config commit.cleanup whitespace` (note that you will
- have to remove the help lines that begin with `#` in the commit log
- template yourself, if you do this).
+ have to remove the help lines that begin with the comment character
+ in the commit log template yourself, if you do this).
`commit.gpgSign`::
A boolean to specify whether all commits should be GPG signed.
diff --git a/Documentation/fsck-msgids.adoc b/Documentation/fsck-msgids.adoc
index 9601fff228..0ba4f9a27e 100644
--- a/Documentation/fsck-msgids.adoc
+++ b/Documentation/fsck-msgids.adoc
@@ -59,6 +59,12 @@
`emptyName`::
(WARN) A path contains an empty name.
+`emptyPackedRefsFile`::
+ (INFO) "packed-refs" file is empty. Report to the
+ git@vger.kernel.org mailing list if you see this error. As only
+ very early versions of Git would create such an empty
+ "packed_refs" file, we might tighten this rule in the future.
+
`extraHeaderEntry`::
(IGNORE) Extra headers found after `tagger`.
diff --git a/Documentation/git-cat-file.adoc b/Documentation/git-cat-file.adoc
index fc4b92f104..cde79ad242 100644
--- a/Documentation/git-cat-file.adoc
+++ b/Documentation/git-cat-file.adoc
@@ -9,8 +9,7 @@ SYNOPSIS
--------
[verse]
'git cat-file' <type> <object>
-'git cat-file' (-e | -p) <object>
-'git cat-file' (-t | -s) [--allow-unknown-type] <object>
+'git cat-file' (-e | -p | -t | -s) <object>
'git cat-file' (--textconv | --filters)
[<rev>:<path|tree-ish> | --path=<path|tree-ish> <rev>]
'git cat-file' (--batch | --batch-check | --batch-command) [--batch-all-objects]
@@ -202,9 +201,6 @@ flush::
only once, even if it is stored multiple times in the
repository.
---allow-unknown-type::
- Allow `-s` or `-t` to query broken/corrupt objects of unknown type.
-
--follow-symlinks::
With `--batch` or `--batch-check`, follow symlinks inside the
repository when requesting objects with extended SHA-1
diff --git a/Documentation/git-daemon.adoc b/Documentation/git-daemon.adoc
index ede7b935d6..99389f0388 100644
--- a/Documentation/git-daemon.adoc
+++ b/Documentation/git-daemon.adoc
@@ -7,21 +7,21 @@ git-daemon - A really simple server for Git repositories
SYNOPSIS
--------
-[verse]
-'git daemon' [--verbose] [--syslog] [--export-all]
- [--timeout=<n>] [--init-timeout=<n>] [--max-connections=<n>]
- [--strict-paths] [--base-path=<path>] [--base-path-relaxed]
- [--user-path | --user-path=<path>]
- [--interpolated-path=<pathtemplate>]
- [--reuseaddr] [--detach] [--pid-file=<file>]
- [--enable=<service>] [--disable=<service>]
- [--allow-override=<service>] [--forbid-override=<service>]
- [--access-hook=<path>] [--[no-]informative-errors]
- [--inetd |
- [--listen=<host-or-ipaddr>] [--port=<n>]
- [--user=<user> [--group=<group>]]]
- [--log-destination=(stderr|syslog|none)]
- [<directory>...]
+[synopsis]
+git daemon [--verbose] [--syslog] [--export-all]
+ [--timeout=<n>] [--init-timeout=<n>] [--max-connections=<n>]
+ [--strict-paths] [--base-path=<path>] [--base-path-relaxed]
+ [--user-path | --user-path=<path>]
+ [--interpolated-path=<pathtemplate>]
+ [--reuseaddr] [--detach] [--pid-file=<file>]
+ [--enable=<service>] [--disable=<service>]
+ [--allow-override=<service>] [--forbid-override=<service>]
+ [--access-hook=<path>] [--[no-]informative-errors]
+ [--inetd |
+ [--listen=<host-or-ipaddr>] [--port=<n>]
+ [--user=<user> [--group=<group>]]]
+ [--log-destination=(stderr|syslog|none)]
+ [<directory>...]
DESCRIPTION
-----------
@@ -32,111 +32,111 @@ that service if it is enabled.
It verifies that the directory has the magic file "git-daemon-export-ok", and
it will refuse to export any Git directory that hasn't explicitly been marked
for export this way (unless the `--export-all` parameter is specified). If you
-pass some directory paths as 'git daemon' arguments, the offers are limited to
+pass some directory paths as `git daemon` arguments, the offers are limited to
repositories within those directories.
By default, only `upload-pack` service is enabled, which serves
-'git fetch-pack' and 'git ls-remote' clients, which are invoked
-from 'git fetch', 'git pull', and 'git clone'.
+`git fetch-pack` and `git ls-remote` clients, which are invoked
+from `git fetch`, `git pull`, and `git clone`.
This is ideally suited for read-only updates, i.e., pulling from
Git repositories.
-An `upload-archive` also exists to serve 'git archive'.
+An `upload-archive` also exists to serve `git archive`.
OPTIONS
-------
---strict-paths::
+`--strict-paths`::
Match paths exactly (i.e. don't allow "/foo/repo" when the real path is
"/foo/repo.git" or "/foo/repo/.git") and don't do user-relative paths.
- 'git daemon' will refuse to start when this option is enabled and no
+ `git daemon` will refuse to start when this option is enabled and no
directory arguments are provided.
---base-path=<path>::
+`--base-path=<path>`::
Remap all the path requests as relative to the given path.
- This is sort of "Git root" - if you run 'git daemon' with
- '--base-path=/srv/git' on example.com, then if you later try to pull
- 'git://example.com/hello.git', 'git daemon' will interpret the path
- as `/srv/git/hello.git`.
-
---base-path-relaxed::
- If --base-path is enabled and repo lookup fails, with this option
- 'git daemon' will attempt to lookup without prefixing the base path.
- This is useful for switching to --base-path usage, while still
+ This is sort of "Git root" - if you run `git daemon` with
+ `--base-path=/srv/git` on `example.com`, then if you later try
+ to pull from `git://example.com/hello.git`, `git daemon` will
+ interpret the path as `/srv/git/hello.git`.
+
+`--base-path-relaxed`::
+ If `--base-path` is enabled and repo lookup fails, with this option
+ `git daemon` will attempt to lookup without prefixing the base path.
+ This is useful for switching to `--base-path` usage, while still
allowing the old paths.
---interpolated-path=<pathtemplate>::
+`--interpolated-path=<pathtemplate>`::
To support virtual hosting, an interpolated path template can be
used to dynamically construct alternate paths. The template
- supports %H for the target hostname as supplied by the client but
- converted to all lowercase, %CH for the canonical hostname,
- %IP for the server's IP address, %P for the port number,
- and %D for the absolute path of the named repository.
+ supports `%H` for the target hostname as supplied by the client but
+ converted to all lowercase, `%CH` for the canonical hostname,
+ `%IP` for the server's IP address, `%P` for the port number,
+ and `%D` for the absolute path of the named repository.
After interpolation, the path is validated against the directory
list.
---export-all::
+`--export-all`::
Allow pulling from all directories that look like Git repositories
(have the 'objects' and 'refs' subdirectories), even if they
- do not have the 'git-daemon-export-ok' file.
+ do not have the `git-daemon-export-ok` file.
---inetd::
- Have the server run as an inetd service. Implies --syslog (may be
- overridden with `--log-destination=`).
- Incompatible with --detach, --port, --listen, --user and --group
- options.
+`--inetd`::
+ Have the server run as an inetd service. Implies `--syslog` (may
+ be overridden with `--log-destination=`).
+ Incompatible with `--detach`, `--port`, `--listen`, `--user` and
+ `--group` options.
---listen=<host-or-ipaddr>::
+`--listen=<host-or-ipaddr>`::
Listen on a specific IP address or hostname. IP addresses can
be either an IPv4 address or an IPv6 address if supported. If IPv6
- is not supported, then --listen=<hostname> is also not supported and
- --listen must be given an IPv4 address.
+ is not supported, then `--listen=<hostname>` is also not supported
+ and `--listen` must be given an IPv4 address.
Can be given more than once.
Incompatible with `--inetd` option.
---port=<n>::
+`--port=<n>`::
Listen on an alternative port. Incompatible with `--inetd` option.
---init-timeout=<n>::
+`--init-timeout=<n>`::
Timeout (in seconds) between the moment the connection is established
and the client request is received (typically a rather low value, since
that should be basically immediate).
---timeout=<n>::
+`--timeout=<n>`::
Timeout (in seconds) for specific client sub-requests. This includes
the time it takes for the server to process the sub-request and the
time spent waiting for the next client's request.
---max-connections=<n>::
+`--max-connections=<n>`::
Maximum number of concurrent clients, defaults to 32. Set it to
zero for no limit.
---syslog::
+`--syslog`::
Short for `--log-destination=syslog`.
---log-destination=<destination>::
+`--log-destination=<destination>`::
Send log messages to the specified destination.
- Note that this option does not imply --verbose,
+ Note that this option does not imply `--verbose`,
thus by default only error conditions will be logged.
- The <destination> must be one of:
+ The _<destination>_ must be one of:
+
--
-stderr::
+`stderr`::
Write to standard error.
Note that if `--detach` is specified,
the process disconnects from the real standard error,
making this destination effectively equivalent to `none`.
-syslog::
+`syslog`::
Write to syslog, using the `git-daemon` identifier.
-none::
+`none`::
Disable all logging.
--
+
The default destination is `syslog` if `--inetd` or `--detach` is specified,
otherwise `stderr`.
---user-path::
---user-path=<path>::
+`--user-path`::
+`--user-path=<path>`::
Allow {tilde}user notation to be used in requests. When
specified with no parameter, a request to
git://host/{tilde}alice/foo is taken as a request to access
@@ -145,23 +145,23 @@ otherwise `stderr`.
taken as a request to access `<path>/foo` repository in
the home directory of user `alice`.
---verbose::
+`--verbose`::
Log details about the incoming connections and requested files.
---reuseaddr::
- Use SO_REUSEADDR when binding the listening socket.
+`--reuseaddr`::
+ Use `SO_REUSEADDR` when binding the listening socket.
This allows the server to restart without waiting for
old connections to time out.
---detach::
- Detach from the shell. Implies --syslog.
+`--detach`::
+ Detach from the shell. Implies `--syslog`.
---pid-file=<file>::
- Save the process id in 'file'. Ignored when the daemon
+`--pid-file=<file>`::
+ Save the process id in _<file>_. Ignored when the daemon
is run under `--inetd`.
---user=<user>::
---group=<group>::
+`--user=<user>`::
+`--group=<group>`::
Change daemon's uid and gid before entering the service loop.
When only `--user` is given without `--group`, the
primary group ID for the user is used. The values of
@@ -170,43 +170,44 @@ otherwise `stderr`.
+
Giving these options is an error when used with `--inetd`; use
the facility of inet daemon to achieve the same before spawning
-'git daemon' if needed.
+`git daemon` if needed.
+
Like many programs that switch user id, the daemon does not reset
-environment variables such as `$HOME` when it runs git programs,
+environment variables such as `HOME` when it runs git programs,
e.g. `upload-pack` and `receive-pack`. When using this option, you
may also want to set and export `HOME` to point at the home
-directory of `<user>` before starting the daemon, and make sure any
-Git configuration files in that directory are readable by `<user>`.
+directory of _<user>_ before starting the daemon, and make sure any
+Git configuration files in that directory are readable by _<user>_.
---enable=<service>::
---disable=<service>::
+`--enable=<service>`::
+`--disable=<service>`::
Enable/disable the service site-wide per default. Note
that a service disabled site-wide can still be enabled
per repository if it is marked overridable and the
repository enables the service with a configuration
item.
---allow-override=<service>::
---forbid-override=<service>::
+`--allow-override=<service>`::
+`--forbid-override=<service>`::
Allow/forbid overriding the site-wide default with per
repository configuration. By default, all the services
may be overridden.
---[no-]informative-errors::
+`--informative-errors`::
+`--no-informative-errors`::
When informative errors are turned on, git-daemon will report
more verbose errors to the client, differentiating conditions
like "no such repository" from "repository not exported". This
is more convenient for clients, but may leak information about
the existence of unexported repositories. When informative
errors are not enabled, all errors report "access denied" to the
- client. The default is --no-informative-errors.
+ client. The default is `--no-informative-errors`.
---access-hook=<path>::
+`--access-hook=<path>`::
Every time a client connects, first run an external command
specified by the <path> with service name (e.g. "upload-pack"),
- path to the repository, hostname (%H), canonical hostname
- (%CH), IP address (%IP), and TCP port (%P) as its command-line
+ path to the repository, hostname (`%H`), canonical hostname
+ (`%CH`), IP address (`%IP`), and TCP port (`%P`) as its command-line
arguments. The external command can decide to decline the
service by exiting with a non-zero status (or to allow it by
exiting with a zero status). It can also look at the $REMOTE_ADDR
@@ -217,7 +218,7 @@ The external command can optionally write a single line to its
standard output to be sent to the requestor as an error message when
it declines the service.
-<directory>::
+_<directory>_::
The remaining arguments provide a list of directories. If any
directories are specified, then the `git-daemon` process will
serve a requested directory only if it is contained in one of
@@ -229,24 +230,24 @@ SERVICES
These services can be globally enabled/disabled using the
command-line options of this command. If finer-grained
-control is desired (e.g. to allow 'git archive' to be run
+control is desired (e.g. to allow `git archive` to be run
against only in a few selected repositories the daemon serves),
the per-repository configuration file can be used to enable or
disable them.
upload-pack::
- This serves 'git fetch-pack' and 'git ls-remote'
+ This serves `git fetch-pack` and `git ls-remote`
clients. It is enabled by default, but a repository can
disable it by setting `daemon.uploadpack` configuration
item to `false`.
upload-archive::
- This serves 'git archive --remote'. It is disabled by
+ This serves `git archive --remote`. It is disabled by
default, but a repository can enable it by setting
`daemon.uploadarch` configuration item to `true`.
receive-pack::
- This serves 'git send-pack' clients, allowing anonymous
+ This serves `git send-pack` clients, allowing anonymous
push. It is disabled by default, as there is _no_
authentication in the protocol (in other words, anybody
can push anything into the repository, including removal
@@ -300,7 +301,7 @@ default repository could be made as well.
'git daemon' as regular daemon for virtual hosts::
- To set up 'git daemon' as a regular, non-inetd service that
+ To set up `git daemon` as a regular, non-inetd service that
handles repositories for multiple virtual hosts based on
their IP addresses, start the daemon like this:
+
@@ -317,7 +318,7 @@ Repositories can still be accessed by hostname though, assuming
they correspond to these IP addresses.
selectively enable/disable services per repository::
- To enable 'git archive --remote' and disable 'git fetch' against
+ To enable `git archive --remote` and disable `git fetch` against
a repository, have the following in the configuration file in the
repository (that is the file 'config' next to `HEAD`, 'refs' and
'objects').
@@ -331,8 +332,8 @@ selectively enable/disable services per repository::
ENVIRONMENT
-----------
-'git daemon' will set REMOTE_ADDR to the IP address of the client
-that connected to it, if the IP address is available. REMOTE_ADDR will
+`git daemon` will set `REMOTE_ADDR` to the IP address of the client
+that connected to it, if the IP address is available. `REMOTE_ADDR` will
be available in the environment of hooks called when
services are performed.
diff --git a/Documentation/git-merge-tree.adoc b/Documentation/git-merge-tree.adoc
index cf0578f9b5..f824eea61f 100644
--- a/Documentation/git-merge-tree.adoc
+++ b/Documentation/git-merge-tree.adoc
@@ -65,6 +65,12 @@ OPTIONS
default is to include these messages if there are merge
conflicts, and to omit them otherwise.
+--quiet::
+ Disable all output from the program. Useful when you are only
+ interested in the exit status. Allows merge-tree to exit
+ early when it finds a conflict, and allows it to avoid writing
+ most objects created by merges.
+
--allow-unrelated-histories::
merge-tree will by default error out if the two branches specified
share no common history. This flag can be given to override that
diff --git a/Documentation/git-multi-pack-index.adoc b/Documentation/git-multi-pack-index.adoc
index 631d5c7d15..b6cd0d7f85 100644
--- a/Documentation/git-multi-pack-index.adoc
+++ b/Documentation/git-multi-pack-index.adoc
@@ -38,10 +38,13 @@ write::
+
--
--preferred-pack=<pack>::
- Optionally specify the tie-breaking pack used when
- multiple packs contain the same object. `<pack>` must
- contain at least one object. If not given, ties are
- broken in favor of the pack with the lowest mtime.
+ When specified, break ties in favor of this pack when
+ there are additional copies of its objects in other
+ packs. Ties for objects not found in the preferred
+ pack are always resolved in favor of the copy in the
+ pack with the highest mtime. If unspecified, the pack
+ with the lowest mtime is used by default. The
+ preferred pack must have at least one object.
--[no-]bitmap::
Control whether or not a multi-pack bitmap is written.
diff --git a/Documentation/git-notes.adoc b/Documentation/git-notes.adoc
index bcfe3dacd3..46a232ca71 100644
--- a/Documentation/git-notes.adoc
+++ b/Documentation/git-notes.adoc
@@ -87,6 +87,9 @@ In `--stdin` mode, take lines in the format
on standard input, and copy the notes from each _<from-object>_ to its
corresponding _<to-object>_. (The optional _<rest>_ is ignored so that
the command can read the input given to the `post-rewrite` hook.)
++
+`--stdin` cannot be combined with object names given on the command
+line.
`append`::
Append new message(s) given by `-m` or `-F` options to an
@@ -124,6 +127,10 @@ When done, the user can either finalize the merge with
giving zero or one object from the command line, this is
equivalent to specifying an empty note message to
the `edit` subcommand.
++
+In `--stdin` mode, also remove the object names given on standard
+input. In other words, `--stdin` can be combined with object names from
+the command line.
`prune`::
Remove all notes for non-existing/unreachable objects.
@@ -144,26 +151,18 @@ OPTIONS
Use the given note message (instead of prompting).
If multiple `-m` options are given, their values
are concatenated as separate paragraphs.
- Lines starting with `#` and empty lines other than a
- single line between paragraphs will be stripped out.
- If you wish to keep them verbatim, use `--no-stripspace`.
`-F <file>`::
`--file=<file>`::
Take the note message from the given file. Use `-` to
read the note message from the standard input.
- Lines starting with `#` and empty lines other than a
- single line between paragraphs will be stripped out.
- If you wish to keep them verbatim, use `--no-stripspace`.
`-C <object>`::
`--reuse-message=<object>`::
Take the given blob object (for example, another note) as the
note message. (Use `git notes copy <object>` instead to
- copy notes between objects.). By default, message will be
- copied verbatim, but if you wish to strip out the lines
- starting with `#` and empty lines other than a single line
- between paragraphs, use with `--stripspace` option.
+ copy notes between objects.) Implies `--no-stripspace` since
+ the default behavior is to copy the message verbatim.
`-c <object>`::
`--reedit-message=<object>`::
@@ -174,21 +173,34 @@ OPTIONS
Allow an empty note object to be stored. The default behavior is
to automatically remove empty notes.
-`--[no-]separator`::
`--separator=<paragraph-break>`::
+`--separator`::
+`--no-separator`::
Specify a string used as a custom inter-paragraph separator
(a newline is added at the end as needed). If `--no-separator`, no
separators will be added between paragraphs. Defaults to a blank
line.
-`--[no-]stripspace`::
- Strip leading and trailing whitespace from the note message.
- Also strip out empty lines other than a single line between
- paragraphs. Lines starting with `#` will be stripped out
- in non-editor cases like `-m`, `-F` and `-C`, but not in
- editor case like `git notes edit`, `-c`, etc.
-
-`--ref <ref>`::
+`--stripspace`::
+`--no-stripspace`::
+ Clean up whitespace. Specifically (see
+ linkgit:git-stripspace[1]):
++
+--
+- remove trailing whitespace from all lines
+- collapse multiple consecutive empty lines into one empty line
+- remove empty lines from the beginning and end of the input
+- add a missing `\n` to the last line if necessary.
+--
++
+`--stripspace` is the default except for
+`-C`/`--reuse-message`. However, keep in mind that this depends on the
+order of similar options. For example, for `-C <object> -m<message>`,
+`--stripspace` will be used because the default for `-m` overrides the
+previous `-C`. This is a known limitation that may be fixed in the
+future.
+
+`--ref=<ref>`::
Manipulate the notes tree in _<ref>_. This overrides
`GIT_NOTES_REF` and the `core.notesRef` configuration. The ref
specifies the full refname when it begins with `refs/notes/`; when it
@@ -200,9 +212,7 @@ OPTIONS
object that does not have notes attached to it.
`--stdin`::
- Also read the object names to remove notes from the standard
- input (there is no reason you cannot combine this with object
- names from the command line).
+ Only valid for `remove` and `copy`. See the respective subcommands.
`-n`::
`--dry-run`::
diff --git a/Documentation/git-receive-pack.adoc b/Documentation/git-receive-pack.adoc
index 20aca92073..0956086d61 100644
--- a/Documentation/git-receive-pack.adoc
+++ b/Documentation/git-receive-pack.adoc
@@ -46,6 +46,18 @@ OPTIONS
`$GIT_URL/info/refs?service=git-receive-pack` requests. See
`--http-backend-info-refs` in linkgit:git-upload-pack[1].
+--skip-connectivity-check::
+ Bypasses the connectivity checks that validate the existence of all
+ objects in the transitive closure of reachable objects. This option is
+ intended for server operators that want to implement their own object
+ connectivity validation outside of Git. This is useful in such cases
+ where the server-side knows additional information about how Git is
+ being used and thus can rely on certain guarantees to more efficiently
+ compute object connectivity that Git itself cannot make. Usage of this
+ option without a reliable external mechanism to ensure full reachable
+ object connectivity risks corrupting the repository and should not be
+ used in the general case.
+
PRE-RECEIVE HOOK
----------------
Before any ref is updated, if $GIT_DIR/hooks/pre-receive file exists
diff --git a/Documentation/git-stripspace.adoc b/Documentation/git-stripspace.adoc
index a293327581..37287f211f 100644
--- a/Documentation/git-stripspace.adoc
+++ b/Documentation/git-stripspace.adoc
@@ -37,7 +37,8 @@ OPTIONS
-------
-s::
--strip-comments::
- Skip and remove all lines starting with a comment character (default '#').
+ Skip and remove all lines starting with a comment character
+ (`core.commentChar`, default `#`).
-c::
--comment-lines::
diff --git a/Documentation/git-var.adoc b/Documentation/git-var.adoc
index 0680568dfd..b606c2d649 100644
--- a/Documentation/git-var.adoc
+++ b/Documentation/git-var.adoc
@@ -8,8 +8,8 @@ git-var - Show a Git logical variable
SYNOPSIS
--------
-[verse]
-'git var' (-l | <variable>)
+[synopsis]
+git var (-l | <variable>)
DESCRIPTION
-----------
@@ -18,7 +18,7 @@ no value.
OPTIONS
-------
--l::
+`-l`::
Display the logical variables. In addition, all the
variables of the Git configuration file .git/config are listed
as well. (However, the configuration variables listing functionality
@@ -32,58 +32,56 @@ EXAMPLES
VARIABLES
---------
-GIT_AUTHOR_IDENT::
+`GIT_AUTHOR_IDENT`::
The author of a piece of code.
-GIT_COMMITTER_IDENT::
+`GIT_COMMITTER_IDENT`::
The person who put a piece of code into Git.
-GIT_EDITOR::
+`GIT_EDITOR`::
Text editor for use by Git commands. The value is meant to be
interpreted by the shell when it is used. Examples: `~/bin/vi`,
`$SOME_ENVIRONMENT_VARIABLE`, `"C:\Program Files\Vim\gvim.exe"
- --nofork`. The order of preference is the `$GIT_EDITOR`
- environment variable, then `core.editor` configuration, then
- `$VISUAL`, then `$EDITOR`, and then the default chosen at compile
+ --nofork`. The order of preference is `$GIT_EDITOR`, then
+ `core.editor` configuration value, then `$VISUAL`, then
+ `$EDITOR`, and then the default chosen at compile
time, which is usually 'vi'.
ifdef::git-default-editor[]
The build you are using chose '{git-default-editor}' as the default.
endif::git-default-editor[]
-GIT_SEQUENCE_EDITOR::
+`GIT_SEQUENCE_EDITOR`::
Text editor used to edit the 'todo' file while running `git rebase
-i`. Like `GIT_EDITOR`, the value is meant to be interpreted by
- the shell when it is used. The order of preference is the
- `$GIT_SEQUENCE_EDITOR` environment variable, then
- `sequence.editor` configuration, and then the value of `git var
- GIT_EDITOR`.
+ the shell when it is used. The order of preference is
+ `$GIT_SEQUENCE_EDITOR`, then `sequence.editor` configuration value,
+ and then the value of `git var GIT_EDITOR`.
-GIT_PAGER::
+`GIT_PAGER`::
Text viewer for use by Git commands (e.g., 'less'). The value
is meant to be interpreted by the shell. The order of preference
- is the `$GIT_PAGER` environment variable, then `core.pager`
- configuration, then `$PAGER`, and then the default chosen at
- compile time (usually 'less').
+ is `$GIT_PAGER`, then the value of `core.pager` configuration, then
+ `$PAGER`, and then the default chosen at compile time (usually `less`).
ifdef::git-default-pager[]
The build you are using chose '{git-default-pager}' as the default.
endif::git-default-pager[]
-GIT_DEFAULT_BRANCH::
+`GIT_DEFAULT_BRANCH`::
The name of the first branch created in newly initialized repositories.
-GIT_SHELL_PATH::
+`GIT_SHELL_PATH`::
The path of the binary providing the POSIX shell for commands which use the shell.
-GIT_ATTR_SYSTEM::
+`GIT_ATTR_SYSTEM`::
The path to the system linkgit:gitattributes[5] file, if one is enabled.
-GIT_ATTR_GLOBAL::
+`GIT_ATTR_GLOBAL`::
The path to the global (per-user) linkgit:gitattributes[5] file.
-GIT_CONFIG_SYSTEM::
+`GIT_CONFIG_SYSTEM`::
The path to the system configuration file, if one is enabled.
-GIT_CONFIG_GLOBAL::
+`GIT_CONFIG_GLOBAL`::
The path to the global (per-user) configuration files, if any.
Most path values contain only one value. However, some can contain multiple
diff --git a/Documentation/git-verify-commit.adoc b/Documentation/git-verify-commit.adoc
index aee4c40eac..ff5b8b97ef 100644
--- a/Documentation/git-verify-commit.adoc
+++ b/Documentation/git-verify-commit.adoc
@@ -7,26 +7,24 @@ git-verify-commit - Check the GPG signature of commits
SYNOPSIS
--------
-[verse]
-'git verify-commit' [-v | --verbose] [--raw] <commit>...
+[synopsis]
+git verify-commit [-v | --verbose] [--raw] <commit>...
DESCRIPTION
-----------
-Validates the GPG signature created by 'git commit -S'.
+Validates the GPG signature created by `git commit -S`
+on the commit objects given on the command line.
OPTIONS
-------
---raw::
+`--raw`::
Print the raw gpg status output to standard error instead of the normal
human-readable output.
--v::
---verbose::
+`-v`::
+`--verbose`::
Print the contents of the commit object before validating it.
-<commit>...::
- SHA-1 identifiers of Git commit objects.
-
GIT
---
Part of the linkgit:git[1] suite
diff --git a/Documentation/git-verify-pack.adoc b/Documentation/git-verify-pack.adoc
index d7e886918a..b0462d8db3 100644
--- a/Documentation/git-verify-pack.adoc
+++ b/Documentation/git-verify-pack.adoc
@@ -8,43 +8,39 @@ git-verify-pack - Validate packed Git archive files
SYNOPSIS
--------
-[verse]
-'git verify-pack' [-v | --verbose] [-s | --stat-only] [--] <pack>.idx...
+[synopsis]
+git verify-pack [-v | --verbose] [-s | --stat-only] [--] <pack>.idx...
DESCRIPTION
-----------
-Reads given idx file for packed Git archive created with the
-'git pack-objects' command and verifies the idx file and the
-corresponding pack file.
+Read each idx file for packed Git archive given on the command line,
+and verify the idx file and the corresponding pack file.
OPTIONS
-------
-<pack>.idx ...::
- The idx files to verify.
-
--v::
---verbose::
+`-v`::
+`--verbose`::
After verifying the pack, show the list of objects contained
in the pack and a histogram of delta chain length.
--s::
---stat-only::
+`-s`::
+`--stat-only`::
Do not verify the pack contents; only show the histogram of delta
chain length. With `--verbose`, the list of objects is also shown.
-\--::
+`--`::
Do not interpret any more arguments as options.
OUTPUT FORMAT
-------------
-When specifying the -v option the format used is:
+When specifying the `-v` option the format used is:
- SHA-1 type size size-in-packfile offset-in-packfile
+ object-name type size size-in-packfile offset-in-packfile
for objects that are not deltified in the pack, and
- SHA-1 type size size-in-packfile offset-in-packfile depth base-SHA-1
+ object-name type size size-in-packfile offset-in-packfile depth base-object-name
for objects that are deltified.
diff --git a/Documentation/git-verify-tag.adoc b/Documentation/git-verify-tag.adoc
index 81d50ecc4c..b3721a86f4 100644
--- a/Documentation/git-verify-tag.adoc
+++ b/Documentation/git-verify-tag.adoc
@@ -7,26 +7,24 @@ git-verify-tag - Check the GPG signature of tags
SYNOPSIS
--------
-[verse]
-'git verify-tag' [-v | --verbose] [--format=<format>] [--raw] <tag>...
+[synopsis]
+git verify-tag [-v | --verbose] [--format=<format>] [--raw] <tag>...
DESCRIPTION
-----------
-Validates the gpg signature created by 'git tag'.
+Validates the gpg signature created by `git tag` in the tag
+objects listed on the command line.
OPTIONS
-------
---raw::
+`--raw`::
Print the raw gpg status output to standard error instead of the normal
human-readable output.
--v::
---verbose::
+`-v`::
+`--verbose`::
Print the contents of the tag object before validating it.
-<tag>...::
- SHA-1 identifiers of Git tag objects.
-
GIT
---
Part of the linkgit:git[1] suite
diff --git a/Documentation/git-write-tree.adoc b/Documentation/git-write-tree.adoc
index f22041a9dc..4c7100ea1e 100644
--- a/Documentation/git-write-tree.adoc
+++ b/Documentation/git-write-tree.adoc
@@ -8,8 +8,8 @@ git-write-tree - Create a tree object from the current index
SYNOPSIS
--------
-[verse]
-'git write-tree' [--missing-ok] [--prefix=<prefix>/]
+[synopsis]
+git write-tree [--missing-ok] [--prefix=<prefix>/]
DESCRIPTION
-----------
@@ -18,23 +18,23 @@ tree object is printed to standard output.
The index must be in a fully merged state.
-Conceptually, 'git write-tree' sync()s the current index contents
+Conceptually, `git write-tree` sync()s the current index contents
into a set of tree files.
In order to have that match what is actually in your directory right
-now, you need to have done a 'git update-index' phase before you did the
-'git write-tree'.
+now, you need to have done a `git update-index` phase before you did the
+`git write-tree`.
OPTIONS
-------
---missing-ok::
- Normally 'git write-tree' ensures that the objects referenced by the
+`--missing-ok`::
+ Normally `git write-tree` ensures that the objects referenced by the
directory exist in the object database. This option disables this
check.
---prefix=<prefix>/::
+`--prefix=<prefix>/`::
Writes a tree object that represents a subdirectory
- `<prefix>`. This can be used to write the tree object
+ _<prefix>_. This can be used to write the tree object
for a subproject that is in the named subdirectory.
GIT
diff --git a/Documentation/scalar.adoc b/Documentation/scalar.adoc
index 7e4259c674..4bd5b150e8 100644
--- a/Documentation/scalar.adoc
+++ b/Documentation/scalar.adoc
@@ -9,12 +9,12 @@ SYNOPSIS
--------
[verse]
scalar clone [--single-branch] [--branch <main-branch>] [--full-clone]
- [--[no-]src] <url> [<enlistment>]
+ [--[no-]src] [--[no-]tags] [--[no-]maintenance] <url> [<enlistment>]
scalar list
-scalar register [<enlistment>]
+scalar register [--[no-]maintenance] [<enlistment>]
scalar unregister [<enlistment>]
scalar run ( all | config | commit-graph | fetch | loose-objects | pack-files ) [<enlistment>]
-scalar reconfigure [ --all | <enlistment> ]
+scalar reconfigure [--maintenance=(enable|disable|keep)] [ --all | <enlistment> ]
scalar diagnose [<enlistment>]
scalar delete <enlistment>
@@ -97,6 +97,11 @@ cloning. If the HEAD at the remote did not point at any branch when
A sparse-checkout is initialized by default. This behavior can be
turned off via `--full-clone`.
+--[no-]maintenance::
+ By default, `scalar clone` configures the enlistment to use Git's
+ background maintenance feature. Use the `--no-maintenance` to skip
+ this configuration.
+
List
~~~~
@@ -117,6 +122,12 @@ Note: when this subcommand is called in a worktree that is called `src/`, its
parent directory is considered to be the Scalar enlistment. If the worktree is
_not_ called `src/`, it itself will be considered to be the Scalar enlistment.
+--[no-]maintenance::
+ By default, `scalar register` configures the enlistment to use Git's
+ background maintenance feature. Use the `--no-maintenance` to skip
+ this configuration. This does not disable any maintenance that may
+ already be enabled in other ways.
+
Unregister
~~~~~~~~~~
@@ -149,8 +160,18 @@ After a Scalar upgrade, or when the configuration of a Scalar enlistment
was somehow corrupted or changed by mistake, this subcommand allows to
reconfigure the enlistment.
-With the `--all` option, all enlistments currently registered with Scalar
-will be reconfigured. Use this option after each Scalar upgrade.
+--all::
+ When `--all` is specified, reconfigure all enlistments currently
+ registered with Scalar by the `scalar.repo` config key. Use this
+ option after each upgrade to get the latest features.
+
+--maintenance=(enable|disable|keep)::
+ By default, Scalar configures the enlistment to use Git's
+ background maintenance feature; this is the same as using the
+ `enable` value for this option. Use the `disable` value to
+ remove each considered enlistment from background maintenance.
+ Use `keep' to leave the background maintenance configuration
+ untouched for these repositories.
Diagnose
~~~~~~~~
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index b981598298..cea2a13401 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,6 +1,6 @@
#!/bin/sh
-DEF_VER=v2.49.GIT
+DEF_VER=v2.50.0-rc0
LF='
'
diff --git a/Makefile b/Makefile
index ecd590a643..70d1543b6b 100644
--- a/Makefile
+++ b/Makefile
@@ -859,6 +859,7 @@ TEST_BUILTINS_OBJS += test-wildmatch.o
TEST_BUILTINS_OBJS += test-windows-named-pipe.o
TEST_BUILTINS_OBJS += test-write-cache.o
TEST_BUILTINS_OBJS += test-xml-encode.o
+TEST_BUILTINS_OBJS += test-zlib.o
# Do not add more tests here unless they have extra dependencies. Add
# them in TEST_BUILTINS_OBJS above.
diff --git a/apply.c b/apply.c
index 381d2e3652..8bbe6ed224 100644
--- a/apply.c
+++ b/apply.c
@@ -2219,7 +2219,7 @@ static void reverse_patches(struct patch *p)
struct fragment *frag = p->fragments;
SWAP(p->new_name, p->old_name);
- if (p->new_mode)
+ if (p->new_mode || p->is_delete)
SWAP(p->new_mode, p->old_mode);
SWAP(p->is_new, p->is_delete);
SWAP(p->lines_added, p->lines_deleted);
diff --git a/builtin/add.c b/builtin/add.c
index 747511b68b..7c292ffdc6 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -390,6 +390,10 @@ int cmd_add(int argc,
argc = parse_options(argc, argv, prefix, builtin_add_options,
builtin_add_usage, PARSE_OPT_KEEP_ARGV0);
+
+ prepare_repo_settings(repo);
+ repo->settings.command_requires_full_index = 0;
+
if (patch_interactive)
add_interactive = 1;
if (add_interactive) {
@@ -426,9 +430,6 @@ int cmd_add(int argc,
add_new_files = !take_worktree_changes && !refresh_only && !add_renormalize;
require_pathspec = !(take_worktree_changes || (0 < addremove_explicit));
- prepare_repo_settings(repo);
- repo->settings.command_requires_full_index = 0;
-
repo_hold_locked_index(repo, &lock_file, LOCK_DIE_ON_ERROR);
/*
diff --git a/builtin/apply.c b/builtin/apply.c
index 84f1863d3a..a1e20c593d 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -12,7 +12,7 @@ static const char * const apply_usage[] = {
int cmd_apply(int argc,
const char **argv,
const char *prefix,
- struct repository *repo UNUSED)
+ struct repository *repo)
{
int force_apply = 0;
int options = 0;
@@ -35,6 +35,11 @@ int cmd_apply(int argc,
&state, &force_apply, &options,
apply_usage);
+ if (repo) {
+ prepare_repo_settings(repo);
+ repo->settings.command_requires_full_index = 0;
+ }
+
if (check_apply_state(&state, force_apply))
exit(128);
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 3914a2a3f6..67a5ff2b9e 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -100,8 +100,7 @@ static int stream_blob(const struct object_id *oid)
return 0;
}
-static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
- int unknown_type)
+static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
{
int ret;
struct object_id oid;
@@ -110,7 +109,6 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
unsigned long size;
struct object_context obj_context = {0};
struct object_info oi = OBJECT_INFO_INIT;
- struct strbuf sb = STRBUF_INIT;
unsigned flags = OBJECT_INFO_LOOKUP_REPLACE;
unsigned get_oid_flags =
GET_OID_RECORD_PATH |
@@ -121,9 +119,6 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
if (!path && opt_cw)
get_oid_flags |= GET_OID_REQUIRE_PATH;
- if (unknown_type)
- flags |= OBJECT_INFO_ALLOW_UNKNOWN_TYPE;
-
if (get_oid_with_context(the_repository, obj_name, get_oid_flags, &oid,
&obj_context))
die("Not a valid object name %s", obj_name);
@@ -136,16 +131,12 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
buf = NULL;
switch (opt) {
case 't':
- oi.type_name = &sb;
+ oi.typep = &type;
if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
die("git cat-file: could not get object info");
- if (sb.len) {
- printf("%s\n", sb.buf);
- strbuf_release(&sb);
- ret = 0;
- goto cleanup;
- }
- break;
+ printf("%s\n", type_name(type));
+ ret = 0;
+ goto cleanup;
case 's':
oi.sizep = &size;
@@ -1038,8 +1029,7 @@ int cmd_cat_file(int argc,
const char * const builtin_catfile_usage[] = {
N_("git cat-file <type> <object>"),
- N_("git cat-file (-e | -p) <object>"),
- N_("git cat-file (-t | -s) [--allow-unknown-type] <object>"),
+ N_("git cat-file (-e | -p | -t | -s) <object>"),
N_("git cat-file (--textconv | --filters)\n"
" [<rev>:<path|tree-ish> | --path=<path|tree-ish> <rev>]"),
N_("git cat-file (--batch | --batch-check | --batch-command) [--batch-all-objects]\n"
@@ -1057,8 +1047,8 @@ int cmd_cat_file(int argc,
OPT_GROUP(N_("Emit [broken] object attributes")),
OPT_CMDMODE('t', NULL, &opt, N_("show object type (one of 'blob', 'tree', 'commit', 'tag', ...)"), 't'),
OPT_CMDMODE('s', NULL, &opt, N_("show object size"), 's'),
- OPT_BOOL(0, "allow-unknown-type", &unknown_type,
- N_("allow -s and -t to work with broken/corrupt objects")),
+ OPT_HIDDEN_BOOL(0, "allow-unknown-type", &unknown_type,
+ N_("historical option -- no-op")),
OPT_BOOL(0, "use-mailmap", &use_mailmap, N_("use mail map file")),
OPT_ALIAS(0, "mailmap", "use-mailmap"),
/* Batch mode */
@@ -1209,10 +1199,7 @@ int cmd_cat_file(int argc,
obj_name = argv[1];
}
- if (unknown_type && opt != 't' && opt != 's')
- die("git cat-file --allow-unknown-type: use with -s or -t");
-
- ret = cat_one_file(opt, exp_type, obj_name, unknown_type);
+ ret = cat_one_file(opt, exp_type, obj_name);
out:
list_objects_filter_release(&batch.objects_filter);
diff --git a/builtin/commit.c b/builtin/commit.c
index 66bd91fd52..fba0dded64 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1022,7 +1022,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
for (i = 0; i < the_repository->index->cache_nr; i++)
if (ce_intent_to_add(the_repository->index->cache[i]))
ita_nr++;
- committable = the_repository->index->cache_nr - ita_nr > 0;
+ committable = the_repository->index->cache_nr > ita_nr;
} else {
/*
* Unless the user did explicitly request a submodule
diff --git a/builtin/fetch.c b/builtin/fetch.c
index cda6eaf1fd..40a0e8d244 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1728,7 +1728,7 @@ static int do_fetch(struct transport *transport,
if (transport->remote->follow_remote_head != FOLLOW_REMOTE_NEVER)
do_set_head = 1;
}
- if (branch_has_merge_config(branch) &&
+ if (branch && branch_has_merge_config(branch) &&
!strcmp(branch->remote_name, transport->remote->name)) {
int i;
for (i = 0; i < branch->merge_nr; i++) {
@@ -2560,6 +2560,7 @@ int cmd_fetch(int argc,
if (server_options.nr)
gtransport->server_options = &server_options;
result = transport_fetch_refs(gtransport, NULL);
+ gtransport->smart_options->acked_commits = NULL;
oidset_iter_init(&acked_commits, &iter);
while ((oid = oidset_iter_next(&iter)))
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 6cac28356c..e7d96a9c8e 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -614,12 +614,11 @@ static void get_default_heads(void)
struct for_each_loose_cb
{
struct progress *progress;
- struct strbuf obj_type;
};
-static int fsck_loose(const struct object_id *oid, const char *path, void *data)
+static int fsck_loose(const struct object_id *oid, const char *path,
+ void *data UNUSED)
{
- struct for_each_loose_cb *cb_data = data;
struct object *obj;
enum object_type type = OBJ_NONE;
unsigned long size;
@@ -629,8 +628,6 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
struct object_id real_oid = *null_oid(the_hash_algo);
int err = 0;
- strbuf_reset(&cb_data->obj_type);
- oi.type_name = &cb_data->obj_type;
oi.sizep = &size;
oi.typep = &type;
@@ -642,10 +639,6 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
err = error(_("%s: object corrupt or missing: %s"),
oid_to_hex(oid), path);
}
- if (type != OBJ_NONE && type < 0)
- err = error(_("%s: object is of unknown type '%s': %s"),
- oid_to_hex(&real_oid), cb_data->obj_type.buf,
- path);
if (err < 0) {
errors_found |= ERROR_OBJECT;
free(contents);
@@ -697,7 +690,6 @@ static void fsck_object_dir(const char *path)
{
struct progress *progress = NULL;
struct for_each_loose_cb cb_data = {
- .obj_type = STRBUF_INIT,
.progress = progress,
};
@@ -712,7 +704,6 @@ static void fsck_object_dir(const char *path)
&cb_data);
display_progress(progress, 256);
stop_progress(&progress);
- strbuf_release(&cb_data.obj_type);
}
static int fsck_head_link(const char *head_ref_name,
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index cd53fa3bde..6a99ec250d 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -19,49 +19,15 @@
#include "strbuf.h"
#include "write-or-die.h"
-enum {
- HASH_OBJECT_CHECK = (1 << 0),
- HASH_OBJECT_WRITE = (1 << 1),
-};
-
-/*
- * This is to create corrupt objects for debugging and as such it
- * needs to bypass the data conversion performed by, and the type
- * limitation imposed by, index_fd() and its callees.
- */
-static int hash_literally(struct object_id *oid, int fd, const char *type, unsigned flags)
+static void hash_fd(int fd, const char *type, const char *path, unsigned flags)
{
- struct strbuf buf = STRBUF_INIT;
- int ret;
-
- if (strbuf_read(&buf, fd, 4096) < 0)
- ret = -1;
- else
- ret = write_object_file_literally(buf.buf, buf.len, type, oid,
- (flags & HASH_OBJECT_WRITE) ? WRITE_OBJECT_FILE_PERSIST : 0);
- close(fd);
- strbuf_release(&buf);
- return ret;
-}
-
-static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
- int literally)
-{
- unsigned int index_flags = 0;
struct stat st;
struct object_id oid;
- if (flags & HASH_OBJECT_WRITE)
- index_flags |= INDEX_WRITE_OBJECT;
- if (flags & HASH_OBJECT_CHECK)
- index_flags |= INDEX_FORMAT_CHECK;
-
if (fstat(fd, &st) < 0 ||
- (literally
- ? hash_literally(&oid, fd, type, flags)
- : index_fd(the_repository->index, &oid, fd, &st,
- type_from_string(type), path, index_flags)))
- die((flags & HASH_OBJECT_WRITE)
+ index_fd(the_repository->index, &oid, fd, &st,
+ type_from_string(type), path, flags))
+ die((flags & INDEX_WRITE_OBJECT)
? "Unable to add %s to database"
: "Unable to hash %s", path);
printf("%s\n", oid_to_hex(&oid));
@@ -69,15 +35,14 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
}
static void hash_object(const char *path, const char *type, const char *vpath,
- unsigned flags, int literally)
+ unsigned flags)
{
int fd;
fd = xopen(path, O_RDONLY);
- hash_fd(fd, type, vpath, flags, literally);
+ hash_fd(fd, type, vpath, flags);
}
-static void hash_stdin_paths(const char *type, int no_filters, unsigned flags,
- int literally)
+static void hash_stdin_paths(const char *type, int no_filters, unsigned flags)
{
struct strbuf buf = STRBUF_INIT;
struct strbuf unquoted = STRBUF_INIT;
@@ -89,8 +54,7 @@ static void hash_stdin_paths(const char *type, int no_filters, unsigned flags,
die("line is badly quoted");
strbuf_swap(&buf, &unquoted);
}
- hash_object(buf.buf, type, no_filters ? NULL : buf.buf, flags,
- literally);
+ hash_object(buf.buf, type, no_filters ? NULL : buf.buf, flags);
}
strbuf_release(&buf);
strbuf_release(&unquoted);
@@ -111,19 +75,20 @@ int cmd_hash_object(int argc,
int hashstdin = 0;
int stdin_paths = 0;
int no_filters = 0;
- int literally = 0;
int nongit = 0;
- unsigned flags = HASH_OBJECT_CHECK;
+ unsigned flags = INDEX_FORMAT_CHECK;
const char *vpath = NULL;
char *vpath_free = NULL;
const struct option hash_object_options[] = {
OPT_STRING('t', NULL, &type, N_("type"), N_("object type")),
OPT_BIT('w', NULL, &flags, N_("write the object into the object database"),
- HASH_OBJECT_WRITE),
+ INDEX_WRITE_OBJECT),
OPT_COUNTUP( 0 , "stdin", &hashstdin, N_("read the object from stdin")),
OPT_BOOL( 0 , "stdin-paths", &stdin_paths, N_("read file names from stdin")),
OPT_BOOL( 0 , "no-filters", &no_filters, N_("store file as is without filters")),
- OPT_BOOL( 0, "literally", &literally, N_("just hash any random garbage to create corrupt objects for debugging Git")),
+ OPT_NEGBIT( 0, "literally", &flags,
+ N_("just hash any random garbage to create corrupt objects for debugging Git"),
+ INDEX_FORMAT_CHECK),
OPT_STRING( 0 , "path", &vpath, N_("file"), N_("process file as it were from this path")),
OPT_END()
};
@@ -133,7 +98,7 @@ int cmd_hash_object(int argc,
argc = parse_options(argc, argv, prefix, hash_object_options,
hash_object_usage, 0);
- if (flags & HASH_OBJECT_WRITE)
+ if (flags & INDEX_WRITE_OBJECT)
prefix = setup_git_directory();
else
prefix = setup_git_directory_gently(&nongit);
@@ -169,7 +134,7 @@ int cmd_hash_object(int argc,
}
if (hashstdin)
- hash_fd(0, type, vpath, flags, literally);
+ hash_fd(0, type, vpath, flags);
for (i = 0 ; i < argc; i++) {
const char *arg = argv[i];
@@ -178,12 +143,12 @@ int cmd_hash_object(int argc,
if (prefix)
arg = to_free = prefix_filename(prefix, arg);
hash_object(arg, type, no_filters ? NULL : vpath ? vpath : arg,
- flags, literally);
+ flags);
free(to_free);
}
if (stdin_paths)
- hash_stdin_paths(type, no_filters, flags, literally);
+ hash_stdin_paths(type, no_filters, flags);
free(vpath_free);
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 4aafa73c61..7f41665dfd 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -490,6 +490,9 @@ static int real_merge(struct merge_tree_options *o,
if (result.clean < 0)
die(_("failure to merge"));
+ if (o->merge_options.mergeability_only)
+ goto cleanup;
+
if (show_messages == -1)
show_messages = !result.clean;
@@ -522,6 +525,8 @@ static int real_merge(struct merge_tree_options *o,
}
if (o->use_stdin)
putchar(line_termination);
+
+cleanup:
merge_finalize(&opt, &result);
clear_merge_options(&opt);
return !result.clean; /* result.clean < 0 handled above */
@@ -538,6 +543,7 @@ int cmd_merge_tree(int argc,
int original_argc;
const char *merge_base = NULL;
int ret;
+ int quiet = 0;
const char * const merge_tree_usage[] = {
N_("git merge-tree [--write-tree] [<options>] <branch1> <branch2>"),
@@ -552,6 +558,10 @@ int cmd_merge_tree(int argc,
N_("do a trivial merge only"), MODE_TRIVIAL),
OPT_BOOL(0, "messages", &o.show_messages,
N_("also show informational/conflict messages")),
+ OPT_BOOL_F(0, "quiet",
+ &quiet,
+ N_("suppress all output; only exit status wanted"),
+ PARSE_OPT_NONEG),
OPT_SET_INT('z', NULL, &line_termination,
N_("separate paths with the NUL character"), '\0'),
OPT_BOOL_F(0, "name-only",
@@ -583,6 +593,14 @@ int cmd_merge_tree(int argc,
argc = parse_options(argc, argv, prefix, mt_options,
merge_tree_usage, PARSE_OPT_STOP_AT_NON_OPTION);
+ if (quiet && o.show_messages == -1)
+ o.show_messages = 0;
+ o.merge_options.mergeability_only = quiet;
+ die_for_incompatible_opt2(quiet, "--quiet", o.show_messages, "--messages");
+ die_for_incompatible_opt2(quiet, "--quiet", o.name_only, "--name-only");
+ die_for_incompatible_opt2(quiet, "--quiet", o.use_stdin, "--stdin");
+ die_for_incompatible_opt2(quiet, "--quiet", !line_termination, "-z");
+
if (xopts.nr && o.mode == MODE_TRIVIAL)
die(_("--trivial-merge is incompatible with all other options"));
for (size_t x = 0; x < xopts.nr; x++)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index c92e57ba18..a317d6c278 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -81,6 +81,7 @@ static int prefer_ofs_delta = 1;
static int auto_update_server_info;
static int auto_gc = 1;
static int reject_thin;
+static int skip_connectivity_check;
static int stateless_rpc;
static const char *service_dir;
static const char *head_name;
@@ -1938,27 +1939,29 @@ static void execute_commands(struct command *commands,
return;
}
- if (use_sideband) {
- memset(&muxer, 0, sizeof(muxer));
- muxer.proc = copy_to_sideband;
- muxer.in = -1;
- if (!start_async(&muxer))
- err_fd = muxer.in;
- /* ...else, continue without relaying sideband */
- }
+ if (!skip_connectivity_check) {
+ if (use_sideband) {
+ memset(&muxer, 0, sizeof(muxer));
+ muxer.proc = copy_to_sideband;
+ muxer.in = -1;
+ if (!start_async(&muxer))
+ err_fd = muxer.in;
+ /* ...else, continue without relaying sideband */
+ }
- data.cmds = commands;
- data.si = si;
- opt.err_fd = err_fd;
- opt.progress = err_fd && !quiet;
- opt.env = tmp_objdir_env(tmp_objdir);
- opt.exclude_hidden_refs_section = "receive";
+ data.cmds = commands;
+ data.si = si;
+ opt.err_fd = err_fd;
+ opt.progress = err_fd && !quiet;
+ opt.env = tmp_objdir_env(tmp_objdir);
+ opt.exclude_hidden_refs_section = "receive";
- if (check_connected(iterate_receive_command_list, &data, &opt))
- set_connectivity_errors(commands, si);
+ if (check_connected(iterate_receive_command_list, &data, &opt))
+ set_connectivity_errors(commands, si);
- if (use_sideband)
- finish_async(&muxer);
+ if (use_sideband)
+ finish_async(&muxer);
+ }
reject_updates_to_hidden(commands);
@@ -2519,6 +2522,7 @@ int cmd_receive_pack(int argc,
struct option options[] = {
OPT__QUIET(&quiet, N_("quiet")),
+ OPT_HIDDEN_BOOL(0, "skip-connectivity-check", &skip_connectivity_check, NULL),
OPT_HIDDEN_BOOL(0, "stateless-rpc", &stateless_rpc, NULL),
OPT_HIDDEN_BOOL(0, "http-backend-info-refs", &advertise_refs, NULL),
OPT_ALIAS(0, "advertise-refs", "http-backend-info-refs"),
diff --git a/builtin/replay.c b/builtin/replay.c
index 032c172b65..225cef0880 100644
--- a/builtin/replay.c
+++ b/builtin/replay.c
@@ -20,21 +20,22 @@
#include <oidset.h>
#include <tree.h>
-static const char *short_commit_name(struct commit *commit)
+static const char *short_commit_name(struct repository *repo,
+ struct commit *commit)
{
- return repo_find_unique_abbrev(the_repository, &commit->object.oid,
+ return repo_find_unique_abbrev(repo, &commit->object.oid,
DEFAULT_ABBREV);
}
-static struct commit *peel_committish(const char *name)
+static struct commit *peel_committish(struct repository *repo, const char *name)
{
struct object *obj;
struct object_id oid;
- if (repo_get_oid(the_repository, name, &oid))
+ if (repo_get_oid(repo, name, &oid))
return NULL;
- obj = parse_object(the_repository, &oid);
- return (struct commit *)repo_peel_to_type(the_repository, name, 0, obj,
+ obj = parse_object(repo, &oid);
+ return (struct commit *)repo_peel_to_type(repo, name, 0, obj,
OBJ_COMMIT);
}
@@ -50,7 +51,8 @@ static char *get_author(const char *message)
return NULL;
}
-static struct commit *create_commit(struct tree *tree,
+static struct commit *create_commit(struct repository *repo,
+ struct tree *tree,
struct commit *based_on,
struct commit *parent)
{
@@ -62,7 +64,7 @@ static struct commit *create_commit(struct tree *tree,
struct commit_extra_header *extra = NULL;
struct strbuf msg = STRBUF_INIT;
const char *out_enc = get_commit_output_encoding();
- const char *message = repo_logmsg_reencode(the_repository, based_on,
+ const char *message = repo_logmsg_reencode(repo, based_on,
NULL, out_enc);
const char *orig_message = NULL;
const char *exclude_gpgsig[] = { "gpgsig", NULL };
@@ -79,7 +81,7 @@ static struct commit *create_commit(struct tree *tree,
goto out;
}
- obj = parse_object(the_repository, &ret);
+ obj = parse_object(repo, &ret);
out:
free_commit_extra_headers(extra);
@@ -97,7 +99,8 @@ struct ref_info {
int negative_refexprs;
};
-static void get_ref_information(struct rev_cmdline_info *cmd_info,
+static void get_ref_information(struct repository *repo,
+ struct rev_cmdline_info *cmd_info,
struct ref_info *ref_info)
{
int i;
@@ -132,14 +135,14 @@ static void get_ref_information(struct rev_cmdline_info *cmd_info,
if (*refexpr == '^')
refexpr++;
- if (repo_dwim_ref(the_repository, refexpr, strlen(refexpr), &oid, &fullname, 0) != 1)
+ if (repo_dwim_ref(repo, refexpr, strlen(refexpr), &oid, &fullname, 0) != 1)
can_uniquely_dwim = 0;
if (e->flags & BOTTOM) {
if (can_uniquely_dwim)
strset_add(&ref_info->negative_refs, fullname);
if (!ref_info->negative_refexprs)
- ref_info->onto = lookup_commit_reference_gently(the_repository,
+ ref_info->onto = lookup_commit_reference_gently(repo,
&e->item->oid, 1);
ref_info->negative_refexprs++;
} else {
@@ -152,7 +155,8 @@ static void get_ref_information(struct rev_cmdline_info *cmd_info,
}
}
-static void determine_replay_mode(struct rev_cmdline_info *cmd_info,
+static void determine_replay_mode(struct repository *repo,
+ struct rev_cmdline_info *cmd_info,
const char *onto_name,
char **advance_name,
struct commit **onto,
@@ -160,14 +164,14 @@ static void determine_replay_mode(struct rev_cmdline_info *cmd_info,
{
struct ref_info rinfo;
- get_ref_information(cmd_info, &rinfo);
+ get_ref_information(repo, cmd_info, &rinfo);
if (!rinfo.positive_refexprs)
die(_("need some commits to replay"));
die_for_incompatible_opt2(!!onto_name, "--onto",
!!*advance_name, "--advance");
if (onto_name) {
- *onto = peel_committish(onto_name);
+ *onto = peel_committish(repo, onto_name);
if (rinfo.positive_refexprs <
strset_get_size(&rinfo.positive_refs))
die(_("all positive revisions given must be references"));
@@ -175,8 +179,8 @@ static void determine_replay_mode(struct rev_cmdline_info *cmd_info,
struct object_id oid;
char *fullname = NULL;
- *onto = peel_committish(*advance_name);
- if (repo_dwim_ref(the_repository, *advance_name, strlen(*advance_name),
+ *onto = peel_committish(repo, *advance_name);
+ if (repo_dwim_ref(repo, *advance_name, strlen(*advance_name),
&oid, &fullname, 0) == 1) {
free(*advance_name);
*advance_name = fullname;
@@ -245,7 +249,8 @@ static struct commit *mapped_commit(kh_oid_map_t *replayed_commits,
return kh_value(replayed_commits, pos);
}
-static struct commit *pick_regular_commit(struct commit *pickme,
+static struct commit *pick_regular_commit(struct repository *repo,
+ struct commit *pickme,
kh_oid_map_t *replayed_commits,
struct commit *onto,
struct merge_options *merge_opt,
@@ -257,12 +262,12 @@ static struct commit *pick_regular_commit(struct commit *pickme,
base = pickme->parents->item;
replayed_base = mapped_commit(replayed_commits, base, onto);
- result->tree = repo_get_commit_tree(the_repository, replayed_base);
- pickme_tree = repo_get_commit_tree(the_repository, pickme);
- base_tree = repo_get_commit_tree(the_repository, base);
+ result->tree = repo_get_commit_tree(repo, replayed_base);
+ pickme_tree = repo_get_commit_tree(repo, pickme);
+ base_tree = repo_get_commit_tree(repo, base);
- merge_opt->branch1 = short_commit_name(replayed_base);
- merge_opt->branch2 = short_commit_name(pickme);
+ merge_opt->branch1 = short_commit_name(repo, replayed_base);
+ merge_opt->branch2 = short_commit_name(repo, pickme);
merge_opt->ancestor = xstrfmt("parent of %s", merge_opt->branch2);
merge_incore_nonrecursive(merge_opt,
@@ -275,13 +280,13 @@ static struct commit *pick_regular_commit(struct commit *pickme,
merge_opt->ancestor = NULL;
if (!result->clean)
return NULL;
- return create_commit(result->tree, pickme, replayed_base);
+ return create_commit(repo, result->tree, pickme, replayed_base);
}
int cmd_replay(int argc,
const char **argv,
const char *prefix,
- struct repository *repo UNUSED)
+ struct repository *repo)
{
const char *advance_name_opt = NULL;
char *advance_name = NULL;
@@ -329,7 +334,7 @@ int cmd_replay(int argc,
"--advance", "--contained");
advance_name = xstrdup_or_null(advance_name_opt);
- repo_init_revisions(the_repository, &revs, prefix);
+ repo_init_revisions(repo, &revs, prefix);
/*
* Set desired values for rev walking options here. If they
@@ -380,7 +385,7 @@ int cmd_replay(int argc,
revs.simplify_history = 0;
}
- determine_replay_mode(&revs.cmdline, onto_name, &advance_name,
+ determine_replay_mode(repo, &revs.cmdline, onto_name, &advance_name,
&onto, &update_refs);
if (!onto) /* FIXME: Should handle replaying down to root commit */
@@ -391,7 +396,7 @@ int cmd_replay(int argc,
goto cleanup;
}
- init_basic_merge_options(&merge_opt, the_repository);
+ init_basic_merge_options(&merge_opt, repo);
memset(&result, 0, sizeof(result));
merge_opt.show_rename_progress = 0;
last_commit = onto;
@@ -406,8 +411,8 @@ int cmd_replay(int argc,
if (commit->parents->next)
die(_("replaying merge commits is not supported yet!"));
- last_commit = pick_regular_commit(commit, replayed_commits, onto,
- &merge_opt, &result);
+ last_commit = pick_regular_commit(repo, commit, replayed_commits,
+ onto, &merge_opt, &result);
if (!last_commit)
break;
diff --git a/builtin/reset.c b/builtin/reset.c
index 73b4537a9a..dc50ffc1ac 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -420,6 +420,9 @@ int cmd_reset(int argc,
oidcpy(&oid, &tree->object.oid);
}
+ prepare_repo_settings(the_repository);
+ the_repository->settings.command_requires_full_index = 0;
+
if (patch_mode) {
if (reset_type != NONE)
die(_("options '%s' and '%s' cannot be used together"), "--patch", "--{hard,mixed,soft}");
@@ -457,9 +460,6 @@ int cmd_reset(int argc,
if (intent_to_add && reset_type != MIXED)
die(_("the option '%s' requires '%s'"), "-N", "--mixed");
- prepare_repo_settings(the_repository);
- the_repository->settings.command_requires_full_index = 0;
-
if (repo_read_index(the_repository) < 0)
die(_("index file corrupt"));
diff --git a/bundle-uri.c b/bundle-uri.c
index dc120664d1..9accf157b4 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -532,11 +532,13 @@ static int fetch_bundles_by_token(struct repository *r,
*/
if (!repo_config_get_value(r,
"fetch.bundlecreationtoken",
- &creationTokenStr) &&
- sscanf(creationTokenStr, "%"PRIu64, &maxCreationToken) == 1 &&
- bundles.items[0]->creationToken <= maxCreationToken) {
- free(bundles.items);
- return 0;
+ &creationTokenStr)) {
+ if (sscanf(creationTokenStr, "%"PRIu64, &maxCreationToken) != 1)
+ maxCreationToken = 0;
+ if (bundles.items[0]->creationToken <= maxCreationToken) {
+ free(bundles.items);
+ return 0;
+ }
}
/*
diff --git a/commit-graph.c b/commit-graph.c
index 4a6e34f8a0..ad3943b690 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1929,6 +1929,8 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,
}
if (open_pack_index(p)) {
ret = error(_("error opening index for %s"), packname.buf);
+ close_pack(p);
+ free(p);
goto cleanup;
}
for_each_object_in_pack(p, add_packed_commits, ctx,
@@ -2509,7 +2511,17 @@ int write_commit_graph(struct object_directory *odb,
const struct commit_graph_opts *opts)
{
struct repository *r = the_repository;
- struct write_commit_graph_context *ctx;
+ struct write_commit_graph_context ctx = {
+ .r = r,
+ .odb = odb,
+ .append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0,
+ .report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0,
+ .split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0,
+ .opts = opts,
+ .total_bloom_filter_data_size = 0,
+ .write_generation_data = (get_configured_generation_version(r) == 2),
+ .num_generation_data_overflows = 0,
+ };
uint32_t i;
int res = 0;
int replace = 0;
@@ -2531,17 +2543,6 @@ int write_commit_graph(struct object_directory *odb,
return 0;
}
- CALLOC_ARRAY(ctx, 1);
- ctx->r = r;
- ctx->odb = odb;
- ctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0;
- ctx->report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0;
- ctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0;
- ctx->opts = opts;
- ctx->total_bloom_filter_data_size = 0;
- ctx->write_generation_data = (get_configured_generation_version(r) == 2);
- ctx->num_generation_data_overflows = 0;
-
bloom_settings.hash_version = r->settings.commit_graph_changed_paths_version;
bloom_settings.bits_per_entry = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY",
bloom_settings.bits_per_entry);
@@ -2549,14 +2550,14 @@ int write_commit_graph(struct object_directory *odb,
bloom_settings.num_hashes);
bloom_settings.max_changed_paths = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_MAX_CHANGED_PATHS",
bloom_settings.max_changed_paths);
- ctx->bloom_settings = &bloom_settings;
+ ctx.bloom_settings = &bloom_settings;
init_topo_level_slab(&topo_levels);
- ctx->topo_levels = &topo_levels;
+ ctx.topo_levels = &topo_levels;
- prepare_commit_graph(ctx->r);
- if (ctx->r->objects->commit_graph) {
- struct commit_graph *g = ctx->r->objects->commit_graph;
+ prepare_commit_graph(ctx.r);
+ if (ctx.r->objects->commit_graph) {
+ struct commit_graph *g = ctx.r->objects->commit_graph;
while (g) {
g->topo_levels = &topo_levels;
@@ -2565,15 +2566,15 @@ int write_commit_graph(struct object_directory *odb,
}
if (flags & COMMIT_GRAPH_WRITE_BLOOM_FILTERS)
- ctx->changed_paths = 1;
+ ctx.changed_paths = 1;
if (!(flags & COMMIT_GRAPH_NO_WRITE_BLOOM_FILTERS)) {
struct commit_graph *g;
- g = ctx->r->objects->commit_graph;
+ g = ctx.r->objects->commit_graph;
/* We have changed-paths already. Keep them in the next graph */
if (g && g->bloom_filter_settings) {
- ctx->changed_paths = 1;
+ ctx.changed_paths = 1;
/* don't propagate the hash_version unless unspecified */
if (bloom_settings.hash_version == -1)
@@ -2586,116 +2587,123 @@ int write_commit_graph(struct object_directory *odb,
bloom_settings.hash_version = bloom_settings.hash_version == 2 ? 2 : 1;
- if (ctx->split) {
- struct commit_graph *g = ctx->r->objects->commit_graph;
+ if (ctx.split) {
+ struct commit_graph *g = ctx.r->objects->commit_graph;
while (g) {
- ctx->num_commit_graphs_before++;
+ ctx.num_commit_graphs_before++;
g = g->base_graph;
}
- if (ctx->num_commit_graphs_before) {
- ALLOC_ARRAY(ctx->commit_graph_filenames_before, ctx->num_commit_graphs_before);
- i = ctx->num_commit_graphs_before;
- g = ctx->r->objects->commit_graph;
+ if (ctx.num_commit_graphs_before) {
+ ALLOC_ARRAY(ctx.commit_graph_filenames_before, ctx.num_commit_graphs_before);
+ i = ctx.num_commit_graphs_before;
+ g = ctx.r->objects->commit_graph;
while (g) {
- ctx->commit_graph_filenames_before[--i] = xstrdup(g->filename);
+ ctx.commit_graph_filenames_before[--i] = xstrdup(g->filename);
g = g->base_graph;
}
}
- if (ctx->opts)
- replace = ctx->opts->split_flags & COMMIT_GRAPH_SPLIT_REPLACE;
+ if (ctx.opts)
+ replace = ctx.opts->split_flags & COMMIT_GRAPH_SPLIT_REPLACE;
}
- ctx->approx_nr_objects = repo_approximate_object_count(the_repository);
+ ctx.approx_nr_objects = repo_approximate_object_count(the_repository);
- if (ctx->append && ctx->r->objects->commit_graph) {
- struct commit_graph *g = ctx->r->objects->commit_graph;
+ if (ctx.append && ctx.r->objects->commit_graph) {
+ struct commit_graph *g = ctx.r->objects->commit_graph;
for (i = 0; i < g->num_commits; i++) {
struct object_id oid;
oidread(&oid, g->chunk_oid_lookup + st_mult(g->hash_len, i),
the_repository->hash_algo);
- oid_array_append(&ctx->oids, &oid);
+ oid_array_append(&ctx.oids, &oid);
}
}
if (pack_indexes) {
- ctx->order_by_pack = 1;
- if ((res = fill_oids_from_packs(ctx, pack_indexes)))
+ ctx.order_by_pack = 1;
+ if ((res = fill_oids_from_packs(&ctx, pack_indexes)))
goto cleanup;
}
if (commits) {
- if ((res = fill_oids_from_commits(ctx, commits)))
+ if ((res = fill_oids_from_commits(&ctx, commits)))
goto cleanup;
}
if (!pack_indexes && !commits) {
- ctx->order_by_pack = 1;
- fill_oids_from_all_packs(ctx);
+ ctx.order_by_pack = 1;
+ fill_oids_from_all_packs(&ctx);
}
- close_reachable(ctx);
+ close_reachable(&ctx);
- copy_oids_to_commits(ctx);
+ copy_oids_to_commits(&ctx);
- if (ctx->commits.nr >= GRAPH_EDGE_LAST_MASK) {
+ if (ctx.commits.nr >= GRAPH_EDGE_LAST_MASK) {
error(_("too many commits to write graph"));
res = -1;
goto cleanup;
}
- if (!ctx->commits.nr && !replace)
+ if (!ctx.commits.nr && !replace)
goto cleanup;
- if (ctx->split) {
- split_graph_merge_strategy(ctx);
+ if (ctx.split) {
+ split_graph_merge_strategy(&ctx);
if (!replace)
- merge_commit_graphs(ctx);
+ merge_commit_graphs(&ctx);
} else
- ctx->num_commit_graphs_after = 1;
+ ctx.num_commit_graphs_after = 1;
- ctx->trust_generation_numbers = validate_mixed_generation_chain(ctx->r->objects->commit_graph);
+ ctx.trust_generation_numbers = validate_mixed_generation_chain(ctx.r->objects->commit_graph);
- compute_topological_levels(ctx);
- if (ctx->write_generation_data)
- compute_generation_numbers(ctx);
+ compute_topological_levels(&ctx);
+ if (ctx.write_generation_data)
+ compute_generation_numbers(&ctx);
- if (ctx->changed_paths)
- compute_bloom_filters(ctx);
+ if (ctx.changed_paths)
+ compute_bloom_filters(&ctx);
- res = write_commit_graph_file(ctx);
+ res = write_commit_graph_file(&ctx);
- if (ctx->changed_paths)
+ if (ctx.changed_paths)
deinit_bloom_filters();
- if (ctx->split)
- mark_commit_graphs(ctx);
+ if (ctx.split)
+ mark_commit_graphs(&ctx);
- expire_commit_graphs(ctx);
+ expire_commit_graphs(&ctx);
cleanup:
- free(ctx->graph_name);
- free(ctx->base_graph_name);
- free(ctx->commits.list);
- oid_array_clear(&ctx->oids);
+ free(ctx.graph_name);
+ free(ctx.base_graph_name);
+ free(ctx.commits.list);
+ oid_array_clear(&ctx.oids);
clear_topo_level_slab(&topo_levels);
- for (i = 0; i < ctx->num_commit_graphs_before; i++)
- free(ctx->commit_graph_filenames_before[i]);
- free(ctx->commit_graph_filenames_before);
+ if (ctx.r->objects->commit_graph) {
+ struct commit_graph *g = ctx.r->objects->commit_graph;
- for (i = 0; i < ctx->num_commit_graphs_after; i++) {
- free(ctx->commit_graph_filenames_after[i]);
- free(ctx->commit_graph_hash_after[i]);
+ while (g) {
+ g->topo_levels = NULL;
+ g = g->base_graph;
+ }
}
- free(ctx->commit_graph_filenames_after);
- free(ctx->commit_graph_hash_after);
- free(ctx);
+ for (i = 0; i < ctx.num_commit_graphs_before; i++)
+ free(ctx.commit_graph_filenames_before[i]);
+ free(ctx.commit_graph_filenames_before);
+
+ for (i = 0; i < ctx.num_commit_graphs_after; i++) {
+ free(ctx.commit_graph_filenames_after[i]);
+ free(ctx.commit_graph_hash_after[i]);
+ }
+ free(ctx.commit_graph_filenames_after);
+ free(ctx.commit_graph_hash_after);
return res;
}
diff --git a/configure.ac b/configure.ac
index d7e0503f1e..f6caab919a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1069,9 +1069,28 @@ GIT_CONF_SUBST([CHARSET_LIB])
#
# Define HAVE_SYSINFO=YesPlease if sysinfo is available.
-GIT_CHECK_FUNC(sysinfo,
- [HAVE_SYSINFO=YesPlease],
- [HAVE_SYSINFO=])
+#
+AC_DEFUN([HAVE_SYSINFO_SRC], [
+AC_LANG_PROGRAM([[
+#include <stdint.h>
+#include <sys/sysinfo.h>
+]], [[
+struct sysinfo si;
+uint64_t t = 0;
+if (!sysinfo(&si)) {
+ t = si.totalram;
+ if (si.mem_unit > 1)
+ t *= (uint64_t)si.mem_unit;
+}
+return t;
+]])])
+
+AC_MSG_CHECKING([for sysinfo])
+AC_COMPILE_IFELSE([HAVE_SYSINFO_SRC],
+ [AC_MSG_RESULT([yes])
+ HAVE_SYSINFO=YesPlease],
+ [AC_MSG_RESULT([no])
+ HAVE_SYSINFO=])
GIT_CONF_SUBST([HAVE_SYSINFO])
#
diff --git a/fsck.h b/fsck.h
index b1deae61ee..0c5869ac34 100644
--- a/fsck.h
+++ b/fsck.h
@@ -84,6 +84,7 @@ enum fsck_msg_type {
FUNC(LARGE_PATHNAME, WARN) \
/* infos (reported as warnings, but ignored by default) */ \
FUNC(BAD_FILEMODE, INFO) \
+ FUNC(EMPTY_PACKED_REFS_FILE, INFO) \
FUNC(GITMODULES_PARSE, INFO) \
FUNC(GITIGNORE_SYMLINK, INFO) \
FUNC(GITATTRIBUTES_SYMLINK, INFO) \
diff --git a/git-compat-util.h b/git-compat-util.h
index 36b9577c8d..4678e21c4c 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -668,6 +668,22 @@ static inline int cast_size_t_to_int(size_t a)
return (int)a;
}
+static inline uint64_t u64_mult(uint64_t a, uint64_t b)
+{
+ if (unsigned_mult_overflows(a, b))
+ die("uint64_t overflow: %"PRIuMAX" * %"PRIuMAX,
+ (uintmax_t)a, (uintmax_t)b);
+ return a * b;
+}
+
+static inline uint64_t u64_add(uint64_t a, uint64_t b)
+{
+ if (unsigned_add_overflows(a, b))
+ die("uint64_t overflow: %"PRIuMAX" + %"PRIuMAX,
+ (uintmax_t)a, (uintmax_t)b);
+ return a + b;
+}
+
/*
* Limit size of IO chunks, because huge chunks only cause pain. OS X
* 64-bit is buggy, returning EINVAL if len >= INT_MAX; and even in
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index a4e1bad33c..d8d5422cbc 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -4986,13 +4986,13 @@ sub gethistorydense
return $result;
}
-=head2 escapeRefName
+=head2 unescapeRefName
-Apply an escape mechanism to compensate for characters that
+Undo an escape mechanism to compensate for characters that
git ref names can have that CVS tags can not.
=cut
-sub escapeRefName
+sub unescapeRefName
{
my($self,$refName)=@_;
@@ -5009,27 +5009,6 @@ sub escapeRefName
# = "_-xx-" Where "xx" is the hexadecimal representation of the
# desired ASCII character byte. (for anything else)
- if(! $refName=~/^[1-9][0-9]*(\.[1-9][0-9]*)*$/)
- {
- $refName=~s/_-/_-u--/g;
- $refName=~s/\./_-p-/g;
- $refName=~s%/%_-s-%g;
- $refName=~s/[^-_a-zA-Z0-9]/sprintf("_-%02x-",$1)/eg;
- }
-}
-
-=head2 unescapeRefName
-
-Undo an escape mechanism to compensate for characters that
-git ref names can have that CVS tags can not.
-
-=cut
-sub unescapeRefName
-{
- my($self,$refName)=@_;
-
- # see escapeRefName() for description of escape mechanism.
-
$refName=~s/_-([spu]|[0-9a-f][0-9a-f])-/unescapeRefNameChar($1)/eg;
# allowed tag names
diff --git a/git-gui/.gitattributes b/git-gui/.gitattributes
index 118d56cfbd..889d58257f 100644
--- a/git-gui/.gitattributes
+++ b/git-gui/.gitattributes
@@ -4,3 +4,4 @@ git-gui.sh encoding=UTF-8
/po/*.po encoding=UTF-8
/GIT-VERSION-GEN eol=lf
Makefile whitespace=!indent,trail,space
+meson.build whitespace=space
diff --git a/git-gui/.gitignore b/git-gui/.gitignore
index 6483b21cbf..ff6e0be4b4 100644
--- a/git-gui/.gitignore
+++ b/git-gui/.gitignore
@@ -2,7 +2,7 @@
config.mak
Git Gui.app*
git-gui.tcl
+GIT-GUI-BUILD-OPTIONS
GIT-VERSION-FILE
-GIT-GUI-VARS
git-gui
lib/tclIndex
diff --git a/git-gui/GIT-GUI-BUILD-OPTIONS.in b/git-gui/GIT-GUI-BUILD-OPTIONS.in
new file mode 100644
index 0000000000..5fd885c2bf
--- /dev/null
+++ b/git-gui/GIT-GUI-BUILD-OPTIONS.in
@@ -0,0 +1,7 @@
+GITGUI_GITEXECDIR=@GITGUI_GITEXECDIR@
+GITGUI_LIBDIR=@GITGUI_LIBDIR@
+GITGUI_RELATIVE=@GITGUI_RELATIVE@
+SHELL_PATH=@SHELL_PATH@
+TCLTK_PATH=@TCLTK_PATH@
+TCL_PATH=@TCL_PATH@
+TKEXECUTABLE=@TKEXECUTABLE@
diff --git a/git-gui/GIT-VERSION-GEN b/git-gui/GIT-VERSION-GEN
index 92373d251a..c2767b4136 100755
--- a/git-gui/GIT-VERSION-GEN
+++ b/git-gui/GIT-VERSION-GEN
@@ -1,19 +1,33 @@
#!/bin/sh
-GVF=GIT-VERSION-FILE
DEF_VER=0.21.GITGUI
LF='
'
+if test "$#" -ne 2
+then
+ echo >&2 "usage: $0 <SOURCE_DIR> <OUTPUT>"
+ exit 1
+fi
+
+SOURCE_DIR="$1"
+OUTPUT="$2"
+
+# Protect us from reading Git version information outside of the Git directory
+# in case it is not a repository itself, but embedded in an unrelated
+# repository.
+GIT_CEILING_DIRECTORIES="$SOURCE_DIR/.."
+export GIT_CEILING_DIRECTORIES
+
tree_search ()
{
head=$1
tree=$2
- for p in $(git rev-list --parents --max-count=1 $head 2>/dev/null)
+ for p in $(git -C "$SOURCE_DIR" rev-list --parents --max-count=1 $head 2>/dev/null)
do
- test $tree = $(git rev-parse $p^{tree} 2>/dev/null) &&
- vn=$(git describe --abbrev=4 $p 2>/dev/null) &&
+ test $tree = $(git -C "$SOURCE_DIR" rev-parse $p^{tree} 2>/dev/null) &&
+ vn=$(git -C "$SOURCE_DIR" describe --abbrev=4 $p 2>/dev/null) &&
case "$vn" in
gitgui-[0-9]*) echo $vn; break;;
esac
@@ -34,14 +48,14 @@ tree_search ()
# If we are at the toplevel or the merge assumption fails
# try looking for a gitgui-* tag.
-if test -f version &&
- VN=$(cat version)
+if test -f "$SOURCE_DIR"/version &&
+ VN=$(cat "$SOURCE_DIR"/version)
then
: happy
-elif prefix="$(git rev-parse --show-prefix 2>/dev/null)"
+elif prefix="$(git -C "$SOURCE_DIR" rev-parse --show-prefix 2>/dev/null)"
test -n "$prefix" &&
- head=$(git rev-list --max-count=1 HEAD -- . 2>/dev/null) &&
- tree=$(git rev-parse --verify "HEAD:$prefix" 2>/dev/null) &&
+ head=$(git -C "$SOURCE_DIR" rev-list --max-count=1 HEAD -- . 2>/dev/null) &&
+ tree=$(git -C "$SOURCE_DIR" rev-parse --verify "HEAD:$prefix" 2>/dev/null) &&
VN=$(tree_search $head $tree)
case "$VN" in
gitgui-[0-9]*) : happy ;;
@@ -49,7 +63,7 @@ elif prefix="$(git rev-parse --show-prefix 2>/dev/null)"
esac
then
VN=$(echo "$VN" | sed -e 's/^gitgui-//;s/-/./g');
-elif VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
+elif VN=$(git -C "$SOURCE_DIR" describe --abbrev=4 HEAD 2>/dev/null) &&
case "$VN" in
gitgui-[0-9]*) : happy ;;
*) (exit 1) ;;
@@ -60,7 +74,7 @@ else
VN="$DEF_VER"
fi
-dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=
+dirty=$(git -C "$SOURCE_DIR" diff-index --name-only HEAD 2>/dev/null) || dirty=
case "$dirty" in
'')
;;
@@ -68,13 +82,13 @@ case "$dirty" in
VN="$VN-dirty" ;;
esac
-if test -r $GVF
+if test -r "$OUTPUT"
then
- VC=$(sed -e 's/^GITGUI_VERSION = //' <$GVF)
+ VC=$(sed -e 's/^GITGUI_VERSION=//' <"$OUTPUT")
else
VC=unset
fi
test "$VN" = "$VC" || {
- echo >&2 "GITGUI_VERSION = $VN"
- echo "GITGUI_VERSION = $VN" >$GVF
+ echo >&2 "GITGUI_VERSION=$VN"
+ echo "GITGUI_VERSION=$VN" >"$OUTPUT"
}
diff --git a/git-gui/Makefile b/git-gui/Makefile
index e3b4f324b6..8672dd2d6b 100644
--- a/git-gui/Makefile
+++ b/git-gui/Makefile
@@ -9,10 +9,7 @@ all::
#
GIT-VERSION-FILE: FORCE
- @$(SHELL_PATH) ./GIT-VERSION-GEN
-ifneq ($(MAKECMDGOALS),clean)
--include GIT-VERSION-FILE
-endif
+ @$(SHELL_PATH) ./GIT-VERSION-GEN . $@
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
@@ -76,7 +73,6 @@ ifndef V
QUIET_INDEX = $(QUIET)echo ' ' INDEX $(dir $@) &&
QUIET_MSGFMT0 = $(QUIET)printf ' MSGFMT %12s ' $@ && v=`
QUIET_MSGFMT1 = 2>&1` && echo "$$v" | sed -e 's/fuzzy translations/fuzzy/' | sed -e 's/ messages*//g'
- QUIET_2DEVNULL = 2>/dev/null
INSTALL_D0 = dir=
INSTALL_D1 = && echo ' ' DEST $$dir && $(INSTALL) -d -m 755 "$$dir"
@@ -114,7 +110,8 @@ ifeq ($(uname_S),Darwin)
TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish\ Shell.app
endif
endif
- TKEXECUTABLE = $(shell basename "$(TKFRAMEWORK)" .app)
+ TKEXECUTABLE = $(TKFRAMEWORK)/Contents/MacOS/$(shell basename "$(TKFRAMEWORK)" .app)
+ TKEXECUTABLE_SQ = $(subst ','\'',$(TKEXECUTABLE))
endif
ifeq ($(findstring $(firstword -$(MAKEFLAGS)),s),s)
@@ -128,21 +125,17 @@ gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH))
TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
-TCLTK_PATH_SED = $(subst ','\'',$(subst \,\\,$(TCLTK_PATH)))
gg_libdir ?= $(sharedir)/git-gui/lib
libdir_SQ = $(subst ','\'',$(gg_libdir))
-libdir_SED = $(subst ','\'',$(subst \,\\,$(gg_libdir_sed_in)))
exedir = $(dir $(gitexecdir))share/git-gui/lib
-GITGUI_SCRIPT := $$0
GITGUI_RELATIVE :=
GITGUI_MACOSXAPP :=
ifeq ($(exedir),$(gg_libdir))
GITGUI_RELATIVE := 1
endif
-gg_libdir_sed_in := $(gg_libdir)
ifeq ($(uname_S),Darwin)
ifeq ($(shell test -d $(TKFRAMEWORK) && echo y),y)
GITGUI_MACOSXAPP := YesPlease
@@ -159,41 +152,15 @@ endif
ifdef GITGUI_MACOSXAPP
GITGUI_MAIN := git-gui.tcl
-git-gui: GIT-VERSION-FILE GIT-GUI-VARS
- $(QUIET_GEN)rm -f $@ $@+ && \
- echo '#!$(SHELL_PATH_SQ)' >$@+ && \
- echo 'if test "z$$*" = zversion ||' >>$@+ && \
- echo ' test "z$$*" = z--version' >>$@+ && \
- echo then >>$@+ && \
- echo ' 'echo \'git-gui version '$(GITGUI_VERSION)'\' >>$@+ && \
- echo else >>$@+ && \
- echo ' libdir="$${GIT_GUI_LIB_DIR:-$(libdir_SQ)}"' >>$@+ && \
- echo ' 'exec \"'$$libdir/Git Gui.app/Contents/MacOS/$(subst \,,$(TKEXECUTABLE))'\" \
- '"$$0" "$$@"' >>$@+ && \
- echo fi >>$@+ && \
- chmod +x $@+ && \
- mv $@+ $@
-
-Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-VARS \
+git-gui: generate-macos-wrapper.sh GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
+ $(QUIET_GEN)$(SHELL_PATH) generate-macos-wrapper.sh "$@" ./GIT-GUI-BUILD-OPTIONS ./GIT-VERSION-FILE
+
+Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS \
macosx/Info.plist \
macosx/git-gui.icns \
macosx/AppMain.tcl \
- $(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)
- $(QUIET_GEN)rm -rf '$@' '$@'+ && \
- mkdir -p '$@'+/Contents/MacOS && \
- mkdir -p '$@'+/Contents/Resources/Scripts && \
- cp '$(subst ','\'',$(subst \,,$(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)))' \
- '$@'+/Contents/MacOS && \
- cp macosx/git-gui.icns '$@'+/Contents/Resources && \
- sed -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
- -e 's/@@GITGUI_TKEXECUTABLE@@/$(TKEXECUTABLE)/g' \
- macosx/Info.plist \
- >'$@'+/Contents/Info.plist && \
- sed -e 's|@@gitexecdir@@|$(gitexecdir_SQ)|' \
- -e 's|@@GITGUI_LIBDIR@@|$(libdir_SED)|' \
- macosx/AppMain.tcl \
- >'$@'+/Contents/Resources/Scripts/AppMain.tcl && \
- mv '$@'+ '$@'
+ $(TKEXECUTABLE)
+ $(QUIET_GEN)$(SHELL_PATH) generate-macos-app.sh . "$@" ./GIT-GUI-BUILD-OPTIONS ./GIT-VERSION-FILE
endif
ifdef GITGUI_WINDOWS_WRAPPER
@@ -203,18 +170,8 @@ git-gui: windows/git-gui.sh
cp $< $@
endif
-$(GITGUI_MAIN): git-gui.sh GIT-VERSION-FILE GIT-GUI-VARS
- $(QUIET_GEN)rm -f $@ $@+ && \
- sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
- -e 's|@@SHELL_PATH@@|$(SHELL_PATH_SQ)|' \
- -e '1,30s|^ argv0=$$0| argv0=$(GITGUI_SCRIPT)|' \
- -e '1,30s|^ exec wish | exec '\''$(TCLTK_PATH_SED)'\'' |' \
- -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
- -e 's|@@GITGUI_RELATIVE@@|$(GITGUI_RELATIVE)|' \
- -e '$(GITGUI_RELATIVE)s|@@GITGUI_LIBDIR@@|$(libdir_SED)|' \
- git-gui.sh >$@+ && \
- chmod +x $@+ && \
- mv $@+ $@
+$(GITGUI_MAIN): git-gui.sh GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
+ $(QUIET_GEN)$(SHELL_PATH) generate-git-gui.sh "$<" "$@" ./GIT-GUI-BUILD-OPTIONS ./GIT-VERSION-FILE
XGETTEXT ?= xgettext
ifdef NO_MSGFMT
@@ -239,35 +196,21 @@ update-po:: $(PO_TEMPLATE)
$(ALL_MSGFILES): %.msg : %.po
$(QUIET_MSGFMT0)$(MSGFMT) --statistics --tcl -l $(basename $(notdir $<)) -d $(dir $@) $< $(QUIET_MSGFMT1)
-lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-VARS
- $(QUIET_INDEX)if echo \
- $(foreach p,$(PRELOAD_FILES),source $p\;) \
- auto_mkindex lib $(patsubst lib/%,%,$(sort $(ALL_LIBFILES))) \
- | $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \
- else \
- echo >&2 " * $(TCL_PATH) failed; using unoptimized loading"; \
- rm -f $@ ; \
- echo '# Autogenerated by git-gui Makefile' >$@ && \
- echo >>$@ && \
- $(foreach p,$(PRELOAD_FILES) $(sort $(ALL_LIBFILES)),echo '$(subst lib/,,$p)' >>$@ &&) \
- echo >>$@ ; \
- fi
-
-TRACK_VARS = \
- $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
- $(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
- $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
- $(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
- $(subst ','\'',gg_libdir='$(libdir_SQ)') \
- GITGUI_MACOSXAPP=$(GITGUI_MACOSXAPP) \
-#end TRACK_VARS
-
-GIT-GUI-VARS: FORCE
- @VARS='$(TRACK_VARS)'; \
- if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
- echo >&2 " * new locations or Tcl/Tk interpreter"; \
- echo >$@ "$$VARS"; \
- fi
+lib/tclIndex: $(ALL_LIBFILES) generate-tclindex.sh GIT-GUI-BUILD-OPTIONS
+ $(QUIET_INDEX)$(SHELL_PATH) generate-tclindex.sh . ./GIT-GUI-BUILD-OPTIONS $(ALL_LIBFILES)
+
+GIT-GUI-BUILD-OPTIONS: FORCE
+ @sed \
+ -e 's|@GITGUI_GITEXECDIR@|$(gitexecdir_SQ)|' \
+ -e 's|@GITGUI_LIBDIR@|$(libdir_SQ)|' \
+ -e 's|@GITGUI_RELATIVE@|$(GITGUI_RELATIVE)|' \
+ -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
+ -e 's|@TCLTK_PATH@|$(TCLTK_PATH_SQ)|' \
+ -e 's|@TCL_PATH@|$(TCL_PATH_SQ)|' \
+ -e 's|@TKEXECUTABLE@|$(TKEXECUTABLE_SQ)|' \
+ $@.in >$@+
+ @if grep -q '^[A-Z][A-Z_]*=@.*@$$' $@+; then echo "Unsubstituted build options in $@" >&2 && exit 1; fi
+ @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
ifdef GITGUI_MACOSXAPP
all:: git-gui Git\ Gui.app
@@ -317,13 +260,13 @@ endif
$(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(REMOVE_D1)
$(QUIET)$(REMOVE_D0)`dirname '$(DESTDIR_SQ)$(libdir_SQ)'` $(REMOVE_D1)
-dist-version:
+dist-version: GIT-VERSION-FILE
@mkdir -p $(TARDIR)
- @echo $(GITGUI_VERSION) > $(TARDIR)/version
+ @sed 's|^GITGUI_VERSION=||' <GIT-VERSION-FILE >$(TARDIR)/version
clean::
$(RM_RF) $(GITGUI_MAIN) lib/tclIndex po/*.msg $(PO_TEMPLATE)
- $(RM_RF) GIT-VERSION-FILE GIT-GUI-VARS
+ $(RM_RF) GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
ifdef GITGUI_MACOSXAPP
$(RM_RF) 'Git Gui.app'* git-gui
endif
diff --git a/git-gui/generate-git-gui.sh b/git-gui/generate-git-gui.sh
new file mode 100755
index 0000000000..39dfafdc4a
--- /dev/null
+++ b/git-gui/generate-git-gui.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+set -e
+
+if test "$#" -ne 4
+then
+ echo >&2 "usage: $0 <INPUT> <OUTPUT> <BUILD_OPTIONS> <VERSION_FILE>"
+ exit 1
+fi
+
+INPUT="$1"
+OUTPUT="$2"
+BUILD_OPTIONS="$3"
+VERSION_FILE="$4"
+
+. "${BUILD_OPTIONS}"
+. "${VERSION_FILE}"
+
+rm -f "$OUTPUT" "$OUTPUT+"
+sed \
+ -e "1s|#!.*/sh|#!$SHELL_PATH|" \
+ -e "s|@@SHELL_PATH@@|$SHELL_PATH|" \
+ -e "1,30s|^ exec wish | exec '$TCLTK_PATH' |" \
+ -e "s|@@GITGUI_VERSION@@|$GITGUI_VERSION|g" \
+ -e "s|@@GITGUI_RELATIVE@@|$GITGUI_RELATIVE|" \
+ -e "${GITGUI_RELATIVE}s|@@GITGUI_LIBDIR@@|$GITGUI_LIBDIR|" \
+ "$INPUT" >"$OUTPUT"+
+chmod +x "$OUTPUT"+
+mv "$OUTPUT"+ "$OUTPUT"
diff --git a/git-gui/generate-macos-app.sh b/git-gui/generate-macos-app.sh
new file mode 100755
index 0000000000..71b9fa67a4
--- /dev/null
+++ b/git-gui/generate-macos-app.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+set -e
+
+SOURCE_DIR="$1"
+OUTPUT="$2"
+BUILD_OPTIONS="$3"
+VERSION_FILE="$4"
+
+. "$BUILD_OPTIONS"
+. "$VERSION_FILE"
+
+rm -rf "$OUTPUT" "$OUTPUT+"
+
+mkdir -p "$OUTPUT+/Contents/MacOS"
+mkdir -p "$OUTPUT+/Contents/Resources/Scripts"
+
+cp "$TKEXECUTABLE" "$OUTPUT+/Contents/MacOS"
+cp "$SOURCE_DIR/macosx/git-gui.icns" "$OUTPUT+/Contents/Resources"
+sed \
+ -e "s/@@GITGUI_VERSION@@/$GITGUI_VERSION/g" \
+ -e "s/@@GITGUI_TKEXECUTABLE@@/$(basename "$TKEXECUTABLE")/g" \
+ "$SOURCE_DIR/macosx/Info.plist" \
+ >"$OUTPUT+/Contents/Info.plist"
+sed \
+ -e "s|@@gitexecdir@@|$GITGUI_GITEXECDIR|" \
+ -e "s|@@GITGUI_LIBDIR@@|$GITGUI_LIBDIR|" \
+ "$SOURCE_DIR/macosx/AppMain.tcl" \
+ >"$OUTPUT+/Contents/Resources/Scripts/AppMain.tcl"
+mv "$OUTPUT+" "$OUTPUT"
diff --git a/git-gui/generate-macos-wrapper.sh b/git-gui/generate-macos-wrapper.sh
new file mode 100755
index 0000000000..0304937f41
--- /dev/null
+++ b/git-gui/generate-macos-wrapper.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+set -e
+
+if test "$#" -ne 3
+then
+ echo >&2 "usage: $0 <OUTPUT> <BUILD_OPTIONS> <VERSION_FILE>"
+ exit 1
+fi
+
+OUTPUT="$1"
+BUILD_OPTIONS="$2"
+VERSION_FILE="$3"
+
+. "$BUILD_OPTIONS"
+
+rm -f "$OUTPUT" "$OUTPUT+"
+
+(
+ echo "#!$SHELL_PATH"
+ cat "$BUILD_OPTIONS" "$VERSION_FILE"
+ cat <<-'EOF'
+ if test "z$*" = zversion ||
+ test "z$*" = z--version
+ then
+ echo "git-gui version $GITGUI_VERSION"
+ else
+ libdir="${GIT_GUI_LIB_DIR:-$GITGUI_LIBDIR}"
+ exec "$libdir/Git Gui.app/Contents/MacOS/$(basename "$TKEXECUTABLE")" "$0" "$@"
+ fi
+ EOF
+) >"$OUTPUT+"
+
+chmod +x "$OUTPUT+"
+mv "$OUTPUT+" "$OUTPUT"
diff --git a/git-gui/generate-tclindex.sh b/git-gui/generate-tclindex.sh
new file mode 100755
index 0000000000..36e3a0bd90
--- /dev/null
+++ b/git-gui/generate-tclindex.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+if test "$#" -lt 3
+then
+ echo >&2 "usage: $0 <BUILD_DIR> <BUILD_OPTIONS> <LIBFILE> [<LIBFILE>...]"
+ exit 1
+fi
+
+BUILD_DIR="$1"
+BUILD_OPTIONS="$2"
+shift 2
+LIBFILES="$(echo "$@" | sort | sed 's|lib/||g')"
+
+. "$BUILD_OPTIONS"
+
+cd "$BUILD_DIR"
+
+if {
+ echo "source lib/class.tcl;"
+ echo "auto_mkindex lib $LIBFILES"
+} | "$TCL_PATH"
+then
+ : ok
+else
+ echo >&2 " * $TCL_PATH failed; using unoptimized loading"
+ rm -f $@
+ echo '# Autogenerated by git-gui Makefile' >lib/tclIndex
+ echo >>lib/tclIndex
+ echo "class.tcl" >>lib/tclIndex
+ printf "%s\n" $LIBFILES >>lib/tclIndex
+ echo >>lib/tclIndex
+fi
diff --git a/git-gui/lib/meson.build b/git-gui/lib/meson.build
new file mode 100644
index 0000000000..4b9efab774
--- /dev/null
+++ b/git-gui/lib/meson.build
@@ -0,0 +1,74 @@
+libfiles = [
+ 'about.tcl',
+ 'blame.tcl',
+ 'branch_checkout.tcl',
+ 'branch_create.tcl',
+ 'branch_delete.tcl',
+ 'branch_rename.tcl',
+ 'branch.tcl',
+ 'browser.tcl',
+ 'checkout_op.tcl',
+ 'choose_font.tcl',
+ 'choose_repository.tcl',
+ 'choose_rev.tcl',
+ 'chord.tcl',
+ 'class.tcl',
+ 'commit.tcl',
+ 'console.tcl',
+ 'database.tcl',
+ 'date.tcl',
+ 'diff.tcl',
+ 'encoding.tcl',
+ 'error.tcl',
+ 'index.tcl',
+ 'line.tcl',
+ 'logo.tcl',
+ 'merge.tcl',
+ 'mergetool.tcl',
+ 'option.tcl',
+ 'remote_add.tcl',
+ 'remote_branch_delete.tcl',
+ 'remote.tcl',
+ 'search.tcl',
+ 'shortcut.tcl',
+ 'spellcheck.tcl',
+ 'sshkey.tcl',
+ 'status_bar.tcl',
+ 'themed.tcl',
+ 'tools_dlg.tcl',
+ 'tools.tcl',
+ 'transport.tcl',
+ 'win32.tcl',
+]
+
+nontcl_libfiles = [
+ 'git-gui.ico',
+ 'win32_shortcut.js',
+]
+
+foreach file : libfiles + nontcl_libfiles
+ configure_file(
+ input: file,
+ output: file,
+ copy: true,
+ install: true,
+ install_dir: get_option('datadir') / 'git-gui/lib',
+ )
+endforeach
+
+custom_target(
+ output: 'tclIndex',
+ command: [
+ shell,
+ meson.project_source_root() / 'generate-tclindex.sh',
+ meson.project_build_root(),
+ meson.project_build_root() / 'GIT-GUI-BUILD-OPTIONS',
+ libfiles,
+ ],
+ depend_files: [
+ libfiles,
+ build_options,
+ ],
+ install: true,
+ install_dir: get_option('datadir') / 'git-gui/lib',
+)
diff --git a/git-gui/meson.build b/git-gui/meson.build
new file mode 100644
index 0000000000..cdae85e4b9
--- /dev/null
+++ b/git-gui/meson.build
@@ -0,0 +1,148 @@
+project('git-gui',
+ meson_version: '>=0.61.0',
+)
+
+fs = import('fs')
+
+shell = find_program('sh')
+tclsh = find_program('tclsh')
+wish = find_program('wish')
+
+build_options_config = configuration_data()
+if target_machine.system() == 'windows'
+ build_options_config.set('GITGUI_RELATIVE', '1')
+else
+ build_options_config.set('GITGUI_RELATIVE', '')
+endif
+build_options_config.set_quoted('GITGUI_GITEXECDIR', get_option('prefix') / get_option('libexecdir') / 'git-core')
+build_options_config.set_quoted('GITGUI_LIBDIR', get_option('prefix') / get_option('datadir') / 'git-gui/lib')
+build_options_config.set_quoted('SHELL_PATH', fs.as_posix(shell.full_path()))
+build_options_config.set_quoted('TCLTK_PATH', fs.as_posix(wish.full_path()))
+build_options_config.set_quoted('TCL_PATH', fs.as_posix(tclsh.full_path()))
+if target_machine.system() == 'darwin'
+ tkexecutables = [
+ '/Library/Frameworks/Tk.framework/Resources/Wish.app/Contents/MacOS/Wish',
+ '/System/Library/Frameworks/Tk.framework/Resources/Wish.app/Contents/MacOS/Wish',
+ '/System/Library/Frameworks/Tk.framework/Resources/Wish Shell.app/Contents/MacOS/Wish Shell',
+ ]
+ tkexecutable = find_program(tkexecutables)
+ build_options_config.set_quoted('TKEXECUTABLE', tkexecutable.full_path())
+else
+ build_options_config.set('TKEXECUTABLE', '')
+endif
+
+build_options = configure_file(
+ input: 'GIT-GUI-BUILD-OPTIONS.in',
+ output: 'GIT-GUI-BUILD-OPTIONS',
+ configuration: build_options_config,
+)
+
+version_file = custom_target(
+ input: 'GIT-VERSION-GEN',
+ output: 'GIT-VERSION-FILE',
+ command: [
+ shell,
+ '@INPUT@',
+ meson.current_source_dir(),
+ '@OUTPUT@',
+ ],
+ build_always_stale: true,
+)
+
+configure_file(
+ input: 'git-gui--askpass',
+ output: 'git-gui--askpass',
+ copy: true,
+ install: true,
+ install_dir: get_option('libexecdir') / 'git-core',
+)
+
+gitgui_main = 'git-gui'
+gitgui_main_install_dir = get_option('libexecdir') / 'git-core'
+
+if target_machine.system() == 'windows'
+ gitgui_main = 'git-gui.tcl'
+
+ configure_file(
+ input: 'windows/git-gui.sh',
+ output: 'git-gui',
+ copy: true,
+ install: true,
+ install_dir: get_option('libexecdir') / 'git-core',
+ )
+elif target_machine.system() == 'darwin'
+ gitgui_main = 'git-gui.tcl'
+ gitgui_main_install_dir = get_option('datadir') / 'git-gui/lib'
+
+ custom_target(
+ output: 'git-gui',
+ command: [
+ shell,
+ meson.current_source_dir() / 'generate-macos-wrapper.sh',
+ '@OUTPUT@',
+ meson.current_build_dir() / 'GIT-GUI-BUILD-OPTIONS',
+ meson.current_build_dir() / 'GIT-VERSION-FILE',
+ ],
+ depends: [
+ version_file,
+ ],
+ depend_files: [
+ build_options,
+ ],
+ install: true,
+ install_dir: get_option('libexecdir') / 'git-core',
+ )
+
+ custom_target(
+ output: 'Git Gui.app',
+ command: [
+ shell,
+ meson.current_source_dir() / 'generate-macos-app.sh',
+ meson.current_source_dir(),
+ meson.current_build_dir() / 'Git Gui.app',
+ meson.current_build_dir() / 'GIT-GUI-BUILD-OPTIONS',
+ meson.current_build_dir() / 'GIT-VERSION-FILE',
+ ],
+ depends: [
+ version_file,
+ ],
+ depend_files: [
+ build_options,
+ 'macosx/AppMain.tcl',
+ 'macosx/Info.plist',
+ 'macosx/git-gui.icns',
+ ],
+ build_by_default: true,
+ install: true,
+ install_dir: get_option('datadir') / 'git-gui/lib',
+ )
+endif
+
+custom_target(
+ input: 'git-gui.sh',
+ output: gitgui_main,
+ command: [
+ shell,
+ meson.current_source_dir() / 'generate-git-gui.sh',
+ '@INPUT@',
+ '@OUTPUT@',
+ meson.current_build_dir() / 'GIT-GUI-BUILD-OPTIONS',
+ meson.current_build_dir() / 'GIT-VERSION-FILE',
+ ],
+ depends: [
+ version_file,
+ ],
+ depend_files: [
+ build_options,
+ ],
+ install: true,
+ install_dir: gitgui_main_install_dir,
+)
+
+install_symlink('git-citool',
+ install_dir: get_option('libexecdir') / 'git-core',
+ pointing_to: 'git-gui',
+)
+
+subdir('lib')
+subdir('po')
diff --git a/git-gui/po/meson.build b/git-gui/po/meson.build
new file mode 100644
index 0000000000..00cae74338
--- /dev/null
+++ b/git-gui/po/meson.build
@@ -0,0 +1,38 @@
+languages = [
+ 'bg',
+ 'de',
+ 'el',
+ 'fr',
+ 'hu',
+ 'it',
+ 'ja',
+ 'nb',
+ 'pt_br',
+ 'pt_pt',
+ 'ru',
+ 'sv',
+ 'vi',
+ 'zh_cn',
+]
+
+msgfmt = find_program('msgfmt', required: false)
+if not msgfmt.found()
+ subdir_done()
+endif
+
+foreach language : languages
+ custom_target(
+ input: language + '.po',
+ output: language + '.msg',
+ command: [
+ msgfmt,
+ '--statistics',
+ '--tcl',
+ '--locale=' + language,
+ '-d', meson.current_build_dir(),
+ '@INPUT@',
+ ],
+ install: true,
+ install_dir: get_option('datadir') / 'git-gui/lib/msgs',
+ )
+endforeach
diff --git a/git-send-email.perl b/git-send-email.perl
index 55b7e00d29..659e6c588b 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1393,8 +1393,22 @@ sub maildomain_mta {
return $maildomain;
}
+sub maildomain_hostname_command {
+ my $maildomain;
+
+ if ($^O eq 'linux' || $^O eq 'darwin') {
+ my $domain = `(hostname -f) 2>/dev/null`;
+ if (!$?) {
+ chomp($domain);
+ $maildomain = $domain if valid_fqdn($domain);
+ }
+ }
+ return $maildomain;
+}
+
sub maildomain {
- return maildomain_net() || maildomain_mta() || 'localhost.localdomain';
+ return maildomain_net() || maildomain_mta() ||
+ maildomain_hostname_command || 'localhost.localdomain';
}
sub smtp_host_string {
diff --git a/gitk-git/Makefile b/gitk-git/Makefile
index 3a3c56c318..cc32dcab4b 100644
--- a/gitk-git/Makefile
+++ b/gitk-git/Makefile
@@ -73,7 +73,7 @@ update-po:: $(PO_TEMPLATE)
$(foreach p, $(ALL_POFILES), echo Updating $p ; msgmerge -U $p $(PO_TEMPLATE) ; )
$(ALL_MSGFILES): %.msg : %.po
@echo Generating catalog $@
- $(MSGFMT) --statistics --tcl $< -l $(basename $(notdir $<)) -d $(dir $@)
+ $(MSGFMT) --statistics --tcl -l $(basename $(notdir $<)) -d $(dir $@) $<
.PHONY: all install uninstall clean update-po
.PHONY: FORCE
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 11ad639d06..19689765cd 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -7108,7 +7108,7 @@ proc findselectline {l} {
# mark the bits of a headline or author that match a find string
proc markmatches {canv l str tag matches font row} {
- global selectedline
+ global selectedline foundbgcolor
set bbox [$canv bbox $tag]
set x0 [lindex $bbox 0]
@@ -7122,7 +7122,7 @@ proc markmatches {canv l str tag matches font row} {
set xlen [font measure $font [string range $str 0 [expr {$end}]]]
set t [$canv create rect [expr {$x0+$xoff}] $y0 \
[expr {$x0+$xlen+2}] $y1 \
- -outline {} -tags [list match$l matches] -fill yellow]
+ -outline {} -tags [list match$l matches] -fill $foundbgcolor]
$canv lower $t
if {$row == $selectedline} {
$canv raise $t secsel
@@ -11736,13 +11736,11 @@ proc prefspage_general {notebook} {
grid x $page.tabstopl $page.tabstop -sticky w
${NS}::label $page.wrapcommentl -text [mc "Wrap comment text"]
- ${NS}::combobox $page.wrapcomment -values {none char word} -state readonly \
- -textvariable wrapcomment
+ makedroplist $page.wrapcomment wrapcomment none char word
grid x $page.wrapcommentl $page.wrapcomment -sticky w
${NS}::label $page.wrapdefaultl -text [mc "Wrap other text"]
- ${NS}::combobox $page.wrapdefault -values {none char word} -state readonly \
- -textvariable wrapdefault
+ makedroplist $page.wrapdefault wrapdefault none char word
grid x $page.wrapdefaultl $page.wrapdefault -sticky w
${NS}::checkbutton $page.ntag -text [mc "Display nearby tags/heads"] \
diff --git a/help.c b/help.c
index 6ef90838f1..21b778707a 100644
--- a/help.c
+++ b/help.c
@@ -214,7 +214,7 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
else if (cmp == 0) {
ei++;
free(cmds->names[ci++]);
- } else if (cmp > 0)
+ } else
ei++;
}
diff --git a/json-writer.c b/json-writer.c
index 8c5187e9fd..34577dc25f 100644
--- a/json-writer.c
+++ b/json-writer.c
@@ -268,10 +268,6 @@ static void append_sub_jw(struct json_writer *jw,
strbuf_addbuf(&jw->json, &value->json);
}
-/*
- * Append existing (properly terminated) JSON sub-data (object or array)
- * as-is onto the given JSON data.
- */
void jw_object_sub_jw(struct json_writer *jw, const char *key,
const struct json_writer *value)
{
diff --git a/json-writer.h b/json-writer.h
index 04413bd1af..8f845d4d29 100644
--- a/json-writer.h
+++ b/json-writer.h
@@ -28,6 +28,34 @@
* object/array) -or- by building them inline in one pass. This is a
* personal style and/or data shape choice.
*
+ * USAGE:
+ * ======
+ *
+ * - Initialize the json_writer with jw_init.
+ *
+ * - Open an object as the main data structure with jw_object_begin.
+ * Append a key-value pair to it using the jw_object_<type> functions.
+ * Conclude with jw_end.
+ *
+ * - Alternatively, open an array as the main data structure with
+ * jw_array_begin. Append a value to it using the jw_array_<type>
+ * functions. Conclude with jw_end.
+ *
+ * - Append a new, unterminated array or object to the current
+ * object using the jw_object_inline_begin_{array, object} functions.
+ * Similarly, append a new, unterminated array or object to
+ * the current array using the jw_array_inline_begin_{array, object}
+ * functions.
+ *
+ * - Append other json_writer as a value to the current array or object
+ * using the jw_{array, object}_sub_jw functions.
+ *
+ * - Extend the current array with an null-terminated array of strings
+ * by using jw_array_argv or with a fixed number of elements of a
+ * array of string by using jw_array_argc_argv.
+ *
+ * - Release the json_writer after using it by calling jw_release.
+ *
* See t/helper/test-json-writer.c for various usage examples.
*
* LIMITATIONS:
@@ -69,42 +97,185 @@ struct json_writer
.open_stack = STRBUF_INIT, \
}
+/*
+ * Initialize a json_writer with empty values.
+ */
void jw_init(struct json_writer *jw);
+
+/*
+ * Release the internal buffers of a json_writer.
+ */
void jw_release(struct json_writer *jw);
+/*
+ * Begin the json_writer using an object as the top-level data structure. If
+ * pretty is set to 1, the result will be a human-readable and indented JSON,
+ * and if it is set to 0 the result will be minified single-line JSON.
+ */
void jw_object_begin(struct json_writer *jw, int pretty);
+
+/*
+ * Begin the json_writer using an array as the top-level data structure. If
+ * pretty is set to 1, the result will be a human-readable and indented JSON,
+ * and if it is set to 0 the result will be minified single-line JSON.
+ */
void jw_array_begin(struct json_writer *jw, int pretty);
+/*
+ * Append a string field to the current object of the json_writer, given its key
+ * and its value. Trigger a BUG when not in an object.
+ */
void jw_object_string(struct json_writer *jw, const char *key,
const char *value);
+
+/*
+ * Append an int field to the current object of the json_writer, given its key
+ * and its value. Trigger a BUG when not in an object.
+ */
void jw_object_intmax(struct json_writer *jw, const char *key, intmax_t value);
+
+/*
+ * Append a double field to the current object of the json_writer, given its key
+ * and its value. The precision parameter defines the number of significant
+ * digits, where -1 can be used for maximum precision. Trigger a BUG when not in
+ * an object.
+ */
void jw_object_double(struct json_writer *jw, const char *key, int precision,
double value);
+
+/*
+ * Append a boolean field set to true to the current object of the json_writer,
+ * given its key. Trigger a BUG when not in an object.
+ */
void jw_object_true(struct json_writer *jw, const char *key);
+
+/*
+ * Append a boolean field set to false to the current object of the json_writer,
+ * given its key. Trigger a BUG when not in an object.
+ */
void jw_object_false(struct json_writer *jw, const char *key);
+
+/*
+ * Append a boolean field to the current object of the json_writer, given its
+ * key and its value. Trigger a BUG when not in an object.
+ */
void jw_object_bool(struct json_writer *jw, const char *key, int value);
+
+/*
+ * Append a null field to the current object of the json_writer, given its key.
+ * Trigger a BUG when not in an object.
+ */
void jw_object_null(struct json_writer *jw, const char *key);
+
+/*
+ * Append a field to the current object of the json_writer, given its key and
+ * another json_writer that represents its content. Trigger a BUG when not in
+ * an object.
+ */
void jw_object_sub_jw(struct json_writer *jw, const char *key,
const struct json_writer *value);
+/*
+ * Start an object as the value of a field in the current object of the
+ * json_writer. Trigger a BUG when not in an object.
+ */
void jw_object_inline_begin_object(struct json_writer *jw, const char *key);
+
+/*
+ * Start an array as the value of a field in the current object of the
+ * json_writer. Trigger a BUG when not in an object.
+ */
void jw_object_inline_begin_array(struct json_writer *jw, const char *key);
+/*
+ * Append a string value to the current array of the json_writer. Trigger a BUG
+ * when not in an array.
+ */
void jw_array_string(struct json_writer *jw, const char *value);
+
+/*
+ * Append an int value to the current array of the json_writer. Trigger a BUG
+ * when not in an array.
+ */
void jw_array_intmax(struct json_writer *jw, intmax_t value);
+
+/*
+ * Append a double value to the current array of the json_writer. The precision
+ * parameter defines the number of significant digits, where -1 can be used for
+ * maximum precision. Trigger a BUG when not in an array.
+ */
void jw_array_double(struct json_writer *jw, int precision, double value);
+
+/*
+ * Append a true value to the current array of the json_writer. Trigger a BUG
+ * when not in an array.
+ */
void jw_array_true(struct json_writer *jw);
+
+/*
+ * Append a false value to the current array of the json_writer. Trigger a BUG
+ * when not in an array.
+ */
void jw_array_false(struct json_writer *jw);
+
+/*
+ * Append a boolean value to the current array of the json_writer. Trigger a BUG
+ * when not in an array.
+ */
void jw_array_bool(struct json_writer *jw, int value);
+
+/*
+ * Append a null value to the current array of the json_writer. Trigger a BUG
+ * when not in an array.
+ */
void jw_array_null(struct json_writer *jw);
+
+/*
+ * Append a json_writer as a value to the current array of the
+ * json_writer. Trigger a BUG when not in an array.
+ */
void jw_array_sub_jw(struct json_writer *jw, const struct json_writer *value);
+
+/*
+ * Append the first argc values from the argv array of strings to the current
+ * array of the json_writer. Trigger a BUG when not in an array.
+ *
+ * This function does not provide safety for cases where the array has less than
+ * argc values.
+ */
void jw_array_argc_argv(struct json_writer *jw, int argc, const char **argv);
+
+/*
+ * Append a null-terminated array of strings to the current array of the
+ * json_writer. Trigger a BUG when not in an array.
+ */
void jw_array_argv(struct json_writer *jw, const char **argv);
+/*
+ * Start an object as a value in the current array of the json_writer. Trigger a
+ * BUG when not in an array.
+ */
void jw_array_inline_begin_object(struct json_writer *jw);
+
+/*
+ * Start an array as a value in the current array. Trigger a BUG when not in an
+ * array.
+ */
void jw_array_inline_begin_array(struct json_writer *jw);
+/*
+ * Return whether the json_writer is terminated. In other words, if the all the
+ * objects and arrays are already closed.
+ */
int jw_is_terminated(const struct json_writer *jw);
+
+/*
+ * Terminates the current object or array of the json_writer. In other words,
+ * append a ] if the current array is not closed or } if the current object
+ * is not closed.
+ *
+ * Abort the execution if there's no object or array that can be terminated.
+ */
void jw_end(struct json_writer *jw);
#endif /* JSON_WRITER_H */
diff --git a/mailinfo.c b/mailinfo.c
index 7b001fa5db..ee4597da6b 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -381,12 +381,12 @@ static int is_format_patch_separator(const char *line, int len)
return !memcmp(SAMPLE + (cp - line), cp, strlen(SAMPLE) - (cp - line));
}
-static struct strbuf *decode_q_segment(const struct strbuf *q_seg, int rfc2047)
+static int decode_q_segment(struct strbuf *out, const struct strbuf *q_seg,
+ int rfc2047)
{
const char *in = q_seg->buf;
int c;
- struct strbuf *out = xmalloc(sizeof(struct strbuf));
- strbuf_init(out, q_seg->len);
+ strbuf_grow(out, q_seg->len);
while ((c = *in++) != 0) {
if (c == '=') {
@@ -405,16 +405,15 @@ static struct strbuf *decode_q_segment(const struct strbuf *q_seg, int rfc2047)
c = 0x20;
strbuf_addch(out, c);
}
- return out;
+ return 0;
}
-static struct strbuf *decode_b_segment(const struct strbuf *b_seg)
+static int decode_b_segment(struct strbuf *out, const struct strbuf *b_seg)
{
/* Decode in..ep, possibly in-place to ot */
int c, pos = 0, acc = 0;
const char *in = b_seg->buf;
- struct strbuf *out = xmalloc(sizeof(struct strbuf));
- strbuf_init(out, b_seg->len);
+ strbuf_grow(out, b_seg->len);
while ((c = *in++) != 0) {
if (c == '+')
@@ -447,7 +446,7 @@ static struct strbuf *decode_b_segment(const struct strbuf *b_seg)
break;
}
}
- return out;
+ return 0;
}
static int convert_to_utf8(struct mailinfo *mi,
@@ -475,7 +474,7 @@ static int convert_to_utf8(struct mailinfo *mi,
static void decode_header(struct mailinfo *mi, struct strbuf *it)
{
char *in, *ep, *cp;
- struct strbuf outbuf = STRBUF_INIT, *dec;
+ struct strbuf outbuf = STRBUF_INIT, dec = STRBUF_INIT;
struct strbuf charset_q = STRBUF_INIT, piecebuf = STRBUF_INIT;
int found_error = 1; /* pessimism */
@@ -530,18 +529,19 @@ static void decode_header(struct mailinfo *mi, struct strbuf *it)
default:
goto release_return;
case 'b':
- dec = decode_b_segment(&piecebuf);
+ if ((found_error = decode_b_segment(&dec, &piecebuf)))
+ goto release_return;
break;
case 'q':
- dec = decode_q_segment(&piecebuf, 1);
+ if ((found_error = decode_q_segment(&dec, &piecebuf, 1)))
+ goto release_return;
break;
}
- if (convert_to_utf8(mi, dec, charset_q.buf))
+ if (convert_to_utf8(mi, &dec, charset_q.buf))
goto release_return;
- strbuf_addbuf(&outbuf, dec);
- strbuf_release(dec);
- free(dec);
+ strbuf_addbuf(&outbuf, &dec);
+ strbuf_release(&dec);
in = ep + 2;
}
strbuf_addstr(&outbuf, in);
@@ -552,6 +552,7 @@ release_return:
strbuf_release(&outbuf);
strbuf_release(&charset_q);
strbuf_release(&piecebuf);
+ strbuf_release(&dec);
if (found_error)
mi->input_error = -1;
@@ -634,23 +635,22 @@ static int is_inbody_header(const struct mailinfo *mi,
static void decode_transfer_encoding(struct mailinfo *mi, struct strbuf *line)
{
- struct strbuf *ret;
+ struct strbuf ret = STRBUF_INIT;
switch (mi->transfer_encoding) {
case TE_QP:
- ret = decode_q_segment(line, 0);
+ decode_q_segment(&ret, line, 0);
break;
case TE_BASE64:
- ret = decode_b_segment(line);
+ decode_b_segment(&ret, line);
break;
case TE_DONTCARE:
default:
return;
}
strbuf_reset(line);
- strbuf_addbuf(line, ret);
- strbuf_release(ret);
- free(ret);
+ strbuf_addbuf(line, &ret);
+ strbuf_release(&ret);
}
static inline int patchbreak(const struct strbuf *line)
diff --git a/merge-ort.c b/merge-ort.c
index 77310a4a52..47b3d1730e 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -2127,6 +2127,7 @@ static int handle_content_merge(struct merge_options *opt,
const struct version_info *b,
const char *pathnames[3],
const int extra_marker_size,
+ const int record_object,
struct version_info *result)
{
/*
@@ -2214,7 +2215,7 @@ static int handle_content_merge(struct merge_options *opt,
ret = -1;
}
- if (!ret &&
+ if (!ret && record_object &&
write_object_file(result_buf.ptr, result_buf.size,
OBJ_BLOB, &result->oid)) {
path_msg(opt, ERROR_OBJECT_WRITE_FAILED, 0,
@@ -2897,6 +2898,7 @@ static int process_renames(struct merge_options *opt,
struct version_info merged;
struct conflict_info *base, *side1, *side2;
unsigned was_binary_blob = 0;
+ const int record_object = true;
pathnames[0] = oldpath;
pathnames[1] = newpath;
@@ -2947,6 +2949,7 @@ static int process_renames(struct merge_options *opt,
&side2->stages[2],
pathnames,
1 + 2 * opt->priv->call_depth,
+ record_object,
&merged);
if (clean_merge < 0)
return -1;
@@ -3061,6 +3064,7 @@ static int process_renames(struct merge_options *opt,
struct conflict_info *base, *side1, *side2;
int clean;
+ const int record_object = true;
pathnames[0] = oldpath;
pathnames[other_source_index] = oldpath;
@@ -3080,6 +3084,7 @@ static int process_renames(struct merge_options *opt,
&side2->stages[2],
pathnames,
1 + 2 * opt->priv->call_depth,
+ record_object,
&merged);
if (clean < 0)
return -1;
@@ -3931,9 +3936,12 @@ static int write_completed_directory(struct merge_options *opt,
* Write out the tree to the git object directory, and also
* record the mode and oid in dir_info->result.
*/
+ int record_tree = (!opt->mergeability_only ||
+ opt->priv->call_depth);
dir_info->is_null = 0;
dir_info->result.mode = S_IFDIR;
- if (write_tree(&dir_info->result.oid, &info->versions, offset,
+ if (record_tree &&
+ write_tree(&dir_info->result.oid, &info->versions, offset,
opt->repo->hash_algo->rawsz) < 0)
ret = -1;
}
@@ -4231,10 +4239,13 @@ static int process_entry(struct merge_options *opt,
struct version_info *o = &ci->stages[0];
struct version_info *a = &ci->stages[1];
struct version_info *b = &ci->stages[2];
+ int record_object = (!opt->mergeability_only ||
+ opt->priv->call_depth);
clean_merge = handle_content_merge(opt, path, o, a, b,
ci->pathnames,
opt->priv->call_depth * 2,
+ record_object,
&merged_file);
if (clean_merge < 0)
return -1;
@@ -4395,6 +4406,8 @@ static int process_entries(struct merge_options *opt,
STRING_LIST_INIT_NODUP,
NULL, 0 };
int ret = 0;
+ const int record_tree = (!opt->mergeability_only ||
+ opt->priv->call_depth);
trace2_region_enter("merge", "process_entries setup", opt->repo);
if (strmap_empty(&opt->priv->paths)) {
@@ -4454,6 +4467,12 @@ static int process_entries(struct merge_options *opt,
ret = -1;
goto cleanup;
};
+ if (!ci->merged.clean && opt->mergeability_only &&
+ !opt->priv->call_depth) {
+ ret = 0;
+ goto cleanup;
+ }
+
}
}
trace2_region_leave("merge", "processing", opt->repo);
@@ -4468,7 +4487,8 @@ static int process_entries(struct merge_options *opt,
fflush(stdout);
BUG("dir_metadata accounting completely off; shouldn't happen");
}
- if (write_tree(result_oid, &dir_metadata.versions, 0,
+ if (record_tree &&
+ write_tree(result_oid, &dir_metadata.versions, 0,
opt->repo->hash_algo->rawsz) < 0)
ret = -1;
cleanup:
@@ -4715,6 +4735,8 @@ void merge_display_update_messages(struct merge_options *opt,
if (opt->record_conflict_msgs_as_headers)
BUG("Either display conflict messages or record them as headers, not both");
+ if (opt->mergeability_only)
+ BUG("Displaying conflict messages incompatible with mergeability-only checks");
trace2_region_enter("merge", "display messages", opt->repo);
@@ -5171,10 +5193,12 @@ redo:
result->path_messages = &opt->priv->conflicts;
if (result->clean >= 0) {
- result->tree = parse_tree_indirect(&working_tree_oid);
- if (!result->tree)
- die(_("unable to read tree (%s)"),
- oid_to_hex(&working_tree_oid));
+ if (!opt->mergeability_only) {
+ result->tree = parse_tree_indirect(&working_tree_oid);
+ if (!result->tree)
+ die(_("unable to read tree (%s)"),
+ oid_to_hex(&working_tree_oid));
+ }
/* existence of conflicted entries implies unclean */
result->clean &= strmap_empty(&opt->priv->conflicted);
}
diff --git a/merge-ort.h b/merge-ort.h
index 30750c0396..6045579825 100644
--- a/merge-ort.h
+++ b/merge-ort.h
@@ -83,6 +83,7 @@ struct merge_options {
/* miscellaneous control options */
const char *subtree_shift;
unsigned renormalize : 1;
+ unsigned mergeability_only : 1; /* exit early, write fewer objects */
unsigned record_conflict_msgs_as_headers : 1;
const char *msg_header_prefix;
diff --git a/meson.build b/meson.build
index a1476e5b32..596f5ac711 100644
--- a/meson.build
+++ b/meson.build
@@ -215,14 +215,12 @@ project('git', 'c',
capture: true,
check: true,
).stdout().strip() : 'unknown',
- default_options: [
- # Git requires C99 with GNU extensions, which of course isn't supported by
- # MSVC. Funny enough, C99 doesn't work with MSVC either, as it has only
- # learned to define __STDC_VERSION__ with C11 and later. We thus require
- # GNU C99 and fall back to C11. Meson only learned to handle the fallback
- # with version 1.3.0, so on older versions we use GNU C99 unconditionally.
- 'c_std=' + (meson.version().version_compare('>=1.3.0') ? 'gnu99,c11' : 'gnu99'),
- ],
+ # Git requires C99 with GNU extensions, which of course isn't supported by
+ # MSVC. Funny enough, C99 doesn't work with MSVC either, as it has only
+ # learned to define __STDC_VERSION__ with C11 and later. We thus require
+ # GNU C99 and fall back to C11. Meson only learned to handle the fallback
+ # with version 1.3.0, so on older versions we use GNU C99 unconditionally.
+ default_options: meson.version().version_compare('>=1.3.0') ? ['c_std=gnu99,c11'] : ['c_std=gnu99'],
)
fs = import('fs')
@@ -743,7 +741,7 @@ build_options_config.set('GIT_TEST_OPTS', '')
build_options_config.set('GIT_TEST_PERL_FATAL_WARNINGS', '')
build_options_config.set_quoted('GIT_TEST_UTF8_LOCALE', get_option('test_utf8_locale'))
build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))
-build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
+build_options_config.set_quoted('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
if get_option('sane_tool_path').length() != 0
sane_tool_path = (host_machine.system() == 'windows' ? ';' : ':').join(get_option('sane_tool_path'))
@@ -761,8 +759,6 @@ endif
libgit_c_args = [
'-DBINDIR="' + get_option('bindir') + '"',
'-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
- '-DETC_GITATTRIBUTES="' + get_option('gitattributes') + '"',
- '-DETC_GITCONFIG="' + get_option('gitconfig') + '"',
'-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
'-DGIT_HOST_CPU="' + host_machine.cpu_family() + '"',
'-DGIT_HTML_PATH="' + get_option('datadir') / 'doc/git-doc"',
@@ -773,6 +769,20 @@ libgit_c_args = [
'-DSHELL_PATH="' + fs.as_posix(target_shell.full_path()) + '"',
]
+system_attributes = get_option('gitattributes')
+if system_attributes != ''
+ libgit_c_args += '-DETC_GITATTRIBUTES="' + system_attributes + '"'
+else
+ libgit_c_args += '-DETC_GITATTRIBUTES="' + get_option('sysconfdir') / 'gitattributes"'
+endif
+
+system_config = get_option('gitconfig')
+if system_config != ''
+ libgit_c_args += '-DETC_GITCONFIG="' + system_config + '"'
+else
+ libgit_c_args += '-DETC_GITCONFIG="' + get_option('sysconfdir') / 'gitconfig"'
+endif
+
editor_opt = get_option('default_editor')
if editor_opt != '' and editor_opt != 'vi'
libgit_c_args += '-DDEFAULT_EDITOR="' + editor_opt + '"'
@@ -1584,10 +1594,19 @@ else
error('Unsupported CSPRNG backend: ' + csprng_backend)
endif
+git_exec_path = 'libexec/git-core'
+libexec = get_option('libexecdir')
+if libexec != 'libexec' and libexec != '.'
+ git_exec_path = libexec
+endif
+
if get_option('runtime_prefix')
libgit_c_args += '-DRUNTIME_PREFIX'
build_options_config.set('RUNTIME_PREFIX', 'true')
- git_exec_path = get_option('libexecdir') / 'git-core'
+
+ if git_exec_path.startswith('/')
+ error('runtime_prefix requires a relative libexecdir not:', libexec)
+ endif
if compiler.has_header('mach-o/dyld.h')
libgit_c_args += '-DHAVE_NS_GET_EXECUTABLE_PATH'
@@ -1624,7 +1643,6 @@ if get_option('runtime_prefix')
endif
else
build_options_config.set('RUNTIME_PREFIX', 'false')
- git_exec_path = get_option('prefix') / get_option('libexecdir') / 'git-core'
endif
libgit_c_args += '-DGIT_EXEC_PATH="' + git_exec_path + '"'
diff --git a/meson_options.txt b/meson_options.txt
index 54c63614d4..e7f768df24 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,10 +7,10 @@ option('default_pager', type: 'string', value: 'less',
description: 'Fall-back pager.')
option('default_editor', type: 'string', value: 'vi',
description: 'Fall-back editor.')
-option('gitconfig', type: 'string', value: '/etc/gitconfig',
- description: 'Path to the global git configuration file.')
-option('gitattributes', type: 'string', value: '/etc/gitattributes',
- description: 'Path to the global git attributes file.')
+option('gitconfig', type: 'string',
+ description: 'Path to the global git configuration file. (default: etc/gitconfig)')
+option('gitattributes', type: 'string',
+ description: 'Path to the global git attributes file. (default: etc/gitattributes)')
option('pager_environment', type: 'string', value: 'LESS=FRX LV=-c',
description: 'Environment used when spawning the pager')
option('perl_cpan_fallback', type: 'boolean', value: true,
diff --git a/midx-write.c b/midx-write.c
index dd3b3070e5..ba4a94950a 100644
--- a/midx-write.c
+++ b/midx-write.c
@@ -1566,7 +1566,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
_("Counting referenced objects"),
m->num_objects);
for (i = 0; i < m->num_objects; i++) {
- int pack_int_id = nth_midxed_pack_int_id(m, i);
+ uint32_t pack_int_id = nth_midxed_pack_int_id(m, i);
count[pack_int_id]++;
display_progress(progress, i + 1);
}
@@ -1697,21 +1697,31 @@ static void fill_included_packs_batch(struct repository *r,
total_size = 0;
for (i = 0; total_size < batch_size && i < m->num_packs; i++) {
- int pack_int_id = pack_info[i].pack_int_id;
+ uint32_t pack_int_id = pack_info[i].pack_int_id;
struct packed_git *p = m->packs[pack_int_id];
- size_t expected_size;
+ uint64_t expected_size;
if (!want_included_pack(r, m, pack_kept_objects, pack_int_id))
continue;
- expected_size = st_mult(p->pack_size,
- pack_info[i].referenced_objects);
+ /*
+ * Use shifted integer arithmetic to calculate the
+ * expected pack size to ~4 significant digits without
+ * overflow for packsizes less that 1PB.
+ */
+ expected_size = (uint64_t)pack_info[i].referenced_objects << 14;
expected_size /= p->num_objects;
+ expected_size = u64_mult(expected_size, p->pack_size);
+ expected_size = u64_add(expected_size, 1u << 13) >> 14;
if (expected_size >= batch_size)
continue;
- total_size += expected_size;
+ if (unsigned_add_overflows(total_size, (size_t)expected_size))
+ total_size = SIZE_MAX;
+ else
+ total_size += expected_size;
+
include_pack[pack_int_id] = 1;
}
diff --git a/name-hash.c b/name-hash.c
index d66de1cdfd..b91e276267 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -492,8 +492,10 @@ static void *lazy_name_thread_proc(void *_data)
for (k = 0; k < d->istate->cache_nr; k++) {
struct cache_entry *ce_k = d->istate->cache[k];
ce_k->ce_flags |= CE_HASHED;
- hashmap_entry_init(&ce_k->ent, d->lazy_entries[k].hash_name);
- hashmap_add(&d->istate->name_hash, &ce_k->ent);
+ if (!S_ISSPARSEDIR(ce_k->ce_mode)) {
+ hashmap_entry_init(&ce_k->ent, d->lazy_entries[k].hash_name);
+ hashmap_add(&d->istate->name_hash, &ce_k->ent);
+ }
}
return NULL;
diff --git a/object-file.c b/object-file.c
index dc56a4766d..1ac04c2891 100644
--- a/object-file.c
+++ b/object-file.c
@@ -130,12 +130,6 @@ int has_loose_object(const struct object_id *oid)
return check_and_freshen(oid, 0);
}
-static int format_object_header_literally(char *str, size_t size,
- const char *type, size_t objsize)
-{
- return xsnprintf(str, size, "%s %"PRIuMAX, type, (uintmax_t)objsize) + 1;
-}
-
int format_object_header(char *str, size_t size, enum object_type type,
size_t objsize)
{
@@ -144,7 +138,7 @@ int format_object_header(char *str, size_t size, enum object_type type,
if (!name)
BUG("could not get a type name for 'enum object_type' value %d", type);
- return format_object_header_literally(str, size, name, objsize);
+ return xsnprintf(str, size, "%s %"PRIuMAX, name, (uintmax_t)objsize) + 1;
}
int check_object_signature(struct repository *r, const struct object_id *oid,
@@ -299,8 +293,7 @@ enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
unsigned char *map,
unsigned long mapsize,
void *buffer,
- unsigned long bufsiz,
- struct strbuf *header)
+ unsigned long bufsiz)
{
int status;
@@ -325,32 +318,9 @@ enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
return ULHR_OK;
/*
- * We have a header longer than MAX_HEADER_LEN. The "header"
- * here is only non-NULL when we run "cat-file
- * --allow-unknown-type".
+ * We have a header longer than MAX_HEADER_LEN.
*/
- if (!header)
- return ULHR_TOO_LONG;
-
- /*
- * buffer[0..bufsiz] was not large enough. Copy the partial
- * result out to header, and then append the result of further
- * reading the stream.
- */
- strbuf_add(header, buffer, stream->next_out - (unsigned char *)buffer);
-
- do {
- stream->next_out = buffer;
- stream->avail_out = bufsiz;
-
- obj_read_unlock();
- status = git_inflate(stream, 0);
- obj_read_lock();
- strbuf_add(header, buffer, stream->next_out - (unsigned char *)buffer);
- if (memchr(buffer, '\0', stream->next_out - (unsigned char *)buffer))
- return 0;
- } while (status == Z_OK);
- return ULHR_BAD;
+ return ULHR_TOO_LONG;
}
static void *unpack_loose_rest(git_zstream *stream,
@@ -427,8 +397,6 @@ int parse_loose_header(const char *hdr, struct object_info *oi)
}
type = type_from_string_gently(type_buf, type_len, 1);
- if (oi->type_name)
- strbuf_add(oi->type_name, type_buf, type_len);
if (oi->typep)
*oi->typep = type;
@@ -476,10 +444,8 @@ int loose_object_info(struct repository *r,
void *map;
git_zstream stream;
char hdr[MAX_HEADER_LEN];
- struct strbuf hdrbuf = STRBUF_INIT;
unsigned long size_scratch;
enum object_type type_scratch;
- int allow_unknown = flags & OBJECT_INFO_ALLOW_UNKNOWN_TYPE;
if (oi->delta_base_oid)
oidclr(oi->delta_base_oid, the_repository->hash_algo);
@@ -492,7 +458,7 @@ int loose_object_info(struct repository *r,
* return value implicitly indicates whether the
* object even exists.
*/
- if (!oi->typep && !oi->type_name && !oi->sizep && !oi->contentp) {
+ if (!oi->typep && !oi->sizep && !oi->contentp) {
struct stat st;
if (!oi->disk_sizep && (flags & OBJECT_INFO_QUICK))
return quick_has_loose(r, oid) ? 0 : -1;
@@ -521,18 +487,15 @@ int loose_object_info(struct repository *r,
if (oi->disk_sizep)
*oi->disk_sizep = mapsize;
- switch (unpack_loose_header(&stream, map, mapsize, hdr, sizeof(hdr),
- allow_unknown ? &hdrbuf : NULL)) {
+ switch (unpack_loose_header(&stream, map, mapsize, hdr, sizeof(hdr))) {
case ULHR_OK:
- if (parse_loose_header(hdrbuf.len ? hdrbuf.buf : hdr, oi) < 0)
+ if (parse_loose_header(hdr, oi) < 0)
status = error(_("unable to parse %s header"), oid_to_hex(oid));
- else if (!allow_unknown && *oi->typep < 0)
+ else if (*oi->typep < 0)
die(_("invalid object type"));
if (!oi->contentp)
break;
- if (hdrbuf.len)
- BUG("unpacking content with unknown types not yet supported");
*oi->contentp = unpack_loose_rest(&stream, hdr, *oi->sizep, oid);
if (*oi->contentp)
goto cleanup;
@@ -558,7 +521,6 @@ cleanup:
munmap(map, mapsize);
if (oi->sizep == &size_scratch)
oi->sizep = NULL;
- strbuf_release(&hdrbuf);
if (oi->typep == &type_scratch)
oi->typep = NULL;
oi->whence = OI_LOOSE;
@@ -590,17 +552,6 @@ static void write_object_file_prepare(const struct git_hash_algo *algo,
hash_object_body(algo, &c, buf, len, oid, hdr, hdrlen);
}
-static void write_object_file_prepare_literally(const struct git_hash_algo *algo,
- const void *buf, unsigned long len,
- const char *type, struct object_id *oid,
- char *hdr, int *hdrlen)
-{
- struct git_hash_ctx c;
-
- *hdrlen = format_object_header_literally(hdr, *hdrlen, type, len);
- hash_object_body(algo, &c, buf, len, oid, hdr, hdrlen);
-}
-
#define CHECK_COLLISION_DEST_VANISHED -2
static int check_collision(const char *source, const char *dest)
@@ -730,21 +681,14 @@ out:
return 0;
}
-static void hash_object_file_literally(const struct git_hash_algo *algo,
- const void *buf, unsigned long len,
- const char *type, struct object_id *oid)
-{
- char hdr[MAX_HEADER_LEN];
- int hdrlen = sizeof(hdr);
-
- write_object_file_prepare_literally(algo, buf, len, type, oid, hdr, &hdrlen);
-}
-
void hash_object_file(const struct git_hash_algo *algo, const void *buf,
unsigned long len, enum object_type type,
struct object_id *oid)
{
- hash_object_file_literally(algo, buf, len, type_name(type), oid);
+ char hdr[MAX_HEADER_LEN];
+ int hdrlen = sizeof(hdr);
+
+ write_object_file_prepare(algo, buf, len, type, oid, hdr, &hdrlen);
}
/* Finalize a file on disk, and close it. */
@@ -1146,53 +1090,6 @@ int write_object_file_flags(const void *buf, unsigned long len,
return 0;
}
-int write_object_file_literally(const void *buf, unsigned long len,
- const char *type, struct object_id *oid,
- unsigned flags)
-{
- char *header;
- struct repository *repo = the_repository;
- const struct git_hash_algo *algo = repo->hash_algo;
- const struct git_hash_algo *compat = repo->compat_hash_algo;
- struct object_id compat_oid;
- int hdrlen, status = 0;
- int compat_type = -1;
-
- if (compat) {
- compat_type = type_from_string_gently(type, -1, 1);
- if (compat_type == OBJ_BLOB)
- hash_object_file(compat, buf, len, compat_type,
- &compat_oid);
- else if (compat_type != -1) {
- struct strbuf converted = STRBUF_INIT;
- convert_object_file(the_repository,
- &converted, algo, compat,
- buf, len, compat_type, 0);
- hash_object_file(compat, converted.buf, converted.len,
- compat_type, &compat_oid);
- strbuf_release(&converted);
- }
- }
-
- /* type string, SP, %lu of the length plus NUL must fit this */
- hdrlen = strlen(type) + MAX_HEADER_LEN;
- header = xmalloc(hdrlen);
- write_object_file_prepare_literally(the_hash_algo, buf, len, type,
- oid, header, &hdrlen);
-
- if (!(flags & WRITE_OBJECT_FILE_PERSIST))
- goto cleanup;
- if (freshen_packed_object(oid) || freshen_loose_object(oid))
- goto cleanup;
- status = write_loose_object(oid, header, hdrlen, buf, len, 0, 0);
- if (compat_type != -1)
- return repo_add_loose_object_map(repo, oid, &compat_oid);
-
-cleanup:
- free(header);
- return status;
-}
-
int force_object_loose(const struct object_id *oid, time_t mtime)
{
struct repository *repo = the_repository;
@@ -1682,8 +1579,7 @@ int read_loose_object(const char *path,
goto out;
}
- if (unpack_loose_header(&stream, map, mapsize, hdr, sizeof(hdr),
- NULL) != ULHR_OK) {
+ if (unpack_loose_header(&stream, map, mapsize, hdr, sizeof(hdr)) != ULHR_OK) {
error(_("unable to unpack header of %s"), path);
goto out_inflate;
}
@@ -1693,6 +1589,12 @@ int read_loose_object(const char *path,
goto out_inflate;
}
+ if (*oi->typep < 0) {
+ error(_("unable to parse type from header '%s' of %s"),
+ hdr, path);
+ goto out_inflate;
+ }
+
if (*oi->typep == OBJ_BLOB &&
*size > repo_settings_get_big_file_threshold(the_repository)) {
if (check_stream_oid(&stream, hdr, *size, path, expected_oid) < 0)
@@ -1703,9 +1605,9 @@ int read_loose_object(const char *path,
error(_("unable to unpack contents of %s"), path);
goto out_inflate;
}
- hash_object_file_literally(the_repository->hash_algo,
- *contents, *size,
- oi->type_name->buf, real_oid);
+ hash_object_file(the_repository->hash_algo,
+ *contents, *size,
+ *oi->typep, real_oid);
if (!oideq(expected_oid, real_oid))
goto out_inflate;
}
diff --git a/object-file.h b/object-file.h
index a85b2e5b49..6f41142452 100644
--- a/object-file.h
+++ b/object-file.h
@@ -133,12 +133,7 @@ int format_object_header(char *str, size_t size, enum object_type type,
* - ULHR_BAD on error
* - ULHR_TOO_LONG if the header was too long
*
- * It will only parse up to MAX_HEADER_LEN bytes unless an optional
- * "hdrbuf" argument is non-NULL. This is intended for use with
- * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
- * reporting. The full header will be extracted to "hdrbuf" for use
- * with parse_loose_header(), ULHR_TOO_LONG will still be returned
- * from this function to indicate that the header was too long.
+ * It will only parse up to MAX_HEADER_LEN bytes.
*/
enum unpack_loose_header_result {
ULHR_OK,
@@ -149,8 +144,7 @@ enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
unsigned char *map,
unsigned long mapsize,
void *buffer,
- unsigned long bufsiz,
- struct strbuf *hdrbuf);
+ unsigned long bufsiz);
/**
* parse_loose_header() parses the starting "<type> <len>\0" of an
@@ -165,7 +159,7 @@ int parse_loose_header(const char *hdr, struct object_info *oi);
enum {
/*
- * By default, `write_object_file_literally()` does not actually write
+ * By default, `write_object_file()` does not actually write
* anything into the object store, but only computes the object ID.
* This flag changes that so that the object will be written as a loose
* object and persisted.
@@ -180,7 +174,7 @@ enum {
int write_object_file_flags(const void *buf, unsigned long len,
enum object_type type, struct object_id *oid,
- struct object_id *comapt_oid_in, unsigned flags);
+ struct object_id *compat_oid_in, unsigned flags);
static inline int write_object_file(const void *buf, unsigned long len,
enum object_type type, struct object_id *oid)
{
@@ -193,9 +187,6 @@ struct input_stream {
int is_finished;
};
-int write_object_file_literally(const void *buf, unsigned long len,
- const char *type, struct object_id *oid,
- unsigned flags);
int stream_loose_object(struct input_stream *in_stream, size_t len,
struct object_id *oid);
diff --git a/object-store.c b/object-store.c
index 517f1fd145..58cde0313a 100644
--- a/object-store.c
+++ b/object-store.c
@@ -646,8 +646,6 @@ static int do_oid_object_info_extended(struct repository *r,
*(oi->disk_sizep) = 0;
if (oi->delta_base_oid)
oidclr(oi->delta_base_oid, the_repository->hash_algo);
- if (oi->type_name)
- strbuf_addstr(oi->type_name, type_name(co->type));
if (oi->contentp)
*oi->contentp = xmemdupz(co->buf, co->size);
oi->whence = OI_CACHED;
@@ -727,7 +725,7 @@ static int oid_object_info_convert(struct repository *r,
{
const struct git_hash_algo *input_algo = &hash_algos[input_oid->algo];
int do_die = flags & OBJECT_INFO_DIE_IF_CORRUPT;
- struct strbuf type_name = STRBUF_INIT;
+ enum object_type type;
struct object_id oid, delta_base_oid;
struct object_info new_oi, *oi;
unsigned long size;
@@ -753,7 +751,7 @@ static int oid_object_info_convert(struct repository *r,
if (input_oi->sizep || input_oi->contentp) {
new_oi.contentp = &content;
new_oi.sizep = &size;
- new_oi.type_name = &type_name;
+ new_oi.typep = &type;
}
oi = &new_oi;
}
@@ -766,12 +764,7 @@ static int oid_object_info_convert(struct repository *r,
if (new_oi.contentp) {
struct strbuf outbuf = STRBUF_INIT;
- enum object_type type;
- type = type_from_string_gently(type_name.buf, type_name.len,
- !do_die);
- if (type == -1)
- return -1;
if (type != OBJ_BLOB) {
ret = convert_object_file(the_repository, &outbuf,
the_hash_algo, input_algo,
@@ -788,10 +781,8 @@ static int oid_object_info_convert(struct repository *r,
*input_oi->contentp = content;
else
free(content);
- if (input_oi->type_name)
- *input_oi->type_name = type_name;
- else
- strbuf_release(&type_name);
+ if (input_oi->typep)
+ *input_oi->typep = type;
}
if (new_oi.delta_base_oid == &delta_base_oid) {
if (repo_oid_to_algop(r, &delta_base_oid, input_algo,
diff --git a/object-store.h b/object-store.h
index 141b801113..c589008535 100644
--- a/object-store.h
+++ b/object-store.h
@@ -206,7 +206,6 @@ struct object_info {
unsigned long *sizep;
off_t *disk_sizep;
struct object_id *delta_base_oid;
- struct strbuf *type_name;
void **contentp;
/* Response */
@@ -241,8 +240,6 @@ struct object_info {
/* Invoke lookup_replace_object() on the given hash */
#define OBJECT_INFO_LOOKUP_REPLACE 1
-/* Allow reading from a loose object file of unknown/bogus type */
-#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2
/* Do not retry packed storage after checking packed and loose storage */
#define OBJECT_INFO_QUICK 8
/*
diff --git a/pack-bitmap.c b/pack-bitmap.c
index b9f1d86604..ac6d62b980 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -388,10 +388,6 @@ static int load_bitmap_entries_v1(struct bitmap_index *index)
return error(_("corrupt ewah bitmap: commit index %u out of range"),
(unsigned)commit_idx_pos);
- bitmap = read_bitmap_1(index);
- if (!bitmap)
- return -1;
-
if (xor_offset > MAX_XOR_OFFSET || xor_offset > i)
return error(_("corrupted bitmap pack index"));
@@ -402,6 +398,10 @@ static int load_bitmap_entries_v1(struct bitmap_index *index)
return error(_("invalid XOR offset in bitmap pack index"));
}
+ bitmap = read_bitmap_1(index);
+ if (!bitmap)
+ return -1;
+
recent_bitmaps[i % MAX_XOR_OFFSET] = store_bitmap(
index, bitmap, &oid, xor_bitmap, flags);
}
diff --git a/packfile.c b/packfile.c
index 933036e260..70c7208f02 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1609,17 +1609,12 @@ int packed_object_info(struct repository *r, struct packed_git *p,
*oi->disk_sizep = pack_pos_to_offset(p, pos + 1) - obj_offset;
}
- if (oi->typep || oi->type_name) {
+ if (oi->typep) {
enum object_type ptot;
ptot = packed_to_object_type(r, p, obj_offset,
type, &w_curs, curpos);
if (oi->typep)
*oi->typep = ptot;
- if (oi->type_name) {
- const char *tn = type_name(ptot);
- if (tn)
- strbuf_addstr(oi->type_name, tn);
- }
if (ptot < 0) {
type = OBJ_BAD;
goto out;
diff --git a/perl/Git/SVN/Memoize/meson.build b/perl/Git/SVN/Memoize/meson.build
index 4c589b30c3..d6209dc3bf 100644
--- a/perl/Git/SVN/Memoize/meson.build
+++ b/perl/Git/SVN/Memoize/meson.build
@@ -3,6 +3,6 @@ test_dependencies += custom_target(
output: 'YAML.pm',
command: generate_perl_command,
install: true,
- install_dir: perllibdir / 'Git/SVN',
+ install_dir: perllibdir / 'Git/SVN/Memoize',
depends: [git_version_file],
)
diff --git a/read-cache.c b/read-cache.c
index 73f83a7e7a..c0bb760ad4 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1117,48 +1117,19 @@ static int has_dir_name(struct index_state *istate,
*
* Compare the entry's full path with the last path in the index.
*/
- if (istate->cache_nr > 0) {
- cmp_last = strcmp_offset(name,
- istate->cache[istate->cache_nr - 1]->name,
- &len_eq_last);
- if (cmp_last > 0) {
- if (name[len_eq_last] != '/') {
- /*
- * The entry sorts AFTER the last one in the
- * index.
- *
- * If there were a conflict with "file", then our
- * name would start with "file/" and the last index
- * entry would start with "file" but not "file/".
- *
- * The next character after common prefix is
- * not '/', so there can be no conflict.
- */
- return retval;
- } else {
- /*
- * The entry sorts AFTER the last one in the
- * index, and the next character after common
- * prefix is '/'.
- *
- * Either the last index entry is a file in
- * conflict with this entry, or it has a name
- * which sorts between this entry and the
- * potential conflicting file.
- *
- * In both cases, we fall through to the loop
- * below and let the regular search code handle it.
- */
- }
- } else if (cmp_last == 0) {
- /*
- * The entry exactly matches the last one in the
- * index, but because of multiple stage and CE_REMOVE
- * items, we fall through and let the regular search
- * code handle it.
- */
- }
- }
+ if (!istate->cache_nr)
+ return 0;
+
+ cmp_last = strcmp_offset(name,
+ istate->cache[istate->cache_nr - 1]->name,
+ &len_eq_last);
+ if (cmp_last > 0 && name[len_eq_last] != '/')
+ /*
+ * The entry sorts AFTER the last one in the
+ * index and their paths have no common prefix,
+ * so there cannot be a F/D conflict.
+ */
+ return 0;
for (;;) {
size_t len;
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 3ad1ed0787..7fd73a0e6d 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -517,6 +517,32 @@ static int refname_contains_nul(struct strbuf *refname)
#define SMALL_FILE_SIZE (32*1024)
+static int allocate_snapshot_buffer(struct snapshot *snapshot, int fd, struct stat *st)
+{
+ ssize_t bytes_read;
+ size_t size;
+
+ size = xsize_t(st->st_size);
+ if (!size)
+ return 0;
+
+ if (mmap_strategy == MMAP_NONE || size <= SMALL_FILE_SIZE) {
+ snapshot->buf = xmalloc(size);
+ bytes_read = read_in_full(fd, snapshot->buf, size);
+ if (bytes_read < 0 || bytes_read != size)
+ die_errno("couldn't read %s", snapshot->refs->path);
+ snapshot->mmapped = 0;
+ } else {
+ snapshot->buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
+ snapshot->mmapped = 1;
+ }
+
+ snapshot->start = snapshot->buf;
+ snapshot->eof = snapshot->buf + size;
+
+ return 1;
+}
+
/*
* Depending on `mmap_strategy`, either mmap or read the contents of
* the `packed-refs` file into the snapshot. Return 1 if the file
@@ -525,10 +551,9 @@ static int refname_contains_nul(struct strbuf *refname)
*/
static int load_contents(struct snapshot *snapshot)
{
- int fd;
struct stat st;
- size_t size;
- ssize_t bytes_read;
+ int ret;
+ int fd;
fd = open(snapshot->refs->path, O_RDONLY);
if (fd < 0) {
@@ -550,27 +575,11 @@ static int load_contents(struct snapshot *snapshot)
if (fstat(fd, &st) < 0)
die_errno("couldn't stat %s", snapshot->refs->path);
- size = xsize_t(st.st_size);
-
- if (!size) {
- close(fd);
- return 0;
- } else if (mmap_strategy == MMAP_NONE || size <= SMALL_FILE_SIZE) {
- snapshot->buf = xmalloc(size);
- bytes_read = read_in_full(fd, snapshot->buf, size);
- if (bytes_read < 0 || bytes_read != size)
- die_errno("couldn't read %s", snapshot->refs->path);
- snapshot->mmapped = 0;
- } else {
- snapshot->buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
- snapshot->mmapped = 1;
- }
- close(fd);
- snapshot->start = snapshot->buf;
- snapshot->eof = snapshot->buf + size;
+ ret = allocate_snapshot_buffer(snapshot, fd, &st);
- return 1;
+ close(fd);
+ return ret;
}
static const char *find_reference_location_1(struct snapshot *snapshot,
@@ -2059,7 +2068,7 @@ static int packed_fsck(struct ref_store *ref_store,
{
struct packed_ref_store *refs = packed_downcast(ref_store,
REF_STORE_READ, "fsck");
- struct strbuf packed_ref_content = STRBUF_INIT;
+ struct snapshot snapshot = { 0 };
unsigned int sorted = 0;
struct stat st;
int ret = 0;
@@ -2103,21 +2112,25 @@ static int packed_fsck(struct ref_store *ref_store,
goto cleanup;
}
- if (strbuf_read(&packed_ref_content, fd, 0) < 0) {
- ret = error_errno(_("unable to read '%s'"), refs->path);
+ if (!allocate_snapshot_buffer(&snapshot, fd, &st)) {
+ struct fsck_ref_report report = { 0 };
+ report.path = "packed-refs";
+ ret = fsck_report_ref(o, &report,
+ FSCK_MSG_EMPTY_PACKED_REFS_FILE,
+ "file is empty");
goto cleanup;
}
- ret = packed_fsck_ref_content(o, ref_store, &sorted, packed_ref_content.buf,
- packed_ref_content.buf + packed_ref_content.len);
+ ret = packed_fsck_ref_content(o, ref_store, &sorted, snapshot.start,
+ snapshot.eof);
if (!ret && sorted)
- ret = packed_fsck_ref_sorted(o, ref_store, packed_ref_content.buf,
- packed_ref_content.buf + packed_ref_content.len);
+ ret = packed_fsck_ref_sorted(o, ref_store, snapshot.start,
+ snapshot.eof);
cleanup:
if (fd >= 0)
close(fd);
- strbuf_release(&packed_ref_content);
+ clear_snapshot_buffer(&snapshot);
return ret;
}
diff --git a/reftable/basics.h b/reftable/basics.h
index d8888c1262..7d22f96261 100644
--- a/reftable/basics.h
+++ b/reftable/basics.h
@@ -16,7 +16,11 @@
#include "system.h"
#include "reftable-basics.h"
+#ifdef __GNUC__
#define REFTABLE_UNUSED __attribute__((__unused__))
+#else
+#define REFTABLE_UNUSED
+#endif
/*
* Initialize the buffer such that it is ready for use. This is equivalent to
diff --git a/scalar.c b/scalar.c
index d359f08bb8..355baf75e4 100644
--- a/scalar.c
+++ b/scalar.c
@@ -209,6 +209,12 @@ static int set_recommended_config(int reconfigure)
return 0;
}
+/**
+ * Enable or disable the maintenance mode for the current repository:
+ *
+ * * If 'enable' is nonzero, run 'git maintenance start'.
+ * * If 'enable' is zero, run 'git maintenance unregister --force'.
+ */
static int toggle_maintenance(int enable)
{
return run_git("maintenance",
@@ -259,7 +265,15 @@ static int stop_fsmonitor_daemon(void)
return 0;
}
-static int register_dir(void)
+/**
+ * Register the current directory as a Scalar enlistment, and set the
+ * recommended configuration.
+ *
+ * * If 'maintenance' is non-zero, then enable background maintenance.
+ * * If 'maintenance' is zero, then leave background maintenance as it is
+ * currently configured.
+ */
+static int register_dir(int maintenance)
{
if (add_or_remove_enlistment(1))
return error(_("could not add enlistment"));
@@ -267,8 +281,9 @@ static int register_dir(void)
if (set_recommended_config(0))
return error(_("could not set recommended config"));
- if (toggle_maintenance(1))
- warning(_("could not turn on maintenance"));
+ if (maintenance &&
+ toggle_maintenance(maintenance))
+ warning(_("could not toggle maintenance"));
if (have_fsmonitor_support() && start_fsmonitor_daemon()) {
return error(_("could not start the FSMonitor daemon"));
@@ -411,7 +426,7 @@ static int cmd_clone(int argc, const char **argv)
const char *branch = NULL;
char *branch_to_free = NULL;
int full_clone = 0, single_branch = 0, show_progress = isatty(2);
- int src = 1, tags = 1;
+ int src = 1, tags = 1, maintenance = 1;
struct option clone_options[] = {
OPT_STRING('b', "branch", &branch, N_("<branch>"),
N_("branch to checkout after clone")),
@@ -424,11 +439,13 @@ static int cmd_clone(int argc, const char **argv)
N_("create repository within 'src' directory")),
OPT_BOOL(0, "tags", &tags,
N_("specify if tags should be fetched during clone")),
+ OPT_BOOL(0, "maintenance", &maintenance,
+ N_("specify if background maintenance should be enabled")),
OPT_END(),
};
const char * const clone_usage[] = {
N_("scalar clone [--single-branch] [--branch <main-branch>] [--full-clone]\n"
- "\t[--[no-]src] [--[no-]tags] <url> [<enlistment>]"),
+ "\t[--[no-]src] [--[no-]tags] [--[no-]maintenance] <url> [<enlistment>]"),
NULL
};
const char *url;
@@ -550,7 +567,8 @@ static int cmd_clone(int argc, const char **argv)
if (res)
goto cleanup;
- res = register_dir();
+ /* If --no-maintenance, then skip maintenance command entirely. */
+ res = register_dir(maintenance);
cleanup:
free(branch_to_free);
@@ -597,11 +615,14 @@ static int cmd_list(int argc, const char **argv UNUSED)
static int cmd_register(int argc, const char **argv)
{
+ int maintenance = 1;
struct option options[] = {
+ OPT_BOOL(0, "maintenance", &maintenance,
+ N_("specify if background maintenance should be enabled")),
OPT_END(),
};
const char * const usage[] = {
- N_("scalar register [<enlistment>]"),
+ N_("scalar register [--[no-]maintenance] [<enlistment>]"),
NULL
};
@@ -610,7 +631,8 @@ static int cmd_register(int argc, const char **argv)
setup_enlistment_directory(argc, argv, usage, options, NULL);
- return register_dir();
+ /* If --no-maintenance, then leave maintenance as-is. */
+ return register_dir(maintenance);
}
static int get_scalar_repos(const char *key, const char *value,
@@ -646,13 +668,19 @@ static int remove_deleted_enlistment(struct strbuf *path)
static int cmd_reconfigure(int argc, const char **argv)
{
int all = 0;
+ const char *maintenance_str = NULL;
+ int maintenance = 1; /* Enable maintenance by default. */
+
struct option options[] = {
OPT_BOOL('a', "all", &all,
N_("reconfigure all registered enlistments")),
+ OPT_STRING(0, "maintenance", &maintenance_str,
+ N_("(enable|disable|keep)"),
+ N_("signal how to adjust background maintenance")),
OPT_END(),
};
const char * const usage[] = {
- N_("scalar reconfigure [--all | <enlistment>]"),
+ N_("scalar reconfigure [--maintenance=(enable|disable|keep)] [--all | <enlistment>]"),
NULL
};
struct string_list scalar_repos = STRING_LIST_INIT_DUP;
@@ -672,6 +700,18 @@ static int cmd_reconfigure(int argc, const char **argv)
usage_msg_opt(_("--all or <enlistment>, but not both"),
usage, options);
+ if (maintenance_str) {
+ if (!strcmp(maintenance_str, "enable"))
+ maintenance = 1;
+ else if (!strcmp(maintenance_str, "disable"))
+ maintenance = 0;
+ else if (!strcmp(maintenance_str, "keep"))
+ maintenance = -1;
+ else
+ die(_("unknown mode for --maintenance option: %s"),
+ maintenance_str);
+ }
+
git_config(get_scalar_repos, &scalar_repos);
for (size_t i = 0; i < scalar_repos.nr; i++) {
@@ -736,7 +776,8 @@ static int cmd_reconfigure(int argc, const char **argv)
the_repository = old_repo;
repo_clear(&r);
- if (toggle_maintenance(1) >= 0)
+ if (maintenance >= 0 &&
+ toggle_maintenance(maintenance) >= 0)
succeeded = 1;
loop_end:
@@ -803,13 +844,13 @@ static int cmd_run(int argc, const char **argv)
strbuf_release(&buf);
if (i == 0)
- return register_dir();
+ return register_dir(1);
if (i > 0)
return run_git("maintenance", "run",
"--task", tasks[i].task, NULL);
- if (register_dir())
+ if (register_dir(1))
return -1;
for (i = 1; tasks[i].arg; i++)
if (run_git("maintenance", "run",
diff --git a/sequencer.c b/sequencer.c
index 4edf66fb28..1ee0abbd45 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2636,9 +2636,12 @@ static int is_command(enum todo_command command, const char **bol)
const char nick = todo_command_info[command].c;
const char *p = *bol;
- return (skip_prefix(p, str, &p) || (nick && *p++ == nick)) &&
- (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || !*p) &&
- (*bol = p);
+ if ((skip_prefix(p, str, &p) || (nick && *p++ == nick)) &&
+ (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || !*p)) {
+ *bol = p;
+ return 1;
+ }
+ return 0;
}
static int check_label_or_ref_arg(enum todo_command command, const char *arg)
@@ -5899,11 +5902,11 @@ static int make_script_with_merges(struct pretty_print_context *pp,
/* Create a label from the commit message */
strbuf_reset(&label_from_message);
- if (skip_prefix(oneline.buf, "Merge ", &p1) &&
+ if (skip_prefix(oneline.buf, "# Merge ", &p1) &&
(p1 = strchr(p1, '\'')) &&
(p2 = strchr(++p1, '\'')))
strbuf_add(&label_from_message, p1, p2 - p1);
- else if (skip_prefix(oneline.buf, "Merge pull request ",
+ else if (skip_prefix(oneline.buf, "# Merge pull request ",
&p1) &&
(p1 = strstr(p1, " from ")))
strbuf_addstr(&label_from_message, p1 + strlen(" from "));
@@ -5938,7 +5941,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
strbuf_addstr(&buf, label_oid(oid, label, &state));
}
- strbuf_addf(&buf, " # %s", oneline.buf);
+ strbuf_addf(&buf, " %s", oneline.buf);
FLEX_ALLOC_STR(entry, string, buf.buf);
oidcpy(&entry->entry.oid, &commit->object.oid);
@@ -6020,7 +6023,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
else {
strbuf_reset(&oneline);
pretty_print_commit(pp, commit, &oneline);
- strbuf_addf(out, "%s %s # %s\n",
+ strbuf_addf(out, "%s %s %s\n",
cmd_reset, to, oneline.buf);
}
}
@@ -6088,8 +6091,14 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
git_config_get_string("rebase.instructionFormat", &format);
if (!format || !*format) {
free(format);
- format = xstrdup("%s");
+ format = xstrdup("# %s");
}
+ if (*format != '#') {
+ char *temp = format;
+ format = xstrfmt("# %s", temp);
+ free(temp);
+ }
+
get_commit_format(format, &revs);
free(format);
pp.fmt = revs.commit_format;
@@ -6594,6 +6603,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
char **subjects;
struct commit_todo_item commit_todo;
struct todo_item *items = NULL;
+ int ret = 0;
init_commit_todo_item(&commit_todo);
/*
@@ -6624,8 +6634,8 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
}
if (is_fixup(item->command)) {
- clear_commit_todo_item(&commit_todo);
- return error(_("the script was already rearranged."));
+ ret = error(_("the script was already rearranged."));
+ goto cleanup;
}
repo_parse_commit(the_repository, item->commit);
@@ -6727,6 +6737,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
todo_list->items = items;
}
+cleanup:
free(next);
free(tail);
for (i = 0; i < todo_list->nr; i++)
@@ -6736,7 +6747,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
clear_commit_todo_item(&commit_todo);
- return 0;
+ return ret;
}
int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
diff --git a/streaming.c b/streaming.c
index 127d6b5d6a..6d6512e2e0 100644
--- a/streaming.c
+++ b/streaming.c
@@ -238,7 +238,7 @@ static int open_istream_loose(struct git_istream *st, struct repository *r,
return -1;
switch (unpack_loose_header(&st->z, st->u.loose.mapped,
st->u.loose.mapsize, st->u.loose.hdr,
- sizeof(st->u.loose.hdr), NULL)) {
+ sizeof(st->u.loose.hdr))) {
case ULHR_OK:
break;
case ULHR_BAD:
diff --git a/t/helper/meson.build b/t/helper/meson.build
index d4e8b26df8..675e64c010 100644
--- a/t/helper/meson.build
+++ b/t/helper/meson.build
@@ -77,6 +77,7 @@ test_tool_sources = [
'test-windows-named-pipe.c',
'test-write-cache.c',
'test-xml-encode.c',
+ 'test-zlib.c',
]
test_tool = executable('test-tool',
diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
index 74812ed86d..a7abc618b3 100644
--- a/t/helper/test-tool.c
+++ b/t/helper/test-tool.c
@@ -91,6 +91,7 @@ static struct test_cmd cmds[] = {
{ "windows-named-pipe", cmd__windows_named_pipe },
#endif
{ "write-cache", cmd__write_cache },
+ { "zlib", cmd__zlib },
};
static NORETURN void die_usage(void)
diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
index 2571a3ccfe..7f150fa1eb 100644
--- a/t/helper/test-tool.h
+++ b/t/helper/test-tool.h
@@ -84,6 +84,7 @@ int cmd__wildmatch(int argc, const char **argv);
int cmd__windows_named_pipe(int argc, const char **argv);
#endif
int cmd__write_cache(int argc, const char **argv);
+int cmd__zlib(int argc, const char **argv);
int cmd_hash_impl(int ac, const char **av, int algo, int unsafe);
diff --git a/t/helper/test-zlib.c b/t/helper/test-zlib.c
new file mode 100644
index 0000000000..de7e9edee1
--- /dev/null
+++ b/t/helper/test-zlib.c
@@ -0,0 +1,62 @@
+#include "test-tool.h"
+#include "git-zlib.h"
+#include "strbuf.h"
+
+static const char *zlib_usage = "test-tool zlib [inflate|deflate]";
+
+static void do_zlib(struct git_zstream *stream,
+ int (*zlib_func)(git_zstream *, int),
+ int fd_in, int fd_out)
+{
+ struct strbuf buf_in = STRBUF_INIT;
+ int status = Z_OK;
+
+ if (strbuf_read(&buf_in, fd_in, 0) < 0)
+ die_errno("read error");
+
+ stream->next_in = (unsigned char *)buf_in.buf;
+ stream->avail_in = buf_in.len;
+
+ while (status == Z_OK ||
+ (status == Z_BUF_ERROR && !stream->avail_out)) {
+ unsigned char buf_out[4096];
+
+ stream->next_out = buf_out;
+ stream->avail_out = sizeof(buf_out);
+
+ status = zlib_func(stream, Z_FINISH);
+ if (write_in_full(fd_out, buf_out,
+ sizeof(buf_out) - stream->avail_out) < 0)
+ die_errno("write error");
+ }
+
+ if (status != Z_STREAM_END)
+ die("zlib error %d", status);
+
+ strbuf_release(&buf_in);
+}
+
+int cmd__zlib(int argc, const char **argv)
+{
+ git_zstream stream;
+
+ if (argc != 2)
+ usage(zlib_usage);
+
+ memset(&stream, 0, sizeof(stream));
+
+ if (!strcmp(argv[1], "inflate")) {
+ git_inflate_init(&stream);
+ do_zlib(&stream, git_inflate, 0, 1);
+ git_inflate_end(&stream);
+ } else if (!strcmp(argv[1], "deflate")) {
+ git_deflate_init(&stream, Z_DEFAULT_COMPRESSION);
+ do_zlib(&stream, git_deflate, 0, 1);
+ git_deflate_end(&stream);
+ } else {
+ error("unknown mode: %s", argv[1]);
+ usage(zlib_usage);
+ }
+
+ return 0;
+}
diff --git a/t/lib-loose.sh b/t/lib-loose.sh
new file mode 100644
index 0000000000..3613631eaf
--- /dev/null
+++ b/t/lib-loose.sh
@@ -0,0 +1,30 @@
+# Support routines for hand-crafting loose objects.
+
+# Write a loose object into the odb at $1, with object type $2 and contents
+# from stdin. Writes the oid to stdout. Example:
+#
+# oid=$(echo foo | loose_obj .git/objects blob)
+#
+loose_obj () {
+ cat >tmp_loose.content &&
+ size=$(wc -c <tmp_loose.content) &&
+ {
+ # Do not quote $size here; we want the shell
+ # to strip whitespace that "wc" adds on some platforms.
+ printf "%s %s\0" "$2" $size &&
+ cat tmp_loose.content
+ } >tmp_loose.raw &&
+
+ oid=$(test-tool $test_hash_algo <tmp_loose.raw) &&
+ suffix=${oid#??} &&
+ prefix=${oid%$suffix} &&
+ dir=$1/$prefix &&
+ file=$dir/$suffix &&
+
+ test-tool zlib deflate <tmp_loose.raw >tmp_loose.zlib &&
+ mkdir -p "$dir" &&
+ mv tmp_loose.zlib "$file" &&
+
+ rm tmp_loose.raw tmp_loose.content &&
+ echo "$oid"
+}
diff --git a/t/meson.build b/t/meson.build
index fcfc1c2c2b..d052fc3e23 100644
--- a/t/meson.build
+++ b/t/meson.build
@@ -629,7 +629,7 @@ integration_tests = [
't5407-post-rewrite-hook.sh',
't5408-send-pack-stdin.sh',
't5409-colorize-remote-messages.sh',
- 't5410-receive-pack-alternates.sh',
+ 't5410-receive-pack.sh',
't5411-proc-receive-hook.sh',
't5500-fetch-pack.sh',
't5501-fetch-push-alternates.sh',
diff --git a/t/perf/p2000-sparse-operations.sh b/t/perf/p2000-sparse-operations.sh
index 39e92b0841..aadf22bc2f 100755
--- a/t/perf/p2000-sparse-operations.sh
+++ b/t/perf/p2000-sparse-operations.sh
@@ -135,5 +135,8 @@ test_perf_on_all git diff-tree HEAD
test_perf_on_all git diff-tree HEAD -- $SPARSE_CONE/a
test_perf_on_all "git worktree add ../temp && git worktree remove ../temp"
test_perf_on_all git check-attr -a -- $SPARSE_CONE/a
+test_perf_on_all 'echo >>a && test_write_lines y | git add -p'
+test_perf_on_all 'test_write_lines y y y | git checkout --patch -'
+test_perf_on_all 'echo >>a && git add a && test_write_lines y | git reset --patch'
test_done
diff --git a/t/perf/p5313-pack-objects.sh b/t/perf/p5313-pack-objects.sh
index be5229a0ec..786a2c1c6f 100755
--- a/t/perf/p5313-pack-objects.sh
+++ b/t/perf/p5313-pack-objects.sh
@@ -3,9 +3,6 @@
test_description='Tests pack performance using bitmaps'
. ./perf-lib.sh
-GIT_TEST_PASSING_SANITIZE_LEAK=0
-export GIT_TEST_PASSING_SANITIZE_LEAK
-
test_perf_large_repo
test_expect_success 'create rev input' '
diff --git a/t/perf/p5314-name-hash.sh b/t/perf/p5314-name-hash.sh
index 4ef0ba7711..235cdfc824 100755
--- a/t/perf/p5314-name-hash.sh
+++ b/t/perf/p5314-name-hash.sh
@@ -3,9 +3,6 @@
test_description='Tests pack performance using bitmaps'
. ./perf-lib.sh
-GIT_TEST_PASSING_SANITIZE_LEAK=0
-export GIT_TEST_PASSING_SANITIZE_LEAK
-
test_perf_large_repo
test_size 'paths at head' '
diff --git a/t/t0602-reffiles-fsck.sh b/t/t0602-reffiles-fsck.sh
index 9d1dc2144c..f671ac4d3a 100755
--- a/t/t0602-reffiles-fsck.sh
+++ b/t/t0602-reffiles-fsck.sh
@@ -647,6 +647,23 @@ test_expect_success SYMLINKS 'the filetype of packed-refs should be checked' '
)
'
+test_expect_success 'empty packed-refs should be reported' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit default &&
+
+ >.git/packed-refs &&
+ git refs verify 2>err &&
+ cat >expect <<-EOF &&
+ warning: packed-refs: emptyPackedRefsFile: file is empty
+ EOF
+ rm .git/packed-refs &&
+ test_cmp expect err
+ )
+'
+
test_expect_success 'packed-refs header should be checked' '
test_when_finished "rm -rf repo" &&
git init repo &&
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index ce8b27bf54..317da6869c 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -3,6 +3,7 @@
test_description='git cat-file'
. ./test-lib.sh
+. "$TEST_DIRECTORY/lib-loose.sh"
test_cmdmode_usage () {
test_expect_code 129 "$@" 2>err &&
@@ -136,18 +137,6 @@ $content"
test_cmp expect actual
'
- test_expect_success "Type of $type is correct using --allow-unknown-type" '
- echo $type >expect &&
- git cat-file -t --allow-unknown-type $oid >actual &&
- test_cmp expect actual
- '
-
- test_expect_success "Size of $type is correct using --allow-unknown-type" '
- echo $size >expect &&
- git cat-file -s --allow-unknown-type $oid >actual &&
- test_cmp expect actual
- '
-
test -z "$content" ||
test_expect_success "Content of $type is correct" '
echo_without_newline "$content" >expect &&
@@ -669,103 +658,75 @@ test_expect_success 'setup bogus data' '
bogus_short_type="bogus" &&
bogus_short_content="bogus" &&
bogus_short_size=$(strlen "$bogus_short_content") &&
- bogus_short_oid=$(echo_without_newline "$bogus_short_content" | git hash-object -t $bogus_short_type --literally -w --stdin) &&
+ bogus_short_oid=$(echo_without_newline "$bogus_short_content" | loose_obj .git/objects $bogus_short_type) &&
bogus_long_type="abcdefghijklmnopqrstuvwxyz1234679" &&
bogus_long_content="bogus" &&
bogus_long_size=$(strlen "$bogus_long_content") &&
- bogus_long_oid=$(echo_without_newline "$bogus_long_content" | git hash-object -t $bogus_long_type --literally -w --stdin)
+ bogus_long_oid=$(echo_without_newline "$bogus_long_content" | loose_obj .git/objects $bogus_long_type)
'
-for arg1 in '' --allow-unknown-type
+for arg1 in -s -t -p
do
- for arg2 in -s -t -p
- do
- if test "$arg1" = "--allow-unknown-type" && test "$arg2" = "-p"
- then
- continue
- fi
+ test_expect_success "cat-file $arg1 error on bogus short OID" '
+ cat >expect <<-\EOF &&
+ fatal: invalid object type
+ EOF
+ test_must_fail git cat-file $arg1 $bogus_short_oid >out 2>actual &&
+ test_must_be_empty out &&
+ test_cmp expect actual
+ '
- test_expect_success "cat-file $arg1 $arg2 error on bogus short OID" '
- cat >expect <<-\EOF &&
- fatal: invalid object type
+ test_expect_success "cat-file $arg1 error on bogus full OID" '
+ if test "$arg1" = "-p"
+ then
+ cat >expect <<-EOF
+ error: header for $bogus_long_oid too long, exceeds 32 bytes
+ fatal: Not a valid object name $bogus_long_oid
+ EOF
+ else
+ cat >expect <<-EOF
+ error: header for $bogus_long_oid too long, exceeds 32 bytes
+ fatal: git cat-file: could not get object info
EOF
+ fi &&
- if test "$arg1" = "--allow-unknown-type"
- then
- git cat-file $arg1 $arg2 $bogus_short_oid
- else
- test_must_fail git cat-file $arg1 $arg2 $bogus_short_oid >out 2>actual &&
- test_must_be_empty out &&
- test_cmp expect actual
- fi
- '
+ test_must_fail git cat-file $arg1 $bogus_long_oid >out 2>actual &&
+ test_must_be_empty out &&
+ test_cmp expect actual
+ '
- test_expect_success "cat-file $arg1 $arg2 error on bogus full OID" '
- if test "$arg2" = "-p"
- then
- cat >expect <<-EOF
- error: header for $bogus_long_oid too long, exceeds 32 bytes
- fatal: Not a valid object name $bogus_long_oid
- EOF
- else
- cat >expect <<-EOF
- error: header for $bogus_long_oid too long, exceeds 32 bytes
- fatal: git cat-file: could not get object info
- EOF
- fi &&
-
- if test "$arg1" = "--allow-unknown-type"
- then
- git cat-file $arg1 $arg2 $bogus_short_oid
- else
- test_must_fail git cat-file $arg1 $arg2 $bogus_long_oid >out 2>actual &&
- test_must_be_empty out &&
- test_cmp expect actual
- fi
- '
+ test_expect_success "cat-file $arg1 error on missing short OID" '
+ cat >expect.err <<-EOF &&
+ fatal: Not a valid object name $(test_oid deadbeef_short)
+ EOF
+ test_must_fail git cat-file $arg1 $(test_oid deadbeef_short) >out 2>err.actual &&
+ test_must_be_empty out &&
+ test_cmp expect.err err.actual
+ '
- test_expect_success "cat-file $arg1 $arg2 error on missing short OID" '
- cat >expect.err <<-EOF &&
- fatal: Not a valid object name $(test_oid deadbeef_short)
+ test_expect_success "cat-file $arg1 error on missing full OID" '
+ if test "$arg1" = "-p"
+ then
+ cat >expect.err <<-EOF
+ fatal: Not a valid object name $(test_oid deadbeef)
EOF
- test_must_fail git cat-file $arg1 $arg2 $(test_oid deadbeef_short) >out 2>err.actual &&
- test_must_be_empty out &&
- test_cmp expect.err err.actual
- '
-
- test_expect_success "cat-file $arg1 $arg2 error on missing full OID" '
- if test "$arg2" = "-p"
- then
- cat >expect.err <<-EOF
- fatal: Not a valid object name $(test_oid deadbeef)
- EOF
- else
- cat >expect.err <<-\EOF
- fatal: git cat-file: could not get object info
- EOF
- fi &&
- test_must_fail git cat-file $arg1 $arg2 $(test_oid deadbeef) >out 2>err.actual &&
- test_must_be_empty out &&
- test_cmp expect.err err.actual
- '
- done
+ else
+ cat >expect.err <<-\EOF
+ fatal: git cat-file: could not get object info
+ EOF
+ fi &&
+ test_must_fail git cat-file $arg1 $(test_oid deadbeef) >out 2>err.actual &&
+ test_must_be_empty out &&
+ test_cmp expect.err err.actual
+ '
done
-test_expect_success '-e is OK with a broken object without --allow-unknown-type' '
+test_expect_success '-e is OK with a broken object' '
git cat-file -e $bogus_short_oid
'
-test_expect_success '-e can not be combined with --allow-unknown-type' '
- test_expect_code 128 git cat-file -e --allow-unknown-type $bogus_short_oid
-'
-
-test_expect_success '-p cannot print a broken object even with --allow-unknown-type' '
- test_must_fail git cat-file -p $bogus_short_oid &&
- test_expect_code 128 git cat-file -p --allow-unknown-type $bogus_short_oid
-'
-
test_expect_success '<type> <hash> does not work with objects of broken types' '
cat >err.expect <<-\EOF &&
fatal: invalid object type "bogus"
@@ -788,60 +749,8 @@ test_expect_success 'broken types combined with --batch and --batch-check' '
test_cmp err.expect err.actual
'
-test_expect_success 'the --batch and --batch-check options do not combine with --allow-unknown-type' '
- test_expect_code 128 git cat-file --batch --allow-unknown-type <bogus-oid &&
- test_expect_code 128 git cat-file --batch-check --allow-unknown-type <bogus-oid
-'
-
-test_expect_success 'the --allow-unknown-type option does not consider replacement refs' '
- cat >expect <<-EOF &&
- $bogus_short_type
- EOF
- git cat-file -t --allow-unknown-type $bogus_short_oid >actual &&
- test_cmp expect actual &&
-
- # Create it manually, as "git replace" will die on bogus
- # types.
- head=$(git rev-parse --verify HEAD) &&
- test_when_finished "test-tool ref-store main delete-refs 0 msg refs/replace/$bogus_short_oid" &&
- test-tool ref-store main update-ref msg "refs/replace/$bogus_short_oid" $head $ZERO_OID REF_SKIP_OID_VERIFICATION &&
-
- cat >expect <<-EOF &&
- commit
- EOF
- git cat-file -t --allow-unknown-type $bogus_short_oid >actual &&
- test_cmp expect actual
-'
-
-test_expect_success "Type of broken object is correct" '
- echo $bogus_short_type >expect &&
- git cat-file -t --allow-unknown-type $bogus_short_oid >actual &&
- test_cmp expect actual
-'
-
-test_expect_success "Size of broken object is correct" '
- echo $bogus_short_size >expect &&
- git cat-file -s --allow-unknown-type $bogus_short_oid >actual &&
- test_cmp expect actual
-'
-
-test_expect_success 'clean up broken object' '
- rm .git/objects/$(test_oid_to_path $bogus_short_oid)
-'
-
-test_expect_success "Type of broken object is correct when type is large" '
- echo $bogus_long_type >expect &&
- git cat-file -t --allow-unknown-type $bogus_long_oid >actual &&
- test_cmp expect actual
-'
-
-test_expect_success "Size of large broken object is correct when type is large" '
- echo $bogus_long_size >expect &&
- git cat-file -s --allow-unknown-type $bogus_long_oid >actual &&
- test_cmp expect actual
-'
-
-test_expect_success 'clean up broken object' '
+test_expect_success 'clean up broken objects' '
+ rm .git/objects/$(test_oid_to_path $bogus_short_oid) &&
rm .git/objects/$(test_oid_to_path $bogus_long_oid)
'
@@ -903,25 +812,6 @@ test_expect_success 'cat-file -t and -s on corrupt loose object' '
)
'
-test_expect_success 'truncated object with --allow-unknown-type' - <<\EOT
- objtype='a really long type name that exceeds the 32-byte limit' &&
- blob=$(git hash-object -w --literally -t "$objtype" /dev/null) &&
- objpath=.git/objects/$(test_oid_to_path "$blob") &&
-
- # We want to truncate the object far enough in that we don't hit the
- # end while inflating the first 32 bytes (since we want to have to dig
- # for the trailing NUL of the header). But we don't want to go too far,
- # since our header isn't very big. And of course we are counting
- # deflated zlib bytes in the on-disk file, so it's a bit of a guess.
- # Empirically 50 seems to work.
- mv "$objpath" obj.bak &&
- test_when_finished 'mv obj.bak "$objpath"' &&
- test_copy_bytes 50 <obj.bak >"$objpath" &&
-
- test_must_fail git cat-file --allow-unknown-type -t $blob 2>err &&
- test_grep "unable to unpack $blob header" err
-EOT
-
test_expect_success 'object reading handles zlib dictionary' - <<\EOT
echo 'content that will be recompressed' >file &&
blob=$(git hash-object -w file) &&
diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
index b3cf53ff8c..dbbe9fb0d4 100755
--- a/t/t1007-hash-object.sh
+++ b/t/t1007-hash-object.sh
@@ -248,15 +248,8 @@ test_expect_success 'hash-object complains about truncated type name' '
test_must_fail git hash-object -t bl --stdin </dev/null
'
-test_expect_success '--literally' '
- t=1234567890 &&
- echo example | git hash-object -t $t --literally --stdin
-'
-
-test_expect_success '--literally with extra-long type' '
- t=12345678901234567890123456789012345678901234567890 &&
- t="$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t" &&
- echo example | git hash-object -t $t --literally --stdin
+test_expect_success '--literally complains about non-standard types' '
+ test_must_fail git hash-object -t bogus --literally --stdin
'
test_expect_success '--stdin outside of repository (uses SHA-1)' '
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
index f9b448792c..d8101139b4 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
@@ -384,6 +384,44 @@ test_expect_success 'add, commit, checkout' '
test_all_match git checkout -
'
+test_expect_success 'git add, checkout, and reset with -p' '
+ init_repos &&
+
+ write_script edit-contents <<-\EOF &&
+ echo text >>$1
+ EOF
+
+ # Does not expand when edits are within sparse checkout.
+ run_on_all ../edit-contents deep/a &&
+ run_on_all ../edit-contents deep/deeper1/a &&
+
+ test_write_lines y n >in &&
+ run_on_all git add -p <in &&
+ test_all_match git status --porcelain=v2 &&
+ test_all_match git reset -p <in &&
+
+ test_write_lines u 1 "" q >in &&
+ run_on_all git add -i <in &&
+ test_all_match git status --porcelain=v2 &&
+ test_all_match git reset --hard &&
+
+ run_on_sparse mkdir -p folder1 &&
+ run_on_all ../edit-contents folder1/a &&
+ test_write_lines y n y >in &&
+ run_on_all git add -p <in &&
+ test_sparse_match git status --porcelain=v2 &&
+ test_sparse_match git reset &&
+ test_write_lines u 2 3 "" q >in &&
+ run_on_all git add -i <in &&
+ test_sparse_match git status --porcelain=v2 &&
+
+ run_on_all git add --sparse folder1 &&
+ run_on_all git commit -m "take changes" &&
+ test_write_lines y n y >in &&
+ test_sparse_match git checkout HEAD~1 --patch <in &&
+ test_sparse_match git status --porcelain=v2
+'
+
test_expect_success 'deep changes during checkout' '
init_repos &&
@@ -1340,6 +1378,30 @@ test_expect_success 'submodule handling' '
grep "160000 $(git -C initial-repo rev-parse HEAD) 0 modules/sub" cache
'
+test_expect_success 'git apply functionality' '
+ init_repos &&
+
+ test_all_match git checkout base &&
+
+ git -C full-checkout diff base..merge-right -- deep >patch-in-sparse &&
+ git -C full-checkout diff base..merge-right -- folder2 >patch-outside &&
+
+ # Apply a patch to a file inside the sparse definition
+ test_all_match git apply --index --stat ../patch-in-sparse &&
+ test_all_match git status --porcelain=v2 &&
+
+ # Apply a patch to a file outside the sparse definition
+ test_sparse_match test_must_fail git apply ../patch-outside &&
+ grep "No such file or directory" sparse-checkout-err &&
+
+ # But it works with --index and --cached
+ test_all_match git apply --index --stat ../patch-outside &&
+ test_all_match git status --porcelain=v2 &&
+ test_all_match git reset --hard &&
+ test_all_match git apply --cached --stat ../patch-outside &&
+ test_all_match git status --porcelain=v2
+'
+
# When working with a sparse index, some commands will need to expand the
# index to operate properly. If those commands also write the index back
# to disk, they need to convert the index to sparse before writing.
@@ -2345,6 +2407,95 @@ test_expect_success 'sparse-index is not expanded: check-attr' '
ensure_not_expanded check-attr -a --cached -- folder1/a
'
+test_expect_success 'sparse-index is not expanded: git apply' '
+ init_repos &&
+
+ git -C sparse-index checkout base &&
+ git -C full-checkout diff base..merge-right -- deep >patch-in-sparse &&
+ git -C full-checkout diff base..merge-right -- folder2 >patch-outside &&
+
+ # Apply a patch to a file inside the sparse definition
+ ensure_not_expanded apply --index --stat ../patch-in-sparse &&
+
+ # Apply a patch to a file outside the sparse definition
+ # Fails when caring about the worktree.
+ ensure_not_expanded ! apply ../patch-outside &&
+
+ # Expands when using --index.
+ ensure_expanded apply --index ../patch-outside &&
+
+ # Does not when index is partially expanded.
+ git -C sparse-index reset --hard &&
+ ensure_not_expanded apply --cached ../patch-outside &&
+
+ # Try again with a reset and collapsed index.
+ git -C sparse-index reset --hard &&
+ git -C sparse-index sparse-checkout reapply &&
+
+ # Expands when index is collapsed.
+ ensure_expanded apply --cached ../patch-outside
+'
+
+test_expect_success 'sparse-index is not expanded: git add -p' '
+ init_repos &&
+
+ # Does not expand when edits are within sparse checkout.
+ echo "new content" >sparse-index/deep/a &&
+ echo "new content" >sparse-index/deep/deeper1/a &&
+ test_write_lines y n >in &&
+ ensure_not_expanded add -p <in &&
+ git -C sparse-index reset &&
+ ensure_not_expanded add -i <in &&
+
+ # -p does expand when edits are outside sparse checkout.
+ mkdir -p sparse-index/folder1 &&
+ echo "new content" >sparse-index/folder1/a &&
+ test_write_lines y n y >in &&
+ ensure_expanded add -p <in &&
+
+ # Fully reset the index.
+ git -C sparse-index reset --hard &&
+ git -C sparse-index sparse-checkout reapply &&
+
+ # -i does expand when edits are outside sparse checkout.
+ mkdir -p sparse-index/folder1 &&
+ echo "new content" >sparse-index/folder1/a &&
+ test_write_lines u 2 3 "" q >in &&
+ ensure_expanded add -i <in
+'
+
+test_expect_success 'sparse-index is not expanded: checkout -p, reset -p' '
+ init_repos &&
+
+ # Does not expand when edits are within sparse checkout.
+ echo "new content" >sparse-index/deep/a &&
+ echo "new content" >sparse-index/deep/deeper1/a &&
+ git -C sparse-index commit -a -m "inside-changes" &&
+
+ test_write_lines y y >in &&
+ ensure_not_expanded checkout HEAD~1 --patch <in &&
+
+ echo "new content" >sparse-index/deep/a &&
+ echo "new content" >sparse-index/deep/deeper1/a &&
+ git -C sparse-index add . &&
+ ensure_not_expanded reset --patch <in &&
+
+ # -p does expand when edits are outside sparse checkout.
+ mkdir -p sparse-index/folder1 &&
+ echo "new content" >sparse-index/folder1/a &&
+ git -C sparse-index add --sparse folder1 &&
+ git -C sparse-index sparse-checkout reapply &&
+ ensure_expanded reset --patch <in &&
+
+ # Fully reset the index.
+ mkdir -p sparse-index/folder1 &&
+ echo "new content" >sparse-index/folder1/a &&
+ git -C sparse-index add --sparse folder1 &&
+ git -C sparse-index commit -m "folder1 change" &&
+ git -C sparse-index sparse-checkout reapply &&
+ ensure_expanded checkout HEAD~1 --patch <in
+'
+
test_expect_success 'advice.sparseIndexExpanded' '
init_repos &&
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 0105045376..5ae86c42be 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -7,6 +7,7 @@ test_description='git fsck random collection of tests
'
. ./test-lib.sh
+. "$TEST_DIRECTORY/lib-loose.sh"
test_expect_success setup '
git config gc.auto 0 &&
@@ -71,30 +72,6 @@ test_expect_success 'object with hash mismatch' '
)
'
-test_expect_success 'object with hash and type mismatch' '
- git init --bare hash-type-mismatch &&
- (
- cd hash-type-mismatch &&
-
- oid=$(echo blob | git hash-object -w --stdin -t garbage --literally) &&
- oldoid=$oid &&
- old=$(test_oid_to_path "$oid") &&
- new=$(dirname $old)/$(test_oid ff_2) &&
- oid="$(dirname $new)$(basename $new)" &&
-
- mv objects/$old objects/$new &&
- git update-index --add --cacheinfo 100644 $oid foo &&
- tree=$(git write-tree) &&
- cmt=$(echo bogus | git commit-tree $tree) &&
- git update-ref refs/heads/bogus $cmt &&
-
-
- test_must_fail git fsck 2>out &&
- grep "^error: $oldoid: hash-path mismatch, found at: .*$new" out &&
- grep "^error: $oldoid: object is of unknown type '"'"'garbage'"'"'" out
- )
-'
-
test_expect_success 'zlib corrupt loose object output ' '
git init --bare corrupt-loose-output &&
(
@@ -997,12 +974,13 @@ test_expect_success 'fsck error and recovery on invalid object type' '
(
cd garbage-type &&
- garbage_blob=$(git hash-object --stdin -w -t garbage --literally </dev/null) &&
+ garbage_blob=$(loose_obj objects garbage </dev/null) &&
test_must_fail git fsck 2>err &&
grep -e "^error" -e "^fatal" err >errors &&
- test_line_count = 1 errors &&
- grep "$garbage_blob: object is of unknown type '"'"'garbage'"'"':" err
+ test_line_count = 2 errors &&
+ test_grep "unable to parse type from header .garbage" err &&
+ test_grep "$garbage_blob: object corrupt or missing:" err
)
'
diff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh
index 70f1e0a998..1a380a4184 100755
--- a/t/t1512-rev-parse-disambiguation.sh
+++ b/t/t1512-rev-parse-disambiguation.sh
@@ -24,6 +24,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
+. "$TEST_DIRECTORY/lib-loose.sh"
test_cmp_failed_rev_parse () {
dir=$1
@@ -67,8 +68,8 @@ test_expect_success 'ambiguous loose bad object parsed as OBJ_BAD' '
cd blob.bad &&
# Both have the prefix "bad0"
- echo xyzfaowcoh | git hash-object -t bad -w --stdin --literally &&
- echo xyzhjpyvwl | git hash-object -t bad -w --stdin --literally
+ echo xyzfaowcoh | loose_obj objects bad &&
+ echo xyzhjpyvwl | loose_obj objects bad
) &&
test_cmp_failed_rev_parse blob.bad bad0 <<-\EOF
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 2aee9789a2..6bac217ed3 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1468,7 +1468,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
cat >expect <<-EOF &&
Warning: some commits may have been dropped accidentally.
Dropped commits (newer to older):
- - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
+ - $(git log --format="%h # %s" -1 primary)
To avoid this message, use "drop" to explicitly remove a commit.
EOF
test_config rebase.missingCommitsCheck warn &&
@@ -1486,8 +1486,8 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
cat >expect <<-EOF &&
Warning: some commits may have been dropped accidentally.
Dropped commits (newer to older):
- - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
- - $(git rev-list --pretty=oneline --abbrev-commit -1 primary~2)
+ - $(git log --format="%h # %s" -1 primary)
+ - $(git log --format="%h # %s" -1 primary~2)
To avoid this message, use "drop" to explicitly remove a commit.
Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings.
@@ -1530,11 +1530,11 @@ test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = ig
test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' '
cat >expect <<-EOF &&
error: invalid command '\''pickled'\''
- error: invalid line 1: pickled $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
+ error: invalid line 1: pickled $(git log --format="%h # %s" -1 primary~4)
Warning: some commits may have been dropped accidentally.
Dropped commits (newer to older):
- - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
- - $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
+ - $(git log --format="%h # %s" -1 primary)
+ - $(git log --format="%h # %s" -1 primary~4)
To avoid this message, use "drop" to explicitly remove a commit.
EOF
head -n5 expect >expect.2 &&
@@ -1565,11 +1565,11 @@ test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = wa
test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = error' '
cat >expect <<-EOF &&
error: invalid command '\''pickled'\''
- error: invalid line 1: pickled $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
+ error: invalid line 1: pickled $(git log --format="%h # %s" -1 primary~4)
Warning: some commits may have been dropped accidentally.
Dropped commits (newer to older):
- - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
- - $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
+ - $(git log --format="%h # %s" -1 primary)
+ - $(git log --format="%h # %s" -1 primary~4)
To avoid this message, use "drop" to explicitly remove a commit.
Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings.
@@ -1642,11 +1642,11 @@ test_expect_success 'respects rebase.abbreviateCommands with fixup, squash and e
test_commit "fixup! first" file2.txt "first line again" first_fixup &&
test_commit "squash! second" file1.txt "another line here" second_squash &&
cat >expected <<-EOF &&
- p $(git rev-list --abbrev-commit -1 first) first
- f $(git rev-list --abbrev-commit -1 first_fixup) fixup! first
+ p $(git rev-list --abbrev-commit -1 first) # first
+ f $(git rev-list --abbrev-commit -1 first_fixup) # fixup! first
x git show HEAD
- p $(git rev-list --abbrev-commit -1 second) second
- s $(git rev-list --abbrev-commit -1 second_squash) squash! second
+ p $(git rev-list --abbrev-commit -1 second) # second
+ s $(git rev-list --abbrev-commit -1 second_squash) # squash! second
x git show HEAD
EOF
git checkout abbrevcmd &&
@@ -1665,7 +1665,7 @@ test_expect_success 'static check of bad command' '
set_fake_editor &&
test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
git rebase -i --root 2>actual &&
- test_grep "pickled $(git rev-list --oneline -1 primary~1)" \
+ test_grep "pickled $(git log --format="%h # %s" -1 primary~1)" \
actual &&
test_grep "You can fix this with .git rebase --edit-todo.." \
actual &&
@@ -1865,15 +1865,15 @@ test_expect_success '--update-refs adds label and update-ref commands' '
set_cat_todo_editor &&
cat >expect <<-EOF &&
- pick $(git log -1 --format=%h J) J
- fixup $(git log -1 --format=%h update-refs) fixup! J # empty
+ pick $(git log -1 --format=%h J) # J
+ fixup $(git log -1 --format=%h update-refs) # fixup! J # empty
update-ref refs/heads/second
update-ref refs/heads/first
- pick $(git log -1 --format=%h K) K
- pick $(git log -1 --format=%h L) L
- fixup $(git log -1 --format=%h is-not-reordered) fixup! L # empty
+ pick $(git log -1 --format=%h K) # K
+ pick $(git log -1 --format=%h L) # L
+ fixup $(git log -1 --format=%h is-not-reordered) # fixup! L # empty
update-ref refs/heads/third
- pick $(git log -1 --format=%h M) M
+ pick $(git log -1 --format=%h M) # M
update-ref refs/heads/no-conflict-branch
update-ref refs/heads/is-not-reordered
update-ref refs/heads/shared-tip
@@ -1905,19 +1905,19 @@ test_expect_success '--update-refs adds commands with --rebase-merges' '
cat >expect <<-EOF &&
label onto
reset onto
- pick $(git log -1 --format=%h branch2~1) F
- pick $(git log -1 --format=%h branch2) I
+ pick $(git log -1 --format=%h branch2~1) # F
+ pick $(git log -1 --format=%h branch2) # I
update-ref refs/heads/branch2
label branch2
reset onto
- pick $(git log -1 --format=%h refs/heads/second) J
+ pick $(git log -1 --format=%h refs/heads/second) # J
update-ref refs/heads/second
update-ref refs/heads/first
- pick $(git log -1 --format=%h refs/heads/third~1) K
- pick $(git log -1 --format=%h refs/heads/third) L
- fixup $(git log -1 --format=%h update-refs-with-merge) fixup! L # empty
+ pick $(git log -1 --format=%h refs/heads/third~1) # K
+ pick $(git log -1 --format=%h refs/heads/third) # L
+ fixup $(git log -1 --format=%h update-refs-with-merge) # fixup! L # empty
update-ref refs/heads/third
- pick $(git log -1 --format=%h HEAD~2) M
+ pick $(git log -1 --format=%h HEAD~2) # M
update-ref refs/heads/no-conflict-branch
merge -C $(git log -1 --format=%h HEAD~1) branch2 # merge
update-ref refs/heads/merge-branch
diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh
index fcc40d6fe1..26b42a526a 100755
--- a/t/t3415-rebase-autosquash.sh
+++ b/t/t3415-rebase-autosquash.sh
@@ -257,8 +257,8 @@ test_expect_success 'auto squash of fixup commit that matches branch name which
GIT_SEQUENCE_EDITOR="cat >tmp" git rebase --autosquash -i HEAD^^ &&
sed -ne "/^[^#]/{s/[0-9a-f]\{7,\}/HASH/g;p;}" tmp >actual &&
cat <<-EOF >expect &&
- pick HASH second commit
- pick HASH fixup! self-cycle # empty
+ pick HASH # second commit
+ pick HASH # fixup! self-cycle # empty
EOF
test_cmp expect actual
'
@@ -311,10 +311,10 @@ test_auto_fixup_fixup () {
parent2=$(git rev-parse --short HEAD^^) &&
parent3=$(git rev-parse --short HEAD^^^) &&
cat >expected <<-EOF &&
- pick $parent3 first commit
- $1 $parent1 $1! first
- $1 $head $1! $2! first
- pick $parent2 second commit
+ pick $parent3 # first commit
+ $1 $parent1 # $1! first
+ $1 $head # $1! $2! first
+ pick $parent2 # second commit
EOF
test_cmp expected actual
) &&
@@ -389,7 +389,7 @@ test_expect_success 'autosquash with empty custom instructionFormat' '
set_cat_todo_editor &&
test_must_fail git -c rebase.instructionFormat= \
rebase --autosquash --force-rebase -i HEAD^ >actual &&
- git log -1 --format="pick %h %s" >expect &&
+ git log -1 --format="pick %h # %s" >expect &&
test_cmp expect actual
)
'
diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh
index ff81adab8c..cc627e34a7 100755
--- a/t/t3430-rebase-merges.sh
+++ b/t/t3430-rebase-merges.sh
@@ -115,18 +115,18 @@ test_expect_success 'generate correct todo list' '
label onto
reset onto
- pick $b B
+ pick $b # B
label first
reset onto
- pick $c C
+ pick $c # C
label branch-point
- pick $f F
- pick $g G
+ pick $f # F
+ pick $g # G
label second
reset branch-point # C
- pick $d D
+ pick $d # D
merge -C $e first # E
merge -C $h second # H
diff --git a/t/t4018/bash-bashism-style-complete-line-capture b/t/t4018/bash-bashism-style-complete-line-capture
new file mode 100644
index 0000000000..070b979fa6
--- /dev/null
+++ b/t/t4018/bash-bashism-style-complete-line-capture
@@ -0,0 +1,4 @@
+function myfunc # RIGHT
+{
+ echo 'ChangeMe'
+}
diff --git a/t/t4018/bash-posix-style-complete-line-capture b/t/t4018/bash-posix-style-complete-line-capture
new file mode 100644
index 0000000000..b56942f322
--- /dev/null
+++ b/t/t4018/bash-posix-style-complete-line-capture
@@ -0,0 +1,4 @@
+func() { # RIGHT
+
+ ChangeMe
+}
diff --git a/t/t4018/bash-posix-style-single-command-function b/t/t4018/bash-posix-style-single-command-function
new file mode 100644
index 0000000000..398ae1c5d2
--- /dev/null
+++ b/t/t4018/bash-posix-style-single-command-function
@@ -0,0 +1,3 @@
+RIGHT() echo "hello"
+
+ ChangeMe
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index f51d3557f1..0be647c2fb 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -320,6 +320,7 @@ test_expect_success 'unset default driver' '
test_language_driver ada
test_language_driver bibtex
+test_language_driver bash
test_language_driver cpp
test_language_driver csharp
test_language_driver css
diff --git a/t/t4034/bash/expect b/t/t4034/bash/expect
new file mode 100644
index 0000000000..1864ab25dc
--- /dev/null
+++ b/t/t4034/bash/expect
@@ -0,0 +1,36 @@
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 09ac008..60ba6a2 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
+<CYAN>@@ -1,31 +1,31 @@<RESET>
+<RED>my_var<RESET><GREEN>new_var<RESET>=10
+x=<RED>123<RESET><GREEN>456<RESET>
+echo <RED>$1<RESET><GREEN>$2<RESET>
+echo <RED>$USER<RESET><GREEN>$USERNAME<RESET>
+${<RED>HOME<RESET><GREEN>HOMEDIR<RESET>}
+((a<RED>+<RESET><GREEN>+=<RESET>b))
+((a<RED>*<RESET><GREEN>*=<RESET>b))
+((a<RED>/<RESET><GREEN>/=<RESET>b))
+((a<RED>%<RESET><GREEN>%=<RESET>b))
+((a<RED>|<RESET><GREEN>|=<RESET>b))
+((a<RED>^<RESET><GREEN>^=<RESET>b))
+((a<RED>=<RESET><GREEN>==<RESET>b))
+((a<RED>!<RESET><GREEN>!=<RESET>b))
+((a<RED><<RESET><GREEN><=<RESET>b))
+((a<RED>><RESET><GREEN>>=<RESET>b))
+$((a<RED><<RESET><GREEN><<<RESET>b))
+$((a<RED>><RESET><GREEN>>><RESET>b))
+$((a<RED>&<RESET><GREEN>&&<RESET>b))
+$((a<RED>|<RESET><GREEN>||<RESET>b))
+${a<RED>:<RESET><GREEN>:-<RESET>b}
+${a<RED>:<RESET><GREEN>:=<RESET>b}
+${a<RED>:<RESET><GREEN>:+<RESET>b}
+${a<RED>:<RESET><GREEN>:?<RESET>b}
+${a<RED>#<RESET><GREEN>##<RESET>*/}
+${a<RED>%<RESET><GREEN>%%<RESET>.*}
+${a<RED>^<RESET><GREEN>^^<RESET>}
+${a<RED>,<RESET><GREEN>,,<RESET>}
+${<GREEN>!<RESET>a}
+${a[<RED>*<RESET><GREEN>@<RESET>]}
+ls <RED>-a<RESET><GREEN>-x<RESET>
+ls <RED>--all<RESET><GREEN>--color<RESET>
diff --git a/t/t4034/bash/post b/t/t4034/bash/post
new file mode 100644
index 0000000000..2bbee8936d
--- /dev/null
+++ b/t/t4034/bash/post
@@ -0,0 +1,31 @@
+new_var=10
+x=456
+echo $2
+echo $USERNAME
+${HOMEDIR}
+((a+=b))
+((a*=b))
+((a/=b))
+((a%=b))
+((a|=b))
+((a^=b))
+((a==b))
+((a!=b))
+((a<=b))
+((a>=b))
+$((a<<b))
+$((a>>b))
+$((a&&b))
+$((a||b))
+${a:-b}
+${a:=b}
+${a:+b}
+${a:?b}
+${a##*/}
+${a%%.*}
+${a^^}
+${a,,}
+${!a}
+${a[@]}
+ls -x
+ls --color
diff --git a/t/t4034/bash/pre b/t/t4034/bash/pre
new file mode 100644
index 0000000000..8d22039c40
--- /dev/null
+++ b/t/t4034/bash/pre
@@ -0,0 +1,31 @@
+my_var=10
+x=123
+echo $1
+echo $USER
+${HOME}
+((a+b))
+((a*b))
+((a/b))
+((a%b))
+((a|b))
+((a^b))
+((a=b))
+((a!b))
+((a<b))
+((a>b))
+$((a<b))
+$((a>b))
+$((a&b))
+$((a|b))
+${a:b}
+${a:b}
+${a:b}
+${a:b}
+${a#*/}
+${a%.*}
+${a^}
+${a,}
+${a}
+${a[*]}
+ls -a
+ls --all
diff --git a/t/t4129-apply-samemode.sh b/t/t4129-apply-samemode.sh
index 2149ad5da4..1d6317bd71 100755
--- a/t/t4129-apply-samemode.sh
+++ b/t/t4129-apply-samemode.sh
@@ -102,15 +102,32 @@ test_expect_success POSIXPERM 'do not use core.sharedRepository for working tree
)
'
+test_file_mode_common () {
+ if test "$1" = "000000"
+ then
+ test_must_be_empty "$2"
+ else
+ test_grep "^$1 " "$2"
+ fi
+}
+
+test_file_mode_staged () {
+ git ls-files --stage -- "$2" >ls-files-output &&
+ test_file_mode_common "$1" ls-files-output
+}
+
+test_file_mode_HEAD () {
+ git ls-tree HEAD -- "$2" >ls-tree-output &&
+ test_file_mode_common "$1" ls-tree-output
+}
+
test_expect_success 'git apply respects core.fileMode' '
test_config core.fileMode false &&
echo true >script.sh &&
git add --chmod=+x script.sh &&
- git ls-files -s script.sh >ls-files-output &&
- test_grep "^100755" ls-files-output &&
+ test_file_mode_staged 100755 script.sh &&
test_tick && git commit -m "Add script" &&
- git ls-tree -r HEAD script.sh >ls-tree-output &&
- test_grep "^100755" ls-tree-output &&
+ test_file_mode_HEAD 100755 script.sh &&
echo true >>script.sh &&
test_tick && git commit -m "Modify script" script.sh &&
@@ -126,7 +143,211 @@ test_expect_success 'git apply respects core.fileMode' '
test_grep ! "has type 100644, expected 100755" err &&
git apply --cached patch 2>err &&
- test_grep ! "has type 100644, expected 100755" err
+ test_grep ! "has type 100644, expected 100755" err &&
+ git reset --hard
+'
+
+test_expect_success 'setup: git apply [--reverse] warns about incorrect file modes' '
+ test_config core.fileMode false &&
+
+ >mode_test &&
+ git add --chmod=-x mode_test &&
+ test_file_mode_staged 100644 mode_test &&
+ test_tick && git commit -m "add mode_test" &&
+ test_file_mode_HEAD 100644 mode_test &&
+ git tag mode_test_forward_initial &&
+
+ echo content >>mode_test &&
+ test_tick && git commit -m "append to mode_test" mode_test &&
+ test_file_mode_HEAD 100644 mode_test &&
+ git tag mode_test_reverse_initial &&
+
+ git format-patch -1 --stdout >patch &&
+ test_grep "^index .* 100644$" patch
+'
+
+test_expect_success 'git apply warns about incorrect file modes' '
+ test_config core.fileMode false &&
+ git reset --hard mode_test_forward_initial &&
+
+ git add --chmod=+x mode_test &&
+ test_file_mode_staged 100755 mode_test &&
+ test_tick && git commit -m "make mode_test executable" &&
+ test_file_mode_HEAD 100755 mode_test &&
+
+ git apply --index patch 2>err &&
+ test_grep "has type 100755, expected 100644" err &&
+ test_file_mode_staged 100755 mode_test &&
+ test_tick && git commit -m "redo: append to mode_test" &&
+ test_file_mode_HEAD 100755 mode_test
+'
+
+test_expect_success 'git apply --reverse warns about incorrect file modes' '
+ test_config core.fileMode false &&
+ git reset --hard mode_test_reverse_initial &&
+
+ git add --chmod=+x mode_test &&
+ test_file_mode_staged 100755 mode_test &&
+ test_tick && git commit -m "make mode_test executable" &&
+ test_file_mode_HEAD 100755 mode_test &&
+
+ git apply --index --reverse patch 2>err &&
+ test_grep "has type 100755, expected 100644" err &&
+ test_file_mode_staged 100755 mode_test &&
+ test_tick && git commit -m "undo: append to mode_test" &&
+ test_file_mode_HEAD 100755 mode_test
+'
+
+test_expect_success 'setup: git apply [--reverse] restores file modes (change_x_to_notx)' '
+ test_config core.fileMode false &&
+
+ touch change_x_to_notx &&
+ git add --chmod=+x change_x_to_notx &&
+ test_file_mode_staged 100755 change_x_to_notx &&
+ test_tick && git commit -m "add change_x_to_notx as executable" &&
+ test_file_mode_HEAD 100755 change_x_to_notx &&
+
+ git add --chmod=-x change_x_to_notx &&
+ test_file_mode_staged 100644 change_x_to_notx &&
+ test_tick && git commit -m "make change_x_to_notx not executable" &&
+ test_file_mode_HEAD 100644 change_x_to_notx &&
+
+ git rm change_x_to_notx &&
+ test_file_mode_staged 000000 change_x_to_notx &&
+ test_tick && git commit -m "remove change_x_to_notx" &&
+ test_file_mode_HEAD 000000 change_x_to_notx &&
+
+ git format-patch -o patches -3 &&
+ mv patches/0001-* change_x_to_notx-0001-create-0755.patch &&
+ mv patches/0002-* change_x_to_notx-0002-chmod-0644.patch &&
+ mv patches/0003-* change_x_to_notx-0003-delete.patch &&
+
+ test_grep "^new file mode 100755$" change_x_to_notx-0001-create-0755.patch &&
+ test_grep "^old mode 100755$" change_x_to_notx-0002-chmod-0644.patch &&
+ test_grep "^new mode 100644$" change_x_to_notx-0002-chmod-0644.patch &&
+ test_grep "^deleted file mode 100644$" change_x_to_notx-0003-delete.patch &&
+
+ git tag change_x_to_notx_initial
+'
+
+test_expect_success 'git apply restores file modes (change_x_to_notx)' '
+ test_config core.fileMode false &&
+ git reset --hard change_x_to_notx_initial &&
+
+ git apply --index change_x_to_notx-0001-create-0755.patch &&
+ test_file_mode_staged 100755 change_x_to_notx &&
+ test_tick && git commit -m "redo: add change_x_to_notx as executable" &&
+ test_file_mode_HEAD 100755 change_x_to_notx &&
+
+ git apply --index change_x_to_notx-0002-chmod-0644.patch 2>err &&
+ test_grep ! "has type 100.*, expected 100.*" err &&
+ test_file_mode_staged 100644 change_x_to_notx &&
+ test_tick && git commit -m "redo: make change_x_to_notx not executable" &&
+ test_file_mode_HEAD 100644 change_x_to_notx &&
+
+ git apply --index change_x_to_notx-0003-delete.patch 2>err &&
+ test_grep ! "has type 100.*, expected 100.*" err &&
+ test_file_mode_staged 000000 change_x_to_notx &&
+ test_tick && git commit -m "redo: remove change_notx_to_x" &&
+ test_file_mode_HEAD 000000 change_x_to_notx
+'
+
+test_expect_success 'git apply --reverse restores file modes (change_x_to_notx)' '
+ test_config core.fileMode false &&
+ git reset --hard change_x_to_notx_initial &&
+
+ git apply --index --reverse change_x_to_notx-0003-delete.patch &&
+ test_file_mode_staged 100644 change_x_to_notx &&
+ test_tick && git commit -m "undo: remove change_x_to_notx" &&
+ test_file_mode_HEAD 100644 change_x_to_notx &&
+
+ git apply --index --reverse change_x_to_notx-0002-chmod-0644.patch 2>err &&
+ test_grep ! "has type 100.*, expected 100.*" err &&
+ test_file_mode_staged 100755 change_x_to_notx &&
+ test_tick && git commit -m "undo: make change_x_to_notx not executable" &&
+ test_file_mode_HEAD 100755 change_x_to_notx &&
+
+ git apply --index --reverse change_x_to_notx-0001-create-0755.patch 2>err &&
+ test_grep ! "has type 100.*, expected 100.*" err &&
+ test_file_mode_staged 000000 change_x_to_notx &&
+ test_tick && git commit -m "undo: add change_x_to_notx as executable" &&
+ test_file_mode_HEAD 000000 change_x_to_notx
+'
+
+test_expect_success 'setup: git apply [--reverse] restores file modes (change_notx_to_x)' '
+ test_config core.fileMode false &&
+
+ touch change_notx_to_x &&
+ git add --chmod=-x change_notx_to_x &&
+ test_file_mode_staged 100644 change_notx_to_x &&
+ test_tick && git commit -m "add change_notx_to_x as not executable" &&
+ test_file_mode_HEAD 100644 change_notx_to_x &&
+
+ git add --chmod=+x change_notx_to_x &&
+ test_file_mode_staged 100755 change_notx_to_x &&
+ test_tick && git commit -m "make change_notx_to_x executable" &&
+ test_file_mode_HEAD 100755 change_notx_to_x &&
+
+ git rm change_notx_to_x &&
+ test_file_mode_staged 000000 change_notx_to_x &&
+ test_tick && git commit -m "remove change_notx_to_x" &&
+ test_file_mode_HEAD 000000 change_notx_to_x &&
+
+ git format-patch -o patches -3 &&
+ mv patches/0001-* change_notx_to_x-0001-create-0644.patch &&
+ mv patches/0002-* change_notx_to_x-0002-chmod-0755.patch &&
+ mv patches/0003-* change_notx_to_x-0003-delete.patch &&
+
+ test_grep "^new file mode 100644$" change_notx_to_x-0001-create-0644.patch &&
+ test_grep "^old mode 100644$" change_notx_to_x-0002-chmod-0755.patch &&
+ test_grep "^new mode 100755$" change_notx_to_x-0002-chmod-0755.patch &&
+ test_grep "^deleted file mode 100755$" change_notx_to_x-0003-delete.patch &&
+
+ git tag change_notx_to_x_initial
+'
+
+test_expect_success 'git apply restores file modes (change_notx_to_x)' '
+ test_config core.fileMode false &&
+ git reset --hard change_notx_to_x_initial &&
+
+ git apply --index change_notx_to_x-0001-create-0644.patch &&
+ test_file_mode_staged 100644 change_notx_to_x &&
+ test_tick && git commit -m "redo: add change_notx_to_x as not executable" &&
+ test_file_mode_HEAD 100644 change_notx_to_x &&
+
+ git apply --index change_notx_to_x-0002-chmod-0755.patch 2>err &&
+ test_grep ! "has type 100.*, expected 100.*" err &&
+ test_file_mode_staged 100755 change_notx_to_x &&
+ test_tick && git commit -m "redo: make change_notx_to_x executable" &&
+ test_file_mode_HEAD 100755 change_notx_to_x &&
+
+ git apply --index change_notx_to_x-0003-delete.patch &&
+ test_grep ! "has type 100.*, expected 100.*" err &&
+ test_file_mode_staged 000000 change_notx_to_x &&
+ test_tick && git commit -m "undo: remove change_notx_to_x" &&
+ test_file_mode_HEAD 000000 change_notx_to_x
+'
+
+test_expect_success 'git apply --reverse restores file modes (change_notx_to_x)' '
+ test_config core.fileMode false &&
+ git reset --hard change_notx_to_x_initial &&
+
+ git apply --index --reverse change_notx_to_x-0003-delete.patch &&
+ test_file_mode_staged 100755 change_notx_to_x &&
+ test_tick && git commit -m "undo: remove change_notx_to_x" &&
+ test_file_mode_HEAD 100755 change_notx_to_x &&
+
+ git apply --index --reverse change_notx_to_x-0002-chmod-0755.patch 2>err &&
+ test_grep ! "has type 100.*, expected 100.*" err &&
+ test_file_mode_staged 100644 change_notx_to_x &&
+ test_tick && git commit -m "undo: make change_notx_to_x executable" &&
+ test_file_mode_HEAD 100644 change_notx_to_x &&
+
+ git apply --index --reverse change_notx_to_x-0001-create-0644.patch 2>err &&
+ test_grep ! "has type 100.*, expected 100.*" err &&
+ test_file_mode_staged 000000 change_notx_to_x &&
+ test_tick && git commit -m "undo: add change_notx_to_x as not executable" &&
+ test_file_mode_HEAD 000000 change_notx_to_x
'
test_expect_success POSIXPERM 'patch mode for new file is canonicalized' '
diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh
index f9c5883a7f..6e117ee93c 100755
--- a/t/t4301-merge-tree-write-tree.sh
+++ b/t/t4301-merge-tree-write-tree.sh
@@ -54,6 +54,25 @@ test_expect_success setup '
git commit -m first-commit
'
+test_expect_success '--quiet on clean merge' '
+ # Get rid of loose objects to start with
+ git gc &&
+ echo "0 objects, 0 kilobytes" >expect &&
+ git count-objects >actual &&
+ test_cmp expect actual &&
+
+ # Ensure merge is successful (exit code of 0)
+ git merge-tree --write-tree --quiet side1 side3 >output &&
+
+ # Ensure there is no output
+ test_must_be_empty output &&
+
+ # Ensure no loose objects written (all new objects written would have
+ # been in "outer layer" of the merge)
+ git count-objects >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'Clean merge' '
TREE_OID=$(git merge-tree --write-tree side1 side3) &&
q_to_tab <<-EOF >expect &&
@@ -72,6 +91,25 @@ test_expect_success 'Failed merge without rename detection' '
grep "CONFLICT (modify/delete): numbers deleted" out
'
+test_expect_success '--quiet on conflicted merge' '
+ # Get rid of loose objects to start with
+ git gc &&
+ echo "0 objects, 0 kilobytes" >expect &&
+ git count-objects >actual &&
+ test_cmp expect actual &&
+
+ # Ensure merge has conflict
+ test_expect_code 1 git merge-tree --write-tree --quiet side1 side2 >output &&
+
+ # Ensure there is no output
+ test_must_be_empty output &&
+
+ # Ensure no loose objects written (all new objects written would have
+ # been in "outer layer" of the merge)
+ git count-objects >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'Content merge and a few conflicts' '
git checkout side1^0 &&
test_must_fail git merge side2 &&
diff --git a/t/t5410-receive-pack-alternates.sh b/t/t5410-receive-pack-alternates.sh
deleted file mode 100755
index 4e82fd102e..0000000000
--- a/t/t5410-receive-pack-alternates.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-
-test_description='git receive-pack with alternate ref filtering'
-
-GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
-export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
-
-. ./test-lib.sh
-
-test_expect_success 'setup' '
- test_commit base &&
- git clone -s --bare . fork &&
- git checkout -b public/branch main &&
- test_commit public &&
- git checkout -b private/branch main &&
- test_commit private
-'
-
-extract_haves () {
- depacketize | sed -n 's/^\([^ ][^ ]*\) \.have/\1/p'
-}
-
-test_expect_success 'with core.alternateRefsCommand' '
- write_script fork/alternate-refs <<-\EOF &&
- git --git-dir="$1" for-each-ref \
- --format="%(objectname)" \
- refs/heads/public/
- EOF
- test_config -C fork core.alternateRefsCommand ./alternate-refs &&
- git rev-parse public/branch >expect &&
- printf "0000" | git receive-pack fork >actual &&
- extract_haves <actual >actual.haves &&
- test_cmp expect actual.haves
-'
-
-test_expect_success 'with core.alternateRefsPrefixes' '
- test_config -C fork core.alternateRefsPrefixes "refs/heads/private" &&
- git rev-parse private/branch >expect &&
- printf "0000" | git receive-pack fork >actual &&
- extract_haves <actual >actual.haves &&
- test_cmp expect actual.haves
-'
-
-test_done
diff --git a/t/t5410-receive-pack.sh b/t/t5410-receive-pack.sh
new file mode 100755
index 0000000000..f76a22943e
--- /dev/null
+++ b/t/t5410-receive-pack.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+test_description='git receive-pack'
+
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ test_commit base &&
+ git clone -s --bare . fork &&
+ git checkout -b public/branch main &&
+ test_commit public &&
+ git checkout -b private/branch main &&
+ test_commit private
+'
+
+extract_haves () {
+ depacketize | sed -n 's/^\([^ ][^ ]*\) \.have/\1/p'
+}
+
+test_expect_success 'with core.alternateRefsCommand' '
+ write_script fork/alternate-refs <<-\EOF &&
+ git --git-dir="$1" for-each-ref \
+ --format="%(objectname)" \
+ refs/heads/public/
+ EOF
+ test_config -C fork core.alternateRefsCommand ./alternate-refs &&
+ git rev-parse public/branch >expect &&
+ printf "0000" | git receive-pack fork >actual &&
+ extract_haves <actual >actual.haves &&
+ test_cmp expect actual.haves
+'
+
+test_expect_success 'with core.alternateRefsPrefixes' '
+ test_config -C fork core.alternateRefsPrefixes "refs/heads/private" &&
+ git rev-parse private/branch >expect &&
+ printf "0000" | git receive-pack fork >actual &&
+ extract_haves <actual >actual.haves &&
+ test_cmp expect actual.haves
+'
+
+test_expect_success 'receive-pack missing objects fails connectivity check' '
+ test_when_finished rm -rf repo remote.git setup.git &&
+
+ git init repo &&
+ git -C repo commit --allow-empty -m 1 &&
+ git clone --bare repo setup.git &&
+ git -C repo commit --allow-empty -m 2 &&
+
+ # Capture git-send-pack(1) output sent to git-receive-pack(1).
+ git -C repo send-pack ../setup.git --all \
+ --receive-pack="tee ${SQ}$(pwd)/out${SQ} | git-receive-pack" &&
+
+ # Replay captured git-send-pack(1) output on new empty repository.
+ git init --bare remote.git &&
+ git receive-pack remote.git <out >actual 2>err &&
+
+ test_grep "missing necessary objects" actual &&
+ test_grep "fatal: Failed to traverse parents" err &&
+ test_must_fail git -C remote.git cat-file -e $(git -C repo rev-parse HEAD)
+'
+
+test_expect_success 'receive-pack missing objects bypasses connectivity check' '
+ test_when_finished rm -rf repo remote.git setup.git &&
+
+ git init repo &&
+ git -C repo commit --allow-empty -m 1 &&
+ git clone --bare repo setup.git &&
+ git -C repo commit --allow-empty -m 2 &&
+
+ # Capture git-send-pack(1) output sent to git-receive-pack(1).
+ git -C repo send-pack ../setup.git --all \
+ --receive-pack="tee ${SQ}$(pwd)/out${SQ} | git-receive-pack" &&
+
+ # Replay captured git-send-pack(1) output on new empty repository.
+ git init --bare remote.git &&
+ git receive-pack --skip-connectivity-check remote.git <out >actual 2>err &&
+
+ test_grep ! "missing necessary objects" actual &&
+ test_must_be_empty err &&
+ git -C remote.git cat-file -e $(git -C repo rev-parse HEAD) &&
+ test_must_fail git -C remote.git rev-list $(git -C repo rev-parse HEAD)
+'
+
+test_done
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 47534f1062..63c9a8f04b 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -813,7 +813,7 @@ test_expect_success 'git pull --rebase does not reapply old patches' '
cd dst &&
test_must_fail git pull --rebase &&
cat .git/rebase-merge/done .git/rebase-merge/git-rebase-todo >work &&
- grep -v -e \# -e ^$ work >patches &&
+ grep -v -e ^\# -e ^$ work >patches &&
test_line_count = 1 patches &&
rm -f work
)
diff --git a/t/t6601-path-walk.sh b/t/t6601-path-walk.sh
index c89b0f1e19..8d187f7279 100755
--- a/t/t6601-path-walk.sh
+++ b/t/t6601-path-walk.sh
@@ -1,7 +1,5 @@
#!/bin/sh
-TEST_PASSES_SANITIZE_LEAK=true
-
test_description='direct path-walk API tests'
. ./test-lib.sh
diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 802f8f704c..25e8e9711f 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -139,7 +139,7 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last command done (1 command done):
- pick $LAST_COMMIT one_second
+ pick $LAST_COMMIT # one_second
No commands remaining.
You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
(fix conflicts and then run "git rebase --continue")
@@ -168,7 +168,7 @@ test_expect_success 'status during rebase -i after resolving conflicts' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last command done (1 command done):
- pick $LAST_COMMIT one_second
+ pick $LAST_COMMIT # one_second
No commands remaining.
You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
(all conflicts fixed: run "git rebase --continue")
@@ -200,8 +200,8 @@ test_expect_success 'status when rebasing -i in edit mode' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (2 commands done):
- pick $COMMIT2 two_rebase_i
- edit $COMMIT3 three_rebase_i
+ pick $COMMIT2 # two_rebase_i
+ edit $COMMIT3 # three_rebase_i
No commands remaining.
You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
@@ -233,10 +233,10 @@ test_expect_success 'status when splitting a commit' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (2 commands done):
- pick $COMMIT2 two_split
- edit $COMMIT3 three_split
+ pick $COMMIT2 # two_split
+ edit $COMMIT3 # three_split
Next command to do (1 remaining command):
- pick $COMMIT4 four_split
+ pick $COMMIT4 # four_split
(use "git rebase --edit-todo" to view and edit)
You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
(Once your working directory is clean, run "git rebase --continue")
@@ -271,8 +271,8 @@ test_expect_success 'status after editing the last commit with --amend during a
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (3 commands done):
- pick $COMMIT3 three_amend
- edit $COMMIT4 four_amend
+ pick $COMMIT3 # three_amend
+ edit $COMMIT4 # four_amend
(see more in file .git/rebase-merge/done)
No commands remaining.
You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
@@ -309,10 +309,10 @@ test_expect_success 'status: (continue first edit) second edit' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (2 commands done):
- edit $COMMIT2 two_edits
- edit $COMMIT3 three_edits
+ edit $COMMIT2 # two_edits
+ edit $COMMIT3 # three_edits
Next command to do (1 remaining command):
- pick $COMMIT4 four_edits
+ pick $COMMIT4 # four_edits
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
@@ -340,10 +340,10 @@ test_expect_success 'status: (continue first edit) second edit and split' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (2 commands done):
- edit $COMMIT2 two_edits
- edit $COMMIT3 three_edits
+ edit $COMMIT2 # two_edits
+ edit $COMMIT3 # three_edits
Next command to do (1 remaining command):
- pick $COMMIT4 four_edits
+ pick $COMMIT4 # four_edits
(use "git rebase --edit-todo" to view and edit)
You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(Once your working directory is clean, run "git rebase --continue")
@@ -375,10 +375,10 @@ test_expect_success 'status: (continue first edit) second edit and amend' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (2 commands done):
- edit $COMMIT2 two_edits
- edit $COMMIT3 three_edits
+ edit $COMMIT2 # two_edits
+ edit $COMMIT3 # three_edits
Next command to do (1 remaining command):
- pick $COMMIT4 four_edits
+ pick $COMMIT4 # four_edits
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
@@ -406,10 +406,10 @@ test_expect_success 'status: (amend first edit) second edit' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (2 commands done):
- edit $COMMIT2 two_edits
- edit $COMMIT3 three_edits
+ edit $COMMIT2 # two_edits
+ edit $COMMIT3 # three_edits
Next command to do (1 remaining command):
- pick $COMMIT4 four_edits
+ pick $COMMIT4 # four_edits
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
@@ -438,10 +438,10 @@ test_expect_success 'status: (amend first edit) second edit and split' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (2 commands done):
- edit $COMMIT2 two_edits
- edit $COMMIT3 three_edits
+ edit $COMMIT2 # two_edits
+ edit $COMMIT3 # three_edits
Next command to do (1 remaining command):
- pick $COMMIT4 four_edits
+ pick $COMMIT4 # four_edits
(use "git rebase --edit-todo" to view and edit)
You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(Once your working directory is clean, run "git rebase --continue")
@@ -474,10 +474,10 @@ test_expect_success 'status: (amend first edit) second edit and amend' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (2 commands done):
- edit $COMMIT2 two_edits
- edit $COMMIT3 three_edits
+ edit $COMMIT2 # two_edits
+ edit $COMMIT3 # three_edits
Next command to do (1 remaining command):
- pick $COMMIT4 four_edits
+ pick $COMMIT4 # four_edits
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
@@ -507,10 +507,10 @@ test_expect_success 'status: (split first edit) second edit' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (2 commands done):
- edit $COMMIT2 two_edits
- edit $COMMIT3 three_edits
+ edit $COMMIT2 # two_edits
+ edit $COMMIT3 # three_edits
Next command to do (1 remaining command):
- pick $COMMIT4 four_edits
+ pick $COMMIT4 # four_edits
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
@@ -541,10 +541,10 @@ test_expect_success 'status: (split first edit) second edit and split' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (2 commands done):
- edit $COMMIT2 two_edits
- edit $COMMIT3 three_edits
+ edit $COMMIT2 # two_edits
+ edit $COMMIT3 # three_edits
Next command to do (1 remaining command):
- pick $COMMIT4 four_edits
+ pick $COMMIT4 # four_edits
(use "git rebase --edit-todo" to view and edit)
You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(Once your working directory is clean, run "git rebase --continue")
@@ -579,10 +579,10 @@ test_expect_success 'status: (split first edit) second edit and amend' '
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (2 commands done):
- edit $COMMIT2 two_edits
- edit $COMMIT3 three_edits
+ edit $COMMIT2 # two_edits
+ edit $COMMIT3 # three_edits
Next command to do (1 remaining command):
- pick $COMMIT4 four_edits
+ pick $COMMIT4 # four_edits
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
@@ -997,11 +997,11 @@ test_expect_success 'status: two commands done with some white lines in done fil
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (2 commands done):
- pick $COMMIT2 two_commit
+ pick $COMMIT2 # two_commit
exec exit 15
Next commands to do (2 remaining commands):
- pick $COMMIT3 three_commit
- pick $COMMIT4 four_commit
+ pick $COMMIT3 # three_commit
+ pick $COMMIT4 # four_commit
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
@@ -1025,12 +1025,12 @@ test_expect_success 'status: two remaining commands with some white lines in tod
cat >expected <<EOF &&
interactive rebase in progress; onto $ONTO
Last commands done (3 commands done):
- pick $COMMIT2 two_commit
+ pick $COMMIT2 # two_commit
exec exit 15
(see more in file .git/rebase-merge/done)
Next commands to do (2 remaining commands):
- pick $COMMIT3 three_commit
- pick $COMMIT4 four_commit
+ pick $COMMIT3 # three_commit
+ pick $COMMIT4 # four_commit
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
@@ -1050,7 +1050,7 @@ test_expect_success 'status: handle not-yet-started rebase -i gracefully' '
On branch several_commits
No commands done.
Next command to do (1 remaining command):
- pick $COMMIT four_commit
+ pick $COMMIT # four_commit
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
diff --git a/t/t9210-scalar.sh b/t/t9210-scalar.sh
index a81662713e..bd6f0c40d2 100755
--- a/t/t9210-scalar.sh
+++ b/t/t9210-scalar.sh
@@ -108,7 +108,7 @@ test_expect_success 'scalar register warns when background maintenance fails' '
git init register-repo &&
GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
scalar register register-repo 2>err &&
- grep "could not turn on maintenance" err
+ grep "could not toggle maintenance" err
'
test_expect_success 'scalar unregister' '
@@ -129,6 +129,17 @@ test_expect_success 'scalar unregister' '
scalar unregister vanish
'
+test_expect_success 'scalar register --no-maintenance' '
+ git init register-no-maint &&
+ event_log="$(pwd)/no-maint.event" &&
+ GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
+ GIT_TRACE2_EVENT="$event_log" \
+ GIT_TRACE2_EVENT_DEPTH=100 \
+ scalar register --no-maintenance register-no-maint 2>err &&
+ test_must_be_empty err &&
+ test_subcommand ! git maintenance unregister --force <no-maint.event
+'
+
test_expect_success 'set up repository to clone' '
test_commit first &&
test_commit second &&
@@ -199,7 +210,18 @@ test_expect_success 'scalar reconfigure' '
GIT_TRACE2_EVENT="$(pwd)/reconfigure" scalar reconfigure -a &&
test_path_is_file one/src/cron.txt &&
test true = "$(git -C one/src config core.preloadIndex)" &&
- test_subcommand git maintenance start <reconfigure
+ test_subcommand git maintenance start <reconfigure &&
+ test_subcommand ! git maintenance unregister --force <reconfigure &&
+
+ GIT_TRACE2_EVENT="$(pwd)/reconfigure-maint-disable" \
+ scalar reconfigure -a --maintenance=disable &&
+ test_subcommand ! git maintenance start <reconfigure-maint-disable &&
+ test_subcommand git maintenance unregister --force <reconfigure-maint-disable &&
+
+ GIT_TRACE2_EVENT="$(pwd)/reconfigure-maint-keep" \
+ scalar reconfigure --maintenance=keep -a &&
+ test_subcommand ! git maintenance start <reconfigure-maint-keep &&
+ test_subcommand ! git maintenance unregister --force <reconfigure-maint-keep
'
test_expect_success 'scalar reconfigure --all with includeIf.onbranch' '
diff --git a/t/t9211-scalar-clone.sh b/t/t9211-scalar-clone.sh
index 01f71910f5..bfbf22a462 100755
--- a/t/t9211-scalar-clone.sh
+++ b/t/t9211-scalar-clone.sh
@@ -177,7 +177,16 @@ test_expect_success 'progress without tty' '
test_expect_success 'scalar clone warns when background maintenance fails' '
GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
scalar clone "file://$(pwd)/to-clone" maint-fail 2>err &&
- grep "could not turn on maintenance" err
+ grep "could not toggle maintenance" err
+'
+
+test_expect_success 'scalar clone --no-maintenance' '
+ GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
+ GIT_TRACE2_EVENT="$(pwd)/no-maint.event" \
+ GIT_TRACE2_EVENT_DEPTH=100 \
+ scalar clone --no-maintenance "file://$(pwd)/to-clone" no-maint 2>err &&
+ ! grep "could not toggle maintenance" err &&
+ test_subcommand ! git maintenance unregister --force <no-maint.event
'
test_expect_success '`scalar clone --no-src`' '
diff --git a/trace2/tr2_tmr.c b/trace2/tr2_tmr.c
index 51f564b07a..038181ad9b 100644
--- a/trace2/tr2_tmr.c
+++ b/trace2/tr2_tmr.c
@@ -102,25 +102,11 @@ void tr2_update_final_timers(void)
struct tr2_timer *t_final = &final_timer_block.timer[tid];
struct tr2_timer *t = &ctx->timer_block.timer[tid];
- if (t->recursion_count) {
- /*
- * The current thread is exiting with
- * timer[tid] still running.
- *
- * Technically, this is a bug, but I'm going
- * to ignore it.
- *
- * I don't think it is worth calling die()
- * for. I don't think it is worth killing the
- * process for this bookkeeping error. We
- * might want to call warning(), but I'm going
- * to wait on that.
- *
- * The downside here is that total_ns won't
- * include the current open interval (now -
- * start_ns). I can live with that.
- */
- }
+ /*
+ * `t->recursion_count` could technically be non-zero, which
+ * would constitute a bug. Reporting the bug would potentially
+ * cause an infinite recursion, though, so let's ignore it.
+ */
if (!t->interval_count)
continue; /* this timer was not used by this thread */
diff --git a/transport-helper.c b/transport-helper.c
index 69391ee7d2..0789e5bca5 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1437,7 +1437,7 @@ static int udt_do_read(struct unidirectional_transfer *t)
transfer_debug("%s EOF (with %i bytes in buffer)",
t->src_name, (int)t->bufuse);
t->state = SSTATE_FLUSHING;
- } else if (bytes > 0) {
+ } else {
t->bufuse += bytes;
transfer_debug("Read %i bytes from %s (buffer now at %i)",
(int)bytes, t->src_name, (int)t->bufuse);
diff --git a/upload-pack.c b/upload-pack.c
index 956da5b061..26f29b85b5 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1780,16 +1780,16 @@ static void send_shallow_info(struct upload_pack_data *data)
packet_delim(1);
}
-enum fetch_state {
- FETCH_PROCESS_ARGS = 0,
- FETCH_SEND_ACKS,
- FETCH_SEND_PACK,
- FETCH_DONE,
+enum upload_state {
+ UPLOAD_PROCESS_ARGS = 0,
+ UPLOAD_SEND_ACKS,
+ UPLOAD_SEND_PACK,
+ UPLOAD_DONE,
};
int upload_pack_v2(struct repository *r, struct packet_reader *request)
{
- enum fetch_state state = FETCH_PROCESS_ARGS;
+ enum upload_state state = UPLOAD_PROCESS_ARGS;
struct upload_pack_data data;
clear_object_flags(the_repository, ALL_FLAGS);
@@ -1798,9 +1798,9 @@ int upload_pack_v2(struct repository *r, struct packet_reader *request)
data.use_sideband = LARGE_PACKET_MAX;
get_upload_pack_config(r, &data);
- while (state != FETCH_DONE) {
+ while (state != UPLOAD_DONE) {
switch (state) {
- case FETCH_PROCESS_ARGS:
+ case UPLOAD_PROCESS_ARGS:
process_args(request, &data);
if (!data.want_obj.nr && !data.wait_for_done) {
@@ -1811,27 +1811,27 @@ int upload_pack_v2(struct repository *r, struct packet_reader *request)
* to just send 'have's without 'want's); guess
* they didn't want anything.
*/
- state = FETCH_DONE;
+ state = UPLOAD_DONE;
} else if (data.seen_haves) {
/*
* Request had 'have' lines, so lets ACK them.
*/
- state = FETCH_SEND_ACKS;
+ state = UPLOAD_SEND_ACKS;
} else {
/*
* Request had 'want's but no 'have's so we can
* immediately go to construct and send a pack.
*/
- state = FETCH_SEND_PACK;
+ state = UPLOAD_SEND_PACK;
}
break;
- case FETCH_SEND_ACKS:
+ case UPLOAD_SEND_ACKS:
if (process_haves_and_send_acks(&data))
- state = FETCH_SEND_PACK;
+ state = UPLOAD_SEND_PACK;
else
- state = FETCH_DONE;
+ state = UPLOAD_DONE;
break;
- case FETCH_SEND_PACK:
+ case UPLOAD_SEND_PACK:
send_wanted_ref_info(&data);
send_shallow_info(&data);
@@ -1841,9 +1841,9 @@ int upload_pack_v2(struct repository *r, struct packet_reader *request)
packet_writer_write(&data.writer, "packfile\n");
create_pack_file(&data, NULL);
}
- state = FETCH_DONE;
+ state = UPLOAD_DONE;
break;
- case FETCH_DONE:
+ case UPLOAD_DONE:
continue;
}
}
diff --git a/userdiff.c b/userdiff.c
index da75625020..05776ccd10 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -59,20 +59,30 @@ PATTERNS("bash",
"("
"("
/* POSIX identifier with mandatory parentheses */
- "[a-zA-Z_][a-zA-Z0-9_]*[ \t]*\\([ \t]*\\))"
+ "([a-zA-Z_][a-zA-Z0-9_]*[ \t]*\\([ \t]*\\))"
"|"
/* Bashism identifier with optional parentheses */
- "(function[ \t]+[a-zA-Z_][a-zA-Z0-9_]*(([ \t]*\\([ \t]*\\))|([ \t]+))"
+ "(function[ \t]+[a-zA-Z_][a-zA-Z0-9_]*(([ \t]*\\([ \t]*\\))|([ \t]+)))"
")"
- /* Optional whitespace */
- "[ \t]*"
- /* Compound command starting with `{`, `(`, `((` or `[[` */
- "(\\{|\\(\\(?|\\[\\[)"
+ /* Everything after the function header is captured */
+ ".*$"
/* End of captured text */
")",
/* -- */
- /* Characters not in the default $IFS value */
- "[^ \t]+"),
+ /* Identifiers: variable and function names */
+ "[a-zA-Z_][a-zA-Z0-9_]*"
+ /* Shell variables: $VAR, ${VAR} */
+ "|\\$[a-zA-Z0-9_]+|\\$\\{"
+ /*Command list separators and redirection operators */
+ "|\\|\\||&&|<<|>>"
+ /* Operators ending in '=' (comparison + compound assignment) */
+ "|==|!=|<=|>=|[-+*/%&|^]="
+ /* Additional parameter expansion operators */
+ "|:=|:-|:\\+|:\\?|##|%%|\\^\\^|,,"
+ /* Command-line options (to avoid splitting -option) */
+ "|[-a-zA-Z0-9_]+"
+ /* Brackets and grouping symbols */
+ "|\\(|\\)|\\{|\\}|\\[|\\]"),
PATTERNS("bibtex",
"(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$",
/* -- */