Commit 77734da
Win32: don't copy the environment twice when spawning child processes
When spawning child processes via start_command(), the environment and all
environment entries are copied twice. First by make_augmented_environ /
copy_environ to merge with child_process.env. Then a second time by
make_environment_block to create a sorted environment block string as
required by CreateProcess.
Move the merge logic to make_environment_block so that we only need to copy
the environment once. This changes semantics of the env parameter: it now
expects a delta (such as child_process.env) rather than a full environment.
This is not a problem as the parameter is only used by start_command()
(all other callers previously passed char **environ, and now pass NULL).
The merge logic no longer xstrdup()s the environment strings, so do_putenv
must not free them. Add a parameter to distinguish this from normal putenv.
Remove the now unused make_augmented_environ / free_environ API.
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent df0e998 commit 77734da
3 files changed
+30
-64
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
899 | 899 | | |
900 | 900 | | |
901 | 901 | | |
| 902 | + | |
| 903 | + | |
902 | 904 | | |
903 | 905 | | |
904 | 906 | | |
| |||
907 | 909 | | |
908 | 910 | | |
909 | 911 | | |
910 | | - | |
| 912 | + | |
| 913 | + | |
911 | 914 | | |
912 | | - | |
| 915 | + | |
913 | 916 | | |
914 | 917 | | |
915 | 918 | | |
916 | 919 | | |
917 | 920 | | |
918 | 921 | | |
919 | | - | |
| 922 | + | |
920 | 923 | | |
921 | 924 | | |
922 | | - | |
| 925 | + | |
923 | 926 | | |
924 | | - | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
925 | 936 | | |
926 | 937 | | |
927 | 938 | | |
| |||
944 | 955 | | |
945 | 956 | | |
946 | 957 | | |
947 | | - | |
| 958 | + | |
948 | 959 | | |
949 | 960 | | |
950 | 961 | | |
| |||
1012 | 1023 | | |
1013 | 1024 | | |
1014 | 1025 | | |
1015 | | - | |
1016 | | - | |
| 1026 | + | |
1017 | 1027 | | |
1018 | 1028 | | |
1019 | 1029 | | |
| |||
1051 | 1061 | | |
1052 | 1062 | | |
1053 | 1063 | | |
1054 | | - | |
| 1064 | + | |
1055 | 1065 | | |
1056 | 1066 | | |
1057 | | - | |
| 1067 | + | |
1058 | 1068 | | |
1059 | 1069 | | |
1060 | 1070 | | |
| |||
1078 | 1088 | | |
1079 | 1089 | | |
1080 | 1090 | | |
1081 | | - | |
| 1091 | + | |
1082 | 1092 | | |
1083 | 1093 | | |
1084 | 1094 | | |
1085 | 1095 | | |
1086 | 1096 | | |
1087 | 1097 | | |
1088 | | - | |
| 1098 | + | |
1089 | 1099 | | |
1090 | 1100 | | |
1091 | 1101 | | |
| |||
1182 | 1192 | | |
1183 | 1193 | | |
1184 | 1194 | | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
1193 | | - | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
1200 | | - | |
1201 | | - | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
1205 | | - | |
1206 | 1195 | | |
1207 | 1196 | | |
1208 | 1197 | | |
| |||
1218 | 1207 | | |
1219 | 1208 | | |
1220 | 1209 | | |
1221 | | - | |
| 1210 | + | |
1222 | 1211 | | |
1223 | 1212 | | |
1224 | 1213 | | |
| |||
1233 | 1222 | | |
1234 | 1223 | | |
1235 | 1224 | | |
1236 | | - | |
| 1225 | + | |
| 1226 | + | |
1237 | 1227 | | |
1238 | 1228 | | |
1239 | 1229 | | |
| |||
1243 | 1233 | | |
1244 | 1234 | | |
1245 | 1235 | | |
1246 | | - | |
1247 | | - | |
1248 | | - | |
1249 | | - | |
1250 | | - | |
1251 | | - | |
1252 | | - | |
1253 | | - | |
1254 | | - | |
1255 | | - | |
1256 | | - | |
1257 | | - | |
1258 | | - | |
1259 | | - | |
1260 | 1236 | | |
1261 | 1237 | | |
1262 | 1238 | | |
| |||
1272 | 1248 | | |
1273 | 1249 | | |
1274 | 1250 | | |
1275 | | - | |
| 1251 | + | |
1276 | 1252 | | |
1277 | 1253 | | |
1278 | 1254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
| 360 | + | |
| 361 | + | |
366 | 362 | | |
367 | 363 | | |
368 | 364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
457 | | - | |
458 | 457 | | |
459 | 458 | | |
460 | 459 | | |
| |||
479 | 478 | | |
480 | 479 | | |
481 | 480 | | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | 481 | | |
486 | 482 | | |
487 | 483 | | |
488 | 484 | | |
489 | 485 | | |
490 | | - | |
491 | | - | |
| 486 | + | |
| 487 | + | |
492 | 488 | | |
493 | 489 | | |
494 | 490 | | |
495 | 491 | | |
496 | 492 | | |
497 | 493 | | |
498 | | - | |
499 | | - | |
500 | 494 | | |
501 | 495 | | |
502 | 496 | | |
| |||
0 commit comments