@@ -27,6 +27,12 @@ public async Task AbortAsync(CommandLog log)
2727 {
2828 if ( _abortCmd != null )
2929 await _abortCmd . Use ( log ) . ExecAsync ( ) ;
30+
31+ OnAborted ( ) ;
32+ }
33+
34+ protected virtual void OnAborted ( )
35+ {
3036 }
3137
3238 protected Commands . Command _continueCmd = null ;
@@ -101,6 +107,7 @@ public Models.Commit Onto
101107
102108 public RebaseInProgress ( Repository repo )
103109 {
110+ _gitDir = repo . GitDir ;
104111 Name = "Rebase" ;
105112
106113 _continueCmd = new Commands . Command
@@ -123,6 +130,7 @@ public RebaseInProgress(Repository repo)
123130 WorkingDirectory = repo . FullPath ,
124131 Context = repo . FullPath ,
125132 Args = "rebase --abort" ,
133+ RaiseError = false ,
126134 } ;
127135
128136 HeadName = File . ReadAllText ( Path . Combine ( repo . GitDir , "rebase-merge" , "head-name" ) ) . Trim ( ) ;
@@ -143,6 +151,19 @@ public RebaseInProgress(Repository repo)
143151 Onto = new Commands . QuerySingleCommit ( repo . FullPath , ontoSHA ) . GetResult ( ) ?? new Models . Commit ( ) { SHA = ontoSHA } ;
144152 BaseName = Onto . GetFriendlyName ( ) ;
145153 }
154+
155+ protected override void OnAborted ( )
156+ {
157+ var rebaseMergeDir = Path . Combine ( _gitDir , "rebase-merge" ) ;
158+ if ( Directory . Exists ( rebaseMergeDir ) )
159+ Directory . Delete ( rebaseMergeDir , true ) ;
160+
161+ var rebaseApplyDir = Path . Combine ( _gitDir , "rebase-apply" ) ;
162+ if ( Directory . Exists ( rebaseApplyDir ) )
163+ Directory . Delete ( rebaseApplyDir , true ) ;
164+ }
165+
166+ private readonly string _gitDir ;
146167 }
147168
148169 public class RevertInProgress : InProgressContext
0 commit comments