2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
6 populate
= # Set to 1 if we shall seed local branches with this
18 echo "Usage: tg [...] remote [--populate] REMOTE" >&2
25 git config
"remote.$name.url" >/dev
/null || die
"unknown remote '$name'"
28 ## Configure the remote
30 git config
--add "remote.$name.fetch" "+refs/top-bases/*:refs/remotes/$name/top-bases/*"
31 git config
--add "remote.$name.push" "+refs/top-bases/*:refs/top-bases/*"
32 git config
--add "remote.$name.push" "+refs/heads/*:refs/heads/*"
34 info
"Remote $name can now follow TopGit topic branches."
35 if [ -z "$populate" ]; then
36 info
"Next, do: git fetch $name"
41 ## Populate local branches
43 info
"Populating local topic branches from remote '$name'..."
46 git for-each-ref
"refs/remotes/$name/top-bases" |
47 while read rev type ref
; do
48 branch
="${ref#refs/remotes/$name/top-bases/}"
49 if git rev-parse
"$branch" >/dev
/null
2>&1; then
50 git rev-parse
"refs/top-bases/$branch" >/dev
/null
2>&1 ||
51 git update-ref
"refs/top-bases/$branch" "$rev"
52 info
"Skipping branch $branch: Already exists"
55 info
"Adding branch $branch..."
56 git update-ref
"refs/top-bases/$branch" "$rev"
57 git update-ref
"refs/heads/$branch" "$(git rev-parse "$name/$branch")"
60 git config
"topgit.remote" "$name"
61 info
"The remote '$name' is now the default source of topic branches."