arxanas / scm-record

`scm-record` is a UI component to interactively select changes to include in a commit. It's meant to be embedded in source control tooling.
23 stars 9 forks source link

bug: empty files are not selectable #26

Open arxanas opened 6 months ago

arxanas commented 6 months ago

Description of the bug

As reported here https://github.com/martinvonz/jj/issues/3016#issuecomment-1937849128

Expected behavior

No response

Actual behavior

No response

Version of rustc

No response

arxanas commented 4 months ago

As discussed in the original comment, my intention was that the caller would always provide at least one item per section, and a file mode section (from 0 to the real file mode) is one meaningful item to provide. In this thread, it's also suggested to use a zero-byte binary section, which also makes sense to me.

We should consider whether it's a design defect to even have scm-record effectively require that all sections have at least one item. Maybe it should render some kind of default item in that case? Or maybe it should simply be possible to select sections without selecting their constituent items (as is currently required)?

emesterhazy commented 4 months ago

I personally think using the mode change section is fine, but I don't have a strong opinion. One thing in favor of the mode section is that I believe empty files are currently treated as text files, which makes sense to me.

I think that there are a couple of things to fix here. One is how the UI renders empty files, and the other is how get_selected_contents determines what's changed for an empty file. I'm working on a fix for both of these that I'll hopefully be able to push later this week.