Skip to content

Commit f6f6bbb

Browse files
committed
cmd-diff: support git difftool so we can utilize vimdiff
Having vimdiff is a lot more powerful to me because you can manually do a few things in the terminal to massage the files on each side of the diff to give you more information (i.e. narrow in on exactly what diff you are interested in). Let's add a --difftool boolean flag to trigger `git difftool`, which will allow diffs to be displayed using vimdiff. Additionally include vim-enhanced so we have `vimdiff` installed and at our disposal.
1 parent 0119659 commit f6f6bbb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/cmd-diff

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,17 @@ TMP_REPO = 'tmp/repo'
5454

5555
DIFF_CACHE = 'tmp/diff-cache'
5656

57+
USE_DIFFTOOL = False
58+
5759

5860
def main():
5961
args = parse_args()
6062
builds = Builds()
6163

64+
# Modify the USE_DIFFTOOL global based on the --difftool argument
65+
global USE_DIFFTOOL
66+
USE_DIFFTOOL = args.difftool
67+
6268
latest_build = builds.get_latest()
6369

6470
os.makedirs(DIFF_CACHE, exist_ok=True)
@@ -114,6 +120,7 @@ def parse_args():
114120
parser.add_argument("--to", dest='diff_to', help="Second build ID")
115121
parser.add_argument("--gc", action='store_true', help="Delete cached diff content")
116122
parser.add_argument("--arch", dest='arch', help="Architecture of builds")
123+
parser.add_argument("--difftool", action='store_true', help="Use git difftool")
117124

118125
for differ in DIFFERS:
119126
parser.add_argument("--" + differ.name, action='store_true', default=False,
@@ -424,7 +431,10 @@ def diff_cmd_outputs(cmd, path_from, path_to, strategy: DiffCmdOutputStrategy =
424431

425432

426433
def git_diff(arg_from, arg_to):
427-
runcmd(['git', 'diff', '--no-index', arg_from, arg_to], check=False)
434+
subcmd = 'diff'
435+
if USE_DIFFTOOL:
436+
subcmd = 'difftool'
437+
runcmd(['git', subcmd, '--no-index', arg_from, arg_to], check=False)
428438

429439

430440
def cache_dir(dir):

src/deps.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,6 @@ python3-libguestfs
111111

112112
# For generating kubernetes YAML files (e.g Konflux resources)
113113
kustomize
114+
115+
# For vimdiff
116+
vim-enhanced

0 commit comments

Comments
 (0)