]> dgit.raspbian.org Git - git-annex.git/commitdiff
set remote's annexUrl automatically
authorJoey Hess <joeyh@joeyh.name>
Mon, 29 Jul 2024 00:13:41 +0000 (20:13 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 29 Jul 2024 00:13:41 +0000 (20:13 -0400)
When the remote repository's git config file
has annex.url set to an annex+http url.

Remote/Git.hs
Types/GitConfig.hs
doc/git-annex.mdwn
doc/tips/smart_http_server.mdwn
doc/todo/git-annex_proxies.mdwn

index 8657c3d4f6dbe84a79b99e1677618c0ea20c0989..a915b2835ae4a6c26c5f31626f40e97daf829548 100644 (file)
@@ -340,6 +340,12 @@ tryGitConfigRead autoinit r hasuuid
                                -- optimisation.
                                unless (fromMaybe False $ Git.Config.isBare r') $
                                        setremote setRemoteBare False
+                               -- When annex.url is set to a P2P http url,
+                               -- store in remote.name.annexUrl
+                               case Git.fromConfigValue <$> Git.Config.getMaybe (annexConfig "url") r' of
+                                       Just u | isP2PHttpProtocolUrl u ->
+                                               setremote (setConfig . annexUrlConfigKey) u
+                                       _ -> noop
                                return r'
                        Left err -> do
                                set_ignore "not usable by git-annex" False
index d7f4f52af1763442288cc918ee4e41019bf8d80e..d6c295edfb71f0f02ef081024d1f11b0be3a319c 100644 (file)
@@ -109,6 +109,7 @@ data GitConfig = GitConfig
        , annexSyncMigrations :: Bool
        , annexDebug :: Bool
        , annexDebugFilter :: Maybe String
+       , annexUrl :: Maybe String
        , annexWebOptions :: [String]
        , annexYoutubeDlOptions :: [String]
        , annexYoutubeDlCommand :: Maybe String
@@ -204,6 +205,7 @@ extractGitConfig configsource r = GitConfig
        , annexSyncMigrations = getbool (annexConfig "syncmigrations") True
        , annexDebug = getbool (annexConfig "debug") False
        , annexDebugFilter = getmaybe (annexConfig "debugfilter")
+       , annexUrl = getmaybe (annexConfig "url")
        , annexWebOptions = getwords (annexConfig "web-options")
        , annexYoutubeDlOptions = getwords (annexConfig "youtube-dl-options")
        , annexYoutubeDlCommand = getmaybe (annexConfig "youtube-dl-command")
index 6700b5c8528ddb5ae4a3e22d4e55020f6a195ce1..5a0b3a7cc09aed7b735dea98ee80ce7902c92105 100644 (file)
@@ -1242,6 +1242,13 @@ repository, using [[git-annex-config]]. See its man page for a list.)
   After changing this config, you need to re-run `git-annex init` for it
   to take effect.
 
+* `annex.url`
+
+  When a remote has a http url, the first time git-annex uses the remote
+  it will check if it can download its `.git/config` file. If it is able
+  to, and the file has this config set to an "annex+http" or "annex+https"
+  url, that url will be copied into `remote.<name>.annexUrl`. 
+
 * `annex.resolvemerge`
 
   Set to false to prevent merge conflicts in the checked out branch
index f2440036b9b93f9dc10955011df42f11813bad1b..242c2e96e387c395071bf945247f5f8e81a4fb36 100644 (file)
@@ -15,22 +15,26 @@ You will still need to run a web server to serve the git repository.
 [[API|design/p2p_protocol_over_http]], and it does it
 on a different port (9417 by default).
 
-All you need to do on the server is to arrange to run 
-`git-annex p2phttp` in your repository as a daemon, or service.
-Note that it should not be run as root, but as whatever user owns the
-repository. It has several options you can use to configure it, including
-controlling who can access the repository.
-
-After cloning a repository, it's necessary to configure
-`remote.name.annexUrl` to an "annex+http" or "annex+https" url,
-so that git-annex knows where the API endpoint is.
-
-For example:
-
-    git clone http://example.com/foo.git
-    cd foo
-    git config remote.origin.annexUrl annex+http://example.com/git-annex/bbdac17e-6633-4b27-8f7b-fb447d5bae7c
-    git-annex get ...
-
-The last part of the "annex+http" url is the annex.uuid of the
-remote repository.
+You will need to arrange to run `git-annex p2phttp` in your repository as a
+daemon or service. Note that it should not be run as root, but as whatever
+user owns the repository. It has several options you can use to configure
+it, including controlling who can access the repository.
+
+So there are two web servers, and thus two different urls.
+A remote will have `remote.name.url` set to the http url
+that git will use, and also have `remote.name.annexUrl` set to the url
+that git-annex will use to talk to `git-annex p2phttp`. That url
+looks like this:
+    
+    annex+http://example.com/git-annex/bbdac17e-6633-4b27-8f7b-fb447d5bae7c
+
+The "annex+http" (or "annex+https") indicates that it's a git-annex API
+url, which defaults to being on port 9417 unless a different port is set.
+And the last part of the url is the annex.uuid of the repository.
+
+It would be annoying if every user who cloned your repository 
+had to set `remote.name.annexUrl` manually. So there's a way to automate it.
+In the git config file of the repository, set `annex.url` to the "annex+http"
+(or "annex+https") url. The first time it uses a http remote, git-annex
+downloads the git config file, and sets `remote.name.annexUrl` to the value
+of annex.url.
index 8839d7c676b36aa19a32a472dba7263ed6ef3606..fcec9843fe8743803f70fab237195c317fcff623 100644 (file)
@@ -28,11 +28,6 @@ Planned schedule of work:
 
 ## work notes
 
-* When getting the remote .git/config of a http remote, check if
-  annex.apiurl is set, and if so, set the remote's annexUrl automically.
-
-  git-annex-p2phttp could automatically set annex.apiurl as well.
-
 * An interrupted PUT to cluster that has a node that is a special remote
   over http leaves open the connection to the cluster, so the next request
   opens another one.