Johnny Todd ships out, leaving his sweetheart in Liverpool. She meets another sailor, who offers to marry her. She accepts; Todd returns to find his love married. The moral: "Do not leave your love like Johnny/Marry her before you go"
I include the cross-reference because the verses in which the rival sailor courts the lady seem to be lifted from a broken-token song such as "John Riley (I)". - PJS
Interestingly, the Montgomerie text also has this bit, so it appears to be genuinely traditional.
The group Ossian has recorded a version of this in which Johnny Todd returns to his girl. They admit, however, to having rewritten the ending. To my mind, it doesn't add much.... - RBW