From: Junio C Hamano Date: Fri, 23 May 2008 22:52:43 +0000 (-0700) Subject: Merge branch 'maint-1.5.4' into maint X-Git-Tag: v1.5.5.2^0 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/77599cc0bbd0a08defc3bfa80ca52d931d8dc786?ds=inline;hp=-c Merge branch 'maint-1.5.4' into maint * maint-1.5.4: rev-parse --symbolic-full-name: don't print '^' if SHA1 is not a ref --- 77599cc0bbd0a08defc3bfa80ca52d931d8dc786 diff --combined builtin-rev-parse.c index 0351d54435,1ae086ad17..00b607824d --- a/builtin-rev-parse.c +++ b/builtin-rev-parse.c @@@ -96,6 -96,14 +96,14 @@@ static void show(const char *arg puts(arg); } + /* Like show(), but with a negation prefix according to type */ + static void show_with_type(int type, const char *arg) + { + if (type != show_type) + putchar('^'); + show(arg); + } + /* Output a revision, only if filter allows it */ static void show_rev(int type, const unsigned char *sha1, const char *name) { @@@ -104,8 -112,6 +112,6 @@@ def = NULL; revs_count++; - if (type != show_type) - putchar('^'); if (symbolic && name) { if (symbolic == SHOW_SYMBOLIC_FULL) { unsigned char discard[20]; @@@ -122,20 -128,20 +128,20 @@@ */ break; case 1: /* happy */ - show(full); + show_with_type(type, full); break; default: /* ambiguous */ error("refname '%s' is ambiguous", name); break; } } else { - show(name); + show_with_type(type, name); } } else if (abbrev) - show(find_unique_abbrev(sha1, abbrev)); + show_with_type(type, find_unique_abbrev(sha1, abbrev)); else - show(sha1_to_hex(sha1)); + show_with_type(type, sha1_to_hex(sha1)); } /* Output a flag, only if filter allows it. */ @@@ -322,24 -328,18 +328,24 @@@ static int cmd_parseopt(int argc, cons o->type = OPTION_CALLBACK; o->help = xstrdup(skipspaces(s)); o->value = &parsed; + o->flags = PARSE_OPT_NOARG; o->callback = &parseopt_dump; - switch (s[-1]) { - case '=': - s--; - break; - case '?': - o->flags = PARSE_OPT_OPTARG; - s--; - break; - default: - o->flags = PARSE_OPT_NOARG; - break; + while (s > sb.buf && strchr("*=?!", s[-1])) { + switch (*--s) { + case '=': + o->flags &= ~PARSE_OPT_NOARG; + break; + case '?': + o->flags &= ~PARSE_OPT_NOARG; + o->flags |= PARSE_OPT_OPTARG; + break; + case '!': + o->flags |= PARSE_OPT_NONEG; + break; + case '*': + o->flags |= PARSE_OPT_HIDDEN; + break; + } } if (s - sb.buf == 1) /* short option only */