{"thread":{"id":"10637","subject":"ph/parseopt-sh reloaded","startedAt":"2007-11-04T10:30:52Z","lastAt":"2007-11-06T19:44:15Z","messageCount":20,"participants":["Pierre Habouzit","Ralf Wildenhues","Junio C Hamano","Nicolas Pitre"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"58240","messageId":"1194172262-1563-1-git-send-email-madcoder@debian.org","threadId":"10637","inReplyTo":null,"subject":"ph/parseopt-sh reloaded","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T10:30:52Z","receivedAt":"2007-11-04T10:30:52Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Okay here is a fixed series wrt the security issue Junio raised.\nInstead of the old PARSEOPT_OPTS variable, I now only have\nOPTIONS_KEEPDASHDASH to be set to non empty if you want to add\n--keep-dashdash. The reason for that is that I dislike that every single\ngit-rev-parse --parseopt user had to do a `PASREOPT_OPTS=` at the\nbegining of each script, it's error prone, and ugly.\n\nPARSEOPT_OPTS was an overkill as it wasn't really used for anything else\nthan OPTIONS_KEEPDASHDASH, and if it has to be used for more, it'll be\neasy to extend the specification parser to take options on stdin rather\nthan through parameters.\n\nI also removed the PARSEOPT_OPTS from git-clone.sh as it was a spurious\nuse, I don't intend users to override this variable, it's indeed an\ninternal that changes git-rev-parse --parseopt behaviour in a\nincompatible way for the scripts that uses it, it should not be\nuser-tweakable anyway.\n\nThe 10 patch series (and not 11, I forgot about 7 when I incrementally\nsent the previous one) is fetcheable from my repository:\n\n  git://git.madism.org/git.git on branch ph/parseopt-sh\n\n(ph/parseopt has the remaining patches that are problematic right now\neither because of the small change -h vs. -H or the patches that\nconflicts with git-fetch series right now, but in the spirit this is\ndefinitely a ph/parseopt series).\n\nCheers,\n"},{"id":"299013","messageId":"1194172262-1563-2-git-send-email-madcoder@debian.org","threadId":"10637","inReplyTo":"1194172262-1563-1-git-send-email-madcoder@debian.org","subject":"[PATCH 01/10] Add a parseopt mode to git-rev-parse to bring parse-options to shell scripts.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T10:30:53Z","receivedAt":"2007-11-04T10:30:53Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n Documentation/git-rev-parse.txt |   75 ++++++++++++++++++++++-\n builtin-rev-parse.c             |  126 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 199 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt\nindex 4758c33..6811656 100644\n--- a/Documentation/git-rev-parse.txt\n+++ b/Documentation/git-rev-parse.txt\n@@ -23,6 +23,13 @@ distinguish between them.\n \n OPTIONS\n -------\n+--parseopt::\n+        Use `git-rev-parse` in option parsing mode (see PARSEOPT section below).\n+\n+--keep-dash-dash::\n+\tOnly meaningful in `--parseopt` mode. Tells the option parser to echo\n+        out the first `--` met instead of skipping it.\n+\n --revs-only::\n \tDo not output flags and parameters not meant for\n \t`git-rev-list` command.\n@@ -288,10 +295,74 @@ Here are a handful examples:\n    C^@              I J F\n    F^! D            G H D F\n \n+PARSEOPT\n+--------\n+\n+In `--parseopt` mode, `git-rev-parse` helps massaging options to bring to shell\n+scripts the same facilities C builtins have. It works as an option normalizer\n+(e.g. splits single switches aggregate values), a bit like `getopt(1)` does.\n+\n+It takes on the standard input the specification of the options to parse and\n+understand, and echoes on the standard ouput a line suitable for `sh(1)` `eval`\n+to replace the arguments with normalized ones.  In case of error, it ouputs\n+usage on the standard error stream, and exits with code 129.\n+\n+Input Format\n+~~~~~~~~~~~~\n+\n+`git-ref-parse --parseopt` input format is fully text based. It has two parts,\n+separated by a line that contains only `--`. The lines before (should be more\n+than one) are used for the usage. The lines after describe the options.\n+\n+Each line of options has this format:\n+\n+------------\n+<opt_spec><arg_spec>? SP+ help LF\n+------------\n+\n+`<opt_spec>`::\n+\tits format is the short option character, then the long option name\n+        separated by a comma. Both parts are not required, though at least one\n+        is necessary. `h,help`, `dry-run` and `f` are all three correct\n+        `<opt_spec>`.\n+\n+`<arg_spec>`::\n+\tan `<arg_spec>` tells the option parser if the option has an argument\n+        (`=`), an optionnal one (`?` though its use is discouraged) or none\n+        (no `<arg_spec>` in that case).\n+\n+The rest of the line after as many spaces up to the ending line feed is used\n+as the help associated to the option.\n+\n+Blank lines are ignored, and lines that don't match this specification are used\n+as option group headers (start the line with a space to purposely create such\n+lines).\n+\n+Example\n+~~~~~~~\n+\n+------------\n+OPTS_SPEC=\"\\\n+some-command [options] <args>...\n+\n+some-command does foo and bar !\n+--\n+h,help    show the help\n+\n+foo       some nifty option --foo\n+bar=      some cool option --bar with an argument\n+\n+  An option group Header\n+C?        option C with an optionnal argument\"\n+\n+eval `echo \"$OPTS_SPEC\" | git-rev-parse --parseopt -- \"$@\" || echo exit $?`\n+------------\n+\n+\n Author\n ------\n-Written by Linus Torvalds <torvalds@osdl.org> and\n-Junio C Hamano <junkio@cox.net>\n+Written by Linus Torvalds <torvalds@osdl.org> .\n+Junio C Hamano <junkio@cox.net> and Pierre Habouzit <madcoder@debian.org>\n \n Documentation\n --------------\ndiff --git a/builtin-rev-parse.c b/builtin-rev-parse.c\nindex 8d78b69..054519b 100644\n--- a/builtin-rev-parse.c\n+++ b/builtin-rev-parse.c\n@@ -8,6 +8,7 @@\n #include \"refs.h\"\n #include \"quote.h\"\n #include \"builtin.h\"\n+#include \"parse-options.h\"\n \n #define DO_REVS\t\t1\n #define DO_NOREV\t2\n@@ -209,6 +210,128 @@ static int try_difference(const char *arg)\n \treturn 0;\n }\n \n+static int parseopt_dump(const struct option *o, const char *arg, int unset)\n+{\n+\tstruct strbuf *parsed = o->value;\n+\tif (unset)\n+\t\tstrbuf_addf(parsed, \" --no-%s\", o->long_name);\n+\telse if (o->short_name)\n+\t\tstrbuf_addf(parsed, \" -%c\", o->short_name);\n+\telse\n+\t\tstrbuf_addf(parsed, \" --%s\", o->long_name);\n+\tif (arg) {\n+\t\tstrbuf_addch(parsed, ' ');\n+\t\tsq_quote_buf(parsed, arg);\n+\t}\n+\treturn 0;\n+}\n+\n+static const char *skipspaces(const char *s)\n+{\n+\twhile (isspace(*s))\n+\t\ts++;\n+\treturn s;\n+}\n+\n+static int cmd_parseopt(int argc, const char **argv, const char *prefix)\n+{\n+\tstatic int keep_dashdash = 0;\n+\tstatic char const * const parseopt_usage[] = {\n+\t\t\"git-rev-parse --parseopt [options] -- [<args>...]\",\n+\t\tNULL\n+\t};\n+\tstatic struct option parseopt_opts[] = {\n+\t\tOPT_BOOLEAN(0, \"keep-dashdash\", &keep_dashdash,\n+\t\t\t\t\t\"keep the `--` passed as an arg\"),\n+\t\tOPT_END(),\n+\t};\n+\n+\tstruct strbuf sb, parsed;\n+\tconst char **usage = NULL;\n+\tstruct option *opts = NULL;\n+\tint onb = 0, osz = 0, unb = 0, usz = 0;\n+\n+\tstrbuf_init(&parsed, 0);\n+\tstrbuf_addstr(&parsed, \"set --\");\n+\targc = parse_options(argc, argv, parseopt_opts, parseopt_usage,\n+\t                     PARSE_OPT_KEEP_DASHDASH);\n+\tif (argc < 1 || strcmp(argv[0], \"--\"))\n+\t\tusage_with_options(parseopt_usage, parseopt_opts);\n+\n+\tstrbuf_init(&sb, 0);\n+\t/* get the usage up to the first line with a -- on it */\n+\tfor (;;) {\n+\t\tif (strbuf_getline(&sb, stdin, '\\n') == EOF)\n+\t\t\tdie(\"premature end of input\");\n+\t\tALLOC_GROW(usage, unb + 1, usz);\n+\t\tif (!strcmp(\"--\", sb.buf)) {\n+\t\t\tif (unb < 1)\n+\t\t\t\tdie(\"no usage string given before the `--' separator\");\n+\t\t\tusage[unb] = NULL;\n+\t\t\tbreak;\n+\t\t}\n+\t\tusage[unb++] = strbuf_detach(&sb, NULL);\n+\t}\n+\n+\t/* parse: (<short>|<short>,<long>|<long>)[=?]? SP+ <help> */\n+\twhile (strbuf_getline(&sb, stdin, '\\n') != EOF) {\n+\t\tconst char *s;\n+\t\tstruct option *o;\n+\n+\t\tif (!sb.len)\n+\t\t\tcontinue;\n+\n+\t\tALLOC_GROW(opts, onb + 1, osz);\n+\t\tmemset(opts + onb, 0, sizeof(opts[onb]));\n+\n+\t\to = &opts[onb++];\n+\t\ts = strchr(sb.buf, ' ');\n+\t\tif (!s || *sb.buf == ' ') {\n+\t\t\to->type = OPTION_GROUP;\n+\t\t\to->help = xstrdup(skipspaces(s));\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\to->type = OPTION_CALLBACK;\n+\t\to->help = xstrdup(skipspaces(s));\n+\t\to->value = &parsed;\n+\t\to->callback = &parseopt_dump;\n+\t\tswitch (s[-1]) {\n+\t\tcase '=':\n+\t\t\ts--;\n+\t\t\tbreak;\n+\t\tcase '?':\n+\t\t\to->flags = PARSE_OPT_OPTARG;\n+\t\t\ts--;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\to->flags = PARSE_OPT_NOARG;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (s - sb.buf == 1) /* short option only */\n+\t\t\to->short_name = *sb.buf;\n+\t\telse if (sb.buf[1] != ',') /* long option only */\n+\t\t\to->long_name = xmemdupz(sb.buf, s - sb.buf);\n+\t\telse {\n+\t\t\to->short_name = *sb.buf;\n+\t\t\to->long_name = xmemdupz(sb.buf + 2, s - sb.buf - 2);\n+\t\t}\n+\t}\n+\tstrbuf_release(&sb);\n+\n+\t/* put an OPT_END() */\n+\tALLOC_GROW(opts, onb + 1, osz);\n+\tmemset(opts + onb, 0, sizeof(opts[onb]));\n+\targc = parse_options(argc, argv, opts, usage,\n+\t                     keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0);\n+\n+\tstrbuf_addf(&parsed, \" --\");\n+\tsq_quote_argv(&parsed, argv, argc, 0);\n+\tputs(parsed.buf);\n+\treturn 0;\n+}\n+\n int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n {\n \tint i, as_is = 0, verify = 0;\n@@ -216,6 +339,9 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \n \tgit_config(git_default_config);\n \n+\tif (argc > 1 && !strcmp(\"--parseopt\", argv[1]))\n+\t\treturn cmd_parseopt(argc - 1, argv + 1, prefix);\n+\n \tfor (i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \n-- \n1.5.3.5.1509.g66d41\n\n"},{"id":"299014","messageId":"1194172262-1563-3-git-send-email-madcoder@debian.org","threadId":"10637","inReplyTo":"1194172262-1563-2-git-send-email-madcoder@debian.org","subject":"[PATCH 02/10] Update git-sh-setup(1) to allow transparent use of git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T10:30:54Z","receivedAt":"2007-11-04T10:30:54Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"If you set OPTIONS_SPEC, git-sh-setups uses git-rev-parse --parseopt\nautomatically.\n\nIt also diverts usage to re-exec $0 with the -h option as parse-options.c\nwill catch that.\n\nIf you need git-rev-parse --parseopt to keep the `--` the user may have\npassed to your command, just set OPTIONS_KEEPDASHDASH to a non empty value.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-sh-setup.sh |   48 ++++++++++++++++++++++++++++++------------------\n 1 files changed, 30 insertions(+), 18 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 86d7d4c..e1cf885 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -16,9 +16,36 @@ die() {\n \texit 1\n }\n \n-usage() {\n-\tdie \"Usage: $0 $USAGE\"\n-}\n+if test -n \"$OPTIONS_SPEC\"; then\n+\tusage() {\n+\t\texec \"$0\" -h\n+\t}\n+\n+\tparseopt_extra=\n+\t[ -n \"$OPTIONS_KEEPDASHDASH\" ] &&\n+\t\tparseopt_extra=\"$parseopt_extra --keep-dashdash\"\n+\n+\teval `echo \"$OPTIONS_SPEC\" | git rev-parse --parseopt $parseopt_extra -- \"$@\" || echo exit $?`\n+else\n+\tusage() {\n+\t\tdie \"Usage: $0 $USAGE\"\n+\t}\n+\n+\tif [ -z \"$LONG_USAGE\" ]\n+\tthen\n+\t\tLONG_USAGE=\"Usage: $0 $USAGE\"\n+\telse\n+\t\tLONG_USAGE=\"Usage: $0 $USAGE\n+\n+$LONG_USAGE\"\n+\tfi\n+\n+\tcase \"$1\" in\n+\t\t-h|--h|--he|--hel|--help)\n+\t\techo \"$LONG_USAGE\"\n+\t\texit\n+\tesac\n+fi\n \n set_reflog_action() {\n \tif [ -z \"${GIT_REFLOG_ACTION:+set}\" ]\n@@ -91,21 +118,6 @@ get_author_ident_from_commit () {\n \tLANG=C LC_ALL=C sed -ne \"$pick_author_script\"\n }\n \n-if [ -z \"$LONG_USAGE\" ]\n-then\n-\tLONG_USAGE=\"Usage: $0 $USAGE\"\n-else\n-\tLONG_USAGE=\"Usage: $0 $USAGE\n-\n-$LONG_USAGE\"\n-fi\n-\n-case \"$1\" in\n-\t-h|--h|--he|--hel|--help)\n-\techo \"$LONG_USAGE\"\n-\texit\n-esac\n-\n # Make sure we are in a valid repository of a vintage we understand.\n if [ -z \"$SUBDIRECTORY_OK\" ]\n then\n-- \n1.5.3.5.1509.g66d41\n\n"},{"id":"299015","messageId":"1194172262-1563-4-git-send-email-madcoder@debian.org","threadId":"10637","inReplyTo":"1194172262-1563-3-git-send-email-madcoder@debian.org","subject":"[PATCH 03/10] Migrate git-clean.sh to use git-rev-parse --parseopt.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T10:30:55Z","receivedAt":"2007-11-04T10:30:55Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Also minor consistency tweaks in how errors are caught.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-clean.sh |   38 ++++++++++++++++++++------------------\n 1 files changed, 20 insertions(+), 18 deletions(-)\n\ndiff --git a/git-clean.sh b/git-clean.sh\nindex 4491738..6959433 100755\n--- a/git-clean.sh\n+++ b/git-clean.sh\n@@ -3,16 +3,21 @@\n # Copyright (c) 2005-2006 Pavel Roskin\n #\n \n-USAGE=\"[-d] [-f] [-n] [-q] [-x | -X] [--] <paths>...\"\n-LONG_USAGE='Clean untracked files from the working directory\n-\t-d\tremove directories as well\n-\t-f\toverride clean.requireForce and clean anyway\n-\t-n \tdon'\\''t remove anything, just show what would be done\n-\t-q\tbe quiet, only report errors\n-\t-x\tremove ignored files as well\n-\t-X\tremove only ignored files\n+OPTIONS_SPEC=\"\\\n+git-clean [options] <paths>...\n+\n+Clean untracked files from the working directory\n+\n When optional <paths>... arguments are given, the paths\n-affected are further limited to those that match them.'\n+affected are further limited to those that match them.\n+--\n+d remove directories as well\n+f override clean.requireForce and clean anyway\n+n don't remove anything, just show what would be done\n+q be quiet, only report errors\n+x remove ignored files as well\n+X remove only ignored files\"\n+\n SUBDIRECTORY_OK=Yes\n . git-sh-setup\n require_work_tree\n@@ -55,23 +60,20 @@ do\n \t\tshift\n \t\tbreak\n \t\t;;\n-\t-*)\n-\t\tusage\n-\t\t;;\n \t*)\n-\t\tbreak\n+\t\tusage # should not happen\n+\t\t;;\n \tesac\n \tshift\n done\n \n if [ \"$disabled\" = true ]; then\n-\techo \"clean.requireForce set and -n or -f not given; refusing to clean\"\n-\texit 1\n+\tdie \"clean.requireForce set and -n or -f not given; refusing to clean\"\n fi\n \n-case \"$ignored,$ignoredonly\" in\n-\t1,1) usage;;\n-esac\n+if [ \"$ignored,$ignoredonly\" = \"1,1\" ]; then\n+\tdie \"-x and -X cannot be set together\"\n+fi\n \n if [ -z \"$ignored\" ]; then\n \texcl=\"--exclude-per-directory=.gitignore\"\n-- \n1.5.3.5.1509.g66d41\n\n"},{"id":"299016","messageId":"1194172262-1563-5-git-send-email-madcoder@debian.org","threadId":"10637","inReplyTo":"1194172262-1563-4-git-send-email-madcoder@debian.org","subject":"[PATCH 04/10] Migrate git-clone to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T10:30:56Z","receivedAt":"2007-11-04T10:30:56Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-clone.sh |  102 +++++++++++++++++++++++++++++++++-------------------------\n 1 files changed, 58 insertions(+), 44 deletions(-)\n\ndiff --git a/git-clone.sh b/git-clone.sh\nindex 0ea3c24..52c5601 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -8,15 +8,36 @@\n # See git-sh-setup why.\n unset CDPATH\n \n+OPTIONS_SPEC=\"\\\n+git-clone [options] <repo> [<dir>]\n+--\n+n,no-checkout        don't create a checkout\n+bare                 create a bare repository\n+naked                create a bare repository\n+l,local              to clone from a local repository\n+no-hardlinks         don't use local hardlinks, always copy\n+s,shared             setup as a shared repository\n+template=            path to the template directory\n+q,quiet              be quiet\n+reference=           reference repository\n+o,origin=            use <name> instead of 'origin' to track upstream\n+u,upload-pack=       path to git-upload-pack on the remote\n+depth=               create a shallow clone of that depth\n+\n+use-separate-remote  compatibility, do not use\n+no-separate-remote   compatibility, do not use\"\n+\n die() {\n \techo >&2 \"$@\"\n \texit 1\n }\n \n usage() {\n-\tdie \"Usage: $0 [--template=<template_directory>] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [--depth <n>] [-n] <repo> [<dir>]\"\n+\texec \"$0\" -h\n }\n \n+eval `echo \"$OPTIONS_SPEC\" | git rev-parse --parseopt -- \"$@\" || echo exit $?`\n+\n get_repo_base() {\n \t(\n \t\tcd \"`/bin/pwd`\" &&\n@@ -106,64 +127,57 @@ depth=\n no_progress=\n local_explicitly_asked_for=\n test -t 1 || no_progress=--no-progress\n-while\n-\tcase \"$#,$1\" in\n-\t0,*) break ;;\n-\t*,-n|*,--no|*,--no-|*,--no-c|*,--no-ch|*,--no-che|*,--no-chec|\\\n-\t*,--no-check|*,--no-checko|*,--no-checkou|*,--no-checkout)\n-\t  no_checkout=yes ;;\n-\t*,--na|*,--nak|*,--nake|*,--naked|\\\n-\t*,-b|*,--b|*,--ba|*,--bar|*,--bare) bare=yes ;;\n-\t*,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local)\n-\t  local_explicitly_asked_for=yes\n-\t  use_local_hardlink=yes ;;\n-\t*,--no-h|*,--no-ha|*,--no-har|*,--no-hard|*,--no-hardl|\\\n-\t*,--no-hardli|*,--no-hardlin|*,--no-hardlink|*,--no-hardlinks)\n-\t  use_local_hardlink=no ;;\n-        *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared)\n-          local_shared=yes; ;;\n-\t1,--template) usage ;;\n-\t*,--template)\n+\n+while test $# != 0\n+do\n+\tcase \"$1\" in\n+\t-n|--no-checkout)\n+\t\tno_checkout=yes ;;\n+\t--naked|--bare)\n+\t\tbare=yes ;;\n+\t-l|--local)\n+\t\tlocal_explicitly_asked_for=yes\n+\t\tuse_local_hardlink=yes\n+\t\t;;\n+\t--no-hardlinks)\n+\t\tuse_local_hardlink=no ;;\n+\t-s|--shared)\n+\t\tlocal_shared=yes ;;\n+\t--template)\n \t\tshift; template=\"--template=$1\" ;;\n-\t*,--template=*)\n-\t  template=\"$1\" ;;\n-\t*,-q|*,--quiet) quiet=-q ;;\n-\t*,--use-separate-remote) ;;\n-\t*,--no-separate-remote)\n+\t-q|--quiet)\n+\t\tquiet=-q ;;\n+\t--use-separate-remote|--no-separate-remote)\n \t\tdie \"clones are always made with separate-remote layout\" ;;\n-\t1,--reference) usage ;;\n-\t*,--reference)\n+\t--reference)\n \t\tshift; reference=\"$1\" ;;\n-\t*,--reference=*)\n-\t\treference=`expr \"z$1\" : 'z--reference=\\(.*\\)'` ;;\n-\t*,-o|*,--or|*,--ori|*,--orig|*,--origi|*,--origin)\n-\t\tcase \"$2\" in\n+\t-o,--origin)\n+\t\tshift;\n+\t\tcase \"$1\" in\n \t\t'')\n \t\t    usage ;;\n \t\t*/*)\n-\t\t    die \"'$2' is not suitable for an origin name\"\n+\t\t    die \"'$1' is not suitable for an origin name\"\n \t\tesac\n-\t\tgit check-ref-format \"heads/$2\" ||\n-\t\t    die \"'$2' is not suitable for a branch name\"\n+\t\tgit check-ref-format \"heads/$1\" ||\n+\t\t    die \"'$1' is not suitable for a branch name\"\n \t\ttest -z \"$origin_override\" ||\n \t\t    die \"Do not give more than one --origin options.\"\n \t\torigin_override=yes\n-\t\torigin=\"$2\"; shift\n+\t\torigin=\"$1\"\n \t\t;;\n-\t1,-u|1,--upload-pack) usage ;;\n-\t*,-u|*,--upload-pack)\n+\t-u|--upload-pack)\n \t\tshift\n \t\tupload_pack=\"--upload-pack=$1\" ;;\n-\t*,--upload-pack=*)\n-\t\tupload_pack=--upload-pack=$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\n-\t1,--depth) usage;;\n-\t*,--depth)\n+\t--depth)\n+\t\tshift\n+\t\tdepth=\"--depth=$1\" ;;\n+\t--)\n \t\tshift\n-\t\tdepth=\"--depth=$1\";;\n-\t*,-*) usage ;;\n-\t*) break ;;\n+\t\tbreak ;;\n+\t*)\n+\t\tusage ;;\n \tesac\n-do\n \tshift\n done\n \n-- \n1.5.3.5.1509.g66d41\n\n"},{"id":"299017","messageId":"1194172262-1563-6-git-send-email-madcoder@debian.org","threadId":"10637","inReplyTo":"1194172262-1563-5-git-send-email-madcoder@debian.org","subject":"[PATCH 05/10] Migrate git-am.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T10:30:57Z","receivedAt":"2007-11-04T10:30:57Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-am.sh |   93 +++++++++++++++++++++++++++++++-----------------------------\n 1 files changed, 48 insertions(+), 45 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 2514d07..2d2b1c6 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -2,11 +2,25 @@\n #\n # Copyright (c) 2005, 2006 Junio C Hamano\n \n-USAGE='[--signoff] [--dotest=<dir>] [--keep] [--utf8 | --no-utf8]\n-  [--3way] [--interactive] [--binary]\n-  [--whitespace=<option>] [-C<n>] [-p<n>]\n-  <mbox>|<Maildir>...\n-  or, when resuming [--skip | --resolved]'\n+OPTIONS_SPEC=\"\\\n+git-am [options] <mbox>|<Maildir>...\n+git-am [options] --resolved\n+git-am [options] --skip\n+--\n+d,dotest=       use <dir> and not .dotest\n+i,interactive=  run interactively\n+b,binary        pass --allo-binary-replacement to git-apply\n+3,3way          allow fall back on 3way merging if needed\n+s,signoff       add a Signed-off-by line to the commit message\n+u,utf8          recode into utf8 (default)\n+k,keep          pass -k flagg to git-mailinfo\n+whitespace=     pass it through git-apply\n+C=              pass it through git-apply\n+p=              pass it through git-apply\n+resolvemsg=     override error message when patch failure occurs\n+r,resolved      to be used after a patch failure\n+skip            skip the current patch\"\n+\n . git-sh-setup\n set_reflog_action am\n require_work_tree\n@@ -110,49 +124,38 @@ git_apply_opt=\n while test $# != 0\n do\n \tcase \"$1\" in\n-\t-d=*|--d=*|--do=*|--dot=*|--dote=*|--dotes=*|--dotest=*)\n-\tdotest=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`; shift ;;\n-\t-d|--d|--do|--dot|--dote|--dotes|--dotest)\n-\tcase \"$#\" in 1) usage ;; esac; shift\n-\tdotest=\"$1\"; shift;;\n-\n-\t-i|--i|--in|--int|--inte|--inter|--intera|--interac|--interact|\\\n-\t--interacti|--interactiv|--interactive)\n-\tinteractive=t; shift ;;\n-\n-\t-b|--b|--bi|--bin|--bina|--binar|--binary)\n-\tbinary=t; shift ;;\n-\n-\t-3|--3|--3w|--3wa|--3way)\n-\tthreeway=t; shift ;;\n-\t-s|--s|--si|--sig|--sign|--signo|--signof|--signoff)\n-\tsign=t; shift ;;\n-\t-u|--u|--ut|--utf|--utf8)\n-\tutf8=t; shift ;; # this is now default\n-\t--no-u|--no-ut|--no-utf|--no-utf8)\n-\tutf8=; shift ;;\n-\t-k|--k|--ke|--kee|--keep)\n-\tkeep=t; shift ;;\n-\n-\t-r|--r|--re|--res|--reso|--resol|--resolv|--resolve|--resolved)\n-\tresolved=t; shift ;;\n-\n-\t--sk|--ski|--skip)\n-\tskip=t; shift ;;\n-\n-\t--whitespace=*|-C*|-p*)\n-\tgit_apply_opt=\"$git_apply_opt $1\"; shift ;;\n-\n-\t--resolvemsg=*)\n-\tresolvemsg=${1#--resolvemsg=}; shift ;;\n-\n+\t-i|--interactive)\n+\t\tinteractive=t ;;\n+\t-b|--binary)\n+\t\tbinary=t ;;\n+\t-3|--3way)\n+\t\tthreeway=t ;;\n+\t-s--signoff)\n+\t\tsign=t ;;\n+\t-u|--utf8)\n+\t\tutf8=t ;; # this is now default\n+\t--no-utf8)\n+\t\tutf8= ;;\n+\t-k|--keep)\n+\t\tkeep=t ;;\n+\t-r|--resolved)\n+\t\tresolved=t ;;\n+\t--skip)\n+\t\tskip=t ;;\n+\t-d|--dotest)\n+\t\tshift; dotest=$1;;\n+\t--resolvemsg)\n+\t\tshift; resolvemsg=$1 ;;\n+\t--whitespace)\n+\t\tgit_apply_opt=\"$git_apply_opt $1=$2\"; shift ;;\n+\t-C|-p)\n+\t\tgit_apply_opt=\"$git_apply_opt $1$2\"; shift ;;\n \t--)\n-\tshift; break ;;\n-\t-*)\n-\tusage ;;\n+\t\tshift; break ;;\n \t*)\n-\tbreak ;;\n+\t\tusage ;;\n \tesac\n+\tshift\n done\n \n # If the dotest directory exists, but we have finished applying all the\n-- \n1.5.3.5.1509.g66d41\n\n"},{"id":"299018","messageId":"1194172262-1563-7-git-send-email-madcoder@debian.org","threadId":"10637","inReplyTo":"1194172262-1563-6-git-send-email-madcoder@debian.org","subject":"[PATCH 06/10] Migrate git-merge.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T10:30:58Z","receivedAt":"2007-11-04T10:30:58Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-merge.sh |  125 ++++++++++++++++++++++++---------------------------------\n 1 files changed, 53 insertions(+), 72 deletions(-)\n\ndiff --git a/git-merge.sh b/git-merge.sh\nindex b9f0519..d19bfc2 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -3,7 +3,18 @@\n # Copyright (c) 2005 Junio C Hamano\n #\n \n-USAGE='[-n] [--summary] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s <strategy>] [-m=<merge-message>] <commit>+'\n+OPTIONS_SPEC=\"\\\n+git-merge [options] <remote>...\n+git-merge [options] <msg> HEAD <remote>\n+--\n+summary              show a diffstat at the end of the merge\n+n,no-summary         don't show a diffstat at the end of the merge\n+squash               create a single commit instead of doing a merge\n+commit               perform a commit if the merge sucesses (default)\n+ff                   allow fast forward (default)\n+s,strategy=          merge strategy to use\n+m,message=           message to be used for the merge commit (if any)\n+\"\n \n SUBDIRECTORY_OK=Yes\n . git-sh-setup\n@@ -132,72 +143,47 @@ merge_name () {\n \tfi\n }\n \n-parse_option () {\n-\tcase \"$1\" in\n-\t-n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\\\n-\t\t--no-summa|--no-summar|--no-summary)\n-\t\tshow_diffstat=false ;;\n-\t--summary)\n-\t\tshow_diffstat=t ;;\n-\t--sq|--squ|--squa|--squas|--squash)\n-\t\tallow_fast_forward=t squash=t no_commit=t ;;\n-\t--no-sq|--no-squ|--no-squa|--no-squas|--no-squash)\n-\t\tallow_fast_forward=t squash= no_commit= ;;\n-\t--c|--co|--com|--comm|--commi|--commit)\n-\t\tallow_fast_forward=t squash= no_commit= ;;\n-\t--no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)\n-\t\tallow_fast_forward=t squash= no_commit=t ;;\n-\t--ff)\n-\t\tallow_fast_forward=t squash= no_commit= ;;\n-\t--no-ff)\n-\t\tallow_fast_forward=false squash= no_commit= ;;\n-\t-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\\\n-\t\t--strateg=*|--strategy=*|\\\n-\t-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)\n-\t\tcase \"$#,$1\" in\n-\t\t*,*=*)\n-\t\t\tstrategy=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'` ;;\n-\t\t1,*)\n-\t\t\tusage ;;\n-\t\t*)\n-\t\t\tstrategy=\"$2\"\n-\t\t\tshift ;;\n-\t\tesac\n-\t\tcase \" $all_strategies \" in\n-\t\t*\" $strategy \"*)\n-\t\t\tuse_strategies=\"$use_strategies$strategy \" ;;\n-\t\t*)\n-\t\t\tdie \"available strategies are: $all_strategies\" ;;\n-\t\tesac\n-\t\t;;\n-\t-m=*|--m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*)\n-\t\tmerge_msg=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n-\t\thave_message=t\n-\t\t;;\n-\t-m|--m|--me|--mes|--mess|--messa|--messag|--message)\n-\t\tshift\n-\t\tcase \"$#\" in\n-\t\t1)\tusage ;;\n-\t\tesac\n-\t\tmerge_msg=\"$1\"\n-\t\thave_message=t\n-\t\t;;\n-\t-*)\tusage ;;\n-\t*)\treturn 1 ;;\n-\tesac\n-\tshift\n-\targs_left=$#\n-}\n-\n parse_config () {\n-\twhile test $# -gt 0\n-\tdo\n-\t\tparse_option \"$@\" || usage\n-\t\twhile test $args_left -lt $#\n-\t\tdo\n+\twhile test $# != 0; do\n+\t\tcase \"$1\" in\n+\t\t-n|--no-summary)\n+\t\t\tshow_diffstat=false ;;\n+\t\t--summary)\n+\t\t\tshow_diffstat=t ;;\n+\t\t--squash)\n+\t\t\tallow_fast_forward=t squash=t no_commit=t ;;\n+\t\t--no-squash)\n+\t\t\tallow_fast_forward=t squash= no_commit= ;;\n+\t\t--commit)\n+\t\t\tallow_fast_forward=t squash= no_commit= ;;\n+\t\t--no-commit)\n+\t\t\tallow_fast_forward=t squash= no_commit=t ;;\n+\t\t--ff)\n+\t\t\tallow_fast_forward=t squash= no_commit= ;;\n+\t\t--no-ff)\n+\t\t\tallow_fast_forward=false squash= no_commit= ;;\n+\t\t-s|--strategy)\n+\t\t\tshift\n+\t\t\tcase \" $all_strategies \" in\n+\t\t\t*\" $1 \"*)\n+\t\t\t\tuse_strategies=\"$use_strategies$1 \" ;;\n+\t\t\t*)\n+\t\t\t\tdie \"available strategies are: $all_strategies\" ;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t-m|--message)\n \t\t\tshift\n-\t\tdone\n+\t\t\tmerge_msg=\"$1\"\n+\t\t\thave_message=t\n+\t\t\t;;\n+\t\t--)\n+\t\t\tshift\n+\t\t\tbreak ;;\n+\t\t*)\tusage ;;\n+\t\tesac\n+\t\tshift\n \tdone\n+\targs_left=$#\n }\n \n test $# != 0 || usage\n@@ -209,17 +195,12 @@ then\n \tmergeopts=$(git config \"branch.${branch#refs/heads/}.mergeoptions\")\n \tif test -n \"$mergeopts\"\n \tthen\n-\t\tparse_config $mergeopts\n+\t\tparse_config $mergeopts --\n \tfi\n fi\n \n-while parse_option \"$@\"\n-do\n-\twhile test $args_left -lt $#\n-\tdo\n-\t\tshift\n-\tdone\n-done\n+parse_config \"$@\"\n+while test $args_left -lt $#; do shift; done\n \n if test -z \"$show_diffstat\"; then\n     test \"$(git config --bool merge.diffstat)\" = false && show_diffstat=false\n-- \n1.5.3.5.1509.g66d41\n\n"},{"id":"299019","messageId":"1194172262-1563-8-git-send-email-madcoder@debian.org","threadId":"10637","inReplyTo":"1194172262-1563-7-git-send-email-madcoder@debian.org","subject":"[PATCH 07/10] Migrate git-instaweb.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T10:30:59Z","receivedAt":"2007-11-04T10:30:59Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-instaweb.sh |   73 ++++++++++++++++++++++---------------------------------\n 1 files changed, 29 insertions(+), 44 deletions(-)\n\ndiff --git a/git-instaweb.sh b/git-instaweb.sh\nindex 95c3e5a..d912bf5 100755\n--- a/git-instaweb.sh\n+++ b/git-instaweb.sh\n@@ -2,9 +2,20 @@\n #\n # Copyright (c) 2006 Eric Wong\n #\n-USAGE='[--start] [--stop] [--restart]\n-  [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]\n-  [--module-path=<path> (for Apache2 only)]'\n+\n+OPTIONS_SPEC=\"\\\n+git-instaweb [options] (--start | --stop | --restart)\n+--\n+l,local        only bind on 127.0.0.1\n+p,port=        the port to bind to\n+d,httpd=       the command to launch\n+b,browser=     the browser to launch\n+m,module-path= the module path (only needed for apache2)\n+ Action\n+stop           stop the web server\n+start          start the web server\n+restart        restart the web server\n+\"\n \n . git-sh-setup\n \n@@ -78,52 +89,26 @@ do\n \t\tstart_httpd\n \t\texit 0\n \t\t;;\n-\t--local|-l)\n+\t-l|--local)\n \t\tlocal=true\n \t\t;;\n-\t-d|--httpd|--httpd=*)\n-\t\tcase \"$#,$1\" in\n-\t\t*,*=*)\n-\t\t\thttpd=`expr \"$1\" : '-[^=]*=\\(.*\\)'` ;;\n-\t\t1,*)\n-\t\t\tusage ;;\n-\t\t*)\n-\t\t\thttpd=\"$2\"\n-\t\t\tshift ;;\n-\t\tesac\n+\t-d|--httpd)\n+\t\tshift\n+\t\thttpd=\"$1\"\n+\t\t;;\n+\t-b|--browser)\n+\t\tshift\n+\t\tbrowser=\"$1\"\n \t\t;;\n-\t-b|--browser|--browser=*)\n-\t\tcase \"$#,$1\" in\n-\t\t*,*=*)\n-\t\t\tbrowser=`expr \"$1\" : '-[^=]*=\\(.*\\)'` ;;\n-\t\t1,*)\n-\t\t\tusage ;;\n-\t\t*)\n-\t\t\tbrowser=\"$2\"\n-\t\t\tshift ;;\n-\t\tesac\n+\t-p|--port)\n+\t\tshift\n+\t\tport=\"$1\"\n \t\t;;\n-\t-p|--port|--port=*)\n-\t\tcase \"$#,$1\" in\n-\t\t*,*=*)\n-\t\t\tport=`expr \"$1\" : '-[^=]*=\\(.*\\)'` ;;\n-\t\t1,*)\n-\t\t\tusage ;;\n-\t\t*)\n-\t\t\tport=\"$2\"\n-\t\t\tshift ;;\n-\t\tesac\n+\t-m|--module-path)\n+\t\tshift\n+\t\tmodule_path=\"$1\"\n \t\t;;\n-\t-m|--module-path=*|--module-path)\n-\t\tcase \"$#,$1\" in\n-\t\t*,*=*)\n-\t\t\tmodule_path=`expr \"$1\" : '-[^=]*=\\(.*\\)'` ;;\n-\t\t1,*)\n-\t\t\tusage ;;\n-\t\t*)\n-\t\t\tmodule_path=\"$2\"\n-\t\t\tshift ;;\n-\t\tesac\n+\t--)\n \t\t;;\n \t*)\n \t\tusage\n-- \n1.5.3.5.1509.g66d41\n\n"},{"id":"299020","messageId":"1194172262-1563-9-git-send-email-madcoder@debian.org","threadId":"10637","inReplyTo":"1194172262-1563-8-git-send-email-madcoder@debian.org","subject":"[PATCH 08/10] Migrate git-checkout.sh to use git-rev-parse --parseopt --keep-dashdash","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T10:31:00Z","receivedAt":"2007-11-04T10:31:00Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Also fix some space versus tabs issues.\n---\n git-checkout.sh |   99 +++++++++++++++++++++++++++----------------------------\n 1 files changed, 49 insertions(+), 50 deletions(-)\n\ndiff --git a/git-checkout.sh b/git-checkout.sh\nindex 8993920..c00cedd 100755\n--- a/git-checkout.sh\n+++ b/git-checkout.sh\n@@ -1,6 +1,16 @@\n #!/bin/sh\n \n-USAGE='[-q] [-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]'\n+OPTIONS_KEEPDASHDASH=t\n+OPTIONS_SPEC=\"\\\n+git-branch [options] [<branch>] [<paths>...]\n+--\n+b=          create a new branch started at <branch>\n+l           create the new branchs reflog\n+track       tells if the new branch should track the remote branch\n+f           proceed even if the index or working tree is not HEAD\n+m           performa  three-way merge on local modifications if needed\n+q,quiet     be quiet\n+\"\n SUBDIRECTORY_OK=Sometimes\n . git-sh-setup\n require_work_tree\n@@ -20,13 +30,12 @@ quiet=\n v=-v\n LF='\n '\n-while [ \"$#\" != \"0\" ]; do\n-    arg=\"$1\"\n-    shift\n-    case \"$arg\" in\n-\t\"-b\")\n-\t\tnewbranch=\"$1\"\n+\n+while test $# != 0; do\n+\tcase \"$1\" in\n+\t-b)\n \t\tshift\n+\t\tnewbranch=\"$1\"\n \t\t[ -z \"$newbranch\" ] &&\n \t\t\tdie \"git checkout: -b needs a branch name\"\n \t\tgit show-ref --verify --quiet -- \"refs/heads/$newbranch\" &&\n@@ -34,64 +43,54 @@ while [ \"$#\" != \"0\" ]; do\n \t\tgit check-ref-format \"heads/$newbranch\" ||\n \t\t\tdie \"git checkout: we do not like '$newbranch' as a branch name.\"\n \t\t;;\n-\t\"-l\")\n+\t-l)\n \t\tnewbranch_log=-l\n \t\t;;\n-\t\"--track\"|\"--no-track\")\n-\t\ttrack=\"$arg\"\n+\t--track|--no-track)\n+\t\ttrack=\"$1\"\n \t\t;;\n-\t\"-f\")\n+\t-f)\n \t\tforce=1\n \t\t;;\n \t-m)\n \t\tmerge=1\n \t\t;;\n-\t\"-q\")\n+\t-q|--quiet)\n \t\tquiet=1\n \t\tv=\n \t\t;;\n \t--)\n+\t\tshift\n \t\tbreak\n \t\t;;\n-\t-*)\n-\t\tusage\n-\t\t;;\n \t*)\n-\t\tif rev=$(git rev-parse --verify \"$arg^0\" 2>/dev/null)\n-\t\tthen\n-\t\t\tif [ -z \"$rev\" ]; then\n-\t\t\t\techo \"unknown flag $arg\"\n-\t\t\t\texit 1\n-\t\t\tfi\n-\t\t\tnew_name=\"$arg\"\n-\t\t\tif git show-ref --verify --quiet -- \"refs/heads/$arg\"\n-\t\t\tthen\n-\t\t\t\trev=$(git rev-parse --verify \"refs/heads/$arg^0\")\n-\t\t\t\tbranch=\"$arg\"\n-\t\t\tfi\n-\t\t\tnew=\"$rev\"\n-\t\telif rev=$(git rev-parse --verify \"$arg^{tree}\" 2>/dev/null)\n-\t\tthen\n-\t\t\t# checking out selected paths from a tree-ish.\n-\t\t\tnew=\"$rev\"\n-\t\t\tnew_name=\"$arg^{tree}\"\n-\t\t\tbranch=\n-\t\telse\n-\t\t\tnew=\n-\t\t\tnew_name=\n-\t\t\tbranch=\n-\t\t\tset x \"$arg\" \"$@\"\n-\t\t\tshift\n-\t\tfi\n-\t\tcase \"$1\" in\n-\t\t--)\n-\t\t\tshift ;;\n-\t\tesac\n-\t\tbreak\n+\t\tusage\n \t\t;;\n-    esac\n+\tesac\n+\tshift\n done\n \n+arg=\"$1\"\n+if rev=$(git rev-parse --verify \"$arg^0\" 2>/dev/null)\n+then\n+\t[ -z \"$rev\" ] && die \"unknown flag $arg\"\n+\tnew_name=\"$arg\"\n+\tif git show-ref --verify --quiet -- \"refs/heads/$arg\"\n+\tthen\n+\t\trev=$(git rev-parse --verify \"refs/heads/$arg^0\")\n+\t\tbranch=\"$arg\"\n+\tfi\n+\tnew=\"$rev\"\n+\tshift\n+elif rev=$(git rev-parse --verify \"$arg^{tree}\" 2>/dev/null)\n+then\n+\t# checking out selected paths from a tree-ish.\n+\tnew=\"$rev\"\n+\tnew_name=\"$arg^{tree}\"\n+\tshift\n+fi\n+[ \"$1\" = \"--\" ] && shift\n+\n case \"$newbranch,$track\" in\n ,--*)\n \tdie \"git checkout: --track and --no-track require -b\"\n@@ -138,8 +137,8 @@ Did you intend to checkout '$@' which can not be resolved as commit?\"\n \tgit ls-files -- \"$@\" |\n \tgit checkout-index -f -u --stdin\n \n-        # Run a post-checkout hook -- the HEAD does not change so the\n-        # current HEAD is passed in for both args\n+\t# Run a post-checkout hook -- the HEAD does not change so the\n+\t# current HEAD is passed in for both args\n \tif test -x \"$GIT_DIR\"/hooks/post-checkout; then\n \t    \"$GIT_DIR\"/hooks/post-checkout $old $old 0\n \tfi\n@@ -294,5 +293,5 @@ fi\n \n # Run a post-checkout hook\n if test -x \"$GIT_DIR\"/hooks/post-checkout; then\n-        \"$GIT_DIR\"/hooks/post-checkout $old $new 1\n+\t\"$GIT_DIR\"/hooks/post-checkout $old $new 1\n fi\n-- \n1.5.3.5.1509.g66d41\n\n"},{"id":"299021","messageId":"1194172262-1563-10-git-send-email-madcoder@debian.org","threadId":"10637","inReplyTo":"1194172262-1563-9-git-send-email-madcoder@debian.org","subject":"[PATCH 09/10] Migrate git-quiltimport.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T10:31:01Z","receivedAt":"2007-11-04T10:31:01Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-quiltimport.sh |   38 +++++++++++++++-----------------------\n 1 files changed, 15 insertions(+), 23 deletions(-)\n\ndiff --git a/git-quiltimport.sh b/git-quiltimport.sh\nindex 880c81d..b6c24c8 100755\n--- a/git-quiltimport.sh\n+++ b/git-quiltimport.sh\n@@ -1,5 +1,11 @@\n #!/bin/sh\n-USAGE='--dry-run --author <author> --patches </path/to/quilt/patch/directory>'\n+OPTIONS_SPEC=\"\\\n+git-quiltimport [options]\n+--\n+n,dry-run     dry run\n+author=       author name and email address for patches without any\n+patches=      path to the quilt series and patches\n+\"\n SUBDIRECTORY_ON=Yes\n . git-sh-setup\n \n@@ -8,39 +14,25 @@ quilt_author=\"\"\n while test $# != 0\n do\n \tcase \"$1\" in\n-\t--au=*|--aut=*|--auth=*|--autho=*|--author=*)\n-\t\tquilt_author=$(expr \"z$1\" : 'z-[^=]*\\(.*\\)')\n-\t\tshift\n-\t\t;;\n-\n-\t--au|--aut|--auth|--autho|--author)\n-\t\tcase \"$#\" in 1) usage ;; esac\n+\t--author)\n \t\tshift\n \t\tquilt_author=\"$1\"\n-\t\tshift\n \t\t;;\n-\n-\t--dry-run)\n-\t\tshift\n+\t-n|--dry-run)\n \t\tdry_run=1\n \t\t;;\n-\n-\t--pa=*|--pat=*|--patc=*|--patch=*|--patche=*|--patches=*)\n-\t\tQUILT_PATCHES=$(expr \"z$1\" : 'z-[^=]*\\(.*\\)')\n-\t\tshift\n-\t\t;;\n-\n-\t--pa|--pat|--patc|--patch|--patche|--patches)\n-\t\tcase \"$#\" in 1) usage ;; esac\n-\t\tshift\n+\t--patches)\n \t\tQUILT_PATCHES=\"$1\"\n \t\tshift\n \t\t;;\n-\n+\t--)\n+\t\tshift\n+\t\tbreak;;\n \t*)\n-\t\tbreak\n+\t\tusage\n \t\t;;\n \tesac\n+\tshift\n done\n \n # Quilt Author\n-- \n1.5.3.5.1509.g66d41\n\n"},{"id":"299022","messageId":"1194172262-1563-11-git-send-email-madcoder@debian.org","threadId":"10637","inReplyTo":"1194172262-1563-10-git-send-email-madcoder@debian.org","subject":"[PATCH 10/10] Migrate git-repack.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T10:31:02Z","receivedAt":"2007-11-04T10:31:02Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"---\n git-repack.sh |   23 ++++++++++++++++++-----\n 1 files changed, 18 insertions(+), 5 deletions(-)\n\ndiff --git a/git-repack.sh b/git-repack.sh\nindex 7220635..4d4840e 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -3,7 +3,21 @@\n # Copyright (c) 2005 Linus Torvalds\n #\n \n-USAGE='[-a|-A] [-d] [-f] [-l] [-n] [-q] [--max-pack-size=N] [--window=N] [--window-memory=N] [--depth=N]'\n+OPTIONS_SPEC=\"\\\n+git-repack [options]\n+--\n+a               pack everything in a single pack\n+A               same as -a, and keep unreachable objects too\n+d               remove redundant packs, and run git-prune-packed\n+f               pass --no-reuse-delta to git-pack-objects\n+q,quiet         be quiet\n+l               pass --local to git-pack-objects\n+ Packing constraints\n+window=         size of the window used for delta compression\n+window-memory=  same as the above, but limit memory size instead of entries count\n+depth=          limits the maximum delta depth\n+max-pack-size=  maximum size of each packfile\n+\"\n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n \n@@ -20,10 +34,9 @@ do\n \t-q)\tquiet=-q ;;\n \t-f)\tno_reuse=--no-reuse-object ;;\n \t-l)\tlocal=--local ;;\n-\t--max-pack-size=*) extra=\"$extra $1\" ;;\n-\t--window=*) extra=\"$extra $1\" ;;\n-\t--window-memory=*) extra=\"$extra $1\" ;;\n-\t--depth=*) extra=\"$extra $1\" ;;\n+\t--max-pack-size|--window|--window-memory|--depth)\n+\t\textra=\"$extra $1=$2\"; shift ;;\n+\t--) shift; break;;\n \t*)\tusage ;;\n \tesac\n \tshift\n-- \n1.5.3.5.1509.g66d41\n\n"},{"id":"58246","messageId":"20071104112931.GB2119@ins.uni-bonn.de","threadId":"10637","inReplyTo":"1194172262-1563-2-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 01/10] Add a parseopt mode to git-rev-parse to bring parse-options to shell scripts.","fromName":"Ralf Wildenhues","fromEmail":"ralf.wildenhues@gmx.de","sentAt":"2007-11-04T11:29:31Z","receivedAt":"2007-11-04T11:29:31Z","isPatch":true,"sender":{"key":"ralf.wildenhues@gmx.de","avatar":null},"body":"Hello Pierre,\n\nA couple of language nits:\n\n* Pierre Habouzit wrote on Sun, Nov 04, 2007 at 11:30:53AM CET:\n> +PARSEOPT\n> +--------\n> +\n> +In `--parseopt` mode, `git-rev-parse` helps massaging options to bring to shell\n> +scripts the same facilities C builtins have. It works as an option normalizer\n> +(e.g. splits single switches aggregate values), a bit like `getopt(1)` does.\n> +\n> +It takes on the standard input the specification of the options to parse and\n> +understand, and echoes on the standard ouput a line suitable for `sh(1)` `eval`\n> +to replace the arguments with normalized ones.  In case of error, it ouputs\n\ns/ouputs/outputs/\n\n> +usage on the standard error stream, and exits with code 129.\n> +\n> +Input Format\n> +~~~~~~~~~~~~\n> +\n> +`git-ref-parse --parseopt` input format is fully text based. It has two parts,\n\ns/^/The /\ns/git-ref-parse/git-rev-parse/\n\n> +separated by a line that contains only `--`. The lines before (should be more\n> +than one) are used for the usage. The lines after describe the options.\n\nI would write\n  s/before/& the `--`/\n  s/after/& the `--`/\n\nor maybe write \"separator\" instead of `--`.\n\n[...]\n> +`<opt_spec>`::\n> +\tits format is the short option character, then the long option name\n> +        separated by a comma. Both parts are not required, though at least one\n> +        is necessary. `h,help`, `dry-run` and `f` are all three correct\n> +        `<opt_spec>`.\n> +\n> +`<arg_spec>`::\n> +\tan `<arg_spec>` tells the option parser if the option has an argument\n> +        (`=`), an optionnal one (`?` though its use is discouraged) or none\n\ns/optionnal/optional/\n\n> +        (no `<arg_spec>` in that case).\n> +\n> +The rest of the line after as many spaces up to the ending line feed is used\n> +as the help associated to the option.\n\nI'd write (in case that is technically correct):\n  After following white space, the rest of the line after is used as the\n  help associated to the option.\n\n> +Blank lines are ignored, and lines that don't match this specification are used\n> +as option group headers (start the line with a space to purposely create such\n> +lines).\n\nI'd write:\n  ... to create such lines on purpose.\n\n> +Example\n> +~~~~~~~\n> +\n> +------------\n> +OPTS_SPEC=\"\\\n> +some-command [options] <args>...\n> +\n> +some-command does foo and bar !\n\nPlease no white space before \"!\".\n\n> +--\n> +h,help    show the help\n> +\n> +foo       some nifty option --foo\n> +bar=      some cool option --bar with an argument\n> +\n> +  An option group Header\n> +C?        option C with an optionnal argument\"\n\ns/optionnal/optional/\n\nCheers,\nRalf\n"},{"id":"58247","messageId":"20071104113130.GC2119@ins.uni-bonn.de","threadId":"10637","inReplyTo":"20071104112931.GB2119@ins.uni-bonn.de","subject":"Re: [PATCH 01/10] Add a parseopt mode to git-rev-parse to bring parse-options to shell scripts.","fromName":"Ralf Wildenhues","fromEmail":"ralf.wildenhues@gmx.de","sentAt":"2007-11-04T11:31:30Z","receivedAt":"2007-11-04T11:31:30Z","isPatch":true,"sender":{"key":"ralf.wildenhues@gmx.de","avatar":null},"body":"* Ralf Wildenhues wrote on Sun, Nov 04, 2007 at 12:29:31PM CET:\n> A couple of language nits:\n> \n> * Pierre Habouzit wrote on Sun, Nov 04, 2007 at 11:30:53AM CET:\n[...]\n> > +It takes on the standard input the specification of the options to parse and\n> > +understand, and echoes on the standard ouput a line suitable for `sh(1)` `eval`\n\nMissed another  s/ouput/output/  here.\n\n> > +to replace the arguments with normalized ones.  In case of error, it ouputs\n> \n> s/ouputs/outputs/\n"},{"id":"58277","messageId":"20071104144918.GI26269@artemis.corp","threadId":"10637","inReplyTo":"1194172262-1563-5-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 04/10] Migrate git-clone to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T14:49:18Z","receivedAt":"2007-11-04T14:49:18Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"  Note: this patch now conflicts with a recent patch to make git clone\ngrok `--`. As git rev-parse --parseopt does that as a side effect, you\ncan force the update to the parseopt version without functionality loss.\n\nCheers,\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"58316","messageId":"7v8x5dsjne.fsf@gitster.siamese.dyndns.org","threadId":"10637","inReplyTo":"1194172262-1563-2-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 01/10] Add a parseopt mode to git-rev-parse to bring parse-options to shell scripts.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-04T22:58:13Z","receivedAt":"2007-11-04T22:58:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Two comments.\n\n * I have updated 1/10 with typo and indentation fixes.\n\n * I see you changed 2/10 to use OPTIONS_KEEPDASHDASH instead of\n   PARSEOPT_OPTS, but the scripts that do not want the --keep\n   behaviour do not set OPTIONS_KEEPDASHDASH to empty, so I do\n   not see how this updatet would make _any_ difference.  The\n   user can still screw up by having OPTIONS_KEEPDASHDASH in\n   their environments by mistake, curiosity or just plain\n   stupidity.\n"},{"id":"58320","messageId":"20071104231416.GF4207@artemis.corp","threadId":"10637","inReplyTo":"7v8x5dsjne.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 01/10] Add a parseopt mode to git-rev-parse to bring parse-options to shell scripts.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T23:14:16Z","receivedAt":"2007-11-04T23:14:16Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sun, Nov 04, 2007 at 10:58:13PM +0000, Junio C Hamano wrote:\n> Two comments.\n> \n>  * I have updated 1/10 with typo and indentation fixes.\n> \n>  * I see you changed 2/10 to use OPTIONS_KEEPDASHDASH instead of\n>    PARSEOPT_OPTS, but the scripts that do not want the --keep\n>    behaviour do not set OPTIONS_KEEPDASHDASH to empty, so I do\n>    not see how this updatet would make _any_ difference.  The\n>    user can still screw up by having OPTIONS_KEEPDASHDASH in\n>    their environments by mistake, curiosity or just plain\n>    stupidity.\n\n  Hmmm right, I was worried by the fact that the old PARSEOPT_OPTS was\nbeing possibly diverted to inject malicious commands. I tend to find the\nforced `OPTIONS_KEEPDASHDASH=` thing quite painful, but indeed it is\nprobably the sole way to guard ourselves against user stupidity (or more\nlikely unclean environments).\n\n  Do you mind adding: OPTIONS_KEEPDASHDASH= front to the 8 patches that\nneeds it, or should I send an updated series ? (actually it's more like\nthe 7 that needs it as git-clean has been rewritten as a builtin if I'm\ncorrect).\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"58566","messageId":"alpine.LFD.0.9999.0711061355330.21255@xanadu.home","threadId":"10637","inReplyTo":"1194172262-1563-5-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 04/10] Migrate git-clone to use git-rev-parse --parseopt","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-11-06T19:04:07Z","receivedAt":"2007-11-06T19:04:07Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Sun, 4 Nov 2007, Pierre Habouzit wrote:\n\n> Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n> ---\n>  git-clone.sh |  102 +++++++++++++++++++++++++++++++++-------------------------\n>  1 files changed, 58 insertions(+), 44 deletions(-)\n\nWell, this patch was merged in \"next\" and broke git-clone rather badly.\n\nJust try something as fundamental as this:\n\n\t$ git clone git://git.kernel.org/pub/scm/git/git.git\n\tfatal: Not a git repository\n\nDon't we have test cases covering this really basic operation?\n\n\nNicolas\n"},{"id":"58568","messageId":"7vr6j3gof2.fsf@gitster.siamese.dyndns.org","threadId":"10637","inReplyTo":"alpine.LFD.0.9999.0711061355330.21255@xanadu.home","subject":"Re: [PATCH 04/10] Migrate git-clone to use git-rev-parse --parseopt","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-06T19:32:49Z","receivedAt":"2007-11-06T19:32:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Gaah.\n\nI'd blame Linus for suggesting to make parseopt part of\nrev-parse, the latter of which makes sense only inside git while\nthe former of which makes sense outside git.\n\nWould something like this help?\n\n---\n builtin-rev-parse.c |    4 ++--\n git.c               |    2 +-\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-rev-parse.c b/builtin-rev-parse.c\nindex 054519b..d1038a0 100644\n--- a/builtin-rev-parse.c\n+++ b/builtin-rev-parse.c\n@@ -337,11 +337,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \tint i, as_is = 0, verify = 0;\n \tunsigned char sha1[20];\n \n-\tgit_config(git_default_config);\n-\n \tif (argc > 1 && !strcmp(\"--parseopt\", argv[1]))\n \t\treturn cmd_parseopt(argc - 1, argv + 1, prefix);\n \n+\tprefix = setup_git_directory();\n+\tgit_config(git_default_config);\n \tfor (i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \ndiff --git a/git.c b/git.c\nindex 6c5f9af..204a6f7 100644\n--- a/git.c\n+++ b/git.c\n@@ -340,7 +340,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"rerere\", cmd_rerere, RUN_SETUP },\n \t\t{ \"reset\", cmd_reset, RUN_SETUP },\n \t\t{ \"rev-list\", cmd_rev_list, RUN_SETUP },\n-\t\t{ \"rev-parse\", cmd_rev_parse, RUN_SETUP },\n+\t\t{ \"rev-parse\", cmd_rev_parse },\n \t\t{ \"revert\", cmd_revert, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"rm\", cmd_rm, RUN_SETUP },\n \t\t{ \"runstatus\", cmd_runstatus, RUN_SETUP | NEED_WORK_TREE },\n"},{"id":"58570","messageId":"7vmytrgo4q.fsf@gitster.siamese.dyndns.org","threadId":"10637","inReplyTo":"alpine.LFD.0.9999.0711061355330.21255@xanadu.home","subject":"Re: [PATCH 04/10] Migrate git-clone to use git-rev-parse --parseopt","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-06T19:39:01Z","receivedAt":"2007-11-06T19:39:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nicolas Pitre <nico@cam.org> writes:\n\n> On Sun, 4 Nov 2007, Pierre Habouzit wrote:\n>\n>> Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n>> ---\n>>  git-clone.sh |  102 +++++++++++++++++++++++++++++++++-------------------------\n>>  1 files changed, 58 insertions(+), 44 deletions(-)\n>\n> Well, this patch was merged in \"next\" and broke git-clone rather badly.\n>\n> Just try something as fundamental as this:\n>\n> \t$ git clone git://git.kernel.org/pub/scm/git/git.git\n> \tfatal: Not a git repository\n>\n> Don't we have test cases covering this really basic operation?\n\nWe do, but RUN_SETUP will happily go up to find the .git/ next\nto t/ directory that is the parent of trash/ directory, in which\nthe tests run, without reporting errors.  As parseopt does not\ndepend on anything in git, this will not do any harm other than\nfalsely succeeding the test that should not pass.\n\nWe could probably introduce an environment variable, GIT_CEILING,\nthat tells the setup_git_directory_gentry() never go up beyond\nthat point, and set it to the t/trash directory while running\nthe test.\n\nSomething like that may have other uses in practice.  Often\npeople wonder what would happen if there is /.git repository and\nthey would want to make sure they would not accidentally add to\nthe repository controlled by /.git when they have bunch of other\nrepositories /some/where/.git in which they usually work.\n"},{"id":"58573","messageId":"alpine.LFD.0.9999.0711061443030.21255@xanadu.home","threadId":"10637","inReplyTo":"7vr6j3gof2.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 04/10] Migrate git-clone to use git-rev-parse --parseopt","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-11-06T19:44:15Z","receivedAt":"2007-11-06T19:44:15Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Tue, 6 Nov 2007, Junio C Hamano wrote:\n\n> Gaah.\n> \n> I'd blame Linus for suggesting to make parseopt part of\n> rev-parse, the latter of which makes sense only inside git while\n> the former of which makes sense outside git.\n> \n> Would something like this help?\n> \n> ---\n>  builtin-rev-parse.c |    4 ++--\n>  git.c               |    2 +-\n>  2 files changed, 3 insertions(+), 3 deletions(-)\n\nThat does help indeed.\n\n\nNicolas\n"}]}