11 USAGE="usage: zit COMMAND FILE [ARGS...]"
23 echo "Set up a git repository under .zit.FILE to track changes for FILE."
24 echo "File must be a regular file and in the current directory."
27 echo " init Synonym for track"
28 echo " list Synonym for tracked"
29 echo " track Start tracking changes to FILE"
30 echo " tracked List tracked files in current directory"
32 echo "See 'zit help git' or 'git help' for git commands."
39 test $ZIT_FILE || abort "Please specify a file"
41 test -f $ZIT_FILE || abort "No such file $ZIT_FILE"
42 test $ZIT_FILE = "`basename $ZIT_FILE`" || abort "Sorry, Zit only works on files in the current directory"
43 export GIT_DIR=".$ZIT_FILE.git"
44 export GIT_WORK_TREE="`pwd`"
49 test -e $GIT_DIR && abort "$GIT_DIR exists, is $ZIT_FILE tracked already?"
50 mkdir $GIT_DIR && echo "Initializing Zit repository in $GIT_DIR"
51 test -d $GIT_DIR || abort "Failed to create $GIT_DIR"
52 git init || abort "Failed to initialize Git repository in $GIT_DIR"
53 echo "*" > $GIT_DIR/info/exclude
54 git add -f $ZIT_FILE || abort "Failed to add $ZIT_FILE"
55 git commit "$@" || abort "Failed to make first commit for $ZIT_FILE"
59 export GIT_WORK_TREE="`pwd`"
60 for file in .*.git; do
61 if ! test -e $file; then
62 echo "(no files tracked by zit)"
65 export GIT_DIR="$file"
68 # TODO show actual file status