diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2015-03-03 13:47:13 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-03-03 13:47:13 +0100 |
| commit | 99b68a2aecfaa24f252f265d61b230b8e2576dd2 (patch) | |
| tree | e54ed236c68b3d3cab3882634a0e6fb54f988617 /src | |
| parent | 31bc6c044091c4d65f3a6fd7078beb260c210137 (diff) | |
| parent | 496b76d415b080712d7648fc6f1ff2e55d27a6a5 (diff) | |
| download | libgit2-99b68a2aecfaa24f252f265d61b230b8e2576dd2.tar.gz | |
Merge pull request #2908 from ethomson/safe_create
Allow checkout to handle newly cloned repositories, remove `GIT_CHECKOUT_SAFE_CREATE`
Diffstat (limited to 'src')
| -rw-r--r-- | src/.checkout.c.swp | bin | 0 -> 94208 bytes | |||
| -rw-r--r-- | src/checkout.c | 18 | ||||
| -rw-r--r-- | src/cherrypick.c | 2 | ||||
| -rw-r--r-- | src/revert.c | 2 |
4 files changed, 14 insertions, 8 deletions
diff --git a/src/.checkout.c.swp b/src/.checkout.c.swp Binary files differnew file mode 100644 index 000000000..d946ab551 --- /dev/null +++ b/src/.checkout.c.swp diff --git a/src/checkout.c b/src/checkout.c index f71be26f9..c06928138 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -255,13 +255,13 @@ static int checkout_action_no_wd( error = checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, NULL); if (error) return error; - *action = CHECKOUT_ACTION_IF(SAFE_CREATE, UPDATE_BLOB, NONE); + *action = CHECKOUT_ACTION_IF(RECREATE_MISSING, UPDATE_BLOB, NONE); break; case GIT_DELTA_ADDED: /* case 2 or 28 (and 5 but not really) */ *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); break; case GIT_DELTA_MODIFIED: /* case 13 (and 35 but not really) */ - *action = CHECKOUT_ACTION_IF(SAFE_CREATE, UPDATE_BLOB, CONFLICT); + *action = CHECKOUT_ACTION_IF(RECREATE_MISSING, UPDATE_BLOB, CONFLICT); break; case GIT_DELTA_TYPECHANGE: /* case 21 (B->T) and 28 (T->B)*/ if (delta->new_file.mode == GIT_FILEMODE_TREE) @@ -2346,11 +2346,17 @@ static int checkout_data_init( } } - /* if you are forcing, definitely allow safe updates */ + /* if you are forcing, allow all safe updates, plus recreate missing */ if ((data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) != 0) - data->opts.checkout_strategy |= GIT_CHECKOUT_SAFE_CREATE; - if ((data->opts.checkout_strategy & GIT_CHECKOUT_SAFE_CREATE) != 0) - data->opts.checkout_strategy |= GIT_CHECKOUT_SAFE; + data->opts.checkout_strategy |= GIT_CHECKOUT_SAFE | + GIT_CHECKOUT_RECREATE_MISSING; + + /* if the repository does not actually have an index file, then this + * is an initial checkout (perhaps from clone), so we allow safe updates + */ + if (!data->index->on_disk && + (data->opts.checkout_strategy & GIT_CHECKOUT_SAFE) != 0) + data->opts.checkout_strategy |= GIT_CHECKOUT_RECREATE_MISSING; data->strategy = data->opts.checkout_strategy; diff --git a/src/cherrypick.c b/src/cherrypick.c index ebc9fcdd8..c92975194 100644 --- a/src/cherrypick.c +++ b/src/cherrypick.c @@ -72,7 +72,7 @@ static int cherrypick_normalize_opts( const char *their_label) { int error = 0; - unsigned int default_checkout_strategy = GIT_CHECKOUT_SAFE_CREATE | + unsigned int default_checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS; GIT_UNUSED(repo); diff --git a/src/revert.c b/src/revert.c index f8a7f4333..c481e7dea 100644 --- a/src/revert.c +++ b/src/revert.c @@ -73,7 +73,7 @@ static int revert_normalize_opts( const char *their_label) { int error = 0; - unsigned int default_checkout_strategy = GIT_CHECKOUT_SAFE_CREATE | + unsigned int default_checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS; GIT_UNUSED(repo); |
