diff --git a/pkg/commands/git_commands/rebase.go b/pkg/commands/git_commands/rebase.go index 6990d6bd5..0c79e92b7 100644 --- a/pkg/commands/git_commands/rebase.go +++ b/pkg/commands/git_commands/rebase.go @@ -130,7 +130,7 @@ func (self *RebaseCommands) InteractiveRebaseBreakAfter(commits []*models.Commit // PrepareInteractiveRebaseCommand returns the cmd for an interactive rebase // we tell git to run lazygit to edit the todo list, and we pass the client // lazygit a todo string to write to the todo file -func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseSha string, todoLines []TodoLine, overrideEditor bool) oscommands.ICmdObj { +func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseShaOrRoot string, todoLines []TodoLine, overrideEditor bool) oscommands.ICmdObj { todo := self.buildTodo(todoLines) ex := oscommands.GetLazygitPath() @@ -139,7 +139,7 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseSha string, todo debug = "TRUE" } - cmdStr := fmt.Sprintf("git rebase --interactive --autostash --keep-empty --no-autosquash %s", baseSha) + cmdStr := fmt.Sprintf("git rebase --interactive --autostash --keep-empty --no-autosquash %s", baseShaOrRoot) self.Log.WithField("command", cmdStr).Debug("RunCommand") cmdObj := self.cmd.New(cmdStr) @@ -172,10 +172,6 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseSha string, todo func (self *RebaseCommands) BuildSingleActionTodo(commits []*models.Commit, actionIndex int, action string) ([]TodoLine, string, error) { baseIndex := actionIndex + 1 - if len(commits) <= baseIndex { - return nil, "", errors.New(self.Tr.CannotRebaseOntoFirstCommit) - } - if action == "squash" || action == "fixup" { baseIndex++ } @@ -193,7 +189,12 @@ func (self *RebaseCommands) BuildSingleActionTodo(commits []*models.Commit, acti } }) - return todoLines, commits[baseIndex].Sha, nil + baseSha := "--root" + if baseIndex < len(commits) { + baseSha = commits[baseIndex].Sha + } + + return todoLines, baseSha, nil } // AmendTo amends the given commit with whatever files are staged diff --git a/pkg/i18n/chinese.go b/pkg/i18n/chinese.go index 68ee2735b..dbc8122e9 100644 --- a/pkg/i18n/chinese.go +++ b/pkg/i18n/chinese.go @@ -216,7 +216,6 @@ func chineseTranslationSet() TranslationSet { LcPasteCommits: "粘贴提交(拣选)", SureCherryPick: "您确定要将选中的提交进行拣选到这个分支吗?", CherryPick: "拣选 (Cherry-Pick)", - CannotRebaseOntoFirstCommit: "您不能以交互方式变基 (rebase) 至第一次提交", Donate: "捐助", AskQuestion: "提问咨询", PrevLine: "选择上一行", diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go index 31ef939ab..d8fcb5338 100644 --- a/pkg/i18n/dutch.go +++ b/pkg/i18n/dutch.go @@ -181,7 +181,6 @@ func dutchTranslationSet() TranslationSet { LcPasteCommits: "plak commits (cherry-pick)", SureCherryPick: "Weet je zeker dat je de gekopieerde commits naar deze branch wil cherry-picken?", CherryPick: "Cherry-Pick", - CannotRebaseOntoFirstCommit: "Je kan niet interactief rebasen naar de eerste commit", Donate: "Doneer", PrevLine: "selecteer de vorige lijn", NextLine: "selecteer de volgende lijn", diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 6639b9e48..315851f35 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -219,7 +219,6 @@ type TranslationSet struct { LcPasteCommits string SureCherryPick string CherryPick string - CannotRebaseOntoFirstCommit string Donate string AskQuestion string PrevLine string @@ -868,7 +867,6 @@ func EnglishTranslationSet() TranslationSet { LcPasteCommits: "paste commits (cherry-pick)", SureCherryPick: "Are you sure you want to cherry-pick the copied commits onto this branch?", CherryPick: "Cherry-Pick", - CannotRebaseOntoFirstCommit: "You cannot interactive rebase onto the first commit", Donate: "Donate", AskQuestion: "Ask Question", PrevLine: "select previous line", diff --git a/pkg/i18n/japanese.go b/pkg/i18n/japanese.go index 122fd3133..891d737b0 100644 --- a/pkg/i18n/japanese.go +++ b/pkg/i18n/japanese.go @@ -215,8 +215,7 @@ func japaneseTranslationSet() TranslationSet { LcCherryPickCopyRange: "コミットを範囲コピー (cherry-pick)", LcPasteCommits: "コミットを貼り付け (cherry-pick)", // SureCherryPick: "Are you sure you want to cherry-pick the copied commits onto this branch?", - CherryPick: "Cherry-Pick", - // CannotRebaseOntoFirstCommit: "You cannot interactive rebase onto the first commit", + CherryPick: "Cherry-Pick", Donate: "支援", AskQuestion: "質問", PrevLine: "前の行を選択", diff --git a/pkg/i18n/korean.go b/pkg/i18n/korean.go index 361df81f2..fa649bcc0 100644 --- a/pkg/i18n/korean.go +++ b/pkg/i18n/korean.go @@ -217,7 +217,6 @@ func koreanTranslationSet() TranslationSet { LcPasteCommits: "커밋을 붙여넣기 (cherry-pick)", SureCherryPick: "정말로 복사한 커밋을 이 브랜치에 체리픽하시겠습니까?", CherryPick: "체리픽", - CannotRebaseOntoFirstCommit: "첫 번째 커밋에 대해 대화식으로 리베이스할 수 없습니다.", Donate: "후원", AskQuestion: "질문하기", PrevLine: "이전 줄 선택", diff --git a/pkg/i18n/polish.go b/pkg/i18n/polish.go index 5bc2a9a35..3db26a22c 100644 --- a/pkg/i18n/polish.go +++ b/pkg/i18n/polish.go @@ -149,7 +149,6 @@ func polishTranslationSet() TranslationSet { LcPasteCommits: "wklej commity (przebieranie)", SureCherryPick: "Czy na pewno chcesz przebierać w skopiowanych commitach na tej gałęzi?", CherryPick: "Przebieranie", - CannotRebaseOntoFirstCommit: "Nie można interaktywnie zmienić bazy na pierwszym commicie", Donate: "Wesprzyj", PrevLine: "poprzednia linia", NextLine: "następna linia",