aboutsummaryrefslogtreecommitdiff
path: root/git/git-st
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-12 13:24:49 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-12 13:27:07 +0200
commit03d827e2fbc409ef97829f25b8eeca5204f81a3c (patch)
tree6099f0feb9adf3425fba87549b164043e18bd0c7 /git/git-st
parent45cddd072119c5abd7ec076cf28d51ee01f125b7 (diff)
downloadxutil-03d827e2fbc409ef97829f25b8eeca5204f81a3c.tar.gz
Re-organize files
Diffstat (limited to 'git/git-st')
-rwxr-xr-xgit/git-st31
1 files changed, 31 insertions, 0 deletions
diff --git a/git/git-st b/git/git-st
new file mode 100755
index 0000000..8edae3f
--- /dev/null
+++ b/git/git-st
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+# git-st -- show git status (but handle binary files correctly)
+
+open $p, '-|', 'git', '-c', 'color.status=always', 'status', @ARGV
+ or die "$!\n";
+chomp($g = `git rev-parse --show-toplevel`);
+
+while (<$p>) {
+ if (/^Changes not staged for commit:$/ .. /^$/) {
+ if (/modified:\s+(.*\.pdf)/) {
+ $f = "$ENV{PWD}/$1";
+ $f =~ s,^\Q$g\E/?,,;
+ $f =~ s/'/'"'"'/g;
+ `git-bdiff '$f'`;
+ if ($?) {
+ $mbuf .= $_;
+ $mod = 1;
+ }
+ } else {
+ $mod = 1 if not $mod and /[^t]:\s+/;
+ $mbuf .= $_;
+ }
+ $buf .= $mbuf if /^$/ and $mod;
+ } else {
+ $buf .= $_;
+ }
+}
+
+close $p;
+print $buf;