Last active
October 16, 2019 07:59
-
-
Save tavinus/07de28617aaac3dcd4ad808f208485f8 to your computer and use it in GitHub Desktop.
Use git-diff as diff in OpenWRT / LEDE
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
#!/bin/sh | |
############################################################## | |
# Gustavo Arnosti Neves | |
# | |
# Provides a diff-git shortcut in /usr/bin/diff-git | |
# | |
# Required: GIT | |
# # opkg install git | |
# | |
# You may install diffutils for the simplified diff | |
# # opkg install diffutils | |
# | |
# YOU SHOULD NOT USE /usr/bin/diff AS TARGET! | |
# SINCE THAT IS WHERE diffutils WOULD INSTALL diff | |
# | |
# No man pages on OpenWRT / LEDE so here you go: | |
# https://git-scm.com/docs/git-diff | |
# | |
# Wanted this to diff config files after updates | |
# Using --no-color makes git diff work well for me | |
# Not sure if it is needed everywhere, but both | |
# bash and ash gave me garbage chars without --no-color | |
# | |
# You can just copy-paste the on-liner if you want | |
# | |
# 05 / 2017 - LEDE 17.01.1 | |
# This one-liner just add a shell script named diff-git | |
# to /usr/bin/diff-git and makes it executable. | |
# You may want to change the target path/file | |
# by editing the TGT_DIFF variable. | |
# Example if you want to use git-diff in sbin: | |
# TGT_DIFF='/usr/sbin/git-diff' && \ | |
TGT_DIFF='/usr/bin/diff-git' && \ | |
echo '#!/bin/sh'$'\n''"$(which git)" diff --no-color "$@"'$'\n' > "$TGT_DIFF" && \ | |
chmod 755 "$TGT_DIFF" | |
############################################################## | |
# Example run: | |
# # diff-git /etc/config/luci_statistics /etc/config/luci_statistics-opkg | |
# index 8b3c6af..c081a8e 100644 | |
# --- a/etc/config/luci_statistics | |
# +++ b/etc/config/luci_statistics-opkg | |
# @@ -1,3 +1,4 @@ | |
# +# general settings | |
# | |
# config statistics 'collectd' | |
# option BaseDir '/var/run/collectd' | |
# @@ -13,12 +14,14 @@ config statistics 'rrdtool' | |
# option image_width '600' | |
# option image_path '/tmp/rrdimg' | |
# | |
# +# output plugins | |
# + | |
# config statistics 'collectd_rrdtool' | |
# option enable '1' | |
# ... | |
############################################################## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment