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
21 branch_prefix="$1"; shift;;
25 echo "Usage: tg [...] import [-d BASE_BRANCH] {[-p PREFIX] RANGE...|-s NAME COMMIT}" >&2
28 ranges="$ranges $arg";;
33 ## Make sure our tree is clean
35 git update-index --ignore-submodules --refresh || exit
36 [ -z "$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)" ] ||
37 die "the index is not clean"
45 git log -1 --pretty=format:"From: %an <%ae>%n%n%s%n%n%b" "$commit"
50 # nice sed script from git-format-patch.sh
61 git log -1 --pretty=format:"%s" "$commit" | sed -e "$titleScript"
68 info "---- Importing $commit to $branch_name"
69 tg create "$branch_name" $basedep
71 git cherry-pick --no-commit "$commit"
72 get_commit_msg "$commit" > .topmsg
73 git add -f .topmsg .topdeps
74 git commit -C "$commit"
75 info "++++ Importing $commit finished"
78 if [ -n "$single" ]; then
79 process_commit "$ranges" "$single"
83 # nice arg verification stolen from git-format-patch.sh
84 for revpair in $ranges
88 rev1=`expr "z$revpair" : 'z\(.*\)\.\.'`
89 rev2=`expr "z$revpair" : 'z.*\.\.\(.*\)'`
92 die "Unknow range spec $revpair"
95 git rev-parse --verify "$rev1^0" >/dev/null 2>&1 ||
96 die "Not a valid rev $rev1 ($revpair)"
97 git rev-parse --verify "$rev2^0" >/dev/null 2>&1 ||
98 die "Not a valid rev $rev2 ($revpair)"
99 git cherry -v "$rev1" "$rev2" |
100 while read sign rev comment
104 info "Merged already: $comment"
107 process_commit "$rev" "$branch_prefix$(get_branch_name "$rev")"