Commit Graph

6351 Commits

Author SHA1 Message Date
Russell Belfer
f10d7a368f Further callback error check style fixes
Okay, I've decided I like the readability of this style much
better so I used it everywhere.
2013-12-11 10:57:50 -08:00
Russell Belfer
c7b3e1b320 Some callback error check style cleanups
I find this easier to read...
2013-12-11 10:57:50 -08:00
Russell Belfer
60058018dc Fix C99 __func__ for MSVC 2013-12-11 10:57:50 -08:00
Russell Belfer
25e0b1576d Remove converting user error to GIT_EUSER
This changes the behavior of callbacks so that the callback error
code is not converted into GIT_EUSER and instead we propagate the
return value through to the caller.  Instead of using the
giterr_capture and giterr_restore functions, we now rely on all
functions to pass back the return value from a callback.

To avoid having a return value with no error message, the user
can call the public giterr_set_str or some such function to set
an error message.  There is a new helper 'giterr_set_callback'
that functions can invoke after making a callback which ensures
that some error message was set in case the callback did not set
one.

In places where the sign of the callback return value is
meaningful (e.g. positive to skip, negative to abort), only the
negative values are returned back to the caller, obviously, since
the other values allow for continuing the loop.

The hardest parts of this were in the checkout code where positive
return values were overloaded as meaningful values for checkout.
I fixed this by adding an output parameter to many of the internal
checkout functions and removing the overload.  This added some
code, but it is probably a better implementation.

There is some funkiness in the network code where user provided
callbacks could be returning a positive or a negative value and
we want to rely on that to cancel the loop.  There are still a
couple places where an user error might get turned into GIT_EUSER
there, I think, though none exercised by the tests.
2013-12-11 10:57:49 -08:00
Russell Belfer
fcd324c625 Add git_vector_free_all
There are a lot of places that we call git__free on each item in
a vector and then call git_vector_free on the vector itself.  This
just wraps that up into one convenient helper function.
2013-12-11 10:57:49 -08:00
Russell Belfer
dab89f9b68 Further EUSER and error propagation fixes
This continues auditing all the places where GIT_EUSER is being
returned and making sure to clear any existing error using the
new giterr_user_cancel helper.  As a result, places that relied
on intercepting GIT_EUSER but having the old error preserved also
needed to be cleaned up to correctly stash and then retrieve the
actual error.

Additionally, as I encountered places where error codes were not
being propagated correctly, I tried to fix them up.  A number of
those fixes are included in the this commit as well.
2013-12-11 10:57:49 -08:00
Russell Belfer
96869a4edb Improve GIT_EUSER handling
This adds giterr_user_cancel to return GIT_EUSER and clear any
error message that is sitting around.  As a result of using that
in places, we need to be more thorough with capturing errors that
happen inside a callback when used internally.  To help with that,
this also adds giterr_capture and giterr_restore so that when we
internally use a foreach-type function that clears errors and
converts them to GIT_EUSER, it is easier to restore not just the
return value, but the actual error message text.
2013-12-11 10:57:49 -08:00
Russell Belfer
9f77b3f6f5 Add config read fns with controlled error behavior
This adds `git_config__lookup_entry` which will look up a key in
a config and return either the entry or NULL if the key was not
present.  Optionally, it can either suppress all errors or can
return them (although not finding the key is not an error for this
function).  Unlike other accessors, this does not normalize the
config key string, so it must only be used when the key is known
to be in normalized form (i.e. all lower-case before the first dot
and after the last dot, with no invalid characters).

This also adds three high-level helper functions to look up config
values with no errors and a fallback value.  The three functions
are for string, bool, and int values, and will resort to the
fallback value for any error that arises.  They are:

* `git_config__get_string_force`
* `git_config__get_bool_force`
* `git_config__get_int_force`

None of them normalize the config `key` either, so they can only
be used for internal cases where the key is known to be in normal
format.
2013-12-11 10:57:49 -08:00
Russell Belfer
0eedacb06a Merge pull request #1985 from libgit2/diff-rename-config
Rename detection using diff.renames
2013-12-11 10:39:36 -08:00
Ben Straub
5a52d6be4c Check version earlier 2013-12-11 06:43:17 -08:00
Vicent Marti
65e9dc659a Merge pull request #1996 from ethomson/warnings
Clean up warnings
2013-12-09 08:55:00 -08:00
Edward Thomson
5588f07360 Clean up warnings 2013-12-09 11:40:44 -05:00
Matthew Bowen
0db9322547 Fix GIT_MERGE_OPTS_INIT on MSVC. 2013-12-09 10:44:26 -05:00
Carlos Martín Nieto
f21051297c refs: expose has_log() on the backend
The frontend used to look at the file directly, but that's obviously not
the right thing to do. Expose it on the backend and use that function
instead.
2013-12-09 15:55:11 +01:00
Carlos Martín Nieto
8d5ec9106a refs: expose a way to ensure a ref has a log
Sometimes (e.g. stash) we want to make sure that a log will be written,
even if it's not in one of the standard locations. Let's make that
easier.
2013-12-09 15:55:11 +01:00
Carlos Martín Nieto
6f13a30565 reflog: write to the reflog following git's rules
git-core only writes to the reflogs of HEAD, refs/heads/ and,
refs/notes/ or if there is already a reflog in place. Adjust our code to
follow these semantics.
2013-12-09 15:55:11 +01:00
Edward Thomson
07c5dc84fd Merge pull request #1994 from palistov/commit-cleanup
commit: Fix potential segfault
2013-12-08 12:36:48 -08:00
Paul Holden
be0a1a7958 commit: Fix potential segfault in git_commit_message
Dereferencing commit pointer before asserting
2013-12-08 10:21:13 -08:00
Vicent Marti
65e726a8ec Merge pull request #1993 from jaredlwong/development
Fixed left shift size of int.
2013-12-08 06:43:52 -08:00
Jared Wong
307a3d6762 Fixed left shift size of int.
Simply switched the ordering of the checks in the for loop where this left
shift was being made.
2013-12-08 01:50:10 -08:00
Ben Straub
a7c83aec21 Clarify docs 2013-12-06 13:39:08 -08:00
Ben Straub
7fb4147f1f Don't clobber whitespace settings 2013-12-06 13:38:59 -08:00
Ben Straub
710f383868 Clarify default value and behavior 2013-12-06 09:32:09 -08:00
Vicent Martí
c4fcae5f7c Merge pull request #1989 from palistov/blame-cleanup
blame.c: Remove unnecessary error-check and goto
2013-12-06 04:29:59 -08:00
Paul Holden
8f460f2c46 blame.c: Remove unnecessary error-check and goto
In private function 'load_blob'.
2013-12-05 20:42:14 -08:00
Ben Straub
628e92cdb3 Don't use weird return codes 2013-12-05 14:47:04 -08:00
Ben Straub
c56c6d6945 Implement GIT_DIFF_FIND_BY_CONFIG 2013-12-05 14:13:46 -08:00
Vicent Martí
98c248d7bf Merge pull request #1988 from mgbowen/fix-libssh2-windows
Fixed compilation on Windows when using libssh2.
2013-12-05 08:43:29 -08:00
mgbowen
ed5b77b0fd Fixed compilation on Windows when using libssh2. 2013-12-05 11:13:58 -05:00
Ben Straub
a6ebc2bdb3 Introduce GIT_DIFF_FIND_BY_CONFIG 2013-12-05 08:11:00 -08:00
Edward Thomson
cf297c353f Merge pull request #1984 from ethomson/revert_fix
Reorder revert test variable decls
2013-12-03 08:03:56 -08:00
Edward Thomson
d192e60b7a Reorder var decls in revert test
Oh, MSVC.
2013-12-03 10:47:18 -05:00
Vicent Martí
9f802b5b26 Merge pull request #1983 from ethomson/revert
Bare naked merge and rebase
2013-12-03 07:40:30 -08:00
Edward Thomson
eac938d96e Bare naked merge and rebase 2013-12-03 10:18:53 -05:00
Vicent Martí
553d33732a Merge pull request #1982 from linquize/revert.h
Include git2/revert.h in git2.h
2013-12-03 07:05:52 -08:00
Linquize
d706e843e1 Include git2/revert.h in git2.h 2013-12-03 23:00:50 +08:00
Vicent Martí
a149a18923 Merge pull request #1981 from jamill/download_cancel_tweaks
Updates to cancellation logic during download and indexing of packfile.
2013-12-03 02:14:28 -08:00
Vicent Martí
db0a7e39b3 Merge pull request #1977 from ethomson/revert
Revert support for a single commit
2013-12-03 02:11:55 -08:00
Jameson Miller
db4cbfe504 Updates to cancellation logic during download and indexing of packfile. 2013-12-02 23:05:10 -05:00
Edward Thomson
bab0b9f2d2 clean up state metadata more consistently 2013-12-02 16:57:41 -06:00
Edward Thomson
300d192f7e Introduce git_revert to revert a single commit 2013-12-02 16:57:41 -06:00
Vicent Martí
96fb6a647f Merge pull request #1979 from libgit2/rb/diff-find-delete-unmod
Add GIT_DIFF_FIND_REMOVE_UNMODIFIED flag and fix copy detection bug
2013-12-02 13:56:28 -08:00
Russell Belfer
f62c174d0d GIT_DIFF_FIND_REMOVE_UNMODIFIED sounds better 2013-12-02 13:49:58 -08:00
Russell Belfer
97ad85b88d Add GIT_DIFF_FIND_DELETE_UNMODIFIED flag
When doing copy detection, it is often necessary to include
UNMODIFIED records in the git_diff so they are available as source
records for GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED.  Yet in the final
diff, often you will not want to have these UNMODIFIED records.
This adds a flag which marks these UNMODIFIED records for deletion
from the diff list so they will be removed after the rename detect
phase is over.
2013-12-02 13:30:05 -08:00
Russell Belfer
2123a17f83 Fix bug making split deltas a COPIED targets
When FIND_COPIES is used in combination with BREAK_REWRITES for
rename detection, there was a bug where the split MODIFIED delta
was only used as a target for RENAME records and not for COPIED
records.  This fixes that, converting the split into a pair of
DELETED and COPIED deltas when that circumstance arises.
2013-12-02 13:27:06 -08:00
Vicent Martí
da02ebe37e Merge pull request #1978 from libgit2/rb/cmake-find-iconv
Improve iconv finding for cmake
2013-12-02 11:59:31 -08:00
Russell Belfer
726b75d1b8 Improve iconv finding for cmake
* add FindIconv helper for CMake iconv detection
* only default using iconv to ON for MacOS
* update pkg-config generation to include iconv dependency better
2013-12-02 11:32:37 -08:00
Vicent Martí
14984af6cb Merge pull request #1975 from nikai3d/patch-2
fix typos in docs
2013-12-01 04:10:51 -08:00
Nicolas Kaiser
27f680a998 fix typos in docs 2013-12-01 10:35:56 +01:00
Vicent Martí
ca1fba5115 Merge pull request #1974 from ghedo/strnlen
posix: Solaris doesn't have strnlen either
2013-11-27 05:36:13 -08:00