3

The filename given to git diff is 76 characters long.

aaaa/bbb/cccccccccc/ddddddddddddddddddddddddd/eeeeeeeeeeeeeeeeeeeeeeeee.json

The concatenated files line is 254 characters long.

origin/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB:aaaa/bbb/cccccccccc/ddddddddddddddddddddddddd/eeeeeeeeeeeeeeeeeeeeeeeee.json..origin/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB:aaaa/bbb/cccccccccc/ddddddddddddddddddddddddd/eeeeeeeeeeeeeeeeeeeeeeeee.json

Execution of the git diff command produces:

git diff --ignore-cr-at-eol --exit-code origin/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB:aaaa/bbb/cccccccccc/ddddddddddddddddddddddddd/eeeeeeeeeeeeeeeeeeeeeeeee.json..origin/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB:aaaa/bbb/cccccccccc/ddddddddddddddddddddddddd/eeeeeeeeeeeeeeeeeeeeeeeee.json
fatal: failed to stat 'origin/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB:aaaa/bbb/cccccccccc/ddddddddddddddddddddddddd/eeeeeeeeeeeeeeeeeeeeeeeee.json..origin/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB:aaaa/bbb/cccccccccc/ddddddddddddddddddddddddd/eeeeeeeeeeeeeeeeeeeeeeeee.json': Filename too long

Environment:

Caption             : Microsoft Windows 10 Enterprise
Version             : 10.0.19044
DisplayVersion      : 21H2
lit
  • 14,456
  • 10
  • 65
  • 119
  • What O/S are you on? – stdunbar Aug 09 '23 at 18:42
  • Running Windows 10 – lit Aug 09 '23 at 18:43
  • 1
    Windows I bet. Git hasn't quite figured out long path names in Windows like the rest of the world. – Blindy Aug 09 '23 at 18:44
  • On Windows the `:` character is not a legal file name character. – stdunbar Aug 09 '23 at 18:46
  • 1
    @stdunbar, I thought that the COLON character was part of the `git diff` syntax separating `origin/branch` from the filename. – lit Aug 09 '23 at 18:49
  • 2
    That's weird because it is interpreting the 2 files you want to compare as if they were a single file. What happens if you enclose it in single or double quotes? – eftshift0 Aug 09 '23 at 18:49
  • @lit what you are trying to do is correct: `branch1:some-file..branch2:another-file`. – eftshift0 Aug 09 '23 at 18:49
  • @eftshift0, same result using QUOTATION MARK characters. I am also specifying `origin/branch`. Is that a problem? – lit Aug 09 '23 at 18:54
  • Nope, that should not be a problem. Does it also fail if you try on a linux box? – eftshift0 Aug 09 '23 at 18:54
  • @eftshift0, would that I could try it on a Linux box. Not available. – lit Aug 09 '23 at 18:57
  • What is your question about this error? – mkrieger1 Aug 09 '23 at 22:19
  • The filename is only 76 characters long. Is git really limited to 76 character file names? Is this a limit of `git diff`? Is there any docmentation on file name length limits? – lit Aug 09 '23 at 22:43
  • _technically_ there isn't a question in your post, I imagine you are asking how to fix this issue. See for example : https://stackoverflow.com/q/22575662/86072 . Found by searching the error message in the search box : https://stackoverflow.com/search?q=%5Bgit%5D+Filename+too+long – LeGEC Aug 10 '23 at 13:37
  • @LeGEC, yes, the question is how to make it work. That is why we are here on SO. Right? It appears that using `git config --system core.longpaths true` made it work. I have done limited testing. It might be helpful if this failure is encountered and running on Windows, that a message about core.longpaths should be emitted. – lit Aug 10 '23 at 15:50

0 Answers0