Skip to content

Commit 1ecd124

Browse files
committed
Show rebase step number
1 parent 2d5933a commit 1ecd124

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

custom-prompt/custom-prompt.cc

+17-1
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class GitRepository
198198
void establish_description(void);
199199
void establish_tag(void);
200200
void establish_state(void);
201+
void establish_state_rebasing(void);
201202
void establish_dirty_staged_untracked(void);
202203
// These are static methods because otherwise, their signatures do not
203204
// match the required signatures for use as callback functions.
@@ -310,7 +311,7 @@ void GitRepository::establish_state(void)
310311
case C::GIT_REPOSITORY_STATE_REBASE:
311312
case C::GIT_REPOSITORY_STATE_REBASE_INTERACTIVE:
312313
case C::GIT_REPOSITORY_STATE_REBASE_MERGE:
313-
this->state = "rebasing";
314+
this->establish_state_rebasing();
314315
break;
315316
case C::GIT_REPOSITORY_STATE_REVERT:
316317
case C::GIT_REPOSITORY_STATE_REVERT_SEQUENCE:
@@ -319,6 +320,21 @@ void GitRepository::establish_state(void)
319320
}
320321
}
321322

323+
324+
/**
325+
* Obtain the rebase state of the working tree of the current Git repository.
326+
*/
327+
void GitRepository::establish_state_rebasing(void){
328+
this->state = "rebasing";
329+
std::ifstream msgnum_file(this->gitdir / "rebase-merge/msgnum");
330+
if(!msgnum_file.good()){
331+
return;
332+
}
333+
std::string msgnum_contents;
334+
msgnum_file >> msgnum_contents;
335+
this->state += " " + msgnum_contents;
336+
}
337+
322338
/**
323339
* Obtain the statuses of the index and working tree of the current Git
324340
* repository.

0 commit comments

Comments
 (0)