{"thread":{"id":"29367","subject":"git-upload-archive help was not shown correctly","startedAt":"2012-01-14T13:40:16Z","lastAt":"2012-01-14T20:56:11Z","messageCount":3,"participants":["devendra","Carlos Martín Nieto","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"182552","messageId":"1326548416.5992.1.camel@devendra-Linux","threadId":"29367","inReplyTo":null,"subject":"git-upload-archive help was not shown correctly","fromName":"devendra","fromEmail":"dev@savarinetworks.com","sentAt":"2012-01-14T13:40:16Z","receivedAt":"2012-01-14T13:40:16Z","isPatch":false,"sender":{"key":"dev@savarinetworks.com","avatar":null},"body":"Hi git folks,\n\nthe command git-upload-archive is not properly showing usage info when\nran barely with out any args.\n\nit shows some kind of unwanted garbage instead of showing a nice help\nmessage.\n\nThe output is pasted here.\n\nroot@devendra-Linux:/home/devendra/git/Documentation#\ngit-upload-archive \n0008ACK\n00000026 usage: git upload-archive <repo>\n0031 git upload-archive: archiver died with errorfatal: sent error to\nthe client: git upload-archive: archiver died with error\n\nmy git latest version shows commit sha1 number\n6db5c6e43dccb380ca6e9947777985eb11248c31.\n\nDevendra.\n"},{"id":"182557","messageId":"20120114154633.GA3444@beez.lab.cmartin.tk","threadId":"29367","inReplyTo":"1326548416.5992.1.camel@devendra-Linux","subject":"Re: git-upload-archive help was not shown correctly","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-01-14T15:46:33Z","receivedAt":"2012-01-14T15:46:33Z","isPatch":false,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On Sat, Jan 14, 2012 at 07:10:16PM +0530, devendra wrote:\n> Hi git folks,\n> \n> the command git-upload-archive is not properly showing usage info when\n> ran barely with out any args.\n\ngit-upload-package is not for human use. It's what gets run on the\nremote end when you run e.g. 'git archive --remote=origin HEAD'\n\n> \n> it shows some kind of unwanted garbage instead of showing a nice help\n> message.\n\nIt's trying to talk to git. What you see is the \"Git Smart\nProtocol\". What were you trying to do?\n\n   cmn\n"},{"id":"182562","messageId":"20120114205611.GA21756@sigill.intra.peff.net","threadId":"29367","inReplyTo":"20120114154633.GA3444@beez.lab.cmartin.tk","subject":"Re: git-upload-archive help was not shown correctly","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-01-14T20:56:11Z","receivedAt":"2012-01-14T20:56:11Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jan 14, 2012 at 04:46:33PM +0100, Carlos Martín Nieto wrote:\n\n> On Sat, Jan 14, 2012 at 07:10:16PM +0530, devendra wrote:\n> > Hi git folks,\n> > \n> > the command git-upload-archive is not properly showing usage info when\n> > ran barely with out any args.\n> \n> git-upload-package is not for human use. It's what gets run on the\n> remote end when you run e.g. 'git archive --remote=origin HEAD'\n\nYeah, but notice that it does detect the error condition; it just wraps\nit in a bunch of cruft. More explanation (and a patch) are below, though\nI'm lukewarm on the patch.\n\n> > it shows some kind of unwanted garbage instead of showing a nice help\n> > message.\n> \n> It's trying to talk to git. What you see is the \"Git Smart\n> Protocol\". What were you trying to do?\n\nYeah, this is the more important question. You shouldn't generally ever\nbe running git-upload-* yourself.\n\n-- >8 --\nSubject: upload-archive: detect bad command-line arguments early\n\nThe upload-archive command spawns a helper process to\nactually generate the archive (passing along all of its\ncommand-line arguments), and the parent process then\nmultiplexes the stdout and stderr of the helper back to the\nclient.\n\nThis means an incorrect invocation (which in this case means\nfailing to provide a single <repo> argument) will cause the\nhelper to complain, and the error will be sent to the client\nover the multiplexed channel.\n\nThis is not ideal for two reasons:\n\n  1. An invocation error in upload-pack is almost certainly\n     not something the client can do anything about. It\n     generally implies a bug in either git-daemon or\n     git-archive. The one exception is something like:\n\n       git archive --remote=ssh_host:repo.git \\\n                   --exec=\"git upload-archive bogus\" \\\n\n  2. For local users who are experimenting with git\n     commands, running \"upload-archive\" appears to generate\n     a bunch of barely-readable garbage (which is in fact\n     the git protocol intermingled with stderr). It's nicer\n     if we provide them with a readable error message.\n\nInstead, we can detect a bad command-line before we spawn\nthe helper and give a more human-readable complaint (i.e.,\nhelping reason (2) above). This doesn't hurt case (1) as\nmuch as you might think, because in the ssh case, the user\nshould be receiving stderr from the parent process anyway.\n\nSo before they saw:\n\n  $ git archive --remote=... --exec='git upload-archive bogus'\n  fatal: sent error to the client: git upload-archive: archiver died with error\n  remote: usage: git upload-archive <repo>\n  remote: git upload-archive: archiver died with error\n\nand now they see:\n\n  usage: git upload-archive <repo>\n  fatal: The remote end hung up unexpectedly\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nI'm lukewarm on this patch. I actually think the original output is\nslightly nicer, so you are hurting case (1) for people in case (2). But\ncase (2), running random programs to see what happens, is not something\nwe probably need to be encouraging.\n\n builtin/upload-archive.c |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/upload-archive.c b/builtin/upload-archive.c\nindex b928beb..0733775 100644\n--- a/builtin/upload-archive.c\n+++ b/builtin/upload-archive.c\n@@ -10,6 +10,8 @@\n \n static const char upload_archive_usage[] =\n \t\"git upload-archive <repo>\";\n+static const char upload_archive_writer_usage[] =\n+\t\"git upload-archive--writer <repo>\";\n \n static const char deadchild[] =\n \"git upload-archive: archiver died with error\";\n@@ -25,7 +27,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)\n \tint len;\n \n \tif (argc != 2)\n-\t\tusage(upload_archive_usage);\n+\t\tusage(upload_archive_writer_usage);\n \n \tif (strlen(argv[1]) + 1 > sizeof(buf))\n \t\tdie(\"insanely long repository name\");\n@@ -96,6 +98,9 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)\n {\n \tstruct child_process writer = { argv };\n \n+\tif (argc != 2)\n+\t\tusage(upload_archive_usage);\n+\n \t/*\n \t * Set up sideband subprocess.\n \t *\n-- \n1.7.9.rc0.33.gd3c17\n"}]}