In this question, the OP uses giraffe necks as a supportive example of evolution. Is the mechanism described in this post accurate? At some point, I thought I remember hearing that giraffes did not evolve long necks to reach higher food resources, but instead longer, stronger necks gave some sort of mating advantage (male competition perhaps?).

Is there a consensus in the scientific community as to evolutionary mechanism(s) that contributed most to the evolution of long necks in giraffes?