File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -780,11 +780,11 @@ static int checkout(int submodule_progress)
780
780
if (!strcmp (head , "HEAD" )) {
781
781
if (advice_detached_head )
782
782
detach_advice (oid_to_hex (& oid ));
783
+ FREE_AND_NULL (head );
783
784
} else {
784
785
if (!starts_with (head , "refs/heads/" ))
785
786
die (_ ("HEAD not found below refs/heads!" ));
786
787
}
787
- free (head );
788
788
789
789
/* We need to be in the new work tree for the checkout */
790
790
setup_work_tree ();
@@ -799,13 +799,16 @@ static int checkout(int submodule_progress)
799
799
opts .verbose_update = (option_verbosity >= 0 );
800
800
opts .src_index = & the_index ;
801
801
opts .dst_index = & the_index ;
802
+ init_checkout_metadata (& opts .meta , head , & oid , NULL );
802
803
803
804
tree = parse_tree_indirect (& oid );
804
805
parse_tree (tree );
805
806
init_tree_desc (& t , tree -> buffer , tree -> size );
806
807
if (unpack_trees (1 , & t , & opts ) < 0 )
807
808
die (_ ("unable to checkout working tree" ));
808
809
810
+ free (head );
811
+
809
812
if (write_locked_index (& the_index , & lock_file , COMMIT_LOCK ))
810
813
die (_ ("unable to write new index file" ));
811
814
Original file line number Diff line number Diff line change @@ -748,7 +748,8 @@ test_expect_success PERL 'delayed checkout in process filter' '
748
748
) &&
749
749
750
750
S=$(file_size "$TEST_ROOT/test.o") &&
751
- M="blob=$(git -C repo rev-parse --verify master:test.a)" &&
751
+ PM="ref=refs/heads/master treeish=$(git -C repo rev-parse --verify master) " &&
752
+ M="${PM}blob=$(git -C repo rev-parse --verify master:test.a)" &&
752
753
cat >a.exp <<-EOF &&
753
754
START
754
755
init handshake complete
@@ -789,8 +790,11 @@ test_expect_success PERL 'delayed checkout in process filter' '
789
790
790
791
rm *.a *.b &&
791
792
filter_git checkout . &&
792
- test_cmp_count ../a.exp a.log &&
793
- test_cmp_count ../b.exp b.log &&
793
+ # We are not checking out a ref here, so filter out ref metadata.
794
+ sed -e "s!$PM!!" ../a.exp >a.exp.filtered &&
795
+ sed -e "s!$PM!!" ../b.exp >b.exp.filtered &&
796
+ test_cmp_count a.exp.filtered a.log &&
797
+ test_cmp_count b.exp.filtered b.log &&
794
798
795
799
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.a &&
796
800
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test-delay10.a &&
You can’t perform that action at this time.
0 commit comments