Sebastian Bauer [Thu, 24 Jan 2013 19:44:17 +0000 (20:44 +0100)]
Added git_branch_name().
This is a convenience function to get the branch name of a given
ref. The returned branch name is compatible with the name that can
be supplied e.g. to git_branch_lookup(). That is, the prefixes
"refs/heads" or "refs/remotes" are omitted.
Also added a new test for testing the new function.
Russell Belfer [Tue, 22 Jan 2013 23:28:25 +0000 (15:28 -0800)]
Fix case sensitivity bug with tree iterators
With the new code to make tree iterators support ignore_case,
there is a bug in setting the start entry for range bounded
iterators where memcmp was being used instead of strncasecmp.
This fixes that and expands the tree iterator test to cover
the cases that were broken.
Russell Belfer [Mon, 21 Jan 2013 21:19:41 +0000 (13:19 -0800)]
Parse commit time as uint64_t to avoid overflow
The commit time is already stored as a git_time_t, but we were
parsing is as a uint32_t. This just switches the parser to use
uint64_t which will handle dates further in the future (and adds
some tests of those future dates).
commit: don't include the LF in the header field value
When the encoding header changed to be treated as an additional
header, the EOL pointer started to point to the byte after the LF,
making the git__strndup call copy the LF into the value.
Increase the EOL pointer value after copying the data to keep the rest
of the semantics but avoid copying LF.
Russell Belfer [Thu, 17 Jan 2013 21:19:09 +0000 (13:19 -0800)]
Add skipping of unknown commit headers
This moves the check for the "encoding" header into a loop which
is just scanning for non-required headers at the end of a commit
header. That loop will skip unrecognized lines (including header
continuation lines) until a terminating completely blank line is
found, and only then does it move to reading the commit message.
Russell Belfer [Thu, 10 Jan 2013 00:07:54 +0000 (16:07 -0800)]
Support case insensitive tree iterators and status
This makes tree iterators directly support case insensitivity by
using a secondary index that can be sorted by icase. Also, this
fixes the ambiguity check in the git_status_file API to also be
case insensitive. Lastly, this adds new test cases for case
insensitive range boundary checking for all types of iterators.
With this change, it should be possible to deprecate the spool
and sort iterator, but I haven't done that yet.
Russell Belfer [Thu, 10 Jan 2013 00:03:35 +0000 (16:03 -0800)]
Add git_tree_entry_cmp and git_tree_entry_icmp
This adds a new external API git_tree_entry_cmp and a new internal
API git_tree_entry_icmp for sorting tree entries. The case
insensitive one is internal only because general users should
never be seeing case-insensitively sorted trees.
Russell Belfer [Thu, 10 Jan 2013 00:00:16 +0000 (16:00 -0800)]
Add payload "_r" versions of bsearch and tsort
git__bsearch and git__tsort did not pass a payload through to the
comparison function. This makes it impossible to implement sorted
lists where the sort order depends on external data (e.g. building
a secondary sort order for the entries in a tree). This commit
adds git__bsearch_r and git__tsort_r versions that pass a third
parameter to the cmp function of a user payload.
Russell Belfer [Tue, 8 Jan 2013 23:56:11 +0000 (15:56 -0800)]
Test for ignore_case ranges on workdir iterator
This adds a test that confirms that the working directory iterator
can actually correctly process ranges of files case insensitively
with proper sorting and proper boundaries.
Russell Belfer [Tue, 8 Jan 2013 23:53:13 +0000 (15:53 -0800)]
Update iterator API with flags for ignore_case
This changes the iterator API so that flags can be passed in to
the constructor functions to control the ignore_case behavior.
At this point, the flags are not supported on tree iterators (i.e.
there is no functional change over the old API), but the API
changes are all made to accomodate this.
By the way, I went with a flags parameter because in the future
I have a couple of other ideas for iterator flags that will make
it easier to fix some diff/status/checkout bugs.
Russell Belfer [Tue, 8 Jan 2013 21:45:06 +0000 (13:45 -0800)]
Fix err msg for ambiguous path in git_status_file
Returning GIT_EAMBIGUOUS from inside the status callback gets
overridden with GIT_EUSER. `git_status_file` accounted for this
via the callback payload, but was allowing the error message to
be cleared. Move the `giterr_set` call outside the callback to
where the EUSER case was being dealt with.
Somewhat surprisingly, this can increase the speed considerably, as we
don't bother trying to decide what to evict, and the most used entries
are quickly back into the cache.
Sebastian Bauer [Sun, 13 Jan 2013 10:30:05 +0000 (11:30 +0100)]
Do not use GIT_CPDIR_CHMOD flag when copying the template.
This is an intermin solution. While this essentially disables the
--shared flag feature, previously external templates did not work
at all. This change fixes the previously corrected, and since
then failing, repo_init__extended_with_template() test.
The problem is now documented in the source code comments.
Russell Belfer [Fri, 11 Jan 2013 19:24:26 +0000 (11:24 -0800)]
Match binary file check of core git in diff
Core git just looks for NUL bytes in files when deciding about
is-binary inside diff (although it uses a better algorithm in
checkout, when deciding if CRLF conversion should be done).
Libgit2 was using the better algorithm in both places, but that
is causing some confusion. For now, this makes diff just look
for NUL bytes to decide if a file is binary by content in diff.
Russell Belfer [Fri, 11 Jan 2013 19:20:44 +0000 (11:20 -0800)]
Fix diff patch line number calculation
This was just wrong. Added a test that verifying patch line
numbers even for hunks further into a file and then fixed the
algorithm. I needed to add a little extra state into the patch
so that I could track old and new file numbers independently,
but it should be okay.