]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
23 months agodiff-files: move misplaced cleanup label
Jeff King [Tue, 12 Jul 2022 07:03:45 +0000 (03:03 -0400)] 
diff-files: move misplaced cleanup label

Commit 0139c58ab9 (revisions API users: add "goto cleanup" for
release_revisions(), 2022-04-13) converted an early return in
cmd_diff_files() into a goto. But it put the cleanup label too early: if
read_cache_preload() returns an error, we'll set result to "-1", but
then jump to calling run_diff_files(), overwriting our result.

We should jump past the call to run_diff_files(). Likewise, we should go
past diff_result_code(), which is expecting to see a code from an actual
diff, not a negative error code.

In practice, I suspect this bug cannot actually be triggered, because
read_cache_preload() does not seem to ever return an error. Its return
value (eventually) comes from do_read_index(), which gives the number of
cache entries found, and calls die() on error. Still, it makes sense to
fix the inadvertent change from 0139c58ab9 first, and we can look into
the overall error handling of read_cache() separately (which is present
in many other callsites).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API: add a TODO for diff_free(&revs->diffopt)
Ævar Arnfjörð Bjarmason [Thu, 14 Apr 2022 05:56:40 +0000 (07:56 +0200)] 
revisions API: add a TODO for diff_free(&revs->diffopt)

Add a TODO comment indicating that we should release "diffopt" in
release_revisions(). In a preceding commit we started releasing the
"pruning" member of the same type, but handling "diffopt" will require
us to untangle the "no_free" conditions I added in e900d494dcf (diff:
add an API for deferred freeing, 2021-02-11).

Let's leave a TODO comment to that effect, and so that we don't forget
refactor code that was changed to use release_revisions() in earlier
commits to stop using the "diffopt" member after a call to
release_revisions(). This works currently, but would become a logic
error as soon as we started freeing "diffopt". Doing that change now
doesn't harm anything, and future-proofs us against a later change to
release_revisions().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API: have release_revisions() release "topo_walk_info"
Ævar Arnfjörð Bjarmason [Thu, 14 Apr 2022 05:56:39 +0000 (07:56 +0200)] 
revisions API: have release_revisions() release "topo_walk_info"

Refactor the existing reset_topo_walk() into a thin wrapper for a
release_revisions_topo_walk_info() + resetting the member to "NULL",
and call release_revisions_topo_walk_info() from release_revisions().

This fixes memory leaks that have been with us ever since
"topo_walk_info" was added to revision.[ch] in
f0d9cc4196a (revision.c: begin refactoring --topo-order logic,
2018-11-01).

Due to various other leaks this makes no tests pass in their entirety,
but e.g. before this running this on git.git:

    ./git -P log --pretty=tformat:"%P   %H | %s" --parents --full-history --topo-order -3 -- README.md

Would report under SANITIZE=leak:

    SUMMARY: LeakSanitizer: 531064 byte(s) leaked in 6 allocation(s).

Now we'll free all of that memory.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API: have release_revisions() release "date_mode"
Ævar Arnfjörð Bjarmason [Thu, 14 Apr 2022 05:56:38 +0000 (07:56 +0200)] 
revisions API: have release_revisions() release "date_mode"

Extend the the release_revisions() function so that it frees the
"date_mode" in the "struct ref_info".

This uses the date_mode_release() function added in 974c919d36d (date
API: add and use a date_mode_release(), 2022-02-16). As that commit
notes "t7004-tag.sh" tests for the leaks that are being fixed
here. That test now fails "only" 44 tests, instead of the 46 it failed
before this change.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API: call diff_free(&revs->pruning) in revisions_release()
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:53 +0000 (22:01 +0200)] 
revisions API: call diff_free(&revs->pruning) in revisions_release()

Call diff_free() on the "pruning" member of "struct rev_info".  Doing
so makes several tests pass under SANITIZE=leak.

This was also the last missing piece that allows us to remove the
UNLEAK() in "cmd_diff" and "cmd_diff_index", which allows us to use
those commands as a canary for general leaks in the revisions API. See
[1] for further rationale, and 886e1084d78 (builtin/: add UNLEAKs,
2017-10-01) for the commit that added the UNLEAK() there.

1. https://lore.kernel.org/git/220218.861r00ib86.gmgdl@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API: release "reflog_info" in release revisions()
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:52 +0000 (22:01 +0200)] 
revisions API: release "reflog_info" in release revisions()

Add a missing reflog_walk_info_release() to "reflog-walk.c" and use it
in release_revisions().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API: clear "boundary_commits" in release_revisions()
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:51 +0000 (22:01 +0200)] 
revisions API: clear "boundary_commits" in release_revisions()

Clear the "boundary_commits" object_array in release_revisions(). This
makes a few more tests pass under SANITIZE=leak, including
"t/t4126-apply-empty.sh" which started failed as an UNLEAK() in
cmd_format_patch() was removed in a preceding commit.

This also re-marks the various tests relying on "git format-patch" as
passing under "SANITIZE=leak", in the preceding "revisions API users:
use release_revisions() in builtin/log.c" commit those were marked as
failing as we removed the UNLEAK(rev) from cmd_format_patch() in
"builtin/log.c".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API: have release_revisions() release "prune_data"
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:50 +0000 (22:01 +0200)] 
revisions API: have release_revisions() release "prune_data"

Extend the the release_revisions() function so that it frees the
"prune_data" in the "struct rev_info". This means that any code that
calls "release_revisions()" already can get rid of adjacent calls to
clear_pathspec().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API: have release_revisions() release "grep_filter"
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:49 +0000 (22:01 +0200)] 
revisions API: have release_revisions() release "grep_filter"

Extend the the release_revisions() function so that it frees the
"grep_filter" in the "struct rev_info".This allows us to mark a test
as passing under "TEST_PASSES_SANITIZE_LEAK=true".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API: have release_revisions() release "filter"
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:48 +0000 (22:01 +0200)] 
revisions API: have release_revisions() release "filter"

Extend the the release_revisions() function so that it frees the
"filter" in the "struct rev_info". This in combination with a
preceding change to free "cmdline" means that we can mark another set
of tests as passing under "TEST_PASSES_SANITIZE_LEAK=true".

The "filter" member was added recently in ffaa137f646 (revision: put
object filter into struct rev_info, 2022-03-09), and this fixes leaks
intruded in the subsequent leak 7940941de1f (pack-objects: use
rev.filter when possible, 2022-03-09) and 105c6f14ad3 (bundle: parse
filter capability, 2022-03-09).

The "builtin/pack-objects.c" leak in 7940941de1f was effectively with
us already, but the variable was referred to by a "static" file-scoped
variable. The "bundle.c " leak in 105c6f14ad3 was newly introduced
with the new "filter" feature for bundles.

The "t5600-clone-fail-cleanup.sh" change here to add
"TEST_PASSES_SANITIZE_LEAK=true" is one of the cases where
run-command.c in not carrying the abort() exit code upwards would have
had that test passing before, but now it *actually* passes[1]. We
should fix the lack of 1=1 mapping of SANITIZE=leak testing to actual
leaks some other time, but it's an existing edge case, let's just mark
the really-passing test as passing for now.

1. https://lore.kernel.org/git/220303.86fsnz5o9w.gmgdl@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API: have release_revisions() release "cmdline"
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:47 +0000 (22:01 +0200)] 
revisions API: have release_revisions() release "cmdline"

Extend the the release_revisions() function so that it frees the
"cmdline" in the "struct rev_info". This in combination with a
preceding change to free "commits" and "mailmap" means that we can
whitelist another test under "TEST_PASSES_SANITIZE_LEAK=true".

There was a proposal in [1] to do away with xstrdup()-ing this
add_rev_cmdline(), perhaps that would be worthwhile, but for now let's
just free() it.

We could also make that a "char *" in "struct rev_cmdline_entry"
itself, but since we own it let's expose it as a constant to outside
callers. I proposed that in [2] but have since changed my mind. See
14d30cdfc04 (ref-filter: fix memory leak in `free_array_item()`,
2019-07-10), c514c62a4fd (checkout: fix leak of non-existent branch
names, 2020-08-14) and other log history hits for "free((char *)" for
prior art.

This includes the tests we had false-positive passes on before my
6798b08e848 (perl Git.pm: don't ignore signalled failure in
_cmd_close(), 2022-02-01), now they pass for real.

Since there are 66 tests matching t/t[0-9]*git-svn*.sh it's easier to
list those that don't pass than to touch most of those 66. So let's
introduce a "TEST_FAILS_SANITIZE_LEAK=true", which if set in the tests
won't cause lib-git-svn.sh to set "TEST_PASSES_SANITIZE_LEAK=true.

This change also marks all the tests that we removed
"TEST_FAILS_SANITIZE_LEAK=true" from in an earlier commit due to
removing the UNLEAK() from cmd_format_patch(), we can now assert that
its API use doesn't leak any "struct rev_info" memory.

This change also made commit "t5503-tagfollow.sh" pass on current
master, but that would regress when combined with
ps/fetch-atomic-fixup's de004e848a9 (t5503: simplify setup of test
which exercises failure of backfill, 2022-03-03) (through no fault of
that topic, that change started using "git clone" in the test, which
has an outstanding leak). Let's leave that test out for now to avoid
in-flight semantic conflicts.

1. https://lore.kernel.org/git/YUj%2FgFRh6pwrZalY@carlos-mbp.lan/
2. https://lore.kernel.org/git/87o88obkb1.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API: have release_revisions() release "mailmap"
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:46 +0000 (22:01 +0200)] 
revisions API: have release_revisions() release "mailmap"

Extend the the release_revisions() function so that it frees the
"mailmap" in the "struct rev_info".

The log family of functions now calls the clear_mailmap() function
added in fa8afd18e5a (revisions API: provide and use a
release_revisions(), 2021-09-19), allowing us to whitelist some tests
with "TEST_PASSES_SANITIZE_LEAK=true".

Unfortunately having a pointer to a mailmap in "struct rev_info"
instead of an embedded member that we "own" get a bit messy, as can be
seen in the change to builtin/commit.c.

When we free() this data we won't be able to tell apart a pointer to a
"mailmap" on the heap from one on the stack. As seen in
ea57bc0d41b (log: add --use-mailmap option, 2013-01-05) the "log"
family allocates it on the heap, but in the find_author_by_nickname()
code added in ea16794e430 (commit: search author pattern against
mailmap, 2013-08-23) we allocated it on the stack instead.

Ideally we'd simply change that member to a "struct string_list
mailmap" and never free() the "mailmap" itself, but that would be a
much larger change to the revisions API.

We have code that needs to hand an existing "mailmap" to a "struct
rev_info", while we could change all of that, let's not go there
now.

The complexity isn't in the ownership of the "mailmap" per-se, but
that various things assume a "rev_info.mailmap == NULL" means "doesn't
want mailmap", if we changed that to an init'd "struct string_list
we'd need to carefully refactor things to change those assumptions.

Let's instead always free() it, and simply declare that if you add
such a "mailmap" it must be allocated on the heap. Any modern libc
will correctly panic if we free() a stack variable, so this should be
safe going forward.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API: have release_revisions() release "commits"
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:45 +0000 (22:01 +0200)] 
revisions API: have release_revisions() release "commits"

Extend the the release_revisions() function so that it frees the
"commits" in the "struct rev_info".

We don't expect to use this "struct rev_info" again, so there's no
reason to NULL out revs->commits, as e.g. simplify_merges() and
create_boundary_commit_list() do.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API users: use release_revisions() for "prune_data" users
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:44 +0000 (22:01 +0200)] 
revisions API users: use release_revisions() for "prune_data" users

Use release_revisions() for users of "struct rev_list" that reach into
the "struct rev_info" and clear the "prune_data" already.

In a subsequent commit we'll teach release_revisions() to clear this
itself, but in the meantime let's invoke release_revisions() here to
clear anything else we may have missed, and for reasons of having
consistent boilerplate.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API users: use release_revisions() with UNLEAK()
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:43 +0000 (22:01 +0200)] 
revisions API users: use release_revisions() with UNLEAK()

Use a release_revisions() with those "struct rev_list" users which
already "UNLEAK" the struct. It may seem odd to simultaneously attempt
to free() memory, but also to explicitly ignore whether we have memory
leaks in the same.

As explained in preceding commits this is being done to use the
built-in commands as a guinea pig for whether the release_revisions()
function works as expected, we'd like to test e.g. whether we segfault
as we change it. In subsequent commits we'll then remove these
UNLEAK() as the function is made to free the memory that caused us to
add them in the first place.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API users: use release_revisions() in builtin/log.c
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:42 +0000 (22:01 +0200)] 
revisions API users: use release_revisions() in builtin/log.c

In preparation for having the "log" family of functions make wider use
of release_revisions() let's have them call it just before
exiting. This changes the "log", "whatchanged", "show",
"format-patch", etc. commands, all of which live in this file.

The release_revisions() API still only frees the "pending" member, but
will learn to release more members of "struct rev_info" in subsequent
commits.

In the case of "format-patch" revert the addition of UNLEAK() in
dee839a2633 (format-patch: mark rev_info with UNLEAK, 2021-12-16),
which will cause several tests that previously passed under
"TEST_PASSES_SANITIZE_LEAK=true" to start failing.

In subsequent commits we'll now be able to use those tests to check
whether that part of the API is really leaking memory, and will fix
all of those memory leaks. Removing the UNLEAK() allows us to make
incremental progress in that direction. See [1] for further details
about this approach.

Note that the release_revisions() will not be sufficient to deal with
the code in cmd_show() added in 5d7eeee2ac6 (git-show: grok blobs,
trees and tags, too, 2006-12-14) which clobbers the "pending" array in
the case of "OBJ_COMMIT". That will need to be dealt with by some
future follow-up work.

1. https://lore.kernel.org/git/220218.861r00ib86.gmgdl@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API users: use release_revisions() in http-push.c
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:41 +0000 (22:01 +0200)] 
revisions API users: use release_revisions() in http-push.c

In the case of cmd_main() in http-push.c we need to move the
deceleration of the "struct rev-list" into the loop over the
"remote_refs" when adding a release_revisions().

We'd previously set up the "revs" for each remote, but would
potentially leak memory on each one.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API users: add "goto cleanup" for release_revisions()
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:40 +0000 (22:01 +0200)] 
revisions API users: add "goto cleanup" for release_revisions()

Add a release_revisions() to various users of "struct rev_info" which
requires a minor refactoring to a "goto cleanup" pattern to use that
function.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agostash: always have the owner of "stash_info" free it
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:39 +0000 (22:01 +0200)] 
stash: always have the owner of "stash_info" free it

Change the initialization of the "revision" member of "struct
stash_info" to be initialized vi a macro, and more importantly that
that initializing function be tasked to free it, usually via a "goto
cleanup" pattern.

Despite the "revision" name (and the topic of the series containing
this commit) the "stash info" has nothing to do with the "struct
rev_info". I'm making this change because in the subsequent commit
when we do want to free the "struct rev_info" via a "goto cleanup"
pattern we'd otherwise free() uninitialized memory in some cases, as
we only strbuf_init() the string in get_stash_info().

So while it's not the smallest possible change, let's convert all
users of this pattern in the file while we're at it.

A good follow-up to this change would be to change all the "ret = -1;
goto done;" in this file to instead use a "goto cleanup", and
initialize "int ret = -1" at the start of the relevant functions. That
would allow us to drop a lot of needless brace verbosity on two-line
"if" statements, but let's leave that alone for now.

To ensure that there's a 1=1 mapping between owners of the "struct
stash_info" and free_stash_info() change the assert_stash_ref()
function to be a trivial get_stash_info_assert() wrapper. The caller
will call free_stash_info(), and by returning -1 we'll eventually (via
!!ret) exit with status 1 anyway.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API users: use release_revisions() needing REV_INFO_INIT
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:38 +0000 (22:01 +0200)] 
revisions API users: use release_revisions() needing REV_INFO_INIT

Use release_revisions() to various users of "struct rev_list" which
need to have their "struct rev_info" zero-initialized before we can
start using it.

For the bundle.c code see the early exit case added in
3bbbe467f29 (bundle verify: error out if called without an object
database, 2019-05-27).

For the relevant bisect.c code see 45b6370812c (bisect: libify
`check_good_are_ancestors_of_bad` and its dependents, 2020-02-17).

For the submodule.c code see the "goto" on "(!left || !right || !sub)"
added in 8e6df65015f (submodule: refactor show_submodule_summary with
helper function, 2016-08-31).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevision.[ch]: document and move code declared around "init"
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:37 +0000 (22:01 +0200)] 
revision.[ch]: document and move code declared around "init"

A subsequent commit will add "REV_INFO_INIT" macro adjacent to
repo_init_revisions(), unfortunately between the "struct rev_info"
itself and that function we've added various miscellaneous code
between the two over the years.

Let's move that code either lower in revision.h, giving it API docs
while we're at it, or in cases where it wasn't public API at all move
it into revision.c No lines of code are changed here, only moved
around. The only changes are the addition of new API comments.

The "tree_difference" variable could also be declared like this, which
I think would be a lot clearer, but let's leave that for now to keep
this a move-only change:

static enum {
REV_TREE_SAME,
REV_TREE_NEW, /* Only new files */
REV_TREE_OLD, /* Only files removed */
REV_TREE_DIFFERENT, /* Mixed changes */
} tree_difference = REV_TREE_SAME;

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevisions API users: add straightforward release_revisions()
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:36 +0000 (22:01 +0200)] 
revisions API users: add straightforward release_revisions()

Add a release_revisions() to various users of "struct rev_list" in
those straightforward cases where we only need to add the
release_revisions() call to the end of a block, and don't need to
e.g. refactor anything to use a "goto cleanup" pattern.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorevision.[ch]: provide and start using a release_revisions()
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:35 +0000 (22:01 +0200)] 
revision.[ch]: provide and start using a release_revisions()

The users of the revision.[ch] API's "struct rev_info" are a major
source of memory leaks in the test suite under SANITIZE=leak, which in
turn adds a lot of noise when trying to mark up tests with
"TEST_PASSES_SANITIZE_LEAK=true".

The users of that API are largely one-shot, e.g. "git rev-list" or
"git log", or the "git checkout" and "git stash" being modified here

For these callers freeing the memory is arguably a waste of time, but
in many cases they've actually been trying to free the memory, and
just doing that in a buggy manner.

Let's provide a release_revisions() function for these users, and
start migrating them over per the plan outlined in [1]. Right now this
only handles the "pending" member of the struct, but more will be
added in subsequent commits.

Even though we only clear the "pending" member now, let's not leave a
trap in code like the pre-image of index_differs_from(), where we'd
start doing the wrong thing as soon as the release_revisions() learned
to clear its "diffopt". I.e. we need to call release_revisions() after
we've inspected any state in "struct rev_info".

This leaves in place e.g. clear_pathspec(&rev.prune_data) in
stash_working_tree() in builtin/stash.c, subsequent commits will teach
release_revisions() to free "prune_data" and other members that in
some cases are individually cleared by users of "struct rev_info" by
reaching into its members. Those subsequent commits will remove the
relevant calls to e.g. clear_pathspec().

We avoid amending code in index_differs_from() in diff-lib.c as well
as wt_status_collect_changes_index(), has_unstaged_changes() and
has_uncommitted_changes() in wt-status.c in a way that assumes that we
are already clearing the "diffopt" member. That will be handled in a
subsequent commit.

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

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agococci: add and apply free_commit_list() rules
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:34 +0000 (22:01 +0200)] 
cocci: add and apply free_commit_list() rules

Add and apply coccinelle rules to remove "if (E)" before
"free_commit_list(E)", the function can accept NULL, and further
change cases where "E = NULL" followed to also be unconditionally.

The code changes in this commit were entirely made by the coccinelle
rule being added here, and applied with:

    make contrib/coccinelle/free.cocci.patch
    patch -p1 <contrib/coccinelle/free.cocci.patch

The only manual intervention here is that the the relevant code in
commit.c has been manually re-indented.

Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoformat-patch: don't leak "extra_headers" or "ref_message_ids"
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:33 +0000 (22:01 +0200)] 
format-patch: don't leak "extra_headers" or "ref_message_ids"

Fix two memory leaks in "struct rev_info" by freeing that memory in
cmd_format_patch(). These two are unusual special-cases in being in
the "struct rev_info", but not being "owned" by the code in
revision.c. I.e. they're members of the struct so that this code in
"builtin/log.c" can conveniently pass information code in
"log-tree.c".

See e.g. the make_cover_letter() caller of log_write_email_headers()
here in "builtin/log.c", and [1] for a demonstration of where the
"extra_headers" and "ref_message_ids" struct members are used.

See 20ff06805c6 (format-patch: resurrect extra headers from config,
2006-06-02) and d1566f7883f (git-format-patch: Make the second and
subsequent mails replies to the first, 2006-07-14) for the initial
introduction of "extra_headers" and "ref_message_ids".

We can count on repo_init_revisions() memset()-ing this data to 0
however, so we can count on it being either NULL or something we
allocated. In the case of "extra_headers" let's add a local "char *"
variable to hold it, to avoid the eventual cast from "const char *"
when we free() it.

1. https://lore.kernel.org/git/220401.868rsoogxf.gmgdl@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agostring_list API users: use string_list_init_{no,}dup
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:32 +0000 (22:01 +0200)] 
string_list API users: use string_list_init_{no,}dup

Follow-up on the introduction of string_list_init_nodup() and
string_list_init_dup() in the series merged in bd4232fac33 (Merge
branch 'ab/struct-init', 2021-07-16) and convert code that implicitly
relied on xcalloc() being equivalent to the initializer to use
xmalloc() and string_list_init_{no,}dup() instead.

In the case of get_unmerged() in merge-recursive.c we used the
combination of xcalloc() and assigning "1" to "strdup_strings" to get
what we'd get via string_list_init_dup(), let's use that instead.

Adjacent code in cmd_format_patch() will be changed in a subsequent
commit, since we're changing that let's change the other in-tree
patterns that do the same. Let's also convert a "x == NULL" to "!x"
per our CodingGuidelines, as we need to change the "if" line anyway.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoblame: use "goto cleanup" for cleanup_scoreboard()
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:31 +0000 (22:01 +0200)] 
blame: use "goto cleanup" for cleanup_scoreboard()

Amend a freeing pattern added in 0906ac2b54b (blame: use changed-path
Bloom filters, 2020-04-16) to use a "goto cleanup", so that we can be
sure that we call cleanup_scoreboard().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot/helper/test-fast-rebase.c: don't leak "struct strbuf"
Ævar Arnfjörð Bjarmason [Wed, 13 Apr 2022 20:01:30 +0000 (22:01 +0200)] 
t/helper/test-fast-rebase.c: don't leak "struct strbuf"

Fix a memory leak that's been with us since f9500261e0a (fast-rebase:
write conflict state to working tree, index, and HEAD, 2021-05-20)
changed this code to move these strbuf_release() into an if/else
block.

We'll also add to "reflog_msg" in the "else" arm of the "if" block
being modified here, and we'll append to "branch_msg" in both
cases. But after f9500261e0a only the "if" block would free these two
"struct strbuf".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ds/partial-bundle-more' into ab/plug-leak-in-revisions
Junio C Hamano [Sun, 3 Apr 2022 22:03:05 +0000 (15:03 -0700)] 
Merge branch 'ds/partial-bundle-more' into ab/plug-leak-in-revisions

* ds/partial-bundle-more:
  pack-objects: lazily set up "struct rev_info", don't leak
  bundle: output hash information in 'verify'
  bundle: move capabilities to end of 'verify'
  pack-objects: parse --filter directly into revs.filter
  pack-objects: move revs out of get_object_list()
  list-objects-filter: remove CL_ARG__FILTER

2 years agopack-objects: lazily set up "struct rev_info", don't leak
Ævar Arnfjörð Bjarmason [Mon, 28 Mar 2022 15:43:18 +0000 (17:43 +0200)] 
pack-objects: lazily set up "struct rev_info", don't leak

In the preceding [1] (pack-objects: move revs out of
get_object_list(), 2022-03-22) the "repo_init_revisions()" was moved
to cmd_pack_objects() so that it unconditionally took place for all
invocations of "git pack-objects".

We'd thus start leaking memory, which is easily reproduced in
e.g. git.git by feeding e83c5163316 (Initial revision of "git", the
information manager from hell, 2005-04-07) to "git pack-objects";

    $ echo e83c5163316f89bfbde7d9ab23ca2e25604af290 | ./git pack-objects initial
    [...]
==19130==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 7120 byte(s) in 1 object(s) allocated from:
    #0 0x455308 in __interceptor_malloc (/home/avar/g/git/git+0x455308)
    #1 0x75b399 in do_xmalloc /home/avar/g/git/wrapper.c:41:8
    #2 0x75b356 in xmalloc /home/avar/g/git/wrapper.c:62:9
    #3 0x5d7609 in prep_parse_options /home/avar/g/git/diff.c:5647:2
    #4 0x5d415a in repo_diff_setup /home/avar/g/git/diff.c:4621:2
    #5 0x6dffbb in repo_init_revisions /home/avar/g/git/revision.c:1853:2
    #6 0x4f599d in cmd_pack_objects /home/avar/g/git/builtin/pack-objects.c:3980:2
    #7 0x4592ca in run_builtin /home/avar/g/git/git.c:465:11
    #8 0x457d81 in handle_builtin /home/avar/g/git/git.c:718:3
    #9 0x458ca5 in run_argv /home/avar/g/git/git.c:785:4
    #10 0x457b40 in cmd_main /home/avar/g/git/git.c:916:19
    #11 0x562259 in main /home/avar/g/git/common-main.c:56:11
    #12 0x7fce792ac7ec in __libc_start_main csu/../csu/libc-start.c:332:16
    #13 0x4300f9 in _start (/home/avar/g/git/git+0x4300f9)

SUMMARY: LeakSanitizer: 7120 byte(s) leaked in 1 allocation(s).
Aborted

Narrowly fixing that commit would have been easy, just add call
repo_init_revisions() right before get_object_list(), which is
effectively what was done before that commit.

But an unstated constraint when setting it up early is that it was
needed for the subsequent [2] (pack-objects: parse --filter directly
into revs.filter, 2022-03-22), i.e. we might have a --filter
command-line option, and need to either have the "struct rev_info"
setup when we encounter that option, or later.

Let's just change the control flow so that we'll instead set up the
"struct rev_info" only when we need it. Doing so leads to a bit more
verbosity, but it's a lot clearer what we're doing and why.

An earlier version of this commit[3] went behind
opt_parse_list_objects_filter()'s back by faking up a "struct option"
before calling it. Let's avoid that and instead create a blessed API
for this pattern.

We could furthermore combine the two get_object_list() invocations
here by having repo_init_revisions() invoked on &pfd.revs, but I think
clearly separating the two makes the flow clearer. Likewise
redundantly but explicitly (i.e. redundant v.s. a "{ 0 }") "0" to
"have_revs" early in cmd_pack_objects().

While we're at it add parentheses around the arguments to the OPT_*
macros in in list-objects-filter-options.h, as we need to change those
lines anyway. It doesn't matter in this case, but is good general
practice.

1. https://lore.kernel.org/git/619b757d98465dbc4995bdc11a5282fbfcbd3daa.1647970119.git.gitgitgadget@gmail.com
2. https://lore.kernel.org/git/97de926904988b89b5663bd4c59c011a1723a8f5.1647970119.git.gitgitgadget@gmail.com
3. https://lore.kernel.org/git/patch-1.1-193534b0f07-20220325T121715Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoThe 14th batch
Junio C Hamano [Wed, 23 Mar 2022 21:04:45 +0000 (14:04 -0700)] 
The 14th batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ab/plug-random-leaks'
Junio C Hamano [Wed, 23 Mar 2022 21:09:31 +0000 (14:09 -0700)] 
Merge branch 'ab/plug-random-leaks'

Double-free fix for a recently merged topic.

* ab/plug-random-leaks:
  diff.c: fix a double-free regression in a18d66cefb
  tests: demonstrate "show --word-diff --color-moved" regression

2 years agoMerge branch 'dc/complete-restore'
Junio C Hamano [Wed, 23 Mar 2022 21:09:31 +0000 (14:09 -0700)] 
Merge branch 'dc/complete-restore'

The command line completion support (in contrib/) learns to give
modified paths to the "git restore" command.

* dc/complete-restore:
  completion: tab completion of filenames for 'git restore'

2 years agoMerge branch 'jc/cat-file-batch-default-format-optim'
Junio C Hamano [Wed, 23 Mar 2022 21:09:31 +0000 (14:09 -0700)] 
Merge branch 'jc/cat-file-batch-default-format-optim'

Optimize away strbuf_expand() call with a hardcoded formatting logic
specific for the default format in the --batch and --batch-check
options of "git cat-file".

* jc/cat-file-batch-default-format-optim:
  cat-file: skip expanding default format

2 years agoMerge branch 'js/in-place-reverse-in-sequencer'
Junio C Hamano [Wed, 23 Mar 2022 21:09:31 +0000 (14:09 -0700)] 
Merge branch 'js/in-place-reverse-in-sequencer'

Code clean-up.

* js/in-place-reverse-in-sequencer:
  sequencer: use reverse_commit_list() helper

2 years agoMerge branch 'ac/test-lazy-fetch'
Junio C Hamano [Wed, 23 Mar 2022 21:09:30 +0000 (14:09 -0700)] 
Merge branch 'ac/test-lazy-fetch'

A new test to ensure a lazy fetching is not triggered when it
should not be.

* ac/test-lazy-fetch:
  partial-clone: add a partial-clone test case

2 years agoMerge branch 'ps/repack-with-server-info'
Junio C Hamano [Wed, 23 Mar 2022 21:09:30 +0000 (14:09 -0700)] 
Merge branch 'ps/repack-with-server-info'

"git repack" learned a new configuration to disable triggering of
age-old "update-server-info" command, which is rarely useful these
days.

* ps/repack-with-server-info:
  repack: add config to skip updating server info
  repack: refactor to avoid double-negation of update-server-info

2 years agoMerge branch 'ds/doc-maintenance-synopsis-fix'
Junio C Hamano [Wed, 23 Mar 2022 21:09:30 +0000 (14:09 -0700)] 
Merge branch 'ds/doc-maintenance-synopsis-fix'

Doc update.

* ds/doc-maintenance-synopsis-fix:
  maintenance: fix synopsis in documentation

2 years agoMerge branch 'ab/reflog-prep-fix'
Junio C Hamano [Wed, 23 Mar 2022 21:09:30 +0000 (14:09 -0700)] 
Merge branch 'ab/reflog-prep-fix'

Regression fix.

* ab/reflog-prep-fix:
  reflog: don't be noisy on empty reflogs

2 years agoMerge branch 'ep/remove-duplicated-includes'
Junio C Hamano [Wed, 23 Mar 2022 21:09:30 +0000 (14:09 -0700)] 
Merge branch 'ep/remove-duplicated-includes'

Code clean-up.

* ep/remove-duplicated-includes:
  attr.h: remove duplicate struct definition
  t/helper/test-run-command.c: delete duplicate include
  builtin/stash.c: delete duplicate include
  builtin/sparse-checkout.c: delete duplicate include
  builtin/gc.c: delete duplicate include
  attr.c: delete duplicate include

2 years agoMerge branch 'ep/t6423-modernize'
Junio C Hamano [Wed, 23 Mar 2022 21:09:29 +0000 (14:09 -0700)] 
Merge branch 'ep/t6423-modernize'

Code clean-up.

* ep/t6423-modernize:
  t6423-merge-rename-directories.sh: use the $(...) construct

2 years agoMerge branch 'jk/name-rev-w-genno'
Junio C Hamano [Wed, 23 Mar 2022 21:09:29 +0000 (14:09 -0700)] 
Merge branch 'jk/name-rev-w-genno'

"git name-rev" learned to use the generation numbers when setting
the lower bound of searching commits used to explain the revision,
when available, instead of committer time.

* jk/name-rev-w-genno:
  name-rev: use generation numbers if available

2 years agoMerge branch 'jd/userdiff-kotlin'
Junio C Hamano [Wed, 23 Mar 2022 21:09:29 +0000 (14:09 -0700)] 
Merge branch 'jd/userdiff-kotlin'

A new built-in userdiff driver for kotlin.

* jd/userdiff-kotlin:
  userdiff: add builtin diff driver for kotlin language.

2 years agoMerge branch 'bc/block-sha1-without-gcc-asm-extension'
Junio C Hamano [Wed, 23 Mar 2022 21:09:29 +0000 (14:09 -0700)] 
Merge branch 'bc/block-sha1-without-gcc-asm-extension'

Get rid of one use of __asm__() GCC extension that does not help us
much these days, which has an added advantage of not having to
worry about -pedantic complaining.

* bc/block-sha1-without-gcc-asm-extension:
  block-sha1: remove use of obsolete x86 assembly

2 years agoMerge branch 'gc/submodule-update-part1'
Junio C Hamano [Wed, 23 Mar 2022 21:09:28 +0000 (14:09 -0700)] 
Merge branch 'gc/submodule-update-part1'

Rewrite of "git submodule update" in C (early part).

* gc/submodule-update-part1:
  submodule--helper update-clone: check for --filter and --init
  submodule update: add tests for --filter
  submodule--helper: remove ensure-core-worktree
  submodule--helper update-clone: learn --init
  submodule--helper: allow setting superprefix for init_submodule()
  submodule--helper: refactor get_submodule_displaypath()
  submodule--helper run-update-procedure: learn --remote
  submodule--helper: don't use bitfield indirection for parse_options()
  submodule--helper: get remote names from any repository
  submodule--helper run-update-procedure: remove --suboid
  submodule--helper: reorganize code for sh to C conversion
  submodule--helper: remove update-module-mode
  submodule tests: test for init and update failure output

2 years agobundle: output hash information in 'verify'
Derrick Stolee [Tue, 22 Mar 2022 17:28:39 +0000 (17:28 +0000)] 
bundle: output hash information in 'verify'

The previous change moved the 'filter' capability to the end of the 'git
bundle verify' output. Now, add the 'object-format' capability to the
output, when it exists.

This change makes 'git bundle verify' output the hash used in all cases,
even if the capability is not in the bundle. This means that v2 bundles
will always output that they use "sha1". This might look noisy to some
users, but it does simplify the implementation and the test strategy for
this feature.

Since 'verify' ends early when a prerequisite commit is missing, we need
to insert this hash message carefully into our expected test output
throughout t6020.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobundle: move capabilities to end of 'verify'
Derrick Stolee [Tue, 22 Mar 2022 17:28:38 +0000 (17:28 +0000)] 
bundle: move capabilities to end of 'verify'

The 'filter' capability was added in 105c6f14a (bundle: parse filter
capability, 2022-03-09), but was added in a strange place in the 'git
bundle verify' output.

The tests for this show output like the following:

The bundle contains these 2 refs:
<COMMIT1> <REF1>
<COMMIT2> <REF2>
The bundle uses this filter: blob:none
The bundle records a complete history.

This looks very odd if we have a thin bundle that contains boundary
commits instead of a complete history:

The bundle contains these 2 refs:
<COMMIT1> <REF1>
<COMMIT2> <REF2>
The bundle uses this filter: blob:none
The bundle requires these 2 refs:
<COMMIT3>
<COMMIT4>

This separation between tip refs and boundary refs is unfortunate. Move
the filter capability output to the end of the output. Update the
documentation to match.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-objects: parse --filter directly into revs.filter
Derrick Stolee [Tue, 22 Mar 2022 17:28:37 +0000 (17:28 +0000)] 
pack-objects: parse --filter directly into revs.filter

The previous change moved the 'revs' variable into cmd_pack_objects()
and now we can remove the global filter_options in favor of revs.filter.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-objects: move revs out of get_object_list()
Derrick Stolee [Tue, 22 Mar 2022 17:28:36 +0000 (17:28 +0000)] 
pack-objects: move revs out of get_object_list()

We intend to parse the --filter option directly into revs.filter, but we
first need to move the 'revs' variable out of get_object_list() and pass
it as a pointer instead. This change only deals with the issues of
making that work.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agolist-objects-filter: remove CL_ARG__FILTER
Derrick Stolee [Tue, 22 Mar 2022 17:28:35 +0000 (17:28 +0000)] 
list-objects-filter: remove CL_ARG__FILTER

We have established the command-line interface for the --[no-]filter
options for a while now, so we do not need a helper to make this
editable in the future.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoThe thirteenth batch
Junio C Hamano [Mon, 21 Mar 2022 21:18:51 +0000 (14:18 -0700)] 
The thirteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'jy/gitweb-no-need-for-meta'
Junio C Hamano [Mon, 21 Mar 2022 22:14:24 +0000 (15:14 -0700)] 
Merge branch 'jy/gitweb-no-need-for-meta'

Remove unneeded <meta http-equiv=content-type...> from gitweb
output.

* jy/gitweb-no-need-for-meta:
  gitweb: remove invalid http-equiv="content-type"
  comment: fix typo

2 years agoMerge branch 'pw/single-key-interactive'
Junio C Hamano [Mon, 21 Mar 2022 22:14:24 +0000 (15:14 -0700)] 
Merge branch 'pw/single-key-interactive'

The single-key interactive operation used by "git add -p" has been
made more robust.

* pw/single-key-interactive:
  add -p: disable stdin buffering when interactive.singlekey is set
  terminal: set VMIN and VTIME in non-canonical mode
  terminal: pop signal handler when terminal is restored
  terminal: always reset terminal when reading without echo

2 years agoMerge branch 'ds/partial-bundles'
Junio C Hamano [Mon, 21 Mar 2022 22:14:24 +0000 (15:14 -0700)] 
Merge branch 'ds/partial-bundles'

Bundle file format gets extended to allow a partial bundle,
filtered by similar criteria you would give when making a
partial/lazy clone.

* ds/partial-bundles:
  clone: fail gracefully when cloning filtered bundle
  bundle: unbundle promisor packs
  bundle: create filtered bundles
  rev-list: move --filter parsing into revision.c
  bundle: parse filter capability
  list-objects: handle NULL function pointers
  MyFirstObjectWalk: update recommended usage
  list-objects: consolidate traverse_commit_list[_filtered]
  pack-bitmap: drop filter in prepare_bitmap_walk()
  pack-objects: use rev.filter when possible
  revision: put object filter into struct rev_info
  list-objects-filter-options: create copy helper
  index-pack: document and test the --promisor option

2 years agoMerge branch 'ep/test-malloc-check-with-glibc-2.34'
Junio C Hamano [Mon, 21 Mar 2022 22:14:23 +0000 (15:14 -0700)] 
Merge branch 'ep/test-malloc-check-with-glibc-2.34'

The method to trigger malloc check used in our tests no longer work
with newer versions of glibc.

* ep/test-malloc-check-with-glibc-2.34:
  test-lib: declare local variables as local
  test-lib.sh: Use GLIBC_TUNABLES instead of MALLOC_CHECK_ on glibc >= 2.34

2 years agoMerge branch 'sm/no-git-in-upstream-of-pipe-in-tests'
Junio C Hamano [Mon, 21 Mar 2022 22:14:23 +0000 (15:14 -0700)] 
Merge branch 'sm/no-git-in-upstream-of-pipe-in-tests'

Test fixes.

* sm/no-git-in-upstream-of-pipe-in-tests:
  t0030-t0050: avoid pipes with Git on LHS
  t0001-t0028: avoid pipes with Git on LHS
  t0003: avoid pipes with Git on LHS

2 years agodiff.c: fix a double-free regression in a18d66cefb
Ævar Arnfjörð Bjarmason [Thu, 17 Mar 2022 14:55:35 +0000 (15:55 +0100)] 
diff.c: fix a double-free regression in a18d66cefb

My a18d66cefb9 (diff.c: free "buf" in diff_words_flush(), 2022-03-04)
has what it retrospect is a rather obvious bug (I don't know what I
was thinking, if it all): We use the "emitted_symbols" allocation in
append_emitted_diff_symbol() N times, but starting with a18d66cefb9
we'd free it after its first use!

The correct way to free this data would have been to add the free() to
the existing free_diff_words_data() function, so let's do that. The
"ecbdata->diff_words->opt->emitted_symbols" might be NULL, so let's
add a trivial free_emitted_diff_symbols() helper next to the function
that appends to it.

This fixes the "no effect on show from" leak tested for in the
preceding commit. Perhaps confusingly this change will skip that test
under SANITIZE=leak, but otherwise opt-in the
"t4015-diff-whitespace.sh" test.

The reason is that a18d66cefb9 "fixed" the leak in the preceding "no
effect on diff" test, but for the first call to diff_words_flush() the
"wol->buf" would be NULL, so we wouldn't double-free (and
SANITIZE=address would see nothing amiss). With this change we'll
still pass that test, showing that we've also fixed leaks on this
codepath.

We then have to skip the new "no effect on show" test because it
happens to trip over an unrelated memory leak (in revision.c). The
same goes for "move detection with submodules". Both of them pass with
SANITIZE=address though, which would error on the "no effect on show"
test before this change.

Reported-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agotests: demonstrate "show --word-diff --color-moved" regression
Michael J Gruber [Thu, 17 Mar 2022 14:55:34 +0000 (15:55 +0100)] 
tests: demonstrate "show --word-diff --color-moved" regression

Add a failing test which demonstrates a regression in
a18d66cefb ("diff.c: free "buf" in diff_words_flush()", 2022-03-04),
the regression is discussed in detail in the subsequent commit. With
it running `git show --word-diff --color-moved` with SANITIZE=address
would emit:

==31191==ERROR: AddressSanitizer: attempting double-free on 0x617000021100 in thread T0:
    #0 0x49f0a2 in free (git+0x49f0a2)
    #1 0x9b0e4d in diff_words_flush diff.c:2153:3
    #2 0x9aed5d in fn_out_consume diff.c:2354:3
    #3 0xe092ab in consume_one xdiff-interface.c:43:9
    #4 0xe072eb in xdiff_outf xdiff-interface.c:76:10
    #5 0xec7014 in xdl_emit_diffrec xdiff/xutils.c:53:6
    [...]

0x617000021100 is located 0 bytes inside of 768-byte region [0x617000021100,0x617000021400)
freed by thread T0 here:
    #0 0x49f0a2 in free (git+0x49f0a2)
    [...(same stacktrace)...]

previously allocated by thread T0 here:
    #0 0x49f603 in __interceptor_realloc (git+0x49f603)
    #1 0xde4da4 in xrealloc wrapper.c:126:8
    #2 0x995dc5 in append_emitted_diff_symbol diff.c:794:2
    #3 0x96c44a in emit_diff_symbol diff.c:1527:3
    [...]

This was not caught by the test suite because we test `diff
--word-diff --color-moved` only so far.

Therefore, add a test for `show`, too.

Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoThe twelfth batch
Junio C Hamano [Thu, 17 Mar 2022 00:45:59 +0000 (17:45 -0700)] 
The twelfth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ab/string-list-count-in-size-t'
Junio C Hamano [Thu, 17 Mar 2022 00:53:09 +0000 (17:53 -0700)] 
Merge branch 'ab/string-list-count-in-size-t'

Count string_list items in size_t, not "unsigned int".

* ab/string-list-count-in-size-t:
  string-list API: change "nr" and "alloc" to "size_t"
  gettext API users: don't explicitly cast ngettext()'s "n"

2 years agoMerge branch 'ab/racy-hooks'
Junio C Hamano [Thu, 17 Mar 2022 00:53:09 +0000 (17:53 -0700)] 
Merge branch 'ab/racy-hooks'

Code clean-up to allow callers of run_commit_hook() to learn if it
got "success" because the hook succeeded or because there wasn't
any hook.

* ab/racy-hooks:
  hooks: fix an obscure TOCTOU "did we just run a hook?" race
  merge: don't run post-hook logic on --no-verify

2 years agoMerge branch 'ab/keep-git-exit-codes-in-tests'
Junio C Hamano [Thu, 17 Mar 2022 00:53:09 +0000 (17:53 -0700)] 
Merge branch 'ab/keep-git-exit-codes-in-tests'

Updates tests around the use of "test $(git cmd) = constant".

* ab/keep-git-exit-codes-in-tests:
  rev-list simplify tests: don't ignore "git" exit code
  checkout tests: don't ignore "git <cmd>" exit code
  apply tests: don't ignore "git ls-files" exit code, drop sub-shell
  gettext tests: don't ignore "test-tool regex" exit code
  rev-list tests: don't hide abort() in "test_expect_failure"
  diff tests: don't ignore "git rev-list" exit code
  notes tests: don't ignore "git" exit code
  rev-parse tests: don't ignore "git reflog" exit code
  merge tests: use "test_must_fail" instead of ad-hoc pattern
  apply tests: use "test_must_fail" instead of ad-hoc pattern
  diff tests: don't ignore "git diff" exit code in "read" loop
  diff tests: don't ignore "git diff" exit code
  read-tree tests: check "diff-files" exit code on failure
  tests: use "test_stdout_line_count", not "test $(git [...] | wc -l)"
  tests: change some 'test $(git) = "x"' to test_cmp

2 years agoMerge branch 'tk/t7063-chmtime-dirs-too'
Junio C Hamano [Thu, 17 Mar 2022 00:53:09 +0000 (17:53 -0700)] 
Merge branch 'tk/t7063-chmtime-dirs-too'

Teach "test-chmtime" to work on a directory and use it to avoid
having to wait for a second in a few places in tests.

* tk/t7063-chmtime-dirs-too:
  t7063: mtime-mangling instead of delays in untracked cache testing
  t/helper/test-chmtime: update mingw to support chmtime on directories

2 years agoMerge branch 'ds/commit-graph-gen-v2-fixes'
Junio C Hamano [Thu, 17 Mar 2022 00:53:09 +0000 (17:53 -0700)] 
Merge branch 'ds/commit-graph-gen-v2-fixes'

Fixes to the way generation number v2 in the commit-graph files are
(not) handled.

* ds/commit-graph-gen-v2-fixes:
  commit-graph: declare bankruptcy on GDAT chunks
  commit-graph: fix generation number v2 overflow values
  commit-graph: start parsing generation v2 (again)
  commit-graph: fix ordering bug in generation numbers
  t5318: extract helpers to lib-commit-graph.sh
  test-read-graph: include extra post-parse info

2 years agoMerge branch 'jc/stash-drop'
Junio C Hamano [Thu, 17 Mar 2022 00:53:08 +0000 (17:53 -0700)] 
Merge branch 'jc/stash-drop'

"git stash drop" is reimplemented as an internal call to
reflog_delete() function, instead of invoking "git reflog delete"
via run_command() API.

* jc/stash-drop:
  stash: call reflog_delete() in reflog.c
  reflog: libify delete reflog function and helpers
  stash: add tests to ensure reflog --rewrite --updatref behavior

2 years agoMerge branch 'tb/rename-remote-progress'
Junio C Hamano [Thu, 17 Mar 2022 00:53:08 +0000 (17:53 -0700)] 
Merge branch 'tb/rename-remote-progress'

"git remote rename A B", depending on the number of remote-tracking
refs involved, takes long time renaming them.  The command has been
taught to show progress bar while making the user wait.

* tb/rename-remote-progress:
  builtin/remote.c: show progress when renaming remote references
  builtin/remote.c: parse options in 'rename'

2 years agoMerge branch 'vd/sparse-read-tree'
Junio C Hamano [Thu, 17 Mar 2022 00:53:08 +0000 (17:53 -0700)] 
Merge branch 'vd/sparse-read-tree'

"git read-tree" has been made to be aware of the sparse-index
feature.

* vd/sparse-read-tree:
  read-tree: make three-way merge sparse-aware
  read-tree: make two-way merge sparse-aware
  read-tree: narrow scope of index expansion for '--prefix'
  read-tree: integrate with sparse index
  read-tree: expand sparse checkout test coverage
  read-tree: explicitly disallow prefixes with a leading '/'
  status: fix nested sparse directory diff in sparse index
  sparse-index: prevent repo root from becoming sparse

2 years agoMerge branch 'ab/object-file-api-updates'
Junio C Hamano [Thu, 17 Mar 2022 00:53:08 +0000 (17:53 -0700)] 
Merge branch 'ab/object-file-api-updates'

Object-file API shuffling.

* ab/object-file-api-updates:
  object-file API: pass an enum to read_object_with_reference()
  object-file.c: add a literal version of write_object_file_prepare()
  object-file API: have hash_object_file() take "enum object_type"
  object API: rename hash_object_file_literally() to write_*()
  object-file API: split up and simplify check_object_signature()
  object API users + docs: check <0, not !0 with check_object_signature()
  object API docs: move check_object_signature() docs to cache.h
  object API: correct "buf" v.s. "map" mismatch in *.c and *.h
  object-file API: have write_object_file() take "enum object_type"
  object-file API: add a format_object_header() function
  object-file API: return "void", not "int" from hash_object_file()
  object-file.c: split up declaration of unrelated variables

2 years agoMerge branch 'mf/fix-type-in-config-h'
Junio C Hamano [Thu, 17 Mar 2022 00:53:07 +0000 (17:53 -0700)] 
Merge branch 'mf/fix-type-in-config-h'

"git config -h" did not describe the "--type" option correctly.

* mf/fix-type-in-config-h:
  config: correct "--type" option in "git config -h" output

2 years agoMerge branch 'ps/fetch-mirror-optim'
Junio C Hamano [Thu, 17 Mar 2022 00:53:07 +0000 (17:53 -0700)] 
Merge branch 'ps/fetch-mirror-optim'

Various optimization for "git fetch".

* ps/fetch-mirror-optim:
  refs/files-backend: optimize reading of symbolic refs
  remote: read symbolic refs via `refs_read_symbolic_ref()`
  refs: add ability for backends to special-case reading of symbolic refs
  fetch: avoid lookup of commits when not appending to FETCH_HEAD
  upload-pack: look up "want" lines via commit-graph

2 years agoMerge branch 'tk/empty-untracked-cache'
Junio C Hamano [Thu, 17 Mar 2022 00:53:07 +0000 (17:53 -0700)] 
Merge branch 'tk/empty-untracked-cache'

The untracked cache newly computed weren't written back to the
on-disk index file when there is no other change to the index,
which has been corrected.

* tk/empty-untracked-cache:
  untracked-cache: write index when populating empty untracked cache
  t7519: populate untracked cache before test
  t7519: avoid file to index mtime race for untracked cache

2 years agoMerge branch 'ab/grep-patterntype'
Junio C Hamano [Thu, 17 Mar 2022 00:53:06 +0000 (17:53 -0700)] 
Merge branch 'ab/grep-patterntype'

Test fix-up for a topic already in master.

* ab/grep-patterntype:
  log tests: fix "abort tests early" regression in ff37a60c369

2 years agopartial-clone: add a partial-clone test case
Abhradeep Chakraborty [Wed, 16 Mar 2022 09:46:09 +0000 (09:46 +0000)] 
partial-clone: add a partial-clone test case

In a blobless-cloned repo, `git log --follow -- <path>` (`<path>` have
an exact OID rename) shouldn't download blob of the file from where the
new file is renamed.

Add a test case to verify it.

Signed-off-by: Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agosequencer: use reverse_commit_list() helper
Jayati Shrivastava [Wed, 16 Mar 2022 11:20:23 +0000 (11:20 +0000)] 
sequencer: use reverse_commit_list() helper

Instead of creating a new allocation, reverse the original list
in-place by calling the reverse_commit_list() helper.

The original code discards the list "bases" after storing its
reverse copy in a newly created list "reversed".  If the code that
followed from here used both "bases" and "reversed", the
modification would not have worked, but since the original list
"bases" gets discarded, we can simply reverse "bases" in-place with
the reverse_commit_list() helper and reuse the same variable in the
code that follows.

builtin/merge.c has been left unmodified, since in its case, the
original list is needed separately from its reverse copy by the
code.

Signed-off-by: Jayati Shrivastava <gaurijove@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocompletion: tab completion of filenames for 'git restore'
David Cantrell [Tue, 15 Mar 2022 22:13:57 +0000 (22:13 +0000)] 
completion: tab completion of filenames for 'git restore'

If no --args are present after 'git restore', it assumes that you
want to tab-complete one of the files with unstaged uncommitted
changes.

If a file has been staged, we don't want to list it, as restoring those
requires a slightly more complex `git restore --staged`, so we only list
those files that are --modified. While --committable also looks like
a good candidate, that includes changes that have been staged.

Signed-off-by: David Cantrell <david@cantrell.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomaintenance: fix synopsis in documentation
Derrick Stolee [Tue, 15 Mar 2022 17:41:44 +0000 (17:41 +0000)] 
maintenance: fix synopsis in documentation

The synopsis for 'git maintenance' did not include the commands other
than the 'run' command. Update this to include the others. The 'start'
command is the only one of these that parses additional options, and
then only the --scheduler option.

Also move the 'register' command down after 'stop' and before
'unregister' for a logical grouping of the commands instead of an
alphabetical one. The diff makes it look as three other commands are
moved up.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocat-file: skip expanding default format
John Cai [Tue, 15 Mar 2022 02:40:36 +0000 (02:40 +0000)] 
cat-file: skip expanding default format

When format is passed into --batch, --batch-check, --batch-command,
the format gets expanded. When nothing is passed in, the default format
is set and the expand_format() gets called.

We can save on these cycles by hardcoding how to print the
information when nothing is passed as the format, or when the default
format is passed. There is no need for the fully expanded format with
the default. Since batch_object_write() happens on every object provided
in batch mode, we get a nice performance improvement.

git rev-list --all > /tmp/all-obj.txt

git cat-file --batch-check </tmp/all-obj.txt

with HEAD^:

Time (mean ± σ): 57.6 ms ± 1.7 ms [User: 51.5 ms, System: 6.2 ms]
Range (min … max): 54.6 ms … 64.7 ms 50 runs

with HEAD:

Time (mean ± σ): 49.8 ms ± 1.7 ms [User: 42.6 ms, System: 7.3 ms]
Range (min … max): 46.9 ms … 55.9 ms 56 runs

If nothing is provided as a format argument, or if the default format is
passed, skip expanding of the format and print the object info with a
default format.

See https://lore.kernel.org/git/87eecf8ork.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorepack: add config to skip updating server info
Patrick Steinhardt [Mon, 14 Mar 2022 07:42:51 +0000 (08:42 +0100)] 
repack: add config to skip updating server info

By default, git-repack(1) will update server info that is required by
the dumb HTTP transport. This can be skipped by passing the `-n` flag,
but what we're noticably missing is a config option to permanently
disable updating this information.

Add a new option "repack.updateServerInfo" which can be used to disable
the logic. Most hosting providers have turned off the dumb HTTP protocol
anyway, and on the client-side it woudln't typically be useful either.
Giving a persistent way to disable this feature thus makes quite some
sense to avoid wasting compute cycles and storage.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorepack: refactor to avoid double-negation of update-server-info
Patrick Steinhardt [Mon, 14 Mar 2022 07:42:46 +0000 (08:42 +0100)] 
repack: refactor to avoid double-negation of update-server-info

By default, git-repack(1) runs `update_server_info()` to generate info
required for the dumb HTTP protocol. This can be disabled via the `-n`
flag, which then sets the `no_update_server_info` flag. Further down the
code this leads to some double-negation logic, which is about to become
more confusing as we're about to add a new config which allows the user
to permanently disable generation of the info.

Refactor the code to avoid the double-negation and add some tests which
verify that the flag continues to work as expected.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoattr.h: remove duplicate struct definition
Elia Pinto [Mon, 14 Mar 2022 00:23:27 +0000 (00:23 +0000)] 
attr.h: remove duplicate struct definition

struct index_state is declared more than once.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoThe eleventh batch
Junio C Hamano [Sun, 13 Mar 2022 22:50:24 +0000 (22:50 +0000)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ab/plug-random-leaks'
Junio C Hamano [Sun, 13 Mar 2022 22:56:18 +0000 (22:56 +0000)] 
Merge branch 'ab/plug-random-leaks'

Plug random memory leaks.

* ab/plug-random-leaks:
  repository.c: free the "path cache" in repo_clear()
  range-diff: plug memory leak in read_patches()
  range-diff: plug memory leak in common invocation
  lockfile API users: simplify and don't leak "path"
  commit-graph: stop fill_oids_from_packs() progress on error and free()
  commit-graph: fix memory leak in misused string_list API
  submodule--helper: fix trivial leak in module_add()
  transport: stop needlessly copying bundle header references
  bundle: call strvec_clear() on allocated strvec
  remote-curl.c: free memory in cmd_main()
  urlmatch.c: add and use a *_release() function
  diff.c: free "buf" in diff_words_flush()
  merge-base: free() allocated "struct commit **" list
  index-pack: fix memory leaks

2 years agoMerge branch 'nj/read-tree-doc-reffix'
Junio C Hamano [Sun, 13 Mar 2022 22:56:18 +0000 (22:56 +0000)] 
Merge branch 'nj/read-tree-doc-reffix'

Documentation mark-up fix.

* nj/read-tree-doc-reffix:
  Documentation: git-read-tree: separate links using commas

2 years agoMerge branch 'ps/fetch-atomic-fixup'
Junio C Hamano [Sun, 13 Mar 2022 22:56:17 +0000 (22:56 +0000)] 
Merge branch 'ps/fetch-atomic-fixup'

Test simplification.

* ps/fetch-atomic-fixup:
  t5503: simplify setup of test which exercises failure of backfill

2 years agoMerge branch 'fs/gpgsm-update'
Junio C Hamano [Sun, 13 Mar 2022 22:56:17 +0000 (22:56 +0000)] 
Merge branch 'fs/gpgsm-update'

Newer version of GPGSM changed its output in a backward
incompatible way to break our code that parses its output.  It also
added more processes our tests need to kill when cleaning up.
Adjustments have been made to accommodate these changes.

* fs/gpgsm-update:
  t/lib-gpg: kill all gpg components, not just gpg-agent
  t/lib-gpg: reload gpg components after updating trustlist
  gpg-interface/gpgsm: fix for v2.3

2 years agoMerge branch 'gc/parse-tree-indirect-errors'
Junio C Hamano [Sun, 13 Mar 2022 22:56:17 +0000 (22:56 +0000)] 
Merge branch 'gc/parse-tree-indirect-errors'

Check the return value from parse_tree_indirect() to turn segfaults
into calls to die().

* gc/parse-tree-indirect-errors:
  checkout, clone: die if tree cannot be parsed

2 years agoMerge branch 'en/merge-ort-align-verbosity-with-recursive'
Junio C Hamano [Sun, 13 Mar 2022 22:56:17 +0000 (22:56 +0000)] 
Merge branch 'en/merge-ort-align-verbosity-with-recursive'

Align the level of verbose output from the ort backend during inner
merge to that of the recursive backend.

* en/merge-ort-align-verbosity-with-recursive:
  merge-ort: exclude messages from inner merges by default

2 years agoMerge branch 'ab/make-optim-noop'
Junio C Hamano [Sun, 13 Mar 2022 22:56:17 +0000 (22:56 +0000)] 
Merge branch 'ab/make-optim-noop'

Makefile refactoring with a bit of suffixes rule stripping to
optimize the runtime overhead.

* ab/make-optim-noop:
  Makefiles: add and use wildcard "mkdir -p" template
  Makefile: add "$(QUIET)" boilerplate to shared.mak
  Makefile: move $(comma), $(empty) and $(space) to shared.mak
  Makefile: move ".SUFFIXES" rule to shared.mak
  Makefile: define $(LIB_H) in terms of $(FIND_SOURCE_FILES)
  Makefile: disable GNU make built-in wildcard rules
  Makefiles: add "shared.mak", move ".DELETE_ON_ERROR" to it
  scalar Makefile: use "The default target of..." pattern

2 years agoMerge branch 'ps/fetch-atomic'
Junio C Hamano [Sun, 13 Mar 2022 22:56:16 +0000 (22:56 +0000)] 
Merge branch 'ps/fetch-atomic'

"git fetch" can make two separate fetches, but ref updates coming
from them were in two separate ref transactions under "--atomic",
which has been corrected.

* ps/fetch-atomic:
  fetch: make `--atomic` flag cover pruning of refs
  fetch: make `--atomic` flag cover backfilling of tags
  refs: add interface to iterate over queued transactional updates
  fetch: report errors when backfilling tags fails
  fetch: control lifecycle of FETCH_HEAD in a single place
  fetch: backfill tags before setting upstream
  fetch: increase test coverage of fetches

2 years agot/helper/test-run-command.c: delete duplicate include
Elia Pinto [Sun, 13 Mar 2022 19:55:36 +0000 (19:55 +0000)] 
t/helper/test-run-command.c: delete duplicate include

parse-options.h is included more than once.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobuiltin/stash.c: delete duplicate include
Elia Pinto [Sun, 13 Mar 2022 19:55:35 +0000 (19:55 +0000)] 
builtin/stash.c: delete duplicate include

 entry.h is included more than once.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobuiltin/sparse-checkout.c: delete duplicate include
Elia Pinto [Sun, 13 Mar 2022 19:55:34 +0000 (19:55 +0000)] 
builtin/sparse-checkout.c: delete duplicate include

cache.h is included more than once.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobuiltin/gc.c: delete duplicate include
Elia Pinto [Sun, 13 Mar 2022 19:55:33 +0000 (19:55 +0000)] 
builtin/gc.c: delete duplicate include

object-store.h is included more than once.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoattr.c: delete duplicate include
Elia Pinto [Sun, 13 Mar 2022 19:55:32 +0000 (19:55 +0000)] 
attr.c: delete duplicate include

dir.h is included more than once

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot6423-merge-rename-directories.sh: use the $(...) construct
Elia Pinto [Sun, 13 Mar 2022 17:28:29 +0000 (17:28 +0000)] 
t6423-merge-rename-directories.sh: use the $(...) construct

The Git CodingGuidelines prefer the $(...) construct for command
substitution instead of using the backquotes `...`.

The backquoted form is the traditional method for command
substitution, and is supported by POSIX.  However, all but the
simplest uses become complicated quickly.  In particular, embedded
command substitutions and/or the use of double quotes require
careful escaping with the backslash character.

The patch was generated by:

for _f in $(find . -name "*.sh")
do
shellcheck -i SC2006 -f diff ${_f} | ifne git apply -p2
done

and then carefully proof-read.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoname-rev: use generation numbers if available
Jacob Keller [Sat, 12 Mar 2022 00:00:15 +0000 (16:00 -0800)] 
name-rev: use generation numbers if available

If a commit in a sequence of linear history has a non-monotonically
increasing commit timestamp, git name-rev might not properly name the
commit.

This occurs because name-rev uses a heuristic of the commit date to
avoid searching down tags which lead to commits that are older than the
named commit. This is intended to avoid work on larger repositories.

This heuristic impacts git name-rev, and by extension git describe
--contains which is built on top of name-rev.

Further more, if --all or --annotate-stdin is used, the heuristic is not
enabled because the full history has to be analyzed anyways. This
results in some confusion if a user sees that --annotate-stdin works but
a normal name-rev does not.

If the repository has a commit graph, we can use the generation numbers
instead of using the commit dates. This is essentially the same check
except that generation numbers make it exact, where the commit date
heuristic could be incorrect due to clock errors.

Since we're extending the notion of cutoff to more than one variable,
create a series of functions for setting and checking the cutoff. This
avoids duplication and moves access of the global cutoff and
generation_cutoff to as few functions as possible.

Add several test cases including a test that covers the new commitGraph
behavior, as well as tests for --all and --annotate-stdin with and
without commitGraphs.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoreflog: don't be noisy on empty reflogs
Ævar Arnfjörð Bjarmason [Thu, 10 Mar 2022 22:56:11 +0000 (23:56 +0100)] 
reflog: don't be noisy on empty reflogs

Fix a regression in my daf1d8285ee (reflog expire: don't use
lookup_commit_reference_gently(), 2021-12-22), in changing from
lookup_commit_reference_gently() to lookup_commit() we stopped trying
to call deref_tag() and parse_object() on the provided OID, but we
also started returning non-NULL for the null_oid().

As a result we'd emit an error() via mark_reachable() later in this
function as we tried to invoke parse_commit() on it.

Reported-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Tested-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agouserdiff: add builtin diff driver for kotlin language.
Jaydeep P Das [Sat, 12 Mar 2022 04:48:32 +0000 (10:18 +0530)] 
userdiff: add builtin diff driver for kotlin language.

The xfuncname pattern finds func/class declarations
in diffs to display as a hunk header. The word_regex
pattern finds individual tokens in Kotlin code to generate
appropriate diffs.

This patch adds xfuncname regex and word_regex for Kotlin
language.

Signed-off-by: Jaydeep P Das <jaydeepjd.8914@gmail.com>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot0030-t0050: avoid pipes with Git on LHS
Shubham Mishra [Sat, 12 Mar 2022 06:21:26 +0000 (11:51 +0530)] 
t0030-t0050: avoid pipes with Git on LHS

Pipes ignore error codes of LHS command and thus we should not use
them with Git in tests. As an alternative, use a 'tmp' file to write
the Git output so we can test the exit code.

Signed-off-by: Shubham Mishra <shivam828787@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot0001-t0028: avoid pipes with Git on LHS
Shubham Mishra [Sat, 12 Mar 2022 06:21:25 +0000 (11:51 +0530)] 
t0001-t0028: avoid pipes with Git on LHS

Pipes ignore error codes of LHS command and thus we should not use
them with Git in tests. As an alternative, use a 'tmp' file to write
the Git output so we can test the exit code.

Signed-off-by: Shubham Mishra <shivam828787@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>