aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-07-03 15:42:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-07-03 15:42:56 -0400
commitac3d31034a0a2181e21d3ad599450322ed6a55dd (patch)
tree7135de5cab66606444ab0ea2504e9ef53fbc651f
parentfa45610f3809b7c0f1a469547d0c7e4209c05a9d (diff)
merge: Now also merges synced/master or similar branches, which makes it useful to put in a post-receive hook to make a repository automatically update its working copy when git annex sync or the assistant sync with it.
-rw-r--r--Command/Merge.hs33
-rw-r--r--debian/changelog4
-rw-r--r--doc/git-annex.mdwn16
-rw-r--r--doc/tips/setup_a_public_repository_on_a_web_site.mdwn7
4 files changed, 38 insertions, 22 deletions
diff --git a/Command/Merge.hs b/Command/Merge.hs
index 382a251df..659f14080 100644
--- a/Command/Merge.hs
+++ b/Command/Merge.hs
@@ -1,6 +1,6 @@
{- git-annex command
-
- - Copyright 2011 Joey Hess <joey@kitenet.net>
+ - Copyright 2011, 2013 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -10,22 +10,29 @@ module Command.Merge where
import Common.Annex
import Command
import qualified Annex.Branch
+import qualified Git.Branch
+import Command.Sync (mergeLocal)
def :: [Command]
def = [command "merge" paramNothing seek SectionMaintenance
- "auto-merge remote changes into git-annex branch"]
+ "automatically merge changes from remotes"]
seek :: [CommandSeek]
-seek = [withNothing start]
+seek =
+ [ withNothing mergeBranch
+ , withNothing mergeSynced
+ ]
-start :: CommandStart
-start = do
- showStart "merge" "."
- next perform
+mergeBranch :: CommandStart
+mergeBranch = do
+ showStart "merge" "git-annex"
+ next $ do
+ Annex.Branch.update
+ -- commit explicitly, in case no remote branches were merged
+ Annex.Branch.commit "update"
+ next $ return True
-perform :: CommandPerform
-perform = do
- Annex.Branch.update
- -- commit explicitly, in case no remote branches were merged
- Annex.Branch.commit "update"
- next $ return True
+mergeSynced :: CommandStart
+mergeSynced = do
+ branch <- inRepo Git.Branch.current
+ maybe stop mergeLocal branch
diff --git a/debian/changelog b/debian/changelog
index d708ed908..57f777758 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,10 @@ git-annex (4.20130628) UNRELEASED; urgency=low
by the last run of git annex unused. Supported by fsck, get, move, copy.
* get, move, copy: Can now be run in a bare repository,
like fsck already could. --all is enabled automatically in this case.
+ * merge: Now also merges synced/master or similar branches, which
+ makes it useful to put in a post-receive hook to make a repository
+ automatically update its working copy when git annex sync or the assistant
+ sync with it.
* webapp: Fix ssh setup with nonstandard port, broken in last release.
-- Joey Hess <joeyh@debian.org> Tue, 02 Jul 2013 15:40:55 -0400
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 0dc6fe7ae..5c364bd57 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -148,6 +148,15 @@ subdirectories).
Note that sync does not transfer any file contents from or to the remote
repositories.
+* merge
+
+ This performs the same merging that is done by the sync command, but
+ without pushing or pulling any data.
+
+ One way to use this is to put `git annex merge` into a repository's
+ post-receive hook. Then any syncs to the repository will update its working
+ copy automatically.
+
* addurl [url ...]
Downloads each url to its own file, which is added to the annex.
@@ -401,13 +410,6 @@ subdirectories).
as listed by the last `git annex unused`. The files will have names
starting with "unused."
-* merge
-
- Automatically merges remote tracking branches */git-annex into
- the git-annex branch. While git-annex mostly handles keeping the
- git-annex branch merged automatically, if you find you are unable
- to push the git-annex branch due non-fast-forward, this will fix it.
-
* fix [path ...]
Fixes up symlinks that have become broken to again point to annexed content.
diff --git a/doc/tips/setup_a_public_repository_on_a_web_site.mdwn b/doc/tips/setup_a_public_repository_on_a_web_site.mdwn
index dae1d69c2..e1fbd1e47 100644
--- a/doc/tips/setup_a_public_repository_on_a_web_site.mdwn
+++ b/doc/tips/setup_a_public_repository_on_a_web_site.mdwn
@@ -20,9 +20,12 @@ Here's how I set it up. --[[Joey]]
7. Instruct advanced users to clone a http url that ends with the "/.git/"
directory. For example, for downloads.kitenet.net, the clone url
is `https://downloads.kitenet.net/.git/`
+8. Set up a git `post-receive` hook that runs `git annex merge`, and
+ the repository's working tree will automatically be updated when
+ you run `git annex sync` in a clone that can push to the repository.
+ (Needs git-annex version 4.20130703 or newer; older versions
+ can use `git annex sync` in the post-receive hook instead.)
When users clone over http, and run git-annex, it will
automatically learn all about your repository and be able to download files
right out of it, also using http.
-
-Enjoy!