mailmap: work around implementations with pure inline strcasecmp

On some systems (e.g. MinGW 4.0), string.h has only inline
definition of strcasecmp and no non-inline implementation is
supplied anywhere, which is, eh, "unusual".  We cannot take an
address of such a function to store it in namemap.cmp.

Work it around by introducing our own level of indirection.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack v4: decode tree objects

For now we recreate the whole tree object in its canonical form.

Eventually, the core code should grow some ability to walk packv4 tree
entries directly which would be way more efficient.  Not only would that
avoid double tree entry parsing, but the pack v4 encoding allows for
getting at child objects without going through the SHA1 search.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: we can read tree objects now

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
packv4-create: add a command line argument to limit tree copy sequences

Because there is no delta object cache for tree objects yet, walking
tree entries may result in a lot of recursion.

Let's add --min-tree-copy=N where N is the minimum number of copied
entries in a single copy sequence allowed for encoding tree deltas.
The default is 1. Specifying 0 disables tree deltas entirely.

This allows for experiments with the delta width and see the influence
on pack size vs runtime access cost.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: allow canonical commit and tree objects

If for some reason we can't transcode a commit or tree object (lossy
encoding such as the zero-padded file mode for example) then we can still
store the canonical object like in pack v2.

This is also useful for completing a thin pack without having to add
missing entries to the dictionary tables.

To simplify things, the canonical commit and tree types retain their type
number 1 and 2 respectively, and the transcoded types are now 9 and 10
i.e. with bit 3 added.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Document pack v4 format

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>

[np: added some precisions on thin pack, new object types, etc.]
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
packv4-parse.c: get rid of snprintf()

Profiling 'git rev-list --all --objects' shows snprintf() related
functions topping the total execution time chart.

Let's replace that with specialized string generation functions.
This reduced the total runtime by a wopping 40% on a Core2 processor.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
packv4-parse.c: allow tree entry copying from a canonical tree object

It is possible for a base tree object to be in the canonical
representation.  This may happen if the encoder detected an irregularity
preventing a loss free encoding to the pack v4 format, or if a thin pack
was completed with such tree objects.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: allocate dicts from the beginning

commit_ident_table and tree_path_table are local to packv4-create.c
and test-packv4.c. Move them out of add_*_dict_entries so
add_*_dict_entries can be exported to pack-objects.c

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: stop using static/global variables in packv4-create.c

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: move packv4-create.c to libgit.a

git-packv4-create now becomes test-packv4. Code that will not be used
by pack-objects.c is moved to test-packv4.c. It may be removed when
the code transition to pack-objects completes.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: split pv4_create_dict() out of load_dict()

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: add pv4_free_dict()

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: avoid strlen() in tree_entry_prefix

We do know the length of the path name of an tree entry from the tree
dictionary. On an unoptimized build, this cuts down "git rev-list
--objects v1.8.4"'s time from 6.2s to 5.8s. This difference is less on
optimized builds.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
index-pack: add more comments on some big functions

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
index-pack: split out varint decoding code

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
index-pack: do not allocate buffer for unpacking deltas in the first pass

We do need deltas until the second pass. Allocating a buffer for it
then freeing later is wasteful is unnecessary. Make it use fixed_buf
(aka large blob code path).

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
index-pack: split inflate/digest code out of unpack_entry_data

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
index-pack: parse v4 header and dictionaries

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
index-pack: make sure all objects are registered in v4's SHA-1 table

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>