Repository: jesseduffield/lazygit
File: pkg/commands/git_commands/commit.go (Go)

Code before:
		Arg("--no-patch", "--oneline").
		Arg(shas...).
		ToArgv()

	return self.cmd.New(cmdArgs).DontLog().RunWithOutput()
}

// AmendHead amends HEAD with whatever is staged in your working tree
func (self *CommitCommands) AmendHead() error {
	return self.AmendHeadCmdObj().Run()
}

func (self *CommitCommands) AmendHeadCmdObj() oscommands.ICmdObj {
	cmdArgs := NewGitCmd("commit").
		Arg("--amend", "--no-edit", "--allow-empty").
		ToArgv()

	return self.cmd.New(cmdArgs)
}

func (self *CommitCommands) ShowCmdObj(sha string, filterPath string, ignoreWhitespace bool) oscommands.ICmdObj {
	contextSize := self.UserConfig.Git.DiffContextSize

	extDiffCmd := self.UserConfig.Git.Paging.ExternalDiffCommand
	cmdArgs := NewGitCmd("show").
		ConfigIf(extDiffCmd != "", "diff.external="+extDiffCmd).
		Arg("--submodule").
		ArgIfElse(extDiffCmd == "", "--no-ext-diff", "--ext-diff").
		Arg("--color="+self.UserConfig.Git.Paging.ColorArg).
		Arg(fmt.Sprintf("--unified=%d", contextSize)).
		Arg("--stat").
		Arg("--decorate").
		Arg("-p").
		Arg(sha).
		ArgIf(ignoreWhitespace, "--ignore-all-space").
		ArgIf(filterPath != "", "--", filterPath).
		ToArgv()

	return self.cmd.New(cmdArgs).DontLog()
}

// Revert reverts the selected commit by sha
func (self *CommitCommands) Revert(sha string) error {
	cmdArgs := NewGitCmd("revert").Arg(sha).ToArgv()

	return self.cmd.New(cmdArgs).Run()
}

func (self *CommitCommands) RevertMerge(sha string, parentNumber int) error {
	cmdArgs := NewGitCmd("revert").Arg(sha, "-m", fmt.Sprintf("%d", parentNumber)).
		ToArgv()

Review comment (suggestion):
```suggestion
		ConfigIf(extDiffCmd != "", "diff.external="+extDiffCmd).
		ArgIfElse(extDiffCmd != "", "--ext-diff", "--no-ext-diff").
		Arg("--submodule").
```
A little clearer imo (aligning the two calls at the cost of a double negative)

Code after:
		Arg("--no-patch", "--oneline").
		Arg(shas...).
		ToArgv()

	return self.cmd.New(cmdArgs).DontLog().RunWithOutput()
}

// AmendHead amends HEAD with whatever is staged in your working tree
func (self *CommitCommands) AmendHead() error {
	return self.AmendHeadCmdObj().Run()
}

func (self *CommitCommands) AmendHeadCmdObj() oscommands.ICmdObj {
	cmdArgs := NewGitCmd("commit").
		Arg("--amend", "--no-edit", "--allow-empty").
		ToArgv()

	return self.cmd.New(cmdArgs)
}

func (self *CommitCommands) ShowCmdObj(sha string, filterPath string, ignoreWhitespace bool) oscommands.ICmdObj {
	contextSize := self.UserConfig.Git.DiffContextSize

	extDiffCmd := self.UserConfig.Git.Paging.ExternalDiffCommand
	cmdArgs := NewGitCmd("show").
		ConfigIf(extDiffCmd != "", "diff.external="+extDiffCmd).
		ArgIfElse(extDiffCmd != "", "--ext-diff", "--no-ext-diff").
		Arg("--submodule").
		Arg("--color="+self.UserConfig.Git.Paging.ColorArg).
		Arg(fmt.Sprintf("--unified=%d", contextSize)).
		Arg("--stat").
		Arg("--decorate").
		Arg("-p").
		Arg(sha).
		ArgIf(ignoreWhitespace, "--ignore-all-space").
		ArgIf(filterPath != "", "--", filterPath).
		ToArgv()

	return self.cmd.New(cmdArgs).DontLog()
}

// Revert reverts the selected commit by sha
func (self *CommitCommands) Revert(sha string) error {
	cmdArgs := NewGitCmd("revert").Arg(sha).ToArgv()

	return self.cmd.New(cmdArgs).Run()
}

func (self *CommitCommands) RevertMerge(sha string, parentNumber int) error {
	cmdArgs := NewGitCmd("revert").Arg(sha, "-m", fmt.Sprintf("%d", parentNumber)).
		ToArgv()