summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2018-11-06 17:56:15 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2019-01-02 21:18:29 -0500
commit530812d93645a4238ff33b6ca2f600ceb7ea8143 (patch)
tree488b497cd6518576d1d29514603d0a35765230e7
parent1168ab0f37a3db529cabbe6183ed6f4c9e0a420c (diff)
downloadjgit-530812d93645a4238ff33b6ca2f600ceb7ea8143.tar.gz
jgit-530812d93645a4238ff33b6ca2f600ceb7ea8143.zip
Fix detection of "initial checkout"
A checkout done directly after cloning (the "initial checkout") has a different semantic as a default checkout. That is defined in the documentation of "git read-tree" [1]. JGit was detecting that it is doing an initial checkout differently from native git: jgit used to check that the index is empty but native git required that the index file does not exist [2]. Teach JGit to behave like native git. [1] https://github.com/git/git/blob/master/Documentation/git-read-tree.txt#L187 [2] https://marc.info/?t=154150811200001&r=1&w=2 Change-Id: I1dd0f1ede7cd7ea60d28607916d0165269a9f628
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
index db6073f89a..ce7485bf1f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
@@ -157,7 +157,7 @@ public class DirCacheCheckout {
private ArrayList<String> toBeDeleted = new ArrayList<>();
- private boolean emptyDirCache;
+ private boolean initialCheckout;
private boolean performingCheckout;
@@ -230,7 +230,7 @@ public class DirCacheCheckout {
this.headCommitTree = headCommitTree;
this.mergeCommitTree = mergeCommitTree;
this.workingTree = workingTree;
- this.emptyDirCache = (dc == null) || (dc.getEntryCount() == 0);
+ this.initialCheckout = !repo.isBare() && !repo.getIndexFile().exists();
}
/**
@@ -961,7 +961,7 @@ public class DirCacheCheckout {
// called before). Ignore the cached deletion and use what we
// find in Merge. Potentially updates the file.
if (equalIdAndMode(hId, hMode, mId, mMode)) {
- if (emptyDirCache)
+ if (initialCheckout)
update(name, mId, mMode);
else
keep(dce);