@@ -284,6 +284,7 @@ sub plan_unstow {
284
284
$self -> {stow_path },
285
285
$package ,
286
286
' .' ,
287
+ $path ,
287
288
);
288
289
}
289
290
debug(2, " Planning unstow of package $package ... done" );
@@ -316,6 +317,7 @@ sub plan_stow {
316
317
$package ,
317
318
' .' ,
318
319
$path , # source from target
320
+ 0,
319
321
);
320
322
debug(2, " Planning stow of package $package ... done" );
321
323
$self -> {action_count }++;
@@ -367,10 +369,12 @@ sub within_target_do {
367
369
# ============================================================================
368
370
sub stow_contents {
369
371
my $self = shift ;
370
- my ($stow_path , $package , $target , $source ) = @_ ;
371
-
372
- my $path = join_paths($stow_path , $package , $target );
372
+ my ($stow_path , $package , $target , $source , $level ) = @_ ;
373
373
374
+ # Remove leading $level times .. from $source
375
+ my $n = 0;
376
+ my $path = join ' /' , map { (++$n <= $level ) ? ( ) : $_ } (split m { /+} , $source );
377
+
374
378
return if $self -> should_skip_target_which_is_stow_dir($target );
375
379
376
380
my $cwd = getcwd();
@@ -407,6 +411,7 @@ sub stow_contents {
407
411
$package ,
408
412
$node_target , # target
409
413
join_paths($source , $node ), # source
414
+ $level
410
415
);
411
416
}
412
417
}
@@ -429,7 +434,7 @@ sub stow_contents {
429
434
# ============================================================================
430
435
sub stow_node {
431
436
my $self = shift ;
432
- my ($stow_path , $package , $target , $source ) = @_ ;
437
+ my ($stow_path , $package , $target , $source , $level ) = @_ ;
433
438
434
439
my $path = join_paths($stow_path , $package , $target );
435
440
@@ -499,12 +504,14 @@ sub stow_node {
499
504
$existing_package ,
500
505
$target ,
501
506
join_paths(' ..' , $existing_source ),
507
+ $level + 1,
502
508
);
503
509
$self -> stow_contents(
504
510
$self -> {stow_path },
505
511
$package ,
506
512
$target ,
507
513
join_paths(' ..' , $source ),
514
+ $level + 1,
508
515
);
509
516
}
510
517
else {
@@ -531,6 +538,7 @@ sub stow_node {
531
538
$package ,
532
539
$target ,
533
540
join_paths(' ..' , $source ),
541
+ $level + 1,
534
542
);
535
543
}
536
544
else {
@@ -554,6 +562,7 @@ sub stow_node {
554
562
$package ,
555
563
$target ,
556
564
join_paths(' ..' , $source ),
565
+ $level + 1,
557
566
);
558
567
}
559
568
else {
@@ -740,9 +749,7 @@ sub unstow_node_orig {
740
749
# ============================================================================
741
750
sub unstow_contents {
742
751
my $self = shift ;
743
- my ($stow_path , $package , $target ) = @_ ;
744
-
745
- my $path = join_paths($stow_path , $package , $target );
752
+ my ($stow_path , $package , $target , $path ) = @_ ;
746
753
747
754
return if $self -> should_skip_target_which_is_stow_dir($target );
748
755
@@ -778,7 +785,7 @@ sub unstow_contents {
778
785
$node_target = $adj_node_target ;
779
786
}
780
787
781
- $self -> unstow_node($stow_path , $package , $node_target );
788
+ $self -> unstow_node($stow_path , $package , $node_target , join_paths( $path , $node ) );
782
789
}
783
790
if (-d $target ) {
784
791
$self -> cleanup_invalid_links($target );
@@ -798,7 +805,7 @@ sub unstow_contents {
798
805
# ============================================================================
799
806
sub unstow_node {
800
807
my $self = shift ;
801
- my ($stow_path , $package , $target ) = @_ ;
808
+ my ($stow_path , $package , $target , $source ) = @_ ;
802
809
803
810
my $path = join_paths($stow_path , $package , $target );
804
811
@@ -872,7 +879,7 @@ sub unstow_node {
872
879
elsif (-e $target ) {
873
880
debug(4, " Evaluate existing node: $target " );
874
881
if (-d $target ) {
875
- $self -> unstow_contents($stow_path , $package , $target );
882
+ $self -> unstow_contents($stow_path , $package , $target , $source );
876
883
877
884
# This action may have made the parent directory foldable
878
885
if (my $parent = $self -> foldable($target )) {
0 commit comments