1

How can I update my modified fork of a git repo if the original repo has a different format for things like whitespacing?

This is the repo that I have forked: Original Repo

They space like this:

for ( final ListenerInfo info : config.getListeners() )

Where I would instead space:

for (final ListenerInfo info : config.getListeners())

As well as this, the original repo uses 4 spaces to indent where as my modified fork uses tab.

It's difficult to merge the changes because almost everything comes up in the diff due to the extra spaces.

I could not have this issue if I changed my IDE format settings to space like their project, but I don't care for the look of the extra spacing.

Jake
  • 11
  • 2
  • Are the answers here http://stackoverflow.com/questions/6956631/git-merge-ignore-spaces and here http://stackoverflow.com/questions/1751612/git-tool-to-remove-lines-from-staging-if-they-consist-only-of-changes-in-whitesp of any use? – MBlanc Jun 08 '14 at 19:38
  • 3
    However, I think it's worth sticking to the conventions of the code you're working with so as to avoid this kind of problems in the future. Furthermore, if at some point you send a pull request, it'll improve the odds of your changes getting accepted. Cheers – MBlanc Jun 08 '14 at 19:49

1 Answers1

0

You can use locally the space convention that you want, but you need to make sure you check in only code which respects the space convention of the original repo (like a git clean filter driver which could try and call the Eclipse formatter from the command line).

<path-to-eclipse>\eclipse.exe -vm <path-to-vm>\java.exe \
  -application org.eclipse.jdt.core.JavaCodeFormatter \
  -verbose \
   -config <path-to-config-file>\org.eclipse.jdt.core.prefs <path-to-your-source-files>\*.java

Unless you can convince the original repo to adopt your convention, it is best to not touch anything in a project you want to contribute back to.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250