]> pd.if.org Git - scripts/commitdiff
added program to import a directory setting timestamps
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 11 Mar 2017 09:51:24 +0000 (03:51 -0600)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 11 Mar 2017 09:51:24 +0000 (03:51 -0600)
git-slurp [new file with mode: 0644]

diff --git a/git-slurp b/git-slurp
new file mode 100644 (file)
index 0000000..a21539a
--- /dev/null
+++ b/git-slurp
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# suck in a pile of files, commit based on timestamp,
+# set author
+
+: ${AUTHOR:="Unknown <>"}
+
+base="$1"
+
+test -d "$base/.git" || git init "$base"
+
+cd $base
+
+set -x
+prevts=
+find . -name .git -prune -o -type f -printf '%T@ %P\n' | sort -n | while read ts fn; do
+       if [ -n "$prevts" ] && [ "$prevts" != "$ts" ]; then
+               git commit --date="$prevts" --author="$AUTHOR" -m 'auto commit for import'
+               printf '\n' "$ts"
+       fi
+       git add "$fn"
+       printf '%s\n' "$fn"
+       prevts="$ts"
+done
+
+find . -name .git -prune -o -type f -printf '%T@ %P\n' | sort -n | tail -1 | while read ts fn; do
+       git commit --date="$ts" --author="$AUTHOR" -m 'auto commit for import'
+done