Page MenuHomePhabricator

In Drydock, don't reset current branch to point at unrelated commit
ClosedPublic

Authored by epriestley on Dec 22 2015, 2:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 24, 9:49 PM
Unknown Object (File)
Sun, Apr 21, 3:38 PM
Unknown Object (File)
Wed, Apr 17, 2:28 PM
Unknown Object (File)
Sat, Apr 13, 3:40 AM
Unknown Object (File)
Fri, Apr 12, 8:00 AM
Unknown Object (File)
Thu, Apr 11, 6:55 AM
Unknown Object (File)
Feb 24 2024, 1:57 AM
Unknown Object (File)
Feb 16 2024, 11:39 AM
Subscribers

Details

Summary

Fixes T10037. When we're building commit aabbccdd, we currently do this to check it out:

git reset --hard aabbccdd

However, this has an undesirable side effect of moving the current branch pointer to point at aabbccdd. The current branch pointer may be some totally different branch which aabbccdd is not part of, so this is confusing and misleading.

Instead, use git reset --hard HEAD to get the primary effect we want (destroying staged changes) and then git checkout aabbccdd to checkout the commit in a detached HEAD state.

Test Plan
  • Ran a build (a commit-focused operation) successfully.
  • Verified working copy was pointed at a detached HEAD afterward:
builder@sbuild001:/var/drydock/workingcopy-167/repo/git-test-ii$ git status
HEAD detached at ffc7635
nothing to commit, working directory clean
  • Ran a land (a branch-foused operation) successfully.
  • Verified working copy was pointed at a branch afterward:
builder@sbuild001:/core/data/drydock/workingcopy-168/repo/git-test$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to In Drydock, don't reset current branch to point at unrelated commit.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
chad edited edge metadata.
This revision is now accepted and ready to land.Dec 22 2015, 2:36 PM
This revision was automatically updated to reflect the committed changes.