GitRepository.diff: add 'text' option
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 6 Jun 2013 20:24:48 +0000 (23:24 +0300)
committerGuido Günther <agx@sigxcpu.org>
Thu, 5 Sep 2013 09:37:16 +0000 (11:37 +0200)
For generating textual diffs. Useful for Pq - for example, the 'patch'
utility does not support git binary diffs.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/git/repository.py
tests/test_GitRepository.py

index 6eed58847bee02f23b2a51ebfccc2222a987fb3d..2e8d77964433eef74201eb4906d5fe096a6e0b05 100644 (file)
@@ -1518,7 +1518,8 @@ class GitRepository(object):
         args.append(patch)
         self._git_command("apply", args)
 
-    def diff(self, obj1, obj2=None, paths=None, stat=False, summary=False):
+    def diff(self, obj1, obj2=None, paths=None, stat=False, summary=False,
+             text=False):
         """
         Diff two git repository objects
 
@@ -1532,6 +1533,8 @@ class GitRepository(object):
         @type stat: C{bool} or C{int} or C{str}
         @param summary: Show diffstat
         @type summary: C{bool}
+        @param text: Generate textual diffs, treat all files as text
+        @type text: C{bool}
         @return: diff
         @rtype: C{str}
         """
@@ -1541,6 +1544,7 @@ class GitRepository(object):
         elif stat:
             options.add('--stat=%s' % stat)
         options.add_true(summary, '--summary')
+        options.add_true(text, '--text')
         options.add(obj1)
         options.add_true(obj2, obj2)
         if paths:
index 187712e8ffc6b49c435f17c50f96e6793d7c5b34..5f0e3dd2f14e9235ee05b831afb5176c4ff5d67d 100644 (file)
@@ -487,6 +487,8 @@ def test_diff():
     True
     >>> len(repo.diff('HEAD~1', 'HEAD', 'testfile')) > 3
     True
+    >>> len(repo.diff('HEAD~1', 'HEAD', 'testfile', text=True)) > 3
+    True
     >>> len(repo.diff('HEAD~1', 'HEAD', 'filenotexist')) == 0
     True
     """