mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
revert git-ignore but retain argc == 0 as showing .gitignore contents
This commit is contained in:
parent
1f7edd9d24
commit
b7222ed26e
|
|
@ -1,33 +1,10 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
template=""
|
|
||||||
while getopts "t:" opt; do
|
|
||||||
case "$opt" in
|
|
||||||
t) template=$OPTARG;shift;shift;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -z "$template" ]; then
|
|
||||||
gitignoredir="`dirname $0`/../etc/gitignore"
|
|
||||||
available_templates() {
|
|
||||||
find $gitignoredir -type f -name *.gitignore | xargs -i basename {} .gitignore | sort
|
|
||||||
}
|
|
||||||
selected_template() {
|
|
||||||
available_templates | grep $template
|
|
||||||
}
|
|
||||||
count=$(selected_template | wc -w)
|
|
||||||
case "$count" in
|
|
||||||
0) echo "The pattern '$template' does not match any available templates." && available_templates | less && exit 1;;
|
|
||||||
1) find $gitignoredir -name $(selected_template).gitignore -exec cat {} \; >> .gitignore && echo "... added patterns from template '$(selected_template)'";;
|
|
||||||
*) echo "Be more specific. $count matches found:" && selected_template | grep --color $template && exit 2;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $# -eq 0; then
|
if test $# -eq 0; then
|
||||||
test -z $template && test -f .gitignore && cat .gitignore
|
test -f .gitignore && cat .gitignore
|
||||||
else
|
else
|
||||||
for pattern in $@; do
|
for pattern in $@; do
|
||||||
|
echo "... adding '$pattern' to .gitignore"
|
||||||
echo $pattern >> .gitignore
|
echo $pattern >> .gitignore
|
||||||
echo "... added '$pattern'"
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit acbcdb02e5e608cfd1c9a93eba67c6a73d632870
|
|
||||||
Loading…
Reference in a new issue