jjlee / git-meld-index

Run meld or any git difftool to interactively stage changes
Other
75 stars 4 forks source link

FR/Suggestion: Mark the working copy files as read-only in the filesystem #7

Closed ilyagr closed 2 days ago

ilyagr commented 2 weeks ago

This causes Meld to not allow editing of the working copy pane, which makes sense since those edits are lost.

This makes the dir somewhat harder to remove; https://docs.python.org/3.11/library/shutil.html#rmtree-example might work.

BTW, it might be fine to never allow editing of the working copy with git-meld-index, as the user can just edit the working copy and many other tools allow for doing that while seeing the diff with the index.

jjlee commented 3 days ago

:((( did this cause you to lose any edits?

I'm sure past-me knew about this, but present day me doesn't like it at all and sees it as more bug than feature request.

Thinking through options:

ilyagr commented 3 days ago

No, I didn't lose anything, no worries, and thanks for the concern! 😀

I suggested this because that's what https://github.com/martinvonz/jj use this trick. Seems to work OK, even on Mac and Windows; I don't remember whether there were platform-dependent issues (but it uses the Rust library as opposed to Python's).

At a glance, I didn't see a relevant option in meld --help. Potentially, it could be a nice feature for them to add.

The last option is also an option, I agree. I'm not sure it's easier, though.

ilyagr commented 3 days ago

One minor problem the read-only trick does have is if you use Meld's UI to copy entire files. (In one direction, the file will be lost; in the other -- it will be unexpectedly readonly) However, I think people do this rarely, and it will make sense to people if they are used to one of the sides being read-only.

jjlee commented 2 days ago

Ah, you're suggesting changing write access permission on the source files! I heard "read-only" and thought of read-only mount.

That works I see, nice idea, thanks I'll certainly do that

jjlee commented 2 days ago

it will be unexpectedly readonly

I think git only tracks executable permissions not unix-style read/write permissions, so I don't think this is a problem for staging, unless I misunderstand you?