{"thread":{"id":"10602","subject":"let's retry this based on git-rev-parse --parseopt","startedAt":"2007-11-02T22:39:47Z","lastAt":"2007-11-04T14:18:09Z","messageCount":25,"participants":["Pierre Habouzit","Alex Riesen","Junio C Hamano","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"58051","messageId":"1194043193-29601-1-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":null,"subject":"let's retry this based on git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-02T22:39:47Z","receivedAt":"2007-11-02T22:39:47Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"So as it seems git-rev-parse is the place to do that, here is a new\nproposal, with a few more commands migrated. Of course it doesn't means\nwe should not rewrite some (if not all) of the shell scripts as\nbuiltins, but it will take some pain from the user, and provide nice\noption parsers from day 1 for new porcelains.\n\nI believe that the git-am.sh migration is a perfect example of why this\noption parser helps.\n\nNote that in the patch 1, the documentation _needs_ to be reviewed by a\nnative speaker.\n"},{"id":"298999","messageId":"1194043193-29601-2-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194043193-29601-1-git-send-email-madcoder@debian.org","subject":"[PATCH 1/5] 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-02T22:39:48Z","receivedAt":"2007-11-02T22:39:48Z","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.1460.gdb47\n\n"},{"id":"299000","messageId":"1194043193-29601-3-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194043193-29601-2-git-send-email-madcoder@debian.org","subject":"[PATCH 2/5] Update git-sh-setup(1) to allow transparent use of git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-02T22:39:49Z","receivedAt":"2007-11-02T22:39:49Z","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\nPARSEOPT_OPTS can also be used to pass options git git-rev-parse --parseopt\nmode (like --keep-dashdash).\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-sh-setup.sh |   44 ++++++++++++++++++++++++++------------------\n 1 files changed, 26 insertions(+), 18 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 86d7d4c..330b78e 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -16,9 +16,32 @@ 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+\teval `echo \"$OPTIONS_SPEC\" | git rev-parse --parseopt $PARSEOPT_OPTS -- \"$@\" || 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 +114,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.1460.gdb47\n\n"},{"id":"299001","messageId":"1194043193-29601-4-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194043193-29601-3-git-send-email-madcoder@debian.org","subject":"[PATCH 3/5] Migrate git-clean.sh to use git-rev-parse --parseopt.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-02T22:39:50Z","receivedAt":"2007-11-02T22:39:50Z","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.1460.gdb47\n\n"},{"id":"299002","messageId":"1194043193-29601-5-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194043193-29601-4-git-send-email-madcoder@debian.org","subject":"[PATCH 4/5] Migrate git-clone to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-02T22:39:51Z","receivedAt":"2007-11-02T22:39:51Z","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..8680a7c 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 $PARSEOPT_OPTS -- \"$@\" || 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.1460.gdb47\n\n"},{"id":"299003","messageId":"1194043193-29601-6-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194043193-29601-5-git-send-email-madcoder@debian.org","subject":"[PATCH 5/5] Migrate git-am.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-02T22:39:52Z","receivedAt":"2007-11-02T22:39:52Z","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 |   97 +++++++++++++++++++++++++++++++-----------------------------\n 1 files changed, 50 insertions(+), 47 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 2514d07..e5ed6a7 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--)\n-\tshift; break ;;\n-\t-*)\n-\tusage ;;\n-\t*)\n-\tbreak ;;\n+\t\t-i|--interactive)\n+\t\t\tinteractive=t ;;\n+\t\t-b|--binary)\n+\t\t\tbinary=t ;;\n+\t\t-3|--3way)\n+\t\t\tthreeway=t ;;\n+\t\t-s--signoff)\n+\t\t\tsign=t ;;\n+\t\t-u|--utf8)\n+\t\t\tutf8=t ;; # this is now default\n+\t\t--no-utf8)\n+\t\t\tutf8= ;;\n+\t\t-k|--keep)\n+\t\t\tkeep=t ;;\n+\t\t-r|--resolved)\n+\t\t\tresolved=t ;;\n+\t\t--skip)\n+\t\t\tskip=t ;;\n+\t\t-d|--dotest)\n+\t\t\tshift; dotest=$1;;\n+\t\t--resolvemsg)\n+\t\t\tshift; resolvemsg=$1 ;;\n+\t\t--whitespace)\n+\t\t\tgit_apply_opt=\"$git_apply_opt $1=$2\"; shift ;;\n+\t\t-C|-p)\n+\t\t\tgit_apply_opt=\"$git_apply_opt $1$2\"; shift ;;\n+\t\t--)\n+\t\t\tshift; break ;;\n+\t\t*)\n+\t\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.1460.gdb47\n\n"},{"id":"58089","messageId":"20071103095556.GB2853@steel.home","threadId":"10602","inReplyTo":"1194043193-29601-6-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 5/5] Migrate git-am.sh to use git-rev-parse --parseopt","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-11-03T09:55:56Z","receivedAt":"2007-11-03T09:55:56Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Pierre Habouzit, Fri, Nov 02, 2007 23:39:52 +0100:\n> diff --git a/git-am.sh b/git-am.sh\n> index 2514d07..e5ed6a7 100755\n> --- a/git-am.sh\n> +++ b/git-am.sh\n...\n> -\tusage ;;\n> -\t*)\n> -\tbreak ;;\n> +\t\t-i|--interactive)\n> +\t\t\tinteractive=t ;;\n> +\t\t-b|--binary)\n> +\t\t\tbinary=t ;;\n\nDid you really have to change the indentation?\n"},{"id":"58104","messageId":"20071103115445.GA13417@artemis.corp","threadId":"10602","inReplyTo":"20071103095556.GB2853@steel.home","subject":"Re: [PATCH 5/5] Migrate git-am.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-03T11:54:45Z","receivedAt":"2007-11-03T11:54:45Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sat, Nov 03, 2007 at 09:55:56AM +0000, Alex Riesen wrote:\n> Pierre Habouzit, Fri, Nov 02, 2007 23:39:52 +0100:\n> > diff --git a/git-am.sh b/git-am.sh\n> > index 2514d07..e5ed6a7 100755\n> > --- a/git-am.sh\n> > +++ b/git-am.sh\n> ....\n> > -\tusage ;;\n> > -\t*)\n> > -\tbreak ;;\n> > +\t\t-i|--interactive)\n> > +\t\t\tinteractive=t ;;\n> > +\t\t-b|--binary)\n> > +\t\t\tbinary=t ;;\n> \n> Did you really have to change the indentation?\n\n  Well, I'm unsure what the standard is for git, I gladly use any\nindentation, I don't really care. I assumed that it wasn't indented\nbefore becauuse instead of -i|--interactive you had:\n\n  -i|--in|--int|....|--interactive which took a lot of space, as it\nseemed to me that the case \"..\" in foo) esac construction in git had the\ncases indented in most places. But I may be wrong.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"58108","messageId":"20071103120541.GB13417@artemis.corp","threadId":"10602","inReplyTo":"20071103115445.GA13417@artemis.corp","subject":"Re: [PATCH 5/5] Migrate git-am.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-03T12:05:41Z","receivedAt":"2007-11-03T12:05:41Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sat, Nov 03, 2007 at 11:54:45AM +0000, Pierre Habouzit wrote:\n> On Sat, Nov 03, 2007 at 09:55:56AM +0000, Alex Riesen wrote:\n> > Pierre Habouzit, Fri, Nov 02, 2007 23:39:52 +0100:\n> > > diff --git a/git-am.sh b/git-am.sh\n> > > index 2514d07..e5ed6a7 100755\n> > > --- a/git-am.sh\n> > > +++ b/git-am.sh\n> > ....\n> > > -\tusage ;;\n> > > -\t*)\n> > > -\tbreak ;;\n> > > +\t\t-i|--interactive)\n> > > +\t\t\tinteractive=t ;;\n> > > +\t\t-b|--binary)\n> > > +\t\t\tbinary=t ;;\n> > \n> > Did you really have to change the indentation?\n> \n>   Well, I'm unsure what the standard is for git, I gladly use any\n> indentation, I don't really care. I assumed that it wasn't indented\n> before becauuse instead of -i|--interactive you had:\n> \n>   -i|--in|--int|....|--interactive which took a lot of space, as it\n> seemed to me that the case \"..\" in foo) esac construction in git had the\n> cases indented in most places. But I may be wrong.\n\n  Okay seems I was wrong, sorry then, that wasn't done on purpose at\nall.\n\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"299004","messageId":"1194112219-19968-1-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194043193-29601-5-git-send-email-madcoder@debian.org","subject":"[PATCH 5/5 FIX SPACING] Migrate git-am.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-03T17:50:15Z","receivedAt":"2007-11-03T17:50:15Z","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.1496.gcb1d6-dirty\n\n"},{"id":"299005","messageId":"1194112219-19968-2-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194112219-19968-1-git-send-email-madcoder@debian.org","subject":"[PATCH 6/5] Migrate git-merge.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-03T17:50:16Z","receivedAt":"2007-11-03T17:50:16Z","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.1496.gcb1d6-dirty\n\n"},{"id":"299006","messageId":"1194112219-19968-3-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194112219-19968-2-git-send-email-madcoder@debian.org","subject":"[PATCH 8/5] Migrate git-instaweb.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-03T17:50:17Z","receivedAt":"2007-11-03T17:50:17Z","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.1496.gcb1d6-dirty\n\n"},{"id":"299007","messageId":"1194112219-19968-4-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194112219-19968-3-git-send-email-madcoder@debian.org","subject":"[PATCH 9/5] Migrate git-checkout.sh to use git-rev-parse --parseopt --keep-dashdash","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-03T17:50:18Z","receivedAt":"2007-11-03T17:50:18Z","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..5424745 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+PARSEOPT_OPTS=--keep-dashdash\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.1496.gcb1d6-dirty\n\n"},{"id":"299008","messageId":"1194112219-19968-5-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194112219-19968-4-git-send-email-madcoder@debian.org","subject":"[PATCH 10/5] Migrate git-quiltimport.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-03T17:50:19Z","receivedAt":"2007-11-03T17:50:19Z","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.1496.gcb1d6-dirty\n\n"},{"id":"299009","messageId":"1194114913-22717-1-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194112219-19968-5-git-send-email-madcoder@debian.org","subject":"[PATCH 11/5] Migrate git-repack.sh to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-03T18:35:13Z","receivedAt":"2007-11-03T18:35:13Z","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.1498.gf0d63-dirty\n\n"},{"id":"58222","messageId":"7vd4uqtpza.fsf@gitster.siamese.dyndns.org","threadId":"10602","inReplyTo":"1194043193-29601-3-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 2/5] Update git-sh-setup(1) to allow transparent use of git-rev-parse --parseopt","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-04T07:43:53Z","receivedAt":"2007-11-04T07:43:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> If you set OPTIONS_SPEC, git-sh-setups uses git-rev-parse --parseopt\n> automatically.\n>\n> It also diverts usage to re-exec $0 with the -h option as parse-options.c\n> will catch that.\n>\n> PARSEOPT_OPTS can also be used to pass options git git-rev-parse --parseopt\n> mode (like --keep-dashdash).\n>\n> Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n> ...\n> +if test -n \"$OPTIONS_SPEC\"; then\n> +\tusage() {\n> +\t\texec \"$0\" -h\n> +\t}\n> +\n> +\teval `echo \"$OPTIONS_SPEC\" | git rev-parse --parseopt $PARSEOPT_OPTS -- \"$@\" || echo exit $?`\n\nI do not quite get why you use $PARSEOPT_OPTS without setting\nany yourself, which means that the users can screw themselves by\nhaving something random and insane in their environments.\n\nTrust me that this kind of backdoor, especially when the\nintended uses of the backdoor is not documented well, will be\nabused by (perhaps clueless, perhaps curious, perhaps fearless)\nusers and you will get blamed.\n\nSo I'd rather (1) first find out what _you_ wanted to use this\nbackdoor for, (2) see if that is a useful feature to share with\nothers instead of keeping that to yourself, and (3) if so to\nhave a much narrower interface to allow such an option that\ncannot be abused.\n\nThe same comment applies to the git-clone one which has a\nsimilar invocation of \"rev-parse --parseopt\" because it cannot\nsource git-sh-setup.\n"},{"id":"58223","messageId":"7v7ikytpz0.fsf@gitster.siamese.dyndns.org","threadId":"10602","inReplyTo":"1194112219-19968-4-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 9/5] Migrate git-checkout.sh to use git-rev-parse --parseopt --keep-dashdash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-04T07:44:03Z","receivedAt":"2007-11-04T07:44:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> Also fix some space versus tabs issues.\n> ---\n>  git-checkout.sh |   99 +++++++++++++++++++++++++++----------------------------\n>  1 files changed, 49 insertions(+), 50 deletions(-)\n>\n> diff --git a/git-checkout.sh b/git-checkout.sh\n> index 8993920..5424745 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> +PARSEOPT_OPTS=--keep-dashdash\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\nOk, so this is how PARSEOPT_OPTS gets used.  It is a way for the\ncommand that sources git-sh-setup to tell the parseopt code what\nto do.  I can agree with this, but then all the other commands\nthat do not set PARSEOPT_OPTS before sourcing git-sh-setup\nshould set it to empty string.  Otherwise the users can screw\nyou with their environment variables.\n"},{"id":"58228","messageId":"20071104090335.GB26269@artemis.corp","threadId":"10602","inReplyTo":"7v7ikytpz0.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 9/5] Migrate git-checkout.sh to use git-rev-parse --parseopt --keep-dashdash","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T09:03:35Z","receivedAt":"2007-11-04T09:03:35Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sun, Nov 04, 2007 at 07:44:03AM +0000, Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> > Also fix some space versus tabs issues.\n> > ---\n> >  git-checkout.sh |   99 +++++++++++++++++++++++++++----------------------------\n> >  1 files changed, 49 insertions(+), 50 deletions(-)\n> >\n> > diff --git a/git-checkout.sh b/git-checkout.sh\n> > index 8993920..5424745 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> > +PARSEOPT_OPTS=--keep-dashdash\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> \n> Ok, so this is how PARSEOPT_OPTS gets used.  It is a way for the\n> command that sources git-sh-setup to tell the parseopt code what\n> to do.  I can agree with this, but then all the other commands\n> that do not set PARSEOPT_OPTS before sourcing git-sh-setup\n> should set it to empty string.  Otherwise the users can screw\n> you with their environment variables.\n\n  yes it's the why, and it's also the why this variable isn't quoted\nbecause it is meant to get options to pass to git-rev-parse --parseopt\nIn fact it's only used in git-checkout right now. I believe the proper\nway to do that is that git-sh-setup does a PARSEOPT_OPTS= and that\ngit-checkout.sh its sole user overrides it once git-sh-setup is sourced.\nI'll send the two updated patches for that.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"299010","messageId":"1194167515-30378-1-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"7vd4uqtpza.fsf@gitster.siamese.dyndns.org","subject":"[UPDATED PATCH 3/5] Update git-sh-setup(1) to allow transparent use of git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T09:11:53Z","receivedAt":"2007-11-04T09:11:53Z","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\nPARSEOPT_OPTS can also be used to pass options git git-rev-parse --parseopt\nmode (like --keep-dashdash).\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-sh-setup.sh |   46 ++++++++++++++++++++++++++++------------------\n 1 files changed, 28 insertions(+), 18 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 86d7d4c..dfff0d1 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -16,9 +16,34 @@ die() {\n \texit 1\n }\n \n-usage() {\n-\tdie \"Usage: $0 $USAGE\"\n-}\n+if test -n \"$OPTIONS_SPEC\"; then\n+\t# override this after . git-sh-setup if you need to use --keep-dashdash\n+\tPARSEOPT_OPTS=\n+\tusage() {\n+\t\texec \"$0\" -h\n+\t}\n+\n+\teval `echo \"$OPTIONS_SPEC\" | git rev-parse --parseopt $PARSEOPT_OPTS -- \"$@\" || 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 +116,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.1498.g0a37d\n\n"},{"id":"299011","messageId":"1194167515-30378-2-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194167515-30378-1-git-send-email-madcoder@debian.org","subject":"[UPDATED PATCH 5/5] Migrate git-clone to use git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T09:11:54Z","receivedAt":"2007-11-04T09:11:54Z","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.1498.g0a37d\n\n"},{"id":"299012","messageId":"1194167515-30378-3-git-send-email-madcoder@debian.org","threadId":"10602","inReplyTo":"1194167515-30378-2-git-send-email-madcoder@debian.org","subject":"[UPDATED PATCH 9/5] Migrate git-checkout.sh to use git-rev-parse --parseopt --keep-dashdash","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T09:11:55Z","receivedAt":"2007-11-04T09:11:55Z","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..f99f0d5 100755\n--- a/git-checkout.sh\n+++ b/git-checkout.sh\n@@ -1,8 +1,18 @@\n #!/bin/sh\n \n-USAGE='[-q] [-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]'\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+PARSEOPT_OPTS=--keep-dashdash\n require_work_tree\n \n old_name=HEAD\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.1498.g0a37d\n\n"},{"id":"58229","messageId":"20071104091449.GC26269@artemis.corp","threadId":"10602","inReplyTo":"7vd4uqtpza.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/5] Update git-sh-setup(1) to allow transparent use of git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T09:14:49Z","receivedAt":"2007-11-04T09:14:49Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sun, Nov 04, 2007 at 07:43:53AM +0000, Junio C Hamano wrote:\n> Trust me that this kind of backdoor, especially when the\n> intended uses of the backdoor is not documented well, will be\n> abused by (perhaps clueless, perhaps curious, perhaps fearless)\n> users and you will get blamed.\n\n  That has been fixed, and documented in git-sh-setup. I renumbered my 3\npatches incorrectly though. Those are supposed to supersede patches 2, 4, and 9.\n\nCheers,\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"58230","messageId":"20071104091529.GD26269@artemis.corp","threadId":"10602","inReplyTo":"20071104091449.GC26269@artemis.corp","subject":"Re: [PATCH 2/5] Update git-sh-setup(1) to allow transparent use of git-rev-parse --parseopt","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T09:15:29Z","receivedAt":"2007-11-04T09:15:29Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On dim, nov 04, 2007 at 09:14:49 +0000, Pierre Habouzit wrote:\n> On Sun, Nov 04, 2007 at 07:43:53AM +0000, Junio C Hamano wrote:\n> > Trust me that this kind of backdoor, especially when the\n> > intended uses of the backdoor is not documented well, will be\n> > abused by (perhaps clueless, perhaps curious, perhaps fearless)\n> > users and you will get blamed.\n> \n>   That has been fixed, and documented in git-sh-setup. I renumbered my 3\n> patches incorrectly though. Those are supposed to supersede patches 2, 4, and 9.\n\n  And I'm stupid this obviously doesnt work doh..... sorry, I'll\nrethought this.\n\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"58265","messageId":"Pine.LNX.4.64.0711041343470.4362@racer.site","threadId":"10602","inReplyTo":"7v7ikytpz0.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 9/5] Migrate git-checkout.sh to use git-rev-parse --parseopt --keep-dashdash","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-04T13:48:36Z","receivedAt":"2007-11-04T13:48:36Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 4 Nov 2007, Junio C Hamano wrote:\n\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> > Also fix some space versus tabs issues.\n> > ---\n> >  git-checkout.sh |   99 +++++++++++++++++++++++++++----------------------------\n> >  1 files changed, 49 insertions(+), 50 deletions(-)\n> >\n> > diff --git a/git-checkout.sh b/git-checkout.sh\n> > index 8993920..5424745 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> > +PARSEOPT_OPTS=--keep-dashdash\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> \n> Ok, so this is how PARSEOPT_OPTS gets used.\n\nI also read in the docs:\n\n> It takes on the standard input the specification of the options to parse\n> and understand, and echoes on the standard ouput a line suitable for \n> `sh(1)` `eval` to replace the arguments with normalized ones.\n\nWhy not go the full nine yards and output something which when eval'ed \nsets the variables correctly (taking the variable names from the option \nnames; long name if available, otherwise short one)?  It can also set the \ncommand line arguments to what's left after option parsing, with a \"set\" \ncall.\n\nAnd to prevent funny games with \"PARSEOPT_OPTS=blabla git xyz\", why not \nprovide a function in git-sh-setup which takes the string as argument, and \nis called _after_ sourcing git-sh-setup?\n\nCiao,\nDscho\n"},{"id":"58272","messageId":"20071104141809.GG26269@artemis.corp","threadId":"10602","inReplyTo":"Pine.LNX.4.64.0711041343470.4362@racer.site","subject":"Re: [PATCH 9/5] Migrate git-checkout.sh to use git-rev-parse --parseopt --keep-dashdash","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T14:18:09Z","receivedAt":"2007-11-04T14:18:09Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sun, Nov 04, 2007 at 01:48:36PM +0000, Johannes Schindelin wrote:\n> > Pierre Habouzit <madcoder@debian.org> writes:\n> > It takes on the standard input the specification of the options to parse\n> > and understand, and echoes on the standard ouput a line suitable for \n> > `sh(1)` `eval` to replace the arguments with normalized ones.\n> \n> Why not go the full nine yards and output something which when eval'ed \n> sets the variables correctly (taking the variable names from the option \n> names; long name if available, otherwise short one)?  It can also set the \n> command line arguments to what's left after option parsing, with a \"set\" \n> call.\n\nWe could do that, though it's not as great as it looks like at the first\nglance. If you want -vvv to work like an accumulator, then you need a\nreally more complex approach in the C code. To enter the gory details,\ngit-rev-parse --parseopt uses a callback that deals with options and\ntheir arguments one by one, then appends a delimiter to tell the shell\nscript that only arguments follow, and then appends the arguments the\noption parser left alone.\n\nIt does not deal with the semantics that the C has available at all,\nit's up to the shell script to decide which is better.\n\nMy goal with this is not really to do all the work for the shell script\nauthor, but rather to the user: it's not because a porcelain is new (or\nnot a builtin yet) that it should have a creepy interface. If it helps\nthe programmer as a side effect, then it's great, but this series really\nis about usability to me.\n\nOf course we can do what you propose, but it will probably be quite\nsophisticated and looks to me like an overkill to what shell builtins\nreally are used for: prototyping a new porcelain until it becomes a new\nfull blown C-builtin.  I do believe in simplicity after all :)\n\n> And to prevent funny games with \"PARSEOPT_OPTS=blabla git xyz\", why not \n> provide a function in git-sh-setup which takes the string as argument, and \n> is called _after_ sourcing git-sh-setup?\n\nThis one is quite a non issue, it's only used for keep-dashdash, and I\nsee no other need in the near future. And if the need arise, it'll still\nbe doable any time. So for now I've taken a non-generic way to do that,\nand I believe it's fine as it is.\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"}]}