chiark / gitweb /
Add --file option to pick
authorCatalin Marinas <catalin.marinas@gmail.com>
Wed, 28 Jan 2009 23:08:13 +0000 (23:08 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Wed, 28 Jan 2009 23:08:58 +0000 (23:08 +0000)
This allows folding of specific files only.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/pick.py

index ee08c01c5219114647217ac73df315199f9c3b36..e0e6624fd20d2939c594765b2be0e99641a603fa 100644 (file)
@@ -52,6 +52,8 @@ options = [
         short = 'Fold the commit object into the current patch'),
     opt('--update', action = 'store_true',
         short = 'Like fold but only update the current patch files'),
+    opt('-f', '--file', action = 'append',
+        short = 'Only fold the given file (can be used multiple times)'),
     opt('--unapplied', action = 'store_true',
         short = 'Keep the patch unapplied')]
 
@@ -83,8 +85,11 @@ def __pick_commit(commit_id, patchname, options):
         out.start('Folding commit %s' % commit_id)
 
         # try a direct git apply first
-        if not git.apply_diff(bottom, top):
-            git.merge_recursive(bottom, git.get_head(), top)
+        if not git.apply_diff(bottom, top, files = options.file):
+            if options.file:
+                raise CmdException('Patch folding failed')
+            else:
+                git.merge_recursive(bottom, git.get_head(), top)
 
         out.done()
     elif options.update:
@@ -152,6 +157,9 @@ def func(parser, options, args):
     if not args:
         parser.error('incorrect number of arguments')
 
+    if options.file and not options.fold:
+        parser.error('--file can only be specified with --fold')
+
     if not options.unapplied:
         check_local_changes()
         check_conflicts()