Merge branch 'maint-1.5.4' into maint
authorJunio C Hamano <gitster@pobox.com>
Thu, 10 Apr 2008 07:29:33 +0000 (00:29 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 10 Apr 2008 07:29:33 +0000 (00:29 -0700)
* 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.

1  2 
Documentation/git-tag.txt
builtin-tag.c
parse-options.c
index c22fb71176984f40e4b549d0d492f75af85e0e1b,74b461f66194be5abc944c9feeb8666125955d82..4b6fd90eafbcb9834a4b3bf733fef28b3f895fde
@@@ -11,7 -11,7 +11,7 @@@ SYNOPSI
  [verse]
  'git-tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>]  <name> [<head>]
  'git-tag' -d <name>...
- 'git-tag' [-n [<num>]] -l [<pattern>]
+ 'git-tag' [-n[<num>]] -l [<pattern>]
  'git-tag' -v <name>...
  
  DESCRIPTION
@@@ -26,9 -26,6 +26,9 @@@ creates a 'tag' object, and requires th
  `-m <msg>` or `-F <file>` is given, an editor is started for the user to type
  in the tag message.
  
 +If `-m <msg>` or `-F <file>` is given and `-a`, `-s`, and `-u <key-id>`
 +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 <num>::
+ -n<num>::
        <num> specifies how many lines from the annotation, if any,
        are printed when using -l.
        The default is not to print any annotation lines.
        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 <key-id>`
 +      is given.
  
  -F <file>::
        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 <key-id>`
 +      is given.
  
  CONFIGURATION
  -------------
diff --combined builtin-tag.c
index 8dd959fe1c74507023f8e82c7f4682c1588ebac6,95ecfdbab650f3b60bb3ecb7e20f68a913470d20..129ff57f11d2cdfdacc6be9685736ada07caef7f
@@@ -16,7 -16,7 +16,7 @@@
  static const char * const git_tag_usage[] = {
        "git-tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]",
        "git-tag -d <tagname>...",
-       "git-tag -l [-n [<num>]] [<pattern>]",
+       "git-tag -l [-n[<num>]] [<pattern>]",
        "git-tag -v <tagname>...",
        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 e87cafbe4199acb39fd9113e4b5096de19a3a61c,59dc9ce6b471c61aff22d51293ee3d74b020c88a..acf3fe3a1a82cd99e7bd6e0ff9d6d3d7e344a155
@@@ -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;
                }
  
                        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, " [<n>]");
+                               pos += fprintf(stderr, "[<n>]");
                        else
                                pos += fprintf(stderr, " <n>");
                        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;
 +}