Compare commits

...

12 Commits

Author SHA1 Message Date
7c184ed11e git🐮 Fix GIT_DIR for submodules via git alias
Git sets some environment variables when executing a shell command.
Specifically it sets GIT_DIR when called inside a submodule. This makes
git inside the subshell target the main worktree instead of the
temporary one.
2025-09-15 14:24:36 +02:00
8e8ef29b37 git🐮 Use %s to print worktree path
Don't pass the worktree path directly into the format string - just to
be safe.
2025-09-15 13:49:34 +02:00
d8859bc709 git🐮 Keep as much relative offset as possible 2025-09-15 13:49:34 +02:00
65d99c40e8 git🐮 Keep relative path offset 2025-09-15 13:49:33 +02:00
d28ef61694 git🐮 Rename temporary worktree directory
Shorten the "worktree" and place the random bytes at the end for better
sorting.
2025-09-15 13:23:01 +02:00
d5a95f9ce5 git🐮 Fix name of submodules
Previously git-checkout-worktree would use the name of the superproject
instead of the submodule for the temporary directory.
2025-09-15 13:19:28 +02:00
723899d70f git: Add empty line before include section
I want the section at the very end and this broke the alphabetic
sorting.
2025-09-12 17:06:01 +02:00
126ccb0c7a git: Fix option capitalization
Semantically this changes nothing, but the name with a capital `S` is
used by git-config(1).
2025-09-12 17:04:49 +02:00
dadf344f2b git: Explicitly set core.whitespace.tabwidth=8 2025-09-12 17:03:53 +02:00
f17cde7943 git: Show all refs as decoration in logs 2025-09-12 16:57:00 +02:00
a89ad407ba git: Make all graph colors bold
This looks a bit better in my opinion.
2025-09-12 16:56:05 +02:00
a26a899213 git: Make all bold colors bright
Make all bold colors (also) bright, since kitty does not render bold
colors in their bright version, but I've gotten used to how this looks.

For the graph I've gotten rid of the boldness and only switched to
bright versions since I think it makes no sense to have different line
weights for the branches (Although I apparently never noticed, so I
can't say that this was misleading in practice).
2025-09-12 16:51:36 +02:00
2 changed files with 63 additions and 6 deletions

View File

@@ -52,6 +52,38 @@
sort = -committerdate
[clone]
filterSubmodules = yes
[color "diff"]
# Make all bold colors also bright. See diff_colors in git's diff.c
oldMoved = bold brightmagenta
oldMovedAlternative = bold brightblue
newMoved = bold brightcyan
newMovedAlternative = bold brightyellow
oldBold = bold brightred
newBold = bold brightgreen
[color "decorate"]
# Make all bold colors also bright. See decoration_colors in git's
# log-tree.c
branch = bold brightgreen
remoteBranch = bold brightred
tag = bold brightyellow
stash = bold brightmagenta
HEAD = bold brightcyan
grafted = bold brightblue
[color "grep"]
# Make all bold colors also bright. See GREP_OPT_INIT in git's grep.h
matchContext = bold brightred
matchSelected = bold brightred
[color "interactive"]
# Make all bold colors also bright. See init_add_i_state in git's
# add-interactive.c
help = bold brightred
prompt = bold brightblue
error = bold brightred
[color "remote"]
# Make all bold colors also bright. See keywords in git's sideband.c
warning = bold brightyellow
success = bold brightgreen
error = bold brightred
[color "status"]
added = 076
untracked = 014
@@ -69,7 +101,7 @@
abbrev = 12
#pager = delta
pager = diff-so-fancy | less --tabs=8 --RAW-CONTROL-CHARS
whitespace = trailing-spaces,space-before-tab,indent-with-non-tab
whitespace = trailing-spaces,space-before-tab,indent-with-non-tab,tabwidth=8
[delta]
navigate = true
commit-decoration-style = bold yellow box
@@ -102,6 +134,12 @@
singleKey = true
[log]
follow = true
# Make all colors bold and additionally use bright versions of
# previously bold-only colors. See column_colors_ansi in git's color.c
# used by graph.c
graphColors = bold red,bold green,bold yellow,bold blue,bold magenta,bold cyan,bold brightred,bold brightgreen,bold brightyellow,bold brightblue,bold brightmagenta,bold brightcyan
# Show all refs as decoration (e.g. also notes)
initialDecorationSet = all
[merge]
conflictstyle = diff3
log = true
@@ -118,7 +156,7 @@
[rerere]
enabled = false
[status]
submodulesummary = true
submoduleSummary = true
[submodule]
fetchJobs = 0
[trailer]
@@ -127,5 +165,6 @@
email = julian@druck.dev
name = Julian Prein
signingkey = C0A44F69F2E29F6586C86B96CA6B3A516FAC2555
[include]
path = user.config

View File

@@ -31,11 +31,13 @@
emulate -L zsh -o err_return -o no_unset
local REPO_NAME WORKTREE_PATH
local git_dir cwd_offset REPO_NAME WORKTREE_PATH
# Use the folder name of the main working tree to make calls from another
# temporary working tree possible
REPO_NAME="${${${$(git rev-parse --git-dir):A}%%/.git*}:t}"
WORKTREE_PATH="$(mktemp -d -p "" "worktree.XXX.$REPO_NAME.${1//\//_}")"
git_dir="${$(git rev-parse --git-dir):A}"
[[ $git_dir == */.git/modules/* ]] || git_dir="${git_dir%%/.git*}"
REPO_NAME="${git_dir:t}"
WORKTREE_PATH="$(mktemp -d -p "" "wtree.$REPO_NAME.${1//\//_}.XXX")"
local errc ret=0
git worktree add "$WORKTREE_PATH" "$@" || ret=$?
@@ -47,11 +49,27 @@ fi
trap '
errc=$?
<&2 printf "Exiting abnormally. Check and possibly remove '$WORKTREE_PATH' manually.\n"
<&2 printf "Exiting abnormally. Check and possibly remove \"%s\" manually.\n" "'$WORKTREE_PATH'"
return $errc
' INT QUIT TERM EXIT
cwd_offset="${${PWD#$(git rev-parse --show-toplevel)}#/}"
pushd -q "$WORKTREE_PATH"
until [[ -d $cwd_offset || -z $cwd_offset ]]; do
cwd_offset="${cwd_offset:h}"
done
[[ -z $cwd_offset ]] || cd "$cwd_offset"
# Discard some environment variables that were set by git when calling this
# script through an alias.
#
# Is set for submodules and will confuse git in the subshell
unset GIT_DIR
# Not sure if this can bring any issues, but better be safe
unset GIT_PREFIX
# TODO: Do we want to unset this too? Could have been set on purpose by the user
# and not git. Maybe only for the subshell via `env`?
#unset GIT_EXEC_PATH
"$SHELL" && errc=$? || errc=$?
(( !errc )) || echo "shell exited with $errc"