builtin/rebase: compute checkout metadata for rebases
Signed-off-by: brian m. carlson <bk2204@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Mar 16, 2020 at 18:05 UTC
3f267856243693676c04b4d6dfa1e22de62e407a
3 files changed
+40
-1
builtin/rebase.c
+1
@@ -868,6 +868,7 @@ static int reset_head(struct object_id *oid, const char *action,
868
unpack_tree_opts.fn = reset_hard ? oneway_merge : twoway_merge;
869
unpack_tree_opts.update = 1;
870
unpack_tree_opts.merge = 1;
871
+ init_checkout_metadata(&unpack_tree_opts.meta, switch_to_branch, oid, NULL);
872
if (!detach_head)
873
unpack_tree_opts.reset = 1;
874
sequencer.c
+1
@@ -3288,6 +3288,7 @@ static int do_reset(struct repository *r,
3288
unpack_tree_opts.fn = oneway_merge;
3289
unpack_tree_opts.merge = 1;
3290
unpack_tree_opts.update = 1;
3291
+ init_checkout_metadata(&unpack_tree_opts.meta, name, &oid, NULL);
3292
3293
if (repo_read_index_unmerged(r)) {
3294
rollback_lock_file(&lock);
t/t0021-conversion.sh
+38
-1
@@ -382,7 +382,8 @@ test_expect_success PERL 'required process filter should filter data' '
382
test_cmp_count expected.log debug.log &&
383
384
git commit -m "test commit 2" &&
385
- META="ref=refs/heads/master treeish=$(git rev-parse --verify master)" &&
385
+ MASTER=$(git rev-parse --verify master) &&
386
+ META="ref=refs/heads/master treeish=$MASTER" &&
387
rm -f test2.r "testsubdir/test3 '\''sq'\'',\$x=.r" &&
388
389
filter_git checkout --quiet --no-progress . &&
@@ -425,6 +426,42 @@ test_expect_success PERL 'required process filter should filter data' '
426
)
427
'
428
429
+test_expect_success PERL 'required process filter should filter data for various subcommands' '
430
+ test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
431
+ test_config_global filter.protocol.required true &&
432
+ (
433
+ cd repo &&
434
+
435
+ S=$(file_size test.r) &&
436
+ S2=$(file_size test2.r) &&
437
+ S3=$(file_size "testsubdir/test3 '\''sq'\'',\$x=.r") &&
438
+ M=$(git hash-object test.r) &&
439
+ M2=$(git hash-object test2.r) &&
440
+ M3=$(git hash-object "testsubdir/test3 '\''sq'\'',\$x=.r") &&
441
+ EMPTY=$(git hash-object /dev/null) &&
442
+
443
+ MASTER=$(git rev-parse --verify master) &&
444
+
445
+ cp "$TEST_ROOT/test.o" test5.r &&
446
+ git add test5.r &&
447
+ git commit -m "test commit 3" &&
448
+ git checkout empty-branch &&
449
+ filter_git rebase --onto empty-branch master^^ master &&
450
+ META="ref=refs/heads/master treeish=$(git rev-parse --verify master)" &&
451
+ cat >expected.log <<-EOF &&
452
+ START
453
+ init handshake complete
454
+ IN: smudge test.r $META blob=$M $S [OK] -- OUT: $S . [OK]
455
+ IN: smudge test2.r $META blob=$M2 $S2 [OK] -- OUT: $S2 . [OK]
456
+ IN: smudge test4-empty.r $META blob=$EMPTY 0 [OK] -- OUT: 0 [OK]
457
+ IN: smudge test5.r $META blob=$M $S [OK] -- OUT: $S . [OK]
458
+ IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $META blob=$M3 $S3 [OK] -- OUT: $S3 . [OK]
459
+ STOP
460
+ EOF
461
+ test_cmp_exclude_clean expected.log debug.log
462
+ )
463
+'
464
+
465
test_expect_success PERL 'required process filter takes precedence' '
466
test_config_global filter.protocol.clean false &&
467
test_config_global filter.protocol.process "rot13-filter.pl debug.log clean" &&