Your comments

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.

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.