builtin/clone: compute checkout metadata for clones
When checking out a commit, provide metadata to the filter process including the ref we're using. Signed-off-by: brian m. carlson <bk2204@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
13e7ed6a3a
commit
dfc8cdc677
@ -780,11 +780,11 @@ static int checkout(int submodule_progress)
|
|||||||
if (!strcmp(head, "HEAD")) {
|
if (!strcmp(head, "HEAD")) {
|
||||||
if (advice_detached_head)
|
if (advice_detached_head)
|
||||||
detach_advice(oid_to_hex(&oid));
|
detach_advice(oid_to_hex(&oid));
|
||||||
|
FREE_AND_NULL(head);
|
||||||
} else {
|
} else {
|
||||||
if (!starts_with(head, "refs/heads/"))
|
if (!starts_with(head, "refs/heads/"))
|
||||||
die(_("HEAD not found below refs/heads!"));
|
die(_("HEAD not found below refs/heads!"));
|
||||||
}
|
}
|
||||||
free(head);
|
|
||||||
|
|
||||||
/* We need to be in the new work tree for the checkout */
|
/* We need to be in the new work tree for the checkout */
|
||||||
setup_work_tree();
|
setup_work_tree();
|
||||||
@ -799,6 +799,7 @@ static int checkout(int submodule_progress)
|
|||||||
opts.verbose_update = (option_verbosity >= 0);
|
opts.verbose_update = (option_verbosity >= 0);
|
||||||
opts.src_index = &the_index;
|
opts.src_index = &the_index;
|
||||||
opts.dst_index = &the_index;
|
opts.dst_index = &the_index;
|
||||||
|
init_checkout_metadata(&opts.meta, head, &oid, NULL);
|
||||||
|
|
||||||
tree = parse_tree_indirect(&oid);
|
tree = parse_tree_indirect(&oid);
|
||||||
parse_tree(tree);
|
parse_tree(tree);
|
||||||
@ -806,6 +807,8 @@ static int checkout(int submodule_progress)
|
|||||||
if (unpack_trees(1, &t, &opts) < 0)
|
if (unpack_trees(1, &t, &opts) < 0)
|
||||||
die(_("unable to checkout working tree"));
|
die(_("unable to checkout working tree"));
|
||||||
|
|
||||||
|
free(head);
|
||||||
|
|
||||||
if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
|
if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
|
||||||
die(_("unable to write new index file"));
|
die(_("unable to write new index file"));
|
||||||
|
|
||||||
|
@ -748,7 +748,8 @@ test_expect_success PERL 'delayed checkout in process filter' '
|
|||||||
) &&
|
) &&
|
||||||
|
|
||||||
S=$(file_size "$TEST_ROOT/test.o") &&
|
S=$(file_size "$TEST_ROOT/test.o") &&
|
||||||
M="blob=$(git -C repo rev-parse --verify master:test.a)" &&
|
PM="ref=refs/heads/master treeish=$(git -C repo rev-parse --verify master) " &&
|
||||||
|
M="${PM}blob=$(git -C repo rev-parse --verify master:test.a)" &&
|
||||||
cat >a.exp <<-EOF &&
|
cat >a.exp <<-EOF &&
|
||||||
START
|
START
|
||||||
init handshake complete
|
init handshake complete
|
||||||
@ -789,8 +790,11 @@ test_expect_success PERL 'delayed checkout in process filter' '
|
|||||||
|
|
||||||
rm *.a *.b &&
|
rm *.a *.b &&
|
||||||
filter_git checkout . &&
|
filter_git checkout . &&
|
||||||
test_cmp_count ../a.exp a.log &&
|
# We are not checking out a ref here, so filter out ref metadata.
|
||||||
test_cmp_count ../b.exp b.log &&
|
sed -e "s!$PM!!" ../a.exp >a.exp.filtered &&
|
||||||
|
sed -e "s!$PM!!" ../b.exp >b.exp.filtered &&
|
||||||
|
test_cmp_count a.exp.filtered a.log &&
|
||||||
|
test_cmp_count b.exp.filtered b.log &&
|
||||||
|
|
||||||
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.a &&
|
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.a &&
|
||||||
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test-delay10.a &&
|
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test-delay10.a &&
|
||||||
|
Loading…
Reference in New Issue
Block a user