Mr Quinion is no doubt correct as to the quoted version of "cock-up", but surely it originated as the old printing term. At least that's how I've always heard it. A cock-up is when one or more typeset letters are "cocked up" above their neighbours, resulting in uneven printing. (Old-fashioned printing, of course—can't happen these days!) I would guess that this meaning of cock, in the sense of turned up, elevated, erected or whatever, is one of the very earliest usages. "Cock-eyed", in the sense of crooked or out of alignment, is also pretty common down this-a-way.

lusy