vscode-git-graph icon indicating copy to clipboard operation
vscode-git-graph copied to clipboard

Support for Git File Type Changes (e.g. symbolic links <-> files)

Open marco-m-pix4d opened this issue 3 years ago • 3 comments

Describe the Bug

Git allows to track symlinks. If a file was originally added to a git repo as a symlink, and subsequently is replaced with a normal file (so the name stays the same), it will be reported as typechange:

$ git status
...
    typechange: foo

This extension:

  • reports correctly the change count: "Uncommitted Changes (1)"
  • but does NOT list the change in the panel to the right of "Displaying all uncommitted changes."

Steps to Reproduce

$ git init
$ touch foo
$ ln -s foo bar
$ ls -l
lrwxrwxrwx bar -> foo
-rw-r--r-- foo
$ git add bar foo
$ git commit -m 1
[master (root-commit) 1b5fc81209] 1
 2 files changed, 1 insertion(+)
 create mode 120000 bar
 create mode 100644 foo
$ code --add .
$ rm bar
$ touch bar
$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        typechange: bar

no changes added to commit (use "git add" and/or "git commit -a")

The extension shows:

graph

NOTE: The reproduction steps above use an empty file for simplicity, but the bug is present also if the file is not empty.

Expected Behaviour

The panel to the right of "Displaying all uncommitted changes." should show file bar.

Environment

  • Git Graph Extension Version: v1.30.0 (latest)
  • Visual Studio Code Version: 1.56.2 (latest)
  • Operating System: macOS Big Sur

Additional Context (optional)

Note that I am using Git Graph with the Remote SSH extension.

Additional notes

Once more, thanks for Git Graph!

marco-m-pix4d avatar Jun 08 '21 06:06 marco-m-pix4d

Hi @marco-m-pix4d,

The extension currently runs git status --untracked-files=all --porcelain to determine the number of uncommitted changes (1 in your example). However when retrieving the files to display in the Commit Details View, the commands git diff --name-status --find-renames --diff-filter=AMDR HEAD and git diff --numstat --find-renames --diff-filter=AMDR -z HEAD are used. As expected by the currently used value of the --diff-filter argument, only additions, modifications, deletions and renames are returned - not type changes "T".

Visual Studio Code's in-built Git Extension doesn't support type changes - it also only supports additions, modifications, deletions and renames. image

Currently type changes are not supported in the extension as: they are such a rare edge case, are complicated to implement well (given the lack of available information from Git), and to be consistent with Visual Studio Code's implementation.

However, the example you've provided highlights that the current behaviour in the extension is inconsistent, as type changes are counted for "Uncommitted Changes (1)", but not shown in the Commit Details View. I'll change this to an improvement request to add support for type changes throughout the entire extension.

mhutchie avatar Jun 08 '21 08:06 mhutchie

Hello @mhutchie, thanks for the quick and detailed explanation.

I now understand that, since vscode itself (via the built-in extension) doesn't support git type changes, it can be complicated / unclear if justified to implement support for this in Git Graph.

If I could choose, I would prefer for this extension to stay lean and quick (in general, not only for this particular feature), so for sure I will leave up to you to decide if and how to prioritize this feature.

Thanks!

marco-m-pix4d avatar Jun 08 '21 11:06 marco-m-pix4d

I disagree that symlinks are so rare though. We use them all the time to refer to boilerplate files inside submodules.

sanmai-NL avatar Aug 16 '23 08:08 sanmai-NL