@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix fatal in Git hook when a --force push completely rewrites a ref

Summary: Fixes T4224. If you `git merge-base A B`, and they have //no// ancestor, the command exits with an error. Assume errors mean "no ancestry" and continue.

Test Plan: Completely rewrite a repository with a `--force` push.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4224

Differential Revision: https://secure.phabricator.com/D7756

+13 -2
+13 -2
src/applications/diffusion/engine/DiffusionCommitHookEngine.php
··· 256 256 } 257 257 258 258 foreach (Futures($futures)->limit(8) as $key => $future) { 259 - list($stdout) = $future->resolvex(); 260 - $updates[$key]['merge-base'] = rtrim($stdout, "\n"); 259 + 260 + // If 'old' and 'new' have no common ancestors (for example, a force push 261 + // which completely rewrites a ref), `git merge-base` will exit with 262 + // an error and no output. It would be nice to find a positive test 263 + // for this instead, but I couldn't immediately come up with one. See 264 + // T4224. Assume this means there are no ancestors. 265 + 266 + list($err, $stdout) = $future->resolve(); 267 + if ($err) { 268 + $updates[$key]['merge-base'] = null; 269 + } else { 270 + $updates[$key]['merge-base'] = rtrim($stdout, "\n"); 271 + } 261 272 } 262 273 263 274 return $updates;