OSDN Git Service

Merge branch 'jk/commit-buffer-length'
authorJunio C Hamano <gitster@pobox.com>
Wed, 2 Jul 2014 19:53:02 +0000 (12:53 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Jul 2014 19:53:02 +0000 (12:53 -0700)
Move "commit->buffer" out of the in-core commit object and keep
track of their lengths.  Use this to optimize the code paths to
validate GPG signatures in commit objects.

* jk/commit-buffer-length:
  reuse cached commit buffer when parsing signatures
  commit: record buffer length in cache
  commit: convert commit->buffer to a slab
  commit-slab: provide a static initializer
  use get_commit_buffer everywhere
  convert logmsg_reencode to get_commit_buffer
  use get_commit_buffer to avoid duplicate code
  use get_cached_commit_buffer where appropriate
  provide helpers to access the commit buffer
  provide a helper to set the commit buffer
  provide a helper to free commit buffer
  sequencer: use logmsg_reencode in get_message
  logmsg_reencode: return const buffer
  do not create "struct commit" with xcalloc
  commit: push commit_index update into alloc_commit_node
  alloc: include any-object allocations in alloc_report
  replace dangerous uses of strbuf_attach
  commit_tree: take a pointer/len pair rather than a const strbuf

14 files changed:
1  2 
builtin/blame.c
builtin/commit.c
builtin/fast-export.c
builtin/index-pack.c
builtin/log.c
builtin/merge.c
builtin/reset.c
commit.c
merge-recursive.c
notes-cache.c
notes-utils.c
pretty.c
revision.c
sequencer.c

diff --cc builtin/blame.c
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc builtin/log.c
Simple merge
diff --cc builtin/merge.c
Simple merge
diff --cc builtin/reset.c
Simple merge
diff --cc commit.c
Simple merge
Simple merge
diff --cc notes-cache.c
@@@ -57,12 -56,11 +56,11 @@@ int notes_cache_write(struct notes_cach
  
        if (write_notes_tree(&c->tree, tree_sha1))
                return -1;
-       strbuf_attach(&msg, c->validity,
-                     strlen(c->validity), strlen(c->validity) + 1);
-       if (commit_tree(&msg, tree_sha1, NULL, commit_sha1, NULL, NULL) < 0)
+       if (commit_tree(c->validity, strlen(c->validity), tree_sha1, NULL,
+                       commit_sha1, NULL, NULL) < 0)
                return -1;
        if (update_ref("update notes cache", c->tree.ref, commit_sha1, NULL,
 -                     0, QUIET_ON_ERR) < 0)
 +                     0, UPDATE_REFS_QUIET_ON_ERR) < 0)
                return -1;
  
        return 0;
diff --cc notes-utils.c
@@@ -46,10 -47,9 +47,10 @@@ void commit_notes(struct notes_tree *t
        if (buf.buf[buf.len - 1] != '\n')
                strbuf_addch(&buf, '\n'); /* Make sure msg ends with newline */
  
-       create_notes_commit(t, NULL, &buf, commit_sha1);
+       create_notes_commit(t, NULL, buf.buf, buf.len, commit_sha1);
        strbuf_insert(&buf, 0, "notes: ", 7); /* commit message starts at index 7 */
 -      update_ref(buf.buf, t->ref, commit_sha1, NULL, 0, DIE_ON_ERR);
 +      update_ref(buf.buf, t->ref, commit_sha1, NULL, 0,
 +                 UPDATE_REFS_DIE_ON_ERR);
  
        strbuf_release(&buf);
  }
diff --cc pretty.c
Simple merge
diff --cc revision.c
Simple merge
diff --cc sequencer.c
Simple merge