Skip to content

Commit a94c532

Browse files
authored
Merge pull request #3263 from carapace-sh/git-diff-follow
git: fix `--follow` diff flag
2 parents 446cb7b + a92b6f8 commit a94c532

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

completers/common/git_completer/cmd/common/diff.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func AddDiffFlags(cmd *cobra.Command) {
3737
cmd.Flags().Bool("find-copies-harder", false, "inspect unmodified files as candidates for the source of copy")
3838
cmd.Flags().String("find-object", "", "Look for differences that change the number of occurrences of the specified object")
3939
cmd.Flags().StringP("find-renames", "M", "", "Detect renames")
40+
cmd.Flags().String("follow", "", "Continue listing the history of a file beyond renames")
4041
cmd.Flags().Bool("full-index", false, "show the full pre- and post-image blob object names")
4142
cmd.Flags().BoolP("function-context", "W", false, "Show whole surrounding functions of changes")
4243
cmd.Flags().Bool("histogram", false, "Generate a diff using the \"histogram diff\" algorithm")
@@ -61,6 +62,7 @@ func AddDiffFlags(cmd *cobra.Command) {
6162
cmd.Flags().Bool("no-color-moved", false, "Turn off move detection")
6263
cmd.Flags().Bool("no-color-moved-ws", false, "Do not ignore whitespace when performing move detection")
6364
cmd.Flags().Bool("no-ext-diff", false, "Disallow external diff drivers")
65+
cmd.Flags().Bool("no-follow", false, "Do not continue listing the history of a file beyond renames.")
6466
cmd.Flags().Bool("no-indent-heuristic", false, "Disable the indent heuristic")
6567
cmd.Flags().Bool("no-index", false, "Compare paths on the file system")
6668
cmd.Flags().BoolP("no-patch", "s", false, "Suppress diff output")
@@ -107,11 +109,21 @@ func AddDiffFlags(cmd *cobra.Command) {
107109
cmd.Flag("color-moved-ws").NoOptDefVal = " "
108110
cmd.Flag("word-diff").NoOptDefVal = "plain"
109111

112+
cmd.MarkFlagsMutuallyExclusive("abbrev", "no-abbrev")
113+
cmd.MarkFlagsMutuallyExclusive("color", "no-color")
114+
cmd.MarkFlagsMutuallyExclusive("color-moved", "no-color-moved")
115+
cmd.MarkFlagsMutuallyExclusive("color-moved-ws", "no-color-moved-ws")
116+
cmd.MarkFlagsMutuallyExclusive("ext-diff", "no-ext-diff")
117+
cmd.MarkFlagsMutuallyExclusive("follow", "no-follow")
118+
cmd.MarkFlagsMutuallyExclusive("indent-heuristic", "no-indent-heuristic")
119+
cmd.MarkFlagsMutuallyExclusive("patch", "no-patch")
120+
110121
carapace.Gen(cmd).FlagCompletion(carapace.ActionMap{
111122
"color": git.ActionColorModes(),
112123
"color-moved": git.ActionColorMovedModes(),
113124
"color-moved-ws": git.ActionColorMovedWsModes(),
114125
"diff-algorithm": git.ActionDiffAlgorithms(),
126+
"follow": carapace.ActionFiles(), // TODO complete files of specific revision/modified between commits?
115127
"ignore-submodules": carapace.ActionValues("none", "untracked", "dirty", "all"),
116128
"output": carapace.ActionFiles(),
117129
"submodule": carapace.ActionValues("short", "long", "log"),

completers/common/git_completer/cmd/diff.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ func init() {
2222

2323
// TODO move into common flag groups
2424
diffCmd.Flags().StringS("G", "G", "", "Look for differences whose patch text contains added/removed lines that match <regex>")
25-
diffCmd.Flags().String("follow", "", "Continue listing the history of a file beyond renames")
2625
diffCmd.Flags().Bool("quiet", false, "Disable all output of the program")
2726
diffCmd.Flags().String("rotate-to", "", "Move the files before the named <file> to the end")
2827
diffCmd.Flags().String("skip-to", "", "Discard the files before the named <file> from the output")
@@ -31,7 +30,6 @@ func init() {
3130
rootCmd.AddCommand(diffCmd)
3231

3332
carapace.Gen(diffCmd).FlagCompletion(carapace.ActionMap{
34-
"follow": carapace.ActionFiles(), // TODO complete files of specific revision/modified between commits?
3533
"skip-to": carapace.ActionFiles(), // TODO complete files of specific revision/modified between commits?
3634
})
3735

completers/common/git_completer/cmd/diffFiles.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ func init() {
2020
diffFilesCmd.Flags().StringS("G", "G", "", "Look for differences whose patch text contains added/removed lines that match <regex>")
2121
diffFilesCmd.Flags().Bool("default", false, "Use argument as default revision")
2222
diffFilesCmd.Flags().Bool("early-output", false, "undocumented")
23-
diffFilesCmd.Flags().Bool("follow", false, "Continue listing the history of a file beyond renames")
2423
diffFilesCmd.Flags().Bool("full-diff", false, "Show full commit diffs")
2524
diffFilesCmd.Flags().Bool("log-size", false, "Print log message size in bytes before the message")
2625
diffFilesCmd.Flags().Bool("mailmap", false, "Use mailmap file to map author and committer name")

completers/common/git_completer/cmd/log.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ func init() {
3232
logCmd.Flags().Bool("dense", false, "Only the selected commits are shown")
3333
logCmd.Flags().String("diff-merges", "", "Specify diff format to be used for merge commits.")
3434
logCmd.Flags().Bool("early-output", false, "undocumented")
35-
logCmd.Flags().Bool("follow", false, "Continue listing the history of a file beyond renames.")
3635
logCmd.Flags().Bool("full-diff", false, "With this, the full diff is shown for commits that touch the specified paths")
3736
logCmd.Flags().Bool("full-history", false, "Same as the default mode, but does not prune some history.")
3837
logCmd.Flags().BoolP("help", "h", false, "Show help.")
3938
logCmd.Flags().Bool("log-size", false, "Include a line “log size <number>” in the output for each commit.")
4039
logCmd.Flags().Bool("mailmap", false, "Use mailmap file to map author and committer names and email addresses to canonical real names and email addresses.")
4140
logCmd.Flags().Bool("no-decorate", false, "Print out the ref names of any commits that are shown.")
4241
logCmd.Flags().Bool("no-diff-merges", false, "Specify diff format to be used for merge commits.")
43-
logCmd.Flags().Bool("no-follow", false, "Do not continue listing the history of a file beyond renames.")
4442
logCmd.Flags().Bool("no-mailmap", false, "Do not use mailmap file to map author and committer names and email addresses to canonical real names and email addresses.")
4543
logCmd.Flags().Bool("no-notes", false, "Do not show notes.")
4644
logCmd.Flags().Bool("no-relative", false, "When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option.")

0 commit comments

Comments
 (0)