Skip to content

Git EOL character conversion #8508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Collection;
import org.eclipse.jgit.dircache.Checkout;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheCheckout.CheckoutMetadata;
import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.dircache.DirCacheIterator;
import org.eclipse.jgit.lib.FileMode;
Expand Down Expand Up @@ -87,25 +88,25 @@ public void checkout() throws IOException, GitException {
if (dit != null && (recursively || directChild(roots, repository.getWorkTree(), path)) && (fit == null || fit.isModified(dit.getDirCacheEntry(), checkContent, od))) {
// update entry
listener.notifyFile(path, treeWalk.getPathString());
checkoutEntry(repository, path, dit.getDirCacheEntry(), od);
checkoutEntry(repository, treeWalk, path, dit.getDirCacheEntry(), od);
}
}
}
}

public void checkoutEntry (Repository repository, File file, DirCacheEntry e, ObjectReader od) throws IOException, GitException {
private void checkoutEntry(Repository repository, TreeWalk treeWalk, File file, DirCacheEntry entry, ObjectReader reader) throws IOException, GitException {
// ... create/overwrite this file ...
if (!ensureParentFolderExists(file.getParentFile())) {
return;
}

boolean exists = file.exists();
if (exists && e.getFileMode() == FileMode.SYMLINK) {
if (exists && entry.getFileMode() == FileMode.SYMLINK) {
monitor.notifyWarning(MessageFormat.format(Utils.getBundle(CheckoutIndex.class).getString("MSG_Warning_SymLink"), file.getAbsolutePath())); //NOI18N
return;
}

if (Utils.isFromNested(e.getFileMode().getBits())) {
if (Utils.isFromNested(entry.getFileMode().getBits())) {
if (!exists) {
file.mkdirs();
}
Expand All @@ -116,9 +117,13 @@ public void checkoutEntry (Repository repository, File file, DirCacheEntry e, Ob
}
file.createNewFile();
if (file.isFile()) {
CheckoutMetadata checkoutMetadata = new CheckoutMetadata(
treeWalk.getCheckoutEolStreamType(0),
treeWalk.getSmudgeCommand(0)
);
new Checkout(repository)
.setRecursiveDeletion(false)
.checkout(e, null, od, null);
.checkout(entry, checkoutMetadata, reader, null);
} else {
monitor.notifyError(MessageFormat.format(Utils.getBundle(CheckoutIndex.class).getString("MSG_Warning_CannotCreateFile"), file.getAbsolutePath())); //NOI18N
}
Expand Down
Loading