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."
25 echo "The filesystem must support hardlinks."
28 echo " init Synonym for track"
29 echo " list Synonym for tracked"
30 echo " track Start tracking changes to FILE"
31 echo " tracked List tracked files in current directory"
33 echo "See 'zit help git' or 'git help' for git commands."
40 test $ZIT_FILE || abort "Please specify a file"
42 test -f $ZIT_FILE || abort "No such file $ZIT_FILE"
43 test $ZIT_FILE = "`basename $ZIT_FILE`" || abort "Sorry, Zit only works on files in the current directory"
44 ZIT_DIR=".zit.$ZIT_FILE"
49 test -e $ZIT_DIR && abort "$ZIT_DIR exists, is $ZIT_FILE tracked already?"
50 mkdir $ZIT_DIR && echo "Initializing Zit repository in $ZIT_DIR"
51 test -d $ZIT_DIR || abort "Failed to create $ZIT_DIR"
53 git init || abort "Failed to initialize Git repository in $ZIT_DIR"
54 ln ../$ZIT_FILE $ZIT_FILE || abort "Failed to link $ZIT_FILE into $ZIT_DIR"
55 git add $ZIT_FILE || abort "Failed to add $ZIT_FILE"
56 git commit "$@" || abort "Failed to make first commit for $ZIT_FILE"
60 for file in `find -path ./.zit.\*/.git`; do
61 export GIT_DIR="$file"
62 file="${file#./.zit.}"
64 # TODO show actual file status