diff --git a/files_panel.go b/files_panel.go index 4f993beac..08bb9f049 100644 --- a/files_panel.go +++ b/files_panel.go @@ -74,6 +74,9 @@ func handleAddPatch(g *gocui.Gui, v *gocui.View) error { if !file.HasUnstagedChanges { return createErrorPanel(g, "File has no unstaged changes to add") } + if !file.Tracked { + return createErrorPanel(g, "Cannot git add --patch untracked files") + } gitAddPatch(g, file.Name) return err } diff --git a/gitcommands.go b/gitcommands.go index 2c5a4f2dc..22fa4d1f3 100644 --- a/gitcommands.go +++ b/gitcommands.go @@ -306,7 +306,7 @@ func getOpenCommand() (string, string, error) { } func gitAddPatch(g *gocui.Gui, filename string) { - runSubProcess(g, "git", "add", "-p", filename) + runSubProcess(g, "git", "add", "--patch", filename) } func editFile(g *gocui.Gui, filename string) (string, error) {