Navigation Menu

Skip to content

Commit

Permalink
builtin/rebase: compute checkout metadata for rebases
Browse files Browse the repository at this point in the history
Signed-off-by: brian m. carlson <bk2204@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
bk2204 authored and gitster committed Mar 16, 2020
1 parent dfc8cdc commit 3f26785
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions builtin/rebase.c
Expand Up @@ -868,6 +868,7 @@ static int reset_head(struct object_id *oid, const char *action,
unpack_tree_opts.fn = reset_hard ? oneway_merge : twoway_merge;
unpack_tree_opts.update = 1;
unpack_tree_opts.merge = 1;
init_checkout_metadata(&unpack_tree_opts.meta, switch_to_branch, oid, NULL);
if (!detach_head)
unpack_tree_opts.reset = 1;

Expand Down
1 change: 1 addition & 0 deletions sequencer.c
Expand Up @@ -3288,6 +3288,7 @@ static int do_reset(struct repository *r,
unpack_tree_opts.fn = oneway_merge;
unpack_tree_opts.merge = 1;
unpack_tree_opts.update = 1;
init_checkout_metadata(&unpack_tree_opts.meta, name, &oid, NULL);

if (repo_read_index_unmerged(r)) {
rollback_lock_file(&lock);
Expand Down
39 changes: 38 additions & 1 deletion t/t0021-conversion.sh
Expand Up @@ -382,7 +382,8 @@ test_expect_success PERL 'required process filter should filter data' '
test_cmp_count expected.log debug.log &&
git commit -m "test commit 2" &&
META="ref=refs/heads/master treeish=$(git rev-parse --verify master)" &&
MASTER=$(git rev-parse --verify master) &&
META="ref=refs/heads/master treeish=$MASTER" &&
rm -f test2.r "testsubdir/test3 '\''sq'\'',\$x=.r" &&
filter_git checkout --quiet --no-progress . &&
Expand Down Expand Up @@ -425,6 +426,42 @@ test_expect_success PERL 'required process filter should filter data' '
)
'

test_expect_success PERL 'required process filter should filter data for various subcommands' '
test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
test_config_global filter.protocol.required true &&
(
cd repo &&
S=$(file_size test.r) &&
S2=$(file_size test2.r) &&
S3=$(file_size "testsubdir/test3 '\''sq'\'',\$x=.r") &&
M=$(git hash-object test.r) &&
M2=$(git hash-object test2.r) &&
M3=$(git hash-object "testsubdir/test3 '\''sq'\'',\$x=.r") &&
EMPTY=$(git hash-object /dev/null) &&
MASTER=$(git rev-parse --verify master) &&
cp "$TEST_ROOT/test.o" test5.r &&
git add test5.r &&
git commit -m "test commit 3" &&
git checkout empty-branch &&
filter_git rebase --onto empty-branch master^^ master &&
META="ref=refs/heads/master treeish=$(git rev-parse --verify master)" &&
cat >expected.log <<-EOF &&
START
init handshake complete
IN: smudge test.r $META blob=$M $S [OK] -- OUT: $S . [OK]
IN: smudge test2.r $META blob=$M2 $S2 [OK] -- OUT: $S2 . [OK]
IN: smudge test4-empty.r $META blob=$EMPTY 0 [OK] -- OUT: 0 [OK]
IN: smudge test5.r $META blob=$M $S [OK] -- OUT: $S . [OK]
IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $META blob=$M3 $S3 [OK] -- OUT: $S3 . [OK]
STOP
EOF
test_cmp_exclude_clean expected.log debug.log
)
'

test_expect_success PERL 'required process filter takes precedence' '
test_config_global filter.protocol.clean false &&
test_config_global filter.protocol.process "rot13-filter.pl debug.log clean" &&
Expand Down

0 comments on commit 3f26785

Please sign in to comment.