Em [Tue, 14 Jun 2011 13:37:10 +0000 (06:37 -0700)]
Port MSVC specific Waf compilation flags to CMake and remove dynamic dependence to msvcr100.dll on Windows
The '/MT' and '/MTd' flags replace the dynamic link to 'msvcr100.dll' with a static link to 'libcmt.lib'. This has the nice effect to ease the deployment of libgit2 by removing the dependence on 'msvcr100.dll' which is not deployed by default on Windows.
Add missing function declarations to avoid MSVC compiler warnings
The better solution would probably be to turn the gitfo_lstat /
gitfo_readlink macros into real functions that wrap either lstat or
gitfo_lstat__w32 (and readlink or gitfo_readlink__w32). However, that
would introduce an indirection unless inlined. For now, this is the less
intrusive change.
Marc Pegon [Wed, 8 Jun 2011 09:16:31 +0000 (11:16 +0200)]
Changed commit short messages so that they match git log --oneline output.
In git, the short message of a commit is the part of the commit message before 2 consecutive line breaks. In the short message, line breaks are replaced by space characters.
filebuf cleanup: only unlink lockfile if we've opened it
Add a check for the file descriptor in git_filebuf_cleanup. Without
it, an existing lockfile would be deleted if we tried to acquire it
(but failed, as the lockfile already existed).
Jakob Pfender [Tue, 7 Jun 2011 12:10:06 +0000 (14:10 +0200)]
fileops: Allow differentiation between deep and shallow exists()
When calling gitfo_exists() on a symbolic link, sometimes we need to
simply check whether the link exists and sometimes we need to check
whether the file pointed to by the symlink exists.
Introduce a new function gitfo_shallow_exists that only checks if the
link exists and revert gitfo_exists to the original functionality of
checking whether the file pointed to by the link exists.
As 8a27b6b reverts the exposition of struct stat to the external API, we
do not need - indeed, do not want - struct stat to be in the outer
include layer.
Jakob Pfender [Tue, 7 Jun 2011 09:11:09 +0000 (11:11 +0200)]
blob: Stat path inside git_blob_create_fromfile
00582bc introduced a change that required the caller of
git_blob_create_fromfile() to pass a struct stat with the stat
information for the file. Several developers pointed out that this would
make life hard for the bindings developers as struct stat isn't widely
supported by other languages.
Make git_blob_create_fromfile() stat the path itself, eliminating the
need for the file to be stat'ed by the caller. This makes
index_init_entry() more costly as the file will be stat'ed twice but
makes life easier for everyone else.
Jakob Pfender [Wed, 25 May 2011 14:31:14 +0000 (16:31 +0200)]
common: Include stat.h in include/git2/common.h instead of src/common.h
00582bcb introduced a change to git_blob_create_fromfile() that required
the caller to pass a stat struct. This means that we need to include
stat.h higher in the hierarchy of includes.
Jakob Pfender [Wed, 25 May 2011 14:16:41 +0000 (16:16 +0200)]
index: Correctly write entry mode
The entry mode flags for an entry created from a path name were not
correctly written if the entry was a symlink. The st_mode of a statted
symlink is 0120777, however git requires the mode to read 0120000,
because it does not care about permissions of symlinks.
Introduce index_create_mode() that correctly writes the mode flags in
the form expected by git.
Jakob Pfender [Wed, 25 May 2011 14:11:57 +0000 (16:11 +0200)]
index/fileops: Correctly process symbolic links
gitfo_exists() used to error out if the given file was a symbolic link,
due to access() returning an error code. This is not expected behaviour,
as gitfo_exists() should only check whether the file itself exists, not
its link target if it is a symbolic link.
Fix this by calling gitfo_lstat() instead, which is just a wrapper for
lstat().
Jakob Pfender [Wed, 25 May 2011 14:04:29 +0000 (16:04 +0200)]
blob: Require stat information for git_blob_create_fromfile()
In order to be able to write symlinks with git_blob_create_fromfile(),
we need to check whether the file to be written is a symbolic link or
not. Since the calling function of git_blob_create_fromfile() is likely to have
stated the file before calling, we make it pass the stat.
The reason for this is that writing symbolic link blobs is significantly
different from writing ordinary files - we do not want to open the link
destination but instead want to write the link itself, regardless of
whether it exists or not.
Previously, index_init_entry() used to error out if the file to be added
was a symlink that pointed to a nonexistent file. Fix this behaviour to
add the file regardless of whether it exists. This mimics git.git's
behaviour.
Marc Pegon [Mon, 6 Jun 2011 08:55:36 +0000 (10:55 +0200)]
Renamed git_oid_match to git_oid_ncmp.
As suggested by carlosmn, git_oid_ncmp would probably
be a better name than git_oid_match, for it does the same
as git_oid_cmp but only up to a certain amount of hex digits.
Romain Geissler [Mon, 6 Jun 2011 08:02:07 +0000 (10:02 +0200)]
Repository: A little fix in error code. GIT_ENOTFOUND is returned when a gitfile is malformed and GIT_ENOTAREPO when the pointed dir is not a repo.
Fixed tests so that it check the right error code.
Romain Geissler [Sun, 5 Jun 2011 19:19:03 +0000 (21:19 +0200)]
Index: API uniformisation: Use unsigned int for all index number.
Feature Added: Search an unmerged entry by path (git_index_get_unmerged
renamed to git_index_get_unmerged_bypath) or by index (git_index_get_unmerged_byindex).
Romain Geissler [Sat, 4 Jun 2011 14:28:39 +0000 (16:28 +0200)]
Repository: Fixed some errors with ceiling_dirs in git_repository_discover.
Now the ceiling_dirs are compared with their symbolic free version (like base_path).
The ceiling dirs check is now performed after getting the parent directory.
Romain Geissler [Fri, 3 Jun 2011 21:44:38 +0000 (23:44 +0200)]
Repository: Added some util functions that we'll need to discover repository path.
retrieve_device returns the file device for a given path (so that we can detect device change while walking through parent directories).
abspath returns a canonicalized path, symbolic link free.
retrieive_ceiling_directories_offset returns the biggest path offset that path match in the ceiling directory list (so that we can stop at ceiling directories).
Romain Geissler [Fri, 3 Jun 2011 17:26:45 +0000 (19:26 +0200)]
Fileops:retrieve_path_root_offset is now named gitfo_retrieve_path_root_offset (like other public functions). Added platform specific directory separator definition.
Marc Pegon [Sun, 29 May 2011 15:57:25 +0000 (17:57 +0200)]
Fixed some error messages related to searching objects from a short oid. Fixed forgot to check that prefix length is greater than minimum prefix length in read_unique_short_oid method from pack backend.
Marc Pegon [Sun, 29 May 2011 09:45:34 +0000 (11:45 +0200)]
Changed return value of git_oid_match to be consistent with the other compare methods (0 means oids match). Added method to compare prefixes of hex formatted oids.
Marc Pegon [Sat, 28 May 2011 19:24:25 +0000 (21:24 +0200)]
Added a GIT_OID_MINPREFIXLEN constant to define the minimum length allowed for oid prefixes (set to 4, like in git). Consequently updated some object lookup methods and their documentation.
Marc Pegon [Fri, 27 May 2011 20:46:41 +0000 (22:46 +0200)]
Added git.git sha1 lookup method to replace simple binary search in pack backend.
Implemented find_unique_short_oid for pack backend, based on git sha1 lookup method;
finding an object given its full oid is just a particular case of searching
the unique object matching an oid prefix (short oid).
Added git_odb_read_unique_short_oid, which iterates over all the backends to
find and read the unique object matching the given oid prefix.
Added a git_object_lookup_short_oid method to find the unique object in
the repository matching a given oid prefix : it generalizes git_object_lookup
which now does nothing but calls git_object_lookup_short_oid.
Marc Pegon [Fri, 27 May 2011 16:49:09 +0000 (18:49 +0200)]
Added a read_unique_short_oid method to backends, to make it possible to find objects from sha1 prefixes in the future. Default implementations throw GIT_ENOTIMPLEMENTED for strict prefixes (i.e. length < GIT_OID_HEXSZ).