chiark / gitweb /
tg import -s: Import single commit using well-defined name
authorPetr Baudis <pasky@suse.cz>
Thu, 25 Sep 2008 18:06:57 +0000 (20:06 +0200)
committerPetr Baudis <pasky@suse.cz>
Thu, 25 Sep 2008 18:06:57 +0000 (20:06 +0200)
README
tg-import.sh

diff --git a/README b/README
index 8a68a65..8129f91 100644 (file)
--- 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
index 799efc9..6f8c8da 100644 (file)
@@ -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