summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorTomasz Zarna <tzarna@gmail.com>2012-10-07 23:38:34 +0200
committerTomasz Zarna <tzarna@gmail.com>2012-10-07 23:38:34 +0200
commite8c25a1738cb8c34116aced00152cd99ac5b44ef (patch)
treee07c4fdfd8755509094bad43aae3d45516d106fd /org.eclipse.jgit.pgm
parenta27c1a6b15c8237739285544ab1e4c56543b2985 (diff)
downloadjgit-e8c25a1738cb8c34116aced00152cd99ac5b44ef.tar.gz
jgit-e8c25a1738cb8c34116aced00152cd99ac5b44ef.zip
Add --squash option to org.eclipse.jgit.pgm.Merge
Change-Id: Ifd20b6f4731cfa71319145cac7b464aa53db18b8
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties3
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java10
3 files changed, 14 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties
index 5e38c04bb5..8bbcf5e841 100644
--- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties
+++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties
@@ -66,6 +66,7 @@ listeningOn=Listening on {0}
mergeConflict=CONFLICT(content): Merge conflict in {0}
mergeFailed=Automatic merge failed; fix conflicts and then commit the result
mergeMadeBy=Merge made by the ''{0}'' strategy.
+mergedSquashed=Squash commit -- not updating HEAD\nAutomatic merge went well; stopped before committing as requested
metaVar_DAG=DAG
metaVar_KEY=KEY
metaVar_arg=ARG
@@ -127,6 +128,7 @@ notAnIndexFile={0} is not an index file
notAnObject={0} is not an object
notFound=!! NOT FOUND !!
noteObjectTooLargeToPrint=Note object {0} too large to print
+nothingToSquash=\ (nothing to squash)
notOnAnyBranch=Not currently on any branch.
onBranch=On branch {0}
onBranchToBeBorn=You are on a branch yet to be born
@@ -262,6 +264,7 @@ usage_showRefNamesMatchingCommits=Show ref names matching commits
usage_showPatch=display patch
usage_showRefNamesMatchingCommits=Show ref names matching commits
usage_showNotes=Add this ref to the list of note branches from which notes are displayed
+usage_squash=Squash commits as if a real merge happened, but do not make a commit or move the HEAD.
usage_srcPrefix=show the source prefix instead of "a/"
usage_symbolicVersionForTheProject=Symbolic version for the project
usage_synchronizeIPZillaData=Synchronize IPZilla data
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java
index a5756cec14..86ec92d382 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java
@@ -133,6 +133,7 @@ public class CLIText extends TranslationBundle {
/***/ public String mergeConflict;
/***/ public String mergeFailed;
/***/ public String mergeMadeBy;
+ /***/ public String mergedSquashed;
/***/ public String metaVar_KEY;
/***/ public String metaVar_arg;
/***/ public String metaVar_author;
@@ -189,6 +190,7 @@ public class CLIText extends TranslationBundle {
/***/ public String notFound;
/***/ public String notOnAnyBranch;
/***/ public String noteObjectTooLargeToPrint;
+ /***/ public String nothingToSquash;
/***/ public String onBranchToBeBorn;
/***/ public String onBranch;
/***/ public String onlyOneMetaVarExpectedIn;
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java
index 8c769e6076..728866d182 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java
@@ -60,6 +60,9 @@ class Merge extends TextBuiltin {
@Option(name = "--strategy", aliases = { "-s" }, usage = "usage_mergeStrategy")
private String strategyName;
+ @Option(name = "--squash", usage = "usage_squash")
+ private boolean squash;
+
private MergeStrategy mergeStrategy = MergeStrategy.RESOLVE;
@Argument(required = true)
@@ -83,10 +86,12 @@ class Merge extends TextBuiltin {
Git git = new Git(db);
MergeResult result = git.merge().setStrategy(mergeStrategy)
- .include(src).call();
+ .setSquash(squash).include(src).call();
switch (result.getMergeStatus()) {
case ALREADY_UP_TO_DATE:
+ if (squash)
+ outw.print(CLIText.get().nothingToSquash);
outw.println(CLIText.get().alreadyUpToDate);
break;
case FAST_FORWARD:
@@ -117,6 +122,9 @@ class Merge extends TextBuiltin {
outw.println(MessageFormat.format(CLIText.get().mergeMadeBy,
mergeStrategy.getName()));
break;
+ case MERGED_SQUASHED:
+ outw.println(CLIText.get().mergedSquashed);
+ break;
case NOT_SUPPORTED:
outw.println(MessageFormat.format(
CLIText.get().unsupportedOperation, result.toString()));