chiark / gitweb /
tg-delete.sh: Factor out the emptiness test to tg.sh:branch_empty()
authorPetr Baudis <pasky@suse.cz>
Sun, 3 Aug 2008 02:20:04 +0000 (04:20 +0200)
committerPetr Baudis <pasky@suse.cz>
Sun, 3 Aug 2008 02:20:04 +0000 (04:20 +0200)
tg-delete.sh
tg.sh

index 287c4fa..f0114cc 100644 (file)
@@ -35,7 +35,7 @@ baserev="$(git rev-parse --verify "refs/top-bases/$name" 2>/dev/null)" ||
        die "cannot delete your current branch"
 
 nonempty=
-[ -z "$(git diff-tree "refs/top-bases/$name" "$name" | fgrep -v "      .top")" ] || nonempty=1
+branch_empty "$name" || nonempty=1
 
 [ -z "$nonempty" ] || [ -n "$force" ] || die "branch is non-empty: $name"
 
diff --git a/tg.sh b/tg.sh
index 54b7875..56c5709 100644 (file)
--- a/tg.sh
+++ b/tg.sh
@@ -112,6 +112,12 @@ needs_update()
        } || : # $1 is not tracked by TopGit anymore
 }
 
+# branch_empty NAME
+branch_empty()
+{
+       [ -z "$(git diff-tree "refs/top-bases/$1" "$1" | fgrep -v "     .top")" ]
+}
+
 # switch_to_base NAME [SEED]
 switch_to_base()
 {