Commit Graph

1739 Commits

Author SHA1 Message Date
Vicent Marti
2ba14f2367 tree: Add payload to git_tree_walk 2011-11-18 01:40:35 +01:00
Vicent Marti
9432af36fc Rename git_tree_frompath to git_tree_get_subtree
That makes more sense to me.
2011-11-18 01:40:35 +01:00
Vicent Martí
010879d9e7 Merge pull request #486 from petdance/development
Quoted the asterisk to avoid markdown highlighter confusion
2011-11-16 20:35:29 -08:00
Andy Lester
a07d899449 Quoted the asterisk to avoid markdown highlighter confusion 2011-11-16 17:33:02 -06:00
Vicent Martí
682408110f Merge pull request #484 from brodie/packed-refs-perms
refs: permissions-related fixes/improvements
2011-11-16 11:45:37 -08:00
Brodie Rao
9788e72ad4 refs: move GIT_PACKED_REFS_FILE_MODE to refs.h as GIT_PACKEDREFS_FILE_MODE
This groups the #define with the other ref-related file modes, and it
makes the name consistent with the other packed-refs definitions.
2011-11-16 11:39:03 -08:00
Brodie Rao
7096d0f9e4 refs: use 0666 permissions when writing packed-refs, not 0644
This matches stock Git's behavior.
2011-11-16 11:36:13 -08:00
Vicent Martí
b2ae96fd6b Merge pull request #482 from leto/patch-1
Fix docs about the command to mix the clay tests
2011-11-16 11:34:10 -08:00
Jonathan "Duke" Leto
7b6156108c Fix docs about the command to mix the clay tests 2011-11-16 10:22:13 -08:00
Vicent Marti
a15c550db8 threads: Fix the shared global state with TLS
See `global.c` for a description of what we're doing.

When libgit2 is built with GIT_THREADS support, the threading system
must be explicitly initialized with `git_threads_init()`.
2011-11-16 14:09:44 +01:00
Vicent Martí
b0b2dd5ecc Merge pull request #475 from carlosmn/perms
Fix Windows permissions problems
2011-11-07 12:04:13 -08:00
Carlos Martín Nieto
657a395186 Write packed-refs with 0644 permissions
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-07 20:40:50 +01:00
Carlos Martín Nieto
718eb4b8ae Reword packed-refs error messages so they're easier to track down
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-07 20:34:42 +01:00
Carlos Martín Nieto
0c49ec2d3b Implement p_rename
Move the callers of git_futils_mv_atomic to use p_rename.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-07 20:34:27 +01:00
Vicent Martí
38068dc1d3 Merge pull request #473 from drafnel/bc/update-examples
bc/update examples
2011-11-07 06:27:49 -08:00
Vicent Martí
3b83bdac39 Merge pull request #470 from schu/test-helpers-no-assert
test_helpers: do not rely on assert
2011-11-07 06:25:22 -08:00
Vicent Martí
f8e8c8d44d Merge pull request #472 from libgit2/new-references
References! References! References!
2011-11-07 04:38:12 -08:00
Brandon Casey
0b142c9cb2 examples/network/.gitignore: ignore 'git2' 2011-11-06 20:07:27 -06:00
Brandon Casey
349532d0b1 examples/network/git2.c: exit with proper status, and avoid segfault
This function should exit after printing usage information if too few
arguments were specified.

Additionally, it should exit with a failure status if the first argument
supplied is not one in the internal command list.
2011-11-06 19:44:29 -06:00
Brandon Casey
983562e475 examples/network/git2.c: add newline to usage message 2011-11-06 19:43:44 -06:00
Brandon Casey
faeebd06e4 examples/network/fetch.c: revert overzealous conversion of free to git__free
Since git__free is not exported (it's actually a macro), it should not be
used in client programs.  Change this call to 'git__free' back to 'free'.
2011-11-06 19:35:35 -06:00
Vicent Marti
62dd6d1637 reflog: Do not free references before time 2011-11-06 03:15:38 +01:00
Vicent Marti
d4a0b124d0 refs: Partial rewrite for read-only refs
This new version of the references code is significantly faster and
hopefully easier to read.

External API stays the same. A new method `git_reference_reload()` has
been added to force updating a memory reference from disk. In-memory
references are no longer updated automagically -- this was killing us.

If a reference is deleted externally and the user doesn't reload the
memory object, nothing critical happens: any functions using that
reference should fail gracefully (e.g. deletion, renaming, and so on).

All generated references from the API are read only and must be free'd
by the user. There is no reference counting and no traces of generated
references are kept in the library.

There is no longer an internal representation for references. There is
only one reference struct `git_reference`, and symbolic/oid targets are
stored inside an union.

Packfile references are stored using an optimized struct with flex array
for reference names. This should significantly reduce the memory cost of
loading the packfile from disk.
2011-11-06 03:15:34 +01:00
schu
549bbd1342 git_reference_rename: cleanup reference renaming
git_reference_rename() didn't properly cleanup old references given by
the user to not break some ugly old tests. Since references don't point
to libgit's internal cache anymore we can cleanup git_reference_rename()
to be somewhat less messy.

Signed-off-by: schu <schu-github@schulog.org>
2011-11-06 03:15:30 +01:00
schu
75abd2b924 Free all used references in the source tree
Since references are not owned by the repository anymore we have to free
them manually now.

Signed-off-by: schu <schu-github@schulog.org>
2011-11-06 03:15:26 +01:00
schu
4fd89fa039 refs: add test case checking "immutable" references
Signed-off-by: schu <schu-github@schulog.org>
2011-11-06 03:15:22 +01:00
schu
a46ec45746 refs: split internal and external references
Currently libgit2 shares pointers to its internal reference cache with
the user. This leads to several problems like invalidation of reference
pointers when reordering the cache or manipulation of the cache from
user side.

Give each user its own git_reference instead of leaking the internal
representation (struct reference).

Add the following new API functions:

	* git_reference_free
	* git_reference_is_packed

Signed-off-by: schu <schu-github@schulog.org>
2011-11-06 03:15:19 +01:00
Brandon Casey
54ccc71786 examples/general.c: update for recent API renaming of git_config_get_int
git_config_get_int --> git_config_get_int32
2011-11-05 18:01:32 -05:00
schu
ec9079443c test_helpers: do not rely on assert
The functions loose_object_mode and loose_object_dir_mode call stat
inside an assert statement which isn't evaluated when compiling in
Release mode (NDEBUG) and leads to failing tests. Replace it.

Signed-off-by: schu <schu-github@schulog.org>
2011-10-30 13:48:00 +01:00
Vicent Martí
d3104fa0a3 Merge pull request #468 from nulltoken/ntk/fix/issue-465
Status: fix segfault (#465) and order issues
2011-10-29 14:06:36 -07:00
nulltoken
e3baa3ccf3 status: Fix a sorting issue in the treewalker
This ensures that entries from the working directory are retrieved according to the following rules:

 - The file "subdir" should appear before the file "subdir.txt"
 - The folder "subdir" should appear after the file "subdir.txt"
2011-10-29 22:42:37 +02:00
nulltoken
a1bd78ea29 status: Add a file in the test repository to cover the correct sorting of entries when the working folder is being read
In this case, "subdir.txt" should be listed before the "subdir" directory.
2011-10-29 22:05:56 +02:00
nulltoken
d1db74bf57 status: Prevent segfaulting when determining the status of a repository
Fixes #465
2011-10-29 22:05:56 +02:00
Vicent Martí
89fb8f025a Merge pull request #456 from brodie/perm-fixes
Create objects, indexes, and directories with the right file permissions
2011-10-28 19:04:23 -07:00
Vicent Marti
3286c408ec global: Properly use git__ memory wrappers
Ensure that all memory related functions (malloc, calloc, strdup, free,
etc) are using their respective `git__` wrappers.
2011-10-28 19:02:36 -07:00
Vicent Marti
da37654d04 tree: Add traversal in post-order 2011-10-27 22:33:31 -07:00
Vicent Marti
4849dbb8b9 Merge branch 'status' of https://github.com/carlosmn/libgit2 into development 2011-10-27 17:54:17 -07:00
Carlos Martín Nieto
1ca715e07a status: move GIT_STATUS_PATH_* into an enum
Their actual values have no meaning, so pack them in an enum.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-27 16:13:09 -07:00
Carlos Martín Nieto
68a26dfa7c status: reorder retrieve_head_tree error checks
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-27 16:13:09 -07:00
Carlos Martín Nieto
c2892d61ac status: remove git_tree_entry_bypos
The only caller has been changed to treat a NULL tree as a special
case and use the existing git_tree_entry_byindex.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-27 16:13:09 -07:00
Carlos Martín Nieto
899cb7a876 status: remove git_index_entry_bypos
This function is already implemented (better) as git_index_get. Change
the only caller to use that function.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-27 16:13:09 -07:00
Vicent Martí
a2366c949d Merge pull request #467 from oleganza/oa-config-parse-fix
Fixed crash in config parser when empty value is encountered.
2011-10-27 15:33:53 -07:00
Oleg Andreev
9f861826be Fixed crash in config parser when empty value is encountered.
Example:

key1 = value1
key2 =

In this config the value will be a bad pointer which config object will attempt to free() causing a crash.
2011-10-27 16:45:44 +02:00
Vicent Martí
d533c8885b Merge pull request #463 from schu/tests-clay-object-raw
tests-clay: move t01-rawobj.c to clay
2011-10-26 19:25:18 -07:00
Vicent Marti
11d51ca631 windows: Add support for non-UTF codepages
Our previous assumption that all paths in Windows are encoded in UTF-8
is rather weak, specially when considering that Git is
encoding-agnostic.

These set of functions allow the user to change the library's active
codepage globally, so it is possible to access paths and files on all
international versions of Windows.

Note that the default encoding here is UTF-8 because we assume that 99%
of all Git repositories will be in UTF-8.

Also, if you use non-ascii characters in paths, anywhere, please burn on
a fire.
2011-10-26 17:43:44 -07:00
schu
9ff46db911 tests-clay: move t01-rawobj.c to clay
Signed-off-by: schu <schu-github@schulog.org>
2011-10-24 23:51:28 +02:00
Vicent Martí
c2fbe42346 Merge pull request #464 from rtyley/development
Tolerate zlib deflation with window size < 32Kb
2011-10-24 14:43:18 -07:00
Roberto Tyley
c51065e3e9 Tolerate zlib deflation with window size < 32Kb
libgit2 currently identifies loose objects as corrupt if they've been
deflated using a window size less than 32Kb, because the
is_zlib_compressed_data() function doesn't recognise the header
byte as a zlib header. This patch makes the method tolerant of
all valid window sizes (15-bit to 8-bit) - but doesn't sacrifice
it's accuracy in distingushing the standard loose-object format
from the experimental (now abandoned) format. It's based on a patch
which has been merged into C-Git master branch:

https://github.com/git/git/commit/7f684a2aff636f44a506

On memory constrained systems zlib may use a much smaller window
size - working on Agit, I found that Android uses a 4KB window;
giving a header byte of 0x48, not 0x78. Consequently all loose
objects generated by the Android platform appear 'corrupt' :(

It might appear that this patch changes isStandardFormat() to the
point where it could incorrectly identify the experimental format as
the standard one, but the two criteria (bitmask & checksum) can only
give a false result for an experimental object where both of the
following are true:

1) object size is exactly 8 bytes when uncompressed (bitmask)
2) [single-byte in-pack git type&size header] * 256
   + [1st byte of the following zlib header] % 31 = 0 (checksum)

As it happens, for all possible combinations of valid object type
(1-4) and window bits (0-7), the only time when the checksum will be
divisible by 31 is for 0x1838 - ie object type *1*, a Commit - which,
due the fields all Commit objects must contain, could never be as
small as 8 bytes in size.

Given this, the combination of the two criteria (bitmask & checksum)
always correctly determines the buffer format, and is more tolerant
than the previous version.

References:

Android uses a 4KB window for deflation:
http://android.git.kernel.org/?p=platform/libcore.git;a=blob;f=luni/src/main/native/java_util_zip_Deflater.cpp;h=c0b2feff196e63a7b85d97cf9ae5bb258

Code snippet searching for false positives with the zlib checksum:
https://gist.github.com/1118177

Change-Id: Ifd84cd2bd6b46f087c9984fb4cbd8309f483dec0
2011-10-24 14:39:03 -07:00
Carlos Martín Nieto
4ce16ed82f CMake: use -O0 in debug mode
Otherwise, GCC optimizes variables away and gdb can't tell us what's
in them.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-22 12:26:56 +02:00
Vicent Marti
28c1451a7c tree: Fix name lookups once and for all
Double-pass binary search. Jeez.
2011-10-20 02:40:14 +02:00