aboutsummaryrefslogtreecommitdiff
path: root/git-st
blob: 8edae3f6aa7647c82e084c18fc8dc9d9c47e7876 (plain)
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
#!/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;