Merge pull request #1933 from libgit2/vmg/gcc-warnings

Warnings for Windows x64 (MSVC) and GCC on Linux
Merge pull request #1916 from libgit2/simplify-examples

Fix examples to make the important stuff more obvious
Fix some of the glaring errors in GIT_DIFF_REVERSE

These changes fix the basic problem with GIT_DIFF_REVERSE being
broken for text diffs.  The reversed diff entries were getting
added to the git_diff correctly, but some of the metadata was kept
incorrectly in a way that prevented the text diffs from being
generated correctly.  Once I fixed that, it became clear that it
was not possible to merge reversed diffs correctly.  This has a
first pass at fixing that problem.  We probably need more tests
to make sure that is really fixed thoroughly.
Make diff and status perform soft index reload

This changes `git_index_read` to have two modes - a hard index
reload that always resets the index to match the on-disk data
(which was the old behavior) and a soft index reload that uses
the timestamp / file size information and only replaces the index
data if the file on disk has been modified.

This then updates the git_status code to do a soft reload unless
the new GIT_STATUS_OPT_NO_REFRESH flag is passed in.

This also changes the behavior of the git_diff functions that use
the index so that when an index is not explicitly passed in (i.e.
when the functions call git_repository_index for you), they will
also do a soft reload for you.

This intentionally breaks the file signature of git_index_read
because there has been some confusion about the behavior previously
and it seems like all existing uses of the API should probably be
examined to select the desired behavior.
Convert git_index_read to have a "force" flag

This is a little more intuitive than the turned-around option that
I originally wrote.
Add git_diff_options_init helper

Sometimes the static initializer for git_diff_options cannot be
used and since setting them to all zeroes doesn't actually work
quite right, this adds a new helper for that situation.

This also adds an explicit new value to the submodule settings
options to be used when those enums need static initialization.
Relicense examples under CC0
More tests and fixed for merging reversed diffs

There were a lot more cases to deal with to make sure that our
merged (i.e. workdir-to-tree-to-index) diffs were matching the
output of core Git.
Fix --assume-unchanged support

This was never really working right because we were checking the
wrong flag and not checking it in all the places that we need to
be checking it.  I finally got around to writing a test and adding
actual support for it.
preserve windows error numbers as well
remote: download HEAD when no refspecs are given

The correct behaviour when a remote has no refspecs (e.g. a URL from the
command-line) is to download the remote's HEAD. Let's do that.

This fixes #1261.
remote: give up after 256 failures to find a common object

This avoids sending our whole history bit by bit to the remote in cases
where there is no common history, just to give up in the end.

The number comes from the canonical implementation.
remote: create FETCH_HEAD with a refspecless remote

When downloading the default branch due to lack of refspecs, we still
need to write out FETCH_HEAD with the tip we downloaded, unfortunately
with a format that doesn't match what we already have.
remote: store dwimed refspecs separately

This allows us to add e.g. "HEAD" as a refspec when none are given
without overwriting the user's data.
Merge pull request #1935 from ethomson/winerrs

preserve windows error numbers as well
Streamline url-parsing logic.
Clarify parsing issues and errors
Checkout: Unifiy const-ness of `opts` parameter

Since all 3 checkout APIs perform the same operation with the options,
all of them should use the same const-ness.
Checkout: Don't assert if treeish is NULL

In git_checkout_tree, the first check tests if either repo or treeish is
NULL and says that eithor of them has to have a valid value. But there
is no code to handle the treeish == NULL case.

So, do something meaningful in that case: use HEAD instead.
Checkout: git_checkout_head is git_checkout_tree without a treeish

The last commit taught git_checkout_tree to actually do something
meaningfull, when treeish was NULL. This lets us rewrite
git_checkout_head to simply call git_checkout_tree without giving it a
treeish.