chiark / gitweb /
stgit.el: Refactor: add stgit-find-copies-harder-diff-arg helper function
authorGustav Hållberg <gustav@virtutech.com>
Thu, 30 Jul 2009 22:57:58 +0000 (00:57 +0200)
committerGustav Hållberg <gustav@virtutech.com>
Thu, 6 Aug 2009 20:49:07 +0000 (22:49 +0200)
Signed-off-by: Gustav Hållberg <gustav@virtutech.com>
contrib/stgit.el

index c624ecc7318ab8329b56aa373942977ef1a8dc90..944d01e6e58084750497b69878060b8720df624a 100644 (file)
@@ -439,14 +439,19 @@ (defun stgit-file-pp (file)
                          (list 'entry-type 'file
                                'file-data file))))
 
+(defun stgit-find-copies-harder-diff-arg ()
+  "Return the flag to use with `git-diff' depending on the
+`stgit-expand-find-copies-harder' flag."
+  (if stgit-expand-find-copies-harder
+      "--find-copies-harder"
+    "-C"))
+
 (defun stgit-insert-patch-files (patch)
   "Expand (show modification of) the patch PATCH after the line
 at point."
   (let* ((patchsym (stgit-patch-name patch))
          (end (progn (insert "#") (prog1 (point-marker) (forward-char -1))))
-         (args (list "-z" (if stgit-expand-find-copies-harder
-                              "--find-copies-harder"
-                            "-C")))
+         (args (list "-z" (stgit-find-copies-harder-diff-arg)))
          (ewoc (ewoc-create #'stgit-file-pp nil nil t)))
     (setf (stgit-patch-files-ewoc patch) ewoc)
     (with-temp-buffer
@@ -920,9 +925,7 @@ (defun stgit-show ()
               (patch-name (stgit-patch-name-at-point))
               (patch-id (stgit-id patch-name))
               (args (append (and (stgit-file-cr-from patched-file)
-                                 (if stgit-expand-find-copies-harder
-                                     '("--find-copies-harder")
-                                   '("-C")))
+                                 (list (stgit-find-copies-harder-diff-arg)))
                             (cond ((eq patch-id :index)
                                    '("--cached"))
                                   ((eq patch-id :work)