Server-side support for user-relative paths.
PATCH 3/4 Server-side support for user-relative paths.
Remove the redundant code from {receive,upload}-pack.c in favour of the library code in path.c (previous patch) with documentation of the changes to the affected programs.
---
Documentation/pull-fetch-param.txt | 35 +++++++++++++++++++++++++++-------- receive-pack.c | 13 ++----------- upload-pack.c | 13 ++----------- 3 files changed, 31 insertions(+), 30 deletions(-)
applies-to: 17cf0474b857a396561f2def13ac6ac6b01e1e33 dd1ddd3d653b28bd57092f0e243efa545cd214d3
Documentation/pull-fetch-param.txt +27 -8
@@ -1,16 +1,35 @@ <repository>:: - The "remote" repository to pull from. One of the - following notations can be used to name the repository - to pull from: + The repository to pull/fetch from or push to. The following + notations can be used to name the repository: + =============================================================== -- Rsync URL: rsync://remote.machine/path/to/repo.git/ -- HTTP(s) URL: http://remote.machine/path/to/repo.git/ -- git URL: git://remote.machine/path/to/repo.git/ - or remote.machine:/path/to/repo.git/ -- Local directory: /path/to/repo.git/ +- rsync://host.xz/path/to/repo.git/ +- http://host.xz/path/to/repo.git/ +- https://host.xz/path/to/repo.git/ +- git://host.xz/path/to/repo.git/ +- git://host.xz/~user/path/to/repo.git/ +- ssh://host.xz/path/to/repo.git/ +- ssh://host.xz/~user/path/to/repo.git/ =============================================================== + + SSH Is the default transport protocol and also supports an + scp-like syntax. Both syntaxes support username expansion, + as does the git-protocol. The following two are identical + to the last two above: ++ +=============================================================== +- host.xz:/path/to/repo.git/ +- host.xz:~user/path/to/repo.git/ +=============================================================== ++ + To sync with a local directory, use: ++ +=============================================================== +- /path/to/repo.git/ +=============================================================== ++ +Note that you can't push via HTTP or HTTPS. ++ In addition to the above, as a short-hand, the name of a file in $GIT_DIR/remotes directory can be given; the named file should be in the following format:
receive-pack.c +2 -11
@@ -265,18 +265,9 @@ int main(int argc, char **argv)if (!dir)usage (receive_pack_usage); -/* chdir to the directory. If that fails, try appending ".git" */ -if (chdir (dir) <0 ) { -if (chdir (mkpath ("%s.git" , dir)) <0 ) -die ("unable to cd to %s" , dir); - } - -/* If we have a ".git" directory, chdir to it */ -chdir (".git" ); -putenv ("GIT_DIR=." ); +if (!is_git_repo (dir,0 )) +die ("'%s': unable to chdir or not a git archive" , dir); -if (access ("objects" ,X_OK ) <0 ||access ("refs/heads" ,X_OK ) <0 ) -die ("%s doesn't appear to be a git directory" , dir);write_head_info ();/* EOF */
upload-pack.c +2 -11
@@ -275,18 +275,9 @@ int main(int argc, char **argv)usage (upload_pack_usage); dir = argv[i]; -/* chdir to the directory. If that fails, try appending ".git" */ -if (chdir (dir) <0 ) { -if (strict ||chdir (mkpath ("%s.git" , dir)) <0 ) -die ("git-upload-pack unable to chdir to %s" , dir); - } -if (!strict) -chdir (".git" ); +if (!is_git_repo (dir, strict)) +die ("'%s': unable to chdir or not a git archive" , dir); -if (access ("objects" ,X_OK ) ||access ("refs" ,X_OK )) -die ("git-upload-pack: %s doesn't seem to be a git archive" , dir); - -putenv ("GIT_DIR=." );upload_pack ();return 0 ; }
---
0.99.9.GIT
Quoted 3 lines · Andreas Ericsson
Remove the redundant code from {receive,upload}-pack.c in favour of the library code in
path.c(previous patch) with documentation of the changes to the affected programs.
I like the simplification of these two calling sites, but it makes me feel uneasy to see the workhorse named is_git_repo().
The name implies a check to see if the given path is a git repo or not (i.e. side-effect free predicate), while what it actually does are three things: (1) resolve and check, (2) chdir to it,
(3) set up GIT_DIR environment. Not that I have a better name in mind...
Documentation/pull-fetch-param.txt line 15
Quoted 1 line
Documentation/pull-fetch-param.txt +1
-0+ SSH Is the default transport protocol and also supports an
Just a typo ("Is")?
Quoted 8 lines · Junio C Hamano
Quoted 3 lines · Andreas Ericsson
Remove the redundant code from {receive,upload}-pack.c in favour of the library code in
path.c(previous patch) with documentation of the changes to the affected programs.
Quoted 9 lines
I like the simplification of these two calling sites, but it makes me feel uneasy to see the workhorse named
is_git_repo().The name implies a check to see if the given path is a git repo or not (i.e. side-effect free predicate), while what it actually does are three things: (1) resolve and check, (2) chdir to it,
(3) set upGIT_DIRenvironment. Not that I have a better name in mind...
I went with this implementation because when I tried to break it up I had to add the chdir() and putenv() calls in the three callers. No programs in the git-suite tries to resolve the canonical path of a repo without subsequently entering it and using it.
Perhaps it should be enter_repo() or some such? Optionally with is_git_repo() as a separate function?
Quoted 6 lines
Documentation/pull-fetch-param.txt line 15
Quoted 2 lines
Documentation/pull-fetch-param.txt +1
-0+ SSH Is the default transport protocol and also supports anJust a typo ("Is")?
Yes.
Signature · 3 lines
Andreas Ericsson [email protected] OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231
Quoted 3 lines · Andreas Ericsson
I went with this implementation because...
Perhaps it should beenter_repo()or some such? Optionally withis_git_repo()as a separate function?
I agree with you that splitting this into three separate functions does not make much sense. I was just unsure about that name; enter_repo() sounds more sensible.