Last active
August 29, 2015 14:03
-
-
Save tokutoku3/9316aeb747291fd5165e to your computer and use it in GitHub Desktop.
gitから差分ファイルリスト作成。引数1つでHEADからの差分(整数orコミットID)、引数二つでコミット間の差分(コミットIDのみ対応)
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/bash | |
diff="" | |
name="" | |
if [ $# -eq 1 ]; then | |
if expr "$1" : '.*[^0-9].*' > /dev/null ; then | |
diff=" HEAD ${1}" | |
name="HEAD ~ ${1}" | |
else | |
diff=" HEAD HEAD~${1}" | |
name="HEAD ~ HEAD~${1} " | |
fi | |
elif [ $# -eq 2 ]; then | |
diff="${1} ${2}" | |
name="${1} ~ ${2}" | |
fi | |
echo -e "\033[0;37mNot staged files :\033[0;31m" | |
git diff --name-only | |
echo -e "\033[0;37m" | |
echo -e "Diff files \033[0;33m${name}\033[0;37m:" | |
if [ "$diff" != "" ]; then | |
list=$(git diff --name-only $diff) | |
echo -e "\033[0;32m$list" | |
else | |
echo "Not exists." | |
fi | |
echo -e "\033[0;37m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment