views:

236

answers:

1

I want my ASP.NET page to shell out and execute git commands. I put the commands in a bat file which works:

REM cd to the git repo folder
cd c:\temp\mygitrepo
"c:\Program Files\Git\Bin\git.exe" show c090dc4b8b1b3512c1b5363c371e21d810d02f54 -- myfile.txt

If I run my .bat file from a cmd prompt, no problem. If I run it using System.Diagnostics.Process.Start, I get this error:
RUNTIME_PREFIX requested, but prefix computation failed. Using static fallback

The error is coming from this git file: http://github.com/git/git/blob/master/exec%5Fcmd.c

I use exactly the same technique to run svn.exe commands, no problem.

EDIT 1: From the thread here I've learned that msysgit installs some files in a location associated with the current user, me, instead of all users. The IIS web server is running under another user account. I tried copying some of the git files that caught my eye, like .gitconfig, to other users (in Documents and Settings). No luck. So, I have switched my focus to getting IIS to impersonate me when it launches the git command.

+3  A: 

Is it actually an error, or is it just notifying you of a fallback? Based on the code linked, it appears that the command should still execute successfully, only using the static PREFIX rather than the RUNTIME_PREFIX.

If the command is indeed failing, you might want to make sure that any required environment variables are available when starting the process from .NET. You might also need to impersonate a different windows identity to run the command with proper permissions (I am assuming that the ASP.NET identity is restricted as much as possible.) The ProcessStartInfo object provides a few ways to configure the process, including the windows identity, the process verb, and environment variables. Make sure you are providing the proper context that your batch file requires before running it.

jrista
Mentally, I quickly dismissed your "Is it actually an error... the command should still execute successfully". But that's was key.My logic captured stdout and stderr. If stderr wasn't blank, my logic assumed that the command failed and only displayed stderr. As you suspected, stdout did contain the output I was expecting despite the error.
Corey Trager
Sometimes it just takes a little out-of-the-box thinking. ;) Glad its working.
jrista