Skip to content

Commit

Permalink
Allow empty commit (once, and not in loop)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal MALAISE committed Aug 7, 2017
1 parent d4b92c9 commit feb8e4a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion usr/agite/Afpx.xml
Expand Up @@ -3,7 +3,7 @@
<!-- For agite -->

<Afpx_Descriptors Height="46" Width="55">
<Var Name="Version" Value="V34.03"/>
<Var Name="Version" Value="V34.04"/>

<!-- Main screen: explorator -->
<Descriptor Num="1" Background="Light_Grey" Name="Main">
Expand Down
14 changes: 10 additions & 4 deletions usr/agite/Agite.txt
@@ -1,6 +1,6 @@
Agite user guide
================
V34.03
V34.04

General purpose
---------------
Expand Down Expand Up @@ -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

Expand Down
16 changes: 13 additions & 3 deletions usr/agite/commit.adb
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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);

Expand Down

0 comments on commit feb8e4a

Please sign in to comment.