Skip to content

Commit 46637b5

Browse files
committed
checkout: remove unused code for deferred removals
With commit 05f6901 (checkout: remove blocking dir when FORCEd, 2015-03-31), the last case was removde that actually queued a deferred removal. This is now more than five years in the past and nobody complained, so we can rest quite assured that the deferred removal is not really needed at all. Let's remove all related code to simplify the already complicated checkout logic.
1 parent 9e4e25b commit 46637b5

File tree

1 file changed

+11
-53
lines changed

1 file changed

+11
-53
lines changed

src/checkout.c

Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ enum {
4444
CHECKOUT_ACTION__REMOVE_CONFLICT = 16,
4545
CHECKOUT_ACTION__UPDATE_CONFLICT = 32,
4646
CHECKOUT_ACTION__MAX = 32,
47-
CHECKOUT_ACTION__DEFER_REMOVE = 64,
4847
CHECKOUT_ACTION__REMOVE_AND_UPDATE =
4948
(CHECKOUT_ACTION__UPDATE_BLOB | CHECKOUT_ACTION__REMOVE),
5049
};
@@ -196,7 +195,7 @@ static bool checkout_is_workdir_modified(
196195
}
197196

198197
if (git_submodule_status(&sm_status, data->repo, wditem->path, GIT_SUBMODULE_IGNORE_UNSPECIFIED) < 0 ||
199-
GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status))
198+
GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status))
200199
rval = true;
201200
else if ((sm_oid = git_submodule_wd_id(sm)) == NULL)
202201
rval = false;
@@ -274,9 +273,8 @@ static int checkout_action_common(
274273

275274
/* if the file is on disk and doesn't match our mode, force update */
276275
if (wd &&
277-
GIT_PERMS_IS_EXEC(wd->mode) !=
278-
GIT_PERMS_IS_EXEC(delta->new_file.mode))
279-
*action |= CHECKOUT_ACTION__REMOVE;
276+
GIT_PERMS_IS_EXEC(wd->mode) != GIT_PERMS_IS_EXEC(delta->new_file.mode))
277+
*action |= CHECKOUT_ACTION__REMOVE;
280278

281279
notify = GIT_CHECKOUT_NOTIFY_UPDATED;
282280
}
@@ -800,7 +798,7 @@ static int checkout_conflictdata_cmp(const void *a, const void *b)
800798
int diff;
801799

802800
if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 &&
803-
(diff = checkout_idxentry_cmp(ca->ours, cb->theirs)) == 0)
801+
(diff = checkout_idxentry_cmp(ca->ours, cb->theirs)) == 0)
804802
diff = checkout_idxentry_cmp(ca->theirs, cb->theirs);
805803

806804
return diff;
@@ -1179,7 +1177,7 @@ static int checkout_conflicts_mark_directoryfile(
11791177
/* Find d/f conflicts */
11801178
git_vector_foreach(&data->update_conflicts, i, conflict) {
11811179
if ((conflict->ours && conflict->theirs) ||
1182-
(!conflict->ours && !conflict->theirs))
1180+
(!conflict->ours && !conflict->theirs))
11831181
continue;
11841182

11851183
path = conflict->ours ?
@@ -1228,8 +1226,8 @@ static int checkout_get_update_conflicts(
12281226
return 0;
12291227

12301228
if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 ||
1231-
(error = checkout_conflicts_coalesce_renames(data)) < 0 ||
1232-
(error = checkout_conflicts_mark_directoryfile(data)) < 0)
1229+
(error = checkout_conflicts_coalesce_renames(data)) < 0 ||
1230+
(error = checkout_conflicts_mark_directoryfile(data)) < 0)
12331231
goto done;
12341232

12351233
done:
@@ -1314,11 +1312,11 @@ static int checkout_get_actions(
13141312
return -1;
13151313

13161314
if (data->opts.paths.count > 0 &&
1317-
git_pathspec__vinit(&pathspec, &data->opts.paths, &pathpool) < 0)
1315+
git_pathspec__vinit(&pathspec, &data->opts.paths, &pathpool) < 0)
13181316
return -1;
13191317

13201318
if ((error = git_iterator_current(&wditem, workdir)) < 0 &&
1321-
error != GIT_ITEROVER)
1319+
error != GIT_ITEROVER)
13221320
goto fail;
13231321

13241322
deltas = &data->diff->deltas;
@@ -1357,8 +1355,7 @@ static int checkout_get_actions(
13571355
counts[CHECKOUT_ACTION__REMOVE] += data->removes.length;
13581356

13591357
if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
1360-
(data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0)
1361-
{
1358+
(data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0) {
13621359
git_error_set(GIT_ERROR_CHECKOUT, "%"PRIuZ" %s checkout",
13631360
counts[CHECKOUT_ACTION__CONFLICT],
13641361
counts[CHECKOUT_ACTION__CONFLICT] == 1 ?
@@ -1369,7 +1366,7 @@ static int checkout_get_actions(
13691366

13701367

13711368
if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 ||
1372-
(error = checkout_get_update_conflicts(data, workdir, &pathspec)) < 0)
1369+
(error = checkout_get_update_conflicts(data, workdir, &pathspec)) < 0)
13731370
goto fail;
13741371

13751372
counts[CHECKOUT_ACTION__REMOVE_CONFLICT] = git_vector_length(&data->remove_conflicts);
@@ -1860,26 +1857,6 @@ static int checkout_remove_the_old(
18601857
return 0;
18611858
}
18621859

1863-
static int checkout_deferred_remove(git_repository *repo, const char *path)
1864-
{
1865-
#if 0
1866-
int error = git_futils_rmdir_r(
1867-
path, data->opts.target_directory, GIT_RMDIR_EMPTY_PARENTS);
1868-
1869-
if (error == GIT_ENOTFOUND) {
1870-
error = 0;
1871-
git_error_clear();
1872-
}
1873-
1874-
return error;
1875-
#else
1876-
GIT_UNUSED(repo);
1877-
GIT_UNUSED(path);
1878-
assert(false);
1879-
return 0;
1880-
#endif
1881-
}
1882-
18831860
static int checkout_create_the_new(
18841861
unsigned int *actions,
18851862
checkout_data *data)
@@ -1889,15 +1866,6 @@ static int checkout_create_the_new(
18891866
size_t i;
18901867

18911868
git_vector_foreach(&data->diff->deltas, i, delta) {
1892-
if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) {
1893-
/* this had a blocker directory that should only be removed iff
1894-
* all of the contents of the directory were safely removed
1895-
*/
1896-
if ((error = checkout_deferred_remove(
1897-
data->repo, delta->old_file.path)) < 0)
1898-
return error;
1899-
}
1900-
19011869
if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && !S_ISLNK(delta->new_file.mode)) {
19021870
if ((error = checkout_blob(data, &delta->new_file)) < 0)
19031871
return error;
@@ -1922,20 +1890,10 @@ static int checkout_create_submodules(
19221890
unsigned int *actions,
19231891
checkout_data *data)
19241892
{
1925-
int error = 0;
19261893
git_diff_delta *delta;
19271894
size_t i;
19281895

19291896
git_vector_foreach(&data->diff->deltas, i, delta) {
1930-
if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) {
1931-
/* this has a blocker directory that should only be removed iff
1932-
* all of the contents of the directory were safely removed
1933-
*/
1934-
if ((error = checkout_deferred_remove(
1935-
data->repo, delta->old_file.path)) < 0)
1936-
return error;
1937-
}
1938-
19391897
if (actions[i] & CHECKOUT_ACTION__UPDATE_SUBMODULE) {
19401898
int error = checkout_submodule(data, &delta->new_file);
19411899
if (error < 0)

0 commit comments

Comments
 (0)