From 7acb0e11f092f1e7c931cc3def9c7d95fd3d0333 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Thu, 10 Jul 2008 14:21:32 -0400 Subject: [PATCH] cmd_switch: require confirmation before switching with changes --- yap/yap.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yap/yap.py b/yap/yap.py index aa57a6e..8522fc0 100644 --- a/yap/yap.py +++ b/yap/yap.py @@ -596,12 +596,16 @@ are updated to reflect their state in the new branch. Additionally, any future commits are added to the new branch instead of the previous line of history. """) - def cmd_switch(self, branch): - "" + @takes_options("f") + def cmd_switch(self, branch, **flags): + "[-f] " ref = get_output("git rev-parse --verify 'refs/heads/%s'" % branch) if not ref: raise YapError("No such branch: %s" % branch) + if '-f' not in flags and (self._get_unstaged_files() or self._get_staged_files()): + raise YapError("You have uncommitted changes. Use -f to continue anyway") + if self._get_unstaged_files() and self._get_staged_files(): raise YapError("You have staged and unstaged changes. Perhaps unstage -a?") -- 2.11.4.GIT