Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gitshow and gitshowview #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -13,6 +13,8 @@ bin_SCRIPTS = \
dist_bin_SCRIPTS = \
patchview/gitdiff \
patchview/gitdiffview \
patchview/gitshow \
patchview/gitshowview \
patchview/svndiff \
patchview/svndiffview

Expand Down
7 changes: 6 additions & 1 deletion patchview/README.patchview
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ is equivalent to: lsdiff --number

is equivalent to: filterdiff -F2- (or whatever arguments are supplied)

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


$ svndiff
$ gitdiff
Expand All @@ -34,6 +36,9 @@ pipe all patches through filterdiff to `vim - -R` (in read-only mode, easy to qu

will pipe patch of file #2 to `vim - -R`

gitshow and gitshowview instead use git diff, use git show .


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 -