org.eclipse.jgit.lib.FileMode Java Examples

The following examples show how to use org.eclipse.jgit.lib.FileMode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitUtilsTest.java    From onedev with MIT License 6 votes vote down vote up
@Test
public void testMergeWithDeletionAndModificationConflict() throws Exception {
	addFileAndCommit("file", "", "initial commit");
	git.checkout().setCreateBranch(true).setName("dev").call();
	removeFileAndCommit("file", "remove file");
	git.checkout().setName("master").call();
	addFileAndCommit("file", "1", "master");

	assertNull(GitUtils.merge(git.getRepository(), git.getRepository().resolve("master"), 
			git.getRepository().resolve("dev"), false, user, user, "merge commit", false));
	
	ObjectId mergeCommitId = GitUtils.merge(git.getRepository(), git.getRepository().resolve("master"), 
			git.getRepository().resolve("dev"), false, user, user, "merge commit", true);
	assertNotNull(mergeCommitId);
	
	try (	RevWalk revWalk = new RevWalk(git.getRepository())) {
		RevCommit mergeCommit = revWalk.parseCommit(mergeCommitId);
		TreeWalk treeWalk = TreeWalk.forPath(git.getRepository(), "file", mergeCommit.getTree());
		BlobIdent blobIdent = new BlobIdent(mergeCommit.name(), "file", FileMode.REGULAR_FILE.getBits());
		Blob blob = new Blob(blobIdent, treeWalk.getObjectId(0), treeWalk.getObjectReader());
		assertEquals("1", blob.getText().getContent());
	}
}
 
Example #2
Source File: BlobEditsTest.java    From onedev with MIT License 6 votes vote down vote up
@Test
public void testObsoleteOldCommit() throws IOException {
	addFileAndCommit("a.java", "a", "add a");
	
	String refName = "refs/heads/master";
	ObjectId oldCommitId = git.getRepository().resolve(refName);
	
	addFileAndCommit("b.java", "b", "add b");
	
	ObjectId newCommitId = git.getRepository().resolve(refName);

	Map<String, BlobContent> newBlobs = new HashMap<>();
	newBlobs.put("/server/src/com/example/c/c.java", new BlobContent.Immutable("c".getBytes(), FileMode.REGULAR_FILE));
	BlobEdits edits = new BlobEdits(Sets.newHashSet(), newBlobs);
	try {
		edits.commit(git.getRepository(), refName, oldCommitId, oldCommitId, user, "test add");
		assertTrue("An ObsoleteCommitException should be thrown", false);
	} catch (ObsoleteCommitException e) {
		assertTrue(newCommitId.equals(e.getOldCommitId()));
	}
}
 
Example #3
Source File: BlobEditsTest.java    From onedev with MIT License 6 votes vote down vote up
@Test
public void shouldFailIfOldPathIsTreeWhenRename() throws IOException {
	createDir("client");
	addFileAndCommit("client/a.java", "a", "add a");
	addFileAndCommit("client/b.java", "b", "add b");
	
	createDir("server/src/com/example/a");
	createDir("server/src/com/example/b");
	addFileAndCommit("server/src/com/example/a/a.java", "a", "add a");
	addFileAndCommit("server/src/com/example/b/b.java", "b", "add b");
	
	String refName = "refs/heads/master";
	ObjectId oldCommitId = git.getRepository().resolve(refName);
	
	Map<String, BlobContent> newBlobs = new HashMap<>();
	newBlobs.put("client/c.java", new BlobContent.Immutable("a".getBytes(), FileMode.REGULAR_FILE));
	BlobEdits edits = new BlobEdits(Sets.newHashSet("server/src/com/example/a"), newBlobs);
	ObjectId newCommitId = edits.commit(git.getRepository(), refName, oldCommitId, oldCommitId, user, 
			"test rename");
	try (RevWalk revWalk = new RevWalk(git.getRepository())) {
		RevTree revTree = revWalk.parseCommit(newCommitId).getTree();
		assertNotNull(TreeWalk.forPath(git.getRepository(), "client/c.java", revTree));
		assertNull(TreeWalk.forPath(git.getRepository(), "server/src/com/example/a", revTree));
	}
}
 
Example #4
Source File: AddTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testAddMissingSymlink () throws Exception {
    if (isWindows()) {
        return;
    }
    String path = "folder/file";
    File f = new File(workDir, path);
    
    // try with commandline client
    File link = new File(workDir, "link");
    Files.createSymbolicLink(Paths.get(link.getAbsolutePath()), Paths.get(path));
    getClient(workDir).add(new File[] { link }, NULL_PROGRESS_MONITOR);
    DirCacheEntry e = repository.readDirCache().getEntry(link.getName());
    assertEquals(FileMode.SYMLINK, e.getFileMode());
    assertEquals(0, e.getLength());
    try (ObjectReader reader = repository.getObjectDatabase().newReader()) {
        assertTrue(reader.has(e.getObjectId()));
        byte[] bytes = reader.open(e.getObjectId()).getBytes();
        assertEquals(path, RawParseUtils.decode(bytes));
    }
}
 
Example #5
Source File: InsertUrlPanel.java    From onedev with MIT License 5 votes vote down vote up
private Set<BlobIdent> getPickerState(@Nullable ObjectId commitId, BlobIdent currentBlobIdent, 
		@Nullable Set<String> expandedPaths) {
	Set<BlobIdent> pickerState = new HashSet<>();
	if (commitId != null) {
		if (expandedPaths != null) {
			for (String path: expandedPaths)
				pickerState.add(new BlobIdent(commitId.name(), path, FileMode.TREE.getBits()));
		} 
		
		String parentPath;
		if (currentBlobIdent.isTree())
			parentPath = currentBlobIdent.path;
		else if (currentBlobIdent.path.contains("/"))
			parentPath = StringUtils.substringBeforeLast(currentBlobIdent.path, "/");
		else
			parentPath = null;
		
		while (parentPath != null) {
			pickerState.add(new BlobIdent(commitId.name(), parentPath, FileMode.TYPE_TREE));
			if (parentPath.contains("/"))
				parentPath = StringUtils.substringBeforeLast(parentPath, "/");
			else
				parentPath = null;
		}
	}
	return pickerState;
}
 
Example #6
Source File: NodeJobSuggestion.java    From onedev with MIT License 5 votes vote down vote up
@Nullable
private static JsonNode getPackageJson(Project project, ObjectId commitId) {
	Blob blob = project.getBlob(new BlobIdent(commitId.name(), "package.json", FileMode.TYPE_FILE), false);
	if (blob != null) {
		String content = blob.getText().getContent();
		ObjectMapper objectMapper = OneDev.getInstance(ObjectMapper.class);
		try {
			return objectMapper.readTree(content);
		} catch (IOException e) {
			logger.error("Error parsing package.json", e);
		}
	} 
	return null;
}
 
Example #7
Source File: ResolveMerger.java    From onedev with MIT License 5 votes vote down vote up
private boolean isWorktreeDirty(WorkingTreeIterator work,
		DirCacheEntry ourDce) throws IOException {
	if (work == null)
		return false;

	final int modeF = tw.getRawMode(T_FILE);
	final int modeO = tw.getRawMode(T_OURS);

	// Worktree entry has to match ours to be considered clean
	boolean isDirty;
	if (ourDce != null)
		isDirty = work.isModified(ourDce, true, reader);
	else {
		isDirty = work.isModeDifferent(modeO);
		if (!isDirty && nonTree(modeF))
			isDirty = !tw.idEqual(T_FILE, T_OURS);
	}

	// Ignore existing empty directories
	if (isDirty && modeF == FileMode.TYPE_TREE
			&& modeO == FileMode.TYPE_MISSING)
		isDirty = false;
	if (isDirty)
		failingPaths.put(tw.getPathString(),
				MergeFailureReason.DIRTY_WORKTREE);
	return isDirty;
}
 
Example #8
Source File: BlobIdent.java    From onedev with MIT License 5 votes vote down vote up
public BlobIdent(Project project, List<String> urlSegments) {
	StringBuilder revisionBuilder = new StringBuilder();
	for (int i=0; i<urlSegments.size(); i++) {
		if (i != 0)
			revisionBuilder.append("/");
		revisionBuilder.append(urlSegments.get(i));
		if (project.getObjectId(revisionBuilder.toString(), false) != null) {
			revision = revisionBuilder.toString();
			StringBuilder pathBuilder = new StringBuilder();
			for (int j=i+1; j<urlSegments.size(); j++) {
				if (j != i+1)
					pathBuilder.append("/");
				pathBuilder.append(urlSegments.get(j));
			}
			if (pathBuilder.length() != 0) {
				path = pathBuilder.toString();
				mode = project.getMode(revision, path);
			} else {
				mode = FileMode.TREE.getBits();
			}
			return;
		}
	}
	if (revisionBuilder.length() != 0) {
		throw new ObjectNotFoundException("Revision not found: " + revisionBuilder.toString());
	} else {
		revision = project.getDefaultBranch();
		mode = FileMode.TREE.getBits();
	}
}
 
Example #9
Source File: GfsFileAttributes.java    From ParallelGit with Apache License 2.0 5 votes vote down vote up
public Git(Map<String, Object> attributes) throws IOException {
  super(attributes);
  isNew = (boolean) attributes.get(GfsFileAttributeView.IS_NEW);
  isModified = (boolean) attributes.get(GfsFileAttributeView.IS_MODIFIED);
  objectId = (ObjectId) attributes.get(GfsFileAttributeView.OBJECT_ID);
  fileMode = (FileMode) attributes.get(GfsFileAttributeView.FILE_MODE);
}
 
Example #10
Source File: JobDefLink.java    From onedev with MIT License 5 votes vote down vote up
@Override
public PageParameters getPageParameters() {
	ProjectBlobPage.State state = new ProjectBlobPage.State();
	state.blobIdent = new BlobIdent(commitId.name(), BuildSpec.BLOB_PATH, FileMode.REGULAR_FILE.getBits()); 
	if (getProject().getBlob(state.blobIdent, false) == null)
		state.blobIdent = new BlobIdent(commitId.name(), ".onedev-buildspec", FileMode.REGULAR_FILE.getBits());
	state.position = BuildSpecRendererProvider.getPosition(Job.SELECTION_PREFIX + jobName);
	return ProjectBlobPage.paramsOf(getProject(), state);
}
 
Example #11
Source File: GitFileTreeEntry.java    From git-as-svn with GNU General Public License v2.0 5 votes vote down vote up
@NotNull
@Override
public Map<String, String> getProperties() throws IOException {
  final Map<String, String> props = getUpstreamProperties();
  final FileMode fileMode = getFileMode();
  if (fileMode.equals(FileMode.SYMLINK)) {
    props.remove(SVNProperty.EOL_STYLE);
    props.remove(SVNProperty.MIME_TYPE);
    props.put(SVNProperty.SPECIAL, "*");
  } else {
    if (fileMode.equals(FileMode.EXECUTABLE_FILE))
      props.put(SVNProperty.EXECUTABLE, "*");

    if (props.containsKey(SVNProperty.MIME_TYPE)) {
      props.remove(SVNProperty.EOL_STYLE);
    } else if (props.containsKey(SVNProperty.EOL_STYLE)) {
      props.remove(SVNProperty.MIME_TYPE);
    } else if (fileMode.getObjectType() == Constants.OBJ_BLOB) {
      if (branch.getRepository().isObjectBinary(filter, getObjectId())) {
        props.put(SVNProperty.MIME_TYPE, MIME_BINARY);
      } else {
        props.put(SVNProperty.EOL_STYLE, SVNProperty.EOL_STYLE_NATIVE);
      }
    }
  }
  return props;
}
 
Example #12
Source File: CommitOptionPanel.java    From onedev with MIT License 5 votes vote down vote up
private BlobChange getChange(TreeWalk treeWalk, RevCommit oldCommit, RevCommit newCommit) {
	DiffEntry.ChangeType changeType = DiffEntry.ChangeType.MODIFY;
	BlobIdent oldBlobIdent;
	if (!treeWalk.getObjectId(0).equals(ObjectId.zeroId())) {
		oldBlobIdent = new BlobIdent(oldCommit.name(), treeWalk.getPathString(), treeWalk.getRawMode(0));
	} else {
		oldBlobIdent = new BlobIdent(oldCommit.name(), null, FileMode.TREE.getBits());
		changeType = DiffEntry.ChangeType.ADD;
	}
	
	BlobIdent newBlobIdent;
	if (!treeWalk.getObjectId(1).equals(ObjectId.zeroId())) {
		newBlobIdent = new BlobIdent(newCommit.name(), treeWalk.getPathString(), treeWalk.getRawMode(1));
	} else {
		newBlobIdent = new BlobIdent(newCommit.name(), null, FileMode.TREE.getBits());
		changeType = DiffEntry.ChangeType.DELETE;
	}
	
	return new BlobChange(changeType, oldBlobIdent, newBlobIdent, WhitespaceOption.DEFAULT) {

		@Override
		public Blob getBlob(BlobIdent blobIdent) {
			return context.getProject().getBlob(blobIdent, true);
		}

	};
}
 
Example #13
Source File: GitRepository.java    From centraldogma with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(DirCacheEntry ent) {
    try {
        ent.setObjectId(inserter.insert(Constants.OBJ_BLOB, Jackson.writeValueAsBytes(jsonNode)));
        ent.setFileMode(FileMode.REGULAR_FILE);
    } catch (IOException e) {
        throw new StorageException("failed to create a new JSON blob", e);
    }
}
 
Example #14
Source File: CheckoutIndex.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void checkoutEntry (Repository repository, File file, DirCacheEntry e, ObjectReader od) throws IOException, GitException {
    // ... create/overwrite this file ...
    if (!ensureParentFolderExists(file.getParentFile())) {
        return;
    }

    boolean exists = file.exists();
    if (exists && e.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 (!exists) {
            file.mkdirs();
        }
    } else {
        if (exists && file.isDirectory()) {
            monitor.notifyWarning(MessageFormat.format(Utils.getBundle(CheckoutIndex.class).getString("MSG_Warning_ReplacingDirectory"), file.getAbsolutePath())); //NOI18N
            Utils.deleteRecursively(file);
        }
        file.createNewFile();
        if (file.isFile()) {
            DirCacheCheckout.checkoutEntry(repository, e, od);
        } else {
            monitor.notifyError(MessageFormat.format(Utils.getBundle(CheckoutIndex.class).getString("MSG_Warning_CannotCreateFile"), file.getAbsolutePath())); //NOI18N
        }
    }
}
 
Example #15
Source File: StatusCommand.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private GitStatus.Status getGitlinkStatus (int mode1, ObjectId id1, int mode2, ObjectId id2) {
    if (mode1 == FileMode.TYPE_GITLINK || mode2 == FileMode.TYPE_GITLINK) {
        if (mode1 == FileMode.TYPE_MISSING) {
            return GitStatus.Status.STATUS_REMOVED;
        } else if (mode2 == FileMode.TYPE_MISSING) {
            return GitStatus.Status.STATUS_ADDED;
        } else if (!id1.equals(id2)) {
            return GitStatus.Status.STATUS_MODIFIED;
        }
    }
    return GitStatus.Status.STATUS_NORMAL;
}
 
Example #16
Source File: BlobEditsTest.java    From onedev with MIT License 5 votes vote down vote up
@Test
public void testModifyFile() throws IOException {
	createDir("a");
	addFileAndCommit("a/file.java", "", "add a/file.java");
	
	createDir("a.b");
	addFileAndCommit("a.b/file2.java", "", "add a.b/file.java");
	addFileAndCommit("a.b/file1.java", "", "add a.b/file.java");
	addFileAndCommit("a.b/file1", "", "add a.b/file.java");
	
	String refName = "refs/heads/master";
	ObjectId oldCommitId = git.getRepository().resolve(refName);

	List<String> oldPaths = new ArrayList<>();
	try (	RevWalk revWalk = new RevWalk(git.getRepository());
			TreeWalk treeWalk = new TreeWalk(git.getRepository());) {
		treeWalk.addTree(revWalk.parseCommit(oldCommitId).getTree());
		while (treeWalk.next())
			oldPaths.add(treeWalk.getPathString());
	}
	
	Map<String, BlobContent> newBlobs = new HashMap<>();
	newBlobs.put("a.b/file2.java", new BlobContent.Immutable("hello".getBytes(), FileMode.REGULAR_FILE));
	BlobEdits edits = new BlobEdits(Sets.newHashSet("a.b/file2.java"), newBlobs);
	ObjectId newCommitId = edits.commit(git.getRepository(), refName, oldCommitId, oldCommitId, user, "test modify");

	List<String> newPaths = new ArrayList<>();
	try (	RevWalk revWalk = new RevWalk(git.getRepository());
			TreeWalk treeWalk = new TreeWalk(git.getRepository());) {
		treeWalk.addTree(revWalk.parseCommit(newCommitId).getTree());
		while (treeWalk.next())
			newPaths.add(treeWalk.getPathString());
	}
	
	assertEquals(oldPaths, newPaths);
}
 
Example #17
Source File: GitUtilsTest.java    From onedev with MIT License 5 votes vote down vote up
@Test
public void testMergeWithLinkAndLinkConflict() throws Exception {
	File tempDir;
	
	tempDir = FileUtils.createTempDir();
	try (InputStream is = Resources.getResource(GitUtilsTest.class, "git-conflict-link-link.zip").openStream()) {
		ZipUtils.unzip(is, tempDir);
		try (Git git = Git.open(tempDir)) {
			ObjectId mergeCommitId;

			mergeCommitId = GitUtils.merge(git.getRepository(), git.getRepository().resolve("master"), 
					git.getRepository().resolve("dev"), false, user, user, "merge commit", false);
			
			assertNull(mergeCommitId);

			mergeCommitId = GitUtils.merge(git.getRepository(), git.getRepository().resolve("master"), 
					git.getRepository().resolve("dev"), false, user, user, "merge commit", true);
			
			assertNotNull(mergeCommitId);
			
			try (	RevWalk revWalk = new RevWalk(git.getRepository())) {
				RevCommit mergeCommit = revWalk.parseCommit(mergeCommitId);
				TreeWalk treeWalk = TreeWalk.forPath(git.getRepository(), "lib", mergeCommit.getTree());
				assertTrue(treeWalk != null && treeWalk.getFileMode(0) == FileMode.GITLINK);
				treeWalk = TreeWalk.forPath(git.getRepository(), ".gitmodules", mergeCommit.getTree());
				BlobIdent blobIdent = new BlobIdent(mergeCommit.name(), ".gitmodules", FileMode.GITLINK.getBits());
				Blob blob = new Blob(blobIdent, treeWalk.getObjectId(0), treeWalk.getObjectReader());
				assertTrue(blob.getText().getContent().trim().endsWith("/home/robin/temp/lib"));
			}
		}
	} finally {
		deleteDir(tempDir, 3);
	}
}
 
Example #18
Source File: ProjectBlobPage.java    From onedev with MIT License 5 votes vote down vote up
public static ProjectBlobPage.State getState(CodeComment comment) {
	BlobIdent blobIdent = new BlobIdent(comment.getMark().getCommitHash(), comment.getMark().getPath(), 
			FileMode.REGULAR_FILE.getBits());
	ProjectBlobPage.State state = new ProjectBlobPage.State(blobIdent);
	state.commentId = comment.getId();
	state.position = SourceRendererProvider.getPosition(comment.getMark().getRange());
	return state;
}
 
Example #19
Source File: GitEntryImpl.java    From git-as-svn with GNU General Public License v2.0 4 votes vote down vote up
GitEntryImpl(@NotNull GitProperty[] parentProps, @NotNull String parentPath, @NotNull GitProperty[] props, @NotNull String name, @NotNull FileMode fileMode) {
  this.parentPath = parentPath;
  this.name = name;
  this.props = GitProperty.joinProperties(parentProps, name, fileMode, props);
}
 
Example #20
Source File: GfsFileAttributeView.java    From ParallelGit with Apache License 2.0 4 votes vote down vote up
@Override
public void setFileMode(FileMode mode) {
  node.setMode(mode);
}
 
Example #21
Source File: StatusCommand.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private boolean isSymlinkFolder (int mHead, boolean isSymlink) {
    // it seems symlink to a folder comes as two separate tree entries, 
    // first has always mWorking set to 0 and is a symlink in index and HEAD
    // the other is identified as a new tree
    return isSymlink || (mHead & FileMode.TYPE_SYMLINK) == FileMode.TYPE_SYMLINK;
}
 
Example #22
Source File: StatusCommand.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private boolean isExistingSymlink (int fileMode1, int fileModeWorking) {
    return (fileModeWorking & FileMode.TYPE_FILE) == FileMode.TYPE_FILE && (fileMode1 & FileMode.TYPE_SYMLINK) == FileMode.TYPE_SYMLINK;
}
 
Example #23
Source File: GfsFileAttributeView.java    From ParallelGit with Apache License 2.0 4 votes vote down vote up
@Override
public void setPermissions(Set<PosixFilePermission> perms) throws IOException {
  FileMode mode = perms.contains(OWNER_EXECUTE) ? EXECUTABLE_FILE : REGULAR_FILE;
  node.setMode(mode);
}
 
Example #24
Source File: Utils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static boolean isFromNested (int fm) {
    return fm == FileMode.TYPE_GITLINK;
}
 
Example #25
Source File: CheckoutTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testCheckoutWithAddedNestedRoot () throws Exception {
    File f = new File(workDir, "f");
    write(f, "file");
    
    GitClient client = getClient(workDir);
    client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
    client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
    client.createBranch(BRANCH, "master", NULL_PROGRESS_MONITOR);
    
    File nested = new File(workDir, "nested");
    nested.mkdirs();
    File f2 = new File(nested, "f");
    write(f2, "file");
    GitClient clientNested = getClient(nested);
    clientNested.init(NULL_PROGRESS_MONITOR);
    clientNested.add(new File[] { f2 }, NULL_PROGRESS_MONITOR);
    clientNested.commit(new File[] { f2 }, "init commit", null, null, NULL_PROGRESS_MONITOR);
    
    // add the root as gitlink
    client.add(new File[] { nested }, NULL_PROGRESS_MONITOR);
    client.commit(new File[] { nested }, "nested repo added", null, null, NULL_PROGRESS_MONITOR);
    Utils.deleteRecursively(nested);
    nested.mkdirs();
    Map<File, GitStatus> statuses = client.getStatus(new File[] { nested }, NULL_PROGRESS_MONITOR);
    assertEquals(1, statuses.size());
    assertStatus(statuses, workDir, nested, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
    
    client.checkoutRevision(BRANCH, true, NULL_PROGRESS_MONITOR);
    assertFalse(nested.isDirectory());
    statuses = client.getStatus(new File[] { workDir }, NULL_PROGRESS_MONITOR);
    assertEquals(1, statuses.size());
    assertStatus(statuses, workDir, f, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);

    // ours
    assertFalse(nested.isDirectory());
    client.checkoutRevision("master", true, NULL_PROGRESS_MONITOR);
    assertTrue(nested.isDirectory());
    DirCacheEntry e = repository.readDirCache().getEntry("nested");
    assertEquals(FileMode.GITLINK, e.getFileMode());
    statuses = client.getStatus(new File[] { workDir }, NULL_PROGRESS_MONITOR);
    assertEquals(2, statuses.size());
    assertStatus(statuses, workDir, f, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
    assertStatus(statuses, workDir, nested, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);

    //checkout index - aka revert
    assertTrue(nested.delete());
    client.remove(new File[] { nested }, true, NULL_PROGRESS_MONITOR);
    client.checkout(new File[] { nested }, "master", true, NULL_PROGRESS_MONITOR);
    assertTrue(nested.isDirectory());
    e = repository.readDirCache().getEntry("nested");
    assertEquals(FileMode.GITLINK, e.getFileMode());
    statuses = client.getStatus(new File[] { workDir }, NULL_PROGRESS_MONITOR);
    assertEquals(2, statuses.size());
    assertStatus(statuses, workDir, f, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
    assertStatus(statuses, workDir, nested, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
}
 
Example #26
Source File: GitTreeEntry.java    From git-as-svn with GNU General Public License v2.0 4 votes vote down vote up
@NotNull
FileMode getFileMode() {
  return fileMode;
}
 
Example #27
Source File: FileNode.java    From ParallelGit with Apache License 2.0 4 votes vote down vote up
@Nonnull
protected static FileNode fromBlob(ObjectId id, FileMode mode, DirectoryNode parent) {
  return new FileNode(id, mode, parent);
}
 
Example #28
Source File: GitFileAttributes.java    From ParallelGit with Apache License 2.0 4 votes vote down vote up
@Nonnull
FileMode getFileMode();
 
Example #29
Source File: Node.java    From ParallelGit with Apache License 2.0 4 votes vote down vote up
protected Node(ObjectId id, FileMode mode, GfsObjectService objService) {
  this.objService = objService;
  this.id = id;
  this.mode = mode;
}
 
Example #30
Source File: Node.java    From ParallelGit with Apache License 2.0 4 votes vote down vote up
protected Node(FileMode mode, GfsObjectService objService) {
  this.objService = objService;
  this.mode = mode;
  initialize();
}