test asserting checkout should not recreate deleted files
Fix checkout of modified file when missing from wd

This fixes the checkout case when a file is modified between the
baseline and the target and yet missing in the working directory.
The logic for that case appears to have been wrong.

This also adds a useful checkout notify callback to the checkout
test helpers that will count notifications and also has a debug
mode to visualize what checkout thinks that it's doing.
Merge pull request #1664 from arrbee/checkout-deleted-with-fix

Checkout should not recreate deleted files - with fix
Add target directory to checkout

This adds the ability for checkout to write to a target directory
instead of having to use the working directory of the repository.
This makes it easier to do exports of repository data and the like.

This is similar to, but not quite the same as, the --prefix option
to `git checkout-index` (this will always be treated as a directory
name, not just as a simple text prefix).

As part of this, the workdir iterator was extended to take the
path to the working directory as a parameter and fallback on the
git_repository_workdir result only if it's not specified.

Fixes #1332
Loosen ensure_not_bare rules in checkout

With the new target directory option to checkout, the non-bareness
of the repository should be checked much later in the parameter
validation process - actually that check was already in place, but
I was doing it redundantly in the checkout APIs.

This removes the now unnecessary early check for bare repos.  It
also adds some other parameter validation and makes it so that
implied parameters can actually be passed as NULL (i.e. if you
pass a git_index, you don't have to pass the git_repository - we
can get it from index).
Addition checkout target directory tests

This adds additonal tests of the checkout target directory option
including using it to dump data from bare repos.
Merge pull request #1665 from arrbee/checkout-target-directory

Add target directory to checkout options
Do not redefine WC_ERR_INVALID_CHARS

WC_ERR_INVALID_CHARS might be already defined by the Windows SDK.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
Constrain mkdir calls to avoid extra mkdirs

This updates the calls that make the subdirectories for objects
to use a base directory above which git_futils_mkdir won't walk
any higher.  This prevents attempts to mkdir all the way up to
the root of the filesystem.

Also, this moves the objects_dir into the loose backend structure
and removes the separate allocation, plus does some preformatting
of the objects_dir value to guarantee a trailing slash, etc.
Merge pull request #1668 from csware/WC_ERR_INVALID_CHARS

Do not redefine WC_ERR_INVALID_CHARS
Add O_CLOEXEC to open calls
Fixed most documentation header bugs

Fixed a few header @param and @return typos with the help of -Wdocumentation in Xcode.

The following warnings have not been fixed:
common.h:213 - Not sure how the documentation format is for '...'
notes.h:102 - Correct @param name but empty text
notes.h:111 - Correct @param name but empty text
pack.h:140 - @return missing text
pack.h:148 - @return missing text
Work around reparse point stat issues

In theory, p_stat should never return an S_ISLNK result, but due
to the current implementation on Windows with mount points it is
possible that it will.  For now, work around that by allowing a
link in the path to a directory being created.  If it is really a
problem, then the issue will be caught on the next iteration of
the loop, but typically this will be the right thing to do.
Merge pull request #1669 from arrbee/fix-index-add-bypath

In loose objects backend, constrain mkdir calls to avoid extra mkdirs
Merge pull request #1670 from arrbee/open-cloexec

Add O_CLOEXEC to open calls
Merge pull request #1672 from TheRealKerni/fix/header_docs

Fixed most documentation header bugs
Fix checkout tests on Windows
Fix a leak in the local transport code.
Merge pull request #1674 from arrbee/fix-checkout-target-dir-win32

Fix checkout tests on Windows
Merge pull request #1675 from arthurschreiber/fix-leak-in-local-transport

Fix a leak in the local transport code.