Client-side hook doesn't execute

455 views
Skip to first unread message

Hans

unread,
Aug 23, 2012, 3:47:20 AM8/23/12
to us...@tortoisesvn.tigris.org
Hi,

I started playing with client-side hooks. Configured a "start commit" hook, and when it didn't work, I melted it all down to the following: Hook Type= start_commit_hook; Path = D:\trunk; Command Line = C:\Windows\system32\cmd.exe; Wait = true
Show/Hide = show (see attached screenshot).

When I commit D:\trunk (or any of its subdirs), I see a brief flash on the screen, like a command prompt window. I tried adding things like "/K pause" to the command line but it didn't make a change. When I change the file name ("cmd.ex") I see a "file not found" error message (which shows that TortoiseSVN is at least trying to execute the hook).

My TortoiseSNV version is 1.7.8.23174 on Windows 7 32 bit; the most recent version, as of now.

Thank you!

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=3000376

To unsubscribe from this discussion, e-mail: [users-un...@tortoisesvn.tigris.org].
HookScript.png

Simon Large

unread,
Aug 23, 2012, 4:13:31 AM8/23/12
to us...@tortoisesvn.tigris.org
On 23 August 2012 08:47, Hans <hschle...@munich-metrology.com> wrote:
> Hi,
>
> I started playing with client-side hooks. Configured a "start commit" hook, and when it didn't work, I melted it all down to the following: Hook Type= start_commit_hook; Path = D:\trunk; Command Line = C:\Windows\system32\cmd.exe; Wait = true
> Show/Hide = show (see attached screenshot).
>
> When I commit D:\trunk (or any of its subdirs), I see a brief flash on the screen, like a command prompt window. I tried adding things like "/K pause" to the command line but it didn't make a change. When I change the file name ("cmd.ex") I see a "file not found" error message (which shows that TortoiseSVN is at least trying to execute the hook).
>
> My TortoiseSNV version is 1.7.8.23174 on Windows 7 32 bit; the most recent version, as of now.

Cmd.exe is not a hook script, it is just the command interpreter. You
need to provide the path to the actual script, e.g. start-commit.bat,
start-commit.js, start-commit.exe, my-own-hook.cmd, or whatever your
hook is called.

Simon

--
: ___
: oo // \\ "De Chelonian Mobile"
: (_,\/ \_/ \ TortoiseSVN
: \ \_/_\_/> The coolest Interface to (Sub)Version Control
: /_/ \_\ http://tortoisesvn.net

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=3000385

Hans

unread,
Aug 23, 2012, 5:05:00 AM8/23/12
to us...@tortoisesvn.tigris.org
> Cmd.exe is not a hook script, it is just the command interpreter. You
> need to provide the path to the actual script, e.g. start-commit.bat,
> start-commit.js, start-commit.exe, my-own-hook.cmd, or whatever your
> hook is called.

Simon, thanks for the reply. I know that cmd.exe is not a meaningful program in this context, I just wanted to have **something** executed. I had configured the start_commit_script as a *.bat file which only contains the follwing text:

echo %0 %*
pause

...which only showed the flashing command prompt window, so I tried cmd.exe instead.

I believe I found the reason for the problem:
To execute the *.bat hook script, cmd.exe is run, but input and output are redirected (probably, to/from the NUL device), so the pause command, like cmd.exe itself, thinks this is the end of the input, and exits; likewise, the echo command echoes to nowhere, and the command windows remains empty. The command

pause > con < con

in contrast, outputs "press any key", and then waits for a keypress!

I guess this behaviour makes sense for automated scripting, but for testing scripts, it comes as a bit of a surprise...

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=3000395

Simon Large

unread,
Aug 23, 2012, 5:15:29 AM8/23/12
to us...@tortoisesvn.tigris.org
On 23 August 2012 10:05, Hans <hschle...@munich-metrology.com> wrote:
>> Cmd.exe is not a hook script, it is just the command interpreter. You
>> need to provide the path to the actual script, e.g. start-commit.bat,
>> start-commit.js, start-commit.exe, my-own-hook.cmd, or whatever your
>> hook is called.
>
> Simon, thanks for the reply. I know that cmd.exe is not a meaningful program in this context, I just wanted to have **something** executed. I had configured the start_commit_script as a *.bat file which only contains the follwing text:
>
> echo %0 %*
> pause
>
> ...which only showed the flashing command prompt window, so I tried cmd.exe instead.
>
> I believe I found the reason for the problem:
> To execute the *.bat hook script, cmd.exe is run, but input and output are redirected (probably, to/from the NUL device), so the pause command, like cmd.exe itself, thinks this is the end of the input, and exits; likewise, the echo command echoes to nowhere, and the command windows remains empty. The command
>
> pause > con < con
>
> in contrast, outputs "press any key", and then waits for a keypress!
>
> I guess this behaviour makes sense for automated scripting, but for testing scripts, it comes as a bit of a surprise...

Well I never knew that. I have also tried using PAUSE while debugging
a hook script before without success. Thanks for the update, I'll add
a note to the docs.

Simon

--
: ___
: oo // \\ "De Chelonian Mobile"
: (_,\/ \_/ \ TortoiseSVN
: \ \_/_\_/> The coolest Interface to (Sub)Version Control
: /_/ \_\ http://tortoisesvn.net

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=3000404
Reply all
Reply to author
Forward
0 new messages