fix hardcoded origin name in checkAdjustedClone
authorJoey Hess <joeyh@joeyh.name>
Wed, 14 Apr 2021 22:53:27 +0000 (18:53 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 14 Apr 2021 22:53:27 +0000 (18:53 -0400)
init: Fix a crash when the repo's was cloned from a repo that had an
adjusted branch checked out, and the origin remote is not named "origin".

The only other hardcoding of the name of origin is in:

- Upgrade.V2, which can be ignored probably
- Annex.Branch, which doesn't fail if it has some other name, but just
  doesn't set up the git-annex branch with quite as linear a history in
  that case.

Annex/AdjustedBranch.hs
CHANGELOG
doc/bugs/crippledfs__58___annex-init_crash_when_remote_name_is.mdwn

index a2b606ef667a54b8cb02028c5adc4dd9c6af043e..bb5321d90a77ea36265ffb3b7fcd01d8c627fedd 100644 (file)
@@ -613,12 +613,12 @@ checkAdjustedClone = ifM isBareRepo
                Just (adj, origbranch) -> do
                        let basis@(BasisBranch bb) = basisBranch (originalToAdjusted origbranch adj)
                        unlessM (inRepo $ Git.Ref.exists bb) $ do
-                               unlessM (inRepo $ Git.Ref.exists origbranch) $ do
-                                       let remotebranch = Git.Ref.underBase "refs/remotes/origin" origbranch
-                                       inRepo $ Git.Branch.update' origbranch remotebranch
                                aps <- fmap commitParent <$> findAdjustingCommit (AdjBranch currbranch)
                                case aps of
-                                       Just [p] -> setBasisBranch basis p
+                                       Just [p] -> do
+                                               unlessM (inRepo $ Git.Ref.exists origbranch) $
+                                                       inRepo $ Git.Branch.update' origbranch p
+                                               setBasisBranch basis p
                                        _ -> giveup $ "Unable to clean up from clone of adjusted branch; perhaps you should check out " ++ Git.Ref.describe origbranch
                        return InAdjustedClone
 
index c626a14f07c570c0c2f2ce1a41d6624582008e77..cdbf2c004f2a564bf0444a5a87d7897b15eb1f03 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,8 @@ git-annex (8.20210331) UNRELEASED; urgency=medium
   * fsck: When downloading content from a remote, if the content is able
     to be verified during the transfer, skip checksumming it a second time.
   * directory: When cp supports reflinks, use it.
+  * init: Fix a crash when the repo's was cloned from a repo that had an
+    adjusted branch checked out, and the origin remote is not named "origin".    
 
  -- Joey Hess <id@joeyh.name>  Thu, 01 Apr 2021 12:17:26 -0400
 
index 1a4ba82657820ecdf2ead5a0105f22dd027e19c3..42e433d0b05436399ab231eb8c39c8412d4d62ff 100644 (file)
@@ -51,3 +51,5 @@ overriding `annex.crippledfilesystem`.  Entering an adjusted branch in
 `a` is sufficient to trigger this.
 
 [[!tag projects/datalad]]
+
+> [[fixed|done]] --[[Joey]]