2

I have made Git to diff some binary files by copying the files to a directory in the Temp folder in Windows using a .bat file (or batch script).

The script copies the original file and makes a companion file with extension .txt which contains the text representation of the binary file. Afterwards, it writes the contents of the generated file using the command

type C:\DOCUME~1\ROGER\CONFIG~1\Temp\roger\file.txt

All that is using Git attributes. Now, I need to use the companion .txt file to be used in the git difftool command instead of the original file. How do I tell Git which files it should use when diffing .someExtension files?

I have tried to make another .bat file, but the configuration needed in .gitconfig seems to run only Linux scripts, not Windows which are the ones I need, because Linux doesn't understand the path given by Git, i.e., C:\DOCUME~1\ROGER\CONFIG~1\Temp\ when running the copy command cp.

This is my .gitconfig:

[difftool "fmbdiff"]
    keepBackup = false
    keepTemporaries = false
    path = C:/Archivos de programa/Git/cmd/fmbDiffTool.bat
    cmd = \"/c/Archivos de programa/Git/cmd/fmbDiffTool.bat\" \"/$LOCAL\" \"$PWD/$BASE\"

So, the questions that might solve the problem are:

  • How do I run a .bat file specified in the cmd entry of the difftool in gitconfig?
  • Or: How do I get the path of the Windows temporary folder when running the script Git invokes and Linux can understand for copying?
  • Or: What am I doing wrong to achieve this?
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Roger
  • 2,912
  • 2
  • 31
  • 39
  • I never been able to make .bat script work with difftool in Windows: only bash script: http://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-a-visual-diff-program/255212#255212 – VonC Jun 15 '13 at 03:30
  • @VonC Ok, what about the bash understading the correct route to my temporary folder in windows? how can I achieve this?, do I have to make a .exe or something instead of the bash? – Roger Jun 15 '13 at 13:01
  • Try with bash-like path for Windows: `"/C/Document and Settings\ROGER\CONFIG\Temp\"`: make sure to get the case (lowercase, uppercase) right for said path though. – VonC Jun 15 '13 at 13:16
  • @VonC Well, that wouldn't work for my team, I'm making this for at least 10 people, not everyone have the same path, and I wouldn't want them to set that each time for every computer, they also may have multiple accounts in their computers. I think I will go for the .exe file (or maybe a .jar), thanks for your help. – Roger Jun 15 '13 at 13:18
  • Ok, I have summarized that conclusion in an answer. – VonC Jun 15 '13 at 13:25

1 Answers1

1

Basically, the difftool declares a batch script, which can work with a Windows path like:

/c/xxx

That is what I did in "How do I view 'git diff' output with a visual diff program?" 4 years ago.

But for a more complex script, the easiest way is to make a separate one (exe or jar, as you suggests), and call it from the batch script.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • One more doubt though before I dive into this. Since the new file is going to be executed from a bash, getting the temp directory in there, say a scala .jar, would that get me "/temp" or indeed point to "C:\DOCUM~"? – Roger Jun 15 '13 at 13:28
  • @Roger the `exe` called from the bash script should benefit from classic windows path and environment variables. – VonC Jun 15 '13 at 16:30