@@ -769,43 +769,54 @@ private void UpdateDetail()
769769
770770 private void UpdateInProgressState ( )
771771 {
772- if ( string . IsNullOrEmpty ( _commitMessage ) )
773- {
774- var mergeMsgFile = Path . Combine ( _repo . GitDir , "MERGE_MSG" ) ;
775- if ( File . Exists ( mergeMsgFile ) )
776- CommitMessage = File . ReadAllText ( mergeMsgFile ) ;
777- }
772+ var oldType = _inProgressContext != null ? _inProgressContext . GetType ( ) : null ;
778773
779774 if ( File . Exists ( Path . Combine ( _repo . GitDir , "CHERRY_PICK_HEAD" ) ) )
780- {
781775 InProgressContext = new CherryPickInProgress ( _repo ) ;
782- }
783776 else if ( Directory . Exists ( Path . Combine ( _repo . GitDir , "rebase-merge" ) ) || Directory . Exists ( Path . Combine ( _repo . GitDir , "rebase-apply" ) ) )
784- {
785- var rebasing = new RebaseInProgress ( _repo ) ;
786- InProgressContext = rebasing ;
787-
788- if ( string . IsNullOrEmpty ( _commitMessage ) )
789- {
790- var rebaseMsgFile = Path . Combine ( _repo . GitDir , "rebase-merge" , "message" ) ;
791- if ( File . Exists ( rebaseMsgFile ) )
792- CommitMessage = File . ReadAllText ( rebaseMsgFile ) ;
793- else if ( rebasing . StoppedAt != null )
794- CommitMessage = new Commands . QueryCommitFullMessage ( _repo . FullPath , rebasing . StoppedAt . SHA ) . GetResult ( ) ;
795- }
796- }
777+ InProgressContext = new RebaseInProgress ( _repo ) ;
797778 else if ( File . Exists ( Path . Combine ( _repo . GitDir , "REVERT_HEAD" ) ) )
798- {
799779 InProgressContext = new RevertInProgress ( _repo ) ;
800- }
801780 else if ( File . Exists ( Path . Combine ( _repo . GitDir , "MERGE_HEAD" ) ) )
802- {
803781 InProgressContext = new MergeInProgress ( _repo ) ;
804- }
805782 else
806- {
807783 InProgressContext = null ;
808- }
784+
785+ if ( _inProgressContext == null )
786+ return ;
787+
788+ if ( _inProgressContext . GetType ( ) == oldType && ! string . IsNullOrEmpty ( _commitMessage ) )
789+ return ;
790+
791+ do
792+ {
793+ if ( LoadCommitMessageFromFile ( Path . Combine ( _repo . GitDir , "MERGE_MSG" ) ) )
794+ break ;
795+
796+ if ( LoadCommitMessageFromFile ( Path . Combine ( _repo . GitDir , "rebase-merge" , "message" ) ) )
797+ break ;
798+
799+ var rebaseProcessingFile = Path . Combine ( _repo . GitDir , "rebase-apply" , "final-commit" ) ;
800+ if ( File . Exists ( rebaseProcessingFile ) )
801+ {
802+ var sha = File . ReadAllText ( rebaseProcessingFile ) ;
803+ if ( ! string . IsNullOrEmpty ( sha ) )
804+ CommitMessage = new Commands . QueryCommitFullMessage ( _repo . FullPath , sha ) . GetResult ( ) ;
805+ }
806+ } while ( false ) ;
807+ }
808+
809+ private bool LoadCommitMessageFromFile ( string file )
810+ {
811+ if ( ! File . Exists ( file ) )
812+ return false ;
813+
814+ var msg = File . ReadAllText ( file ) . Trim ( ) ;
815+ if ( string . IsNullOrEmpty ( msg ) )
816+ return false ;
817+
818+ CommitMessage = msg ;
819+ return true ;
809820 }
810821
811822 private void SetDetail ( Models . Change change , bool isUnstaged )
0 commit comments