From b95726dd8be0153ddc8841caec7c04078dbd9543 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 7 Nov 2016 13:41:38 +0100 Subject: [PATCH 01/45] squash! msvc: add NuGet scripts for building with VS2015 We need to be very precise when specifying NuGet package versions: while nuget.exe auto-completes a version, say, 1.0.2 to 1.0.2.0, we will want to parse packages.config ourselves, to generate the Visual Studio solution, and there we need the exact version number to be able to generate the exact path to the correct .targets file. --- compat/vcbuild/packages.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/vcbuild/packages.config b/compat/vcbuild/packages.config index 5598c7b7d0bbd7..ee01be5edb1c6c 100644 --- a/compat/vcbuild/packages.config +++ b/compat/vcbuild/packages.config @@ -13,7 +13,7 @@ - + From 4c1e67488b23a832a1d3c57f79b86b2d66c78925 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 8 Nov 2016 16:39:44 +0100 Subject: [PATCH 02/45] Really work around "uninitialized value" warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ever since 457f08a (git-rev-list: add --bisect-vars option., 2007-03-21), Git's source code uses the following trick to fool GCC into *not* warning about uninitialized values: int value = value; We use this trick to silence the "warning: ‘x’ is used uninitialized in this function [-Wuninitialized]" when the variables are not really used uninitialized (but it is hard for the compiler to determine that). This trick works well for GCC, and even Clang seems to appease that workaround. Not so Visual C. It does realize that this is just a trick to fool it, and it simply refuses to be fooled. The only way to silence the warning for Visual C would be to write something like this: #pragma warning(suppress: 4700) int value; Obviously this is not portable, and neither is that trick that fools GCC. So let's just introduce a new macro that continues to fool GCC, but simply initializes the values everywhere else. Signed-off-by: Johannes Schindelin --- builtin/rev-list.c | 3 ++- fast-import.c | 4 ++-- git-compat-util.h | 17 +++++++++++++++++ merge-recursive.c | 2 +- read-cache.c | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/builtin/rev-list.c b/builtin/rev-list.c index c43decda70112a..487b76b5ad30ed 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -388,7 +388,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) mark_edges_uninteresting(&revs, show_edge); if (bisect_list) { - int reaches = reaches, all = all; + FAKE_INIT(int, reaches, 0); + FAKE_INIT(int, all, 0); revs.commits = find_bisection(revs.commits, &reaches, &all, bisect_find_all); diff --git a/fast-import.c b/fast-import.c index cb545d7df514b7..145930aabdfd2a 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2992,7 +2992,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20]) static void parse_get_mark(const char *p) { - struct object_entry *oe = oe; + FAKE_INIT(struct object_entry *, oe, NULL); char output[42]; /* get-mark SP LF */ @@ -3009,7 +3009,7 @@ static void parse_get_mark(const char *p) static void parse_cat_blob(const char *p) { - struct object_entry *oe = oe; + FAKE_INIT(struct object_entry *, oe, NULL); unsigned char sha1[20]; /* cat-blob SP LF */ diff --git a/git-compat-util.h b/git-compat-util.h index 65954b35ee21b0..fc0ac89980def9 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -51,6 +51,23 @@ #endif #endif +/* + * Under certain circumstances Git's source code is cleverer than the C + * compiler when the latter warns about some "uninitialized value", e.g. when + * a value is both initialized and used under the same condition. + * + * GCC can be fooled to not spit out this warning by using the construct: + * "int value = value;". Other C compilers are not that easily fooled and would + * require a #pragma (which is not portable, and would litter the source code). + * + * To keep things simple, we only fool GCC, and initialize such values instead + * when compiling with other C compilers. + */ +#ifdef __GNUC__ +#define FAKE_INIT(a, b, c) a b = b +#else +#define FAKE_INIT(a, b, c) a b = c +#endif /* * BUILD_ASSERT_OR_ZERO - assert a build-time dependency, as an expression. diff --git a/merge-recursive.c b/merge-recursive.c index 9041c2f149c011..83900db2ca5ec4 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1999,7 +1999,7 @@ int merge_recursive(struct merge_options *o, { struct commit_list *iter; struct commit *merged_common_ancestors; - struct tree *mrtree = mrtree; + FAKE_INIT(struct tree *, mrtree, NULL); int clean; if (show(o, 4)) { diff --git a/read-cache.c b/read-cache.c index 7fbe993dd7cf0b..5e2a06a43b0ff0 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1907,7 +1907,7 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce, { int size; struct ondisk_cache_entry *ondisk; - int saved_namelen = saved_namelen; /* compiler workaround */ + FAKE_INIT(int, saved_namelen, 0); char *name; int result; From 5036e9f3d708293f628edd168703d6e2a57af191 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 15:59:04 +0100 Subject: [PATCH 03/45] perl/Makefile: treat a missing PM.stamp as if empty 'make clean', or a 'git clean -dfx' will delete the PM stamp file, so it cannot be a direct target in such clean conditions, resulting in an error. Normally the PM.stamp is recreated by the git/Makefile, except when a dry-run is requested, for example, as used in the msysgit msvc-build script which implements the compat/vcbuild/README using contrib/buildsystems. The script msvc-build is introduced later in this series. Protect the PM.stamp target when the PM.stamp file does not exist, allowing a Git 'Makefile -n' to succeed on a clean repo. Signed-off-by: Philip Oakley --- This is development of the original "[PATCH 4/17] Makefile: a dry-run can error out if no perl. Document the issue" 2015-06-25, (http://marc.info/?l=git&m=143519054716960&w=2), which simply documented the issue and then used NO_PERL to avoid the problem. See follow on email thread for some discussion. --- perl/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/perl/Makefile b/perl/Makefile index 15d96fcc7a5a81..5b86aac41cc5bd 100644 --- a/perl/Makefile +++ b/perl/Makefile @@ -22,7 +22,9 @@ clean: $(RM) $(makfile).old $(RM) PM.stamp +ifneq (,$(wildcard PM.stamp)) $(makfile): PM.stamp +endif ifdef NO_PERL_MAKEMAKER instdir_SQ = $(subst ','\'',$(prefix)/lib) From 18ff3df3de91f85b29d3a61ec56d311930dbd089 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Fri, 6 May 2016 11:46:05 +0100 Subject: [PATCH 04/45] Avoid multiple PREFIX definitions The short and sweet PREFIX can be confused when used in many places. Rename both usages to better describe their purpose. EXEC_CMD_PREFIX is used in full to disambiguate it from the nearby GIT_EXEC_PATH. The PREFIX in sideband.c, while nominally independant of the exec_cmd PREFIX, does reside within libgit[1], so the definitions would clash when taken together with a PREFIX given on the command line for use by exec_cmd.c. Noticed when compiling Git for Windows using MSVC/Visual Studio [1] which reports the conflict beteeen the command line definition and the definition in sideband.c within the libgit project. [1] the libgit functions are brought into a single sub-project within the Visual Studio construction script provided in contrib, and hence uses a single command for both exec_cmd.c and sideband.c. Signed-off-by: Philip Oakley --- Makefile | 2 +- exec_cmd.c | 4 ++-- sideband.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 2a80656cc20355..37ed194d161e1b 100644 --- a/Makefile +++ b/Makefile @@ -2021,7 +2021,7 @@ exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \ '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \ '-DBINDIR="$(bindir_relative_SQ)"' \ - '-DPREFIX="$(prefix_SQ)"' + '-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"' builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \ diff --git a/exec_cmd.c b/exec_cmd.c index 9d5703a157fe8e..7f1d687c2de75d 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -12,7 +12,7 @@ char *system_path(const char *path) #ifdef RUNTIME_PREFIX static const char *prefix; #else - static const char *prefix = PREFIX; + static const char *prefix = FALLBACK_RUNTIME_PREFIX; #endif struct strbuf d = STRBUF_INIT; @@ -27,7 +27,7 @@ char *system_path(const char *path) !(prefix = strip_path_suffix(argv0_path, GIT_EXEC_PATH)) && !(prefix = strip_path_suffix(argv0_path, BINDIR)) && !(prefix = strip_path_suffix(argv0_path, "git"))) { - prefix = PREFIX; + prefix = FALLBACK_RUNTIME_PREFIX; trace_printf("RUNTIME_PREFIX requested, " "but prefix computation failed. " "Using static fallback '%s'.\n", prefix); diff --git a/sideband.c b/sideband.c index 1e4d684d6c5dcd..82dda5fa155022 100644 --- a/sideband.c +++ b/sideband.c @@ -13,7 +13,7 @@ * the remote died unexpectedly. A flush() concludes the stream. */ -#define PREFIX "remote: " +#define DISPLAY_PREFIX "remote: " #define ANSI_SUFFIX "\033[K" #define DUMB_SUFFIX " " @@ -50,7 +50,7 @@ int recv_sideband(const char *me, int in_stream, int out) switch (band) { case 3: strbuf_addf(&outbuf, "%s%s%s", outbuf.len ? "\n" : "", - PREFIX, buf + 1); + DISPLAY_PREFIX, buf + 1); retval = SIDEBAND_REMOTE_ERROR; break; case 2: @@ -68,7 +68,7 @@ int recv_sideband(const char *me, int in_stream, int out) int linelen = brk - b; if (!outbuf.len) - strbuf_addstr(&outbuf, PREFIX); + strbuf_addstr(&outbuf, DISPLAY_PREFIX); if (linelen > 0) { strbuf_addf(&outbuf, "%.*s%s%c", linelen, b, suffix, *brk); @@ -82,8 +82,8 @@ int recv_sideband(const char *me, int in_stream, int out) } if (*b) - strbuf_addf(&outbuf, "%s%s", - outbuf.len ? "" : PREFIX, b); + strbuf_addf(&outbuf, "%s%s", outbuf.len ? + "" : DISPLAY_PREFIX, b); break; case 1: write_or_die(out, buf + 1, len); From 4e02fbfe3c9481b82fd03bef08765b92cea0fe06 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 27 Oct 2016 06:25:56 -0700 Subject: [PATCH 05/45] obstack: fix compiler warning MS Visual C suggests that the construct condition ? (int) i : (ptrdiff_t) d is incorrect. Let's fix this by casting to ptrdiff_t also for the positive arm of the conditional. Signed-off-by: Johannes Schindelin --- compat/obstack.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/obstack.h b/compat/obstack.h index ceb4bdbcdd6ed5..892dc28828170b 100644 --- a/compat/obstack.h +++ b/compat/obstack.h @@ -493,7 +493,7 @@ __extension__ \ ( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \ ((((h)->temp.tempint > 0 \ && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \ - ? (int) ((h)->next_free = (h)->object_base \ + ? (ptrdiff_t) ((h)->next_free = (h)->object_base \ = (h)->temp.tempint + (char *) (h)->chunk) \ : (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0))) From b076bbce02c24fc5b2195c03a21bd6da0a68722a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 27 Oct 2016 08:06:29 -0700 Subject: [PATCH 06/45] terminal.c: guard the inclusion of inttypes.h We do have a lovely Makefile option to state that that header file is not available. Let's use it everywhere... Signed-off-by: Johannes Schindelin --- compat/terminal.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat/terminal.c b/compat/terminal.c index 1d37f0aafbaeb7..d9d3945afa391f 100644 --- a/compat/terminal.c +++ b/compat/terminal.c @@ -1,4 +1,6 @@ +#ifndef NO_INTTYPES_H #include +#endif #include "git-compat-util.h" #include "run-command.h" #include "compat/terminal.h" From 9b11a113e4c37d1afa43ef09bec8ff8e0662f2f4 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 25 Nov 2016 18:29:51 +0100 Subject: [PATCH 07/45] Ensure that bin-wrappers/* targets adds `.exe` if necessary When compiling with Visual Studio, the projects' names are identical to the executables modulo the extensions. Which means that the bin-wrappers *need* to target the .exe files lest they try to execute directories. Signed-off-by: Johannes Schindelin --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 37ed194d161e1b..86cb8d8bbdb373 100644 --- a/Makefile +++ b/Makefile @@ -2269,7 +2269,7 @@ bin-wrappers/%: wrap-for-bin.sh @mkdir -p bin-wrappers $(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ -e 's|@@BUILD_DIR@@|$(shell pwd)|' \ - -e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))|' < $< > $@ && \ + -e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%$(X),$(@F))$(patsubst git%,$(X),$(filter $(@F),$(BINDIR_PROGRAMS_NEED_X)))|' < $< > $@ && \ chmod +x $@ # GNU make supports exporting all variables by "export" without parameters. From d22f699b85ce6639aacbd445f83a8cd5200070b8 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 15:37:01 +0100 Subject: [PATCH 08/45] .gitattributes: fix end-of-lines The test suite does actually not pass when files are checked out with CR/LF line endings, so we have to force them to LF-only. For good measure, we simply force all source files to LF, also to make it easier for Git for Windows contributors to contribute to upstream Git's source code. Signed-off-by: Johannes Schindelin --- .gitattributes | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 320e33c327c6f5..9b742a03a1dc84 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ * whitespace=!indent,trail,space -*.[ch] whitespace=indent,trail,space diff=cpp -*.sh whitespace=indent,trail,space +*.[ch] whitespace=indent,trail,space diff=cpp eol=lf +*.sh whitespace=indent,trail,space eol=lf +*.{perl,pm,txt} eol=lf From 62c784e79c83cfcf9c52a23a4d4b9a6bdbbbb666 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 23:07:18 +0100 Subject: [PATCH 09/45] windows: clarify the need for invalidcontinue.obj Git's source code wants to be able to close() the same file descriptor multiple times, ignoring the error returned by the second call (and the ones after that), or to access the osfhandle of an already-closed stdout, among other things that the UCRT does not like. Simply linking invalidcontinue.obj allows such usage without resorting to Debug Assertions (or exiting with exit code 9 in Release Mode). Let's add a note so we don't forget, as suggested by Jeff Hostetler. See https://msdn.microsoft.com/en-us/library/ms235330.aspx for more details. Signed-off-by: Johannes Schindelin --- config.mak.uname | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config.mak.uname b/config.mak.uname index ad72d95c031df9..975b1c0f2f7e1e 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -395,6 +395,9 @@ ifeq ($(uname_S),Windows) compat/win32/dirent.o compat/win32/fscache.o COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\" BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE + # invalidcontinue.obj allows Git's source code to close the same file + # handle twice, or to access the osfhandle of an already-closed stdout + # See https://msdn.microsoft.com/en-us/library/ms235330.aspx EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib PTHREAD_LIBS = lib = From ea6a9e8179d7ff64b091fd5ca6e5001df93138c3 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 30 Nov 2016 11:55:14 +0100 Subject: [PATCH 10/45] mailinfo: remove misguided assert() statement The idea of this assert() statement was to test, in debug mode, that the check_header() function actually finds anything. However, enclosing the call to that function in an assert() makes it fair game for smart compilers *to skip the call in release mode*. Which is not at all what we want here. Remember: just because it works with GCC does not mean that it is correct. Signed-off-by: Johannes Schindelin --- mailinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mailinfo.c b/mailinfo.c index 2fb3877ee44e9c..eb14244ba6cdc6 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -710,7 +710,7 @@ static void flush_inbody_header_accum(struct mailinfo *mi) { if (!mi->inbody_header_accum.len) return; - assert(check_header(mi, &mi->inbody_header_accum, mi->s_hdr_data, 0)); + check_header(mi, &mi->inbody_header_accum, mi->s_hdr_data, 0); strbuf_reset(&mi->inbody_header_accum); } From 084c87f3c4bc759030ee7cd0ccd2e00c9c6353e4 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 30 Nov 2016 12:00:59 +0100 Subject: [PATCH 11/45] t5505,t5516: create .git/branches/ when needed It is a real old anachronism from the Cogito days to have a .git/branches/ directory. And to have tests that ensure that Cogito users can migrate away from using that directory. But so be it, let's continue testing it. Let's make sure, however, that git init does not need to create that directory. This bug was noticed when testing with templates that had been pre-committed, skipping the empty branches/ directory of course because Git does not track empty directories. Signed-off-by: Johannes Schindelin --- t/t5505-remote.sh | 2 ++ t/t5516-fetch-push.sh | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 8198d8eb05c536..b2a7d586002e7e 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -804,6 +804,7 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' ' ( cd six && git remote rm origin && + mkdir -p .git/branches && echo "$origin_url" >.git/branches/origin && git remote rename origin origin && test_path_is_missing .git/branches/origin && @@ -818,6 +819,7 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)' ( cd seven && git remote rm origin && + mkdir -p .git/branches && echo "quux#foom" > .git/branches/origin && git remote rename origin origin && test_path_is_missing .git/branches/origin && diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 26b2cafc4795ba..de5747a39a414c 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -866,6 +866,7 @@ test_expect_success 'fetch with branches' ' mk_empty testrepo && git branch second $the_first_commit && git checkout second && + mkdir -p testrepo/.git/branches && echo ".." > testrepo/.git/branches/branch1 && ( cd testrepo && @@ -879,6 +880,7 @@ test_expect_success 'fetch with branches' ' test_expect_success 'fetch with branches containing #' ' mk_empty testrepo && + mkdir -p testrepo/.git/branches && echo "..#second" > testrepo/.git/branches/branch2 && ( cd testrepo && @@ -893,6 +895,7 @@ test_expect_success 'fetch with branches containing #' ' test_expect_success 'push with branches' ' mk_empty testrepo && git checkout second && + mkdir -p .git/branches && echo "testrepo" > .git/branches/branch1 && git push branch1 && ( @@ -905,6 +908,7 @@ test_expect_success 'push with branches' ' test_expect_success 'push with branches containing #' ' mk_empty testrepo && + mkdir -p .git/branches && echo "testrepo#branch3" > .git/branches/branch2 && git push branch2 && ( From 519d2f40439772a045f50a75f304e875f7a43b40 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 16:02:40 +0100 Subject: [PATCH 12/45] .gitignore: improve MSVC ignore patterns Add the Microsoft .manifest pattern, and correct the generic 'Debug' and 'Release' directory patterns which were mechanically adjusted way back in c591d5f (gitignore: root most patterns at the top-level directory, 2009-10-26) to allow multi-level projects within the Git suite. Signed-off-by: Philip Oakley --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e3b61dd736ef1d..b69d7967b5ca74 100644 --- a/.gitignore +++ b/.gitignore @@ -221,8 +221,9 @@ *.pdb *.ilk .vs/ -/Debug/ -/Release/ +*.manifest +Debug/ +Release/ /.vagrant/ /vagrant2[0-9][0-9][0-9]*-*-* /d2[0-9][0-9][0-9]*-*-* From 4dc105d263d5c49955f5342cc8756216255a471b Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Mon, 23 Feb 2015 12:50:35 +0000 Subject: [PATCH 13/45] .gitignore: ignore library directories created by MSVC VS2008 buildsystem Signed-off-by: Philip Oakley --- .gitignore | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.gitignore b/.gitignore index b69d7967b5ca74..e1d60390949014 100644 --- a/.gitignore +++ b/.gitignore @@ -181,7 +181,43 @@ /gitweb/gitweb.cgi /gitweb/static/gitweb.js /gitweb/static/gitweb.min.* +/libgit +/test-chmtime +/test-ctype +/test-config +/test-date +/test-delta +/test-dump-cache-tree +/test-dump-split-index +/test-dump-untracked-cache +/test-fake-ssh +/test-scrap-cache-tree +/test-genrandom +/test-hashmap +/test-index-version +/test-line-buffer +/test-match-trees +/test-mergesort +/test-mktemp +/test-parse-options +/test-path-utils +/test-prio-queue +/test-read-cache +/test-regex +/test-revision-walking +/test-run-command +/test-sha1 +/test-sha1-array +/test-sigchain +/test-string-list +/test-submodule-config +/test-subprocess +/test-svn-fe +/test-urlmatch-normalization +/test-wildmatch /common-cmds.h +/vcs-svn_lib +/xdiff_lib *.tar.gz *.dsc *.deb From 97ec1dfa04fbc7d10dbd5cc7640584b74f477630 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 28 Nov 2016 18:17:49 +0100 Subject: [PATCH 14/45] git: avoid calling aliased builtins via their dashed form This is one of the few places where Git violates its own deprecation of the dashed form. It is not necessary, either. Signed-off-by: Johannes Schindelin --- git.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/git.c b/git.c index d77e9f089ad264..afd7b31be0f9a6 100644 --- a/git.c +++ b/git.c @@ -635,6 +635,32 @@ static int run_argv(int *argcp, const char ***argv) */ if (!done_alias) handle_builtin(*argcp, *argv); + else if (get_builtin(**argv)) { + struct argv_array args = ARGV_ARRAY_INIT; + int i; + + argv_array_push(&args, "git"); + for (i = 0; i < *argcp; i++) + argv_array_push(&args, (*argv)[i]); + + if (get_super_prefix()) + die("%s doesn't support --super-prefix", args.argv[0]); + + if (use_pager == -1) + use_pager = check_pager_config(args.argv[0]); + commit_pager_choice(); + + trace_argv_printf(args.argv, "trace: exec:"); + + /* + * if we fail because the command is not found, it is + * OK to return. Otherwise, we just pass along the status code. + */ + i = run_command_v_opt(args.argv, RUN_SILENT_EXEC_FAILURE | RUN_CLEAN_ON_EXIT); + if (i >= 0 || errno != ENOENT) + exit(i); + die("could not execute builtin %s", args.argv[1]); + } /* .. then try the external ones */ execv_dashed_external(*argv); From e0ee9b822f42585ae85901ca4112a0efd30305af Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 11:40:55 +0100 Subject: [PATCH 15/45] merge-resolve: avoid dashed call We started deprecating the dashed form a long time ago, advertising the fact that dashed invocations of Git commands are deprecated for several major versions. Yet we still used them ourselves. With ashes on our heads, we now start to finally get rid of those calls. Signed-off-by: Johannes Schindelin --- git-merge-resolve.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-merge-resolve.sh b/git-merge-resolve.sh index c9da747fcfe504..343fe7bccd0d64 100755 --- a/git-merge-resolve.sh +++ b/git-merge-resolve.sh @@ -45,7 +45,7 @@ then exit 0 else echo "Simple merge failed, trying Automatic merge." - if git-merge-index -o git-merge-one-file -a + if git merge-index -o git-merge-one-file -a then exit 0 else From 593d5e90d9d2321fa81480aa450cd3a91452f0a0 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 23:34:18 +0100 Subject: [PATCH 16/45] rebase--merge: avoid dashed invocation We deprecated the dashed invocations ages ago. Might just as well hold ourselves to that. Signed-off-by: Johannes Schindelin --- git-rebase--merge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh index 06a4723d4db3db..9bc88b70544a25 100644 --- a/git-rebase--merge.sh +++ b/git-rebase--merge.sh @@ -69,7 +69,7 @@ call_merge () { test -z "$strategy" && strategy=recursive # If cmt doesn't have a parent, don't include it as a base base=$(git rev-parse --verify --quiet $cmt^) - eval 'git-merge-$strategy' $strategy_opts $base ' -- "$hd" "$cmt"' + eval 'git merge-$strategy' $strategy_opts $base ' -- "$hd" "$cmt"' rv=$? case "$rv" in 0) From 8cccd6a3991cf8d3493286b8150c70440c25f3e7 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 23:34:18 +0100 Subject: [PATCH 17/45] stash: avoid dashed invocation The invocation of dashed Git commands was rightfully deprecated a long time ago. We failed to heed that deprecation ourselves, but it is never too late... Signed-off-by: Johannes Schindelin --- git-stash.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-stash.sh b/git-stash.sh index 4546abaaef3dab..39d526e29dca3c 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -502,7 +502,7 @@ apply_stash () { if test -n "$u_tree" then - GIT_INDEX_FILE="$TMPindex" git-read-tree "$u_tree" && + GIT_INDEX_FILE="$TMPindex" git read-tree "$u_tree" && GIT_INDEX_FILE="$TMPindex" git checkout-index --all && rm -f "$TMPindex" || die "$(gettext "Could not restore untracked files from stash")" From 76a8d8659e114067cc624339930cc1efc15e299a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 23:34:18 +0100 Subject: [PATCH 18/45] merge-octopus: avoid dashed invocation A long time ago, in turn a long time after introducing builtins and moving Git's scripts to libexec/git-core/, we deprecated the invocation of dashed commands. The merge-octopus script is a holdover from the time before that, as it still tries to invoke a builtin by its dashed form. Let's just not. Signed-off-by: Johannes Schindelin --- git-merge-octopus.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh index bcf0d92ec223bf..6c390d6c229d7e 100755 --- a/git-merge-octopus.sh +++ b/git-merge-octopus.sh @@ -100,7 +100,7 @@ do if test $? -ne 0 then gettextln "Simple merge did not work, trying automatic merge." - git-merge-index -o git-merge-one-file -a || + git merge-index -o git-merge-one-file -a || OCTOPUS_FAILURE=1 next=$(git write-tree 2>/dev/null) fi From 6dccef8c0ddb46d48e7321a81c1be59542a05660 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 23:34:18 +0100 Subject: [PATCH 19/45] merge-one-file: avoid dashed invocation The original idea of deprecating invocations of Git subcommands via their dashed form was to be able to ship without having to hard-link each and every builtin to its dashed form. We need to follow this plan ourselves, by patching our very own scripts accordingly. Signed-off-by: Johannes Schindelin --- git-merge-one-file.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh index 424b034e34b4b4..9879c59395edff 100755 --- a/git-merge-one-file.sh +++ b/git-merge-one-file.sh @@ -115,16 +115,16 @@ case "${1:-.}${2:-.}${3:-.}" in ;; esac - src1=$(git-unpack-file $2) - src2=$(git-unpack-file $3) + src1=$(git unpack-file $2) + src2=$(git unpack-file $3) case "$1" in '') echo "Added $4 in both, but differently." - orig=$(git-unpack-file e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) + orig=$(git unpack-file e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) ;; *) echo "Auto-merging $4" - orig=$(git-unpack-file $1) + orig=$(git unpack-file $1) ;; esac From 8e1395d077166c3e8a4a4cd43f3076c9f2aed784 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 23:34:18 +0100 Subject: [PATCH 20/45] submodule: avoid dashed invocation In the years-old effort to clean up the PATH a bit, we deprecated dashed invocations. But we did not hold ourselves to that. Until now. Signed-off-by: Johannes Schindelin --- git-submodule.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index a024a135d6663c..4aac71f076190e 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -843,7 +843,7 @@ cmd_summary() { test $status != A && test $ignore_config = all && continue fi # Also show added or modified modules which are checked out - GIT_DIR="$sm_path/.git" git-rev-parse --git-dir >/dev/null 2>&1 && + GIT_DIR="$sm_path/.git" git rev-parse --git-dir >/dev/null 2>&1 && printf '%s\n' "$sm_path" done ) @@ -877,11 +877,11 @@ cmd_summary() { missing_dst= test $mod_src = 160000 && - ! GIT_DIR="$name/.git" git-rev-parse -q --verify $sha1_src^0 >/dev/null && + ! GIT_DIR="$name/.git" git rev-parse -q --verify $sha1_src^0 >/dev/null && missing_src=t test $mod_dst = 160000 && - ! GIT_DIR="$name/.git" git-rev-parse -q --verify $sha1_dst^0 >/dev/null && + ! GIT_DIR="$name/.git" git rev-parse -q --verify $sha1_dst^0 >/dev/null && missing_dst=t display_name=$(git submodule--helper relative-path "$name" "$wt_prefix") From 8a48ddb260aac30ce683d651ee5fa09cf26f68a7 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Oct 2016 06:06:10 -0700 Subject: [PATCH 21/45] .gitignore: ignore Visual Studio's temporary/generated files Signed-off-by: Johannes Schindelin --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index e1d60390949014..6c0476c185b7de 100644 --- a/.gitignore +++ b/.gitignore @@ -260,6 +260,9 @@ *.manifest Debug/ Release/ +/UpgradeLog*.htm +/git.VC.VC.opendb +/git.VC.db /.vagrant/ /vagrant2[0-9][0-9][0-9]*-*-* /d2[0-9][0-9][0-9]*-*-* From d7353cfa2f685f02593c31368efb5d9d9d1c0e59 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 17:41:13 +0100 Subject: [PATCH 22/45] contrib/buildsystems: fix misleading error message The error message talked about a "lib option", but it clearly referred to a link option. Signed-off-by: Philip Oakley Signed-off-by: Johannes Schindelin --- contrib/buildsystems/engine.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 53e65d4db713c3..11f0e16ddacb89 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -333,7 +333,7 @@ sub handleLinkLine } elsif ($part =~ /\.obj$/) { # do nothing, 'make' should not be producing .obj, only .o files } else { - die "Unhandled lib option @ line $lineno: $part"; + die "Unhandled link option @ line $lineno: $part"; } } # print "AppOut: '$appout'\nLFlags: @lflags\nLibs : @libs\nOfiles: @objfiles\n"; From f233b5ce42a9541fbf8c51822cde881edbf5b3db Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 16:08:21 +0100 Subject: [PATCH 23/45] contrib/buildsystems: handle quoted spaces in filenames The engine.pl script expects file names not to contain spaces. However, paths with spaces are quite prevalent on Windows. Use shellwords() rather than split() to parse them correctly. Helped-by: Junio C Hamano Signed-off-by: Philip Oakley Signed-off-by: Johannes Schindelin --- contrib/buildsystems/engine.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 11f0e16ddacb89..ad6a82c30ce808 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -12,6 +12,7 @@ use File::Spec; use Cwd; use Generators; +use Text::ParseWords; my (%build_structure, %compile_options, @makedry); my $out_dir = getcwd(); @@ -231,7 +232,7 @@ sub removeDuplicates sub handleCompileLine { my ($line, $lineno) = @_; - my @parts = split(' ', $line); + my @parts = shellwords($line); my $sourcefile; shift(@parts); # ignore cmd while (my $part = shift @parts) { @@ -265,7 +266,7 @@ sub handleLibLine my (@objfiles, @lflags, $libout, $part); # kill cmd and rm 'prefix' $line =~ s/^rm -f .* && .* rcs //; - my @parts = split(' ', $line); + my @parts = shellwords($line); while ($part = shift @parts) { if ($part =~ /^-/) { push(@lflags, $part); @@ -306,7 +307,7 @@ sub handleLinkLine { my ($line, $lineno) = @_; my (@objfiles, @lflags, @libs, $appout, $part); - my @parts = split(' ', $line); + my @parts = shellwords($line); shift(@parts); # ignore cmd while ($part = shift @parts) { if ($part =~ /^-IGNORE/) { From a40e119986dd5d22fbb74d43def12a15dc3d0bf9 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Mon, 9 Feb 2015 14:34:29 +0000 Subject: [PATCH 24/45] contrib/buildsystems: ignore gettext stuff Git's build contains steps to handle internationalization. This caused hiccups in the parser used to generate QMake/Visual Studio project files. As those steps are irrelevant in this context, let's just ignore them. Signed-off-by: Philip Oakley Signed-off-by: Johannes Schindelin --- contrib/buildsystems/engine.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index ad6a82c30ce808..9db3d43a1eb2f7 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -141,6 +141,12 @@ sub parseMakeOutput next; } + if ($text =~ /^(mkdir|msgfmt) /) { + # options to the Portable Object translations + # the line "mkdir ... && msgfmt ..." contains no linker options + next; + } + if($text =~ / -c /) { # compilation handleCompileLine($text, $line); From df0fd7cddd41f0461dfbe105c3f5a9e81a7ed43b Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 16:45:32 +0100 Subject: [PATCH 25/45] contrib/buildsystems: redirect errors of the dry run into a log file Rather than swallowing the errors, it is better to have them in a file. To make it obvious what this is about, use the file name 'msvc-build-makedryerrors.txt'. Further, if the output is empty, simply delete that file. As we target Git for Windows' SDK (which, unlike its predecessor msysGit, offers Perl versions newer than 5.8), we can use the quite readable syntax `if -f -z $ErrsFile` (available in Perl >=5.10). Note that the file will contain the new values of the GIT_VERSION and GITGUI_VERSION if they were generated by the make file. They are omitted if the release is tagged and indentically defined in their respective GIT_VERSION_GEN file DEF_VER variables. Signed-off-by: Philip Oakley Signed-off-by: Johannes Schindelin --- contrib/buildsystems/engine.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 9db3d43a1eb2f7..019e9f5b1a996b 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -73,7 +73,12 @@ sub showUsage EOM # Pipe a make --dry-run into a variable, if not already loaded from file -@makedry = `cd $git_dir && make -n MSVC=1 V=1 2>/dev/null` if !@makedry; +# Capture the make dry stderr to file for review (will be empty for a release build). + +my $ErrsFile = "msvc-build-makedryerrors.txt"; +@makedry = `cd $git_dir && make -n MSVC=1 V=1 2>$ErrsFile` if !@makedry; +# test for an empty Errors file and remove it +unlink $ErrsFile if -f -z $ErrsFile; # Parse the make output into usable info parseMakeOutput(); From d56e0e546470eb0d6393b287a0b30760b1c4c6ff Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Wed, 4 May 2016 15:53:48 +0100 Subject: [PATCH 26/45] contrib/buildsystems: handle the curl library option Upon seeing the '-lcurl' option, point to the libcurl.lib. While there, fix the elsif indentation. Signed-off-by: Philip Oakley Signed-off-by: Johannes Schindelin --- contrib/buildsystems/engine.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 019e9f5b1a996b..abce09946f7190 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -329,10 +329,12 @@ sub handleLinkLine $appout = shift @parts; } elsif ("$part" eq "-lz") { push(@libs, "zlib.lib"); - } elsif ("$part" eq "-lcrypto") { + } elsif ("$part" eq "-lcrypto") { push(@libs, "libeay32.lib"); } elsif ("$part" eq "-lssl") { push(@libs, "ssleay32.lib"); + } elsif ("$part" eq "-lcurl") { + push(@libs, "libcurl.lib"); } elsif ($part =~ /^-/) { push(@lflags, $part); } elsif ($part =~ /\.(a|lib)$/) { From 6b376d0ac304ad4a266516d8691b509808b5ca3d Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 26 Oct 2016 04:59:06 -0700 Subject: [PATCH 27/45] contrib/buildsystems: ignore irrelevant files in Generators/ The Generators/ directory can contain spurious files such as editors' backup files. Even worse, there could be .swp files which are not even valid Perl scripts. Let's just ignore anything but .pm files in said directory. Signed-off-by: Johannes Schindelin --- contrib/buildsystems/Generators.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/buildsystems/Generators.pm b/contrib/buildsystems/Generators.pm index 408ef714b8f0dc..aa4cbaa2adacb1 100644 --- a/contrib/buildsystems/Generators.pm +++ b/contrib/buildsystems/Generators.pm @@ -17,7 +17,7 @@ BEGIN { $me = dirname($me); if (opendir(D,"$me/Generators")) { foreach my $gen (readdir(D)) { - next if ($gen =~ /^\.\.?$/); + next unless ($gen =~ /\.pm$/); require "${me}/Generators/$gen"; $gen =~ s,\.pm,,; push(@AVAILABLE, $gen); From cd62af22fc8bbb01103c56afd236e3aceb73411f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 27 Oct 2016 01:45:49 -0700 Subject: [PATCH 28/45] contrib/buildsystems: handle libiconv, too Git's test suite shows tons of breakages unless Git is compiled *without* NO_ICONV. That means, in turn, that we need to generate build definitions *with* libiconv, which in turn implies that we have to handle the -liconv option properly. Signed-off-by: Johannes Schindelin --- contrib/buildsystems/engine.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index abce09946f7190..b08b06f7c66d29 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -335,6 +335,8 @@ sub handleLinkLine push(@libs, "ssleay32.lib"); } elsif ("$part" eq "-lcurl") { push(@libs, "libcurl.lib"); + } elsif ("$part" eq "-liconv") { + push(@libs, "libiconv.lib"); } elsif ($part =~ /^-/) { push(@lflags, $part); } elsif ($part =~ /\.(a|lib)$/) { From 142041123c2befd6d58b8dc06582127ecd9a7a1e Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Thu, 16 Jul 2015 23:40:13 +0100 Subject: [PATCH 29/45] contrib/buildsystems: optionally capture the dry-run in a file Add an option for capturing the output of the make dry-run used in determining the msvc-build structure for easy debugging. You can use the output of `--make-out ` in subsequent runs via the `--in ` option. Signed-off-by: Philip Oakley Signed-off-by: Johannes Schindelin --- contrib/buildsystems/engine.pl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index b08b06f7c66d29..92cc511a1b90e7 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -32,6 +32,7 @@ sub showUsage -g --gen Specify the buildsystem generator (default: $gen) Available: $genlist -o --out Specify output directory generation (default: .) + --make-out Write the output of GNU Make into a file -i --in Specify input file, instead of running GNU Make -h,-? --help This help EOM @@ -39,6 +40,7 @@ sub showUsage } # Parse command-line options +my $make_out; while (@ARGV) { my $arg = shift @ARGV; if ("$arg" eq "-h" || "$arg" eq "--help" || "$arg" eq "-?") { @@ -46,6 +48,8 @@ sub showUsage exit(0); } elsif("$arg" eq "--out" || "$arg" eq "-o") { $out_dir = shift @ARGV; + } elsif("$arg" eq "--make-out") { + $make_out = shift @ARGV; } elsif("$arg" eq "--gen" || "$arg" eq "-g") { $gen = shift @ARGV; } elsif("$arg" eq "--in" || "$arg" eq "-i") { @@ -80,6 +84,12 @@ sub showUsage # test for an empty Errors file and remove it unlink $ErrsFile if -f -z $ErrsFile; +if (defined $make_out) { + open OUT, ">" . $make_out; + print OUT @makedry; + close OUT; +} + # Parse the make output into usable info parseMakeOutput(); From e77e645562faf43993e0438b73b45bcbd032cd54 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 27 Oct 2016 07:25:00 -0700 Subject: [PATCH 30/45] contrib/buildsystems: handle options starting with a slash With the recent changes to allow building with MSVC=1, we now pass the /OPT:REF option to the compiler. This confuses the parser that wants to turn the output of a dry run into project definitions for QMake and Visual Studio: Unhandled link option @ line 213: /OPT:REF at [...] Let's just extend the code that passes through options that start with a dash, so that it passes through options that start with a slash, too. Signed-off-by: Johannes Schindelin --- contrib/buildsystems/engine.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 92cc511a1b90e7..6cfaedb029364d 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -347,7 +347,7 @@ sub handleLinkLine push(@libs, "libcurl.lib"); } elsif ("$part" eq "-liconv") { push(@libs, "libiconv.lib"); - } elsif ($part =~ /^-/) { + } elsif ($part =~ /^[-\/]/) { push(@lflags, $part); } elsif ($part =~ /\.(a|lib)$/) { $part =~ s/\.a$/.lib/; From 0109f032744c6f148916c0f3da7f6c75f8707184 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 26 Oct 2016 02:28:10 -0700 Subject: [PATCH 31/45] contrib/buildsystems: support modern Visual Studio project definitions The .sln/.vcproj files were used to define projects up until Visual Studio 2008, but starting with Visual Studio 2010 the project definitions are stored in .sln/.vcxproj files (which can also be used by the MSBuild system). Let's just copy-edit the generator of the .vcproj files to a new generator that produces .vcxproj files directly, without forcing Visual Studio to upgrade the project definitions. Signed-off-by: Johannes Schindelin --- contrib/buildsystems/Generators/Vcxproj.pm | 399 +++++++++++++++++++++ 1 file changed, 399 insertions(+) create mode 100644 contrib/buildsystems/Generators/Vcxproj.pm diff --git a/contrib/buildsystems/Generators/Vcxproj.pm b/contrib/buildsystems/Generators/Vcxproj.pm new file mode 100644 index 00000000000000..be56ed694dccfb --- /dev/null +++ b/contrib/buildsystems/Generators/Vcxproj.pm @@ -0,0 +1,399 @@ +package Generators::Vcxproj; +require Exporter; + +use strict; +use vars qw($VERSION); + +our $VERSION = '1.00'; +our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE); +@ISA = qw(Exporter); + +BEGIN { + push @EXPORT_OK, qw(generate); +} + +my $guid_index = 0; +my @GUIDS = ( + "{E07B9989-2BF7-4F21-8918-BE22BA467AC3}", + "{278FFB51-0296-4A44-A81A-22B87B7C3592}", + "{7346A2C4-F0FD-444F-9EBE-1AF23B2B5650}", + "{67F421AC-EB34-4D49-820B-3196807B423F}", + "{385DCFE1-CC8C-4211-A451-80FCFC31CA51}", + "{97CC46C5-D2CC-4D26-B634-E75792B79916}", + "{C7CE21FE-6EF8-4012-A5C7-A22BCEDFBA11}", + "{51575134-3FDF-42D1-BABD-3FB12669C6C9}", + "{0AE195E4-9823-4B87-8E6F-20C5614AF2FF}", + "{4B918255-67CA-43BB-A46C-26704B666E6B}", + "{18CCFEEF-C8EE-4CC1-A265-26F95C9F4649}", + "{5D5D90FA-01B7-4973-AFE5-CA88C53AC197}", + "{1F054320-036D-49E1-B384-FB5DF0BC8AC0}", + "{7CED65EE-F2D9-4171-825B-C7D561FE5786}", + "{8D341679-0F07-4664-9A56-3BA0DE88B9BC}", + "{C189FEDC-2957-4BD7-9FA4-7622241EA145}", + "{66844203-1B9F-4C53-9274-164FFF95B847}", + "{E4FEA145-DECC-440D-AEEA-598CF381FD43}", + "{73300A8E-C8AC-41B0-B555-4F596B681BA7}", + "{873FDEB1-D01D-40BF-A1BF-8BBC58EC0F51}", + "{7922C8BE-76C5-4AC6-8BF7-885C0F93B782}", + "{E245D370-308B-4A49-BFC1-1E527827975F}", + "{F6FA957B-66FC-4ED7-B260-E59BBE4FE813}", + "{E6055070-0198-431A-BC49-8DB6CEE770AE}", + "{54159234-C3EB-43DA-906B-CE5DA5C74654}", + "{594CFC35-0B60-46F6-B8EF-9983ACC1187D}", + "{D93FCAB7-1F01-48D2-B832-F761B83231A5}", + "{DBA5E6AC-E7BE-42D3-8703-4E787141526E}", + "{6171953F-DD26-44C7-A3BE-CC45F86FC11F}", + "{9E19DDBE-F5E4-4A26-A2FE-0616E04879B8}", + "{AE81A615-99E3-4885-9CE0-D9CAA193E867}", + "{FBF4067E-1855-4F6C-8BCD-4D62E801A04D}", + "{17007948-6593-4AEB-8106-F7884B4F2C19}", + "{199D4C8D-8639-4DA6-82EF-08668C35DEE0}", + "{E085E50E-C140-4CF3-BE4B-094B14F0DDD6}", + "{00785268-A9CC-4E40-AC29-BAC0019159CE}", + "{4C06F56A-DCDB-46A6-B67C-02339935CF12}", + "{3A62D3FD-519E-4EC9-8171-D2C1BFEA022F}", + "{9392EB58-D7BA-410B-B1F0-B2FAA6BC89A7}", + "{2ACAB2D5-E0CE-4027-BCA0-D78B2D7A6C66}", + "{86E216C3-43CE-481A-BCB2-BE5E62850635}", + "{FB631291-7923-4B91-9A57-7B18FDBB7A42}", + "{0A176EC9-E934-45B8-B87F-16C7F4C80039}", + "{DF55CA80-46E8-4C53-B65B-4990A23DD444}", + "{3A0F9895-55D2-4710-BE5E-AD7498B5BF44}", + "{294BDC5A-F448-48B6-8110-DD0A81820F8C}", + "{4B9F66E9-FAC9-47AB-B1EF-C16756FBFD06}", + "{72EA49C6-2806-48BD-B81B-D4905102E19C}", + "{5728EB7E-8929-486C-8CD5-3238D060E768}", + "{A3E300FC-5630-4850-A470-E9F2C2EFA7E7}", + "{CEA071D4-D9F3-4250-98F7-44AFDC8ACAA1}", + "{3FD87BB4-2236-4A1B-ADD2-46211A302442}", + "{49B03F41-5157-4079-95A7-64D728BCF74F}", + "{95D5A28B-80E2-40A9-BEA3-C52B9CA488E3}", + "{B85E6545-D523-4323-9F29-45389D090343}", + "{06840CEF-746C-4B71-9442-C395DD6590A5}" +); + +sub generate { + my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; + my @libs = @{$build_structure{"LIBS"}}; + foreach (@libs) { + createProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure, 1); + } + + my @apps = @{$build_structure{"APPS"}}; + foreach (@apps) { + createProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure, 0); + } + + createGlueProject($git_dir, $out_dir, $rel_dir, %build_structure); + return 0; +} + +sub createProject { + my ($name, $git_dir, $out_dir, $rel_dir, $build_structure, $static_library) = @_; + my $label = $static_library ? "lib" : "app"; + my $prefix = $static_library ? "LIBS_" : "APPS_"; + my $config_type = $static_library ? "StaticLibrary" : "Utility"; + print "Generate $name vcxproj $label project\n"; + my $cdup = $name; + $cdup =~ s/[^\/]+/../g; + $cdup =~ s/\//\\/g; + $rel_dir = $rel_dir eq "." ? $cdup : "$cdup\\$rel_dir"; + $rel_dir =~ s/\//\\/g; + + my $target = $name; + if ($static_library) { + $target =~ s/\.a//; + } else { + $target =~ s/\.exe//; + } + + my $uuid = $GUIDS[$guid_index++]; + $$build_structure{"$prefix${target}_GUID"} = $uuid; + my $vcxproj = $target; + $vcxproj =~ s/(.*\/)?(.*)/$&\/$2.vcxproj/; + $vcxproj =~ s/([^\/]*)(\/lib)\/(lib.vcxproj)/$1$2\/$1_$3/; + $$build_structure{"$prefix${target}_VCXPROJ"} = $vcxproj; + + my @srcs = sort(map("$rel_dir\\$_", @{$$build_structure{"$prefix${name}_SOURCES"}})); + my @sources; + foreach (@srcs) { + $_ =~ s/\//\\/g; + push(@sources, $_); + } + my $defines = join(";", sort(@{$$build_structure{"$prefix${name}_DEFINES"}})); + my $includes= join(";", sort(map { s/^-I//; s/\//\\/g; File::Spec->file_name_is_absolute($_) ? $_ : "$rel_dir\\$_" } @{$$build_structure{"$prefix${name}_INCLUDES"}})); + my $cflags = join(" ", sort(map { s/^-[GLMOZ].*//; s/.* .*/"$&"/; $_; } @{$$build_structure{"$prefix${name}_CFLAGS"}})); + $cflags =~ s/\"/"/g; + $cflags =~ s//>/g; + + my $libs = ''; + if (!$static_library) { + $libs = join(";", sort(grep /^(?!libgit\.lib|xdiff\/lib\.lib)/, @{$$build_structure{"$prefix${name}_LIBS"}})); + } + my $ldirs = join(";", map { /^-L(?!TCG)(.*)/ ? (File::Spec->file_name_is_absolute($1) ? $1 : "$rel_dir\\$1") : () } @{$$build_structure{"$prefix${name}_LFLAGS"}}); + + $defines =~ s/-D//g; + $defines =~ s/\"/"/g; + $defines =~ s//>/g; + $defines =~ s/\'//g; + + die "Could not create the directory $target for $label project!\n" unless (-d "$target" || mkdir "$target"); + open F, ">$vcxproj" or die "Could not open $vcxproj for writing!\n"; + binmode F, ":crlf :utf8"; + print F chr(0xFEFF); + print F << "EOM"; + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + $uuid + Win32Proj + + + + true + true + + + false + true + + + $config_type + v140 + + ..\\ + + + + + + + + + + + + + false + true + + + + $cflags %(AdditionalOptions) + $includes;%(AdditionalIncludeDirectories) + + true + OnlyExplicitInline + + ProgramDatabase + + + true + + + $libs;\$(AdditionalDependencies) + $ldirs + $cdup\\compat\\win32\\git.manifest + Console + + + + + MachineX86 + + + + + Disabled + WIN32;_DEBUG;$defines;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + + + true + + + + + MaxSpeed + true + WIN32;NDEBUG;$defines;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Speed + + + true + true + true + + + +EOM + foreach(@sources) { + print F << "EOM"; + +EOM + } + print F << "EOM"; + +EOM + if (!$static_library) { + my $uuid_libgit = $$build_structure{"LIBS_libgit_GUID"}; + my $uuid_xdiff_lib = $$build_structure{"LIBS_xdiff/lib_GUID"}; + + print F << "EOM"; + + + $uuid_libgit + false + + + $uuid_xdiff_lib + false + +EOM + if ($name =~ /(test-(line-buffer|svn-fe)|^git-remote-testsvn)\.exe$/) { + my $uuid_vcs_svn_lib = $$build_structure{"LIBS_vcs-svn/lib_GUID"}; + print F << "EOM"; + + $uuid_vcs_svn_lib + false + +EOM + } + print F << "EOM"; + +EOM + } + print F << "EOM"; + + + + +EOM + close F; +} + +sub createGlueProject { + my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; + print "Generate solutions file\n"; + $rel_dir = "..\\$rel_dir"; + $rel_dir =~ s/\//\\/g; + my $SLN_HEAD = "Microsoft Visual Studio Solution File, Format Version 11.00\n# Visual Studio 2010\n"; + my $SLN_PRE = "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = "; + my $SLN_POST = "\nEndProject\n"; + + my @libs = @{$build_structure{"LIBS"}}; + my @tmp; + foreach (@libs) { + $_ =~ s/\.a//; + push(@tmp, $_); + } + @libs = @tmp; + + my @apps = @{$build_structure{"APPS"}}; + @tmp = (); + foreach (@apps) { + $_ =~ s/\.exe//; + if ($_ eq "git" ) { + unshift(@tmp, $_); + } else { + push(@tmp, $_); + } + } + @apps = @tmp; + + open F, ">git.sln" || die "Could not open git.sln for writing!\n"; + binmode F, ":crlf :utf8"; + print F chr(0xFEFF); + print F "$SLN_HEAD"; + + foreach (@apps) { + my $appname = $_; + my $uuid = $build_structure{"APPS_${appname}_GUID"}; + print F "$SLN_PRE"; + my $vcxproj = $build_structure{"APPS_${appname}_VCXPROJ"}; + $vcxproj =~ s/\//\\/g; + $appname =~ s/.*\///; + print F "\"${appname}\", \"${vcxproj}\", \"${uuid}\""; + print F "$SLN_POST"; + } + foreach (@libs) { + my $libname = $_; + my $uuid = $build_structure{"LIBS_${libname}_GUID"}; + print F "$SLN_PRE"; + my $vcxproj = $build_structure{"LIBS_${libname}_VCXPROJ"}; + $vcxproj =~ s/\//\\/g; + $libname =~ s/\//_/g; + print F "\"${libname}\", \"${vcxproj}\", \"${uuid}\""; + print F "$SLN_POST"; + } + + print F << "EOM"; +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection +EOM + print F << "EOM"; + GlobalSection(ProjectConfigurationPlatforms) = postSolution +EOM + foreach (@apps) { + my $appname = $_; + my $uuid = $build_structure{"APPS_${appname}_GUID"}; + print F "\t\t${uuid}.Debug|x64.ActiveCfg = Debug|x64\n"; + print F "\t\t${uuid}.Debug|x64.Build.0 = Debug|x64\n"; + print F "\t\t${uuid}.Debug|x86.ActiveCfg = Debug|Win32\n"; + print F "\t\t${uuid}.Debug|x86.Build.0 = Debug|Win32\n"; + print F "\t\t${uuid}.Release|x64.ActiveCfg = Release|x64\n"; + print F "\t\t${uuid}.Release|x64.Build.0 = Release|x64\n"; + print F "\t\t${uuid}.Release|x86.ActiveCfg = Release|Win32\n"; + print F "\t\t${uuid}.Release|x86.Build.0 = Release|Win32\n"; + } + foreach (@libs) { + my $libname = $_; + my $uuid = $build_structure{"LIBS_${libname}_GUID"}; + print F "\t\t${uuid}.Debug|x64.ActiveCfg = Debug|x64\n"; + print F "\t\t${uuid}.Debug|x64.Build.0 = Debug|x64\n"; + print F "\t\t${uuid}.Debug|x86.ActiveCfg = Debug|Win32\n"; + print F "\t\t${uuid}.Debug|x86.Build.0 = Debug|Win32\n"; + print F "\t\t${uuid}.Release|x64.ActiveCfg = Release|x64\n"; + print F "\t\t${uuid}.Release|x64.Build.0 = Release|x64\n"; + print F "\t\t${uuid}.Release|x86.ActiveCfg = Release|Win32\n"; + print F "\t\t${uuid}.Release|x86.Build.0 = Release|Win32\n"; + } + + print F << "EOM"; + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal +EOM + close F; +} + +1; From 526ab50bb6da2f3eea0f384106cf33d26178bf21 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 5 Nov 2016 15:05:47 +0100 Subject: [PATCH 32/45] contrib/buildsystems: make 'Restore NuGet Packages' work in Visual Studio Visual Studio has this very neat feature that you can get dependencies in the form of NuGet packages, and even further: you can specify in a project what NuGet packages it needs. These dependencies can then be fetched via right-clicking the solution in the Solution Explorer and clicking the "Restore NuGet Packages" entry. This feature is so neat, in fact, that we want to support it in Git for Windows. The idea is that we will be able to provide developers with a checkout of the Git sources that can be built outside of the Git for Windows SDK, using *only* Visual Studio. Signed-off-by: Johannes Schindelin --- contrib/buildsystems/Generators/Vcxproj.pm | 56 ++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/contrib/buildsystems/Generators/Vcxproj.pm b/contrib/buildsystems/Generators/Vcxproj.pm index be56ed694dccfb..154d74fab33b5a 100644 --- a/contrib/buildsystems/Generators/Vcxproj.pm +++ b/contrib/buildsystems/Generators/Vcxproj.pm @@ -92,7 +92,7 @@ sub createProject { my ($name, $git_dir, $out_dir, $rel_dir, $build_structure, $static_library) = @_; my $label = $static_library ? "lib" : "app"; my $prefix = $static_library ? "LIBS_" : "APPS_"; - my $config_type = $static_library ? "StaticLibrary" : "Utility"; + my $config_type = $static_library ? "StaticLibrary" : "Application"; print "Generate $name vcxproj $label project\n"; my $cdup = $name; $cdup =~ s/[^\/]+/../g; @@ -129,7 +129,7 @@ sub createProject { my $libs = ''; if (!$static_library) { - $libs = join(";", sort(grep /^(?!libgit\.lib|xdiff\/lib\.lib)/, @{$$build_structure{"$prefix${name}_LIBS"}})); + $libs = join(";", sort(grep /^(?!libgit\.lib|xdiff\/lib\.lib|vcs-svn\/lib\.lib|libcurl\.lib|libeay32\.lib|libiconv\.lib|ssleay32\.lib|zlib\.lib)/, @{$$build_structure{"$prefix${name}_LIBS"}})); } my $ldirs = join(";", map { /^-L(?!TCG)(.*)/ ? (File::Spec->file_name_is_absolute($1) ? $1 : "$rel_dir\\$1") : () } @{$$build_structure{"$prefix${name}_LFLAGS"}}); @@ -140,6 +140,39 @@ sub createProject { $defines =~ s/\'//g; die "Could not create the directory $target for $label project!\n" unless (-d "$target" || mkdir "$target"); + + use File::Copy; + copy("$git_dir/compat/vcbuild/packages.config", "$target/packages.config"); + + my $needsCurl = grep(/libcurl.lib/, @{$$build_structure{"$prefix${name}_LIBS"}}); + my $targetsImport = ''; + my $targetsErrors = ''; + my $afterTargets = ''; + open F, "<$git_dir/compat/vcbuild/packages.config"; + while () { + if (/"; + } elsif ($needsCurl && $1 eq 'curl') { + # libcurl is only available targeting v100 and v110 + $libs .= ";$rel_dir\\compat\\vcbuild\\GEN.PKGS\\$1.$2\\build\\native\\lib\\v110\\\$(Platform)\\Release\\dynamic\\libcurl.lib"; + $afterTargets .= "\n "; + } elsif ($needsCurl && $1 eq 'expat') { + # libexpat is only available targeting v100 and v110 + $libs .= ";$rel_dir\\compat\\vcbuild\\GEN.PKGS\\$1.$2\\build\\native\\lib\\v110\\\$(Platform)\\Release\\dynamic\\utf8\\libexpat.lib"; + } + next if ($1 =~ /^(zlib$|openssl(?!.*(x64|x86)$))/); + my $targetsFile = "$rel_dir\\compat\\vcbuild\\GEN.PKGS\\$1.$2\\build\\native\\$1.targets"; + $targetsImport .= "\n "; + $targetsErrors .= "\n "; + } + } + close F; + open F, ">$vcxproj" or die "Could not open $vcxproj for writing!\n"; binmode F, ":crlf :utf8"; print F chr(0xFEFF); @@ -213,6 +246,7 @@ sub createProject { $libs;\$(AdditionalDependencies) $ldirs + invalidcontinue.obj %(AdditionalOptions) $cdup\\compat\\win32\\git.manifest Console @@ -286,9 +320,25 @@ EOM EOM } print F << "EOM"; + + + - + $targetsImport + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + $targetsErrors + +EOM + if (!$static_library && $afterTargets ne '') { + print F << "EOM"; + $afterTargets + +EOM + } + print F << "EOM"; EOM close F; From 3116872079d6b4e8c64c4e2fe958cca1bfc5362c Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Mon, 13 Jul 2015 13:59:55 +0100 Subject: [PATCH 33/45] Vcproj.pm: remove duplicate GUID Delete the duplicated GUID from the generation code for the Visual Studio .sln project file. The duplicate GUID tended to be allocated to test-svn-fe, which was then ignored by Visual Studio / MSVC, and its omission from the build never noticed. Signed-off-by: Philip Oakley Signed-off-by: Johannes Schindelin --- contrib/buildsystems/Generators/Vcproj.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/contrib/buildsystems/Generators/Vcproj.pm b/contrib/buildsystems/Generators/Vcproj.pm index cfa74adcc23881..1b01d5821fb5d7 100644 --- a/contrib/buildsystems/Generators/Vcproj.pm +++ b/contrib/buildsystems/Generators/Vcproj.pm @@ -52,7 +52,6 @@ my @GUIDS = ( "{00785268-A9CC-4E40-AC29-BAC0019159CE}", "{4C06F56A-DCDB-46A6-B67C-02339935CF12}", "{3A62D3FD-519E-4EC9-8171-D2C1BFEA022F}", - "{3A62D3FD-519E-4EC9-8171-D2C1BFEA022F}", "{9392EB58-D7BA-410B-B1F0-B2FAA6BC89A7}", "{2ACAB2D5-E0CE-4027-BCA0-D78B2D7A6C66}", "{86E216C3-43CE-481A-BCB2-BE5E62850635}", From 4b3c8b01d8bc9ef5ff3d7bbad6d6973d815ca206 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 17:43:29 +0100 Subject: [PATCH 34/45] Vcproj.pm: list git.exe first to be startup project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Visual Studio takes the first listed application/library as the default startup project [1]. Detect the 'git' project and place it the head of the apps list, rather than the tail. Export the apps list before libs list for both the projects and global structures of the .sln file. [1] http://stackoverflow.com/questions/1238553/ vs2008-where-is-the-startup-project-setting-stored-for-a-solution "In the solution file, there are a list of pseudo-XML "Project" entries. It turns out that whatever is the first one ends up as the Startup Project, unless it’s overridden in the suo file. Argh. I just rearranged the order in the file and it’s good." "just moving the pseudo-xml isn't enough. You also have to move the group of entries in the "GlobalSection(ProjectConfigurationPlatforms) = postSolution" group that has the GUID of the project you moved to the top. So there are two places to move lines." Signed-off-by: Philip Oakley --- contrib/buildsystems/Generators/Vcproj.pm | 33 +++++++++++++---------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/contrib/buildsystems/Generators/Vcproj.pm b/contrib/buildsystems/Generators/Vcproj.pm index 1b01d5821fb5d7..cc2fa21533d271 100644 --- a/contrib/buildsystems/Generators/Vcproj.pm +++ b/contrib/buildsystems/Generators/Vcproj.pm @@ -560,20 +560,18 @@ sub createGlueProject { foreach (@apps) { $_ =~ s/\//_/g; $_ =~ s/\.exe//; - push(@tmp, $_); + if ($_ eq "git" ) { + unshift(@tmp, $_); + } else { + push(@tmp, $_); + } } @apps = @tmp; open F, ">git.sln" || die "Could not open git.sln for writing!\n"; binmode F, ":crlf"; print F "$SLN_HEAD"; - foreach (@libs) { - my $libname = $_; - my $uuid = $build_structure{"LIBS_${libname}_GUID"}; - print F "$SLN_PRE"; - print F "\"${libname}\", \"${libname}\\${libname}.vcproj\", \"${uuid}\""; - print F "$SLN_POST"; - } + my $uuid_libgit = $build_structure{"LIBS_libgit_GUID"}; my $uuid_xdiff_lib = $build_structure{"LIBS_xdiff_lib_GUID"}; foreach (@apps) { @@ -587,6 +585,13 @@ sub createGlueProject { print F " EndProjectSection"; print F "$SLN_POST"; } + foreach (@libs) { + my $libname = $_; + my $uuid = $build_structure{"LIBS_${libname}_GUID"}; + print F "$SLN_PRE"; + print F "\"${libname}\", \"${libname}\\${libname}.vcproj\", \"${uuid}\""; + print F "$SLN_POST"; + } print F << "EOM"; Global @@ -598,17 +603,17 @@ EOM print F << "EOM"; GlobalSection(ProjectConfigurationPlatforms) = postSolution EOM - foreach (@libs) { - my $libname = $_; - my $uuid = $build_structure{"LIBS_${libname}_GUID"}; + foreach (@apps) { + my $appname = $_; + my $uuid = $build_structure{"APPS_${appname}_GUID"}; print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n"; print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n"; print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n"; print F "\t\t${uuid}.Release|Win32.Build.0 = Release|Win32\n"; } - foreach (@apps) { - my $appname = $_; - my $uuid = $build_structure{"APPS_${appname}_GUID"}; + foreach (@libs) { + my $libname = $_; + my $uuid = $build_structure{"LIBS_${libname}_GUID"}; print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n"; print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n"; print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n"; From 98438950e9f69671adac59772d3f047cad6a9409 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Wed, 6 Apr 2016 15:24:42 +0100 Subject: [PATCH 35/45] Vcproj.pm: provide more GUIDs Needed for: test-config; t-dump-split-index; t-dump-untracked-cache; t-fake-ssh; t-sha1-array; t-submodule-config. Plus a few spares. Signed-off-by: Philip Oakley --- contrib/buildsystems/Generators/Vcproj.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/contrib/buildsystems/Generators/Vcproj.pm b/contrib/buildsystems/Generators/Vcproj.pm index cc2fa21533d271..0572ba8609670f 100644 --- a/contrib/buildsystems/Generators/Vcproj.pm +++ b/contrib/buildsystems/Generators/Vcproj.pm @@ -62,7 +62,14 @@ my @GUIDS = ( "{294BDC5A-F448-48B6-8110-DD0A81820F8C}", "{4B9F66E9-FAC9-47AB-B1EF-C16756FBFD06}", "{72EA49C6-2806-48BD-B81B-D4905102E19C}", - "{5728EB7E-8929-486C-8CD5-3238D060E768}" + "{5728EB7E-8929-486C-8CD5-3238D060E768}", + "{A3E300FC-5630-4850-A470-E9F2C2EFA7E7}", + "{CEA071D4-D9F3-4250-98F7-44AFDC8ACAA1}", + "{3FD87BB4-2236-4A1B-ADD2-46211A302442}", + "{49B03F41-5157-4079-95A7-64D728BCF74F}", + "{95D5A28B-80E2-40A9-BEA3-C52B9CA488E3}", + "{B85E6545-D523-4323-9F29-45389D090343}", + "{06840CEF-746C-4B71-9442-C395DD6590A5}" ); sub generate { From ff446724b107f9c22add4e054cb1b3e4e7862a1c Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Oct 2016 03:02:36 -0700 Subject: [PATCH 36/45] Vcproj.pm: do not configure VCWebServiceProxyGeneratorTool It is not necessary, and Visual Studio 2015 no longer supports it, anyway. Signed-off-by: Johannes Schindelin --- contrib/buildsystems/Generators/Vcproj.pm | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/contrib/buildsystems/Generators/Vcproj.pm b/contrib/buildsystems/Generators/Vcproj.pm index 0572ba8609670f..70e7c8d7fc32cc 100644 --- a/contrib/buildsystems/Generators/Vcproj.pm +++ b/contrib/buildsystems/Generators/Vcproj.pm @@ -168,9 +168,6 @@ sub createLibProject { - @@ -234,9 +231,6 @@ sub createLibProject { - @@ -393,9 +387,6 @@ sub createAppProject { - @@ -464,9 +455,6 @@ sub createAppProject { - From 161ab2a223a4ae720829e3db4613b71da66d5fa9 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Oct 2016 03:11:22 -0700 Subject: [PATCH 37/45] Vcproj.pm: urlencode '<' and '>' when generating VC projects Signed-off-by: Johannes Schindelin --- contrib/buildsystems/Generators/Vcproj.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/contrib/buildsystems/Generators/Vcproj.pm b/contrib/buildsystems/Generators/Vcproj.pm index 70e7c8d7fc32cc..1c61ea6b938561 100644 --- a/contrib/buildsystems/Generators/Vcproj.pm +++ b/contrib/buildsystems/Generators/Vcproj.pm @@ -112,6 +112,8 @@ sub createLibProject { my $includes= join(";", sort(map(""$rel_dir\\$_"", @{$$build_structure{"LIBS_${libname}_INCLUDES"}}))); my $cflags = join(" ", sort(@{$$build_structure{"LIBS_${libname}_CFLAGS"}})); $cflags =~ s/\"/"/g; + $cflags =~ s//>/g; my $cflags_debug = $cflags; $cflags_debug =~ s/-MT/-MTd/; @@ -133,6 +135,8 @@ sub createLibProject { $defines =~ s/-D//g; $defines =~ s/\"/\\"/g; + $defines =~ s//>/g; $defines =~ s/\'//g; $includes =~ s/-I//g; mkdir "$target" || die "Could not create the directory $target for lib project!\n"; @@ -325,6 +329,8 @@ sub createAppProject { my $includes= join(";", sort(map(""$rel_dir\\$_"", @{$$build_structure{"APPS_${appname}_INCLUDES"}}))); my $cflags = join(" ", sort(@{$$build_structure{"APPS_${appname}_CFLAGS"}})); $cflags =~ s/\"/"/g; + $cflags =~ s//>/g; my $cflags_debug = $cflags; $cflags_debug =~ s/-MT/-MTd/; @@ -351,6 +357,8 @@ sub createAppProject { $defines =~ s/-D//g; $defines =~ s/\"/\\"/g; + $defines =~ s//>/g; $defines =~ s/\'//g; $defines =~ s/\\\\/\\/g; $includes =~ s/-I//g; From 56c8db2f51a6c01b927ee34471ff8104839a8d20 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 17:03:15 +0100 Subject: [PATCH 38/45] msvc: add No_SafeExceptionHandler option Microsoft flipped the Windows Safe Exception Handling default in VS2013 so that zlib became unacceptable to certain OS versions (Vista and subsequent 32-bit OS's) without the addition of the option -SAFESEH:NO. Provide a switch to disable the Safe Exception Handler when required. The option ImageHasSafeExceptionHandlers for VS2013 is not available in earlier versions, so use the SAFESEH:NO linker flag. See https://msdn.microsoft.com/en-us/library/9a89h429.aspx for further details. This has only had limited testing due to the lack of a suitable system. Helped-by: Yue Lin Ho Signed-off-by: Philip Oakley Signed-off-by: Johannes Schindelin --- config.mak.uname | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config.mak.uname b/config.mak.uname index ad72d95c031df9..22308c681ae2d6 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -1,5 +1,9 @@ # Platform specific Makefile tweaks based on uname detection +# Define NO_SAFESEH if you need MSVC/Visual Studio to ignore the lack of +# Microsoft's Safe Exception Handling in libraries (such as zlib). +# Typically required for VS2013+/32-bit compilation on Vista+ versions. + uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not') uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not') @@ -427,6 +431,11 @@ ifeq ($(uname_S),Windows) # release mode) to force a PDB to be generated (like RelWithDebInfo). BASIC_CFLAGS += -Zi BASIC_LDFLAGS += -debug + +ifdef NO_SAFESEH + LDFLAGS += -SAFESEH:NO +endif + ifndef DEBUG BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP From 8bd9d7416a9edbf869d231dd5df168aa6303e843 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Fri, 22 Apr 2016 13:33:33 +0100 Subject: [PATCH 39/45] msvc: do not include inttypes.h This file is not available in earlier MSVC versions, and it is not necessary to include it with MSVC, anyway. Signed-off-by: Philip Oakley Signed-off-by: Johannes Schindelin --- config.mak.uname | 1 + 1 file changed, 1 insertion(+) diff --git a/config.mak.uname b/config.mak.uname index 22308c681ae2d6..6e01bd532f78c9 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -366,6 +366,7 @@ ifeq ($(uname_S),Windows) NO_STRTOUMAX = YesPlease NO_MKDTEMP = YesPlease NO_MKSTEMPS = YesPlease + NO_INTTYPES_H = YesPlease # VS2015 with UCRT claims that snprintf and friends are C99 compliant, # so we don't need this. # From 6c2d418326b1e8d3ff72a064c4d90a47550001fe Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Wed, 4 May 2016 16:18:07 +0100 Subject: [PATCH 40/45] msvc: add pragmas for common warnings MSVC can be overzealous about some warnings. Disable them. Signed-off-by: Philip Oakley --- compat/msvc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compat/msvc.h b/compat/msvc.h index 1b6e525f2f9cae..5110957f6e7115 100644 --- a/compat/msvc.h +++ b/compat/msvc.h @@ -6,6 +6,10 @@ #include #include +#pragma warning(disable: 4018) /* signed/unsigned comparison */ +#pragma warning(disable: 4244) /* type conversion, possible loss of data */ +#pragma warning(disable: 4090) /* 'function' : different 'const' qualifiers (ALLOC_GROW etc.)*/ + /* porting function */ #define inline __inline #define __inline__ __inline From dc78302fdc02ed81c7d7d68ee8379d5d1edaf682 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 5 Nov 2016 15:19:31 +0100 Subject: [PATCH 41/45] msvc: tell Visual Studio where we expect NuGet packages to be unpacked We already unpack the NuGet packages in a certain place, via compat/vcbuild/Makefile. Let's let Visual Studio use the very same place. Signed-off-by: Johannes Schindelin --- .nuget/NuGet.config | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .nuget/NuGet.config diff --git a/.nuget/NuGet.config b/.nuget/NuGet.config new file mode 100644 index 00000000000000..93e50042cb7699 --- /dev/null +++ b/.nuget/NuGet.config @@ -0,0 +1,6 @@ + + + + + + From b7de342589c5aa775fa34975b80c2d7d558f5982 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 8 Nov 2016 11:00:01 +0100 Subject: [PATCH 42/45] msvc: ignore .dll files copied into the top-level directory Signed-off-by: Johannes Schindelin --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6c0476c185b7de..ec4e526125e799 100644 --- a/.gitignore +++ b/.gitignore @@ -256,6 +256,7 @@ *.idb *.pdb *.ilk +*.dll .vs/ *.manifest Debug/ From 53b2de33bb0f71098801418c8f7514fda28f0e2b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 8 Nov 2016 13:17:12 +0100 Subject: [PATCH 43/45] msvc: ignore incremental compile output Signed-off-by: Johannes Schindelin --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ec4e526125e799..006bf00df129ef 100644 --- a/.gitignore +++ b/.gitignore @@ -256,6 +256,8 @@ *.idb *.pdb *.ilk +*.iobj +*.ipdb *.dll .vs/ *.manifest From b91836a6ed1ce4174ed33b4f0453173c0d75cbb8 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 3 Nov 2016 09:40:12 -0700 Subject: [PATCH 44/45] msvc: fix `make test` without having to play PATH games When building with Microsoft Visual C, we use NuGet to acquire the dependencies (such as OpenSSL, cURL, etc). We even unpack those dependencies. This patch teaches the test suite to add the directory with the unpacked .dll files to the PATH before running the tests. Signed-off-by: Johannes Schindelin --- Makefile | 4 ++++ t/test-lib-functions.sh | 2 +- t/test-lib.sh | 17 +++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2a80656cc20355..635614ecb25591 100644 --- a/Makefile +++ b/Makefile @@ -2217,6 +2217,7 @@ GIT-BUILD-OPTIONS: FORCE @echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@+ @echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+ @echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+ + @echo X=\'$(X)\' >>$@+ ifdef TEST_OUTPUT_DIRECTORY @echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+ endif @@ -2245,6 +2246,9 @@ ifdef GIT_PERF_MAKE_OPTS endif ifdef TEST_GIT_INDEX_VERSION @echo TEST_GIT_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(TEST_GIT_INDEX_VERSION)))'\' >>$@+ +endif +ifdef MSVC_DEPS + @echo MSVC_DEPS=\''$(subst ','\'',$(subst ','\'',$(MSVC_DEPS)))'\' >>$@+ endif @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index fdaeb3a96bed36..52f2503abd2142 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -786,7 +786,7 @@ test_create_repo () { mkdir -p "$repo" ( cd "$repo" || error "Cannot setup test environment" - "$GIT_EXEC_PATH/git-init" "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 || + "$GIT_EXEC_PATH/git$X" init "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 || error "cannot run git init -- have you built things yet?" mv .git/hooks .git/hooks-disabled ) || exit diff --git a/t/test-lib.sh b/t/test-lib.sh index 9980a46133f01f..6e65569d1c4331 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -36,18 +36,27 @@ then fi GIT_BUILD_DIR="$TEST_DIRECTORY"/.. +if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS +then + echo >&2 'error: GIT-BUILD-OPTIONS missing (has Git been built?).' + exit 1 +fi + +. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS +export PERL_PATH SHELL_PATH + +test -z "$MSVC_DEPS" || +PATH="$GIT_BUILD_DIR/$MSVC_DEPS/bin:$PATH" + ################################################################ # It appears that people try to run tests without building... -"$GIT_BUILD_DIR/git" >/dev/null +"$GIT_BUILD_DIR/git$X" >/dev/null if test $? != 1 then echo >&2 'error: you do not seem to have built git yet.' exit 1 fi -. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS -export PERL_PATH SHELL_PATH - # if --tee was passed, write the output not only to the terminal, but # additionally to the file test-results/$BASENAME.out, too. case "$GIT_TEST_TEE_STARTED, $* " in From bdd78f9aec23d35da126813832cb0c39e416429f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 28 Nov 2016 15:54:59 +0100 Subject: [PATCH 45/45] msvc: add a Makefile target to pre-generate the VS solution The entire idea of generating the VS solution makes only sense if we generate it via Continuous Integration; otherwise potential users would still have to download the entire Git for Windows SDK. So let's just add a target in the Makefile that can be used to generate said solution; The generated files will then be committed so that they can be pushed to a branch ready to check out by Visual Studio users. To make things even more useful, we also generate and commit other files that are required to run the test suite, such as templates and bin-wrappers: with this, developers can run the test suite in a regular Git Bash (that is part of a regular Git for Windows installation) after building the solution in Visual Studio. Signed-off-by: Johannes Schindelin --- config.mak.uname | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/config.mak.uname b/config.mak.uname index 6e01bd532f78c9..b4989b013cef4d 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -447,6 +447,65 @@ endif X = .exe compat/msvc.o: compat/msvc.c compat/mingw.c GIT-CFLAGS + +vcxproj: + # Require clean work tree + git update-index -q --refresh && \ + git diff-files --quiet && \ + git diff-index --cached --quiet HEAD -- + + # Make .vcxproj files and add them + unset QUIET_GEN QUIET_BUILT_IN; \ + perl contrib/buildsystems/generate -g Vcxproj + git add -f git.sln {*,*/lib,t/helper/*}/{packages.config,*.vcxproj} + + # Add common-cmds.h + $(MAKE) MSVC=1 prefix=/mingw64 common-cmds.h + git add -f common-cmds.h + + # Add scripts + rm -f perl/perl.mak + $(MAKE) MSVC=1 prefix=/mingw64 \ + $(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN) + # Strip out the sane tool path, needed only for building + sed -i '/^git_broken_path_fix ".*/d' git-sh-setup + git add -f $(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN) + + # Add Perl module + $(MAKE) -C perl + git add -f perl/blib/lib + + # Add bin-wrappers, for testing + rm -rf bin-wrappers/ + $(MAKE) MSVC=1 prefix=/mingw64 $(test_bindir_programs) + # Ensure that the GIT_EXEC_PATH is a Unix-y one, and that the absolute + # path of the repository is not hard-coded (GIT_EXEC_PATH will be set + # by test-lib.sh according to the current setup) + sed -i -e 's/^\(GIT_EXEC_PATH\)=.*/test -n "$${\1##*:*}" ||\ + \1="$$(cygpath -u "$$\1")"/' \ + -e "s|'$$(pwd)|\"\$$GIT_EXEC_PATH\"'|g" bin-wrappers/* + # Ensure that test-* helpers find the .dll files copied to top-level + sed -i 's|^PATH=.*|&:"$$GIT_EXEC_PATH"|' bin-wrappers/test-* + # We do not want to force hard-linking builtins + sed -i 's|\(git\)-\([-a-z]*\)\.exe"|\1.exe" \2|g' \ + bin-wrappers/git-{receive-pack,upload-archive} + git add -f $(test_bindir_programs) + # remote-ext is a builtin, but invoked as if it were external + sed 's|receive-pack|remote-ext|g' \ + bin-wrappers/git-remote-ext + git add -f bin-wrappers/git-remote-ext + + # Add templates + $(MAKE) -C templates + git add -f templates/boilerplates.made templates/blt/ + + # Add build options + $(MAKE) MSVC=1 prefix=/mingw64 GIT-BUILD-OPTIONS + git add -f GIT-BUILD-OPTIONS + + # Commit the whole shebang + git commit -m "Generate Visual Studio solution" \ + -m "Auto-generated by \`$(MAKE)$(MAKEFLAGS) $@\`" endif ifeq ($(uname_S),Interix) NO_INITGROUPS = YesPlease