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