From 6deb09efcdb4d5a743cfba06ec7e4191e1b16714 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 24 Oct 2018 06:05:36 -0700 Subject: [PATCH] When leasing a Working Copy in Drydock, just "git reset --hard" so empty repositories work Summary: Ref T13210. We currently "git reset --hard HEAD" during working copy leasing, mostly by convention/familiarity. However, this command does not work in an empty repository, because there is no HEAD yet. The command "git reset --hard" appears to have the same meaning and effect in all cases, except that it also works correctly in an empty repository. The manual suggests that omitting HEAD should be the same as specifying HEAD, too: > The / defaults to HEAD in all forms. Test Plan: Successfully leased a working copy for an empty repository using Drydock. Reviewers: amckinley Reviewed By: amckinley Subscribers: yelirekim, PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13210 Differential Revision: https://secure.phabricator.com/D19750 --- .../blueprint/DrydockWorkingCopyBlueprintImplementation.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php index f45c4f2adb..c1672f99fb 100644 --- a/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php +++ b/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php @@ -256,8 +256,9 @@ final class DrydockWorkingCopyBlueprintImplementation $ref = idx($spec, 'ref'); // Reset things first, in case previous builds left anything staged or - // dirty. - $cmd[] = 'git reset --hard HEAD'; + // dirty. Note that we don't reset to "HEAD" because that does not work + // in empty repositories. + $cmd[] = 'git reset --hard'; if ($commit !== null) { $cmd[] = 'git checkout %s --';