When you have infantry facing heavy cavalry, repelling is a real advantage, since heavy cavalry usually have the attack and damage rating to overcome defense and protection. Any longer weapon will do, but with pike you are sure to get it, while spear is not certain (some heavy infantry carry spear, and spear won't block the lance attack), and anything shorter won't work.
But the best way to protect your heavy infantry from the enemy's cavalry lance attack is to have a rank of slaves/hoburg militia/slinger/ woodsman blowpipe in front. Works like a charm