]> pd.if.org Git - scripts/blob - git-slurp
a21539a545ddc6e16ca29f5d5886f1e3df9303f3
[scripts] / git-slurp
1 #!/bin/sh
2
3 # suck in a pile of files, commit based on timestamp,
4 # set author
5
6 : ${AUTHOR:="Unknown <>"}
7
8 base="$1"
9
10 test -d "$base/.git" || git init "$base"
11
12 cd $base
13
14 set -x
15 prevts=
16 find . -name .git -prune -o -type f -printf '%T@ %P\n' | sort -n | while read ts fn; do
17         if [ -n "$prevts" ] && [ "$prevts" != "$ts" ]; then
18                 git commit --date="$prevts" --author="$AUTHOR" -m 'auto commit for import'
19                 printf '\n' "$ts"
20         fi
21         git add "$fn"
22         printf '%s\n' "$fn"
23         prevts="$ts"
24 done
25
26 find . -name .git -prune -o -type f -printf '%T@ %P\n' | sort -n | tail -1 | while read ts fn; do
27         git commit --date="$ts" --author="$AUTHOR" -m 'auto commit for import'
28 done