On 23. 2. 26 13:41, Daniel Sahlberg wrote:
Den mån 23 feb. 2026 kl 12:02 skrev Johan Corveleyn <[email protected]>:
On Wed, Feb 18, 2026 at 6:17 PM Branko Čibej <[email protected]> wrote:
> On 18. 2. 26 17:49, Daniel Sahlberg wrote:
>> Hi,
>>
>> There was a message on the TortoiseSVN mailing list suggesting
to add cmd.exe based hook script templates to repositories created
on Windows[1].
>>
>> I think it was a great suggestion and I started thinking about
how it should be implemented.
>>
>> We currently create /bin/sh based hook script templates (see
around line 392 in repos.c[2]). sh (bash) is not generally
available on Windows and from what I can tell there would at least
be some path style conversion issues (c:\repositories\xyz\ vs.
/c/repositories/xyz/).
>>
>> I see two options - on Windows:
>> 1. Keeping the existing sh based templates and adding cmd.exe
based templates as well.
>> 2. Creating only cmd.exe based templates.
>>
>> (On other platforms there would be no change in behaviour).
>>
>> I think option 2 makes more sense, but maybe it would be
"non-backwards compatible" if we stop offering the sh templates.
OTOH I don't see how they would have worked anyway.
>>
>> Thoughts?
>
> The only thing that would make sense in a cross-platform kind of
way would be to convert those templates to Python. and use that on
all platforms. Just as we do in our test suite.
Unfortunately Python isn't generally present on Windows either. If one
would go for the lowest common denominator on Windows I think it would
have to be cmd.exe (or perhaps powershell).
Python is at available in Windows Store so it isn't overly complicated
to get going. Maybe a Python rewrite would be nice in the long run?
Would that bring benefits to our *nix users?
Still, I think a BAT file is NEEDED on Windows to start a Python
program. check_hook_cmd seems to look for ".exe", ".cmd", ".bat",
".wsf". If I'm reading the APR sources correctly, a .BAT/.CMD command
is special-cased to run via cmd.exe, otherwise the hook script is
started via CreateProcess which expects an EXECUTABLE file (don't
quite know how it manages .WSF files). So we would need a .BAT
glue-file for both Python and Powershell based scripts.
It's trivial for Python and the difference between a Windows batch file
and an Anynormalsystem Python file is just one line:
C:\Users\brane\src>type pyrun.bat
@echo off & python -x "%~f0" %* & goto :eof
import sys
v = sys.version_info
print(f"Python {v.major}.{v.minor}.{v.micro}")
C:\Users\brane\src>pyrun.bat
Python 3.13.3
-- Brane