-
Notifications
You must be signed in to change notification settings - Fork 1
/
git_export
executable file
·58 lines (47 loc) · 1.02 KB
/
git_export
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
#
# Copyright (c) 2008 Daniel Schierbeck
#
# Export the contents of the git index to a specified directory
USAGE="[-f | --force] <destination>"
LONG_USAGE="Export the contents of the git index to the specified directory"
SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
. "`git --exec-path`/git-sh-setup"
force=0
destination=
args=`getopt -o fh -l force,help,he,hel -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$args"
while true ; do
case "$1" in
-f|--force)
force=1
shift
;;
-h|--h|--he|--hel|--help)
usage
shift
;;
--)
shift; break ;;
*)
die "Invalid argument found!"
exit 2;
;;
esac
done
if [ $# -ne 1 ]
then
die "You can only export to a single destination"
exit 1
fi
if [ -e $1 -a $force -ne 1 ]
then
die "$1 already exists. Use --force to overwrite any existing files."
exit 1
fi
destination=$1
cd_to_toplevel
echo "Exporting git repository to ${destination}"
git checkout-index -a --prefix=${destination}/