- 09 May, 2011 4 commits
-
-
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");
Vicent Marti committed -
Vicent Marti committed
-
Vicent Marti committed
-
Vicent Marti committed
-
- 06 May, 2011 2 commits
-
-
Fix two warnings from Clang. Fixes issue #173
Vicent Martí committed -
Both are about not reading the value stored in a variable. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto committed
-
- 02 May, 2011 2 commits
-
-
Support root commits
Vicent Martí committed -
Fix tree-entry attribute convertion (fix corrupted trees)
Vicent Martí committed
-
- 01 May, 2011 6 commits
-
-
Vicent Marti committed
-
Fix -Wunused-but-set-variable warnings
Vicent Martí committed -
Fix memory leak in pack_backend__free
Vicent Martí committed -
Isolate "writing" refs tests in a temporary folder
Vicent Martí committed -
Change implementation of refs tests that alter the current repository to make them run against a temporary clone of the test repository
nulltoken committed -
Do not check the folder's size to detect new packfiles at runtime. This doesn't work on Win32.
Vicent Marti committed
-
- 29 Apr, 2011 3 commits
-
-
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto committed -
A root commit is a commit whose branch (usually what HEAD points to) doesn't exist (yet). This situation can happen when the commit is the first after 1) a repository is initialized or 2) a orphan checkout has been performed. Take this opportunity to remove the symbolic link check, as git_reference_resolve works on OID refs as well. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto committed -
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>
Carlos Martín Nieto committed
-
- 27 Apr, 2011 1 commit
-
-
Sergey Nikishin committed
-
- 26 Apr, 2011 2 commits
-
-
Magic constant replaced by direct to-string covertion because of: 1) with value length 6 (040000 - subtree) final tree will be corrupted; 2) for wrong values length <6 final tree will be corrupted too.
Sergey Nikishin committed -
As of gcc 4.6 -Wall includes -Wunused-but-set-variable. Use GIT_UNUSED or remove actually unused variables to prevent those warnings.
schu committed
-
- 23 Apr, 2011 7 commits
-
-
index.h: Add IDXENTRY flags needed for index operations
Vicent Martí committed -
Fix memory leaks in the tests
Vicent Martí committed -
refs: Allow MERGE_HEAD in normalize_name()
Vicent Martí committed -
Removed the optional `replace` argument, we now have 4 add methods: `git_index_add`: add or update from path `git_index_add2`: add or update from struct `git_index_append`: add without replacing from path `git_index_append2`: add without replacing from struct Yes, this breaks the bindings.
Vicent Marti committed -
index: Allow user to toggle whether to replace an index entry
Vicent Martí committed -
Fix going into infinite loop in read_header_loose()
Vicent Martí committed -
Vicent Marti committed
-
- 22 Apr, 2011 1 commit
-
-
read_header_loose causes infinite loop on this file: $ cat ../libcppgit/bin/sample-repo/test_mailbox/.git/objects/8f/e274605cbc740a2a957f44b2722a8a73915a09 | base64 eAErKUpNVTAzYzA0MDAzMVHISUxKzSlmWLgkuyN5+rxr6juMPR2EmN8s7Vl9D6oiN7UkkcHJdLbl 7Z3N/oxfE0W8wrSbuFRkAwDFfBn1
Sergey Nikishin committed
-
- 21 Apr, 2011 6 commits
-
-
fix solaris build --- Before this patch the build failure looked like: ... ../../deps/zlib/inffast.c: In function `inflate_fast': ../../deps/zlib/inffast.c:324: warning: visibility attribute not supported in this configuration; ignored [34/38] c: src/revwalk.c -> build/shared/src/revwalk.c.0.o ../../deps/zlib/inftrees.c: In function `inflate_table': ../../deps/zlib/inftrees.c:330: warning: visibility attribute not supported in this configuration; ignored [35/38] c: deps/zlib/zutil.c -> build/shared/deps/zlib/zutil.c.0.o [36/38] c: deps/zlib/trees.c -> build/shared/deps/zlib/trees.c.0.o ../../deps/zlib/zutil.c: In function `zcalloc': ../../deps/zlib/zutil.c:308: warning: visibility attribute not supported in this configuration; ignored ../../deps/zlib/zutil.c: In function `zcfree': ../../deps/zlib/zutil.c:316: warning: visibility attribute not supported in this configuration; ignored ../../deps/zlib/trees.c:1244: warning: visibility attribute not supported in this configuration; ignored ../../deps/zlib/trees.c:1244: warning: visibility attribute not supported in this configuration; ignored ../../deps/zlib/trees.c: In function `_tr_init': ../../deps/zlib/trees.c:410: warning: visibility attribute not supported in this configuration; ignored ../../deps/zlib/trees.c: In function `_tr_align': ../../deps/zlib/trees.c:919: warning: visibility attribute not supported in this configuration; ignored ../../deps/zlib/trees.c: In function `_tr_stored_block': ../../deps/zlib/trees.c:883: warning: visibility attribute not supported in this configuration; ignored ../../deps/zlib/trees.c: In function `_tr_flush_block': ../../deps/zlib/trees.c:1020: warning: visibility attribute not supported in this configuration; ignored ../../deps/zlib/trees.c: In function `_tr_tally': ../../deps/zlib/trees.c:1071: warning: visibility attribute not supported in this configuration; ignored [37/38] cshlib: build/shared/src/blob.c.0.o build/shared/src/cache.c.0.o build/shared/src/commit.c.0.o build/shared/src/delta-apply.c.0.o build/shared/src/errors.c.0.o build/shared/src/filebuf.c.0.o build/shared/src/fileops.c.0.o build/shared/src/hash.c.0.o build/shared/src/hashtable.c.0.o build/shared/src/index.c.0.o build/shared/src/object.c.0.o build/shared/src/odb.c.0.o build/shared/src/odb_loose.c.0.o build/shared/src/odb_pack.c.0.o build/shared/src/oid.c.0.o build/shared/src/pqueue.c.0.o build/shared/src/refs.c.0.o build/shared/src/repository.c.0.o build/shared/src/revwalk.c.0.o build/shared/src/signature.c.0.o build/shared/src/tag.c.0.o build/shared/src/thread-utils.c.0.o build/shared/src/tree.c.0.o build/shared/src/util.c.0.o build/shared/src/vector.c.0.o build/shared/src/unix/map.c.0.o build/shared/src/backends/hiredis.c.0.o build/shared/src/backends/sqlite.c.0.o build/shared/deps/zlib/adler32.c.0.o build/shared/deps/zlib/deflate.c.0.o build/shared/deps/zlib/inffast.c.0.o build/shared/deps/zlib/inflate.c.0.o build/shared/deps/zlib/inftrees.c.0.o build/shared/deps/zlib/trees.c.0.o build/shared/deps/zlib/zutil.c.0.o build/shared/src/block-sha1/sha1.c.0.o -> build/shared/libgit2.so ld: fatal: relocation error: R_386_GOTOFF: file deps/zlib/deflate.c.0.o: symbol zcfree: a GOT relative relocation must reference a local symbol ld: fatal: relocation error: R_386_GOTOFF: file deps/zlib/deflate.c.0.o: symbol zcalloc: a GOT relative relocation must reference a local symbol ld: fatal: relocation error: R_386_GOTOFF: file deps/zlib/deflate.c.0.o: symbol _length_code: a GOT relative relocation must reference a local symbol ld: fatal: relocation error: R_386_GOTOFF: file deps/zlib/deflate.c.0.o: symbol _dist_code: a GOT relative relocation must reference a local symbol ld: fatal: relocation error: R_386_GOTOFF: file deps/zlib/deflate.c.0.o: symbol _length_code: a GOT relative relocation must reference a local symbol ld: fatal: relocation error: R_386_GOTOFF: file deps/zlib/deflate.c.0.o: symbol _dist_code: a GOT relative relocation must reference a local symbol ld: fatal: relocation error: R_386_GOTOFF: file deps/zlib/deflate.c.0.o: symbol _dist_code: a GOT relative relocation must reference a local symbol ld: fatal: relocation error: R_386_GOTOFF: file deps/zlib/deflate.c.0.o: symbol _length_code: a GOT relative relocation must reference a local symbol ld: fatal: relocation error: R_386_GOTOFF: file deps/zlib/deflate.c.0.o: symbol _dist_code: a GOT relative relocation must reference a local symbol ld: fatal: relocation error: R_386_GOTOFF: file deps/zlib/deflate.c.0.o: symbol _dist_code: a GOT relative relocation must reference a local symbol collect2: ld returned 1 exit status Waf: Leaving directory `/home/node/src/libgit2/build/shared' Build failed -> task failed (exit status 1): {task 138650764: cshlib blob.c.0.o,cache.c.0.o,commit.c.0.o,delta-apply.c.0.o,errors.c.0.o,filebuf.c.0.o,fileops.c.0.o,hash.c.0.o,hashtable.c.0.o,index.c.0.o,object.c.0.o,odb.c.0.o,odb_loose.c.0.o,odb_pack.c.0.o,oid.c.0.o,pqueue.c.0.o,refs.c.0.o,repository.c.0.o,revwalk.c.0.o,signature.c.0.o,tag.c.0.o,thread-utils.c.0.o,tree.c.0.o,util.c.0.o,vector.c.0.o,map.c.0.o,hiredis.c.0.o,sqlite.c.0.o,adler32.c.0.o,deflate.c.0.o,inffast.c.0.o,inflate.c.0.o,inftrees.c.0.o,trees.c.0.o,zutil.c.0.o,sha1.c.0.o -> libgit2.so} ['/home/node/local/bin/gcc', '', 'src/blob.c.0.o', 'src/cache.c.0.o', 'src/commit.c.0.o', 'src/delta-apply.c.0.o', 'src/errors.c.0.o', 'src/filebuf.c.0.o', 'src/fileops.c.0.o', 'src/hash.c.0.o', 'src/hashtable.c.0.o', 'src/index.c.0.o', 'src/object.c.0.o', 'src/odb.c.0.o', 'src/odb_loose.c.0.o', 'src/odb_pack.c.0.o', 'src/oid.c.0.o', 'src/pqueue.c.0.o', 'src/refs.c.0.o', 'src/repository.c.0.o', 'src/revwalk.c.0.o', 'src/signature.c.0.o', 'src/tag.c.0.o', 'src/thread-utils.c.0.o', 'src/tree.c.0.o', 'src/util.c.0.o', 'src/vector.c.0.o', 'src/unix/map.c.0.o', 'src/backends/hiredis.c.0.o', 'src/backends/sqlite.c.0.o', 'deps/zlib/adler32.c.0.o', 'deps/zlib/deflate.c.0.o', 'deps/zlib/inffast.c.0.o', 'deps/zlib/inflate.c.0.o', 'deps/zlib/inftrees.c.0.o', 'deps/zlib/trees.c.0.o', 'deps/zlib/zutil.c.0.o', 'src/block-sha1/sha1.c.0.o', '-o', '', '/home/node/src/libgit2/build/shared/libgit2.so', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-shared', '-Wl,-h,libgit2.so.0'] ... If helpful, here is the equivalent error with varnish: http://www.varnish-cache.org/trac/ticket/852 and the autoconf/configure handling for the equivalent in python: http://hg.python.org/cpython/file/96e0e79d33de/Modules/zlib/configure#l513 So a better fix would probably be to reproduce that configure logic (see similar in the Varnish patch) ... but I'm not sure if shelling out to the C compiler (however waf spells that) is wanted in wscript here. It would be great to have a libgit2 release with the quicker fix for Solaris. My actual issue is with building node-gitteh. Thanks, Trent
Vicent Martí committed -
LIBGIT2_VER_MINOR now matches LIBGIT2_VERSION (0.11.0) --- LIBGIT2_VER_MINOR was left at 10 instead of 11.
Vicent Martí committed -
LIBGIT2_VER_MINOR was left at 10 instead of 11.
Emmanuel Rodriguez committed -
When in the middle of a merge, the index needs to contain several files with the same name. git_index_insert() used to prevent this by not adding a new entry if an entry with the same name already existed.
Jakob Pfender committed -
Do not return with EINVALIDREFNAME when trying to normalize MERGE_HEAD's name.
Jakob Pfender committed -
Before this patch the build failure looked like: ... ../../deps/zlib/inftrees.c:330: warning: visibility attribute not supported in this configuration; ignored ... ld: fatal: relocation error: R_386_GOTOFF: file deps/zlib/deflate.c.0.o: symbol zcfree: a GOT relative relocation must reference a local symbol ...
Trent Mick committed
-
- 15 Apr, 2011 3 commits
-
-
Vicent Marti committed
-
Vicent Marti committed
-
Fixes the issue where object lookups were failing right after a pull on an open repository.
Vicent Marti committed
-
- 13 Apr, 2011 3 commits
-
-
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto committed -
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto committed -
If we don't create any leaks in the tests, we can use them to search for leaks in the implementation. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto committed
-