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)
Sat, Dec 7, 6:20 PM
Unknown Object (File)
Mon, Nov 25, 4:40 AM
Unknown Object (File)
Thu, Nov 21, 8:38 AM
Unknown Object (File)
Nov 17 2024, 12:51 AM
Unknown Object (File)
Oct 21 2024, 10:13 PM
Unknown Object (File)
Oct 20 2024, 7:17 AM
Unknown Object (File)
Oct 15 2024, 6:26 PM
Unknown Object (File)
Oct 13 2024, 7:41 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.