willb (owner)

Revisions

gist: 210416 Download_button fork
public
Public Clone URL: git://gist.github.com/210416.git
Embed All Files: show embed
git-tidy.sh #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
 
# Run git-tidy instead of "git clean" to keep from shooting yourself
# in the foot. Use "-i" to examine each file to be deleted.
 
function noninteractive() {
    git clean -n | grep "Would remove"
 
    echo
 
echo -n "Really delete the preceding files? (yes/no) "
 
    while read input ; do
case "$input" in
yes) git clean ; exit ;;
YES) git clean ; exit ;;
            no) exit;;
            NO) exit;;
esac
echo 'Please enter "yes" or "no"'
echo -n "Really delete the preceding files? (yes/no) "
    done
}
 
function interactive() {
    git clean -n | grep "Would remove" | cut -c14- | tr \\n \\0 | xargs --null --interactive -L 1 rm
}
 
if [ "x$1" = "x-i" ] ; then
interactive
else
noninteractive
fi