-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwestvimdiff
More file actions
executable file
·95 lines (89 loc) · 2.32 KB
/
westvimdiff
File metadata and controls
executable file
·95 lines (89 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
#
# Copyright (C) 2010,
# Thomas Langewouters <thomas.langewouters@thouters.be>
# Based on the script svnvimdiff, written by
# Copyright (C) 2007,
# Geoff Buchan <geoffrey.buchan@gmail.com>
# Based on the script cvsvimdiff, written by
# Stefano Zacchiroli <zack@cs.unibo.it>
# Enrico Tassi <tassi@cs.unibo.it>
#
# This is free software, you can redistribute it and/or modify it under the
# terms of the GNU General Public License version 2 as published by the Free
# Software Foundation.
#
set -e
vimdiff="vimdiff"
#suffix="vimgitdiff"
if [[ $1 == "-g" ]] ; then
vimdiff="gvimdiff -f"
shift 1
fi
if [[ $# -lt 0 || $1 == "--help" || $1 == "-h" ]] ; then
echo "westvimdiff - script to show git diff in vimdiff format in tabs"
echo ""
echo "westvimdiff [options] file"
echo ""
echo "Option:"
echo "-g Use gvimdiff (graphical mode) instead of vimdiff"
echo "All other options are passed to git diff"
echo ""
echo "If file is omitted it will cycle through all changed files in"
echo "the current directory."
exit 1
fi
# Assume the last argument is the filename.
# Save everything to pass to svn diff
if (( $# > 0 )) ; then
shift_args=$(($# - 1))
else
shift_args=$#
fi
TMP=$(mktemp -d /tmp/westvimdiff.XXXX)
args=$*
shift "$shift_args"
files="$1"
#patch=$TMP/patch
script=$TMP/script
WESTROOT=$(pwd)
while [[ ! -e $WESTROOT/.west ]]
do
WESTROOT=$(dirname "$WESTROOT")
if [ "$WESTROOT" = "/" ]
then
break
fi
done
if [ "$WESTROOT" = "/" ]
then
echo WESTROOT not found! >/dev/stderr
exit 0
fi
cd "$WESTROOT"
for WEST_MODULEDIR in $(west list -f "{path}")
do
cd "${WESTROOT}/${WEST_MODULEDIR}"
# No file given, so loop over all files svn st says have changed
if [ -z "$args" ]; then
files=$(git diff --name-only)
else
files=$(git diff --name-only "$args")
fi
for new in $files
do
#Instead of [ -z $(foo | grep bar) ], use ! foo | grep -q bar . [SC2143]
if ! file "$new" |grep -q text;
then
#binary file
true
else
orig=$TMP/$new
mkdir -p "$(dirname "$orig")"
git show HEAD:"$new" >"$orig"
echo -e ":tabnew $orig\n:vert diffsplit $PWD/$new" >> "$script"
fi
done
done
$vimdiff -s "$script" commit.txt
#trap "rm -rf $TMP" EXIT