{"thread":{"id":"2300","subject":"[PATCH 3/4] Server-side support for user-relative paths.","startedAt":"2005-11-01T22:59:21Z","lastAt":"2005-11-02T09:47:13Z","messageCount":4,"participants":["Andreas Ericsson","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"10956","messageId":"20051101225921.3835C5BF73@nox.op5.se","threadId":"2300","inReplyTo":null,"subject":"[PATCH 3/4] Server-side support for user-relative paths.","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2005-11-01T22:59:21Z","receivedAt":"2005-11-01T22:59:21Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Remove the redundant code from {receive,upload}-pack.c in favour of the\nlibrary code in path.c (previous patch) with documentation of the changes\nto the affected programs.\n\nSigned-off-by: Andreas Ericsson <ae@op5.se>\n\n---\n\n Documentation/pull-fetch-param.txt |   35 +++++++++++++++++++++++++++--------\n receive-pack.c                     |   13 ++-----------\n upload-pack.c                      |   13 ++-----------\n 3 files changed, 31 insertions(+), 30 deletions(-)\n\napplies-to: 17cf0474b857a396561f2def13ac6ac6b01e1e33\ndd1ddd3d653b28bd57092f0e243efa545cd214d3\ndiff --git a/Documentation/pull-fetch-param.txt b/Documentation/pull-fetch-param.txt\nindex e8db9d7..33ee02e 100644\n--- a/Documentation/pull-fetch-param.txt\n+++ b/Documentation/pull-fetch-param.txt\n@@ -1,16 +1,35 @@\n <repository>::\n-\tThe \"remote\" repository to pull from.  One of the\n-\tfollowing notations can be used to name the repository\n-\tto pull from:\n+\tThe repository to pull/fetch from or push to.  The following\n+\tnotations can be used to name the repository:\n +\n ===============================================================\n-- Rsync URL:\t\trsync://remote.machine/path/to/repo.git/\n-- HTTP(s) URL:\t\thttp://remote.machine/path/to/repo.git/\n-- git URL:\t\tgit://remote.machine/path/to/repo.git/\n-\t\t\tor remote.machine:/path/to/repo.git/\n-- Local directory:\t/path/to/repo.git/\n+- rsync://host.xz/path/to/repo.git/\n+- http://host.xz/path/to/repo.git/\n+- https://host.xz/path/to/repo.git/\n+- git://host.xz/path/to/repo.git/\n+- git://host.xz/~user/path/to/repo.git/\n+- ssh://host.xz/path/to/repo.git/\n+- ssh://host.xz/~user/path/to/repo.git/\n ===============================================================\n +\n+\tSSH Is the default transport protocol and also supports an\n+\tscp-like syntax.  Both syntaxes support username expansion,\n+\tas does the git-protocol. The following two are\tidentical\n+\tto the last two above:\n++\n+===============================================================\n+- host.xz:/path/to/repo.git/\n+- host.xz:~user/path/to/repo.git/\n+===============================================================\n++\n+\tTo sync with a local directory, use:\n++\n+===============================================================\n+- /path/to/repo.git/\n+===============================================================\n++\n+Note that you can't push via HTTP or HTTPS.\n++\n In addition to the above, as a short-hand, the name of a\n file in $GIT_DIR/remotes directory can be given; the\n named file should be in the following format:\ndiff --git a/receive-pack.c b/receive-pack.c\nindex 8f157bc..2c56018 100644\n--- a/receive-pack.c\n+++ b/receive-pack.c\n@@ -265,18 +265,9 @@ int main(int argc, char **argv)\n \tif (!dir)\n \t\tusage(receive_pack_usage);\n \n-\t/* chdir to the directory. If that fails, try appending \".git\" */\n-\tif (chdir(dir) < 0) {\n-\t\tif (chdir(mkpath(\"%s.git\", dir)) < 0)\n-\t\t\tdie(\"unable to cd to %s\", dir);\n-\t}\n-\n-\t/* If we have a \".git\" directory, chdir to it */\n-\tchdir(\".git\");\n-\tputenv(\"GIT_DIR=.\");\n+\tif(!is_git_repo(dir, 0))\n+\t\tdie(\"'%s': unable to chdir or not a git archive\", dir);\n \n-\tif (access(\"objects\", X_OK) < 0 || access(\"refs/heads\", X_OK) < 0)\n-\t\tdie(\"%s doesn't appear to be a git directory\", dir);\n \twrite_head_info();\n \n \t/* EOF */\ndiff --git a/upload-pack.c b/upload-pack.c\nindex c5eff21..86e2a61 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -275,18 +275,9 @@ int main(int argc, char **argv)\n \t\tusage(upload_pack_usage);\n \tdir = argv[i];\n \n-\t/* chdir to the directory. If that fails, try appending \".git\" */\n-\tif (chdir(dir) < 0) {\n-\t\tif (strict || chdir(mkpath(\"%s.git\", dir)) < 0)\n-\t\t\tdie(\"git-upload-pack unable to chdir to %s\", dir);\n-\t}\n-\tif (!strict)\n-\t\tchdir(\".git\");\n+\tif(!is_git_repo(dir, strict))\n+\t\tdie(\"'%s': unable to chdir or not a git archive\", dir);\n \n-\tif (access(\"objects\", X_OK) || access(\"refs\", X_OK))\n-\t\tdie(\"git-upload-pack: %s doesn't seem to be a git archive\", dir);\n-\n-\tputenv(\"GIT_DIR=.\");\n \tupload_pack();\n \treturn 0;\n }\n---\n0.99.9.GIT\n"},{"id":"10969","messageId":"7vek5z6h3f.fsf@assigned-by-dhcp.cox.net","threadId":"2300","inReplyTo":"20051101225921.3835C5BF73@nox.op5.se","subject":"Re: [PATCH 3/4] Server-side support for user-relative paths.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-02T00:14:44Z","receivedAt":"2005-11-02T00:14:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Ericsson <ae@op5.se> writes:\n\n> Remove the redundant code from {receive,upload}-pack.c in favour of the\n> library code in path.c (previous patch) with documentation of the changes\n> to the affected programs.\n\nI like the simplification of these two calling sites, but it\nmakes me feel uneasy to see the workhorse named is_git_repo().\n\nThe name implies a check to see if the given path is a git repo\nor not (i.e. side-effect free predicate), while what it actually\ndoes are three things: (1) resolve and check, (2) chdir to it,\n(3) set up GIT_DIR environment.  Not that I have a better name\nin mind...\n\n> +\tSSH Is the default transport protocol and also supports an\n\nJust a typo (\"Is\")?\n"},{"id":"11000","messageId":"43687914.6080906@op5.se","threadId":"2300","inReplyTo":"7vek5z6h3f.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 3/4] Server-side support for user-relative paths.","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2005-11-02T08:30:12Z","receivedAt":"2005-11-02T08:30:12Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> Andreas Ericsson <ae@op5.se> writes:\n> \n> \n>>Remove the redundant code from {receive,upload}-pack.c in favour of the\n>>library code in path.c (previous patch) with documentation of the changes\n>>to the affected programs.\n> \n> \n> I like the simplification of these two calling sites, but it\n> makes me feel uneasy to see the workhorse named is_git_repo().\n> \n> The name implies a check to see if the given path is a git repo\n> or not (i.e. side-effect free predicate), while what it actually\n> does are three things: (1) resolve and check, (2) chdir to it,\n> (3) set up GIT_DIR environment.  Not that I have a better name\n> in mind...\n> \n\nI went with this implementation because when I tried to break it up I \nhad to add the chdir() and putenv() calls in the three callers. No \nprograms in the git-suite tries to resolve the canonical path of a repo \nwithout subsequently entering it and using it.\n\nPerhaps it should be enter_repo() or some such? Optionally with \nis_git_repo() as a separate function?\n\n> \n>>+\tSSH Is the default transport protocol and also supports an\n> \n> \n> Just a typo (\"Is\")?\n> \n\nYes.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"11010","messageId":"7vll07tm8u.fsf@assigned-by-dhcp.cox.net","threadId":"2300","inReplyTo":"43687914.6080906@op5.se","subject":"Re: [PATCH 3/4] Server-side support for user-relative paths.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-02T09:47:13Z","receivedAt":"2005-11-02T09:47:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Ericsson <ae@op5.se> writes:\n\n> I went with this implementation because...\n> Perhaps it should be enter_repo() or some such? Optionally with \n> is_git_repo() as a separate function?\n\nI agree with you that splitting this into three separate\nfunctions does not make much sense.  I was just unsure about\nthat name; enter_repo() sounds more sensible.\n"}]}