| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | 7 | import re | |
| 8 | 8 | import objects.blob as blob | |
| 9 | - | ||
| 9 | + from errors import GitCommandError | ||
| 10 | 10 | ||
| 11 | 11 | class Diffable(object): | |
| 12 | 12 | """ | |
@@ -26,15 +26,17 @@ class Diffable(object): | |||
| 26 | 26 | class Index(object): | |
| 27 | 27 | pass | |
| 28 | 28 | ||
| 29 | - def diff(self, other=None, paths=None, create_patch=False, **kwargs): | ||
| 29 | + def diff(self, other=Index, paths=None, create_patch=False, **kwargs): | ||
| 30 | 30 | """ | |
| 31 | 31 | Creates diffs between two items being trees, trees and index or an | |
| 32 | 32 | index and the working tree. | |
| 33 | 33 | ||
| 34 | 34 | ``other`` | |
| 35 | 35 | Is the item to compare us with. | |
| 36 | 36 | If None, we will be compared to the working tree. | |
| 37 | - If Index ( type ), it will be compared against the index | ||
| 37 | + If Index ( type ), it will be compared against the index. | ||
| 38 | + It defaults to Index to assure the method will not by-default fail | ||
| 39 | + on bare repositories. | ||
| 38 | 40 | ||
| 39 | 41 | ``paths`` | |
| 40 | 42 | is a list of paths or a single path to limit the diff to. | |
@@ -53,7 +55,10 @@ def diff(self, other=None, paths=None, create_patch=False, **kwargs): | |||
| 53 | 55 | git.DiffIndex | |
| 54 | 56 | ||
| 55 | 57 | Note | |
| 56 | - Rename detection will only work if create_patch is True | ||
| 58 | + Rename detection will only work if create_patch is True. | ||
| 59 | + | ||
| 60 | + On a bare repository, 'other' needs to be provided as Index or as | ||
| 61 | + as Tree/Commit, or a git command error will occour | ||
| 57 | 62 | """ | |
| 58 | 63 | args = list(self._diff_args[:]) | |
| 59 | 64 | args.append( "--abbrev=40" ) # we need full shas | |
@@ -87,7 +92,13 @@ def diff(self, other=None, paths=None, create_patch=False, **kwargs): | |||
| 87 | 92 | diff_method = Diff._index_from_raw_format | |
| 88 | 93 | if create_patch: | |
| 89 | 94 | diff_method = Diff._index_from_patch_format | |
| 90 | - return diff_method(self.repo, proc.stdout) | ||
| 95 | + index = diff_method(self.repo, proc.stdout) | ||
| 96 | + | ||
| 97 | + status = proc.wait() | ||
| 98 | + if status != 0: | ||
| 99 | + raise GitCommandError("git-diff", status, proc.stderr ) | ||
| 100 | + | ||
| 101 | + return index | ||
| 91 | 102 | ||
| 92 | 103 | ||
| 93 | 104 | class DiffIndex(list): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,3 +52,9 @@ def next(self): | |||
| 52 | 52 | ||
| 53 | 53 | def __init__(self, input_list_or_string): | |
| 54 | 54 | self.stdout = self.Stream(input_list_or_string) | |
| 55 | + self.stderr = self.Stream('') | ||
| 56 | + | ||
| 57 | + def wait(self): | ||
| 58 | + return 0 | ||
| 59 | + | ||
| 60 | + poll = wait | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments