Fix git.get_disclosable_head
ClosedPublic

Authored by thcipriani on May 1 2018, 9:30 PM.

Details

Reviewers
demon
mmodell
Group Reviewers
Release-Engineering-Team
Commits
rMSCA9af67b80f3ea: Fix git.get_disclosable_head
Patch without arc
git checkout -b D1037 && curl -L https://phabricator.wikimedia.org/D1037?download=true | git apply
Summary

Currently get_disclosable_head is taking the value of [git_dir]/HEAD
and using that value ot determine the disclosable head. If that value
starts with refs/heads/ or refs/tags/ the disclosable head is a
substring of symbolic-ref in HEAD, combined with the remote (to create
the appropriate upstream). The merge-base of the derrived upstream and
HEAD is found by running:

git merge-base HEAD [remote]/[remote-name]

For example, if .git/HEAD contained refs/heads/master and `git
remote` returned origin the derived upstream would be origin/master
and the disclosable head would be: git merge-base HEAD origin/master
this is all correct.

However, if the git repo is in a detatched head state, as is the case
for git submodules, there is no derived upstream and the disclosable
head becomes the merge-base of HEAD and the value found in .git/HEAD,
i.e., git merget-base HEAD HEAD which will always be the same as the
value of HEAD which is the value we often don't want to disclose.

Typically, a remote has a symbolic-ref pointing to the default remote
branch set in .git/refs/remotes/[remote]. That is, it is valid to use:

git merge-base HEAD [remote]

And git is smart enough to dereference the symbolic-ref in
.git/refs/remotes/origin/HEAD to find the appropriate remote much of
the time.

Diff Detail

Repository
rMSCA Scap
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
thcipriani created this revision.May 1 2018, 9:30 PM
Restricted Application added a reviewer: Release-Engineering-Team. · View Herald TranscriptMay 1 2018, 9:30 PM
Restricted Application added a project: Release-Engineering-Team. · View Herald Transcript
thcipriani updated this revision to Diff 2731.May 1 2018, 9:33 PM

Ran spell-check on the commit message

Harbormaster completed remote builds in B2944: Diff 2731.
thcipriani requested review of this revision.May 1 2018, 9:35 PM
demon accepted this revision.May 1 2018, 9:48 PM
This revision is now accepted and ready to land.May 1 2018, 9:48 PM
This revision was automatically updated to reflect the committed changes.