| Summary: | Support creation of patch from synchronize view | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Technology] EGit | Reporter: | Andreas Höhmann <andreas.hoehmann> | ||||
| Component: | Core | Assignee: | Project Inbox <egit.core-inbox> | ||||
| Status: | NEW --- | QA Contact: | |||||
| Severity: | enhancement | ||||||
| Priority: | P3 | CC: | b.muskalla, Knut.Friedhelm, mauromol, piotr.findeisen | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Andreas Höhmann
Created attachment 185819 [details]
ui mock
I tried last night to understand the code behind org.eclipse.egit.ui.internal.history.FileDiff.compute(TreeWalk, RevCommit) ... without success :D
Is it impossible to calculate a Diff between the head (last commited state) and a local changed file (changes not commited) ?
I tried to use the Code from org.eclipse.egit.ui.internal.history.command.CreatePatchHandler.execute(ExecutionEvent) to implement
a new org.eclipse.egit.ui.internal.actions.CreatePatchActionHandler.execute(ExecutionEvent) ... no way :-(
CreatePatchHandler:
RevCommit commit = (RevCommit) selection.getFirstElement();
Repository repo = getRepository(event);
TreeWalk fileWalker = new TreeWalk(repo);
fileWalker.setRecursive(true);
fileWalker.setFilter(TreeFilter.ANY_DIFF);
GitCreatePatchWizard.run(getPart(event), commit, fileWalker, repo);
CreatePatchActionHandler:
final IResource resource = getSelectedResources(event)[0];
final RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
final Repository repository = mapping.getRepository();
try {
Ref head = repository.getRef(Constants.HEAD);
RevWalk rw = new RevWalk(repository);
RevCommit commit = rw.parseCommit(head.getObjectId());
final String gitPath = mapping.getRepoRelativePath(resource);
ITypedElement next = CompareUtils.getFileRevisionTypedElement(gitPath, commit,repository);
TreeWalk fileWalker = new TreeWalk(repository);
fileWalker.setRecursive(true);
fileWalker.setFilter(AndTreeFilter.create(PathFilterGroup.createFromStrings(Arrays.asList(gitPath)), TreeFilter.ANY_DIFF));
GitCreatePatchWizard.run(getPart(event), commit, fileWalker, repository);
...
But I get always a NPE ...
Caused by: java.lang.NullPointerException
at org.eclipse.egit.ui.internal.history.FileDiff.trees(FileDiff.java:57)
at org.eclipse.egit.ui.internal.history.FileDiff.compute(FileDiff.java:69)
at org.eclipse.egit.ui.internal.history.GitCreatePatchWizard$1.run(GitCreatePatchWizard.java:165)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Root exception:
java.lang.NullPointerException
at org.eclipse.egit.ui.internal.history.FileDiff.trees(FileDiff.java:57)
at org.eclipse.egit.ui.internal.history.FileDiff.compute(FileDiff.java:69)
at org.eclipse.egit.ui.internal.history.GitCreatePatchWizard$1.run(GitCreatePatchWizard.java:165)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
private static ObjectId[] trees(final RevCommit commit) {
final ObjectId[] r = new ObjectId[commit.getParentCount() + 1];
for (int i = 0; i < r.length - 1; i++) {
RevCommit parent = commit.getParent(i);
RevTree tree = parent.getTree();
// if (tree == null)
// continue;
r[i] = tree.getId();
}
the tree is null ?
Any hint would be nice :D
How about submitting your initial version to Gerrit (maybe prefix it with Draft) so we can look at it together to resolve the problem. |