Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-06-09 00:27:51 +0300
committerJunio C Hamano <gitster@pobox.com>2022-06-09 00:27:51 +0300
commitf02e23405f51d761168d81d117fde4b816abbd2f (patch)
tree48fad31d065cf3bb0d2ef123f7e1a26e446728d4
parent9d1304155be0e79b77e1f68bdd4c9a7ac442f0e8 (diff)
parent7c898554d7a80e5d70ee8816a23dc425d2f1729c (diff)
Merge branch 'ab/valgrind-fixes' into maint
A bit of test framework fixes with a few fixes to issues found by valgrind. source: <20220512223218.237544-1-gitster@pobox.com> * ab/valgrind-fixes: commit-graph.c: don't assume that stat() succeeds object-file: fix a unpack_loose_header() regression in 3b6a8db3b03 log test: skip a failing mkstemp() test under valgrind tests: using custom GIT_EXEC_PATH breaks --valgrind tests
-rw-r--r--commit-graph.c6
-rw-r--r--object-file.c8
-rwxr-xr-xt/t0060-path-utils.sh4
-rwxr-xr-xt/t1006-cat-file.sh10
-rwxr-xr-xt/t1450-fsck.sh13
-rwxr-xr-xt/t4202-log.sh11
-rw-r--r--t/test-lib.sh1
7 files changed, 39 insertions, 14 deletions
diff --git a/commit-graph.c b/commit-graph.c
index 441b36016b..2b52818731 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2206,7 +2206,8 @@ static void mark_commit_graphs(struct write_commit_graph_context *ctx)
struct stat st;
struct utimbuf updated_time;
- stat(ctx->commit_graph_filenames_before[i], &st);
+ if (stat(ctx->commit_graph_filenames_before[i], &st) < 0)
+ continue;
updated_time.actime = st.st_atime;
updated_time.modtime = now;
@@ -2247,7 +2248,8 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
strbuf_setlen(&path, dirnamelen);
strbuf_addstr(&path, de->d_name);
- stat(path.buf, &st);
+ if (stat(path.buf, &st) < 0)
+ continue;
if (st.st_mtime > expire_time)
continue;
diff --git a/object-file.c b/object-file.c
index 5ffbf3d4fd..b5d1d12b68 100644
--- a/object-file.c
+++ b/object-file.c
@@ -2623,8 +2623,12 @@ int read_loose_object(const char *path,
goto out;
}
- if (unpack_loose_header(&stream, map, mapsize, hdr, sizeof(hdr),
- NULL) < 0) {
+ switch (unpack_loose_header(&stream, map, mapsize, hdr, sizeof(hdr),
+ NULL)) {
+ case ULHR_OK:
+ break;
+ case ULHR_BAD:
+ case ULHR_TOO_LONG:
error(_("unable to unpack header of %s"), path);
goto out;
}
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 2fe6ae6a4e..aa35350b6f 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -542,7 +542,7 @@ test_lazy_prereq CAN_EXEC_IN_PWD '
./git rev-parse
'
-test_expect_success RUNTIME_PREFIX,CAN_EXEC_IN_PWD 'RUNTIME_PREFIX works' '
+test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD 'RUNTIME_PREFIX works' '
mkdir -p pretend/bin pretend/libexec/git-core &&
echo "echo HERE" | write_script pretend/libexec/git-core/git-here &&
cp "$GIT_EXEC_PATH"/git$X pretend/bin/ &&
@@ -550,7 +550,7 @@ test_expect_success RUNTIME_PREFIX,CAN_EXEC_IN_PWD 'RUNTIME_PREFIX works' '
echo HERE >expect &&
test_cmp expect actual'
-test_expect_success RUNTIME_PREFIX,CAN_EXEC_IN_PWD '%(prefix)/ works' '
+test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD '%(prefix)/ works' '
mkdir -p pretend/bin &&
cp "$GIT_EXEC_PATH"/git$X pretend/bin/ &&
git config yes.path "%(prefix)/yes" &&
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 1b85207694..dadf3b1458 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -681,7 +681,7 @@ test_expect_success 'cat-file -t and -s on corrupt loose object' '
# Setup and create the empty blob and its path
empty_path=$(git rev-parse --git-path objects/$(test_oid_to_path "$EMPTY_BLOB")) &&
- git hash-object -w --stdin </dev/null &&
+ empty_blob=$(git hash-object -w --stdin </dev/null) &&
# Create another blob and its path
echo other >other.blob &&
@@ -722,7 +722,13 @@ test_expect_success 'cat-file -t and -s on corrupt loose object' '
# content out as-is. Try to make it zlib-invalid.
mv -f other.blob "$empty_path" &&
test_must_fail git fsck 2>err.fsck &&
- grep "^error: inflate: data stream error (" err.fsck
+ cat >expect <<-EOF &&
+ error: inflate: data stream error (incorrect header check)
+ error: unable to unpack header of ./$empty_path
+ error: $empty_blob: object corrupt or missing: ./$empty_path
+ EOF
+ grep "^error: " err.fsck >actual &&
+ test_cmp expect actual
)
'
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index de50c0ea01..ab7f31f1dc 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -774,10 +774,19 @@ test_expect_success 'fsck finds problems in duplicate loose objects' '
# no "-d" here, so we end up with duplicates
git repack &&
# now corrupt the loose copy
- file=$(sha1_file "$(git rev-parse HEAD)") &&
+ oid="$(git rev-parse HEAD)" &&
+ file=$(sha1_file "$oid") &&
rm "$file" &&
echo broken >"$file" &&
- test_must_fail git fsck
+ test_must_fail git fsck 2>err &&
+
+ cat >expect <<-EOF &&
+ error: inflate: data stream error (incorrect header check)
+ error: unable to unpack header of $file
+ error: $oid: object corrupt or missing: $file
+ EOF
+ grep "^error: " err >actual &&
+ test_cmp expect actual
)
'
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index be07407f85..6e66352558 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -1992,10 +1992,13 @@ test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
git tag -s -m signed_tag_msg signed_tag_fail &&
git checkout plain-fail &&
git merge --no-ff -m msg signed_tag_fail &&
- TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
- grep "^merged tag" actual &&
- grep "^No signature" actual &&
- ! grep "^gpg: Signature made" actual
+ if ! test_have_prereq VALGRIND
+ then
+ TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
+ grep "^merged tag" actual &&
+ grep "^No signature" actual &&
+ ! grep "^gpg: Signature made" actual
+ fi
'
test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 531cef097d..7f3d323e93 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1666,6 +1666,7 @@ test -n "$USE_LIBPCRE2" && test_set_prereq PCRE
test -n "$USE_LIBPCRE2" && test_set_prereq LIBPCRE2
test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
test -n "$SANITIZE_LEAK" && test_set_prereq SANITIZE_LEAK
+test -n "$GIT_VALGRIND_ENABLED" && test_set_prereq VALGRIND
if test -z "$GIT_TEST_CHECK_CACHE_TREE"
then