src/oid.c


Log

Author Commit Date CI Message
nulltoken 34aff010 2011-10-12T14:06:23 oid: Add git_oid_streq() which checks if an oid and an hex formatted string are equal
J. David Ibáñez 0e058e78 2011-10-02T21:40:57 oid: add missing check to git_oid_fromstrn Signed-off-by: J. David Ibáñez <jdavid.ibp@gmail.com>
J. David Ibáñez b9caa185 2011-09-30T19:50:13 oid: now git_oid_fromstrn checks whether the given string is too short Signed-off-by: J. David Ibáñez <jdavid.ibp@gmail.com>
J. David Ibáñez 6d8d3f19 2011-09-30T19:41:29 oid: optimize git_oid_fromstrn by using memset Signed-off-by: J. David Ibáñez <jdavid.ibp@gmail.com>
J. David Ibáñez e724b058 2011-09-30T19:08:48 oid: make git_oid_fromstrn support hex strings of odd length This fixes issue #433. Signed-off-by: J. David Ibáñez <jdavid.ibp@gmail.com>
Vicent Marti 87d9869f 2011-09-19T03:34:49 Tabify everything There were quite a few places were spaces were being used instead of tabs. Try to catch them all. This should hopefully not break anything. Except for `git blame`. Oh well.
Vicent Marti bb742ede 2011-09-19T01:54:32 Cleanup legal data 1. The license header is technically not valid if it doesn't have a copyright signature. 2. The COPYING file has been updated with the different licenses used in the project. 3. The full GPLv2 header in each file annoys me.
Vicent Marti 06c43821 2011-07-09T02:37:16 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.
Vicent Marti afeecf4f 2011-07-09T02:10:46 odb: Direct writes are back DIRECT WRITES ARE BACK AND FASTER THAN EVER. The streaming writer to the ODB was an overkill for the smaller objects like Commit and Tags; most of the streaming logic was taking too long. This commit makes Commits, Tags and Trees to be built-up in memory, and then written to disk in 2 pushes (header + data), instead of streaming everything. This is *always* faster, even for big files (since the git_filebuf class still does streaming writes when the memory cache overflows). This is also a gazillion lines of code smaller, because we don't have to precompute the final size of the object before starting the stream (this was kind of defeating the point of streaming, anyway). Blobs are still written with full streaming instead of loading them in memory, since this is still the fastest way. A new `git_buf` class has been added. It's missing some features, but it'll get there.
Vicent Marti f0ab9fda 2011-07-08T18:22:44 index: Return `GIT_ENOTFOUND` when an entry cannot be opened
Kirill A. Shutemov 932d1baf 2011-06-30T19:52:34 cleanup: remove trailing spaces Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Vicent Marti 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.
Vicent Marti f1d01851 2011-06-16T02:48:48 oid: Uniformize ncmp methods Drop redundant methods. The ncmp method is now public
Vicent Marti 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.
Scott Chacon 737406b7 2011-06-14T09:31:19 fix gid_ misspelling
Marc Pegon c09093cc 2011-06-06T10:55:36 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.
Marc Pegon da03c9f3 2011-05-29T11:45:34 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 53c0bd81 2011-05-27T22:37:10 Added error for ambiguous oid prefixes. Added methods to compare the first nth hexadecimal characters (i.e. packets of 4 bits) of OIDs.
Jakob Pfender bea54842 2011-05-19T13:50:46 oid.c: Move to new error handling mechanism
Vicent Marti 720d5472 2011-04-02T12:42:04 Change `parse` methods to const buffer Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti 72a3fe42 2011-03-18T19:38:49 I broke your bindings Hey. Apologies in advance -- I broke your bindings. This is a major commit that includes a long-overdue redesign of the whole object-database structure. This is expected to be the last major external API redesign of the library until the first non-alpha release. Please get your bindings up to date with these changes. They will be included in the next minor release. Sorry again! Major features include: - Real caching and refcounting on parsed objects - Real caching and refcounting on objects read from the ODB - Streaming writes & reads from the ODB - Single-method writes for all object types - The external API is now partially thread-safe The speed increases are significant in all aspects, specially when reading an object several times from the ODB (revwalking) and when writing big objects to the ODB. Here's a full changelog for the external API: blob.h ------ - Remove `git_blob_new` - Remove `git_blob_set_rawcontent` - Remove `git_blob_set_rawcontent_fromfile` - Rename `git_blob_writefile` -> `git_blob_create_fromfile` - Change `git_blob_create_fromfile`: The `path` argument is now relative to the repository's working dir - Add `git_blob_create_frombuffer` commit.h -------- - Remove `git_commit_new` - Remove `git_commit_add_parent` - Remove `git_commit_set_message` - Remove `git_commit_set_committer` - Remove `git_commit_set_author` - Remove `git_commit_set_tree` - Add `git_commit_create` - Add `git_commit_create_v` - Add `git_commit_create_o` - Add `git_commit_create_ov` tag.h ----- - Remove `git_tag_new` - Remove `git_tag_set_target` - Remove `git_tag_set_name` - Remove `git_tag_set_tagger` - Remove `git_tag_set_message` - Add `git_tag_create` - Add `git_tag_create_o` tree.h ------ - Change `git_tree_entry_2object`: New signature is `(git_object **object_out, git_repository *repo, git_tree_entry *entry)` - Remove `git_tree_new` - Remove `git_tree_add_entry` - Remove `git_tree_remove_entry_byindex` - Remove `git_tree_remove_entry_byname` - Remove `git_tree_clearentries` - Remove `git_tree_entry_set_id` - Remove `git_tree_entry_set_name` - Remove `git_tree_entry_set_attributes` object.h ------------ - Remove `git_object_new - Remove `git_object_write` - Change `git_object_close`: This method is now *mandatory*. Not closing an object causes a memory leak. odb.h ----- - Remove type `git_rawobj` - Remove `git_rawobj_close` - Rename `git_rawobj_hash` -> `git_odb_hash` - Change `git_odb_hash`: New signature is `(git_oid *id, const void *data, size_t len, git_otype type)` - Add type `git_odb_object` - Add `git_odb_object_close` - Change `git_odb_read`: New signature is `(git_odb_object **out, git_odb *db, const git_oid *id)` - Change `git_odb_read_header`: New signature is `(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id)` - Remove `git_odb_write` - Add `git_odb_open_wstream` - Add `git_odb_open_rstream` odb_backend.h ------------- - Change type `git_odb_backend`: New internal signatures are as follows int (* read)(void **, size_t *, git_otype *, struct git_odb_backend *, const git_oid *) int (* read_header)(size_t *, git_otype *, struct git_odb_backend *, const git_oid *) int (* writestream)(struct git_odb_stream **, struct git_odb_backend *, size_t, git_otype) int (* readstream)( struct git_odb_stream **, struct git_odb_backend *, const git_oid *) - Add type `git_odb_stream` - Add enum `git_odb_streammode` Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti 26022f07 2011-03-05T23:54:49 Add `git_oid_shorten` (unique OID minimzer) Set of methods to find the minimal-length to uniquely identify every OID in a list. Useful for GUI applications, commit logs and so on. Includes stress test. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti 86627121 2011-03-06T00:03:31 Fix type-conversion warning in MSVC Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti d6b5f5cc 2011-03-05T23:54:49 Add `git_oid_shorten` Set of methods to find the minimal-length to uniquely identify every OID in a list. Includes stress test. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti 44908fe7 2010-12-06T23:03:16 Change the library include file Libgit2 is now officially include as #include "<git2.h>" or indidividual files may be included as #include <git2/index.h> Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti d12299fe 2010-12-03T22:22:10 Change include structure for the project The maze with include dependencies has been fixed. There is now a global include: #include <git.h> The git_odb_backend API has been exposed. Signed-off-by: Vicent Marti <tanoku@gmail.com>
nulltoken 6f02c3ba 2010-12-05T20:18:56 Small source code readability improvements. Replaced magic number "0" with GIT_SUCCESS constant wherever it made sense.
Vicent Marti 58519018 2010-10-28T02:07:18 Fix internal memory management on the library String mememory is now managed in a much more sane manner. Fixes include: - git_person email and name is no longer limited to 64 characters - git_tree_entry filename is no longer limited to 255 characters - raw objects are properly opened & closed the minimum amount of times required for parsing - unit tests no longer leak - removed 5 other misc memory leaks as reported by Valgrind - tree writeback no longer segfaults on rare ocassions The git_person struct is no longer public. It is now managed by the library, and getter methods are in place to access its internal attributes. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Ramsay Jones 552e23ba 2010-06-02T19:16:28 Fix a bug in the git_oid_to_string() function When git_oid_to_string() was passed a buffer size larger than GIT_OID_HEXSZ+1, the function placed the c-string NUL char at the wrong position. Fix the code to place the NUL at the end of the (possibly truncated) oid string. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 0ef9d2aa 2010-01-03T22:56:54 Fix some "signed v unsigned comparison" warnings with -Wextra Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 960ca1d7 2009-08-28T21:22:46 Add the git_oid_to_string() utility function Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Shawn O. Pearce 64a47c01 2008-12-30T23:21:36 Wrap malloc and friends and report out of memory as GIT_ENOMEM We now forbid direct use of malloc, strdup or calloc within the library and instead use wrapper functions git__malloc, etc. to invoke the underlying library malloc and set git_errno to a no memory error code if the allocation fails. In the future once we have pack objects in memory we are likely to enhance these routines with garbage collection logic to purge cached pack data when allocations fail. Because the size of the function will grow somewhat large, we don't want to mark them for inline as gcc tends to aggressively inline, creating larger than expected executables. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Julio Espinoza-Sokal 213e720c 2008-12-20T20:47:41 Change usages of static inline to GIT_INLINE Signed-off-by: Julio Espinoza-Sokal <julioes@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Ramsay Jones b3be0fc7 2008-12-03T23:54:47 Fix an "implicit function definition" warning on cygwin In particular, the warning relates to malloc(), which is declared in <stdlib.h>. This header is now included, indirectly, via the "common.h" header. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce af795e49 2008-12-02T09:56:23 Add routines to convert git_oid to hex strings [sp: Credit for some of this implementation goes to Pieter, I started off a patch he proposed for libgit2 but reworked enough of it that I don't want to blame him for any bugs.] Suggested-by: Pieter de Bie <pdebie@ai.rug.nl> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce b7c891c6 2008-11-03T17:31:16 Add git_oid_cpy, git_oid_cmp as inline functions These are easily built off the standard C library functions memcpy and memcmp. By marking these inline we stand a good chance of the C compiler replacing the entire thing with tight machine code, because many compilers will actually inline a memcmp or memcpy when the 3rd argument (the size) is a constant value. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce b3a2f90e 2008-11-03T18:00:49 Enable warnings by default and fix warning in oid.c Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce 50298f44 2008-11-01T15:55:01 Switch the license from BSD to GPL+libgcc exception Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce d1ea30c3 2008-11-01T15:42:23 Move include files to include/git/, drop git_ prefix from file names Signed-off-by: Shawn O. Pearce <spearce@spearce.org>