-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrapper script to use ktx compare for git diff. (#919)
Those wishing to use this must run, or have run, install-gitconfig.sh so that .gitconfig, which now includes a "ktx-compare" diff command will be included by their repo clone's `.git/config`. They need to have the `ktx` command installed and in $PATH. They need to add the line *.ktx2 binary diff=ktx-compare to their clone's .git/info/attributes. This is not included in the repo's .gitattributes because not everyone will have the ktx command installed. This will not work in a user-global or system-global Git attributes file because those are lower priority than `.gitattributes` so are read first and `.gitattributes` already has an entry for `*.ktx2`, indicating `binary`, which overrides anything from the global files. Will be happy to accept a PR to add a .ps1 equivalent script.
- Loading branch information
1 parent
e8a2e19
commit 8cd4fea
Showing
3 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#! /usr/bin/env bash | ||
# -*- tab-width: 4; -*- | ||
# vi: set sw=2 ts=4: | ||
|
||
# Copyright 2024 The Khronos Group Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Wrapper for git diff to use ktx compare. | ||
|
||
# Per https://git-scm.com/docs/git/2.18.0#Documentation/git.txt-codeGITEXTERNALDIFFcode | ||
# git diff sends 7 arguments: | ||
# path old-file old-hex old-mode new-file new-hex new-mode | ||
|
||
if [ $# -ne 7 ]; then | ||
echo "$0: Git did not provide the expected 7 arguments." | ||
exit 1 | ||
fi | ||
|
||
oldfile=$2 | ||
newfile=$5 | ||
|
||
#echo "oldfile = $oldfile" | ||
#echo "newfile = $newfile" | ||
|
||
ktx compare $oldfile $newfile | ||
# Mask ktx compare's exit code. git diff expects the diff program to exit | ||
# without error even when there are differences. | ||
status=$? | ||
if [ $status -eq 7 ]; then | ||
exit 0 | ||
else | ||
exit $status | ||
fi |