Fix a number of git_odb_exists_prefix bugs

The git_odb_exists_prefix API was not dealing correctly when a
later backend returned GIT_ENOTFOUND even if an earlier backend
had found the object.

Additionally, the unit tests were not properly exercising the API
and had a couple mistakes in checking the results.

Lastly, since the backends are not expected to behavior correctly
unless all bytes of the short id are zero except for the prefix,
this makes the ODB prefix APIs explicitly clear out the extra
bytes so the user doesn't have to be as careful.
Add failing test for git_object_short_id
In-memory packing backend
Retry renaming files on Access Denied errors

When a file is open for reading (without shared-delete permission), and
then a different thread/process called p_rename, that would fail, even
if the file was only open for reading for a few milliseconds. This
change lets p_rename wait up to 50ms for the file to be closed by the
reader. Applies only to win32.

This is especially important for git_filebuf_commit, because writes
should not fail if the file is read simultaneously.

Fixes #2207
Add faster git_submodule__is_submodule check
Fix submodule sorting in workdir iterator

With the changes to how git_path_dirload_with_stat handles things
that look like submodules, submodules could end up sorted in the
wrong order with the workdir iterator.  This moves the submodule
check earlier in the iterator processing of a new directory so
that the submodule name updates will happen immediately and the
sort order will be correct.
Cleanups
Improve test of submodule name sorting
No need to find merge base.
Merge pull request #2178 from libgit2/rb/fix-short-id

Fix git_odb_short_id and git_odb_exists_prefix bugs
examples: Use git_object_short_id
remote: rename inmemory to anonymous and swap url and fetch order

The order in this function is the opposite to what
create_with_fetchspec() has, so change this one, as url-then-refspec is
what git does.

As we need to break compilation and the swap doesn't do that, let's take
this opportunity to rename in-memory remotes to anonymous as that's
really what sets them apart.
Merge pull request #2206 from libgit2/cmn/inmemory-swap-order

Rename in-memory remote to anonymous and swap url and fetch order
Merge pull request #2228 from mekishizufu/example_short_id

Use git_object_short_id in examples
Add CFLAGS -Wdeclaration-after-statement

This warns local variables declarations after statement, which helps not to break MSVC
Merge pull request #2229 from linquize/Wdeclaration-after-statement

Add CFLAGS -Wdeclaration-after-statement
Merge pull request #2226 from libgit2/rb/submodule-sorting-fix

Fix submodule sort order during iteration
Merge pull request #2208 from libgit2/vmg/mempack

In-memory packing backend
Add efficient git_buf join3 API

There are a few places where we need to join three strings to
assemble a path.  This adds a simple join3 function to avoid the
comparatively expensive join_n (which calls strlen on each string
twice).
Fix git_submodule_sync and add new config helper

This fixes `git_submodule_sync` to correctly update the remote URL
of the default branch of the submodule along with the URL in the
parent repository config (i.e. match core Git's behavior).

Also move some useful helper logic from the submodule code into
a shared config API `git_config__update_entry` that can either set
or delete an entry with constraints like not overwriting or not
creating a new entry.  I used that helper to update a couple other
places in the code.