return $ concat [hostname, ":", reldir]
#endif
-initialize :: Maybe String -> Annex ()
-initialize mdescription = do
+initialize :: Maybe String -> Maybe Version -> Annex ()
+initialize mdescription mversion = do
{- Has to come before any commits are made as the shared
- clone heuristic expects no local objects. -}
sharedclone <- checkSharedClone
ensureCommit $ Annex.Branch.create
prepUUID
- initialize'
+ initialize' mversion
initSharedClone sharedclone
-- Everything except for uuid setup, shared clone setup, and initial
-- description.
-initialize' :: Annex ()
-initialize' = do
+initialize' :: Maybe Version -> Annex ()
+initialize' mversion = do
checkLockSupport
checkFifoSupport
checkCrippledFileSystem
unlessM isBare $
hookWrite preCommitHook
setDifferences
- setVersion currentVersion
- configureSmudgeFilter
+ unlessM (isJust <$> getVersion) $
+ setVersion (fromMaybe defaultVersion mversion)
+ whenM versionSupportsUnlockedPointers
+ configureSmudgeFilter
ifM (crippledFileSystem <&&> not <$> isBare)
( do
enableDirectMode
ensureInitialized = getVersion >>= maybe needsinit checkUpgrade
where
needsinit = ifM Annex.Branch.hasSibling
- ( initialize Nothing
+ ( initialize Nothing Nothing
, error "First run: git-annex init"
)
initRepo' :: Maybe String -> Maybe StandardGroup -> Annex ()
initRepo' desc mgroup = unlessM isInitialized $ do
- initialize desc
+ initialize desc Nothing
u <- getUUID
maybe noop (defaultStandardGroup u) mgroup
{- Ensure branch gets committed right away so it is
type Version = String
-currentVersion :: Version
-currentVersion = "6"
+defaultVersion :: Version
+defaultVersion = "5"
+
+latestVersion :: Version
+latestVersion = "6"
supportedVersions :: [Version]
-supportedVersions = ["5", currentVersion]
+supportedVersions = ["5", "6"]
upgradableVersions :: [Version]
#ifndef mingw32_HOST_OS
else ifM (Annex.Branch.hasSibling <||> (isJust <$> Fields.getField Fields.autoInit))
( do
liftIO checkNotReadOnly
- initialize Nothing
+ initialize Nothing Nothing
getUUID
, return NoUUID
)
import Common.Annex
import Command
import Annex.Init
+import Annex.Version
import qualified Annex.SpecialRemote
cmd :: Command
cmd = dontCheck repoExists $
command "init" SectionSetup "initialize git-annex"
- paramDesc (withParams seek)
+ paramDesc (seek <$$> optParser)
-seek :: CmdParams -> CommandSeek
-seek = withWords start
+data InitOptions = InitOptions
+ { initDesc :: String
+ , initVersion :: Maybe Version
+ }
-start :: [String] -> CommandStart
-start ws = do
- showStart "init" description
- next $ perform description
- where
- description = unwords ws
+optParser :: CmdParamsDesc -> Parser InitOptions
+optParser desc = InitOptions
+ <$> (unwords <$> cmdParams desc)
+ <*> optional (option (str >>= parseVersion)
+ ( long "version" <> metavar paramValue
+ <> help "Override default annex.version"
+ ))
-perform :: String -> CommandPerform
-perform description = do
- initialize $ if null description then Nothing else Just description
+parseVersion :: Monad m => String -> m Version
+parseVersion v
+ | v `elem` supportedVersions = return v
+ | otherwise = fail $ v ++ " is not a currently supported repository version"
+
+seek :: InitOptions -> CommandSeek
+seek = commandAction . start
+
+start :: InitOptions -> CommandStart
+start os = do
+ showStart "init" (initDesc os)
+ next $ perform os
+
+perform :: InitOptions -> CommandPerform
+perform os = do
+ initialize
+ (if null (initDesc os) then Nothing else Just (initDesc os))
+ (initVersion os)
Annex.SpecialRemote.autoEnable
next $ return True
then return $ toUUID s
else Remote.nameToUUID s
storeUUID u
- initialize'
+ initialize' Nothing
Annex.SpecialRemote.autoEnable
next $ return True
upgrade automatic = do
upgraded <- go =<< getVersion
when upgraded $
- setVersion currentVersion
+ setVersion latestVersion
return upgraded
where
#ifndef mingw32_HOST_OS
ifM (fromRepo Git.repoIsLocalBare)
( do
moveContent
- setVersion currentVersion
+ setVersion latestVersion
, do
moveContent
updateSymlinks
moveLocationLogs
Annex.Queue.flush
- setVersion currentVersion
+ setVersion latestVersion
)
Upgrade.V2.upgrade
git-annex (6.20151225) unstable; urgency=medium
- * annex.version increased to 6, but version 5 is also still supported.
+ * Added v6 repository mode, but v5 is still the default for now.
* The upgrade to version 6 is not done fully automatically, because
upgrading a direct mode repository to version 6 will prevent old
versions of git-annex from working in other clones of that repository.
* unlock, lock: In v6 mode, unlocking a file changes it from a symlink to a
pointer file, and this change can be committed to the git repository.
* add: In v6 mode, adds modified files to the annex.
+ * init: --version parameter added to control which supported repository
+ version to use.
-- Joey Hess <id@joeyh.name> Tue, 08 Dec 2015 11:14:03 -0400
This command is entirely safe, although usually pointless, to run inside an
already initialized git-annex repository.
+# OPTIONS
+
+* `--version=N`
+
+ Force the repository to be initialized using a different annex.version
+ than the current default.
+
# SEE ALSO
[[git-annex]](1)