diff --git a/Remote/Git.hs b/Remote/Git.hs index 8657c3d4f6..a915b2835a 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -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 diff --git a/Types/GitConfig.hs b/Types/GitConfig.hs index d7f4f52af1..d6c295edfb 100644 --- a/Types/GitConfig.hs +++ b/Types/GitConfig.hs @@ -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") diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index 6700b5c852..5a0b3a7cc0 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -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..annexUrl`. + * `annex.resolvemerge` Set to false to prevent merge conflicts in the checked out branch diff --git a/doc/tips/smart_http_server.mdwn b/doc/tips/smart_http_server.mdwn index f2440036b9..242c2e96e3 100644 --- a/doc/tips/smart_http_server.mdwn +++ b/doc/tips/smart_http_server.mdwn @@ -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. +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. -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. +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 -For example: +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. - 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. +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. diff --git a/doc/todo/git-annex_proxies.mdwn b/doc/todo/git-annex_proxies.mdwn index 8839d7c676..fcec9843fe 100644 --- a/doc/todo/git-annex_proxies.mdwn +++ b/doc/todo/git-annex_proxies.mdwn @@ -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.