tags:

views:

24

answers:

1

I was doing some refactoring on another branch and moved some methods in different place in the same file.

Then, after merge to master, git did not remove the old placement, and imported the new methods in new location. As a result I got a new file with some methods duplicated (also some code blocks were messed up).

It looks like git treated the new methods as a PHPDoc comments.

Is there any chance to avoid such a behavior in the future?

(Im using git for development with Zend Framework, the code is formatted using ZF coding standard)

+1  A: 

Git does not know about PHPDoc comments, as it happily ignores the content of the files (well except for the evil CR/LF issue).

It looks to me you did not add all the files or one of your colleagues triggered a change in the lines in question.

Check with git log if all files with changes were actually committed. With git diff you can check the differences between the commits to figure out exactly where it went pear shaped.

Peter Tillemans
Actually it is not quite true that git completely ignores the content as you can install diff helpers to deal with specific file types, but this is definitely not run-of-the-mill stuff. It is difficult to say genric things of git as it is so flexible you can probably configure it to do the laundry, iron it and put it in the cupboards.
Peter Tillemans
Thanks for the answer, Peter. Using git log and git diff I was able to find the actual problems. But seems like I am probably looking for some kind pre/post commit hook to parse the php files to check for syntax problems and disable the commit if something goes wrong.
takeshin