Fix a bug in symlink calculation code, that triggered in rare cases where an annexed file is in a subdirectory that nearly matched to the .git/annex/object/xx/yy subdirectories.
This is a straight up pure-code stinker. The relative path calculation looked for common subdirectories in the two paths, but failed to stop after the paths diverged. When a later pair of subdirectories were the same, the resulting relative path was wrong. Added regression test for this.
This commit is contained in:
parent
52e88f3ebf
commit
51338486dc
3 changed files with 14 additions and 1 deletions
|
@ -82,7 +82,7 @@ relPathDirToFile from to = join s $ dotdots ++ uncommon
|
||||||
s = [pathSeparator]
|
s = [pathSeparator]
|
||||||
pfrom = split s from
|
pfrom = split s from
|
||||||
pto = split s to
|
pto = split s to
|
||||||
common = map fst $ filter same $ zip pfrom pto
|
common = map fst $ takeWhile same $ zip pfrom pto
|
||||||
same (c,d) = c == d
|
same (c,d) = c == d
|
||||||
uncommon = drop numcommon pto
|
uncommon = drop numcommon pto
|
||||||
dotdots = replicate (length pfrom - numcommon) ".."
|
dotdots = replicate (length pfrom - numcommon) ".."
|
||||||
|
@ -95,6 +95,15 @@ prop_relPathDirToFile_basics from to
|
||||||
where
|
where
|
||||||
r = relPathDirToFile from to
|
r = relPathDirToFile from to
|
||||||
|
|
||||||
|
prop_relPathDirToFile_regressionTest :: Bool
|
||||||
|
prop_relPathDirToFile_regressionTest = same_dir_shortcurcuits_at_difference
|
||||||
|
where
|
||||||
|
{- Two paths have the same directory component at the same
|
||||||
|
- location, but it's not really the same directory.
|
||||||
|
- Code used to get this wrong. -}
|
||||||
|
same_dir_shortcurcuits_at_difference =
|
||||||
|
relPathDirToFile "/tmp/r/lll/xxx/yyy/18" "/tmp/r/.git/annex/objects/18/gk/SHA256-foo/SHA256-foo" == "../../../../.git/annex/objects/18/gk/SHA256-foo/SHA256-foo"
|
||||||
|
|
||||||
{- Given an original list of files, and an expanded list derived from it,
|
{- Given an original list of files, and an expanded list derived from it,
|
||||||
- ensures that the original list's ordering is preserved.
|
- ensures that the original list's ordering is preserved.
|
||||||
-
|
-
|
||||||
|
|
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -8,6 +8,9 @@ git-annex (3.20120230) UNRELEASED; urgency=low
|
||||||
* Add configurable hooks that are run when git-annex starts and stops
|
* Add configurable hooks that are run when git-annex starts and stops
|
||||||
using a remote: remote.name.annex-start-command and
|
using a remote: remote.name.annex-start-command and
|
||||||
remote.name.annex-stop-command
|
remote.name.annex-stop-command
|
||||||
|
* Fix a bug in symlink calculation code, that triggered in rare
|
||||||
|
cases where an annexed file is in a subdirectory that nearly
|
||||||
|
matched to the .git/annex/object/xx/yy subdirectories.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Thu, 01 Mar 2012 22:34:27 -0400
|
-- Joey Hess <joeyh@debian.org> Thu, 01 Mar 2012 22:34:27 -0400
|
||||||
|
|
||||||
|
|
1
test.hs
1
test.hs
|
@ -82,6 +82,7 @@ quickcheck = TestLabel "quickcheck" $ TestList
|
||||||
, qctest "prop_parentDir_basics" Utility.Path.prop_parentDir_basics
|
, qctest "prop_parentDir_basics" Utility.Path.prop_parentDir_basics
|
||||||
|
|
||||||
, qctest "prop_relPathDirToFile_basics" Utility.Path.prop_relPathDirToFile_basics
|
, qctest "prop_relPathDirToFile_basics" Utility.Path.prop_relPathDirToFile_basics
|
||||||
|
, qctest "prop_relPathDirToFile_regressionTest" Utility.Path.prop_relPathDirToFile_regressionTest
|
||||||
, qctest "prop_cost_sane" Config.prop_cost_sane
|
, qctest "prop_cost_sane" Config.prop_cost_sane
|
||||||
, qctest "prop_hmacWithCipher_sane" Crypto.prop_hmacWithCipher_sane
|
, qctest "prop_hmacWithCipher_sane" Crypto.prop_hmacWithCipher_sane
|
||||||
, qctest "prop_TimeStamp_sane" Logs.UUIDBased.prop_TimeStamp_sane
|
, qctest "prop_TimeStamp_sane" Logs.UUIDBased.prop_TimeStamp_sane
|
||||||
|
|
Loading…
Reference in a new issue