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
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ bin_SCRIPTS = \
dist_bin_SCRIPTS = \
patchview/gitdiff \
patchview/gitdiffview \
patchview/gitshow \
patchview/gitshowview \
patchview/svndiff \
patchview/svndiffview

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Patchutils is a small collection of programs that operate on patch files. It pro

- **gitdiff** / **gitdiffview** - Git-specific diff viewing tools.

- **gitshow** / **gitshowview** - Git-specific show viewing tools.

- **svndiff** / **svndiffview** - Subversion-specific diff viewing tools.

## Installation
Expand Down
32 changes: 14 additions & 18 deletions patchview/README.patchview
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
So what is patchview? It is a wrapper of filterdiff for use with numbered files.

$ patchview
(without args)

is equivalent to: lsdiff --number
Without args is equivalent to: lsdiff --number

$ patchview -F2-
(or with any other args)


is equivalent to: filterdiff -F2- (or whatever arguments are supplied)
With one or more args is equivalent to: filterdiff args

There are 4 scripts for working with git repos (gitdiff, gitdiffview, gitshow and gitshowview) and 2 for svn (svndiff and svndiffview).
Also these scripts have option -v which shows the full command that is which is being executed.

There are two scripts for working with git (gitdiff and gitdiffview) and two for svn (svndiff and svndiffview).

$ svndiff
$ gitdiff
(without args)

will give the list of files modified
$ gitdiff

$ svndiff -F1
$ gitdiff -F1

will show the patch of file #1
Without args, will give the list of files modified
With args will show the patches according the args, for example, `gitdiff -F1` will show the patch for first file

$ svndiffview
$ gitdiffview

pipe all patches through filterdiff to `vim - -R` (in read-only mode, easy to quit), showing complete patch with color.
Without args will pipe all patches through filterdiff to `vim - -R` (in read-only mode, easy to quit), showing complete patch with colors.
With args will pipe the patches according the args, for example, `gitsvnview -F2` will pipe the patch for second file to `vim - -R`.

$ svndiffview -F2
$ gitdiffview -F2
(or any other args)
$ gitshow
$ gitshowview

will pipe patch of file #2 to `vim - -R`
Is the same of gitdiff but use `git show` instead of `git diff`.

Example:
We can make the following one-line script with the name difftotrunk.sh, to view the differences of two directories or svn repos (trunk and .)
Expand Down
47 changes: 47 additions & 0 deletions patchview/gitshow
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2020 Sérgio Basto <sergio@serjux.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#

import os
import sys
import argparse
from subprocess import Popen, PIPE

enviro = os.environ
workdir = '.'

parser = argparse.ArgumentParser()
parser.add_argument('-v', '--debug',
help='writes the commands that will be executed',
action='store_true')
parser.add_argument('git_args', nargs='*', default=[])
parser.add_argument('patchview_args', nargs=argparse.REMAINDER)
args, unknown = parser.parse_known_args()
largs = vars(args).get("git_args")
rargs = vars(args).get("patchview_args")

if args.debug:
print("%s | %s" % (" ".join(['git', 'diff'] + largs),
" ".join(['patchview'] + rargs + unknown)))

p1 = Popen(['git', 'show'] + largs, stdout=PIPE, env=enviro, cwd=workdir)
p2 = Popen(['patchview'] + rargs + unknown, stdin=p1.stdout, stdout=PIPE,
env=enviro, cwd=workdir)
p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits.
sys.stdout.buffer.write(p2.communicate()[0])
20 changes: 20 additions & 0 deletions patchview/gitshowview
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
#
# Copyright (C) 2014-2020 Sérgio Basto <sergio@serjux.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#

gitshow --filter "$@" | vim -R -