gits: when asking for reset --hard, also offer push -f
Change-Id: Iab38229ee7deaec91c342fa114028e222e652b60
diff --git a/src/gits b/src/gits
index c7f5750..d47759f 100755
--- a/src/gits
+++ b/src/gits
@@ -238,16 +238,19 @@
return answer
-def ask_reset_hard(git_dir):
+def ask_reset_hard_or_push_f(git_dir):
do_reset = ask(git_dir, 'Diverged.',
'%s: git reset --hard %s?' % (
orig_branch, upstream_branch),
'<empty> no',
- 'OK yes (write OK in caps!)',
- valid_answers=('', 'OK'))
+ 'OK yes, reset to upstream (write OK in caps!)',
+ 'P `push -f` to overwrite upstream (P in caps!)',
+ valid_answers=('', 'OK', 'P'))
if do_reset == 'OK':
git(git_dir, 'reset', '--hard', upstream_branch)
+ elif do_reset == 'P':
+ git(git_dir, 'push', '-f')
def rebase(git_dir):
@@ -287,7 +290,7 @@
# Diverged
elif ahead and behind:
- ask_reset_hard(git_dir)
+ ask_reset_hard_or_push_f(git_dir)
# Behind
elif behind:
@@ -315,7 +318,7 @@
git(git_dir, 'commit', '-am', 'wip', may_fail=True)
git(git_dir, 'checkout', orig_branch)
- ask_reset_hard(git_dir)
+ ask_reset_hard_or_push_f(git_dir)
return orig_branch