{"thread":{"id":"1029","subject":"[PATCH] git-ssh-pull: commit-id consistency","startedAt":"2005-06-26T19:45:47Z","lastAt":"2005-06-27T19:03:07Z","messageCount":3,"participants":["Sven Verdoolaege","Daniel Barkalow"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"5284","messageId":"20050626214547.A29432@tin.liacs.nl","threadId":"1029","inReplyTo":null,"subject":"[PATCH] git-ssh-pull: commit-id consistency","fromName":"Sven Verdoolaege","fromEmail":"skimo@liacs.nl","sentAt":"2005-06-26T19:45:47Z","receivedAt":"2005-06-26T19:45:47Z","isPatch":true,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"I thought about keeping the check for a leading dot or slash,\nbut then I figured that you'd get an error from the other\nside pretty quickly.\n\nskimo\n--\nIn contrast to other plumbing tools, git-ssh-pu{sh,ll} only\nallow a very restrictive form of commit-id filenames.\nThis patch removes this restriction.\n\nSigned-off-by: Sven Verdoolaege <skimo@kotnet.org>\n\n---\ncommit 00437f1bafcb710bb809cd2e87cdaeae340a67b8\ntree 480e77cde9afbd0b0abd33e3f272288739b01a7e\nparent 641e1cac73acd67d0b1830dfd7196bca58dffbf2\nauthor Sven Verdoolaege <skimo@kotnet.org> Sun, 26 Jun 2005 19:41:44 +0200\ncommitter Sven Verdoolaege <skimo@kotnet.org> Sun, 26 Jun 2005 19:41:44 +0200\n\n pull.c     |    7 ++-----\n ssh-push.c |    2 +-\n 2 files changed, 3 insertions(+), 6 deletions(-)\n\ndiff --git a/pull.c b/pull.c\n--- a/pull.c\n+++ b/pull.c\n@@ -152,11 +152,8 @@ static int interpret_target(char *target\n {\n \tif (!get_sha1_hex(target, sha1))\n \t\treturn 0;\n-\tif (!check_ref_format(target)) {\n-\t\tif (!fetch_ref(target, sha1)) {\n-\t\t\treturn 0;\n-\t\t}\n-\t}\n+\tif (!fetch_ref(target, sha1))\n+\t\treturn 0;\n \treturn -1;\n }\n \ndiff --git a/ssh-push.c b/ssh-push.c\n--- a/ssh-push.c\n+++ b/ssh-push.c\n@@ -74,7 +74,7 @@ int serve_ref(int fd_in, int fd_out)\n \t\t\treturn -1;\n \t\tposn++;\n \t} while (ref[posn - 1]);\n-\tif (get_ref_sha1(ref, sha1))\n+\tif (get_sha1(ref, sha1))\n \t\tremote = -1;\n \twrite(fd_out, &remote, 1);\n \tif (remote)\n"},{"id":"5287","messageId":"Pine.LNX.4.21.0506261550460.30848-100000@iabervon.org","threadId":"1029","inReplyTo":"20050626214547.A29432@tin.liacs.nl","subject":"Re: [PATCH] git-ssh-pull: commit-id consistency","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2005-06-26T20:11:50Z","receivedAt":"2005-06-26T20:11:50Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sun, 26 Jun 2005, Sven Verdoolaege wrote:\n\n> I thought about keeping the check for a leading dot or slash,\n> but then I figured that you'd get an error from the other\n> side pretty quickly.\n> \n> skimo\n> --\n> In contrast to other plumbing tools, git-ssh-pu{sh,ll} only\n> allow a very restrictive form of commit-id filenames.\n> This patch removes this restriction.\n\nThere are a few problems with this: not all pull methods can handle\nvagueness; HTTP, for instance, needs to know exactly what URL to request,\nand it can't deal with having the user request just anything. Also, it's\nnot particularly useful to support just anything as the hash to start\nfrom, when you have to specify exactly the file to write the ref to (the\n-w argument), which would be a lot more difficult and flaky, because we\ncan't just look for the only thing that works.\n\nMore generally, I think we should require explicit instructions, even when\nwe might be able to figure things out, when we're moving data between\nrepositories, similar to how we are strict about the data stored in\nrepositories (although, of course, we need to support a few more cases).\n\nIn addition, I think that stuff outside of objects/ and refs/ (and, when\nwe have something in it, info/) should be considered private, and not\ntransmitted from place to place.\n\nOne thing that might be a good idea, however, is to allow using symlinks\nfrom .git/ to refs/<x>/<y> on the local side of git-ssh-push by converting\nthem to <x>/<y>. That way, when you push \"HEAD\", it will actually push\nrefs/heads/my-current-branch instead. Of course, the -w issue remains,\nbecause you may have different names on the other side (i.e., on the local\nside, it might be refs/heads/new-diff-algo, but the remote side might be\nrefs/heads/my-latest).\n\nReally, the right solution is to keep this sort of info somewhere and have \nscripts do the right thing with exact specifications.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"5302","messageId":"20050627210307.A3189@tin.liacs.nl","threadId":"1029","inReplyTo":"20050626214547.A29432@tin.liacs.nl","subject":"[PATCH] git-ssh-pull: commit-id consistency","fromName":"Sven Verdoolaege","fromEmail":"skimo@liacs.nl","sentAt":"2005-06-27T19:03:07Z","receivedAt":"2005-06-27T19:03:07Z","isPatch":true,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"As requested by Daniel, this new version leaves *-pull alone\nand only changes the behaviour of git-ssh-push.\n\nskimo\n--\nIn contrast to other plumbing tools, git-ssh-push only\nallow a very restrictive form of commit-id filenames.\nThis patch removes this restriction.\n\nAcked-by: Daniel Barkalow <barkalow@iabervon.org>\nSigned-off-by: Sven Verdoolaege <skimo@kotnet.org>\n\n---\ncommit 28ec093e92206cd907249e741ca1d19f14da4cf3\ntree 5ad7b33ec80c2c04272cb0abd4531e1d9abfbbe1\nparent e18088451d92fbf83bfb57fd48201eda117f8103\nauthor Sven Verdoolaege <skimo@kotnet.org> Mon, 27 Jun 2005 20:12:40 +0200\ncommitter Sven Verdoolaege <skimo@kotnet.org> Mon, 27 Jun 2005 20:12:40 +0200\n\n Documentation/git-ssh-push.txt |    2 +-\n ssh-push.c                     |   18 ++++++++++++++----\n 2 files changed, 15 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-ssh-push.txt b/Documentation/git-ssh-push.txt\n--- a/Documentation/git-ssh-push.txt\n+++ b/Documentation/git-ssh-push.txt\n@@ -20,7 +20,7 @@ git-ssh-pull, aside from which end you r\n OPTIONS\n -------\n commit-id::\n-        Either the hash or the filename under $GIT_DIR/refs/ to push.\n+        Id of commit to push.\n \n -c::\n         Get the commit objects.\ndiff --git a/ssh-push.c b/ssh-push.c\n--- a/ssh-push.c\n+++ b/ssh-push.c\n@@ -2,6 +2,8 @@\n #include \"rsh.h\"\n #include \"refs.h\"\n \n+#include <string.h>\n+\n unsigned char local_version = 1;\n unsigned char remote_version = 0;\n \n@@ -103,6 +105,9 @@ void service(int fd_in, int fd_out) {\n \t} while (1);\n }\n \n+static const char *ssh_push_usage =\n+\t\"git-ssh-push [-c] [-t] [-a] [-w ref] commit-id url\";\n+\n int main(int argc, char **argv)\n {\n \tint arg = 1;\n@@ -110,18 +115,23 @@ int main(int argc, char **argv)\n         char *url;\n \tint fd_in, fd_out;\n \tconst char *prog = getenv(\"GIT_SSH_PULL\") ? : \"git-ssh-pull\";\n+\tunsigned char sha1[20];\n+\tchar hex[41];\n \n \twhile (arg < argc && argv[arg][0] == '-') {\n \t\tif (argv[arg][1] == 'w')\n \t\t\targ++;\n                 arg++;\n         }\n-        if (argc < arg + 2) {\n-\t\tusage(\"git-ssh-push [-c] [-t] [-a] [-w ref] commit-id url\");\n-                return 1;\n-        }\n+\tif (argc < arg + 2)\n+\t\tusage(ssh_push_usage);\n \tcommit_id = argv[arg];\n \turl = argv[arg + 1];\n+\tif (get_sha1(commit_id, sha1))\n+\t\tusage(ssh_push_usage);\n+\tmemcpy(hex, sha1_to_hex(sha1), sizeof(hex));\n+\targv[arg] = hex;\n+\n \tif (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))\n \t\treturn 1;\n \n"}]}