Skip to content

Commit 898c6e6

Browse files
committed
Merge 'misc-vs-fixes' into HEAD
2 parents cfea747 + 638624d commit 898c6e6

14 files changed

+46
-15
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX
21062106
exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
21072107
'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
21082108
'-DBINDIR="$(bindir_relative_SQ)"' \
2109-
'-DPREFIX="$(prefix_SQ)"'
2109+
'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
21102110

21112111
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
21122112
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
@@ -2403,7 +2403,7 @@ bin-wrappers/%: wrap-for-bin.sh
24032403
@mkdir -p bin-wrappers
24042404
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
24052405
-e 's|@@BUILD_DIR@@|$(shell pwd)|' \
2406-
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))|' < $< > $@ && \
2406+
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%$(X),$(@F))$(patsubst git%,$(X),$(filter $(@F),$(BINDIR_PROGRAMS_NEED_X)))|' < $< > $@ && \
24072407
chmod +x $@
24082408

24092409
# GNU make supports exporting all variables by "export" without parameters.

builtin/rev-list.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
395395
mark_edges_uninteresting(&revs, show_edge);
396396

397397
if (bisect_list) {
398-
int reaches = reaches, all = all;
398+
FAKE_INIT(int, reaches, 0);
399+
FAKE_INIT(int, all, 0);
399400

400401
revs.commits = find_bisection(revs.commits, &reaches, &all,
401402
bisect_find_all);

compat/obstack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ __extension__ \
493493
( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \
494494
((((h)->temp.tempint > 0 \
495495
&& (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \
496-
? (int) ((h)->next_free = (h)->object_base \
496+
? (ptrdiff_t) ((h)->next_free = (h)->object_base \
497497
= (h)->temp.tempint + (char *) (h)->chunk) \
498498
: (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))
499499

compat/terminal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#ifndef NO_INTTYPES_H
12
#include <inttypes.h>
3+
#endif
24
#include "git-compat-util.h"
35
#include "run-command.h"
46
#include "compat/terminal.h"

config.mak.uname

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ ifeq ($(uname_S),Windows)
391391
compat/win32/dirent.o compat/win32/fscache.o
392392
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
393393
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
394+
# invalidcontinue.obj allows Git's source code to close the same file
395+
# handle twice, or to access the osfhandle of an already-closed stdout
396+
# See https://msdn.microsoft.com/en-us/library/ms235330.aspx
394397
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
395398
PTHREAD_LIBS =
396399
lib =

exec_cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static const char *system_prefix(void)
2020
!(prefix = strip_path_suffix(argv0_path, GIT_EXEC_PATH)) &&
2121
!(prefix = strip_path_suffix(argv0_path, BINDIR)) &&
2222
!(prefix = strip_path_suffix(argv0_path, "git"))) {
23-
prefix = PREFIX;
23+
prefix = FALLBACK_RUNTIME_PREFIX;
2424
trace_printf("RUNTIME_PREFIX requested, "
2525
"but prefix computation failed. "
2626
"Using static fallback '%s'.\n", prefix);
@@ -45,7 +45,7 @@ void git_extract_argv0_path(const char *argv0)
4545

4646
static const char *system_prefix(void)
4747
{
48-
return PREFIX;
48+
return FALLBACK_RUNTIME_PREFIX;
4949
}
5050

5151
void git_extract_argv0_path(const char *argv0)

fast-import.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3002,7 +3002,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
30023002

30033003
static void parse_get_mark(const char *p)
30043004
{
3005-
struct object_entry *oe = oe;
3005+
FAKE_INIT(struct object_entry *, oe, NULL);
30063006
char output[GIT_MAX_HEXSZ + 2];
30073007

30083008
/* get-mark SP <object> LF */
@@ -3019,7 +3019,7 @@ static void parse_get_mark(const char *p)
30193019

30203020
static void parse_cat_blob(const char *p)
30213021
{
3022-
struct object_entry *oe = oe;
3022+
FAKE_INIT(struct object_entry *, oe, NULL);
30233023
struct object_id oid;
30243024

30253025
/* cat-blob SP <object> LF */

git-compat-util.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@
5151
#endif
5252
#endif
5353

54+
/*
55+
* Under certain circumstances Git's source code is cleverer than the C
56+
* compiler when the latter warns about some "uninitialized value", e.g. when
57+
* a value is both initialized and used under the same condition.
58+
*
59+
* GCC can be fooled to not spit out this warning by using the construct:
60+
* "int value = value;". Other C compilers are not that easily fooled and would
61+
* require a #pragma (which is not portable, and would litter the source code).
62+
*
63+
* To keep things simple, we only fool GCC, and initialize such values instead
64+
* when compiling with other C compilers.
65+
*/
66+
#ifdef __GNUC__
67+
#define FAKE_INIT(a, b, c) a b = b
68+
#else
69+
#define FAKE_INIT(a, b, c) a b = c
70+
#endif
5471

5572
/*
5673
* BUILD_ASSERT_OR_ZERO - assert a build-time dependency, as an expression.

merge-recursive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,7 @@ int merge_recursive(struct merge_options *o,
20152015
{
20162016
struct commit_list *iter;
20172017
struct commit *merged_common_ancestors;
2018-
struct tree *mrtree = mrtree;
2018+
FAKE_INIT(struct tree *, mrtree, NULL);
20192019
int clean;
20202020

20212021
if (show(o, 4)) {

perl/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ clean:
2222
$(RM) $(makfile).old
2323
$(RM) PM.stamp
2424

25+
ifneq (,$(wildcard PM.stamp))
2526
$(makfile): PM.stamp
27+
endif
2628

2729
ifdef NO_PERL_MAKEMAKER
2830
instdir_SQ = $(subst ','\'',$(prefix)/lib)

read-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,7 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce,
20682068
{
20692069
int size;
20702070
struct ondisk_cache_entry *ondisk;
2071-
int saved_namelen = saved_namelen; /* compiler workaround */
2071+
FAKE_INIT(int, saved_namelen, 0);
20722072
char *name;
20732073
int result;
20742074

sideband.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* the remote died unexpectedly. A flush() concludes the stream.
1414
*/
1515

16-
#define PREFIX "remote: "
16+
#define DISPLAY_PREFIX "remote: "
1717

1818
#define ANSI_SUFFIX "\033[K"
1919
#define DUMB_SUFFIX " "
@@ -50,7 +50,7 @@ int recv_sideband(const char *me, int in_stream, int out)
5050
switch (band) {
5151
case 3:
5252
strbuf_addf(&outbuf, "%s%s%s", outbuf.len ? "\n" : "",
53-
PREFIX, buf + 1);
53+
DISPLAY_PREFIX, buf + 1);
5454
retval = SIDEBAND_REMOTE_ERROR;
5555
break;
5656
case 2:
@@ -68,7 +68,7 @@ int recv_sideband(const char *me, int in_stream, int out)
6868
int linelen = brk - b;
6969

7070
if (!outbuf.len)
71-
strbuf_addstr(&outbuf, PREFIX);
71+
strbuf_addstr(&outbuf, DISPLAY_PREFIX);
7272
if (linelen > 0) {
7373
strbuf_addf(&outbuf, "%.*s%s%c",
7474
linelen, b, suffix, *brk);
@@ -82,8 +82,8 @@ int recv_sideband(const char *me, int in_stream, int out)
8282
}
8383

8484
if (*b)
85-
strbuf_addf(&outbuf, "%s%s",
86-
outbuf.len ? "" : PREFIX, b);
85+
strbuf_addf(&outbuf, "%s%s", outbuf.len ?
86+
"" : DISPLAY_PREFIX, b);
8787
break;
8888
case 1:
8989
write_or_die(out, buf + 1, len);

t/t5505-remote.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
830830
(
831831
cd six &&
832832
git remote rm origin &&
833+
mkdir -p .git/branches &&
833834
echo "$origin_url" >.git/branches/origin &&
834835
git remote rename origin origin &&
835836
test_path_is_missing .git/branches/origin &&
@@ -844,6 +845,7 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)'
844845
(
845846
cd seven &&
846847
git remote rm origin &&
848+
mkdir -p .git/branches &&
847849
echo "quux#foom" > .git/branches/origin &&
848850
git remote rename origin origin &&
849851
test_path_is_missing .git/branches/origin &&

t/t5516-fetch-push.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ test_expect_success 'fetch with branches' '
866866
mk_empty testrepo &&
867867
git branch second $the_first_commit &&
868868
git checkout second &&
869+
mkdir -p testrepo/.git/branches &&
869870
echo ".." > testrepo/.git/branches/branch1 &&
870871
(
871872
cd testrepo &&
@@ -879,6 +880,7 @@ test_expect_success 'fetch with branches' '
879880

880881
test_expect_success 'fetch with branches containing #' '
881882
mk_empty testrepo &&
883+
mkdir -p testrepo/.git/branches &&
882884
echo "..#second" > testrepo/.git/branches/branch2 &&
883885
(
884886
cd testrepo &&
@@ -893,6 +895,7 @@ test_expect_success 'fetch with branches containing #' '
893895
test_expect_success 'push with branches' '
894896
mk_empty testrepo &&
895897
git checkout second &&
898+
mkdir -p .git/branches &&
896899
echo "testrepo" > .git/branches/branch1 &&
897900
git push branch1 &&
898901
(
@@ -905,6 +908,7 @@ test_expect_success 'push with branches' '
905908

906909
test_expect_success 'push with branches containing #' '
907910
mk_empty testrepo &&
911+
mkdir -p .git/branches &&
908912
echo "testrepo#branch3" > .git/branches/branch2 &&
909913
git push branch2 &&
910914
(

0 commit comments

Comments
 (0)