commit 2d265c9244a93ab6f06672d4a8aed4a3f5dc3ff5 from: Omar Polo date: Fri Feb 16 19:56:54 2024 UTC remove `got add' workaround earlier version of got would fail when trying to `got add' a file that was already added (or committed.) Since the error message was potentially scary, got_add tries to be smart and issue a `got info file' first to see whether the file can be added, and only then eventually issues `got add'. This whole dance is now moot. got doesn't warn for files already added. (also, this code could have been simpler from the beginning.) Noticed since the pipe trick in the got sub was failing on linux. Issue reported by Christoph Cremer, thanks! commit - fdb1653a62fcf31a8ef3467c53c2ab99fd6109c2 commit + 2d265c9244a93ab6f06672d4a8aed4a3f5dc3ff5 blob - bfede8401b8d50ecccaa607d99abfffb90a1514e blob + 3e96945974f9e6a0b6ea5a7fd33e9b83da66df12 --- plass +++ plass @@ -142,25 +142,22 @@ sub passfind { } sub got { - # discard stdout - open my $fh, '-|', ('got', @_); - close($fh); - return !$?; + my $pid = fork; + die "failed to fork: $!" unless defined $pid; + + if ($pid != 0) { + wait; + return !$?; + } + + open (STDOUT, '>', '/dev/null') + or die "can't redirect to /dev/null"; + exec ('got', @_); } sub got_add { - 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); + got 'add', shift + or exit(1); } sub got_rm {