summaryrefslogtreecommitdiffstats
path: root/bin/git-export
diff options
context:
space:
mode:
Diffstat (limited to 'bin/git-export')
-rwxr-xr-xbin/git-export27
1 files changed, 21 insertions, 6 deletions
diff --git a/bin/git-export b/bin/git-export
index fc76081..06d832a 100755
--- a/bin/git-export
+++ b/bin/git-export
@@ -18,23 +18,38 @@ set -u
18export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' 18export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin'
19 19
20export_prefix='/home/plugins/exported' 20export_prefix='/home/plugins/exported'
21export_branch='master'
22myself=${0##*/} 21myself=${0##*/}
23 22
24if [ $# -lt 1 ] 23usage()
25then 24{
26 echo >&2 "Usage: $myself <repository> ..." 25 echo >&2 "Usage: $myself [-b <branch>] <repository> ..."
27 exit 2 26 exit 2
28fi 27}
28
29while getopts b: option
30do
31 case $option in
32 b)
33 branch=$OPTARG
34 ;;
35 *)
36 usage
37 ;;
38 esac
39done
40
41shift $((OPTIND - 1))
42test $# -ge 1 || usage
29 43
30for repository in "$@" 44for repository in "$@"
31do 45do
32 export_dir="$export_prefix/${repository##*/}" 46 export_dir="$export_prefix/${repository##*/}"
33 export_dir=${export_dir%.git} 47 export_dir=${export_dir%.git}
48 export_dir="$export_dir${branch:+-$branch}"
34 49
35 cd "$repository" 50 cd "$repository"
36 rm -r -f "$export_dir" 51 rm -r -f "$export_dir"
37 mkdir -p "$export_dir" 52 mkdir -p "$export_dir"
38 git archive "$export_branch" | tar -x -C "$export_dir" -f - 53 git archive "${branch:-master}" | tar -x -C "$export_dir" -f -
39 cd "$OLDPWD" 54 cd "$OLDPWD"
40done 55done