send-email: don't call methods on undefined values

If SSL verification is enabled in git send-email, we could attempt to call a
method on an undefined value if the verification failed, since $smtp would end
up being undef.  Look up the error string in a way that will produce a helpful
error message and not cause further errors.

Signed-off-by: Brian M. Carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reset: handle submodule with trailing slash

When using tab-completion, a directory path will often end with a
trailing slash which currently confuses "git reset" when dealing with
submodules.  Now that we have parse_pathspec we can easily handle this
by simply adding the PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP flag.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
rm: re-use parse_pathspec's trailing-slash removal

Instead of re-implementing the "remove trailing slashes" loop in
builtin/rm.c just pass PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP to
parse_pathspec.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
show-index: index v3 support

There is no more SHA1 table in the index v3 as pack v4 already carries
it.  So the best we can do here is to display the object position in
place of its SHA1.

Relevance of this tool may be questioned at this point since verify-pack
may provide the complete information.  That's a separate matter though.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
packv4-create: normalize pack name to properly generate the pack index file name

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
packv4-create: add progress display

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: initial pack index v3 support on the read side

A bit crud but good enough for now.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: object header decode

For this we need the pack version.  However only open_packed_git_1() has
been audited for pack v4 so far, hence the version validation is not
added to pack_version_ok() just yet.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: code to obtain a SHA1 from a sha1ref

Let's start actually parsing pack v4 data.  Here's the first item.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: code to load and prepare a pack dictionary table for use

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: code to retrieve an ident entry

The ident dictionary is loaded if not already done.  We know it is
located right after the SHA1 table (20 bytes per object) which is
itself right after the 12-byte header.

Then the ident index is parsed from the input buffer and a pointer to the
corresponding entry is returned.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: code to recreate a canonical commit object

Usage of snprintf() is possibly not the most efficient approach.
For example we could simply copy the needed strings and generate
the SHA1 hex strings directly into the destination buffer.  But
such optimizations may come later.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
sha1_file.c: make use of decode_varint()

... replacing the equivalent open coded loop.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: parse delta base reference

There is only one type of delta with pack v4.  The base reference
encoding already handles either an offset (via the pack index) or a
literal SHA1.

We assume in the literal SHA1 case that the object lives in the same
pack, just like with previous pack versions.

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

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
pack v4: code to retrieve a path component

Because the path dictionary table is located right after the ident
dictionary table, we currently need to load the later to find the
former.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
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>