chiark / gitweb /
Merge branch 'tg-import'
authorPetr Baudis <pasky@suse.cz>
Tue, 9 Sep 2008 22:47:15 +0000 (00:47 +0200)
committerPetr Baudis <pasky@suse.cz>
Tue, 9 Sep 2008 22:47:15 +0000 (00:47 +0200)
README
tg-create.sh
tg.sh

diff --git a/README b/README
index 9c6f3352185130cf58f6158ffa96fd5ebbc1960d..f45eb6cca897cda03b64354a9343c8ddb281b484 100644 (file)
--- a/README
+++ b/README
@@ -184,6 +184,24 @@ SYNOPSIS
        tg: Updating base with t/gitweb/nifty-links changes...
        tg: Updating t/whatever against new base...
 
+       ## Clone a TopGit-controlled repository
+       $ git clone URL repo
+       $ cd repo
+       $ tg remote --populate origin
+       ...
+       $ git fetch
+       $ tg update
+
+       ## Add a TopGit remote to a repository and push to it
+       $ git remote add foo URL
+       $ tg remote foo
+       $ git push foo
+
+       ## Update from a non-default TopGit remote
+       $ git fetch foo
+       $ tg -r foo summary
+       $ tg -r foo update
+
 
 USAGE
 -----
@@ -215,6 +233,10 @@ tg create
        it will detect that you are on a topic branch base ref and
        resume the topic branch creation operation.
 
+       In an alternative use case, if '-r BRANCH' is given instead
+       of dependency list, the topic branch is created based on
+       the given remote branch.
+
 tg delete
 ~~~~~~~~~
        Remove a TopGit-controlled topic branch of given name
@@ -374,6 +396,13 @@ tg update
        In case your dependencies are not up-to-date, tg update
        will first recurse into them and update these.
 
+       If a remote branch update brings dependencies on branches
+       not yet instantiated locally, you can either bring in all
+       the new branches from the remote using 'tg remote --populate'
+       or only pick out the missing ones using 'tg create -r'
+       ('tg summary' will point out branches with incomplete
+       dependencies by showing an '!' near to them).
+
        TODO: tg update -a for updating all topic branches
 
 TODO: Some infrastructure for sharing topic branches between
index fee7dff3ee9fdf5d1e29c31282cf73abdc9f7067..6ee3f027d23e797ac80e07c1024b22aaedc461f5 100644 (file)
@@ -7,6 +7,7 @@ deps= # List of dependent branches
 restarted= # Set to 1 if we are picking up in the middle of base setup
 merge= # List of branches to be merged; subset of $deps
 name=
+rname= # Remote branch to base this one on
 
 
 ## Parse options
@@ -14,8 +15,10 @@ name=
 while [ -n "$1" ]; do
        arg="$1"; shift
        case "$arg" in
+       -r)
+               rname="$1"; shift;;
        -*)
-               echo "Usage: tg [...] create NAME [DEPS...]" >&2
+               echo "Usage: tg [...] create NAME [DEPS...|-r RNAME]" >&2
                exit 1;;
        *)
                if [ -z "$name" ]; then
@@ -27,6 +30,20 @@ while [ -n "$1" ]; do
 done
 
 
+## Fast-track creating branches based on remote ones
+
+if [ -n "$rname" ]; then
+       [ -n "$name" ] || die "no branch name given"
+       ! ref_exists "$name" || die "branch '$name' already exists"
+       has_remote "$rname" || die "no branch $rname in remote $base_remote"
+
+       git update-ref "refs/top-bases/$name" "refs/remotes/$base_remote/top-bases/$rname"
+       git update-ref "refs/heads/$name" "refs/remotes/$base_remote/$rname"
+       info "Topic branch $name based on $base_remote : $rname set up."
+       exit 0
+fi
+
+
 ## Auto-guess dependencies
 
 deps="${deps# }"
diff --git a/tg.sh b/tg.sh
index 6c28467d8829f46d370c415d051ff453cf0e646c..084dc5446e0fdf9e7cd5eaa4675ab7e4d1d3c06e 100644 (file)
--- a/tg.sh
+++ b/tg.sh
@@ -77,7 +77,7 @@ measure_branch()
 # Whether B1 is a superset of B2.
 branch_contains()
 {
-       [ -z "$(git rev-list ^"$1" "$2")" ]
+       [ -z "$(git rev-list ^"$1" "$2" --)" ]
 }
 
 # ref_exists REF