kahole / edamagit

Magit for VSCode

Home Page:https://marketplace.visualstudio.com/items?itemName=kahole.magit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ensure git runs with `diff.noprefix=false` when diffing

zoldar opened this issue · comments

First and foremost, thank you for a great tool I've been using every day over past couple years!

For some time, I've been struggling with staging and unstaging particular hunks in staging view. Every time I tried to stage a selection, I ended up an error like:

[1] git apply --ignore-space-change --cached
error: app/code.ex does not exist in index

Only after some time I've registered that the path in the error is missing a directory directly at the project root level (so, it's lib/app/code.ex, per example above). On a closer inspection I've finally sorted out that it's because of diff.noprefix being set to true in my global config. The purpose of that option is shaving off a|b/ prefixes from patch paths.

Now, while I've set that option back to default (staging hunks started working again!) and I have no problem with leaving that option that way, some folks might find it more convenient to keep it enabled (AFAIK some collab tooling expects no extra prefixes). I'm wondering if, perhaps, the git commands issued by edamagit shouldn't explicitly override this option with something like:

git -c diff.noprefix=false diff ...

?

This is just a suggestion of course but I wanted to at least bring that problem up for awareness because I've been stuck with defunct chunk staging for quite some time before I've finally took a proper stab at resolving it myself 😅