@@ -243,7 +243,6 @@ enum hide_dotfiles_type {
243243 HIDE_DOTFILES_DOTGITONLY
244244};
245245
246- static int core_restrict_inherited_handles = -1 ;
247246static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY ;
248247static char * unset_environment_variables ;
249248
@@ -267,15 +266,6 @@ int mingw_core_config(const char *var, const char *value,
267266 return 0 ;
268267 }
269268
270- if (!strcmp (var , "core.restrictinheritedhandles" )) {
271- if (value && !strcasecmp (value , "auto" ))
272- core_restrict_inherited_handles = -1 ;
273- else
274- core_restrict_inherited_handles =
275- git_config_bool (var , value );
276- return 0 ;
277- }
278-
279269 return 0 ;
280270}
281271
@@ -1763,7 +1753,6 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
17631753 const char * dir ,
17641754 int prepend_cmd , int fhin , int fhout , int fherr )
17651755{
1766- static int restrict_handle_inheritance = -1 ;
17671756 STARTUPINFOEXW si ;
17681757 PROCESS_INFORMATION pi ;
17691758 LPPROC_THREAD_ATTRIBUTE_LIST attr_list = NULL ;
@@ -1783,16 +1772,6 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
17831772 /* Make sure to override previous errors, if any */
17841773 errno = 0 ;
17851774
1786- if (restrict_handle_inheritance < 0 )
1787- restrict_handle_inheritance = core_restrict_inherited_handles ;
1788- /*
1789- * The following code to restrict which handles are inherited seems
1790- * to work properly only on Windows 7 and later, so let's disable it
1791- * on Windows Vista and 2008.
1792- */
1793- if (restrict_handle_inheritance < 0 )
1794- restrict_handle_inheritance = GetVersion () >> 16 >= 7601 ;
1795-
17961775 do_unset_environment_variables ();
17971776
17981777 /* Determine whether or not we are associated to a console */
@@ -1894,7 +1873,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
18941873 wenvblk = make_environment_block (deltaenv );
18951874
18961875 memset (& pi , 0 , sizeof (pi ));
1897- if (restrict_handle_inheritance && stdhandles_count &&
1876+ if (stdhandles_count &&
18981877 (InitializeProcThreadAttributeList (NULL , 1 , 0 , & size ) ||
18991878 GetLastError () == ERROR_INSUFFICIENT_BUFFER ) &&
19001879 (attr_list = (LPPROC_THREAD_ATTRIBUTE_LIST )
@@ -1915,52 +1894,13 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
19151894 & si .StartupInfo , & pi );
19161895
19171896 /*
1918- * On Windows 2008 R2, it seems that specifying certain types of handles
1919- * (such as FILE_TYPE_CHAR or FILE_TYPE_PIPE) will always produce an
1920- * error. Rather than playing finicky and fragile games, let's just try
1921- * to detect this situation and simply try again without restricting any
1922- * handle inheritance. This is still better than failing to create
1923- * processes.
1897+ * On the off-chance that something with the file handle restriction
1898+ * went wrong, silently fall back to trying without it.
19241899 */
1925- if (!ret && restrict_handle_inheritance && stdhandles_count ) {
1900+ if (!ret && stdhandles_count ) {
19261901 DWORD err = GetLastError ();
19271902 struct strbuf buf = STRBUF_INIT ;
19281903
1929- if (err != ERROR_NO_SYSTEM_RESOURCES &&
1930- /*
1931- * On Windows 7 and earlier, handles on pipes and character
1932- * devices are inherited automatically, and cannot be
1933- * specified in the thread handle list. Rather than trying
1934- * to catch each and every corner case (and running the
1935- * chance of *still* forgetting a few), let's just fall
1936- * back to creating the process without trying to limit the
1937- * handle inheritance.
1938- */
1939- !(err == ERROR_INVALID_PARAMETER &&
1940- GetVersion () >> 16 < 9200 ) &&
1941- !getenv ("SUPPRESS_HANDLE_INHERITANCE_WARNING" )) {
1942- DWORD fl = 0 ;
1943- int i ;
1944-
1945- setenv ("SUPPRESS_HANDLE_INHERITANCE_WARNING" , "1" , 1 );
1946-
1947- for (i = 0 ; i < stdhandles_count ; i ++ ) {
1948- HANDLE h = stdhandles [i ];
1949- strbuf_addf (& buf , "handle #%d: %p (type %lx, "
1950- "handle info (%d) %lx\n" , i , h ,
1951- GetFileType (h ),
1952- GetHandleInformation (h , & fl ),
1953- fl );
1954- }
1955- strbuf_addstr (& buf , "\nThis is a bug; please report it "
1956- "at\nhttps://github.com/git-for-windows/"
1957- "git/issues/new\n\n"
1958- "To suppress this warning, please set "
1959- "the environment variable\n\n"
1960- "\tSUPPRESS_HANDLE_INHERITANCE_WARNING=1"
1961- "\n" );
1962- }
1963- restrict_handle_inheritance = 0 ;
19641904 flags &= ~EXTENDED_STARTUPINFO_PRESENT ;
19651905 ret = CreateProcessW (* wcmd ? wcmd : NULL , wargs , NULL , NULL ,
19661906 TRUE, flags , wenvblk , dir ? wdir : NULL ,
0 commit comments