Skip to content

Commit aa0c334

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
Prepare for v2.47.0.windows.2 (#5221)
At the moment, the Git maintainer is on vacation. While there _is_ an interim maintainer, it seems as if v2.47.1 will need to wait for "the end of the month". However, I do not have the luxury of waiting for the end of the month, as #5199 is stacking up comments relating various degrees of upset over the lack of a new Git for Windows version that fixes fetches/pushes via SSH. To make it truly worth the effort, let's integrate a couple of topics that have been integrated into upstream Git's `master` and `next` branches in the meantime, topics I consider important enough to be fast-tracked into a new Git for Windows version, since we already have the need for one: - 53d9f27 Merge branch 'jh/config-unset-doc-fix' Fixes incorrect documentation - a89881e Merge branch 'js/doc-platform-support-link-fix' Fixes broken links in the documentation - 784986f Merge branch 'jk/fsmonitor-event-listener-race-fix' CI-only: fixes 6h timeouts in the `osx-*` jobs - 59bf8d2 Merge branch 'ps/cache-tree-w-broken-index-entry' into next Fixes segmentation faults e.g. after a checkout failed due to invalid filenames and there is now a half-valid Git index - ffd5653 Merge branch 'pb/clar-build-fix' into next I suspect that this might cause some flakiness in (parallel) CI builds, even if I have not personally noticed those flakes. - fe0f4bc Merge branch 'db/submodule-fetch-with-remote-name-fix' into next Seems like a bug fix submodule users might want - 6860bff Merge branch 'sk/msvc-warnings' into next This _should_ only affect builds with MS Visual C (which Git for Windows does not use for the official builds), it's still a good idea to do, if only to align with upstream Git's code.
2 parents 2f1d903 + 2a67747 commit aa0c334

File tree

6 files changed

+49
-12
lines changed

6 files changed

+49
-12
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3974,6 +3974,7 @@ $(UNIT_TEST_DIR)/clar-decls.h: $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUI
39743974
done >$@
39753975
$(UNIT_TEST_DIR)/clar.suite: $(UNIT_TEST_DIR)/clar-decls.h
39763976
$(QUIET_GEN)awk -f $(UNIT_TEST_DIR)/clar-generate.awk $< >$(UNIT_TEST_DIR)/clar.suite
3977+
$(UNIT_TEST_DIR)/clar/clar.o: $(UNIT_TEST_DIR)/clar.suite
39773978
$(CLAR_TEST_OBJS): $(UNIT_TEST_DIR)/clar-decls.h
39783979
$(CLAR_TEST_OBJS): EXTRA_CPPFLAGS = -I$(UNIT_TEST_DIR)
39793980
$(CLAR_TEST_PROG): $(UNIT_TEST_DIR)/clar.suite $(CLAR_TEST_OBJS) $(GITLIBS) GIT-LDFLAGS

builtin/submodule--helper.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2333,7 +2333,14 @@ static int fetch_in_submodule(const char *module_path, int depth, int quiet,
23332333
strvec_pushf(&cp.args, "--depth=%d", depth);
23342334
if (oid) {
23352335
char *hex = oid_to_hex(oid);
2336-
char *remote = get_default_remote();
2336+
char *remote;
2337+
int code;
2338+
2339+
code = get_default_remote_submodule(module_path, &remote);
2340+
if (code) {
2341+
child_process_clear(&cp);
2342+
return code;
2343+
}
23372344

23382345
strvec_pushl(&cp.args, remote, hex, NULL);
23392346
free(remote);

compat/compiler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
static inline void get_compiler_info(struct strbuf *info)
1111
{
12-
int len = info->len;
12+
size_t len = info->len;
1313
#ifdef __clang__
1414
strbuf_addf(info, "clang: %s\n", __clang_version__);
1515
#elif defined(__GNUC__)
@@ -27,7 +27,7 @@ static inline void get_compiler_info(struct strbuf *info)
2727

2828
static inline void get_libc_info(struct strbuf *info)
2929
{
30-
int len = info->len;
30+
size_t len = info->len;
3131

3232
#ifdef __GLIBC__
3333
strbuf_addf(info, "glibc: %s\n", gnu_get_libc_version());

compat/mingw.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ int mingw_chmod(const char *filename, int mode)
10491049
*/
10501050
static int has_valid_directory_prefix(wchar_t *wfilename)
10511051
{
1052-
int n = wcslen(wfilename);
1052+
size_t n = wcslen(wfilename);
10531053

10541054
while (n > 0) {
10551055
wchar_t c = wfilename[--n];
@@ -1628,7 +1628,8 @@ static const char *parse_interpreter(const char *cmd)
16281628
{
16291629
static char buf[MAX_PATH];
16301630
char *p, *opt;
1631-
int n, fd;
1631+
ssize_t n; /* read() can return negative values */
1632+
int fd;
16321633

16331634
/* don't even try a .exe */
16341635
n = strlen(cmd);
@@ -1752,7 +1753,7 @@ static char *path_lookup(const char *cmd, int exe_only)
17521753
{
17531754
const char *path;
17541755
char *prog = NULL;
1755-
int len = strlen(cmd);
1756+
size_t len = strlen(cmd);
17561757
int isexe = len >= 4 && !strcasecmp(cmd+len-4, ".exe");
17571758

17581759
if (strpbrk(cmd, "/\\"))
@@ -2389,7 +2390,7 @@ char *mingw_getenv(const char *name)
23892390
#define GETENV_MAX_RETAIN 64
23902391
static char *values[GETENV_MAX_RETAIN];
23912392
static int value_counter;
2392-
int len_key, len_value;
2393+
size_t len_key, len_value;
23932394
wchar_t *w_key;
23942395
char *value;
23952396
wchar_t w_value[32768];
@@ -2401,7 +2402,8 @@ char *mingw_getenv(const char *name)
24012402
/* We cannot use xcalloc() here because that uses getenv() itself */
24022403
w_key = calloc(len_key, sizeof(wchar_t));
24032404
if (!w_key)
2404-
die("Out of memory, (tried to allocate %u wchar_t's)", len_key);
2405+
die("Out of memory, (tried to allocate %"PRIuMAX" wchar_t's)",
2406+
(uintmax_t)len_key);
24052407
xutftowcs(w_key, name, len_key);
24062408
/* GetEnvironmentVariableW() only sets the last error upon failure */
24072409
SetLastError(ERROR_SUCCESS);
@@ -2416,7 +2418,8 @@ char *mingw_getenv(const char *name)
24162418
/* We cannot use xcalloc() here because that uses getenv() itself */
24172419
value = calloc(len_value, sizeof(char));
24182420
if (!value)
2419-
die("Out of memory, (tried to allocate %u bytes)", len_value);
2421+
die("Out of memory, (tried to allocate %"PRIuMAX" bytes)",
2422+
(uintmax_t)len_value);
24202423
xwcstoutf(value, w_value, len_value);
24212424

24222425
/*
@@ -2434,7 +2437,7 @@ char *mingw_getenv(const char *name)
24342437

24352438
int mingw_putenv(const char *namevalue)
24362439
{
2437-
int size;
2440+
size_t size;
24382441
wchar_t *wide, *equal;
24392442
BOOL result;
24402443

@@ -2444,7 +2447,8 @@ int mingw_putenv(const char *namevalue)
24442447
size = strlen(namevalue) * 2 + 1;
24452448
wide = calloc(size, sizeof(wchar_t));
24462449
if (!wide)
2447-
die("Out of memory, (tried to allocate %u wchar_t's)", size);
2450+
die("Out of memory, (tried to allocate %" PRIuMAX " wchar_t's)",
2451+
(uintmax_t)size);
24482452
xutftowcs(wide, namevalue, size);
24492453
equal = wcschr(wide, L'=');
24502454
if (!equal)
@@ -4072,7 +4076,8 @@ static BOOL WINAPI handle_ctrl_c(DWORD ctrl_type)
40724076
*/
40734077
int wmain(int argc, const wchar_t **wargv)
40744078
{
4075-
int i, maxlen, exit_status;
4079+
int i, exit_status;
4080+
size_t maxlen;
40764081
char *buffer, **save;
40774082
const char **argv;
40784083

compat/vcbuild/include/unistd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ typedef _mode_t mode_t;
1414

1515
#ifndef _SSIZE_T_
1616
#define _SSIZE_T_
17+
#ifdef _WIN64
18+
typedef __int64 _ssize_t;
19+
#else
1720
typedef long _ssize_t;
21+
#endif /* _WIN64 */
1822

1923
#ifndef _OFF_T_
2024
#define _OFF_T_

t/t5572-pull-submodule.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ test_expect_success 'branch has no merge base with remote-tracking counterpart'
230230
231231
test_create_repo a-submodule &&
232232
test_commit -C a-submodule foo &&
233+
test_commit -C a-submodule bar &&
233234
234235
test_create_repo parent &&
235236
git -C parent submodule add "$(pwd)/a-submodule" &&
@@ -246,4 +247,23 @@ test_expect_success 'branch has no merge base with remote-tracking counterpart'
246247
git -C child pull --recurse-submodules --rebase
247248
'
248249

250+
test_expect_success 'fetch submodule remote of different name from superproject' '
251+
git -C child remote rename origin o1 &&
252+
git -C child submodule update --init &&
253+
254+
# Needs to create unreachable commit from current master branch.
255+
git -C a-submodule checkout -b newmain HEAD^ &&
256+
test_commit -C a-submodule echo &&
257+
test_commit -C a-submodule moreecho &&
258+
subc=$(git -C a-submodule rev-parse --short HEAD) &&
259+
260+
git -C parent/a-submodule fetch &&
261+
git -C parent/a-submodule checkout "$subc" &&
262+
git -C parent commit -m "update submodule" a-submodule &&
263+
git -C a-submodule reset --hard HEAD^^ &&
264+
265+
git -C child pull --no-recurse-submodules &&
266+
git -C child submodule update
267+
'
268+
249269
test_done

0 commit comments

Comments
 (0)