File tree 2 files changed +45
-1
lines changed
2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 16
16
# To avoid this, we append a slash to the directory path to make it a "full" entry.
17
17
components = split ($1 , _, " /" );
18
18
if ($0 ~ /type=dir / && components == 1 ) {
19
- $1 = $1 " /" ;
19
+ if ($0 !~ /^ /) {
20
+ $1 = $1 " /" ;
21
+ }
22
+ else {
23
+ # this line is the root directory and only contains orphaned keywords, which will be discarded
24
+ next ;
25
+ }
20
26
}
21
27
} else {
22
28
# this line declares some path under a parent directory, which will be discarded
Original file line number Diff line number Diff line change @@ -465,3 +465,41 @@ assert_unused_listing(
465
465
"lib/tests/tar/unused/space in name.txt" ,
466
466
],
467
467
)
468
+
469
+ #############
470
+ # Example 16: Ensure that root directories are properly handled with strip_prefix (bug #978)
471
+ # Don't assume that files or directories exist after stripping the prefix. See (bug #851)
472
+
473
+ _SRCS16 = [
474
+ "src_file" ,
475
+ ":fixture1" ,
476
+ ]
477
+
478
+ mtree_spec (
479
+ name = "mtree16" ,
480
+ srcs = _SRCS16 ,
481
+ )
482
+
483
+ mtree_mutate (
484
+ name = "strip_prefix16" ,
485
+ mtree = ":mtree16" ,
486
+ strip_prefix = "lib" ,
487
+ )
488
+
489
+ tar (
490
+ name = "tar_strip_prefix16" ,
491
+ srcs = _SRCS16 ,
492
+ out = "16.tar" ,
493
+ mtree = "strip_prefix16" ,
494
+ )
495
+
496
+ assert_tar_listing (
497
+ name = "test_strip_prefix16" ,
498
+ actual = "tar_strip_prefix16" ,
499
+ expected = [
500
+ "drwxr-xr-x 0 0 0 0 Jan 1 2023 tests/" ,
501
+ "drwxr-xr-x 0 0 0 0 Jan 1 2023 tests/tar/" ,
502
+ "-rwxr-xr-x 0 0 0 21 Jan 1 2023 tests/tar/src_file" ,
503
+ "-rwxr-xr-x 0 0 0 7 Jan 1 2023 tests/tar/generated.txt" ,
504
+ ],
505
+ )
You can’t perform that action at this time.
0 commit comments