We had a master's student working on our project. He set up a database for us, and wrote some of the initial code with me in a pair programming session. At one point, he had more commits to the repository than any of the other students working on the project. Then he went to do an internship for the summer, and after that my advisor did not want to keep him on the project for some reason, even though I thought he was friendly and easy to work with.
My advisor chose not to list him as a coauthor, and put him in the acknowledgements section instead. However, there was another guy (a professor) who didn't write any code at all, and wasn't there throughout most of the project, but he wrote the introduction and related work sections for us, and he got listed as a coauthor, even though he probably did a day's worth of work on the project (maybe two). In fact, my advisor gave him the coveted last author position, even though my advisor came up with the idea and directed the whole project.
What determines who gets put as a coauthor, and who gets put in the acknowledgement sections?