From ab8c5324ddaaa152b1d291a861e174d3a63a454b Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Sat, 11 Mar 2017 03:51:24 -0600 Subject: [PATCH] added program to import a directory setting timestamps --- git-slurp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 git-slurp diff --git a/git-slurp b/git-slurp new file mode 100644 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 -- 2.40.0