Commit Graph

1510 Commits

Author SHA1 Message Date
Carlos Martín Nieto
1a8167afbc status: don't hide tree closing
It's not obvious that recurse_tree_entries or recurse_tree_entry
should free a resource that wasn't allocated by them. Do this
explicitely and plug a leak while we're at it.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-14 00:06:24 +02:00
Carlos Martín Nieto
91d8a4c077 typo: one git_remote_fetchspec should be pushspec
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-07-13 23:55:48 +02:00
Vicent Martí
8dc91e31f3 Merge pull request #323 from nulltoken/ntk/fix/treebuilder-insert
tree: fix insertion of entries with invalid filenames
2011-07-13 04:38:31 -07:00
nulltoken
f4ad64c109 tree: fix insertion of entries with invalid filenames 2011-07-13 07:58:17 +02:00
Vicent Marti
e6629d8313 tree: More accurate matching on entries
The old matcher was returning fake matches when given stupid entry
names. E.g.

	`git2` could be matched by `git2   /`, `git2/foobar`, git2/////`
	and other stupid stuff
2011-07-13 03:36:03 +02:00
Vicent Marti
761aa2aa35 tree: Fix wrong sort order when querying entries
Fixes #127 (that was quite an outstanding issue).

Rationale:

The tree objects on Git are stored and read following a very specific
sorting algorithm that places folders before files. That original sort
was the sort we were storing on memory, but this sort was being queried
with a binary search that used a simple `strcmp` for comparison, so
there were many instances where the search was failing.

Obviously, the most straightforward way to fix this is changing the
binary search CB to use the same comparison method as the sorting CB.
The problem with this is that the binary search callback compares a path
and an entry, so there is no way to know if the given path is a folder
or a standard file.

How do we work around this? Instead of splitting the `entry_byname`
method in two (one for searching directories and one for searching
normal files), we just assume that the path we are searching for is of
the same kind as the path it's being compared at the moment.

	return git_futils_cmp_path(
		ksearch->filename, ksearch->filename_len, entry->attr & 040000,
        entry->filename, entry->filename_len, entry->attr & 040000);

Since there cannot be a folder and a regular file with the same name on
the same tree, the most basic equality check will always fail
for all comparsions, until our path is compared with the actual entry we
are looking for; in this case, the matching will succeed with the file
type of the entry -- whatever it was initially.

I hope that makes sense.

PS: While I was at it, I switched the cmp methods to use cached values
for the length of each filename. That makes searches and sorts
retardedly fast -- I was wondering the reason of the performance hiccups
on massive trees; it's because of 2*strlen for each comparsion call.
2011-07-13 02:49:47 +02:00
Vicent Marti
3dd26d1e36 index: Yes, we have to truncate 2011-07-13 02:15:31 +02:00
Kirill A. Shutemov
b16692faa3 index: fix potential overflow
mode field of git_index_entry_unmerged is array of unsigned ints. It's
unsafe to cast pointer to an element of the array to long int *. It may
cause overflow in git_strtol32().

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-13 02:03:34 +02:00
Kirill A. Shutemov
ae9f771c99 index: drop useless type casting
Type casting usually points to some trick or bug. It's better not hide
it between useless type castings.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-13 02:03:34 +02:00
Kirill A. Shutemov
e1fca01477 vector: mark internal functions as static
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-13 02:03:34 +02:00
Kirill A. Shutemov
046dfea343 vector: avoid double asserting
index_initialize() calls assert() for arguments on its own. No need to
call it twice.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-13 02:03:34 +02:00
Kirill A. Shutemov
fad6607a55 index: drop sort_index()
Remove dummy wrapper around git_vector_sort().

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-13 02:03:34 +02:00
Kirill A. Shutemov
07d3487761 index: do not sort index before git_vector_bsearch2()
git_vector_bsearch2() calls git_vector_sort(). No need to call it
directly.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-13 02:03:34 +02:00
Kirill A. Shutemov
212b379a1f index: do not free vectors twice in git_index_free()
git_index_clear() frees index->entries and index->unmerged. No need to
free it once again.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-13 02:03:34 +02:00
Carlos Martín Nieto
cd0fe1ac27 Free sig in reflog test
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-07-13 00:23:15 +02:00
nulltoken
d4760a42f9 status: refactor the tests to remove some code duplication 2011-07-12 22:20:15 +02:00
Vicent Martí
467545d0a5 Merge pull request #321 from letolabs/readme
Add parrot-libgit2 to the list of language bindings in the readme
2011-07-12 11:26:25 -07:00
Vicent Martí
dd49827417 Merge pull request #319 from carlosmn/valgrind
Fix more memory leaks
2011-07-12 11:23:12 -07:00
Vicent Martí
5903aa2b9a Merge pull request #318 from schu/ref-fix-leak
reference_rename: make sure old_name gets freed
2011-07-12 11:22:11 -07:00
Jonathan "Duke" Leto
d2b96cf47f Add parrot-libgit2 to the list of language bindings in the readme 2011-07-12 11:19:42 -07:00
Carlos Martín Nieto
75c2002f97 status: plug some leaks
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-12 18:25:31 +02:00
Carlos Martín Nieto
55e1609b2f Don't leak the buf when testing it
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-12 18:19:56 +02:00
schu
ca6f203c59 reference_rename: make sure old_name gets freed
Signed-off-by: schu <schu-github@schulog.org>
2011-07-12 17:59:22 +02:00
Vicent Marti
b08683ffb2 config: Rename del to `delete 2011-07-12 02:38:20 +02:00
nulltoken
bfbb55628b tag: Add creation of lightweight tag 2011-07-11 19:42:21 +02:00
Vicent Marti
eb1fd1d0cb What the fuck was this doing in src? 2011-07-11 19:42:21 +02:00
Vicent Martí
9b6fccc9ba Merge pull request #315 from belkiss/development
Finish to hide git_pkt from external API.
2011-07-11 04:19:46 -07:00
Lambert CLARA
f6e4a98a95 Finish to hide git_pkt from external API. 2011-07-11 13:05:13 +02:00
Vicent Martí
283eeefb09 Merge pull request #314 from nulltoken/ntk/fix-reflog
reflog: Fix reflog writer/reader
2011-07-10 18:02:33 -07:00
Lambert CLARA
5f35d0ce77 Remove the last reference of git_net_direction enum 2011-07-11 03:00:34 +02:00
Vicent Marti
bdd18829ad Cleanup external API
Some of the WIP API calls have been hidden in preparation for the next
minor release.
2011-07-11 02:59:18 +02:00
Vicent Marti
f27f29b100 include: Fix unmatched params in documentation 2011-07-11 02:59:17 +02:00
nulltoken
7757be33a2 reflog: Fix reflog writer/reader
- Use a space to separate oids and signature
 - Enforce test coverage
 - Make test run in a temporary folder in order not to alter the test repository
2011-07-10 19:17:07 +02:00
Vicent Martí
d37ba6720d Merge pull request #312 from nulltoken/patch-2
Fix MSVC compilation warning
2011-07-09 06:45:30 -07:00
nulltoken
b21fb8496f Fix MSVC compilation warning 2011-07-09 06:36:18 -07:00
Vicent Marti
c52736fa52 status: Cleanup
The `hashfile` function has been moved to ODB, next to `git_odb_hash`.

Global state has been removed from the dirent call in `status.c`,
because global state is killing the rainforest and causing global
warming.
2011-07-09 15:05:14 +02:00
Jason Penny
3b2a423c3f status: nonexistent file with git_status_file()
Throws GIT_ENOTFOUND error if given a filename that is not in
HEAD, index, nor the work tree.
2011-07-09 13:49:50 +02:00
Jason Penny
2b90cc26de status: consolidate some test code
Refactored copy of test repo to a function.
2011-07-09 13:49:50 +02:00
Jason Penny
34dfea2774 status: handle subdirs for git_status_file 2011-07-09 13:49:50 +02:00
Jason Penny
6b251490a8 status: add subdir to test repo 2011-07-09 13:49:50 +02:00
Jason Penny
20361b2f69 status: get status for single file
Add git_status_file to be able to retrieve status of single file by
supplying a path.
2011-07-09 13:49:50 +02:00
Jason Penny
3af6b34a76 status: get file statuses and run callback
Add git_status_foreach() to run a callback on each file passing the path
and a status value.
2011-07-09 13:49:50 +02:00
Jason Penny
210940da84 status: new test repo 2011-07-09 13:49:50 +02:00
Jason Penny
205166d27c status: get blob object id of file on disk
Add git_status_hashfile() to get blob's object id for a file without adding
it to the object database or needing a repository at all.
This functionality is similar to `git hash-object` without '-w'.
2011-07-09 13:49:50 +02:00
Jason Penny
7361857c50 Update tests/NAMING 2011-07-09 13:49:49 +02:00
Vicent Marti
c2db984b1c tsort: Remove unused CLZ methods 2011-07-09 13:27:08 +02:00
Vicent Martí
0448310f73 Merge pull request #311 from nulltoken/ntk/fix-win32-specs
Ntk/fix win32 specs
2011-07-09 04:24:23 -07:00
nulltoken
ae2e4c6a06 win32: replace usage of _MSV_VER with _MSC_VER 2011-07-09 08:41:02 +02:00
nulltoken
38ce60f091 Fix MSVC compilation warning 2011-07-09 08:36:37 +02:00
Vicent Marti
06c43821b9 Remove unused methods
The direct-writes commit left some (slow) internals methods that
were no longer needed. These have been removed.

Also, the Reflog code was using the old `git_signature__write`, so
it has been rewritten to use a normal buffer and the new `writebuf`
signature writer. It's now slightly simpler and faster.
2011-07-09 02:40:16 +02:00