svn diff on windows vs linux - linux

I have two checkouts of an SVN repository, one on a Windows machine, and one on a Linux machine. The exact same modification is made to both repositories. I then run svn diff on both to generate 2 patch files. I expect these two patch files to be identical, but they are not. The reason is that svn diff on Windows generates a file with carriage returns.
What is the easiest way to modify the behavior of svn diff on Windows to match that of svn diff on Linux?

In order to get the exact same output on Windows as you would on Linux you can use Cygwin and run svn from that instead of the normal command prompt. This will use a linux-esque version of svn which will generate the patch file with unix line endings while maintaining the line endings of the source file.

Related

git clone comes with edited files

When I clone a project, I did git status right away and some files appear edited.
I check with git diff . and all edited files have the same message: "warning: CRLF will be replaced by LF".
I didn't even open any files.
git checkout . didn't work.
How is this possible?
On Linux new line mark it is \n, and on Windows it is \r\n, so it looks like when you clone a repository, the operating system changes \r\n to \n and you see the difference

Possible to use git on cross-OS network share?

We have a few work flows where we want to use git repositories mounted on NFS network shares. This generally works well, with the exception of line endings. Obviously, line endings on Linux and Windows differ, so a git status on the CentOS host may show no changes, and a git status in the same directory on Windows shows all files as modified.
Can any of the various git mechanisms to deal with line endings be configured to support this scenario ? We only want Unix-style line endings in our repos, of course, and we don't really care about the Windows SEEING the Unix line endings, but on occasion, a Windows tool will add or accidentally convert files, which we would then not want checked in with those endings.
There are a couple possible solutions here. The best solution depends on whether you care about the endings in the working tree.
If you always want line endings in the repository to be LF, and you don't care about the working tree, you can set the following in the .gitattributes file in your repository (creating it if it doesn't exist):
* text=auto
That will make Git guess whether a given file is binary or text, and if it's text, it will perform conversion to the proper line endings when it's checked out. On Unix, the proper line endings will be LF, and on Windows, usually it will be CRLF (although you can use core.eol to override that).
If you always want line endings in both the objects and the working tree to be LF, then you need to do a little more work. You need to set each individual text file type appropriately with eol=lf:
*.c text eol=lf
*.h text eol=lf
The reason this is necessary is because eol=lf overrides text detection, which means it's not safe to apply to binary files, such as PDFs or JPEG files. If you applied it to all files in your repository, you'd corrupt any binary files that happened to contain a CRLF.
Regardless of which you do, you should do a git add --renormalize . and then a git commit. That will ensure that all of your files in the repository contain LF endings and they'll be checked out with the appropriate endings whenever Git checks them out. That doesn't prevent Windows tools from dirtying the repository with CRLF line endings, but if they do that by accident, only LF endings will be checked in.

SVN incosistent eol when adding file

Quiet simply I am trying to add new files to my repository, my command goes like this:
svn add * --force
but this produces:
svn: File 'install/config.xml.php' has inconsistent newlines svn:
Inconsistent line ending style
The thing is that this file is not yet under version control, so when I try to propdel or anything similar it doesn't work.
I am sure this file is not under version control because svn status shows this:
? install/version
? install/config.xml.php
I have already enabled the autoprops in svn default config but this did not help.
Any ideas?
Btw: this is a server, so no GUI.
vim makes it easy to force line endings to entirely CRLF or entirely CR.
:set ff=unix
:wq
d2u, dtox, dos2unix, are some names for simple utilities that are often installed on systems to do this task. You could also use the standard tr(1) utility:
tr -d '\r' < input > output
While working on Windows OS use Notepad ++:
Edit -> EOL Conversion.
- Windows Format
- UNIX/OSX Format
- Old Mac Format
You have current format information in the status bar.

How to get diff between all files inside 2 folders that are on the web?

So I want to compare this folder http://cloudobserver.googlecode.com/svn/branches/v0.4/Boost.Extension.Tutorial/libs/boost/extension/ with this http://svn.boost.org/svn/boost/sandbox/boost/extension/. I want to get a diff file as a result. These folders are under svn control but I'd prefer git styled diff file (like one shown here) I tried git diff but it seems not to work that way for web folders. So how to do the same thing with one command on Linux?
Update:
So we had a great answer. But it works strangely - it seems to me it shows that all files (same files) have all theire contents replaced with very same contents (while I know for sure that there were only like 3-4 code lines changed at all)...
Update 2:
To achieve what I really needed (dif file with only really changed lines, with git styling, on Linux) do:
$ svn export http://cloudobserver.googlecode.com/svn/branches/v0.4/Boost.Extension.Tutorial/libs/boost/extension/ repos2 --native-eol CRLF
$ svn export http://svn.boost.org/svn/boost/sandbox/boost/extension/ repos --native-eol CRLF
$ git diff repos repos2 > fileWithReadableDiff.diff
Once you have the source trees, e.g.
diff -ENwbur repos1/ repos2/
Even better
diff -ENwbur repos1/ repos2/ | kompare -o -
and have a crack at it in a good gui tool :)
-Ewb ignore the bulk of whitespace changes
-N detect new files
-u unified
-r recurse
You urls are not in the same repository, so you can't do it with the svn diff command.
svn: 'http://svn.boost.org/svn/boost/sandbox/boost/extension' isn't in the same repository as 'http://cloudobserver.googlecode.com/svn'
Another way you could do it, is export each repos using svn export, and then use the diff command to compare the 2 directories you exported.
// Export repositories
svn export http://svn.boost.org/svn/boost/sandbox/boost/extension/ repos1
svn export http://cloudobserver.googlecode.com/svn/branches/v0.4/Boost.Extension.Tutorial/libs/boost/extension/ repos2
// Compare exported directories
diff repos1 repos2 > file.diff

Defaulting cygwin to use CRLF

I'm using a windows PC and editing files checked out from SVN, which has files checked in using DOS.
I use cygwin and when I either create a new file or patch a file using cygwin binaries the file format is unix. Really I need to always use DOS format for these so my colleagues are not inconvenienced.
Is there any way I can have cygwin use DOS format for say a bash session?
I appreciate I can run unix2dos against such files but this is a pain - I'd rather just have them as DOS to begin with if possible.
You can make SVN do this conversion for you automatically. Check out propset and the eol-style option:
http://svnbook.red-bean.com/en/1.1/ch07s02.html#svn-ch-7-sect-2.3.5
This will make the files always have the newline sequence native to the platform on which you checked out the files (i.e., you may get them in LF and the other ones will have the same files with CRLF):
svn propset svn:eol-style native put-your-filenames-here
You can choose the UNIX or DOS file format during the installation of cygwin.

Resources