Skip to content

Commit 6be5ac2

Browse files
committed
checkout: postpone creation of symlinks to the end
On most platforms it's fine to create symlinks to nonexisting files. Not so on Windows, where the type of a symlink (file or directory) needs to be set at creation time. So depending on whether the target file exists or not, we may end up with different symlink types. This creates a problem when performing checkouts, where we simply iterate over all blobs that need to be updated without treating symlinks any special. If the target file of the symlink is going to be checked out after the symlink itself, then the symlink will be created as directory symlink and not as file symlink. Fix the issue by iterating over blobs twice: once to perform postponed deletions and updates to non-symlink blobs, and once to perform updates to symlink blobs.
1 parent 50194dc commit 6be5ac2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/checkout.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,11 +1893,18 @@ static int checkout_create_the_new(
18931893
return error;
18941894
}
18951895

1896-
if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB) {
1897-
error = checkout_blob(data, &delta->new_file);
1898-
if (error < 0)
1896+
if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && !S_ISLNK(delta->new_file.mode)) {
1897+
if ((error = checkout_blob(data, &delta->new_file)) < 0)
18991898
return error;
1899+
data->completed_steps++;
1900+
report_progress(data, delta->new_file.path);
1901+
}
1902+
}
19001903

1904+
git_vector_foreach(&data->diff->deltas, i, delta) {
1905+
if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && S_ISLNK(delta->new_file.mode)) {
1906+
if ((error = checkout_blob(data, &delta->new_file)) < 0)
1907+
return error;
19011908
data->completed_steps++;
19021909
report_progress(data, delta->new_file.path);
19031910
}

0 commit comments

Comments
 (0)