give more helpful conflict messages
This commit is contained in:
parent
ec7d169446
commit
024404df48
1 changed files with 26 additions and 24 deletions
50
Stow.pm
50
Stow.pm
|
@ -382,11 +382,11 @@ sub StowDir {
|
||||||
|
|
||||||
warn "Stowing directory $dir\n" if ($opts{verbose} > 1);
|
warn "Stowing directory $dir\n" if ($opts{verbose} > 1);
|
||||||
|
|
||||||
my $subdirPath = &JoinPaths($opts{target}, $subdir);
|
my $targetSubdirPath = &JoinPaths($opts{target}, $subdir);
|
||||||
if (-l $subdirPath) {
|
if (-l $targetSubdirPath) {
|
||||||
# We found a link; now let's see if we should remove it.
|
# We found a link; now let's see if we should remove it.
|
||||||
my $linktarget = readlink($subdirPath);
|
my $linktarget = readlink($targetSubdirPath);
|
||||||
$linktarget or die "$RealScript: Could not read link $subdirPath ($!)\n";
|
$linktarget or die "$RealScript: Could not read link $targetSubdirPath ($!)\n";
|
||||||
|
|
||||||
# Does the link point to somewhere within the stow directory?
|
# Does the link point to somewhere within the stow directory?
|
||||||
my $stowsubdir = &FindStowMember(
|
my $stowsubdir = &FindStowMember(
|
||||||
|
@ -395,43 +395,43 @@ sub StowDir {
|
||||||
);
|
);
|
||||||
unless ($stowsubdir) {
|
unless ($stowsubdir) {
|
||||||
# No, so we can't touch it.
|
# No, so we can't touch it.
|
||||||
&Conflict($dir, $subdir, 1);
|
&Conflict($dir, $subdir, "link doesn't point within stow dir; cannot split open");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Yes it does.
|
# Yes it does.
|
||||||
if (-e &JoinPaths($opts{stow}, $stowsubdir)) {
|
my $stowSubdirPath = &JoinPaths($opts{stow}, $stowsubdir);
|
||||||
|
if (-e $stowSubdirPath) {
|
||||||
if ($stowsubdir eq $dir) {
|
if ($stowsubdir eq $dir) {
|
||||||
warn sprintf("%s already points to %s\n",
|
warn "$targetSubdirPath already points to $stowSubdirPath\n"
|
||||||
$subdirPath,
|
if $opts{verbose} > 2;
|
||||||
&JoinPaths($opts{stow}, $dir))
|
|
||||||
if ($opts{verbose} > 2);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (-d &JoinPaths($opts{stow}, $stowsubdir)) {
|
if (-d $stowSubdirPath) {
|
||||||
# This is the splitting open of a folded tree which the stow
|
# This is the splitting open of a folded tree which the stow
|
||||||
# manual refers to.
|
# manual refers to.
|
||||||
&DoUnlink($subdirPath);
|
&DoUnlink($targetSubdirPath);
|
||||||
&DoMkdir($subdirPath);
|
&DoMkdir($targetSubdirPath);
|
||||||
&StowContents($stowsubdir, &JoinPaths('..', $stow));
|
&StowContents($stowsubdir, &JoinPaths('..', $stow));
|
||||||
&StowContents($dir, &JoinPaths('..', $stow));
|
&StowContents($dir, &JoinPaths('..', $stow));
|
||||||
} else {
|
} else {
|
||||||
(&Conflict($dir, $subdir, 2), return);
|
&Conflict($dir, $subdir, "$stowSubdirPath exists but not a directory");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
&DoUnlink($subdirPath);
|
&DoUnlink($targetSubdirPath);
|
||||||
&DoLink(&JoinPaths($stow, $dir),
|
&DoLink(&JoinPaths($stow, $dir),
|
||||||
$subdirPath);
|
$targetSubdirPath);
|
||||||
}
|
}
|
||||||
} elsif (-e $subdirPath) {
|
} elsif (-e $targetSubdirPath) {
|
||||||
if (-d $subdirPath) {
|
if (-d $targetSubdirPath) {
|
||||||
&StowContents($dir, &JoinPaths('..', $stow));
|
&StowContents($dir, &JoinPaths('..', $stow));
|
||||||
} else {
|
} else {
|
||||||
&Conflict($dir, $subdir, 3);
|
&Conflict($dir, $subdir, "$targetSubdirPath exists but not a directory");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
&DoLink(&JoinPaths($stow, $dir),
|
&DoLink(&JoinPaths($stow, $dir),
|
||||||
$subdirPath);
|
$targetSubdirPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,12 +450,14 @@ sub StowNondir {
|
||||||
$linktarget
|
$linktarget
|
||||||
);
|
);
|
||||||
if (! $stowsubfile) {
|
if (! $stowsubfile) {
|
||||||
&Conflict($file, $subfile, 4);
|
&Conflict($file, $subfile, "$subfilePath symlink did not point within stow dir");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (-e &JoinPaths($opts{stow}, $stowsubfile)) {
|
if (-e &JoinPaths($opts{stow}, $stowsubfile)) {
|
||||||
(&Conflict($file, $subfile, 5), return)
|
if ($stowsubfile ne $file) {
|
||||||
unless ($stowsubfile eq $file);
|
&Conflict($file, $subfile, "$subfilePath pointed to something else within stow dir");
|
||||||
|
return;
|
||||||
|
}
|
||||||
warn sprintf("%s already points to %s\n",
|
warn sprintf("%s already points to %s\n",
|
||||||
$subfilePath,
|
$subfilePath,
|
||||||
&JoinPaths($opts{stow}, $file))
|
&JoinPaths($opts{stow}, $file))
|
||||||
|
@ -465,7 +467,7 @@ sub StowNondir {
|
||||||
&DoLink(&JoinPaths($stow, $file), $subfilePath);
|
&DoLink(&JoinPaths($stow, $file), $subfilePath);
|
||||||
}
|
}
|
||||||
} elsif (-e $subfilePath) {
|
} elsif (-e $subfilePath) {
|
||||||
&Conflict($file, $subfile, 6);
|
&Conflict($file, $subfile, "$subfilePath exists but is not a symlink");
|
||||||
} else {
|
} else {
|
||||||
&DoLink(&JoinPaths($stow, $file), $subfilePath);
|
&DoLink(&JoinPaths($stow, $file), $subfilePath);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue