2

I am trying to formalize a patch workflow for our org. We have an internal project where we don't mind white-spaces(would like to keep them same for each user if possible), EOF/EOL characters etc. We have developers working on both Mac and Windows platform. AT both places we use git with Cygwin.

I read here that core.autocrlf true does the trick or you can use --keep-cr. But here VonC suggests core.autocrlf false is a better strategy.

My Questions are:

  1. When to use true and when false? (I just don't want git to bug me and patches should apply smooth).
  2. When was --keep-cr introduced? I use git 1.7.2 and am man page does not have this option?
  3. What Ignore-whitespace options to use so as to have smooth patch workflow?
Community
  • 1
  • 1
Mudassir Razvi
  • 1,593
  • 10
  • 29

1 Answers1

3

1.7.2 should have --keep-cr for git am, since it was introduced in commit ad2c928 by Stefan-W. Hahn, included in Git 1.7.1.

when you know you are feeding output from "git format-patch" directly to "git am", and especially when your contents have CR at the end of line, such stripping is undesirable. To help such a use case, teach --keep-cr option to "git am" and pass that to "git mailinfo".

However, on Windows, I always use the latest Git For Windows release, not the cygwin one (even though you can have both).

The issue with core.autocrlf is that it is a repository-wide setting which can affect all files (even non-text ones).
I prefer core.eol directives.

For whitespace, you can try "git: patch does not apply":

git apply --ignore-space-change --ignore-whitespace mychanges.patch
Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • What is the difference between apply and am. Coz I have noticed some patches apply seamlessly using apply but create problem on using am. – Mudassir Razvi Jun 12 '14 at 07:48
  • 1
    @MudassirRazvi Git am is more for patches coming from mails – VonC Jun 12 '14 at 07:50
  • That brings to my next question. What difference does it make? I create patch using format-patch. Send it to my colleague via Outlook. he downloads and applies patch using am. Anything wrong here? – Mudassir Razvi Jun 12 '14 at 07:52
  • @MudassirRazvi nothing wrong, the end result is the same. I will have more when I get back (I am outside, typing from my phone) – VonC Jun 12 '14 at 07:54
  • Will be waiting..! :) – Mudassir Razvi Jun 12 '14 at 07:59
  • @MudassirRazvi for more on the difference between am and apply: http://stackoverflow.com/q/12240154/6309. http://alblue.bandlem.com/2011/12/git-tip-of-week-patches-by-email.html is a good read: I like communicating patches through bundle (http://stackoverflow.com/a/16407577/6309, http://stackoverflow.com/a/24075658/6309) – VonC Jun 12 '14 at 09:29