summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/main.yml10
-rw-r--r--Documentation/CodingGuidelines6
-rw-r--r--Documentation/RelNotes/2.42.0.txt102
-rw-r--r--Documentation/config.txt2
-rw-r--r--Documentation/config/advice.txt4
-rw-r--r--Documentation/config/feature.txt3
-rw-r--r--Documentation/config/gc.txt15
-rw-r--r--Documentation/config/pack.txt17
-rw-r--r--Documentation/diff-options.txt7
-rw-r--r--Documentation/git-cat-file.txt15
-rw-r--r--Documentation/git-credential.txt2
-rw-r--r--Documentation/git-cvsserver.txt2
-rw-r--r--Documentation/git-describe.txt4
-rw-r--r--Documentation/git-diff.txt9
-rw-r--r--Documentation/git-format-patch.txt2
-rw-r--r--Documentation/git-interpret-trailers.txt134
-rw-r--r--Documentation/git-ls-files.txt6
-rw-r--r--Documentation/git-ls-remote.txt48
-rw-r--r--Documentation/git-ls-tree.txt8
-rw-r--r--Documentation/git-merge.txt11
-rw-r--r--Documentation/git-mktag.txt2
-rw-r--r--Documentation/git-pack-refs.txt29
-rw-r--r--Documentation/git-show-branch.txt16
-rw-r--r--Documentation/git-show-ref.txt40
-rw-r--r--Documentation/git-sparse-checkout.txt2
-rw-r--r--Documentation/git-stash.txt2
-rw-r--r--Documentation/git-tag.txt10
-rw-r--r--Documentation/git-worktree.txt16
-rw-r--r--Documentation/gitcredentials.txt2
-rw-r--r--Documentation/gitweb.txt2
-rw-r--r--Documentation/revisions.txt50
-rw-r--r--Documentation/technical/remembering-renames.txt2
-rw-r--r--Documentation/urls-remotes.txt2
-rw-r--r--Documentation/user-manual.txt27
-rwxr-xr-xGIT-VERSION-GEN2
l---------RelNotes2
-rw-r--r--advice.c1
-rw-r--r--advice.h1
-rw-r--r--builtin/add.c2
-rw-r--r--builtin/cat-file.c87
-rw-r--r--builtin/commit-graph.c2
-rw-r--r--builtin/commit.c6
-rw-r--r--builtin/config.c17
-rw-r--r--builtin/credential-cache--daemon.c17
-rw-r--r--builtin/credential-store.c15
-rw-r--r--builtin/diff-tree.c4
-rw-r--r--builtin/fetch.c147
-rw-r--r--builtin/fsck.c2
-rw-r--r--builtin/index-pack.c2
-rw-r--r--builtin/log.c17
-rw-r--r--builtin/ls-files.c27
-rw-r--r--builtin/merge-tree.c2
-rw-r--r--builtin/pack-objects.c2
-rw-r--r--builtin/pack-refs.c31
-rw-r--r--builtin/prune.c2
-rw-r--r--builtin/replace.c2
-rw-r--r--builtin/submodule--helper.c7
-rw-r--r--builtin/tag.c24
-rw-r--r--builtin/unpack-objects.c2
-rw-r--r--builtin/upload-pack.c2
-rw-r--r--builtin/worktree.c233
-rwxr-xr-xci/lib.sh7
-rwxr-xr-xci/run-build-and-tests.sh1
-rw-r--r--commit-graph.c4
-rw-r--r--commit-reach.c2
-rw-r--r--config.c54
-rw-r--r--config.h4
-rw-r--r--contrib/coccinelle/README40
-rw-r--r--contrib/completion/git-completion.bash2
-rw-r--r--credential.c7
-rw-r--r--credential.h2
-rw-r--r--diff.c53
-rw-r--r--diff.h7
-rw-r--r--dir.h14
-rw-r--r--environment.c4
-rw-r--r--environment.h1
-rw-r--r--git.c2
-rw-r--r--log-tree.c2
-rw-r--r--notes.h19
-rw-r--r--object.c6
-rw-r--r--object.h2
-rw-r--r--pack-bitmap.c249
-rw-r--r--pack-bitmap.h4
-rw-r--r--pathspec.c19
-rw-r--r--pathspec.h8
-rw-r--r--reachable.c85
-rw-r--r--refs.c4
-rw-r--r--refs.h8
-rw-r--r--refs/debug.c4
-rw-r--r--refs/files-backend.c27
-rw-r--r--refs/packed-backend.c2
-rw-r--r--refs/refs-internal.h3
-rw-r--r--replace-object.c28
-rw-r--r--replace-object.h30
-rw-r--r--repo-settings.c8
-rw-r--r--repository.c1
-rw-r--r--repository.h11
-rw-r--r--revision.h2
-rw-r--r--run-command.c14
-rw-r--r--setup.c12
-rw-r--r--statinfo.h14
-rw-r--r--strbuf.c11
-rw-r--r--strbuf.h12
-rw-r--r--submodule-config.c3
-rw-r--r--t/README4
-rw-r--r--t/helper/test-ref-store.c11
-rw-r--r--t/lib-credential.sh103
-rw-r--r--t/lib-gpg.sh3
-rwxr-xr-xt/perf/p2000-sparse-operations.sh3
-rwxr-xr-xt/t0000-basic.sh2
-rwxr-xr-xt/t0030-stripspace.sh560
-rwxr-xr-xt/t0211-trace2-perf.sh4
-rwxr-xr-xt/t1001-read-tree-m-2way.sh2
-rwxr-xr-xt/t1002-read-tree-m-u-2way.sh589
-rwxr-xr-xt/t1006-cat-file.sh249
-rwxr-xr-xt/t1092-sparse-checkout-compatibility.sh79
-rwxr-xr-xt/t1800-hook.sh20
-rwxr-xr-xt/t2400-worktree-add.sh507
-rwxr-xr-xt/t3007-ls-files-recurse-submodules.sh33
-rwxr-xr-xt/t3013-ls-files-format.sh35
-rwxr-xr-xt/t3210-pack-refs.sh191
-rwxr-xr-xt/t3500-cherry.sh69
-rwxr-xr-xt/t3700-add.sh34
-rwxr-xr-xt/t3701-add-interactive.sh38
-rwxr-xr-xt/t3903-stash.sh26
-rwxr-xr-xt/t4000-diff-format.sh34
-rwxr-xr-xt/t4002-diff-basic.sh243
-rwxr-xr-xt/t4003-diff-rename-1.sh62
-rwxr-xr-xt/t4004-diff-rename-symlink.sh42
-rwxr-xr-xt/t4202-log.sh23
-rwxr-xr-xt/t4206-log-follow-harder-copies.sh36
-rwxr-xr-xt/t5300-pack-object.sh184
-rwxr-xr-xt/t5301-sliding-window.sh100
-rwxr-xr-xt/t5303-pack-corruption-resilience.sh584
-rwxr-xr-xt/t5304-prune.sh14
-rwxr-xr-xt/t5306-pack-nobase.sh94
-rwxr-xr-xt/t5310-pack-bitmaps.sh38
-rwxr-xr-xt/t5326-multi-pack-bitmaps.sh35
-rwxr-xr-xt/t5329-pack-objects-cruft.sh171
-rwxr-xr-xt/t6050-replace.sh296
-rwxr-xr-xt/t7004-tag.sh19
-rwxr-xr-xt/t7101-reset-empty-subdirs.sh48
-rwxr-xr-xt/t7110-reset-merge.sh314
-rwxr-xr-xt/t7111-reset-table.sh20
-rwxr-xr-xt/t7201-co.sh92
-rwxr-xr-xt/t7400-submodule-basic.sh16
-rwxr-xr-xt/t7508-status.sh4
-rwxr-xr-xt/t7600-merge.sh40
-rwxr-xr-xt/t7700-repack.sh10
-rwxr-xr-xt/t7701-repack-unpack-unreachable.sh31
-rwxr-xr-xt/t7814-grep-recurse-submodules.sh40
-rwxr-xr-xt/t9001-send-email.sh2
-rwxr-xr-xt/t9100-git-svn-basic.sh31
-rwxr-xr-xt/t9104-git-svn-follow-parent.sh62
-rwxr-xr-xt/t9200-git-cvsexportcommit.sh351
-rwxr-xr-xt/t9400-git-cvsserver-server.sh530
-rw-r--r--t/test-lib-functions.sh13
-rw-r--r--worktree.c4
158 files changed, 5271 insertions, 2933 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 30492ea..079645b 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -246,9 +246,6 @@ jobs:
fail-fast: false
matrix:
vector:
- - jobname: linux-clang
- cc: clang
- pool: ubuntu-latest
- jobname: linux-sha256
cc: clang
pool: ubuntu-latest
@@ -273,11 +270,8 @@ jobs:
- jobname: linux-leaks
cc: gcc
pool: ubuntu-latest
- - jobname: linux-asan
- cc: gcc
- pool: ubuntu-latest
- - jobname: linux-ubsan
- cc: gcc
+ - jobname: linux-asan-ubsan
+ cc: clang
pool: ubuntu-latest
env:
CC: ${{matrix.vector.cc}}
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 003393e..ad0e190 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -188,6 +188,10 @@ For shell scripts specifically (not exhaustive):
hopefully nobody starts using "local" before they are reimplemented
in C ;-)
+ - Use octal escape sequences (e.g. "\302\242"), not hexadecimal (e.g.
+ "\xc2\xa2") in printf format strings, since hexadecimal escape
+ sequences are not portable.
+
For C programs:
@@ -687,7 +691,7 @@ Writing Documentation:
Do: [-q | --quiet]
Don't: [-q|--quiet]
- Don't use spacing around "|" tokens when they're used to seperate the
+ Don't use spacing around "|" tokens when they're used to separate the
alternate arguments of an option:
Do: --track[=(direct|inherit)]
Don't: --track[=(direct | inherit)]
diff --git a/Documentation/RelNotes/2.42.0.txt b/Documentation/RelNotes/2.42.0.txt
new file mode 100644
index 0000000..e01051d
--- /dev/null
+++ b/Documentation/RelNotes/2.42.0.txt
@@ -0,0 +1,102 @@
+Git v2.42 Release Notes
+=======================
+
+UI, Workflows & Features
+
+ * "git pack-refs" learns "--include" and "--exclude" to tweak the ref
+ hierarchy to be packed using pattern matching.
+
+ * 'git worktree add' learned how to create a worktree based on an
+ orphaned branch with `--orphan`.
+
+
+Performance, Internal Implementation, Development Support etc.
+
+ * "git diff-tree" has been taught to take advantage of the
+ sparse-index feature.
+
+ * Clang's sanitizer implementation seems to work better than GCC's.
+ (merge d88d727143 jk/ci-use-clang-for-sanitizer-jobs later to maint).
+
+ * The object traversal using reachability bitmap done by
+ "pack-object" has been tweaked to take advantage of the fact that
+ using "boundary" commits as representative of all the uninteresting
+ ones can save quite a lot of object enumeration.
+
+
+Fixes since v2.41
+-----------------
+
+ * "git tag" learned to leave the "$GIT_DIR/TAG_EDITMSG" file when the
+ command failed, so that the user can salvage what they typed.
+ (merge 08c12ec1d0 kh/keep-tag-editmsg-upon-failure later to maint).
+
+ * The "-s" (silent, squelch) option of the "diff" family of commands
+ did not interact with other options that specify the output format
+ well. This has been cleaned up so that it will clear all the
+ formatting options given before.
+ (merge 9d484b92ed jc/diff-s-with-other-options later to maint).
+
+ * Update documentation regarding Coccinelle patches.
+ (merge 3bd0097cfc gc/doc-cocci-updates later to maint).
+
+ * Some atoms that can be used in "--format=<format>" for "git ls-tree"
+ were not supported by "git ls-files", even though they were relevant
+ in the context of the latter.
+ (merge 4d28c4f75f zh/ls-files-format-atoms later to maint).
+
+ * Document more pseudo-refs and teach the command line completion
+ machinery to complete AUTO_MERGE.
+ (merge 982ff3a649 pb/complete-and-document-auto-merge-and-friends later to maint).
+
+ * "git submodule" code trusted the data coming from the config (and
+ the in-tree .gitmodules file) too much without validating, leading
+ to NULL dereference if the user mucks with a repository (e.g.
+ submodule.<name>.url is removed). This has been corrected.
+ (merge fbc806acd1 tb/submodule-null-deref-fix later to maint).
+
+ * The value of config.worktree is per-repository, but has been kept
+ in a singleton global variable per process. This has been OK as
+ most Git operations interacted with a single repository at a time,
+ but not right for operations like recursive "grep" that want to
+ access multiple repositories from a single process without forking.
+
+ The global variable has been eliminated and made into a member in
+ the per-repository data structure.
+ (merge 3867f6d650 vd/worktree-config-is-per-repository later to maint).
+
+ * "git [-c log.follow=true] log [--follow] ':(glob)f**'" used to barf.
+ (merge 8260bc5902 jk/log-follow-with-non-literal-pathspec later to maint).
+
+ * Introduce a mechanism to disable replace refs globally and per
+ repository.
+ (merge 9c7d1b057f ds/disable-replace-refs later to maint).
+
+ * "git cat-file --batch" and friends learned "-Z" that uses NUL
+ delimiter for both input and output.
+ (merge f79e18849b ps/cat-file-null-output later to maint).
+
+ * The reimplemented "git add -i" did not honor color.ui configuration.
+ (merge 6f74648cea ds/add-i-color-configuration-fix later to maint).
+
+ * Compilation fix for platforms without D_TYPE in struct dirent.
+ (merge 03bf92b9bf as/dtype-compilation-fix later to maint).
+
+ * Suggest to refrain from using hex literals that are non-portable
+ when writing printf(1) format strings.
+ (merge f0b68f0546 jt/doc-use-octal-with-printf later to maint).
+
+ * Other code cleanup, docfix, build fix, etc.
+ (merge 51f9d2e563 sa/doc-ls-remote later to maint).
+ (merge c6d26a9dda jk/format-patch-message-id-unleak later to maint).
+ (merge f7e063f326 ps/fetch-cleanups later to maint).
+ (merge e4cf013468 tl/quote-problematic-arg-for-clarity later to maint).
+ (merge 20025fdfc7 tz/test-ssh-verifytime-fix later to maint).
+ (merge e48a21df65 tz/test-fix-pthreads-prereq later to maint).
+ (merge 68b51172e3 mh/commit-reach-get-reachable-plug-leak later to maint).
+ (merge aeee1408ce kh/use-default-notes-doc later to maint).
+ (merge 3b8724bce6 jc/test-modernization later to maint).
+ (merge 447a3b7331 jc/test-modernization-2 later to maint).
+ (merge d57fa7fc73 la/doc-interpret-trailers later to maint).
+ (merge 548afb0d9a la/docs-typofixes later to maint).
+ (merge 3744ffcbcd rs/doc-ls-tree-hex-literal later to maint).
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 0e93aef..229b63a 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -182,7 +182,7 @@ included, Git breaks the cycle by prohibiting these files from affecting
the resolution of these conditions (thus, prohibiting them from
declaring remote URLs).
+
-As for the naming of this keyword, it is for forwards compatibiliy with
+As for the naming of this keyword, it is for forwards compatibility with
a naming scheme that supports more variable-based include conditions,
but currently Git only supports the exact keyword described above.
diff --git a/Documentation/config/advice.txt b/Documentation/config/advice.txt
index c96b5b2..c548a91 100644
--- a/Documentation/config/advice.txt
+++ b/Documentation/config/advice.txt
@@ -138,4 +138,8 @@ advice.*::
checkout.
diverging::
Advice shown when a fast-forward is not possible.
+ worktreeAddOrphan::
+ Advice shown when a user tries to create a worktree from an
+ invalid reference, to instruct how to create a new orphan
+ branch instead.
--
diff --git a/Documentation/config/feature.txt b/Documentation/config/feature.txt
index 17b4d39..bf9546f 100644
--- a/Documentation/config/feature.txt
+++ b/Documentation/config/feature.txt
@@ -14,6 +14,9 @@ feature.experimental::
+
* `fetch.negotiationAlgorithm=skipping` may improve fetch negotiation times by
skipping more commits at a time, reducing the number of round trips.
++
+* `pack.useBitmapBoundaryTraversal=true` may improve bitmap traversal times by
+walking fewer objects.
feature.manyFiles::
Enable config options that optimize for repos with many files in the
diff --git a/Documentation/config/gc.txt b/Documentation/config/gc.txt
index 7f95c86..ca47eb2 100644
--- a/Documentation/config/gc.txt
+++ b/Documentation/config/gc.txt
@@ -130,6 +130,21 @@ or rebase occurring. Since these changes are not part of the current
project most users will want to expire them sooner, which is why the
default is more aggressive than `gc.reflogExpire`.
+gc.recentObjectsHook::
+ When considering whether or not to remove an object (either when
+ generating a cruft pack or storing unreachable objects as
+ loose), use the shell to execute the specified command(s).
+ Interpret their output as object IDs which Git will consider as
+ "recent", regardless of their age. By treating their mtimes as
+ "now", any objects (and their descendants) mentioned in the
+ output will be kept regardless of their true age.
++
+Output must contain exactly one hex object ID per line, and nothing
+else. Objects which cannot be found in the repository are ignored.
+Multiple hooks are supported, but all must exit successfully, else the
+operation (either generating a cruft pack or unpacking unreachable
+objects) will be halted.
+
gc.rerereResolved::
Records of conflicted merge you resolved earlier are
kept for this many days when 'git rerere gc' is run.
diff --git a/Documentation/config/pack.txt b/Documentation/config/pack.txt
index d4c7c9d..3748136 100644
--- a/Documentation/config/pack.txt
+++ b/Documentation/config/pack.txt
@@ -123,6 +123,23 @@ pack.useBitmaps::
true. You should not generally need to turn this off unless
you are debugging pack bitmaps.
+pack.useBitmapBoundaryTraversal::
+ When true, Git will use an experimental algorithm for computing
+ reachability queries with bitmaps. Instead of building up
+ complete bitmaps for all of the negated tips and then OR-ing
+ them together, consider negated tips with existing bitmaps as
+ additive (i.e. OR-ing them into the result if they exist,
+ ignoring them otherwise), and build up a bitmap at the boundary
+ instead.
++
+When using this algorithm, Git may include too many objects as a result
+of not opening up trees belonging to certain UNINTERESTING commits. This
+inexactness matches the non-bitmap traversal algorithm.
++
+In many cases, this can provide a speed-up over the exact algorithm,
+particularly when there is poor bitmap coverage of the negated side of
+the query.
+
pack.useSparse::
When true, git will default to using the '--sparse' option in
'git pack-objects' when the '--revs' option is present. This
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 08ab861..9f33f88 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -35,8 +35,11 @@ endif::git-diff[]
-s::
--no-patch::
- Suppress diff output. Useful for commands like `git show` that
- show the patch by default, or to cancel the effect of `--patch`.
+ Suppress all output from the diff machinery. Useful for
+ commands like `git show` that show the patch by default to
+ squelch their output, or to cancel the effect of options like
+ `--patch`, `--stat` earlier on the command line in an alias.
+
endif::git-format-patch[]
ifdef::git-log[]
diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt
index 411de2e..0e4936d 100644
--- a/Documentation/git-cat-file.txt
+++ b/Documentation/git-cat-file.txt
@@ -14,7 +14,7 @@ SYNOPSIS
'git cat-file' (-t | -s) [--allow-unknown-type] <object>
'git cat-file' (--batch | --batch-check | --batch-command) [--batch-all-objects]
[--buffer] [--follow-symlinks] [--unordered]
- [--textconv | --filters] [-z]
+ [--textconv | --filters] [-Z]
'git cat-file' (--textconv | --filters)
[<rev>:<path|tree-ish> | --path=<path|tree-ish> <rev>]
@@ -243,10 +243,16 @@ respectively print:
/etc/passwd
--
+-Z::
+ Only meaningful with `--batch`, `--batch-check`, or
+ `--batch-command`; input and output is NUL-delimited instead of
+ newline-delimited.
+
-z::
Only meaningful with `--batch`, `--batch-check`, or
`--batch-command`; input is NUL-delimited instead of
- newline-delimited.
+ newline-delimited. This option is deprecated in favor of
+ `-Z` as the output can otherwise be ambiguous.
OUTPUT
@@ -384,6 +390,11 @@ notdir SP <size> LF
is printed when, during symlink resolution, a file is used as a
directory name.
+Alternatively, when `-Z` is passed, the line feeds in any of the above examples
+are replaced with NUL terminators. This ensures that output will be parsable if
+the output itself would contain a linefeed and is thus recommended for
+scripting purposes.
+
CAVEATS
-------
diff --git a/Documentation/git-credential.txt b/Documentation/git-credential.txt
index 0e6d9e8..a220afe 100644
--- a/Documentation/git-credential.txt
+++ b/Documentation/git-credential.txt
@@ -39,7 +39,7 @@ for later use.
If the action is `reject`, git-credential will send the description to
any configured credential helpers, which may erase any stored
-credential matching the description.
+credentials matching the description.
If the action is `approve` or `reject`, no output should be emitted.
diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt
index 53f111b..cf4a5a2 100644
--- a/Documentation/git-cvsserver.txt
+++ b/Documentation/git-cvsserver.txt
@@ -118,7 +118,7 @@ for example:
myuser:$5$.NqmNH1vwfzGpV8B$znZIcumu1tNLATgV2l6e1/mY8RzhUDHMOaVOeL1cxV3
------
You can use the 'htpasswd' facility that comes with Apache to make these
-files, but only with the -d option (or -B if your system suports it).
+files, but only with the -d option (or -B if your system supports it).
Preferably use the system specific utility that manages password hash
creation in your platform (e.g. mkpasswd in Linux, encrypt in OpenBSD or
diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
index c6a79c2..08ff715 100644
--- a/Documentation/git-describe.txt
+++ b/Documentation/git-describe.txt
@@ -140,7 +140,7 @@ at the end.
The number of additional commits is the number
of commits which would be displayed by "git log v1.0.4..parent".
-The hash suffix is "-g" + an unambigous abbreviation for the tip commit
+The hash suffix is "-g" + an unambiguous abbreviation for the tip commit
of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`). The
length of the abbreviation scales as the repository grows, using the
approximate number of objects in the repository and a bit of math
@@ -203,7 +203,7 @@ BUGS
Tree objects as well as tag objects not pointing at commits, cannot be described.
When describing blobs, the lightweight tags pointing at blobs are ignored,
-but the blob is still described as <committ-ish>:<path> despite the lightweight
+but the blob is still described as <commit-ish>:<path> despite the lightweight
tag being favorable.
GIT
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index 52b6792..08087ff 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -102,7 +102,11 @@ If --merge-base is given, use the merge base of the two commits for the
Just in case you are doing something exotic, it should be
noted that all of the <commit> in the above description, except
in the `--merge-base` case and in the last two forms that use `..`
-notations, can be any <tree>.
+notations, can be any <tree>. A tree of interest is the one pointed to
+by the special ref `AUTO_MERGE`, which is written by the 'ort' merge
+strategy upon hitting merge conflicts (see linkgit:git-merge[1]).
+Comparing the working tree with `AUTO_MERGE` shows changes you've made
+so far to resolve textual conflicts (see the examples below).
For a more complete list of ways to spell <commit>, see
"SPECIFYING REVISIONS" section in linkgit:gitrevisions[7].
@@ -152,6 +156,7 @@ Various ways to check your working tree::
$ git diff <1>
$ git diff --cached <2>
$ git diff HEAD <3>
+$ git diff AUTO_MERGE <4>
------------
+
<1> Changes in the working tree not yet staged for the next commit.
@@ -159,6 +164,8 @@ $ git diff HEAD <3>
would be committing if you run `git commit` without `-a` option.
<3> Changes in the working tree since your last commit; what you
would be committing if you run `git commit -a`
+<4> Changes in the working tree you've made to resolve textual
+ conflicts so far.
Comparing with arbitrary commits::
+
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index b1c13fb..373b46f 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -245,7 +245,7 @@ populated with placeholder text.
or "--reroll-count=4rev2" are allowed), but the downside of
using such a reroll-count is that the range-diff/interdiff
with the previous version does not state exactly which
- version the new interation is compared against.
+ version the new iteration is compared against.
--to=<email>::
Add a `To:` header to the email headers. This is in addition
diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt
index 4b97f81..55d8961 100644
--- a/Documentation/git-interpret-trailers.txt
+++ b/Documentation/git-interpret-trailers.txt
@@ -14,21 +14,38 @@ SYNOPSIS
DESCRIPTION
-----------
-Help parsing or adding 'trailers' lines, that look similar to RFC 822 e-mail
+Add or parse 'trailer' lines that look similar to RFC 822 e-mail
headers, at the end of the otherwise free-form part of a commit
-message.
+message. For example, in the following commit message
-This command reads some patches or commit messages from either the
-<file> arguments or the standard input if no <file> is specified. If
-`--parse` is specified, the output consists of the parsed trailers.
+------------------------------------------------
+subject
+
+Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+
+Signed-off-by: Alice <alice@example.com>
+Signed-off-by: Bob <bob@example.com>
+------------------------------------------------
+
+the last two lines starting with "Signed-off-by" are trailers.
+This command reads commit messages from either the
+<file> arguments or the standard input if no <file> is specified.
+If `--parse` is specified, the output consists of the parsed trailers.
Otherwise, this command applies the arguments passed using the
-`--trailer` option, if any, to the commit message part of each input
-file. The result is emitted on the standard output.
+`--trailer` option, if any, to each input file. The result is emitted on the
+standard output.
+
+This command can also operate on the output of linkgit:git-format-patch[1],
+which is more elaborate than a plain commit message. Namely, such output
+includes a commit message (as above), a "---" divider line, and a patch part.
+For these inputs, the divider and patch parts are not modified by
+this command and are emitted as is on the output, unless
+`--no-divider` is specified.
Some configuration variables control the way the `--trailer` arguments
-are applied to each commit message and the way any existing trailer in
-the commit message is changed. They also make it possible to
+are applied to each input and the way any existing trailer in
+the input is changed. They also make it possible to
automatically add some trailers.
By default, a '<token>=<value>' or '<token>:<value>' argument given
@@ -36,41 +53,46 @@ using `--trailer` will be appended after the existing trailers only if
the last trailer has a different (<token>, <value>) pair (or if there
is no existing trailer). The <token> and <value> parts will be trimmed
to remove starting and trailing whitespace, and the resulting trimmed
-<token> and <value> will appear in the message like this:
+<token> and <value> will appear in the output like this:
------------------------------------------------
token: value
------------------------------------------------
This means that the trimmed <token> and <value> will be separated by
-`': '` (one colon followed by one space).
+`': '` (one colon followed by one space). For convenience, the <token> can be a
+shortened string key (e.g., "sign") instead of the full string which should
+appear before the separator on the output (e.g., "Signed-off-by"). This can be
+configured using the 'trailer.<token>.key' configuration variable.
By default the new trailer will appear at the end of all the existing
trailers. If there is no existing trailer, the new trailer will appear
-after the commit message part of the output, and, if there is no line
-with only spaces at the end of the commit message part, one blank line
-will be added before the new trailer.
+at the end of the input. A blank line will be added before the new
+trailer if there isn't one already.
-Existing trailers are extracted from the input message by looking for
+Existing trailers are extracted from the input by looking for
a group of one or more lines that (i) is all trailers, or (ii) contains at
least one Git-generated or user-configured trailer and consists of at
least 25% trailers.
The group must be preceded by one or more empty (or whitespace-only) lines.
-The group must either be at the end of the message or be the last
+The group must either be at the end of the input or be the last
non-whitespace lines before a line that starts with '---' (followed by a
-space or the end of the line). Such three minus signs start the patch
-part of the message. See also `--no-divider` below.
+space or the end of the line).
When reading trailers, there can be no whitespace before or inside the
-token, but any number of regular space and tab characters are allowed
-between the token and the separator. There can be whitespaces before,
-inside or after the value. The value may be split over multiple lines
+<token>, but any number of regular space and tab characters are allowed
+between the <token> and the separator. There can be whitespaces before,
+inside or after the <value>. The <value> may be split over multiple lines
with each subsequent line starting with at least one whitespace, like
-the "folding" in RFC 822.
+the "folding" in RFC 822. Example:
+
+------------------------------------------------
+token: This is a very long value, with spaces and
+ newlines in it.
+------------------------------------------------
-Note that 'trailers' do not follow and are not intended to follow many
-rules for RFC 822 headers. For example they do not follow
-the encoding rules and probably many other rules.
+Note that trailers do not follow (nor are they intended to follow) many of the
+rules for RFC 822 headers. For example they do not follow the encoding rule.
OPTIONS
-------
@@ -79,12 +101,12 @@ OPTIONS
--trim-empty::
If the <value> part of any trailer contains only whitespace,
- the whole trailer will be removed from the resulting message.
+ the whole trailer will be removed from the output.
This applies to existing trailers as well as new trailers.
--trailer <token>[(=|:)<value>]::
Specify a (<token>, <value>) pair that should be applied as a
- trailer to the input messages. See the description of this
+ trailer to the inputs. See the description of this
command.
--where <placement>::
@@ -98,7 +120,7 @@ OPTIONS
--if-exists <action>::
--no-if-exists::
Specify what action will be performed when there is already at
- least one trailer with the same <token> in the message. A setting
+ least one trailer with the same <token> in the input. A setting
provided with '--if-exists' overrides all configuration variables
and applies to all '--trailer' options until the next occurrence of
'--if-exists' or '--no-if-exists'. Possible actions are `addIfDifferent`,
@@ -107,7 +129,7 @@ OPTIONS
--if-missing <action>::
--no-if-missing::
Specify what action will be performed when there is no other
- trailer with the same <token> in the message. A setting
+ trailer with the same <token> in the input. A setting
provided with '--if-missing' overrides all configuration variables
and applies to all '--trailer' options until the next occurrence of
'--if-missing' or '--no-if-missing'. Possible actions are `doNothing`
@@ -174,7 +196,7 @@ first trailer with the same <token>.
trailer.ifexists::
This option makes it possible to choose what action will be
performed when there is already at least one trailer with the
- same <token> in the message.
+ same <token> in the input.
+
The valid values for this option are: `addIfDifferentNeighbor` (this
is the default), `addIfDifferent`, `add`, `replace` or `doNothing`.
@@ -184,10 +206,10 @@ trailer with the same (<token>, <value>) pair is above or below the line
where the new trailer will be added.
+
With `addIfDifferent`, a new trailer will be added only if no trailer
-with the same (<token>, <value>) pair is already in the message.
+with the same (<token>, <value>) pair is already in the input.
+
With `add`, a new trailer will be added, even if some trailers with
-the same (<token>, <value>) pair are already in the message.
+the same (<token>, <value>) pair are already in the input.
+
With `replace`, an existing trailer with the same <token> will be
deleted and the new trailer will be added. The deleted trailer will be
@@ -195,12 +217,12 @@ the closest one (with the same <token>) to the place where the new one
will be added.
+
With `doNothing`, nothing will be done; that is no new trailer will be
-added if there is already one with the same <token> in the message.
+added if there is already one with the same <token> in the input.
trailer.ifmissing::
This option makes it possible to choose what action will be
performed when there is not yet any trailer with the same
- <token> in the message.
+ <token> in the input.
+
The valid values for this option are: `add` (this is the default) and
`doNothing`.
@@ -235,13 +257,13 @@ trailer.<token>.ifmissing::
that option for trailers with the specified <token>.
trailer.<token>.command::
+ Deprecated in favor of 'trailer.<token>.cmd'.
This option behaves in the same way as 'trailer.<token>.cmd', except
that it doesn't pass anything as argument to the specified command.
Instead the first occurrence of substring $ARG is replaced by the
- value that would be passed as argument.
+ <value> that would be passed as argument.
+
-The 'trailer.<token>.command' option has been deprecated in favor of
-'trailer.<token>.cmd' due to the fact that $ARG in the user's command is
+Note that $ARG in the user's command is
only replaced once and that the original way of replacing $ARG is not safe.
+
When both 'trailer.<token>.cmd' and 'trailer.<token>.command' are given
@@ -249,10 +271,10 @@ for the same <token>, 'trailer.<token>.cmd' is used and
'trailer.<token>.command' is ignored.
trailer.<token>.cmd::
- This option can be used to specify a shell command that will be called:
+ This option can be used to specify a shell command that will be called
once to automatically add a trailer with the specified <token>, and then
- each time a '--trailer <token>=<value>' argument to modify the <value> of
- the trailer that this option would produce.
+ called each time a '--trailer <token>=<value>' argument is specified to
+ modify the <value> of the trailer that this option would produce.
+
When the specified command is first called to add a trailer
with the specified <token>, the behavior is as if a special
@@ -272,37 +294,37 @@ EXAMPLES
--------
* Configure a 'sign' trailer with a 'Signed-off-by' key, and then
- add two of these trailers to a message:
+ add two of these trailers to a commit message file:
+
------------
$ git config trailer.sign.key "Signed-off-by"
$ cat msg.txt
subject
-message
+body text
$ git interpret-trailers --trailer 'sign: Alice <alice@example.com>' --trailer 'sign: Bob <bob@example.com>' <msg.txt
subject
-message
+body text
Signed-off-by: Alice <alice@example.com>
Signed-off-by: Bob <bob@example.com>
------------
-* Use the `--in-place` option to edit a message file in place:
+* Use the `--in-place` option to edit a commit message file in place:
+
------------
$ cat msg.txt
subject
-message
+body text
Signed-off-by: Bob <bob@example.com>
$ git interpret-trailers --trailer 'Acked-by: Alice <alice@example.com>' --in-place msg.txt
$ cat msg.txt
subject
-message
+body text
Signed-off-by: Bob <bob@example.com>
Acked-by: Alice <alice@example.com>
@@ -325,7 +347,7 @@ $ git interpret-trailers --trailer 'Cc: Alice <alice@example.com>' --trailer 'Re
$ cat msg1.txt
subject
-message
+body text
$ git config trailer.sign.key "Signed-off-by: "
$ git config trailer.sign.ifmissing add
$ git config trailer.sign.ifexists doNothing
@@ -333,19 +355,19 @@ $ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.
$ git interpret-trailers --trailer sign <msg1.txt
subject
-message
+body text
Signed-off-by: Bob <bob@example.com>
$ cat msg2.txt
subject
-message
+body text
Signed-off-by: Alice <alice@example.com>
$ git interpret-trailers --trailer sign <msg2.txt
subject
-message
+body text
Signed-off-by: Alice <alice@example.com>
------------
@@ -373,14 +395,14 @@ test -n "$1" && git log --author="$1" --pretty="%an <%ae>" -1 || true
$ cat msg.txt
subject
-message
+body text
$ git config trailer.help.key "Helped-by: "
$ git config trailer.help.ifExists "addIfDifferentNeighbor"
$ git config trailer.help.cmd "~/bin/glog-find-author"
$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <msg.txt
subject
-message
+body text
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Christian Couder <christian.couder@gmail.com>
@@ -397,14 +419,14 @@ test -n "$1" && git log --grep "$1" --pretty=reference -1 || true
$ cat msg.txt
subject
-message
+body text
$ git config trailer.ref.key "Reference-to: "
$ git config trailer.ref.ifExists "replace"
$ git config trailer.ref.cmd "~/bin/glog-grep"
$ git interpret-trailers --trailer="ref:Add copyright notices." <msg.txt
subject
-message
+body text
Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07)
------------
@@ -416,7 +438,7 @@ Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07)
$ cat msg.txt
subject
-message
+body text
see: HEAD~2
$ cat ~/bin/glog-ref
@@ -429,7 +451,7 @@ $ git config trailer.see.cmd "glog-ref"
$ git interpret-trailers --trailer=see <msg.txt
subject
-message
+body text
See-also: fe3187489d69c4 (subject of related commit)
------------
diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
index 1abdd3c..1bc0328 100644
--- a/Documentation/git-ls-files.txt
+++ b/Documentation/git-ls-files.txt
@@ -270,8 +270,14 @@ interpolated. The following "fieldname" are understood:
objectmode::
The mode of the file which is recorded in the index.
+objecttype::
+ The object type of the file which is recorded in the index.
objectname::
The name of the file which is recorded in the index.
+objectsize[:padded]::
+ The object size of the file which is recorded in the index
+ ("-" if the object is a `commit` or `tree`).
+ It also supports a padded format of size with "%(objectsize:padded)".
stage::
The stage of the file which is recorded in the index.
eolinfo:index::
diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt
index ff3da54..1c4f696 100644
--- a/Documentation/git-ls-remote.txt
+++ b/Documentation/git-ls-remote.txt
@@ -96,27 +96,51 @@ OPTIONS
separator (so `bar` matches `refs/heads/bar` but not
`refs/heads/foobar`).
+OUTPUT
+------
+
+The output is in the format:
+
+------------
+<oid> TAB <ref> LF
+------------
+
+When showing an annotated tag, unless `--refs` is given, two such
+lines are shown: one with the refname for the tag itself as `<ref>`,
+and another with `<ref>` followed by `^{}`. The `<oid>` on the latter
+line shows the name of the object the tag points at.
+
EXAMPLES
--------
+* List all references (including symbolics and pseudorefs), peeling
+ tags:
++
+----
+$ git ls-remote
+27d43aaaf50ef0ae014b88bba294f93658016a2e HEAD
+950264636c68591989456e3ba0a5442f93152c1a refs/heads/main
+d9ab777d41f92a8c1684c91cfb02053d7dd1046b refs/heads/next
+d4ca2e3147b409459955613c152220f4db848ee1 refs/tags/v2.40.0
+73876f4861cd3d187a4682290ab75c9dccadbc56 refs/tags/v2.40.0^{}
----
-$ git ls-remote --tags .
-d6602ec5194c87b0fc87103ca4d67251c76f233a refs/tags/v0.99
-f25a265a342aed6041ab0cc484224d9ca54b6f41 refs/tags/v0.99.1
-7ceca275d047c90c0c7d5afb13ab97efdf51bd6e refs/tags/v0.99.3
-c5db5456ae3b0873fc659c19fafdde22313cc441 refs/tags/v0.99.2
-0918385dbd9656cab0d1d81ba7453d49bbc16250 refs/tags/junio-gpg-pub
+* List all references matching given patterns:
++
+----
$ git ls-remote http://www.kernel.org/pub/scm/git/git.git master seen rc
5fe978a5381f1fbad26a80e682ddd2a401966740 refs/heads/master
c781a84b5204fb294c9ccc79f8b3baceeb32c061 refs/heads/seen
+----
-$ git remote add korg http://www.kernel.org/pub/scm/git/git.git
-$ git ls-remote --tags korg v\*
-d6602ec5194c87b0fc87103ca4d67251c76f233a refs/tags/v0.99
-f25a265a342aed6041ab0cc484224d9ca54b6f41 refs/tags/v0.99.1
-c5db5456ae3b0873fc659c19fafdde22313cc441 refs/tags/v0.99.2
-7ceca275d047c90c0c7d5afb13ab97efdf51bd6e refs/tags/v0.99.3
+* List only tags matching a given wildcard pattern:
++
+----
+$ git ls-remote --tags http://www.kernel.org/pub/scm/git/git.git v\*
+485a869c64a68cc5795dd99689797c5900f4716d refs/tags/v2.39.2
+cbf04937d5b9fcf0a76c28f69e6294e9e3ecd7e6 refs/tags/v2.39.2^{}
+d4ca2e3147b409459955613c152220f4db848ee1 refs/tags/v2.40.0
+73876f4861cd3d187a4682290ab75c9dccadbc56 refs/tags/v2.40.0^{}
----
SEE ALSO
diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt
index 0240adb..6572095 100644
--- a/Documentation/git-ls-tree.txt
+++ b/Documentation/git-ls-tree.txt
@@ -86,9 +86,9 @@ OPTIONS
--format=<format>::
A string that interpolates `%(fieldname)` from the result
being shown. It also interpolates `%%` to `%`, and
- `%xx` where `xx` are hex digits interpolates to character
- with hex code `xx`; for example `%00` interpolates to
- `\0` (NUL), `%09` to `\t` (TAB) and `%0a` to `\n` (LF).
+ `%xNN` where `NN` are hex digits interpolates to character
+ with hex code `NN`; for example `%x00` interpolates to
+ `\0` (NUL), `%x09` to `\t` (TAB) and `%x0a` to `\n` (LF).
When specified, `--format` cannot be combined with other
format-altering options, including `--long`, `--name-only`
and `--object-only`.
@@ -145,7 +145,7 @@ FIELD NAMES
-----------
Various values from structured fields can be used to interpolate
-into the resulting output. For each outputing line, the following
+into the resulting output. For each outputting line, the following
names can be used:
objectmode::
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index 0aeff57..8625c5c 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -194,9 +194,13 @@ happens:
versions: stage 1 stores the version from the common ancestor,
stage 2 from `HEAD`, and stage 3 from `MERGE_HEAD` (you
can inspect the stages with `git ls-files -u`). The working
- tree files contain the result of the "merge" program; i.e. 3-way
+ tree files contain the result of the merge operation; i.e. 3-way
merge results with familiar conflict markers `<<<` `===` `>>>`.
-5. No other changes are made. In particular, the local
+5. A special ref `AUTO_MERGE` is written, pointing to a tree
+ corresponding to the current content of the working tree (including
+ conflict markers for textual conflicts). Note that this ref is only
+ written when the 'ort' merge strategy is used (the default).
+6. No other changes are made. In particular, the local
modifications you had before you started merge will stay the
same and the index entries for them stay as they were,
i.e. matching `HEAD`.
@@ -336,7 +340,8 @@ You can work through the conflict with a number of tools:
* Look at the diffs. `git diff` will show a three-way diff,
highlighting changes from both the `HEAD` and `MERGE_HEAD`
- versions.
+ versions. `git diff AUTO_MERGE` will show what changes you've
+ made so far to resolve textual conflicts.
* Look at the diffs from each branch. `git log --merge -p <path>`
will show diffs first for the `HEAD` version and then the
diff --git a/Documentation/git-mktag.txt b/Documentation/git-mktag.txt
index 466a697..b2a2e80 100644
--- a/Documentation/git-mktag.txt
+++ b/Documentation/git-mktag.txt
@@ -33,7 +33,7 @@ from warnings to errors (so e.g. a missing "tagger" line is an error).
Extra headers in the object are also an error under mktag, but ignored
by linkgit:git-fsck[1]. This extra check can be turned off by setting
-the appropriate `fsck.<msg-id>` varible:
+the appropriate `fsck.<msg-id>` variable:
git -c fsck.extraHeaderEntry=ignore mktag <my-tag-with-headers
diff --git a/Documentation/git-pack-refs.txt b/Documentation/git-pack-refs.txt
index 154081f..284956a 100644
--- a/Documentation/git-pack-refs.txt
+++ b/Documentation/git-pack-refs.txt
@@ -8,7 +8,7 @@ git-pack-refs - Pack heads and tags for efficient repository access
SYNOPSIS
--------
[verse]
-'git pack-refs' [--all] [--no-prune]
+'git pack-refs' [--all] [--no-prune] [--include <pattern>] [--exclude <pattern>]
DESCRIPTION
-----------
@@ -51,14 +51,37 @@ The command by default packs all tags and refs that are already
packed, and leaves other refs
alone. This is because branches are expected to be actively
developed and packing their tips does not help performance.
-This option causes branch tips to be packed as well. Useful for
-a repository with many branches of historical interests.
+This option causes all refs to be packed as well, with the exception
+of hidden refs, broken refs, and symbolic refs. Useful for a repository
+with many branches of historical interests.
--no-prune::
The command usually removes loose refs under `$GIT_DIR/refs`
hierarchy after packing them. This option tells it not to.
+--include <pattern>::
+
+Pack refs based on a `glob(7)` pattern. Repetitions of this option
+accumulate inclusion patterns. If a ref is both included in `--include` and
+`--exclude`, `--exclude` takes precedence. Using `--include` will preclude all
+tags from being included by default. Symbolic refs and broken refs will never
+be packed. When used with `--all`, it will be a noop. Use `--no-include` to clear
+and reset the list of patterns.
+
+--exclude <pattern>::
+
+Do not pack refs matching the given `glob(7)` pattern. Repetitions of this option
+accumulate exclusion patterns. Use `--no-exclude` to clear and reset the list of
+patterns. If a ref is already packed, including it with `--exclude` will not
+unpack it.
+
+When used with `--all`, pack only loose refs which do not match any of
+the provided `--exclude` patterns.
+
+When used with `--include`, refs provided to `--include`, minus refs that are
+provided to `--exclude` will be packed.
+
BUGS
----
diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt
index 71f608b..58cf621 100644
--- a/Documentation/git-show-branch.txt
+++ b/Documentation/git-show-branch.txt
@@ -74,8 +74,7 @@ OPTIONS
that is the common ancestor of all the branches. This
flag tells the command to go <n> more common commits
beyond that. When <n> is negative, display only the
- <reference>s given, without showing the commit ancestry
- tree.
+ <ref>s given, without showing the commit ancestry tree.
--list::
Synonym to `--more=-1`
@@ -88,8 +87,8 @@ OPTIONS
the case of three or more commits.
--independent::
- Among the <reference>s given, display only the ones that
- cannot be reached from any other <reference>.
+ Among the <ref>s given, display only the ones that cannot be
+ reached from any other <ref>.
--no-name::
Do not show naming strings for each commit.
@@ -132,10 +131,11 @@ are mutually exclusive.
OUTPUT
------
-Given N <references>, the first N lines are the one-line
-description from their commit message. The branch head that is
-pointed at by $GIT_DIR/HEAD is prefixed with an asterisk `*`
-character while other heads are prefixed with a `!` character.
+
+Given N <ref>s, the first N lines are the one-line description from
+their commit message. The branch head that is pointed at by
+$GIT_DIR/HEAD is prefixed with an asterisk `*` character while other
+heads are prefixed with a `!` character.
Following these N lines, one-line log for each commit is
displayed, indented N places. If a commit is on the I-th
diff --git a/Documentation/git-show-ref.txt b/Documentation/git-show-ref.txt
index d1d56f6..44c7387 100644
--- a/Documentation/git-show-ref.txt
+++ b/Documentation/git-show-ref.txt
@@ -23,7 +23,7 @@ particular ref exists.
By default, shows the tags, heads, and remote refs.
-The --exclude-existing form is a filter that does the inverse. It reads
+The `--exclude-existing` form is a filter that does the inverse. It reads
refs from stdin, one ref per line, and shows those that don't exist in
the local repository.
@@ -47,14 +47,14 @@ OPTIONS
-d::
--dereference::
- Dereference tags into object IDs as well. They will be shown with "{caret}{}"
+ Dereference tags into object IDs as well. They will be shown with `{caret}{}`
appended.
-s::
--hash[=<n>]::
- Only show the SHA-1 hash, not the reference name. When combined with
- --dereference the dereferenced tag will still be shown after the SHA-1.
+ Only show the OID, not the reference name. When combined with
+ `--dereference`, the dereferenced tag will still be shown after the OID.
--verify::
@@ -70,15 +70,15 @@ OPTIONS
-q::
--quiet::
- Do not print any results to stdout. When combined with `--verify` this
+ Do not print any results to stdout. When combined with `--verify`, this
can be used to silently check if a reference exists.
--exclude-existing[=<pattern>]::
- Make 'git show-ref' act as a filter that reads refs from stdin of the
- form "`^(?:<anything>\s)?<refname>(?:\^{})?$`"
+ Make `git show-ref` act as a filter that reads refs from stdin of the
+ form `^(?:<anything>\s)?<refname>(?:\^{})?$`
and performs the following actions on each:
- (1) strip "{caret}{}" at the end of line if any;
+ (1) strip `{caret}{}` at the end of line if any;
(2) ignore if pattern is provided and does not head-match refname;
(3) warn if refname is not a well-formed refname and skip;
(4) ignore if refname is a ref that exists in the local repository;
@@ -96,7 +96,13 @@ OPTIONS
OUTPUT
------
-The output is in the format: '<SHA-1 ID>' '<space>' '<reference name>'.
+The output is in the format:
+
+------------
+<oid> SP <ref> LF
+------------
+
+For example,
-----------------------------------------------------------------------------
$ git show-ref --head --dereference
@@ -110,7 +116,13 @@ $ git show-ref --head --dereference
...
-----------------------------------------------------------------------------
-When using --hash (and not --dereference) the output format is: '<SHA-1 ID>'
+When using `--hash` (and not `--dereference`), the output is in the format:
+
+------------
+<oid> LF
+------------
+
+For example,
-----------------------------------------------------------------------------
$ git show-ref --heads --hash
@@ -142,10 +154,10 @@ When using the `--verify` flag, the command requires an exact path:
will only match the exact branch called "master".
-If nothing matches, 'git show-ref' will return an error code of 1,
+If nothing matches, `git show-ref` will return an error code of 1,
and in the case of verification, it will show an error message.
-For scripting, you can ask it to be quiet with the "--quiet" flag, which
+For scripting, you can ask it to be quiet with the `--quiet` flag, which
allows you to do things like
-----------------------------------------------------------------------------
@@ -157,11 +169,11 @@ to check whether a particular branch exists or not (notice how we don't
actually want to show any results, and we want to use the full refname for it
in order to not trigger the problem with ambiguous partial matches).
-To show only tags, or only proper branch heads, use "--tags" and/or "--heads"
+To show only tags, or only proper branch heads, use `--tags` and/or `--heads`
respectively (using both means that it shows tags and heads, but not other
random references under the refs/ subdirectory).
-To do automatic tag object dereferencing, use the "-d" or "--dereference"
+To do automatic tag object dereferencing, use the `-d` or `--dereference`
flag, so you can do
-----------------------------------------------------------------------------
diff --git a/Documentation/git-sparse-checkout.txt b/Documentation/git-sparse-checkout.txt
index 53dc17a..529a8ed 100644
--- a/Documentation/git-sparse-checkout.txt
+++ b/Documentation/git-sparse-checkout.txt
@@ -286,7 +286,7 @@ patterns in non-cone mode has a number of shortcomings:
problem above? Also, if it suggests paths, what if the user has a
file or directory that begins with either a '!' or '#' or has a '*',
'\', '?', '[', or ']' in its name? And if it suggests paths, will
- it complete "/pro" to "/proc" (in the root filesytem) rather than to
+ it complete "/pro" to "/proc" (in the root filesystem) rather than to
"/progress.txt" in the current directory? (Note that users are
likely to want to start paths with a leading '/' in non-cone mode,
for the same reason that .gitignore files often have one.)
diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index f4bb611..06fb7f1 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -366,7 +366,7 @@ only the commit ends-up being in the stash and not on the current branch.
# ... hack hack hack ...
$ git add --patch foo # add unrelated changes to the index
$ git stash push --staged # save these changes to the stash
-# ... hack hack hack, finish curent changes ...
+# ... hack hack hack, finish current changes ...
$ git commit -m 'Massive' # commit fully tested changes
$ git switch fixup-branch # switch to another branch
$ git stash pop # to finish work on the saved changes
diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt
index 7f61c1e..d42efb3 100644
--- a/Documentation/git-tag.txt
+++ b/Documentation/git-tag.txt
@@ -381,6 +381,16 @@ $ GIT_COMMITTER_DATE="2006-10-02 10:31" git tag -s v1.0.1
include::date-formats.txt[]
+FILES
+-----
+
+`$GIT_DIR/TAG_EDITMSG`::
+ This file contains the message of an in-progress annotated
+ tag. If `git tag` exits due to an error before creating an
+ annotated tag then the tag message that has been provided by the
+ user in an editor session will be available in this file, but
+ may be overwritten by the next invocation of `git tag`.
+
NOTES
-----
diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 063d6ee..a4fbf5e 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -10,7 +10,7 @@ SYNOPSIS
--------
[verse]
'git worktree add' [-f] [--detach] [--checkout] [--lock [--reason <string>]]
- [-b <new-branch>] <path> [<commit-ish>]
+ [--orphan] [(-b | -B) <new-branch>] <path> [<commit-ish>]
'git worktree list' [-v | --porcelain [-z]]
'git worktree lock' [--reason <string>] <worktree>
'git worktree move' <worktree> <new-path>
@@ -95,6 +95,16 @@ exist, a new branch based on `HEAD` is automatically created as if
`-b <branch>` was given. If `<branch>` does exist, it will be checked out
in the new worktree, if it's not checked out anywhere else, otherwise the
command will refuse to create the worktree (unless `--force` is used).
++
+If `<commit-ish>` is omitted, neither `--detach`, or `--orphan` is
+used, and there are no valid local branches (or remote branches if
+`--guess-remote` is specified) then, as a convenience, the new worktree is
+associated with a new orphan branch named `<branch>` (after
+`$(basename <path>)` if neither `-b` or `-B` is used) as if `--orphan` was
+passed to the command. In the event the repository has a remote and
+`--guess-remote` is used, but no remote or local branches exist, then the
+command fails with a warning reminding the user to fetch from their remote
+first (or override by using `-f/--force`).
list::
@@ -222,6 +232,10 @@ This can also be set up as the default behaviour by using the
With `prune`, do not remove anything; just report what it would
remove.
+--orphan::
+ With `add`, make the new worktree and index empty, associating
+ the worktree with a new orphan/unborn branch named `<new-branch>`.
+
--porcelain::
With `list`, output in an easy-to-parse format for scripts.
This format will remain stable across Git versions and regardless of user
diff --git a/Documentation/gitcredentials.txt b/Documentation/gitcredentials.txt
index 100f045..65d652d 100644
--- a/Documentation/gitcredentials.txt
+++ b/Documentation/gitcredentials.txt
@@ -260,7 +260,7 @@ appended to its command line, which is one of:
`erase`::
- Remove a matching credential, if any, from the helper's storage.
+ Remove matching credentials, if any, from the helper's storage.
The details of the credential will be provided on the helper's stdin
stream. The exact format is the same as the input/output format of the
diff --git a/Documentation/gitweb.txt b/Documentation/gitweb.txt
index 7cee9d3..af6bf3c 100644
--- a/Documentation/gitweb.txt
+++ b/Documentation/gitweb.txt
@@ -503,7 +503,7 @@ repositories, you can configure Apache like this:
The above configuration expects your public repositories to live under
`/pub/git` and will serve them as `http://git.domain.org/dir-under-pub-git`,
-both as clonable Git URL and as browseable gitweb interface. If you then
+both as clonable Git URL and as browsable gitweb interface. If you then
start your linkgit:git-daemon[1] with `--base-path=/pub/git --export-all`
then you can even use the `git://` URL with exactly the same path.
diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt
index 9aa5805..6ea6c7c 100644
--- a/Documentation/revisions.txt
+++ b/Documentation/revisions.txt
@@ -30,10 +30,11 @@ characters and to avoid word splitting.
explicitly say 'heads/master' to tell Git which one you mean.
When ambiguous, a '<refname>' is disambiguated by taking the
first match in the following rules:
-
++
. If '$GIT_DIR/<refname>' exists, that is what you mean (this is usually
- useful only for `HEAD`, `FETCH_HEAD`, `ORIG_HEAD`, `MERGE_HEAD`
- and `CHERRY_PICK_HEAD`);
+ useful only for `HEAD`, `FETCH_HEAD`, `ORIG_HEAD`, `MERGE_HEAD`,
+ `REBASE_HEAD`, `REVERT_HEAD`, `CHERRY_PICK_HEAD`, `BISECT_HEAD`
+ and `AUTO_MERGE`);
. otherwise, 'refs/<refname>' if it exists;
@@ -44,19 +45,38 @@ characters and to avoid word splitting.
. otherwise, 'refs/remotes/<refname>' if it exists;
. otherwise, 'refs/remotes/<refname>/HEAD' if it exists.
+
+
-`HEAD` names the commit on which you based the changes in the working tree.
-`FETCH_HEAD` records the branch which you fetched from a remote repository
-with your last `git fetch` invocation.
-`ORIG_HEAD` is created by commands that move your `HEAD` in a drastic
-way (`git am`, `git merge`, `git rebase`, `git reset`),
-to record the position of the `HEAD` before their operation, so that
-you can easily change the tip of the branch back to the state before you ran
-them.
-`MERGE_HEAD` records the commit(s) which you are merging into your branch
-when you run `git merge`.
-`CHERRY_PICK_HEAD` records the commit which you are cherry-picking
-when you run `git cherry-pick`.
+ `HEAD`:::
+ names the commit on which you based the changes in the working tree.
+ `FETCH_HEAD`:::
+ records the branch which you fetched from a remote repository with
+ your last `git fetch` invocation.
+ `ORIG_HEAD`:::
+ is created by commands that move your `HEAD` in a drastic way (`git
+ am`, `git merge`, `git rebase`, `git reset`), to record the position
+ of the `HEAD` before their operation, so that you can easily change
+ the tip of the branch back to the state before you ran them.
+ `MERGE_HEAD`:::
+ records the commit(s) which you are merging into your branch when you
+ run `git merge`.
+ `REBASE_HEAD`:::
+ during a rebase, records the commit at which the operation is
+ currently stopped, either because of conflicts or an `edit` command in
+ an interactive rebase.
+ `REVERT_HEAD`:::
+ records the commit which you are reverting when you run `git revert`.
+ `CHERRY_PICK_HEAD`:::
+ records the commit which you are cherry-picking when you run `git
+ cherry-pick`.
+ `BISECT_HEAD`:::
+ records the current commit to be tested when you run `git bisect
+ --no-checkout`.
+ `AUTO_MERGE`:::
+ records a tree object corresponding to the state the
+ 'ort' merge strategy wrote to the working tree when a merge operation
+ resulted in conflicts.
+
+
Note that any of the 'refs/*' cases above may come either from
the `$GIT_DIR/refs` directory or from the `$GIT_DIR/packed-refs` file.
diff --git a/Documentation/technical/remembering-renames.txt b/Documentation/technical/remembering-renames.txt
index 1e34d91..73f4176 100644
--- a/Documentation/technical/remembering-renames.txt
+++ b/Documentation/technical/remembering-renames.txt
@@ -664,7 +664,7 @@ skip-irrelevant-renames optimization means we sometimes don't detect
renames for any files within a directory that was renamed, in which
case we will not have been able to detect any rename for the directory
itself. In such a case, we do not know whether the directory was
-renamed; we want to be careful to avoid cacheing some kind of "this
+renamed; we want to be careful to avoid caching some kind of "this
directory was not renamed" statement. If we did, then a subsequent
commit being rebased could add a file to the old directory, and the
user would expect it to end up in the correct directory -- something
diff --git a/Documentation/urls-remotes.txt b/Documentation/urls-remotes.txt
index e410912..ae8c2db 100644
--- a/Documentation/urls-remotes.txt
+++ b/Documentation/urls-remotes.txt
@@ -35,7 +35,7 @@ config file would appear like this:
The `<pushurl>` is used for pushes only. It is optional and defaults
to `<URL>`. Pushing to a remote affects all defined pushurls or to all
defined urls if no pushurls are defined. Fetch, however, will only
-fetch from the first defined url if muliple urls are defined.
+fetch from the first defined url if multiple urls are defined.
Named file in `$GIT_DIR/remotes`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
index dc9c6a6..aa38513 100644
--- a/Documentation/user-manual.txt
+++ b/Documentation/user-manual.txt
@@ -1343,6 +1343,33 @@ $ git diff -3 file.txt # diff against stage 3
$ git diff --theirs file.txt # same as the above.
-------------------------------------------------
+When using the 'ort' merge strategy (the default), before updating the working
+tree with the result of the merge, Git writes a special ref named AUTO_MERGE
+reflecting the state of the tree it is about to write. Conflicted paths with
+textual conflicts that could not be automatically merged are written to this
+tree with conflict markers, just as in the working tree. AUTO_MERGE can thus be
+used with linkgit:git-diff[1] to show the changes you've made so far to resolve
+conflicts. Using the same example as above, after resolving the conflict we
+get:
+
+-------------------------------------------------
+$ git diff AUTO_MERGE
+diff --git a/file.txt b/file.txt
+index cd10406..8bf5ae7 100644
+--- a/file.txt
++++ b/file.txt
+@@ -1,5 +1 @@
+-<<<<<<< HEAD:file.txt
+-Hello world
+-=======
+-Goodbye
+->>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt
++Goodbye world
+-------------------------------------------------
+
+Notice that the diff shows we deleted the conflict markers and both versions of
+the content line, and wrote "Goodbye world" instead.
+
The linkgit:git-log[1] and linkgit:gitk[1] commands also provide special help
for merges:
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index b37f72a..07e72c2 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,7 +1,7 @@
#!/bin/sh
GVF=GIT-VERSION-FILE
-DEF_VER=v2.41.0
+DEF_VER=v2.41.GIT
LF='
'
diff --git a/RelNotes b/RelNotes
index 4da73c9..0527f30 120000
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes/2.41.0.txt \ No newline at end of file
+Documentation/RelNotes/2.42.0.txt \ No newline at end of file
diff --git a/advice.c b/advice.c
index d623243..e5a9bb9 100644
--- a/advice.c
+++ b/advice.c
@@ -78,6 +78,7 @@ static struct {
[ADVICE_SUBMODULES_NOT_UPDATED] = { "submodulesNotUpdated", 1 },
[ADVICE_UPDATE_SPARSE_PATH] = { "updateSparsePath", 1 },
[ADVICE_WAITING_FOR_EDITOR] = { "waitingForEditor", 1 },
+ [ADVICE_WORKTREE_ADD_ORPHAN] = { "worktreeAddOrphan", 1 },
};
static const char turn_off_instructions[] =
diff --git a/advice.h b/advice.h
index 0f58416..2affbe1 100644
--- a/advice.h
+++ b/advice.h
@@ -49,6 +49,7 @@ struct string_list;
ADVICE_UPDATE_SPARSE_PATH,
ADVICE_WAITING_FOR_EDITOR,
ADVICE_SKIPPED_CHERRY_PICKS,
+ ADVICE_WORKTREE_ADD_ORPHAN,
};
int git_default_advice_config(const char *var, const char *value);
diff --git a/builtin/add.c b/builtin/add.c
index 76cc026..6137e7b 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -365,7 +365,7 @@ static int add_config(const char *var, const char *value, void *cb)
return 0;
}
- return git_default_config(var, value, cb);
+ return git_color_default_config(var, value, cb);
}
static const char embedded_advice[] = N_(
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 0bafc14..7ff56d5 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -42,7 +42,8 @@ struct batch_options {
int all_objects;
int unordered;
int transform_mode; /* may be 'w' or 'c' for --filters or --textconv */
- int nul_terminated;
+ char input_delim;
+ char output_delim;
const char *format;
};
@@ -437,11 +438,12 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
}
}
-static void print_default_format(struct strbuf *scratch, struct expand_data *data)
+static void print_default_format(struct strbuf *scratch, struct expand_data *data,
+ struct batch_options *opt)
{
- strbuf_addf(scratch, "%s %s %"PRIuMAX"\n", oid_to_hex(&data->oid),
+ strbuf_addf(scratch, "%s %s %"PRIuMAX"%c", oid_to_hex(&data->oid),
type_name(data->type),
- (uintmax_t)data->size);
+ (uintmax_t)data->size, opt->output_delim);
}
/*
@@ -470,8 +472,8 @@ static void batch_object_write(const char *obj_name,
&data->oid, &data->info,
OBJECT_INFO_LOOKUP_REPLACE);
if (ret < 0) {
- printf("%s missing\n",
- obj_name ? obj_name : oid_to_hex(&data->oid));
+ printf("%s missing%c",
+ obj_name ? obj_name : oid_to_hex(&data->oid), opt->output_delim);
fflush(stdout);
return;
}
@@ -492,17 +494,17 @@ static void batch_object_write(const char *obj_name,
strbuf_reset(scratch);
if (!opt->format) {
- print_default_format(scratch, data);
+ print_default_format(scratch, data, opt);
} else {
strbuf_expand(scratch, opt->format, expand_format, data);
- strbuf_addch(scratch, '\n');
+ strbuf_addch(scratch, opt->output_delim);
}
batch_write(opt, scratch->buf, scratch->len);
if (opt->batch_mode == BATCH_MODE_CONTENTS) {
print_object_or_die(opt, data);
- batch_write(opt, "\n", 1);
+ batch_write(opt, &opt->output_delim, 1);
}
}
@@ -520,22 +522,25 @@ static void batch_one_object(const char *obj_name,
if (result != FOUND) {
switch (result) {
case MISSING_OBJECT:
- printf("%s missing\n", obj_name);
+ printf("%s missing%c", obj_name, opt->output_delim);
break;
case SHORT_NAME_AMBIGUOUS:
- printf("%s ambiguous\n", obj_name);
+ printf("%s ambiguous%c", obj_name, opt->output_delim);
break;
case DANGLING_SYMLINK:
- printf("dangling %"PRIuMAX"\n%s\n",
- (uintmax_t)strlen(obj_name), obj_name);
+ printf("dangling %"PRIuMAX"%c%s%c",
+ (uintmax_t)strlen(obj_name),
+ opt->output_delim, obj_name, opt->output_delim);
break;
case SYMLINK_LOOP:
- printf("loop %"PRIuMAX"\n%s\n",
- (uintmax_t)strlen(obj_name), obj_name);
+ printf("loop %"PRIuMAX"%c%s%c",
+ (uintmax_t)strlen(obj_name),
+ opt->output_delim, obj_name, opt->output_delim);
break;
case NOT_DIR:
- printf("notdir %"PRIuMAX"\n%s\n",
- (uintmax_t)strlen(obj_name), obj_name);
+ printf("notdir %"PRIuMAX"%c%s%c",
+ (uintmax_t)strlen(obj_name),
+ opt->output_delim, obj_name, opt->output_delim);
break;
default:
BUG("unknown get_sha1_with_context result %d\n",
@@ -547,9 +552,9 @@ static void batch_one_object(const char *obj_name,
}
if (ctx.mode == 0) {
- printf("symlink %"PRIuMAX"\n%s\n",
+ printf("symlink %"PRIuMAX"%c%s%c",
(uintmax_t)ctx.symlink_path.len,
- ctx.symlink_path.buf);
+ opt->output_delim, ctx.symlink_path.buf, opt->output_delim);
fflush(stdout);
return;
}
@@ -694,20 +699,12 @@ static void batch_objects_command(struct batch_options *opt,
struct queued_cmd *queued_cmd = NULL;
size_t alloc = 0, nr = 0;
- while (1) {
- int i, ret;
+ while (strbuf_getdelim_strip_crlf(&input, stdin, opt->input_delim) != EOF) {
+ int i;
const struct parse_cmd *cmd = NULL;
const char *p = NULL, *cmd_end;
struct queued_cmd call = {0};
- if (opt->nul_terminated)
- ret = strbuf_getline_nul(&input, stdin);
- else
- ret = strbuf_getline(&input, stdin);
-
- if (ret)
- break;
-
if (!input.len)
die(_("empty command in input"));
if (isspace(*input.buf))
@@ -805,7 +802,7 @@ static int batch_objects(struct batch_options *opt)
if (repo_has_promisor_remote(the_repository))
warning("This repository uses promisor remotes. Some objects may not be loaded.");
- read_replace_refs = 0;
+ disable_replace_refs();
cb.opt = opt;
cb.expand = &data;
@@ -851,16 +848,7 @@ static int batch_objects(struct batch_options *opt)
goto cleanup;
}
- while (1) {
- int ret;
- if (opt->nul_terminated)
- ret = strbuf_getline_nul(&input, stdin);
- else
- ret = strbuf_getline(&input, stdin);
-
- if (ret == EOF)
- break;
-
+ while (strbuf_getdelim_strip_crlf(&input, stdin, opt->input_delim) != EOF) {
if (data.split_on_whitespace) {
/*
* Split at first whitespace, tying off the beginning
@@ -929,6 +917,8 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
const char *exp_type = NULL, *obj_name = NULL;
struct batch_options batch = {0};
int unknown_type = 0;
+ int input_nul_terminated = 0;
+ int nul_terminated = 0;
const char * const usage[] = {
N_("git cat-file <type> <object>"),
@@ -936,7 +926,7 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
N_("git cat-file (-t | -s) [--allow-unknown-type] <object>"),
N_("git cat-file (--batch | --batch-check | --batch-command) [--batch-all-objects]\n"
" [--buffer] [--follow-symlinks] [--unordered]\n"
- " [--textconv | --filters] [-z]"),
+ " [--textconv | --filters] [-Z]"),
N_("git cat-file (--textconv | --filters)\n"
" [<rev>:<path|tree-ish> | --path=<path|tree-ish> <rev>]"),
NULL
@@ -965,7 +955,9 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
N_("like --batch, but don't emit <contents>"),
PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
batch_option_callback),
- OPT_BOOL('z', NULL, &batch.nul_terminated, N_("stdin is NUL-terminated")),
+ OPT_BOOL_F('z', NULL, &input_nul_terminated, N_("stdin is NUL-terminated"),
+ PARSE_OPT_HIDDEN),
+ OPT_BOOL('Z', NULL, &nul_terminated, N_("stdin and stdout is NUL-terminated")),
OPT_CALLBACK_F(0, "batch-command", &batch, N_("format"),
N_("read commands from stdin"),
PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
@@ -1024,9 +1016,18 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
else if (batch.all_objects)
usage_msg_optf(_("'%s' requires a batch mode"), usage, options,
"--batch-all-objects");
- else if (batch.nul_terminated)
+ else if (input_nul_terminated)
usage_msg_optf(_("'%s' requires a batch mode"), usage, options,
"-z");
+ else if (nul_terminated)
+ usage_msg_optf(_("'%s' requires a batch mode"), usage, options,
+ "-Z");
+
+ batch.input_delim = batch.output_delim = '\n';
+ if (input_nul_terminated)
+ batch.input_delim = '\0';
+ if (nul_terminated)
+ batch.input_delim = batch.output_delim = '\0';
/* Batch defaults */
if (batch.buffer_output < 0)
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index a3d00fa..dd732b3 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -324,7 +324,7 @@ int cmd_commit_graph(int argc, const char **argv, const char *prefix)
git_config(git_default_config, NULL);
- read_replace_refs = 0;
+ disable_replace_refs();
save_commit_buffer = 0;
argc = parse_options(argc, argv, prefix, options,
diff --git a/builtin/commit.c b/builtin/commit.c
index e67c4be..9ab57ea 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -763,7 +763,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
struct commit *c;
c = lookup_commit_reference_by_name(squash_message);
if (!c)
- die(_("could not lookup commit %s"), squash_message);
+ die(_("could not lookup commit '%s'"), squash_message);
ctx.output_encoding = get_commit_output_encoding();
repo_format_commit_message(the_repository, c,
"squash! %s\n\n", &sb,
@@ -798,7 +798,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
char *fmt;
commit = lookup_commit_reference_by_name(fixup_commit);
if (!commit)
- die(_("could not lookup commit %s"), fixup_commit);
+ die(_("could not lookup commit '%s'"), fixup_commit);
ctx.output_encoding = get_commit_output_encoding();
fmt = xstrfmt("%s! %%s\n\n", fixup_prefix);
repo_format_commit_message(the_repository, commit, fmt, &sb,
@@ -1189,7 +1189,7 @@ static const char *read_commit_message(const char *name)
commit = lookup_commit_reference_by_name(name);
if (!commit)
- die(_("could not lookup commit %s"), name);
+ die(_("could not lookup commit '%s'"), name);
out_enc = get_commit_output_encoding();
return repo_logmsg_reencode(the_repository, commit, NULL, out_enc);
}
diff --git a/builtin/config.c b/builtin/config.c
index ff2fe8e..d40fddb 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -5,6 +5,7 @@
#include "color.h"
#include "editor.h"
#include "environment.h"
+#include "repository.h"
#include "gettext.h"
#include "ident.h"
#include "parse-options.h"
@@ -375,7 +376,8 @@ static int get_value(const char *key_, const char *regex_, unsigned flags)
}
config_with_options(collect_config, &values,
- &given_config_source, &config_options);
+ &given_config_source, the_repository,
+ &config_options);
if (!values.nr && default_value) {
struct strbuf *item;
@@ -486,7 +488,8 @@ static void get_color(const char *var, const char *def_color)
get_color_found = 0;
parsed_color[0] = '\0';
config_with_options(git_get_color_config, NULL,
- &given_config_source, &config_options);
+ &given_config_source, the_repository,
+ &config_options);
if (!get_color_found && def_color) {
if (color_parse(def_color, parsed_color) < 0)
@@ -518,7 +521,8 @@ static int get_colorbool(const char *var, int print)
get_diff_color_found = -1;
get_color_ui_found = -1;
config_with_options(git_get_colorbool_config, NULL,
- &given_config_source, &config_options);
+ &given_config_source, the_repository,
+ &config_options);
if (get_colorbool_found < 0) {
if (!strcmp(get_colorbool_slot, "color.diff"))
@@ -607,7 +611,8 @@ static int get_urlmatch(const char *var, const char *url)
}
config_with_options(urlmatch_config_entry, &config,
- &given_config_source, &config_options);
+ &given_config_source, the_repository,
+ &config_options);
ret = !values.nr;
@@ -713,7 +718,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
given_config_source.scope = CONFIG_SCOPE_LOCAL;
} else if (use_worktree_config) {
struct worktree **worktrees = get_worktrees();
- if (repository_format_worktree_config)
+ if (the_repository->repository_format_worktree_config)
given_config_source.file = git_pathdup("config.worktree");
else if (worktrees[0] && worktrees[1])
die(_("--worktree cannot be used with multiple "
@@ -827,7 +832,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
if (actions == ACTION_LIST) {
check_argc(argc, 0, 0);
if (config_with_options(show_all_config, NULL,
- &given_config_source,
+ &given_config_source, the_repository,
&config_options) < 0) {
if (given_config_source.file)
die_errno(_("unable to read config file '%s'"),
diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
index 756c5f0..dc1cf2d 100644
--- a/builtin/credential-cache--daemon.c
+++ b/builtin/credential-cache--daemon.c
@@ -38,19 +38,22 @@ static struct credential_cache_entry *lookup_credential(const struct credential
int i;
for (i = 0; i < entries_nr; i++) {
struct credential *e = &entries[i].item;
- if (credential_match(c, e))
+ if (credential_match(c, e, 0))
return &entries[i];
}
return NULL;
}
-static void remove_credential(const struct credential *c)
+static void remove_credential(const struct credential *c, int match_password)
{
struct credential_cache_entry *e;
- e = lookup_credential(c);
- if (e)
- e->expiration = 0;
+ int i;
+ for (i = 0; i < entries_nr; i++) {
+ e = &entries[i];
+ if (credential_match(c, &e->item, match_password))
+ e->expiration = 0;
+ }
}
static timestamp_t check_expirations(void)
@@ -151,14 +154,14 @@ static void serve_one_client(FILE *in, FILE *out)
exit(0);
}
else if (!strcmp(action.buf, "erase"))
- remove_credential(&c);
+ remove_credential(&c, 1);
else if (!strcmp(action.buf, "store")) {
if (timeout < 0)
warning("cache client didn't specify a timeout");
else if (!c.username || !c.password)
warning("cache client gave us a partial credential");
else {
- remove_credential(&c);
+ remove_credential(&c, 0);
cache_credential(&c, timeout);
}
}
diff --git a/builtin/credential-store.c b/builtin/credential-store.c
index 30c6ccf..0937230 100644
--- a/builtin/credential-store.c
+++ b/builtin/credential-store.c
@@ -13,7 +13,8 @@ static struct lock_file credential_lock;
static int parse_credential_file(const char *fn,
struct credential *c,
void (*match_cb)(struct credential *),
- void (*other_cb)(struct strbuf *))
+ void (*other_cb)(struct strbuf *),
+ int match_password)
{
FILE *fh;
struct strbuf line = STRBUF_INIT;
@@ -30,7 +31,7 @@ static int parse_credential_file(const char *fn,
while (strbuf_getline_lf(&line, fh) != EOF) {
if (!credential_from_url_gently(&entry, line.buf, 1) &&
entry.username && entry.password &&
- credential_match(c, &entry)) {
+ credential_match(c, &entry, match_password)) {
found_credential = 1;
if (match_cb) {
match_cb(&entry);
@@ -60,7 +61,7 @@ static void print_line(struct strbuf *buf)
}
static void rewrite_credential_file(const char *fn, struct credential *c,
- struct strbuf *extra)
+ struct strbuf *extra, int match_password)
{
int timeout_ms = 1000;
@@ -69,7 +70,7 @@ static void rewrite_credential_file(const char *fn, struct credential *c,
die_errno(_("unable to get credential storage lock in %d ms"), timeout_ms);
if (extra)
print_line(extra);
- parse_credential_file(fn, c, NULL, print_line);
+ parse_credential_file(fn, c, NULL, print_line, match_password);
if (commit_lock_file(&credential_lock) < 0)
die_errno("unable to write credential store");
}
@@ -91,7 +92,7 @@ static void store_credential_file(const char *fn, struct credential *c)
is_rfc3986_reserved_or_unreserved);
}
- rewrite_credential_file(fn, c, &buf);
+ rewrite_credential_file(fn, c, &buf, 0);
strbuf_release(&buf);
}
@@ -138,7 +139,7 @@ static void remove_credential(const struct string_list *fns, struct credential *
return;
for_each_string_list_item(fn, fns)
if (!access(fn->string, F_OK))
- rewrite_credential_file(fn->string, c, NULL);
+ rewrite_credential_file(fn->string, c, NULL, 1);
}
static void lookup_credential(const struct string_list *fns, struct credential *c)
@@ -146,7 +147,7 @@ static void lookup_credential(const struct string_list *fns, struct credential *
struct string_list_item *fn;
for_each_string_list_item(fn, fns)
- if (parse_credential_file(fn->string, c, print_entry, NULL))
+ if (parse_credential_file(fn->string, c, print_entry, NULL, 0))
return; /* Found credential */
}
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 0b02c62..c054031 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -122,6 +122,10 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
usage(diff_tree_usage);
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
+
+ prepare_repo_settings(the_repository);
+ the_repository->settings.command_requires_full_index = 0;
+
repo_init_revisions(the_repository, opt, prefix);
if (repo_read_index(the_repository) < 0)
die(_("index file corrupt"));
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 849a9be..e387104 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -58,7 +58,6 @@ enum {
};
enum display_format {
- DISPLAY_FORMAT_UNKNOWN = 0,
DISPLAY_FORMAT_FULL,
DISPLAY_FORMAT_COMPACT,
DISPLAY_FORMAT_PORCELAIN,
@@ -74,14 +73,11 @@ struct display_state {
int url_len, shown_url;
};
-static int fetch_prune_config = -1; /* unspecified */
-static int fetch_show_forced_updates = 1;
static uint64_t forced_updates_ms = 0;
static int prefetch = 0;
static int prune = -1; /* unspecified */
#define PRUNE_BY_DEFAULT 0 /* do we prune by default? */
-static int fetch_prune_tags_config = -1; /* unspecified */
static int prune_tags = -1; /* unspecified */
#define PRUNE_TAGS_BY_DEFAULT 0 /* do we prune tags by default? */
@@ -90,8 +86,6 @@ static int write_fetch_head = 1;
static int verbosity, deepen_relative, set_upstream, refetch;
static int progress = -1;
static int tags = TAGS_DEFAULT, update_shallow, deepen;
-static int submodule_fetch_jobs_config = -1;
-static int fetch_parallel_config = 1;
static int atomic_fetch;
static enum transport_family family;
static const char *depth;
@@ -101,7 +95,6 @@ static struct string_list deepen_not = STRING_LIST_INIT_NODUP;
static struct strbuf default_rla = STRBUF_INIT;
static struct transport *gtransport;
static struct transport *gsecondary;
-static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
static struct refspec refmap = REFSPEC_INIT_FETCH;
static struct list_objects_filter_options filter_options = LIST_OBJECTS_FILTER_INIT;
static struct string_list server_options = STRING_LIST_INIT_DUP;
@@ -109,6 +102,12 @@ static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
struct fetch_config {
enum display_format display_format;
+ int prune;
+ int prune_tags;
+ int show_forced_updates;
+ int recurse_submodules;
+ int parallel;
+ int submodule_fetch_jobs;
};
static int git_fetch_config(const char *k, const char *v, void *cb)
@@ -116,40 +115,40 @@ static int git_fetch_config(const char *k, const char *v, void *cb)
struct fetch_config *fetch_config = cb;
if (!strcmp(k, "fetch.prune")) {
- fetch_prune_config = git_config_bool(k, v);
+ fetch_config->prune = git_config_bool(k, v);
return 0;
}
if (!strcmp(k, "fetch.prunetags")) {
- fetch_prune_tags_config = git_config_bool(k, v);
+ fetch_config->prune_tags = git_config_bool(k, v);
return 0;
}
if (!strcmp(k, "fetch.showforcedupdates")) {
- fetch_show_forced_updates = git_config_bool(k, v);
+ fetch_config->show_forced_updates = git_config_bool(k, v);
return 0;
}
if (!strcmp(k, "submodule.recurse")) {
int r = git_config_bool(k, v) ?
RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF;
- recurse_submodules = r;
+ fetch_config->recurse_submodules = r;
}
if (!strcmp(k, "submodule.fetchjobs")) {
- submodule_fetch_jobs_config = parse_submodule_fetchjobs(k, v);
+ fetch_config->submodule_fetch_jobs = parse_submodule_fetchjobs(k, v);
return 0;
} else if (!strcmp(k, "fetch.recursesubmodules")) {
- recurse_submodules = parse_fetch_recurse_submodules_arg(k, v);
+ fetch_config->recurse_submodules = parse_fetch_recurse_submodules_arg(k, v);
return 0;
}
if (!strcmp(k, "fetch.parallel")) {
- fetch_parallel_config = git_config_int(k, v);
- if (fetch_parallel_config < 0)
+ fetch_config->parallel = git_config_int(k, v);
+ if (fetch_config->parallel < 0)
die(_("fetch.parallel cannot be negative"));
- if (!fetch_parallel_config)
- fetch_parallel_config = online_cpus();
+ if (!fetch_config->parallel)
+ fetch_config->parallel = online_cpus();
return 0;
}
@@ -892,7 +891,8 @@ static int update_local_ref(struct ref *ref,
struct ref_transaction *transaction,
struct display_state *display_state,
const struct ref *remote_ref,
- int summary_width)
+ int summary_width,
+ const struct fetch_config *config)
{
struct commit *current = NULL, *updated;
int fast_forward = 0;
@@ -954,11 +954,10 @@ static int update_local_ref(struct ref *ref,
* Base this on the remote's ref name, as it's
* more likely to follow a standard layout.
*/
- const char *name = remote_ref ? remote_ref->name : "";
- if (starts_with(name, "refs/tags/")) {
+ if (starts_with(remote_ref->name, "refs/tags/")) {
msg = "storing tag";
what = _("[new tag]");
- } else if (starts_with(name, "refs/heads/")) {
+ } else if (starts_with(remote_ref->name, "refs/heads/")) {
msg = "storing head";
what = _("[new branch]");
} else {
@@ -974,7 +973,7 @@ static int update_local_ref(struct ref *ref,
return r;
}
- if (fetch_show_forced_updates) {
+ if (config->show_forced_updates) {
uint64_t t_before = getnanotime();
fast_forward = repo_in_merge_bases(the_repository, current,
updated);
@@ -1127,7 +1126,8 @@ static int store_updated_refs(struct display_state *display_state,
const char *remote_name,
int connectivity_checked,
struct ref_transaction *transaction, struct ref *ref_map,
- struct fetch_head *fetch_head)
+ struct fetch_head *fetch_head,
+ const struct fetch_config *config)
{
int rc = 0;
struct strbuf note = STRBUF_INIT;
@@ -1210,7 +1210,7 @@ static int store_updated_refs(struct display_state *display_state,
ref->force = rm->peer_ref->force;
}
- if (recurse_submodules != RECURSE_SUBMODULES_OFF &&
+ if (config->recurse_submodules != RECURSE_SUBMODULES_OFF &&
(!rm->peer_ref || !oideq(&ref->old_oid, &ref->new_oid))) {
check_for_new_submodule_commits(&rm->old_oid);
}
@@ -1243,7 +1243,7 @@ static int store_updated_refs(struct display_state *display_state,
if (ref) {
rc |= update_local_ref(ref, transaction, display_state,
- rm, summary_width);
+ rm, summary_width, config);
free(ref);
} else if (write_fetch_head || dry_run) {
/*
@@ -1267,7 +1267,7 @@ static int store_updated_refs(struct display_state *display_state,
"branches"), remote_name);
if (advice_enabled(ADVICE_FETCH_SHOW_FORCED_UPDATES)) {
- if (!fetch_show_forced_updates) {
+ if (!config->show_forced_updates) {
warning(_(warn_show_forced_updates));
} else if (forced_updates_ms > FORCED_UPDATES_DELAY_WARNING_IN_MS) {
warning(_(warn_time_show_forced_updates),
@@ -1328,7 +1328,8 @@ static int fetch_and_consume_refs(struct display_state *display_state,
struct transport *transport,
struct ref_transaction *transaction,
struct ref *ref_map,
- struct fetch_head *fetch_head)
+ struct fetch_head *fetch_head,
+ const struct fetch_config *config)
{
int connectivity_checked = 1;
int ret;
@@ -1351,7 +1352,7 @@ static int fetch_and_consume_refs(struct display_state *display_state,
trace2_region_enter("fetch", "consume_refs", the_repository);
ret = store_updated_refs(display_state, transport->remote->name,
connectivity_checked, transaction, ref_map,
- fetch_head);
+ fetch_head, config);
trace2_region_leave("fetch", "consume_refs", the_repository);
out:
@@ -1522,7 +1523,8 @@ static int backfill_tags(struct display_state *display_state,
struct transport *transport,
struct ref_transaction *transaction,
struct ref *ref_map,
- struct fetch_head *fetch_head)
+ struct fetch_head *fetch_head,
+ const struct fetch_config *config)
{
int retcode, cannot_reuse;
@@ -1543,7 +1545,8 @@ static int backfill_tags(struct display_state *display_state,
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL);
transport_set_option(transport, TRANS_OPT_DEPTH, "0");
transport_set_option(transport, TRANS_OPT_DEEPEN_RELATIVE, NULL);
- retcode = fetch_and_consume_refs(display_state, transport, transaction, ref_map, fetch_head);
+ retcode = fetch_and_consume_refs(display_state, transport, transaction, ref_map,
+ fetch_head, config);
if (gsecondary) {
transport_disconnect(gsecondary);
@@ -1555,7 +1558,7 @@ static int backfill_tags(struct display_state *display_state,
static int do_fetch(struct transport *transport,
struct refspec *rs,
- enum display_format display_format)
+ const struct fetch_config *config)
{
struct ref_transaction *transaction = NULL;
struct ref *ref_map = NULL;
@@ -1641,7 +1644,8 @@ static int do_fetch(struct transport *transport,
if (retcode)
goto cleanup;
- display_state_init(&display_state, ref_map, transport->url, display_format);
+ display_state_init(&display_state, ref_map, transport->url,
+ config->display_format);
if (atomic_fetch) {
transaction = ref_transaction_begin(&err);
@@ -1669,7 +1673,8 @@ static int do_fetch(struct transport *transport,
retcode = 1;
}
- if (fetch_and_consume_refs(&display_state, transport, transaction, ref_map, &fetch_head)) {
+ if (fetch_and_consume_refs(&display_state, transport, transaction, ref_map,
+ &fetch_head, config)) {
retcode = 1;
goto cleanup;
}
@@ -1692,7 +1697,7 @@ static int do_fetch(struct transport *transport,
* the transaction and don't commit anything.
*/
if (backfill_tags(&display_state, transport, transaction, tags_ref_map,
- &fetch_head))
+ &fetch_head, config))
retcode = 1;
}
@@ -1830,7 +1835,7 @@ static int add_remote_or_group(const char *name, struct string_list *list)
}
static void add_options_to_argv(struct strvec *argv,
- enum display_format format)
+ const struct fetch_config *config)
{
if (dry_run)
strvec_push(argv, "--dry-run");
@@ -1844,11 +1849,11 @@ static void add_options_to_argv(struct strvec *argv,
strvec_push(argv, "--force");
if (keep)
strvec_push(argv, "--keep");
- if (recurse_submodules == RECURSE_SUBMODULES_ON)
+ if (config->recurse_submodules == RECURSE_SUBMODULES_ON)
strvec_push(argv, "--recurse-submodules");
- else if (recurse_submodules == RECURSE_SUBMODULES_OFF)
+ else if (config->recurse_submodules == RECURSE_SUBMODULES_OFF)
strvec_push(argv, "--no-recurse-submodules");
- else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
+ else if (config->recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
strvec_push(argv, "--recurse-submodules=on-demand");
if (tags == TAGS_SET)
strvec_push(argv, "--tags");
@@ -1866,7 +1871,7 @@ static void add_options_to_argv(struct strvec *argv,
strvec_push(argv, "--ipv6");
if (!write_fetch_head)
strvec_push(argv, "--no-write-fetch-head");
- if (format == DISPLAY_FORMAT_PORCELAIN)
+ if (config->display_format == DISPLAY_FORMAT_PORCELAIN)
strvec_pushf(argv, "--porcelain");
}
@@ -1876,7 +1881,7 @@ struct parallel_fetch_state {
const char **argv;
struct string_list *remotes;
int next, result;
- enum display_format format;
+ const struct fetch_config *config;
};
static int fetch_next_remote(struct child_process *cp,
@@ -1896,7 +1901,7 @@ static int fetch_next_remote(struct child_process *cp,
strvec_push(&cp->args, remote);
cp->git_cmd = 1;
- if (verbosity >= 0 && state->format != DISPLAY_FORMAT_PORCELAIN)
+ if (verbosity >= 0 && state->config->display_format != DISPLAY_FORMAT_PORCELAIN)
printf(_("Fetching %s\n"), remote);
return 1;
@@ -1929,7 +1934,7 @@ static int fetch_finished(int result, struct strbuf *out,
}
static int fetch_multiple(struct string_list *list, int max_children,
- enum display_format format)
+ const struct fetch_config *config)
{
int i, result = 0;
struct strvec argv = STRVEC_INIT;
@@ -1947,10 +1952,10 @@ static int fetch_multiple(struct string_list *list, int max_children,
strvec_pushl(&argv, "-c", "fetch.bundleURI=",
"fetch", "--append", "--no-auto-gc",
"--no-write-commit-graph", NULL);
- add_options_to_argv(&argv, format);
+ add_options_to_argv(&argv, config);
if (max_children != 1 && list->nr != 1) {
- struct parallel_fetch_state state = { argv.v, list, 0, 0, format };
+ struct parallel_fetch_state state = { argv.v, list, 0, 0, config };
const struct run_process_parallel_opts opts = {
.tr2_category = "fetch",
.tr2_label = "parallel/fetch",
@@ -1974,7 +1979,7 @@ static int fetch_multiple(struct string_list *list, int max_children,
strvec_pushv(&cmd.args, argv.v);
strvec_push(&cmd.args, name);
- if (verbosity >= 0 && format != DISPLAY_FORMAT_PORCELAIN)
+ if (verbosity >= 0 && config->display_format != DISPLAY_FORMAT_PORCELAIN)
printf(_("Fetching %s\n"), name);
cmd.git_cmd = 1;
if (run_command(&cmd)) {
@@ -2030,7 +2035,7 @@ static inline void fetch_one_setup_partial(struct remote *remote)
static int fetch_one(struct remote *remote, int argc, const char **argv,
int prune_tags_ok, int use_stdin_refspecs,
- enum display_format display_format)
+ const struct fetch_config *config)
{
struct refspec rs = REFSPEC_INIT_FETCH;
int i;
@@ -2048,8 +2053,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
/* no command line request */
if (0 <= remote->prune)
prune = remote->prune;
- else if (0 <= fetch_prune_config)
- prune = fetch_prune_config;
+ else if (0 <= config->prune)
+ prune = config->prune;
else
prune = PRUNE_BY_DEFAULT;
}
@@ -2058,8 +2063,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
/* no command line request */
if (0 <= remote->prune_tags)
prune_tags = remote->prune_tags;
- else if (0 <= fetch_prune_tags_config)
- prune_tags = fetch_prune_tags_config;
+ else if (0 <= config->prune_tags)
+ prune_tags = config->prune_tags;
else
prune_tags = PRUNE_TAGS_BY_DEFAULT;
}
@@ -2097,7 +2102,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
sigchain_push_common(unlock_pack_on_signal);
atexit(unlock_pack_atexit);
sigchain_push(SIGPIPE, SIG_IGN);
- exit_code = do_fetch(gtransport, &rs, display_format);
+ exit_code = do_fetch(gtransport, &rs, config);
sigchain_pop(SIGPIPE);
refspec_clear(&rs);
transport_disconnect(gtransport);
@@ -2109,6 +2114,12 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
{
struct fetch_config config = {
.display_format = DISPLAY_FORMAT_FULL,
+ .prune = -1,
+ .prune_tags = -1,
+ .show_forced_updates = 1,
+ .recurse_submodules = RECURSE_SUBMODULES_DEFAULT,
+ .parallel = 1,
+ .submodule_fetch_jobs = -1,
};
const char *submodule_prefix = "";
const char *bundle_uri;
@@ -2206,7 +2217,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
N_("run 'maintenance --auto' after fetching")),
OPT_BOOL(0, "auto-gc", &enable_auto_gc,
N_("run 'maintenance --auto' after fetching")),
- OPT_BOOL(0, "show-forced-updates", &fetch_show_forced_updates,
+ OPT_BOOL(0, "show-forced-updates", &config.show_forced_updates,
N_("check for forced-updates on all updated branches")),
OPT_BOOL(0, "write-commit-graph", &fetch_write_commit_graph,
N_("write the commit-graph after fetching")),
@@ -2237,7 +2248,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
builtin_fetch_options, builtin_fetch_usage, 0);
if (recurse_submodules_cli != RECURSE_SUBMODULES_DEFAULT)
- recurse_submodules = recurse_submodules_cli;
+ config.recurse_submodules = recurse_submodules_cli;
if (negotiate_only) {
switch (recurse_submodules_cli) {
@@ -2248,7 +2259,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
* submodules. Skip it by setting recurse_submodules to
* RECURSE_SUBMODULES_OFF.
*/
- recurse_submodules = RECURSE_SUBMODULES_OFF;
+ config.recurse_submodules = RECURSE_SUBMODULES_OFF;
break;
default:
@@ -2257,11 +2268,11 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
}
}
- if (recurse_submodules != RECURSE_SUBMODULES_OFF) {
- int *sfjc = submodule_fetch_jobs_config == -1
- ? &submodule_fetch_jobs_config : NULL;
- int *rs = recurse_submodules == RECURSE_SUBMODULES_DEFAULT
- ? &recurse_submodules : NULL;
+ if (config.recurse_submodules != RECURSE_SUBMODULES_OFF) {
+ int *sfjc = config.submodule_fetch_jobs == -1
+ ? &config.submodule_fetch_jobs : NULL;
+ int *rs = config.recurse_submodules == RECURSE_SUBMODULES_DEFAULT
+ ? &config.recurse_submodules : NULL;
fetch_config_from_gitmodules(sfjc, rs);
}
@@ -2275,7 +2286,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
* Reference updates in submodules would be ambiguous
* in porcelain mode, so we reject this combination.
*/
- recurse_submodules = RECURSE_SUBMODULES_OFF;
+ config.recurse_submodules = RECURSE_SUBMODULES_OFF;
break;
default:
@@ -2385,7 +2396,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
if (filter_options.choice || repo_has_promisor_remote(the_repository))
fetch_one_setup_partial(remote);
result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs,
- config.display_format);
+ &config);
} else {
int max_children = max_jobs;
@@ -2402,10 +2413,10 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
"from one remote"));
if (max_children < 0)
- max_children = fetch_parallel_config;
+ max_children = config.parallel;
/* TODO should this also die if we have a previous partial-clone? */
- result = fetch_multiple(&list, max_children, config.display_format);
+ result = fetch_multiple(&list, max_children, &config);
}
/*
@@ -2417,20 +2428,20 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
* the fetched history from each remote, so there is no need
* to fetch submodules from here.
*/
- if (!result && remote && (recurse_submodules != RECURSE_SUBMODULES_OFF)) {
+ if (!result && remote && (config.recurse_submodules != RECURSE_SUBMODULES_OFF)) {
struct strvec options = STRVEC_INIT;
int max_children = max_jobs;
if (max_children < 0)
- max_children = submodule_fetch_jobs_config;
+ max_children = config.submodule_fetch_jobs;
if (max_children < 0)
- max_children = fetch_parallel_config;
+ max_children = config.parallel;
- add_options_to_argv(&options, config.display_format);
+ add_options_to_argv(&options, &config);
result = fetch_submodules(the_repository,
&options,
submodule_prefix,
- recurse_submodules,
+ config.recurse_submodules,
recurse_submodules_default,
verbosity < 0,
max_children);
diff --git a/builtin/fsck.c b/builtin/fsck.c
index dcc165b..d9aa4db 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -929,7 +929,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
fetch_if_missing = 0;
errors_found = 0;
- read_replace_refs = 0;
+ disable_replace_refs();
save_commit_buffer = 0;
argc = parse_options(argc, argv, prefix, fsck_opts, fsck_usage, 0);
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index bb67e16..d0d8067 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1752,7 +1752,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
if (argc == 2 && !strcmp(argv[1], "-h"))
usage(index_pack_usage);
- read_replace_refs = 0;
+ disable_replace_refs();
fsck_options.walk = mark_link;
reset_pack_idx_option(&opts);
diff --git a/builtin/log.c b/builtin/log.c
index 676de10..c85f13a 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -866,7 +866,7 @@ static void log_setup_revisions_tweak(struct rev_info *rev,
struct setup_revision_opt *opt)
{
if (rev->diffopt.flags.default_follow_renames &&
- rev->prune_data.nr == 1)
+ diff_check_follow_pathspec(&rev->prune_data, 0))
rev->diffopt.flags.follow_renames = 1;
if (rev->first_parent_only)
@@ -1406,7 +1406,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
}
}
-static const char *clean_message_id(const char *msg_id)
+static char *clean_message_id(const char *msg_id)
{
char ch;
const char *a, *z, *m;
@@ -1424,7 +1424,7 @@ static const char *clean_message_id(const char *msg_id)
if (!z)
die(_("insane in-reply-to: %s"), msg_id);
if (++z == m)
- return a;
+ return xstrdup(a);
return xmemdupz(a, z - a);
}
@@ -2310,11 +2310,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (in_reply_to || thread || cover_letter) {
rev.ref_message_ids = xmalloc(sizeof(*rev.ref_message_ids));
- string_list_init_nodup(rev.ref_message_ids);
+ string_list_init_dup(rev.ref_message_ids);
}
if (in_reply_to) {
- const char *msgid = clean_message_id(in_reply_to);
- string_list_append(rev.ref_message_ids, msgid);
+ char *msgid = clean_message_id(in_reply_to);
+ string_list_append_nodup(rev.ref_message_ids, msgid);
}
rev.numbered_files = just_numbers;
rev.patch_suffix = fmt_patch_suffix;
@@ -2370,8 +2370,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
&& (!cover_letter || rev.nr > 1))
free(rev.message_id);
else
- string_list_append(rev.ref_message_ids,
- rev.message_id);
+ string_list_append_nodup(rev.ref_message_ids,
+ rev.message_id);
}
gen_message_id(&rev, oid_to_hex(&commit->object.oid));
}
@@ -2420,6 +2420,7 @@ done:
strbuf_release(&rdiff_title);
strbuf_release(&sprefix);
free(to_free);
+ free(rev.message_id);
if (rev.ref_message_ids)
string_list_clear(rev.ref_message_ids, 0);
free(rev.ref_message_ids);
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 625f48f..72012c0 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -25,6 +25,9 @@
#include "setup.h"
#include "submodule.h"
#include "submodule-config.h"
+#include "object-store.h"
+#include "hex.h"
+
static int abbrev;
static int show_deleted;
@@ -241,6 +244,24 @@ static void show_submodule(struct repository *superproject,
repo_clear(&subrepo);
}
+static void expand_objectsize(struct strbuf *line, const struct object_id *oid,
+ const enum object_type type, unsigned int padded)
+{
+ if (type == OBJ_BLOB) {
+ unsigned long size;
+ if (oid_object_info(the_repository, oid, &size) < 0)
+ die(_("could not get object info about '%s'"),
+ oid_to_hex(oid));
+ if (padded)
+ strbuf_addf(line, "%7"PRIuMAX, (uintmax_t)size);
+ else
+ strbuf_addf(line, "%"PRIuMAX, (uintmax_t)size);
+ } else if (padded) {
+ strbuf_addf(line, "%7s", "-");
+ } else {
+ strbuf_addstr(line, "-");
+ }
+}
struct show_index_data {
const char *pathname;
struct index_state *istate;
@@ -272,6 +293,12 @@ static size_t expand_show_index(struct strbuf *sb, const char *start,
strbuf_addf(sb, "%06o", data->ce->ce_mode);
else if (skip_prefix(start, "(objectname)", &p))
strbuf_add_unique_abbrev(sb, &data->ce->oid, abbrev);
+ else if (skip_prefix(start, "(objecttype)", &p))
+ strbuf_addstr(sb, type_name(object_type(data->ce->ce_mode)));
+ else if (skip_prefix(start, "(objectsize:padded)", &p))
+ expand_objectsize(sb, &data->ce->oid, object_type(data->ce->ce_mode), 1);
+ else if (skip_prefix(start, "(objectsize)", &p))
+ expand_objectsize(sb, &data->ce->oid, object_type(data->ce->ce_mode), 0);
else if (skip_prefix(start, "(stage)", &p))
strbuf_addf(sb, "%d", ce_stage(data->ce));
else if (skip_prefix(start, "(eolinfo:index)", &p))
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index b8f8a8b..4325897 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -448,7 +448,7 @@ static int real_merge(struct merge_tree_options *o,
base_commit = lookup_commit_reference_by_name(merge_base);
if (!base_commit)
- die(_("could not lookup commit %s"), merge_base);
+ die(_("could not lookup commit '%s'"), merge_base);
opt.ancestor = merge_base;
base_tree = repo_get_commit_tree(the_repository, base_commit);
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 9cfc880..3af2d84 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -4284,7 +4284,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
if (DFS_NUM_STATES > (1 << OE_DFS_STATE_BITS))
BUG("too many dfs states, increase OE_DFS_STATE_BITS");
- read_replace_refs = 0;
+ disable_replace_refs();
sparse = git_env_bool("GIT_TEST_PACK_SPARSE", -1);
if (the_repository->gitdir) {
diff --git a/builtin/pack-refs.c b/builtin/pack-refs.c
index 9833815..bcf383c 100644
--- a/builtin/pack-refs.c
+++ b/builtin/pack-refs.c
@@ -4,22 +4,45 @@
#include "parse-options.h"
#include "refs.h"
#include "repository.h"
+#include "revision.h"
static char const * const pack_refs_usage[] = {
- N_("git pack-refs [--all] [--no-prune]"),
+ N_("git pack-refs [--all] [--no-prune] [--include <pattern>] [--exclude <pattern>]"),
NULL
};
int cmd_pack_refs(int argc, const char **argv, const char *prefix)
{
unsigned int flags = PACK_REFS_PRUNE;
+ static struct ref_exclusions excludes = REF_EXCLUSIONS_INIT;
+ static struct string_list included_refs = STRING_LIST_INIT_NODUP;
+ struct pack_refs_opts pack_refs_opts = { .exclusions = &excludes,
+ .includes = &included_refs,
+ .flags = flags };
+ static struct string_list option_excluded_refs = STRING_LIST_INIT_NODUP;
+ struct string_list_item *item;
+
struct option opts[] = {
- OPT_BIT(0, "all", &flags, N_("pack everything"), PACK_REFS_ALL),
- OPT_BIT(0, "prune", &flags, N_("prune loose refs (default)"), PACK_REFS_PRUNE),
+ OPT_BIT(0, "all", &pack_refs_opts.flags, N_("pack everything"), PACK_REFS_ALL),
+ OPT_BIT(0, "prune", &pack_refs_opts.flags, N_("prune loose refs (default)"), PACK_REFS_PRUNE),
+ OPT_STRING_LIST(0, "include", pack_refs_opts.includes, N_("pattern"),
+ N_("references to include")),
+ OPT_STRING_LIST(0, "exclude", &option_excluded_refs, N_("pattern"),
+ N_("references to exclude")),
OPT_END(),
};
git_config(git_default_config, NULL);
if (parse_options(argc, argv, prefix, opts, pack_refs_usage, 0))
usage_with_options(pack_refs_usage, opts);
- return refs_pack_refs(get_main_ref_store(the_repository), flags);
+
+ for_each_string_list_item(item, &option_excluded_refs)
+ add_ref_exclusion(pack_refs_opts.exclusions, item->string);
+
+ if (pack_refs_opts.flags & PACK_REFS_ALL)
+ string_list_append(pack_refs_opts.includes, "*");
+
+ if (!pack_refs_opts.includes->nr)
+ string_list_append(pack_refs_opts.includes, "refs/tags/*");
+
+ return refs_pack_refs(get_main_ref_store(the_repository), &pack_refs_opts);
}
diff --git a/builtin/prune.c b/builtin/prune.c
index 5dc9b20..2877201 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -164,7 +164,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
expire = TIME_MAX;
save_commit_buffer = 0;
- read_replace_refs = 0;
+ disable_replace_refs();
repo_init_revisions(the_repository, &revs, prefix);
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
diff --git a/builtin/replace.c b/builtin/replace.c
index 981f189..abff800 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -566,7 +566,7 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
OPT_END()
};
- read_replace_refs = 0;
+ disable_replace_refs();
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options, git_replace_usage, 0);
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 6bf8d66..6a16208 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2024,14 +2024,17 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
strbuf_reset(&sb);
strbuf_addf(&sb, "submodule.%s.url", sub->name);
if (repo_config_get_string_tmp(the_repository, sb.buf, &url)) {
- if (starts_with_dot_slash(sub->url) ||
- starts_with_dot_dot_slash(sub->url)) {
+ if (sub->url && (starts_with_dot_slash(sub->url) ||
+ starts_with_dot_dot_slash(sub->url))) {
url = resolve_relative_url(sub->url, NULL, 0);
need_free_url = 1;
} else
url = sub->url;
}
+ if (!url)
+ die(_("cannot clone submodule '%s' without a URL"), sub->name);
+
strbuf_reset(&sb);
strbuf_addf(&sb, "%s/.git", ce->name);
needs_cloning = !file_exists(sb.buf);
diff --git a/builtin/tag.c b/builtin/tag.c
index 1850a6a..49b64c7 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -271,11 +271,10 @@ static const char message_advice_nested_tag[] =
static void create_tag(const struct object_id *object, const char *object_ref,
const char *tag,
struct strbuf *buf, struct create_tag_options *opt,
- struct object_id *prev, struct object_id *result)
+ struct object_id *prev, struct object_id *result, char *path)
{
enum object_type type;
struct strbuf header = STRBUF_INIT;
- char *path = NULL;
type = oid_object_info(the_repository, object, NULL);
if (type <= OBJ_NONE)
@@ -299,7 +298,6 @@ static void create_tag(const struct object_id *object, const char *object_ref,
int fd;
/* write the template message before editing: */
- path = git_pathdup("TAG_EDITMSG");
fd = xopen(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
if (opt->message_given) {
@@ -341,10 +339,6 @@ static void create_tag(const struct object_id *object, const char *object_ref,
path);
exit(128);
}
- if (path) {
- unlink_or_warn(path);
- free(path);
- }
}
static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
@@ -495,6 +489,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
};
int ret = 0;
const char *only_in_list = NULL;
+ char *path = NULL;
setup_ref_filter_porcelain_msg();
@@ -629,7 +624,9 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
if (create_tag_object) {
if (force_sign_annotate && !annotate)
opt.sign = 1;
- create_tag(&object, object_ref, tag, &buf, &opt, &prev, &object);
+ path = git_pathdup("TAG_EDITMSG");
+ create_tag(&object, object_ref, tag, &buf, &opt, &prev, &object,
+ path);
}
transaction = ref_transaction_begin(&err);
@@ -637,8 +634,17 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
ref_transaction_update(transaction, ref.buf, &object, &prev,
create_reflog ? REF_FORCE_CREATE_REFLOG : 0,
reflog_msg.buf, &err) ||
- ref_transaction_commit(transaction, &err))
+ ref_transaction_commit(transaction, &err)) {
+ if (path)
+ fprintf(stderr,
+ _("The tag message has been left in %s\n"),
+ path);
die("%s", err.buf);
+ }
+ if (path) {
+ unlink_or_warn(path);
+ free(path);
+ }
ref_transaction_free(transaction);
if (force && !is_null_oid(&prev) && !oideq(&prev, &object))
printf(_("Updated tag '%s' (was %s)\n"), tag,
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 2c52c3a..0b4fe80 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -609,7 +609,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix UNUSED)
int i;
struct object_id oid;
- read_replace_refs = 0;
+ disable_replace_refs();
git_config(git_default_config, NULL);
diff --git a/builtin/upload-pack.c b/builtin/upload-pack.c
index beb9dd0..81d2008 100644
--- a/builtin/upload-pack.c
+++ b/builtin/upload-pack.c
@@ -36,7 +36,7 @@ int cmd_upload_pack(int argc, const char **argv, const char *prefix)
};
packet_trace_identity("upload-pack");
- read_replace_refs = 0;
+ disable_replace_refs();
argc = parse_options(argc, argv, prefix, options, upload_pack_usage, 0);
diff --git a/builtin/worktree.c b/builtin/worktree.c
index f318046..5a9cf07 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "abspath.h"
+#include "advice.h"
#include "checkout.h"
#include "config.h"
#include "copy.h"
@@ -14,6 +15,7 @@
#include "strvec.h"
#include "branch.h"
#include "refs.h"
+#include "remote.h"
#include "repository.h"
#include "run-command.h"
#include "hook.h"
@@ -26,7 +28,8 @@
#define BUILTIN_WORKTREE_ADD_USAGE \
N_("git worktree add [-f] [--detach] [--checkout] [--lock [--reason <string>]]\n" \
- " [-b <new-branch>] <path> [<commit-ish>]")
+ " [--orphan] [(-b | -B) <new-branch>] <path> [<commit-ish>]")
+
#define BUILTIN_WORKTREE_LIST_USAGE \
N_("git worktree list [-v | --porcelain [-z]]")
#define BUILTIN_WORKTREE_LOCK_USAGE \
@@ -42,6 +45,23 @@
#define BUILTIN_WORKTREE_UNLOCK_USAGE \
N_("git worktree unlock <worktree>")
+#define WORKTREE_ADD_DWIM_ORPHAN_INFER_TEXT \
+ _("No possible source branch, inferring '--orphan'")
+
+#define WORKTREE_ADD_ORPHAN_WITH_DASH_B_HINT_TEXT \
+ _("If you meant to create a worktree containing a new orphan branch\n" \
+ "(branch with no commits) for this repository, you can do so\n" \
+ "using the --orphan flag:\n" \
+ "\n" \
+ " git worktree add --orphan -b %s %s\n")
+
+#define WORKTREE_ADD_ORPHAN_NO_DASH_B_HINT_TEXT \
+ _("If you meant to create a worktree containing a new orphan branch\n" \
+ "(branch with no commits) for this repository, you can do so\n" \
+ "using the --orphan flag:\n" \
+ "\n" \
+ " git worktree add --orphan %s\n")
+
static const char * const git_worktree_usage[] = {
BUILTIN_WORKTREE_ADD_USAGE,
BUILTIN_WORKTREE_LIST_USAGE,
@@ -99,6 +119,7 @@ struct add_opts {
int detach;
int quiet;
int checkout;
+ int orphan;
const char *keep_locked;
};
@@ -372,6 +393,22 @@ static int checkout_worktree(const struct add_opts *opts,
return run_command(&cp);
}
+static int make_worktree_orphan(const char * ref, const struct add_opts *opts,
+ struct strvec *child_env)
+{
+ struct strbuf symref = STRBUF_INIT;
+ struct child_process cp = CHILD_PROCESS_INIT;
+
+ validate_new_branchname(ref, &symref, 0);
+ strvec_pushl(&cp.args, "symbolic-ref", "HEAD", symref.buf, NULL);
+ if (opts->quiet)
+ strvec_push(&cp.args, "--quiet");
+ strvec_pushv(&cp.env, child_env->v);
+ strbuf_release(&symref);
+ cp.git_cmd = 1;
+ return run_command(&cp);
+}
+
static int add_worktree(const char *path, const char *refname,
const struct add_opts *opts)
{
@@ -401,7 +438,7 @@ static int add_worktree(const char *path, const char *refname,
die_if_checked_out(symref.buf, 0);
}
commit = lookup_commit_reference_by_name(refname);
- if (!commit)
+ if (!commit && !opts->orphan)
die(_("invalid reference: %s"), refname);
name = worktree_basename(path, &len);
@@ -483,17 +520,17 @@ static int add_worktree(const char *path, const char *refname,
* values from the current worktree into the new one, that way the
* new worktree behaves the same as this one.
*/
- if (repository_format_worktree_config)
+ if (the_repository->repository_format_worktree_config)
copy_filtered_worktree_config(sb_repo.buf);
strvec_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf);
strvec_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path);
cp.git_cmd = 1;
- if (!is_branch)
+ if (!is_branch && commit) {
strvec_pushl(&cp.args, "update-ref", "HEAD",
oid_to_hex(&commit->object.oid), NULL);
- else {
+ } else {
strvec_pushl(&cp.args, "symbolic-ref", "HEAD",
symref.buf, NULL);
if (opts->quiet)
@@ -505,6 +542,10 @@ static int add_worktree(const char *path, const char *refname,
if (ret)
goto done;
+ if (opts->orphan &&
+ (ret = make_worktree_orphan(refname, opts, &child_env)))
+ goto done;
+
if (opts->checkout &&
(ret = checkout_worktree(opts, &child_env)))
goto done;
@@ -524,7 +565,7 @@ done:
* Hook failure does not warrant worktree deletion, so run hook after
* is_junk is cleared, but do return appropriate code when hook fails.
*/
- if (!ret && opts->checkout) {
+ if (!ret && opts->checkout && !opts->orphan) {
struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
strvec_pushl(&opt.env, "GIT_DIR", "GIT_WORK_TREE", NULL);
@@ -572,7 +613,7 @@ static void print_preparing_worktree_line(int detach,
else {
struct commit *commit = lookup_commit_reference_by_name(branch);
if (!commit)
- die(_("invalid reference: %s"), branch);
+ BUG(_("unreachable: invalid reference: %s"), branch);
fprintf_ln(stderr, _("Preparing worktree (detached HEAD %s)"),
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
}
@@ -580,6 +621,123 @@ static void print_preparing_worktree_line(int detach,
}
}
+/**
+ * Callback to short circuit iteration over refs on the first reference
+ * corresponding to a valid oid.
+ *
+ * Returns 0 on failure and non-zero on success.
+ */
+static int first_valid_ref(const char *refname,
+ const struct object_id *oid,
+ int flags,
+ void *cb_data)
+{
+ return 1;
+}
+
+/**
+ * Verifies HEAD and determines whether there exist any valid local references.
+ *
+ * - Checks whether HEAD points to a valid reference.
+ *
+ * - Checks whether any valid local branches exist.
+ *
+ * - Emits a warning if there exist any valid branches but HEAD does not point
+ * to a valid reference.
+ *
+ * Returns 1 if any of the previous checks are true, otherwise returns 0.
+ */
+static int can_use_local_refs(const struct add_opts *opts)
+{
+ if (head_ref(first_valid_ref, NULL)) {
+ return 1;
+ } else if (for_each_branch_ref(first_valid_ref, NULL)) {
+ if (!opts->quiet) {
+ struct strbuf path = STRBUF_INIT;
+ struct strbuf contents = STRBUF_INIT;
+
+ strbuf_add_real_path(&path, get_worktree_git_dir(NULL));
+ strbuf_addstr(&path, "/HEAD");
+ strbuf_read_file(&contents, path.buf, 64);
+ strbuf_stripspace(&contents, 0);
+ strbuf_strip_suffix(&contents, "\n");
+
+ warning(_("HEAD points to an invalid (or orphaned) reference.\n"
+ "HEAD path: '%s'\n"
+ "HEAD contents: '%s'"),
+ path.buf, contents.buf);
+ strbuf_release(&path);
+ strbuf_release(&contents);
+ }
+ return 1;
+ }
+ return 0;
+}
+
+/**
+ * Reports whether the necessary flags were set and whether the repository has
+ * remote references to attempt DWIM tracking of upstream branches.
+ *
+ * 1. Checks that `--guess-remote` was used or `worktree.guessRemote = true`.
+ *
+ * 2. Checks whether any valid remote branches exist.
+ *
+ * 3. Checks that there exists at least one remote and emits a warning/error
+ * if both checks 1. and 2. are false (can be bypassed with `--force`).
+ *
+ * Returns 1 if checks 1. and 2. are true, otherwise 0.
+ */
+static int can_use_remote_refs(const struct add_opts *opts)
+{
+ if (!guess_remote) {
+ return 0;
+ } else if (for_each_remote_ref(first_valid_ref, NULL)) {
+ return 1;
+ } else if (!opts->force && remote_get(NULL)) {
+ die(_("No local or remote refs exist despite at least one remote\n"
+ "present, stopping; use 'add -f' to overide or fetch a remote first"));
+ }
+ return 0;
+}
+
+/**
+ * Determines whether `--orphan` should be inferred in the evaluation of
+ * `worktree add path/` or `worktree add -b branch path/` and emits an error
+ * if the supplied arguments would produce an illegal combination when the
+ * `--orphan` flag is included.
+ *
+ * `opts` and `opt_track` contain the other options & flags supplied to the
+ * command.
+ *
+ * remote determines whether to check `can_use_remote_refs()` or not. This
+ * is primarily to differentiate between the basic `add` DWIM and `add -b`.
+ *
+ * Returns 1 when inferring `--orphan`, 0 otherwise, and emits an error when
+ * `--orphan` is inferred but doing so produces an illegal combination of
+ * options and flags. Additionally produces an error when remote refs are
+ * checked and the repo is in a state that looks like the user added a remote
+ * but forgot to fetch (and did not override the warning with -f).
+ */
+static int dwim_orphan(const struct add_opts *opts, int opt_track, int remote)
+{
+ if (can_use_local_refs(opts)) {
+ return 0;
+ } else if (remote && can_use_remote_refs(opts)) {
+ return 0;
+ } else if (!opts->quiet) {
+ fprintf_ln(stderr, WORKTREE_ADD_DWIM_ORPHAN_INFER_TEXT);
+ }
+
+ if (opt_track) {
+ die(_("'%s' and '%s' cannot be used together"), "--orphan",
+ "--track");
+ } else if (!opts->checkout) {
+ die(_("'%s' and '%s' cannot be used together"), "--orphan",
+ "--no-checkout");
+ }
+ return 1;
+}
+
static const char *dwim_branch(const char *path, const char **new_branch)
{
int n;
@@ -616,6 +774,7 @@ static int add(int ac, const char **av, const char *prefix)
const char *opt_track = NULL;
const char *lock_reason = NULL;
int keep_locked = 0;
+ int used_new_branch_options;
struct option options[] = {
OPT__FORCE(&opts.force,
N_("checkout <branch> even if already checked out in other worktree"),
@@ -624,6 +783,7 @@ static int add(int ac, const char **av, const char *prefix)
N_("create a new branch")),
OPT_STRING('B', NULL, &new_branch_force, N_("branch"),
N_("create or reset a branch")),
+ OPT_BOOL(0, "orphan", &opts.orphan, N_("create unborn/orphaned branch")),
OPT_BOOL('d', "detach", &opts.detach, N_("detach HEAD at named commit")),
OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new working tree")),
OPT_BOOL(0, "lock", &keep_locked, N_("keep the new working tree locked")),
@@ -644,6 +804,17 @@ static int add(int ac, const char **av, const char *prefix)
ac = parse_options(ac, av, prefix, options, git_worktree_add_usage, 0);
if (!!opts.detach + !!new_branch + !!new_branch_force > 1)
die(_("options '%s', '%s', and '%s' cannot be used together"), "-b", "-B", "--detach");
+ if (opts.detach && opts.orphan)
+ die(_("options '%s', and '%s' cannot be used together"),
+ "--orphan", "--detach");
+ if (opts.orphan && opt_track)
+ die(_("'%s' and '%s' cannot be used together"), "--orphan", "--track");
+ if (opts.orphan && !opts.checkout)
+ die(_("'%s' and '%s' cannot be used together"), "--orphan",
+ "--no-checkout");
+ if (opts.orphan && ac == 2)
+ die(_("'%s' and '%s' cannot be used together"), "--orphan",
+ _("<commit-ish>"));
if (lock_reason && !keep_locked)
die(_("the option '%s' requires '%s'"), "--reason", "--lock");
if (lock_reason)
@@ -656,6 +827,7 @@ static int add(int ac, const char **av, const char *prefix)
path = prefix_filename(prefix, av[0]);
branch = ac < 2 ? "HEAD" : av[1];
+ used_new_branch_options = new_branch || new_branch_force;
if (!strcmp(branch, "-"))
branch = "@{-1}";
@@ -672,13 +844,28 @@ static int add(int ac, const char **av, const char *prefix)
strbuf_release(&symref);
}
- if (ac < 2 && !new_branch && !opts.detach) {
+ if (opts.orphan && !new_branch) {
+ int n;
+ const char *s = worktree_basename(path, &n);
+ new_branch = xstrndup(s, n);
+ } else if (opts.orphan) {
+ // No-op
+ } else if (opts.detach) {
+ // Check HEAD
+ if (!strcmp(branch, "HEAD"))
+ can_use_local_refs(&opts);
+ } else if (ac < 2 && new_branch) {
+ // DWIM: Infer --orphan when repo has no refs.
+ opts.orphan = dwim_orphan(&opts, !!opt_track, 0);
+ } else if (ac < 2) {
+ // DWIM: Guess branch name from path.
const char *s = dwim_branch(path, &new_branch);
if (s)
branch = s;
- }
- if (ac == 2 && !new_branch && !opts.detach) {
+ // DWIM: Infer --orphan when repo has no refs.
+ opts.orphan = (!s) && dwim_orphan(&opts, !!opt_track, 1);
+ } else if (ac == 2) {
struct object_id oid;
struct commit *commit;
const char *remote;
@@ -691,11 +878,31 @@ static int add(int ac, const char **av, const char *prefix)
branch = remote;
}
}
+
+ if (!strcmp(branch, "HEAD"))
+ can_use_local_refs(&opts);
+
+ }
+
+ if (!opts.orphan && !lookup_commit_reference_by_name(branch)) {
+ int attempt_hint = !opts.quiet && (ac < 2);
+ if (attempt_hint && used_new_branch_options) {
+ advise_if_enabled(ADVICE_WORKTREE_ADD_ORPHAN,
+ WORKTREE_ADD_ORPHAN_WITH_DASH_B_HINT_TEXT,
+ new_branch, path);
+ } else if (attempt_hint) {
+ advise_if_enabled(ADVICE_WORKTREE_ADD_ORPHAN,
+ WORKTREE_ADD_ORPHAN_NO_DASH_B_HINT_TEXT, path);
+ }
+ die(_("invalid reference: %s"), branch);
}
+
if (!opts.quiet)
print_preparing_worktree_line(opts.detach, branch, new_branch, !!new_branch_force);
- if (new_branch) {
+ if (opts.orphan) {
+ branch = new_branch;
+ } else if (new_branch) {
struct child_process cp = CHILD_PROCESS_INIT;
cp.git_cmd = 1;
strvec_push(&cp.args, "branch");
@@ -1200,5 +1407,9 @@ int cmd_worktree(int ac, const char **av, const char *prefix)
prefix = "";
ac = parse_options(ac, av, prefix, options, git_worktree_usage, 0);
+
+ prepare_repo_settings(the_repository);
+ the_repository->settings.command_requires_full_index = 0;
+
return fn(ac, av, prefix);
}
diff --git a/ci/lib.sh b/ci/lib.sh
index db7105e..369d462 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -278,11 +278,8 @@ linux-leaks)
export GIT_TEST_PASSING_SANITIZE_LEAK=true
export GIT_TEST_SANITIZE_LEAK_LOG=true
;;
-linux-asan)
- export SANITIZE=address
- ;;
-linux-ubsan)
- export SANITIZE=undefined
+linux-asan-ubsan)
+ export SANITIZE=address,undefined
;;
esac
diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh
index a18b13a..2528f25 100755
--- a/ci/run-build-and-tests.sh
+++ b/ci/run-build-and-tests.sh
@@ -29,6 +29,7 @@ linux-TEST-vars)
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_NO_WRITE_REV_INDEX=1
export GIT_TEST_CHECKOUT_WORKERS=2
+ export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1
;;
linux-clang)
export GIT_TEST_DEFAULT_HASH=sha1
diff --git a/commit-graph.c b/commit-graph.c
index 843bdb4..fd0ff8c 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -204,14 +204,12 @@ static struct commit_graph *alloc_commit_graph(void)
return g;
}
-extern int read_replace_refs;
-
static int commit_graph_compatible(struct repository *r)
{
if (!r->gitdir)
return 0;
- if (read_replace_refs) {
+ if (replace_refs_enabled(r)) {
prepare_replace_object(r);
if (hashmap_get_size(&r->objects->replace_map->map))
return 0;
diff --git a/commit-reach.c b/commit-reach.c
index 70bde8a..f15d845 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -944,6 +944,8 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
}
}
+ clear_prio_queue(&queue);
+
clear_commit_marks_many(nr_to, to, PARENT1);
clear_commit_marks_many(nr_from, from, PARENT2);
diff --git a/config.c b/config.c
index 207e439..2eeb662 100644
--- a/config.c
+++ b/config.c
@@ -199,6 +199,7 @@ struct config_include_data {
void *data;
const struct config_options *opts;
struct git_config_source *config_source;
+ struct repository *repo;
struct config_reader *config_reader;
/*
@@ -415,7 +416,8 @@ static void populate_remote_urls(struct config_include_data *inc)
inc->remote_urls = xmalloc(sizeof(*inc->remote_urls));
string_list_init_dup(inc->remote_urls);
- config_with_options(add_remote_url, inc->remote_urls, inc->config_source, &opts);
+ config_with_options(add_remote_url, inc->remote_urls,
+ inc->config_source, inc->repo, &opts);
config_reader_set_scope(inc->config_reader, store_scope);
}
@@ -1839,11 +1841,6 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
return 0;
}
- if (!strcmp(var, "core.usereplacerefs")) {
- read_replace_refs = git_config_bool(var, value);
- return 0;
- }
-
/* Add other config variables here and to Documentation/config.txt. */
return platform_core_config(var, value, cb);
}
@@ -2193,6 +2190,7 @@ int git_config_system(void)
static int do_git_config_sequence(struct config_reader *reader,
const struct config_options *opts,
+ const struct repository *repo,
config_fn_t fn, void *data)
{
int ret = 0;
@@ -2200,14 +2198,24 @@ static int do_git_config_sequence(struct config_reader *reader,
char *xdg_config = NULL;
char *user_config = NULL;
char *repo_config;
+ char *worktree_config;
enum config_scope prev_parsing_scope = reader->parsing_scope;
- if (opts->commondir)
+ /*
+ * Ensure that either:
+ * - the git_dir and commondir are both set, or
+ * - the git_dir and commondir are both NULL
+ */
+ if (!opts->git_dir != !opts->commondir)
+ BUG("only one of commondir and git_dir is non-NULL");
+
+ if (opts->commondir) {
repo_config = mkpathdup("%s/config", opts->commondir);
- else if (opts->git_dir)
- BUG("git_dir without commondir");
- else
+ worktree_config = mkpathdup("%s/config.worktree", opts->git_dir);
+ } else {
repo_config = NULL;
+ worktree_config = NULL;
+ }
config_reader_set_scope(reader, CONFIG_SCOPE_SYSTEM);
if (git_config_system() && system_config &&
@@ -2230,11 +2238,10 @@ static int do_git_config_sequence(struct config_reader *reader,
ret += git_config_from_file(fn, repo_config, data);
config_reader_set_scope(reader, CONFIG_SCOPE_WORKTREE);
- if (!opts->ignore_worktree && repository_format_worktree_config) {
- char *path = git_pathdup("config.worktree");
- if (!access_or_die(path, R_OK, 0))
- ret += git_config_from_file(fn, path, data);
- free(path);
+ if (!opts->ignore_worktree && worktree_config &&
+ repo && repo->repository_format_worktree_config &&
+ !access_or_die(worktree_config, R_OK, 0)) {
+ ret += git_config_from_file(fn, worktree_config, data);
}
config_reader_set_scope(reader, CONFIG_SCOPE_COMMAND);
@@ -2246,11 +2253,13 @@ static int do_git_config_sequence(struct config_reader *reader,
free(xdg_config);
free(user_config);
free(repo_config);
+ free(worktree_config);
return ret;
}
int config_with_options(config_fn_t fn, void *data,
struct git_config_source *config_source,
+ struct repository *repo,
const struct config_options *opts)
{
struct config_include_data inc = CONFIG_INCLUDE_INIT;
@@ -2261,6 +2270,7 @@ int config_with_options(config_fn_t fn, void *data,
inc.fn = fn;
inc.data = data;
inc.opts = opts;
+ inc.repo = repo;
inc.config_source = config_source;
inc.config_reader = &the_reader;
fn = git_config_include;
@@ -2279,12 +2289,10 @@ int config_with_options(config_fn_t fn, void *data,
} else if (config_source && config_source->file) {
ret = git_config_from_file(fn, config_source->file, data);
} else if (config_source && config_source->blob) {
- struct repository *repo = config_source->repo ?
- config_source->repo : the_repository;
ret = git_config_from_blob_ref(fn, repo, config_source->blob,
data);
} else {
- ret = do_git_config_sequence(&the_reader, opts, fn, data);
+ ret = do_git_config_sequence(&the_reader, opts, repo, fn, data);
}
if (inc.remote_urls) {
@@ -2343,7 +2351,7 @@ void read_early_config(config_fn_t cb, void *data)
opts.git_dir = gitdir.buf;
}
- config_with_options(cb, data, NULL, &opts);
+ config_with_options(cb, data, NULL, NULL, &opts);
strbuf_release(&commondir);
strbuf_release(&gitdir);
@@ -2363,7 +2371,7 @@ void read_very_early_config(config_fn_t cb, void *data)
opts.ignore_cmdline = 1;
opts.system_gently = 1;
- config_with_options(cb, data, NULL, &opts);
+ config_with_options(cb, data, NULL, NULL, &opts);
}
RESULT_MUST_BE_USED
@@ -2671,7 +2679,7 @@ static void repo_read_config(struct repository *repo)
data.config_set = repo->config;
data.config_reader = &the_reader;
- if (config_with_options(config_set_callback, &data, NULL, &opts) < 0)
+ if (config_with_options(config_set_callback, &data, NULL, repo, &opts) < 0)
/*
* config_with_options() normally returns only
* zero, as most errors are fatal, and
@@ -2815,7 +2823,7 @@ static void read_protected_config(void)
git_configset_init(&protected_config);
data.config_set = &protected_config;
data.config_reader = &the_reader;
- config_with_options(config_set_callback, &data, NULL, &opts);
+ config_with_options(config_set_callback, &data, NULL, NULL, &opts);
}
void git_protected_config(config_fn_t fn, void *data)
@@ -3327,7 +3335,7 @@ int repo_config_set_worktree_gently(struct repository *r,
const char *key, const char *value)
{
/* Only use worktree-specific config if it is already enabled. */
- if (repository_format_worktree_config) {
+ if (r->repository_format_worktree_config) {
char *file = repo_git_path(r, "config.worktree");
int ret = git_config_set_multivar_in_file_gently(
file, key, value, NULL, 0);
diff --git a/config.h b/config.h
index 247b572..d1c5577 100644
--- a/config.h
+++ b/config.h
@@ -3,6 +3,7 @@
#include "hashmap.h"
#include "string-list.h"
+#include "repository.h"
/**
@@ -49,8 +50,6 @@ const char *config_scope_name(enum config_scope scope);
struct git_config_source {
unsigned int use_stdin:1;
const char *file;
- /* The repository if blob is not NULL; leave blank for the_repository */
- struct repository *repo;
const char *blob;
enum config_scope scope;
};
@@ -196,6 +195,7 @@ void git_config(config_fn_t fn, void *);
*/
int config_with_options(config_fn_t fn, void *,
struct git_config_source *config_source,
+ struct repository *repo,
const struct config_options *opts);
/**
diff --git a/contrib/coccinelle/README b/contrib/coccinelle/README
index d1daa1f..055ad0e 100644
--- a/contrib/coccinelle/README
+++ b/contrib/coccinelle/README
@@ -1,7 +1,9 @@
-This directory provides examples of Coccinelle (http://coccinelle.lip6.fr/)
-semantic patches that might be useful to developers.
+= coccinelle
-There are two types of semantic patches:
+This directory provides Coccinelle (http://coccinelle.lip6.fr/) semantic patches
+that might be useful to developers.
+
+== Types of semantic patches
* Using the semantic transformation to check for bad patterns in the code;
The target 'make coccicheck' is designed to check for these patterns and
@@ -42,7 +44,7 @@ There are two types of semantic patches:
This allows to expose plans of pending large scale refactorings without
impacting the bad pattern checks.
-Git-specific tips & things to know about how we run "spatch":
+== Git-specific tips & things to know about how we run "spatch":
* The "make coccicheck" will piggy-back on
"COMPUTE_HEADER_DEPENDENCIES". If you've built a given object file
@@ -90,3 +92,33 @@ Git-specific tips & things to know about how we run "spatch":
The absolute times will differ for you, but the relative speedup
from caching should be on that order.
+
+== Authoring and reviewing coccinelle changes
+
+* When a .cocci is made, both the Git changes and .cocci file should be
+ reviewed. When reviewing such a change, do your best to understand the .cocci
+ changes (e.g. by asking the author to explain the change) and be explicit
+ about your understanding of the changes. This helps us decide whether input
+ from coccinelle experts is needed or not. If you aren't sure of the cocci
+ changes, indicate what changes you actively endorse and leave an Acked-by
+ (instead of Reviewed-by).
+
+* Authors should consider that reviewers may not be coccinelle experts, thus the
+ the .cocci changes may not be self-evident. A plain text description of the
+ changes is strongly encouraged, especially when using more esoteric features
+ of the language.
+
+* .cocci rules should target only the problem it is trying to solve; "collateral
+ damage" is not allowed. Reviewers should look out and flag overly-broad rules.
+
+* Consider the cost-benefit ratio of .cocci changes. In particular, consider the
+ effect on the runtime of "make coccicheck", and how often your .cocci check
+ will catch something valuable. As a rule of thumb, rules that can bail early
+ if a file doesn't have a particular token will have a small impact on runtime,
+ and vice-versa.
+
+* .cocci files used for refactoring should be temporarily kept in-tree to aid
+ the refactoring of out-of-tree code (e.g. in-flight topics). Periodically
+ evaluate the cost-benefit ratio to determine when the file should be removed.
+ For example, consider how many out-of-tree users are left and how much this
+ slows down "make coccicheck".
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index dc95c34..945d254 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -767,7 +767,7 @@ __git_refs ()
track=""
;;
*)
- for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD CHERRY_PICK_HEAD; do
+ for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD CHERRY_PICK_HEAD REVERT_HEAD BISECT_HEAD AUTO_MERGE; do
case "$i" in
$match*|$umatch*)
if [ -e "$dir/$i" ]; then
diff --git a/credential.c b/credential.c
index 023b59d..8825c6f 100644
--- a/credential.c
+++ b/credential.c
@@ -33,13 +33,14 @@ void credential_clear(struct credential *c)
}
int credential_match(const struct credential *want,
- const struct credential *have)
+ const struct credential *have, int match_password)
{
#define CHECK(x) (!want->x || (have->x && !strcmp(want->x, have->x)))
return CHECK(protocol) &&
CHECK(host) &&
CHECK(path) &&
- CHECK(username);
+ CHECK(username) &&
+ (!match_password || CHECK(password));
#undef CHECK
}
@@ -102,7 +103,7 @@ static int match_partial_url(const char *url, void *cb)
warning(_("skipping credential lookup for key: credential.%s"),
url);
else
- matches = credential_match(&want, c);
+ matches = credential_match(&want, c, 0);
credential_clear(&want);
return matches;
diff --git a/credential.h b/credential.h
index b8e2936..acc41ad 100644
--- a/credential.h
+++ b/credential.h
@@ -211,6 +211,6 @@ void credential_from_url(struct credential *, const char *url);
int credential_from_url_gently(struct credential *, const char *url, int quiet);
int credential_match(const struct credential *want,
- const struct credential *have);
+ const struct credential *have, int match_password);
#endif /* CREDENTIAL_H */
diff --git a/diff.c b/diff.c
index 3c88c37..c106f8a 100644
--- a/diff.c
+++ b/diff.c
@@ -4751,6 +4751,31 @@ unsigned diff_filter_bit(char status)
return filter_bit[(int) status];
}
+int diff_check_follow_pathspec(struct pathspec *ps, int die_on_error)
+{
+ unsigned forbidden_magic;
+
+ if (ps->nr != 1) {
+ if (die_on_error)
+ die(_("--follow requires exactly one pathspec"));
+ return 0;
+ }
+
+ forbidden_magic = ps->items[0].magic & ~(PATHSPEC_FROMTOP |
+ PATHSPEC_LITERAL);
+ if (forbidden_magic) {
+ if (die_on_error) {
+ struct strbuf sb = STRBUF_INIT;
+ pathspec_magic_names(forbidden_magic, &sb);
+ die(_("pathspec magic not supported by --follow: %s"),
+ sb.buf);
+ }
+ return 0;
+ }
+
+ return 1;
+}
+
void diff_setup_done(struct diff_options *options)
{
unsigned check_mask = DIFF_FORMAT_NAME |
@@ -4858,8 +4883,8 @@ void diff_setup_done(struct diff_options *options)
options->diff_path_counter = 0;
- if (options->flags.follow_renames && options->pathspec.nr != 1)
- die(_("--follow requires exactly one pathspec"));
+ if (options->flags.follow_renames)
+ diff_check_follow_pathspec(&options->pathspec, 1);
if (!options->use_color || external_diff())
options->color_moved = 0;
@@ -4936,6 +4961,7 @@ static int diff_opt_stat(const struct option *opt, const char *value, int unset)
} else
BUG("%s should not get here", opt->long_name);
+ options->output_format &= ~DIFF_FORMAT_NO_OUTPUT;
options->output_format |= DIFF_FORMAT_DIFFSTAT;
options->stat_name_width = name_width;
options->stat_graph_width = graph_width;
@@ -4955,6 +4981,7 @@ static int parse_dirstat_opt(struct diff_options *options, const char *params)
* The caller knows a dirstat-related option is given from the command
* line; allow it to say "return this_function();"
*/
+ options->output_format &= ~DIFF_FORMAT_NO_OUTPUT;
options->output_format |= DIFF_FORMAT_DIRSTAT;
return 1;
}
@@ -5154,6 +5181,7 @@ static int diff_opt_compact_summary(const struct option *opt,
options->flags.stat_with_summary = 0;
} else {
options->flags.stat_with_summary = 1;
+ options->output_format &= ~DIFF_FORMAT_NO_OUTPUT;
options->output_format |= DIFF_FORMAT_DIFFSTAT;
}
return 0;
@@ -5499,9 +5527,8 @@ struct option *add_diff_options(const struct option *opts,
OPT_BITOP('p', "patch", &options->output_format,
N_("generate patch"),
DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),
- OPT_BIT_F('s', "no-patch", &options->output_format,
- N_("suppress diff output"),
- DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG),
+ OPT_SET_INT('s', "no-patch", &options->output_format,
+ N_("suppress diff output"), DIFF_FORMAT_NO_OUTPUT),
OPT_BITOP('u', NULL, &options->output_format,
N_("generate patch"),
DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),
@@ -5510,9 +5537,9 @@ struct option *add_diff_options(const struct option *opts,
PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_unified),
OPT_BOOL('W', "function-context", &options->flags.funccontext,
N_("generate diffs with <n> lines context")),
- OPT_BIT_F(0, "raw", &options->output_format,
+ OPT_BITOP(0, "raw", &options->output_format,
N_("generate the diff in raw format"),
- DIFF_FORMAT_RAW, PARSE_OPT_NONEG),
+ DIFF_FORMAT_RAW, DIFF_FORMAT_NO_OUTPUT),
OPT_BITOP(0, "patch-with-raw", &options->output_format,
N_("synonym for '-p --raw'"),
DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,
@@ -5521,12 +5548,12 @@ struct option *add_diff_options(const struct option *opts,
N_("synonym for '-p --stat'"),
DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT,
DIFF_FORMAT_NO_OUTPUT),
- OPT_BIT_F(0, "numstat", &options->output_format,
+ OPT_BITOP(0, "numstat", &options->output_format,
N_("machine friendly --stat"),
- DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),
- OPT_BIT_F(0, "shortstat", &options->output_format,
+ DIFF_FORMAT_NUMSTAT, DIFF_FORMAT_NO_OUTPUT),
+ OPT_BITOP(0, "shortstat", &options->output_format,
N_("output only the last line of --stat"),
- DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),
+ DIFF_FORMAT_SHORTSTAT, DIFF_FORMAT_NO_OUTPUT),
OPT_CALLBACK_F('X', "dirstat", options, N_("<param1,param2>..."),
N_("output the distribution of relative amount of changes for each sub-directory"),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
@@ -5542,9 +5569,9 @@ struct option *add_diff_options(const struct option *opts,
OPT_BIT_F(0, "check", &options->output_format,
N_("warn if changes introduce conflict markers or whitespace errors"),
DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),
- OPT_BIT_F(0, "summary", &options->output_format,
+ OPT_BITOP(0, "summary", &options->output_format,
N_("condensed summary such as creations, renames and mode changes"),
- DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG),
+ DIFF_FORMAT_SUMMARY, DIFF_FORMAT_NO_OUTPUT),
OPT_BIT_F(0, "name-only", &options->output_format,
N_("show only names of changed files"),
DIFF_FORMAT_NAME, PARSE_OPT_NONEG),
diff --git a/diff.h b/diff.h
index 3a7a9e8..6c10ce2 100644
--- a/diff.h
+++ b/diff.h
@@ -539,6 +539,13 @@ void repo_diff_setup(struct repository *, struct diff_options *);
struct option *add_diff_options(const struct option *, struct diff_options *);
int diff_opt_parse(struct diff_options *, const char **, int, const char *);
void diff_setup_done(struct diff_options *);
+
+/*
+ * Returns true if the pathspec can work with --follow mode. If die_on_error is
+ * set, die() with a specific error message rather than returning false.
+ */
+int diff_check_follow_pathspec(struct pathspec *ps, int die_on_error);
+
int git_config_rename(const char *var, const char *value);
#define DIFF_DETECT_RENAME 1
diff --git a/dir.h b/dir.h
index 79b85a0..d65a401 100644
--- a/dir.h
+++ b/dir.h
@@ -641,18 +641,4 @@ static inline int starts_with_dot_dot_slash_native(const char *const path)
return path_match_flags(path, what | PATH_MATCH_NATIVE);
}
-#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
-#define DTYPE(de) ((de)->d_type)
-#else
-#undef DT_UNKNOWN
-#undef DT_DIR
-#undef DT_REG
-#undef DT_LNK
-#define DT_UNKNOWN 0
-#define DT_DIR 1
-#define DT_REG 2
-#define DT_LNK 3
-#define DTYPE(de) DT_UNKNOWN
-#endif
-
#endif
diff --git a/environment.c b/environment.c
index 28d18ea..d449f97 100644
--- a/environment.c
+++ b/environment.c
@@ -42,7 +42,6 @@ int is_bare_repository_cfg = -1; /* unspecified */
int warn_ambiguous_refs = 1;
int warn_on_object_refname_ambiguity = 1;
int repository_format_precious_objects;
-int repository_format_worktree_config;
const char *git_commit_encoding;
const char *git_log_output_encoding;
char *apply_default_whitespace;
@@ -63,7 +62,6 @@ const char *editor_program;
const char *askpass_program;
const char *excludes_file;
enum auto_crlf auto_crlf = AUTO_CRLF_FALSE;
-int read_replace_refs = 1;
enum eol core_eol = EOL_UNSET;
int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN;
char *check_roundtrip_encoding = "SHIFT-JIS";
@@ -184,7 +182,7 @@ void setup_git_env(const char *git_dir)
strvec_clear(&to_free);
if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
- read_replace_refs = 0;
+ disable_replace_refs();
replace_ref_base = getenv(GIT_REPLACE_REF_BASE_ENVIRONMENT);
git_replace_ref_base = xstrdup(replace_ref_base ? replace_ref_base
: "refs/replace/");
diff --git a/environment.h b/environment.h
index 30cb7e0..e666807 100644
--- a/environment.h
+++ b/environment.h
@@ -197,7 +197,6 @@ extern char *notes_ref_name;
extern int grafts_replace_parents;
extern int repository_format_precious_objects;
-extern int repository_format_worktree_config;
/*
* Create a temporary file rooted in the object database directory, or
diff --git a/git.c b/git.c
index 2f42da2..bb6ea35 100644
--- a/git.c
+++ b/git.c
@@ -186,7 +186,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
if (envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--no-replace-objects")) {
- read_replace_refs = 0;
+ disable_replace_refs();
setenv(NO_REPLACE_OBJECTS_ENVIRONMENT, "1", 1);
if (envchanged)
*envchanged = 1;
diff --git a/log-tree.c b/log-tree.c
index f4b22a6..4846808 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -156,7 +156,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,
if (starts_with(refname, git_replace_ref_base)) {
struct object_id original_oid;
- if (!read_replace_refs)
+ if (!replace_refs_enabled(the_repository))
return 0;
if (get_oid_hex(refname + strlen(git_replace_ref_base),
&original_oid)) {
diff --git a/notes.h b/notes.h
index c1682c3..064fd71 100644
--- a/notes.h
+++ b/notes.h
@@ -256,7 +256,17 @@ void free_notes(struct notes_tree *t);
struct string_list;
struct display_notes_opt {
+ /*
+ * Less than `0` is "unset", which means that the default notes
+ * are shown iff no other notes are given. Otherwise,
+ * treat it like a boolean.
+ */
int use_default_notes;
+
+ /*
+ * A list of globs (in the same style as notes.displayRef) where
+ * notes should be loaded from.
+ */
struct string_list extra_notes_refs;
};
@@ -283,14 +293,7 @@ void disable_display_notes(struct display_notes_opt *opt, int *show_notes);
/*
* Load the notes machinery for displaying several notes trees.
*
- * If 'opt' is not NULL, then it specifies additional settings for the
- * displaying:
- *
- * - suppress_default_notes indicates that the notes from
- * core.notesRef and notes.displayRef should not be loaded.
- *
- * - extra_notes_refs may contain a list of globs (in the same style
- * as notes.displayRef) where notes should be loaded from.
+ * 'opt' may be NULL.
*/
void load_display_notes(struct display_notes_opt *opt);
diff --git a/object.c b/object.c
index 6d4ef15..f1adb45 100644
--- a/object.c
+++ b/object.c
@@ -356,6 +356,12 @@ void object_list_free(struct object_list **list)
*/
static char object_array_slopbuf[1];
+void object_array_init(struct object_array *array)
+{
+ struct object_array blank = OBJECT_ARRAY_INIT;
+ memcpy(array, &blank, sizeof(*array));
+}
+
void add_object_array_with_path(struct object *obj, const char *name,
struct object_array *array,
unsigned mode, const char *path)
diff --git a/object.h b/object.h
index 5871615..114d459 100644
--- a/object.h
+++ b/object.h
@@ -58,6 +58,8 @@ struct object_array {
#define OBJECT_ARRAY_INIT { 0 }
+void object_array_init(struct object_array *array);
+
/*
* object flag allocation:
* revision.h: 0---------10 15 23------27
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 999f962..35669e2 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -387,9 +387,11 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
}
for (i = 0; i < bitmap_git->midx->num_packs; i++) {
- if (prepare_midx_pack(the_repository, bitmap_git->midx, i))
- die(_("could not open pack %s"),
- bitmap_git->midx->pack_names[i]);
+ if (prepare_midx_pack(the_repository, bitmap_git->midx, i)) {
+ warning(_("could not open pack %s"),
+ bitmap_git->midx->pack_names[i]);
+ goto cleanup;
+ }
}
preferred = bitmap_git->midx->packs[midx_preferred_pack(bitmap_git)];
@@ -1043,6 +1045,160 @@ static int add_commit_to_bitmap(struct bitmap_index *bitmap_git,
return 1;
}
+static struct bitmap *fill_in_bitmap(struct bitmap_index *bitmap_git,
+ struct rev_info *revs,
+ struct bitmap *base,
+ struct bitmap *seen)
+{
+ struct include_data incdata;
+ struct bitmap_show_data show_data;
+
+ if (!base)
+ base = bitmap_new();
+
+ incdata.bitmap_git = bitmap_git;
+ incdata.base = base;
+ incdata.seen = seen;
+
+ revs->include_check = should_include;
+ revs->include_check_obj = should_include_obj;
+ revs->include_check_data = &incdata;
+
+ if (prepare_revision_walk(revs))
+ die(_("revision walk setup failed"));
+
+ show_data.bitmap_git = bitmap_git;
+ show_data.base = base;
+
+ traverse_commit_list(revs, show_commit, show_object, &show_data);
+
+ revs->include_check = NULL;
+ revs->include_check_obj = NULL;
+ revs->include_check_data = NULL;
+
+ return base;
+}
+
+struct bitmap_boundary_cb {
+ struct bitmap_index *bitmap_git;
+ struct bitmap *base;
+
+ struct object_array boundary;
+};
+
+static void show_boundary_commit(struct commit *commit, void *_data)
+{
+ struct bitmap_boundary_cb *data = _data;
+
+ if (commit->object.flags & BOUNDARY)
+ add_object_array(&commit->object, "", &data->boundary);
+
+ if (commit->object.flags & UNINTERESTING) {
+ if (bitmap_walk_contains(data->bitmap_git, data->base,
+ &commit->object.oid))
+ return;
+
+ add_commit_to_bitmap(data->bitmap_git, &data->base, commit);
+ }
+}
+
+static void show_boundary_object(struct object *object,
+ const char *name, void *data)
+{
+ BUG("should not be called");
+}
+
+static struct bitmap *find_boundary_objects(struct bitmap_index *bitmap_git,
+ struct rev_info *revs,
+ struct object_list *roots)
+{
+ struct bitmap_boundary_cb cb;
+ struct object_list *root;
+ unsigned int i;
+ unsigned int tmp_blobs, tmp_trees, tmp_tags;
+ int any_missing = 0;
+
+ cb.bitmap_git = bitmap_git;
+ cb.base = bitmap_new();
+ object_array_init(&cb.boundary);
+
+ revs->ignore_missing_links = 1;
+
+ /*
+ * OR in any existing reachability bitmaps among `roots` into
+ * `cb.base`.
+ */
+ for (root = roots; root; root = root->next) {
+ struct object *object = root->item;
+ if (object->type != OBJ_COMMIT ||
+ bitmap_walk_contains(bitmap_git, cb.base, &object->oid))
+ continue;
+
+ if (add_commit_to_bitmap(bitmap_git, &cb.base,
+ (struct commit *)object))
+ continue;
+
+ any_missing = 1;
+ }
+
+ if (!any_missing)
+ goto cleanup;
+
+ tmp_blobs = revs->blob_objects;
+ tmp_trees = revs->tree_objects;
+ tmp_tags = revs->blob_objects;
+ revs->blob_objects = 0;
+ revs->tree_objects = 0;
+ revs->tag_objects = 0;
+
+ /*
+ * We didn't have complete coverage of the roots. First setup a
+ * revision walk to (a) OR in any bitmaps that are UNINTERESTING
+ * between the tips and boundary, and (b) record the boundary.
+ */
+ trace2_region_enter("pack-bitmap", "boundary-prepare", the_repository);
+ if (prepare_revision_walk(revs))
+ die("revision walk setup failed");
+ trace2_region_leave("pack-bitmap", "boundary-prepare", the_repository);
+
+ trace2_region_enter("pack-bitmap", "boundary-traverse", the_repository);
+ revs->boundary = 1;
+ traverse_commit_list_filtered(revs,
+ show_boundary_commit,
+ show_boundary_object,
+ &cb, NULL);
+ revs->boundary = 0;
+ trace2_region_leave("pack-bitmap", "boundary-traverse", the_repository);
+
+ revs->blob_objects = tmp_blobs;
+ revs->tree_objects = tmp_trees;
+ revs->tag_objects = tmp_tags;
+
+ reset_revision_walk();
+ clear_object_flags(UNINTERESTING);
+
+ /*
+ * Then add the boundary commit(s) as fill-in traversal tips.
+ */
+ trace2_region_enter("pack-bitmap", "boundary-fill-in", the_repository);
+ for (i = 0; i < cb.boundary.nr; i++) {
+ struct object *obj = cb.boundary.objects[i].item;
+ if (bitmap_walk_contains(bitmap_git, cb.base, &obj->oid))
+ obj->flags |= SEEN;
+ else
+ add_pending_object(revs, obj, "");
+ }
+ if (revs->pending.nr)
+ cb.base = fill_in_bitmap(bitmap_git, revs, cb.base, NULL);
+ trace2_region_leave("pack-bitmap", "boundary-fill-in", the_repository);
+
+cleanup:
+ object_array_clear(&cb.boundary);
+ revs->ignore_missing_links = 0;
+
+ return cb.base;
+}
+
static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
struct rev_info *revs,
struct object_list *roots,
@@ -1109,33 +1265,19 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
}
if (needs_walk) {
- struct include_data incdata;
- struct bitmap_show_data show_data;
-
- if (!base)
- base = bitmap_new();
-
- incdata.bitmap_git = bitmap_git;
- incdata.base = base;
- incdata.seen = seen;
-
- revs->include_check = should_include;
- revs->include_check_obj = should_include_obj;
- revs->include_check_data = &incdata;
-
- if (prepare_revision_walk(revs))
- die(_("revision walk setup failed"));
-
- show_data.bitmap_git = bitmap_git;
- show_data.base = base;
-
- traverse_commit_list(revs,
- show_commit, show_object,
- &show_data);
-
- revs->include_check = NULL;
- revs->include_check_obj = NULL;
- revs->include_check_data = NULL;
+ /*
+ * This fill-in traversal may walk over some objects
+ * again, since we have already traversed in order to
+ * find the boundary.
+ *
+ * But this extra walk should be extremely cheap, since
+ * all commit objects are loaded into memory, and
+ * because we skip walking to parents that are
+ * UNINTERESTING, since it will be marked in the haves
+ * bitmap already (or it has an on-disk bitmap, since
+ * OR-ing it in covers all of its ancestors).
+ */
+ base = fill_in_bitmap(bitmap_git, revs, base, seen);
}
return base;
@@ -1528,6 +1670,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
int filter_provided_objects)
{
unsigned int i;
+ int use_boundary_traversal;
struct object_list *wants = NULL;
struct object_list *haves = NULL;
@@ -1578,13 +1721,21 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
object_list_insert(object, &wants);
}
- /*
- * if we have a HAVES list, but none of those haves is contained
- * in the packfile that has a bitmap, we don't have anything to
- * optimize here
- */
- if (haves && !in_bitmapped_pack(bitmap_git, haves))
- goto cleanup;
+ use_boundary_traversal = git_env_bool(GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL, -1);
+ if (use_boundary_traversal < 0) {
+ prepare_repo_settings(revs->repo);
+ use_boundary_traversal = revs->repo->settings.pack_use_bitmap_boundary_traversal;
+ }
+
+ if (!use_boundary_traversal) {
+ /*
+ * if we have a HAVES list, but none of those haves is contained
+ * in the packfile that has a bitmap, we don't have anything to
+ * optimize here
+ */
+ if (haves && !in_bitmapped_pack(bitmap_git, haves))
+ goto cleanup;
+ }
/* if we don't want anything, we're done here */
if (!wants)
@@ -1598,18 +1749,32 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
if (load_bitmap(revs->repo, bitmap_git) < 0)
goto cleanup;
- object_array_clear(&revs->pending);
+ if (!use_boundary_traversal)
+ object_array_clear(&revs->pending);
if (haves) {
- revs->ignore_missing_links = 1;
- haves_bitmap = find_objects(bitmap_git, revs, haves, NULL);
- reset_revision_walk();
- revs->ignore_missing_links = 0;
+ if (use_boundary_traversal) {
+ trace2_region_enter("pack-bitmap", "haves/boundary", the_repository);
+ haves_bitmap = find_boundary_objects(bitmap_git, revs, haves);
+ trace2_region_leave("pack-bitmap", "haves/boundary", the_repository);
+ } else {
+ trace2_region_enter("pack-bitmap", "haves/classic", the_repository);
+ revs->ignore_missing_links = 1;
+ haves_bitmap = find_objects(bitmap_git, revs, haves, NULL);
+ reset_revision_walk();
+ revs->ignore_missing_links = 0;
+ trace2_region_leave("pack-bitmap", "haves/classic", the_repository);
+ }
if (!haves_bitmap)
BUG("failed to perform bitmap walk");
}
+ if (use_boundary_traversal) {
+ object_array_clear(&revs->pending);
+ reset_revision_walk();
+ }
+
wants_bitmap = find_objects(bitmap_git, revs, wants, haves_bitmap);
if (!wants_bitmap)
diff --git a/pack-bitmap.h b/pack-bitmap.h
index 84591f0..5273a6a 100644
--- a/pack-bitmap.h
+++ b/pack-bitmap.h
@@ -62,6 +62,10 @@ void traverse_bitmap_commit_list(struct bitmap_index *,
void test_bitmap_walk(struct rev_info *revs);
int test_bitmap_commits(struct repository *r);
int test_bitmap_hashes(struct repository *r);
+
+#define GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL \
+ "GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL"
+
struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
int filter_provided_objects);
uint32_t midx_preferred_pack(struct bitmap_index *bitmap_git);
diff --git a/pathspec.c b/pathspec.c
index 6966b26..5049dbb 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -531,24 +531,29 @@ static int pathspec_item_cmp(const void *a_, const void *b_)
return strcmp(a->match, b->match);
}
-static void NORETURN unsupported_magic(const char *pattern,
- unsigned magic)
+void pathspec_magic_names(unsigned magic, struct strbuf *out)
{
- struct strbuf sb = STRBUF_INIT;
int i;
for (i = 0; i < ARRAY_SIZE(pathspec_magic); i++) {
const struct pathspec_magic *m = pathspec_magic + i;
if (!(magic & m->bit))
continue;
- if (sb.len)
- strbuf_addstr(&sb, ", ");
+ if (out->len)
+ strbuf_addstr(out, ", ");
if (m->mnemonic)
- strbuf_addf(&sb, _("'%s' (mnemonic: '%c')"),
+ strbuf_addf(out, _("'%s' (mnemonic: '%c')"),
m->name, m->mnemonic);
else
- strbuf_addf(&sb, "'%s'", m->name);
+ strbuf_addf(out, "'%s'", m->name);
}
+}
+
+static void NORETURN unsupported_magic(const char *pattern,
+ unsigned magic)
+{
+ struct strbuf sb = STRBUF_INIT;
+ pathspec_magic_names(magic, &sb);
/*
* We may want to substitute "this command" with a command
* name. E.g. when "git add -p" or "git add -i" dies when running
diff --git a/pathspec.h b/pathspec.h
index a5b38e0..fec4399 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -130,6 +130,14 @@ void parse_pathspec_file(struct pathspec *pathspec,
void copy_pathspec(struct pathspec *dst, const struct pathspec *src);
void clear_pathspec(struct pathspec *);
+/*
+ * Add a human-readable string to "out" representing the PATHSPEC_* flags set
+ * in "magic". The result is suitable for error messages, but not for
+ * parsing as pathspec magic itself (you get 'icase' with quotes, not
+ * :(icase)).
+ */
+void pathspec_magic_names(unsigned magic, struct strbuf *out);
+
static inline int ps_strncmp(const struct pathspec_item *item,
const char *s1, const char *s2, size_t n)
{
diff --git a/reachable.c b/reachable.c
index 55bb114..60a7336 100644
--- a/reachable.c
+++ b/reachable.c
@@ -16,6 +16,8 @@
#include "object-store.h"
#include "pack-bitmap.h"
#include "pack-mtimes.h"
+#include "config.h"
+#include "run-command.h"
struct connectivity_progress {
struct progress *progress;
@@ -67,8 +69,77 @@ struct recent_data {
timestamp_t timestamp;
report_recent_object_fn *cb;
int ignore_in_core_kept_packs;
+
+ struct oidset extra_recent_oids;
+ int extra_recent_oids_loaded;
};
+static int run_one_gc_recent_objects_hook(struct oidset *set,
+ const char *args)
+{
+ struct child_process cmd = CHILD_PROCESS_INIT;
+ struct strbuf buf = STRBUF_INIT;
+ FILE *out;
+ int ret = 0;
+
+ cmd.use_shell = 1;
+ cmd.out = -1;
+
+ strvec_push(&cmd.args, args);
+
+ if (start_command(&cmd))
+ return -1;
+
+ out = xfdopen(cmd.out, "r");
+ while (strbuf_getline(&buf, out) != EOF) {
+ struct object_id oid;
+ const char *rest;
+
+ if (parse_oid_hex(buf.buf, &oid, &rest) || *rest) {
+ ret = error(_("invalid extra cruft tip: '%s'"), buf.buf);
+ break;
+ }
+
+ oidset_insert(set, &oid);
+ }
+
+ fclose(out);
+ ret |= finish_command(&cmd);
+
+ strbuf_release(&buf);
+ return ret;
+}
+
+static void load_gc_recent_objects(struct recent_data *data)
+{
+ const struct string_list *programs;
+ int ret = 0;
+ size_t i;
+
+ data->extra_recent_oids_loaded = 1;
+
+ if (git_config_get_string_multi("gc.recentobjectshook", &programs))
+ return;
+
+ for (i = 0; i < programs->nr; i++) {
+ ret = run_one_gc_recent_objects_hook(&data->extra_recent_oids,
+ programs->items[i].string);
+ if (ret)
+ die(_("unable to enumerate additional recent objects"));
+ }
+}
+
+static int obj_is_recent(const struct object_id *oid, timestamp_t mtime,
+ struct recent_data *data)
+{
+ if (mtime > data->timestamp)
+ return 1;
+
+ if (!data->extra_recent_oids_loaded)
+ load_gc_recent_objects(data);
+ return oidset_contains(&data->extra_recent_oids, oid);
+}
+
static void add_recent_object(const struct object_id *oid,
struct packed_git *pack,
off_t offset,
@@ -78,7 +149,7 @@ static void add_recent_object(const struct object_id *oid,
struct object *obj;
enum object_type type;
- if (mtime <= data->timestamp)
+ if (!obj_is_recent(oid, mtime, data))
return;
/*
@@ -193,16 +264,24 @@ int add_unseen_recent_objects_to_traversal(struct rev_info *revs,
data.cb = cb;
data.ignore_in_core_kept_packs = ignore_in_core_kept_packs;
+ oidset_init(&data.extra_recent_oids, 0);
+ data.extra_recent_oids_loaded = 0;
+
r = for_each_loose_object(add_recent_loose, &data,
FOR_EACH_OBJECT_LOCAL_ONLY);
if (r)
- return r;
+ goto done;
flags = FOR_EACH_OBJECT_LOCAL_ONLY | FOR_EACH_OBJECT_PACK_ORDER;
if (ignore_in_core_kept_packs)
flags |= FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS;
- return for_each_packed_object(add_recent_packed, &data, flags);
+ r = for_each_packed_object(add_recent_packed, &data, flags);
+
+done:
+ oidset_clear(&data.extra_recent_oids);
+
+ return r;
}
static int mark_object_seen(const struct object_id *oid,
diff --git a/refs.c b/refs.c
index d2a98e1..881a0da 100644
--- a/refs.c
+++ b/refs.c
@@ -2132,9 +2132,9 @@ void base_ref_store_init(struct ref_store *refs, struct repository *repo,
}
/* backend functions */
-int refs_pack_refs(struct ref_store *refs, unsigned int flags)
+int refs_pack_refs(struct ref_store *refs, struct pack_refs_opts *opts)
{
- return refs->be->pack_refs(refs, flags);
+ return refs->be->pack_refs(refs, opts);
}
int peel_iterated_oid(const struct object_id *base, struct object_id *peeled)
diff --git a/refs.h b/refs.h
index 123cfa4..933fdeb 100644
--- a/refs.h
+++ b/refs.h
@@ -63,6 +63,12 @@ struct worktree;
#define RESOLVE_REF_NO_RECURSE 0x02
#define RESOLVE_REF_ALLOW_BAD_NAME 0x04
+struct pack_refs_opts {
+ unsigned int flags;
+ struct ref_exclusions *exclusions;
+ struct string_list *includes;
+};
+
const char *refs_resolve_ref_unsafe(struct ref_store *refs,
const char *refname,
int resolve_flags,
@@ -405,7 +411,7 @@ void warn_dangling_symrefs(FILE *fp, const char *msg_fmt,
* Write a packed-refs file for the current repository.
* flags: Combination of the above PACK_REFS_* flags.
*/
-int refs_pack_refs(struct ref_store *refs, unsigned int flags);
+int refs_pack_refs(struct ref_store *refs, struct pack_refs_opts *opts);
/*
* Setup reflog before using. Fill in err and return -1 on failure.
diff --git a/refs/debug.c b/refs/debug.c
index 6f11e6d..c0fa707 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -123,10 +123,10 @@ static int debug_initial_transaction_commit(struct ref_store *refs,
return res;
}
-static int debug_pack_refs(struct ref_store *ref_store, unsigned int flags)
+static int debug_pack_refs(struct ref_store *ref_store, struct pack_refs_opts *opts)
{
struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
- int res = drefs->refs->be->pack_refs(drefs->refs, flags);
+ int res = drefs->refs->be->pack_refs(drefs->refs, opts);
trace_printf_key(&trace_refs, "pack_refs: %d\n", res);
return res;
}
diff --git a/refs/files-backend.c b/refs/files-backend.c
index bca7b85..9a8333c 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -21,6 +21,8 @@
#include "../worktree.h"
#include "../wrapper.h"
#include "../write-or-die.h"
+#include "../revision.h"
+#include <wildmatch.h>
/*
* This backend uses the following flags in `ref_update::flags` for
@@ -1175,17 +1177,15 @@ static void prune_refs(struct files_ref_store *refs, struct ref_to_prune **refs_
*/
static int should_pack_ref(const char *refname,
const struct object_id *oid, unsigned int ref_flags,
- unsigned int pack_flags)
+ struct pack_refs_opts *opts)
{
+ struct string_list_item *item;
+
/* Do not pack per-worktree refs: */
if (parse_worktree_ref(refname, NULL, NULL, NULL) !=
REF_WORKTREE_SHARED)
return 0;
- /* Do not pack non-tags unless PACK_REFS_ALL is set: */
- if (!(pack_flags & PACK_REFS_ALL) && !starts_with(refname, "refs/tags/"))
- return 0;
-
/* Do not pack symbolic refs: */
if (ref_flags & REF_ISSYMREF)
return 0;
@@ -1194,10 +1194,18 @@ static int should_pack_ref(const char *refname,
if (!ref_resolves_to_object(refname, the_repository, oid, ref_flags))
return 0;
- return 1;
+ if (ref_excluded(opts->exclusions, refname))
+ return 0;
+
+ for_each_string_list_item(item, opts->includes)
+ if (!wildmatch(item->string, refname, 0))
+ return 1;
+
+ return 0;
}
-static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)
+static int files_pack_refs(struct ref_store *ref_store,
+ struct pack_refs_opts *opts)
{
struct files_ref_store *refs =
files_downcast(ref_store, REF_STORE_WRITE | REF_STORE_ODB,
@@ -1222,8 +1230,7 @@ static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)
* in the packed ref cache. If the reference should be
* pruned, also add it to refs_to_prune.
*/
- if (!should_pack_ref(iter->refname, iter->oid, iter->flags,
- flags))
+ if (!should_pack_ref(iter->refname, iter->oid, iter->flags, opts))
continue;
/*
@@ -1237,7 +1244,7 @@ static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)
iter->refname, err.buf);
/* Schedule the loose reference for pruning if requested. */
- if ((flags & PACK_REFS_PRUNE)) {
+ if ((opts->flags & PACK_REFS_PRUNE)) {
struct ref_to_prune *n;
FLEX_ALLOC_STR(n, name, iter->refname);
oidcpy(&n->oid, iter->oid);
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 5b412a1..291e53f 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -1577,7 +1577,7 @@ static int packed_delete_refs(struct ref_store *ref_store, const char *msg,
}
static int packed_pack_refs(struct ref_store *ref_store UNUSED,
- unsigned int flags UNUSED)
+ struct pack_refs_opts *pack_opts UNUSED)
{
/*
* Packed refs are already packed. It might be that loose refs
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index a85d113..f72b7be 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -547,7 +547,8 @@ typedef int ref_transaction_commit_fn(struct ref_store *refs,
struct ref_transaction *transaction,
struct strbuf *err);
-typedef int pack_refs_fn(struct ref_store *ref_store, unsigned int flags);
+typedef int pack_refs_fn(struct ref_store *ref_store,
+ struct pack_refs_opts *opts);
typedef int create_symref_fn(struct ref_store *ref_store,
const char *ref_target,
const char *refs_heads_master,
diff --git a/replace-object.c b/replace-object.c
index e98825d..ae2d55b 100644
--- a/replace-object.c
+++ b/replace-object.c
@@ -64,7 +64,7 @@ void prepare_replace_object(struct repository *r)
* replacement object's name (replaced recursively, if necessary).
* The return value is either oid or a pointer to a
* permanently-allocated value. This function always respects replace
- * references, regardless of the value of read_replace_refs.
+ * references, regardless of the value of r->settings.read_replace_refs.
*/
const struct object_id *do_lookup_replace_object(struct repository *r,
const struct object_id *oid)
@@ -84,3 +84,29 @@ const struct object_id *do_lookup_replace_object(struct repository *r,
}
die(_("replace depth too high for object %s"), oid_to_hex(oid));
}
+
+/*
+ * This indicator determines whether replace references should be
+ * respected process-wide, regardless of which repository is being
+ * using at the time.
+ */
+static int read_replace_refs = 1;
+
+void disable_replace_refs(void)
+{
+ read_replace_refs = 0;
+}
+
+int replace_refs_enabled(struct repository *r)
+{
+ if (!read_replace_refs)
+ return 0;
+
+ if (r->gitdir) {
+ prepare_repo_settings(r);
+ return r->settings.read_replace_refs;
+ }
+
+ /* repository has no objects or refs. */
+ return 0;
+}
diff --git a/replace-object.h b/replace-object.h
index 500482b..ba478eb 100644
--- a/replace-object.h
+++ b/replace-object.h
@@ -5,14 +5,6 @@
#include "repository.h"
#include "object-store.h"
-/*
- * Do replace refs need to be checked this run? This variable is
- * initialized to true unless --no-replace-object is used or
- * $GIT_NO_REPLACE_OBJECTS is set, but is set to false by some
- * commands that do not want replace references to be active.
- */
-extern int read_replace_refs;
-
struct replace_object {
struct oidmap_entry original;
struct object_id replacement;
@@ -28,6 +20,18 @@ const struct object_id *do_lookup_replace_object(struct repository *r,
const struct object_id *oid);
/*
+ * Some commands disable replace-refs unconditionally, and otherwise each
+ * repository could alter the core.useReplaceRefs config value.
+ *
+ * Return 1 if and only if all of the following are true:
+ *
+ * a. disable_replace_refs() has not been called.
+ * b. GIT_NO_REPLACE_OBJECTS is unset or zero.
+ * c. the given repository does not have core.useReplaceRefs=false.
+ */
+int replace_refs_enabled(struct repository *r);
+
+/*
* If object sha1 should be replaced, return the replacement object's
* name (replaced recursively, if necessary). The return value is
* either sha1 or a pointer to a permanently-allocated value. When
@@ -41,11 +45,19 @@ const struct object_id *do_lookup_replace_object(struct repository *r,
static inline const struct object_id *lookup_replace_object(struct repository *r,
const struct object_id *oid)
{
- if (!read_replace_refs ||
+ if (!replace_refs_enabled(r) ||
(r->objects->replace_map_initialized &&
r->objects->replace_map->map.tablesize == 0))
return oid;
return do_lookup_replace_object(r, oid);
}
+/*
+ * Some commands override config and environment settings for using
+ * replace references. Use this method to disable the setting and ensure
+ * those other settings will not override this choice. This applies
+ * globally to all in-process repositories.
+ */
+void disable_replace_refs(void);
+
#endif /* REPLACE_OBJECT_H */
diff --git a/repo-settings.c b/repo-settings.c
index d220c5d..525f69c 100644
--- a/repo-settings.c
+++ b/repo-settings.c
@@ -41,8 +41,10 @@ void prepare_repo_settings(struct repository *r)
repo_cfg_bool(r, "feature.experimental", &experimental, 0);
/* Defaults modified by feature.* */
- if (experimental)
+ if (experimental) {
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
+ r->settings.pack_use_bitmap_boundary_traversal = 1;
+ }
if (manyfiles) {
r->settings.index_version = 4;
r->settings.index_skip_hash = 1;
@@ -62,6 +64,10 @@ void prepare_repo_settings(struct repository *r)
repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0);
repo_cfg_bool(r, "index.skiphash", &r->settings.index_skip_hash, r->settings.index_skip_hash);
repo_cfg_bool(r, "pack.readreverseindex", &r->settings.pack_read_reverse_index, 1);
+ repo_cfg_bool(r, "pack.usebitmapboundarytraversal",
+ &r->settings.pack_use_bitmap_boundary_traversal,
+ r->settings.pack_use_bitmap_boundary_traversal);
+ repo_cfg_bool(r, "core.usereplacerefs", &r->settings.read_replace_refs, 1);
/*
* The GIT_TEST_MULTI_PACK_INDEX variable is special in that
diff --git a/repository.c b/repository.c
index c53e480..104960f 100644
--- a/repository.c
+++ b/repository.c
@@ -182,6 +182,7 @@ int repo_init(struct repository *repo,
goto error;
repo_set_hash_algo(repo, format.hash_algo);
+ repo->repository_format_worktree_config = format.worktree_config;
/* take ownership of format.partial_clone */
repo->repository_format_partial_clone = format.partial_clone;
diff --git a/repository.h b/repository.h
index 1a13ff2..af294de 100644
--- a/repository.h
+++ b/repository.h
@@ -37,6 +37,16 @@ struct repo_settings {
int command_requires_full_index;
int sparse_index;
int pack_read_reverse_index;
+ int pack_use_bitmap_boundary_traversal;
+
+ /*
+ * Does this repository have core.useReplaceRefs=true (on by
+ * default)? This provides a repository-scoped version of this
+ * config, though it could be disabled process-wide via some Git
+ * builtins or the --no-replace-objects option. See
+ * replace_refs_enabled() for more details.
+ */
+ int read_replace_refs;
struct fsmonitor_settings *fsmonitor; /* lazily loaded */
@@ -163,6 +173,7 @@ struct repository {
struct promisor_remote_config *promisor_remote_config;
/* Configurations */
+ int repository_format_worktree_config;
/* Indicate if a repository has a different 'commondir' from 'gitdir' */
unsigned different_commondir:1;
diff --git a/revision.h b/revision.h
index 3182874..25776af 100644
--- a/revision.h
+++ b/revision.h
@@ -87,7 +87,7 @@ struct rev_cmdline_info {
struct ref_exclusions {
/*
* Excluded refs is a list of wildmatch patterns. If any of the
- * patterns matches, the reference will be excluded.
+ * patterns match, the reference will be excluded.
*/
struct string_list excluded_refs;
diff --git a/run-command.c b/run-command.c
index 60c9419..758f853 100644
--- a/run-command.c
+++ b/run-command.c
@@ -307,7 +307,6 @@ enum child_errcode {
CHILD_ERR_DUP2,
CHILD_ERR_CLOSE,
CHILD_ERR_SIGPROCMASK,
- CHILD_ERR_ENOENT,
CHILD_ERR_SILENT,
CHILD_ERR_ERRNO
};
@@ -390,9 +389,6 @@ static void child_err_spew(struct child_process *cmd, struct child_err *cerr)
case CHILD_ERR_SIGPROCMASK:
error_errno("sigprocmask failed restoring signals");
break;
- case CHILD_ERR_ENOENT:
- error_errno("cannot run %s", cmd->args.v[0]);
- break;
case CHILD_ERR_SILENT:
break;
case CHILD_ERR_ERRNO:
@@ -846,13 +842,9 @@ fail_pipe:
execve(argv.v[0], (char *const *) argv.v,
(char *const *) childenv);
- if (errno == ENOENT) {
- if (cmd->silent_exec_failure)
- child_die(CHILD_ERR_SILENT);
- child_die(CHILD_ERR_ENOENT);
- } else {
- child_die(CHILD_ERR_ERRNO);
- }
+ if (cmd->silent_exec_failure && errno == ENOENT)
+ child_die(CHILD_ERR_SILENT);
+ child_die(CHILD_ERR_ERRNO);
}
atfork_parent(&as);
if (cmd->pid < 0)
diff --git a/setup.c b/setup.c
index 4585822..6f6e92b 100644
--- a/setup.c
+++ b/setup.c
@@ -650,11 +650,10 @@ static int check_repository_format_gently(const char *gitdir, struct repository_
}
repository_format_precious_objects = candidate->precious_objects;
- repository_format_worktree_config = candidate->worktree_config;
string_list_clear(&candidate->unknown_extensions, 0);
string_list_clear(&candidate->v1_only_extensions, 0);
- if (repository_format_worktree_config) {
+ if (candidate->worktree_config) {
/*
* pick up core.bare and core.worktree from per-worktree
* config if present
@@ -1423,11 +1422,6 @@ int discover_git_directory(struct strbuf *commondir,
return -1;
}
- /* take ownership of candidate.partial_clone */
- the_repository->repository_format_partial_clone =
- candidate.partial_clone;
- candidate.partial_clone = NULL;
-
clear_repository_format(&candidate);
return 0;
}
@@ -1560,6 +1554,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
}
if (startup_info->have_repository) {
repo_set_hash_algo(the_repository, repo_fmt.hash_algo);
+ the_repository->repository_format_worktree_config =
+ repo_fmt.worktree_config;
/* take ownership of repo_fmt.partial_clone */
the_repository->repository_format_partial_clone =
repo_fmt.partial_clone;
@@ -1651,6 +1647,8 @@ void check_repository_format(struct repository_format *fmt)
check_repository_format_gently(get_git_dir(), fmt, NULL);
startup_info->have_repository = 1;
repo_set_hash_algo(the_repository, fmt->hash_algo);
+ the_repository->repository_format_worktree_config =
+ fmt->worktree_config;
the_repository->repository_format_partial_clone =
xstrdup_or_null(fmt->partial_clone);
clear_repository_format(&repo_fmt);
diff --git a/statinfo.h b/statinfo.h
index e49e305..fe8df63 100644
--- a/statinfo.h
+++ b/statinfo.h
@@ -21,4 +21,18 @@ struct stat_data {
unsigned int sd_size;
};
+#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
+#define DTYPE(de) ((de)->d_type)
+#else
+#undef DT_UNKNOWN
+#undef DT_DIR
+#undef DT_REG
+#undef DT_LNK
+#define DT_UNKNOWN 0
+#define DT_DIR 1
+#define DT_REG 2
+#define DT_LNK 3
+#define DTYPE(de) DT_UNKNOWN
+#endif
+
#endif
diff --git a/strbuf.c b/strbuf.c
index 08eec8f..31dc48c 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -721,11 +721,11 @@ static int strbuf_getdelim(struct strbuf *sb, FILE *fp, int term)
return 0;
}
-int strbuf_getline(struct strbuf *sb, FILE *fp)
+int strbuf_getdelim_strip_crlf(struct strbuf *sb, FILE *fp, int term)
{
- if (strbuf_getwholeline(sb, fp, '\n'))
+ if (strbuf_getwholeline(sb, fp, term))
return EOF;
- if (sb->buf[sb->len - 1] == '\n') {
+ if (term == '\n' && sb->buf[sb->len - 1] == '\n') {
strbuf_setlen(sb, sb->len - 1);
if (sb->len && sb->buf[sb->len - 1] == '\r')
strbuf_setlen(sb, sb->len - 1);
@@ -733,6 +733,11 @@ int strbuf_getline(struct strbuf *sb, FILE *fp)
return 0;
}
+int strbuf_getline(struct strbuf *sb, FILE *fp)
+{
+ return strbuf_getdelim_strip_crlf(sb, fp, '\n');
+}
+
int strbuf_getline_lf(struct strbuf *sb, FILE *fp)
{
return strbuf_getdelim(sb, fp, '\n');
diff --git a/strbuf.h b/strbuf.h
index 3dfeadb..0e69b65 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -476,6 +476,18 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint);
ssize_t strbuf_write(struct strbuf *sb, FILE *stream);
/**
+ * Read from a FILE * until the specified terminator is encountered,
+ * overwriting the existing contents of the strbuf.
+ *
+ * Reading stops after the terminator or at EOF. The terminator is
+ * removed from the buffer before returning. If the terminator is LF
+ * and if it is preceded by a CR, then the whole CRLF is stripped.
+ * Returns 0 unless there was nothing left before EOF, in which case
+ * it returns `EOF`.
+ */
+int strbuf_getdelim_strip_crlf(struct strbuf *sb, FILE *fp, int term);
+
+/**
* Read a line from a FILE *, overwriting the existing contents of
* the strbuf. The strbuf_getline*() family of functions share
* this signature, but have different line termination conventions.
diff --git a/submodule-config.c b/submodule-config.c
index 58dfbde..7eb7a0d 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -659,7 +659,6 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void
config_source.file = file;
} else if (repo_get_oid(repo, GITMODULES_INDEX, &oid) >= 0 ||
repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {
- config_source.repo = repo;
config_source.blob = oidstr = xstrdup(oid_to_hex(&oid));
if (repo != the_repository)
add_submodule_odb_by_path(repo->objects->odb->path);
@@ -667,7 +666,7 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void
goto out;
}
- config_with_options(fn, data, &config_source, &opts);
+ config_with_options(fn, data, &config_source, repo, &opts);
out:
free(oidstr);
diff --git a/t/README b/t/README
index bdfac4c..b71a065 100644
--- a/t/README
+++ b/t/README
@@ -442,6 +442,10 @@ GIT_TEST_INDEX_VERSION=<n> exercises the index read/write code path
for the index version specified. Can be set to any valid version
(currently 2, 3, or 4).
+GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=<boolean> if enabled will
+use the boundary-based bitmap traversal algorithm. See the documentation
+of `pack.useBitmapBoundaryTraversal` for more details.
+
GIT_TEST_PACK_SPARSE=<boolean> if disabled will default the pack-objects
builtin to use the non-sparse object walk. This can still be overridden by
the --sparse command-line argument.
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 6d8f844..a6977b5 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -5,6 +5,7 @@
#include "worktree.h"
#include "object-store.h"
#include "repository.h"
+#include "revision.h"
struct flag_definition {
const char *name;
@@ -116,8 +117,16 @@ static struct flag_definition pack_flags[] = { FLAG_DEF(PACK_REFS_PRUNE),
static int cmd_pack_refs(struct ref_store *refs, const char **argv)
{
unsigned int flags = arg_flags(*argv++, "flags", pack_flags);
+ static struct ref_exclusions exclusions = REF_EXCLUSIONS_INIT;
+ static struct string_list included_refs = STRING_LIST_INIT_NODUP;
+ struct pack_refs_opts pack_opts = { .flags = flags,
+ .exclusions = &exclusions,
+ .includes = &included_refs };
- return refs_pack_refs(refs, flags);
+ if (pack_opts.flags & PACK_REFS_ALL)
+ string_list_append(pack_opts.includes, "*");
+
+ return refs_pack_refs(refs, &pack_opts);
}
static int cmd_create_symref(struct ref_store *refs, const char **argv)
diff --git a/t/lib-credential.sh b/t/lib-credential.sh
index f1ab92b..032b2d8 100644
--- a/t/lib-credential.sh
+++ b/t/lib-credential.sh
@@ -44,6 +44,10 @@ helper_test_clean() {
reject $1 https example.com user1
reject $1 https example.com user2
reject $1 https example.com user4
+ reject $1 https example.com user-distinct-pass
+ reject $1 https example.com user-overwrite
+ reject $1 https example.com user-erase1
+ reject $1 https example.com user-erase2
reject $1 http path.tld user
reject $1 https timeout.tld user
reject $1 https sso.tld
@@ -167,6 +171,49 @@ helper_test() {
EOF
'
+ test_expect_success "helper ($HELPER) overwrites on store" '
+ check approve $HELPER <<-\EOF &&
+ protocol=https
+ host=example.com
+ username=user-overwrite
+ password=pass1
+ EOF
+ check approve $HELPER <<-\EOF &&
+ protocol=https
+ host=example.com
+ username=user-overwrite
+ password=pass2
+ EOF
+ check fill $HELPER <<-\EOF &&
+ protocol=https
+ host=example.com
+ username=user-overwrite
+ --
+ protocol=https
+ host=example.com
+ username=user-overwrite
+ password=pass2
+ EOF
+ check reject $HELPER <<-\EOF &&
+ protocol=https
+ host=example.com
+ username=user-overwrite
+ password=pass2
+ EOF
+ check fill $HELPER <<-\EOF
+ protocol=https
+ host=example.com
+ username=user-overwrite
+ --
+ protocol=https
+ host=example.com
+ username=user-overwrite
+ password=askpass-password
+ --
+ askpass: Password for '\''https://user-overwrite@example.com'\'':
+ EOF
+ '
+
test_expect_success "helper ($HELPER) can forget host" '
check reject $HELPER <<-\EOF &&
protocol=https
@@ -221,6 +268,31 @@ helper_test() {
EOF
'
+ test_expect_success "helper ($HELPER) does not erase a password distinct from input" '
+ check approve $HELPER <<-\EOF &&
+ protocol=https
+ host=example.com
+ username=user-distinct-pass
+ password=pass1
+ EOF
+ check reject $HELPER <<-\EOF &&
+ protocol=https
+ host=example.com
+ username=user-distinct-pass
+ password=pass2
+ EOF
+ check fill $HELPER <<-\EOF
+ protocol=https
+ host=example.com
+ username=user-distinct-pass
+ --
+ protocol=https
+ host=example.com
+ username=user-distinct-pass
+ password=pass1
+ EOF
+ '
+
test_expect_success "helper ($HELPER) can forget user" '
check reject $HELPER <<-\EOF &&
protocol=https
@@ -272,6 +344,37 @@ helper_test() {
EOF
'
+ test_expect_success "helper ($HELPER) erases all matching credentials" '
+ check approve $HELPER <<-\EOF &&
+ protocol=https
+ host=example.com
+ username=user-erase1
+ password=pass1
+ EOF
+ check approve $HELPER <<-\EOF &&
+ protocol=https
+ host=example.com
+ username=user-erase2
+ password=pass1
+ EOF
+ check reject $HELPER <<-\EOF &&
+ protocol=https
+ host=example.com
+ EOF
+ check fill $HELPER <<-\EOF
+ protocol=https
+ host=example.com
+ --
+ protocol=https
+ host=example.com
+ username=askpass-username
+ password=askpass-password
+ --
+ askpass: Username for '\''https://example.com'\'':
+ askpass: Password for '\''https://askpass-username@example.com'\'':
+ EOF
+ '
+
: ${GIT_TEST_LONG_CRED_BUFFER:=1024}
# 23 bytes accounts for "wwwauth[]=basic realm=" plus NUL
LONG_VALUE_LEN=$((GIT_TEST_LONG_CRED_BUFFER - 23))
diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index 1147855..739e6ec 100644
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -135,8 +135,9 @@ test_lazy_prereq GPGSSH '
'
test_lazy_prereq GPGSSH_VERIFYTIME '
+ test_have_prereq GPGSSH &&
# Check if ssh-keygen has a verify-time option by passing an invalid date to it
- ssh-keygen -Overify-time=INVALID -Y check-novalidate -s doesnotmatter 2>&1 | grep -q -F "Invalid \"verify-time\"" &&
+ ssh-keygen -Overify-time=INVALID -Y check-novalidate -n "git" -s doesnotmatter 2>&1 | grep -q -F "Invalid \"verify-time\"" &&
# Set up keys with key lifetimes
ssh-keygen -t ed25519 -N "" -C "timeboxed valid key" -f "${GPGSSH_KEY_TIMEBOXEDVALID}" >/dev/null &&
diff --git a/t/perf/p2000-sparse-operations.sh b/t/perf/p2000-sparse-operations.sh
index 901cc49..96ed3e1 100755
--- a/t/perf/p2000-sparse-operations.sh
+++ b/t/perf/p2000-sparse-operations.sh
@@ -131,5 +131,8 @@ test_perf_on_all git describe --dirty
test_perf_on_all 'echo >>new && git describe --dirty'
test_perf_on_all git diff-files
test_perf_on_all git diff-files -- $SPARSE_CONE/a
+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_done
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 8ea31d1..6e300be 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -1014,7 +1014,7 @@ test_expect_success 'validate object ID for a known tree' '
'
test_expect_success 'showing tree with git ls-tree' '
- git ls-tree $tree >current
+ git ls-tree $tree >current
'
test_expect_success 'git ls-tree output for a known tree' '
diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh
index 0a5713c..d1b3be8 100755
--- a/t/t0030-stripspace.sh
+++ b/t/t0030-stripspace.sh
@@ -17,396 +17,378 @@ printf_git_stripspace () {
printf "$1" | git stripspace
}
-test_expect_success \
- 'long lines without spaces should be unchanged' '
- echo "$ttt" >expect &&
- git stripspace <expect >actual &&
- test_cmp expect actual &&
-
- echo "$ttt$ttt" >expect &&
- git stripspace <expect >actual &&
- test_cmp expect actual &&
-
- echo "$ttt$ttt$ttt" >expect &&
- git stripspace <expect >actual &&
- test_cmp expect actual &&
-
- echo "$ttt$ttt$ttt$ttt" >expect &&
- git stripspace <expect >actual &&
- test_cmp expect actual
+test_expect_success 'long lines without spaces should be unchanged' '
+ echo "$ttt" >expect &&
+ git stripspace <expect >actual &&
+ test_cmp expect actual &&
+
+ echo "$ttt$ttt" >expect &&
+ git stripspace <expect >actual &&
+ test_cmp expect actual &&
+
+ echo "$ttt$ttt$ttt" >expect &&
+ git stripspace <expect >actual &&
+ test_cmp expect actual &&
+
+ echo "$ttt$ttt$ttt$ttt" >expect &&
+ git stripspace <expect >actual &&
+ test_cmp expect actual
'
-test_expect_success \
- 'lines with spaces at the beginning should be unchanged' '
- echo "$sss$ttt" >expect &&
- git stripspace <expect >actual &&
- test_cmp expect actual &&
+test_expect_success 'lines with spaces at the beginning should be unchanged' '
+ echo "$sss$ttt" >expect &&
+ git stripspace <expect >actual &&
+ test_cmp expect actual &&
- echo "$sss$sss$ttt" >expect &&
- git stripspace <expect >actual &&
- test_cmp expect actual &&
+ echo "$sss$sss$ttt" >expect &&
+ git stripspace <expect >actual &&
+ test_cmp expect actual &&
- echo "$sss$sss$sss$ttt" >expect &&
- git stripspace <expect >actual &&
- test_cmp expect actual
+ echo "$sss$sss$sss$ttt" >expect &&
+ git stripspace <expect >actual &&
+ test_cmp expect actual
'
-test_expect_success \
- 'lines with intermediate spaces should be unchanged' '
- echo "$ttt$sss$ttt" >expect &&
- git stripspace <expect >actual &&
- test_cmp expect actual &&
+test_expect_success 'lines with intermediate spaces should be unchanged' '
+ echo "$ttt$sss$ttt" >expect &&
+ git stripspace <expect >actual &&
+ test_cmp expect actual &&
- echo "$ttt$sss$sss$ttt" >expect &&
- git stripspace <expect >actual &&
- test_cmp expect actual
+ echo "$ttt$sss$sss$ttt" >expect &&
+ git stripspace <expect >actual &&
+ test_cmp expect actual
'
-test_expect_success \
- 'consecutive blank lines should be unified' '
- printf "$ttt\n\n$ttt\n" > expect &&
- printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+test_expect_success 'consecutive blank lines should be unified' '
+ printf "$ttt\n\n$ttt\n" > expect &&
+ printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt\n\n$ttt\n" > expect &&
- printf "$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt\n\n$ttt\n" > expect &&
+ printf "$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt$ttt\n\n$ttt\n" > expect &&
- printf "$ttt$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt$ttt\n\n$ttt\n" > expect &&
+ printf "$ttt$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n\n$ttt\n" > expect &&
- printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n\n$ttt\n" > expect &&
+ printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n\n$ttt$ttt\n" > expect &&
- printf "$ttt\n\n\n\n\n$ttt$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n\n$ttt$ttt\n" > expect &&
+ printf "$ttt\n\n\n\n\n$ttt$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n\n$ttt$ttt$ttt\n" > expect &&
- printf "$ttt\n\n\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n\n$ttt$ttt$ttt\n" > expect &&
+ printf "$ttt\n\n\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n\n$ttt\n" > expect &&
- printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n\n$ttt\n" > expect &&
+ printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt\n\n$ttt\n" > expect &&
- printf "$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt\n\n$ttt\n" > expect &&
+ printf "$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt$ttt\n\n$ttt\n" > expect &&
- printf "$ttt$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt$ttt\n\n$ttt\n" > expect &&
+ printf "$ttt$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n\n$ttt\n" > expect &&
- printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n\n$ttt\n" > expect &&
+ printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n\n$ttt$ttt\n" > expect &&
- printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n\n$ttt$ttt\n" > expect &&
+ printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n\n$ttt$ttt$ttt\n" > expect &&
- printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt$ttt\n" | git stripspace >actual &&
- test_cmp expect actual
+ printf "$ttt\n\n$ttt$ttt$ttt\n" > expect &&
+ printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual
'
-test_expect_success \
- 'only consecutive blank lines should be completely removed' '
+test_expect_success 'only consecutive blank lines should be completely removed' '
+ printf "\n" | git stripspace >actual &&
+ test_must_be_empty actual &&
- printf "\n" | git stripspace >actual &&
- test_must_be_empty actual &&
+ printf "\n\n\n" | git stripspace >actual &&
+ test_must_be_empty actual &&
- printf "\n\n\n" | git stripspace >actual &&
- test_must_be_empty actual &&
+ printf "$sss\n$sss\n$sss\n" | git stripspace >actual &&
+ test_must_be_empty actual &&
- printf "$sss\n$sss\n$sss\n" | git stripspace >actual &&
- test_must_be_empty actual &&
+ printf "$sss$sss\n$sss\n\n" | git stripspace >actual &&
+ test_must_be_empty actual &&
- printf "$sss$sss\n$sss\n\n" | git stripspace >actual &&
- test_must_be_empty actual &&
+ printf "\n$sss\n$sss$sss\n" | git stripspace >actual &&
+ test_must_be_empty actual &&
- printf "\n$sss\n$sss$sss\n" | git stripspace >actual &&
- test_must_be_empty actual &&
+ printf "$sss$sss$sss$sss\n\n\n" | git stripspace >actual &&
+ test_must_be_empty actual &&
- printf "$sss$sss$sss$sss\n\n\n" | git stripspace >actual &&
- test_must_be_empty actual &&
+ printf "\n$sss$sss$sss$sss\n\n" | git stripspace >actual &&
+ test_must_be_empty actual &&
- printf "\n$sss$sss$sss$sss\n\n" | git stripspace >actual &&
- test_must_be_empty actual &&
-
- printf "\n\n$sss$sss$sss$sss\n" | git stripspace >actual &&
- test_must_be_empty actual
+ printf "\n\n$sss$sss$sss$sss\n" | git stripspace >actual &&
+ test_must_be_empty actual
'
-test_expect_success \
- 'consecutive blank lines at the beginning should be removed' '
- printf "$ttt\n" > expect &&
- printf "\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+test_expect_success 'consecutive blank lines at the beginning should be removed' '
+ printf "$ttt\n" > expect &&
+ printf "\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n" > expect &&
- printf "\n\n\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n" > expect &&
+ printf "\n\n\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt\n" > expect &&
- printf "\n\n\n$ttt$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt\n" > expect &&
+ printf "\n\n\n$ttt$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt$ttt\n" > expect &&
- printf "\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt$ttt\n" > expect &&
+ printf "\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt$ttt$ttt\n" > expect &&
- printf "\n\n\n$ttt$ttt$ttt$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt$ttt$ttt\n" > expect &&
+ printf "\n\n\n$ttt$ttt$ttt$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n" > expect &&
+ printf "$ttt\n" > expect &&
- printf "$sss\n$sss\n$sss\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$sss\n$sss\n$sss\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "\n$sss\n$sss$sss\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "\n$sss\n$sss$sss\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$sss$sss\n$sss\n\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$sss$sss\n$sss\n\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$sss$sss$sss\n\n\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$sss$sss$sss\n\n\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "\n$sss$sss$sss\n\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "\n$sss$sss$sss\n\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "\n\n$sss$sss$sss\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual
+ printf "\n\n$sss$sss$sss\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual
'
-test_expect_success \
- 'consecutive blank lines at the end should be removed' '
- printf "$ttt\n" > expect &&
- printf "$ttt\n\n" | git stripspace >actual &&
- test_cmp expect actual &&
+test_expect_success 'consecutive blank lines at the end should be removed' '
+ printf "$ttt\n" > expect &&
+ printf "$ttt\n\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n" > expect &&
- printf "$ttt\n\n\n\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n" > expect &&
+ printf "$ttt\n\n\n\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt\n" > expect &&
- printf "$ttt$ttt\n\n\n\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt\n" > expect &&
+ printf "$ttt$ttt\n\n\n\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt$ttt\n" > expect &&
- printf "$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt$ttt\n" > expect &&
+ printf "$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt$ttt$ttt\n" > expect &&
- printf "$ttt$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt$ttt$ttt\n" > expect &&
+ printf "$ttt$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n" > expect &&
+ printf "$ttt\n" > expect &&
- printf "$ttt\n$sss\n$sss\n$sss\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n$sss\n$sss\n$sss\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n\n$sss\n$sss$sss\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n\n$sss\n$sss$sss\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n$sss$sss\n$sss\n\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n$sss$sss\n$sss\n\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n$sss$sss$sss\n\n\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n$sss$sss$sss\n\n\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n\n$sss$sss$sss\n\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n\n$sss$sss$sss\n\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n\n\n$sss$sss$sss\n" | git stripspace >actual &&
- test_cmp expect actual
+ printf "$ttt\n\n\n$sss$sss$sss\n" | git stripspace >actual &&
+ test_cmp expect actual
'
-test_expect_success \
- 'text without newline at end should end with newline' '
- test_stdout_line_count -gt 0 printf_git_stripspace "$ttt" &&
- test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt" &&
- test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt" &&
- test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$ttt"
+test_expect_success 'text without newline at end should end with newline' '
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt" &&
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt" &&
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt" &&
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$ttt"
'
# text plus spaces at the end:
-test_expect_success \
- 'text plus spaces without newline at end should end with newline' '
- test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss" &&
- test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss" &&
- test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$sss" &&
- test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss" &&
- test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss$sss" &&
- test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss$sss"
+test_expect_success 'text plus spaces without newline at end should end with newline' '
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss" &&
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss" &&
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$sss" &&
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss" &&
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss$sss" &&
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss$sss"
'
-test_expect_success \
- 'text plus spaces without newline at end should not show spaces' '
- printf "$ttt$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- printf "$ttt$ttt$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- printf "$ttt$ttt$ttt$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- printf "$ttt$sss$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- printf "$ttt$ttt$sss$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- printf "$ttt$sss$sss$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null
+test_expect_success 'text plus spaces without newline at end should not show spaces' '
+ printf "$ttt$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ printf "$ttt$ttt$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ printf "$ttt$ttt$ttt$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ printf "$ttt$sss$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ printf "$ttt$ttt$sss$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ printf "$ttt$sss$sss$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null
'
-test_expect_success \
- 'text plus spaces without newline should show the correct lines' '
- printf "$ttt\n" >expect &&
- printf "$ttt$sss" | git stripspace >actual &&
- test_cmp expect actual &&
+test_expect_success 'text plus spaces without newline should show the correct lines' '
+ printf "$ttt\n" >expect &&
+ printf "$ttt$sss" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n" >expect &&
- printf "$ttt$sss$sss" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n" >expect &&
+ printf "$ttt$sss$sss" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n" >expect &&
- printf "$ttt$sss$sss$sss" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n" >expect &&
+ printf "$ttt$sss$sss$sss" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt\n" >expect &&
- printf "$ttt$ttt$sss" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt\n" >expect &&
+ printf "$ttt$ttt$sss" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt\n" >expect &&
- printf "$ttt$ttt$sss$sss" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt\n" >expect &&
+ printf "$ttt$ttt$sss$sss" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt$ttt\n" >expect &&
- printf "$ttt$ttt$ttt$sss" | git stripspace >actual &&
- test_cmp expect actual
+ printf "$ttt$ttt$ttt\n" >expect &&
+ printf "$ttt$ttt$ttt$sss" | git stripspace >actual &&
+ test_cmp expect actual
'
-test_expect_success \
- 'text plus spaces at end should not show spaces' '
- echo "$ttt$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- echo "$ttt$ttt$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- echo "$ttt$ttt$ttt$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- echo "$ttt$sss$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- echo "$ttt$ttt$sss$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- echo "$ttt$sss$sss$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null
+test_expect_success 'text plus spaces at end should not show spaces' '
+ echo "$ttt$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ echo "$ttt$ttt$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ echo "$ttt$ttt$ttt$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ echo "$ttt$sss$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ echo "$ttt$ttt$sss$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ echo "$ttt$sss$sss$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null
'
-test_expect_success \
- 'text plus spaces at end should be cleaned and newline must remain' '
- echo "$ttt" >expect &&
- echo "$ttt$sss" | git stripspace >actual &&
- test_cmp expect actual &&
+test_expect_success 'text plus spaces at end should be cleaned and newline must remain' '
+ echo "$ttt" >expect &&
+ echo "$ttt$sss" | git stripspace >actual &&
+ test_cmp expect actual &&
- echo "$ttt" >expect &&
- echo "$ttt$sss$sss" | git stripspace >actual &&
- test_cmp expect actual &&
+ echo "$ttt" >expect &&
+ echo "$ttt$sss$sss" | git stripspace >actual &&
+ test_cmp expect actual &&
- echo "$ttt" >expect &&
- echo "$ttt$sss$sss$sss" | git stripspace >actual &&
- test_cmp expect actual &&
+ echo "$ttt" >expect &&
+ echo "$ttt$sss$sss$sss" | git stripspace >actual &&
+ test_cmp expect actual &&
- echo "$ttt$ttt" >expect &&
- echo "$ttt$ttt$sss" | git stripspace >actual &&
- test_cmp expect actual &&
+ echo "$ttt$ttt" >expect &&
+ echo "$ttt$ttt$sss" | git stripspace >actual &&
+ test_cmp expect actual &&
- echo "$ttt$ttt" >expect &&
- echo "$ttt$ttt$sss$sss" | git stripspace >actual &&
- test_cmp expect actual &&
+ echo "$ttt$ttt" >expect &&
+ echo "$ttt$ttt$sss$sss" | git stripspace >actual &&
+ test_cmp expect actual &&
- echo "$ttt$ttt$ttt" >expect &&
- echo "$ttt$ttt$ttt$sss" | git stripspace >actual &&
- test_cmp expect actual
+ echo "$ttt$ttt$ttt" >expect &&
+ echo "$ttt$ttt$ttt$sss" | git stripspace >actual &&
+ test_cmp expect actual
'
# spaces only:
-test_expect_success \
- 'spaces with newline at end should be replaced with empty string' '
- echo | git stripspace >actual &&
- test_must_be_empty actual &&
+test_expect_success 'spaces with newline at end should be replaced with empty string' '
+ echo | git stripspace >actual &&
+ test_must_be_empty actual &&
- echo "$sss" | git stripspace >actual &&
- test_must_be_empty actual &&
+ echo "$sss" | git stripspace >actual &&
+ test_must_be_empty actual &&
- echo "$sss$sss" | git stripspace >actual &&
- test_must_be_empty actual &&
+ echo "$sss$sss" | git stripspace >actual &&
+ test_must_be_empty actual &&
- echo "$sss$sss$sss" | git stripspace >actual &&
- test_must_be_empty actual &&
+ echo "$sss$sss$sss" | git stripspace >actual &&
+ test_must_be_empty actual &&
- echo "$sss$sss$sss$sss" | git stripspace >actual &&
- test_must_be_empty actual
+ echo "$sss$sss$sss$sss" | git stripspace >actual &&
+ test_must_be_empty actual
'
-test_expect_success \
- 'spaces without newline at end should not show spaces' '
- printf "" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- printf "$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- printf "$sss$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- printf "$sss$sss$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null &&
- printf "$sss$sss$sss$sss" | git stripspace >tmp &&
- ! grep " " tmp >/dev/null
+test_expect_success 'spaces without newline at end should not show spaces' '
+ printf "" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ printf "$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ printf "$sss$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ printf "$sss$sss$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null &&
+ printf "$sss$sss$sss$sss" | git stripspace >tmp &&
+ ! grep " " tmp >/dev/null
'
-test_expect_success \
- 'spaces without newline at end should be replaced with empty string' '
- printf "" | git stripspace >actual &&
- test_must_be_empty actual &&
+test_expect_success 'spaces without newline at end should be replaced with empty string' '
+ printf "" | git stripspace >actual &&
+ test_must_be_empty actual &&
- printf "$sss$sss" | git stripspace >actual &&
- test_must_be_empty actual &&
+ printf "$sss$sss" | git stripspace >actual &&
+ test_must_be_empty actual &&
- printf "$sss$sss$sss" | git stripspace >actual &&
- test_must_be_empty actual &&
+ printf "$sss$sss$sss" | git stripspace >actual &&
+ test_must_be_empty actual &&
- printf "$sss$sss$sss$sss" | git stripspace >actual &&
- test_must_be_empty actual
+ printf "$sss$sss$sss$sss" | git stripspace >actual &&
+ test_must_be_empty actual
'
-test_expect_success \
- 'consecutive text lines should be unchanged' '
- printf "$ttt$ttt\n$ttt\n" >expect &&
- printf "$ttt$ttt\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+test_expect_success 'consecutive text lines should be unchanged' '
+ printf "$ttt$ttt\n$ttt\n" >expect &&
+ printf "$ttt$ttt\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n$ttt$ttt\n$ttt\n" >expect &&
- printf "$ttt\n$ttt$ttt\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n$ttt$ttt\n$ttt\n" >expect &&
+ printf "$ttt\n$ttt$ttt\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" >expect &&
- printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" >expect &&
+ printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" >expect &&
- printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" >expect &&
+ printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" >expect &&
- printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" | git stripspace >actual &&
- test_cmp expect actual &&
+ printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" >expect &&
+ printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual &&
- printf "$ttt\n$ttt$ttt\n\n$ttt\n" >expect &&
- printf "$ttt\n$ttt$ttt\n\n$ttt\n" | git stripspace >actual &&
- test_cmp expect actual
+ printf "$ttt\n$ttt$ttt\n\n$ttt\n" >expect &&
+ printf "$ttt\n$ttt$ttt\n\n$ttt\n" | git stripspace >actual &&
+ test_cmp expect actual
'
test_expect_success 'strip comments, too' '
diff --git a/t/t0211-trace2-perf.sh b/t/t0211-trace2-perf.sh
index b4e9135..cfba686 100755
--- a/t/t0211-trace2-perf.sh
+++ b/t/t0211-trace2-perf.sh
@@ -203,7 +203,7 @@ test_expect_success 'stopwatch timer test/test1' '
have_timer_event "main" "timer" "test" "test1" 5 actual
'
-test_expect_success PTHREAD 'stopwatch timer test/test2' '
+test_expect_success PTHREADS 'stopwatch timer test/test2' '
test_when_finished "rm trace.perf actual" &&
test_config_global trace2.perfBrief 1 &&
test_config_global trace2.perfTarget "$(pwd)/trace.perf" &&
@@ -249,7 +249,7 @@ test_expect_success 'global counter test/test1' '
have_counter_event "main" "counter" "test" "test1" 15 actual
'
-test_expect_success PTHREAD 'global counter test/test2' '
+test_expect_success PTHREADS 'global counter test/test2' '
test_when_finished "rm trace.perf actual" &&
test_config_global trace2.perfBrief 1 &&
test_config_global trace2.perfTarget "$(pwd)/trace.perf" &&
diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh
index 3fb1b0c..88c524f 100755
--- a/t/t1001-read-tree-m-2way.sh
+++ b/t/t1001-read-tree-m-2way.sh
@@ -26,7 +26,7 @@ TEST_PASSES_SANITIZE_LEAK=true
. "$TEST_DIRECTORY"/lib-read-tree.sh
read_tree_twoway () {
- git read-tree -m "$1" "$2" && git ls-files --stage
+ git read-tree -m "$1" "$2" && git ls-files --stage
}
compare_change () {
diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh
index cdc077c..a7c2ed0 100755
--- a/t/t1002-read-tree-m-u-2way.sh
+++ b/t/t1002-read-tree-m-u-2way.sh
@@ -37,315 +37,312 @@ check_cache_at () {
esac
}
-test_expect_success \
- setup \
- 'echo frotz >frotz &&
- echo nitfol >nitfol &&
- echo bozbar >bozbar &&
- echo rezrov >rezrov &&
- git update-index --add nitfol bozbar rezrov &&
- treeH=$(git write-tree) &&
- echo treeH $treeH &&
- git ls-tree $treeH &&
-
- echo gnusto >bozbar &&
- git update-index --add frotz bozbar --force-remove rezrov &&
- git ls-files --stage >M.out &&
- treeM=$(git write-tree) &&
- echo treeM $treeM &&
- git ls-tree $treeM &&
- cp bozbar bozbar.M &&
- cp frotz frotz.M &&
- cp nitfol nitfol.M &&
- git diff-tree $treeH $treeM'
-
-test_expect_success \
- '1, 2, 3 - no carry forward' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- read_tree_u_must_succeed -m -u $treeH $treeM &&
- git ls-files --stage >1-3.out &&
- cmp M.out 1-3.out &&
- test_cmp bozbar.M bozbar &&
- test_cmp frotz.M frotz &&
- test_cmp nitfol.M nitfol &&
- check_cache_at bozbar clean &&
- check_cache_at frotz clean &&
- check_cache_at nitfol clean'
-
-test_expect_success \
- '4 - carry forward local addition.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo "+100644 X 0 yomin" >expected &&
- echo yomin >yomin &&
- git update-index --add yomin &&
- read_tree_u_must_succeed -m -u $treeH $treeM &&
- git ls-files --stage >4.out &&
- test_might_fail git diff -U0 --no-index M.out 4.out >4diff.out &&
- compare_change 4diff.out expected &&
- check_cache_at yomin clean &&
- test_cmp bozbar.M bozbar &&
- test_cmp frotz.M frotz &&
- test_cmp nitfol.M nitfol &&
- echo yomin >yomin1 &&
- diff yomin yomin1 &&
- rm -f yomin1'
-
-test_expect_success \
- '5 - carry forward local addition.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- read_tree_u_must_succeed -m -u $treeH &&
- echo yomin >yomin &&
- git update-index --add yomin &&
- echo yomin yomin >yomin &&
- read_tree_u_must_succeed -m -u $treeH $treeM &&
- git ls-files --stage >5.out &&
- test_might_fail git diff -U0 --no-index M.out 5.out >5diff.out &&
- compare_change 5diff.out expected &&
- check_cache_at yomin dirty &&
- test_cmp bozbar.M bozbar &&
- test_cmp frotz.M frotz &&
- test_cmp nitfol.M nitfol &&
- : dirty index should have prevented -u from checking it out. &&
- echo yomin yomin >yomin1 &&
- diff yomin yomin1 &&
- rm -f yomin1'
-
-test_expect_success \
- '6 - local addition already has the same.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo frotz >frotz &&
- git update-index --add frotz &&
- read_tree_u_must_succeed -m -u $treeH $treeM &&
- git ls-files --stage >6.out &&
- test_cmp M.out 6.out &&
- check_cache_at frotz clean &&
- test_cmp bozbar.M bozbar &&
- test_cmp frotz.M frotz &&
- test_cmp nitfol.M nitfol &&
- echo frotz >frotz1 &&
- diff frotz frotz1 &&
- rm -f frotz1'
-
-test_expect_success \
- '7 - local addition already has the same.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo frotz >frotz &&
- git update-index --add frotz &&
- echo frotz frotz >frotz &&
- read_tree_u_must_succeed -m -u $treeH $treeM &&
- git ls-files --stage >7.out &&
- test_cmp M.out 7.out &&
- check_cache_at frotz dirty &&
- test_cmp bozbar.M bozbar &&
- test_cmp nitfol.M nitfol &&
- : dirty index should have prevented -u from checking it out. &&
- echo frotz frotz >frotz1 &&
- diff frotz frotz1 &&
- rm -f frotz1'
-
-test_expect_success \
- '8 - conflicting addition.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo frotz frotz >frotz &&
- git update-index --add frotz &&
- ! read_tree_u_must_succeed -m -u $treeH $treeM'
-
-test_expect_success \
- '9 - conflicting addition.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo frotz frotz >frotz &&
- git update-index --add frotz &&
- echo frotz >frotz &&
- ! read_tree_u_must_succeed -m -u $treeH $treeM'
-
-test_expect_success \
- '10 - path removed.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo rezrov >rezrov &&
- git update-index --add rezrov &&
- read_tree_u_must_succeed -m -u $treeH $treeM &&
- git ls-files --stage >10.out &&
- cmp M.out 10.out &&
- test_cmp bozbar.M bozbar &&
- test_cmp frotz.M frotz &&
- test_cmp nitfol.M nitfol
+test_expect_success setup '
+ echo frotz >frotz &&
+ echo nitfol >nitfol &&
+ echo bozbar >bozbar &&
+ echo rezrov >rezrov &&
+ git update-index --add nitfol bozbar rezrov &&
+ treeH=$(git write-tree) &&
+ echo treeH $treeH &&
+ git ls-tree $treeH &&
+
+ echo gnusto >bozbar &&
+ git update-index --add frotz bozbar --force-remove rezrov &&
+ git ls-files --stage >M.out &&
+ treeM=$(git write-tree) &&
+ echo treeM $treeM &&
+ git ls-tree $treeM &&
+ cp bozbar bozbar.M &&
+ cp frotz frotz.M &&
+ cp nitfol nitfol.M &&
+ git diff-tree $treeH $treeM
'
-test_expect_success \
- '11 - dirty path removed.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo rezrov >rezrov &&
- git update-index --add rezrov &&
- echo rezrov rezrov >rezrov &&
- ! read_tree_u_must_succeed -m -u $treeH $treeM'
-
-test_expect_success \
- '12 - unmatching local changes being removed.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo rezrov rezrov >rezrov &&
- git update-index --add rezrov &&
- ! read_tree_u_must_succeed -m -u $treeH $treeM'
-
-test_expect_success \
- '13 - unmatching local changes being removed.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo rezrov rezrov >rezrov &&
- git update-index --add rezrov &&
- echo rezrov >rezrov &&
- ! read_tree_u_must_succeed -m -u $treeH $treeM'
+test_expect_success '1, 2, 3 - no carry forward' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ read_tree_u_must_succeed -m -u $treeH $treeM &&
+ git ls-files --stage >1-3.out &&
+ cmp M.out 1-3.out &&
+ test_cmp bozbar.M bozbar &&
+ test_cmp frotz.M frotz &&
+ test_cmp nitfol.M nitfol &&
+ check_cache_at bozbar clean &&
+ check_cache_at frotz clean &&
+ check_cache_at nitfol clean
+'
+
+test_expect_success '4 - carry forward local addition.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo "+100644 X 0 yomin" >expected &&
+ echo yomin >yomin &&
+ git update-index --add yomin &&
+ read_tree_u_must_succeed -m -u $treeH $treeM &&
+ git ls-files --stage >4.out &&
+ test_might_fail git diff -U0 --no-index M.out 4.out >4diff.out &&
+ compare_change 4diff.out expected &&
+ check_cache_at yomin clean &&
+ test_cmp bozbar.M bozbar &&
+ test_cmp frotz.M frotz &&
+ test_cmp nitfol.M nitfol &&
+ echo yomin >yomin1 &&
+ diff yomin yomin1 &&
+ rm -f yomin1
+'
+
+test_expect_success '5 - carry forward local addition.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ read_tree_u_must_succeed -m -u $treeH &&
+ echo yomin >yomin &&
+ git update-index --add yomin &&
+ echo yomin yomin >yomin &&
+ read_tree_u_must_succeed -m -u $treeH $treeM &&
+ git ls-files --stage >5.out &&
+ test_might_fail git diff -U0 --no-index M.out 5.out >5diff.out &&
+ compare_change 5diff.out expected &&
+ check_cache_at yomin dirty &&
+ test_cmp bozbar.M bozbar &&
+ test_cmp frotz.M frotz &&
+ test_cmp nitfol.M nitfol &&
+ : dirty index should have prevented -u from checking it out. &&
+ echo yomin yomin >yomin1 &&
+ diff yomin yomin1 &&
+ rm -f yomin1
+'
+
+test_expect_success '6 - local addition already has the same.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo frotz >frotz &&
+ git update-index --add frotz &&
+ read_tree_u_must_succeed -m -u $treeH $treeM &&
+ git ls-files --stage >6.out &&
+ test_cmp M.out 6.out &&
+ check_cache_at frotz clean &&
+ test_cmp bozbar.M bozbar &&
+ test_cmp frotz.M frotz &&
+ test_cmp nitfol.M nitfol &&
+ echo frotz >frotz1 &&
+ diff frotz frotz1 &&
+ rm -f frotz1
+'
+
+test_expect_success '7 - local addition already has the same.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo frotz >frotz &&
+ git update-index --add frotz &&
+ echo frotz frotz >frotz &&
+ read_tree_u_must_succeed -m -u $treeH $treeM &&
+ git ls-files --stage >7.out &&
+ test_cmp M.out 7.out &&
+ check_cache_at frotz dirty &&
+ test_cmp bozbar.M bozbar &&
+ test_cmp nitfol.M nitfol &&
+ : dirty index should have prevented -u from checking it out. &&
+ echo frotz frotz >frotz1 &&
+ diff frotz frotz1 &&
+ rm -f frotz1
+'
+
+test_expect_success '8 - conflicting addition.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo frotz frotz >frotz &&
+ git update-index --add frotz &&
+ ! read_tree_u_must_succeed -m -u $treeH $treeM
+'
+
+test_expect_success '9 - conflicting addition.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo frotz frotz >frotz &&
+ git update-index --add frotz &&
+ echo frotz >frotz &&
+ ! read_tree_u_must_succeed -m -u $treeH $treeM
+'
+
+test_expect_success '10 - path removed.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo rezrov >rezrov &&
+ git update-index --add rezrov &&
+ read_tree_u_must_succeed -m -u $treeH $treeM &&
+ git ls-files --stage >10.out &&
+ cmp M.out 10.out &&
+ test_cmp bozbar.M bozbar &&
+ test_cmp frotz.M frotz &&
+ test_cmp nitfol.M nitfol
+'
+
+test_expect_success '11 - dirty path removed.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo rezrov >rezrov &&
+ git update-index --add rezrov &&
+ echo rezrov rezrov >rezrov &&
+ ! read_tree_u_must_succeed -m -u $treeH $treeM
+'
+
+test_expect_success '12 - unmatching local changes being removed.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo rezrov rezrov >rezrov &&
+ git update-index --add rezrov &&
+ ! read_tree_u_must_succeed -m -u $treeH $treeM
+'
+
+test_expect_success '13 - unmatching local changes being removed.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo rezrov rezrov >rezrov &&
+ git update-index --add rezrov &&
+ echo rezrov >rezrov &&
+ ! read_tree_u_must_succeed -m -u $treeH $treeM
+'
cat >expected <<EOF
-100644 X 0 nitfol
+100644 X 0 nitfol
EOF
-test_expect_success \
- '14 - unchanged in two heads.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo nitfol nitfol >nitfol &&
- git update-index --add nitfol &&
- read_tree_u_must_succeed -m -u $treeH $treeM &&
- git ls-files --stage >14.out &&
- test_must_fail git diff -U0 --no-index M.out 14.out >14diff.out &&
- compare_change 14diff.out expected &&
- test_cmp bozbar.M bozbar &&
- test_cmp frotz.M frotz &&
- check_cache_at nitfol clean &&
- echo nitfol nitfol >nitfol1 &&
- diff nitfol nitfol1 &&
- rm -f nitfol1'
-
-test_expect_success \
- '15 - unchanged in two heads.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo nitfol nitfol >nitfol &&
- git update-index --add nitfol &&
- echo nitfol nitfol nitfol >nitfol &&
- read_tree_u_must_succeed -m -u $treeH $treeM &&
- git ls-files --stage >15.out &&
- test_must_fail git diff -U0 --no-index M.out 15.out >15diff.out &&
- compare_change 15diff.out expected &&
- check_cache_at nitfol dirty &&
- test_cmp bozbar.M bozbar &&
- test_cmp frotz.M frotz &&
- echo nitfol nitfol nitfol >nitfol1 &&
- diff nitfol nitfol1 &&
- rm -f nitfol1'
-
-test_expect_success \
- '16 - conflicting local change.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo bozbar bozbar >bozbar &&
- git update-index --add bozbar &&
- ! read_tree_u_must_succeed -m -u $treeH $treeM'
-
-test_expect_success \
- '17 - conflicting local change.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo bozbar bozbar >bozbar &&
- git update-index --add bozbar &&
- echo bozbar bozbar bozbar >bozbar &&
- ! read_tree_u_must_succeed -m -u $treeH $treeM'
-
-test_expect_success \
- '18 - local change already having a good result.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo gnusto >bozbar &&
- git update-index --add bozbar &&
- read_tree_u_must_succeed -m -u $treeH $treeM &&
- git ls-files --stage >18.out &&
- test_cmp M.out 18.out &&
- check_cache_at bozbar clean &&
- test_cmp bozbar.M bozbar &&
- test_cmp frotz.M frotz &&
- test_cmp nitfol.M nitfol
+test_expect_success '14 - unchanged in two heads.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo nitfol nitfol >nitfol &&
+ git update-index --add nitfol &&
+ read_tree_u_must_succeed -m -u $treeH $treeM &&
+ git ls-files --stage >14.out &&
+ test_must_fail git diff -U0 --no-index M.out 14.out >14diff.out &&
+ compare_change 14diff.out expected &&
+ test_cmp bozbar.M bozbar &&
+ test_cmp frotz.M frotz &&
+ check_cache_at nitfol clean &&
+ echo nitfol nitfol >nitfol1 &&
+ diff nitfol nitfol1 &&
+ rm -f nitfol1
'
-test_expect_success \
- '19 - local change already having a good result, further modified.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo gnusto >bozbar &&
- git update-index --add bozbar &&
- echo gnusto gnusto >bozbar &&
- read_tree_u_must_succeed -m -u $treeH $treeM &&
- git ls-files --stage >19.out &&
- test_cmp M.out 19.out &&
- check_cache_at bozbar dirty &&
- test_cmp frotz.M frotz &&
- test_cmp nitfol.M nitfol &&
- echo gnusto gnusto >bozbar1 &&
- diff bozbar bozbar1 &&
- rm -f bozbar1'
-
-test_expect_success \
- '20 - no local change, use new tree.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo bozbar >bozbar &&
- git update-index --add bozbar &&
- read_tree_u_must_succeed -m -u $treeH $treeM &&
- git ls-files --stage >20.out &&
- test_cmp M.out 20.out &&
- check_cache_at bozbar clean &&
- test_cmp bozbar.M bozbar &&
- test_cmp frotz.M frotz &&
- test_cmp nitfol.M nitfol
+test_expect_success '15 - unchanged in two heads.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo nitfol nitfol >nitfol &&
+ git update-index --add nitfol &&
+ echo nitfol nitfol nitfol >nitfol &&
+ read_tree_u_must_succeed -m -u $treeH $treeM &&
+ git ls-files --stage >15.out &&
+ test_must_fail git diff -U0 --no-index M.out 15.out >15diff.out &&
+ compare_change 15diff.out expected &&
+ check_cache_at nitfol dirty &&
+ test_cmp bozbar.M bozbar &&
+ test_cmp frotz.M frotz &&
+ echo nitfol nitfol nitfol >nitfol1 &&
+ diff nitfol nitfol1 &&
+ rm -f nitfol1
'
-test_expect_success \
- '21 - no local change, dirty cache.' \
- 'rm -f .git/index nitfol bozbar rezrov frotz &&
- read_tree_u_must_succeed --reset -u $treeH &&
- echo bozbar >bozbar &&
- git update-index --add bozbar &&
- echo gnusto gnusto >bozbar &&
- ! read_tree_u_must_succeed -m -u $treeH $treeM'
+test_expect_success '16 - conflicting local change.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo bozbar bozbar >bozbar &&
+ git update-index --add bozbar &&
+ ! read_tree_u_must_succeed -m -u $treeH $treeM
+'
+
+test_expect_success '17 - conflicting local change.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo bozbar bozbar >bozbar &&
+ git update-index --add bozbar &&
+ echo bozbar bozbar bozbar >bozbar &&
+ ! read_tree_u_must_succeed -m -u $treeH $treeM
+'
+
+test_expect_success '18 - local change already having a good result.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo gnusto >bozbar &&
+ git update-index --add bozbar &&
+ read_tree_u_must_succeed -m -u $treeH $treeM &&
+ git ls-files --stage >18.out &&
+ test_cmp M.out 18.out &&
+ check_cache_at bozbar clean &&
+ test_cmp bozbar.M bozbar &&
+ test_cmp frotz.M frotz &&
+ test_cmp nitfol.M nitfol
+'
+
+test_expect_success '19 - local change already having a good result, further modified.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo gnusto >bozbar &&
+ git update-index --add bozbar &&
+ echo gnusto gnusto >bozbar &&
+ read_tree_u_must_succeed -m -u $treeH $treeM &&
+ git ls-files --stage >19.out &&
+ test_cmp M.out 19.out &&
+ check_cache_at bozbar dirty &&
+ test_cmp frotz.M frotz &&
+ test_cmp nitfol.M nitfol &&
+ echo gnusto gnusto >bozbar1 &&
+ diff bozbar bozbar1 &&
+ rm -f bozbar1
+'
+
+test_expect_success '20 - no local change, use new tree.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo bozbar >bozbar &&
+ git update-index --add bozbar &&
+ read_tree_u_must_succeed -m -u $treeH $treeM &&
+ git ls-files --stage >20.out &&
+ test_cmp M.out 20.out &&
+ check_cache_at bozbar clean &&
+ test_cmp bozbar.M bozbar &&
+ test_cmp frotz.M frotz &&
+ test_cmp nitfol.M nitfol
+'
+
+test_expect_success '21 - no local change, dirty cache.' '
+ rm -f .git/index nitfol bozbar rezrov frotz &&
+ read_tree_u_must_succeed --reset -u $treeH &&
+ echo bozbar >bozbar &&
+ git update-index --add bozbar &&
+ echo gnusto gnusto >bozbar &&
+ ! read_tree_u_must_succeed -m -u $treeH $treeM
+'
# Also make sure we did not break DF vs DF/DF case.
-test_expect_success \
- 'DF vs DF/DF case setup.' \
- 'rm -f .git/index &&
- echo DF >DF &&
- git update-index --add DF &&
- treeDF=$(git write-tree) &&
- echo treeDF $treeDF &&
- git ls-tree $treeDF &&
-
- rm -f DF &&
- mkdir DF &&
- echo DF/DF >DF/DF &&
- git update-index --add --remove DF DF/DF &&
- treeDFDF=$(git write-tree) &&
- echo treeDFDF $treeDFDF &&
- git ls-tree $treeDFDF &&
- git ls-files --stage >DFDF.out'
-
-test_expect_success \
- 'DF vs DF/DF case test.' \
- 'rm -f .git/index &&
- rm -fr DF &&
- echo DF >DF &&
- git update-index --add DF &&
- read_tree_u_must_succeed -m -u $treeDF $treeDFDF &&
- git ls-files --stage >DFDFcheck.out &&
- test_cmp DFDF.out DFDFcheck.out &&
- check_cache_at DF/DF clean'
+test_expect_success 'DF vs DF/DF case setup.' '
+ rm -f .git/index &&
+ echo DF >DF &&
+ git update-index --add DF &&
+ treeDF=$(git write-tree) &&
+ echo treeDF $treeDF &&
+ git ls-tree $treeDF &&
+
+ rm -f DF &&
+ mkdir DF &&
+ echo DF/DF >DF/DF &&
+ git update-index --add --remove DF DF/DF &&
+ treeDFDF=$(git write-tree) &&
+ echo treeDFDF $treeDFDF &&
+ git ls-tree $treeDFDF &&
+ git ls-files --stage >DFDF.out
+'
+
+test_expect_success 'DF vs DF/DF case test.' '
+ rm -f .git/index &&
+ rm -fr DF &&
+ echo DF >DF &&
+ git update-index --add DF &&
+ read_tree_u_must_succeed -m -u $treeDF $treeDFDF &&
+ git ls-files --stage >DFDFcheck.out &&
+ test_cmp DFDF.out DFDFcheck.out &&
+ check_cache_at DF/DF clean
+'
test_done
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 8eac74b..d73a0be 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -89,7 +89,8 @@ done
for opt in --buffer \
--follow-symlinks \
--batch-all-objects \
- -z
+ -z \
+ -Z
do
test_expect_success "usage: bad option combination: $opt without batch mode" '
test_incompatible_usage git cat-file $opt &&
@@ -109,26 +110,12 @@ strlen () {
echo_without_newline "$1" | wc -c | sed -e 's/^ *//'
}
-maybe_remove_timestamp () {
- if test -z "$2"; then
- echo_without_newline "$1"
- else
- echo_without_newline "$(printf '%s\n' "$1" | remove_timestamp)"
- fi
-}
-
-remove_timestamp () {
- sed -e 's/ [0-9][0-9]* [-+][0-9][0-9][0-9][0-9]$//'
-}
-
-
run_tests () {
type=$1
sha1=$2
size=$3
content=$4
pretty_content=$5
- no_ts=$6
batch_output="$sha1 $type $size
$content"
@@ -163,21 +150,21 @@ $content"
test -z "$content" ||
test_expect_success "Content of $type is correct" '
- maybe_remove_timestamp "$content" $no_ts >expect &&
- maybe_remove_timestamp "$(git cat-file $type $sha1)" $no_ts >actual &&
+ echo_without_newline "$content" >expect &&
+ git cat-file $type $sha1 >actual &&
test_cmp expect actual
'
test_expect_success "Pretty content of $type is correct" '
- maybe_remove_timestamp "$pretty_content" $no_ts >expect &&
- maybe_remove_timestamp "$(git cat-file -p $sha1)" $no_ts >actual &&
+ echo_without_newline "$pretty_content" >expect &&
+ git cat-file -p $sha1 >actual &&
test_cmp expect actual
'
test -z "$content" ||
test_expect_success "--batch output of $type is correct" '
- maybe_remove_timestamp "$batch_output" $no_ts >expect &&
- maybe_remove_timestamp "$(echo $sha1 | git cat-file --batch)" $no_ts >actual &&
+ echo "$batch_output" >expect &&
+ echo $sha1 | git cat-file --batch >actual &&
test_cmp expect actual
'
@@ -191,9 +178,8 @@ $content"
do
test -z "$content" ||
test_expect_success "--batch-command $opt output of $type content is correct" '
- maybe_remove_timestamp "$batch_output" $no_ts >expect &&
- maybe_remove_timestamp "$(test_write_lines "contents $sha1" |
- git cat-file --batch-command $opt)" $no_ts >actual &&
+ echo "$batch_output" >expect &&
+ test_write_lines "contents $sha1" | git cat-file --batch-command $opt >actual &&
test_cmp expect actual
'
@@ -228,10 +214,9 @@ $content"
test_expect_success "--batch without type ($type)" '
{
echo "$size" &&
- maybe_remove_timestamp "$content" $no_ts
+ echo "$content"
} >expect &&
- echo $sha1 | git cat-file --batch="%(objectsize)" >actual.full &&
- maybe_remove_timestamp "$(cat actual.full)" $no_ts >actual &&
+ echo $sha1 | git cat-file --batch="%(objectsize)" >actual &&
test_cmp expect actual
'
@@ -239,10 +224,9 @@ $content"
test_expect_success "--batch without size ($type)" '
{
echo "$type" &&
- maybe_remove_timestamp "$content" $no_ts
+ echo "$content"
} >expect &&
- echo $sha1 | git cat-file --batch="%(objecttype)" >actual.full &&
- maybe_remove_timestamp "$(cat actual.full)" $no_ts >actual &&
+ echo $sha1 | git cat-file --batch="%(objecttype)" >actual &&
test_cmp expect actual
'
}
@@ -284,7 +268,7 @@ test_expect_success '--batch-check without %(rest) considers whole line' '
tree_sha1=$(git write-tree)
tree_size=$(($(test_oid rawsz) + 13))
-tree_pretty_content="100644 blob $hello_sha1 hello"
+tree_pretty_content="100644 blob $hello_sha1 hello${LF}"
run_tests 'tree' $tree_sha1 $tree_size "" "$tree_pretty_content"
@@ -292,12 +276,12 @@ commit_message="Initial commit"
commit_sha1=$(echo_without_newline "$commit_message" | git commit-tree $tree_sha1)
commit_size=$(($(test_oid hexsz) + 137))
commit_content="tree $tree_sha1
-author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 0 +0000
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 0 +0000
+author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
$commit_message"
-run_tests 'commit' $commit_sha1 $commit_size "$commit_content" "$commit_content" 1
+run_tests 'commit' $commit_sha1 $commit_size "$commit_content" "$commit_content"
tag_header_without_timestamp="object $hello_sha1
type blob
@@ -311,11 +295,13 @@ $tag_description"
tag_sha1=$(echo_without_newline "$tag_content" | git hash-object -t tag --stdin -w)
tag_size=$(strlen "$tag_content")
-run_tests 'tag' $tag_sha1 $tag_size "$tag_content" "$tag_content" 1
+run_tests 'tag' $tag_sha1 $tag_size "$tag_content" "$tag_content"
-test_expect_success \
- "Reach a blob from a tag pointing to it" \
- "test '$hello_content' = \"\$(git cat-file blob $tag_sha1)\""
+test_expect_success "Reach a blob from a tag pointing to it" '
+ echo_without_newline "$hello_content" >expect &&
+ git cat-file blob $tag_sha1 >actual &&
+ test_cmp expect actual
+'
for batch in batch batch-check batch-command
do
@@ -351,30 +337,47 @@ do
done
test_expect_success "--batch-check for a non-existent named object" '
- test "foobar42 missing
-foobar84 missing" = \
- "$( ( echo foobar42 && echo_without_newline foobar84 ) | git cat-file --batch-check)"
+ cat >expect <<-EOF &&
+ foobar42 missing
+ foobar84 missing
+ EOF
+
+ printf "foobar42\nfoobar84" >in &&
+ git cat-file --batch-check <in >actual &&
+ test_cmp expect actual
'
test_expect_success "--batch-check for a non-existent hash" '
- test "0000000000000000000000000000000000000042 missing
-0000000000000000000000000000000000000084 missing" = \
- "$( ( echo 0000000000000000000000000000000000000042 &&
- echo_without_newline 0000000000000000000000000000000000000084 ) |
- git cat-file --batch-check)"
+ cat >expect <<-EOF &&
+ 0000000000000000000000000000000000000042 missing
+ 0000000000000000000000000000000000000084 missing
+ EOF
+
+ printf "0000000000000000000000000000000000000042\n0000000000000000000000000000000000000084" >in &&
+ git cat-file --batch-check <in >actual &&
+ test_cmp expect actual
'
test_expect_success "--batch for an existent and a non-existent hash" '
- test "$tag_sha1 tag $tag_size
-$tag_content
-0000000000000000000000000000000000000000 missing" = \
- "$( ( echo $tag_sha1 &&
- echo_without_newline 0000000000000000000000000000000000000000 ) |
- git cat-file --batch)"
+ cat >expect <<-EOF &&
+ $tag_sha1 tag $tag_size
+ $tag_content
+ 0000000000000000000000000000000000000000 missing
+ EOF
+
+ printf "$tag_sha1\n0000000000000000000000000000000000000000" >in &&
+ git cat-file --batch <in >actual &&
+ test_cmp expect actual
'
test_expect_success "--batch-check for an empty line" '
- test " missing" = "$(echo | git cat-file --batch-check)"
+ cat >expect <<-EOF &&
+ missing
+ EOF
+
+ echo >in &&
+ git cat-file --batch-check <in >actual &&
+ test_cmp expect actual
'
test_expect_success 'empty --batch-check notices missing object' '
@@ -390,23 +393,34 @@ deadbeef
"
-batch_output="$hello_sha1 blob $hello_size
-$hello_content
-$commit_sha1 commit $commit_size
-$commit_content
-$tag_sha1 tag $tag_size
-$tag_content
-deadbeef missing
- missing"
+printf "%s\0" \
+ "$hello_sha1 blob $hello_size" \
+ "$hello_content" \
+ "$commit_sha1 commit $commit_size" \
+ "$commit_content" \
+ "$tag_sha1 tag $tag_size" \
+ "$tag_content" \
+ "deadbeef missing" \
+ " missing" >batch_output
test_expect_success '--batch with multiple sha1s gives correct format' '
- test "$(maybe_remove_timestamp "$batch_output" 1)" = "$(maybe_remove_timestamp "$(echo_without_newline "$batch_input" | git cat-file --batch)" 1)"
+ tr "\0" "\n" <batch_output >expect &&
+ echo_without_newline "$batch_input" >in &&
+ git cat-file --batch <in >actual &&
+ test_cmp expect actual
'
test_expect_success '--batch, -z with multiple sha1s gives correct format' '
echo_without_newline_nul "$batch_input" >in &&
- test "$(maybe_remove_timestamp "$batch_output" 1)" = \
- "$(maybe_remove_timestamp "$(git cat-file --batch -z <in)" 1)"
+ tr "\0" "\n" <batch_output >expect &&
+ git cat-file --batch -z <in >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success '--batch, -Z with multiple sha1s gives correct format' '
+ echo_without_newline_nul "$batch_input" >in &&
+ git cat-file --batch -Z <in >actual &&
+ test_cmp batch_output actual
'
batch_check_input="$hello_sha1
@@ -417,36 +431,55 @@ deadbeef
"
-batch_check_output="$hello_sha1 blob $hello_size
-$tree_sha1 tree $tree_size
-$commit_sha1 commit $commit_size
-$tag_sha1 tag $tag_size
-deadbeef missing
- missing"
+printf "%s\0" \
+ "$hello_sha1 blob $hello_size" \
+ "$tree_sha1 tree $tree_size" \
+ "$commit_sha1 commit $commit_size" \
+ "$tag_sha1 tag $tag_size" \
+ "deadbeef missing" \
+ " missing" >batch_check_output
test_expect_success "--batch-check with multiple sha1s gives correct format" '
- test "$batch_check_output" = \
- "$(echo_without_newline "$batch_check_input" | git cat-file --batch-check)"
+ tr "\0" "\n" <batch_check_output >expect &&
+ echo_without_newline "$batch_check_input" >in &&
+ git cat-file --batch-check <in >actual &&
+ test_cmp expect actual
'
test_expect_success "--batch-check, -z with multiple sha1s gives correct format" '
- echo_without_newline_nul "$batch_check_input" >in &&
- test "$batch_check_output" = "$(git cat-file --batch-check -z <in)"
+ tr "\0" "\n" <batch_check_output >expect &&
+ echo_without_newline_nul "$batch_check_input" >in &&
+ git cat-file --batch-check -z <in >actual &&
+ test_cmp expect actual
'
-test_expect_success FUNNYNAMES '--batch-check, -z with newline in input' '
+test_expect_success "--batch-check, -Z with multiple sha1s gives correct format" '
+ echo_without_newline_nul "$batch_check_input" >in &&
+ git cat-file --batch-check -Z <in >actual &&
+ test_cmp batch_check_output actual
+'
+
+test_expect_success FUNNYNAMES 'setup with newline in input' '
touch -- "newline${LF}embedded" &&
git add -- "newline${LF}embedded" &&
git commit -m "file with newline embedded" &&
test_tick &&
- printf "HEAD:newline${LF}embedded" >in &&
- git cat-file --batch-check -z <in >actual &&
+ printf "HEAD:newline${LF}embedded" >in
+'
+test_expect_success FUNNYNAMES '--batch-check, -z with newline in input' '
+ git cat-file --batch-check -z <in >actual &&
echo "$(git rev-parse "HEAD:newline${LF}embedded") blob 0" >expect &&
test_cmp expect actual
'
+test_expect_success FUNNYNAMES '--batch-check, -Z with newline in input' '
+ git cat-file --batch-check -Z <in >actual &&
+ printf "%s\0" "$(git rev-parse "HEAD:newline${LF}embedded") blob 0" >expect &&
+ test_cmp expect actual
+'
+
batch_command_multiple_info="info $hello_sha1
info $tree_sha1
info $commit_sha1
@@ -470,7 +503,13 @@ test_expect_success '--batch-command with multiple info calls gives correct form
echo "$batch_command_multiple_info" | tr "\n" "\0" >in &&
git cat-file --batch-command --buffer -z <in >actual &&
- test_cmp expect actual
+ test_cmp expect actual &&
+
+ echo "$batch_command_multiple_info" | tr "\n" "\0" >in &&
+ tr "\n" "\0" <expect >expect_nul &&
+ git cat-file --batch-command --buffer -Z <in >actual &&
+
+ test_cmp expect_nul actual
'
batch_command_multiple_contents="contents $hello_sha1
@@ -480,27 +519,30 @@ contents deadbeef
flush"
test_expect_success '--batch-command with multiple command calls gives correct format' '
- remove_timestamp >expect <<-EOF &&
- $hello_sha1 blob $hello_size
- $hello_content
- $commit_sha1 commit $commit_size
- $commit_content
- $tag_sha1 tag $tag_size
- $tag_content
- deadbeef missing
- EOF
+ printf "%s\0" \
+ "$hello_sha1 blob $hello_size" \
+ "$hello_content" \
+ "$commit_sha1 commit $commit_size" \
+ "$commit_content" \
+ "$tag_sha1 tag $tag_size" \
+ "$tag_content" \
+ "deadbeef missing" >expect_nul &&
+ tr "\0" "\n" <expect_nul >expect &&
echo "$batch_command_multiple_contents" >in &&
- git cat-file --batch-command --buffer <in >actual_raw &&
+ git cat-file --batch-command --buffer <in >actual &&
- remove_timestamp <actual_raw >actual &&
test_cmp expect actual &&
echo "$batch_command_multiple_contents" | tr "\n" "\0" >in &&
- git cat-file --batch-command --buffer -z <in >actual_raw &&
+ git cat-file --batch-command --buffer -z <in >actual &&
- remove_timestamp <actual_raw >actual &&
- test_cmp expect actual
+ test_cmp expect actual &&
+
+ echo "$batch_command_multiple_contents" | tr "\n" "\0" >in &&
+ git cat-file --batch-command --buffer -Z <in >actual &&
+
+ test_cmp expect_nul actual
'
test_expect_success 'setup blobs which are likely to delta' '
@@ -840,6 +882,13 @@ test_expect_success 'git cat-file --batch-check --follow-symlinks works for brok
test_cmp expect actual
'
+test_expect_success 'git cat-file --batch-check --follow-symlinks -Z works for broken in-repo, same-dir links' '
+ printf "HEAD:broken-same-dir-link\0" >in &&
+ printf "dangling 25\0HEAD:broken-same-dir-link\0" >expect &&
+ git cat-file --batch-check --follow-symlinks -Z <in >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'git cat-file --batch-check --follow-symlinks works for same-dir links-to-links' '
echo HEAD:link-to-link | git cat-file --batch-check --follow-symlinks >actual &&
test_cmp found actual
@@ -854,6 +903,15 @@ test_expect_success 'git cat-file --batch-check --follow-symlinks works for pare
test_cmp expect actual
'
+test_expect_success 'git cat-file --batch-check --follow-symlinks -Z works for parent-dir links' '
+ echo HEAD:dir/parent-dir-link | git cat-file --batch-check --follow-symlinks >actual &&
+ test_cmp found actual &&
+ printf "notdir 29\0HEAD:dir/parent-dir-link/nope\0" >expect &&
+ printf "HEAD:dir/parent-dir-link/nope\0" >in &&
+ git cat-file --batch-check --follow-symlinks -Z <in >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'git cat-file --batch-check --follow-symlinks works for .. links' '
echo dangling 22 >expect &&
echo HEAD:dir/link-dir/nope >>expect &&
@@ -968,6 +1026,13 @@ test_expect_success 'git cat-file --batch-check --follow-symlink breaks loops' '
test_cmp expect actual
'
+test_expect_success 'git cat-file --batch-check --follow-symlink -Z breaks loops' '
+ printf "loop 10\0HEAD:loop1\0" >expect &&
+ printf "HEAD:loop1\0" >in &&
+ git cat-file --batch-check --follow-symlinks -Z <in >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'git cat-file --batch --follow-symlink returns correct sha and mode' '
echo HEAD:morx | git cat-file --batch >expect &&
echo HEAD:morx | git cat-file --batch --follow-symlinks >actual &&
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
index a63d0cc..8a95adf 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
@@ -2180,4 +2180,83 @@ test_expect_success 'sparse index is not expanded: diff-files' '
ensure_not_expanded diff-files -- "deep/*"
'
+test_expect_success 'diff-tree' '
+ init_repos &&
+
+ # Test change inside sparse cone
+ tree1=$(git -C sparse-index rev-parse HEAD^{tree}) &&
+ tree2=$(git -C sparse-index rev-parse update-deep^{tree}) &&
+ test_all_match git diff-tree $tree1 $tree2 &&
+ test_all_match git diff-tree $tree1 $tree2 -- deep/a &&
+ test_all_match git diff-tree HEAD update-deep &&
+ test_all_match git diff-tree HEAD update-deep -- deep/a &&
+
+ # Test change outside sparse cone
+ tree3=$(git -C sparse-index rev-parse update-folder1^{tree}) &&
+ test_all_match git diff-tree $tree1 $tree3 &&
+ test_all_match git diff-tree $tree1 $tree3 -- folder1/a &&
+ test_all_match git diff-tree HEAD update-folder1 &&
+ test_all_match git diff-tree HEAD update-folder1 -- folder1/a &&
+
+ # Check that SKIP_WORKTREE files are not materialized
+ test_path_is_missing sparse-checkout/folder1/a &&
+ test_path_is_missing sparse-index/folder1/a &&
+ test_path_is_missing sparse-checkout/folder2/a &&
+ test_path_is_missing sparse-index/folder2/a
+'
+
+test_expect_success 'sparse-index is not expanded: diff-tree' '
+ init_repos &&
+
+ tree1=$(git -C sparse-index rev-parse HEAD^{tree}) &&
+ tree2=$(git -C sparse-index rev-parse update-deep^{tree}) &&
+ tree3=$(git -C sparse-index rev-parse update-folder1^{tree}) &&
+
+ ensure_not_expanded diff-tree $tree1 $tree2 &&
+ ensure_not_expanded diff-tree $tree1 $tree2 -- deep/a &&
+ ensure_not_expanded diff-tree HEAD update-deep &&
+ ensure_not_expanded diff-tree HEAD update-deep -- deep/a &&
+ ensure_not_expanded diff-tree $tree1 $tree3 &&
+ ensure_not_expanded diff-tree $tree1 $tree3 -- folder1/a &&
+ ensure_not_expanded diff-tree HEAD update-folder1 &&
+ ensure_not_expanded diff-tree HEAD update-folder1 -- folder1/a
+'
+
+test_expect_success 'worktree' '
+ init_repos &&
+
+ write_script edit-contents <<-\EOF &&
+ echo text >>"$1"
+ EOF
+
+ for repo in full-checkout sparse-checkout sparse-index
+ do
+ worktree=${repo}-wt &&
+ git -C $repo worktree add ../$worktree &&
+
+ # Compare worktree content with "ls"
+ (cd $repo && ls) >worktree_contents &&
+ (cd $worktree && ls) >new_worktree_contents &&
+ test_cmp worktree_contents new_worktree_contents &&
+
+ # Compare index content with "ls-files --sparse"
+ git -C $repo ls-files --sparse >index_contents &&
+ git -C $worktree ls-files --sparse >new_index_contents &&
+ test_cmp index_contents new_index_contents &&
+
+ git -C $repo worktree remove ../$worktree || return 1
+ done &&
+
+ test_all_match git worktree add .worktrees/hotfix &&
+ run_on_all ../edit-contents .worktrees/hotfix/deep/a &&
+ test_all_match test_must_fail git worktree remove .worktrees/hotfix
+'
+
+test_expect_success 'worktree is not expanded' '
+ init_repos &&
+
+ ensure_not_expanded worktree add .worktrees/hotfix &&
+ ensure_not_expanded worktree remove .worktrees/hotfix
+'
+
test_done
diff --git a/t/t1800-hook.sh b/t/t1800-hook.sh
index 3506f62..8b0234c 100755
--- a/t/t1800-hook.sh
+++ b/t/t1800-hook.sh
@@ -156,25 +156,15 @@ test_expect_success 'git hook run a hook with a bad shebang' '
mkdir bad-hooks &&
write_script bad-hooks/test-hook "/bad/path/no/spaces" </dev/null &&
- # TODO: We should emit the same (or at least a more similar)
- # error on MINGW (essentially Git for Windows) and all other
- # platforms.. See the OS-specific code in start_command()
- if test_have_prereq !MINGW
- then
- cat >expect <<-\EOF
- fatal: cannot run bad-hooks/test-hook: ...
- EOF
- else
- cat >expect <<-\EOF
- error: cannot spawn bad-hooks/test-hook: ...
- EOF
- fi &&
test_expect_code 1 git \
-c core.hooksPath=bad-hooks \
hook run test-hook >out 2>err &&
test_must_be_empty out &&
- sed -e "s/test-hook: .*/test-hook: .../" <err >actual &&
- test_cmp expect actual
+
+ # TODO: We should emit the same (or at least a more similar)
+ # error on MINGW (essentially Git for Windows) and all other
+ # platforms.. See the OS-specific code in start_command()
+ grep -E "^(error|fatal): cannot (exec|spawn) .*bad-hooks/test-hook" err
'
test_expect_success 'stdin to hooks' '
diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
index d587e0b..0ac468e 100755
--- a/t/t2400-worktree-add.sh
+++ b/t/t2400-worktree-add.sh
@@ -298,17 +298,24 @@ test_expect_success '"add" no auto-vivify with --detach and <branch> omitted' '
test_must_fail git -C mish/mash symbolic-ref HEAD
'
-test_expect_success '"add" -b/-B mutually exclusive' '
- test_must_fail git worktree add -b poodle -B poodle bamboo main
-'
-
-test_expect_success '"add" -b/--detach mutually exclusive' '
- test_must_fail git worktree add -b poodle --detach bamboo main
-'
+# Helper function to test mutually exclusive options.
+#
+# Note: Quoted arguments containing spaces are not supported.
+test_wt_add_excl () {
+ local opts="$*" &&
+ test_expect_success "'worktree add' with '$opts' has mutually exclusive options" '
+ test_must_fail git worktree add $opts 2>actual &&
+ grep -E "fatal:( options)? .* cannot be used together" actual
+ '
+}
-test_expect_success '"add" -B/--detach mutually exclusive' '
- test_must_fail git worktree add -B poodle --detach bamboo main
-'
+test_wt_add_excl -b poodle -B poodle bamboo main
+test_wt_add_excl -b poodle --detach bamboo main
+test_wt_add_excl -B poodle --detach bamboo main
+test_wt_add_excl --orphan --detach bamboo
+test_wt_add_excl --orphan --no-checkout bamboo
+test_wt_add_excl --orphan bamboo main
+test_wt_add_excl --orphan -b bamboo wtdir/ main
test_expect_success '"add -B" fails if the branch is checked out' '
git rev-parse newmain >before &&
@@ -326,10 +333,111 @@ test_expect_success 'add -B' '
'
test_expect_success 'add --quiet' '
+ test_when_finished "git worktree remove -f -f another-worktree" &&
git worktree add --quiet another-worktree main 2>actual &&
test_must_be_empty actual
'
+test_expect_success 'add --quiet -b' '
+ test_when_finished "git branch -D quietnewbranch" &&
+ test_when_finished "git worktree remove -f -f another-worktree" &&
+ git worktree add --quiet -b quietnewbranch another-worktree 2>actual &&
+ test_must_be_empty actual
+'
+
+test_expect_success '"add --orphan"' '
+ test_when_finished "git worktree remove -f -f orphandir" &&
+ git worktree add --orphan -b neworphan orphandir &&
+ echo refs/heads/neworphan >expected &&
+ git -C orphandir symbolic-ref HEAD >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success '"add --orphan (no -b)"' '
+ test_when_finished "git worktree remove -f -f neworphan" &&
+ git worktree add --orphan neworphan &&
+ echo refs/heads/neworphan >expected &&
+ git -C neworphan symbolic-ref HEAD >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success '"add --orphan --quiet"' '
+ test_when_finished "git worktree remove -f -f orphandir" &&
+ git worktree add --quiet --orphan -b neworphan orphandir 2>log.actual &&
+ test_must_be_empty log.actual &&
+ echo refs/heads/neworphan >expected &&
+ git -C orphandir symbolic-ref HEAD >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success '"add --orphan" fails if the branch already exists' '
+ test_when_finished "git branch -D existingbranch" &&
+ git worktree add -b existingbranch orphandir main &&
+ git worktree remove orphandir &&
+ test_must_fail git worktree add --orphan -b existingbranch orphandir
+'
+
+test_expect_success '"add --orphan" with empty repository' '
+ test_when_finished "rm -rf empty_repo" &&
+ echo refs/heads/newbranch >expected &&
+ GIT_DIR="empty_repo" git init --bare &&
+ git -C empty_repo worktree add --orphan -b newbranch worktreedir &&
+ git -C empty_repo/worktreedir symbolic-ref HEAD >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success '"add" worktree with orphan branch and lock' '
+ git worktree add --lock --orphan -b orphanbr orphan-with-lock &&
+ test_when_finished "git worktree unlock orphan-with-lock || :" &&
+ test -f .git/worktrees/orphan-with-lock/locked
+'
+
+test_expect_success '"add" worktree with orphan branch, lock, and reason' '
+ lock_reason="why not" &&
+ git worktree add --detach --lock --reason "$lock_reason" orphan-with-lock-reason main &&
+ test_when_finished "git worktree unlock orphan-with-lock-reason || :" &&
+ test -f .git/worktrees/orphan-with-lock-reason/locked &&
+ echo "$lock_reason" >expect &&
+ test_cmp expect .git/worktrees/orphan-with-lock-reason/locked
+'
+
+# Note: Quoted arguments containing spaces are not supported.
+test_wt_add_orphan_hint () {
+ local context="$1" &&
+ local use_branch=$2 &&
+ shift 2 &&
+ local opts="$*" &&
+ test_expect_success "'worktree add' show orphan hint in bad/orphan HEAD w/ $context" '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (cd repo && test_commit commit) &&
+ git -C repo switch --orphan noref &&
+ test_must_fail git -C repo worktree add $opts foobar/ 2>actual &&
+ ! grep "error: unknown switch" actual &&
+ grep "hint: If you meant to create a worktree containing a new orphan branch" actual &&
+ if [ $use_branch -eq 1 ]
+ then
+ grep -E "^hint:\s+git worktree add --orphan -b \S+ \S+\s*$" actual
+ else
+ grep -E "^hint:\s+git worktree add --orphan \S+\s*$" actual
+ fi
+
+ '
+}
+
+test_wt_add_orphan_hint 'no opts' 0
+test_wt_add_orphan_hint '-b' 1 -b foobar_branch
+test_wt_add_orphan_hint '-B' 1 -B foobar_branch
+
+test_expect_success "'worktree add' doesn't show orphan hint in bad/orphan HEAD w/ --quiet" '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (cd repo && test_commit commit) &&
+ test_must_fail git -C repo worktree add --quiet foobar_branch foobar/ 2>actual &&
+ ! grep "error: unknown switch" actual &&
+ ! grep "hint: If you meant to create a worktree containing a new orphan branch" actual
+'
+
test_expect_success 'local clone from linked checkout' '
git clone --local here here-clone &&
( cd here-clone && git fsck )
@@ -446,6 +554,14 @@ setup_remote_repo () {
)
}
+test_expect_success '"add" <path> <remote/branch> w/ no HEAD' '
+ test_when_finished rm -rf repo_upstream repo_local foo &&
+ setup_remote_repo repo_upstream repo_local &&
+ git -C repo_local config --bool core.bare true &&
+ git -C repo_local branch -D main &&
+ git -C repo_local worktree add ./foo repo_upstream/foo
+'
+
test_expect_success '--no-track avoids setting up tracking' '
test_when_finished rm -rf repo_upstream repo_local foo &&
setup_remote_repo repo_upstream repo_local &&
@@ -528,6 +644,35 @@ test_expect_success 'git worktree add --guess-remote sets up tracking' '
test_cmp_rev refs/remotes/repo_a/foo refs/heads/foo
)
'
+test_expect_success 'git worktree add --guess-remote sets up tracking (quiet)' '
+ test_when_finished rm -rf repo_a repo_b foo &&
+ setup_remote_repo repo_a repo_b &&
+ (
+ cd repo_b &&
+ git worktree add --quiet --guess-remote ../foo 2>actual &&
+ test_must_be_empty actual
+ ) &&
+ (
+ cd foo &&
+ test_branch_upstream foo repo_a foo &&
+ test_cmp_rev refs/remotes/repo_a/foo refs/heads/foo
+ )
+'
+
+test_expect_success 'git worktree --no-guess-remote (quiet)' '
+ test_when_finished rm -rf repo_a repo_b foo &&
+ setup_remote_repo repo_a repo_b &&
+ (
+ cd repo_b &&
+ git worktree add --quiet --no-guess-remote ../foo
+ ) &&
+ (
+ cd foo &&
+ test_must_fail git config "branch.foo.remote" &&
+ test_must_fail git config "branch.foo.merge" &&
+ test_cmp_rev ! refs/remotes/repo_a/foo refs/heads/foo
+ )
+'
test_expect_success 'git worktree add with worktree.guessRemote sets up tracking' '
test_when_finished rm -rf repo_a repo_b foo &&
@@ -560,6 +705,348 @@ test_expect_success 'git worktree --no-guess-remote option overrides config' '
)
'
+test_dwim_orphan () {
+ local info_text="No possible source branch, inferring '--orphan'" &&
+ local fetch_error_text="fatal: No local or remote refs exist despite at least one remote" &&
+ local orphan_hint="hint: If you meant to create a worktree containing a new orphan branch" &&
+ local invalid_ref_regex="^fatal: invalid reference:\s\+.*" &&
+ local bad_combo_regex="^fatal: '[a-z-]\+' and '[a-z-]\+' cannot be used together" &&
+
+ local git_ns="repo" &&
+ local dashc_args="-C $git_ns" &&
+ local use_cd=0 &&
+
+ local bad_head=0 &&
+ local empty_repo=1 &&
+ local local_ref=0 &&
+ local use_quiet=0 &&
+ local remote=0 &&
+ local remote_ref=0 &&
+ local use_detach=0 &&
+ local use_new_branch=0 &&
+
+ local outcome="$1" &&
+ local outcome_text &&
+ local success &&
+ shift &&
+ local args="" &&
+ local context="" &&
+ case "$outcome" in
+ "infer")
+ success=1 &&
+ outcome_text='"add" DWIM infer --orphan'
+ ;;
+ "no_infer")
+ success=1 &&
+ outcome_text='"add" DWIM doesnt infer --orphan'
+ ;;
+ "fetch_error")
+ success=0 &&
+ outcome_text='"add" error need fetch'
+ ;;
+ "fatal_orphan_bad_combo")
+ success=0 &&
+ outcome_text='"add" error inferred "--orphan" gives illegal opts combo'
+ ;;
+ "warn_bad_head")
+ success=0 &&
+ outcome_text='"add" error, warn on bad HEAD, hint use orphan'
+ ;;
+ *)
+ echo "test_dwim_orphan(): invalid outcome: '$outcome'" >&2 &&
+ return 1
+ ;;
+ esac &&
+ while [ $# -gt 0 ]
+ do
+ case "$1" in
+ # How and from where to create the worktree
+ "-C_repo")
+ use_cd=0 &&
+ git_ns="repo" &&
+ dashc_args="-C $git_ns" &&
+ context="$context, 'git -C repo'"
+ ;;
+ "-C_wt")
+ use_cd=0 &&
+ git_ns="wt" &&
+ dashc_args="-C $git_ns" &&
+ context="$context, 'git -C wt'"
+ ;;
+ "cd_repo")
+ use_cd=1 &&
+ git_ns="repo" &&
+ dashc_args="" &&
+ context="$context, 'cd repo && git'"
+ ;;
+ "cd_wt")
+ use_cd=1 &&
+ git_ns="wt" &&
+ dashc_args="" &&
+ context="$context, 'cd wt && git'"
+ ;;
+
+ # Bypass the "pull first" warning
+ "force")
+ args="$args --force" &&
+ context="$context, --force"
+ ;;
+
+ # Try to use remote refs when DWIM
+ "guess_remote")
+ args="$args --guess-remote" &&
+ context="$context, --guess-remote"
+ ;;
+ "no_guess_remote")
+ args="$args --no-guess-remote" &&
+ context="$context, --no-guess-remote"
+ ;;
+
+ # Whether there is at least one local branch present
+ "local_ref")
+ empty_repo=0 &&
+ local_ref=1 &&
+ context="$context, >=1 local branches"
+ ;;
+ "no_local_ref")
+ empty_repo=0 &&
+ context="$context, 0 local branches"
+ ;;
+
+ # Whether the HEAD points at a valid ref (skip this opt when no refs)
+ "good_head")
+ # requires: local_ref
+ context="$context, valid HEAD"
+ ;;
+ "bad_head")
+ bad_head=1 &&
+ context="$context, invalid (or orphan) HEAD"
+ ;;
+
+ # Whether the code path is tested with the base add command, -b, or --detach
+ "no_-b")
+ use_new_branch=0 &&
+ context="$context, no --branch"
+ ;;
+ "-b")
+ use_new_branch=1 &&
+ context="$context, --branch"
+ ;;
+ "detach")
+ use_detach=1 &&
+ context="$context, --detach"
+ ;;
+
+ # Whether to check that all output is suppressed (except errors)
+ # or that the output is as expected
+ "quiet")
+ use_quiet=1 &&
+ args="$args --quiet" &&
+ context="$context, --quiet"
+ ;;
+ "no_quiet")
+ use_quiet=0 &&
+ context="$context, no --quiet (expect output)"
+ ;;
+
+ # Whether there is at least one remote attached to the repo
+ "remote")
+ empty_repo=0 &&
+ remote=1 &&
+ context="$context, >=1 remotes"
+ ;;
+ "no_remote")
+ empty_repo=0 &&
+ remote=0 &&
+ context="$context, 0 remotes"
+ ;;
+
+ # Whether there is at least one valid remote ref
+ "remote_ref")
+ # requires: remote
+ empty_repo=0 &&
+ remote_ref=1 &&
+ context="$context, >=1 fetched remote branches"
+ ;;
+ "no_remote_ref")
+ empty_repo=0 &&
+ remote_ref=0 &&
+ context="$context, 0 fetched remote branches"
+ ;;
+
+ # Options or flags that become illegal when --orphan is inferred
+ "no_checkout")
+ args="$args --no-checkout" &&
+ context="$context, --no-checkout"
+ ;;
+ "track")
+ args="$args --track" &&
+ context="$context, --track"
+ ;;
+
+ # All other options are illegal
+ *)
+ echo "test_dwim_orphan(): invalid arg: '$1'" >&2 &&
+ return 1
+ ;;
+ esac &&
+ shift
+ done &&
+ context="${context#', '}" &&
+ if [ $use_new_branch -eq 1 ]
+ then
+ args="$args -b foo"
+ elif [ $use_detach -eq 1 ]
+ then
+ args="$args --detach"
+ else
+ context="DWIM (no --branch), $context"
+ fi &&
+ if [ $empty_repo -eq 1 ]
+ then
+ context="empty repo, $context"
+ fi &&
+ args="$args ../foo" &&
+ context="${context%', '}" &&
+ test_expect_success "$outcome_text w/ $context" '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ if [ $local_ref -eq 1 ] && [ "$git_ns" = "repo" ]
+ then
+ (cd repo && test_commit commit) &&
+ if [ $bad_head -eq 1 ]
+ then
+ git -C repo symbolic-ref HEAD refs/heads/badbranch
+ fi
+ elif [ $local_ref -eq 1 ] && [ "$git_ns" = "wt" ]
+ then
+ test_when_finished "git -C repo worktree remove -f ../wt" &&
+ git -C repo worktree add --orphan -b main ../wt &&
+ (cd wt && test_commit commit) &&
+ if [ $bad_head -eq 1 ]
+ then
+ git -C wt symbolic-ref HEAD refs/heads/badbranch
+ fi
+ elif [ $local_ref -eq 0 ] && [ "$git_ns" = "wt" ]
+ then
+ test_when_finished "git -C repo worktree remove -f ../wt" &&
+ git -C repo worktree add --orphan -b orphanbranch ../wt
+ fi &&
+
+ if [ $remote -eq 1 ]
+ then
+ test_when_finished "rm -rf upstream" &&
+ git init upstream &&
+ (cd upstream && test_commit commit) &&
+ git -C upstream switch -c foo &&
+ git -C repo remote add upstream ../upstream
+ fi &&
+
+ if [ $remote_ref -eq 1 ]
+ then
+ git -C repo fetch
+ fi &&
+ if [ $success -eq 1 ]
+ then
+ test_when_finished git -C repo worktree remove ../foo
+ fi &&
+ (
+ if [ $use_cd -eq 1 ]
+ then
+ cd $git_ns
+ fi &&
+ if [ "$outcome" = "infer" ]
+ then
+ git $dashc_args worktree add $args 2>actual &&
+ if [ $use_quiet -eq 1 ]
+ then
+ test_must_be_empty actual
+ else
+ grep "$info_text" actual
+ fi
+ elif [ "$outcome" = "no_infer" ]
+ then
+ git $dashc_args worktree add $args 2>actual &&
+ if [ $use_quiet -eq 1 ]
+ then
+ test_must_be_empty actual
+ else
+ ! grep "$info_text" actual
+ fi
+ elif [ "$outcome" = "fetch_error" ]
+ then
+ test_must_fail git $dashc_args worktree add $args 2>actual &&
+ grep "$fetch_error_text" actual
+ elif [ "$outcome" = "fatal_orphan_bad_combo" ]
+ then
+ test_must_fail git $dashc_args worktree add $args 2>actual &&
+ if [ $use_quiet -eq 1 ]
+ then
+ ! grep "$info_text" actual
+ else
+ grep "$info_text" actual
+ fi &&
+ grep "$bad_combo_regex" actual
+ elif [ "$outcome" = "warn_bad_head" ]
+ then
+ test_must_fail git $dashc_args worktree add $args 2>actual &&
+ if [ $use_quiet -eq 1 ]
+ then
+ grep "$invalid_ref_regex" actual &&
+ ! grep "$orphan_hint" actual
+ else
+ headpath=$(git $dashc_args rev-parse --sq --path-format=absolute --git-path HEAD) &&
+ headcontents=$(cat "$headpath") &&
+ grep "HEAD points to an invalid (or orphaned) reference" actual &&
+ grep "HEAD path:\s*.$headpath." actual &&
+ grep "HEAD contents:\s*.$headcontents." actual &&
+ grep "$orphan_hint" actual &&
+ ! grep "$info_text" actual
+ fi &&
+ grep "$invalid_ref_regex" actual
+ else
+ # Unreachable
+ false
+ fi
+ ) &&
+ if [ $success -ne 1 ]
+ then
+ test_path_is_missing foo
+ fi
+ '
+}
+
+for quiet_mode in "no_quiet" "quiet"
+do
+ for changedir_type in "cd_repo" "cd_wt" "-C_repo" "-C_wt"
+ do
+ dwim_test_args="$quiet_mode $changedir_type"
+ test_dwim_orphan 'infer' $dwim_test_args no_-b
+ test_dwim_orphan 'no_infer' $dwim_test_args no_-b local_ref good_head
+ test_dwim_orphan 'infer' $dwim_test_args no_-b no_local_ref no_remote no_remote_ref no_guess_remote
+ test_dwim_orphan 'infer' $dwim_test_args no_-b no_local_ref remote no_remote_ref no_guess_remote
+ test_dwim_orphan 'fetch_error' $dwim_test_args no_-b no_local_ref remote no_remote_ref guess_remote
+ test_dwim_orphan 'infer' $dwim_test_args no_-b no_local_ref remote no_remote_ref guess_remote force
+ test_dwim_orphan 'no_infer' $dwim_test_args no_-b no_local_ref remote remote_ref guess_remote
+
+ test_dwim_orphan 'infer' $dwim_test_args -b
+ test_dwim_orphan 'no_infer' $dwim_test_args -b local_ref good_head
+ test_dwim_orphan 'infer' $dwim_test_args -b no_local_ref no_remote no_remote_ref no_guess_remote
+ test_dwim_orphan 'infer' $dwim_test_args -b no_local_ref remote no_remote_ref no_guess_remote
+ test_dwim_orphan 'infer' $dwim_test_args -b no_local_ref remote no_remote_ref guess_remote
+ test_dwim_orphan 'infer' $dwim_test_args -b no_local_ref remote remote_ref guess_remote
+
+ test_dwim_orphan 'warn_bad_head' $dwim_test_args no_-b local_ref bad_head
+ test_dwim_orphan 'warn_bad_head' $dwim_test_args -b local_ref bad_head
+ test_dwim_orphan 'warn_bad_head' $dwim_test_args detach local_ref bad_head
+ done
+
+ test_dwim_orphan 'fatal_orphan_bad_combo' $quiet_mode no_-b no_checkout
+ test_dwim_orphan 'fatal_orphan_bad_combo' $quiet_mode no_-b track
+ test_dwim_orphan 'fatal_orphan_bad_combo' $quiet_mode -b no_checkout
+ test_dwim_orphan 'fatal_orphan_bad_combo' $quiet_mode -b track
+done
+
post_checkout_hook () {
test_when_finished "rm -rf .git/hooks" &&
mkdir .git/hooks &&
diff --git a/t/t3007-ls-files-recurse-submodules.sh b/t/t3007-ls-files-recurse-submodules.sh
index dd7770e..7308a3d 100755
--- a/t/t3007-ls-files-recurse-submodules.sh
+++ b/t/t3007-ls-files-recurse-submodules.sh
@@ -299,6 +299,39 @@ test_expect_success '--recurse-submodules does not support --error-unmatch' '
test_i18ngrep "does not support --error-unmatch" actual
'
+test_expect_success '--recurse-submodules parses submodule repo config' '
+ test_config -C submodule index.sparse "invalid non-boolean value" &&
+ test_must_fail git ls-files --recurse-submodules 2>err &&
+ grep "bad boolean config value" err
+'
+
+test_expect_success '--recurse-submodules parses submodule worktree config' '
+ test_config -C submodule extensions.worktreeConfig true &&
+ test_config -C submodule --worktree index.sparse "invalid non-boolean value" &&
+
+ test_must_fail git ls-files --recurse-submodules 2>err &&
+ grep "bad boolean config value" err
+'
+
+test_expect_success '--recurse-submodules submodules ignore super project worktreeConfig extension' '
+ # Enable worktree config in both super project & submodule, set an
+ # invalid config in the submodule worktree config
+ test_config extensions.worktreeConfig true &&
+ test_config -C submodule extensions.worktreeConfig true &&
+ test_config -C submodule --worktree index.sparse "invalid non-boolean value" &&
+
+ # Now, disable the worktree config in the submodule. Note that we need
+ # to manually re-enable extensions.worktreeConfig when the test is
+ # finished, otherwise the test_unconfig of index.sparse will not work.
+ test_unconfig -C submodule extensions.worktreeConfig &&
+ test_when_finished "git -C submodule config extensions.worktreeConfig true" &&
+
+ # With extensions.worktreeConfig disabled in the submodule, the invalid
+ # worktree config is not picked up.
+ git ls-files --recurse-submodules 2>err &&
+ ! grep "bad boolean config value" err
+'
+
test_incompatible_with_recurse_submodules () {
test_expect_success "--recurse-submodules and $1 are incompatible" "
test_must_fail git ls-files --recurse-submodules $1 2>actual &&
diff --git a/t/t3013-ls-files-format.sh b/t/t3013-ls-files-format.sh
index ef6fb53..6e6ea0b 100755
--- a/t/t3013-ls-files-format.sh
+++ b/t/t3013-ls-files-format.sh
@@ -38,6 +38,41 @@ test_expect_success 'git ls-files --format objectname v.s. -s' '
test_cmp expect actual
'
+test_expect_success 'git ls-files --format objecttype' '
+ git ls-files --format="%(objectname)" o1.txt o4.txt o6.txt >objectname &&
+ git cat-file --batch-check="%(objecttype)" >expect <objectname &&
+ git ls-files --format="%(objecttype)" o1.txt o4.txt o6.txt >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files --format objectsize' '
+ cat>expect <<-\EOF &&
+26
+29
+27
+26
+-
+26
+ EOF
+ git ls-files --format="%(objectsize)" >actual &&
+
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files --format objectsize:padded' '
+ cat>expect <<-\EOF &&
+ 26
+ 29
+ 27
+ 26
+ -
+ 26
+ EOF
+ git ls-files --format="%(objectsize:padded)" >actual &&
+
+ test_cmp expect actual
+'
+
test_expect_success 'git ls-files --format v.s. --eol' '
git ls-files --eol >tmp &&
sed -e "s/ / /g" -e "s/ */ /g" tmp >expect 2>err &&
diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh
index 07a0ff9..7326adb 100755
--- a/t/t3210-pack-refs.sh
+++ b/t/t3210-pack-refs.sh
@@ -19,101 +19,138 @@ test_expect_success 'enable reflogs' '
git config core.logallrefupdates true
'
-test_expect_success \
- 'prepare a trivial repository' \
- 'echo Hello > A &&
- git update-index --add A &&
- git commit -m "Initial commit." &&
- HEAD=$(git rev-parse --verify HEAD)'
+test_expect_success 'prepare a trivial repository' '
+ echo Hello > A &&
+ git update-index --add A &&
+ git commit -m "Initial commit." &&
+ HEAD=$(git rev-parse --verify HEAD)
+'
SHA1=
-test_expect_success \
- 'see if git show-ref works as expected' \
- 'git branch a &&
- SHA1=$(cat .git/refs/heads/a) &&
- echo "$SHA1 refs/heads/a" >expect &&
- git show-ref a >result &&
- test_cmp expect result'
-
-test_expect_success \
- 'see if a branch still exists when packed' \
- 'git branch b &&
- git pack-refs --all &&
- rm -f .git/refs/heads/b &&
- echo "$SHA1 refs/heads/b" >expect &&
- git show-ref b >result &&
- test_cmp expect result'
+test_expect_success 'see if git show-ref works as expected' '
+ git branch a &&
+ SHA1=$(cat .git/refs/heads/a) &&
+ echo "$SHA1 refs/heads/a" >expect &&
+ git show-ref a >result &&
+ test_cmp expect result
+'
+
+test_expect_success 'see if a branch still exists when packed' '
+ git branch b &&
+ git pack-refs --all &&
+ rm -f .git/refs/heads/b &&
+ echo "$SHA1 refs/heads/b" >expect &&
+ git show-ref b >result &&
+ test_cmp expect result
+'
test_expect_success 'git branch c/d should barf if branch c exists' '
- git branch c &&
- git pack-refs --all &&
- rm -f .git/refs/heads/c &&
- test_must_fail git branch c/d
+ git branch c &&
+ git pack-refs --all &&
+ rm -f .git/refs/heads/c &&
+ test_must_fail git branch c/d
'
-test_expect_success \
- 'see if a branch still exists after git pack-refs --prune' \
- 'git branch e &&
- git pack-refs --all --prune &&
- echo "$SHA1 refs/heads/e" >expect &&
- git show-ref e >result &&
- test_cmp expect result'
+test_expect_success 'see if a branch still exists after git pack-refs --prune' '
+ git branch e &&
+ git pack-refs --all --prune &&
+ echo "$SHA1 refs/heads/e" >expect &&
+ git show-ref e >result &&
+ test_cmp expect result
+'
test_expect_success 'see if git pack-refs --prune remove ref files' '
- git branch f &&
- git pack-refs --all --prune &&
- ! test -f .git/refs/heads/f
+ git branch f &&
+ git pack-refs --all --prune &&
+ ! test -f .git/refs/heads/f
'
test_expect_success 'see if git pack-refs --prune removes empty dirs' '
- git branch r/s/t &&
- git pack-refs --all --prune &&
- ! test -e .git/refs/heads/r
+ git branch r/s/t &&
+ git pack-refs --all --prune &&
+ ! test -e .git/refs/heads/r
'
-test_expect_success \
- 'git branch g should work when git branch g/h has been deleted' \
- 'git branch g/h &&
- git pack-refs --all --prune &&
- git branch -d g/h &&
- git branch g &&
- git pack-refs --all &&
- git branch -d g'
+test_expect_success 'git branch g should work when git branch g/h has been deleted' '
+ git branch g/h &&
+ git pack-refs --all --prune &&
+ git branch -d g/h &&
+ git branch g &&
+ git pack-refs --all &&
+ git branch -d g
+'
test_expect_success 'git branch i/j/k should barf if branch i exists' '
- git branch i &&
- git pack-refs --all --prune &&
- test_must_fail git branch i/j/k
+ git branch i &&
+ git pack-refs --all --prune &&
+ test_must_fail git branch i/j/k
+'
+
+test_expect_success 'test git branch k after branch k/l/m and k/lm have been deleted' '
+ git branch k/l &&
+ git branch k/lm &&
+ git branch -d k/l &&
+ git branch k/l/m &&
+ git branch -d k/l/m &&
+ git branch -d k/lm &&
+ git branch k
'
-test_expect_success \
- 'test git branch k after branch k/l/m and k/lm have been deleted' \
- 'git branch k/l &&
- git branch k/lm &&
- git branch -d k/l &&
- git branch k/l/m &&
- git branch -d k/l/m &&
- git branch -d k/lm &&
- git branch k'
-
-test_expect_success \
- 'test git branch n after some branch deletion and pruning' \
- 'git branch n/o &&
- git branch n/op &&
- git branch -d n/o &&
- git branch n/o/p &&
- git branch -d n/op &&
- git pack-refs --all --prune &&
- git branch -d n/o/p &&
- git branch n'
-
-test_expect_success \
- 'see if up-to-date packed refs are preserved' \
- 'git branch q &&
- git pack-refs --all --prune &&
- git update-ref refs/heads/q refs/heads/q &&
- ! test -f .git/refs/heads/q'
+test_expect_success 'test git branch n after some branch deletion and pruning' '
+ git branch n/o &&
+ git branch n/op &&
+ git branch -d n/o &&
+ git branch n/o/p &&
+ git branch -d n/op &&
+ git pack-refs --all --prune &&
+ git branch -d n/o/p &&
+ git branch n
+'
+
+test_expect_success 'test excluded refs are not packed' '
+ git branch dont_pack1 &&
+ git branch dont_pack2 &&
+ git branch pack_this &&
+ git pack-refs --all --exclude "refs/heads/dont_pack*" &&
+ test -f .git/refs/heads/dont_pack1 &&
+ test -f .git/refs/heads/dont_pack2 &&
+ ! test -f .git/refs/heads/pack_this'
+
+test_expect_success 'test --no-exclude refs clears excluded refs' '
+ git branch dont_pack3 &&
+ git branch dont_pack4 &&
+ git pack-refs --all --exclude "refs/heads/dont_pack*" --no-exclude &&
+ ! test -f .git/refs/heads/dont_pack3 &&
+ ! test -f .git/refs/heads/dont_pack4'
+
+test_expect_success 'test only included refs are packed' '
+ git branch pack_this1 &&
+ git branch pack_this2 &&
+ git tag dont_pack5 &&
+ git pack-refs --include "refs/heads/pack_this*" &&
+ test -f .git/refs/tags/dont_pack5 &&
+ ! test -f .git/refs/heads/pack_this1 &&
+ ! test -f .git/refs/heads/pack_this2'
+
+test_expect_success 'test --no-include refs clears included refs' '
+ git branch pack1 &&
+ git branch pack2 &&
+ git pack-refs --include "refs/heads/pack*" --no-include &&
+ test -f .git/refs/heads/pack1 &&
+ test -f .git/refs/heads/pack2'
+
+test_expect_success 'test --exclude takes precedence over --include' '
+ git branch dont_pack5 &&
+ git pack-refs --include "refs/heads/pack*" --exclude "refs/heads/pack*" &&
+ test -f .git/refs/heads/dont_pack5'
+
+test_expect_success 'see if up-to-date packed refs are preserved' '
+ git branch q &&
+ git pack-refs --all --prune &&
+ git update-ref refs/heads/q refs/heads/q &&
+ ! test -f .git/refs/heads/q
+'
test_expect_success 'pack, prune and repack' '
git tag foo &&
diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh
index 0458a58..78c3eac 100755
--- a/t/t3500-cherry.sh
+++ b/t/t3500-cherry.sh
@@ -16,46 +16,43 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
GIT_AUTHOR_EMAIL=bogus_email_address
export GIT_AUTHOR_EMAIL
-test_expect_success \
- 'prepare repository with topic branch, and check cherry finds the 2 patches from there' \
- 'echo First > A &&
- git update-index --add A &&
- test_tick &&
- git commit -m "Add A." &&
-
- git checkout -b my-topic-branch &&
-
- echo Second > B &&
- git update-index --add B &&
- test_tick &&
- git commit -m "Add B." &&
-
- echo AnotherSecond > C &&
- git update-index --add C &&
- test_tick &&
- git commit -m "Add C." &&
-
- git checkout -f main &&
- rm -f B C &&
-
- echo Third >> A &&
- git update-index A &&
- test_tick &&
- git commit -m "Modify A." &&
-
- expr "$(echo $(git cherry main my-topic-branch) )" : "+ [^ ]* + .*"
+test_expect_success 'prepare repository with topic branch, and check cherry finds the 2 patches from there' '
+ echo First > A &&
+ git update-index --add A &&
+ test_tick &&
+ git commit -m "Add A." &&
+
+ git checkout -b my-topic-branch &&
+
+ echo Second > B &&
+ git update-index --add B &&
+ test_tick &&
+ git commit -m "Add B." &&
+
+ echo AnotherSecond > C &&
+ git update-index --add C &&
+ test_tick &&
+ git commit -m "Add C." &&
+
+ git checkout -f main &&
+ rm -f B C &&
+
+ echo Third >> A &&
+ git update-index A &&
+ test_tick &&
+ git commit -m "Modify A." &&
+
+ expr "$(echo $(git cherry main my-topic-branch) )" : "+ [^ ]* + .*"
'
-test_expect_success \
- 'check that cherry with limit returns only the top patch'\
- 'expr "$(echo $(git cherry main my-topic-branch my-topic-branch^1) )" : "+ [^ ]*"
+test_expect_success 'check that cherry with limit returns only the top patch' '
+ expr "$(echo $(git cherry main my-topic-branch my-topic-branch^1) )" : "+ [^ ]*"
'
-test_expect_success \
- 'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' \
- 'git cherry-pick my-topic-branch^0 &&
- echo $(git cherry main my-topic-branch) &&
- expr "$(echo $(git cherry main my-topic-branch) )" : "+ [^ ]* - .*"
+test_expect_success 'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' '
+ git cherry-pick my-topic-branch^0 &&
+ echo $(git cherry main my-topic-branch) &&
+ expr "$(echo $(git cherry main my-topic-branch) )" : "+ [^ ]* - .*"
'
test_expect_success 'cherry ignores whitespace' '
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 82dd768..7623689 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -24,17 +24,17 @@ test_mode_in_index () {
esac
}
-test_expect_success \
- 'Test of git add' \
- 'touch foo && git add foo'
+test_expect_success 'Test of git add' '
+ touch foo && git add foo
+'
-test_expect_success \
- 'Post-check that foo is in the index' \
- 'git ls-files foo | grep foo'
+test_expect_success 'Post-check that foo is in the index' '
+ git ls-files foo | grep foo
+'
-test_expect_success \
- 'Test that "git add -- -q" works' \
- 'touch -- -q && git add -- -q'
+test_expect_success 'Test that "git add -- -q" works' '
+ touch -- -q && git add -- -q
+'
BATCH_CONFIGURATION='-c core.fsync=loose-object -c core.fsyncmethod=batch'
@@ -284,14 +284,14 @@ test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors = false)' '
rm -f foo2
test_expect_success POSIXPERM,SANITY '--no-ignore-errors overrides config' '
- git config add.ignore-errors 1 &&
- git reset --hard &&
- date >foo1 &&
- date >foo2 &&
- chmod 0 foo2 &&
- test_must_fail git add --verbose --no-ignore-errors . &&
- ! ( git ls-files foo1 | grep foo1 ) &&
- git config add.ignore-errors 0
+ git config add.ignore-errors 1 &&
+ git reset --hard &&
+ date >foo1 &&
+ date >foo2 &&
+ chmod 0 foo2 &&
+ test_must_fail git add --verbose --no-ignore-errors . &&
+ ! ( git ls-files foo1 | grep foo1 ) &&
+ git config add.ignore-errors 0
'
rm -f foo2
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 3982b6b..34aabb7 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -734,6 +734,44 @@ test_expect_success 'colors can be overridden' '
test_cmp expect actual
'
+test_expect_success 'brackets appear without color' '
+ git reset --hard &&
+ test_when_finished "git rm -f bracket-test" &&
+ test_write_lines context old more-context >bracket-test &&
+ git add bracket-test &&
+ test_write_lines context new more-context another-one >bracket-test &&
+
+ test_write_lines quit >input &&
+ git add -i >actual <input &&
+
+ sed "s/^|//" >expect <<-\EOF &&
+ | staged unstaged path
+ | 1: +3/-0 +2/-1 bracket-test
+ |
+ |*** Commands ***
+ | 1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked
+ | 5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elp
+ |What now> Bye.
+ EOF
+
+ test_cmp expect actual
+'
+
+test_expect_success 'colors can be skipped with color.ui=false' '
+ git reset --hard &&
+ test_when_finished "git rm -f color-test" &&
+ test_write_lines context old more-context >color-test &&
+ git add color-test &&
+ test_write_lines context new more-context another-one >color-test &&
+
+ test_write_lines help quit >input &&
+ force_color git \
+ -c color.ui=false \
+ add -i >actual.raw <input &&
+ test_decode_color <actual.raw >actual &&
+ test_cmp actual.raw actual
+'
+
test_expect_success 'colorized diffs respect diff.wsErrorHighlight' '
git reset --hard &&
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 376cc8f..0b3dfea 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -1211,19 +1211,19 @@ test_expect_success 'stash with file including $IFS character' '
'
test_expect_success 'stash with pathspec matching multiple paths' '
- echo original >file &&
- echo original >other-file &&
- git commit -m "two" file other-file &&
- echo modified >file &&
- echo modified >other-file &&
- git stash push -- "*file" &&
- echo original >expect &&
- test_cmp expect file &&
- test_cmp expect other-file &&
- git stash pop &&
- echo modified >expect &&
- test_cmp expect file &&
- test_cmp expect other-file
+ echo original >file &&
+ echo original >other-file &&
+ git commit -m "two" file other-file &&
+ echo modified >file &&
+ echo modified >other-file &&
+ git stash push -- "*file" &&
+ echo original >expect &&
+ test_cmp expect file &&
+ test_cmp expect other-file &&
+ git stash pop &&
+ echo modified >expect &&
+ test_cmp expect file &&
+ test_cmp expect other-file
'
test_expect_success 'stash push -p with pathspec shows no changes only once' '
diff --git a/t/t4000-diff-format.sh b/t/t4000-diff-format.sh
index bfcaae3..8d50331 100755
--- a/t/t4000-diff-format.sh
+++ b/t/t4000-diff-format.sh
@@ -5,6 +5,9 @@
test_description='Test built-in diff output engine.
+We happen to know that all diff plumbing and diff Porcelain share the
+same command line parser, so testing one should be sufficient; pick
+diff-files as a representative.
'
TEST_PASSES_SANITIZE_LEAK=true
@@ -16,9 +19,11 @@ Line 2
line 3'
cat path0 >path1
chmod +x path1
+mkdir path2
+>path2/path3
test_expect_success 'update-index --add two files with and without +x.' '
- git update-index --add path0 path1
+ git update-index --add path0 path1 path2/path3
'
mv path0 path0-
@@ -91,4 +96,31 @@ test_expect_success 'git diff-files --patch --no-patch does not show the patch'
test_must_be_empty err
'
+
+# Smudge path2/path3 so that dirstat has something to show
+date >path2/path3
+
+for format in stat raw numstat shortstat summary \
+ dirstat cumulative dirstat-by-file \
+ patch-with-raw patch-with-stat compact-summary
+do
+ test_expect_success "--no-patch in 'git diff-files --no-patch --$format' is a no-op" '
+ git diff-files --no-patch "--$format" >actual &&
+ git diff-files "--$format" >expect &&
+ test_cmp expect actual
+ '
+
+ test_expect_success "--no-patch clears all previous ones" '
+ git diff-files --$format -s -p >actual &&
+ git diff-files -p >expect &&
+ test_cmp expect actual
+ '
+
+ test_expect_success "--no-patch in 'git diff --no-patch --$format' is a no-op" '
+ git diff --no-patch "--$format" >actual &&
+ git diff "--$format" >expect &&
+ test_cmp expect actual
+ '
+done
+
test_done
diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh
index ea52e5b..d524d40 100755
--- a/t/t4002-diff-basic.sh
+++ b/t/t4002-diff-basic.sh
@@ -284,132 +284,131 @@ cmp_diff_files_output () {
test_cmp "$1" .test-tmp
}
-test_expect_success \
- 'diff-tree of known trees.' \
- 'git diff-tree $tree_O $tree_A >.test-a &&
- cmp -s .test-a .test-plain-OA'
-
-test_expect_success \
- 'diff-tree of known trees.' \
- 'git diff-tree -r $tree_O $tree_A >.test-a &&
- cmp -s .test-a .test-recursive-OA'
-
-test_expect_success \
- 'diff-tree of known trees.' \
- 'git diff-tree $tree_O $tree_B >.test-a &&
- cmp -s .test-a .test-plain-OB'
-
-test_expect_success \
- 'diff-tree of known trees.' \
- 'git diff-tree -r $tree_O $tree_B >.test-a &&
- cmp -s .test-a .test-recursive-OB'
-
-test_expect_success \
- 'diff-tree of known trees.' \
- 'git diff-tree $tree_A $tree_B >.test-a &&
- cmp -s .test-a .test-plain-AB'
-
-test_expect_success \
- 'diff-tree of known trees.' \
- 'git diff-tree -r $tree_A $tree_B >.test-a &&
- cmp -s .test-a .test-recursive-AB'
-
-test_expect_success \
- 'diff-tree --stdin of known trees.' \
- 'echo $tree_A $tree_B | git diff-tree --stdin > .test-a &&
- echo $tree_A $tree_B > .test-plain-ABx &&
- cat .test-plain-AB >> .test-plain-ABx &&
- cmp -s .test-a .test-plain-ABx'
-
-test_expect_success \
- 'diff-tree --stdin of known trees.' \
- 'echo $tree_A $tree_B | git diff-tree -r --stdin > .test-a &&
- echo $tree_A $tree_B > .test-recursive-ABx &&
- cat .test-recursive-AB >> .test-recursive-ABx &&
- cmp -s .test-a .test-recursive-ABx'
-
-test_expect_success \
- 'diff-cache O with A in cache' \
- 'git read-tree $tree_A &&
- git diff-index --cached $tree_O >.test-a &&
- cmp -s .test-a .test-recursive-OA'
-
-test_expect_success \
- 'diff-cache O with B in cache' \
- 'git read-tree $tree_B &&
- git diff-index --cached $tree_O >.test-a &&
- cmp -s .test-a .test-recursive-OB'
-
-test_expect_success \
- 'diff-cache A with B in cache' \
- 'git read-tree $tree_B &&
- git diff-index --cached $tree_A >.test-a &&
- cmp -s .test-a .test-recursive-AB'
-
-test_expect_success \
- 'diff-files with O in cache and A checked out' \
- 'rm -fr Z [A-Z][A-Z] &&
- git read-tree $tree_A &&
- git checkout-index -f -a &&
- git read-tree --reset $tree_O &&
- test_must_fail git update-index --refresh -q &&
- git diff-files >.test-a &&
- cmp_diff_files_output .test-a .test-recursive-OA'
-
-test_expect_success \
- 'diff-files with O in cache and B checked out' \
- 'rm -fr Z [A-Z][A-Z] &&
- git read-tree $tree_B &&
- git checkout-index -f -a &&
- git read-tree --reset $tree_O &&
- test_must_fail git update-index --refresh -q &&
- git diff-files >.test-a &&
- cmp_diff_files_output .test-a .test-recursive-OB'
-
-test_expect_success \
- 'diff-files with A in cache and B checked out' \
- 'rm -fr Z [A-Z][A-Z] &&
- git read-tree $tree_B &&
- git checkout-index -f -a &&
- git read-tree --reset $tree_A &&
- test_must_fail git update-index --refresh -q &&
- git diff-files >.test-a &&
- cmp_diff_files_output .test-a .test-recursive-AB'
+test_expect_success 'diff-tree of known trees.' '
+ git diff-tree $tree_O $tree_A >.test-a &&
+ cmp -s .test-a .test-plain-OA
+'
+
+test_expect_success 'diff-tree of known trees.' '
+ git diff-tree -r $tree_O $tree_A >.test-a &&
+ cmp -s .test-a .test-recursive-OA
+'
+
+test_expect_success 'diff-tree of known trees.' '
+ git diff-tree $tree_O $tree_B >.test-a &&
+ cmp -s .test-a .test-plain-OB
+'
+
+test_expect_success 'diff-tree of known trees.' '
+ git diff-tree -r $tree_O $tree_B >.test-a &&
+ cmp -s .test-a .test-recursive-OB
+'
+
+test_expect_success 'diff-tree of known trees.' '
+ git diff-tree $tree_A $tree_B >.test-a &&
+ cmp -s .test-a .test-plain-AB
+'
+
+test_expect_success 'diff-tree of known trees.' '
+ git diff-tree -r $tree_A $tree_B >.test-a &&
+ cmp -s .test-a .test-recursive-AB
+'
+
+test_expect_success 'diff-tree --stdin of known trees.' '
+ echo $tree_A $tree_B | git diff-tree --stdin > .test-a &&
+ echo $tree_A $tree_B > .test-plain-ABx &&
+ cat .test-plain-AB >> .test-plain-ABx &&
+ cmp -s .test-a .test-plain-ABx
+'
+
+test_expect_success 'diff-tree --stdin of known trees.' '
+ echo $tree_A $tree_B | git diff-tree -r --stdin > .test-a &&
+ echo $tree_A $tree_B > .test-recursive-ABx &&
+ cat .test-recursive-AB >> .test-recursive-ABx &&
+ cmp -s .test-a .test-recursive-ABx
+'
+
+test_expect_success 'diff-cache O with A in cache' '
+ git read-tree $tree_A &&
+ git diff-index --cached $tree_O >.test-a &&
+ cmp -s .test-a .test-recursive-OA
+'
+
+test_expect_success 'diff-cache O with B in cache' '
+ git read-tree $tree_B &&
+ git diff-index --cached $tree_O >.test-a &&
+ cmp -s .test-a .test-recursive-OB
+'
+
+test_expect_success 'diff-cache A with B in cache' '
+ git read-tree $tree_B &&
+ git diff-index --cached $tree_A >.test-a &&
+ cmp -s .test-a .test-recursive-AB
+'
+
+test_expect_success 'diff-files with O in cache and A checked out' '
+ rm -fr Z [A-Z][A-Z] &&
+ git read-tree $tree_A &&
+ git checkout-index -f -a &&
+ git read-tree --reset $tree_O &&
+ test_must_fail git update-index --refresh -q &&
+ git diff-files >.test-a &&
+ cmp_diff_files_output .test-a .test-recursive-OA
+'
+
+test_expect_success 'diff-files with O in cache and B checked out' '
+ rm -fr Z [A-Z][A-Z] &&
+ git read-tree $tree_B &&
+ git checkout-index -f -a &&
+ git read-tree --reset $tree_O &&
+ test_must_fail git update-index --refresh -q &&
+ git diff-files >.test-a &&
+ cmp_diff_files_output .test-a .test-recursive-OB
+'
+
+test_expect_success 'diff-files with A in cache and B checked out' '
+ rm -fr Z [A-Z][A-Z] &&
+ git read-tree $tree_B &&
+ git checkout-index -f -a &&
+ git read-tree --reset $tree_A &&
+ test_must_fail git update-index --refresh -q &&
+ git diff-files >.test-a &&
+ cmp_diff_files_output .test-a .test-recursive-AB
+'
################################################################
# Now we have established the baseline, we do not have to
# rely on individual object ID values that much.
-test_expect_success \
- 'diff-tree O A == diff-tree -R A O' \
- 'git diff-tree $tree_O $tree_A >.test-a &&
- git diff-tree -R $tree_A $tree_O >.test-b &&
- cmp -s .test-a .test-b'
-
-test_expect_success \
- 'diff-tree -r O A == diff-tree -r -R A O' \
- 'git diff-tree -r $tree_O $tree_A >.test-a &&
- git diff-tree -r -R $tree_A $tree_O >.test-b &&
- cmp -s .test-a .test-b'
-
-test_expect_success \
- 'diff-tree B A == diff-tree -R A B' \
- 'git diff-tree $tree_B $tree_A >.test-a &&
- git diff-tree -R $tree_A $tree_B >.test-b &&
- cmp -s .test-a .test-b'
-
-test_expect_success \
- 'diff-tree -r B A == diff-tree -r -R A B' \
- 'git diff-tree -r $tree_B $tree_A >.test-a &&
- git diff-tree -r -R $tree_A $tree_B >.test-b &&
- cmp -s .test-a .test-b'
-
-test_expect_success \
- 'diff can read from stdin' \
- 'test_must_fail git diff --no-index -- MN - < NN |
- grep -v "^index" | sed "s#/-#/NN#" >.test-a &&
- test_must_fail git diff --no-index -- MN NN |
- grep -v "^index" >.test-b &&
- test_cmp .test-a .test-b'
+test_expect_success 'diff-tree O A == diff-tree -R A O' '
+ git diff-tree $tree_O $tree_A >.test-a &&
+ git diff-tree -R $tree_A $tree_O >.test-b &&
+ cmp -s .test-a .test-b
+'
+
+test_expect_success 'diff-tree -r O A == diff-tree -r -R A O' '
+ git diff-tree -r $tree_O $tree_A >.test-a &&
+ git diff-tree -r -R $tree_A $tree_O >.test-b &&
+ cmp -s .test-a .test-b
+'
+
+test_expect_success 'diff-tree B A == diff-tree -R A B' '
+ git diff-tree $tree_B $tree_A >.test-a &&
+ git diff-tree -R $tree_A $tree_B >.test-b &&
+ cmp -s .test-a .test-b
+'
+
+test_expect_success 'diff-tree -r B A == diff-tree -r -R A B' '
+ git diff-tree -r $tree_B $tree_A >.test-a &&
+ git diff-tree -r -R $tree_A $tree_B >.test-b &&
+ cmp -s .test-a .test-b'
+
+test_expect_success'diff can read from stdin' '
+ test_must_fail git diff --no-index -- MN - < NN |
+ grep -v "^index" | sed "s#/-#/NN#" >.test-a &&
+ test_must_fail git diff --no-index -- MN NN |
+ grep -v "^index" >.test-b &&
+ test_cmp .test-a .test-b
+'
test_done
diff --git a/t/t4003-diff-rename-1.sh b/t/t4003-diff-rename-1.sh
index 181e968..ebe0918 100755
--- a/t/t4003-diff-rename-1.sh
+++ b/t/t4003-diff-rename-1.sh
@@ -11,20 +11,20 @@ TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
-test_expect_success \
- 'prepare reference tree' \
- 'COPYING_test_data >COPYING &&
- echo frotz >rezrov &&
- git update-index --add COPYING rezrov &&
- tree=$(git write-tree) &&
- echo $tree'
-
-test_expect_success \
- 'prepare work tree' \
- 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
- sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
- rm -f COPYING &&
- git update-index --add --remove COPYING COPYING.?'
+test_expect_success 'prepare reference tree' '
+ COPYING_test_data >COPYING &&
+ echo frotz >rezrov &&
+ git update-index --add COPYING rezrov &&
+ tree=$(git write-tree) &&
+ echo $tree
+'
+
+test_expect_success 'prepare work tree' '
+ sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
+ sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
+ rm -f COPYING &&
+ git update-index --add --remove COPYING COPYING.?
+'
# tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
# both are slightly edited, and unchanged rezrov. So we say you
@@ -57,14 +57,14 @@ rename to COPYING.2
+ This file is licensed under the G.P.L v2, or a later version
EOF
-test_expect_success \
- 'validate output from rename/copy detection (#1)' \
- 'compare_diff_patch current expected'
+test_expect_success 'validate output from rename/copy detection (#1)' '
+ compare_diff_patch current expected
+'
-test_expect_success \
- 'prepare work tree again' \
- 'mv COPYING.2 COPYING &&
- git update-index --add --remove COPYING COPYING.1 COPYING.2'
+test_expect_success 'prepare work tree again' '
+ mv COPYING.2 COPYING &&
+ git update-index --add --remove COPYING COPYING.1 COPYING.2
+'
# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
# both are slightly edited, and unchanged rezrov. So we say you
@@ -95,14 +95,14 @@ copy to COPYING.1
+ However, in order to allow a migration to GPLv3 if that seems like
EOF
-test_expect_success \
- 'validate output from rename/copy detection (#2)' \
- 'compare_diff_patch current expected'
+test_expect_success 'validate output from rename/copy detection (#2)' '
+ compare_diff_patch current expected
+'
-test_expect_success \
- 'prepare work tree once again' \
- 'COPYING_test_data >COPYING &&
- git update-index --add --remove COPYING COPYING.1'
+test_expect_success 'prepare work tree once again' '
+ COPYING_test_data >COPYING &&
+ git update-index --add --remove COPYING COPYING.1
+'
# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
# but COPYING is not edited. We say you copy-and-edit COPYING.1; this
@@ -123,8 +123,8 @@ copy to COPYING.1
+ However, in order to allow a migration to GPLv3 if that seems like
EOF
-test_expect_success \
- 'validate output from rename/copy detection (#3)' \
- 'compare_diff_patch current expected'
+test_expect_success 'validate output from rename/copy detection (#3)' '
+ compare_diff_patch current expected
+'
test_done
diff --git a/t/t4004-diff-rename-symlink.sh b/t/t4004-diff-rename-symlink.sh
index 8def4d4..1d70d4d 100755
--- a/t/t4004-diff-rename-symlink.sh
+++ b/t/t4004-diff-rename-symlink.sh
@@ -14,21 +14,21 @@ TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-diff.sh
-test_expect_success SYMLINKS \
- 'prepare reference tree' \
- 'echo xyzzy | tr -d '\\\\'012 >yomin &&
- ln -s xyzzy frotz &&
- git update-index --add frotz yomin &&
- tree=$(git write-tree) &&
- echo $tree'
+test_expect_success SYMLINKS 'prepare reference tree' '
+ echo xyzzy | tr -d '\\\\'012 >yomin &&
+ ln -s xyzzy frotz &&
+ git update-index --add frotz yomin &&
+ tree=$(git write-tree) &&
+ echo $tree
+'
-test_expect_success SYMLINKS \
- 'prepare work tree' \
- 'mv frotz rezrov &&
- rm -f yomin &&
- ln -s xyzzy nitfol &&
- ln -s xzzzy bozbar &&
- git update-index --add --remove frotz rezrov nitfol bozbar yomin'
+test_expect_success SYMLINKS 'prepare work tree' '
+ mv frotz rezrov &&
+ rm -f yomin &&
+ ln -s xyzzy nitfol &&
+ ln -s xzzzy bozbar &&
+ git update-index --add --remove frotz rezrov nitfol bozbar yomin
+'
# tree has frotz pointing at xyzzy, and yomin that contains xyzzy to
# confuse things. work tree has rezrov (xyzzy) nitfol (xyzzy) and
@@ -36,9 +36,9 @@ test_expect_success SYMLINKS \
# rezrov and nitfol are rename/copy of frotz and bozbar should be
# a new creation.
-test_expect_success SYMLINKS 'setup diff output' "
- GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current &&
- cat >expected <<\EOF
+test_expect_success SYMLINKS 'setup diff output' '
+ GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current &&
+ cat >expected <<\EOF
diff --git a/bozbar b/bozbar
new file mode 120000
--- /dev/null
@@ -62,10 +62,10 @@ deleted file mode 100644
-xyzzy
\ No newline at end of file
EOF
-"
+'
-test_expect_success SYMLINKS \
- 'validate diff output' \
- 'compare_diff_patch current expected'
+test_expect_success SYMLINKS 'validate diff output' '
+ compare_diff_patch current expected
+'
test_done
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index ae73aef..af4a123 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -187,6 +187,21 @@ test_expect_success 'git config log.follow does not die with no paths' '
git log --
'
+test_expect_success 'git log --follow rejects unsupported pathspec magic' '
+ test_must_fail git log --follow ":(top,glob,icase)ichi" 2>stderr &&
+ # check full error message; we want to be sure we mention both
+ # of the rejected types (glob,icase), but not the allowed one (top)
+ echo "fatal: pathspec magic not supported by --follow: ${SQ}glob${SQ}, ${SQ}icase${SQ}" >expect &&
+ test_cmp expect stderr
+'
+
+test_expect_success 'log.follow disabled with unsupported pathspec magic' '
+ test_config log.follow true &&
+ git log --format=%s ":(glob,icase)ichi" >actual &&
+ echo third >expect &&
+ test_cmp expect actual
+'
+
test_expect_success 'git config log.follow is overridden by --no-follow' '
test_config log.follow true &&
git log --no-follow --pretty="format:%s" ichi >actual &&
@@ -2343,10 +2358,10 @@ test_expect_success 'log --decorate does not include things outside filter' '
'
test_expect_success 'log --end-of-options' '
- git update-ref refs/heads/--source HEAD &&
- git log --end-of-options --source >actual &&
- git log >expect &&
- test_cmp expect actual
+ git update-ref refs/heads/--source HEAD &&
+ git log --end-of-options --source >actual &&
+ git log >expect &&
+ test_cmp expect actual
'
test_expect_success 'set up commits with different authors' '
diff --git a/t/t4206-log-follow-harder-copies.sh b/t/t4206-log-follow-harder-copies.sh
index 33ecf82..9167b03 100755
--- a/t/t4206-log-follow-harder-copies.sh
+++ b/t/t4206-log-follow-harder-copies.sh
@@ -16,29 +16,29 @@ Line 2
Line 3
'
-test_expect_success \
- 'add a file path0 and commit.' \
- 'git add path0 &&
- git commit -m "Add path0"'
+test_expect_success 'add a file path0 and commit.' '
+ git add path0 &&
+ git commit -m "Add path0"
+'
echo >path0 'New line 1
New line 2
New line 3
'
-test_expect_success \
- 'Change path0.' \
- 'git add path0 &&
- git commit -m "Change path0"'
+test_expect_success 'Change path0.' '
+ git add path0 &&
+ git commit -m "Change path0"
+'
cat <path0 >path1
-test_expect_success \
- 'copy path0 to path1.' \
- 'git add path1 &&
- git commit -m "Copy path1 from path0"'
+test_expect_success 'copy path0 to path1.' '
+ git add path1 &&
+ git commit -m "Copy path1 from path0"
+'
-test_expect_success \
- 'find the copy path0 -> path1 harder' \
- 'git log --follow --name-status --pretty="format:%s" path1 > current'
+test_expect_success 'find the copy path0 -> path1 harder' '
+ git log --follow --name-status --pretty="format:%s" path1 > current
+'
cat >expected <<\EOF
Copy path1 from path0
@@ -51,8 +51,8 @@ Add path0
A path0
EOF
-test_expect_success \
- 'validate the output.' \
- 'compare_diff_patch current expected'
+test_expect_success 'validate the output.' '
+ compare_diff_patch current expected
+'
test_done
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index d2ce236..7450894 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -208,7 +208,7 @@ test_expect_success 'unpack with OFS_DELTA' '
'
test_expect_success 'unpack with OFS_DELTA (core.fsyncmethod=batch)' '
- check_unpack test-3-${packname_3} obj-list "$BATCH_CONFIGURATION"
+ check_unpack test-3-${packname_3} obj-list "$BATCH_CONFIGURATION"
'
test_expect_success 'compare delta flavors' '
@@ -263,97 +263,97 @@ test_expect_success 'survive missing objects/pack directory' '
)
'
-test_expect_success \
- 'verify pack' \
- 'git verify-pack test-1-${packname_1}.idx \
- test-2-${packname_2}.idx \
- test-3-${packname_3}.idx'
-
-test_expect_success \
- 'verify pack -v' \
- 'git verify-pack -v test-1-${packname_1}.idx \
- test-2-${packname_2}.idx \
- test-3-${packname_3}.idx'
-
-test_expect_success \
- 'verify-pack catches mismatched .idx and .pack files' \
- 'cat test-1-${packname_1}.idx >test-3.idx &&
- cat test-2-${packname_2}.pack >test-3.pack &&
- if git verify-pack test-3.idx
- then false
- else :;
- fi'
-
-test_expect_success \
- 'verify-pack catches a corrupted pack signature' \
- 'cat test-1-${packname_1}.pack >test-3.pack &&
- echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=2 &&
- if git verify-pack test-3.idx
- then false
- else :;
- fi'
-
-test_expect_success \
- 'verify-pack catches a corrupted pack version' \
- 'cat test-1-${packname_1}.pack >test-3.pack &&
- echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=7 &&
- if git verify-pack test-3.idx
- then false
- else :;
- fi'
-
-test_expect_success \
- 'verify-pack catches a corrupted type/size of the 1st packed object data' \
- 'cat test-1-${packname_1}.pack >test-3.pack &&
- echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=12 &&
- if git verify-pack test-3.idx
- then false
- else :;
- fi'
-
-test_expect_success \
- 'verify-pack catches a corrupted sum of the index file itself' \
- 'l=$(wc -c <test-3.idx) &&
- l=$(expr $l - 20) &&
- cat test-1-${packname_1}.pack >test-3.pack &&
- printf "%20s" "" | dd of=test-3.idx count=20 bs=1 conv=notrunc seek=$l &&
- if git verify-pack test-3.pack
- then false
- else :;
- fi'
-
-test_expect_success \
- 'build pack index for an existing pack' \
- 'cat test-1-${packname_1}.pack >test-3.pack &&
- git index-pack -o tmp.idx test-3.pack &&
- cmp tmp.idx test-1-${packname_1}.idx &&
-
- git index-pack --promisor=message test-3.pack &&
- cmp test-3.idx test-1-${packname_1}.idx &&
- echo message >expect &&
- test_cmp expect test-3.promisor &&
-
- cat test-2-${packname_2}.pack >test-3.pack &&
- git index-pack -o tmp.idx test-2-${packname_2}.pack &&
- cmp tmp.idx test-2-${packname_2}.idx &&
-
- git index-pack test-3.pack &&
- cmp test-3.idx test-2-${packname_2}.idx &&
-
- cat test-3-${packname_3}.pack >test-3.pack &&
- git index-pack -o tmp.idx test-3-${packname_3}.pack &&
- cmp tmp.idx test-3-${packname_3}.idx &&
-
- git index-pack test-3.pack &&
- cmp test-3.idx test-3-${packname_3}.idx &&
-
- cat test-1-${packname_1}.pack >test-4.pack &&
- rm -f test-4.keep &&
- git index-pack --keep=why test-4.pack &&
- cmp test-1-${packname_1}.idx test-4.idx &&
- test -f test-4.keep &&
-
- :'
+test_expect_success 'verify pack' '
+ git verify-pack test-1-${packname_1}.idx \
+ test-2-${packname_2}.idx \
+ test-3-${packname_3}.idx
+'
+
+test_expect_success 'verify pack -v' '
+ git verify-pack -v test-1-${packname_1}.idx \
+ test-2-${packname_2}.idx \
+ test-3-${packname_3}.idx
+'
+
+test_expect_success 'verify-pack catches mismatched .idx and .pack files' '
+ cat test-1-${packname_1}.idx >test-3.idx &&
+ cat test-2-${packname_2}.pack >test-3.pack &&
+ if git verify-pack test-3.idx
+ then false
+ else :;
+ fi
+'
+
+test_expect_success 'verify-pack catches a corrupted pack signature' '
+ cat test-1-${packname_1}.pack >test-3.pack &&
+ echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=2 &&
+ if git verify-pack test-3.idx
+ then false
+ else :;
+ fi
+'
+
+test_expect_success 'verify-pack catches a corrupted pack version' '
+ cat test-1-${packname_1}.pack >test-3.pack &&
+ echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=7 &&
+ if git verify-pack test-3.idx
+ then false
+ else :;
+ fi
+'
+
+test_expect_success 'verify-pack catches a corrupted type/size of the 1st packed object data' '
+ cat test-1-${packname_1}.pack >test-3.pack &&
+ echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=12 &&
+ if git verify-pack test-3.idx
+ then false
+ else :;
+ fi
+'
+
+test_expect_success 'verify-pack catches a corrupted sum of the index file itself' '
+ l=$(wc -c <test-3.idx) &&
+ l=$(expr $l - 20) &&
+ cat test-1-${packname_1}.pack >test-3.pack &&
+ printf "%20s" "" | dd of=test-3.idx count=20 bs=1 conv=notrunc seek=$l &&
+ if git verify-pack test-3.pack
+ then false
+ else :;
+ fi
+'
+
+test_expect_success 'build pack index for an existing pack' '
+ cat test-1-${packname_1}.pack >test-3.pack &&
+ git index-pack -o tmp.idx test-3.pack &&
+ cmp tmp.idx test-1-${packname_1}.idx &&
+
+ git index-pack --promisor=message test-3.pack &&
+ cmp test-3.idx test-1-${packname_1}.idx &&
+ echo message >expect &&
+ test_cmp expect test-3.promisor &&
+
+ cat test-2-${packname_2}.pack >test-3.pack &&
+ git index-pack -o tmp.idx test-2-${packname_2}.pack &&
+ cmp tmp.idx test-2-${packname_2}.idx &&
+
+ git index-pack test-3.pack &&
+ cmp test-3.idx test-2-${packname_2}.idx &&
+
+ cat test-3-${packname_3}.pack >test-3.pack &&
+ git index-pack -o tmp.idx test-3-${packname_3}.pack &&
+ cmp tmp.idx test-3-${packname_3}.idx &&
+
+ git index-pack test-3.pack &&
+ cmp test-3.idx test-3-${packname_3}.idx &&
+
+ cat test-1-${packname_1}.pack >test-4.pack &&
+ rm -f test-4.keep &&
+ git index-pack --keep=why test-4.pack &&
+ cmp test-1-${packname_1}.idx test-4.idx &&
+ test -f test-4.keep &&
+
+ :
+'
test_expect_success 'unpacking with --strict' '
diff --git a/t/t5301-sliding-window.sh b/t/t5301-sliding-window.sh
index 3ccaaeb..226490d 100755
--- a/t/t5301-sliding-window.sh
+++ b/t/t5301-sliding-window.sh
@@ -8,55 +8,55 @@ test_description='mmap sliding window tests'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
-test_expect_success \
- 'setup' \
- 'rm -f .git/index* &&
- for i in a b c
- do
- echo $i >$i &&
- test-tool genrandom "$i" 32768 >>$i &&
- git update-index --add $i || return 1
- done &&
- echo d >d && cat c >>d && git update-index --add d &&
- tree=$(git write-tree) &&
- commit1=$(git commit-tree $tree </dev/null) &&
- git update-ref HEAD $commit1 &&
- git repack -a -d &&
- test "$(git count-objects)" = "0 objects, 0 kilobytes" &&
- pack1=$(ls .git/objects/pack/*.pack) &&
- test -f "$pack1"'
-
-test_expect_success \
- 'verify-pack -v, defaults' \
- 'git verify-pack -v "$pack1"'
-
-test_expect_success \
- 'verify-pack -v, packedGitWindowSize == 1 page' \
- 'git config core.packedGitWindowSize 512 &&
- git verify-pack -v "$pack1"'
-
-test_expect_success \
- 'verify-pack -v, packedGit{WindowSize,Limit} == 1 page' \
- 'git config core.packedGitWindowSize 512 &&
- git config core.packedGitLimit 512 &&
- git verify-pack -v "$pack1"'
-
-test_expect_success \
- 'repack -a -d, packedGit{WindowSize,Limit} == 1 page' \
- 'git config core.packedGitWindowSize 512 &&
- git config core.packedGitLimit 512 &&
- commit2=$(git commit-tree $tree -p $commit1 </dev/null) &&
- git update-ref HEAD $commit2 &&
- git repack -a -d &&
- test "$(git count-objects)" = "0 objects, 0 kilobytes" &&
- pack2=$(ls .git/objects/pack/*.pack) &&
- test -f "$pack2" &&
- test "$pack1" \!= "$pack2"'
-
-test_expect_success \
- 'verify-pack -v, defaults' \
- 'git config --unset core.packedGitWindowSize &&
- git config --unset core.packedGitLimit &&
- git verify-pack -v "$pack2"'
+test_expect_success 'setup' '
+ rm -f .git/index* &&
+ for i in a b c
+ do
+ echo $i >$i &&
+ test-tool genrandom "$i" 32768 >>$i &&
+ git update-index --add $i || return 1
+ done &&
+ echo d >d && cat c >>d && git update-index --add d &&
+ tree=$(git write-tree) &&
+ commit1=$(git commit-tree $tree </dev/null) &&
+ git update-ref HEAD $commit1 &&
+ git repack -a -d &&
+ test "$(git count-objects)" = "0 objects, 0 kilobytes" &&
+ pack1=$(ls .git/objects/pack/*.pack) &&
+ test -f "$pack1"
+'
+
+test_expect_success 'verify-pack -v, defaults' '
+ git verify-pack -v "$pack1"
+'
+
+test_expect_success 'verify-pack -v, packedGitWindowSize == 1 page' '
+ git config core.packedGitWindowSize 512 &&
+ git verify-pack -v "$pack1"
+'
+
+test_expect_success 'verify-pack -v, packedGit{WindowSize,Limit} == 1 page' '
+ git config core.packedGitWindowSize 512 &&
+ git config core.packedGitLimit 512 &&
+ git verify-pack -v "$pack1"
+'
+
+test_expect_success 'repack -a -d, packedGit{WindowSize,Limit} == 1 page' '
+ git config core.packedGitWindowSize 512 &&
+ git config core.packedGitLimit 512 &&
+ commit2=$(git commit-tree $tree -p $commit1 </dev/null) &&
+ git update-ref HEAD $commit2 &&
+ git repack -a -d &&
+ test "$(git count-objects)" = "0 objects, 0 kilobytes" &&
+ pack2=$(ls .git/objects/pack/*.pack) &&
+ test -f "$pack2" &&
+ test "$pack1" \!= "$pack2"
+'
+
+test_expect_success 'verify-pack -v, defaults' '
+ git config --unset core.packedGitWindowSize &&
+ git config --unset core.packedGitLimit &&
+ git verify-pack -v "$pack2"
+'
test_done
diff --git a/t/t5303-pack-corruption-resilience.sh b/t/t5303-pack-corruption-resilience.sh
index 2926e8d..61469ef 100755
--- a/t/t5303-pack-corruption-resilience.sh
+++ b/t/t5303-pack-corruption-resilience.sh
@@ -59,304 +59,304 @@ do_corrupt_object() {
printf '\0' > zero
-test_expect_success \
- 'initial setup validation' \
- 'create_test_files &&
- create_new_pack &&
- git prune-packed &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- 'create corruption in header of first object' \
- 'do_corrupt_object $blob_1 0 < zero &&
- test_must_fail git cat-file blob $blob_1 > /dev/null &&
- test_must_fail git cat-file blob $blob_2 > /dev/null &&
- test_must_fail git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... but having a loose copy allows for full recovery' \
- 'mv ${pack}.idx tmp &&
- git hash-object -t blob -w file_1 &&
- mv tmp ${pack}.idx &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... and loose copy of first delta allows for partial recovery' \
- 'git prune-packed &&
- test_must_fail git cat-file blob $blob_2 > /dev/null &&
- mv ${pack}.idx tmp &&
- git hash-object -t blob -w file_2 &&
- mv tmp ${pack}.idx &&
- test_must_fail git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- 'create corruption in data of first object' \
- 'create_new_pack &&
- git prune-packed &&
- chmod +w ${pack}.pack &&
- perl -i.bak -pe "s/ base /abcdef/" ${pack}.pack &&
- test_must_fail git cat-file blob $blob_1 > /dev/null &&
- test_must_fail git cat-file blob $blob_2 > /dev/null &&
- test_must_fail git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... but having a loose copy allows for full recovery' \
- 'mv ${pack}.idx tmp &&
- git hash-object -t blob -w file_1 &&
- mv tmp ${pack}.idx &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... and loose copy of second object allows for partial recovery' \
- 'git prune-packed &&
- test_must_fail git cat-file blob $blob_2 > /dev/null &&
- mv ${pack}.idx tmp &&
- git hash-object -t blob -w file_2 &&
- mv tmp ${pack}.idx &&
- test_must_fail git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- 'create corruption in header of first delta' \
- 'create_new_pack &&
- git prune-packed &&
- do_corrupt_object $blob_2 0 < zero &&
- git cat-file blob $blob_1 > /dev/null &&
- test_must_fail git cat-file blob $blob_2 > /dev/null &&
- test_must_fail git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... but having a loose copy allows for full recovery' \
- 'mv ${pack}.idx tmp &&
- git hash-object -t blob -w file_2 &&
- mv tmp ${pack}.idx &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... and then a repack "clears" the corruption' \
- 'do_repack &&
- git prune-packed &&
- git verify-pack ${pack}.pack &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- 'create corruption in data of first delta' \
- 'create_new_pack &&
- git prune-packed &&
- chmod +w ${pack}.pack &&
- perl -i.bak -pe "s/ delta1 /abcdefgh/" ${pack}.pack &&
- git cat-file blob $blob_1 > /dev/null &&
- test_must_fail git cat-file blob $blob_2 > /dev/null &&
- test_must_fail git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... but having a loose copy allows for full recovery' \
- 'mv ${pack}.idx tmp &&
- git hash-object -t blob -w file_2 &&
- mv tmp ${pack}.idx &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... and then a repack "clears" the corruption' \
- 'do_repack &&
- git prune-packed &&
- git verify-pack ${pack}.pack &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- 'corruption in delta base reference of first delta (OBJ_REF_DELTA)' \
- 'create_new_pack &&
- git prune-packed &&
- do_corrupt_object $blob_2 2 < zero &&
- git cat-file blob $blob_1 > /dev/null &&
- test_must_fail git cat-file blob $blob_2 > /dev/null &&
- test_must_fail git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... but having a loose copy allows for full recovery' \
- 'mv ${pack}.idx tmp &&
- git hash-object -t blob -w file_2 &&
- mv tmp ${pack}.idx &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... and then a repack "clears" the corruption' \
- 'do_repack &&
- git prune-packed &&
- git verify-pack ${pack}.pack &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- 'corruption #0 in delta base reference of first delta (OBJ_OFS_DELTA)' \
- 'create_new_pack --delta-base-offset &&
- git prune-packed &&
- do_corrupt_object $blob_2 2 < zero &&
- git cat-file blob $blob_1 > /dev/null &&
- test_must_fail git cat-file blob $blob_2 > /dev/null &&
- test_must_fail git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... but having a loose copy allows for full recovery' \
- 'mv ${pack}.idx tmp &&
- git hash-object -t blob -w file_2 &&
- mv tmp ${pack}.idx &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... and then a repack "clears" the corruption' \
- 'do_repack --delta-base-offset &&
- git prune-packed &&
- git verify-pack ${pack}.pack &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- 'corruption #1 in delta base reference of first delta (OBJ_OFS_DELTA)' \
- 'create_new_pack --delta-base-offset &&
- git prune-packed &&
- printf "\001" | do_corrupt_object $blob_2 2 &&
- git cat-file blob $blob_1 > /dev/null &&
- test_must_fail git cat-file blob $blob_2 > /dev/null &&
- test_must_fail git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... but having a loose copy allows for full recovery' \
- 'mv ${pack}.idx tmp &&
- git hash-object -t blob -w file_2 &&
- mv tmp ${pack}.idx &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... and then a repack "clears" the corruption' \
- 'do_repack --delta-base-offset &&
- git prune-packed &&
- git verify-pack ${pack}.pack &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... and a redundant pack allows for full recovery too' \
- 'do_corrupt_object $blob_2 2 < zero &&
- git cat-file blob $blob_1 > /dev/null &&
- test_must_fail git cat-file blob $blob_2 > /dev/null &&
- test_must_fail git cat-file blob $blob_3 > /dev/null &&
- mv ${pack}.idx tmp &&
- git hash-object -t blob -w file_1 &&
- git hash-object -t blob -w file_2 &&
- printf "$blob_1\n$blob_2\n" | git pack-objects .git/objects/pack/pack &&
- git prune-packed &&
- mv tmp ${pack}.idx &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- 'corruption of delta base reference pointing to wrong object' \
- 'create_new_pack --delta-base-offset &&
- git prune-packed &&
- printf "\220\033" | do_corrupt_object $blob_3 2 &&
- git cat-file blob $blob_1 >/dev/null &&
- git cat-file blob $blob_2 >/dev/null &&
- test_must_fail git cat-file blob $blob_3 >/dev/null'
-
-test_expect_success \
- '... but having a loose copy allows for full recovery' \
- 'mv ${pack}.idx tmp &&
- git hash-object -t blob -w file_3 &&
- mv tmp ${pack}.idx &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- '... and then a repack "clears" the corruption' \
- 'do_repack --delta-base-offset --no-reuse-delta &&
- git prune-packed &&
- git verify-pack ${pack}.pack &&
- git cat-file blob $blob_1 > /dev/null &&
- git cat-file blob $blob_2 > /dev/null &&
- git cat-file blob $blob_3 > /dev/null'
-
-test_expect_success \
- 'corrupting header to have too small output buffer fails unpack' \
- 'create_new_pack &&
- git prune-packed &&
- printf "\262\001" | do_corrupt_object $blob_1 0 &&
- test_must_fail git cat-file blob $blob_1 > /dev/null &&
- test_must_fail git cat-file blob $blob_2 > /dev/null &&
- test_must_fail git cat-file blob $blob_3 > /dev/null'
+test_expect_success 'initial setup validation' '
+ create_test_files &&
+ create_new_pack &&
+ git prune-packed &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success 'create corruption in header of first object' '
+ do_corrupt_object $blob_1 0 < zero &&
+ test_must_fail git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... but having a loose copy allows for full recovery' '
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_1 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... and loose copy of first delta allows for partial recovery' '
+ git prune-packed &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_2 &&
+ mv tmp ${pack}.idx &&
+ test_must_fail git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success 'create corruption in data of first object' '
+ create_new_pack &&
+ git prune-packed &&
+ chmod +w ${pack}.pack &&
+ perl -i.bak -pe "s/ base /abcdef/" ${pack}.pack &&
+ test_must_fail git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... but having a loose copy allows for full recovery' '
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_1 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... and loose copy of second object allows for partial recovery' '
+ git prune-packed &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_2 &&
+ mv tmp ${pack}.idx &&
+ test_must_fail git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success 'create corruption in header of first delta' '
+ create_new_pack &&
+ git prune-packed &&
+ do_corrupt_object $blob_2 0 < zero &&
+ git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... but having a loose copy allows for full recovery' '
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_2 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... and then a repack "clears" the corruption' '
+ do_repack &&
+ git prune-packed &&
+ git verify-pack ${pack}.pack &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success 'create corruption in data of first delta' '
+ create_new_pack &&
+ git prune-packed &&
+ chmod +w ${pack}.pack &&
+ perl -i.bak -pe "s/ delta1 /abcdefgh/" ${pack}.pack &&
+ git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... but having a loose copy allows for full recovery' '
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_2 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... and then a repack "clears" the corruption' '
+ do_repack &&
+ git prune-packed &&
+ git verify-pack ${pack}.pack &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success 'corruption in delta base reference of first delta (OBJ_REF_DELTA)' '
+ create_new_pack &&
+ git prune-packed &&
+ do_corrupt_object $blob_2 2 < zero &&
+ git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... but having a loose copy allows for full recovery' '
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_2 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... and then a repack "clears" the corruption' '
+ do_repack &&
+ git prune-packed &&
+ git verify-pack ${pack}.pack &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success 'corruption #0 in delta base reference of first delta (OBJ_OFS_DELTA)' '
+ create_new_pack --delta-base-offset &&
+ git prune-packed &&
+ do_corrupt_object $blob_2 2 < zero &&
+ git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... but having a loose copy allows for full recovery' '
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_2 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... and then a repack "clears" the corruption' '
+ do_repack --delta-base-offset &&
+ git prune-packed &&
+ git verify-pack ${pack}.pack &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success 'corruption #1 in delta base reference of first delta (OBJ_OFS_DELTA)' '
+ create_new_pack --delta-base-offset &&
+ git prune-packed &&
+ printf "\001" | do_corrupt_object $blob_2 2 &&
+ git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... but having a loose copy allows for full recovery' '
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_2 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... and then a repack "clears" the corruption' '
+ do_repack --delta-base-offset &&
+ git prune-packed &&
+ git verify-pack ${pack}.pack &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... and a redundant pack allows for full recovery too' '
+ do_corrupt_object $blob_2 2 < zero &&
+ git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null &&
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_1 &&
+ git hash-object -t blob -w file_2 &&
+ printf "$blob_1\n$blob_2\n" | git pack-objects .git/objects/pack/pack &&
+ git prune-packed &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success 'corruption of delta base reference pointing to wrong object' '
+ create_new_pack --delta-base-offset &&
+ git prune-packed &&
+ printf "\220\033" | do_corrupt_object $blob_3 2 &&
+ git cat-file blob $blob_1 >/dev/null &&
+ git cat-file blob $blob_2 >/dev/null &&
+ test_must_fail git cat-file blob $blob_3 >/dev/null
+'
+
+test_expect_success '... but having a loose copy allows for full recovery' '
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_3 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success '... and then a repack "clears" the corruption' '
+ do_repack --delta-base-offset --no-reuse-delta &&
+ git prune-packed &&
+ git verify-pack ${pack}.pack &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null
+'
+
+test_expect_success 'corrupting header to have too small output buffer fails unpack' '
+ create_new_pack &&
+ git prune-packed &&
+ printf "\262\001" | do_corrupt_object $blob_1 0 &&
+ test_must_fail git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null
+'
# \0 - empty base
# \1 - one byte in result
# \1 - one literal byte (X)
-test_expect_success \
- 'apply good minimal delta' \
- 'printf "\0\1\1X" > minimal_delta &&
- test-tool delta -p /dev/null minimal_delta /dev/null'
+test_expect_success 'apply good minimal delta' '
+ printf "\0\1\1X" > minimal_delta &&
+ test-tool delta -p /dev/null minimal_delta /dev/null
+'
# \0 - empty base
# \1 - 1 byte in result
# \2 - two literal bytes (one too many)
-test_expect_success \
- 'apply delta with too many literal bytes' \
- 'printf "\0\1\2XX" > too_big_literal &&
- test_must_fail test-tool delta -p /dev/null too_big_literal /dev/null'
+test_expect_success 'apply delta with too many literal bytes' '
+ printf "\0\1\2XX" > too_big_literal &&
+ test_must_fail test-tool delta -p /dev/null too_big_literal /dev/null
+'
# \4 - four bytes in base
# \1 - one byte in result
# \221 - copy, one byte offset, one byte size
# \0 - copy from offset 0
# \2 - copy two bytes (one too many)
-test_expect_success \
- 'apply delta with too many copied bytes' \
- 'printf "\4\1\221\0\2" > too_big_copy &&
- printf base >base &&
- test_must_fail test-tool delta -p base too_big_copy /dev/null'
+test_expect_success 'apply delta with too many copied bytes' '
+ printf "\4\1\221\0\2" > too_big_copy &&
+ printf base >base &&
+ test_must_fail test-tool delta -p base too_big_copy /dev/null
+'
# \0 - empty base
# \2 - two bytes in result
# \2 - two literal bytes (we are short one)
-test_expect_success \
- 'apply delta with too few literal bytes' \
- 'printf "\0\2\2X" > truncated_delta &&
- test_must_fail test-tool delta -p /dev/null truncated_delta /dev/null'
+test_expect_success 'apply delta with too few literal bytes' '
+ printf "\0\2\2X" > truncated_delta &&
+ test_must_fail test-tool delta -p /dev/null truncated_delta /dev/null
+'
# \0 - empty base
# \1 - one byte in result
# \221 - copy, one byte offset, one byte size
# \0 - copy from offset 0
# \1 - copy one byte (we are short one)
-test_expect_success \
- 'apply delta with too few bytes in base' \
- 'printf "\0\1\221\0\1" > truncated_base &&
- test_must_fail test-tool delta -p /dev/null truncated_base /dev/null'
+test_expect_success 'apply delta with too few bytes in base' '
+ printf "\0\1\221\0\1" > truncated_base &&
+ test_must_fail test-tool delta -p /dev/null truncated_base /dev/null
+'
# \4 - four bytes in base
# \2 - two bytes in result
@@ -366,20 +366,20 @@ test_expect_success \
#
# Note that the literal byte is necessary to get past the uninteresting minimum
# delta size check.
-test_expect_success \
- 'apply delta with truncated copy parameters' \
- 'printf "\4\2\1X\221" > truncated_copy_delta &&
- printf base >base &&
- test_must_fail test-tool delta -p base truncated_copy_delta /dev/null'
+test_expect_success 'apply delta with truncated copy parameters' '
+ printf "\4\2\1X\221" > truncated_copy_delta &&
+ printf base >base &&
+ test_must_fail test-tool delta -p base truncated_copy_delta /dev/null
+'
# \0 - empty base
# \1 - one byte in result
# \1 - one literal byte (X)
# \1 - trailing garbage command
-test_expect_success \
- 'apply delta with trailing garbage literal' \
- 'printf "\0\1\1X\1" > tail_garbage_literal &&
- test_must_fail test-tool delta -p /dev/null tail_garbage_literal /dev/null'
+test_expect_success 'apply delta with trailing garbage literal' '
+ printf "\0\1\1X\1" > tail_garbage_literal &&
+ test_must_fail test-tool delta -p /dev/null tail_garbage_literal /dev/null
+'
# \4 - four bytes in base
# \1 - one byte in result
@@ -387,19 +387,19 @@ test_expect_success \
# \221 - copy, one byte offset, one byte size
# \0 - copy from offset 0
# \1 - copy 1 byte
-test_expect_success \
- 'apply delta with trailing garbage copy' \
- 'printf "\4\1\1X\221\0\1" > tail_garbage_copy &&
- printf base >base &&
- test_must_fail test-tool delta -p /dev/null tail_garbage_copy /dev/null'
+test_expect_success 'apply delta with trailing garbage copy' '
+ printf "\4\1\1X\221\0\1" > tail_garbage_copy &&
+ printf base >base &&
+ test_must_fail test-tool delta -p /dev/null tail_garbage_copy /dev/null
+'
# \0 - empty base
# \1 - one byte in result
# \1 - one literal byte (X)
# \0 - bogus opcode
-test_expect_success \
- 'apply delta with trailing garbage opcode' \
- 'printf "\0\1\1X\0" > tail_garbage_opcode &&
- test_must_fail test-tool delta -p /dev/null tail_garbage_opcode /dev/null'
+test_expect_success 'apply delta with trailing garbage opcode' '
+ printf "\0\1\1X\0" > tail_garbage_opcode &&
+ test_must_fail test-tool delta -p /dev/null tail_garbage_opcode /dev/null
+'
test_done
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
index f367327..b4df545 100755
--- a/t/t5304-prune.sh
+++ b/t/t5304-prune.sh
@@ -350,4 +350,18 @@ test_expect_success 'old reachable-from-recent retained with bitmaps' '
test_must_fail git cat-file -e $to_drop
'
+test_expect_success 'gc.recentObjectsHook' '
+ add_blob &&
+ test-tool chmtime =-86500 $BLOB_FILE &&
+
+ write_script precious-objects <<-EOF &&
+ echo $BLOB
+ EOF
+ test_config gc.recentObjectsHook ./precious-objects &&
+
+ git prune --expire=now &&
+
+ git cat-file -p $BLOB
+'
+
test_done
diff --git a/t/t5306-pack-nobase.sh b/t/t5306-pack-nobase.sh
index 846c5ca..0d50c6b 100755
--- a/t/t5306-pack-nobase.sh
+++ b/t/t5306-pack-nobase.sh
@@ -12,18 +12,17 @@ TEST_PASSES_SANITIZE_LEAK=true
# Create A-B chain
#
-test_expect_success \
- 'setup base' \
- 'test_write_lines a b c d e f g h i >text &&
- echo side >side &&
- git update-index --add text side &&
- A=$(echo A | git commit-tree $(git write-tree)) &&
+test_expect_success 'setup base' '
+ test_write_lines a b c d e f g h i >text &&
+ echo side >side &&
+ git update-index --add text side &&
+ A=$(echo A | git commit-tree $(git write-tree)) &&
- echo m >>text &&
- git update-index text &&
- B=$(echo B | git commit-tree $(git write-tree) -p $A) &&
- git update-ref HEAD $B
- '
+ echo m >>text &&
+ git update-index text &&
+ B=$(echo B | git commit-tree $(git write-tree) -p $A) &&
+ git update-ref HEAD $B
+'
# Create repository with C whose parent is B.
# Repository contains C, C^{tree}, C:text, B, B^{tree}.
@@ -31,52 +30,49 @@ test_expect_success \
# Repository is missing A (parent of B).
# Repository is missing A:side.
#
-test_expect_success \
- 'setup patch_clone' \
- 'base_objects=$(pwd)/.git/objects &&
- (mkdir patch_clone &&
- cd patch_clone &&
- git init &&
- echo "$base_objects" >.git/objects/info/alternates &&
- echo q >>text &&
- git read-tree $B &&
- git update-index text &&
- git update-ref HEAD $(echo C | git commit-tree $(git write-tree) -p $B) &&
- rm .git/objects/info/alternates &&
+test_expect_success 'setup patch_clone' '
+ base_objects=$(pwd)/.git/objects &&
+ (mkdir patch_clone &&
+ cd patch_clone &&
+ git init &&
+ echo "$base_objects" >.git/objects/info/alternates &&
+ echo q >>text &&
+ git read-tree $B &&
+ git update-index text &&
+ git update-ref HEAD $(echo C | git commit-tree $(git write-tree) -p $B) &&
+ rm .git/objects/info/alternates &&
- git --git-dir=../.git cat-file commit $B |
- git hash-object -t commit -w --stdin &&
+ git --git-dir=../.git cat-file commit $B |
+ git hash-object -t commit -w --stdin &&
- git --git-dir=../.git cat-file tree "$B^{tree}" |
- git hash-object -t tree -w --stdin
- ) &&
- C=$(git --git-dir=patch_clone/.git rev-parse HEAD)
- '
+ git --git-dir=../.git cat-file tree "$B^{tree}" |
+ git hash-object -t tree -w --stdin
+ ) &&
+ C=$(git --git-dir=patch_clone/.git rev-parse HEAD)
+'
# Clone patch_clone indirectly by cloning base and fetching.
#
-test_expect_success \
- 'indirectly clone patch_clone' \
- '(mkdir user_clone &&
- cd user_clone &&
- git init &&
- git pull ../.git &&
- test $(git rev-parse HEAD) = $B &&
+test_expect_success 'indirectly clone patch_clone' '
+ (mkdir user_clone &&
+ cd user_clone &&
+ git init &&
+ git pull ../.git &&
+ test $(git rev-parse HEAD) = $B &&
- git pull ../patch_clone/.git &&
- test $(git rev-parse HEAD) = $C
- )
- '
+ git pull ../patch_clone/.git &&
+ test $(git rev-parse HEAD) = $C
+ )
+'
# Cloning the patch_clone directly should fail.
#
-test_expect_success \
- 'clone of patch_clone is incomplete' \
- '(mkdir user_direct &&
- cd user_direct &&
- git init &&
- test_must_fail git fetch ../patch_clone/.git
- )
- '
+test_expect_success 'clone of patch_clone is incomplete' '
+ (mkdir user_direct &&
+ cd user_direct &&
+ git init &&
+ test_must_fail git fetch ../patch_clone/.git
+ )
+'
test_done
diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh
index 526a5a5..78c1c6c 100755
--- a/t/t5310-pack-bitmaps.sh
+++ b/t/t5310-pack-bitmaps.sh
@@ -9,6 +9,10 @@ test_description='exercise basic bitmap functionality'
# their place.
GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0
+# Likewise, allow individual tests to control whether or not they use
+# the boundary-based traversal.
+sane_unset GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL
+
objpath () {
echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')"
}
@@ -457,6 +461,13 @@ test_bitmap_cases () {
test_bitmap_cases
+GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1
+export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL
+
+test_bitmap_cases
+
+sane_unset GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL
+
test_expect_success 'incremental repack fails when bitmaps are requested' '
test_commit more-1 &&
test_must_fail git repack -d 2>err &&
@@ -468,6 +479,33 @@ test_expect_success 'incremental repack can disable bitmaps' '
git repack -d --no-write-bitmap-index
'
+test_expect_success 'boundary-based traversal is used when requested' '
+ git repack -a -d --write-bitmap-index &&
+
+ for argv in \
+ "git -c pack.useBitmapBoundaryTraversal=true" \
+ "git -c feature.experimental=true" \
+ "GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1 git"
+ do
+ eval "GIT_TRACE2_EVENT=1 $argv rev-list --objects \
+ --use-bitmap-index second..other 2>perf" &&
+ grep "\"region_enter\".*\"label\":\"haves/boundary\"" perf ||
+ return 1
+ done &&
+
+ for argv in \
+ "git -c pack.useBitmapBoundaryTraversal=false" \
+ "git -c feature.experimental=true -c pack.useBitmapBoundaryTraversal=false" \
+ "GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=0 git -c pack.useBitmapBoundaryTraversal=true" \
+ "GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=0 git -c feature.experimental=true"
+ do
+ eval "GIT_TRACE2_EVENT=1 $argv rev-list --objects \
+ --use-bitmap-index second..other 2>perf" &&
+ grep "\"region_enter\".*\"label\":\"haves/classic\"" perf ||
+ return 1
+ done
+'
+
test_bitmap_cases "pack.writeBitmapLookupTable"
test_expect_success 'verify writing bitmap lookup table when enabled' '
diff --git a/t/t5326-multi-pack-bitmaps.sh b/t/t5326-multi-pack-bitmaps.sh
index f771c44..70d1b58 100755
--- a/t/t5326-multi-pack-bitmaps.sh
+++ b/t/t5326-multi-pack-bitmaps.sh
@@ -478,4 +478,39 @@ test_expect_success 'git fsck correctly identifies good and bad bitmaps' '
grep "bitmap file '\''$packbitmap'\'' has invalid checksum" err
'
+test_expect_success 'corrupt MIDX with bitmap causes fallback' '
+ git init corrupt-midx-bitmap &&
+ (
+ cd corrupt-midx-bitmap &&
+
+ test_commit first &&
+ git repack -d &&
+ test_commit second &&
+ git repack -d &&
+
+ git multi-pack-index write --bitmap &&
+ checksum=$(midx_checksum $objdir) &&
+ for f in $midx $midx-$checksum.bitmap
+ do
+ mv $f $f.bak || return 1
+ done &&
+
+ # pack everything together, invalidating the MIDX
+ git repack -ad &&
+ # then restore the now-stale MIDX
+ for f in $midx $midx-$checksum.bitmap
+ do
+ mv $f.bak $f || return 1
+ done &&
+
+ git rev-list --count --objects --use-bitmap-index HEAD >out 2>err &&
+ # should attempt opening the broken pack twice (once
+ # from the attempt to load it via the stale bitmap, and
+ # again when attempting to load it from the stale MIDX)
+ # before falling back to the non-MIDX case
+ test 2 -eq $(grep -c "could not open pack" err) &&
+ test 6 -eq $(cat out)
+ )
+'
+
test_done
diff --git a/t/t5329-pack-objects-cruft.sh b/t/t5329-pack-objects-cruft.sh
index 303f7a5..45667d4 100755
--- a/t/t5329-pack-objects-cruft.sh
+++ b/t/t5329-pack-objects-cruft.sh
@@ -739,4 +739,175 @@ test_expect_success 'cruft objects are freshend via loose' '
)
'
+test_expect_success 'gc.recentObjectsHook' '
+ git init repo &&
+ test_when_finished "rm -fr repo" &&
+ (
+ cd repo &&
+
+ # Create a handful of objects.
+ #
+ # - one reachable commit, "base", designated for the reachable
+ # pack
+ # - one unreachable commit, "cruft.discard", which is marked
+ # for deletion
+ # - one unreachable commit, "cruft.old", which would be marked
+ # for deletion, but is rescued as an extra cruft tip
+ # - one unreachable commit, "cruft.new", which is not marked
+ # for deletion
+ test_commit base &&
+ git branch -M main &&
+
+ git checkout --orphan discard &&
+ git rm -fr . &&
+ test_commit --no-tag cruft.discard &&
+
+ git checkout --orphan old &&
+ git rm -fr . &&
+ test_commit --no-tag cruft.old &&
+ cruft_old="$(git rev-parse HEAD)" &&
+
+ git checkout --orphan new &&
+ git rm -fr . &&
+ test_commit --no-tag cruft.new &&
+ cruft_new="$(git rev-parse HEAD)" &&
+
+ git checkout main &&
+ git branch -D discard old new &&
+ git reflog expire --all --expire=all &&
+
+ # mark cruft.old with an mtime that is many minutes
+ # older than the expiration period, and mark cruft.new
+ # with an mtime that is in the future (and thus not
+ # eligible for pruning).
+ test-tool chmtime -2000 "$objdir/$(test_oid_to_path $cruft_old)" &&
+ test-tool chmtime +1000 "$objdir/$(test_oid_to_path $cruft_new)" &&
+
+ # Write the list of cruft objects we expect to
+ # accumulate, which is comprised of everything reachable
+ # from cruft.old and cruft.new, but not cruft.discard.
+ git rev-list --objects --no-object-names \
+ $cruft_old $cruft_new >cruft.raw &&
+ sort cruft.raw >cruft.expect &&
+
+ # Write the script to list extra tips, which are limited
+ # to cruft.old, in this case.
+ write_script extra-tips <<-EOF &&
+ echo $cruft_old
+ EOF
+ git config gc.recentObjectsHook ./extra-tips &&
+
+ git repack --cruft --cruft-expiration=now -d &&
+
+ mtimes="$(ls .git/objects/pack/pack-*.mtimes)" &&
+ git show-index <${mtimes%.mtimes}.idx >cruft &&
+ cut -d" " -f2 cruft | sort >cruft.actual &&
+ test_cmp cruft.expect cruft.actual &&
+
+ # Ensure that the "old" objects are removed after
+ # dropping the gc.recentObjectsHook hook.
+ git config --unset gc.recentObjectsHook &&
+ git repack --cruft --cruft-expiration=now -d &&
+
+ mtimes="$(ls .git/objects/pack/pack-*.mtimes)" &&
+ git show-index <${mtimes%.mtimes}.idx >cruft &&
+ cut -d" " -f2 cruft | sort >cruft.actual &&
+
+ git rev-list --objects --no-object-names $cruft_new >cruft.raw &&
+ cp cruft.expect cruft.old &&
+ sort cruft.raw >cruft.expect &&
+ test_cmp cruft.expect cruft.actual &&
+
+ # ensure objects which are no longer in the cruft pack were
+ # removed from the repository
+ for object in $(comm -13 cruft.expect cruft.old)
+ do
+ test_must_fail git cat-file -t $object || return 1
+ done
+ )
+'
+
+test_expect_success 'multi-valued gc.recentObjectsHook' '
+ git init repo &&
+ test_when_finished "rm -fr repo" &&
+ (
+ cd repo &&
+
+ test_commit base &&
+ git branch -M main &&
+
+ git checkout --orphan cruft.a &&
+ git rm -fr . &&
+ test_commit --no-tag cruft.a &&
+ cruft_a="$(git rev-parse HEAD)" &&
+
+ git checkout --orphan cruft.b &&
+ git rm -fr . &&
+ test_commit --no-tag cruft.b &&
+ cruft_b="$(git rev-parse HEAD)" &&
+
+ git checkout main &&
+ git branch -D cruft.a cruft.b &&
+ git reflog expire --all --expire=all &&
+
+ echo "echo $cruft_a" | write_script extra-tips.a &&
+ echo "echo $cruft_b" | write_script extra-tips.b &&
+ echo "false" | write_script extra-tips.c &&
+
+ git rev-list --objects --no-object-names $cruft_a $cruft_b \
+ >cruft.raw &&
+ sort cruft.raw >cruft.expect &&
+
+ # ensure that each extra cruft tip is saved by its
+ # respective hook
+ git config --add gc.recentObjectsHook ./extra-tips.a &&
+ git config --add gc.recentObjectsHook ./extra-tips.b &&
+ git repack --cruft --cruft-expiration=now -d &&
+
+ mtimes="$(ls .git/objects/pack/pack-*.mtimes)" &&
+ git show-index <${mtimes%.mtimes}.idx >cruft &&
+ cut -d" " -f2 cruft | sort >cruft.actual &&
+ test_cmp cruft.expect cruft.actual &&
+
+ # ensure that a dirty exit halts cruft pack generation
+ git config --add gc.recentObjectsHook ./extra-tips.c &&
+ test_must_fail git repack --cruft --cruft-expiration=now -d 2>err &&
+ grep "unable to enumerate additional recent objects" err &&
+
+ # and that the existing cruft pack is left alone
+ test_path_is_file "$mtimes"
+ )
+'
+
+test_expect_success 'additional cruft blobs via gc.recentObjectsHook' '
+ git init repo &&
+ test_when_finished "rm -fr repo" &&
+ (
+ cd repo &&
+
+ test_commit base &&
+
+ blob=$(echo "unreachable" | git hash-object -w --stdin) &&
+
+ # mark the unreachable blob we wrote above as having
+ # aged out of the retention period
+ test-tool chmtime -2000 "$objdir/$(test_oid_to_path $blob)" &&
+
+ # Write the script to list extra tips, which is just the
+ # extra blob as above.
+ write_script extra-tips <<-EOF &&
+ echo $blob
+ EOF
+ git config gc.recentObjectsHook ./extra-tips &&
+
+ git repack --cruft --cruft-expiration=now -d &&
+
+ mtimes="$(ls .git/objects/pack/pack-*.mtimes)" &&
+ git show-index <${mtimes%.mtimes}.idx >cruft &&
+ cut -d" " -f2 cruft >actual &&
+ echo $blob >expect &&
+ test_cmp expect actual
+ )
+'
+
test_done
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index 2500acc..c9925ed 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -62,59 +62,59 @@ HASH6=
HASH7=
test_expect_success 'set up buggy branch' '
- echo "line 1" >>hello &&
- echo "line 2" >>hello &&
- echo "line 3" >>hello &&
- echo "line 4" >>hello &&
- add_and_commit_file hello "4 lines" &&
- HASH1=$(git rev-parse --verify HEAD) &&
- echo "line BUG" >>hello &&
- echo "line 6" >>hello &&
- echo "line 7" >>hello &&
- echo "line 8" >>hello &&
- add_and_commit_file hello "4 more lines with a BUG" &&
- HASH2=$(git rev-parse --verify HEAD) &&
- echo "line 9" >>hello &&
- echo "line 10" >>hello &&
- add_and_commit_file hello "2 more lines" &&
- HASH3=$(git rev-parse --verify HEAD) &&
- echo "line 11" >>hello &&
- add_and_commit_file hello "1 more line" &&
- HASH4=$(git rev-parse --verify HEAD) &&
- sed -e "s/BUG/5/" hello >hello.new &&
- mv hello.new hello &&
- add_and_commit_file hello "BUG fixed" &&
- HASH5=$(git rev-parse --verify HEAD) &&
- echo "line 12" >>hello &&
- echo "line 13" >>hello &&
- add_and_commit_file hello "2 more lines" &&
- HASH6=$(git rev-parse --verify HEAD) &&
- echo "line 14" >>hello &&
- echo "line 15" >>hello &&
- echo "line 16" >>hello &&
- add_and_commit_file hello "again 3 more lines" &&
- HASH7=$(git rev-parse --verify HEAD)
+ echo "line 1" >>hello &&
+ echo "line 2" >>hello &&
+ echo "line 3" >>hello &&
+ echo "line 4" >>hello &&
+ add_and_commit_file hello "4 lines" &&
+ HASH1=$(git rev-parse --verify HEAD) &&
+ echo "line BUG" >>hello &&
+ echo "line 6" >>hello &&
+ echo "line 7" >>hello &&
+ echo "line 8" >>hello &&
+ add_and_commit_file hello "4 more lines with a BUG" &&
+ HASH2=$(git rev-parse --verify HEAD) &&
+ echo "line 9" >>hello &&
+ echo "line 10" >>hello &&
+ add_and_commit_file hello "2 more lines" &&
+ HASH3=$(git rev-parse --verify HEAD) &&
+ echo "line 11" >>hello &&
+ add_and_commit_file hello "1 more line" &&
+ HASH4=$(git rev-parse --verify HEAD) &&
+ sed -e "s/BUG/5/" hello >hello.new &&
+ mv hello.new hello &&
+ add_and_commit_file hello "BUG fixed" &&
+ HASH5=$(git rev-parse --verify HEAD) &&
+ echo "line 12" >>hello &&
+ echo "line 13" >>hello &&
+ add_and_commit_file hello "2 more lines" &&
+ HASH6=$(git rev-parse --verify HEAD) &&
+ echo "line 14" >>hello &&
+ echo "line 15" >>hello &&
+ echo "line 16" >>hello &&
+ add_and_commit_file hello "again 3 more lines" &&
+ HASH7=$(git rev-parse --verify HEAD)
'
test_expect_success 'replace the author' '
- git cat-file commit $HASH2 | grep "author A U Thor" &&
- R=$(git cat-file commit $HASH2 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
- git cat-file commit $R | grep "author O Thor" &&
- git update-ref refs/replace/$HASH2 $R &&
- git show HEAD~5 | grep "O Thor" &&
- git show $HASH2 | grep "O Thor"
+ git cat-file commit $HASH2 | grep "author A U Thor" &&
+ R=$(git cat-file commit $HASH2 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
+ git cat-file commit $R | grep "author O Thor" &&
+ git update-ref refs/replace/$HASH2 $R &&
+ git show HEAD~5 | grep "O Thor" &&
+ git show $HASH2 | grep "O Thor"
'
test_expect_success 'test --no-replace-objects option' '
- git cat-file commit $HASH2 | grep "author O Thor" &&
- git --no-replace-objects cat-file commit $HASH2 | grep "author A U Thor" &&
- git show $HASH2 | grep "O Thor" &&
- git --no-replace-objects show $HASH2 | grep "A U Thor"
+ git cat-file commit $HASH2 | grep "author O Thor" &&
+ git --no-replace-objects cat-file commit $HASH2 | grep "author A U Thor" &&
+ git show $HASH2 | grep "O Thor" &&
+ git --no-replace-objects show $HASH2 | grep "A U Thor"
'
test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '
- GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep "author A U Thor" &&
- GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep "A U Thor"
+ GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep "author A U Thor" &&
+ GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep "A U Thor"
'
test_expect_success 'test core.usereplacerefs config option' '
@@ -132,64 +132,64 @@ tagger T A Gger <> 0 +0000
EOF
test_expect_success 'tag replaced commit' '
- git update-ref refs/tags/mytag $(git mktag <tag.sig)
+ git update-ref refs/tags/mytag $(git mktag <tag.sig)
'
test_expect_success '"git fsck" works' '
- git fsck main >fsck_main.out &&
- test_i18ngrep "dangling commit $R" fsck_main.out &&
- test_i18ngrep "dangling tag $(git show-ref -s refs/tags/mytag)" fsck_main.out &&
- test -z "$(git fsck)"
+ git fsck main >fsck_main.out &&
+ test_i18ngrep "dangling commit $R" fsck_main.out &&
+ test_i18ngrep "dangling tag $(git show-ref -s refs/tags/mytag)" fsck_main.out &&
+ test -z "$(git fsck)"
'
test_expect_success 'repack, clone and fetch work' '
- git repack -a -d &&
- git clone --no-hardlinks . clone_dir &&
- (
- cd clone_dir &&
- git show HEAD~5 | grep "A U Thor" &&
- git show $HASH2 | grep "A U Thor" &&
- git cat-file commit $R &&
- git repack -a -d &&
- test_must_fail git cat-file commit $R &&
- git fetch ../ "refs/replace/*:refs/replace/*" &&
- git show HEAD~5 | grep "O Thor" &&
- git show $HASH2 | grep "O Thor" &&
- git cat-file commit $R
- )
+ git repack -a -d &&
+ git clone --no-hardlinks . clone_dir &&
+ (
+ cd clone_dir &&
+ git show HEAD~5 | grep "A U Thor" &&
+ git show $HASH2 | grep "A U Thor" &&
+ git cat-file commit $R &&
+ git repack -a -d &&
+ test_must_fail git cat-file commit $R &&
+ git fetch ../ "refs/replace/*:refs/replace/*" &&
+ git show HEAD~5 | grep "O Thor" &&
+ git show $HASH2 | grep "O Thor" &&
+ git cat-file commit $R
+ )
'
test_expect_success '"git replace" listing and deleting' '
- test "$HASH2" = "$(git replace -l)" &&
- test "$HASH2" = "$(git replace)" &&
- aa=${HASH2%??????????????????????????????????????} &&
- test "$HASH2" = "$(git replace --list "$aa*")" &&
- test_must_fail git replace -d $R &&
- test_must_fail git replace --delete &&
- test_must_fail git replace -l -d $HASH2 &&
- git replace -d $HASH2 &&
- git show $HASH2 | grep "A U Thor" &&
- test -z "$(git replace -l)"
+ test "$HASH2" = "$(git replace -l)" &&
+ test "$HASH2" = "$(git replace)" &&
+ aa=${HASH2%??????????????????????????????????????} &&
+ test "$HASH2" = "$(git replace --list "$aa*")" &&
+ test_must_fail git replace -d $R &&
+ test_must_fail git replace --delete &&
+ test_must_fail git replace -l -d $HASH2 &&
+ git replace -d $HASH2 &&
+ git show $HASH2 | grep "A U Thor" &&
+ test -z "$(git replace -l)"
'
test_expect_success '"git replace" replacing' '
- git replace $HASH2 $R &&
- git show $HASH2 | grep "O Thor" &&
- test_must_fail git replace $HASH2 $R &&
- git replace -f $HASH2 $R &&
- test_must_fail git replace -f &&
- test "$HASH2" = "$(git replace)"
+ git replace $HASH2 $R &&
+ git show $HASH2 | grep "O Thor" &&
+ test_must_fail git replace $HASH2 $R &&
+ git replace -f $HASH2 $R &&
+ test_must_fail git replace -f &&
+ test "$HASH2" = "$(git replace)"
'
test_expect_success '"git replace" resolves sha1' '
- SHORTHASH2=$(git rev-parse --short=8 $HASH2) &&
- git replace -d $SHORTHASH2 &&
- git replace $SHORTHASH2 $R &&
- git show $HASH2 | grep "O Thor" &&
- test_must_fail git replace $HASH2 $R &&
- git replace -f $HASH2 $R &&
- test_must_fail git replace --force &&
- test "$HASH2" = "$(git replace)"
+ SHORTHASH2=$(git rev-parse --short=8 $HASH2) &&
+ git replace -d $SHORTHASH2 &&
+ git replace $SHORTHASH2 $R &&
+ git show $HASH2 | grep "O Thor" &&
+ test_must_fail git replace $HASH2 $R &&
+ git replace -f $HASH2 $R &&
+ test_must_fail git replace --force &&
+ test "$HASH2" = "$(git replace)"
'
# This creates a side branch where the bug in H2
@@ -207,79 +207,79 @@ test_expect_success '"git replace" resolves sha1' '
# Then we replace H6 with P6.
#
test_expect_success 'create parallel branch without the bug' '
- git replace -d $HASH2 &&
- git show $HASH2 | grep "A U Thor" &&
- git checkout $HASH1 &&
- git cherry-pick $HASH2 &&
- git show $HASH5 | git apply &&
- git commit --amend -m "hello: 4 more lines WITHOUT the bug" hello &&
- PARA2=$(git rev-parse --verify HEAD) &&
- git cherry-pick $HASH3 &&
- PARA3=$(git rev-parse --verify HEAD) &&
- git cherry-pick $HASH4 &&
- PARA4=$(git rev-parse --verify HEAD) &&
- git cherry-pick $HASH6 &&
- PARA6=$(git rev-parse --verify HEAD) &&
- git replace $HASH6 $PARA6 &&
- git checkout main &&
- cur=$(git rev-parse --verify HEAD) &&
- test "$cur" = "$HASH7" &&
- git log --pretty=oneline | grep $PARA2 &&
- git remote add cloned ./clone_dir
+ git replace -d $HASH2 &&
+ git show $HASH2 | grep "A U Thor" &&
+ git checkout $HASH1 &&
+ git cherry-pick $HASH2 &&
+ git show $HASH5 | git apply &&
+ git commit --amend -m "hello: 4 more lines WITHOUT the bug" hello &&
+ PARA2=$(git rev-parse --verify HEAD) &&
+ git cherry-pick $HASH3 &&
+ PARA3=$(git rev-parse --verify HEAD) &&
+ git cherry-pick $HASH4 &&
+ PARA4=$(git rev-parse --verify HEAD) &&
+ git cherry-pick $HASH6 &&
+ PARA6=$(git rev-parse --verify HEAD) &&
+ git replace $HASH6 $PARA6 &&
+ git checkout main &&
+ cur=$(git rev-parse --verify HEAD) &&
+ test "$cur" = "$HASH7" &&
+ git log --pretty=oneline | grep $PARA2 &&
+ git remote add cloned ./clone_dir
'
test_expect_success 'push to cloned repo' '
- git push cloned $HASH6^:refs/heads/parallel &&
- (
- cd clone_dir &&
- git checkout parallel &&
- git log --pretty=oneline | grep $PARA2
- )
+ git push cloned $HASH6^:refs/heads/parallel &&
+ (
+ cd clone_dir &&
+ git checkout parallel &&
+ git log --pretty=oneline | grep $PARA2
+ )
'
test_expect_success 'push branch with replacement' '
- git cat-file commit $PARA3 | grep "author A U Thor" &&
- S=$(git cat-file commit $PARA3 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
- git cat-file commit $S | grep "author O Thor" &&
- git replace $PARA3 $S &&
- git show $HASH6~2 | grep "O Thor" &&
- git show $PARA3 | grep "O Thor" &&
- git push cloned $HASH6^:refs/heads/parallel2 &&
- (
- cd clone_dir &&
- git checkout parallel2 &&
- git log --pretty=oneline | grep $PARA3 &&
- git show $PARA3 | grep "A U Thor"
- )
+ git cat-file commit $PARA3 | grep "author A U Thor" &&
+ S=$(git cat-file commit $PARA3 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
+ git cat-file commit $S | grep "author O Thor" &&
+ git replace $PARA3 $S &&
+ git show $HASH6~2 | grep "O Thor" &&
+ git show $PARA3 | grep "O Thor" &&
+ git push cloned $HASH6^:refs/heads/parallel2 &&
+ (
+ cd clone_dir &&
+ git checkout parallel2 &&
+ git log --pretty=oneline | grep $PARA3 &&
+ git show $PARA3 | grep "A U Thor"
+ )
'
test_expect_success 'fetch branch with replacement' '
- git branch tofetch $HASH6 &&
- (
- cd clone_dir &&
- git fetch origin refs/heads/tofetch:refs/heads/parallel3 &&
- git log --pretty=oneline parallel3 >output.txt &&
- ! grep $PARA3 output.txt &&
- git show $PARA3 >para3.txt &&
- grep "A U Thor" para3.txt &&
- git fetch origin "refs/replace/*:refs/replace/*" &&
- git log --pretty=oneline parallel3 >output.txt &&
- grep $PARA3 output.txt &&
- git show $PARA3 >para3.txt &&
- grep "O Thor" para3.txt
- )
+ git branch tofetch $HASH6 &&
+ (
+ cd clone_dir &&
+ git fetch origin refs/heads/tofetch:refs/heads/parallel3 &&
+ git log --pretty=oneline parallel3 >output.txt &&
+ ! grep $PARA3 output.txt &&
+ git show $PARA3 >para3.txt &&
+ grep "A U Thor" para3.txt &&
+ git fetch origin "refs/replace/*:refs/replace/*" &&
+ git log --pretty=oneline parallel3 >output.txt &&
+ grep $PARA3 output.txt &&
+ git show $PARA3 >para3.txt &&
+ grep "O Thor" para3.txt
+ )
'
test_expect_success 'bisect and replacements' '
- git bisect start $HASH7 $HASH1 &&
- test "$PARA3" = "$(git rev-parse --verify HEAD)" &&
- git bisect reset &&
- GIT_NO_REPLACE_OBJECTS=1 git bisect start $HASH7 $HASH1 &&
- test "$HASH4" = "$(git rev-parse --verify HEAD)" &&
- git bisect reset &&
- git --no-replace-objects bisect start $HASH7 $HASH1 &&
- test "$HASH4" = "$(git rev-parse --verify HEAD)" &&
- git bisect reset
+ git bisect start $HASH7 $HASH1 &&
+ test "$PARA3" = "$(git rev-parse --verify HEAD)" &&
+ git bisect reset &&
+ GIT_NO_REPLACE_OBJECTS=1 git bisect start $HASH7 $HASH1 &&
+ test "$HASH4" = "$(git rev-parse --verify HEAD)" &&
+ git bisect reset &&
+ git --no-replace-objects bisect start $HASH7 $HASH1 &&
+ test "$HASH4" = "$(git rev-parse --verify HEAD)" &&
+ git bisect reset
'
test_expect_success 'index-pack and replacements' '
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 0fe6ba9..e689db4 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -2188,4 +2188,23 @@ test_expect_success 'Does --[no-]contains stop at commits? Yes!' '
test_cmp expected actual
'
+test_expect_success 'If tag is created then tag message file is unlinked' '
+ test_when_finished "git tag -d foo" &&
+ write_script fakeeditor <<-\EOF &&
+ echo Message >.git/TAG_EDITMSG
+ EOF
+ GIT_EDITOR=./fakeeditor git tag -a foo &&
+ test_path_is_missing .git/TAG_EDITMSG
+'
+
+test_expect_success 'If tag cannot be created then tag message file is not unlinked' '
+ test_when_finished "git tag -d foo/bar && rm .git/TAG_EDITMSG" &&
+ write_script fakeeditor <<-\EOF &&
+ echo Message >.git/TAG_EDITMSG
+ EOF
+ git tag foo/bar &&
+ test_must_fail env GIT_EDITOR=./fakeeditor git tag -a foo &&
+ test_path_exists .git/TAG_EDITMSG
+'
+
test_done
diff --git a/t/t7101-reset-empty-subdirs.sh b/t/t7101-reset-empty-subdirs.sh
index 638bb04..89cf98b 100755
--- a/t/t7101-reset-empty-subdirs.sh
+++ b/t/t7101-reset-empty-subdirs.sh
@@ -10,57 +10,57 @@ TEST_PASSES_SANITIZE_LEAK=true
. "$TEST_DIRECTORY"/lib-diff-data.sh
test_expect_success 'creating initial files' '
- mkdir path0 &&
- COPYING_test_data >path0/COPYING &&
- git add path0/COPYING &&
- git commit -m add -a
+ mkdir path0 &&
+ COPYING_test_data >path0/COPYING &&
+ git add path0/COPYING &&
+ git commit -m add -a
'
test_expect_success 'creating second files' '
- mkdir path1 &&
- mkdir path1/path2 &&
- COPYING_test_data >path1/path2/COPYING &&
- COPYING_test_data >path1/COPYING &&
- COPYING_test_data >COPYING &&
- COPYING_test_data >path0/COPYING-TOO &&
- git add path1/path2/COPYING &&
- git add path1/COPYING &&
- git add COPYING &&
- git add path0/COPYING-TOO &&
- git commit -m change -a
+ mkdir path1 &&
+ mkdir path1/path2 &&
+ COPYING_test_data >path1/path2/COPYING &&
+ COPYING_test_data >path1/COPYING &&
+ COPYING_test_data >COPYING &&
+ COPYING_test_data >path0/COPYING-TOO &&
+ git add path1/path2/COPYING &&
+ git add path1/COPYING &&
+ git add COPYING &&
+ git add path0/COPYING-TOO &&
+ git commit -m change -a
'
test_expect_success 'resetting tree HEAD^' '
- git reset --hard HEAD^
+ git reset --hard HEAD^
'
test_expect_success 'checking initial files exist after rewind' '
- test -d path0 &&
- test -f path0/COPYING
+ test -d path0 &&
+ test -f path0/COPYING
'
test_expect_success 'checking lack of path1/path2/COPYING' '
- ! test -f path1/path2/COPYING
+ ! test -f path1/path2/COPYING
'
test_expect_success 'checking lack of path1/COPYING' '
- ! test -f path1/COPYING
+ ! test -f path1/COPYING
'
test_expect_success 'checking lack of COPYING' '
- ! test -f COPYING
+ ! test -f COPYING
'
test_expect_success 'checking checking lack of path1/COPYING-TOO' '
- ! test -f path0/COPYING-TOO
+ ! test -f path0/COPYING-TOO
'
test_expect_success 'checking lack of path1/path2' '
- ! test -d path1/path2
+ ! test -d path1/path2
'
test_expect_success 'checking lack of path1' '
- ! test -d path1
+ ! test -d path1
'
test_done
diff --git a/t/t7110-reset-merge.sh b/t/t7110-reset-merge.sh
index eb881be..772480a 100755
--- a/t/t7110-reset-merge.sh
+++ b/t/t7110-reset-merge.sh
@@ -9,17 +9,17 @@ TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '
- printf "line %d\n" 1 2 3 >file1 &&
- cat file1 >file2 &&
- git add file1 file2 &&
- test_tick &&
- git commit -m "Initial commit" &&
- git tag initial &&
- echo line 4 >>file1 &&
- cat file1 >file2 &&
- test_tick &&
- git commit -m "add line 4 to file1" file1 &&
- git tag second
+ printf "line %d\n" 1 2 3 >file1 &&
+ cat file1 >file2 &&
+ git add file1 file2 &&
+ test_tick &&
+ git commit -m "Initial commit" &&
+ git tag initial &&
+ echo line 4 >>file1 &&
+ cat file1 >file2 &&
+ test_tick &&
+ git commit -m "add line 4 to file1" file1 &&
+ git tag second
'
# The next test will test the following:
@@ -29,19 +29,19 @@ test_expect_success setup '
# file1: C C C D --merge D D D
# file2: C D D D --merge C D D
test_expect_success 'reset --merge is ok with changes in file it does not touch' '
- git reset --merge HEAD^ &&
- ! grep 4 file1 &&
- grep 4 file2 &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&
- test -z "$(git diff --cached)"
+ git reset --merge HEAD^ &&
+ ! grep 4 file1 &&
+ grep 4 file2 &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&
+ test -z "$(git diff --cached)"
'
test_expect_success 'reset --merge is ok when switching back' '
- git reset --merge second &&
- grep 4 file1 &&
- grep 4 file2 &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&
- test -z "$(git diff --cached)"
+ git reset --merge second &&
+ grep 4 file1 &&
+ grep 4 file2 &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&
+ test -z "$(git diff --cached)"
'
# The next test will test the following:
@@ -51,21 +51,21 @@ test_expect_success 'reset --merge is ok when switching back' '
# file1: C C C D --keep D D D
# file2: C D D D --keep C D D
test_expect_success 'reset --keep is ok with changes in file it does not touch' '
- git reset --hard second &&
- cat file1 >file2 &&
- git reset --keep HEAD^ &&
- ! grep 4 file1 &&
- grep 4 file2 &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&
- test -z "$(git diff --cached)"
+ git reset --hard second &&
+ cat file1 >file2 &&
+ git reset --keep HEAD^ &&
+ ! grep 4 file1 &&
+ grep 4 file2 &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&
+ test -z "$(git diff --cached)"
'
test_expect_success 'reset --keep is ok when switching back' '
- git reset --keep second &&
- grep 4 file1 &&
- grep 4 file2 &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&
- test -z "$(git diff --cached)"
+ git reset --keep second &&
+ grep 4 file1 &&
+ grep 4 file2 &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&
+ test -z "$(git diff --cached)"
'
# The next test will test the following:
@@ -75,28 +75,28 @@ test_expect_success 'reset --keep is ok when switching back' '
# file1: B B C D --merge D D D
# file2: C D D D --merge C D D
test_expect_success 'reset --merge discards changes added to index (1)' '
- git reset --hard second &&
- cat file1 >file2 &&
- echo "line 5" >> file1 &&
- git add file1 &&
- git reset --merge HEAD^ &&
- ! grep 4 file1 &&
- ! grep 5 file1 &&
- grep 4 file2 &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&
- test -z "$(git diff --cached)"
+ git reset --hard second &&
+ cat file1 >file2 &&
+ echo "line 5" >> file1 &&
+ git add file1 &&
+ git reset --merge HEAD^ &&
+ ! grep 4 file1 &&
+ ! grep 5 file1 &&
+ grep 4 file2 &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&
+ test -z "$(git diff --cached)"
'
test_expect_success 'reset --merge is ok again when switching back (1)' '
- git reset --hard initial &&
- echo "line 5" >> file2 &&
- git add file2 &&
- git reset --merge second &&
- ! grep 4 file2 &&
- ! grep 5 file1 &&
- grep 4 file1 &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&
- test -z "$(git diff --cached)"
+ git reset --hard initial &&
+ echo "line 5" >> file2 &&
+ git add file2 &&
+ git reset --merge second &&
+ ! grep 4 file2 &&
+ ! grep 5 file1 &&
+ grep 4 file1 &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&
+ test -z "$(git diff --cached)"
'
# The next test will test the following:
@@ -105,10 +105,10 @@ test_expect_success 'reset --merge is ok again when switching back (1)' '
# ----------------------------------------------------
# file1: B B C D --keep (disallowed)
test_expect_success 'reset --keep fails with changes in index in files it touches' '
- git reset --hard second &&
- echo "line 5" >> file1 &&
- git add file1 &&
- test_must_fail git reset --keep HEAD^
+ git reset --hard second &&
+ echo "line 5" >> file1 &&
+ git add file1 &&
+ test_must_fail git reset --keep HEAD^
'
# The next test will test the following:
@@ -118,23 +118,23 @@ test_expect_success 'reset --keep fails with changes in index in files it touche
# file1: C C C D --merge D D D
# file2: C C D D --merge D D D
test_expect_success 'reset --merge discards changes added to index (2)' '
- git reset --hard second &&
- echo "line 4" >> file2 &&
- git add file2 &&
- git reset --merge HEAD^ &&
- ! grep 4 file2 &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&
- test -z "$(git diff)" &&
- test -z "$(git diff --cached)"
+ git reset --hard second &&
+ echo "line 4" >> file2 &&
+ git add file2 &&
+ git reset --merge HEAD^ &&
+ ! grep 4 file2 &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&
+ test -z "$(git diff)" &&
+ test -z "$(git diff --cached)"
'
test_expect_success 'reset --merge is ok again when switching back (2)' '
- git reset --hard initial &&
- git reset --merge second &&
- ! grep 4 file2 &&
- grep 4 file1 &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&
- test -z "$(git diff --cached)"
+ git reset --hard initial &&
+ git reset --merge second &&
+ ! grep 4 file2 &&
+ grep 4 file1 &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&
+ test -z "$(git diff --cached)"
'
# The next test will test the following:
@@ -144,21 +144,21 @@ test_expect_success 'reset --merge is ok again when switching back (2)' '
# file1: C C C D --keep D D D
# file2: C C D D --keep C D D
test_expect_success 'reset --keep keeps changes it does not touch' '
- git reset --hard second &&
- echo "line 4" >> file2 &&
- git add file2 &&
- git reset --keep HEAD^ &&
- grep 4 file2 &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&
- test -z "$(git diff --cached)"
+ git reset --hard second &&
+ echo "line 4" >> file2 &&
+ git add file2 &&
+ git reset --keep HEAD^ &&
+ grep 4 file2 &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&
+ test -z "$(git diff --cached)"
'
test_expect_success 'reset --keep keeps changes when switching back' '
- git reset --keep second &&
- grep 4 file2 &&
- grep 4 file1 &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&
- test -z "$(git diff --cached)"
+ git reset --keep second &&
+ grep 4 file2 &&
+ grep 4 file1 &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&
+ test -z "$(git diff --cached)"
'
# The next test will test the following:
@@ -167,14 +167,14 @@ test_expect_success 'reset --keep keeps changes when switching back' '
# ----------------------------------------------------
# file1: A B B C --merge (disallowed)
test_expect_success 'reset --merge fails with changes in file it touches' '
- git reset --hard second &&
- echo "line 5" >> file1 &&
- test_tick &&
- git commit -m "add line 5" file1 &&
- sed -e "s/line 1/changed line 1/" <file1 >file3 &&
- mv file3 file1 &&
- test_must_fail git reset --merge HEAD^ 2>err.log &&
- grep file1 err.log | grep "not uptodate"
+ git reset --hard second &&
+ echo "line 5" >> file1 &&
+ test_tick &&
+ git commit -m "add line 5" file1 &&
+ sed -e "s/line 1/changed line 1/" <file1 >file3 &&
+ mv file3 file1 &&
+ test_must_fail git reset --merge HEAD^ 2>err.log &&
+ grep file1 err.log | grep "not uptodate"
'
# The next test will test the following:
@@ -183,36 +183,36 @@ test_expect_success 'reset --merge fails with changes in file it touches' '
# ----------------------------------------------------
# file1: A B B C --keep (disallowed)
test_expect_success 'reset --keep fails with changes in file it touches' '
- git reset --hard second &&
- echo "line 5" >> file1 &&
- test_tick &&
- git commit -m "add line 5" file1 &&
- sed -e "s/line 1/changed line 1/" <file1 >file3 &&
- mv file3 file1 &&
- test_must_fail git reset --keep HEAD^ 2>err.log &&
- grep file1 err.log | grep "not uptodate"
+ git reset --hard second &&
+ echo "line 5" >> file1 &&
+ test_tick &&
+ git commit -m "add line 5" file1 &&
+ sed -e "s/line 1/changed line 1/" <file1 >file3 &&
+ mv file3 file1 &&
+ test_must_fail git reset --keep HEAD^ 2>err.log &&
+ grep file1 err.log | grep "not uptodate"
'
test_expect_success 'setup 3 different branches' '
- git reset --hard second &&
- git branch branch1 &&
- git branch branch2 &&
- git branch branch3 &&
- git checkout branch1 &&
- echo "line 5 in branch1" >> file1 &&
- test_tick &&
- git commit -a -m "change in branch1" &&
- git checkout branch2 &&
- echo "line 5 in branch2" >> file1 &&
- test_tick &&
- git commit -a -m "change in branch2" &&
- git tag third &&
- git checkout branch3 &&
- echo a new file >file3 &&
- rm -f file1 &&
- git add file3 &&
- test_tick &&
- git commit -a -m "change in branch3"
+ git reset --hard second &&
+ git branch branch1 &&
+ git branch branch2 &&
+ git branch branch3 &&
+ git checkout branch1 &&
+ echo "line 5 in branch1" >> file1 &&
+ test_tick &&
+ git commit -a -m "change in branch1" &&
+ git checkout branch2 &&
+ echo "line 5 in branch2" >> file1 &&
+ test_tick &&
+ git commit -a -m "change in branch2" &&
+ git tag third &&
+ git checkout branch3 &&
+ echo a new file >file3 &&
+ rm -f file1 &&
+ git add file3 &&
+ test_tick &&
+ git commit -a -m "change in branch3"
'
# The next test will test the following:
@@ -221,12 +221,12 @@ test_expect_success 'setup 3 different branches' '
# ----------------------------------------------------
# file1: X U B C --merge C C C
test_expect_success '"reset --merge HEAD^" is ok with pending merge' '
- git checkout third &&
- test_must_fail git merge branch1 &&
- git reset --merge HEAD^ &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&
- test -z "$(git diff --cached)" &&
- test -z "$(git diff)"
+ git checkout third &&
+ test_must_fail git merge branch1 &&
+ git reset --merge HEAD^ &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&
+ test -z "$(git diff --cached)" &&
+ test -z "$(git diff)"
'
# The next test will test the following:
@@ -235,10 +235,10 @@ test_expect_success '"reset --merge HEAD^" is ok with pending merge' '
# ----------------------------------------------------
# file1: X U B C --keep (disallowed)
test_expect_success '"reset --keep HEAD^" fails with pending merge' '
- git reset --hard third &&
- test_must_fail git merge branch1 &&
- test_must_fail git reset --keep HEAD^ 2>err.log &&
- test_i18ngrep "middle of a merge" err.log
+ git reset --hard third &&
+ test_must_fail git merge branch1 &&
+ test_must_fail git reset --keep HEAD^ 2>err.log &&
+ test_i18ngrep "middle of a merge" err.log
'
# The next test will test the following:
@@ -247,12 +247,12 @@ test_expect_success '"reset --keep HEAD^" fails with pending merge' '
# ----------------------------------------------------
# file1: X U B B --merge B B B
test_expect_success '"reset --merge HEAD" is ok with pending merge' '
- git reset --hard third &&
- test_must_fail git merge branch1 &&
- git reset --merge HEAD &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse third)" &&
- test -z "$(git diff --cached)" &&
- test -z "$(git diff)"
+ git reset --hard third &&
+ test_must_fail git merge branch1 &&
+ git reset --merge HEAD &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse third)" &&
+ test -z "$(git diff --cached)" &&
+ test -z "$(git diff)"
'
# The next test will test the following:
@@ -261,36 +261,36 @@ test_expect_success '"reset --merge HEAD" is ok with pending merge' '
# ----------------------------------------------------
# file1: X U B B --keep (disallowed)
test_expect_success '"reset --keep HEAD" fails with pending merge' '
- git reset --hard third &&
- test_must_fail git merge branch1 &&
- test_must_fail git reset --keep HEAD 2>err.log &&
- test_i18ngrep "middle of a merge" err.log
+ git reset --hard third &&
+ test_must_fail git merge branch1 &&
+ test_must_fail git reset --keep HEAD 2>err.log &&
+ test_i18ngrep "middle of a merge" err.log
'
test_expect_success '--merge is ok with added/deleted merge' '
- git reset --hard third &&
- rm -f file2 &&
- test_must_fail git merge branch3 &&
- ! test -f file2 &&
- test -f file3 &&
- git diff --exit-code file3 &&
- git diff --exit-code branch3 file3 &&
- git reset --merge HEAD &&
- ! test -f file3 &&
- ! test -f file2 &&
- git diff --exit-code --cached
+ git reset --hard third &&
+ rm -f file2 &&
+ test_must_fail git merge branch3 &&
+ ! test -f file2 &&
+ test -f file3 &&
+ git diff --exit-code file3 &&
+ git diff --exit-code branch3 file3 &&
+ git reset --merge HEAD &&
+ ! test -f file3 &&
+ ! test -f file2 &&
+ git diff --exit-code --cached
'
test_expect_success '--keep fails with added/deleted merge' '
- git reset --hard third &&
- rm -f file2 &&
- test_must_fail git merge branch3 &&
- ! test -f file2 &&
- test -f file3 &&
- git diff --exit-code file3 &&
- git diff --exit-code branch3 file3 &&
- test_must_fail git reset --keep HEAD 2>err.log &&
- test_i18ngrep "middle of a merge" err.log
+ git reset --hard third &&
+ rm -f file2 &&
+ test_must_fail git merge branch3 &&
+ ! test -f file2 &&
+ test -f file3 &&
+ git diff --exit-code file3 &&
+ git diff --exit-code branch3 file3 &&
+ test_must_fail git reset --keep HEAD 2>err.log &&
+ test_i18ngrep "middle of a merge" err.log
'
test_done
diff --git a/t/t7111-reset-table.sh b/t/t7111-reset-table.sh
index 78f25c1..01b7c35 100755
--- a/t/t7111-reset-table.sh
+++ b/t/t7111-reset-table.sh
@@ -10,9 +10,9 @@ TEST_PASSES_SANITIZE_LEAK=true
test_expect_success 'creating initial commits' '
- test_commit E file1 &&
- test_commit D file1 &&
- test_commit C file1
+ test_commit E file1 &&
+ test_commit D file1 &&
+ test_commit C file1
'
while read W1 I1 H1 T opt W2 I2 H2
@@ -74,13 +74,13 @@ B C C C keep B C C
EOF
test_expect_success 'setting up branches to test with unmerged entries' '
- git reset --hard C &&
- git branch branch1 &&
- git branch branch2 &&
- git checkout branch1 &&
- test_commit B1 file1 &&
- git checkout branch2 &&
- test_commit B file1
+ git reset --hard C &&
+ git branch branch1 &&
+ git branch branch2 &&
+ git checkout branch1 &&
+ test_commit B1 file1 &&
+ git checkout branch2 &&
+ test_commit B file1
'
while read W1 I1 H1 T opt W2 I2 H2
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 61ad47b..35b9e6e 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -372,75 +372,75 @@ test_expect_success 'checkout specific path while in subdirectory' '
'
test_expect_success 'checkout w/--track sets up tracking' '
- git config branch.autosetupmerge false &&
- git checkout main &&
- git checkout --track -b track1 &&
- test "$(git config branch.track1.remote)" &&
- test "$(git config branch.track1.merge)"
+ git config branch.autosetupmerge false &&
+ git checkout main &&
+ git checkout --track -b track1 &&
+ test "$(git config branch.track1.remote)" &&
+ test "$(git config branch.track1.merge)"
'
test_expect_success 'checkout w/autosetupmerge=always sets up tracking' '
- test_when_finished git config branch.autosetupmerge false &&
- git config branch.autosetupmerge always &&
- git checkout main &&
- git checkout -b track2 &&
- test "$(git config branch.track2.remote)" &&
- test "$(git config branch.track2.merge)"
+ test_when_finished git config branch.autosetupmerge false &&
+ git config branch.autosetupmerge always &&
+ git checkout main &&
+ git checkout -b track2 &&
+ test "$(git config branch.track2.remote)" &&
+ test "$(git config branch.track2.merge)"
'
test_expect_success 'checkout w/--track from non-branch HEAD fails' '
- git checkout main^0 &&
- test_must_fail git symbolic-ref HEAD &&
- test_must_fail git checkout --track -b track &&
- test_must_fail git rev-parse --verify track &&
- test_must_fail git symbolic-ref HEAD &&
- test "z$(git rev-parse main^0)" = "z$(git rev-parse HEAD)"
+ git checkout main^0 &&
+ test_must_fail git symbolic-ref HEAD &&
+ test_must_fail git checkout --track -b track &&
+ test_must_fail git rev-parse --verify track &&
+ test_must_fail git symbolic-ref HEAD &&
+ test "z$(git rev-parse main^0)" = "z$(git rev-parse HEAD)"
'
test_expect_success 'checkout w/--track from tag fails' '
- git checkout main^0 &&
- test_must_fail git symbolic-ref HEAD &&
- test_must_fail git checkout --track -b track frotz &&
- test_must_fail git rev-parse --verify track &&
- test_must_fail git symbolic-ref HEAD &&
- test "z$(git rev-parse main^0)" = "z$(git rev-parse HEAD)"
+ git checkout main^0 &&
+ test_must_fail git symbolic-ref HEAD &&
+ test_must_fail git checkout --track -b track frotz &&
+ test_must_fail git rev-parse --verify track &&
+ test_must_fail git symbolic-ref HEAD &&
+ test "z$(git rev-parse main^0)" = "z$(git rev-parse HEAD)"
'
test_expect_success 'detach a symbolic link HEAD' '
- git checkout main &&
- git config --bool core.prefersymlinkrefs yes &&
- git checkout side &&
- git checkout main &&
- it=$(git symbolic-ref HEAD) &&
- test "z$it" = zrefs/heads/main &&
- here=$(git rev-parse --verify refs/heads/main) &&
- git checkout side^ &&
- test "z$(git rev-parse --verify refs/heads/main)" = "z$here"
+ git checkout main &&
+ git config --bool core.prefersymlinkrefs yes &&
+ git checkout side &&
+ git checkout main &&
+ it=$(git symbolic-ref HEAD) &&
+ test "z$it" = zrefs/heads/main &&
+ here=$(git rev-parse --verify refs/heads/main) &&
+ git checkout side^ &&
+ test "z$(git rev-parse --verify refs/heads/main)" = "z$here"
'
test_expect_success 'checkout with --track fakes a sensible -b <name>' '
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" &&
- git update-ref refs/remotes/origin/koala/bear renamer &&
+ git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" &&
+ git update-ref refs/remotes/origin/koala/bear renamer &&
- git checkout --track origin/koala/bear &&
- test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" &&
+ git checkout --track origin/koala/bear &&
+ test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" &&
- git checkout main && git branch -D koala/bear &&
+ git checkout main && git branch -D koala/bear &&
- git checkout --track refs/remotes/origin/koala/bear &&
- test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" &&
+ git checkout --track refs/remotes/origin/koala/bear &&
+ test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" &&
- git checkout main && git branch -D koala/bear &&
+ git checkout main && git branch -D koala/bear &&
- git checkout --track remotes/origin/koala/bear &&
- test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)"
+ git checkout --track remotes/origin/koala/bear &&
+ test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)"
'
test_expect_success 'checkout with --track, but without -b, fails with too short tracked name' '
- test_must_fail git checkout --track renamer
+ test_must_fail git checkout --track renamer
'
setup_conflicting_index () {
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index eae6a46..d9fbabb 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -1351,6 +1351,22 @@ test_expect_success 'clone active submodule without submodule url set' '
)
'
+test_expect_success 'update submodules without url set in .gitconfig' '
+ test_when_finished "rm -rf multisuper_clone" &&
+ git clone file://"$pwd"/multisuper multisuper_clone &&
+
+ git -C multisuper_clone submodule init &&
+ for s in sub0 sub1 sub2 sub3
+ do
+ key=submodule.$s.url &&
+ git -C multisuper_clone config --local --unset $key &&
+ git -C multisuper_clone config --file .gitmodules --unset $key || return 1
+ done &&
+
+ test_must_fail git -C multisuper_clone submodule update 2>err &&
+ grep "cannot clone submodule .sub[0-3]. without a URL" err
+'
+
test_expect_success 'clone --recurse-submodules with a pathspec works' '
test_when_finished "rm -rf multisuper_clone" &&
cat >expected <<-\EOF &&
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 4c1f03e..3656770 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -1520,8 +1520,8 @@ test_expect_success '"status.branch=true" weaker than "--no-branch"' '
'
test_expect_success '"status.branch=true" weaker than "--porcelain"' '
- git -c status.branch=true status --porcelain >actual &&
- test_cmp expected_nobranch actual
+ git -c status.branch=true status --porcelain >actual &&
+ test_cmp expected_nobranch actual
'
test_expect_success '"status.branch=false" same as "--no-branch"' '
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 060e145..fdc6072 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -639,41 +639,41 @@ test_expect_success 'merge log message' '
test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c0, c2, c0, and c1' '
- git reset --hard c1 &&
- test_tick &&
- git merge c0 c2 c0 c1 &&
- verify_merge file result.1-5 &&
- verify_parents $c1 $c2
+ git reset --hard c1 &&
+ test_tick &&
+ git merge c0 c2 c0 c1 &&
+ verify_merge file result.1-5 &&
+ verify_parents $c1 $c2
'
test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c0, c2, c0, and c1' '
- git reset --hard c1 &&
- test_tick &&
- git merge c0 c2 c0 c1 &&
- verify_merge file result.1-5 &&
- verify_parents $c1 $c2
+ git reset --hard c1 &&
+ test_tick &&
+ git merge c0 c2 c0 c1 &&
+ verify_merge file result.1-5 &&
+ verify_parents $c1 $c2
'
test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c1 and c2' '
- git reset --hard c1 &&
- test_tick &&
- git merge c1 c2 &&
- verify_merge file result.1-5 &&
- verify_parents $c1 $c2
+ git reset --hard c1 &&
+ test_tick &&
+ git merge c1 c2 &&
+ verify_merge file result.1-5 &&
+ verify_parents $c1 $c2
'
test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge fast-forward in a dirty tree' '
- git reset --hard c0 &&
- mv file file1 &&
- cat file1 >file &&
- rm -f file1 &&
- git merge c2
+ git reset --hard c0 &&
+ mv file file1 &&
+ cat file1 >file &&
+ rm -f file1 &&
+ git merge c2
'
test_debug 'git log --graph --decorate --oneline --all'
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index faa739e..3f930fa 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -460,10 +460,10 @@ test_expect_success '--write-midx -b packs non-kept objects' '
'
test_expect_success '--write-midx removes stale pack-based bitmaps' '
- rm -fr repo &&
- git init repo &&
- test_when_finished "rm -fr repo" &&
- (
+ rm -fr repo &&
+ git init repo &&
+ test_when_finished "rm -fr repo" &&
+ (
cd repo &&
test_commit base &&
GIT_TEST_MULTI_PACK_INDEX=0 git repack -Ab &&
@@ -477,7 +477,7 @@ test_expect_success '--write-midx removes stale pack-based bitmaps' '
test_path_is_file $midx &&
test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
test_path_is_missing $pack_bitmap
- )
+ )
'
test_expect_success '--write-midx with --pack-kept-objects' '
diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh
index ebb2678..ba428c1 100755
--- a/t/t7701-repack-unpack-unreachable.sh
+++ b/t/t7701-repack-unpack-unreachable.sh
@@ -113,6 +113,37 @@ test_expect_success 'do not bother loosening old objects' '
test_must_fail git cat-file -p $obj2
'
+test_expect_success 'gc.recentObjectsHook' '
+ obj1=$(echo one | git hash-object -w --stdin) &&
+ obj2=$(echo two | git hash-object -w --stdin) &&
+ obj3=$(echo three | git hash-object -w --stdin) &&
+ pack1=$(echo $obj1 | git pack-objects .git/objects/pack/pack) &&
+ pack2=$(echo $obj2 | git pack-objects .git/objects/pack/pack) &&
+ pack3=$(echo $obj3 | git pack-objects .git/objects/pack/pack) &&
+ git prune-packed &&
+
+ git cat-file -p $obj1 &&
+ git cat-file -p $obj2 &&
+ git cat-file -p $obj3 &&
+
+ git tag -a -m tag obj2-tag $obj2 &&
+ obj2_tag="$(git rev-parse obj2-tag)" &&
+
+ write_script precious-objects <<-EOF &&
+ echo $obj2_tag
+ EOF
+ git config gc.recentObjectsHook ./precious-objects &&
+
+ test-tool chmtime =-86400 .git/objects/pack/pack-$pack2.pack &&
+ test-tool chmtime =-86400 .git/objects/pack/pack-$pack3.pack &&
+ git repack -A -d --unpack-unreachable=1.hour.ago &&
+
+ git cat-file -p $obj1 &&
+ git cat-file -p $obj2 &&
+ git cat-file -p $obj2_tag &&
+ test_must_fail git cat-file -p $obj3
+'
+
test_expect_success 'keep packed objects found only in index' '
echo my-unique-content >file &&
git add file &&
diff --git a/t/t7814-grep-recurse-submodules.sh b/t/t7814-grep-recurse-submodules.sh
index 8143817..d37c83b 100755
--- a/t/t7814-grep-recurse-submodules.sh
+++ b/t/t7814-grep-recurse-submodules.sh
@@ -594,4 +594,44 @@ test_expect_success 'grep partially-cloned submodule' '
)
'
+test_expect_success 'check scope of core.useReplaceRefs' '
+ git init base &&
+ git init base/sub &&
+
+ echo A >base/a &&
+ echo B >base/b &&
+ echo C >base/sub/c &&
+ echo D >base/sub/d &&
+
+ git -C base/sub add c d &&
+ git -C base/sub commit -m "Add files" &&
+
+ git -C base submodule add ./sub &&
+ git -C base add a b sub &&
+ git -C base commit -m "Add files and submodule" &&
+
+ A=$(git -C base rev-parse HEAD:a) &&
+ B=$(git -C base rev-parse HEAD:b) &&
+ C=$(git -C base/sub rev-parse HEAD:c) &&
+ D=$(git -C base/sub rev-parse HEAD:d) &&
+
+ git -C base replace $A $B &&
+ git -C base/sub replace $C $D &&
+
+ test_must_fail git -C base grep --cached --recurse-submodules A &&
+ test_must_fail git -C base grep --cached --recurse-submodules C &&
+
+ git -C base config core.useReplaceRefs false &&
+ git -C base grep --recurse-submodules A &&
+ test_must_fail git -C base grep --cached --recurse-submodules C &&
+
+ git -C base/sub config core.useReplaceRefs false &&
+ git -C base grep --cached --recurse-submodules A &&
+ git -C base grep --cached --recurse-submodules C &&
+
+ git -C base config --unset core.useReplaceRefs &&
+ test_must_fail git -C base grep --cached --recurse-submodules A &&
+ git -C base grep --cached --recurse-submodules C
+'
+
test_done
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 22fc908..48bf0af 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -4,7 +4,7 @@ test_description='git send-email'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
-# no longer TEST_PASSES_SANITIZE_LEAK=true - format-patch --thread leaks
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# May be altered later in the test
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index fea41b3..af28b01 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -21,7 +21,7 @@ test_expect_success 'git svn help works anywhere' '
'
test_expect_success \
- 'initialize git svn' '
+ 'initialize git svn' '
mkdir import &&
(
cd import &&
@@ -38,9 +38,9 @@ test_expect_success \
rm -rf import &&
git svn init "$svnrepo"'
-test_expect_success \
- 'import an SVN revision into git' \
- 'git svn fetch'
+test_expect_success 'import an SVN revision into git' '
+ git svn fetch
+'
test_expect_success "checkout from svn" 'svn co "$svnrepo" "$SVN_TREE"'
@@ -233,27 +233,26 @@ test_expect_success POSIXPERM,SYMLINKS "$name" '
'
test_expect_success 'exit if remote refs are ambigious' '
- git config --add svn-remote.svn.fetch \
+ git config --add svn-remote.svn.fetch \
bar:refs/remotes/git-svn &&
test_must_fail git svn migrate
'
test_expect_success 'exit if init-ing a would clobber a URL' '
- svnadmin create "${PWD}/svnrepo2" &&
- svn mkdir -m "mkdir bar" "${svnrepo}2/bar" &&
- git config --unset svn-remote.svn.fetch \
+ svnadmin create "${PWD}/svnrepo2" &&
+ svn mkdir -m "mkdir bar" "${svnrepo}2/bar" &&
+ git config --unset svn-remote.svn.fetch \
"^bar:refs/remotes/git-svn$" &&
test_must_fail git svn init "${svnrepo}2/bar"
'
-test_expect_success \
- 'init allows us to connect to another directory in the same repo' '
- git svn init --minimize-url -i bar "$svnrepo/bar" &&
- git config --get svn-remote.svn.fetch \
- "^bar:refs/remotes/bar$" &&
- git config --get svn-remote.svn.fetch \
- "^:refs/remotes/git-svn$"
- '
+test_expect_success 'init allows us to connect to another directory in the same repo' '
+ git svn init --minimize-url -i bar "$svnrepo/bar" &&
+ git config --get svn-remote.svn.fetch \
+ "^bar:refs/remotes/bar$" &&
+ git config --get svn-remote.svn.fetch \
+ "^:refs/remotes/git-svn$"
+'
test_expect_success 'dcommit $rev does not clobber current branch' '
git svn fetch -i bar &&
diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh
index 85d7358..b5845e2 100755
--- a/t/t9104-git-svn-follow-parent.sh
+++ b/t/t9104-git-svn-follow-parent.sh
@@ -41,51 +41,51 @@ test_expect_success 'init and fetch a moved directory' '
'
test_expect_success 'init and fetch from one svn-remote' '
- git config svn-remote.svn.url "$svnrepo" &&
- git config --add svn-remote.svn.fetch \
- trunk:refs/remotes/svn/trunk &&
- git config --add svn-remote.svn.fetch \
- thunk:refs/remotes/svn/thunk &&
- git svn fetch -i svn/thunk &&
+ git config svn-remote.svn.url "$svnrepo" &&
+ git config --add svn-remote.svn.fetch \
+ trunk:refs/remotes/svn/trunk &&
+ git config --add svn-remote.svn.fetch \
+ thunk:refs/remotes/svn/thunk &&
+ git svn fetch -i svn/thunk &&
test "$(git rev-parse --verify refs/remotes/svn/trunk)" \
- = "$(git rev-parse --verify refs/remotes/svn/thunk~1)" &&
+ = "$(git rev-parse --verify refs/remotes/svn/thunk~1)" &&
git cat-file blob refs/remotes/svn/thunk:readme >actual &&
test "$(sed -n -e "3p" actual)" = goodbye
- '
+'
test_expect_success 'follow deleted parent' '
- (svn_cmd cp -m "resurrecting trunk as junk" \
- "$svnrepo"/trunk@2 "$svnrepo"/junk ||
- svn cp -m "resurrecting trunk as junk" \
- -r2 "$svnrepo"/trunk "$svnrepo"/junk) &&
- git config --add svn-remote.svn.fetch \
- junk:refs/remotes/svn/junk &&
- git svn fetch -i svn/thunk &&
- git svn fetch -i svn/junk &&
+ (svn_cmd cp -m "resurrecting trunk as junk" \
+ "$svnrepo"/trunk@2 "$svnrepo"/junk ||
+ svn cp -m "resurrecting trunk as junk" \
+ -r2 "$svnrepo"/trunk "$svnrepo"/junk) &&
+ git config --add svn-remote.svn.fetch \
+ junk:refs/remotes/svn/junk &&
+ git svn fetch -i svn/thunk &&
+ git svn fetch -i svn/junk &&
test -z "$(git diff svn/junk svn/trunk)" &&
test "$(git merge-base svn/junk svn/trunk)" \
- = "$(git rev-parse svn/trunk)"
- '
+ = "$(git rev-parse svn/trunk)"
+'
test_expect_success 'follow larger parent' '
- mkdir -p import/trunk/thunk/bump/thud &&
- echo hi > import/trunk/thunk/bump/thud/file &&
- svn import -m "import a larger parent" import "$svnrepo"/larger-parent &&
- svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger &&
- git svn init --minimize-url -i larger \
- "$svnrepo"/larger-parent/trunk/thunk/bump/thud &&
- git svn fetch -i larger &&
+ mkdir -p import/trunk/thunk/bump/thud &&
+ echo hi > import/trunk/thunk/bump/thud/file &&
+ svn import -m "import a larger parent" import "$svnrepo"/larger-parent &&
+ svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger &&
+ git svn init --minimize-url -i larger \
+ "$svnrepo"/larger-parent/trunk/thunk/bump/thud &&
+ git svn fetch -i larger &&
git svn init --minimize-url -i larger-parent \
- "$svnrepo"/another-larger/trunk/thunk/bump/thud &&
+ "$svnrepo"/another-larger/trunk/thunk/bump/thud &&
git svn fetch -i larger-parent &&
- git rev-parse --verify refs/remotes/larger &&
- git rev-parse --verify \
- refs/remotes/larger-parent &&
+ git rev-parse --verify refs/remotes/larger &&
+ git rev-parse --verify \
+ refs/remotes/larger-parent &&
test "$(git merge-base \
refs/remotes/larger-parent \
refs/remotes/larger)" = \
- "$(git rev-parse refs/remotes/larger)"
- '
+ "$(git rev-parse refs/remotes/larger)"
+'
test_expect_success 'follow higher-level parent' '
svn mkdir -m "follow higher-level parent" "$svnrepo"/blob &&
diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh
index c5946cb..a44eabf 100755
--- a/t/t9200-git-cvsexportcommit.sh
+++ b/t/t9200-git-cvsexportcommit.sh
@@ -50,56 +50,56 @@ check_entries () {
fi
}
-test_expect_success \
- 'New file' \
- 'mkdir A B C D E F &&
- echo hello1 >A/newfile1.txt &&
- echo hello2 >B/newfile2.txt &&
- cp "$TEST_DIRECTORY"/test-binary-1.png C/newfile3.png &&
- cp "$TEST_DIRECTORY"/test-binary-1.png D/newfile4.png &&
- git add A/newfile1.txt &&
- git add B/newfile2.txt &&
- git add C/newfile3.png &&
- git add D/newfile4.png &&
- git commit -a -m "Test: New file" &&
- id=$(git rev-list --max-count=1 HEAD) &&
- (cd "$CVSWORK" &&
- git cvsexportcommit -c $id &&
- check_entries A "newfile1.txt/1.1/" &&
- check_entries B "newfile2.txt/1.1/" &&
- check_entries C "newfile3.png/1.1/-kb" &&
- check_entries D "newfile4.png/1.1/-kb" &&
- test_cmp A/newfile1.txt ../A/newfile1.txt &&
- test_cmp B/newfile2.txt ../B/newfile2.txt &&
- test_cmp C/newfile3.png ../C/newfile3.png &&
- test_cmp D/newfile4.png ../D/newfile4.png
- )'
+test_expect_success 'New file' '
+ mkdir A B C D E F &&
+ echo hello1 >A/newfile1.txt &&
+ echo hello2 >B/newfile2.txt &&
+ cp "$TEST_DIRECTORY"/test-binary-1.png C/newfile3.png &&
+ cp "$TEST_DIRECTORY"/test-binary-1.png D/newfile4.png &&
+ git add A/newfile1.txt &&
+ git add B/newfile2.txt &&
+ git add C/newfile3.png &&
+ git add D/newfile4.png &&
+ git commit -a -m "Test: New file" &&
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$CVSWORK" &&
+ git cvsexportcommit -c $id &&
+ check_entries A "newfile1.txt/1.1/" &&
+ check_entries B "newfile2.txt/1.1/" &&
+ check_entries C "newfile3.png/1.1/-kb" &&
+ check_entries D "newfile4.png/1.1/-kb" &&
+ test_cmp A/newfile1.txt ../A/newfile1.txt &&
+ test_cmp B/newfile2.txt ../B/newfile2.txt &&
+ test_cmp C/newfile3.png ../C/newfile3.png &&
+ test_cmp D/newfile4.png ../D/newfile4.png
+ )
+'
-test_expect_success \
- 'Remove two files, add two and update two' \
- 'echo Hello1 >>A/newfile1.txt &&
- rm -f B/newfile2.txt &&
- rm -f C/newfile3.png &&
- echo Hello5 >E/newfile5.txt &&
- cp "$TEST_DIRECTORY"/test-binary-2.png D/newfile4.png &&
- cp "$TEST_DIRECTORY"/test-binary-1.png F/newfile6.png &&
- git add E/newfile5.txt &&
- git add F/newfile6.png &&
- git commit -a -m "Test: Remove, add and update" &&
- id=$(git rev-list --max-count=1 HEAD) &&
- (cd "$CVSWORK" &&
- git cvsexportcommit -c $id &&
- check_entries A "newfile1.txt/1.2/" &&
- check_entries B "" &&
- check_entries C "" &&
- check_entries D "newfile4.png/1.2/-kb" &&
- check_entries E "newfile5.txt/1.1/" &&
- check_entries F "newfile6.png/1.1/-kb" &&
- test_cmp A/newfile1.txt ../A/newfile1.txt &&
- test_cmp D/newfile4.png ../D/newfile4.png &&
- test_cmp E/newfile5.txt ../E/newfile5.txt &&
- test_cmp F/newfile6.png ../F/newfile6.png
- )'
+test_expect_success 'Remove two files, add two and update two' '
+ echo Hello1 >>A/newfile1.txt &&
+ rm -f B/newfile2.txt &&
+ rm -f C/newfile3.png &&
+ echo Hello5 >E/newfile5.txt &&
+ cp "$TEST_DIRECTORY"/test-binary-2.png D/newfile4.png &&
+ cp "$TEST_DIRECTORY"/test-binary-1.png F/newfile6.png &&
+ git add E/newfile5.txt &&
+ git add F/newfile6.png &&
+ git commit -a -m "Test: Remove, add and update" &&
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$CVSWORK" &&
+ git cvsexportcommit -c $id &&
+ check_entries A "newfile1.txt/1.2/" &&
+ check_entries B "" &&
+ check_entries C "" &&
+ check_entries D "newfile4.png/1.2/-kb" &&
+ check_entries E "newfile5.txt/1.1/" &&
+ check_entries F "newfile6.png/1.1/-kb" &&
+ test_cmp A/newfile1.txt ../A/newfile1.txt &&
+ test_cmp D/newfile4.png ../D/newfile4.png &&
+ test_cmp E/newfile5.txt ../E/newfile5.txt &&
+ test_cmp F/newfile6.png ../F/newfile6.png
+ )
+'
# Should fail (but only on the git cvsexportcommit stage)
test_expect_success \
@@ -129,67 +129,67 @@ test_expect_success \
# This test is here because a patch for only binary files will
# fail with gnu patch, so cvsexportcommit must handle that.
-test_expect_success \
- 'Remove only binary files' \
- 'git reset --hard HEAD^^ &&
- rm -f D/newfile4.png &&
- git commit -a -m "test: remove only a binary file" &&
- id=$(git rev-list --max-count=1 HEAD) &&
- (cd "$CVSWORK" &&
- git cvsexportcommit -c $id &&
- check_entries A "newfile1.txt/1.2/" &&
- check_entries B "" &&
- check_entries C "" &&
- check_entries D "" &&
- check_entries E "newfile5.txt/1.1/" &&
- check_entries F "newfile6.png/1.1/-kb" &&
- test_cmp A/newfile1.txt ../A/newfile1.txt &&
- test_cmp E/newfile5.txt ../E/newfile5.txt &&
- test_cmp F/newfile6.png ../F/newfile6.png
- )'
+test_expect_success 'Remove only binary files' '
+ git reset --hard HEAD^^ &&
+ rm -f D/newfile4.png &&
+ git commit -a -m "test: remove only a binary file" &&
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$CVSWORK" &&
+ git cvsexportcommit -c $id &&
+ check_entries A "newfile1.txt/1.2/" &&
+ check_entries B "" &&
+ check_entries C "" &&
+ check_entries D "" &&
+ check_entries E "newfile5.txt/1.1/" &&
+ check_entries F "newfile6.png/1.1/-kb" &&
+ test_cmp A/newfile1.txt ../A/newfile1.txt &&
+ test_cmp E/newfile5.txt ../E/newfile5.txt &&
+ test_cmp F/newfile6.png ../F/newfile6.png
+ )
+'
-test_expect_success \
- 'Remove only a text file' \
- 'rm -f A/newfile1.txt &&
- git commit -a -m "test: remove only a binary file" &&
- id=$(git rev-list --max-count=1 HEAD) &&
- (cd "$CVSWORK" &&
- git cvsexportcommit -c $id &&
- check_entries A "" &&
- check_entries B "" &&
- check_entries C "" &&
- check_entries D "" &&
- check_entries E "newfile5.txt/1.1/" &&
- check_entries F "newfile6.png/1.1/-kb" &&
- test_cmp E/newfile5.txt ../E/newfile5.txt &&
- test_cmp F/newfile6.png ../F/newfile6.png
- )'
+test_expect_success 'Remove only a text file' '
+ rm -f A/newfile1.txt &&
+ git commit -a -m "test: remove only a binary file" &&
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$CVSWORK" &&
+ git cvsexportcommit -c $id &&
+ check_entries A "" &&
+ check_entries B "" &&
+ check_entries C "" &&
+ check_entries D "" &&
+ check_entries E "newfile5.txt/1.1/" &&
+ check_entries F "newfile6.png/1.1/-kb" &&
+ test_cmp E/newfile5.txt ../E/newfile5.txt &&
+ test_cmp F/newfile6.png ../F/newfile6.png
+ )
+'
-test_expect_success \
- 'New file with spaces in file name' \
- 'mkdir "G g" &&
- echo ok then >"G g/with spaces.txt" &&
- git add "G g/with spaces.txt" && \
- cp "$TEST_DIRECTORY"/test-binary-1.png "G g/with spaces.png" && \
- git add "G g/with spaces.png" &&
- git commit -a -m "With spaces" &&
- id=$(git rev-list --max-count=1 HEAD) &&
- (cd "$CVSWORK" &&
- git cvsexportcommit -c $id &&
- check_entries "G g" "with spaces.png/1.1/-kb|with spaces.txt/1.1/"
- )'
+test_expect_success 'New file with spaces in file name' '
+ mkdir "G g" &&
+ echo ok then >"G g/with spaces.txt" &&
+ git add "G g/with spaces.txt" && \
+ cp "$TEST_DIRECTORY"/test-binary-1.png "G g/with spaces.png" && \
+ git add "G g/with spaces.png" &&
+ git commit -a -m "With spaces" &&
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$CVSWORK" &&
+ git cvsexportcommit -c $id &&
+ check_entries "G g" "with spaces.png/1.1/-kb|with spaces.txt/1.1/"
+ )
+'
-test_expect_success \
- 'Update file with spaces in file name' \
- 'echo Ok then >>"G g/with spaces.txt" &&
- cat "$TEST_DIRECTORY"/test-binary-1.png >>"G g/with spaces.png" && \
- git add "G g/with spaces.png" &&
- git commit -a -m "Update with spaces" &&
- id=$(git rev-list --max-count=1 HEAD) &&
- (cd "$CVSWORK" &&
- git cvsexportcommit -c $id &&
- check_entries "G g" "with spaces.png/1.2/-kb|with spaces.txt/1.2/"
- )'
+test_expect_success 'Update file with spaces in file name' '
+ echo Ok then >>"G g/with spaces.txt" &&
+ cat "$TEST_DIRECTORY"/test-binary-1.png >>"G g/with spaces.png" && \
+ git add "G g/with spaces.png" &&
+ git commit -a -m "Update with spaces" &&
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$CVSWORK" &&
+ git cvsexportcommit -c $id &&
+ check_entries "G g" "with spaces.png/1.2/-kb|with spaces.txt/1.2/"
+ )
+'
# Some filesystems mangle pathnames with UTF-8 characters --
# check and skip
@@ -202,68 +202,68 @@ if p="Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" &&
then
# This test contains UTF-8 characters
-test_expect_success !MINGW \
- 'File with non-ascii file name' \
- 'mkdir -p Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö &&
- echo Foo >Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
- git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
- cp "$TEST_DIRECTORY"/test-binary-1.png Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
- git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
- git commit -a -m "Går det så går det" && \
- id=$(git rev-list --max-count=1 HEAD) &&
- (cd "$CVSWORK" &&
- git cvsexportcommit -v -c $id &&
- check_entries \
- "Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" \
- "gårdetsågårdet.png/1.1/-kb|gårdetsågårdet.txt/1.1/"
- )'
+test_expect_success !MINGW 'File with non-ascii file name' '
+ mkdir -p Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö &&
+ echo Foo >Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
+ git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
+ cp "$TEST_DIRECTORY"/test-binary-1.png Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
+ git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
+ git commit -a -m "Går det så går det" && \
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$CVSWORK" &&
+ git cvsexportcommit -v -c $id &&
+ check_entries \
+ "Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" \
+ "gårdetsågårdet.png/1.1/-kb|gårdetsågårdet.txt/1.1/"
+ )
+'
fi
rm -fr tst
-test_expect_success \
- 'Mismatching patch should fail' \
- 'date >>"E/newfile5.txt" &&
- git add "E/newfile5.txt" &&
- git commit -a -m "Update one" &&
- date >>"E/newfile5.txt" &&
- git add "E/newfile5.txt" &&
- git commit -a -m "Update two" &&
- id=$(git rev-list --max-count=1 HEAD) &&
- (cd "$CVSWORK" &&
- test_must_fail git cvsexportcommit -c $id
- )'
-
-test_expect_success FILEMODE \
- 'Retain execute bit' \
- 'mkdir G &&
- echo executeon >G/on &&
- chmod +x G/on &&
- echo executeoff >G/off &&
- git add G/on &&
- git add G/off &&
- git commit -a -m "Execute test" &&
- (cd "$CVSWORK" &&
- git cvsexportcommit -c HEAD &&
- test -x G/on &&
- ! test -x G/off
- )'
+test_expect_success 'Mismatching patch should fail' '
+ date >>"E/newfile5.txt" &&
+ git add "E/newfile5.txt" &&
+ git commit -a -m "Update one" &&
+ date >>"E/newfile5.txt" &&
+ git add "E/newfile5.txt" &&
+ git commit -a -m "Update two" &&
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$CVSWORK" &&
+ test_must_fail git cvsexportcommit -c $id
+ )
+'
+
+test_expect_success FILEMODE 'Retain execute bit' '
+ mkdir G &&
+ echo executeon >G/on &&
+ chmod +x G/on &&
+ echo executeoff >G/off &&
+ git add G/on &&
+ git add G/off &&
+ git commit -a -m "Execute test" &&
+ (cd "$CVSWORK" &&
+ git cvsexportcommit -c HEAD &&
+ test -x G/on &&
+ ! test -x G/off
+ )
+'
test_expect_success '-w option should work with relative GIT_DIR' '
- mkdir W &&
- echo foobar >W/file1.txt &&
- echo bazzle >W/file2.txt &&
- git add W/file1.txt &&
- git add W/file2.txt &&
- git commit -m "More updates" &&
- id=$(git rev-list --max-count=1 HEAD) &&
- (cd "$GIT_DIR" &&
- GIT_DIR=. git cvsexportcommit -w "$CVSWORK" -c $id &&
- check_entries "$CVSWORK/W" "file1.txt/1.1/|file2.txt/1.1/" &&
- test_cmp "$CVSWORK/W/file1.txt" ../W/file1.txt &&
- test_cmp "$CVSWORK/W/file2.txt" ../W/file2.txt
- )
+ mkdir W &&
+ echo foobar >W/file1.txt &&
+ echo bazzle >W/file2.txt &&
+ git add W/file1.txt &&
+ git add W/file2.txt &&
+ git commit -m "More updates" &&
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$GIT_DIR" &&
+ GIT_DIR=. git cvsexportcommit -w "$CVSWORK" -c $id &&
+ check_entries "$CVSWORK/W" "file1.txt/1.1/|file2.txt/1.1/" &&
+ test_cmp "$CVSWORK/W/file1.txt" ../W/file1.txt &&
+ test_cmp "$CVSWORK/W/file2.txt" ../W/file2.txt
+ )
'
test_expect_success 'check files before directories' '
@@ -290,21 +290,20 @@ test_expect_success 'check files before directories' '
'
test_expect_success 're-commit a removed filename which remains in CVS attic' '
-
- (cd "$CVSWORK" &&
- echo >attic_gremlin &&
- cvs -Q add attic_gremlin &&
- cvs -Q ci -m "added attic_gremlin" &&
- rm attic_gremlin &&
- cvs -Q rm attic_gremlin &&
- cvs -Q ci -m "removed attic_gremlin") &&
-
- echo > attic_gremlin &&
- git add attic_gremlin &&
- git commit -m "Added attic_gremlin" &&
+ (cd "$CVSWORK" &&
+ echo >attic_gremlin &&
+ cvs -Q add attic_gremlin &&
+ cvs -Q ci -m "added attic_gremlin" &&
+ rm attic_gremlin &&
+ cvs -Q rm attic_gremlin &&
+ cvs -Q ci -m "removed attic_gremlin") &&
+
+ echo > attic_gremlin &&
+ git add attic_gremlin &&
+ git commit -m "Added attic_gremlin" &&
git cvsexportcommit -w "$CVSWORK" -c HEAD &&
- (cd "$CVSWORK" && cvs -Q update -d) &&
- test -f "$CVSWORK/attic_gremlin"
+ (cd "$CVSWORK" && cvs -Q update -d) &&
+ test -f "$CVSWORK/attic_gremlin"
'
# the state of the CVS sandbox may be indeterminate for ' space'
diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 379b19f..003c0b6 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -66,10 +66,11 @@ test_expect_success 'setup' '
# note that cvs doesn't accept absolute pathnames
# as argument to co -d
-test_expect_success 'basic checkout' \
- 'GIT_CONFIG="$git_config" cvs -Q co -d cvswork main &&
- test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/" &&
- test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | sed -ne \$p))" = "secondrootfile/1.1/"'
+test_expect_success 'basic checkout' '
+ GIT_CONFIG="$git_config" cvs -Q co -d cvswork main &&
+ test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/" &&
+ test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | sed -ne \$p))" = "secondrootfile/1.1/"
+'
#------------------------
# PSERVER AUTHENTICATION
@@ -115,35 +116,40 @@ Ah<Z:yZZ30 e
END VERIFICATION REQUEST
EOF
-test_expect_success 'pserver authentication' \
- 'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
- sed -ne \$p log | grep "^I LOVE YOU\$"'
+test_expect_success 'pserver authentication' '
+ cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU\$"
+'
-test_expect_success 'pserver authentication failure (non-anonymous user)' \
- 'if cat request-git | git-cvsserver pserver >log 2>&1
- then
- false
- else
- true
- fi &&
- sed -ne \$p log | grep "^I HATE YOU\$"'
+test_expect_success 'pserver authentication failure (non-anonymous user)' '
+ if cat request-git | git-cvsserver pserver >log 2>&1
+ then
+ false
+ else
+ true
+ fi &&
+ sed -ne \$p log | grep "^I HATE YOU\$"
+'
-test_expect_success 'pserver authentication success (non-anonymous user with password)' \
- 'cat login-git-ok | git-cvsserver pserver >log 2>&1 &&
- sed -ne \$p log | grep "^I LOVE YOU\$"'
+test_expect_success 'pserver authentication success (non-anonymous user with password)' '
+ cat login-git-ok | git-cvsserver pserver >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU\$"
+'
-test_expect_success 'pserver authentication (login)' \
- 'cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
- sed -ne \$p log | grep "^I LOVE YOU\$"'
+test_expect_success 'pserver authentication (login)' '
+ cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU\$"
+'
-test_expect_success 'pserver authentication failure (login/non-anonymous user)' \
- 'if cat login-git | git-cvsserver pserver >log 2>&1
- then
- false
- else
- true
- fi &&
- sed -ne \$p log | grep "^I HATE YOU\$"'
+test_expect_success 'pserver authentication failure (login/non-anonymous user)' '
+ if cat login-git | git-cvsserver pserver >log 2>&1
+ then
+ false
+ else
+ true
+ fi &&
+ sed -ne \$p log | grep "^I HATE YOU\$"
+'
# misuse pserver authentication for testing of req_Root
@@ -165,36 +171,40 @@ END AUTH REQUEST
Root $WORKDIR
EOF
-test_expect_success 'req_Root failure (relative pathname)' \
- 'if cat request-relative | git-cvsserver pserver >log 2>&1
- then
- echo unexpected success
- false
- else
- true
- fi &&
- tail log | grep "^error 1 Root must be an absolute pathname$"'
+test_expect_success 'req_Root failure (relative pathname)' '
+ if cat request-relative | git-cvsserver pserver >log 2>&1
+ then
+ echo unexpected success
+ false
+ else
+ true
+ fi &&
+ tail log | grep "^error 1 Root must be an absolute pathname$"
+'
-test_expect_success 'req_Root failure (conflicting roots)' \
- 'cat request-conflict | git-cvsserver pserver >log 2>&1 &&
- tail log | grep "^error 1 Conflicting roots specified$"'
+test_expect_success 'req_Root failure (conflicting roots)' '
+ cat request-conflict | git-cvsserver pserver >log 2>&1 &&
+ tail log | grep "^error 1 Conflicting roots specified$"
+'
-test_expect_success 'req_Root (strict paths)' \
- 'cat request-anonymous | git-cvsserver --strict-paths pserver "$SERVERDIR" >log 2>&1 &&
- sed -ne \$p log | grep "^I LOVE YOU\$"'
+test_expect_success 'req_Root (strict paths)' '
+ cat request-anonymous | git-cvsserver --strict-paths pserver "$SERVERDIR" >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU\$"
+'
test_expect_success 'req_Root failure (strict-paths)' '
- ! cat request-anonymous |
- git-cvsserver --strict-paths pserver "$WORKDIR" >log 2>&1
+ ! cat request-anonymous |
+ git-cvsserver --strict-paths pserver "$WORKDIR" >log 2>&1
'
-test_expect_success 'req_Root (w/o strict-paths)' \
- 'cat request-anonymous | git-cvsserver pserver "$WORKDIR/" >log 2>&1 &&
- sed -ne \$p log | grep "^I LOVE YOU\$"'
+test_expect_success 'req_Root (w/o strict-paths)' '
+ cat request-anonymous | git-cvsserver pserver "$WORKDIR/" >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU\$"
+'
test_expect_success 'req_Root failure (w/o strict-paths)' '
- ! cat request-anonymous |
- git-cvsserver pserver "$WORKDIR/gitcvs" >log 2>&1
+ ! cat request-anonymous |
+ git-cvsserver pserver "$WORKDIR/gitcvs" >log 2>&1
'
cat >request-base <<EOF
@@ -206,27 +216,30 @@ END AUTH REQUEST
Root /gitcvs.git
EOF
-test_expect_success 'req_Root (base-path)' \
- 'cat request-base | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
- sed -ne \$p log | grep "^I LOVE YOU\$"'
+test_expect_success 'req_Root (base-path)' '
+ cat request-base | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU\$"
+'
test_expect_success 'req_Root failure (base-path)' '
- ! cat request-anonymous |
- git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" >log 2>&1
+ ! cat request-anonymous |
+ git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" >log 2>&1
'
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1
-test_expect_success 'req_Root (export-all)' \
- 'cat request-anonymous | git-cvsserver --export-all pserver "$WORKDIR" >log 2>&1 &&
- sed -ne \$p log | grep "^I LOVE YOU\$"'
+test_expect_success 'req_Root (export-all)' '
+ cat request-anonymous | git-cvsserver --export-all pserver "$WORKDIR" >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU\$"
+'
-test_expect_success 'req_Root failure (export-all w/o directory list)' \
- '! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)'
+test_expect_success 'req_Root failure (export-all w/o directory list)' '
+ ! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)'
-test_expect_success 'req_Root (everything together)' \
- 'cat request-base | git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
- sed -ne \$p log | grep "^I LOVE YOU\$"'
+test_expect_success 'req_Root (everything together)' '
+ cat request-base | git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU\$"
+'
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1
@@ -247,45 +260,49 @@ test_expect_success 'gitcvs.enabled = false' \
test ! -d cvswork2'
rm -fr cvswork2
-test_expect_success 'gitcvs.ext.enabled = true' \
- 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
- GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
- GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 &&
- test_cmp cvswork cvswork2'
+test_expect_success 'gitcvs.ext.enabled = true' '
+ GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
+ GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
+ GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 &&
+ test_cmp cvswork cvswork2
+'
rm -fr cvswork2
-test_expect_success 'gitcvs.ext.enabled = false' \
- 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false &&
- GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
- if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1
- then
- echo unexpected cvs success
- false
- else
- true
- fi &&
- grep "GITCVS emulation disabled" cvs.log &&
- test ! -d cvswork2'
+test_expect_success 'gitcvs.ext.enabled = false' '
+ GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false &&
+ GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
+ if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1
+ then
+ echo unexpected cvs success
+ false
+ else
+ true
+ fi &&
+ grep "GITCVS emulation disabled" cvs.log &&
+ test ! -d cvswork2
+'
rm -fr cvswork2
-test_expect_success 'gitcvs.dbname' \
- 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
- GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite &&
- GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 &&
- test_cmp cvswork cvswork2 &&
- test -f "$SERVERDIR/gitcvs.ext.main.sqlite" &&
- cmp "$SERVERDIR/gitcvs.main.sqlite" "$SERVERDIR/gitcvs.ext.main.sqlite"'
+test_expect_success 'gitcvs.dbname' '
+ GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
+ GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite &&
+ GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 &&
+ test_cmp cvswork cvswork2 &&
+ test -f "$SERVERDIR/gitcvs.ext.main.sqlite" &&
+ cmp "$SERVERDIR/gitcvs.main.sqlite" "$SERVERDIR/gitcvs.ext.main.sqlite"
+'
rm -fr cvswork2
-test_expect_success 'gitcvs.ext.dbname' \
- 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
- GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
- GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
- GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 &&
- test_cmp cvswork cvswork2 &&
- test -f "$SERVERDIR/gitcvs1.ext.main.sqlite" &&
- test ! -f "$SERVERDIR/gitcvs2.ext.main.sqlite" &&
- cmp "$SERVERDIR/gitcvs.main.sqlite" "$SERVERDIR/gitcvs1.ext.main.sqlite"'
+test_expect_success 'gitcvs.ext.dbname' '
+ GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
+ GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
+ GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
+ GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 &&
+ test_cmp cvswork cvswork2 &&
+ test -f "$SERVERDIR/gitcvs1.ext.main.sqlite" &&
+ test ! -f "$SERVERDIR/gitcvs2.ext.main.sqlite" &&
+ cmp "$SERVERDIR/gitcvs.main.sqlite" "$SERVERDIR/gitcvs1.ext.main.sqlite"
+'
#------------
@@ -299,109 +316,115 @@ GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" ||
exit 1
-test_expect_success 'cvs update (create new file)' \
- 'echo testfile1 >testfile1 &&
- git add testfile1 &&
- git commit -q -m "Add testfile1" &&
- git push gitcvs.git >/dev/null &&
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs -Q update &&
- test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" &&
- test_cmp testfile1 ../testfile1'
+test_expect_success 'cvs update (create new file)' '
+ echo testfile1 >testfile1 &&
+ git add testfile1 &&
+ git commit -q -m "Add testfile1" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs -Q update &&
+ test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" &&
+ test_cmp testfile1 ../testfile1
+'
cd "$WORKDIR"
-test_expect_success 'cvs update (update existing file)' \
- 'echo line 2 >>testfile1 &&
- git add testfile1 &&
- git commit -q -m "Append to testfile1" &&
- git push gitcvs.git >/dev/null &&
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs -Q update &&
- test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" &&
- test_cmp testfile1 ../testfile1'
+test_expect_success 'cvs update (update existing file)' '
+ echo line 2 >>testfile1 &&
+ git add testfile1 &&
+ git commit -q -m "Append to testfile1" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs -Q update &&
+ test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" &&
+ test_cmp testfile1 ../testfile1
+'
cd "$WORKDIR"
#TODO: cvsserver doesn't support update w/o -d
test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" '
- mkdir test &&
- echo >test/empty &&
- git add test &&
- git commit -q -m "Single Subdirectory" &&
- git push gitcvs.git >/dev/null &&
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs -Q update &&
- test ! -d test
+ mkdir test &&
+ echo >test/empty &&
+ git add test &&
+ git commit -q -m "Single Subdirectory" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs -Q update &&
+ test ! -d test
'
cd "$WORKDIR"
-test_expect_success 'cvs update (subdirectories)' \
- '(for dir in A A/B A/B/C A/D E; do
- mkdir $dir &&
- echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")" &&
- git add $dir || exit 1
- done) &&
- git commit -q -m "deep sub directory structure" &&
- git push gitcvs.git >/dev/null &&
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs -Q update -d &&
- (for dir in A A/B A/B/C A/D E; do
- filename="file_in_$(echo $dir|sed -e "s#/# #g")" &&
- if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" &&
- test_cmp "$dir/$filename" "../$dir/$filename"; then
- :
- else
- exit 1
- fi
- done)'
+test_expect_success 'cvs update (subdirectories)' '
+ (for dir in A A/B A/B/C A/D E; do
+ mkdir $dir &&
+ echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")" &&
+ git add $dir || exit 1
+ done) &&
+ git commit -q -m "deep sub directory structure" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs -Q update -d &&
+ (for dir in A A/B A/B/C A/D E; do
+ filename="file_in_$(echo $dir|sed -e "s#/# #g")" &&
+ if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" &&
+ test_cmp "$dir/$filename" "../$dir/$filename"; then
+ :
+ else
+ exit 1
+ fi
+ done)
+'
cd "$WORKDIR"
-test_expect_success 'cvs update (delete file)' \
- 'git rm testfile1 &&
- git commit -q -m "Remove testfile1" &&
- git push gitcvs.git >/dev/null &&
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs -Q update &&
- test -z "$(grep testfile1 CVS/Entries)" &&
- test ! -f testfile1'
+test_expect_success 'cvs update (delete file)' '
+ git rm testfile1 &&
+ git commit -q -m "Remove testfile1" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs -Q update &&
+ test -z "$(grep testfile1 CVS/Entries)" &&
+ test ! -f testfile1
+'
cd "$WORKDIR"
-test_expect_success 'cvs update (re-add deleted file)' \
- 'echo readded testfile >testfile1 &&
- git add testfile1 &&
- git commit -q -m "Re-Add testfile1" &&
- git push gitcvs.git >/dev/null &&
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs -Q update &&
- test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" &&
- test_cmp testfile1 ../testfile1'
+test_expect_success 'cvs update (re-add deleted file)' '
+ echo readded testfile >testfile1 &&
+ git add testfile1 &&
+ git commit -q -m "Re-Add testfile1" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs -Q update &&
+ test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" &&
+ test_cmp testfile1 ../testfile1
+'
cd "$WORKDIR"
-test_expect_success 'cvs update (merge)' \
- 'echo Line 0 >expected &&
- for i in 1 2 3 4 5 6 7
- do
- echo Line $i >>merge &&
- echo Line $i >>expected || return 1
- done &&
- echo Line 8 >>expected &&
- git add merge &&
- git commit -q -m "Merge test (pre-merge)" &&
- git push gitcvs.git >/dev/null &&
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs -Q update &&
- test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" &&
- test_cmp merge ../merge &&
- ( echo Line 0 && cat merge ) >merge.tmp &&
- mv merge.tmp merge &&
- cd "$WORKDIR" &&
- echo Line 8 >>merge &&
- git add merge &&
- git commit -q -m "Merge test (merge)" &&
- git push gitcvs.git >/dev/null &&
- cd cvswork &&
- sleep 1 && touch merge &&
- GIT_CONFIG="$git_config" cvs -Q update &&
- test_cmp merge ../expected'
+test_expect_success 'cvs update (merge)' '
+ echo Line 0 >expected &&
+ for i in 1 2 3 4 5 6 7
+ do
+ echo Line $i >>merge &&
+ echo Line $i >>expected || return 1
+ done &&
+ echo Line 8 >>expected &&
+ git add merge &&
+ git commit -q -m "Merge test (pre-merge)" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs -Q update &&
+ test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" &&
+ test_cmp merge ../merge &&
+ ( echo Line 0 && cat merge ) >merge.tmp &&
+ mv merge.tmp merge &&
+ cd "$WORKDIR" &&
+ echo Line 8 >>merge &&
+ git add merge &&
+ git commit -q -m "Merge test (merge)" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ sleep 1 && touch merge &&
+ GIT_CONFIG="$git_config" cvs -Q update &&
+ test_cmp merge ../expected
+'
cd "$WORKDIR"
@@ -418,55 +441,58 @@ do
echo Line $i >>expected.C
done
-test_expect_success 'cvs update (conflict merge)' \
- '( echo LINE 0 && cat merge ) >merge.tmp &&
- mv merge.tmp merge &&
- git add merge &&
- git commit -q -m "Merge test (conflict)" &&
- git push gitcvs.git >/dev/null &&
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs -Q update &&
- test_cmp merge ../expected.C'
+test_expect_success 'cvs update (conflict merge)' '
+ ( echo LINE 0 && cat merge ) >merge.tmp &&
+ mv merge.tmp merge &&
+ git add merge &&
+ git commit -q -m "Merge test (conflict)" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs -Q update &&
+ test_cmp merge ../expected.C
+'
cd "$WORKDIR"
-test_expect_success 'cvs update (-C)' \
- 'cd cvswork &&
- GIT_CONFIG="$git_config" cvs -Q update -C &&
- test_cmp merge ../merge'
+test_expect_success 'cvs update (-C)' '
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs -Q update -C &&
+ test_cmp merge ../merge
+'
cd "$WORKDIR"
-test_expect_success 'cvs update (merge no-op)' \
- 'echo Line 9 >>merge &&
- cp merge cvswork/merge &&
- git add merge &&
- git commit -q -m "Merge test (no-op)" &&
- git push gitcvs.git >/dev/null &&
- cd cvswork &&
- sleep 1 && touch merge &&
- GIT_CONFIG="$git_config" cvs -Q update &&
- test_cmp merge ../merge'
+test_expect_success 'cvs update (merge no-op)' '
+ echo Line 9 >>merge &&
+ cp merge cvswork/merge &&
+ git add merge &&
+ git commit -q -m "Merge test (no-op)" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ sleep 1 && touch merge &&
+ GIT_CONFIG="$git_config" cvs -Q update &&
+ test_cmp merge ../merge
+'
cd "$WORKDIR"
test_expect_success 'cvs update (-p)' '
- touch really-empty &&
- echo Line 1 > no-lf &&
- printf "Line 2" >> no-lf &&
- git add really-empty no-lf &&
- git commit -q -m "Update -p test" &&
- git push gitcvs.git >/dev/null &&
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs update &&
- for i in merge no-lf empty really-empty; do
- GIT_CONFIG="$git_config" cvs update -p "$i" >$i.out &&
- test_cmp $i.out ../$i || return 1
- done
+ touch really-empty &&
+ echo Line 1 > no-lf &&
+ printf "Line 2" >> no-lf &&
+ git add really-empty no-lf &&
+ git commit -q -m "Update -p test" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs update &&
+ for i in merge no-lf empty really-empty; do
+ GIT_CONFIG="$git_config" cvs update -p "$i" >$i.out &&
+ test_cmp $i.out ../$i || return 1
+ done
'
cd "$WORKDIR"
test_expect_success 'cvs update (module list supports packed refs)' '
- GIT_DIR="$SERVERDIR" git pack-refs --all &&
- GIT_CONFIG="$git_config" cvs -n up -d 2> out &&
- grep "cvs update: New directory \`main'\''" < out
+ GIT_DIR="$SERVERDIR" git pack-refs --all &&
+ GIT_CONFIG="$git_config" cvs -n up -d 2> out &&
+ grep "cvs update: New directory \`main'\''" < out
'
#------------
@@ -475,30 +501,30 @@ test_expect_success 'cvs update (module list supports packed refs)' '
cd "$WORKDIR"
test_expect_success 'cvs status' '
- mkdir status.dir &&
- echo Line > status.dir/status.file &&
- echo Line > status.file &&
- git add status.dir status.file &&
- git commit -q -m "Status test" &&
- git push gitcvs.git >/dev/null &&
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs update &&
- GIT_CONFIG="$git_config" cvs status | grep "^File: status.file" >../out &&
- test_line_count = 2 ../out
+ mkdir status.dir &&
+ echo Line > status.dir/status.file &&
+ echo Line > status.file &&
+ git add status.dir status.file &&
+ git commit -q -m "Status test" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs update &&
+ GIT_CONFIG="$git_config" cvs status | grep "^File: status.file" >../out &&
+ test_line_count = 2 ../out
'
cd "$WORKDIR"
test_expect_success 'cvs status (nonrecursive)' '
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs status -l | grep "^File: status.file" >../out &&
- test_line_count = 1 ../out
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs status -l | grep "^File: status.file" >../out &&
+ test_line_count = 1 ../out
'
cd "$WORKDIR"
test_expect_success 'cvs status (no subdirs in header)' '
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs status | grep ^File: >../out &&
- ! grep / <../out
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs status | grep ^File: >../out &&
+ ! grep / <../out
'
#------------
@@ -507,9 +533,9 @@ test_expect_success 'cvs status (no subdirs in header)' '
cd "$WORKDIR"
test_expect_success 'cvs co -c (shows module database)' '
- GIT_CONFIG="$git_config" cvs co -c > out &&
- grep "^main[ ][ ]*main$" <out &&
- ! grep -v "^main[ ][ ]*main$" <out
+ GIT_CONFIG="$git_config" cvs co -c > out &&
+ grep "^main[ ][ ]*main$" <out &&
+ ! grep -v "^main[ ][ ]*main$" <out
'
#------------
@@ -575,11 +601,11 @@ expectStat="$?"
cd "$WORKDIR"
test_expect_success 'cvs log' '
- cd cvswork &&
- test x"$expectStat" = x"0" &&
- GIT_CONFIG="$git_config" cvs log merge >../out &&
- sed -e "s%2[0-9][0-9][0-9]/[01][0-9]/[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]%__DATE__%" ../out > ../actual &&
- test_cmp ../expect ../actual
+ cd cvswork &&
+ test x"$expectStat" = x"0" &&
+ GIT_CONFIG="$git_config" cvs log merge >../out &&
+sed -e "s%2[0-9][0-9][0-9]/[01][0-9]/[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]%__DATE__%" ../out > ../actual &&
+ test_cmp ../expect ../actual
'
#------------
@@ -588,11 +614,11 @@ test_expect_success 'cvs log' '
cd "$WORKDIR"
test_expect_success 'cvs annotate' '
- cd cvswork &&
- GIT_CONFIG="$git_config" cvs annotate merge >../out &&
- sed -e "s/ .*//" ../out >../actual &&
- printf "1.%d\n" 3 1 1 1 1 1 1 1 2 4 >../expect &&
- test_cmp ../expect ../actual
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs annotate merge >../out &&
+ sed -e "s/ .*//" ../out >../actual &&
+ printf "1.%d\n" 3 1 1 1 1 1 1 1 2 4 >../expect &&
+ test_cmp ../expect ../actual
'
#------------
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 6e19ebc..b3864e2 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -542,8 +542,17 @@ test_config () {
config_dir=$1
shift
fi
- test_when_finished "test_unconfig ${config_dir:+-C '$config_dir'} '$1'" &&
- git ${config_dir:+-C "$config_dir"} config "$@"
+
+ # If --worktree is provided, use it to configure/unconfigure
+ is_worktree=
+ if test "$1" = --worktree
+ then
+ is_worktree=1
+ shift
+ fi
+
+ test_when_finished "test_unconfig ${config_dir:+-C '$config_dir'} ${is_worktree:+--worktree} '$1'" &&
+ git ${config_dir:+-C "$config_dir"} config ${is_worktree:+--worktree} "$@"
}
test_config_global () {
diff --git a/worktree.c b/worktree.c
index b5ee71c..c448fec 100644
--- a/worktree.c
+++ b/worktree.c
@@ -806,7 +806,7 @@ int init_worktree_config(struct repository *r)
* If the extension is already enabled, then we can skip the
* upgrade process.
*/
- if (repository_format_worktree_config)
+ if (r->repository_format_worktree_config)
return 0;
if ((res = git_config_set_gently("extensions.worktreeConfig", "true")))
return error(_("failed to set extensions.worktreeConfig setting"));
@@ -846,7 +846,7 @@ int init_worktree_config(struct repository *r)
* Ensure that we use worktree config for the remaining lifetime
* of the current process.
*/
- repository_format_worktree_config = 1;
+ r->repository_format_worktree_config = 1;
cleanup:
git_configset_clear(&cs);