[StGit PATCH 09/15] Refactoring: pass more than one file to resolved()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This lets us cut down on the number of calls to git.

Signed-off-by: Karl Hasselström <kha@xxxxxxxxxxx>

---

 stgit/commands/common.py   |   11 +++++------
 stgit/commands/resolved.py |    6 +++---
 stgit/commands/status.py   |    3 +--
 stgit/run.py               |    3 +++
 4 files changed, 12 insertions(+), 11 deletions(-)


diff --git a/stgit/commands/common.py b/stgit/commands/common.py
index f31c09b..446ead2 100644
--- a/stgit/commands/common.py
+++ b/stgit/commands/common.py
@@ -135,17 +135,16 @@ def print_crt_patch(branch = None):
     else:
         out.info('No patches applied')
 
-def resolved(filename, reset = None):
+def resolved(filenames, reset = None):
     if reset:
         stage = {'ancestor': 1, 'current': 2, 'patched': 3}[reset]
-        Run('git-checkout-index', '--no-create', '--stage=%d' % stage, '--',
-            filename).no_output()
-    git.add([filename])
+        Run('git-checkout-index', '--no-create', '--stage=%d' % stage,
+            '--stdin', '-z').input_nulterm(filenames).no_output()
+    git.add(filenames)
 
 def resolved_all(reset = None):
     conflicts = git.get_conflicts()
-    for filename in conflicts:
-        resolved(filename, reset)
+    resolved(conflicts, reset)
 
 def push_patches(patches, check_merged = False):
     """Push multiple patches onto the stack. This function is shared
diff --git a/stgit/commands/resolved.py b/stgit/commands/resolved.py
index de38737..d524d51 100644
--- a/stgit/commands/resolved.py
+++ b/stgit/commands/resolved.py
@@ -73,7 +73,7 @@ def func(parser, options, args):
                 raise CmdException, 'No conflicts for "%s"' % filename
 
     # resolved
-    for filename in files:
-        if options.interactive:
+    if options.interactive:
+        for filename in files:
             interactive_merge(filename)
-        resolved(filename, options.reset)
+    resolved(files, options.reset)
diff --git a/stgit/commands/status.py b/stgit/commands/status.py
index 156552b..0d7e5ab 100644
--- a/stgit/commands/status.py
+++ b/stgit/commands/status.py
@@ -70,8 +70,7 @@ def func(parser, options, args):
     """
     if options.reset:
         if args:
-            for f in args:
-                resolved(f)
+            resolved(args)
             git.reset(args)
         else:
             resolved_all()
diff --git a/stgit/run.py b/stgit/run.py
index 7986f3b..85b0e0c 100644
--- a/stgit/run.py
+++ b/stgit/run.py
@@ -104,6 +104,9 @@ class Run:
     def input_lines(self, lines):
         self.__indata = ''.join(['%s\n' % line for line in lines])
         return self
+    def input_nulterm(self, items):
+        self.__indata = ''.join('%s\0' % line for line in lines)
+        return self
     def no_output(self):
         outdata = self.__run_io()
         if outdata:

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux