From: Junio C Hamano Date: Sun, 19 Mar 2023 22:03:12 +0000 (-0700) Subject: Merge branch 'jk/bundle-use-dash-for-stdfiles' X-Git-Tag: v2.41.0-rc0~149 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=95de3763498a5a092a454bb548d40e918c2870c1;p=thirdparty%2Fgit.git Merge branch 'jk/bundle-use-dash-for-stdfiles' "git bundle" learned that "-" is a common way to say that the input comes from the standard input and/or the output goes to the standard output. It used to work only for output and only from the root level of the working tree. * jk/bundle-use-dash-for-stdfiles: parse-options: use prefix_filename_except_for_dash() helper parse-options: consistently allocate memory in fix_filename() bundle: don't blindly apply prefix_filename() to "-" bundle: document handling of "-" as stdin bundle: let "-" mean stdin for reading operations --- 95de3763498a5a092a454bb548d40e918c2870c1 diff --cc builtin/reset.c index 58f567afd3,28083387cb..24b04aeecb --- a/builtin/reset.c +++ b/builtin/reset.c @@@ -492,9 -487,6 +493,10 @@@ int cmd_reset(int argc, const char **ar if (!pathspec.nr) remove_branch_state(the_repository, 0); + discard_index(&the_index); + +cleanup: + clear_pathspec(&pathspec); + free(pathspec_from_file); return update_ref_status; } diff --cc t/t6020-bundle-misc.sh index 8c7b25a281,7fc39660f1..dface8bcfe --- a/t/t6020-bundle-misc.sh +++ b/t/t6020-bundle-misc.sh @@@ -567,56 -566,30 +567,82 @@@ test_expect_success 'cloning from filte grep "cannot clone from filtered bundle" err ' +test_expect_success 'verify catches unreachable, broken prerequisites' ' + test_when_finished rm -rf clone-from clone-to && + git init clone-from && + ( + cd clone-from && + git checkout -b base && + test_commit A && + git checkout -b tip && + git commit --allow-empty -m "will drop by shallow" && + git commit --allow-empty -m "will keep by shallow" && + git commit --allow-empty -m "for bundle, not clone" && + git bundle create tip.bundle tip~1..tip && + git reset --hard HEAD~1 && + git checkout base + ) && + BAD_OID=$(git -C clone-from rev-parse tip~1) && + TIP_OID=$(git -C clone-from rev-parse tip) && + git clone --depth=1 --no-single-branch \ + "file://$(pwd)/clone-from" clone-to && + ( + cd clone-to && + + # Set up broken history by removing shallow markers + git update-ref -d refs/remotes/origin/tip && + rm .git/shallow && + + # Verify should fail + test_must_fail git bundle verify \ + ../clone-from/tip.bundle 2>err && + grep "some prerequisite commits .* are not connected" err && + test_line_count = 1 err && + + # Unbundling should fail + test_must_fail git bundle unbundle \ + ../clone-from/tip.bundle 2>err && + grep "some prerequisite commits .* are not connected" err && + test_line_count = 1 err + ) +' + +test_expect_success 'bundle progress includes write phase' ' + GIT_PROGRESS_DELAY=0 \ + git bundle create --progress out.bundle --all 2>err && + grep 'Writing' err +' + +test_expect_success TTY 'create --quiet disables all bundle progress' ' + test_terminal env GIT_PROGRESS_DELAY=0 \ + git bundle create --quiet out.bundle --all 2>err && + test_must_be_empty err +' + + test_expect_success 'read bundle over stdin' ' + git bundle create some.bundle HEAD && + + git bundle verify - err && + grep " is okay" err && + + git bundle list-heads some.bundle >expect && + git bundle list-heads - actual && + test_cmp expect actual && + + git bundle unbundle some.bundle >expect && + git bundle unbundle - actual && + test_cmp expect actual + ' + + test_expect_success 'send a bundle to standard output' ' + git bundle create - --all HEAD >bundle-one && + mkdir -p down && + git -C down bundle create - --all HEAD >bundle-two && + git bundle verify bundle-one && + git bundle verify bundle-two && + git ls-remote bundle-one >expect && + git ls-remote bundle-two >actual && + test_cmp expect actual + ' + test_done