Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions testdata/empty/left/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print('something here')
Empty file.
7 changes: 6 additions & 1 deletion webdiff/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ def fast_num_lines(path: str) -> int:
# See https://stackoverflow.com/q/9629179/388951 for the idea to use a Unix command.
# Unfortunately `wc -l` ignores the last line if there is no trailing newline. So
# instead, see https://stackoverflow.com/a/38870057/388951
return int(subprocess.check_output(['grep', '-c', '', path]))
try:
return int(subprocess.check_output(['grep', '-c', '', path]))
except subprocess.CalledProcessError as e:
if e.returncode == 1:
return 0 # grep -c returns an error code if there are no matches
raise


def get_diff_ops(
Expand Down