Skip to content

Commit

Permalink
golden version; handle git log output; update README
Browse files Browse the repository at this point in the history
  • Loading branch information
ymattw committed Jan 31, 2013
1 parent eab2534 commit 00bd330
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
33 changes: 31 additions & 2 deletions README.md
@@ -1,7 +1,36 @@
## About

Diff viewer.
Diff viewer, side-by-side, auto pager with `less`.

## Install

Just download the `src/cdiff.py` and save to whatever directory which in your
`$PATH`, for example, `$HOME/bin` is in my `$PATH`, so I save the script there
and name as `cdiff`.

curl -ksS https://raw.github.com/ymattw/cdiff/master/src/cdiff.py > ~/bin/cdiff

## Usage

Read diff from svn, use option `-s` for side-by-side view, use option `-w` to
use text width other than default `80`. You don't need `less`, it's automatic:

svn diff | cdiff
svn diff | cdiff -s
svn diff | cdiff -s -w 90

Read diff from git:

git diff | cdiff -s
git log -p -2 | cdiff -s
git show <commit> | cdiff -s

View a diff (patch) file:

cdiff foo.patch
cdiff foo.patch -s
cdiff foo.patch -s -w 90

Redirect output to another patch file is safe:

TODO
svn diff | cdiff -s > my.patch
6 changes: 5 additions & 1 deletion src/cdiff.py
Expand Up @@ -330,7 +330,11 @@ def _parse_udiff(self, stream):
hunk = None

while stream:
if Udiff.is_header(stream[0]):
# 'common' line occurs before 'old_path' is considered as header
# too, this happens with `git log -p` and `git show <commit>`
#
if Udiff.is_header(stream[0]) or \
(Udiff.is_common(stream[0]) and old_path is None):
if headers and old_path:
# Encounter a new header
assert new_path is not None
Expand Down

0 comments on commit 00bd330

Please sign in to comment.