Docs: Include version Guilt version number in page footer
[guilt.git] / guilt-import-commit
blob47f0dc01284d2fcd7177dfcc73c2c24734f87544
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2007
6 USAGE="[<hash> | <since>..[<until>] | ..<until>]"
7 . guilt
9 if [ $# -ne 1 -o -z "$1" ]; then
10 die "You must specify a range of commits"
13 rhash=`munge_hash_range $1`
15 # make sure that there are no unapplied changes
16 if ! must_commit_first; then
17 die "Uncommited changes detected. Refresh first."
20 echo "About to begin conversion..." >&2
21 echo "Current head: `cat $GIT_DIR/refs/heads/$branch`" >&2
23 for rev in `git-rev-list $rhash`; do
24 if ! head_check $rev; then
25 die "aborting..."
28 s=`git-log --pretty=oneline -1 $rev | cut -c 42-`
30 fname=`echo $s | sed -e "s/&/and/g" -e "s/[ :]/_/g" -e "s,[/\\],-,g" \
31 -e "s/['\\[{}]//g" -e 's/]//g' | tr A-Z a-z`
33 echo "Converting `echo $rev | cut -c 1-8` as $fname"
35 if [ -f "$GUILT_DIR/$branch/$fname" ]; then
36 echo "Oy, the file "$fname" already exists, what should we do? What should we do?" >&2
37 die "Aborting..."
41 do_make_header $rev
42 echo ""
43 git-diff $rev^..$rev
44 ) > $GUILT_DIR/$branch/$fname
46 # FIXME: grab the GIT_AUTHOR_DATE from the commit object and set the
47 # timestamp on the patch
49 # insert the patch name into the series file
50 series_insert_patch $fname
52 # BEWARE: git-reset ahead! Is there a way to verify that we really
53 # created a patch? - We don't want to lose any history.
54 git-reset --hard $rev^ > /dev/null
55 done
57 echo "Done." >&2
58 echo "Current head: `cat $GIT_DIR/refs/heads/$branch`" >&2