Skip to content

Commit 6d5291b

Browse files
committed
Merge branch 'js/azure-pipelines-msvc'
CI updates. * js/azure-pipelines-msvc: ci: also build and test with MS Visual Studio on Azure Pipelines ci: really use shallow clones on Azure Pipelines tests: let --immediate and --write-junit-xml play well together test-tool run-command: learn to run (parts of) the testsuite vcxproj: include more generated files vcxproj: only copy `git-remote-http.exe` once it was built msvc: work around a bug in GetEnvironmentVariable() msvc: handle DEVELOPER=1 msvc: ignore some libraries when linking compat/win32/path-utils.h: add #include guards winansi: use FLEX_ARRAY to avoid compiler warning msvc: avoid using minus operator on unsigned types push: do not pretend to return `int` from `die_push_simple()`
2 parents ccc2899 + 4668931 commit 6d5291b

File tree

14 files changed

+430
-33
lines changed

14 files changed

+430
-33
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3042,6 +3042,10 @@ rpm::
30423042
@false
30433043
.PHONY: rpm
30443044

3045+
ifneq ($(INCLUDE_DLLS_IN_ARTIFACTS),)
3046+
OTHER_PROGRAMS += $(shell echo *.dll t/helper/*.dll)
3047+
endif
3048+
30453049
artifacts-tar:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) \
30463050
GIT-BUILD-OPTIONS $(TEST_PROGRAMS) $(test_bindir_programs) \
30473051
$(MOFILES)

azure-pipelines.yml

Lines changed: 161 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
resources:
2-
- repo: self
3-
fetchDepth: 1
1+
variables:
2+
Agent.Source.Git.ShallowFetchDepth: 1
43

54
jobs:
65
- job: windows_build
@@ -131,6 +130,165 @@ jobs:
131130
PathtoPublish: t/failed-test-artifacts
132131
ArtifactName: failed-test-artifacts
133132

133+
- job: vs_build
134+
displayName: Visual Studio Build
135+
condition: succeeded()
136+
pool: Hosted VS2017
137+
timeoutInMinutes: 240
138+
steps:
139+
- powershell: |
140+
if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
141+
net use s: \\gitfileshare.file.core.windows.net\test-cache "$GITFILESHAREPWD" /user:AZURE\gitfileshare /persistent:no
142+
cmd /c mklink /d "$(Build.SourcesDirectory)\test-cache" S:\
143+
}
144+
displayName: 'Mount test-cache'
145+
env:
146+
GITFILESHAREPWD: $(gitfileshare.pwd)
147+
- powershell: |
148+
$urlbase = "https://dev.azure.com/git-for-windows/git/_apis/build/builds"
149+
$id = ((Invoke-WebRequest -UseBasicParsing "${urlbase}?definitions=22&statusFilter=completed&resultFilter=succeeded&`$top=1").content | ConvertFrom-JSON).value[0].id
150+
$downloadUrl = ((Invoke-WebRequest -UseBasicParsing "${urlbase}/$id/artifacts").content | ConvertFrom-JSON).value[1].resource.downloadUrl
151+
(New-Object Net.WebClient).DownloadFile($downloadUrl,"git-sdk-64-minimal.zip")
152+
Expand-Archive git-sdk-64-minimal.zip -DestinationPath . -Force
153+
Remove-Item git-sdk-64-minimal.zip
154+
155+
# Let Git ignore the SDK and the test-cache
156+
"/git-sdk-64-minimal/`n/test-cache/`n" | Out-File -NoNewLine -Encoding ascii -Append "$(Build.SourcesDirectory)\.git\info\exclude"
157+
displayName: 'Download git-sdk-64-minimal'
158+
- powershell: |
159+
& git-sdk-64-minimal\usr\bin\bash.exe -lc @"
160+
make vcxproj
161+
"@
162+
if (!$?) { exit(1) }
163+
displayName: Generate Visual Studio Solution
164+
env:
165+
HOME: $(Build.SourcesDirectory)
166+
MSYSTEM: MINGW64
167+
DEVELOPER: 1
168+
NO_PERL: 1
169+
GIT_CONFIG_PARAMETERS: "'user.name=CI' 'user.email=ci@git'"
170+
- powershell: |
171+
$urlbase = "https://dev.azure.com/git/git/_apis/build/builds"
172+
$id = ((Invoke-WebRequest -UseBasicParsing "${urlbase}?definitions=9&statusFilter=completed&resultFilter=succeeded&`$top=1").content | ConvertFrom-JSON).value[0].id
173+
$downloadUrl = ((Invoke-WebRequest -UseBasicParsing "${urlbase}/$id/artifacts").content | ConvertFrom-JSON).value[0].resource.downloadUrl
174+
(New-Object Net.WebClient).DownloadFile($downloadUrl, "compat.zip")
175+
Expand-Archive compat.zip -DestinationPath . -Force
176+
Remove-Item compat.zip
177+
displayName: 'Download vcpkg artifacts'
178+
- task: MSBuild@1
179+
inputs:
180+
solution: git.sln
181+
platform: x64
182+
configuration: Release
183+
maximumCpuCount: 4
184+
- powershell: |
185+
& compat\vcbuild\vcpkg_copy_dlls.bat release
186+
if (!$?) { exit(1) }
187+
& git-sdk-64-minimal\usr\bin\bash.exe -lc @"
188+
mkdir -p artifacts &&
189+
eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts | grep ^tar)\"
190+
"@
191+
if (!$?) { exit(1) }
192+
displayName: Bundle artifact tar
193+
env:
194+
HOME: $(Build.SourcesDirectory)
195+
MSYSTEM: MINGW64
196+
DEVELOPER: 1
197+
NO_PERL: 1
198+
MSVC: 1
199+
VCPKG_ROOT: $(Build.SourcesDirectory)\compat\vcbuild\vcpkg
200+
- powershell: |
201+
$tag = (Invoke-WebRequest -UseBasicParsing "https://gitforwindows.org/latest-tag.txt").content
202+
$version = (Invoke-WebRequest -UseBasicParsing "https://gitforwindows.org/latest-version.txt").content
203+
$url = "https://github.com/git-for-windows/git/releases/download/${tag}/PortableGit-${version}-64-bit.7z.exe"
204+
(New-Object Net.WebClient).DownloadFile($url,"PortableGit.exe")
205+
& .\PortableGit.exe -y -oartifacts\PortableGit
206+
# Wait until it is unpacked
207+
while (-not @(Remove-Item -ErrorAction SilentlyContinue PortableGit.exe; $?)) { sleep 1 }
208+
displayName: Download & extract portable Git
209+
- task: PublishPipelineArtifact@0
210+
displayName: 'Publish Pipeline Artifact: MSVC test artifacts'
211+
inputs:
212+
artifactName: 'vs-artifacts'
213+
targetPath: '$(Build.SourcesDirectory)\artifacts'
214+
- powershell: |
215+
if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
216+
cmd /c rmdir "$(Build.SourcesDirectory)\test-cache"
217+
}
218+
displayName: 'Unmount test-cache'
219+
condition: true
220+
env:
221+
GITFILESHAREPWD: $(gitfileshare.pwd)
222+
223+
- job: vs_test
224+
displayName: Visual Studio Test
225+
dependsOn: vs_build
226+
condition: succeeded()
227+
pool: Hosted
228+
timeoutInMinutes: 240
229+
strategy:
230+
parallel: 10
231+
steps:
232+
- powershell: |
233+
if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
234+
net use s: \\gitfileshare.file.core.windows.net\test-cache "$GITFILESHAREPWD" /user:AZURE\gitfileshare /persistent:no
235+
cmd /c mklink /d "$(Build.SourcesDirectory)\test-cache" S:\
236+
}
237+
displayName: 'Mount test-cache'
238+
env:
239+
GITFILESHAREPWD: $(gitfileshare.pwd)
240+
- task: DownloadPipelineArtifact@0
241+
displayName: 'Download Pipeline Artifact: VS test artifacts'
242+
inputs:
243+
artifactName: 'vs-artifacts'
244+
targetPath: '$(Build.SourcesDirectory)'
245+
- powershell: |
246+
& PortableGit\git-cmd.exe --command=usr\bin\bash.exe -lc @"
247+
test -f artifacts.tar.gz || {
248+
echo No test artifacts found\; skipping >&2
249+
exit 0
250+
}
251+
tar xf artifacts.tar.gz || exit 1
252+
253+
# Let Git ignore the SDK and the test-cache
254+
printf '%s\n' /PortableGit/ /test-cache/ >>.git/info/exclude
255+
256+
cd t &&
257+
PATH=\"`$PWD/helper:`$PATH\" &&
258+
test-tool.exe run-command testsuite -V -x --write-junit-xml \
259+
`$(test-tool.exe path-utils slice-tests \
260+
`$SYSTEM_JOBPOSITIONINPHASE `$SYSTEM_TOTALJOBSINPHASE t[0-9]*.sh)
261+
"@
262+
if (!$?) { exit(1) }
263+
displayName: 'Test (parallel)'
264+
env:
265+
HOME: $(Build.SourcesDirectory)
266+
MSYSTEM: MINGW64
267+
NO_SVN_TESTS: 1
268+
GIT_TEST_SKIP_REBASE_P: 1
269+
- powershell: |
270+
if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
271+
cmd /c rmdir "$(Build.SourcesDirectory)\test-cache"
272+
}
273+
displayName: 'Unmount test-cache'
274+
condition: true
275+
env:
276+
GITFILESHAREPWD: $(gitfileshare.pwd)
277+
- task: PublishTestResults@2
278+
displayName: 'Publish Test Results **/TEST-*.xml'
279+
inputs:
280+
mergeTestResults: true
281+
testRunTitle: 'vs'
282+
platform: Windows
283+
publishRunAttachments: false
284+
condition: succeededOrFailed()
285+
- task: PublishBuildArtifacts@1
286+
displayName: 'Publish trash directories of failed tests'
287+
condition: failed()
288+
inputs:
289+
PathtoPublish: t/failed-test-artifacts
290+
ArtifactName: failed-vs-test-artifacts
291+
134292
- job: linux_clang
135293
displayName: linux-clang
136294
condition: succeeded()

builtin/push.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ static int push_url_of_remote(struct remote *remote, const char ***url_p)
143143
return remote->url_nr;
144144
}
145145

146-
static NORETURN int die_push_simple(struct branch *branch,
147-
struct remote *remote)
146+
static NORETURN void die_push_simple(struct branch *branch,
147+
struct remote *remote)
148148
{
149149
/*
150150
* There's no point in using shorten_unambiguous_ref here,

cache.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,19 @@ struct cache_entry *index_file_exists(struct index_state *istate, const char *na
748748
*/
749749
int index_name_pos(const struct index_state *, const char *name, int namelen);
750750

751+
/*
752+
* Some functions return the negative complement of an insert position when a
753+
* precise match was not found but a position was found where the entry would
754+
* need to be inserted. This helper protects that logic from any integer
755+
* underflow.
756+
*/
757+
static inline int index_pos_to_insert_pos(uintmax_t pos)
758+
{
759+
if (pos > INT_MAX)
760+
die("overflow: -1 - %"PRIuMAX, pos);
761+
return -1 - (int)pos;
762+
}
763+
751764
#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */
752765
#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */
753766
#define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */

compat/mingw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,8 @@ char *mingw_getenv(const char *name)
16651665
if (!w_key)
16661666
die("Out of memory, (tried to allocate %u wchar_t's)", len_key);
16671667
xutftowcs(w_key, name, len_key);
1668+
/* GetEnvironmentVariableW() only sets the last error upon failure */
1669+
SetLastError(ERROR_SUCCESS);
16681670
len_value = GetEnvironmentVariableW(w_key, w_value, ARRAY_SIZE(w_value));
16691671
if (!len_value && GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
16701672
free(w_key);

compat/vcbuild/scripts/clink.pl

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,54 @@
6868
} elsif ("$arg" =~ /^-L/ && "$arg" ne "-LTCG") {
6969
$arg =~ s/^-L/-LIBPATH:/;
7070
push(@lflags, $arg);
71-
} elsif ("$arg" =~ /^-R/) {
71+
} elsif ("$arg" =~ /^-[Rl]/) {
7272
# eat
73+
} elsif ("$arg" eq "-Werror") {
74+
push(@cflags, "-WX");
75+
} elsif ("$arg" eq "-Wall") {
76+
# cl.exe understands -Wall, but it is really overzealous
77+
push(@cflags, "-W4");
78+
# disable the "signed/unsigned mismatch" warnings; our source code violates that
79+
push(@cflags, "-wd4018");
80+
push(@cflags, "-wd4245");
81+
push(@cflags, "-wd4389");
82+
# disable the "unreferenced formal parameter" warning; our source code violates that
83+
push(@cflags, "-wd4100");
84+
# disable the "conditional expression is constant" warning; our source code violates that
85+
push(@cflags, "-wd4127");
86+
# disable the "const object should be initialized" warning; these warnings affect only objects that are `static`
87+
push(@cflags, "-wd4132");
88+
# disable the "function/data pointer conversion in expression" warning; our source code violates that
89+
push(@cflags, "-wd4152");
90+
# disable the "non-constant aggregate initializer" warning; our source code violates that
91+
push(@cflags, "-wd4204");
92+
# disable the "cannot be initialized using address of automatic variable" warning; our source code violates that
93+
push(@cflags, "-wd4221");
94+
# disable the "possible loss of data" warnings; our source code violates that
95+
push(@cflags, "-wd4244");
96+
push(@cflags, "-wd4267");
97+
# disable the "array is too small to include a terminating null character" warning; we ab-use strings to initialize OIDs
98+
push(@cflags, "-wd4295");
99+
# disable the "'<<': result of 32-bit shift implicitly converted to 64 bits" warning; our source code violates that
100+
push(@cflags, "-wd4334");
101+
# disable the "declaration hides previous local declaration" warning; our source code violates that
102+
push(@cflags, "-wd4456");
103+
# disable the "declaration hides function parameter" warning; our source code violates that
104+
push(@cflags, "-wd4457");
105+
# disable the "declaration hides global declaration" warning; our source code violates that
106+
push(@cflags, "-wd4459");
107+
# disable the "potentially uninitialized local variable '<name>' used" warning; our source code violates that
108+
push(@cflags, "-wd4701");
109+
# disable the "unreachable code" warning; our source code violates that
110+
push(@cflags, "-wd4702");
111+
# disable the "potentially uninitialized local pointer variable used" warning; our source code violates that
112+
push(@cflags, "-wd4703");
113+
# disable the "assignment within conditional expression" warning; our source code violates that
114+
push(@cflags, "-wd4706");
115+
# disable the "'inet_ntoa': Use inet_ntop() or InetNtop() instead" warning; our source code violates that
116+
push(@cflags, "-wd4996");
117+
} elsif ("$arg" =~ /^-W[a-z]/) {
118+
# let's ignore those
73119
} else {
74120
push(@args, $arg);
75121
}

compat/win32/path-utils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#ifndef WIN32_PATH_UTILS_H
2+
#define WIN32_PATH_UTILS_H
3+
14
#define has_dos_drive_prefix(path) \
25
(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
36
int win32_skip_dos_drive_prefix(char **path);
@@ -18,3 +21,5 @@ static inline char *win32_find_last_dir_sep(const char *path)
1821
#define find_last_dir_sep win32_find_last_dir_sep
1922
int win32_offset_1st_component(const char *path);
2023
#define offset_1st_component win32_offset_1st_component
24+
25+
#endif

compat/winansi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)
546546
typedef struct _OBJECT_NAME_INFORMATION
547547
{
548548
UNICODE_STRING Name;
549-
WCHAR NameBuffer[0];
549+
WCHAR NameBuffer[FLEX_ARRAY];
550550
} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
551551

552552
#define ObjectNameInformation 1

config.mak.uname

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -703,32 +703,35 @@ vcxproj:
703703
perl contrib/buildsystems/generate -g Vcxproj
704704
git add -f git.sln {*,*/lib,t/helper/*}/*.vcxproj
705705

706-
# Generate the LinkOrCopyBuiltins.targets file
706+
# Generate the LinkOrCopyBuiltins.targets and LinkOrCopyRemoteHttp.targets file
707707
(echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \
708708
echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \
709709
for name in $(BUILT_INS);\
710710
do \
711711
echo ' <Copy SourceFiles="$$(OutDir)\git.exe" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
712712
done && \
713+
echo ' </Target>' && \
714+
echo '</Project>') >git/LinkOrCopyBuiltins.targets
715+
(echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \
716+
echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \
713717
for name in $(REMOTE_CURL_ALIASES); \
714718
do \
715719
echo ' <Copy SourceFiles="$$(OutDir)\'"$(REMOTE_CURL_PRIMARY)"'" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
716720
done && \
717721
echo ' </Target>' && \
718-
echo '</Project>') >git/LinkOrCopyBuiltins.targets
719-
git add -f git/LinkOrCopyBuiltins.targets
722+
echo '</Project>') >git-remote-http/LinkOrCopyRemoteHttp.targets
723+
git add -f git/LinkOrCopyBuiltins.targets git-remote-http/LinkOrCopyRemoteHttp.targets
720724

721725
# Add command-list.h
722726
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 command-list.h
723727
git add -f command-list.h
724728

725729
# Add scripts
726730
rm -f perl/perl.mak
727-
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 \
728-
$(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN)
731+
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(SCRIPT_LIB) $(SCRIPTS)
729732
# Strip out the sane tool path, needed only for building
730733
sed -i '/^git_broken_path_fix ".*/d' git-sh-setup
731-
git add -f $(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN)
734+
git add -f $(SCRIPT_LIB) $(SCRIPTS)
732735

733736
# Add Perl module
734737
$(MAKE) $(LIB_PERL_GEN)
@@ -758,6 +761,10 @@ vcxproj:
758761
$(MAKE) -C templates
759762
git add -f templates/boilerplates.made templates/blt/
760763

764+
# Add the translated messages
765+
make MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(MOFILES)
766+
git add -f $(MOFILES)
767+
761768
# Add build options
762769
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 GIT-BUILD-OPTIONS
763770
git add -f GIT-BUILD-OPTIONS

contrib/buildsystems/Generators/Vcxproj.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ EOM
278278
if ($target eq 'git') {
279279
print F " <Import Project=\"LinkOrCopyBuiltins.targets\" />\n";
280280
}
281+
if ($target eq 'git-remote-http') {
282+
print F " <Import Project=\"LinkOrCopyRemoteHttp.targets\" />\n";
283+
}
281284
print F << "EOM";
282285
</Project>
283286
EOM

read-cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
12761276
*/
12771277
if (istate->cache_nr > 0 &&
12781278
strcmp(ce->name, istate->cache[istate->cache_nr - 1]->name) > 0)
1279-
pos = -istate->cache_nr - 1;
1279+
pos = index_pos_to_insert_pos(istate->cache_nr);
12801280
else
12811281
pos = index_name_stage_pos(istate, ce->name, ce_namelen(ce), ce_stage(ce));
12821282

@@ -1915,7 +1915,7 @@ static size_t estimate_cache_size(size_t ondisk_size, unsigned int entries)
19151915
/*
19161916
* Account for potential alignment differences.
19171917
*/
1918-
per_entry += align_padding_size(sizeof(struct cache_entry), -sizeof(struct ondisk_cache_entry));
1918+
per_entry += align_padding_size(per_entry, 0);
19191919
return ondisk_size + entries * per_entry;
19201920
}
19211921

0 commit comments

Comments
 (0)