From: Petr Baudis Date: Thu, 25 Sep 2008 18:06:57 +0000 (+0200) Subject: tg import -s: Import single commit using well-defined name X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=commitdiff_plain;h=995861effbc75374ac47dfd7fd787f01c6366bef tg import -s: Import single commit using well-defined name --- diff --git a/README b/README index 8a68a65..8129f91 100644 --- a/README +++ b/README @@ -423,6 +423,10 @@ tg import and prefixed by t/ by default; use '-p PREFIX' to specify an alternative prefix (even an empty one). + Alternatively, you can use the '-s NAME' parameter to specify + the name of target branch; the command will then take one more + argument describing a single commit to import. + tg update ~~~~~~~~~ Update the current topic branch wrt. changes in the branches diff --git a/tg-import.sh b/tg-import.sh index 799efc9..6f8c8da 100644 --- a/tg-import.sh +++ b/tg-import.sh @@ -5,6 +5,7 @@ # GPLv2 branch_prefix=t/ +single= ranges= @@ -15,8 +16,10 @@ while [ -n "$1" ]; do case "$arg" in -p) branch_prefix="$1"; shift;; + -s) + single="$1"; shift;; -*) - echo "Usage: tg [...] import [-p PREFIX] RANGE..." >&2 + echo "Usage: tg [...] import {[-p PREFIX] RANGE...|-s NAME COMMIT}" >&2 exit 1;; *) ranges="$ranges $arg";; @@ -58,9 +61,9 @@ get_branch_name() process_commit() { commit="$1" - branch_name=$(get_branch_name "$commit") - info "---- Importing $commit to $branch_prefix$branch_name" - tg create "$branch_prefix""$branch_name" + branch_name="$2" + info "---- Importing $commit to $branch_name" + tg create "$branch_name" git cherry-pick --no-commit "$commit" get_commit_msg "$commit" > .topmsg git add -f .topmsg .topdeps @@ -68,6 +71,11 @@ process_commit() info "++++ Importing $commit finished" } +if [ -n "$single" ]; then + process_commit "$ranges" "$single" + exit +fi + # nice arg verification stolen from git-format-patch.sh for revpair in $ranges do @@ -92,7 +100,7 @@ do info "Merged already: $comment" ;; *) - process_commit "$rev" + process_commit "$rev" "$branch_prefix$(get_branch_name "$rev")" ;; esac done