Skip to content

Commit cb01580

Browse files
committed
Apply some v2.48 regression bugfixes (#5376)
Now that most of the Git contributors are back from the holidays, there is an influx of bug fixes. This is precisely why I held off from rushing Git for Windows v2.48.0 out the door. These bug fixes are mostly taken from upstream's branches; In some cases, though, I had to apply them directly from the Git mailing list because they did not make it into git/git yet. I deem those bug fixes necessary to get Git for Windows into a somewhat healthy state again.
2 parents 59e918f + c8a0e17 commit cb01580

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+519
-236
lines changed

Documentation/git-show-index.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ git-show-index - Show packed archive index
99
SYNOPSIS
1010
--------
1111
[verse]
12-
'git show-index' [--object-format=<hash-algorithm>]
12+
'git show-index' [--object-format=<hash-algorithm>] < <pack-idx-file>
1313

1414

1515
DESCRIPTION

builtin/branch.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
473473
if (verify_ref_format(format))
474474
die(_("unable to parse format string"));
475475

476-
filter_ahead_behind(the_repository, format, &array);
476+
filter_ahead_behind(the_repository, &array);
477477
ref_array_sort(sorting, &array);
478478

479479
if (column_active(colopts)) {
@@ -884,7 +884,6 @@ int cmd_branch(int argc,
884884
string_list_clear(&output, 0);
885885
ref_sorting_release(sorting);
886886
ref_filter_clear(&filter);
887-
ref_format_clear(&format);
888887

889888
ret = 0;
890889
goto out;

builtin/credential-cache--daemon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ static void serve_one_client(FILE *in, FILE *out)
142142
fprintf(out, "username=%s\n", e->item.username);
143143
if (e->item.password)
144144
fprintf(out, "password=%s\n", e->item.password);
145-
if (credential_has_capability(&c.capa_authtype, CREDENTIAL_OP_HELPER) && e->item.authtype)
145+
if (credential_has_capability(&c.capa_authtype, CREDENTIAL_OP_RESPONSE) && e->item.authtype)
146146
fprintf(out, "authtype=%s\n", e->item.authtype);
147-
if (credential_has_capability(&c.capa_authtype, CREDENTIAL_OP_HELPER) && e->item.credential)
147+
if (credential_has_capability(&c.capa_authtype, CREDENTIAL_OP_RESPONSE) && e->item.credential)
148148
fprintf(out, "credential=%s\n", e->item.credential);
149149
if (e->item.password_expiry_utc != TIME_MAX)
150150
fprintf(out, "password_expiry_utc=%"PRItime"\n",

builtin/fetch.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,9 +1618,9 @@ static void report_set_head(const char *remote, const char *head_name,
16181618
}
16191619

16201620
static int set_head(const struct ref *remote_refs, int follow_remote_head,
1621-
const char *no_warn_branch)
1621+
const char *no_warn_branch, int mirror)
16221622
{
1623-
int result = 0, create_only, is_bare, was_detached;
1623+
int result = 0, create_only, baremirror, was_detached;
16241624
struct strbuf b_head = STRBUF_INIT, b_remote_head = STRBUF_INIT,
16251625
b_local_head = STRBUF_INIT;
16261626
const char *remote = gtransport->remote->name;
@@ -1655,17 +1655,17 @@ static int set_head(const struct ref *remote_refs, int follow_remote_head,
16551655

16561656
if (!head_name)
16571657
goto cleanup;
1658-
is_bare = is_bare_repository();
1659-
create_only = follow_remote_head == FOLLOW_REMOTE_ALWAYS ? 0 : !is_bare;
1660-
if (is_bare) {
1658+
baremirror = is_bare_repository() && mirror;
1659+
create_only = follow_remote_head == FOLLOW_REMOTE_ALWAYS ? 0 : !baremirror;
1660+
if (baremirror) {
16611661
strbuf_addstr(&b_head, "HEAD");
16621662
strbuf_addf(&b_remote_head, "refs/heads/%s", head_name);
16631663
} else {
16641664
strbuf_addf(&b_head, "refs/remotes/%s/HEAD", remote);
16651665
strbuf_addf(&b_remote_head, "refs/remotes/%s/%s", remote, head_name);
16661666
}
16671667
/* make sure it's valid */
1668-
if (!is_bare && !refs_ref_exists(refs, b_remote_head.buf)) {
1668+
if (!baremirror && !refs_ref_exists(refs, b_remote_head.buf)) {
16691669
result = 1;
16701670
goto cleanup;
16711671
}
@@ -1925,7 +1925,8 @@ static int do_fetch(struct transport *transport,
19251925
}
19261926
}
19271927
if (set_head(remote_refs, transport->remote->follow_remote_head,
1928-
transport->remote->no_warn_branch))
1928+
transport->remote->no_warn_branch,
1929+
transport->remote->mirror))
19291930
;
19301931
/*
19311932
* Way too many cases where this can go wrong

builtin/for-each-ref.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ int cmd_for_each_ref(int argc,
108108
filter_and_format_refs(&filter, flags, sorting, &format);
109109

110110
ref_filter_clear(&filter);
111-
ref_format_clear(&format);
112111
ref_sorting_release(sorting);
113112
strvec_clear(&vec);
114113
return 0;

builtin/index-pack.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,18 @@ static const char *open_pack_file(const char *pack_name)
379379

380380
static void parse_pack_header(void)
381381
{
382-
struct pack_header *hdr = fill(sizeof(struct pack_header));
382+
unsigned char *hdr = fill(sizeof(struct pack_header));
383383

384384
/* Header consistency check */
385-
if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
385+
if (get_be32(hdr) != PACK_SIGNATURE)
386386
die(_("pack signature mismatch"));
387-
if (!pack_version_ok(hdr->hdr_version))
387+
hdr += 4;
388+
if (!pack_version_ok_native(get_be32(hdr)))
388389
die(_("pack version %"PRIu32" unsupported"),
389-
ntohl(hdr->hdr_version));
390+
get_be32(hdr));
391+
hdr += 4;
390392

391-
nr_objects = ntohl(hdr->hdr_entries);
393+
nr_objects = get_be32(hdr);
392394
use(sizeof(struct pack_header));
393395
}
394396

@@ -1954,19 +1956,11 @@ int cmd_index_pack(int argc,
19541956
warning(_("no threads support, ignoring %s"), arg);
19551957
nr_threads = 1;
19561958
}
1957-
} else if (starts_with(arg, "--pack_header=")) {
1958-
struct pack_header *hdr;
1959-
char *c;
1960-
1961-
hdr = (struct pack_header *)input_buffer;
1962-
hdr->hdr_signature = htonl(PACK_SIGNATURE);
1963-
hdr->hdr_version = htonl(strtoul(arg + 14, &c, 10));
1964-
if (*c != ',')
1965-
die(_("bad %s"), arg);
1966-
hdr->hdr_entries = htonl(strtoul(c + 1, &c, 10));
1967-
if (*c)
1968-
die(_("bad %s"), arg);
1969-
input_len = sizeof(*hdr);
1959+
} else if (skip_prefix(arg, "--pack_header=", &arg)) {
1960+
if (parse_pack_header_option(arg,
1961+
input_buffer,
1962+
&input_len) < 0)
1963+
die(_("bad --pack_header: %s"), arg);
19701964
} else if (!strcmp(arg, "-v")) {
19711965
verbose = 1;
19721966
} else if (!strcmp(arg, "--progress-title")) {

builtin/show-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "parse-options.h"
1010

1111
static const char *const show_index_usage[] = {
12-
"git show-index [--object-format=<hash-algorithm>]",
12+
"git show-index [--object-format=<hash-algorithm>] < <pack-idx-file>",
1313
NULL
1414
};
1515

builtin/tag.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,6 @@ int cmd_tag(int argc,
698698
cleanup:
699699
ref_sorting_release(sorting);
700700
ref_filter_clear(&filter);
701-
ref_format_clear(&format);
702701
strbuf_release(&buf);
703702
strbuf_release(&ref);
704703
strbuf_release(&reflog_msg);

builtin/unpack-objects.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "progress.h"
1919
#include "decorate.h"
2020
#include "fsck.h"
21+
#include "packfile.h"
2122

2223
static int dry_run, quiet, recover, has_errors, strict;
2324
static const char unpack_usage[] = "git unpack-objects [-n] [-q] [-r] [--strict]";
@@ -578,15 +579,16 @@ static void unpack_one(unsigned nr)
578579
static void unpack_all(void)
579580
{
580581
int i;
581-
struct pack_header *hdr = fill(sizeof(struct pack_header));
582+
unsigned char *hdr = fill(sizeof(struct pack_header));
582583

583-
nr_objects = ntohl(hdr->hdr_entries);
584-
585-
if (ntohl(hdr->hdr_signature) != PACK_SIGNATURE)
584+
if (get_be32(hdr) != PACK_SIGNATURE)
586585
die("bad pack file");
587-
if (!pack_version_ok(hdr->hdr_version))
586+
hdr += 4;
587+
if (!pack_version_ok_native(get_be32(hdr)))
588588
die("unknown pack file version %"PRIu32,
589-
ntohl(hdr->hdr_version));
589+
get_be32(hdr));
590+
hdr += 4;
591+
nr_objects = get_be32(hdr);
590592
use(sizeof(struct pack_header));
591593

592594
if (!quiet)
@@ -644,19 +646,10 @@ int cmd_unpack_objects(int argc,
644646
fsck_set_msg_types(&fsck_options, arg);
645647
continue;
646648
}
647-
if (starts_with(arg, "--pack_header=")) {
648-
struct pack_header *hdr;
649-
char *c;
650-
651-
hdr = (struct pack_header *)buffer;
652-
hdr->hdr_signature = htonl(PACK_SIGNATURE);
653-
hdr->hdr_version = htonl(strtoul(arg + 14, &c, 10));
654-
if (*c != ',')
655-
die("bad %s", arg);
656-
hdr->hdr_entries = htonl(strtoul(c + 1, &c, 10));
657-
if (*c)
658-
die("bad %s", arg);
659-
len = sizeof(*hdr);
649+
if (skip_prefix(arg, "--pack_header=", &arg)) {
650+
if (parse_pack_header_option(arg,
651+
buffer, &len) < 0)
652+
die(_("bad --pack_header: %s"), arg);
660653
continue;
661654
}
662655
if (skip_prefix(arg, "--max-input-size=", &arg)) {

builtin/verify-tag.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,5 @@ int cmd_verify_tag(int argc,
6969
if (format.format)
7070
pretty_print_ref(name, &oid, &format);
7171
}
72-
ref_format_clear(&format);
7372
return had_error;
7473
}

0 commit comments

Comments
 (0)