diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b419a84e2cc660..58e2ca43e475e8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,10 +69,11 @@ test:linux: CC: gcc artifacts: paths: + - build/meson-logs - t/failed-test-artifacts reports: junit: build/meson-logs/testlog.junit.xml - when: on_failure + when: always test:osx: image: $image @@ -111,10 +112,11 @@ test:osx: CC: clang artifacts: paths: + - build/meson-logs - t/failed-test-artifacts reports: junit: build/meson-logs/testlog.junit.xml - when: on_failure + when: always .windows_before_script: &windows_before_script # Disabling realtime monitoring fails on some of the runners, but it @@ -183,11 +185,14 @@ test:msvc-meson: - job: "build:msvc-meson" artifacts: true script: - - meson test -C build --no-rebuild --print-errorlogs --slice $Env:CI_NODE_INDEX/$Env:CI_NODE_TOTAL + - meson test -C build --test-args=-x --no-rebuild --print-errorlogs --slice $Env:CI_NODE_INDEX/$Env:CI_NODE_TOTAL parallel: 10 artifacts: + paths: + - build/meson-logs reports: junit: build/meson-logs/testlog.junit.xml + when: always test:fuzz-smoke-tests: image: ubuntu:latest diff --git a/builtin/last-modified.c b/builtin/last-modified.c index c80f0535f6a503..d0944673f080f7 100644 --- a/builtin/last-modified.c +++ b/builtin/last-modified.c @@ -123,7 +123,7 @@ static void add_path_from_diff(struct diff_queue_struct *q, static int populate_paths_from_revs(struct last_modified *lm) { - int num_interesting = 0; + int num_interesting = 0, ret = 0; struct diff_options diffopt; /* @@ -145,16 +145,25 @@ static int populate_paths_from_revs(struct last_modified *lm) if (obj->item->flags & UNINTERESTING) continue; - if (num_interesting++) - return error(_("last-modified can only operate on one tree at a time")); + if (num_interesting++) { + ret = error(_("last-modified can only operate on one commit at a time")); + goto out; + } + + if (!repo_peel_to_type(lm->rev.repo, obj->path, 0, obj->item, OBJ_COMMIT)) { + ret = error(_("revision argument '%s' is a %s, not a commit-ish"), obj->name, type_name(obj->item->type)); + goto out; + } diff_tree_oid(lm->rev.repo->hash_algo->empty_tree, &obj->item->oid, "", &diffopt); diff_flush(&diffopt); } + +out: clear_pathspec(&diffopt.pathspec); - return 0; + return ret; } static void last_modified_emit(struct last_modified *lm, @@ -491,7 +500,7 @@ static int last_modified_init(struct last_modified *lm, struct repository *r, lm->rev.bloom_filter_settings = get_bloom_filter_settings(lm->rev.repo); if (populate_paths_from_revs(lm) < 0) - return error(_("unable to setup last-modified")); + return -1; CALLOC_ARRAY(lm->all_paths, hashmap_get_size(&lm->paths)); lm->all_paths_nr = 0; diff --git a/ci/lib.sh b/ci/lib.sh index 3ecbf147db4fc1..9f796af319c925 100755 --- a/ci/lib.sh +++ b/ci/lib.sh @@ -282,7 +282,15 @@ fi MAKEFLAGS="$MAKEFLAGS --jobs=$JOBS" GIT_PROVE_OPTS="--timer --jobs $JOBS" -GIT_TEST_OPTS="$GIT_TEST_OPTS --verbose-log -x" +GIT_TEST_OPTS="$GIT_TEST_OPTS -x" + +case "$jobname" in +*-meson) + ;; +*) + GIT_TEST_OPTS="$GIT_TEST_OPTS --verbose-log";; +esac + case "$CI_OS_NAME" in windows|windows_nt) GIT_TEST_OPTS="$GIT_TEST_OPTS --no-chain-lint --no-bin-wrappers" diff --git a/ci/run-test-slice-meson.sh b/ci/run-test-slice-meson.sh deleted file mode 100755 index 961c94fba0b2ee..00000000000000 --- a/ci/run-test-slice-meson.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# We must load the build options so we know where to find -# things like TEST_OUTPUT_DIRECTORY. This has to come before -# loading lib.sh, though, because it may clobber some CI lib -# variables like our custom GIT_TEST_OPTS. -. "$1"/GIT-BUILD-OPTIONS -. ${0%/*}/lib.sh - -group "Run tests" \ - meson test -C "$1" --no-rebuild --print-errorlogs \ - --test-args="$GIT_TEST_OPTS" --slice "$((1+$2))/$3" || -handle_failed_tests diff --git a/t/t8020-last-modified.sh b/t/t8020-last-modified.sh index 50f4312f715f41..b8cedd1118ffbe 100755 --- a/t/t8020-last-modified.sh +++ b/t/t8020-last-modified.sh @@ -8,14 +8,11 @@ test_expect_success 'setup' ' test_commit 1 file && mkdir a && test_commit 2 a/file && + git tag -mA t2 2 && mkdir a/b && test_commit 3 a/b/file ' -test_expect_success 'cannot run last-modified on two trees' ' - test_must_fail git last-modified HEAD HEAD~1 -' - check_last_modified() { local indir= && while test $# != 0 @@ -55,6 +52,13 @@ test_expect_success 'last-modified recursive' ' EOF ' +test_expect_success 'last-modified on annotated tag' ' + check_last_modified t2 <<-\EOF + 2 a + 1 file + EOF +' + test_expect_success 'last-modified recursive with show-trees' ' check_last_modified -r -t <<-\EOF 3 a/b @@ -230,9 +234,19 @@ test_expect_success 'last-modified merge undoes changes' ' EOF ' +test_expect_success 'cannot run last-modified on two commits' ' + test_must_fail git last-modified HEAD HEAD~1 2>err && + test_grep "last-modified can only operate on one commit at a time" err +' + test_expect_success 'last-modified complains about unknown arguments' ' test_must_fail git last-modified --foo 2>err && - grep "unknown last-modified argument: --foo" err + test_grep "unknown last-modified argument: --foo" err +' + +test_expect_success 'last-modified expects commit-ish' ' + test_must_fail git last-modified HEAD^{tree} 2>err && + test_grep "revision argument ${SQ}HEAD^{tree}${SQ} is a tree, not a commit-ish" err ' test_done