Compare commits
No commits in common. "41ea974e499273df3b27a35db9a2d17f69ce8297" and "0581dbff8652422cd46b50c38ccdde377e236aab" have entirely different histories.
41ea974e49
...
0581dbff86
3 changed files with 15 additions and 46 deletions
|
|
@ -7,8 +7,8 @@
|
||||||
userName = "RingOfStorms (Joshua Bell)";
|
userName = "RingOfStorms (Joshua Bell)";
|
||||||
|
|
||||||
extraConfig = {
|
extraConfig = {
|
||||||
core.pager = "bat";
|
core.pager = "cat";
|
||||||
core.editor = "nano";
|
core.editor = "nvim";
|
||||||
|
|
||||||
pull.rebase = false;
|
pull.rebase = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,48 +76,20 @@ branchdel() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Removing worktree at: $target_wt"
|
echo "Removing worktree at: $target_wt"
|
||||||
# helper: attempt a guarded, forceful removal of a directory
|
if git -C "$repo_dir" worktree remove "$target_wt" 2>/dev/null; then
|
||||||
remove_dir_forcefully() {
|
rm -rf -- "$target_wt" 2>/dev/null || true
|
||||||
local dir="$1"
|
|
||||||
if [ -z "$dir" ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# resolve absolute paths
|
|
||||||
local abs_dir abs_repo
|
|
||||||
abs_dir=$(readlink -f -- "$dir" 2>/dev/null) || abs_dir="$dir"
|
|
||||||
abs_repo=$(readlink -f -- "$repo_dir" 2>/dev/null) || abs_repo="$repo_dir"
|
|
||||||
|
|
||||||
# safety checks: do not remove repository root or /
|
|
||||||
if [ "$abs_dir" = "/" ] || [ "$abs_dir" = "$abs_repo" ]; then
|
|
||||||
echo "Refusing to remove unsafe path: $abs_dir" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# try plain rm -rf
|
|
||||||
rm -rf -- "$abs_dir" 2>/dev/null && return 0
|
|
||||||
|
|
||||||
# fix permissions then try again
|
|
||||||
chmod -R u+rwx "$abs_dir" 2>/dev/null || true
|
|
||||||
rm -rf -- "$abs_dir" 2>/dev/null && return 0
|
|
||||||
|
|
||||||
# try removing contents first, then remove directory
|
|
||||||
if find "$abs_dir" -mindepth 1 -exec rm -rf -- {} + 2>/dev/null; then
|
|
||||||
rmdir "$abs_dir" 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# final existence check
|
|
||||||
[ ! -e "$abs_dir" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
# try unregistering the worktree, prefer normal then fallback to --force
|
|
||||||
if git -C "$repo_dir" worktree remove "$target_wt" 2>/dev/null || git -C "$repo_dir" worktree remove --force "$target_wt" 2>/dev/null; then
|
|
||||||
if remove_dir_forcefully "$target_wt"; then
|
|
||||||
echo "Removed worktree: $target_wt"
|
echo "Removed worktree: $target_wt"
|
||||||
else
|
# delete local branch if it exists
|
||||||
echo "Worktree removed from git, but failed to fully delete directory: $target_wt" >&2
|
if git -C "$repo_dir" show-ref --verify --quiet "refs/heads/$branch"; then
|
||||||
echo "Attempted to force-delete; you may need to remove it manually with sudo." >&2
|
git -C "$repo_dir" branch -D "$branch" 2>/dev/null || true
|
||||||
|
echo "Deleted local branch: $branch"
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
# try with --force as a fallback
|
||||||
|
if git -C "$repo_dir" worktree remove --force "$target_wt" 2>/dev/null; then
|
||||||
|
rm -rf -- "$target_wt" 2>/dev/null || true
|
||||||
|
echo "Removed worktree (forced): $target_wt"
|
||||||
# delete local branch if it exists
|
# delete local branch if it exists
|
||||||
if git -C "$repo_dir" show-ref --verify --quiet "refs/heads/$branch"; then
|
if git -C "$repo_dir" show-ref --verify --quiet "refs/heads/$branch"; then
|
||||||
git -C "$repo_dir" branch -D "$branch" 2>/dev/null || true
|
git -C "$repo_dir" branch -D "$branch" 2>/dev/null || true
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,6 @@ with lib;
|
||||||
gcm = "git commit -m";
|
gcm = "git commit -m";
|
||||||
stashes = "git stash list";
|
stashes = "git stash list";
|
||||||
bd = "branch default";
|
bd = "branch default";
|
||||||
li = "link_ignored";
|
|
||||||
bx = "branchdel";
|
|
||||||
b = "branch";
|
|
||||||
|
|
||||||
# ripgrep
|
# ripgrep
|
||||||
rg = "rg --no-ignore";
|
rg = "rg --no-ignore";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue