diff --git a/.gitignore b/.gitignore index 0af86fb7e05ee1..bf3acc08b7f8ae 100644 --- a/.gitignore +++ b/.gitignore @@ -179,6 +179,7 @@ /gitweb/gitweb.cgi /gitweb/static/gitweb.js /gitweb/static/gitweb.min.* +/libgit /test-chmtime /test-ctype /test-config @@ -213,6 +214,8 @@ /test-urlmatch-normalization /test-wildmatch /common-cmds.h +/vcs-svn_lib +/xdiff_lib *.tar.gz *.dsc *.deb @@ -250,8 +253,9 @@ *.user *.idb *.pdb -/Debug/ -/Release/ +*.manifest +Debug/ +Release/ /.vagrant/ /vagrant2[0-9][0-9][0-9]*-*-* /d2[0-9][0-9][0-9]*-*-* diff --git a/Makefile b/Makefile index 33b0f76fd6da0d..23aa408a3d3a83 100644 --- a/Makefile +++ b/Makefile @@ -1973,7 +1973,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/builtin/rev-list.c b/builtin/rev-list.c index 275da0d647ebe1..deae1f3159966f 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -377,7 +377,7 @@ 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; + int reaches = 0, all = 0; revs.commits = find_bisection(revs.commits, &reaches, &all, bisect_find_all); diff --git a/compat/mingw.c b/compat/mingw.c index e2e5d2f6b776de..fab6d117735201 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2287,7 +2287,7 @@ int symlink(const char *target, const char *link) return 0; } -#ifndef _WINNT_H +#if !defined(_WINNT_H) && !defined(_MSC_VER) /* * The REPARSE_DATA_BUFFER structure is defined in the Windows DDK (in * ntifs.h) and in MSYS1's winnt.h (which defines _WINNT_H). So define diff --git a/compat/mingw.h b/compat/mingw.h index aa989e376a964a..ba81a160d28d47 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -6,6 +6,14 @@ typedef _sigset_t sigset_t; #include #include +#pragma comment(lib, "Ws2_32.lib") +/* add the MS linker for winsock2 when compiling on Visual Studio + https://msdn.microsoft.com/en-us/library/windows/desktop/ms737629%28v=vs.85%29.aspx*/ + +#pragma comment(lib, "wldap32.lib") +/* some ()https://curl.haxx.se/mail/lib-2007-11/0297.html) report that this clears the +unresolved external symbol __imp__curl_* errors */ + /* MinGW-w64 reports to have flockfile, but it does not actually have it. */ #ifdef __MINGW64_VERSION_MAJOR #undef _POSIX_THREAD_SAFE_FUNCTIONS diff --git a/compat/msvc.h b/compat/msvc.h index 580bb55bf4a71d..6eabfa6ba253bd 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 @@ -24,6 +28,52 @@ static __inline int strcasecmp (const char *s1, const char *s2) #undef ERROR +#ifdef _MSC_VER +typedef int sigset_t; +#define O_ACCMODE _O_RDWR /* open for reading and writing (not in fcntl.h) */ + +/* http://thompsonng.blogspot.co.uk/2011/09/vs2010-fseeko.html */ +#ifdef _WIN32 +# ifdef __MINGW32__ +# define fseeko fseeko64 +# define ftello ftello64 +# else +# define fseeko _fseeki64 +# define ftello _ftelli64 +# endif +#endif + +/* https://msdn.microsoft.com/en-us/library/ff552012.aspx */ +typedef struct _REPARSE_DATA_BUFFER { + ULONG ReparseTag; + USHORT ReparseDataLength; + USHORT Reserved; + union { + struct { + USHORT SubstituteNameOffset; + USHORT SubstituteNameLength; + USHORT PrintNameOffset; + USHORT PrintNameLength; + ULONG Flags; + WCHAR PathBuffer[1]; + } SymbolicLinkReparseBuffer; + struct { + USHORT SubstituteNameOffset; + USHORT SubstituteNameLength; + USHORT PrintNameOffset; + USHORT PrintNameLength; + WCHAR PathBuffer[1]; + } MountPointReparseBuffer; + struct { + UCHAR DataBuffer[1]; + } GenericReparseBuffer; + }; +} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; + +/* in the absence of the ntifs.h DDK (device driver development kit) */ + +#endif + #include "compat/mingw.h" #endif diff --git a/compat/regex/regcomp.c b/compat/regex/regcomp.c index fba5986399ed20..1c5824999ea3e1 100644 --- a/compat/regex/regcomp.c +++ b/compat/regex/regcomp.c @@ -18,7 +18,11 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#if defined(_MSC_VER) && _MSC_VER<=1500 + +#else #include +#endif static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, size_t length, reg_syntax_t syntax); diff --git a/compat/terminal.c b/compat/terminal.c index 1d37f0aafbaeb7..8ca9fce2b229b8 100644 --- a/compat/terminal.c +++ b/compat/terminal.c @@ -1,6 +1,10 @@ -#include #include "git-compat-util.h" #include "run-command.h" +#if defined(_MSC_VER) && _MSC_VER<=1500 + +#else +#include +#endif #include "compat/terminal.h" #include "sigchain.h" #include "strbuf.h" diff --git a/compat/vcbuild/README b/compat/vcbuild/README index df8a6574c9ac24..faaea69852c448 100644 --- a/compat/vcbuild/README +++ b/compat/vcbuild/README @@ -3,20 +3,24 @@ The Steps of Build Git with VS2008 1. You need the build environment, which contains the Git dependencies to be able to compile, link and run Git with MSVC. - You can either use the binary repository: + You can either: + use the binary repository: WWW: http://repo.or.cz/w/msvcgit.git Git: git clone git://repo.or.cz/msvcgit.git Zip: http://repo.or.cz/w/msvcgit.git?a=snapshot;h=master;sf=zip - and call the setup_32bit_env.cmd batch script before compiling Git, - (see repo/package README for details), or the source repository: + and call the setup_32bit_env.cmd batch script before compiling Git, + (see repo/package README for details), + + or: + use the source repository: WWW: http://repo.or.cz/w/gitbuild.git Git: git clone git://repo.or.cz/gitbuild.git Zip: (None, as it's a project with submodules) - and build the support libs as instructed in that repo/package. + and build the support libs as instructed in that repo/package. 2. Ensure you have the msysgit environment in your path, so you have GNU Make, bash and perl available. @@ -33,18 +37,25 @@ The Steps of Build Git with VS2008 make common-cmds.h to generate the common-cmds.h file needed to compile git. -4. Then either build Git with the GNU Make Makefile in the Git projects - root +4. Then either + + build Git with the GNU Make Makefile in the Git projects root make MSVC=1 - or generate Visual Studio solution/projects (.sln/.vcproj) with the + or + + generate Visual Studio solution/projects (.sln/.vcproj) with the command perl contrib/buildsystems/generate -g Vcproj and open and build the solution with the IDE devenv git.sln /useenv - or build with the IDE build engine directly from the command line + or + + build with the IDE build engine directly from the command line devenv git.sln /useenv /build "Release|Win32" The /useenv option is required, so Visual Studio picks up the environment variables for the support libraries required to build Git, which you set up in step 1. Done! + +Or, use the msvc-build script; available from /compat/vcbuild/scripts/. diff --git a/compat/vcbuild/scripts/msvc-build b/compat/vcbuild/scripts/msvc-build new file mode 100755 index 00000000000000..d67203b51cb882 --- /dev/null +++ b/compat/vcbuild/scripts/msvc-build @@ -0,0 +1,86 @@ +#!/bin/sh + +# This msvc-build command should be executed from the msysgit directory level +# This is so that the 'cd/git' step works and the subequent operations have the right msysgit super directory. +set -e # Exit immediately if a command exits with a nonzero exit status. + +gui= +clean= +while test $# -gt 0 +do + case "$1" in + --gui|--dev|--devenv|--vs|--visual-studio) + gui=t + ;; + clean) + clean=t + ;; + *) + echo "Usage: $0 [--vs] [clean]" >&2 + exit 1 + ;; + esac + shift +done + +cd $(git rev-parse --show-toplevel) + +case "$clean" in +t) + case "$gui" in + t) + rm -rf git.sln git.sdf libgit vcs-svn_lib xdiff_lib + # remove any other new VS2010... stuff as well: rm -rf ? + ;; + '') + make clean + ;; + esac + exit + ;; +esac + +to_ignore="$(git ls-files --other --exclude-standard msvcgit msvc-build.cmd)" +test -z "$to_ignore" || { + mkdir -p .git/info && + echo "$to_ignore" | + sed 's/^/\//' >> .git/info/exclude +} || exit + +test -d msvcgit || git clone git://repo.or.cz/msvcgit.git + +vsvars= +# assume cl.exe will populate its relevant environment variables +# if cl.exe does not exist, populate vsvars with the most recent Visual Studio path +type cl.exe 2> /dev/null || +vsvars="$(ls -t \ + "$PROGRAMFILES/Microsoft Visual Studio"*/Common7/Tools/vsvars32.bat | + head -n 1)" + + +config_mak= +# if a config.mak file (dot, not underscore) exists, back it up, +# remember the backup file name in config_mak. +test -f config.mak && +config_mak=config.mak.bup.$$ && +mv config.mak $config_mak + +cat > config.mak << EOF +CFLAGS += -Imsvcgit/32bits/include +LDFLAGS += -Lmsvcgit/32bits/lib +EOF + +echo "call \"$vsvars\"" > msvc-build.cmd +if test -z "$gui" +then + echo 'make MSVC=1' >> msvc-build.cmd +else + echo 'perl contrib/buildsystems/generate -g Vcproj' >> msvc-build.cmd + echo 'start git.sln' >> msvc-build.cmd +fi + +cmd /c msvc-build.cmd + +# if we made a backup file (name in config_mak), then restore it. +test -z "$config_mak" || +mv $config_mak config.mak diff --git a/compat/win32.h b/compat/win32.h index a7b81dcd29fa41..dce893c8d47278 100644 --- a/compat/win32.h +++ b/compat/win32.h @@ -67,9 +67,11 @@ static inline void *get_proc_addr(struct proc_addr *proc) /* only do this once */ if (!proc->initialized) { proc->initialized = 1; - HANDLE hnd = LoadLibraryA(proc->dll); + { + HMODULE hnd = LoadLibraryA(proc->dll); if (hnd) proc->pfunction = GetProcAddress(hnd, proc->function); + } } /* set ENOSYS if DLL or function was not found */ if (!proc->pfunction) diff --git a/config.mak.uname b/config.mak.uname index ac81fddf6f893d..803bccb23c6dc2 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') @@ -370,6 +374,9 @@ ifeq ($(uname_S),Windows) NATIVE_CRLF = YesPlease DEFAULT_HELP_FORMAT = html + NO_EXPAT = + NO_CURL = + CC = compat/vcbuild/scripts/clink.pl AR = compat/vcbuild/scripts/lib.pl CFLAGS = @@ -383,6 +390,11 @@ ifeq ($(uname_S),Windows) PTHREAD_LIBS = lib = BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1 + +ifdef NO_SAFESEH + LDFLAGS += -SAFESEH:NO +endif + ifndef DEBUG BASIC_CFLAGS += -GL -Os -MD BASIC_LDFLAGS += -LTCG diff --git a/contrib/buildsystems/Generators/Vcproj.pm b/contrib/buildsystems/Generators/Vcproj.pm index cfa74adcc23881..0572ba8609670f 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}", @@ -63,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 { @@ -561,20 +567,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) { @@ -588,6 +592,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 @@ -599,17 +610,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"; diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 53e65d4db713c3..760f5bf56811cc 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(); @@ -40,6 +41,7 @@ sub showUsage # Parse command-line options while (@ARGV) { my $arg = shift @ARGV; + #print "Arg: $arg \n"; if ("$arg" eq "-h" || "$arg" eq "--help" || "$arg" eq "-?") { showUsage(); exit(0); @@ -72,7 +74,13 @@ 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 1>makedry.txt 2>$ErrsFile`; # capture the dry run as a text file +@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 $ErrsFile && -z _; # Parse the make output into usable info parseMakeOutput(); @@ -122,6 +130,7 @@ sub parseMakeOutput print "Parsing GNU Make output to figure out build structure...\n"; my $line = 0; while (my $text = shift @makedry) { + #print "Make: $text\n"; # show the makedry line my $ate_next; do { $ate_next = 0; @@ -140,6 +149,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); @@ -151,6 +166,10 @@ sub parseMakeOutput } elsif ($text =~ /\.o / && $text =~ /\.a /) { # libifying handleLibLine($text, $line); + + } elsif ($text =~ /^cp /) { + # Post-Build + handlePostBuild($text, $line); # # } elsif ($text =~ /^cp /) { # # copy file around @@ -228,10 +247,15 @@ sub removeDuplicates @cflags = keys %dupHash; } -sub handleCompileLine +sub handlePostBuild { my ($line, $lineno) = @_; my @parts = split(' ', $line); +} +sub handleCompileLine +{ + my ($line, $lineno) = @_; + my @parts = shellwords($line); my $sourcefile; shift(@parts); # ignore cmd while (my $part = shift @parts) { @@ -250,6 +274,7 @@ sub handleCompileLine } elsif ($part =~ /\.(c|cc|cpp)$/) { $sourcefile = $part; } else { + print "full line: $line\n"; die "Unhandled compiler option @ line $lineno: $part"; } } @@ -265,7 +290,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); @@ -275,6 +300,7 @@ sub handleLibLine $libout = $part; $libout =~ s/\.a$//; } else { + print "full line: $line\n"; die "Unhandled lib option @ line $lineno: $part"; } } @@ -306,7 +332,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/) { @@ -317,10 +343,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)$/) { @@ -333,7 +361,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"; 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/fast-import.c b/fast-import.c index 9fc7093406b1e2..ca66d802fc6722 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2935,7 +2935,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; + struct object_entry *oe = NULL; char output[42]; /* get-mark SP LF */ @@ -2952,7 +2952,7 @@ static void parse_get_mark(const char *p) static void parse_cat_blob(const char *p) { - struct object_entry *oe = oe; + 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 5d22c972fe7a6b..035e68f30e8828 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -145,6 +145,12 @@ #define _NETBSD_SOURCE 1 #define _SGI_SOURCE 1 +/* Not all versions of all compilers can cleanly determine + * if a variable either has been, or needs to be, initialized. + * Such variables can be initialized to this value so the + * developer does not need to reason about why the value is chosen*/ +#define SUPPRESS_UNINITIALIZD_WARNINGS 0 + #if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */ # if defined (_MSC_VER) && !defined(_WIN32_WINNT) # define _WIN32_WINNT 0x0502 diff --git a/merge-recursive.c b/merge-recursive.c index b880ae50e7ee4f..ff4852b4a6afe1 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1899,7 +1899,7 @@ int merge_recursive(struct merge_options *o, { struct commit_list *iter; struct commit *merged_common_ancestors; - struct tree *mrtree = mrtree; + struct tree *mrtree = NULL; int clean; if (show(o, 4)) { 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) diff --git a/read-cache.c b/read-cache.c index d9fb78bc559ac9..978d6b6484b4a5 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1870,7 +1870,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 */ + int saved_namelen = 0; char *name; int result; diff --git a/remote.c b/remote.c index fc02698587c61d..c3d811c4b8d76e 100644 --- a/remote.c +++ b/remote.c @@ -1659,7 +1659,7 @@ int branch_merge_matches(struct branch *branch, return refname_match(branch->merge[i]->src, refname); } -__attribute((format (printf,2,3))) +__attribute__((format (printf,2,3))) static const char *error_buf(struct strbuf *err, const char *fmt, ...) { if (err) { diff --git a/sideband.c b/sideband.c index fde8adc000f316..d448ba79190235 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 " " @@ -22,13 +22,13 @@ int recv_sideband(const char *me, int in_stream, int out) { - unsigned pf = strlen(PREFIX); + unsigned pf = strlen(DISPLAY_PREFIX); unsigned sf; char buf[LARGE_PACKET_MAX + 2*FIX_SIZE]; char *suffix, *term; int skip_pf = 0; - memcpy(buf, PREFIX, pf); + memcpy(buf, DISPLAY_PREFIX, pf); term = getenv("TERM"); if (isatty(2) && term && strcmp(term, "dumb")) suffix = ANSI_SUFFIX;