diff options
author | Kevin Sawicki <kevin@github.com> | 2012-06-05 08:23:04 -0700 |
---|---|---|
committer | Kevin Sawicki <kevin@github.com> | 2012-06-05 08:23:04 -0700 |
commit | 59a98b49d2bf1e4514967dfa0acbceea6b37dbd4 (patch) | |
tree | ec16c4be4afce6ce9bcbbf50dd0df5f971306dfb /org.eclipse.jgit.test | |
parent | b61d35e848e637ef85fde4ebe95d60ced171e963 (diff) | |
download | jgit-59a98b49d2bf1e4514967dfa0acbceea6b37dbd4.tar.gz jgit-59a98b49d2bf1e4514967dfa0acbceea6b37dbd4.zip |
Use working tree iterator to compare file modes
Add isModeDifferent method to WorkingTreeIterator
that compares mode with consideration of the
core.filemode setting in the config.
Bug: 379004
Change-Id: I07335300d787a69c3d1608242238991d5b5214ac
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java index 9f92c045c0..469739c57c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.api; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.io.File; @@ -54,7 +55,10 @@ import org.eclipse.jgit.api.CherryPickResult.CherryPickStatus; import org.eclipse.jgit.api.ResetCommand.ResetType; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.dircache.DirCache; +import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.FileMode; import org.eclipse.jgit.lib.RepositoryState; import org.eclipse.jgit.lib.RepositoryTestCase; import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason; @@ -183,6 +187,42 @@ public class CherryPickCommandTest extends RepositoryTestCase { .exists()); } + @Test + public void testCherryPickOverExecutableChangeOnNonExectuableFileSystem() + throws Exception { + Git git = new Git(db); + File file = writeTrashFile("test.txt", "a"); + assertNotNull(git.add().addFilepattern("test.txt").call()); + assertNotNull(git.commit().setMessage("commit1").call()); + + assertNotNull(git.checkout().setCreateBranch(true).setName("a").call()); + + writeTrashFile("test.txt", "b"); + assertNotNull(git.add().addFilepattern("test.txt").call()); + RevCommit commit2 = git.commit().setMessage("commit2").call(); + assertNotNull(commit2); + + assertNotNull(git.checkout().setName(Constants.MASTER).call()); + + DirCache cache = db.lockDirCache(); + cache.getEntry("test.txt").setFileMode(FileMode.EXECUTABLE_FILE); + cache.write(); + assertTrue(cache.commit()); + cache.unlock(); + + assertNotNull(git.commit().setMessage("commit3").call()); + + db.getFS().setExecute(file, false); + git.getRepository() + .getConfig() + .setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, + ConfigConstants.CONFIG_KEY_FILEMODE, false); + + CherryPickResult result = git.cherryPick().include(commit2).call(); + assertNotNull(result); + assertEquals(CherryPickStatus.OK, result.getStatus()); + } + private RevCommit prepareCherryPick(final Git git) throws Exception { // create, add and commit file a writeTrashFile("a", "a"); |