Prefix unmerged paths with conflict description (e.g. "both modified:"), the same way C Git does. Change-Id: I083cd191ae2ad3e2460aa4052774aed6e36c2699tags/v3.0.0.201305080800-m7
/* | /* | ||||
* Copyright (C) 2012, François Rey <eclipse.org_@_francois_._rey_._name> | |||||
* Copyright (C) 2012, 2013 François Rey <eclipse.org_@_francois_._rey_._name> | |||||
* and other copyright owners as documented in the project's IP log. | * and other copyright owners as documented in the project's IP log. | ||||
* | * | ||||
* This program and the accompanying materials are made available | * This program and the accompanying materials are made available | ||||
"# On branch master", // | "# On branch master", // | ||||
"# Unmerged paths:", // | "# Unmerged paths:", // | ||||
"# ", // | "# ", // | ||||
"# \tunmerged", // | |||||
"# \tboth modified: unmerged", // | |||||
"# ", // | "# ", // | ||||
"# Untracked files:", // | "# Untracked files:", // | ||||
"# ", // | "# ", // | ||||
"# Not currently on any branch.", // | "# Not currently on any branch.", // | ||||
"# Unmerged paths:", // | "# Unmerged paths:", // | ||||
"# ", // | "# ", // | ||||
"# \tunmerged", // | |||||
"# \tboth modified: unmerged", // | |||||
"# ", // | "# ", // | ||||
"# Untracked files:", // | "# Untracked files:", // | ||||
"# ", // | "# ", // |
skippingObject=skipping {0} {1} | skippingObject=skipping {0} {1} | ||||
statusFileListFormat=\t%1$s | statusFileListFormat=\t%1$s | ||||
statusFileListFormatWithPrefix=\t%1$-11s %2$s | statusFileListFormatWithPrefix=\t%1$-11s %2$s | ||||
statusFileListFormatUnmerged=\t%1$-20s%2$s | |||||
statusModified=modified: | statusModified=modified: | ||||
statusNewFile=new file: | statusNewFile=new file: | ||||
statusRemoved=deleted: | statusRemoved=deleted: | ||||
statusBothDeleted=both deleted: | |||||
statusAddedByUs=added by us: | |||||
statusDeletedByThem=deleted by them: | |||||
statusAddedByThem=added by them: | |||||
statusDeletedByUs=deleted by us: | |||||
statusBothAdded=both added: | |||||
statusBothModified=both modified: | |||||
switchedToNewBranch=Switched to a new branch ''{0}'' | switchedToNewBranch=Switched to a new branch ''{0}'' | ||||
switchedToBranch=Switched to branch ''{0}'' | switchedToBranch=Switched to branch ''{0}'' | ||||
tagAlreadyExists=tag ''{0}'' already exists | tagAlreadyExists=tag ''{0}'' already exists |
/* | /* | ||||
* Copyright (C) 2010, 2012 Sasa Zivkov <sasa.zivkov@sap.com> | |||||
* Copyright (C) 2010, 2013 Sasa Zivkov <sasa.zivkov@sap.com> | |||||
* and other copyright owners as documented in the project's IP log. | * and other copyright owners as documented in the project's IP log. | ||||
* | * | ||||
* This program and the accompanying materials are made available | * This program and the accompanying materials are made available | ||||
/***/ public String skippingObject; | /***/ public String skippingObject; | ||||
/***/ public String statusFileListFormat; | /***/ public String statusFileListFormat; | ||||
/***/ public String statusFileListFormatWithPrefix; | /***/ public String statusFileListFormatWithPrefix; | ||||
/***/ public String statusFileListFormatUnmerged; | |||||
/***/ public String statusModified; | /***/ public String statusModified; | ||||
/***/ public String statusNewFile; | /***/ public String statusNewFile; | ||||
/***/ public String statusRemoved; | /***/ public String statusRemoved; | ||||
/***/ public String statusBothDeleted; | |||||
/***/ public String statusAddedByUs; | |||||
/***/ public String statusDeletedByThem; | |||||
/***/ public String statusAddedByThem; | |||||
/***/ public String statusDeletedByUs; | |||||
/***/ public String statusBothAdded; | |||||
/***/ public String statusBothModified; | |||||
/***/ public String switchedToNewBranch; | /***/ public String switchedToNewBranch; | ||||
/***/ public String switchedToBranch; | /***/ public String switchedToBranch; | ||||
/***/ public String tagAlreadyExists; | /***/ public String tagAlreadyExists; |
/* | /* | ||||
* Copyright (C) 2011, François Rey <eclipse.org_@_francois_._rey_._name> | |||||
* Copyright (C) 2011, 2013 François Rey <eclipse.org_@_francois_._rey_._name> | |||||
* and other copyright owners as documented in the project's IP log. | * and other copyright owners as documented in the project's IP log. | ||||
* | * | ||||
* This program and the accompanying materials are made available | * This program and the accompanying materials are made available | ||||
import java.text.MessageFormat; | import java.text.MessageFormat; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Collections; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | |||||
import org.eclipse.jgit.api.Git; | import org.eclipse.jgit.api.Git; | ||||
import org.eclipse.jgit.lib.Constants; | import org.eclipse.jgit.lib.Constants; | ||||
import org.eclipse.jgit.lib.IndexDiff.StageState; | |||||
import org.eclipse.jgit.lib.Ref; | import org.eclipse.jgit.lib.Ref; | ||||
import org.eclipse.jgit.lib.Repository; | import org.eclipse.jgit.lib.Repository; | ||||
protected final String statusFileListFormatWithPrefix = CLIText.get().statusFileListFormatWithPrefix; | protected final String statusFileListFormatWithPrefix = CLIText.get().statusFileListFormatWithPrefix; | ||||
protected final String statusFileListFormatUnmerged = CLIText.get().statusFileListFormatUnmerged; | |||||
@Override | @Override | ||||
protected void run() throws Exception { | protected void run() throws Exception { | ||||
// Print current branch name | // Print current branch name | ||||
Collection<String> modified = status.getModified(); | Collection<String> modified = status.getModified(); | ||||
Collection<String> missing = status.getMissing(); | Collection<String> missing = status.getMissing(); | ||||
Collection<String> untracked = status.getUntracked(); | Collection<String> untracked = status.getUntracked(); | ||||
Collection<String> unmerged = status.getConflicting(); | |||||
Map<String, StageState> unmergedStates = status | |||||
.getConflictingStageState(); | |||||
Collection<String> toBeCommitted = new ArrayList<String>(added); | Collection<String> toBeCommitted = new ArrayList<String>(added); | ||||
toBeCommitted.addAll(changed); | toBeCommitted.addAll(changed); | ||||
toBeCommitted.addAll(removed); | toBeCommitted.addAll(removed); | ||||
modified, missing, null); | modified, missing, null); | ||||
firstHeader = false; | firstHeader = false; | ||||
} | } | ||||
int nbUnmerged = unmerged.size(); | |||||
int nbUnmerged = unmergedStates.size(); | |||||
if (nbUnmerged > 0) { | if (nbUnmerged > 0) { | ||||
if (!firstHeader) | if (!firstHeader) | ||||
printSectionHeader(""); //$NON-NLS-1$ | printSectionHeader(""); //$NON-NLS-1$ | ||||
printSectionHeader(CLIText.get().unmergedPaths); | printSectionHeader(CLIText.get().unmergedPaths); | ||||
printList(unmerged); | |||||
printUnmerged(unmergedStates); | |||||
firstHeader = false; | firstHeader = false; | ||||
} | } | ||||
int nbUntracked = untracked.size(); | int nbUntracked = untracked.size(); | ||||
} | } | ||||
return list.size(); | return list.size(); | ||||
} | } | ||||
private void printUnmerged(Map<String, StageState> unmergedStates) | |||||
throws IOException { | |||||
List<String> paths = new ArrayList<String>(unmergedStates.keySet()); | |||||
Collections.sort(paths); | |||||
for (String path : paths) { | |||||
StageState state = unmergedStates.get(path); | |||||
String stateDescription = getStageStateDescription(state); | |||||
outw.println(CLIText.formatLine(String.format( | |||||
statusFileListFormatUnmerged, stateDescription, path))); | |||||
outw.flush(); | |||||
} | |||||
} | |||||
private static String getStageStateDescription(StageState stageState) { | |||||
CLIText text = CLIText.get(); | |||||
switch (stageState) { | |||||
case BOTH_DELETED: | |||||
return text.statusBothDeleted; | |||||
case ADDED_BY_US: | |||||
return text.statusAddedByUs; | |||||
case DELETED_BY_THEM: | |||||
return text.statusDeletedByThem; | |||||
case ADDED_BY_THEM: | |||||
return text.statusAddedByThem; | |||||
case DELETED_BY_US: | |||||
return text.statusDeletedByUs; | |||||
case BOTH_ADDED: | |||||
return text.statusBothAdded; | |||||
case BOTH_MODIFIED: | |||||
return text.statusBothModified; | |||||
default: | |||||
throw new IllegalArgumentException("Unknown StageState: " //$NON-NLS-1$ | |||||
+ stageState); | |||||
} | |||||
} | |||||
} | } |
/* | /* | ||||
* Copyright (C) 2011, Christian Halstrick <christian.halstrick@sap.com> | |||||
* Copyright (C) 2011, 2013 Christian Halstrick <christian.halstrick@sap.com> | |||||
* and other copyright owners as documented in the project's IP log. | * and other copyright owners as documented in the project's IP log. | ||||
* | * | ||||
* This program and the accompanying materials are made available | * This program and the accompanying materials are made available | ||||
package org.eclipse.jgit.api; | package org.eclipse.jgit.api; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.Map; | |||||
import java.util.Set; | import java.util.Set; | ||||
import org.eclipse.jgit.lib.IndexDiff; | import org.eclipse.jgit.lib.IndexDiff; | ||||
import org.eclipse.jgit.lib.IndexDiff.StageState; | |||||
/** | /** | ||||
* A class telling where the working-tree, the index and the current HEAD differ | * A class telling where the working-tree, the index and the current HEAD differ | ||||
return Collections.unmodifiableSet(diff.getConflicting()); | return Collections.unmodifiableSet(diff.getConflicting()); | ||||
} | } | ||||
/** | |||||
* @return a map from conflicting path to its {@link StageState}. | |||||
* @since 3.0 | |||||
*/ | |||||
public Map<String, StageState> getConflictingStageState() { | |||||
return Collections.unmodifiableMap(diff.getConflictingStageStates()); | |||||
} | |||||
/** | /** | ||||
* @return set of files and folders that are ignored and not in the index. | * @return set of files and folders that are ignored and not in the index. | ||||
*/ | */ |