This removes some overhead from all native git calls in the
following ways:
- Removes a fork previously performed by Open3, which double
forks to avoid needing to Process::wait.
- Removes the need to shell escape arguments, since the git
process's argv is passed explicitly as an array.
- Removes the /bin/sh process (1 fork/exec)
Additionally, these changes allow obtaining the git process's exit
status, available as $? after any native git command invocations.
Relative paths in a <repo>.git/objects/info/alternates file are to
be expanded relative to the <repo>.git/objects directory.
Previously, they were expanded relative to the <repo>.git directory.
The current code checks in both locations for backward compatibility
with grit <= 2.3.0 but I'd rather rip it out completely.
This speeds things up considerably when output is large. Especially
so under some versions of Rails (AS) where String#+ is made to be
extremely slow.
With 500K blob, before:
$ ruby bench-string-concat.rb 12044a7603
blob: 12044a7603
size: 499855
user system total real
native cat_file 11.030000 9.140000 20.230000 ( 21.182163)
ruby cat_file 0.040000 0.020000 0.060000 ( 0.061033)
ActiveSupport makes it even worse:
$ ruby -ractive_support bench-string-concat.rb 12044a7603
blob: 12044a7603
size: 499855
user system total real
native cat_file 15.830000 9.570000 25.470000 ( 26.286903)
ruby cat_file 0.050000 0.020000 0.070000 ( 0.073557)
With this commit applied (using String#<< instead of String#+):
$ ruby bench-string-concat.rb 12044a7603
blob: 12044a7603
size: 499855
user system total real
native cat_file 0.310000 0.440000 0.800000 ( 1.765703)
ruby cat_file 0.040000 0.020000 0.060000 ( 0.064426)
The bench-string-concat.rb script is here:
<https://gist.github.com/e749138b066ed9d81fbe>