]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
4 years agot4034: add tests showing problematic cpp tokenizations
Johannes Sixt [Fri, 8 Oct 2021 19:09:54 +0000 (19:09 +0000)] 
t4034: add tests showing problematic cpp tokenizations

The word regex is too loose and matches long streaks of characters
that should actually be separate tokens.  Add these problematic test
cases. Separate the lines with text that will remain identical in the
pre- and post-image so that the diff algorithm will not lump removals
and additions of consecutive lines together. This makes the expected
output easier to read.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot4034/cpp: actually test that operator tokens are not split
Johannes Sixt [Fri, 8 Oct 2021 19:09:53 +0000 (19:09 +0000)] 
t4034/cpp: actually test that operator tokens are not split

8d96e7288f2b (t4034: bulk verify builtin word regex sanity, 2010-12-18)
added many tests with the intent to verify that operators consisting of
more than one symbol are kept together. These are tested by probing a
transition from, e.g., a!=b to x!=y, which results in the word-diff

  [-a-]{+x+}!=[-b-]{+y+}

But that proves only that the letters and operators are separate tokens.
To prove that != is an unseparable token, we have to probe a transition
from, e.g., a=b to a!=b having a word-diff

  a[-=-]{+!=+}b

that proves that the ! is not separate from the =.

In the post-image, add to or remove from operators a character that
turns it into another valid operator.

Change the identifiers used around operators such that the diff
algorithm does not have an incentive to match, e.g., a<b in one spot
in the pre-image with a<b elsewhere in the post-image.

Adjust the expected output to match the new differences. Notice that
there are some undesirable tokenizations around e, ., and -.  This will
be addressed in a later change.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoAdd "test-tool dump-reftable" command.
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:15 +0000 (20:25 +0000)] 
Add "test-tool dump-reftable" command.

This command dumps individual tables or a stack of of tables.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: add dump utility
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:14 +0000 (20:25 +0000)] 
reftable: add dump utility

provide a command-line utility for inspecting individual tables, and
inspecting a complete ref database

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Helped-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: implement stack, a mutable database of reftable files.
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:13 +0000 (20:25 +0000)] 
reftable: implement stack, a mutable database of reftable files.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: implement refname validation
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:12 +0000 (20:25 +0000)] 
reftable: implement refname validation

The packed/loose format has restrictions on refnames: a and a/b cannot
coexist. This limitation does not apply to reftable per se, but must be
maintained for interoperability. This code adds validation routines to
abort transactions that are trying to add invalid names.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: add merged table view
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:11 +0000 (20:25 +0000)] 
reftable: add merged table view

This adds an abstract, read-only interface to the ref database.

This primitive is used to construct the read view of the ref database
(the read view is constructed by merging several *.ref files). It also
provides the mechanism to provide a unified view of the refs in the main
repository and the per-worktree refs.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: add a heap-based priority queue for reftable records
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:10 +0000 (20:25 +0000)] 
reftable: add a heap-based priority queue for reftable records

This is needed to create a merged view multiple reftables

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: reftable file level tests
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:09 +0000 (20:25 +0000)] 
reftable: reftable file level tests

With support for reading and writing files in place, we can construct files (in
memory) and attempt to read them back.

Because some sections of the format are optional (eg. indices, log entries), we
have to exercise this code using multiple sizes of input data

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: read reftable files
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:08 +0000 (20:25 +0000)] 
reftable: read reftable files

This supports reading a single reftable file.

The commit introduces an abstract iterator type, which captures the usecases
both of reading individual refs, and iterating over a segment of the ref
namespace.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: generic interface to tables
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:07 +0000 (20:25 +0000)] 
reftable: generic interface to tables

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: write reftable files
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:06 +0000 (20:25 +0000)] 
reftable: write reftable files

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: a generic binary tree implementation
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:05 +0000 (20:25 +0000)] 
reftable: a generic binary tree implementation

The reftable format includes support for an (OID => ref) map. This map can speed
up visibility and reachability checks. In particular, various operations along
the fetch/push path within Gerrit have ben sped up by using this structure.

The map is constructed with help of a binary tree. Object IDs are hashes, so
they are uniformly distributed. Hence, the tree does not attempt forced
rebalancing.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: reading/writing blocks
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:04 +0000 (20:25 +0000)] 
reftable: reading/writing blocks

The reftable format is structured as a sequence of block. Within a block,
records are prefix compressed, with an index of offsets for fully expand keys to
enable binary search within blocks.

This commit provides the logic to read and write these blocks.

Helped-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoProvide zlib's uncompress2 from compat/zlib-compat.c
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:03 +0000 (20:25 +0000)] 
Provide zlib's uncompress2 from compat/zlib-compat.c

This will be needed for reading reflog blocks in reftable.

Helped-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: (de)serialization for the polymorphic record type.
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:02 +0000 (20:25 +0000)] 
reftable: (de)serialization for the polymorphic record type.

The reftable format is structured as a sequence of blocks, and each block
contains a sequence of prefix-compressed key-value records. There are 4 types of
records, and they have similarities in how they must be handled. This is
achieved by introducing a polymorphic 'record' type that encapsulates ref, log,
index and object records.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: add blocksource, an abstraction for random access reads
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:01 +0000 (20:25 +0000)] 
reftable: add blocksource, an abstraction for random access reads

The reftable format is usually used with files for storage. However, we abstract
away this using the blocksource data structure. This has two advantages:

* log blocks are zlib compressed, and handling them is simplified if we can
  discard byte segments from within the block layer.

* for unittests, it is useful to read and write in-memory. The blocksource
  allows us to abstract the data away from on-disk files.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: utility functions
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:25:00 +0000 (20:25 +0000)] 
reftable: utility functions

This commit provides basic utility classes for the reftable library.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: add error related functionality
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:24:59 +0000 (20:24 +0000)] 
reftable: add error related functionality

The reftable/ directory is structured as a library, so it cannot
crash on misuse. Instead, it returns an error code.

In addition to signaling errors, the error code can be used to signal
conditions from lower levels of the library to be handled by higher
levels of the library. For example, in a transaction we might
legitimately write an empty reftable file, but in that case, we want to
shortcut the transaction.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreftable: add LICENSE
Han-Wen Nienhuys [Thu, 7 Oct 2021 20:24:58 +0000 (20:24 +0000)] 
reftable: add LICENSE

The objective of this code is to be usable as a C library, so it can be reused
in libgit2.

This is currently using a BSD license as it is the liberal license I could find,
but this could be changed to whatever fits the stated goal above.

This code is currently imported from github.com/hanwen/reftable. Once this code
lands in git.git, the C code will be removed from github.com/hanwen/reftable,
and the git.git code will be the source of truth.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotest-mergesort: use repeatable random numbers
René Scharfe [Fri, 8 Oct 2021 04:04:42 +0000 (06:04 +0200)] 
test-mergesort: use repeatable random numbers

Use MINSTD to generate pseudo-random numbers consistently instead of
using rand(3), whose output can vary from system to system, and reset
its seed before filling in the test values.  This gives repeatable
results across versions and systems, which simplifies sharing and
comparing of results between developers.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreset: rename is_missing to !is_in_reset_tree
Victoria Dye [Thu, 7 Oct 2021 21:15:31 +0000 (21:15 +0000)] 
reset: rename is_missing to !is_in_reset_tree

Rename and invert value of `is_missing` to `is_in_reset_tree` to make the
variable more descriptive of what it represents.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoread-cache: let verify_path() reject trailing dir separators again
René Scharfe [Thu, 7 Oct 2021 20:31:58 +0000 (22:31 +0200)] 
read-cache: let verify_path() reject trailing dir separators again

6e773527b6 (sparse-index: convert from full to sparse, 2021-03-30) made
verify_path() accept trailing directory separators for directories,
which is necessary for sparse directory entries.  This clemency causes
"git stash" to stumble over sub-repositories, though, and there may be
more unintended side-effects.

Avoid them by restoring the old verify_path() behavior and accepting
trailing directory separators only in places that are supposed to handle
sparse directory entries.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoread-cache: add verify_path_internal()
René Scharfe [Thu, 7 Oct 2021 20:31:44 +0000 (22:31 +0200)] 
read-cache: add verify_path_internal()

Turn verify_path() into an internal function that distinguishes between
valid paths and those with trailing directory separators and rename it
to verify_path_internal().  Provide a wrapper with the old behavior
under the old name.  No functional change intended.  The new function
will be used in the next patch.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot3905: show failure to ignore sub-repo
René Scharfe [Thu, 7 Oct 2021 20:31:01 +0000 (22:31 +0200)] 
t3905: show failure to ignore sub-repo

"git stash" used to ignore sub-repositories until 6e773527b6
(sparse-index: convert from full to sparse, 2021-03-30).  Add a test
that demonstrates this regression.

Reported-by: Robert Leftwich <robert@gitpod.io>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomerge: add missing strbuf_release()
Ævar Arnfjörð Bjarmason [Thu, 7 Oct 2021 10:01:37 +0000 (12:01 +0200)] 
merge: add missing strbuf_release()

We strbuf_reset() this "struct strbuf" in a loop earlier, but never
freed it. Plugs a memory leak that's been here ever since this code
got introduced in 1c7b76be7d6 (Build in merge, 2008-07-07).

This takes us from 68 failed tests in "t7600-merge.sh" to 59 under
SANITIZE=leak, and makes "t7604-merge-custom-message.sh" pass!

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agols-files: add missing string_list_clear()
Ævar Arnfjörð Bjarmason [Thu, 7 Oct 2021 10:01:36 +0000 (12:01 +0200)] 
ls-files: add missing string_list_clear()

Fix a memory leak that's been here ever since 72aeb18772d (clean.c,
ls-files.c: respect encapsulation of exclude_list_groups, 2013-01-16),
we dup'd the argument in option_parse_exclude(), but never freed the
string_list.

This makes almost all of t3001-ls-files-others-exclude.sh pass (it had
a lot of failures before). Let's mark it as passing with
TEST_PASSES_SANITIZE_LEAK=true, and then exclude the tests that still
failed with a !SANITIZE_LEAK prerequisite check until we fix those
leaks. We can still see the failed tests under
GIT_TEST_FAIL_PREREQS=true.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agols-files: fix a trivial dir_clear() leak
Ævar Arnfjörð Bjarmason [Thu, 7 Oct 2021 10:01:35 +0000 (12:01 +0200)] 
ls-files: fix a trivial dir_clear() leak

Fix an edge case that was missed when the dir_clear() call was added
in eceba532141 (dir: fix problematic API to avoid memory leaks,
2020-08-18), we need to also clean up when we're about to exit with
non-zero.

That commit says, on the topic of the dir_clear() API and UNLEAK():

    [...]two of them clearly thought about leaks since they had an
    UNLEAK(dir) directive, which to me suggests that the method to
    free the data was too unclear.

I think that 0e5bba53af7 (add UNLEAK annotation for reducing leak
false positives, 2017-09-08) which added the UNLEAK() makes it clear
that that wasn't the case, rather it was the desire to avoid the
complexity of freeing the memory at the end of the program.

This does add a bit of complexity, but I think it's worth it to just
fix these leaks when it's easy in built-ins. It allows them to serve
as canaries for underlying APIs that shouldn't be leaking, it
encourages us to make those freeing APIs nicer for all their users,
and it prevents other leaking regressions by being able to mark the
entire test as TEST_PASSES_SANITIZE_LEAK=true.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotests: fix test-oid-array leak, test in SANITIZE=leak
Ævar Arnfjörð Bjarmason [Thu, 7 Oct 2021 10:01:34 +0000 (12:01 +0200)] 
tests: fix test-oid-array leak, test in SANITIZE=leak

Fix a trivial memory leak present ever since 38d905bf585 (sha1-array:
add test-sha1-array and basic tests, 2014-10-01), now that that's
fixed we can test this under GIT_TEST_PASSING_SANITIZE_LEAK=true.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotests: fix a memory leak in test-oidtree.c
Ævar Arnfjörð Bjarmason [Thu, 7 Oct 2021 10:01:33 +0000 (12:01 +0200)] 
tests: fix a memory leak in test-oidtree.c

Fix a memory leak in t/helper/test-oidtree.c, we were not freeing the
"struct strbuf" we used for the stdin input we parsed. This leak has
been here ever since 92d8ed8ac10 (oidtree: a crit-bit tree for
odb_loose_cache, 2021-07-07).

Now that it's fixed we can declare that t0069-oidtree.sh will pass
under GIT_TEST_PASSING_SANITIZE_LEAK=true.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotests: fix a memory leak in test-parse-options.c
Ævar Arnfjörð Bjarmason [Thu, 7 Oct 2021 10:01:32 +0000 (12:01 +0200)] 
tests: fix a memory leak in test-parse-options.c

Fix a memory leak in t/helper/test-parse-options.c, we were not
freeing the allocated "struct string_list" or its items. Let's move
the declaration of the "list" variable into the cmd__parse_options()
and release it at the end.

In c8ba1639165 (parse-options: add OPT_STRING_LIST helper, 2011-06-09)
the "list" variable was added, and later on in
c8ba1639165 (parse-options: add OPT_STRING_LIST helper, 2011-06-09)
the "expect" was added.

The "list" variable was last touched in 2721ce21e43 (use string_list
initializer consistently, 2016-06-13), but it was still left at the
static scope, it's better to move it to the function for consistency.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotests: fix a memory leak in test-prio-queue.c
Ævar Arnfjörð Bjarmason [Thu, 7 Oct 2021 10:01:31 +0000 (12:01 +0200)] 
tests: fix a memory leak in test-prio-queue.c

Fix a memory leak in t/helper/test-prio-queue.c, the lack of freeing
the memory with clear_prio_queue() has been there ever since this code
was originally added in b4b594a3154 (prio-queue: priority queue of
pointers to structs, 2013-06-06).

By fixing this leak we can cleanly run t0009-prio-queue.sh under
SANITIZE=leak, so annotate it as such with
TEST_PASSES_SANITIZE_LEAK=true.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'ab/sanitize-leak-ci' into ab/mark-leak-free-tests-more
Junio C Hamano [Thu, 7 Oct 2021 22:28:38 +0000 (15:28 -0700)] 
Merge branch 'ab/sanitize-leak-ci' into ab/mark-leak-free-tests-more

* ab/sanitize-leak-ci:
  tests: add a test mode for SANITIZE=leak, run it in CI
  Makefile: add SANITIZE=leak flag to GIT-BUILD-OPTIONS

4 years agoMerge branch 'ab/sanitize-leak-ci' into ab/mark-leak-free-tests
Junio C Hamano [Thu, 7 Oct 2021 22:28:38 +0000 (15:28 -0700)] 
Merge branch 'ab/sanitize-leak-ci' into ab/mark-leak-free-tests

* ab/sanitize-leak-ci:
  tests: add a test mode for SANITIZE=leak, run it in CI
  Makefile: add SANITIZE=leak flag to GIT-BUILD-OPTIONS

4 years agounpack-trees: don't leak memory in verify_clean_subdirectory()
Ævar Arnfjörð Bjarmason [Thu, 7 Oct 2021 09:46:09 +0000 (11:46 +0200)] 
unpack-trees: don't leak memory in verify_clean_subdirectory()

Fix two different but related memory leaks in
verify_clean_subdirectory(). We leaked both the "pathbuf" if
read_directory() returned non-zero, and we never cleaned up our own
"struct dir_struct" either.

 * "pathbuf": When the read_directory() call followed by the
   free(pathbuf) was added in c81935348be (Fix switching to a branch
   with D/F when current branch has file D., 2007-03-15) we didn't
   bother to free() before we called die().

   But when this code was later libified in 203a2fe1170 (Allow callers
   of unpack_trees() to handle failure, 2008-02-07) we started to leak
   as we returned data to the caller. This fixes that memory leak,
   which can be observed under SANITIZE=leak with e.g. the
   "t1001-read-tree-m-2way.sh" test.

 * "struct dir_struct": We've leaked the dir_struct ever since this
   code was added back in c81935348be.

   When that commit was written there wasn't an equivalent of
   dir_clear(). Since it was added in 270be816049 (dir.c: provide
   clear_directory() for reclaiming dir_struct memory, 2013-01-06)
   we've omitted freeing the memory allocated here.

   This memory leak could also be observed under SANITIZE=leak and the
   "t1001-read-tree-m-2way.sh" test.

This makes all the test in "t1001-read-tree-m-2way.sh" pass under
"GIT_TEST_PASSING_SANITIZE_LEAK=true", we'd previously die in tests
25, 26 & 28.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'ab/sanitize-leak-ci' into ab/unpack-trees-leakfix
Junio C Hamano [Thu, 7 Oct 2021 22:28:38 +0000 (15:28 -0700)] 
Merge branch 'ab/sanitize-leak-ci' into ab/unpack-trees-leakfix

* ab/sanitize-leak-ci:
  tests: add a test mode for SANITIZE=leak, run it in CI
  Makefile: add SANITIZE=leak flag to GIT-BUILD-OPTIONS

4 years agosparse index: fix use-after-free bug in cache_tree_verify()
Phillip Wood [Thu, 7 Oct 2021 18:07:21 +0000 (18:07 +0000)] 
sparse index: fix use-after-free bug in cache_tree_verify()

In a sparse index it is possible for the tree that is being verified
to be freed while it is being verified. This happens when the index is
sparse but the cache tree is not and index_name_pos() looks up a path
from the cache tree that is a descendant of a sparse index entry. That
triggers a call to ensure_full_index() which frees the cache tree that
is being verified.  Carrying on trying to verify the tree after this
results in a use-after-free bug. Instead restart the verification if a
sparse index is converted to a full index. This bug is triggered by a
call to reset_head() in "git rebase --apply". Thanks to René Scharfe
and Derrick Stolee for their help analyzing the problem.

==74345==ERROR: AddressSanitizer: heap-use-after-free on address 0x606000001b20 at pc 0x557cbe82d3a2 bp 0x7ffdfee08090 sp 0x7ffdfee08080
READ of size 4 at 0x606000001b20 thread T0
    #0 0x557cbe82d3a1 in verify_one /home/phil/src/git/cache-tree.c:863
    #1 0x557cbe82ca9d in verify_one /home/phil/src/git/cache-tree.c:840
    #2 0x557cbe82ca9d in verify_one /home/phil/src/git/cache-tree.c:840
    #3 0x557cbe82ca9d in verify_one /home/phil/src/git/cache-tree.c:840
    #4 0x557cbe830a2b in cache_tree_verify /home/phil/src/git/cache-tree.c:910
    #5 0x557cbea53741 in write_locked_index /home/phil/src/git/read-cache.c:3250
    #6 0x557cbeab7fdd in reset_head /home/phil/src/git/reset.c:87
    #7 0x557cbe72147f in cmd_rebase builtin/rebase.c:2074
    #8 0x557cbe5bd151 in run_builtin /home/phil/src/git/git.c:461
    #9 0x557cbe5bd151 in handle_builtin /home/phil/src/git/git.c:714
    #10 0x557cbe5c0503 in run_argv /home/phil/src/git/git.c:781
    #11 0x557cbe5c0503 in cmd_main /home/phil/src/git/git.c:912
    #12 0x557cbe5bad28 in main /home/phil/src/git/common-main.c:52
    #13 0x7fdd4b82eb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x557cbe5bcb8d in _start (/home/phil/src/git/git+0x1b9b8d)

0x606000001b20 is located 0 bytes inside of 56-byte region [0x606000001b20,0x606000001b58)
freed by thread T0 here:
    #0 0x7fdd4bacff19 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:127
    #1 0x557cbe82af60 in cache_tree_free /home/phil/src/git/cache-tree.c:35
    #2 0x557cbe82aee5 in cache_tree_free /home/phil/src/git/cache-tree.c:31
    #3 0x557cbe82aee5 in cache_tree_free /home/phil/src/git/cache-tree.c:31
    #4 0x557cbe82aee5 in cache_tree_free /home/phil/src/git/cache-tree.c:31
    #5 0x557cbeb2557a in ensure_full_index /home/phil/src/git/sparse-index.c:310
    #6 0x557cbea45c4a in index_name_stage_pos /home/phil/src/git/read-cache.c:588
    #7 0x557cbe82ce37 in verify_one /home/phil/src/git/cache-tree.c:850
    #8 0x557cbe82ca9d in verify_one /home/phil/src/git/cache-tree.c:840
    #9 0x557cbe82ca9d in verify_one /home/phil/src/git/cache-tree.c:840
    #10 0x557cbe82ca9d in verify_one /home/phil/src/git/cache-tree.c:840
    #11 0x557cbe830a2b in cache_tree_verify /home/phil/src/git/cache-tree.c:910
    #12 0x557cbea53741 in write_locked_index /home/phil/src/git/read-cache.c:3250
    #13 0x557cbeab7fdd in reset_head /home/phil/src/git/reset.c:87
    #14 0x557cbe72147f in cmd_rebase builtin/rebase.c:2074
    #15 0x557cbe5bd151 in run_builtin /home/phil/src/git/git.c:461
    #16 0x557cbe5bd151 in handle_builtin /home/phil/src/git/git.c:714
    #17 0x557cbe5c0503 in run_argv /home/phil/src/git/git.c:781
    #18 0x557cbe5c0503 in cmd_main /home/phil/src/git/git.c:912
    #19 0x557cbe5bad28 in main /home/phil/src/git/common-main.c:52
    #20 0x7fdd4b82eb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

previously allocated by thread T0 here:
    #0 0x7fdd4bad0459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x557cbebc1807 in xcalloc /home/phil/src/git/wrapper.c:140
    #2 0x557cbe82b7d8 in cache_tree /home/phil/src/git/cache-tree.c:17
    #3 0x557cbe82b7d8 in prime_cache_tree_rec /home/phil/src/git/cache-tree.c:763
    #4 0x557cbe82b837 in prime_cache_tree_rec /home/phil/src/git/cache-tree.c:764
    #5 0x557cbe82b837 in prime_cache_tree_rec /home/phil/src/git/cache-tree.c:764
    #6 0x557cbe8304e1 in prime_cache_tree /home/phil/src/git/cache-tree.c:779
    #7 0x557cbeab7fa7 in reset_head /home/phil/src/git/reset.c:85
    #8 0x557cbe72147f in cmd_rebase builtin/rebase.c:2074
    #9 0x557cbe5bd151 in run_builtin /home/phil/src/git/git.c:461
    #10 0x557cbe5bd151 in handle_builtin /home/phil/src/git/git.c:714
    #11 0x557cbe5c0503 in run_argv /home/phil/src/git/git.c:781
    #12 0x557cbe5c0503 in cmd_main /home/phil/src/git/git.c:912
    #13 0x557cbe5bad28 in main /home/phil/src/git/common-main.c:52
    #14 0x7fdd4b82eb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotest-read-midx: fix leak of bitmap_index struct
Jeff King [Thu, 7 Oct 2021 02:24:40 +0000 (22:24 -0400)] 
test-read-midx: fix leak of bitmap_index struct

In read_midx_preferred_pack(), we open the bitmap index but never free
it. This isn't a big deal since this is just a test helper, and we exit
immediately after, but since we're trying to keep our leak-checking tidy
now, it's worth fixing.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoThe eleventh batch
Junio C Hamano [Wed, 6 Oct 2021 20:40:32 +0000 (13:40 -0700)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'ab/retire-decl-of-missing-unused-funcs'
Junio C Hamano [Wed, 6 Oct 2021 20:40:14 +0000 (13:40 -0700)] 
Merge branch 'ab/retire-decl-of-missing-unused-funcs'

Remove external declaration of functions that no longer exist.

* ab/retire-decl-of-missing-unused-funcs:
  config.h: remove unused git_config_get_untracked_cache() declaration
  log-tree.h: remove unused function declarations
  grep.h: remove unused grep_threads_ok() declaration
  builtin.h: remove cmd_tar_tree() declaration

4 years agoMerge branch 'lh/systemd-timers'
Junio C Hamano [Wed, 6 Oct 2021 20:40:13 +0000 (13:40 -0700)] 
Merge branch 'lh/systemd-timers'

Testfix.

* lh/systemd-timers:
  maintenance: fix test t7900-maintenance.sh

4 years agoMerge branch 'ab/retire-string-list-init'
Junio C Hamano [Wed, 6 Oct 2021 20:40:13 +0000 (13:40 -0700)] 
Merge branch 'ab/retire-string-list-init'

Code cleanup.

* ab/retire-string-list-init:
  string-list.[ch]: remove string_list_init() compatibility function

4 years agoMerge branch 'ab/retire-refs-unused-funcs'
Junio C Hamano [Wed, 6 Oct 2021 20:40:13 +0000 (13:40 -0700)] 
Merge branch 'ab/retire-refs-unused-funcs'

Code cleanup.

* ab/retire-refs-unused-funcs:
  refs/ref-cache.[ch]: remove "incomplete" from create_dir_entry()
  refs/ref-cache.c: remove "mkdir" parameter from find_containing_dir()
  refs/ref-cache.[ch]: remove unused add_ref_entry()
  refs/ref-cache.[ch]: remove unused remove_entry_from_dir()
  refs.[ch]: remove unused ref_storage_backend_exists()

4 years agoMerge branch 'os/status-docfix'
Junio C Hamano [Wed, 6 Oct 2021 20:40:13 +0000 (13:40 -0700)] 
Merge branch 'os/status-docfix'

Docfix.

* os/status-docfix:
  doc: fix capitalization in "git status --porcelain=v2" description

4 years agoMerge branch 'ws/refer-to-forkpoint-config-in-rebase-doc'
Junio C Hamano [Wed, 6 Oct 2021 20:40:12 +0000 (13:40 -0700)] 
Merge branch 'ws/refer-to-forkpoint-config-in-rebase-doc'

Doc update.

* ws/refer-to-forkpoint-config-in-rebase-doc:
  Document `rebase.forkpoint` in rebase man page

4 years agoMerge branch 'gc/doc-first-contribution-reroll'
Junio C Hamano [Wed, 6 Oct 2021 20:40:12 +0000 (13:40 -0700)] 
Merge branch 'gc/doc-first-contribution-reroll'

Doc update.

* gc/doc-first-contribution-reroll:
  MyFirstContribution: Document --range-diff option when writing v2

4 years agoMerge branch 'pw/rebase-reread-todo-after-editing'
Junio C Hamano [Wed, 6 Oct 2021 20:40:12 +0000 (13:40 -0700)] 
Merge branch 'pw/rebase-reread-todo-after-editing'

The code to re-read the edited todo list in "git rebase -i" was
made more robust.

* pw/rebase-reread-todo-after-editing:
  rebase: fix todo-list rereading
  sequencer.c: factor out a function

4 years agoMerge branch 'ew/midx-doc-update'
Junio C Hamano [Wed, 6 Oct 2021 20:40:12 +0000 (13:40 -0700)] 
Merge branch 'ew/midx-doc-update'

Doc tweak.

* ew/midx-doc-update:
  doc/technical: update note about core.multiPackIndex

4 years agoMerge branch 'ab/repo-settings-cleanup'
Junio C Hamano [Wed, 6 Oct 2021 20:40:11 +0000 (13:40 -0700)] 
Merge branch 'ab/repo-settings-cleanup'

Code cleanup.

* ab/repo-settings-cleanup:
  repository.h: don't use a mix of int and bitfields
  repo-settings.c: simplify the setup
  read-cache & fetch-negotiator: check "enum" values in switch()
  environment.c: remove test-specific "ignore_untracked..." variable
  wrapper.c: add x{un,}setenv(), and use xsetenv() in environment.c

4 years agoMerge branch 'jk/grep-haystack-is-read-only'
Junio C Hamano [Wed, 6 Oct 2021 20:40:11 +0000 (13:40 -0700)] 
Merge branch 'jk/grep-haystack-is-read-only'

Code clean-up in the "grep" machinery.

* jk/grep-haystack-is-read-only:
  grep: store grep_source buffer as const
  grep: mark "haystack" buffers as const
  grep: stop modifying buffer in grep_source_1()
  grep: stop modifying buffer in show_line()
  grep: stop modifying buffer in strip_timestamp

4 years agoMerge branch 'tb/commit-graph-usage-fix'
Junio C Hamano [Wed, 6 Oct 2021 20:40:11 +0000 (13:40 -0700)] 
Merge branch 'tb/commit-graph-usage-fix'

Regression in "git commit-graph" command line parsing has been
corrected.

* tb/commit-graph-usage-fix:
  builtin/multi-pack-index.c: disable top-level --[no-]progress
  builtin/commit-graph.c: don't accept common --[no-]progress

4 years agoMerge branch 'pw/rebase-of-a-tag-fix'
Junio C Hamano [Wed, 6 Oct 2021 20:40:11 +0000 (13:40 -0700)] 
Merge branch 'pw/rebase-of-a-tag-fix'

"git rebase <upstream> <tag>" failed when aborted in the middle, as
it mistakenly tried to write the tag object instead of peeling it
to HEAD.

* pw/rebase-of-a-tag-fix:
  rebase: dereference tags
  rebase: use lookup_commit_reference_by_name()
  rebase: use our standard error return value
  t3407: rework rebase --quit tests
  t3407: strengthen rebase --abort tests
  t3407: use test_path_is_missing
  t3407: rename a variable
  t3407: use test_cmp_rev
  t3407: use test_commit
  t3407: run tests in $TEST_DIRECTORY

4 years agoMerge branch 'jt/add-submodule-odb-clean-up'
Junio C Hamano [Wed, 6 Oct 2021 20:40:10 +0000 (13:40 -0700)] 
Merge branch 'jt/add-submodule-odb-clean-up'

More code paths that use the hack to add submodule's object
database to the set of alternate object store have been cleaned up.

* jt/add-submodule-odb-clean-up:
  revision: remove "submodule" from opt struct
  repository: support unabsorbed in repo_submodule_init
  submodule: remove unnecessary unabsorbed fallback

4 years agoeditor: save and reset terminal after calling EDITOR
Carlo Marcelo Arenas Belón [Tue, 5 Oct 2021 07:46:48 +0000 (00:46 -0700)] 
editor: save and reset terminal after calling EDITOR

When EDITOR is invoked to modify a commit message, it will likely
change the terminal settings, and if it misbehaves will leave the
terminal output damaged as shown in a recent report from Windows
Terminal[1]

Instead use the functions provided by compat/terminal to save the
settings and recover safely.

[1] https://github.com/microsoft/terminal/issues/9359

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoterminal: teach git how to save/restore its terminal settings
Carlo Marcelo Arenas Belón [Tue, 5 Oct 2021 07:46:47 +0000 (00:46 -0700)] 
terminal: teach git how to save/restore its terminal settings

Currently, git will share its console with all its children (unless
they create their own), and is therefore possible that any of them
that might change the settings for it could affect its operations once
completed.

Refactor the platform specific functionality to save the terminal
settings and expand it to also do so for the output handler.

This will allow for the state of the terminal to be saved and
restored around a child that might misbehave (ex vi) which will
be implemented next.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot/perf/perf-lib.sh: remove test_times.* at the end test_perf_()
Jeff Hostetler [Mon, 4 Oct 2021 22:29:03 +0000 (22:29 +0000)] 
t/perf/perf-lib.sh: remove test_times.* at the end test_perf_()

Teach test_perf_() to remove the temporary test_times.* files
at the end of each test.

test_perf_() runs a particular GIT_PERF_REPEAT_COUNT times and creates
./test_times.[123...].  It then uses a perl script to find the minimum
over "./test_times.*" (note the wildcard) and writes that time to
"test-results/<testname>.<testnumber>.result".

If the repeat count is changed during the pXXXX test script, stale
test_times.* files (from previous steps) may be included in the min()
computation.  For example:

...
GIT_PERF_REPEAT_COUNT=3 \
test_perf "status" "
git status
"

GIT_PERF_REPEAT_COUNT=1 \
test_perf "checkout other" "
git checkout other
"
...

The time reported in the summary for "XXXX.2 checkout other" would
be "min( checkout[1], status[2], status[3] )".

We prevent that error by removing the test_times.* files at the end of
each test.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot/perf/aggregate.perl: tolerate leading spaces
Taylor Blau [Sun, 3 Oct 2021 05:14:49 +0000 (01:14 -0400)] 
t/perf/aggregate.perl: tolerate leading spaces

When using `test_size` with `wc -c`, users on certain platforms can run
into issues when `wc` emits leading space characters in its output,
which confuses get_times.

Callers could switch to use test_file_size instead of `wc -c` (the
former never prints leading space characters, so will always work with
test_size regardless of platform), but this is an easy enough spot to
miss that we should teach get_times to be more tolerant of the input it
accepts.

Teach get_times to do just that by stripping any leading space
characters.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoDocumentation/git-status: mention how to detect copies
Johannes Altmanninger [Mon, 4 Oct 2021 19:00:50 +0000 (21:00 +0200)] 
Documentation/git-status: mention how to detect copies

The man page documents that git-status can find copies, but does not
mention how. Whereas git-diff has command line options -C, there is
no such option for git-status - it will only detect copies when the
"status.renames" config option is "copies" or "copy". Document that
in git-status.txt because this has confused me and others[1].

[1]: https://www.reddit.com/r/git/comments/ppc2l9/how_to_get_a_file_with_copied_status/

Signed-off-by: Johannes Altmanninger <aclopte@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoDocumentation/git-status: document porcelain status T (typechange)
Johannes Altmanninger [Mon, 4 Oct 2021 19:00:49 +0000 (21:00 +0200)] 
Documentation/git-status: document porcelain status T (typechange)

As reported in [1], T is missing from the description of porcelain
status letters in git-status(1) (whereas T *is* documented in
git-diff-files(1) and friends). Document T right after M (modified)
because the two are very similar.

[1] https://github.com/fish-shell/fish-shell/issues/8311

Signed-off-by: Johannes Altmanninger <aclopte@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoDocumentation/diff-format: state in which cases porcelain status is T
Johannes Altmanninger [Mon, 4 Oct 2021 19:00:48 +0000 (21:00 +0200)] 
Documentation/diff-format: state in which cases porcelain status is T

Porcelain status letter T is documented as "type of the file", which
is technically correct but not enough information for users that are
not so familiar with this term from systems programming. In particular,
given that the only supported file types are "regular file", "symbolic
link" and "submodule", the term "file type" is surely opaque to the
many(?) users who are not aware that symbolic links can be tracked -
I thought that a "chmod +x" could cause the T status (wrong, it's M).

Explicitly document the three file types so users know if/how they
want to handle this.

Signed-off-by: Johannes Altmanninger <aclopte@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoDocumentation/git-status: remove impossible porcelain status DR and DC
Johannes Altmanninger [Mon, 4 Oct 2021 19:00:47 +0000 (21:00 +0200)] 
Documentation/git-status: remove impossible porcelain status DR and DC

Commit 176ea74793 ("wt-status.c: handle worktree renames", 2017-12-27)
made a porcelain status like .R or .C possible. They occur only when
the source file is added to the index and the destination file is
added with --intent-to-add.

They also documented DR, but that status is impossible.  The index
change D means that the source file does not exist in the index.
The worktree change R/C states that the file has been renamed/copied
since the index, but that's impossible if it did not exist there.

Reported-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Johannes Altmanninger <aclopte@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agop3400: stop using tac(1)
René Scharfe [Sat, 2 Oct 2021 17:44:14 +0000 (19:44 +0200)] 
p3400: stop using tac(1)

b3dfeebb92 (rebase: avoid computing unnecessary patch IDs, 2016-07-29)
added a perf test that calls tac(1) from GNU core utilities.  Support
systems without it by reversing the generated list using sort -nr
instead.  sort(1) with options -n and -r is already used in other tests.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoThe tenth batch
Junio C Hamano [Mon, 4 Oct 2021 04:49:43 +0000 (21:49 -0700)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'ah/connect-parse-feature-v0-fix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:21 +0000 (21:49 -0700)] 
Merge branch 'ah/connect-parse-feature-v0-fix'

Protocol v0 clients can get stuck parsing a malformed feature line.

* ah/connect-parse-feature-v0-fix:
  connect: also update offset for features without values

4 years agoMerge branch 'ab/make-compdb-fix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:21 +0000 (21:49 -0700)] 
Merge branch 'ab/make-compdb-fix'

Build update.

* ab/make-compdb-fix:
  Makefile: pass -Wno-pendantic under GENERATE_COMPILATION_DATABASE=yes

4 years agoMerge branch 'bs/difftool-msg-tweak'
Junio C Hamano [Mon, 4 Oct 2021 04:49:21 +0000 (21:49 -0700)] 
Merge branch 'bs/difftool-msg-tweak'

Message tweak.

* bs/difftool-msg-tweak:
  difftool: fix word spacing in the usage strings

4 years agoMerge branch 'rs/close-pack-leakfix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:20 +0000 (21:49 -0700)] 
Merge branch 'rs/close-pack-leakfix'

Leakfix.

* rs/close-pack-leakfix:
  packfile: release bad_objects in close_pack()

4 years agoMerge branch 'ab/bundle-remove-verbose-option'
Junio C Hamano [Mon, 4 Oct 2021 04:49:20 +0000 (21:49 -0700)] 
Merge branch 'ab/bundle-remove-verbose-option'

Doc update.

* ab/bundle-remove-verbose-option:
  bundle: remove ignored & undocumented "--verbose" flag

4 years agoMerge branch 'ab/auto-depend-with-pedantic'
Junio C Hamano [Mon, 4 Oct 2021 04:49:20 +0000 (21:49 -0700)] 
Merge branch 'ab/auto-depend-with-pedantic'

Improve build procedure for developers.

* ab/auto-depend-with-pedantic:
  Makefile: make COMPUTE_HEADER_DEPENDENCIES=auto work with DEVOPTS=pedantic

4 years agoMerge branch 'ab/make-clean-depend-dirs'
Junio C Hamano [Mon, 4 Oct 2021 04:49:19 +0000 (21:49 -0700)] 
Merge branch 'ab/make-clean-depend-dirs'

"make clean" has been updated to remove leftover .depend/
directories, even when it is not told to use them to compute header
dependencies.

* ab/make-clean-depend-dirs:
  Makefile: clean .depend dirs under COMPUTE_HEADER_DEPENDENCIES != yes

4 years agoMerge branch 'ds/perf-test-built-path-fix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:19 +0000 (21:49 -0700)] 
Merge branch 'ds/perf-test-built-path-fix'

Perf test fix.

* ds/perf-test-built-path-fix:
  t/perf/run: fix bin-wrappers computation

4 years agoMerge branch 'jk/http-redact-fix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:19 +0000 (21:49 -0700)] 
Merge branch 'jk/http-redact-fix'

Sensitive data in the HTTP trace were supposed to be redacted, but
we failed to do so in HTTP/2 requests.

* jk/http-redact-fix:
  http: match headers case-insensitively when redacting

4 years agoMerge branch 'bs/ls-files-opt-help-text-update'
Junio C Hamano [Mon, 4 Oct 2021 04:49:19 +0000 (21:49 -0700)] 
Merge branch 'bs/ls-files-opt-help-text-update'

Help text for "ls-files" options have been updated.

* bs/ls-files-opt-help-text-update:
  ls-files: use imperative mood for -X and -z option description

4 years agoMerge branch 'da/difftool-dir-diff-symlink-fix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:18 +0000 (21:49 -0700)] 
Merge branch 'da/difftool-dir-diff-symlink-fix'

"git difftool --dir-diff" mishandled symbolic links.

* da/difftool-dir-diff-symlink-fix:
  difftool: fix symlink-file writing in dir-diff mode

4 years agoMerge branch 'hn/refs-errno-cleanup'
Junio C Hamano [Mon, 4 Oct 2021 04:49:18 +0000 (21:49 -0700)] 
Merge branch 'hn/refs-errno-cleanup'

Futz with the way 'errno' is relied on in the refs API to carry the
failure modes up the call chain.

* hn/refs-errno-cleanup:
  refs: make errno output explicit for read_raw_ref_fn
  refs/files-backend: stop setting errno from lock_ref_oid_basic
  refs: remove EINVAL errno output from specification of read_raw_ref_fn
  refs file backend: move raceproof_create_file() here

4 years agoMerge branch 'ab/refs-files-cleanup'
Junio C Hamano [Mon, 4 Oct 2021 04:49:18 +0000 (21:49 -0700)] 
Merge branch 'ab/refs-files-cleanup'

Continued work on top of the hn/refs-errno-cleanup topic.

* ab/refs-files-cleanup:
  refs/files: remove unused "errno != ENOTDIR" condition
  refs/files: remove unused "errno == EISDIR" code
  refs/files: remove unused "oid" in lock_ref_oid_basic()
  refs API: remove OID argument to reflog_expire()
  reflog expire: don't lock reflogs using previously seen OID
  refs/files: add a comment about refs_reflog_exists() call
  refs: make repo_dwim_log() accept a NULL oid
  refs/debug: re-indent argument list for "prepare"
  refs/files: remove unused "skip" in lock_raw_ref() too
  refs/files: remove unused "extras/skip" in lock_ref_oid_basic()
  refs: drop unused "flags" parameter to lock_ref_oid_basic()
  refs/files: remove unused REF_DELETING in lock_ref_oid_basic()
  refs/packet: add missing BUG() invocations to reflog callbacks

4 years agoMerge branch 'cb/cvsserver'
Junio C Hamano [Mon, 4 Oct 2021 04:49:17 +0000 (21:49 -0700)] 
Merge branch 'cb/cvsserver'

"git cvsserver" had a long-standing bug in its authentication code,
which has finally been corrected (it is unclear and is a separate
question if anybody is seriously using it, though).

* cb/cvsserver:
  Documentation: cleanup git-cvsserver
  git-cvsserver: protect against NULL in crypt(3)
  git-cvsserver: use crypt correctly to compare password hashes

4 years agoMerge branch 'jx/ci-l10n'
Junio C Hamano [Mon, 4 Oct 2021 04:49:17 +0000 (21:49 -0700)] 
Merge branch 'jx/ci-l10n'

CI help for l10n.

* jx/ci-l10n:
  ci: new github-action for git-l10n code review

4 years agoMerge branch 'jk/clone-unborn-head-in-bare'
Junio C Hamano [Mon, 4 Oct 2021 04:49:17 +0000 (21:49 -0700)] 
Merge branch 'jk/clone-unborn-head-in-bare'

"git clone" from a repository whose HEAD is unborn into a bare
repository didn't follow the branch name the other side used, which
is corrected.

* jk/clone-unborn-head-in-bare:
  clone: handle unborn branch in bare repos

4 years agoMerge branch 'en/stash-df-fix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:16 +0000 (21:49 -0700)] 
Merge branch 'en/stash-df-fix'

"git stash", where the tentative change involves changing a
directory to a file (or vice versa), was confused, which has been
corrected.

* en/stash-df-fix:
  stash: restore untracked files AFTER restoring tracked files
  stash: avoid feeding directories to update-index
  t3903: document a pair of directory/file bugs

4 years agobuiltin/repack.c: pass `--refs-snapshot` when writing bitmaps
Taylor Blau [Fri, 1 Oct 2021 22:38:10 +0000 (18:38 -0400)] 
builtin/repack.c: pass `--refs-snapshot` when writing bitmaps

To prevent the race described in an earlier patch, generate and pass a
reference snapshot to the multi-pack bitmap code, if we are writing one
from `git repack`.

This patch is mostly limited to creating a temporary file, and then
calling for_each_ref(). Except we try to minimize duplicates, since
doing so can drastically reduce the size in network-of-forks style
repositories. In the kernel's fork network (the repository containing
all objects from the kernel and all its forks), deduplicating the
references drops the snapshot size from 934 MB to just 12 MB.

But since we're handling duplicates in this way, we have to make sure
that we preferred references (those listed in pack.preferBitmapTips)
before non-preferred ones (to avoid recording an object which is pointed
at by a preferred tip as non-preferred).

We accomplish this by doing separate passes over the references: first
visiting each prefix in pack.preferBitmapTips, and then over the rest of
the references.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agobisect--helper: add space between colon and following sentence
Bagas Sanjaya [Fri, 1 Oct 2021 11:47:45 +0000 (18:47 +0700)] 
bisect--helper: add space between colon and following sentence

Add missing space between colon sentence (`bisect-run failed:`) and the
following sentence (`git bisect--helper --bisect-state`).

Fixes: d1bbbe45df (bisect--helper: reimplement `bisect_run` shell
function in C, 2021-09-13)
Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoblame: describe default output format
Bagas Sanjaya [Fri, 1 Oct 2021 11:37:25 +0000 (18:37 +0700)] 
blame: describe default output format

While there is descriptions for porcelain and incremental output
formats, the default format isn't described. Describe that format for
the sake of completeness.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofsck: report invalid object type-path combinations
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:53 +0000 (11:16 +0200)] 
fsck: report invalid object type-path combinations

Improve the error that's emitted in cases where we find a loose object
we parse, but which isn't at the location we expect it to be.

Before this change we'd prefix the error with a not-a-OID derived from
the path at which the object was found, due to an emergent behavior in
how we'd end up with an "OID" in these codepaths.

Now we'll instead say what object we hashed, and what path it was
found at. Before this patch series e.g.:

    $ git hash-object --stdin -w -t blob </dev/null
    e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
    $ mv objects/e6/ objects/e7

Would emit ("[...]" used to abbreviate the OIDs):

    git fsck
    error: hash mismatch for ./objects/e7/9d[...] (expected e79d[...])
    error: e79d[...]: object corrupt or missing: ./objects/e7/9d[...]

Now we'll instead emit:

    error: e69d[...]: hash-path mismatch, found at: ./objects/e7/9d[...]

Furthermore, we'll do the right thing when the object type and its
location are bad. I.e. this case:

    $ git hash-object --stdin -w -t garbage --literally </dev/null
    8315a83d2acc4c174aed59430f9a9c4ed926440f
    $ mv objects/83 objects/84

As noted in an earlier commits we'd simply die early in those cases,
until preceding commits fixed the hard die on invalid object type:

    $ git fsck
    fatal: invalid object type

Now we'll instead emit sensible error messages:

    $ git fsck
    error: 8315[...]: hash-path mismatch, found at: ./objects/84/15[...]
    error: 8315[...]: object is of unknown type 'garbage': ./objects/84/15[...]

In both fsck.c and object-file.c we're using null_oid as a sentinel
value for checking whether we got far enough to be certain that the
issue was indeed this OID mismatch.

We need to add the "object corrupt or missing" special-case to deal
with cases where read_loose_object() will return an error before
completing check_object_signature(), e.g. if we have an error in
unpack_loose_rest() because we find garbage after the valid gzip
content:

    $ git hash-object --stdin -w -t blob </dev/null
    e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
    $ chmod 755 objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
    $ echo garbage >>objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
    $ git fsck
    error: garbage at end of loose object 'e69d[...]'
    error: unable to unpack contents of ./objects/e6/9d[...]
    error: e69d[...]: object corrupt or missing: ./objects/e6/9d[...]

There is currently some weird messaging in the edge case when the two
are combined, i.e. because we're not explicitly passing along an error
state about this specific scenario from check_stream_oid() via
read_loose_object() we'll end up printing the null OID if an object is
of an unknown type *and* it can't be unpacked by zlib, e.g.:

    $ git hash-object --stdin -w -t garbage --literally </dev/null
    8315a83d2acc4c174aed59430f9a9c4ed926440f
    $ chmod 755 objects/83/15a83d2acc4c174aed59430f9a9c4ed926440f
    $ echo garbage >>objects/83/15a83d2acc4c174aed59430f9a9c4ed926440f
    $ /usr/bin/git fsck
    fatal: invalid object type
    $ ~/g/git/git fsck
    error: garbage at end of loose object '8315a83d2acc4c174aed59430f9a9c4ed926440f'
    error: unable to unpack contents of ./objects/83/15a83d2acc4c174aed59430f9a9c4ed926440f
    error: 8315a83d2acc4c174aed59430f9a9c4ed926440f: object corrupt or missing: ./objects/83/15a83d2acc4c174aed59430f9a9c4ed926440f
    error: 0000000000000000000000000000000000000000: object is of unknown type 'garbage': ./objects/83/15a83d2acc4c174aed59430f9a9c4ed926440f
    [...]

I think it's OK to leave that for future improvements, which would
involve enum-ifying more error state as we've done with "enum
unpack_loose_header_result" in preceding commits. In these
increasingly more obscure cases the worst that can happen is that
we'll get slightly nonsensical or inapplicable error messages.

There's other such potential edge cases, all of which might produce
some confusing messaging, but still be handled correctly as far as
passing along errors goes. E.g. if check_object_signature() returns
and oideq(real_oid, null_oid()) is true, which could happen if it
returns -1 due to the read_istream() call having failed.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofsck: don't hard die on invalid object types
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:52 +0000 (11:16 +0200)] 
fsck: don't hard die on invalid object types

Change the error fsck emits on invalid object types, such as:

    $ git hash-object --stdin -w -t garbage --literally </dev/null
    <OID>

From the very ungraceful error of:

    $ git fsck
    fatal: invalid object type
    $

To:

    $ git fsck
    error: <OID>: object is of unknown type 'garbage': <OID_PATH>
    [ other fsck output ]

We'll still exit with non-zero, but now we'll finish the rest of the
traversal. The tests that's being added here asserts that we'll still
complain about other fsck issues (e.g. an unrelated dangling blob).

To do this we need to pass down the "OBJECT_INFO_ALLOW_UNKNOWN_TYPE"
flag from read_loose_object() through to parse_loose_header(). Since
the read_loose_object() function is only used in builtin/fsck.c we can
simply change it to accept a "struct object_info" (which contains the
OBJECT_INFO_ALLOW_UNKNOWN_TYPE in its flags). See
f6371f92104 (sha1_file: add read_loose_object() function, 2017-01-13)
for the introduction of read_loose_object().

Since we'll need a "struct strbuf" to hold the "type_name" let's pass
it to the for_each_loose_file_in_objdir() callback to avoid allocating
a new one for each loose object in the iteration. It also makes the
memory management simpler than sticking it in fsck_loose() itself, as
we'll only need to strbuf_reset() it, with no need to do a
strbuf_release() before each "return".

Before this commit we'd never check the "type" if read_loose_object()
failed, but now we do. We therefore need to initialize it to OBJ_NONE
to be able to tell the difference between e.g. its
unpack_loose_header() having failed, and us getting past that and into
parse_loose_header().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoobject-file.c: stop dying in parse_loose_header()
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:51 +0000 (11:16 +0200)] 
object-file.c: stop dying in parse_loose_header()

Make parse_loose_header() return error codes and data instead of
invoking die() by itself.

For now we'll move the relevant die() call to loose_object_info() and
read_loose_object() to keep this change smaller. In a subsequent
commit we'll make read_loose_object() return an error code instead of
dying. We should also address the "allow_unknown" case (should be
moved to builtin/cat-file.c), but for now I'll be leaving it.

For making parse_loose_header() not die() change its prototype to
accept a "struct object_info *" instead of the "unsigned long *sizep"
it accepted before. Its callers can now check the populated populated
"oi->typep".

Because of this we don't need to pass in the "unsigned int flags"
which we used for OBJECT_INFO_ALLOW_UNKNOWN_TYPE, we can instead do
that check in loose_object_info().

This also refactors some confusing control flow around the "status"
variable. In some cases we set it to the return value of "error()",
i.e. -1, and later checked if "status < 0" was true.

Since 93cff9a978e (sha1_loose_object_info: return error for corrupted
objects, 2017-04-01) the return value of loose_object_info() (then
named sha1_loose_object_info()) had been a "status" variable that be
any negative value, as we were expecting to return the "enum
object_type".

The only negative type happens to be OBJ_BAD, but the code still
assumed that more might be added. This was then used later in
e.g. c84a1f3ed4d (sha1_file: refactor read_object, 2017-06-21). Now
that parse_loose_header() will return 0 on success instead of the
type (which it'll stick into the "struct object_info") we don't need
to conflate these two cases in its callers.

Since parse_loose_header() doesn't need to return an arbitrary
"status" we only need to treat its "ret < 0" specially, but can
idiomatically overwrite it with our own error() return. This along
with having made unpack_loose_header() return an "enum
unpack_loose_header_result" in an earlier commit means that we can
move the previously nested if/else cases mostly into the "ULHR_OK"
branch of the "switch" statement.

We should be less silent if we reach that "status = -1" branch, which
happens if we've got trailing garbage in loose objects, see
f6371f92104 (sha1_file: add read_loose_object() function, 2017-01-13)
for a better way to handle it. For now let's punt on it, a subsequent
commit will address that edge case.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoobject-file.c: return ULHR_TOO_LONG on "header too long"
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:50 +0000 (11:16 +0200)] 
object-file.c: return ULHR_TOO_LONG on "header too long"

Split up the return code for "header too long" from the generic
negative return value unpack_loose_header() returns, and report via
error() if we exceed MAX_HEADER_LEN.

As a test added earlier in this series in t1006-cat-file.sh shows
we'll correctly emit zlib errors from zlib.c already in this case, so
we have no need to carry those return codes further down the
stack. Let's instead just return ULHR_TOO_LONG saying we ran into the
MAX_HEADER_LEN limit, or other negative values for "unable to unpack
<OID> header".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoobject-file.c: use "enum" return type for unpack_loose_header()
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:49 +0000 (11:16 +0200)] 
object-file.c: use "enum" return type for unpack_loose_header()

In a preceding commit we changed and documented unpack_loose_header()
from its previous behavior of returning any negative value or zero, to
only -1 or 0.

Let's add an "enum unpack_loose_header_result" type and use it for
these return values, and have the compiler assert that we're
exhaustively covering all of them.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoobject-file.c: simplify unpack_loose_short_header()
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:48 +0000 (11:16 +0200)] 
object-file.c: simplify unpack_loose_short_header()

Combine the unpack_loose_short_header(),
unpack_loose_header_to_strbuf() and unpack_loose_header() functions
into one.

The unpack_loose_header_to_strbuf() function was added in
46f034483eb (sha1_file: support reading from a loose object of unknown
type, 2015-05-03).

Its code was mostly copy/pasted between it and both of
unpack_loose_header() and unpack_loose_short_header(). We now have a
single unpack_loose_header() function which accepts an optional
"struct strbuf *" instead.

I think the remaining unpack_loose_header() function could be further
simplified, we're carrying some complexity just to be able to emit a
garbage type longer than MAX_HEADER_LEN, we could alternatively just
say "we found a garbage type <first 32 bytes>..." instead. But let's
leave the current behavior in place for now.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoobject-file.c: make parse_loose_header_extended() public
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:47 +0000 (11:16 +0200)] 
object-file.c: make parse_loose_header_extended() public

Make the parse_loose_header_extended() function public and remove the
parse_loose_header() wrapper. The only direct user of it outside of
object-file.c itself was in streaming.c, that caller can simply pass
the required "struct object-info *" instead.

This change is being done in preparation for teaching
read_loose_object() to accept a flag to pass to
parse_loose_header(). It isn't strictly necessary for that change, we
could simply use parse_loose_header_extended() there, but will leave
the API in a better end state.

It would be a better end-state to have already moved the declaration
of these functions to object-store.h to avoid the forward declaration
of "struct object_info" in cache.h, but let's leave that cleanup for
some other time.

1. https://lore.kernel.org/git/patch-v6-09.22-5b9278e7bb4-20210907T104559Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoobject-file.c: return -1, not "status" from unpack_loose_header()
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:46 +0000 (11:16 +0200)] 
object-file.c: return -1, not "status" from unpack_loose_header()

Return a -1 when git_inflate() fails instead of whatever Z_* status
we'd get from zlib.c. This makes no difference to any error we report,
but makes it more obvious that we don't care about the specific zlib
error codes here.

See d21f8426907 (unpack_sha1_header(): detect malformed object header,
2016-09-25) for the commit that added the "return status" code. As far
as I can tell there was never a real reason (e.g. different reporting)
for carrying down the "status" as opposed to "-1".

At the time that d21f8426907 was written there was a corresponding
"ret < Z_OK" check right after the unpack_sha1_header() call (the
"unpack_sha1_header()" function was later rename to our current
"unpack_loose_header()").

However, that check was removed in c84a1f3ed4d (sha1_file: refactor
read_object, 2017-06-21) without changing the corresponding return
code.

So let's do the minor cleanup of also changing this function to return
a -1.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoobject-file.c: don't set "typep" when returning non-zero
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:45 +0000 (11:16 +0200)] 
object-file.c: don't set "typep" when returning non-zero

When the loose_object_info() function returns an error stop faking up
the "oi->typep" to OBJ_BAD. Let the return value of the function
itself suffice. This code cleanup simplifies subsequent changes.

That we set this at all is a relic from the past. Before
052fe5eaca9 (sha1_loose_object_info: make type lookup optional,
2013-07-12) we would always return the type_from_string(type) via the
parse_sha1_header() function, or -1 (i.e. OBJ_BAD) if we couldn't
parse it.

Then in a combination of 46f034483eb (sha1_file: support reading from
a loose object of unknown type, 2015-05-03) and
b3ea7dd32d6 (sha1_loose_object_info: handle errors from
unpack_sha1_rest, 2017-10-05) our API drifted even further towards
conflating the two again.

Having read the code paths involved carefully I think this is OK. We
are just about to return -1, and we have only one caller:
do_oid_object_info_extended(). That function will in turn go on to
return -1 when we return -1 here.

This might be introducing a subtle bug where a caller of
oid_object_info_extended() would inspect its "typep" and expect a
meaningful value if the function returned -1.

Such a problem would not occur for its simpler oid_object_info()
sister function. That one always returns the "enum object_type", which
in the case of -1 would be the OBJ_BAD.

Having read the code for all the callers of these functions I don't
believe any such bug is being introduced here, and in any case we'd
likely already have such a bug for the "sizep" member (although
blindly checking "typep" first would be a more common case).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agocat-file tests: test for current --allow-unknown-type behavior
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:44 +0000 (11:16 +0200)] 
cat-file tests: test for current --allow-unknown-type behavior

Add more tests for the current --allow-unknown-type behavior. As noted
in [1] I don't think much of this makes sense, but let's test for it
as-is so we can see if the behavior changes in the future.

1. https://lore.kernel.org/git/87r1i4qf4h.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agocat-file tests: add corrupt loose object test
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:43 +0000 (11:16 +0200)] 
cat-file tests: add corrupt loose object test

Fix a blindspot in the tests for "cat-file" (and by proxy, the guts of
object-file.c) by testing that when we can't decode a loose object
with zlib we'll emit an error from zlib.c.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agocat-file tests: test for missing/bogus object with -t, -s and -p
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:42 +0000 (11:16 +0200)] 
cat-file tests: test for missing/bogus object with -t, -s and -p

When we look up a missing object with cat_one_file() what error we
print out currently depends on whether we'll error out early in
get_oid_with_context(), or if we'll get an error later from
oid_object_info_extended().

The --allow-unknown-type flag then changes whether we pass the
"OBJECT_INFO_ALLOW_UNKNOWN_TYPE" flag to get_oid_with_context() or
not.

The "-p" flag is yet another special-case in printing the same output
on the deadbeef OID as we'd emit on the deadbeef_short OID for the
"-s" and "-t" options, it also doesn't support the
"--allow-unknown-type" flag at all.

Let's test the combination of the two sets of [-t, -s, -p] and
[--{no-}allow-unknown-type] (the --no-allow-unknown-type is implicit
in not supplying it), as well as a [missing,bogus] object pair.

This extends tests added in 3e370f9faf0 (t1006: add tests for git
cat-file --allow-unknown-type, 2015-05-03).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agocat-file tests: move bogus_* variable declarations earlier
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:41 +0000 (11:16 +0200)] 
cat-file tests: move bogus_* variable declarations earlier

Change the short/long bogus bogus object type variables into a form
where the two sets can be used concurrently. This'll be used by
subsequently added tests.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofsck tests: test for garbage appended to a loose object
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:40 +0000 (11:16 +0200)] 
fsck tests: test for garbage appended to a loose object

There wasn't any output tests for this scenario, let's ensure that we
don't regress on it in the changes that come after this.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofsck tests: test current hash/type mismatch behavior
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:39 +0000 (11:16 +0200)] 
fsck tests: test current hash/type mismatch behavior

If fsck we move an object around between .git/objects/?? directories
to simulate a hash mismatch "git fsck" will currently hard die() in
object-file.c. This behavior will be fixed in subsequent commits, but
let's test for it as-is for now.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofsck tests: refactor one test to use a sub-repo
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:38 +0000 (11:16 +0200)] 
fsck tests: refactor one test to use a sub-repo

Refactor one of the fsck tests to use a throwaway repository. It's a
pervasive pattern in t1450-fsck.sh to spend a lot of effort on the
teardown of a tests so we're not leaving corrupt content for the next
test.

We can instead use the pattern of creating a named sub-repository,
then we don't have to worry about cleaning up after ourselves, nobody
will care what state the broken "hash-mismatch" repository is after
this test runs.

See [1] for related discussion on various "modern" test patterns that
can be used to avoid verbosity and increase reliability.

1. https://lore.kernel.org/git/87y27veeyj.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofsck tests: add test for fsck-ing an unknown type
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 09:16:37 +0000 (11:16 +0200)] 
fsck tests: add test for fsck-ing an unknown type

Fix a blindspot in the fsck tests by checking what we do when we
encounter an unknown "garbage" type produced with hash-object's
--literally option.

This behavior needs to be improved, which'll be done in subsequent
patches, but for now let's test for the current behavior.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>