gitweb.git
alloc: factor out commit indexJeff King Sun, 13 Jul 2014 06:42:08 +0000 (02:42 -0400)

alloc: factor out commit index

We keep a static counter to set the commit index on newly
allocated objects. However, since we also need to set the
index on any_objects which are converted to commits, let's
make the counter available as a public function.

While we're moving it, let's make sure the counter is
allocated as an unsigned integer to match the index field in
"struct commit".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

add object_as_type helper for casting objectsJeff King Sun, 13 Jul 2014 06:42:03 +0000 (02:42 -0400)

add object_as_type helper for casting objects

When we call lookup_commit, lookup_tree, etc, the logic goes
something like:

1. Look for an existing object struct. If we don't have
one, allocate and return a new one.

2. Double check that any object we have is the expected
type (and complain and return NULL otherwise).

3. Convert an object with type OBJ_NONE (from a prior
call to lookup_unknown_object) to the expected type.

We can encapsulate steps 2 and 3 in a helper function which
checks whether we have the expected object type, converts
OBJ_NONE as appropriate, and returns the object.

Not only does this shorten the code, but it also provides
one central location for converting OBJ_NONE objects into
objects of other types. Future patches will use that to
enforce type-specific invariants.

Since this is a refactoring, we would want it to behave
exactly as the current code. It takes a little reasoning to
see that this is the case:

- for lookup_{commit,tree,etc} functions, we are just
pulling steps 2 and 3 into a function that does the same
thing.

- for the call in peel_object, we currently only do step 3
(but we want to consolidate it with the others, as
mentioned above). However, step 2 is a noop here, as the
surrounding conditional makes sure we have OBJ_NONE
(which we want to keep to avoid an extraneous call to
sha1_object_info).

- for the call in lookup_commit_reference_gently, we are
currently doing step 2 but not step 3. However, step 3
is a noop here. The object we got will have just come
from deref_tag, which must have figured out the type for
each object in order to know when to stop peeling.
Therefore the type will never be OBJ_NONE.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

parse_object_buffer: do not set object typeJeff King Sun, 13 Jul 2014 06:42:00 +0000 (02:42 -0400)

parse_object_buffer: do not set object type

The only way that "obj" can be non-NULL is if it came from
one of the lookup_* functions. These functions always ensure
that the object has the expected type (and return NULL
otherwise), so there is no need for us to set the type.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

move setting of object->type to alloc_* functionsJeff King Sun, 13 Jul 2014 06:41:55 +0000 (02:41 -0400)

move setting of object->type to alloc_* functions

The "struct object" type implements basic object
polymorphism. Individual instances are allocated as
concrete types (or as a union type that can store any
object), and a "struct object *" can be cast into its real
type after examining its "type" enum. This means it is
dangerous to have a type field that does not match the
allocation (e.g., setting the type field of a "struct blob"
to "OBJ_COMMIT" would mean that a reader might read past the
allocated memory).

In most of the current code this is not a problem; the first
thing we do after allocating an object is usually to set its
type field by passing it to create_object. However, the
virtual commits we create in merge-recursive.c do not ever
get their type set. This does not seem to have caused
problems in practice, though (presumably because we always
pass around a "struct commit" pointer and never even look at
the type).

We can fix this oversight and also make it harder for future
code to get it wrong by setting the type directly in the
object allocation functions.

This will also make it easier to fix problems with commit
index allocation, as we know that any object allocated by
alloc_commit_node will meet the invariant that an object
with an OBJ_COMMIT type field will have a unique index
number.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

alloc: write out allocator definitionsJeff King Sun, 13 Jul 2014 06:41:51 +0000 (02:41 -0400)

alloc: write out allocator definitions

Because the allocator functions for tree, blobs, etc are all
very similar, we originally used a macro to avoid repeating
ourselves. Since the prior commit, though, the heavy lifting
is done by an inline helper function. The macro does still
save us a few lines, but at some readability cost. It
obfuscates the function definitions (and makes them hard to
find via grep).

Much worse, though, is the fact that it isn't used
consistently for all allocators. Somebody coming later may
be tempted to modify DEFINE_ALLOCATOR, but they would miss
alloc_commit_node, which is treated specially.

Let's just drop the macro and write everything out
explicitly.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

alloc.c: remove the alloc_raw_commit_node() functionRamsay Jones Sun, 13 Jul 2014 06:41:41 +0000 (02:41 -0400)

alloc.c: remove the alloc_raw_commit_node() function

In order to encapsulate the setting of the unique commit index, commit
969eba63 ("commit: push commit_index update into alloc_commit_node",
10-06-2014) introduced a (logically private) intermediary allocator
function. However, this function (alloc_raw_commit_node()) was declared
as a public function, which undermines its entire purpose.

Introduce an inline function, alloc_node(), which implements the main
logic of the allocator used by DEFINE_ALLOCATOR, and redefine the macro
in terms of the new function. In addition, use the new function in the
implementation of the alloc_commit_node() allocator, rather than the
intermediary allocator, which can now be removed.

Noticed by sparse ("symbol 'alloc_raw_commit_node' was not declared.
Should it be static?").

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 2.0.3 v2.0.3Junio C Hamano Wed, 23 Jul 2014 18:33:16 +0000 (11:33 -0700)

Git 2.0.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>

.mailmap: combine Stefan Beller's emailsStefan Beller Wed, 23 Jul 2014 12:32:10 +0000 (14:32 +0200)

.mailmap: combine Stefan Beller's emails

Google mail has had the extension @googlemail.com for a long time
in Germany as @gmail.de was already taken by a competitor.
Nowadays the original gmail company isn't there anymore(?), hence
Googlemail also introduced @gmail.com in Germany, which I switched to.

This changed mail address of mine first appeared in 398dd4bd039680b
(2014-07-10, .mailmap: map different names with the same email
address together) ironically.

Signed-off-by: Stefan Beller <stefanbeller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git.1: switch homepage for statsStefan Beller Wed, 23 Jul 2014 12:32:09 +0000 (14:32 +0200)

git.1: switch homepage for stats

According to http://meta.ohloh.net/2014/07/black-duck-open-hub/
the site name of ohloh changed to openhub.

Change the man page accordingly.

Signed-off-by: Stefan Beller <stefanbeller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'ah/fix-http-push' into maintJunio C Hamano Tue, 22 Jul 2014 17:29:07 +0000 (10:29 -0700)

Merge branch 'ah/fix-http-push' into maint

* ah/fix-http-push:
http-push.c: make CURLOPT_IOCTLDATA a usable pointer

Merge branch 'po/error-message-style' into maintJunio C Hamano Tue, 22 Jul 2014 17:28:59 +0000 (10:28 -0700)

Merge branch 'po/error-message-style' into maint

* po/error-message-style:
doc: give some guidelines for error messages

Merge branch 'zk/log-graph-showsig' into maintJunio C Hamano Tue, 22 Jul 2014 17:28:51 +0000 (10:28 -0700)

Merge branch 'zk/log-graph-showsig' into maint

* zk/log-graph-showsig:
log: fix indentation for --graph --show-signature

Merge branch 'mg/fix-log-mergetag-color' into maintJunio C Hamano Tue, 22 Jul 2014 17:28:43 +0000 (10:28 -0700)

Merge branch 'mg/fix-log-mergetag-color' into maint

* mg/fix-log-mergetag-color:
log: correctly identify mergetag signature verification status

Merge branch 'cb/filter-branch-prune-empty-degenerate... Junio C Hamano Tue, 22 Jul 2014 17:28:30 +0000 (10:28 -0700)

Merge branch 'cb/filter-branch-prune-empty-degenerate-merges' into maint

* cb/filter-branch-prune-empty-degenerate-merges:
filter-branch: eliminate duplicate mapped parents

Merge branch 'ye/doc-http-proto' into maintJunio C Hamano Tue, 22 Jul 2014 17:28:02 +0000 (10:28 -0700)

Merge branch 'ye/doc-http-proto' into maint

* ye/doc-http-proto:
http-protocol.txt: Basic Auth is defined in RFC 2617, not RFC 2616

Merge branch 'jm/api-strbuf-doc' into maintJunio C Hamano Tue, 22 Jul 2014 17:26:52 +0000 (10:26 -0700)

Merge branch 'jm/api-strbuf-doc' into maint

* jm/api-strbuf-doc:
api-strbuf.txt minor typos

Merge branch 'jm/dedup-test-config' into maintJunio C Hamano Tue, 22 Jul 2014 17:26:45 +0000 (10:26 -0700)

Merge branch 'jm/dedup-test-config' into maint

* jm/dedup-test-config:
t/t7810-grep.sh: remove duplicate test_config()

Merge branch 'sk/test-cmp-bin' into maintJunio C Hamano Tue, 22 Jul 2014 17:26:34 +0000 (10:26 -0700)

Merge branch 'sk/test-cmp-bin' into maint

* sk/test-cmp-bin:
t5000, t5003: do not use test_cmp to compare binary files

Merge branch 'jm/doc-wording-tweaks' into maintJunio C Hamano Tue, 22 Jul 2014 17:26:17 +0000 (10:26 -0700)

Merge branch 'jm/doc-wording-tweaks' into maint

* jm/doc-wording-tweaks:
Documentation: wording fixes in the user manual and glossary

Merge branch 'jm/instaweb-apache-24' into maintJunio C Hamano Tue, 22 Jul 2014 17:25:24 +0000 (10:25 -0700)

Merge branch 'jm/instaweb-apache-24' into maint

* jm/instaweb-apache-24:
git-instaweb: add support for Apache 2.4

Merge branch 'bg/xcalloc-nmemb-then-size' into maintJunio C Hamano Tue, 22 Jul 2014 17:25:17 +0000 (10:25 -0700)

Merge branch 'bg/xcalloc-nmemb-then-size' into maint

* bg/xcalloc-nmemb-then-size:
transport-helper.c: rearrange xcalloc arguments
remote.c: rearrange xcalloc arguments
reflog-walk.c: rearrange xcalloc arguments
pack-revindex.c: rearrange xcalloc arguments
notes.c: rearrange xcalloc arguments
imap-send.c: rearrange xcalloc arguments
http-push.c: rearrange xcalloc arguments
diff.c: rearrange xcalloc arguments
config.c: rearrange xcalloc arguments
commit.c: rearrange xcalloc arguments
builtin/remote.c: rearrange xcalloc arguments
builtin/ls-remote.c: rearrange xcalloc arguments

Merge branch 'cb/byte-order' into maintJunio C Hamano Tue, 22 Jul 2014 17:25:02 +0000 (10:25 -0700)

Merge branch 'cb/byte-order' into maint

* cb/byte-order:
compat/bswap.h: fix endianness detection
compat/bswap.h: restore preference __BIG_ENDIAN over BIG_ENDIAN
compat/bswap.h: detect endianness on more platforms that don't use BYTE_ORDER

Merge branch 'lt/request-pull' into maintJunio C Hamano Tue, 22 Jul 2014 17:23:41 +0000 (10:23 -0700)

Merge branch 'lt/request-pull' into maint

* lt/request-pull:
fix brown paper bag breakage in t5150-request-pull.sh

Merge branch 'ep/shell-assign-and-export-vars' into... Junio C Hamano Tue, 22 Jul 2014 17:22:57 +0000 (10:22 -0700)

Merge branch 'ep/shell-assign-and-export-vars' into maint

* ep/shell-assign-and-export-vars:
scripts: more "export VAR=VALUE" fixes
scripts: "export VAR=VALUE" construct is not portable

Merge branch 'maint-1.9' into maintJunio C Hamano Tue, 22 Jul 2014 17:17:34 +0000 (10:17 -0700)

Merge branch 'maint-1.9' into maint

* maint-1.9:
Documentation: fix missing text for rev-parse --verify

Merge branch 'maint-1.8.5' into maint-1.9Junio C Hamano Tue, 22 Jul 2014 17:16:50 +0000 (10:16 -0700)

Merge branch 'maint-1.8.5' into maint-1.9

* maint-1.8.5:
Documentation: fix missing text for rev-parse --verify

Documentation: fix missing text for rev-parse --verifybrian m. carlson Mon, 21 Jul 2014 23:00:35 +0000 (23:00 +0000)

Documentation: fix missing text for rev-parse --verify

The caret (^) is used as a markup symbol in AsciiDoc. Due to the
inability of AsciiDoc to parse a line containing an unmatched caret, it
omitted the line from the output, resulting in the man page missing the
end of a sentence. Escape this caret so that the man page ends up with
the complete text.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use xmemdupz() to allocate copies of strings given... René Scharfe Sat, 19 Jul 2014 15:35:34 +0000 (17:35 +0200)

use xmemdupz() to allocate copies of strings given by start and length

Use xmemdupz() to allocate the memory, copy the data and make sure to
NUL-terminate the result, all in one step. The resulting code is
shorter, doesn't contain the constants 1 and '\0', and avoids
duplicating function parameters.

For blame, the last copied byte (o->file.ptr[o->file.size]) is always
set to NUL by fake_working_tree_commit() or read_sha1_file(), so no
information is lost by the conversion to using xmemdupz().

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use xcalloc() to allocate zero-initialized memoryRené Scharfe Sat, 19 Jul 2014 13:56:26 +0000 (15:56 +0200)

use xcalloc() to allocate zero-initialized memory

Use xcalloc() instead of xmalloc() followed by memset() to allocate
and zero out memory because it's shorter and avoids duplicating the
function parameters.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 2.0.2 v2.0.2Junio C Hamano Wed, 16 Jul 2014 18:19:56 +0000 (11:19 -0700)

Git 2.0.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'jc/fix-clone-single-starting-at-a-tag... Junio C Hamano Wed, 16 Jul 2014 18:17:36 +0000 (11:17 -0700)

Merge branch 'jc/fix-clone-single-starting-at-a-tag' into maint

"git clone -b brefs/tags/bar" would have mistakenly thought we were
following a single tag, even though it was a name of the branch,
because it incorrectly used strstr().

* jc/fix-clone-single-starting-at-a-tag:
builtin/clone.c: detect a clone starting at a tag correctly

Merge branch 'jk/pretty-G-format-fixes' into maintJunio C Hamano Wed, 16 Jul 2014 18:17:21 +0000 (11:17 -0700)

Merge branch 'jk/pretty-G-format-fixes' into maint

"%G" (nothing after G) is an invalid pretty format specifier, but
the parser did not notice it as garbage.

* jk/pretty-G-format-fixes:
move "%G" format test from t7510 to t6006
pretty: avoid reading past end-of-string with "%G"
t7510: check %G* pretty-format output
t7510: test a commit signed by an unknown key
t7510: use consistent &&-chains in loop
t7510: stop referring to master in later tests

Merge branch 'rs/fix-alt-odb-path-comparison' into... Junio C Hamano Wed, 16 Jul 2014 18:17:08 +0000 (11:17 -0700)

Merge branch 'rs/fix-alt-odb-path-comparison' into maint

Code to avoid adding the same alternate object store twice was
subtly broken for a long time, but nobody seems to have noticed.

* rs/fix-alt-odb-path-comparison:
sha1_file: avoid overrunning alternate object base string

Merge branch 'jk/commit-buffer-length' into maintJunio C Hamano Wed, 16 Jul 2014 18:16:38 +0000 (11:16 -0700)

Merge branch 'jk/commit-buffer-length' into maint

A handful of code paths had to read the commit object more than
once when showing header fields that are usually not parsed. The
internal data structure to keep track of the contents of the commit
object has been updated to reduce the need for this double-reading,
and to allow the caller find the length of the object.

* 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

Merge branch 'bc/fix-rebase-merge-skip' into maintJunio C Hamano Wed, 16 Jul 2014 18:16:16 +0000 (11:16 -0700)

Merge branch 'bc/fix-rebase-merge-skip' into maint

During "git rebase --merge", a conflicted patch could not be
skipped with "--skip" if the next one also conflicted.

* bc/fix-rebase-merge-skip:
rebase--merge: fix --skip with two conflicts in a row

Merge branch 'maint-1.9' into maintJunio C Hamano Wed, 16 Jul 2014 18:11:06 +0000 (11:11 -0700)

Merge branch 'maint-1.9' into maint

* maint-1.9:
annotate: use argv_array

Merge branch 'maint-1.8.5' into maint-1.9Junio C Hamano Wed, 16 Jul 2014 18:10:30 +0000 (11:10 -0700)

Merge branch 'maint-1.8.5' into maint-1.9

* maint-1.8.5:
annotate: use argv_array
t7300: repair filesystem permissions with test_when_finished
enums: remove trailing ',' after last item in enum

annotate: use argv_arrayRené Scharfe Wed, 16 Jul 2014 08:51:33 +0000 (10:51 +0200)

annotate: use argv_array

Simplify the code and get rid of some magic constants by using
argv_array to build the argument list for cmd_blame. Be lazy and let
the OS release our allocated memory, as before.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

http-push.c: make CURLOPT_IOCTLDATA a usable pointerAbbaad Haider Sun, 6 Jul 2014 00:43:48 +0000 (20:43 -0400)

http-push.c: make CURLOPT_IOCTLDATA a usable pointer

Fixes a small bug affecting push to remotes which use some sort of
multi-pass authentication. In particular the bug affected SabreDAV as
configured by Box.com [1].

It must be a weird server configuration for the bug to have survived
this long. Someone should write a test for it.

[1] http://marc.info/?l=git&m=140460482604482

Signed-off-by: Abbaad Haider <abbaad@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

log: correctly identify mergetag signature verification... Michael J Gruber Fri, 27 Jun 2014 13:18:36 +0000 (15:18 +0200)

log: correctly identify mergetag signature verification status

A wrong '}' made our code record the results of mergetag signature
verification incorrectly.

Fix it.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc: give some guidelines for error messagesPhilip Oakley Mon, 16 Jun 2014 12:55:57 +0000 (13:55 +0100)

doc: give some guidelines for error messages

Clarify error message puntuation to reduce review workload.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Start preparing for 2.0.2Junio C Hamano Thu, 10 Jul 2014 18:15:10 +0000 (11:15 -0700)

Start preparing for 2.0.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'pb/trim-trailing-spaces' into maintJunio C Hamano Thu, 10 Jul 2014 18:10:52 +0000 (11:10 -0700)

Merge branch 'pb/trim-trailing-spaces' into maint

* pb/trim-trailing-spaces:
t0008: do not depend on 'echo' handling backslashes specially
dir.c:trim_trailing_spaces(): fix for " \ " sequence

Merge branch 'jk/repack-pack-keep-objects' into maintJunio C Hamano Thu, 10 Jul 2014 18:10:05 +0000 (11:10 -0700)

Merge branch 'jk/repack-pack-keep-objects' into maint

* jk/repack-pack-keep-objects:
repack: s/write_bitmap/&s/ in code
repack: respect pack.writebitmaps
repack: do not accidentally pack kept objects by default

Merge branch 'mc/doc-submodule-sync-recurse' into maintJunio C Hamano Thu, 10 Jul 2014 18:08:31 +0000 (11:08 -0700)

Merge branch 'mc/doc-submodule-sync-recurse' into maint

* mc/doc-submodule-sync-recurse:
submodule: document "sync --recursive"

log: fix indentation for --graph --show-signatureZoltan Klinger Wed, 9 Jul 2014 02:10:21 +0000 (12:10 +1000)

log: fix indentation for --graph --show-signature

The git log --graph --show-signature command incorrectly indents the gpg
information about signed commits and merged signed tags. It does not
follow the level of indentation of the current commit.

Example of garbled output:
$ git log --show-signature --graph
* commit 258e0a237cb69aaa587b0a4fb528bb0316b1b776
|\ gpg: Signature made Mon, Jun 30, 2014 13:22:33 EDT using RSA key ID DA08
gpg: Good signature from "Jason Pyeron <jpye...@pdinc.us>"
Merge: 727c355 1ca13ed
| | Author: Jason Pyeron <jpye...@pdinc.us>
| | Date: Mon Jun 30 13:22:29 2014 -0400
| |
| | Merge of 1ca13ed2271d60ba9 branch - rebranding
| |
| * commit 1ca13ed2271d60ba93d40bcc8db17ced8545f172
| | gpg: Signature made Mon, Jun 23, 2014 9:45:47 EDT using RSA key ID DD37
gpg: Good signature from "Stephen Robert Guglielmo <s...@guglielmo.us>"
gpg: aka "Stephen Robert Guglielmo <srguglie...@gmail.com>"
Author: Stephen R Guglielmo <s...@guglielmo.us>
| | Date: Mon Jun 23 09:45:27 2014 -0400
| |
| | Minor URL updates

In log-tree.c modify show_sig_lines() function to call graph_show_oneline()
after each line of gpg information it has printed in order to preserve
the level of indentation for the next output line.

Reported-by: Jason Pyeron <jpyeron@pdinc.us>
Signed-off-by: Zoltan Klinger <zoltan.klinger@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'maint-1.8.5' into maintJunio C Hamano Wed, 2 Jul 2014 19:51:50 +0000 (12:51 -0700)

Merge branch 'maint-1.8.5' into maint

* maint-1.8.5:
t7300: repair filesystem permissions with test_when_finished
enums: remove trailing ',' after last item in enum

t7300: repair filesystem permissions with test_when_fin... Jeff King Wed, 2 Jul 2014 18:44:30 +0000 (14:44 -0400)

t7300: repair filesystem permissions with test_when_finished

We create a directory that cannot be removed, confirm that
it cannot be removed, and then fix it like:

chmod 0 foo &&
test_must_fail git clean -d -f &&
chmod 755 foo

If the middle step fails but leaves the directory (e.g., the
bug is that clean does not notice the failure), this
pollutes the test repo with an unremovable directory. Not
only does this cause further tests to fail, but it means
that "rm -rf" fails on the whole trash directory, and the
user has to intervene manually to even re-run the test script.

We can bump the "chmod 755" recovery to a test_when_finished
block to be sure that it always runs.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

enums: remove trailing ',' after last item in enumRonnie Sahlberg Wed, 2 Jul 2014 18:24:05 +0000 (11:24 -0700)

enums: remove trailing ',' after last item in enum

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file: avoid overrunning alternate object base... René Scharfe Tue, 1 Jul 2014 18:00:01 +0000 (20:00 +0200)

sha1_file: avoid overrunning alternate object base string

While checking if a new alternate object database is a duplicate make
sure that old and new base paths have the same length before comparing
them with memcmp. This avoids overrunning the buffer of the existing
entry if the new one is longer and it stops rejecting foobar/ after
foo/ was already added.

Signed-off-by: Rene Scharfe <ls.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

filter-branch: eliminate duplicate mapped parentsCharles Bailey Mon, 30 Jun 2014 21:20:27 +0000 (22:20 +0100)

filter-branch: eliminate duplicate mapped parents

When multiple parents of a merge commit get mapped to the same
commit, filter-branch used to pass all instances of the parent
commit to the parent and commit filters and to "git commit-tree" or
"git_commit_non_empty_tree".

This can often happen when extracting a small project from a large
repository; merges can join history with no commits on any branch
which affect the paths being retained. Once the intermediate
commits have been filtered out, all the immediate parents of the
merge commit can end up being mapped to the same commit - either the
original merge-base or an ancestor of it.

"git commit-tree" would display an error but write the commit with
the normalized parents in any case. "git_commit_non_empty_tree"
would fail to notice that the commit being made was in fact a
non-merge commit and would retain it even if a further pass with
"--prune-empty" would discard the commit as empty.

Ensure that duplicate parents are pruned before the parent filter to
make "--prune-empty" idempotent, removing all empty non-merge
commits in a singe pass.

Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

move "%G" format test from t7510 to t6006Jeff King Wed, 25 Jun 2014 21:42:17 +0000 (17:42 -0400)

move "%G" format test from t7510 to t6006

The final test in t7510 checks that "--format" placeholders
that look similar to GPG placeholders (but that we don't
actually understand) are passed through. That test was
placed in t7510, since the other GPG placeholder tests are
there. However, it does not have a GPG prerequisite, because
it is not actually checking any signed commits.

This causes the test to erroneously fail when gpg is not
installed on a system, however. Not because we need signed
commits, but because we need _any_ commit to run "git log".
If we don't have gpg installed, t7510 doesn't create any
commits at all.

We can fix this by moving the test into t6006. This is
arguably a better place anyway, because it is where we test
most of the other placeholders (we do not test GPG
placeholders there because of the infrastructure needed to
make signed commits).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 2.0.1 v2.0.1Junio C Hamano Wed, 25 Jun 2014 19:21:11 +0000 (12:21 -0700)

Git 2.0.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'na/no-http-test-in-the-middle' into maintJunio C Hamano Wed, 25 Jun 2014 18:50:13 +0000 (11:50 -0700)

Merge branch 'na/no-http-test-in-the-middle' into maint

The mode to run tests with HTTP server tests disabled was broken.

* na/no-http-test-in-the-middle:
t5538: move http push tests out to t5542

Merge branch 'jl/status-added-submodule-is-never-ignore... Junio C Hamano Wed, 25 Jun 2014 18:50:03 +0000 (11:50 -0700)

Merge branch 'jl/status-added-submodule-is-never-ignored' into maint

"git status" (and "git commit") behaved as if changes in a modified
submodule are not there if submodule.*.ignore configuration is set,
which was misleading. The configuration is only to unclutter diff
output during the course of development, and should not to hide
changes in the "status" output to cause the users forget to commit
them.

* jl/status-added-submodule-is-never-ignored:
commit -m: commit staged submodules regardless of ignore config
status/commit: show staged submodules regardless of ignore config

Merge branch 'ym/fix-opportunistic-index-update-race... Junio C Hamano Wed, 25 Jun 2014 18:49:48 +0000 (11:49 -0700)

Merge branch 'ym/fix-opportunistic-index-update-race' into maint

"git status", even though it is a read-only operation, tries to
update the index with refreshed lstat(2) info to optimize future
accesses to the working tree opportunistically, but this could
race with a "read-write" operation that modify the index while it
is running. Detect such a race and avoid overwriting the index.

* ym/fix-opportunistic-index-update-race:
read-cache.c: verify index file before we opportunistically update it
wrapper.c: add xpread() similar to xread()

Merge branch 'mk/show-s-no-extra-blank-line-for-merges... Junio C Hamano Wed, 25 Jun 2014 18:49:39 +0000 (11:49 -0700)

Merge branch 'mk/show-s-no-extra-blank-line-for-merges' into maint

"git show -s" (i.e. show log message only) used to incorrectly emit
an extra blank line after a merge commit.

* mk/show-s-no-extra-blank-line-for-merges:
git-show: fix 'git show -s' to not add extra terminator after merge commit

Merge branch 'rr/rebase-autostash-fix' into maintJunio C Hamano Wed, 25 Jun 2014 18:49:31 +0000 (11:49 -0700)

Merge branch 'rr/rebase-autostash-fix' into maint

The autostash mode of "git rebase -i" did not restore the dirty
working tree state if the user aborted the interactive rebase by
emptying the insn sheet.

* rr/rebase-autostash-fix:
rebase -i: test "Nothing to do" case with autostash
rebase -i: handle "Nothing to do" case with autostash

Merge branch 'jc/shortlog-ref-exclude' into maintJunio C Hamano Wed, 25 Jun 2014 18:49:10 +0000 (11:49 -0700)

Merge branch 'jc/shortlog-ref-exclude' into maint

"git log --exclude=<glob> --all | git shortlog" worked as expected,
but "git shortlog --exclude=<glob> --all", which is supposed to be
identical to the above pipeline, was not accepted at the command
line argument parser level.

* jc/shortlog-ref-exclude:
shortlog: allow --exclude=<glob> to be passed

Merge branch 'jl/remote-rm-prune' into maintJunio C Hamano Wed, 25 Jun 2014 18:49:01 +0000 (11:49 -0700)

Merge branch 'jl/remote-rm-prune' into maint

"git remote rm" and "git remote prune" can involve removing many
refs at once, which is not a very efficient thing to do when very
many refs exist in the packed-refs file.

* jl/remote-rm-prune:
remote prune: optimize "dangling symref" check/warning
remote: repack packed-refs once when deleting multiple refs
remote rm: delete remote configuration as the last

Merge branch 'fc/rerere-conflict-style' into maintJunio C Hamano Wed, 25 Jun 2014 18:48:54 +0000 (11:48 -0700)

Merge branch 'fc/rerere-conflict-style' into maint

"git rerere forget" did not work well when merge.conflictstyle
was set to a non-default value.

* fc/rerere-conflict-style:
rerere: fix for merge.conflictstyle

Merge branch 'rs/pack-objects-no-unnecessary-realloc... Junio C Hamano Wed, 25 Jun 2014 18:48:42 +0000 (11:48 -0700)

Merge branch 'rs/pack-objects-no-unnecessary-realloc' into maint

"git pack-objects" unnecessarily copied the previous contents when
extending the hashtable, even though it will populate the table
from scratch anyway.

* rs/pack-objects-no-unnecessary-realloc:
pack-objects: use free()+xcalloc() instead of xrealloc()+memset()

Merge branch 'dt/merge-recursive-case-insensitive'... Junio C Hamano Wed, 25 Jun 2014 18:48:34 +0000 (11:48 -0700)

Merge branch 'dt/merge-recursive-case-insensitive' into maint

On a case insensitive filesystem, merge-recursive incorrectly
deleted the file that is to be renamed to a name that is the same
except for case differences.

* dt/merge-recursive-case-insensitive:
mv: allow renaming to fix case on case insensitive filesystems
merge-recursive.c: fix case-changing merge bug

Merge branch 'rs/mailinfo-header-cmp' into maintJunio C Hamano Wed, 25 Jun 2014 18:48:23 +0000 (11:48 -0700)

Merge branch 'rs/mailinfo-header-cmp' into maint

"git mailinfo" used to read beyond the end of header string while
parsing an incoming e-mail message to extract the patch.

* rs/mailinfo-header-cmp:
mailinfo: use strcmp() for string comparison

Merge branch 'jk/index-pack-report-missing' into maintJunio C Hamano Wed, 25 Jun 2014 18:48:13 +0000 (11:48 -0700)

Merge branch 'jk/index-pack-report-missing' into maint

The error reporting from "git index-pack" has been improved to
distinguish missing objects from type errors.

* jk/index-pack-report-missing:
index-pack: distinguish missing objects from type errors

Merge branch 'nd/index-pack-one-fd-per-thread' into... Junio C Hamano Wed, 25 Jun 2014 18:47:58 +0000 (11:47 -0700)

Merge branch 'nd/index-pack-one-fd-per-thread' into maint

We used to disable threaded "git index-pack" on platforms without
thread-safe pread(); use a different workaround for such
platforms to allow threaded "git index-pack".

* nd/index-pack-one-fd-per-thread:
index-pack: work around thread-unsafe pread()

Merge branch 'sk/spawn-less-case-insensitively-from... Junio C Hamano Wed, 25 Jun 2014 18:47:49 +0000 (11:47 -0700)

Merge branch 'sk/spawn-less-case-insensitively-from-grep-O-i' into maint

"git grep -O" to show the lines that hit in the pager did not work
well with case insensitive search. We now spawn "less" with its
"-I" option when it is used as the pager (which is the default).

* sk/spawn-less-case-insensitively-from-grep-O-i:
git grep -O -i: if the pager is 'less', pass the '-I' option

Merge branch 'nd/daemonize-gc' into maintJunio C Hamano Wed, 25 Jun 2014 18:47:36 +0000 (11:47 -0700)

Merge branch 'nd/daemonize-gc' into maint

"git gc --auto" was recently changed to run in the background to
give control back early to the end-user sitting in front of the
terminal, but it forgot that housekeeping involving reflogs should
be done without other processes competing for accesses to the refs.

* nd/daemonize-gc:
gc --auto: do not lock refs in the background

Merge branch 'jk/diff-follow-must-take-one-pathspec... Junio C Hamano Wed, 25 Jun 2014 18:47:23 +0000 (11:47 -0700)

Merge branch 'jk/diff-follow-must-take-one-pathspec' into maint

"git format-patch" did not enforce the rule that the "--follow"
option from the log/diff family of commands must be used with
exactly one pathspec.

* jk/diff-follow-must-take-one-pathspec:
move "--follow needs one pathspec" rule to diff_setup_done

Merge branch 'jk/diff-files-assume-unchanged' into... Junio C Hamano Wed, 25 Jun 2014 18:47:09 +0000 (11:47 -0700)

Merge branch 'jk/diff-files-assume-unchanged' into maint

"git diff --find-copies-harder" sometimes pretended as if the mode
bits have changed for paths that are marked with assume-unchanged
bit.

* jk/diff-files-assume-unchanged:
run_diff_files: do not look at uninitialized stat data

Merge branch 'jk/commit-C-pick-empty' into maintJunio C Hamano Wed, 25 Jun 2014 18:46:54 +0000 (11:46 -0700)

Merge branch 'jk/commit-C-pick-empty' into maint

"git commit --allow-empty-message -C $commit" did not work when the
commit did not have any log message.

* jk/commit-C-pick-empty:
commit: do not complain of empty messages from -C

Merge branch 'bc/blame-crlf-test' into maintJunio C Hamano Wed, 25 Jun 2014 18:46:44 +0000 (11:46 -0700)

Merge branch 'bc/blame-crlf-test' into maint

"git blame" assigned the blame to the copy in the working-tree if
the repository is set to core.autocrlf=input and the file used CRLF
line endings.

* bc/blame-crlf-test:
blame: correctly handle files regardless of autocrlf

Merge branch 'jx/blame-align-relative-time' into maintJunio C Hamano Wed, 25 Jun 2014 18:46:34 +0000 (11:46 -0700)

Merge branch 'jx/blame-align-relative-time' into maint

"git blame" miscounted number of columns needed to show localized
timestamps, resulting in jaggy left-side-edge of the source code
lines in its output.

* jx/blame-align-relative-time:
blame: dynamic blame_date_width for different locales
blame: fix broken time_buf paddings in relative timestamp

Merge branch 'jc/apply-ignore-whitespace' into maintJunio C Hamano Wed, 25 Jun 2014 18:46:23 +0000 (11:46 -0700)

Merge branch 'jc/apply-ignore-whitespace' into maint

"--ignore-space-change" option of "git apply" ignored the spaces
at the beginning of line too aggressively, which is inconsistent
with the option of the same name "diff" and "git diff" have.

* jc/apply-ignore-whitespace:
apply --ignore-space-change: lines with and without leading whitespaces do not match

Merge branch 'jk/complete-merge-pull' into maintJunio C Hamano Wed, 25 Jun 2014 18:46:12 +0000 (11:46 -0700)

Merge branch 'jk/complete-merge-pull' into maint

The completion scripts (in contrib/) did not know about quite a few
options that are common between "git merge" and "git pull", and a
couple of options unique to "git merge".

* jk/complete-merge-pull:
completion: add missing options for git-merge
completion: add a note that merge options are shared

Merge branch 'ow/config-mailmap-pathname' into maintJunio C Hamano Wed, 25 Jun 2014 18:45:55 +0000 (11:45 -0700)

Merge branch 'ow/config-mailmap-pathname' into maint

The "mailmap.file" configuration option did not support the tilde
expansion (i.e. ~user/path and ~/path).

* ow/config-mailmap-pathname:
config: respect '~' and '~user' in mailmap.file

Merge branch 'as/pretty-truncate' into maintJunio C Hamano Wed, 25 Jun 2014 18:45:31 +0000 (11:45 -0700)

Merge branch 'as/pretty-truncate' into maint

The "%<(10,trunc)%s" pretty format specifier in the log family of
commands is used to truncate the string to a given length (e.g. 10
in the example) with padding to column-align the output, but did
not take into account that number of bytes and number of display
columns are different.

* as/pretty-truncate:
pretty.c: format string with truncate respects logOutputEncoding
t4205, t6006: add tests that fail with i18n.logOutputEncoding set
t4205 (log-pretty-format): use `tformat` rather than `format`
t4041, t4205, t6006, t7102: don't hardcode tested encoding value
t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs

Merge branch 'jc/revision-dash-count-parsing' into... Junio C Hamano Wed, 25 Jun 2014 18:44:53 +0000 (11:44 -0700)

Merge branch 'jc/revision-dash-count-parsing' into maint

"git log -2master" is a common typo that shows two commits starting
from whichever random branch that is not 'master' that happens to
be checked out currently.

* jc/revision-dash-count-parsing:
revision: parse "git log -<count>" more carefully

Merge branch 'jk/report-fail-to-read-objects-better... Junio C Hamano Wed, 25 Jun 2014 18:43:57 +0000 (11:43 -0700)

Merge branch 'jk/report-fail-to-read-objects-better' into maint

Reworded the error message given upon a failure to open an existing
loose object file due to e.g. permission issues; it was reported as
the object being corrupt, but that is not quite true.

* jk/report-fail-to-read-objects-better:
open_sha1_file: report "most interesting" errno

Merge branch 'mn/sideband-no-ansi' into maintJunio C Hamano Wed, 25 Jun 2014 18:43:43 +0000 (11:43 -0700)

Merge branch 'mn/sideband-no-ansi' into maint

Tools that read diagnostic output in our standard error stream do
not want to see terminal control sequence (e.g. erase-to-eol).
Detect them by checking if the standard error stream is connected
to a tty.

* mn/sideband-no-ansi:
sideband.c: do not use ANSI control sequence on non-terminal

Merge branch 'je/pager-do-not-recurse' into maintJunio C Hamano Wed, 25 Jun 2014 18:43:07 +0000 (11:43 -0700)

Merge branch 'je/pager-do-not-recurse' into maint

We used to unconditionally disable the pager in the pager process
we spawn to feed out output, but that prevented people who want to
run "less" within "less" from doing so.

* je/pager-do-not-recurse:
pager: do allow spawning pager recursively

builtin/clone.c: detect a clone starting at a tag correctlyJunio C Hamano Mon, 23 Jun 2014 21:27:36 +0000 (14:27 -0700)

builtin/clone.c: detect a clone starting at a tag correctly

31b808a0 (clone --single: limit the fetch refspec to fetched branch,
2012-09-20) tried to see if the given "branch" to follow is actually
a tag at the remote repository by checking with "refs/tags/" but it
incorrectly used strstr(3); it is actively wrong to treat a "branch"
"refs/heads/refs/tags/foo" and use the logic for the "refs/tags/"
ref hierarchy. What the code really wanted to do is to see if it
starts with "refs/tags/".

Signed-off-by: Junio C Hamano <gitster@pobox.com>

pretty: avoid reading past end-of-string with "%G"Jeff King Tue, 17 Jun 2014 00:07:07 +0000 (20:07 -0400)

pretty: avoid reading past end-of-string with "%G"

If the user asks for --format=%G with nothing else, we
correctly realize that "%G" is not a valid placeholder (it
should be "%G?", "%GK", etc). But we still tell the
strbuf_expand code that we consumed 2 characters, causing it
to jump over the trailing NUL and output garbage.

This also fixes the case where "%GX" would be consumed (and
produce no output). In other cases, we pass unrecognized
placeholders through to the final string.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7510: check %G* pretty-format outputJeff King Tue, 17 Jun 2014 00:06:24 +0000 (20:06 -0400)

t7510: check %G* pretty-format output

We do not check these along with the other pretty-format
placeholders in t6006, because we need signed commits to
make them interesting. t7510 has such commits, and can
easily exercise them in addition to the regular
--show-signature code path.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7510: test a commit signed by an unknown keyJeff King Tue, 17 Jun 2014 00:05:54 +0000 (20:05 -0400)

t7510: test a commit signed by an unknown key

We tested both good and bad signatures, but not ones made
correctly but with a key for which we have no trust.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7510: use consistent &&-chains in loopMichael J Gruber Tue, 17 Jun 2014 00:03:43 +0000 (20:03 -0400)

t7510: use consistent &&-chains in loop

We check multiple commits in a loop. Because we want to
break out of the loop if any single iteration fails, we use
a subshell/exit like:

(
for i in $stuff
do
do-something $i || exit 1
done
)

However, we are inconsistent in our loop body. Some commands
get their own "|| exit 1", and others try to chain to the
next command with "&&", like:

X &&
Y || exit 1
Z || exit 1

This is a little hard to read and follow, because X and Y
are treated differently for no good reason. But much worse,
the second loop follows a similar pattern and gets it wrong.
"Y" is expected to fail, so we use "&& exit 1", giving us:

X &&
Y && exit 1
Z || exit 1

That gets the test for X wrong (we do not exit unless both X
fails and Y unexpectedly succeeds, but we would want to exit
if _either_ is wrong). We can write this clearly and
correctly by consistently using "&&", followed by a single
"|| exit 1", and negating Y with "!" (as we would in a
normal &&-chain). Like:

X &&
! Y &&
Z || exit 1

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7510: stop referring to master in later testsJeff King Mon, 16 Jun 2014 23:59:59 +0000 (19:59 -0400)

t7510: stop referring to master in later tests

Our setup creates a sequence of commits, each with its own
tag. However, we sometimes refer to "seventh-signed" as
"master". This works, since it is at the tip of the created
branch, but is brittle if new tests need to add more
commits. Let's use its tag name to be unambiguous.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase--merge: fix --skip with two conflicts in a rowbrian m. carlson Mon, 16 Jun 2014 00:01:25 +0000 (00:01 +0000)

rebase--merge: fix --skip with two conflicts in a row

If git rebase --merge encountered a conflict, --skip would not work if the
next commit also conflicted. The msgnum file would never be updated with
the new patch number, so no patch would actually be skipped, resulting in an
inescapable loop.

Update the msgnum file's value as the first thing in call_merge. This also
avoids an "Already applied" message when skipping a commit. There is no
visible change for the other contexts in which call_merge is invoked, as the
msgnum file's value remains unchanged in those situations.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

http-protocol.txt: Basic Auth is defined in RFC 2617... Yi EungJun Sat, 14 Jun 2014 19:09:29 +0000 (04:09 +0900)

http-protocol.txt: Basic Auth is defined in RFC 2617, not RFC 2616

Signed-off-by: Yi EungJun <eungjun.yi@navercorp.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: document "sync --recursive"Matthew Chen Fri, 13 Jun 2014 17:40:50 +0000 (13:40 -0400)

submodule: document "sync --recursive"

The "git submodule sync" command supports the --recursive flag, but
the documentation does not mention this. That flag is useful, for
example when a remote is changed in a submodule of a submodule.

Signed-off-by: Matthew Chen <charlesmchen@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t0008: do not depend on 'echo' handling backslashes... Junio C Hamano Fri, 13 Jun 2014 20:23:58 +0000 (13:23 -0700)

t0008: do not depend on 'echo' handling backslashes specially

The original used to pass with /bin/dash but not with /bin/bash set
to $SHELL_PATH. The former turns "\\" into "\", but the latter does
not.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

reuse cached commit buffer when parsing signaturesJeff King Fri, 13 Jun 2014 06:32:11 +0000 (02:32 -0400)

reuse cached commit buffer when parsing signatures

When we call show_signature or show_mergetag, we read the
commit object fresh via read_sha1_file and reparse its
headers. However, in most cases we already have the object
data available, attached to the "struct commit". This is
partially laziness in dealing with the memory allocation
issues, but partially defensive programming, in that we
would always want to verify a clean version of the buffer
(not one that might have been munged by other users of the
commit).

However, we do not currently ever munge the commit buffer,
and not using the already-available buffer carries a fairly
big performance penalty when we are looking at a large
number of commits. Here are timings on linux.git:

[baseline, no signatures]
$ time git log >/dev/null
real 0m4.902s
user 0m4.784s
sys 0m0.120s

[before]
$ time git log --show-signature >/dev/null
real 0m14.735s
user 0m9.964s
sys 0m0.944s

[after]
$ time git log --show-signature >/dev/null
real 0m9.981s
user 0m5.260s
sys 0m0.936s

Note that our user CPU time drops almost in half, close to
the non-signature case, but we do still spend more
wall-clock and system time, presumably from dealing with
gpg.

An alternative to this is to note that most commits do not
have signatures (less than 1% in this repo), yet we pay the
re-parsing cost for every commit just to find out if it has
a mergetag or signature. If we checked that when parsing the
commit initially, we could avoid re-examining most commits
later on. Even if we did pursue that direction, however,
this would still speed up the cases where we _do_ have
signatures. So it's probably worth doing either way.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit: record buffer length in cacheJeff King Tue, 10 Jun 2014 21:44:13 +0000 (17:44 -0400)

commit: record buffer length in cache

Most callsites which use the commit buffer try to use the
cached version attached to the commit, rather than
re-reading from disk. Unfortunately, that interface provides
only a pointer to the NUL-terminated buffer, with no
indication of the original length.

For the most part, this doesn't matter. People do not put
NULs in their commit messages, and the log code is happy to
treat it all as a NUL-terminated string. However, some code
paths do care. For example, when checking signatures, we
want to be very careful that we verify all the bytes to
avoid malicious trickery.

This patch just adds an optional "size" out-pointer to
get_commit_buffer and friends. The existing callers all pass
NULL (there did not seem to be any obvious sites where we
could avoid an immediate strlen() call, though perhaps with
some further refactoring we could).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit: convert commit->buffer to a slabJeff King Tue, 10 Jun 2014 21:43:02 +0000 (17:43 -0400)

commit: convert commit->buffer to a slab

This will make it easier to manage the buffer cache
independently of the "struct commit" objects. It also
shrinks "struct commit" by one pointer, which may be
helpful.

Unfortunately it does not reduce the max memory size of
something like "rev-list", because rev-list uses
get_cached_commit_buffer() to decide not to show each
commit's output (and due to the design of slab_at, accessing
the slab requires us to extend it, allocating exactly the
same number of buffer pointers we dropped from the commit
structs).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit-slab: provide a static initializerJeff King Tue, 10 Jun 2014 21:42:51 +0000 (17:42 -0400)

commit-slab: provide a static initializer

Callers currently must use init_foo_slab() at runtime before
accessing a slab. For global slabs, it's much nicer if we
can initialize them in BSS, so that each user does not have
to add code to check-and-initialize.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use get_commit_buffer everywhereJeff King Tue, 10 Jun 2014 21:41:51 +0000 (17:41 -0400)

use get_commit_buffer everywhere

Each of these sites assumes that commit->buffer is valid.
Since they would segfault if this was not the case, they are
likely to be correct in practice. However, we can
future-proof them by using get_commit_buffer.

And as a side effect, we abstract away the final bare uses
of commit->buffer.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert logmsg_reencode to get_commit_bufferJeff King Tue, 10 Jun 2014 21:41:39 +0000 (17:41 -0400)

convert logmsg_reencode to get_commit_buffer

Like the callsites in the previous commit, logmsg_reencode
already falls back to read_sha1_file when necessary.
However, I split its conversion out into its own commit
because it's a bit more complex.

We return either:

1. The original commit->buffer

2. A newly allocated buffer from read_sha1_file

3. A reencoded buffer (based on either 1 or 2 above).

while trying to do as few extra reads/allocations as
possible. Callers currently free the result with
logmsg_free, but we can simplify this by pointing them
straight to unuse_commit_buffer. This is a slight layering
violation, in that we may be passing a buffer from (3).
However, since the end result is to free() anything except
(1), which is unlikely to change, and because this makes the
interface much simpler, it's a reasonable bending of the
rules.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use get_commit_buffer to avoid duplicate codeJeff King Tue, 10 Jun 2014 21:41:02 +0000 (17:41 -0400)

use get_commit_buffer to avoid duplicate code

For both of these sites, we already do the "fallback to
read_sha1_file" trick. But we can shorten the code by just
using get_commit_buffer.

Note that the error cases are slightly different when
read_sha1_file fails. get_commit_buffer will die() if the
object cannot be loaded, or is a non-commit.

For get_sha1_oneline, this will almost certainly never
happen, as we will have just called parse_object (and if it
does, it's probably worth complaining about).

For record_author_date, the new behavior is probably better;
we notify the user of the error instead of silently ignoring
it. And because it's used only for sorting by author-date,
somebody examining a corrupt repo can fallback to the
regular traversal order.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use get_cached_commit_buffer where appropriateJeff King Tue, 10 Jun 2014 21:40:46 +0000 (17:40 -0400)

use get_cached_commit_buffer where appropriate

Some call sites check commit->buffer to see whether we have
a cached buffer, and if so, do some work with it. In the
long run we may want to switch these code paths to make
their decision on a different boolean flag (because checking
the cache may get a little more expensive in the future).
But for now, we can easily support them by converting the
calls to use get_cached_commit_buffer.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

provide helpers to access the commit bufferJeff King Tue, 10 Jun 2014 21:40:39 +0000 (17:40 -0400)

provide helpers to access the commit buffer

Many sites look at commit->buffer to get more detailed
information than what is in the parsed commit struct.
However, we sometimes drop commit->buffer to save memory,
in which case the caller would need to read the object
afresh. Some callers do this (leading to duplicated code),
and others do not (which opens the possibility of a segfault
if somebody else frees the buffer).

Let's provide a pair of helpers, "get" and "unuse", that let
callers easily get the buffer. They will use the cached
buffer when possible, and otherwise load from disk using
read_sha1_file.

Note that we also need to add a "get_cached" variant which
returns NULL when we do not have a cached buffer. At first
glance this seems to defeat the purpose of "get", which is
to always provide a return value. However, some log code
paths actually use the NULL-ness of commit->buffer as a
boolean flag to decide whether to try printing the
commit. At least for now, we want to continue supporting
that use.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>