Skip to content

Commit e1ec472

Browse files
larsxschneidergitster
authored andcommitted
t0021: make debug log file name configurable
The "rot13-filter.pl" helper wrote its debug logs always to "rot13-filter.log". Make this configurable by defining the log file as first parameter of "rot13-filter.pl". This is useful if "rot13-filter.pl" is configured multiple times similar to the subsequent patch 'convert: add "status=delayed" to filter process protocol'. Signed-off-by: Lars Schneider <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 58ec9cb commit e1ec472

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

t/t0021-conversion.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ file_size () {
2828
}
2929

3030
filter_git () {
31-
rm -f rot13-filter.log &&
31+
rm -f *.log &&
3232
git "$@"
3333
}
3434

@@ -342,7 +342,7 @@ test_expect_success 'diff does not reuse worktree files that need cleaning' '
342342
'
343343

344344
test_expect_success PERL 'required process filter should filter data' '
345-
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
345+
test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
346346
test_config_global filter.protocol.required true &&
347347
rm -rf repo &&
348348
mkdir repo &&
@@ -375,7 +375,7 @@ test_expect_success PERL 'required process filter should filter data' '
375375
IN: clean testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK]
376376
STOP
377377
EOF
378-
test_cmp_count expected.log rot13-filter.log &&
378+
test_cmp_count expected.log debug.log &&
379379
380380
git commit -m "test commit 2" &&
381381
rm -f test2.r "testsubdir/test3 '\''sq'\'',\$x=.r" &&
@@ -388,7 +388,7 @@ test_expect_success PERL 'required process filter should filter data' '
388388
IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK]
389389
STOP
390390
EOF
391-
test_cmp_exclude_clean expected.log rot13-filter.log &&
391+
test_cmp_exclude_clean expected.log debug.log &&
392392
393393
filter_git checkout --quiet --no-progress empty-branch &&
394394
cat >expected.log <<-EOF &&
@@ -397,7 +397,7 @@ test_expect_success PERL 'required process filter should filter data' '
397397
IN: clean test.r $S [OK] -- OUT: $S . [OK]
398398
STOP
399399
EOF
400-
test_cmp_exclude_clean expected.log rot13-filter.log &&
400+
test_cmp_exclude_clean expected.log debug.log &&
401401
402402
filter_git checkout --quiet --no-progress master &&
403403
cat >expected.log <<-EOF &&
@@ -409,7 +409,7 @@ test_expect_success PERL 'required process filter should filter data' '
409409
IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK]
410410
STOP
411411
EOF
412-
test_cmp_exclude_clean expected.log rot13-filter.log &&
412+
test_cmp_exclude_clean expected.log debug.log &&
413413
414414
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.r &&
415415
test_cmp_committed_rot13 "$TEST_ROOT/test2.o" test2.r &&
@@ -419,7 +419,7 @@ test_expect_success PERL 'required process filter should filter data' '
419419

420420
test_expect_success PERL 'required process filter takes precedence' '
421421
test_config_global filter.protocol.clean false &&
422-
test_config_global filter.protocol.process "rot13-filter.pl clean" &&
422+
test_config_global filter.protocol.process "rot13-filter.pl debug.log clean" &&
423423
test_config_global filter.protocol.required true &&
424424
rm -rf repo &&
425425
mkdir repo &&
@@ -439,12 +439,12 @@ test_expect_success PERL 'required process filter takes precedence' '
439439
IN: clean test.r $S [OK] -- OUT: $S . [OK]
440440
STOP
441441
EOF
442-
test_cmp_count expected.log rot13-filter.log
442+
test_cmp_count expected.log debug.log
443443
)
444444
'
445445

446446
test_expect_success PERL 'required process filter should be used only for "clean" operation only' '
447-
test_config_global filter.protocol.process "rot13-filter.pl clean" &&
447+
test_config_global filter.protocol.process "rot13-filter.pl debug.log clean" &&
448448
rm -rf repo &&
449449
mkdir repo &&
450450
(
@@ -462,7 +462,7 @@ test_expect_success PERL 'required process filter should be used only for "clean
462462
IN: clean test.r $S [OK] -- OUT: $S . [OK]
463463
STOP
464464
EOF
465-
test_cmp_count expected.log rot13-filter.log &&
465+
test_cmp_count expected.log debug.log &&
466466
467467
rm test.r &&
468468
@@ -474,12 +474,12 @@ test_expect_success PERL 'required process filter should be used only for "clean
474474
init handshake complete
475475
STOP
476476
EOF
477-
test_cmp_exclude_clean expected.log rot13-filter.log
477+
test_cmp_exclude_clean expected.log debug.log
478478
)
479479
'
480480

481481
test_expect_success PERL 'required process filter should process multiple packets' '
482-
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
482+
test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
483483
test_config_global filter.protocol.required true &&
484484
485485
rm -rf repo &&
@@ -514,7 +514,7 @@ test_expect_success PERL 'required process filter should process multiple packet
514514
IN: clean 3pkt_2+1.file $(($S*2+1)) [OK] -- OUT: $(($S*2+1)) ... [OK]
515515
STOP
516516
EOF
517-
test_cmp_count expected.log rot13-filter.log &&
517+
test_cmp_count expected.log debug.log &&
518518
519519
rm -f *.file &&
520520
@@ -529,7 +529,7 @@ test_expect_success PERL 'required process filter should process multiple packet
529529
IN: smudge 3pkt_2+1.file $(($S*2+1)) [OK] -- OUT: $(($S*2+1)) ... [OK]
530530
STOP
531531
EOF
532-
test_cmp_exclude_clean expected.log rot13-filter.log &&
532+
test_cmp_exclude_clean expected.log debug.log &&
533533
534534
for FILE in *.file
535535
do
@@ -539,7 +539,7 @@ test_expect_success PERL 'required process filter should process multiple packet
539539
'
540540

541541
test_expect_success PERL 'required process filter with clean error should fail' '
542-
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
542+
test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
543543
test_config_global filter.protocol.required true &&
544544
rm -rf repo &&
545545
mkdir repo &&
@@ -558,7 +558,7 @@ test_expect_success PERL 'required process filter with clean error should fail'
558558
'
559559

560560
test_expect_success PERL 'process filter should restart after unexpected write failure' '
561-
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
561+
test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
562562
rm -rf repo &&
563563
mkdir repo &&
564564
(
@@ -579,7 +579,7 @@ test_expect_success PERL 'process filter should restart after unexpected write f
579579
git add . &&
580580
rm -f *.r &&
581581
582-
rm -f rot13-filter.log &&
582+
rm -f debug.log &&
583583
git checkout --quiet --no-progress . 2>git-stderr.log &&
584584
585585
grep "smudge write error at" git-stderr.log &&
@@ -595,7 +595,7 @@ test_expect_success PERL 'process filter should restart after unexpected write f
595595
IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK]
596596
STOP
597597
EOF
598-
test_cmp_exclude_clean expected.log rot13-filter.log &&
598+
test_cmp_exclude_clean expected.log debug.log &&
599599
600600
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.r &&
601601
test_cmp_committed_rot13 "$TEST_ROOT/test2.o" test2.r &&
@@ -609,7 +609,7 @@ test_expect_success PERL 'process filter should restart after unexpected write f
609609
'
610610

611611
test_expect_success PERL 'process filter should not be restarted if it signals an error' '
612-
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
612+
test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
613613
rm -rf repo &&
614614
mkdir repo &&
615615
(
@@ -639,7 +639,7 @@ test_expect_success PERL 'process filter should not be restarted if it signals a
639639
IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK]
640640
STOP
641641
EOF
642-
test_cmp_exclude_clean expected.log rot13-filter.log &&
642+
test_cmp_exclude_clean expected.log debug.log &&
643643
644644
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.r &&
645645
test_cmp_committed_rot13 "$TEST_ROOT/test2.o" test2.r &&
@@ -648,7 +648,7 @@ test_expect_success PERL 'process filter should not be restarted if it signals a
648648
'
649649

650650
test_expect_success PERL 'process filter abort stops processing of all further files' '
651-
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
651+
test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
652652
rm -rf repo &&
653653
mkdir repo &&
654654
(
@@ -676,7 +676,7 @@ test_expect_success PERL 'process filter abort stops processing of all further f
676676
IN: smudge abort.r $SA [OK] -- OUT: 0 [ABORT]
677677
STOP
678678
EOF
679-
test_cmp_exclude_clean expected.log rot13-filter.log &&
679+
test_cmp_exclude_clean expected.log debug.log &&
680680
681681
test_cmp "$TEST_ROOT/test.o" test.r &&
682682
test_cmp "$TEST_ROOT/test2.o" test2.r &&

t/t0021/rot13-filter.pl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# Example implementation for the Git filter protocol version 2
33
# See Documentation/gitattributes.txt, section "Filter Protocol"
44
#
5-
# The script takes the list of supported protocol capabilities as
6-
# arguments ("clean", "smudge", etc).
5+
# The first argument defines a debug log file that the script write to.
6+
# All remaining arguments define a list of supported protocol
7+
# capabilities ("clean", "smudge", etc).
78
#
89
# This implementation supports special test cases:
910
# (1) If data with the pathname "clean-write-fail.r" is processed with
@@ -24,9 +25,10 @@
2425
use IO::File;
2526

2627
my $MAX_PACKET_CONTENT_SIZE = 65516;
28+
my $log_file = shift @ARGV;
2729
my @capabilities = @ARGV;
2830

29-
open my $debug, ">>", "rot13-filter.log" or die "cannot open log file: $!";
31+
open my $debug, ">>", $log_file or die "cannot open log file: $!";
3032

3133
sub rot13 {
3234
my $str = shift;

0 commit comments

Comments
 (0)