0

I have just encountered a problem with Git. I use Eclipse IDE and EGit plugin. After doing some changes to my C++ file, I see that EGit marks some of the lines I did not touch as being added, whereas others - deleted. So it seems somehow the 'diff' (or whatever is used) does not work correctly for that particular modifications I made. Is there any way to 'help' EGit (git) and mark some lines as unchanged? Preferably from GUI of Egit, not the command line....

If I commit it as is, it thinks I changed good deal of the initial file, which I did not.

Denis
  • 1,526
  • 6
  • 24
  • 40
  • Can you paste an example of a diff where `egit` gets confused? – John Feminella Jun 10 '12 at 09:33
  • @JohnFeminella original file is about 4000 lines, I can try to make an example with Diff viewer, but I'm not sure if the algorithm used there is the same as in git. – Denis Jun 10 '12 at 09:38
  • Are you sure that nothing changed? Maybe you hit Ctrl+Shift+F, which reformats the file (and e.g. removes trailing whitespace). You could try the option to ignore whitespace changes in the diff view. And also, do "git diff" on the command line and look at the diff there. – robinst Jun 10 '12 at 12:30
  • Additionally, line ending changes can result in unexpected changes too. – wadesworld Jun 10 '12 at 13:56
  • @robinst i'm absolutely sure nothing changed. I was not able to solve the problem – Denis Jun 11 '12 at 12:52
  • @robinst so I reintroduced all changes again from the scratch playing with '}' and other symbols so that git (egit?) interpret changes accordingly. I got satisfactory results but only from trial-and-error procedure... – Denis Jun 11 '12 at 12:54

1 Answers1

0

Seem like mixed line endings or that eclipse autoformats. Not sure about C++, but the Java editors likes to add trailing spaces. The menu in the quickdiff barcan be used to revert changed lines to their unchanged state.

robinr
  • 4,376
  • 2
  • 20
  • 18