diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-06-06 23:24:48 +0300 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2013-09-05 11:37:16 +0200 |
commit | e48f0a09e8f13a024d8f51c08b3c2b25e886ac7b (patch) | |
tree | d1deee164ffef9444e7907d8981f1524514be2c1 | |
parent | bc409569f58a2c9c1c0393c923650bf84f159ddc (diff) |
GitRepository.diff: add 'text' option
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>
-rw-r--r-- | gbp/git/repository.py | 6 | ||||
-rw-r--r-- | tests/test_GitRepository.py | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 6eed588..2e8d779 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -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: diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py index 187712e..5f0e3dd 100644 --- a/tests/test_GitRepository.py +++ b/tests/test_GitRepository.py @@ -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 """ |