Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Rosenberg2012-01-08 21:34:28 +0000
committerCode Review2012-01-08 21:34:28 +0000
commit0806c803a9d549b1c44691dd63ebeb49b3e01ffe (patch)
tree7914841577909a77c1eee4b8bf38db19656bd477 /org.eclipse.jgit
parentf9726423abd861c66bbd86bd4cba90260a6d9fe4 (diff)
parentc15c46e41e10283858c151a7ddf8451d1cd0cc6c (diff)
downloadjgit-0806c803a9d549b1c44691dd63ebeb49b3e01ffe.tar.gz
jgit-0806c803a9d549b1c44691dd63ebeb49b3e01ffe.tar.xz
jgit-0806c803a9d549b1c44691dd63ebeb49b3e01ffe.zip
Merge "Retain executable mode of existing files on Windows"
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java26
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeOptions.java7
4 files changed, 33 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java
index 7e670304d9..f3e47ae011 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java
@@ -171,7 +171,7 @@ public class AddCommand extends GitCommand<DirCache> {
DirCacheEntry entry = new DirCacheEntry(path);
if (c == null || c.getDirCacheEntry() == null
|| !c.getDirCacheEntry().isAssumeValid()) {
- FileMode mode = f.getEntryFileMode();
+ FileMode mode = f.getIndexFileMode(c);
entry.setFileMode(mode);
if (FileMode.GITLINK != mode) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
index 14a7494ba6..a6d780e908 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
@@ -343,7 +343,7 @@ public class CommitCommand extends GitCommand<RevCommit> {
long entryLength = fTree.getEntryLength();
dcEntry.setLength(entryLength);
dcEntry.setLastModified(fTree.getEntryLastModified());
- dcEntry.setFileMode(fTree.getEntryFileMode());
+ dcEntry.setFileMode(fTree.getIndexFileMode(dcTree));
boolean objectExists = (dcTree != null && fTree
.idEqual(dcTree))
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
index 7387cb649c..2a42e05d39 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
@@ -751,6 +751,32 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
}
/**
+ * Get the file mode to use for the current entry when it is to be updated
+ * in the index.
+ *
+ * @param indexIter
+ * {@link DirCacheIterator} positioned at the same entry as this
+ * iterator or null if no {@link DirCacheIterator} is available
+ * at this iterator's current entry
+ * @return index file mode
+ */
+ public FileMode getIndexFileMode(final DirCacheIterator indexIter) {
+ final FileMode wtMode = getEntryFileMode();
+ if (indexIter == null)
+ return wtMode;
+ if (getOptions().isFileMode())
+ return wtMode;
+ final FileMode iMode = indexIter.getEntryFileMode();
+ if (FileMode.REGULAR_FILE == wtMode
+ && FileMode.EXECUTABLE_FILE == iMode)
+ return iMode;
+ if (FileMode.EXECUTABLE_FILE == wtMode
+ && FileMode.REGULAR_FILE == iMode)
+ return iMode;
+ return wtMode;
+ }
+
+ /**
* Compares the entries content with the content in the filesystem.
* Unsmudges the entry when it is detected that it is clean.
*
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeOptions.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeOptions.java
index 630d00b376..dafb3a1517 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeOptions.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeOptions.java
@@ -43,6 +43,7 @@
package org.eclipse.jgit.treewalk;
import org.eclipse.jgit.lib.Config;
+import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Config.SectionParser;
import org.eclipse.jgit.lib.CoreConfig.AutoCRLF;
@@ -60,8 +61,10 @@ public class WorkingTreeOptions {
private final AutoCRLF autoCRLF;
private WorkingTreeOptions(final Config rc) {
- fileMode = rc.getBoolean("core", "filemode", true);
- autoCRLF = rc.getEnum("core", null, "autocrlf", AutoCRLF.FALSE);
+ fileMode = rc.getBoolean(ConfigConstants.CONFIG_CORE_SECTION,
+ ConfigConstants.CONFIG_KEY_FILEMODE, true);
+ autoCRLF = rc.getEnum(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_KEY_AUTOCRLF, AutoCRLF.FALSE);
}
/** @return true if the execute bit on working files should be trusted. */

Back to the top