p4-fusion
p4-fusion copied to clipboard
Parsing CL from commit messages breaks after using bfg-repo-cleaner
I used https://github.com/rtyley/bfg-repo-cleaner to purge large files from a repo generated by p4-fusion. bfg adds Former-commit-id to the commit messages:
...
[p4-fusion: depot-paths = "<snip>": change = 43110426]
Former-commit-id: 9885e208a53eb53e0f691fed688eae5565a814fd
After that, p4-fusion is unable to parse the CL from commit message:
[ WARNING @ Main:177 ] Detected last CL committed as CL 814f
[ PRINT @ Main:180 ] Requesting changelists to convert from the Perforce server
[ ERROR @ HandleError:13 ] Received error: error Invalid changelist/client/label/date '@>814f'.
814f comes from Former-commit-id: 9885e208a53eb53e0f691fed688eae5565a814fd.
Workaround: run bfg with --private to omit Former-commit-id from commit messages.
Ah this would break the auto-resume for sure. As a quick workaround that might work right now, you may be able to create a new commit with the correct format by doing this:
$ git show HEAD # Record the commit ID and tree ID
$ git cat-file -p <latest commit ID> | grep tree
tree <tree ID>
$ vi commit.txt # Add the new commit message, but use the proper format that p4-fusion expects
$ echo "$(cat commit.txt)" | git commit-tree <tree ID> -p <latest commit ID>
<new commit ID>
$ git update-ref HEAD <new commit ID>
$ git show # Check if it worked
Naive implementation - p4-fusion should only consider the string from change = up until the next newline character, and not the end of the entire commit message
Probably better implementation - p4-fusion should search for a line in the commit message that has the proper semantics i.e. [p4-fusion: depot-paths = "ABCDEFGH": change = XXXXXXXX], either by regex or only considering the line that starts with [p4-fusion