fix bugs in handing of deep branches with sync and adjusted branches
authorJoey Hess <joeyh@joeyh.name>
Wed, 21 Sep 2016 19:18:51 +0000 (15:18 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 21 Sep 2016 19:23:47 +0000 (15:23 -0400)
* sync: Previously, when run in a branch with a slash in its name,
  such as "foo/bar", the sync branch was "synced/bar". That conflicted
  with the sync branch used for branch "bar", so has been changed to
  "synced/foo/bar".
* adjust: Previously, when adjusting a branch with a slash in its name,
  such as "foo/bar", the adjusted branch was "adjusted/bar(unlocked)".
  That conflicted with the adjusted branch used for branch "bar",
  so has been changed to "adjusted/foo/bar(unlocked)"
* Also, running sync in an adjusted branch did not correctly sync
  changes back to the parent branch when it had a slash in its name.
  This bug has been fixed.

Eliminate use of Git.Ref.under and Git.Ref.basename; using
Git.Ref.underBase and Git.Ref.base make everything handle deep branches
correctly.

Probably noone was adjusting deep branches, and v6 is still experimental
anyway, so I'm not going to worry about the mess that was left by that bug.

In the case of git-annex sync, using a fixed git-annex with an old unfixed
one will mean they use different sync branches for a deep branch, and so
they may stop syncing until the old one is upgraded. However, that's only
a problem when syncing between repositories without going via a central
bare repository. Added a warning about this to the CHANGELOG, but it's
probably not going to affect many people at all.

This commit was sponsored by Riku Voipio.

Annex/AdjustedBranch.hs
CHANGELOG
Command/Sync.hs
Git/Ref.hs
doc/bugs/sync_uses_conflicting_names_for_deep_branches.mdwn

index ae5ad9a518c0c8bfc0d75603e6e7474a3cd52b02..4caf637c7ee241645efc398d49f3ae8469577a91 100644 (file)
@@ -159,14 +159,14 @@ originalToAdjusted :: OrigBranch -> Adjustment -> AdjBranch
 originalToAdjusted orig adj = AdjBranch $ Ref $
        adjustedBranchPrefix ++ base ++ '(' : serialize adj ++ ")"
   where
-       base = fromRef (Git.Ref.basename orig)
+       base = fromRef (Git.Ref.base orig)
 
 adjustedToOriginal :: Branch -> Maybe (Adjustment, OrigBranch)
 adjustedToOriginal b
        | adjustedBranchPrefix `isPrefixOf` bs = do
                let (base, as) = separate (== '(') (drop prefixlen bs)
                adj <- deserialize (takeWhile (/= ')') as)
-               Just (adj, Git.Ref.under "refs/heads" (Ref base))
+               Just (adj, Git.Ref.underBase "refs/heads" (Ref base))
        | otherwise = Nothing
   where
        bs = fromRef b
index 4f7674a8b60db882addc58eaf1165badfee3809a..5c44f412c85fa882185459ed823c2311c3817c6e 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,23 @@ git-annex (6.20160908) UNRELEASED; urgency=medium
   * stack.yaml: Update to lts-7.0 (ghc 8)
   * info: Support being passed a treeish, and show info about the annexed
     files in it similar to how a directory is handled.
+  * sync: Previously, when run in a branch with a slash in its name,
+    such as "foo/bar", the sync branch was "synced/bar". That conflicted
+    with the sync branch used for branch "bar", so has been changed to
+    "synced/foo/bar".
+  * Note that if you're using an old version of git-annex to sync with
+    a branch with a slash in its name, it won't see some changes synced by
+    this version, and this version won't see some changes synced by the older
+    version. This is not a problem if there's a central bare repository,
+    but may impact other configurations until git-annex is upgraded to this
+    version.
+  * adjust: Previously, when adjusting a branch with a slash in its name,
+    such as "foo/bar", the adjusted branch was "adjusted/bar(unlocked)".
+    That conflicted with the adjusted branch used for branch "bar",
+    so has been changed to "adjusted/foo/bar(unlocked)"
+  * Also, running sync in an adjusted branch did not correctly sync
+    changes back to the parent branch when it had a slash in its name.
+    This bug has been fixed.
 
  -- Joey Hess <id@joeyh.name>  Thu, 08 Sep 2016 12:48:55 -0400
 
index fd9d0b27896534a996ff67426ef21d0704091ee3..d7edac7435c3965fe65da4a0ded52bf29ddb0b51 100644 (file)
@@ -178,7 +178,7 @@ merge (b, _) mergeconfig commitmode tomerge =
        autoMergeFrom tomerge b mergeconfig commitmode
 
 syncBranch :: Git.Branch -> Git.Branch
-syncBranch = Git.Ref.under "refs/heads/synced" . fromDirectBranch . fromAdjustedBranch
+syncBranch = Git.Ref.underBase "refs/heads/synced" . fromDirectBranch . fromAdjustedBranch
 
 remoteBranch :: Remote -> Git.Ref -> Git.Ref
 remoteBranch remote = Git.Ref.underBase $ "refs/remotes/" ++ Remote.name remote
index 257c430360679ec080d3b31aa2b5a1c5dba49897..5b3b85324c8862d8633d2533d0d954e9510858e9 100644 (file)
@@ -39,15 +39,6 @@ base = Ref . remove "refs/heads/" . remove "refs/remotes/" . fromRef
                | prefix `isPrefixOf` s = drop (length prefix) s
                | otherwise = s
 
-{- Gets the basename of any qualified ref. -}
-basename :: Ref -> Ref
-basename = Ref . reverse . takeWhile (/= '/') . reverse . fromRef
-
-{- Given a directory and any ref, takes the basename of the ref and puts
- - it under the directory. -}
-under :: String -> Ref -> Ref
-under dir r = Ref $ dir ++ "/" ++ fromRef (basename r)
-
 {- Given a directory such as "refs/remotes/origin", and a ref such as
  - refs/heads/master, yields a version of that ref under the directory,
  - such as refs/remotes/origin/master. -}
index fa6dd0d45369e2603953178fa2e879fe3ca878fe..439bd55e1e5ae2eb30ad25e4c731da6b5e90485e 100644 (file)
@@ -3,4 +3,7 @@ changes to branch named "foo", but that same name is used to sync
 changes to a branch named "bar/foo".
 
 Also, the adjusted branch code uses "adjusted/foo(unlocked)" for
-both "foo" and "bar/foo".
+both "foo" and "bar/foo". And it fails to push changes back from there to
+"bar/foo", instead creating a "foo" branch.
+
+> [[fixed|done]] --[[Joey]]