From 8b2514ac2e790ad22efcc0d7f35580dc579caed4 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Thu, 10 Jan 2013 21:36:46 -0800 Subject: [PATCH] Add xg Signed-off-by: Colin McCabe --- xg | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) create mode 100755 xg diff --git a/xg b/xg new file mode 100755 index 0000000..7edc734 --- /dev/null +++ b/xg @@ -0,0 +1,31 @@ +#!/bin/bash + +die() { + echo $@ + exit 1 +} + +if [ $# -eq 0 ]; then + echo "xg: locate a file in the source tree and display the full git log information." + echo "Usage: xg [filename-substring]" + echo "Example: xg /BlockReader.java" + echo "Example 2: xg test-patch" + echo + exit 1 +fi + +T=/tmp/$$.xg.tmp +trap "rm -rf ${T}; exit" INT TERM EXIT +find . -noleaf -xdev -name '*.java' -o -name '*.h' -o -name '*.c' \ + -o -name '*.cpp' -o -name '*.cxx' -o -name '*.cc' -o -name '*.sh' | \ + grep $@ > "${T}" +LINES=$(wc -l "${T}" | awk '{print $1}') +[ "${LINES}" -lt 1 ] && die "no results" +if [ "${LINES}" -gt 1 ]; then + echo "multiple results: " + cat "${T}" + exit 1 +fi + +F=$(cat "${T}") +git log --follow -p "${F}" -- 1.6.6.rc1.39.g9a42