···518518 IS_EXISTING_DIR=false
519519 IS_GIT_REPO=false
520520 HAS_COMMITS=false
521521+522522+ # Check if we're already in a git repo with the same name
523523+ CURRENT_REPO_NAME=""
524524+ if ${pkgs.git}/bin/git rev-parse --is-inside-work-tree &>/dev/null; then
525525+ CURRENT_REPO_NAME=$(basename "$(${pkgs.git}/bin/git rev-parse --show-toplevel)")
526526+ fi
527527+528528+ # If NAME was provided and we're not in a matching git repo, create/enter the directory
529529+ if [[ -n "$NAME" ]] && [[ "$CURRENT_REPO_NAME" != "$NAME" ]]; then
530530+ if [[ -d "$NAME" ]]; then
531531+ cd "$NAME"
532532+ else
533533+ mkdir -p "$NAME"
534534+ cd "$NAME"
535535+ fi
536536+ fi
537537+521538 if ${pkgs.git}/bin/git rev-parse --is-inside-work-tree &>/dev/null; then
522539 IS_GIT_REPO=true
523540 IS_EXISTING_DIR=true
···542559 else
543560 ${pkgs.git}/bin/git init -b "$BRANCH"
544561 IS_GIT_REPO=true
562562+ ${pkgs.gum}/bin/gum style --foreground 35 "✓ Initialized git repository"
545563 fi
546564 fi
547565