2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
4 # (c) Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> 2008
17 branch_prefix
="$1"; shift;;
19 echo "Usage: tg [...] import [-p PREFIX] RANGE..." >&2
22 ranges
="$ranges $arg";;
27 ## Make sure our tree is clean
29 git update-index
--ignore-submodules --refresh ||
exit
30 [ -z "$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)" ] ||
31 die
"the index is not clean"
39 git log
-1 --pretty=format
:"From: %an <%ae>%n%n%s%n%n%b" "$commit"
44 # nice sed script from git-format-patch.sh
55 git log
-1 --pretty=format
:"%s" "$commit" |
sed -e "$titleScript"
61 branch_name
=$
(get_branch_name
"$commit")
62 info
"---- Importing $commit to $branch_prefix$branch_name"
63 tg create
"$branch_prefix""$branch_name"
64 git read-tree
-u -m "$commit"
65 get_commit_msg
"$commit" > .topmsg
66 git add
-f .topmsg .topdeps
67 git commit
-C "$commit"
68 info
"++++ Importing $commit finished"
71 # nice arg verification stolen from git-format-patch.sh
72 for revpair
in $ranges
76 rev1
=`expr "z$revpair" : 'z\(.*\)\.\.'`
77 rev2
=`expr "z$revpair" : 'z.*\.\.\(.*\)'`
80 die
"Unknow range spec $revpair"
83 git rev-parse
--verify "$rev1^0" >/dev
/null
2>&1 ||
84 die
"Not a valid rev $rev1 ($revpair)"
85 git rev-parse
--verify "$rev2^0" >/dev
/null
2>&1 ||
86 die
"Not a valid rev $rev2 ($revpair)"
87 git cherry
-v "$rev1" "$rev2" |
88 while read sign
rev comment
92 info
"Merged already: $comment"