Browse Source

Handle diverged branches, add --force.

Jelmer Vernooij 2 years ago
parent
commit
e7fbfff571
1 changed files with 6 additions and 1 deletions
  1. 6 1
      dulwich/cli.py

+ 6 - 1
dulwich/cli.py

@@ -561,10 +561,15 @@ class cmd_push(Command):
 
     def run(self, argv):
         parser = argparse.ArgumentParser()
+        parser.add_argument('-f', '--force', action='store_true', help='Force')
         parser.add_argument('to_location', type=str)
         parser.add_argument('refspec', type=str, nargs='*')
         args = parser.parse_args(argv)
-        porcelain.push('.', args.to_location, args.refspec or None)
+        try:
+            porcelain.push('.', args.to_location, args.refspec or None, force=args.force)
+        except porcelain.DivergedBranches:
+            sys.stderr.write('Diverged branches; specify --force to override')
+            return 1
 
 
 class cmd_remote_add(Command):