summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-07-10 13:52:53 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-07-10 13:52:53 -0400
commit7919de73af81d1788867ecbcbcc17e25b348ad1d (patch)
tree9041aaa9c3bfcf083e86b0e77de3ab8da9a8ec1e
parent562fd41d6c7a522d5aa8e8eb65f1c8e12d830df4 (diff)
Bugfix: Make add ../ work.
The complication of check-attr returning absolute paths that have to be converted back to relative paths..
-rw-r--r--Git.hs13
-rw-r--r--debian/changelog1
-rw-r--r--doc/bugs/__39__annex_add__39___fails_to___39__git_add__39___for_parent_relative_path.mdwn2
-rw-r--r--test.hs10
4 files changed, 20 insertions, 6 deletions
diff --git a/Git.hs b/Git.hs
index 7005f24f5..7827f8051 100644
--- a/Git.hs
+++ b/Git.hs
@@ -530,6 +530,7 @@ checkAttr repo attr files = do
-- directory. Convert to absolute, and then convert the filenames
-- in its output back to relative.
cwd <- getCurrentDirectory
+ let top = workTree repo
let absfiles = map (absPathFrom cwd) files
(_, fromh, toh) <- hPipeBoth "git" (toCommand params)
_ <- forkProcess $ do
@@ -539,19 +540,21 @@ checkAttr repo attr files = do
exitSuccess
hClose toh
s <- hGetContents fromh
- return $ map (topair $ cwd++"/") $ lines s
+ return $ map (topair cwd top) $ lines s
where
params = gitCommandLine repo [Param "check-attr", Param attr, Params "-z --stdin"]
- topair cwd l = (relfile, value)
+ topair cwd top l = (relfile, value)
where
- relfile
- | startswith cwd file = drop (length cwd) file
- | otherwise = file
+ relfile
+ | startswith cwd' file = drop (length cwd') file
+ | otherwise = relPathDirToFile top' file
file = decodeGitFile $ join sep $ take end bits
value = bits !! end
end = length bits - 1
bits = split sep l
sep = ": " ++ attr ++ ": "
+ cwd' = cwd ++ "/"
+ top' = top ++ "/"
{- Some git commands output encoded filenames. Decode that (annoyingly
- complex) encoding. -}
diff --git a/debian/changelog b/debian/changelog
index 80fe84256..ec3176d12 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
git-annex (3.20110708) UNRELEASED; urgency=low
* add: Be even more robust to avoid ever leaving the file seemingly deleted.
+ * Bugfix: Make add ../ work.
-- Joey Hess <joeyh@debian.org> Thu, 07 Jul 2011 21:28:49 -0400
diff --git a/doc/bugs/__39__annex_add__39___fails_to___39__git_add__39___for_parent_relative_path.mdwn b/doc/bugs/__39__annex_add__39___fails_to___39__git_add__39___for_parent_relative_path.mdwn
index 1243bbfb2..f129abf62 100644
--- a/doc/bugs/__39__annex_add__39___fails_to___39__git_add__39___for_parent_relative_path.mdwn
+++ b/doc/bugs/__39__annex_add__39___fails_to___39__git_add__39___for_parent_relative_path.mdwn
@@ -11,3 +11,5 @@ error: Invalid path '.git/annex/objects/Jx/...
...
Then it seems it is enough to 'git add ../d/f' to complete the operation.
+
+> Thanks for reporting, [[fixed|done]] --[[Joey]]
diff --git a/test.hs b/test.hs
index 9dad37e0c..51ccc600e 100644
--- a/test.hs
+++ b/test.hs
@@ -108,7 +108,7 @@ test_init = "git-annex init" ~: TestCase $ innewrepo $ do
reponame = "test repo"
test_add :: Test
-test_add = "git-annex add" ~: TestList [basic, sha1dup]
+test_add = "git-annex add" ~: TestList [basic, sha1dup, subdirs]
where
-- this test case runs in the main repo, to set up a basic
-- annexed file that later tests will use
@@ -129,6 +129,14 @@ test_add = "git-annex add" ~: TestList [basic, sha1dup]
git_annex "add" ["-q", sha1annexedfiledup, "--backend=SHA1"] @? "add of second file with same SHA1 failed"
annexed_present sha1annexedfiledup
annexed_present sha1annexedfile
+ subdirs = TestCase $ intmpclonerepo $ do
+ createDirectory "dir"
+ writeFile "dir/foo" $ content annexedfile
+ git_annex "add" ["-q", "dir"] @? "add of subdir failed"
+ createDirectory "dir2"
+ writeFile "dir2/foo" $ content annexedfile
+ changeWorkingDirectory "dir"
+ git_annex "add" ["-q", "../dir2"] @? "add of ../subdir failed"
test_setkey :: Test
test_setkey = "git-annex setkey/fromkey" ~: TestCase $ inmainrepo $ do