Check out the LimeSurvey source code on GitHub!

Git FAQ - Looks like whole files were replaced - what really changed?

4 years 10 months ago #78151 by TMSWhite
The LimeSurvey Git repository is now standardized on using Unix line feeds (LF) as the line ending rather than DOS line endings (CRLF). Unfortunately, if DOS versions of files get pushed to GitHub, it looks as though the entire file has been replaced. Worse, if a few lines within the file were changed, it is impossible to tell which by reviewing GitHub.

Here is one strategy for detecting what really changed from point A to point B in the repository, even if there have been a mixture of line endings.

(1) Ensure your git configuration is not changing line endings
git config --global core.autocrlf input

(2) If you are using Windows and think your repository might have some DOS line endings, re-clone the main LimeSurvey repository so that your local copy has the proper line endings.

(3) Say you want to see the accumulated differences between point A and B, you can do this. Here, A=d654c487623b5439844d55d8986ca83cf419057f and B=fefade01a03bf6e66e07eb29346914d95506a04c
git stash
git checkout -b prefixes d654c487623b5439844d55d8986ca83cf419057f
git checkout -b postfixes fefade01a03bf6e66e07eb29346914d95506a04c
git diff --stat prefixes...postfixes
<Look for complete (or near complete) file replacements from the diff step.  Use a text editor to do bulk replace of change CRLF to LF if needed (e.g. a regex find/replace of "\r" with "")>
git add -A
git commit -m "Fix CRLF"
git diff -p -U10 prefixes...postfixes > /tmp/fixes.diff
<this provides 10 lines of context around the fixes, and saves the accumulated fixes to a patch/diff file>
git branch -d prefixes
git branch -d postfixes

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form