Skip to content

Commit 3345c83

Browse files
committed
Merge 'misc-vs-fixes' into HEAD
2 parents 874cf85 + d406a5d commit 3345c83

14 files changed

+46
-15
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,7 +2131,7 @@ exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX
21312131
exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
21322132
'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
21332133
'-DBINDIR="$(bindir_relative_SQ)"' \
2134-
'-DPREFIX="$(prefix_SQ)"'
2134+
'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
21352135

21362136
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
21372137
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
@@ -2428,7 +2428,7 @@ bin-wrappers/%: wrap-for-bin.sh
24282428
@mkdir -p bin-wrappers
24292429
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
24302430
-e 's|@@BUILD_DIR@@|$(shell pwd)|' \
2431-
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))|' < $< > $@ && \
2431+
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%$(X),$(@F))$(patsubst git%,$(X),$(filter $(@F),$(BINDIR_PROGRAMS_NEED_X)))|' < $< > $@ && \
24322432
chmod +x $@
24332433

24342434
# 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
@@ -393,6 +393,9 @@ ifeq ($(uname_S),Windows)
393393
compat/win32/dirent.o compat/win32/fscache.o
394394
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
395395
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
396+
# invalidcontinue.obj allows Git's source code to close the same file
397+
# handle twice, or to access the osfhandle of an already-closed stdout
398+
# See https://msdn.microsoft.com/en-us/library/ms235330.aspx
396399
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
397400
PTHREAD_LIBS =
398401
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
@@ -3003,7 +3003,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
30033003

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

30093009
/* get-mark SP <object> LF */
@@ -3020,7 +3020,7 @@ static void parse_get_mark(const char *p)
30203020

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

30263026
/* 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
@@ -2053,7 +2053,7 @@ int merge_recursive(struct merge_options *o,
20532053
{
20542054
struct commit_list *iter;
20552055
struct commit *merged_common_ancestors;
2056-
struct tree *mrtree = mrtree;
2056+
FAKE_INIT(struct tree *, mrtree, NULL);
20572057
int clean;
20582058

20592059
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
@@ -2065,7 +2065,7 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce,
20652065
struct strbuf *previous_name, struct ondisk_cache_entry *ondisk)
20662066
{
20672067
int size;
2068-
int saved_namelen = saved_namelen; /* compiler workaround */
2068+
FAKE_INIT(int, saved_namelen, 0);
20692069
int result;
20702070
static unsigned char padding[8] = { 0x00 };
20712071

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)