+1

Select "Local changes" by default on committing some of staged files

ansi dev 2 months ago updated by Thomas Singer 2 months ago 5

When I have multiple staged files, but I select only some of them and press the button "Commit", I expect that the option "Local Changes" will be selected by default because I don't want to commit all staged files.

Sometimes, I forget to change the option, so SmartGit commits all staged files and it takes time to reset and re-commit.


At this time, the option "Staged changes" was selected automatically (https://smartgit.userecho.com/en/communities/1/topics/696-force-commit-dialog-to-always-select-staged-changes). It makes sense if the user selects nothing and only press the button "Commit".

What should happen if you have staged some files, select other files and stage them (keeping them selected). Now you invoke Commit. What should be the choice - only the selected files or the staged files? I would think, that 99% of the users would expect the staged files to be selected.

There are scripts for invoking Commit:
1. All changes are unstaged/staged:

1.1. User selected some files to commit: Commit selected files only.

1.1. User selected nothing/all files to commit: Commit all files.

2. Some changes were staged, remain changes were unstaged:

2.1. User selected some files to commit: Commit selected files only (selected files can contain staged/unstaged file or changes). Because user selects files to commit, it's mean "I want to commit the selected files", so the expected mode for this case is Local changes because, with the current behaviour, the commit mode is Staged change, so the files to be committed contains files which user was not selected.

2.2. User selected nothing/all staged files to commit: Commit all staged files, so the expected mode is Staged changes.

2.3. User selected nothing/all unstaged files to commit: Commit all unstaged files, so the expected mode is Local changes.

If I understand this correctly, this would just commit the last staged (and still selected) file, right?

I assume that the file panel displays something like the below:

===========

Unstaged files:

===========

File 1

File 2

File 3

===========

Staged files:

===========

File 1

File 2

File 4

File 5

Only some lines of file 1 and file 2 were staged, so you see them in both sub-panels.

The bold items mean files were selected by the user.

The expected behaviour:

1. Mode: "Local changes".

2. Commit selected changes:

- Unstaged changes of file 1.

- Whole changes of file 3.

- Staged changes of file 2.

- Whole changes of file 4.


When the user selected changes to commit, don't care about changes were staged or not, but only care changes were selected to commit them.

For a long time SmartGit has a combined view showing working tree and index files in one table. There, staged files are kept selected after the state change.