commit 3cf28f46d454a6b95131133179393b3ae6ac7ec4 from: Omar Polo date: Sat Jan 21 17:09:26 2023 UTC avoid issuing unnecessary `got add' plass always did a `got add $file' before committing changes. However, this leads to a possibly misleading "file has unexpected status" error being printed to stderr. Instead, `got add $file' only when the file is new. commit - 8c4930cfcef7c2310f05b7007f95750513e1fd79 commit + 3cf28f46d454a6b95131133179393b3ae6ac7ec4 blob - c71cc3fa34ba3306ee9a0510cd0e48a97fe2d324 blob + 11a98ed7d57df7a42b505816e14e8f208255173e --- plass +++ plass @@ -148,7 +148,18 @@ sub got { } sub got_add { - return got 'add', '-I', shift; + my $file = shift; + + open (my $null, '>', '/dev/null') or die "can't open /dev/null: $!"; + open (my $stderr, ">&", STDERR) or die "can't save stderr: $!"; + open (STDERR, ">&", $null) or die "can't redirect stderr: $!"; + + got 'info', $file; + my $found = !$?; + + open (STDERR, ">&", $stderr) or die "can't restore stderr: $!"; + + return $found ? 1 : (got 'add', '-I', $file); } sub got_rm {