chiark / gitweb /
make tg remote idempotent
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 14 Jan 2009 20:23:51 +0000 (21:23 +0100)
committermartin f. krafft <madduck@debian.org>
Fri, 23 Jan 2009 04:59:26 +0000 (15:59 +1100)
Before this patch each call to tg remote added three config entries
no matter if they already existed.  After some time my .git/config was
crowded.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
tg-remote.sh

index c3e8bd3968b9075963743a39198e9adcb2124140..3a40081b6b32435837c3b597ee4593f38e79de08 100644 (file)
@@ -27,9 +27,9 @@ git config "remote.$name.url" >/dev/null || die "unknown remote '$name'"
 
 ## Configure the remote
 
-git config --add "remote.$name.fetch" "+refs/top-bases/*:refs/remotes/$name/top-bases/*"
-git config --add "remote.$name.push" "+refs/top-bases/*:refs/top-bases/*"
-git config --add "remote.$name.push" "+refs/heads/*:refs/heads/*"
+git config --replace-all "remote.$name.fetch" "+refs/top-bases/*:refs/remotes/$name/top-bases/*" "\\+refs/top-bases/\\*:refs/remotes/$name/top-bases/\\*"
+git config --replace-all "remote.$name.push" "+refs/top-bases/*:refs/top-bases/*" "\\+refs/top-bases/\\*:refs/top-bases/\\*"
+git config --replace-all "remote.$name.push" "+refs/heads/*:refs/heads/*" "\\+refs/heads/\\*:refs/heads/\\*"
 
 info "Remote $name can now follow TopGit topic branches."
 if [ -z "$populate" ]; then