diff options
Diffstat (limited to 'meta/recipes-devtools/guilt/files/guilt-import-commit.patch')
-rw-r--r-- | meta/recipes-devtools/guilt/files/guilt-import-commit.patch | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/meta/recipes-devtools/guilt/files/guilt-import-commit.patch b/meta/recipes-devtools/guilt/files/guilt-import-commit.patch new file mode 100644 index 0000000000..78cc93e5d2 --- /dev/null +++ b/meta/recipes-devtools/guilt/files/guilt-import-commit.patch | |||
@@ -0,0 +1,94 @@ | |||
1 | guilt: import commits via git format-patch | ||
2 | |||
3 | Rather than attempting to process commits directly, it | ||
4 | is preferable to try dumping the change via git format-patch | ||
5 | to take advantage of the proper header/subject/from lines that | ||
6 | are generated. | ||
7 | |||
8 | If patches cannot be exported, fall back to importing | ||
9 | commits via a more custom method. | ||
10 | |||
11 | Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> | ||
12 | |||
13 | --- | ||
14 | guilt-import-commit | 40 +++++++++++++++++++++++++++++----------- | ||
15 | 1 file changed, 29 insertions(+), 11 deletions(-) | ||
16 | |||
17 | --- a/guilt-import-commit | ||
18 | +++ b/guilt-import-commit | ||
19 | @@ -20,46 +20,64 @@ fi | ||
20 | disp "About to begin conversion..." >&2 | ||
21 | disp "Current head: `cat $GIT_DIR/refs/heads/$branch`" >&2 | ||
22 | |||
23 | +# try git-format-patch first, if it fails fall back to internal | ||
24 | +# methods. | ||
25 | +patches=`git-format-patch -o $GUILT_DIR/$branch $rhash` | ||
26 | +if [ -z "$patches" ]; then | ||
27 | + need_custom_patches="1" | ||
28 | +fi | ||
29 | + | ||
30 | for rev in `git rev-list $rhash`; do | ||
31 | + if [ ! -z "$need_custom_patches" ]; then | ||
32 | s=`git log --pretty=oneline -1 $rev | cut -c 42-` | ||
33 | |||
34 | fname=`echo $s | sed -e "s/&/and/g" -e "s/[ :]/_/g" -e "s,[/\\],-,g" \ | ||
35 | - -e "s/['\\[{}]//g" -e 's/]//g' -e 's/\*/-/g' \ | ||
36 | + -e "s/['\\()<>[{}]//g" -e 's/]//g' -e 's/\*/-/g' \ | ||
37 | -e 's/\?/-/g' | tr A-Z a-z` | ||
38 | |||
39 | - disp "Converting `echo $rev | cut -c 1-8` as $fname" | ||
40 | + disp "Converting `echo $rev | cut -c 1-8` as $fname.patch" | ||
41 | |||
42 | mangle_prefix=1 | ||
43 | fname_base=$fname | ||
44 | - while [ -f "$GUILT_DIR/$branch/$fname" ]; do | ||
45 | + while [ -f "$GUILT_DIR/$branch/$fname.patch" ]; do | ||
46 | fname="$fname_base-$mangle_prefix" | ||
47 | mangle_prefix=`expr $mangle_prefix + 1` | ||
48 | - disp "Patch under that name exists...trying '$fname'" | ||
49 | + disp "Patch under that name exists...trying '$fname.patch'" | ||
50 | done | ||
51 | |||
52 | ( | ||
53 | do_make_header $rev | ||
54 | echo "" | ||
55 | git diff --binary $rev^..$rev | ||
56 | - ) > $GUILT_DIR/$branch/$fname | ||
57 | + ) > $GUILT_DIR/$branch/$fname.patch | ||
58 | |||
59 | # FIXME: grab the GIT_AUTHOR_DATE from the commit object and set the | ||
60 | # timestamp on the patch | ||
61 | |||
62 | - # insert the patch name into the series file | ||
63 | - series_insert_patch $fname | ||
64 | + patches="$patches $fname.patch" | ||
65 | + fi | ||
66 | |||
67 | - # Only reset if the commit was on this branch | ||
68 | - if head_check $rev 2> /dev/null; then | ||
69 | + # Only reset if the commit was on this branch | ||
70 | + if head_check $rev 2> /dev/null; then | ||
71 | # BEWARE: "git reset" ahead! Is there a way to verify that | ||
72 | # we really created a patch? - We don't want to lose any | ||
73 | # history. | ||
74 | git reset --hard $rev^ > /dev/null | ||
75 | - elif [ -z "$warned" ]; then | ||
76 | + elif [ -z "$warned" ]; then | ||
77 | disp "Warning: commit $rev is not the HEAD...preserving commit" >&2 | ||
78 | disp "Warning: (this message is displayed only once)" >&2 | ||
79 | warned=t | ||
80 | - fi | ||
81 | + fi | ||
82 | +done | ||
83 | + | ||
84 | +rpatches=`echo "$patches" | sed 's% %\n%g' | tac` | ||
85 | +for patch in $rpatches; do | ||
86 | + | ||
87 | + iname=`echo $patch | sed s%$GUILT_DIR/$branch/%%` | ||
88 | + echo "Inserting $iname" | ||
89 | + | ||
90 | + # insert the patch name into the series file | ||
91 | + series_insert_patch $iname | ||
92 | done | ||
93 | |||
94 | disp "Done." >&2 | ||