diff options
| author | Russell Belfer <rb@github.com> | 2013-12-03 16:45:39 -0800 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-12-11 10:57:49 -0800 |
| commit | 96869a4edb2872934e0e167a726ab240f4270fea (patch) | |
| tree | 2d770414acef2d1d45a609e004c0aa6fa56d06d7 /src/checkout.c | |
| parent | 9f77b3f6f5ce6944ec49dfc666ef6b8df0af0c6b (diff) | |
| download | libgit2-96869a4edb2872934e0e167a726ab240f4270fea.tar.gz | |
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.
Diffstat (limited to 'src/checkout.c')
| -rw-r--r-- | src/checkout.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/checkout.c b/src/checkout.c index 6d7e3cfd4..4305d3e9a 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -216,7 +216,7 @@ static int checkout_action_common( if (notify != GIT_CHECKOUT_NOTIFY_NONE && checkout_notify(data, notify, delta, wd) != 0) - return GIT_EUSER; + return giterr_user_cancel(); return action; } @@ -230,7 +230,7 @@ static int checkout_action_no_wd( switch (delta->status) { case GIT_DELTA_UNMODIFIED: /* case 12 */ if (checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, NULL)) - return GIT_EUSER; + return giterr_user_cancel(); action = CHECKOUT_ACTION_IF(SAFE_CREATE, UPDATE_BLOB, NONE); break; case GIT_DELTA_ADDED: /* case 2 or 28 (and 5 but not really) */ @@ -302,7 +302,7 @@ static int checkout_action_wd_only( } if (checkout_notify(data, notify, NULL, wd)) - return GIT_EUSER; + return giterr_user_cancel(); if (remove) { char *path = git_pool_strdup(&data->pool, wd->path); @@ -342,7 +342,7 @@ static int checkout_action_with_wd( if (checkout_is_workdir_modified(data, &delta->old_file, wd)) { if (checkout_notify( data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, wd)) - return GIT_EUSER; + return giterr_user_cancel(); action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, NONE); } break; @@ -406,7 +406,7 @@ static int checkout_action_with_wd_blocker( case GIT_DELTA_UNMODIFIED: /* should show delta as dirty / deleted */ if (checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, wd)) - return GIT_EUSER; + return giterr_user_cancel(); action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE); break; case GIT_DELTA_ADDED: @@ -439,7 +439,7 @@ static int checkout_action_with_wd_dir( if (checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, NULL) || checkout_notify( data, GIT_CHECKOUT_NOTIFY_UNTRACKED, NULL, wd)) - return GIT_EUSER; + return giterr_user_cancel(); break; case GIT_DELTA_ADDED:/* case 4 (and 7 for dir) */ case GIT_DELTA_MODIFIED: /* case 20 (or 37 but not really) */ @@ -452,7 +452,7 @@ static int checkout_action_with_wd_dir( if (delta->old_file.mode != GIT_FILEMODE_TREE && checkout_notify( data, GIT_CHECKOUT_NOTIFY_UNTRACKED, NULL, wd)) - return GIT_EUSER; + return giterr_user_cancel(); break; case GIT_DELTA_TYPECHANGE: /* case 24 or 31 */ if (delta->old_file.mode == GIT_FILEMODE_TREE) { @@ -1998,9 +1998,6 @@ int git_checkout_iterator( assert(data.completed_steps == data.total_steps); cleanup: - if (error == GIT_EUSER) - giterr_clear(); - if (!error && data.index != NULL && (data.strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0) error = git_index_write(data.index); |
