Skip to content

Commit

Permalink
feat: Add diff.reverse configuration variable
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Mar 13, 2022
1 parent d2a4417 commit 3f035a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The following configuration variables are available:
| | `command` | string | *none* | External diff command |
| | `exclude` | []string | *none* | Entry types to exclude from diffs |
| | `pager` | string | *none* | Diff-specific pager |
| | `reverse` | bool | `false` | Reverse order of arguments to diff |
| `edit` | `args` | []string | *none* | Extra args to edit command |
| | `command` | string | `$EDITOR` / `$VISUAL` | Edit command |
| | `hardlink` | bool | `true` | Invoke editor with a hardlink to the source file |
Expand Down
8 changes: 4 additions & 4 deletions pkg/cmd/diffcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ type diffCmdConfig struct {
Args []string `mapstructure:"args"`
Exclude *chezmoi.EntryTypeSet `mapstructure:"exclude"`
Pager string `mapstructure:"pager"`
Reverse bool `mapstructure:"reverse"`
include *chezmoi.EntryTypeSet
init bool
recursive bool
reverse bool
useBuiltinDiff bool
}

Expand All @@ -40,7 +40,7 @@ func (c *Config) newDiffCmd() *cobra.Command {
flags.VarP(c.Diff.include, "include", "i", "Include entry types")
flags.BoolVar(&c.Diff.init, "init", c.update.init, "Recreate config file from template")
flags.BoolVarP(&c.Diff.recursive, "recursive", "r", c.Diff.recursive, "Recurse into subdirectories")
flags.BoolVar(&c.Diff.reverse, "reverse", c.Diff.reverse, "Reverse the direction of the diff")
flags.BoolVar(&c.Diff.Reverse, "reverse", c.Diff.Reverse, "Reverse the direction of the diff")
flags.StringVar(&c.Diff.Pager, "pager", c.Diff.Pager, "Set pager")
flags.BoolVarP(&c.Diff.useBuiltinDiff, "use-builtin-diff", "", c.Diff.useBuiltinDiff, "Use the builtin diff")

Expand All @@ -55,7 +55,7 @@ func (c *Config) runDiffCmd(cmd *cobra.Command, args []string) (err error) {
gitDiffSystem := chezmoi.NewGitDiffSystem(dryRunSystem, &builder, c.DestDirAbsPath, &chezmoi.GitDiffSystemOptions{
Color: color,
Include: c.Diff.include.Sub(c.Diff.Exclude),
Reverse: c.Diff.reverse,
Reverse: c.Diff.Reverse,
})
if err = c.applyArgs(cmd.Context(), gitDiffSystem, c.DestDirAbsPath, args, applyArgsOptions{
include: c.Diff.include.Sub(c.Diff.Exclude),
Expand All @@ -70,7 +70,7 @@ func (c *Config) runDiffCmd(cmd *cobra.Command, args []string) (err error) {
}
diffSystem := chezmoi.NewExternalDiffSystem(
dryRunSystem, c.Diff.Command, c.Diff.Args, c.DestDirAbsPath, &chezmoi.ExternalDiffSystemOptions{
Reverse: c.Diff.reverse,
Reverse: c.Diff.Reverse,
},
)
defer func() {
Expand Down

0 comments on commit 3f035a6

Please sign in to comment.