diff --git a/Annex/Init.hs b/Annex/Init.hs index 88389c1389..cb7f8905e1 100644 --- a/Annex/Init.hs +++ b/Annex/Init.hs @@ -1,6 +1,6 @@ {- git-annex repository initialization - - - Copyright 2011-2017 Joey Hess + - Copyright 2011-2019 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -52,6 +52,8 @@ import System.Posix.User import qualified Utility.LockFile.Posix as Posix #endif +import qualified Data.Map as M + checkCanInitialize :: Annex a -> Annex a checkCanInitialize a = inRepo (noAnnexFileContent . Git.repoWorkTree) >>= \case Nothing -> a @@ -88,7 +90,10 @@ initialize mdescription mversion = checkCanInitialize $ do initSharedClone sharedclone u <- getUUID - describeUUID u =<< genDescription mdescription + {- Avoid overwriting existing description with a default + - description. -} + whenM (pure (isJust mdescription) <||> not . M.member u <$> uuidDescMap) $ + describeUUID u =<< genDescription mdescription -- Everything except for uuid setup, shared clone setup, and initial -- description. diff --git a/CHANGELOG b/CHANGELOG index 943c62cf12..9718bf95be 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,9 @@ git-annex (7.20190508) UNRELEASED; urgency=medium import with such an expression will fail. * Improve shape of commit tree when importing from unversioned special remotes. + * init: When the repository already has a description, don't change it. + * describe: When run with no description parameter it used to set + the description to "", now it will error out. -- Joey Hess Mon, 06 May 2019 13:52:02 -0400 diff --git a/Command/Describe.hs b/Command/Describe.hs index 2135482da2..9e1533438e 100644 --- a/Command/Describe.hs +++ b/Command/Describe.hs @@ -21,7 +21,7 @@ seek :: CmdParams -> CommandSeek seek = withWords (commandAction . start) start :: [String] -> CommandStart -start (name:description) = do +start (name:description) | not (null description) = do showStart' "describe" (Just name) u <- Remote.nameToUUID name next $ perform u $ unwords description diff --git a/doc/bugs/git-annex-init_with_no_args_overwrites_existing_repo_description.mdwn b/doc/bugs/git-annex-init_with_no_args_overwrites_existing_repo_description.mdwn index 52885b300f..6687d61cc4 100644 --- a/doc/bugs/git-annex-init_with_no_args_overwrites_existing_repo_description.mdwn +++ b/doc/bugs/git-annex-init_with_no_args_overwrites_existing_repo_description.mdwn @@ -18,3 +18,5 @@ upgrade supported from repository versions: 0 1 2 3 4 5 6 local repository version: 5 (master_env_v135_py36) 13:47 [r2] $ uname -a Linux ip-172-31-90-58.ec2.internal 4.14.114-105.126.amzn2.x86_64 #1 SMP Tue May 7 02:26:40 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/git-annex-init_with_no_args_overwrites_existing_repo_description/comment_1_7facb84de8c8148e8f12ba2c4bd5c74b._comment b/doc/bugs/git-annex-init_with_no_args_overwrites_existing_repo_description/comment_1_7facb84de8c8148e8f12ba2c4bd5c74b._comment new file mode 100644 index 0000000000..1dd9222c99 --- /dev/null +++ b/doc/bugs/git-annex-init_with_no_args_overwrites_existing_repo_description/comment_1_7facb84de8c8148e8f12ba2c4bd5c74b._comment @@ -0,0 +1,16 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2019-05-23T16:40:50Z" + content=""" +Yikes, I was surprised to see this behavior. fixed for `init`. + +For `describe`, I see that when it's run with no parameter for the +description, it sets the description to "". I suppose that's what you +meant. + +I suppose something could conceivably depend on the current `git annex +describe remote` behavior, but I checked and it's nowhere documented that +describe with no description is allowed -- even the --help doesn't say that +luckily. So I have also disallowed that. +"""]]