summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard <axel.richard@obeo.fr>2013-11-29 11:06:11 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2013-11-29 23:42:08 +0100
commitc95e4fb90959c56411cdbf0e00da481b7285f2dc (patch)
tree10f2318cf520695b78418a6f34ef859abd205f7a
parentaf40635aba91a78ec248503906996ca89898e888 (diff)
downloadjgit-c95e4fb90959c56411cdbf0e00da481b7285f2dc.tar.gz
jgit-c95e4fb90959c56411cdbf0e00da481b7285f2dc.zip
Manage CheckoutConflictException in pgm
Change-Id: I49f92bf7cafc80404f0bd07d62ff4b25e4db6e7c Signed-off-by: Axel Richard <axel.richard@obeo.fr> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java7
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java3
3 files changed, 12 insertions, 0 deletions
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
index 1212d93652..fc83b956b9 100644
--- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
+++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
@@ -36,6 +36,8 @@ cantFindGitDirectory=error: can't find git directory
cantWrite=Can't write {0}
changesNotStagedForCommit=Changes not staged for commit:
changesToBeCommitted=Changes to be committed:
+checkoutConflict=error: Your local changes to the following files would be overwritten by checkout:
+checkoutConflictPathLine=\t{0}
commitLabel=commit
configFileNotFound=configuration file {0} not found
conflictingUsageOf_git_dir_andArguments=conflicting usage of --git-dir and arguments
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
index 8115039729..2f35ecbabd 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010, 2012 Chris Aniszczyk <caniszczyk@gmail.com>
+ * Copyright (C) 2013, Obeo
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -47,6 +48,7 @@ import java.text.MessageFormat;
import org.eclipse.jgit.api.CheckoutCommand;
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.CheckoutConflictException;
import org.eclipse.jgit.api.errors.RefAlreadyExistsException;
import org.eclipse.jgit.api.errors.RefNotFoundException;
import org.eclipse.jgit.lib.Constants;
@@ -107,6 +109,11 @@ class Checkout extends TextBuiltin {
} catch (RefAlreadyExistsException e) {
throw die(MessageFormat.format(CLIText.get().branchAlreadyExists,
name));
+ } catch (CheckoutConflictException e) {
+ outw.println(CLIText.get().checkoutConflict);
+ for (String path : e.getConflictingPaths())
+ outw.println(MessageFormat.format(
+ CLIText.get().checkoutConflictPathLine, path));
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
index de8675e0fb..a51313ae1e 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010, 2013 Sasa Zivkov <sasa.zivkov@sap.com>
+ * Copyright (C) 2013, Obeo
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -106,6 +107,8 @@ public class CLIText extends TranslationBundle {
/***/ public String cantWrite;
/***/ public String changesNotStagedForCommit;
/***/ public String changesToBeCommitted;
+ /***/ public String checkoutConflict;
+ /***/ public String checkoutConflictPathLine;
/***/ public String commitLabel;
/***/ public String conflictingUsageOf_git_dir_andArguments;
/***/ public String couldNotCreateBranch;