tidy up CONFLICT output
This commit is contained in:
parent
024404df48
commit
9fd7eab0d1
1 changed files with 29 additions and 10 deletions
39
Stow.pm
39
Stow.pm
|
@ -395,7 +395,9 @@ sub StowDir {
|
||||||
);
|
);
|
||||||
unless ($stowsubdir) {
|
unless ($stowsubdir) {
|
||||||
# No, so we can't touch it.
|
# No, so we can't touch it.
|
||||||
&Conflict($dir, $subdir, "link doesn't point within stow dir; cannot split open");
|
&Conflict($dir, $subdir,
|
||||||
|
&AbbrevHome($targetSubdirPath)
|
||||||
|
. " link doesn't point within stow dir; cannot split open");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +417,9 @@ sub StowDir {
|
||||||
&StowContents($stowsubdir, &JoinPaths('..', $stow));
|
&StowContents($stowsubdir, &JoinPaths('..', $stow));
|
||||||
&StowContents($dir, &JoinPaths('..', $stow));
|
&StowContents($dir, &JoinPaths('..', $stow));
|
||||||
} else {
|
} else {
|
||||||
&Conflict($dir, $subdir, "$stowSubdirPath exists but not a directory");
|
&Conflict($dir, $subdir,
|
||||||
|
&AbbrevHome($stowSubdirPath)
|
||||||
|
. " exists but not a directory");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -427,7 +431,9 @@ sub StowDir {
|
||||||
if (-d $targetSubdirPath) {
|
if (-d $targetSubdirPath) {
|
||||||
&StowContents($dir, &JoinPaths('..', $stow));
|
&StowContents($dir, &JoinPaths('..', $stow));
|
||||||
} else {
|
} else {
|
||||||
&Conflict($dir, $subdir, "$targetSubdirPath exists but not a directory");
|
&Conflict($dir, $subdir,
|
||||||
|
&AbbrevHome($targetSubdirPath)
|
||||||
|
. " exists but not a directory");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
&DoLink(&JoinPaths($stow, $dir),
|
&DoLink(&JoinPaths($stow, $dir),
|
||||||
|
@ -450,12 +456,16 @@ sub StowNondir {
|
||||||
$linktarget
|
$linktarget
|
||||||
);
|
);
|
||||||
if (! $stowsubfile) {
|
if (! $stowsubfile) {
|
||||||
&Conflict($file, $subfile, "$subfilePath symlink did not point within stow dir");
|
&Conflict($file, $subfile,
|
||||||
|
&AbbrevHome($subfilePath)
|
||||||
|
. " symlink did not point within stow dir");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (-e &JoinPaths($opts{stow}, $stowsubfile)) {
|
if (-e &JoinPaths($opts{stow}, $stowsubfile)) {
|
||||||
if ($stowsubfile ne $file) {
|
if ($stowsubfile ne $file) {
|
||||||
&Conflict($file, $subfile, "$subfilePath pointed to something else within stow dir");
|
&Conflict($file, $subfile,
|
||||||
|
&AbbrevHome($subfilePath)
|
||||||
|
. " pointed to something else within stow dir");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
warn sprintf("%s already points to %s\n",
|
warn sprintf("%s already points to %s\n",
|
||||||
|
@ -467,7 +477,9 @@ sub StowNondir {
|
||||||
&DoLink(&JoinPaths($stow, $file), $subfilePath);
|
&DoLink(&JoinPaths($stow, $file), $subfilePath);
|
||||||
}
|
}
|
||||||
} elsif (-e $subfilePath) {
|
} elsif (-e $subfilePath) {
|
||||||
&Conflict($file, $subfile, "$subfilePath exists but is not a symlink");
|
&Conflict($file, $subfile,
|
||||||
|
&AbbrevHome($subfilePath)
|
||||||
|
. " exists but is not a symlink");
|
||||||
} else {
|
} else {
|
||||||
&DoLink(&JoinPaths($stow, $file), $subfilePath);
|
&DoLink(&JoinPaths($stow, $file), $subfilePath);
|
||||||
}
|
}
|
||||||
|
@ -510,17 +522,24 @@ sub DoMkdir {
|
||||||
sub Conflict {
|
sub Conflict {
|
||||||
my($a, $b, $type) = @_;
|
my($a, $b, $type) = @_;
|
||||||
|
|
||||||
my $src = &JoinPaths($opts{stow}, $a);
|
my $src = &AbbrevHome(&JoinPaths($opts{stow}, $a));
|
||||||
my $dst = &JoinPaths($opts{target}, $b);
|
my $dst = &AbbrevHome(&JoinPaths($opts{target}, $b));
|
||||||
|
|
||||||
|
my $msg = "CONFLICT:\n $src\nvs.\n $dst" . ($type ? "\n ($type)" : '') . "\n\n";
|
||||||
if ($opts{conflicts}) {
|
if ($opts{conflicts}) {
|
||||||
warn "CONFLICT: $src vs. $dst", ($type ? " ($type)" : ''), "\n";
|
warn $msg;
|
||||||
#system "ls -l $src $dst";
|
#system "ls -l $src $dst";
|
||||||
} else {
|
} else {
|
||||||
die "$RealScript: CONFLICT: $src vs. $dst", ($type ? " ($type)" : ''), "\n";
|
die "$RealScript: $msg";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub AbbrevHome {
|
||||||
|
my($path) = @_;
|
||||||
|
$path =~ s!^$ENV{HOME}/!~/!;
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
# Given an absolute starting directory and a relative path obtained by
|
# Given an absolute starting directory and a relative path obtained by
|
||||||
# calling readlink() on a symlink in that starting directory,
|
# calling readlink() on a symlink in that starting directory,
|
||||||
# FindStowMember() figures out whether the symlink points to somewhere
|
# FindStowMember() figures out whether the symlink points to somewhere
|
||||||
|
|
Loading…
Reference in a new issue