I reckon the answers is "it depends".
A short dive into the sources indicates Git on Windows uses
mingw_spawnpe() function to run the program obtained from the
core.askpass configuration variable, and on POSIX platforms, fork() +
exec() are used. While I failed to google the actual code of
mingw_spawnpe(), I'm certain it eventually calls CreateProcess().
Both these facts hint at that the program is executed directly, not via
the shell. This, in turn, means there will be no second round of
shell substitutions performed on its pathname.
Now the problem is that you did not tell us which environment your
`git` command runs in: Windows shell (cmd.exe) and Git Bash (bash.exe)
have different rules for quoting and escaping. I'm not sure about
PowerShell you might be using as I'm not familiar with it.
Another problem could be with slashes (forward vs backward) thought I
think Win32 API should have no problem running a program with forward
slashes (or even a mixture of both) in its pathname.
Anyway, what I'd try to do is to enable tracing before running your
command by making sure it sees the "GIT_TRACE" variable in the
environment, set to something like "1" -- this would print out exactly
how your command looks just before it's attempted to be run, so you
could do some debugging.
To do some guesswork, I'd say if you're using Git Bash, any of the
calls would work:
git -c core.askpass=/c/a/path\ with\ spaces/program ...
git -c core.askpass='/c/a/path with spaces/program' ...
git -c core.askpass="/c/a/path with spaces/program" ...
git -c core.askpass='c:\a\path with spaces\program' ...
git -c "core.askpass=/c/a/path with spaces/program" ...
git -c 'core.askpass=c:\a\path with spaces\program' ...
For Windows shell I'd escape the whole argument to '-c' as presented in
the two last examples above, and note that Windows shell does not treat
a single quote character in any special manner, so
git -c "core.askpass=/c/a/path with spaces/program" ...
git -c "core.askpass=c:/a/path with spaces/program" ...
git -c "core.askpass=c:\a\path with spaces\program" ...