#!/usr/bin/env bash # win_tortoisesvn.sh # Usage: # ./win_tortoisesvn.sh commit /path/to/workingcopy "Your commit message" set -euo pipefail if [[ $# -ne 3 ]]; then echo "Usage: $0 commit " >&2 exit 1 fi CMD="$1" WC_LINUX="$2" LOGMSG="$3" if [[ "$CMD" != "commit" ]]; then echo "Error: only the 'commit' command is supported." >&2 exit 1 fi # Validate path if [[ ! -e "$WC_LINUX" ]]; then echo "Error: path '$WC_LINUX' does not exist." >&2 exit 1 fi # Resolve absolute linux path and convert to Windows if command -v readlink >/dev/null 2>&1; then WC_LINUX="$(readlink -f "$WC_LINUX")" fi if ! command -v wslpath >/dev/null 2>&1; then echo "Error: wslpath not found." >&2 exit 1 fi WC_WIN="$(wslpath -w "$WC_LINUX")" # Write commit message to a temporary file and convert its path LOGFILE_LINUX="$(mktemp /tmp/tsvn-commit.XXXXXX.txt)" printf "%s" "$LOGMSG" > "$LOGFILE_LINUX" LOGFILE_WIN="$(wslpath -w "$LOGFILE_LINUX")" # Paths POWERSHELL="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe" TSVN_EXE="C:\\Program Files\\TortoiseSVN\\bin\\TortoiseProc.exe" # Build TortoiseProc arguments: # /command:commit — open Commit dialog # /path:"" — the working copy path # /logmsgfile:"" — prefill commit message (safer than /logmsg for quotes/newlines) # /closeonend:0 — keep dialog; don't auto-close PS_CMD=" Start-Process -FilePath '$TSVN_EXE' -ArgumentList @( '/command:commit', '/path:$WC_WIN', '/logmsgfile:$LOGFILE_WIN', '/closeonend:0' ) " # Launch (non-blocking; remove Start-Process and call directly if you want to block) "$POWERSHELL" -NoProfile -Command "$PS_CMD" # Optional: keep temp file (useful if you want to reuse); otherwise uncomment to auto-clean # rm -f \"$LOGFILE_LINUX\" echo "Opened TortoiseSVN Commit dialog for: $WC_LINUX"