Scott J. Goldman [Sun, 27 May 2012 01:20:33 +0000 (18:20 -0700)]
Refactor CMakeLists.txt for mingw cross-compile
Two things:
1) By default, Linux CMake puts -fPIC on the link line. So we remove that
for MINGW to avoid warnings that it will be ignored.
2) Similarly, move -fvisibility=hidden flag to be for non-mingw
compilation only to avoid warnings that it will be ignored.
Russell Belfer [Fri, 25 May 2012 16:44:56 +0000 (09:44 -0700)]
Make errors for system and global files consistent
The error codes from failed lookups of system and global files
on Windows were not consistent with the codes returned on other
platforms. This makes the error detection patterns match and
adds a unit test for the various errors.
Russell Belfer [Fri, 25 May 2012 00:14:56 +0000 (17:14 -0700)]
Fix bugs for status with spaces and reloaded attrs
This fixes two bugs:
* Issue #728 where git_status_file was not working for files
that contain spaces. This was caused by reusing the "fnmatch"
parsing code from ignore and attribute files to interpret the
"pathspec" that constrained the files to apply the status to.
In that code, unescaped whitespace was considered terminal to
the pattern, so a file with internal whitespace was excluded
from the matched files. The fix was to add a mode to that code
that allows spaces and tabs inside patterns. This mode only
comes into play when parsing in-memory strings.
* The other issue was undetected, but it was in the recently
added code to reload gitattributes / gitignores when they were
changed on disk. That code was not clearing out the old values
from the cached file content before reparsing which meant that
newly added patterns would be read in, but deleted patterns
would not be removed. The fix was to clear the vector of
patterns in a cached file before reparsing the file.
Russell Belfer [Thu, 24 May 2012 20:44:24 +0000 (13:44 -0700)]
Fix bugs in UTF-8 <-> UTF-16 conversion
The function to convert UTF-16 to UTF-8 was only allocating a
buffer of wcslen(utf16str) bytes for the UTF-8 string, but that
is not sufficient if you have multibyte characters, and so when
those occured, the conversion was failing. This updates the
conversion functions to use the Win APIs to calculate the correct
buffer lengths.
Also fixes a comparison in the unit tests that would fail if
you did not have a particular environment variable set.
repository: default to core.bare = false if it's not set
We used to consider a missing core.bare option to mean that the
repository was corrupt. This is too strict. Consider it a non-bare
repository if it's not set.
Russell Belfer [Thu, 24 May 2012 19:45:20 +0000 (12:45 -0700)]
Get user's home dir in UTF-16 clean manner
On Windows, we are having problems with home directories
that have non-ascii characters in them. This rewrites the
relevant code to fetch environment variables as UTF-16 and
then explicitly map then into UTF-8 for our internal usage.
Vicent Marti [Fri, 18 May 2012 23:40:46 +0000 (01:40 +0200)]
libgit2 v0.17.0 "Lord of Diffstruction"
Welcome to yet another libgit2 release, this one being the
biggest we've shipped so far. Highlights on this release
include diff, branches, notes and submodules support. The new
diff API is shiny and powerful. Check it out.
Apologies, one more time, to all the early adopters for the
breaking API changes. We've been iterating on the error
handling for the library until we reached its current state,
which we believe it's significantly more usable both for normal
users and for developers of bindings to other languages.
Also, we've renamed a few legacy calls to ensure that the whole
external API uses a consistent naming scheme.
As always, check the API docs for the full list of new API calls
and backwards-incompatible changes.
http://libgit2.github.com/libgit2/
Changelog of new features follows:
Attributes:
- Added function macros to check attribute values instead of having
to manually compare them
- Added support for choosing the attribute loading order (workdir files
vs index) and to skip the systems' default `.gitattributes`
- Fixed issues when fetching attribute data on bare repositories
Blob:
- Added support for creating blobs from any file on disk (not
restricted to the repository's working directory)
- Aded support for smudge filters when writing blobs to the ODB
- So far only CRLF normalization is available
References:
- Added `git_reference_name_to_oid` helper to resolve
a reference to its final OID
- Added `git_reference_cmp` to compare two references with
a stable order
Remotes:
- Added support for writing and saving remotes
- `git_remote_add`
- `git_remote_save`
- Setters for all the attributes of a remote
- Switched remote download to the new streaming packfile indexer
- Fixed fetch on HTTP and Git under Windows
- Added `git_remote_supported_url` helper to check if a protocol
can be accessed by the library
- Added `git_remote_list`
Repository:
- Made `git_repository_open` smarter when finding the `.git` folder.
- Added `git_repository_open_ext` with extra options when
opening a repository
Revwalk:
- Added support for pushing/hiding several references through a glob
- Added helper to push/hide the current HEAD to the walker
- Added helper to push/hide a single reference to the walker
Status:
- Greatly improved Status implementation using the new `diff` code
as a backend
Submodules:
- Added a partial submodules API to get information about a
submodule and list all the submodules in a repository
- git_submodule_foreach
- git_submodule_lookup
Tag:
- Added `git_tag_peel` helper to peel a tag to its pointed object
- Tag messages are now filtered to match Git rules (stripping comments
and adding proper whitespacing rules)
Tree:
- Killed the old `git_tree_diff` API, which is replaced by the
new diff code.
Russell Belfer [Thu, 17 May 2012 21:21:10 +0000 (14:21 -0700)]
Fix workdir iterators on empty directories
Creating a workdir iterator on a directory with absolutely
no files was returning an error (GIT_ENOTFOUND) instead of
an iterator for nothing. This fixes that and includes two
new tests that cover that case.
Russell Belfer [Thu, 17 May 2012 20:06:20 +0000 (13:06 -0700)]
Optimize away git_text_gather_stats in diff
GProf shows `git_text_gather_stats` as the most expensive call
in large diffs. The function calculates a lot of information
that is not actually used and does not do so in a optimal
order. This introduces a tuned `git_buf_is_binary` function
that executes the same algorithm in a fraction of the time.
Russell Belfer [Thu, 17 May 2012 00:02:06 +0000 (17:02 -0700)]
Fix status for files under ignored dirs
There was a bug where tracked files inside directories that were
inside ignored directories where not being found by status. To
make that a little clearer, if you have a .gitignore with:
ignore/
And then have the following files:
ignore/dir/tracked <-- actually a tracked file
ignore/dir/untracked <-- should be ignored
Then we would show the tracked file as being removed (because
when we got the to contained item "dir/" inside the ignored
directory, we decided it was safe to skip -- bzzt, wrong!).
This update is much more careful about checking that we are
not skipping over any prefix of a tracked item, regardless of
whether it is ignored or not.
As documented in diff.c, this commit does create behavior that
still differs from core git with regards to the handling of
untracked files contained inside ignored directories. With
libgit2, those files will just not show up in status or diff.
With core git, those files don't show up in status or diff
either *unless* they are explicitly ignored by a .gitignore
pattern in which case they show up as ignored files.
Needless to say, this is a local behavior difference only, so
it should not be important and (to me) the libgit2 behavior
seems more consistent.
Russell Belfer [Tue, 15 May 2012 21:17:39 +0000 (14:17 -0700)]
Ranged iterators and rewritten git_status_file
The goal of this work is to rewrite git_status_file to use the
same underlying code as git_status_foreach.
This is done in 3 phases:
1. Extend iterators to allow ranged iteration with start and
end prefixes for the range of file names to be covered.
2. Improve diff so that when there is a pathspec and there is
a common non-wildcard prefix of the pathspec, it will use
ranged iterators to minimize excess iteration.
3. Rewrite git_status_file to call git_status_foreach_ext
with a pathspec that covers just the one file being checked.
Since ranged iterators underlie the status & diff implementation,
this is actually fairly efficient. The workdir iterator does
end up loading the contents of all the directories down to the
single file, which should ideally be avoided, but it is pretty
good.
Nico von Geyso [Tue, 15 May 2012 15:03:07 +0000 (17:03 +0200)]
really reset walker with git_revwalk_reset
From the description of git_revwalk_reset in revwalk.h the function should
clear all pushed and hidden commits, and leave the walker in a blank state (just like at creation).
Apparently everything gets reseted appart of pushed commits (walk->one and walk->twos)
Sascha Cunz [Fri, 11 May 2012 02:25:23 +0000 (04:25 +0200)]
Specifiy dllimport to MSVC if we're not building libgit2.dll
Building a "shared object" (DLL) in Windows includes 2 steps:
- specify __declspec(dllexport)
when building the library itself. MSVC will disallow itself from
optimizing these symbols out and reference them in the PE's
Exports-Table.
Further, a static link library will be generated. This library
contains the symbols which are exported via the declsepc above.
The __declspec(dllexport) becomes part of the symbol-signature
(like parameter types in C++ are 'mangled' into the symbol name,
the export specifier is mingled with the name)
- specify __declspec(dllimport)
when using the library. This again mingles the declspec into the
name and declares the function / variable with external linkage.
cmake automatically adds -Dgit2_EXPORTS to the compiler arguments
when compiling the libgit2 project.
The 'git2' is the name specified via PROJECT() in CMakeLists.txt.
Scott J. Goldman [Mon, 14 May 2012 06:12:51 +0000 (23:12 -0700)]
Add a test to verify FILENAME_MAX
Since we now rely on it (at least under Solaris), I figured we probably
want to make sure it's accurate. The new test makes sure that creating a
file with a name of length FILENAME_MAX+1 fails.
Scott J. Goldman [Thu, 10 May 2012 06:45:55 +0000 (23:45 -0700)]
Fix readdir_r() usage for Solaris
On Solaris, struct dirent is defined differently than Linux. The field
containing the path name is of size 0, rather than NAME_MAX. So, we need to
use a properly sized buffer on Solaris to avoid a stack overflow.