From 9b787421e7c641b6a635707e5e9b80e58aca7fed Mon Sep 17 00:00:00 2001 From: Todd Wolfson Date: Sun, 15 Sep 2013 14:40:35 -0700 Subject: [PATCH] Added multi-delete for git-delete-branch and git-delete-tag Correcting typos Compiled latest documentation Applying changes from delete-tag to delete-branch for consistency Removed unnecessary string quotes (thanks `git` ref design) and everything works Tags are not being found with string concatenation Updated delete-tag to accept multiple tags Corrections for delete-branch Updating docs for delete-tag Added 'Todd Wolfson' to AUTHORS Updated documentation for delete-branch Moved deletions to concatenate strings and delete in one fell swoop Reworking delete-branch to delete multiple branches in series --- AUTHORS | 3 ++- bin/git-delete-branch | 23 ++++++++++++++++++----- bin/git-delete-tag | 19 +++++++++++++++---- man/git-delete-branch.1 | 13 +++++++------ man/git-delete-branch.html | 13 ++++++++----- man/git-delete-branch.md | 2 ++ man/git-delete-tag.1 | 11 ++++++----- man/git-delete-tag.html | 10 ++++++---- man/git-delete-tag.md | 4 +++- 9 files changed, 67 insertions(+), 31 deletions(-) diff --git a/AUTHORS b/AUTHORS index edc6128..2300015 100644 --- a/AUTHORS +++ b/AUTHORS @@ -21,4 +21,5 @@ Patches and Suggestions - Devin Withers - David Baumgold - Leila Muhtasib -- Duane Johnson \ No newline at end of file +- Duane Johnson +- Todd Wolfson \ No newline at end of file diff --git a/bin/git-delete-branch b/bin/git-delete-branch index 1417a65..548fb1b 100755 --- a/bin/git-delete-branch +++ b/bin/git-delete-branch @@ -1,7 +1,20 @@ #!/bin/sh -branch=$1 -test -z $branch && echo "branch required." 1>&2 && exit 1 -git branch -D $branch -git branch -d -r origin/$branch -git push origin :refs/heads/$branch +# Assert there is at least one branch provided +test -z $1 && echo "branch required." 1>&2 && exit 1 + +# Concatenate all branch references +local_branches="" +origin_branches="" +origin_refs="" +for branch in "$@" +do + local_branches=$local_branches" $branch" + origin_branches=$origin_branches" origin/$branch" + origin_refs=$origin_refs" :refs/heads/$branch" +done + +# Delete all branches +git branch -D $local_branches +git branch -d -r $origin_branches +git push origin $origin_refs diff --git a/bin/git-delete-tag b/bin/git-delete-tag index c93a5d0..fa911a0 100755 --- a/bin/git-delete-tag +++ b/bin/git-delete-tag @@ -1,6 +1,17 @@ #!/bin/sh -tagname=$1 -test -z $tagname && echo "tag required." 1>&2 && exit 1 -git tag -d $tagname -git push origin :refs/tags/$tagname +# Assert there is at least one tag provided +test -z $1 && echo "tag required." 1>&2 && exit 1 + +# Concatenate all the tag references +local_tags="" +origin_refs="" +for tagname in "$@" +do + local_tags=$local_tags" $tagname" + origin_refs=$origin_refs" :refs/tags/$tagname" +done + +# Delete all the tags +git tag -d $local_tags +git push origin $origin_refs diff --git a/man/git-delete-branch.1 b/man/git-delete-branch.1 index f5792b2..2e1381b 100644 --- a/man/git-delete-branch.1 +++ b/man/git-delete-branch.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 -.\" https://github.com/rtomayko/ronn/tree/0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-DELETE\-BRANCH" "1" "July 2012" "" "" +.TH "GIT\-DELETE\-BRANCH" "1" "September 2013" "" "" . .SH "NAME" \fBgit\-delete\-branch\fR \- Delete branches @@ -10,19 +10,20 @@ \fBgit\-delete\-branch\fR . .SH "DESCRIPTION" -Deletes local and remote branch named \. +Deletes local and remote branch named \. Note that local deletion fails if the branch is checked out\. . .SH "OPTIONS" . .P -The name of the branch to delete\. +The name of the branch to delete\. If multiple branches are provided, then they will all be deleted\. . .SH "EXAMPLES" . .nf $ git delete\-branch integration +$ git delete\-branch integration bug/1234 . .fi . @@ -30,7 +31,7 @@ $ git delete\-branch integration Written by Tj Holowaychuk <\fItj@vision\-media\.ca\fR> . .SH "REPORTING BUGS" -<\fIhttp://github\.com/visionmedia/git\-extras/issues\fR> +<\fIhttps://github\.com/visionmedia/git\-extras/issues\fR> . .SH "SEE ALSO" -<\fIhttp://github\.com/visionmedia/git\-extras\fR> +<\fIhttps://github\.com/visionmedia/git\-extras\fR> diff --git a/man/git-delete-branch.html b/man/git-delete-branch.html index 557338d..34d15ab 100644 --- a/man/git-delete-branch.html +++ b/man/git-delete-branch.html @@ -2,7 +2,7 @@ - + git-delete-branch(1) - Delete branches