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