From: Junio C Hamano Date: Thu, 10 Apr 2008 07:29:33 +0000 (-0700) Subject: Merge branch 'maint-1.5.4' into maint X-Git-Tag: v1.5.5.1~19 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/179c94b24ae87e28328f9b311489417b66bd62c9?ds=inline;hp=-c Merge branch 'maint-1.5.4' into maint * maint-1.5.4: core-tutorial.txt: Fix showing the current behaviour. git-archive: ignore prefix when checking file attribute Fix documentation syntax of optional arguments in short options. --- 179c94b24ae87e28328f9b311489417b66bd62c9 diff --combined Documentation/git-tag.txt index c22fb71176,74b461f661..4b6fd90eaf --- a/Documentation/git-tag.txt +++ b/Documentation/git-tag.txt @@@ -11,7 -11,7 +11,7 @@@ SYNOPSI [verse] 'git-tag' [-a | -s | -u ] [-f] [-m | -F ] [] 'git-tag' -d ... - 'git-tag' [-n []] -l [] + 'git-tag' [-n[]] -l [] 'git-tag' -v ... DESCRIPTION @@@ -26,9 -26,6 +26,9 @@@ creates a 'tag' object, and requires th `-m ` or `-F ` is given, an editor is started for the user to type in the tag message. +If `-m ` or `-F ` is given and `-a`, `-s`, and `-u ` +are absent, `-a` is implied. + Otherwise just the SHA1 object name of the commit object is written (i.e. a lightweight tag). @@@ -57,7 -54,7 +57,7 @@@ OPTION -v:: Verify the gpg signature of the given tag names. - -n :: + -n:: specifies how many lines from the annotation, if any, are printed when using -l. The default is not to print any annotation lines. @@@ -71,14 -68,10 +71,14 @@@ Use the given tag message (instead of prompting). If multiple `-m` options are given, there values are concatenated as separate paragraphs. + Implies `-a` if none of `-a`, `-s`, or `-u ` + is given. -F :: Take the tag message from the given file. Use '-' to read the message from the standard input. + Implies `-a` if none of `-a`, `-s`, or `-u ` + is given. CONFIGURATION ------------- diff --combined builtin-tag.c index 8dd959fe1c,95ecfdbab6..129ff57f11 --- a/builtin-tag.c +++ b/builtin-tag.c @@@ -16,7 -16,7 +16,7 @@@ static const char * const git_tag_usage[] = { "git-tag [-a|-s|-u ] [-f] [-m |-F ] []", "git-tag -d ...", - "git-tag -l [-n []] []", + "git-tag -l [-n[]] []", "git-tag -v ...", NULL }; @@@ -230,17 -230,19 +230,17 @@@ static int do_sign(struct strbuf *buffe if (write_in_full(gpg.in, buffer->buf, buffer->len) != buffer->len) { close(gpg.in); + close(gpg.out); finish_command(&gpg); return error("gpg did not accept the tag data"); } close(gpg.in); - gpg.close_in = 0; len = strbuf_read(buffer, gpg.out, 1024); + close(gpg.out); if (finish_command(&gpg) || !len || len < 0) return error("gpg failed to sign the tag"); - if (len < 0) - return error("could not read the entire signature from gpg."); - return 0; } diff --combined parse-options.c index e87cafbe41,59dc9ce6b4..acf3fe3a1a --- a/parse-options.c +++ b/parse-options.c @@@ -6,8 -6,7 +6,8 @@@ struct optparse_t { const char **argv; - int argc; + const char **out; + int argc, cpidx; const char *opt; }; @@@ -160,16 -159,6 +160,16 @@@ static int parse_long_opt(struct optpar continue; rest = skip_prefix(arg, options->long_name); + if (options->type == OPTION_ARGUMENT) { + if (!rest) + continue; + if (*rest == '=') + return opterror(options, "takes no value", flags); + if (*rest) + continue; + p->out[p->cpidx++] = arg - 2; + return 0; + } if (!rest) { /* abbreviated? */ if (!strncmp(options->long_name, arg, arg_end - arg)) { @@@ -253,15 -242,14 +253,15 @@@ static NORETURN void usage_with_options int parse_options(int argc, const char **argv, const struct option *options, const char * const usagestr[], int flags) { - struct optparse_t args = { argv + 1, argc - 1, NULL }; - int j = 0; + struct optparse_t args = { argv + 1, argv, argc - 1, 0, NULL }; for (; args.argc; args.argc--, args.argv++) { const char *arg = args.argv[0]; if (*arg != '-' || !arg[1]) { - argv[j++] = args.argv[0]; + if (flags & PARSE_OPT_STOP_AT_NON_OPTION) + break; + args.out[args.cpidx++] = args.argv[0]; continue; } @@@ -298,9 -286,9 +298,9 @@@ usage_with_options(usagestr, options); } - memmove(argv + j, args.argv, args.argc * sizeof(*argv)); - argv[j + args.argc] = NULL; - return j + args.argc; + memmove(args.out + args.cpidx, args.argv, args.argc * sizeof(*args.out)); + args.out[args.cpidx + args.argc] = NULL; + return args.cpidx + args.argc; } #define USAGE_OPTS_WIDTH 24 @@@ -340,11 -328,9 +340,11 @@@ void usage_with_options_internal(const pos += fprintf(stderr, "--%s", opts->long_name); switch (opts->type) { + case OPTION_ARGUMENT: + break; case OPTION_INTEGER: if (opts->flags & PARSE_OPT_OPTARG) - pos += fprintf(stderr, " []"); + pos += fprintf(stderr, "[]"); else pos += fprintf(stderr, " "); break; @@@ -409,10 -395,3 +409,10 @@@ int parse_opt_abbrev_cb(const struct op *(int *)(opt->value) = v; return 0; } + +int parse_opt_approxidate_cb(const struct option *opt, const char *arg, + int unset) +{ + *(unsigned long *)(opt->value) = approxidate(arg); + return 0; +}