Page MenuHomePhabricator

Extract raw commit messages from Git more faithfully across Git versions
ClosedPublic

Authored by epriestley on Feb 24 2020, 7:47 PM.

Details

Summary

Fixes T5028. Older versions of Git (apparently, from before 2010) did not provide a way to extract the raw body of a commit message from "git log", so we approximate it with "subject" and "wrapped body".

In newer versions of Git, the raw body can be extracted exactly.

Adjust how we extract messages based on the version of Git, and try to be more faithful to edge cases: particularly, be more careful to extract the correct number of trailing newlines.

Test Plan
  • Added "var_dump()" + "die(1)" later in this method, then pushed various commit messages. Used "&& false" to force execution down the old path (either path should work in modern Git).
  • Observed more faithful extraction of messages, including a more faithful extraction of the number of trailing newlines. Extraction is fully faithful if we can go down the "%B" path, which we should be able to in nearly all modern cases.
  • Not all messages extract faithfully or consistently across the old and new versions, but the old extraction is destructive so this is likely about as close as we can realistically ever get.

Diff Detail

Repository
rP Phabricator
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

epriestley created this revision.Feb 24 2020, 7:47 PM
epriestley requested review of this revision.Feb 24 2020, 7:48 PM
This revision was not accepted when it landed; it landed in state Needs Review.Feb 24 2020, 8:37 PM
This revision was automatically updated to reflect the committed changes.