gitdiffdir: git diff between two dirs.
This commit is contained in:
parent
3be8b564cb
commit
ab5791e738
15
G/G
15
G/G
|
@ -99,6 +99,7 @@ B<grep>
|
|||
my $i = 0;
|
||||
my @add_X;
|
||||
|
||||
# Make groups of grep options: -v foo -v -i bar => [-v foo] [-v -i bar]
|
||||
for(@ARGV) {
|
||||
if($_ eq "-g") {
|
||||
# -g = recursive-and file grep
|
||||
|
@ -122,6 +123,7 @@ for(@ARGV) {
|
|||
}
|
||||
|
||||
if($opt::g and @cmd) {
|
||||
# -g => search files
|
||||
sub gitdir {
|
||||
# Find .git dir somewhere in parent
|
||||
my $dir = shift;
|
||||
|
@ -140,23 +142,28 @@ if($opt::g and @cmd) {
|
|||
`find "$dir" -type f -print0 | xargs -0 cat >/dev/null`;
|
||||
}
|
||||
my $a = shift @cmd;
|
||||
|
||||
# -v => Use -L instead of -l
|
||||
my $l_or_L = (grep /^-v$/, @$a) ? "L" : "l";
|
||||
@$a = (grep { not /^-v$/ } @$a);
|
||||
|
||||
my $gitdir = gitdir(".");
|
||||
if($gitdir) {
|
||||
cache_gitdir($gitdir);
|
||||
$run = 'git grep --threads 30 -l '.shell_quote(@$a);
|
||||
$run = "git grep --threads 30 -$l_or_L ".shell_quote(@$a);
|
||||
} else {
|
||||
$run = 'find . -type f | parallel --lb -Xq grep -l '.shell_quote(@$a);
|
||||
$run = "find . -type f | parallel --lb -Xq grep -$l_or_L ".shell_quote(@$a);
|
||||
}
|
||||
if(@cmd) {
|
||||
$run .= '|' .
|
||||
join"|", map { 'xargs -d"\n" grep -l '.
|
||||
join"|", map { 'xargs -d"\n" grep -'.$l_or_L.' '.
|
||||
join(" ", shell_quote(@$_)) } @cmd;
|
||||
}
|
||||
exec $run;
|
||||
} elsif(@cmd) {
|
||||
# => search stdin
|
||||
exec join"|", map { "grep ".join(" ", shell_quote(@$_)) } @cmd;
|
||||
} else {
|
||||
# no options => cat
|
||||
exec 'cat';
|
||||
}
|
||||
|
||||
|
|
26
Makefile
26
Makefile
|
@ -1,23 +1,25 @@
|
|||
CMD = 2grep 2search audioping blink burncpu bwlimit clipboard drac \
|
||||
duplicate-packets em emoticons encdir fanspeed field \
|
||||
find-first-fail find-optimal forever ft-udvalg fxkill G \
|
||||
gitnext gitundo goodpasswd histogram Loffice mtrr mirrorpdf \
|
||||
neno not off pdfman pidcmd pidtree plotpipe puniq ramusage \
|
||||
rand rclean rina rn rrm seekmaniac shython sound-reload \
|
||||
splitvideo stdout swapout T teetime timestamp tracefile \
|
||||
transpose upsidedown vid w4it-for-port-open whitehash \
|
||||
wifi-reload wssh youtube-lbry ytv yyyymmdd
|
||||
gitdiffdir gitedit gitnext gitundo goodpasswd histogram \
|
||||
Loffice mtrr mirrorpdf neno not off pdfman pidcmd pidtree \
|
||||
plotpipe puniq ramusage rand rclean rina rn rrm seekmaniac \
|
||||
shython sound-reload splitvideo stdout swapout T teetime \
|
||||
timestamp tracefile transpose upsidedown vid \
|
||||
w4it-for-port-open whitehash wifi-reload wssh youtube-lbry \
|
||||
ytv yyyymmdd
|
||||
|
||||
all: 2search/2grep.1 2search/2search.1 blink/blink.1 \
|
||||
burncpu/burncpu.1 bwlimit/bwlimit.1 clipboard/clipboard.1 \
|
||||
drac/drac.1 encdir/encdir.1 fanspeed/fanspeed.1 field/field.1 \
|
||||
find-first-fail/find-first-fail.1 find-optimal/find-optimal.1 \
|
||||
ft-udvalg/ft-udvalg.1 G/G.1 gitnext/gitnext.1 \
|
||||
gitundo/gitundo.1 goodpasswd/goodpasswd.1 \
|
||||
histogram/histogram.1 mirrorpdf/mirrorpdf.1 neno/neno.1 \
|
||||
off/off.1 pdfman/pdfman.1 pidcmd/pidcmd.1 pidtree/pidtree.1 \
|
||||
plotpipe/plotpipe.1 puniq/puniq.1 rand/rand.1 rina/rina.1 \
|
||||
rn/rn.1 rrm/rrm.1 seekmaniac/seekmaniac.1 shython/shython.1 \
|
||||
ft-udvalg/ft-udvalg.1 G/G.1 gitdiffdir/gitdiffdir.1 \
|
||||
gitedit/gitedit.1 gitnext/gitnext.1 gitundo/gitundo.1 \
|
||||
goodpasswd/goodpasswd.1 histogram/histogram.1 \
|
||||
mirrorpdf/mirrorpdf.1 neno/neno.1 off/off.1 pdfman/pdfman.1 \
|
||||
pidcmd/pidcmd.1 pidtree/pidtree.1 plotpipe/plotpipe.1 \
|
||||
puniq/puniq.1 rand/rand.1 rina/rina.1 rn/rn.1 rrm/rrm.1 \
|
||||
seekmaniac/seekmaniac.1 shython/shython.1 \
|
||||
sound-reload/sound-reload.1 splitvideo/splitvideo.1 \
|
||||
stdout/stdout.1 teetime/teetime.1 timestamp/timestamp.1 \
|
||||
tracefile/tracefile.1 transpose/transpose.1 T/T.1 \
|
||||
|
|
2
README
2
README
|
@ -28,6 +28,8 @@ ft-udvalg - Download udvalgsmembers from folketing.dk as ODS.
|
|||
|
||||
G - shorthand for multi level grep.
|
||||
|
||||
gitdiffdir - git diff between two dirs.
|
||||
|
||||
gitedit - edit last 10 commits.
|
||||
|
||||
gitnext - checkout next revision. Opposite of 'checkout HEAD^'.
|
||||
|
|
|
@ -174,7 +174,7 @@ for udv, member_list in udv_members.items():
|
|||
for member in member_list:
|
||||
if member["biopage"] not in members:
|
||||
members[member["biopage"]] = {"biopage": member["biopage"]}
|
||||
members[member["biopage"]][udv.upper()] = "X" # Mark membership
|
||||
members[member["biopage"]][udv.upper()] = 1 # Mark membership
|
||||
|
||||
# Extract additional data for each unique member
|
||||
for member in members.values():
|
||||
|
|
87
gitdiffdir/gitdiffdir
Executable file
87
gitdiffdir/gitdiffdir
Executable file
|
@ -0,0 +1,87 @@
|
|||
#!/bin/bash
|
||||
|
||||
: <<=cut
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
gitdiffdir - git diff, but between two dirs in different repositories
|
||||
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
gitdiffdir dir1 dir2
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<git diff> only looks at tracked files. B<git diff dir1 dir2>
|
||||
includes all untracked files.
|
||||
|
||||
B<gitdiffdir> tries to simulate B<git diff> but on two dirs in
|
||||
different repositories.
|
||||
|
||||
|
||||
=head1 EXAMPLES
|
||||
|
||||
Diff dirs with the same name:
|
||||
|
||||
gitdiffdir myproject/mydir1 myoldproject/mydir1
|
||||
|
||||
Diff dirs with the different names:
|
||||
|
||||
gitdiffdir myproject/mydir1 myoldproject/mydir2
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2024 Ole Tange,
|
||||
http://ole.tange.dk and Free Software Foundation, Inc.
|
||||
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
|
||||
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
=head1 DEPENDENCIES
|
||||
|
||||
B<gitdiffdir> uses B<git>, B<parallel>, B<sort>.
|
||||
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
B<git>
|
||||
|
||||
|
||||
=cut
|
||||
|
||||
dirA="$1"
|
||||
dirB="$2"
|
||||
|
||||
stdout() {
|
||||
if [ -t 1 ] ; then
|
||||
# STDOUT = terminal
|
||||
# use less
|
||||
less
|
||||
else
|
||||
cat
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
parallel -0 'cd {} && git ls-files' ::: "$dirA" "$dirB" | sort -u |
|
||||
parallel -q diff -Naur "$dirA"/{} "$dirB"/{} | stdout
|
Loading…
Reference in a new issue