Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ install: check
fi; \
tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \
cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \
rm -f $(TEMPFILE); \
fi; \
)
@if [ -z "$(wildcard man/git-*.1)" ]; then \
Expand Down
12 changes: 11 additions & 1 deletion bin/git-delete-squashed-branches
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

set -euo pipefail

proceed=false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be moved out to a separate PR? For matching the argument, would prefer using $1 == @(--proceed|-p) (enabling extglob) or keeping the existing structure and using group commands ({ true && true; }) instead of subshells.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit used to be on the old master branch before it got renamed to main. I based my branch on master because I didn't notice the new main branch, oops! The commit was already merged into main as commit 52897f7, albeit slightly modified. If I can get permission to rebase onto main then I can remove this commit and resolve this problem.

Copy link
Collaborator

@hyperupcall hyperupcall Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely, go ahead

if [[ $# -gt 0 && ("$1" == "--proceed" || "$1" == "-p") ]]; then
proceed=true
shift
fi

if [[ $# -eq 0 ]]; then
targetBranch=$(git rev-parse --abbrev-ref HEAD)
else
Expand All @@ -13,6 +19,10 @@ git for-each-ref refs/heads/ "--format=%(refname:short)" | while read -r branch;
mergeBase=$(git merge-base "$targetBranch" "$branch")

if [[ $(git cherry "$targetBranch" "$(git commit-tree "$(git rev-parse "$branch^{tree}")" -p "$mergeBase" -m _)") == "-"* ]]; then
git branch -D "$branch"
if [[ $proceed == true ]]; then
git branch -D "$branch" || true
else
git branch -D "$branch"
fi
fi
done
7 changes: 6 additions & 1 deletion bin/git-guilt
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,9 @@ do
printf "\033[00m\n"
done

test -n "$DEBUG" && sort -nr "$DEBUG"
rm -f "$MERGED_LOG"

if [[ -n "$DEBUG" ]] ; then
sort -nr "$DEBUG" &&
rm -f "$DEBUG"
fi
5 changes: 4 additions & 1 deletion bin/git-sed
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ case "$all" in
esac

r=$(xargs -r false < /dev/null > /dev/null 2>&1 && echo r)
need_bak=$(sed -i s/hello/world/ "$(git_extra_mktemp)" > /dev/null 2>&1 || echo true)

tmp="$(git_extra_mktemp)"
need_bak=$(sed -i s/hello/world/ "$tmp" > /dev/null 2>&1 || echo true)
rm "$tmp"

if [ "$need_bak" ]; then
command="git grep -lz '$search' $pathspec | xargs -0$r sed -i '' 's$sep$search$sep$replacement$sep$flags'"
Expand Down
10 changes: 8 additions & 2 deletions man/git-delete-squashed-branches.1
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-DELETE\-SQUASHED\-BRANCHES" "1" "May 2021" "" "Git Extras"
.TH "GIT\-DELETE\-SQUASHED\-BRANCHES" "1" "February 2024" "" "Git Extras"
.
.SH "NAME"
\fBgit\-delete\-squashed\-branches\fR \- Delete branches that were squashed
.
.SH "SYNOPSIS"
\fBgit\-delete\-squashed\-branches\fR [<branch\-name>]
\fBgit\-delete\-squashed\-branches\fR [\-\-proceed, \-p] [<branch\-name>]
.
.SH "DESCRIPTION"
Deletes all git branches that have been "squash\-merged" into \fBbranch\-name\fR\.
.
.SH "OPTIONS"
\-\-proceed, \-p
.
.P
Proceed with the next branch even if the current branch cannot be deleted (e\.g\. because it is checked out in a worktree)
.
.P
<branch\-name>
.
.P
Expand Down
10 changes: 7 additions & 3 deletions man/git-delete-squashed-branches.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion man/git-delete-squashed-branches.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ git-delete-squashed-branches(1) -- Delete branches that were squashed

## SYNOPSIS

`git-delete-squashed-branches` [&lt;branch-name&gt;]
`git-delete-squashed-branches` [--proceed, -p] [&lt;branch-name&gt;]

## DESCRIPTION

Deletes all git branches that have been "squash-merged" into `branch-name`.

## OPTIONS

--proceed, -p

Proceed with the next branch even if the current branch cannot be deleted (e.g. because it is checked out in a worktree)

&lt;branch-name&gt;

The target branch were the "squashed-merged" branches were committed to. If no value is given, then the current checked out branch will be used.
Expand Down
Loading