diff --git a/usr/agite/Afpx.xml b/usr/agite/Afpx.xml index 8053494b1..f50ca22fe 100644 --- a/usr/agite/Afpx.xml +++ b/usr/agite/Afpx.xml @@ -3,7 +3,7 @@ - + diff --git a/usr/agite/Agite.txt b/usr/agite/Agite.txt index 3ab7b784c..4f9ffa162 100644 --- a/usr/agite/Agite.txt +++ b/usr/agite/Agite.txt @@ -1,6 +1,6 @@ Agite user guide ================ -V34.03 +V34.04 General purpose --------------- @@ -1592,9 +1592,15 @@ the error is reported through a specific screen. NOTE: Ensure to enter a comment before committing, otherwise the operaton will be rejected. -NOTE: The Commit button is active only if there are some staged changes. + -The text of the button is in red if there are some unstaged changes (except -when editing commits during a xref:XCherry[cherry pick] session). +NOTE: When committing local changes, the text of the Commit button is in red if +there are not staged changes (will do an empty commit) or if there are some +unstaged changes (will do a partial commit). + +To prevent successive empty commits, the button becomes inactive if there is +no staged changes (left) after a commit. + +NOTE: When editing commits during a xref:XCherry[cherry pick] session, the Commit +button is active only if there are some staged changes (empty commit is +forbidden). .Push diff --git a/usr/agite/commit.adb b/usr/agite/commit.adb index 418a5a22f..c44a2b25d 100644 --- a/usr/agite/commit.adb +++ b/usr/agite/commit.adb @@ -320,6 +320,9 @@ package body Commit is -- Reset result Dummy_Result : Boolean; + -- True if a commit has already been performed (disables empty commit) + Commit_Done : Boolean; + -- Reset Ptg stuff procedure Reset_Ptg is begin @@ -520,14 +523,17 @@ package body Commit is -- Allow Diff if some file Afpx.Utils.Protect_Field (Afpx_Xref.Commit.Diff, Afpx.Line_List.Is_Empty); - -- Allow commit if some stages and not forbidden + -- Allow commit only if not forbidden + -- Allow commit if some stages or first commit, not in loop Afpx.Reset_Field (Afpx_Xref.Commit.Commit); Afpx.Utils.Protect_Field (Afpx_Xref.Commit.Commit, - not Some_Staged or else Allow_Commit = Forbid); + Allow_Commit = Forbid or else + (not Some_Staged and then (In_Loop or else Commit_Done)) ); -- If not in a cherry pick and some changes are unstaged => Warn + -- If not in a cherry pick and no change is staged => Warn if not Afpx.Get_Field_Protection (Afpx_Xref.Commit.Commit) and then not In_Loop - and then Some_Unstaged then + and then (Some_Unstaged or else not Some_Staged) then Afpx.Set_Field_Colors (Afpx_Xref.Commit.Commit, Con_Io.Color_Of ("Red")); end if; @@ -700,6 +706,7 @@ package body Commit is -- Git_If.Commit Result := As.U.Tus (Git_If.Do_Commit (Comment.Image)); if Result.Is_Null then + Commit_Done := True; return; end if; -- Show error @@ -712,6 +719,9 @@ package body Commit is Editor := As.U.Tus (Config.Editor); Differator := As.U.Tus (Config.Differator); + -- No commit done in this session + Commit_Done := False; + -- Move to root Directory.Change_Current (Root);