|
50a8fd03
|
2011-08-16T18:16:44
|
|
Fix the reference character check for Unicode
We need to do an unsigned comparison, as otherwise UTF-8 characters
might look like they have the sign bit set and the check will fail.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
|
|
d1f34693
|
2011-08-09T12:07:47
|
|
util: Add git__strcmp_cb() wrapper
We don't want direct pointers to the CRT on Windows, we may get stdcall conflicts.
|
|
f6867e63
|
2011-08-08T16:56:28
|
|
Fix compilation in Windows
|
|
cb1c7563
|
2011-07-28T05:32:47
|
|
Merge pull request #335 from carlosmn/read-updated
Don't stat so much when reading references
|
|
b75bec94
|
2011-07-15T18:24:35
|
|
refs: fix cast warning
/home/kas/git/public/libgit2/src/refs.c: In function ‘normalize_name’:
/home/kas/git/public/libgit2/src/refs.c:1681:12: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
|
|
c4982328
|
2011-07-23T12:09:51
|
|
refs: don't stat so much
In reference_read we stat a file and then call futils which stats it
again. Use git_futils_readbuffer_updated to avoid the extra stat
call. This introduces another parameter which is used to tell the
caller whether the file was read or not.
Modify the callers to take advantage of this new feature. This change
removes ~140 stat calls from the test suite.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
|
|
5c6ae009
|
2011-07-18T01:54:40
|
|
refs: fix memory leak on rename
Current implementation of git_reference_rename() removes 'ref' from
loose cache, but not frees it. In result 'ref' is not reachable any more
and we have got memory leak.
Let's re-add 'ref' with corrected name to loose cache instead of
'new_ref' and free 'new_ref' properly.
'rollback' path seems leak too. git_reference_rename() need to be rewritten
for proper resource management.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
|
|
ca6f203c
|
2011-07-12T17:53:22
|
|
reference_rename: make sure old_name gets freed
Signed-off-by: schu <schu-github@schulog.org>
|
|
73294339
|
2011-07-07T21:24:12
|
|
reference_rename: fix flaw in force-renaming
reference_rename didn't respect the force flag. Fixed.
Reported-by: nulltoken <emeric.fermas@gmail.com>
Signed-off-by: schu <schu-github@schulog.org>
|
|
de18f276
|
2011-07-07T01:46:20
|
|
vector: Timsort all of the things
Drop the GLibc implementation of Merge Sort and replace it with Timsort.
The algorithm has been tuned to work on arrays of pointers (void **),
so there's no longer a need to abstract the byte-width of each element
in the array.
All the comparison callbacks now take pointers-to-elements, not
pointers-to-pointers, so there's now one less level of dereferencing.
E.g.
int index_cmp(const void *a, const void *b)
{
- const git_index_entry *entry_a = *(const git_index_entry **)(a);
+ const git_index_entry *entry_a = (const git_index_entry *)(a);
The result is up to a 40% speed-up when sorting vectors. Memory usage
remains lineal.
A new `bsearch` implementation has been added, whose callback also
supplies pointer-to-elements, to uniform the Vector API again.
|
|
858dba58
|
2011-07-06T18:08:13
|
|
refs: Cleanup reference renaming
`git_futils_rmdir_r`: rename, clean up.
`git_reference_rename`: cleanup. Do not use 3x4096 buffers on the stack
or things will get ugly very fast. We can reuse the same buffer.
|
|
0ffcf78a
|
2011-06-14T15:16:43
|
|
reference_rename: git compliant reference renaming
So far libgit2 didn't handle the following scenarios:
* Rename of reference m -> m/m
* Rename of reference n/n -> n
Fixed.
Since we don't write reflogs, we have to delete any old reflog for the
renamed reference. Otherwise git.git will possibly fail when it finds
invalid logs.
Reported-by: nulltoken <emeric.fermas@gmail.com>
Signed-off-by: schu <schu-github@schulog.org>
|
|
f79026b4
|
2011-07-04T11:43:34
|
|
fileops: Cleanup
Cleaned up the structure of the whole OS-abstraction layer.
fileops.c now contains a set of utility methods for file management used
by the library. These are abstractions on top of the original POSIX
calls.
There's a new file called `posix.c` that contains
emulations/reimplementations of all the POSIX calls the library uses.
These are prefixed with `p_`. There's a specific posix file for each
platform (win32 and unix).
All the path-related methods have been moved from `utils.c` to `path.c`
and have their own prefix.
|
|
932d1baf
|
2011-06-30T19:52:34
|
|
cleanup: remove trailing spaces
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
|
|
637edc9c
|
2011-06-30T20:53:59
|
|
refs: Remove bogus assertion
The assertion in line 360 was there to check that only loose refs were
being written as loose, but there are times when we need to re-write a
packed reference as loose.
|
|
7376ad99
|
2011-06-29T11:01:35
|
|
refs: Remove duplicate rename method
`git_reference_rename` now takes a `force` flag
|
|
9525e47d
|
2011-06-28T19:43:36
|
|
refs: Remove unused declarations
|
|
d5afc039
|
2011-06-28T19:15:48
|
|
Remove redundant methods from the API
A bunch of redundant methods have been removed from the external API.
- All the reference/tag creation methods with `_f` are gone. The force
flag is now passed as an argument to the normal create methods.
- All the different commit creation methods are gone; commit creation
now always requires a `git_commit` pointer for parents and a `git_tree`
pointer for tree, to ensure that corrupted commits cannot be generated.
- All the different tag creation methods are gone; tag creation now
always requires a `git_object` pointer to ensure that tags are not
created to inexisting objects.
|
|
3101a3e5
|
2011-06-23T02:28:29
|
|
refs: Do not overflow when normalizing refnames
|
|
e7e0e20f
|
2011-06-16T16:39:20
|
|
Simplify loose ref writing
There is no need to store the format outselves, as the library
provides git_filebuf_printf which takes care of the formatting itself.
Also get rid of an use of strcat + strcpy which is always a nice
thing.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
|
|
fa48608e
|
2011-06-16T02:36:21
|
|
oid: Rename methods
Yeah. Finally. Fuck the old names, this ain't POSIX
and they don't make any sense at all.
|
|
43521d06
|
2011-06-16T02:27:43
|
|
refs: Rename git_referece_listcb to _foreach
Same name as `git_config_foreach`
|
|
a5aa5bd1
|
2011-06-07T07:04:51
|
|
Merge pull request #245 from schu/use-normalized
rename-reference: use normalized path
|
|
52b188f6
|
2011-06-07T14:18:20
|
|
rename-reference: use normalized path
Signed-off-by: schu <schu-github@schulog.org>
|
|
f120e92b
|
2011-06-07T08:41:33
|
|
Fix compilation warnings in MSVC
|
|
2c9e7fa3
|
2011-06-06T18:24:37
|
|
Merge pull request #232 from schu/ref-available-cb
reference_rename: respect all references v2
|
|
2b397327
|
2011-06-06T01:54:25
|
|
refs: Improve error messages
|
|
76b15cb1
|
2011-06-05T20:47:30
|
|
Raise GIT_EEXISTS in case of conflicting ref names instead of passing
the error returned by the subsystem; clarify error message.
Fix tiny typo.
Signed-off-by: schu <schu-github@schulog.org>
|
|
1b6d8163
|
2011-06-05T19:22:32
|
|
Teach reference_rename() to really respect other references
Add a new function reference_available() to check if a reference name
actually is free and can be used.
Signed-off-by: schu <schu-github@schulog.org>
|
|
0d5d5190
|
2011-05-23T21:37:48
|
|
refs: Reword errors
|
|
5bdf7b9f
|
2011-05-19T14:36:52
|
|
refs.c: Move to new error handling mechanism
|
|
fa59f18d
|
2011-05-09T20:54:04
|
|
Change error handling mechanism once again
Ok, this is the real deal. Hopefully. Here's how it's going to work:
- One main method, called `git__throw`, that sets the error
code and error message when an error happens.
This method must be called in every single place where an error
code was being returned previously, setting an error message
instead.
Example, instead of:
return GIT_EOBJCORRUPTED;
Use:
return git__throw(GIT_EOBJCORRUPTED,
"The object is missing a finalizing line feed");
And instead of:
[...] {
error = GIT_EOBJCORRUPTED;
goto cleanup;
}
Use:
[...] {
error = git__throw(GIT_EOBJCORRUPTED, "What an error!");
goto cleanup;
}
The **only** exception to this are the allocation methods, which
return NULL on failure but already set the message manually.
/* only place where an error code can be returned directly,
because the error message has already been set by the wrapper */
if (foo == NULL)
return GIT_ENOMEM;
- One secondary method, called `git__rethrow`, which can be used to
fine-grain an error message and build an error stack.
Example, instead of:
if ((error = foobar(baz)) < GIT_SUCCESS)
return error;
You can now do:
if ((error = foobar(baz)) < GIT_SUCCESS)
return git__rethrow(error, "Failed to do a major operation");
The return of the `git_lasterror` method will be a string in the
shape of:
"Failed to do a major operation. (Failed to do an internal
operation)"
E.g.
"Failed to open the index. (Not enough permissions to access
'/path/to/index')."
NOTE: do not abuse this method. Try to write all `git__throw`
messages in a descriptive manner, to avoid having to rethrow them to
clarify their meaning.
This method should only be used in the places where the original
error message set by a subroutine is not specific enough.
It is encouraged to continue using this style as much possible to
enforce error propagation:
if ((error = foobar(baz)) < GIT_SUCCESS)
return error; /* `foobar` has set an error message, and
we are just propagating it */
The error handling revamp will take place in two phases:
- Phase 1: Replace all pieces of code that return direct error codes
with calls to `git__throw`. This can be done semi-automatically
using `ack` to locate all the error codes that must be replaced.
- Phase 2: Add some `git__rethrow` calls in those cases where the
original error messages are not specific enough.
Phase 1 is the main goal. A minor libgit2 release will be shipped once
Phase 1 is ready, and the work will start on gradually improving the
error handling mechanism by refining specific error messages.
OTHER NOTES:
- When writing error messages, please refrain from using weasel
words. They add verbosity to the message without giving any real
information. (<3 Emeric)
E.g.
"The reference file appears to be missing a carriage return"
Nope.
"The reference file is missing a carriage return"
Yes.
- When calling `git__throw`, please try to use more generic error
codes so we can eventually reduce the list of error codes to
something more reasonable. Feel free to add new, more generic error
codes if these are going to replace several of the old ones.
E.g.
return GIT_EREFCORRUPTED;
Can be turned into:
return git__throw(GIT_EOBJCORRUPTED,
"The reference is corrupted");
|
|
cc3b82e3
|
2011-05-02T15:29:50
|
|
Merge pull request #151 from carlosmn/root-commit.
Support root commits
|
|
1648fbd3
|
2011-05-02T01:12:53
|
|
Re-apply missing patches
|
|
68a146c1
|
2011-04-29T11:45:42
|
|
refs: don't loose info on resolve error
Typical use is git_reference_resolve(&ref, ref). Currently, if there is
an error, ref will point to NULL, causing the user to lose that
reference.
Always update resolved_ref instead of just on finding an OID ref,
storing the last valid reference in it.
This change helps simplify the code for allowing root commits.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
|
|
402a47a7
|
2011-04-26T11:29:05
|
|
Fix -Wunused-but-set-variable warnings
As of gcc 4.6 -Wall includes -Wunused-but-set-variable. Use GIT_UNUSED
or remove actually unused variables to prevent those warnings.
|
|
df30eac1
|
2011-04-21T10:38:37
|
|
refs: Allow MERGE_HEAD in normalize_name()
Do not return with EINVALIDREFNAME when trying to normalize MERGE_HEAD's
name.
|
|
1bfa053e
|
2011-04-13T21:57:35
|
|
Close an object in packed_find_peel
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
|
|
d79f1da6
|
2011-04-08T12:14:33
|
|
refs: Fix issue when packing weak tags
Weak tags (e.g. tags that point directly to a normal object instead of a
tag object) were failing to be packed.
|
|
83c95128
|
2011-03-24T14:15:00
|
|
normalize_name: allow more references under refs/
Allow any well-formed reference name to live under refs/ removing the
condition that they be under refs/{heads,tags,remotes}/ as was the
design of git.
An exception is made for HEAD which is allowed to contain an OID
reference in detached HEAD state.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
|
|
9a53df7e
|
2011-03-29T19:40:02
|
|
refs: Don't allow references to inexistent OIDs
|
|
95cde17c
|
2011-03-29T19:22:21
|
|
Enforce coding conventions in refs.c
Internal methods are static and without the git prefix.
'Force' methods have a `_f` prefix to match the other 'force' methods.
|
|
dad4a4d5
|
2011-03-29T10:47:48
|
|
rename: don't return early if the target ref exists
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
|
|
fa204962
|
2011-03-28T12:00:50
|
|
Allow forcing the creation or renaming of references
Add internal reference create and rename functions which take a force
parameter, telling them to overwrite an existing reference if it
exists.
These functions try to update the reference if it's of the same type
as the one it's going to be replaced by. Otherwise the old reference
becomes invalid.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
|
|
09e8de0f
|
2011-03-25T23:53:38
|
|
New external API method: `git_reference_listcb`
List all the references in the repository, calling a custom
callback for each one.
The listed references may be filtered by type, or using
a bitwise OR of several types. Use the magic value
`GIT_REF_LISTALL` to obtain all references, including
packed ones.
The `callback` function will be called for each of the references
in the repository, and will receive the name of the reference and
the `payload` value passed to this method.
|
|
567fc1d2
|
2011-03-22T12:47:53
|
|
refs loose_lookup: also free the buffer on success
Free the ref_file buffer at the end of the function also on
success. This fixes a small memory leak.
|
|
7341bf87
|
2011-03-16T23:13:28
|
|
Refs are now always in-sync on disk
|
|
b5abb881
|
2011-03-15T19:55:01
|
|
Do not segfault when listing unpacked references
|
|
7ad96e51
|
2011-03-15T05:38:50
|
|
Remove duplicate refs in `git_reference_listall`
|
|
7c8a7b91
|
2011-03-15T02:45:49
|
|
Skip the optional header in packed-refs files
|
|
6b2a1941
|
2011-03-12T23:09:16
|
|
Fix the retarded object interdependency system
It's no longer retarded. All object interdependencies are stored as OIDs
instead of actual objects. This should be hundreds of times faster,
specially on big repositories. Heck, who knows, maye it doesn't even
segfault -- wouldn't that be awesome?
What has changed on the API?
`git_commit_parent`, `git_commit_tree`, `git_tag_target` now return
their values through a pointer-to-pointer, and have an error code.
`git_commit_set_tree` and `git_tag_set_target` now return an error
code and may fail.
`git_repository_free__no_gc` has been deprecated because it's
stupid. Since there are no longer any interdependencies between
objects, we don't need internal reference counting, and GC
never fails or double-free's pointers.
`git_object_close` now does a very sane thing: marks an object
as unused. Closed objects will be eventually free'd from the
object cache based on LRU. Please use `git_object_close` from
the garbage collector `destroy` method on your bindings. It's
100% safe.
`git_repository_gc` is a new method that forces a garbage collector
pass through the repo, to free as many LRU objects as possible.
This is useful if we are running out of memory.
|
|
00571828
|
2011-03-12T16:04:46
|
|
Add new method `git_reference_listall`
Lists all the references in a repository. Listing may be filtered by
reference type.
This should applease Lord Clem.
|
|
55ffebe3
|
2011-03-05T14:34:32
|
|
Fix creation of deeply-rooted references
Use a new `gitfo_creat_force` that will create the full path to a file
before creating it.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
e06dd9b6
|
2011-03-04T15:23:52
|
|
Fix 'possibly uninitialized variable' warning
|
|
8f90ced5
|
2011-03-03T19:55:48
|
|
Fix corner case in reference renaming
Renaming a packed reference should not pack another reference
which happens to be in both loose and pack state.
|
|
86d7e1ca
|
2011-02-28T12:46:13
|
|
Fix searching in git_vector
We now store only one sorting callback that does entry comparison. This
is used when sorting the entries using a quicksort, and when looking for
a specific entry with the new search methods.
The following search methods now exist:
git_vector_search(vector, entry)
git_vector_search2(vector, custom_search_callback, key)
git_vector_bsearch(vector, entry)
git_vector_bsearch2(vector, custom_search_callback, key)
The sorting state of the vector is now stored internally.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
5de079b8
|
2011-02-28T12:12:26
|
|
Change the object creation/lookup API
The methods previously known as
git_repository_lookup
git_repository_newobject
git_repository_lookup_ref
are now part of their respective namespaces:
git_object_lookup
git_object_new
git_reference_lookup
This makes the API more consistent with the new references API.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
5ad0351d
|
2011-03-03T19:58:07
|
|
Fix reference removal: remove packed refs together with loose ones
|
|
129007b4
|
2011-03-03T19:43:11
|
|
Fix refs renaming to prevent renaming with an invalid name
|
|
19a30a3f
|
2011-03-03T19:53:17
|
|
Add new move function, `gitfo_mv_force`
Forces a move by creating the folder for the destination file, if it
doesn't exist.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
e2d42622
|
2011-03-03T19:41:27
|
|
Fix reference renaming to prevent duplicated names
|
|
76f7cf70
|
2011-03-03T19:38:54
|
|
Fix reference renaming implementation to match standard git behavior
|
|
0594e3ef
|
2011-03-03T19:36:54
|
|
Prevent _dirent_loose_load() from choking on empty folders
|
|
87d3acf4
|
2011-02-27T22:31:43
|
|
Finish the References API
The following methods have been implemented:
git_reference_packall
git_reference_rename
git_reference_delete
The library now has full support for packed references, including
partial and total writing. Internal documentation has been updated with
the details.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
86194b24
|
2011-02-18T21:57:53
|
|
Split packed from unpacked references
These two reference types are now stored separately to eventually allow
the removal/renaming of loose references and rewriting of the refs
packfile.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
32054c24
|
2011-02-18T18:09:19
|
|
Brush up the refs API
Changed some more API details and updated documentation.
Sketched API for addition/removal of entries.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
1d8cc731
|
2011-02-14T22:29:22
|
|
Refactored the reference creation API.
|
|
e1be1028
|
2011-02-13T20:18:35
|
|
Added some more tests to ensure the correct behavior of git_reference__normalize_name().
|
|
aa2120e9
|
2011-02-10T15:08:00
|
|
Added git_reference__normalize_name() along with tests.
|
|
fc658755
|
2011-02-22T21:59:36
|
|
Rewrite git_hashtable internals
The old hash table with chained buckets has been replaced by a new one
using Cuckoo hashing, which offers guaranteed constant lookup times.
This should improve speeds on most use cases, since hash tables in
libgit2 are usually used as caches where the objects are stored once and
queried several times.
The Cuckoo hash implementation is based off the one in the Basekit
library [1] for the IO language, but rewritten to support an arbritrary
number of hashes. We currently use 3 to maximize the usage of the nodes pool.
[1]: https://github.com/stevedekorte/basekit/blob/master/source/CHash.c
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
817c2820
|
2011-02-21T17:05:16
|
|
Rewrite all file IO for more performance
The new `git_filebuf` structure provides atomic high-performance writes
to disk by using a write cache, and optionally a double-buffered scheme
through a worker thread (not enabled yet).
Writes can be done 3-layered, like in git.git (user code -> write cache
-> disk), or 2-layered, by writing directly on the cache. This makes
index writing considerably faster.
The `git_filebuf` structure contains all the old functionality of
`git_filelock` for atomic file writes and reads. The `git_filelock`
structure has been removed.
Additionally, the `git_filebuf` API allows to automatically hash (SHA1)
all the data as it is written to disk (hashing is done smartly on big
chunks to improve performance).
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
995f9c34
|
2011-02-09T12:43:19
|
|
Use the new git__joinpath to build paths in methods
The `git__joinpath` function has been changed to use a statically
allocated buffer; we assume the buffer to be 4096 bytes, because fuck
you.
The new method also supports an arbritrary number of paths to join,
which may come in handy in the future.
Some methods which were manually joining paths with `strcpy` now use the
new function, namely those in `index.c` and `refs.c`.
Based on Emeric Fermas' original patch, which was using the old
`git__joinpath` because I'm stupid. Thanks!
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
ddc9e79a
|
2011-02-02T06:16:50
|
|
Fix more issues with Win32 EOL
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
ff5873ad
|
2011-02-02T04:01:14
|
|
Fix EOL issues in ref parsing under Win32
Reference files can be loaded using Win32 line endings, too.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
2f8a8ab2
|
2011-01-29T01:56:25
|
|
Refactor reference parsing code
Several changes have been committed to allow the user to create
in-memory references and write back to disk. Peeling of symbolic
references has been made explicit. Added getter and setter methods for
all attributes on a reference. Added corresponding documentation.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
9282e921
|
2010-12-27T20:34:19
|
|
Merge nulltoken's reference parsing code
All the commits have been squashed into a single one before refactoring
the final code, to keep everything tidy.
Individual commit messages are as follows:
Added repository reference looking up functionality placeholder.
Added basic reference database definition and caching infrastructure.
Removed useless constant.
Added GIT_EINVALIDREFNAME error and description. Added missing description for GIT_EBAREINDEX.
Added GIT_EREFCORRUPTED error and description.
Added GIT_ETOONESTEDSYMREF error and description.
Added resolving of direct and symbolic references.
Prepared the packed-refs parsing.
Added parsing of the packed-refs file content.
When no loose reference has been found, the full content of the packed-refs file is parsed. All of the new (i.e. not previously parsed as a loose reference) references are eagerly stored in the cached references storage.
The method packed_reference_file__parse() is in deer need of some refactoring. :-)
Extracted to a method the parsing of the peeled target of a tag.
Extracted to a method the parsing of a standard packed ref.
Fixed leaky removal of the cached references.
Ensured that a previously parsed packed reference isn't returned if a more up-to-date loose reference exists.
Enhanced documentation of git_repository_reference_lookup().
Moved some refs related constants from repository.c to refs.h.
Made parsing of a packed tag reference more robust.
Updated git_repository_reference_lookup() documentation.
Added some references to the test repository.
Added some tests covering tag references looking up.
Added some tests covering symbolic and head references looking up.
Added some tests covering packed references looking up.
|