You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Daniel Sahlberg <da...@gmail.com> on 2026/02/18 16:49:53 UTC
Hook script templates on Windows
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?
Cheers,
Daniel
[1] https://groups.google.com/g/tortoisesvn/c/ZRMGZlT7ZLA
[2]
https://svn.apache.org/repos/asf/subversion/trunk/subversion/libsvn_repos/repos.c
Re: Hook script templates on Windows
Posted by Branko Čibej <br...@apache.org>.
On 18. 2. 26 18:16, Branko Čibej 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.
Oh, and please don't confuse /bin/sh with /bin/bash. There are many,
many Unix-like systems where those two aren't the same.
-- Brane
Re: Hook script templates on Windows
Posted by Daniel Sahlberg <da...@gmail.com>.
Den tis 24 feb. 2026 kl 02:34 skrev Branko Čibej <br...@apache.org>:
> On 23. 2. 26 13:41, Daniel Sahlberg wrote:
>
> Den mån 23 feb. 2026 kl 12:02 skrev Johan Corveleyn <jc...@gmail.com>:
>
>> On Wed, Feb 18, 2026 at 6:17 PM Branko Čibej <br...@apache.org> 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
>
>
>
Very neat! We could probably refactor the code writing the template to
write a different first line depending on platform.
So we still seems to have three different options:
1. Add cmd.exe/BAT based templates on WIN32.
2. Add cmd.exe/BAT based templates and REMOVE the SH based templates on
WIN32.
3. Replace the SH based templates with PY based ones using Brane's trick
above.
(Option 4. Do nothing is of course always an option as well).
I still think [2] makes the most sense since it is the smallest change.
In the meantime the original poster came back to me say he is interested in
contributing the scripts on dev@. If he does, I intend to add them (and if
he don't, I might convert the scripts myself, since . Unless I hear
otherwise, I will assume lazy consensus and go with option 2.
Cheers,
Daniel
Re: Hook script templates on Windows
Posted by Branko Čibej <br...@apache.org>.
On 23. 2. 26 13:41, Daniel Sahlberg wrote:
> Den mån 23 feb. 2026 kl 12:02 skrev Johan Corveleyn <jc...@gmail.com>:
>
> On Wed, Feb 18, 2026 at 6:17 PM Branko Čibej <br...@apache.org> 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
Re: Hook script templates on Windows
Posted by Daniel Sahlberg <da...@gmail.com>.
Den mån 23 feb. 2026 kl 12:02 skrev Johan Corveleyn <jc...@gmail.com>:
> On Wed, Feb 18, 2026 at 6:17 PM Branko Čibej <br...@apache.org> 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.
Coming back to my original question. Should we, on Windows:
[1] Provide only cmd.exe based (.BAT) hook script templates
[2] Keep the existing SH based templates and add cmd.exe based templates
[3] Don't change anything
I'm leaning towards [1].
Cheers,
Daniel
Re: Hook script templates on Windows
Posted by Johan Corveleyn <jc...@gmail.com>.
On Wed, Feb 18, 2026 at 6:17 PM Branko Čibej <br...@apache.org> 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).
--
Johan
Re: Hook script templates on Windows
Posted by Branko Čibej <br...@apache.org>.
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.
-- Brane