]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/bundle-use-dash-for-stdfiles'
authorJunio C Hamano <gitster@pobox.com>
Sun, 19 Mar 2023 22:03:12 +0000 (15:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 19 Mar 2023 22:03:12 +0000 (15:03 -0700)
"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

1  2 
Documentation/git-bundle.txt
builtin/bundle.c
builtin/checkout.c
builtin/reset.c
builtin/tag.c
cache.h
parse-options.c
t/t6020-bundle-misc.sh

Simple merge
Simple merge
Simple merge
diff --cc builtin/reset.c
index 58f567afd3ecb8246649a8c6dfd37e58b01c8160,28083387cbb7dd89b05b7538b449149b0b927501..24b04aeecb9222750fe9dd7dcff1e1ab97cb467f
@@@ -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 builtin/tag.c
Simple merge
diff --cc cache.h
Simple merge
diff --cc parse-options.c
Simple merge
index 8c7b25a281751ef510497a9f662bd1652125cfc3,7fc39660f1b6bae98eb0cd5267afd84fdd345554..dface8bcfe2641ee07ee36309d1c333224879283
@@@ -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 - <some.bundle 2>err &&
+       grep "<stdin> is okay" err &&
+       git bundle list-heads some.bundle >expect &&
+       git bundle list-heads - <some.bundle >actual &&
+       test_cmp expect actual &&
+       git bundle unbundle some.bundle >expect &&
+       git bundle unbundle - <some.bundle >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