git/list[1] front-page[2] threads[3] people[4] search[5] about
 

issue: strange `git diff --numstat` behavior.

From
SASergey Andreenko <andreenkosa@gmail.com>
Date
Oct 12, 2018, 18:23 UTC
Message-ID
<CAD1gVxMg0ZiKqFABrnwt0v_=wr2X_3ErkR92RmCAtFQnuM+L5w@mail.gmail.com>

git diff –numstat FOLDER1 FOLDER2 works strange when run from a git controlled folder.

The output shrinks some symbols in the diff file paths.
For example:
Create a folder and call git init, for example: `C:\test`.
              mkdir C:\test
              cd C:\test
              git init

Create two folders with to diff. For example: ` C:\diff`, `C:\base` and put a file in them with a diff (for example `1.txt` with `1` in base and `1.txt` with 2 in diff).

              mkdir C:\base
              mkdir C:\diff
              echo. 12>C:\base\1.txt
              echo 13>C:\diff\1.txt
Run git diff:
pushd C:\
git.exe diff --numstat "C:\diff" "C:\base"
Output will be:
1       1       "C:\\diff/1.txt" => "C:\\base/1.txt"
Now move into C:\test and run it again:
pushd C:\test
git.exe diff --numstat "C:\diff" "C:\base"
1       1       "C:\\diff/1.txt" => "C:\\base/1.txt"
Now create a folder in `C:\test`, for example `one`:
mkdir one
cd one
git.exe diff --numstat "C:\diff" "C:\base"
output will be:
              0       1       {iff => ase}/1.txt
So (folder_name_length) symbols were cut from the path (“C:\\d” and “C:\\b”).

Is any way to avoid that? I have checked several git versions and they all do the same.

Commands to repro:
mkdir C:\test
cd C:\test
git init
mkdir C:\base
mkdir C:\diff
echo. 12>C:\base\1.txt
echo 13>C:\diff\1.txt
pushd C:\
git.exe diff --numstat "C:\diff" "C:\base"
pushd C:\test
git.exe diff --numstat "C:\diff" "C:\base"
mkdir one
cd one
git.exe diff --numstat "C:\diff" "C:\base"
Best Regards,
Sergey Andrenko
Next: Junio C Hamano
Message 1 of 8 in “issue: strange `git diff --numstat` behavior.”
  1. Sergey AndreenkoOct 12, 2018
  2. Junio C HamanoOct 13, 2018
  3. diff: don't attempt to strip prefix from absolute Windows pathsJohannes Sixt, Oct 18, 2018
  4. Stefan BellerOct 18, 2018
  5. Johannes SixtOct 18, 2018
  6. diff: don't attempt to strip prefix from absolute Windows pathsJohannes Sixt, Oct 19, 2018
  7. Stefan BellerOct 19, 2018
  8. Junio C HamanoOct 19, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.