aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2018-02-22 14:25:32 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2018-02-22 14:25:32 -0400
commite1e17f4267576b3dcbeac619b43bc4de2f1c00a5 (patch)
tree3c128ef381efe8a9133428146594128d0f2d770c
parent1e98283d31b2e291a9627ea5e025af4ba4cd63a4 (diff)
annex.merge-annex-branches
Added annex.merge-annex-branches config setting which can be used to disable automatic merge of git-annex branches. I wonder if git-annex merge/sync/assistant should disable this setting? Not sure yet, so have not done so. May be that users will not set it in git config, but pass it via -c to commands that need it. Checking the config setting adds a very small overhead, but it's only checked once per command so should be insignificant. This commit was supported by the NSF-funded DataLad project.
-rw-r--r--Annex/Branch.hs8
-rw-r--r--CHANGELOG2
-rw-r--r--Types/GitConfig.hs2
-rw-r--r--doc/bugs/impossible_to_perform___34__read-only__34___git_annex_info_without_write_permissions/comment_3_05f7eec04634e5b4e200cf3dca1bb1b1._comment33
-rw-r--r--doc/git-annex-config.mdwn6
-rw-r--r--doc/git-annex.mdwn14
6 files changed, 59 insertions, 6 deletions
diff --git a/Annex/Branch.hs b/Annex/Branch.hs
index 070f8ff98..36cfb8b55 100644
--- a/Annex/Branch.hs
+++ b/Annex/Branch.hs
@@ -140,7 +140,13 @@ forceUpdate = updateTo =<< siblingBranches
- Returns True if any refs were merged in, False otherwise.
-}
updateTo :: [(Git.Sha, Git.Branch)] -> Annex Bool
-updateTo pairs = do
+updateTo pairs = ifM (annexMergeAnnexBranches <$> Annex.getGitConfig)
+ ( updateTo' pairs
+ , return False
+ )
+
+updateTo' :: [(Git.Sha, Git.Branch)] -> Annex Bool
+updateTo' pairs = do
-- ensure branch exists, and get its current ref
branchref <- getBranch
dirty <- journalDirty
diff --git a/CHANGELOG b/CHANGELOG
index c03db1f93..fdda10391 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -26,6 +26,8 @@ git-annex (6.20180113) UNRELEASED; urgency=medium
log.
* importfeed: Fix a failure when downloading with youtube-dl
and the destination subdirectory does not exist yet.
+ * Added annex.merge-annex-branches config setting which
+ can be used to disable automatic merge of git-annex branches.
-- Joey Hess <id@joeyh.name> Wed, 24 Jan 2018 20:42:55 -0400
diff --git a/Types/GitConfig.hs b/Types/GitConfig.hs
index ad22dadb8..4b89a6bdc 100644
--- a/Types/GitConfig.hs
+++ b/Types/GitConfig.hs
@@ -59,6 +59,7 @@ data GitConfig = GitConfig
, annexBloomAccuracy :: Maybe Int
, annexSshCaching :: Maybe Bool
, annexAlwaysCommit :: Bool
+ , annexMergeAnnexBranches :: Bool
, annexDelayAdd :: Maybe Int
, annexHttpHeaders :: [String]
, annexHttpHeadersCommand :: Maybe String
@@ -116,6 +117,7 @@ extractGitConfig r = GitConfig
, annexBloomAccuracy = getmayberead (annex "bloomaccuracy")
, annexSshCaching = getmaybebool (annex "sshcaching")
, annexAlwaysCommit = getbool (annex "alwayscommit") True
+ , annexMergeAnnexBranches = getbool (annex "merge-annex-branches") True
, annexDelayAdd = getmayberead (annex "delayadd")
, annexHttpHeaders = getlist (annex "http-headers")
, annexHttpHeadersCommand = getmaybe (annex "http-headers-command")
diff --git a/doc/bugs/impossible_to_perform___34__read-only__34___git_annex_info_without_write_permissions/comment_3_05f7eec04634e5b4e200cf3dca1bb1b1._comment b/doc/bugs/impossible_to_perform___34__read-only__34___git_annex_info_without_write_permissions/comment_3_05f7eec04634e5b4e200cf3dca1bb1b1._comment
new file mode 100644
index 000000000..3edb6654b
--- /dev/null
+++ b/doc/bugs/impossible_to_perform___34__read-only__34___git_annex_info_without_write_permissions/comment_3_05f7eec04634e5b4e200cf3dca1bb1b1._comment
@@ -0,0 +1,33 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 3"""
+ date="2018-02-22T17:27:06Z"
+ content="""
+There are situations where a git command that appears to be read-only,
+such as `git status` actually writes to the repository behind the scenes.
+It looks like git ignores write errors in at least some such cases. So
+there is precident for implicit read-only support, but I think not in cases
+where it would involve significant behavior changes, like it would for the
+git-annex branch auto-merging. In git's case the behavior change probably
+only involves repeated `git status` runs being slower than otherwise,
+or something like that.
+
+As well as populating the .git/annex/index file with information merged in from
+recently fetched git-annex branches, git-annex may need to write to other files
+in order to prepare caches needed to perform what appears to be "read-only"
+query operation, or to lock files in order to prevent someone who does have
+write access from dropping them in a situation where that will lose data.
+An example of the latter is running `git annex drop` in a repository you do have
+write access to, and it needing to exclusively lock files in origin,
+which requires write access to origin as well. Without write access,
+the drop may fail.
+
+The --read-only flag seems to be setting up a situation where git-annex handles
+some things being read-only, but then someone expects the flag to
+make some other thing work read-only, which git-annex can't manage to support
+for whatever reason.
+
+So I prefer a more specific name, like annex.merge-annex-branches=false.
+
+Implemented that.
+"""]]
diff --git a/doc/git-annex-config.mdwn b/doc/git-annex-config.mdwn
index bf24251d8..ed602ec95 100644
--- a/doc/git-annex-config.mdwn
+++ b/doc/git-annex-config.mdwn
@@ -34,9 +34,9 @@ These settings can be overridden on a per-repository basis using
* `annex.resolvemerge`
- Set to false to prevent merge conflicts being automatically resolved
- by the git-annex assitant, git-annex sync, git-annex merge,
- and the git-annex post-receive hook.
+ Set to false to prevent merge conflicts in the checked out branch
+ being automatically resolved by the git-annex assitant,
+ git-annex sync, git-annex merge, and the git-annex post-receive hook.
* `annex.synccontent`
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 684e5c60a..db8cfca61 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -974,6 +974,15 @@ Here are all the supported configuration settings.
since it could garbage collect objects that are staged in git-annex's
index but not yet committed.
+* `annex.merge-annex-branches`
+
+ By default, git-annex branches that have been pulled from remotes
+ are automatically merged into the local git-annex branch, so that
+ git-annex has the most up-to-date possible knowledge.
+
+ To avoid that merging, set this to "false". This can be useful
+ particularly when you don't have write permission to the repository.
+
* `annex.hardlink`
Set this to `true` to make file contents be hard linked between the
@@ -1054,8 +1063,9 @@ Here are all the supported configuration settings.
* `annex.resolvemerge`
- Set to false to prevent merge conflicts being automatically resolved
- by the git-annex assitant, git-annex sync, git-annex merge,
+ Set to false to prevent merge conflicts in the checked out branch
+ being automatically resolved by the git-annex assitant,
+ git-annex sync, git-annex merge,
and the git-annex post-receive hook.
To configure the behavior in all clones of the repository,