From 1010482bc752e6f0fd48e87fd0156d85874e7a9e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 13 Apr 2016 14:07:50 -0400 Subject: [PATCH] webapp: When $HOME is a git repository, and has been initialized for use by git-annex, opening the webapp went ahead and ran the assistant there, annexing all files. Since this is almost certianly not desirable, especially when the user is just opening the webapp from a dekstop menu which happens to run it in $HOME, the webapp will now not treat such a $HOME git repository as a git-annex repository. --- Command/WebApp.hs | 12 +++++++++- debian/changelog | 6 +++++ ..._create_a_repository_in___126____47__.mdwn | 2 ++ ..._ed1b53ceef3e7a499b92e6f3f0f6d672._comment | 24 +++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 doc/bugs/Assistant_will_annex_your_files_on_startup_if_you_create_a_repository_in___126____47__/comment_6_ed1b53ceef3e7a499b92e6f3f0f6d672._comment diff --git a/Command/WebApp.hs b/Command/WebApp.hs index 8c11c18bd8..87a648bdd0 100644 --- a/Command/WebApp.hs +++ b/Command/WebApp.hs @@ -22,6 +22,7 @@ import Utility.Daemon (checkDaemon) #ifdef __ANDROID__ import Utility.Env #endif +import Utility.UserInfo import Annex.Init import qualified Git import qualified Git.Config @@ -60,7 +61,7 @@ start = start' True start' :: Bool -> WebAppOptions -> CommandStart start' allowauto o = do liftIO ensureInstalled - ifM isInitialized + ifM (isInitialized <&&> notHome) ( maybe notinitialized (go <=< needsUpgrade) =<< getVersion , if allowauto then liftIO $ startNoRepo o @@ -99,6 +100,15 @@ start' allowauto o = do liftIO $ cannotStartIn (Git.repoLocation g) "repository has not been initialized by git-annex" liftIO $ firstRun o +{- If HOME is a git repo, even if it's initialized for git-annex, + - the user almost certianly does not want to run the assistant there. -} +notHome :: Annex Bool +notHome = do + g <- Annex.gitRepo + d <- liftIO $ absPath (Git.repoLocation g) + h <- liftIO $ absPath =<< myHomeDir + return (d /= h) + {- When run without a repo, start the first available listed repository in - the autostart file. If none, it's our first time being run! -} startNoRepo :: WebAppOptions -> IO () diff --git a/debian/changelog b/debian/changelog index 6a486b4bf5..acabb254f9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,12 @@ git-annex (6.20160413) UNRELEASED; urgency=medium * smudge: Print a warning when annex.thin is set, as git's smudge interface does not allow honoring that configuration. + * webapp: When $HOME is a git repository, and has been initialized for + use by git-annex, opening the webapp went ahead and ran the assistant + there, annexing all files. Since this is almost certianly not + desirable, especially when the user is just opening the webapp from + a dekstop menu which happens to run it in $HOME, the webapp will now not + treat such a $HOME git repository as a git-annex repository. -- Joey Hess Wed, 13 Apr 2016 13:30:32 -0400 diff --git a/doc/bugs/Assistant_will_annex_your_files_on_startup_if_you_create_a_repository_in___126____47__.mdwn b/doc/bugs/Assistant_will_annex_your_files_on_startup_if_you_create_a_repository_in___126____47__.mdwn index e2d67c68ca..e14a9b67c8 100644 --- a/doc/bugs/Assistant_will_annex_your_files_on_startup_if_you_create_a_repository_in___126____47__.mdwn +++ b/doc/bugs/Assistant_will_annex_your_files_on_startup_if_you_create_a_repository_in___126____47__.mdwn @@ -21,3 +21,5 @@ The assistant shouldn't do anything unless I tell it to. Currently, I cannot pla ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders) I use git annex for managing the image and video resources on my website and it works fine for that. + +> HOME git repo guard added, [[done]] --[[Joey]] diff --git a/doc/bugs/Assistant_will_annex_your_files_on_startup_if_you_create_a_repository_in___126____47__/comment_6_ed1b53ceef3e7a499b92e6f3f0f6d672._comment b/doc/bugs/Assistant_will_annex_your_files_on_startup_if_you_create_a_repository_in___126____47__/comment_6_ed1b53ceef3e7a499b92e6f3f0f6d672._comment new file mode 100644 index 0000000000..5fdcf8e38a --- /dev/null +++ b/doc/bugs/Assistant_will_annex_your_files_on_startup_if_you_create_a_repository_in___126____47__/comment_6_ed1b53ceef3e7a499b92e6f3f0f6d672._comment @@ -0,0 +1,24 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 6""" + date="2016-04-13T17:43:34Z" + content=""" +So, I see that you *did* tell git-annex to treat your home git repo as a +git-annex repo. + +And, starting the the assistant/webapp from inside a git annex repository is +intended to start them running in that repository. This behavior makes a +lot of sense in general. It's consistent with running any other git command +inside a git repository causing that command to run on that repository. + +I guess that the issue here is, opening the git-annex webapp from a menu +causes the program to run with its working directory set to HOME. But in +this case, the HOME is only incidental, the intent is not to start the +webapp/assistant in that repository. + +Seems kind of hard for the assistant to determine intent though. + +So, the best that can be done, I suppose, is to make starting the webapp +in the HOME git repository behave as if that git repository was not +initialized for use by git-annex. +"""]]