aboutsummaryrefslogtreecommitdiff
path: root/git-st
diff options
context:
space:
mode:
authorJohn Ankarstrom <john@ankarstrom.se>2021-07-03 21:57:06 +0200
committerJohn Ankarstrom <john@ankarstrom.se>2021-07-03 21:57:06 +0200
commit301e03b46ce35589dbd2b7985d6ae8bef0dca64a (patch)
tree530f108553d716a9034f59ab5dee169f81e8aad1 /git-st
parent2f78c9a8bd17140b63114a844fa9c23e22489d80 (diff)
downloadxutil-301e03b46ce35589dbd2b7985d6ae8bef0dca64a.tar.gz
Add 'git-st' utility
Diffstat (limited to 'git-st')
-rwxr-xr-xgit-st31
1 files changed, 31 insertions, 0 deletions
diff --git a/git-st b/git-st
new file mode 100755
index 0000000..8edae3f
--- /dev/null
+++ b/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;