Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Sun, 2 Nov 2008 07:15:22 +0000 (00:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 2 Nov 2008 07:15:22 +0000 (00:15 -0700)
* maint:
Start 1.6.0.4 cycle
add instructions on how to send patches to the mailing list with Gmail
Documentation/gitattributes: Add subsection header for each attribute
git send-email: avoid leaking directory file descriptors.
send-pack: do not send out single-level refs such as refs/stash
fix overlapping memcpy in normalize_absolute_path
pack-objects: avoid reading uninitalized data
correct cache_entry allocation

Conflicts:
RelNotes

1  2 
Documentation/SubmittingPatches
Documentation/gitattributes.txt
builtin-pack-objects.c
builtin-send-pack.c
git-send-email.perl
index a1e9100f9e3ccb8466ec603e154cb230dc2cb33b,c59edfa6a9d89aec712b61cb72f9f1605aacae86..f0295c60f5aceb975575903327228776d6b2bb9e
@@@ -71,7 -71,7 +71,7 @@@ run git diff --check on your changes be
  
  (1a) Try to be nice to older C compilers
  
 -We try to support wide range of C compilers to compile
 +We try to support wide range of C compilers to compile
  git with. That means that you should not use C99 initializers, even
  if a lot of compilers grok it.
  
@@@ -456,3 -456,30 +456,30 @@@ This should help you to submit patches 
  
  5) Back in the compose window: add whatever other text you wish to the
  message, complete the addressing and subject fields, and press send.
+ Gmail
+ -----
+ Submitting properly formatted patches via Gmail is simple now that
+ IMAP support is available. First, edit your ~/.gitconfig to specify your
+ account settings:
+ [imap]
+       folder = "[Gmail]/Drafts"
+       host = imaps://imap.gmail.com
+       user = user@gmail.com
+       pass = p4ssw0rd
+       port = 993
+       sslverify = false
+ Next, ensure that your Gmail settings are correct. In "Settings" the
+ "Use Unicode (UTF-8) encoding for outgoing messages" should be checked.
+ Once your commits are ready to send to the mailing list, run the following
+ command to send the patch emails to your Gmail Drafts folder.
+       $ git format-patch -M --stdout origin/master | git imap-send
+ Go to your Gmail account, open the Drafts folder, find the patch email, fill
+ in the To: and CC: fields and send away!
index 24e880c5be1306017ca394af16891cf081fdc30b,37fff208ffb6ce75911ef439ef140550a48b1a18..eb648418eedba4f131aec1f18ccba3bd62f53dc2
@@@ -213,6 -213,9 +213,9 @@@ with `crlf`, and then `ident` and fed t
  Generating diff text
  ~~~~~~~~~~~~~~~~~~~~
  
+ `diff`
+ ^^^^^^
  The attribute `diff` affects if 'git-diff' generates textual
  patch for the path or just says `Binary files differ`.  It also
  can affect what line is shown on the hunk header `@@ -k,l +n,m @@`
@@@ -311,18 -314,10 +314,18 @@@ patterns are available
  
  - `bibtex` suitable for files with BibTeX coded references.
  
 +- `html` suitable for HTML/XHTML documents.
 +
  - `java` suitable for source code in the Java language.
  
 +- `objc` suitable for source code in the Objective-C language.
 +
  - `pascal` suitable for source code in the Pascal/Delphi language.
  
 +- `php` suitable for source code in the PHP language.
 +
 +- `python` suitable for source code in the Python language.
 +
  - `ruby` suitable for source code in the Ruby language.
  
  - `tex` suitable for source code for LaTeX documents.
  Performing a three-way merge
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
+ `merge`
+ ^^^^^^^
  The attribute `merge` affects how three versions of a file is
  merged when a file-level merge is necessary during `git merge`,
  and other programs such as `git revert` and `git cherry-pick`.
diff --combined builtin-pack-objects.c
index 59c30d1caa37416041177ff4aaf01b67f4e8add4,b0dddbee4f93de462090218554e1b1b6d1038c34..15b80db5a1a43ae2ae44375c2cb27978c2e70a71
@@@ -1369,13 -1369,15 +1369,13 @@@ static void find_deltas(struct object_e
                        int window, int depth, unsigned *processed)
  {
        uint32_t i, idx = 0, count = 0;
 -      unsigned int array_size = window * sizeof(struct unpacked);
        struct unpacked *array;
        unsigned long mem_usage = 0;
  
 -      array = xmalloc(array_size);
 -      memset(array, 0, array_size);
 +      array = xcalloc(window, sizeof(struct unpacked));
  
        for (;;) {
-               struct object_entry *entry = *list++;
+               struct object_entry *entry;
                struct unpacked *n = array + idx;
                int j, max_depth, best_base = -1;
  
                        progress_unlock();
                        break;
                }
+               entry = *list++;
                (*list_size)--;
                if (!entry->preferred_base) {
                        (*processed)++;
@@@ -1723,14 -1726,6 +1724,14 @@@ static void prepare_pack(int window, in
                        if (entry->type < 0)
                                die("unable to get type of object %s",
                                    sha1_to_hex(entry->idx.sha1));
 +              } else {
 +                      if (entry->type < 0) {
 +                              /*
 +                               * This object is not found, but we
 +                               * don't have to include it anyway.
 +                               */
 +                              continue;
 +                      }
                }
  
                delta_list[n++] = entry;
diff --combined builtin-send-pack.c
index 910db92b62eb6dd91a4002b2643fef4a76ec8f83,301f23043262059dcb28994527334ba1909671f0..d68ce2d0e3451127c61658ae7df3053f5eae6366
@@@ -18,7 -18,7 +18,7 @@@ static struct send_pack_args args = 
  /*
   * Make a pack stream and spit it out into file descriptor fd
   */
 -static int pack_objects(int fd, struct ref *refs)
 +static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *extra)
  {
        /*
         * The child becomes pack-objects --revs; we feed
@@@ -34,8 -34,6 +34,8 @@@
                NULL,
        };
        struct child_process po;
 +      int i;
 +      char buf[42];
  
        if (args.use_thin_pack)
                argv[4] = "--thin";
         * We feed the pack-objects we just spawned with revision
         * parameters by writing to the pipe.
         */
 -      while (refs) {
 -              char buf[42];
 +      for (i = 0; i < extra->nr; i++) {
 +              memcpy(buf + 1, sha1_to_hex(&extra->array[i][0]), 40);
 +              buf[0] = '^';
 +              buf[41] = '\n';
 +              if (!write_or_whine(po.in, buf, 42, "send-pack: send refs"))
 +                      break;
 +      }
  
 +      while (refs) {
                if (!is_null_sha1(refs->old_sha1) &&
                    has_sha1_file(refs->old_sha1)) {
                        memcpy(buf + 1, sha1_to_hex(refs->old_sha1), 40);
@@@ -140,7 -132,13 +140,13 @@@ static struct ref *remote_refs, **remot
  static int one_local_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
  {
        struct ref *ref;
-       int len = strlen(refname) + 1;
+       int len;
+       /* we already know it starts with refs/ to get here */
+       if (check_ref_format(refname + 5))
+               return 0;
+       len = strlen(refname) + 1;
        ref = xcalloc(1, sizeof(*ref) + len);
        hashcpy(ref->new_sha1, sha1);
        memcpy(ref->name, refname, len);
@@@ -389,17 -387,14 +395,17 @@@ static int do_send_pack(int in, int out
        int expect_status_report = 0;
        int flags = MATCH_REFS_NONE;
        int ret;
 +      struct extra_have_objects extra_have;
  
 +      memset(&extra_have, 0, sizeof(extra_have));
        if (args.send_all)
                flags |= MATCH_REFS_ALL;
        if (args.send_mirror)
                flags |= MATCH_REFS_MIRROR;
  
        /* No funny business with the matcher */
 -      remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, REF_NORMAL);
 +      remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, REF_NORMAL,
 +                                     &extra_have);
        get_local_heads();
  
        /* Does the other end support the reporting? */
  
        packet_flush(out);
        if (new_refs && !args.dry_run) {
 -              if (pack_objects(out, remote_refs) < 0)
 +              if (pack_objects(out, remote_refs, &extra_have) < 0)
                        return -1;
        }
        else
diff --combined git-send-email.perl
index bdbfac66256ffc29e26f5c83531c77a18a263808,18529c76e665e613d9c116e32da6acf31b3eac6a..94ca5c89ad086bac754fb6b6b907fd4e968e8024
@@@ -39,40 -39,75 +39,40 @@@ package main
  sub usage {
        print <<EOT;
  git send-email [options] <file | directory>...
 -Options:
 -   --from         Specify the "From:" line of the email to be sent.
  
 -   --to           Specify the primary "To:" line of the email.
 -
 -   --cc           Specify an initial "Cc:" list for the entire series
 -                  of emails.
 -
 -   --cc-cmd       Specify a command to execute per file which adds
 -                  per file specific cc address entries
 -
 -   --bcc          Specify a list of email addresses that should be Bcc:
 -                on all the emails.
 -
 -   --compose      Use \$GIT_EDITOR, core.editor, \$EDITOR, or \$VISUAL to edit
 -                an introductory message for the patch series.
 -
 -   --subject      Specify the initial "Subject:" line.
 -                  Only necessary if --compose is also set.  If --compose
 -                is not set, this will be prompted for.
 -
 -   --in-reply-to  Specify the first "In-Reply-To:" header line.
 -                  Only used if --compose is also set.  If --compose is not
 -                set, this will be prompted for.
 -
 -   --chain-reply-to If set, the replies will all be to the previous
 -                  email sent, rather than to the first email sent.
 -                  Defaults to on.
 -
 -   --signed-off-cc Automatically add email addresses that appear in
 -                 Signed-off-by: or Cc: lines to the cc: list. Defaults to on.
 -
 -   --identity     The configuration identity, a subsection to prioritise over
 -                  the default section.
 -
 -   --smtp-server  If set, specifies the outgoing SMTP server to use.
 -                  Defaults to localhost.  Port number can be specified here with
 -                  hostname:port format or by using --smtp-server-port option.
 -
 -   --smtp-server-port Specify a port on the outgoing SMTP server to connect to.
 -
 -   --smtp-user    The username for SMTP-AUTH.
 -
 -   --smtp-pass    The password for SMTP-AUTH.
 -
 -   --smtp-encryption Specify 'tls' for STARTTLS encryption, or 'ssl' for SSL.
 -                  Any other value disables the feature.
 -
 -   --smtp-ssl     Synonym for '--smtp-encryption=ssl'.  Deprecated.
 -
 -   --suppress-cc  Suppress the specified category of auto-CC.  The category
 -                can be one of 'author' for the patch author, 'self' to
 -                avoid copying yourself, 'sob' for Signed-off-by lines,
 -                'cccmd' for the output of the cccmd, or 'all' to suppress
 -                all of these.
 -
 -   --suppress-from Suppress sending emails to yourself. Defaults to off.
 -
 -   --thread       Specify that the "In-Reply-To:" header should be set on all
 -                  emails. Defaults to on.
 -
 -   --quiet      Make git-send-email less verbose.  One line per email
 -                  should be all that is output.
 -
 -   --dry-run    Do everything except actually send the emails.
 -
 -   --envelope-sender  Specify the envelope sender used to send the emails.
 -
 -   --no-validate      Don't perform any sanity checks on patches.
 +  Composing:
 +    --from                  <str>  * Email From:
 +    --to                    <str>  * Email To:
 +    --cc                    <str>  * Email Cc:
 +    --bcc                   <str>  * Email Bcc:
 +    --subject               <str>  * Email "Subject:"
 +    --in-reply-to           <str>  * Email "In-Reply-To:"
 +    --compose                      * Open an editor for introduction.
 +
 +  Sending:
 +    --envelope-sender       <str>  * Email envelope sender.
 +    --smtp-server       <str:int>  * Outgoing SMTP server to use. The port
 +                                     is optional. Default 'localhost'.
 +    --smtp-server-port      <int>  * Outgoing SMTP server port.
 +    --smtp-user             <str>  * Username for SMTP-AUTH.
 +    --smtp-pass             <str>  * Password for SMTP-AUTH; not necessary.
 +    --smtp-encryption       <str>  * tls or ssl; anything else disables.
 +    --smtp-ssl                     * Deprecated. Use '--smtp-encryption ssl'.
 +
 +  Automating:
 +    --identity              <str>  * Use the sendemail.<id> options.
 +    --cc-cmd                <str>  * Email Cc: via `<str> \$patch_path`
 +    --suppress-cc           <str>  * author, self, sob, cccmd, all.
 +    --[no-]signed-off-by-cc        * Send to Cc: and Signed-off-by:
 +                                     addresses. Default on.
 +    --[no-]suppress-from           * Send to self. Default off.
 +    --[no-]chain-reply-to          * Chain In-Reply-To: fields. Default on.
 +    --[no-]thread                  * Use In-Reply-To: field. Default on.
 +
 +  Administering:
 +    --quiet                        * Output one line of info per email.
 +    --dry-run                      * Don't actually send the emails.
 +    --[no-]validate                * Perform patch sanity checks. Default on.
  
  EOT
        exit(1);
@@@ -151,19 -186,17 +151,19 @@@ if ($@) 
  my ($quiet, $dry_run) = (0, 0);
  
  # Variables with corresponding config settings
 -my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);
 +my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
  my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);
  my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
 -my ($no_validate);
 +my ($validate);
  my (@suppress_cc);
  
  my %config_bool_settings = (
      "thread" => [\$thread, 1],
      "chainreplyto" => [\$chain_reply_to, 1],
      "suppressfrom" => [\$suppress_from, undef],
 -    "signedoffcc" => [\$signed_off_cc, undef],
 +    "signedoffbycc" => [\$signed_off_by_cc, undef],
 +    "signedoffcc" => [\$signed_off_by_cc, undef],      # Deprecated
 +    "validate" => [\$validate, 1],
  );
  
  my %config_settings = (
@@@ -226,11 -259,11 +226,11 @@@ my $rc = GetOptions("sender|from=s" => 
                    "cc-cmd=s" => \$cc_cmd,
                    "suppress-from!" => \$suppress_from,
                    "suppress-cc=s" => \@suppress_cc,
 -                  "signed-off-cc|signed-off-by-cc!" => \$signed_off_cc,
 +                  "signed-off-cc|signed-off-by-cc!" => \$signed_off_by_cc,
                    "dry-run" => \$dry_run,
                    "envelope-sender=s" => \$envelope_sender,
                    "thread!" => \$thread,
 -                  "no-validate" => \$no_validate,
 +                  "validate!" => \$validate,
         );
  
  unless ($rc) {
@@@ -302,7 -335,7 +302,7 @@@ if ($suppress_cc{'all'}) 
  
  # If explicit old-style ones are specified, they trump --suppress-cc.
  $suppress_cc{'self'} = $suppress_from if defined $suppress_from;
 -$suppress_cc{'sob'} = !$signed_off_cc if defined $signed_off_cc;
 +$suppress_cc{'sob'} = !$signed_off_by_cc if defined $signed_off_by_cc;
  
  # Debugging, print out the suppressions.
  if (0) {
@@@ -374,16 -407,15 +374,15 @@@ for my $f (@ARGV) 
  
                push @files, grep { -f $_ } map { +$f . "/" . $_ }
                                sort readdir(DH);
+               closedir(DH);
        } elsif (-f $f or -p $f) {
                push @files, $f;
        } else {
                print STDERR "Skipping $f - not found.\n";
        }
  }
  
 -if (!$no_validate) {
 +if ($validate) {
        foreach my $f (@files) {
                unless (-p $f) {
                        my $error = validate_patch($f);