mirror of
https://github.com/git/git.git
synced 2024-12-12 11:24:02 +08:00
a90a089611
There is a todo comment in `release_revisions()` that mentions that we
need to free the diff options, which was added via 54c8a7c379
(revisions
API: add a TODO for diff_free(&revs->diffopt), 2022-04-14). Releasing
the diff options wasn't quite feasible at that time because some call
sites rely on its contents to remain even after the revisions have been
released.
In fact, there really only are a couple of callsites that misbehave
here:
- `cmd_shortlog()` releases the revisions, but continues to access its
file pointer.
- `do_diff_cache()` creates a shallow copy of `struct diff_options`,
but does not set the `no_free` member. Consequently, we end up
releasing resources of the caller-provided diff options.
- `diff_free()` and friends do not play nice when being called
multiple times as they don't unset data structures that they have
just released.
Fix all of those cases and enable the call to `diff_free()`, which plugs
a bunch of memory leaks.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
47 lines
1.0 KiB
Bash
Executable File
47 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='--reverse combines with --parents'
|
|
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
|
|
|
|
commit () {
|
|
test_tick &&
|
|
echo $1 > foo &&
|
|
git add foo &&
|
|
git commit -m "$1"
|
|
}
|
|
|
|
test_expect_success 'set up --reverse example' '
|
|
commit one &&
|
|
git tag root &&
|
|
commit two &&
|
|
git checkout -b side HEAD^ &&
|
|
commit three &&
|
|
git checkout main &&
|
|
git merge -s ours side &&
|
|
commit five
|
|
'
|
|
|
|
test_expect_success '--reverse --parents --full-history combines correctly' '
|
|
git rev-list --parents --full-history main -- foo |
|
|
perl -e "print reverse <>" > expected &&
|
|
git rev-list --reverse --parents --full-history main -- foo \
|
|
> actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
test_expect_success '--boundary does too' '
|
|
git rev-list --boundary --parents --full-history main ^root -- foo |
|
|
perl -e "print reverse <>" > expected &&
|
|
git rev-list --boundary --reverse --parents --full-history \
|
|
main ^root -- foo > actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
test_done
|