summaryrefslogtreecommitdiff
path: root/src/checkout.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2013-12-12 11:30:50 -0500
committerEdward Thomson <ethomson@microsoft.com>2013-12-13 09:29:55 -0500
commit81a2012d991212fbbbf98bf7eefca3dc5d0fd7bb (patch)
tree63a0321d37ab381ed8e9db874fc1b0a319d09f3f /src/checkout.c
parent79194bcdc956406979cd27ac99198826860d3f20 (diff)
downloadlibgit2-81a2012d991212fbbbf98bf7eefca3dc5d0fd7bb.tar.gz
Overwrite ignored files on checkout
Diffstat (limited to 'src/checkout.c')
-rw-r--r--src/checkout.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/checkout.c b/src/checkout.c
index 0f30d16f3..50da83a4a 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -333,6 +333,7 @@ static int checkout_action_with_wd(
int *action,
checkout_data *data,
const git_diff_delta *delta,
+ git_iterator *workdir,
const git_index_entry *wd)
{
*action = CHECKOUT_ACTION__NONE;
@@ -346,7 +347,10 @@ static int checkout_action_with_wd(
}
break;
case GIT_DELTA_ADDED: /* case 3, 4 or 6 */
- *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT);
+ if (git_iterator_current_is_ignored(workdir))
+ *action = CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, UPDATE_BLOB);
+ else
+ *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT);
break;
case GIT_DELTA_DELETED: /* case 9 or 10 (or 26 but not really) */
if (checkout_is_workdir_modified(data, &delta->old_file, wd))
@@ -541,7 +545,7 @@ static int checkout_action(
if (cmp == 0) {
/* case 4 */
- error = checkout_action_with_wd(action, data, delta, wd);
+ error = checkout_action_with_wd(action, data, delta, workdir, wd);
advance = git_iterator_advance;
goto done;
}
@@ -554,7 +558,7 @@ static int checkout_action(
if (delta->status == GIT_DELTA_TYPECHANGE) {
if (delta->old_file.mode == GIT_FILEMODE_TREE) {
- error = checkout_action_with_wd(action, data, delta, wd);
+ error = checkout_action_with_wd(action, data, delta, workdir, wd);
advance = git_iterator_advance_into;
goto done;
}
@@ -563,7 +567,7 @@ static int checkout_action(
delta->new_file.mode == GIT_FILEMODE_COMMIT ||
delta->old_file.mode == GIT_FILEMODE_COMMIT)
{
- error = checkout_action_with_wd(action, data, delta, wd);
+ error = checkout_action_with_wd(action, data, delta, workdir, wd);
advance = git_iterator_advance;
goto done;
}
@@ -1017,8 +1021,10 @@ static int checkout_get_actions(
if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
(data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0)
{
- giterr_set(GITERR_CHECKOUT, "%d conflicts prevent checkout",
- (int)counts[CHECKOUT_ACTION__CONFLICT]);
+ giterr_set(GITERR_CHECKOUT, "%d %s checkout",
+ (int)counts[CHECKOUT_ACTION__CONFLICT],
+ counts[CHECKOUT_ACTION__CONFLICT] == 1 ?
+ "conflict prevents" : "conflicts prevent");
error = GIT_EMERGECONFLICT;
goto fail;
}