Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Documentation/RelNotes/2.54.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ Performance, Internal Implementation, Development Support etc.
mnemonic notation for certain control characters like "\t", instead
of octal notation like "\011".

* Adjust test-lint to allow "sed -E" to use ERE in the patterns.


Fixes since v2.53
-----------------
Expand Down Expand Up @@ -344,6 +346,18 @@ Fixes since v2.53
work better with SHA-256 as well as SHA-1.
(merge 30310f3cc4 ss/t3200-test-zero-oid later to maint).

* Instead of hardcoded 'origin', use the configured default remote
when fetching from submodules.
(merge 3b5fb32da8 ng/submodule-default-remote later to maint).

* The code in "git help" that shows configuration items in sorted
order was awkwardly organized and prone to bugs.

* "imap-send" used to use functions whose use is going to be removed
with OpenSSL 4.0; rewrite them using public API that has been
available since OpenSSL 1.1 since 2016 or so.
(merge 6392a0b75d bb/imap-send-openssl-4.0-prep later to maint).

* Other code cleanup, docfix, build fix, etc.
(merge d79fff4a11 jk/remote-tracking-ref-leakfix later to maint).
(merge 7a747f972d dd/t5403-modernise later to maint).
Expand Down Expand Up @@ -385,3 +399,5 @@ Fixes since v2.53
(merge 4c223571be ty/patch-ids-document-lazy-eval later to maint).
(merge 476365ac85 jc/doc-wholesale-replace-before-next later to maint).
(merge 35f220b639 ss/submodule--helper-use-xmalloc later to maint).
(merge 02cbae61df cf/constness-fixes later to maint).
(merge 69efd53c81 ms/t7605-test-path-is-helpers later to maint).
4 changes: 2 additions & 2 deletions bloom.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,
struct hashmap_iter iter;

for (i = 0; i < diff_queued_diff.nr; i++) {
const char *path = diff_queued_diff.queue[i]->two->path;
char *path = diff_queued_diff.queue[i]->two->path;

/*
* Add each leading directory of the changed file, i.e. for
Expand All @@ -523,7 +523,7 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,
free(e);

if (!last_slash)
last_slash = (char*)path;
last_slash = path;
*last_slash = '\0';

} while (*path);
Expand Down
91 changes: 56 additions & 35 deletions builtin/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,49 @@ struct slot_expansion {
int found;
};

static void set_config_vars(struct string_list *keys_uniq, struct string_list_item *var)
{
struct strbuf sb = STRBUF_INIT;
const char *str = var->string;
const char *wildcard = strchr(str, '*');
const char *tag = strchr(str, '<');
const char *cut;

if (wildcard && tag)
cut = wildcard < tag ? wildcard : tag;
else if (wildcard)
cut = wildcard;
else if (tag)
cut = tag;
else {
string_list_append(keys_uniq, str);
return;
}

strbuf_add(&sb, str, cut - str);
string_list_append(keys_uniq, sb.buf);
strbuf_release(&sb);
}

static void set_config_sections(struct string_list *keys_uniq, struct string_list_item *var)
{
struct strbuf sb = STRBUF_INIT;
const char *str = var->string;
const char *dot = strchr(str, '.');
const char *cut;

if (dot)
cut = dot;
else {
set_config_vars(keys_uniq, var);
return;
}

strbuf_add(&sb, str, cut - str);
string_list_append(keys_uniq, sb.buf);
strbuf_release(&sb);
}

static void list_config_help(enum show_config_type type)
{
struct slot_expansion slot_expansions[] = {
Expand All @@ -134,13 +177,12 @@ static void list_config_help(enum show_config_type type)
struct string_list keys = STRING_LIST_INIT_DUP;
struct string_list keys_uniq = STRING_LIST_INIT_DUP;
struct string_list_item *item;
struct strbuf sb = STRBUF_INIT;

for (p = config_name_list; *p; p++) {
const char *var = *p;
struct strbuf sb = STRBUF_INIT;

for (e = slot_expansions; e->prefix; e++) {

strbuf_reset(&sb);
strbuf_addf(&sb, "%s.%s", e->prefix, e->placeholder);
if (!strcasecmp(var, sb.buf)) {
Expand All @@ -149,60 +191,39 @@ static void list_config_help(enum show_config_type type)
break;
}
}
strbuf_release(&sb);

if (!e->prefix)
string_list_append(&keys, var);
}

strbuf_release(&sb);

for (e = slot_expansions; e->prefix; e++)
if (!e->found)
BUG("slot_expansion %s.%s is not used",
e->prefix, e->placeholder);

string_list_sort(&keys);
for (size_t i = 0; i < keys.nr; i++) {
const char *var = keys.items[i].string;
const char *wildcard, *tag, *cut;
const char *dot = NULL;
struct strbuf sb = STRBUF_INIT;

switch (type) {
case SHOW_CONFIG_HUMAN:
puts(var);
continue;
string_list_append(&keys_uniq, keys.items[i].string);
break;
case SHOW_CONFIG_SECTIONS:
dot = strchr(var, '.');
set_config_sections(&keys_uniq, &keys.items[i]);
break;
case SHOW_CONFIG_VARS:
set_config_vars(&keys_uniq, &keys.items[i]);
break;
default:
BUG("%d: unexpected type", type);
}
wildcard = strchr(var, '*');
tag = strchr(var, '<');

if (!dot && !wildcard && !tag) {
string_list_append(&keys_uniq, var);
continue;
}

if (dot)
cut = dot;
else if (wildcard && !tag)
cut = wildcard;
else if (!wildcard && tag)
cut = tag;
else
cut = wildcard < tag ? wildcard : tag;

strbuf_add(&sb, var, cut - var);
string_list_append(&keys_uniq, sb.buf);
strbuf_release(&sb);

}
string_list_clear(&keys, 0);
string_list_remove_duplicates(&keys_uniq, 0);

string_list_sort_u(&keys_uniq, 0);
for_each_string_list_item(item, &keys_uniq)
puts(item->string);
string_list_clear(&keys_uniq, 0);
string_list_clear(&keys, 0);
}

static enum help_format parse_help_format(const char *format)
Expand Down
19 changes: 9 additions & 10 deletions builtin/mktree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*
* Copyright (c) Junio C Hamano, 2006, 2009
*/
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "gettext.h"
#include "hex.h"
Expand Down Expand Up @@ -46,7 +45,7 @@ static int ent_compare(const void *a_, const void *b_)
b->name, b->len, b->mode);
}

static void write_tree(struct object_id *oid)
static void write_tree(struct repository *repo, struct object_id *oid)
{
struct strbuf buf;
size_t size;
Expand All @@ -60,10 +59,10 @@ static void write_tree(struct object_id *oid)
for (i = 0; i < used; i++) {
struct treeent *ent = entries[i];
strbuf_addf(&buf, "%o %s%c", ent->mode, ent->name, '\0');
strbuf_add(&buf, ent->oid.hash, the_hash_algo->rawsz);
strbuf_add(&buf, ent->oid.hash, repo->hash_algo->rawsz);
}

odb_write_object(the_repository->objects, buf.buf, buf.len, OBJ_TREE, oid);
odb_write_object(repo->objects, buf.buf, buf.len, OBJ_TREE, oid);
strbuf_release(&buf);
}

Expand All @@ -72,7 +71,7 @@ static const char *const mktree_usage[] = {
NULL
};

static void mktree_line(char *buf, int nul_term_line, int allow_missing)
static void mktree_line(struct repository *repo, char *buf, int nul_term_line, int allow_missing)
{
char *ptr, *ntr;
const char *p;
Expand All @@ -93,7 +92,7 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)
die("input format error: %s", buf);
ptr = ntr + 1; /* type */
ntr = strchr(ptr, ' ');
if (!ntr || parse_oid_hex(ntr + 1, &oid, &p) ||
if (!ntr || parse_oid_hex_algop(ntr + 1, &oid, &p, repo->hash_algo) ||
*p != '\t')
die("input format error: %s", buf);

Expand Down Expand Up @@ -124,7 +123,7 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)

/* Check the type of object identified by oid without fetching objects */
oi.typep = &obj_type;
if (odb_read_object_info_extended(the_repository->objects, &oid, &oi,
if (odb_read_object_info_extended(repo->objects, &oid, &oi,
OBJECT_INFO_LOOKUP_REPLACE |
OBJECT_INFO_QUICK |
OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)
Expand Down Expand Up @@ -155,7 +154,7 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)
int cmd_mktree(int ac,
const char **av,
const char *prefix,
struct repository *repo UNUSED)
struct repository *repo)
{
struct strbuf sb = STRBUF_INIT;
struct object_id oid;
Expand Down Expand Up @@ -187,7 +186,7 @@ int cmd_mktree(int ac,
break;
die("input format error: (blank line only valid in batch mode)");
}
mktree_line(sb.buf, nul_term_line, allow_missing);
mktree_line(repo, sb.buf, nul_term_line, allow_missing);
}
if (is_batch_mode && got_eof && used < 1) {
/*
Expand All @@ -197,7 +196,7 @@ int cmd_mktree(int ac,
*/
; /* skip creating an empty tree */
} else {
write_tree(&oid);
write_tree(repo, &oid);
puts(oid_to_hex(&oid));
fflush(stdout);
}
Expand Down
38 changes: 38 additions & 0 deletions builtin/submodule--helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,43 @@ static int get_default_remote_submodule(const char *module_path, char **default_
return 0;
}

static int module_get_default_remote(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
const char *path;
char *resolved_path = NULL;
char *default_remote = NULL;
int code;
struct option options[] = {
OPT_END()
};
const char *const usage[] = {
N_("git submodule--helper get-default-remote <path>"),
NULL
};

argc = parse_options(argc, argv, prefix, options, usage, 0);
if (argc != 1)
usage_with_options(usage, options);

path = argv[0];
if (prefix && *prefix && !is_absolute_path(path)) {
resolved_path = xstrfmt("%s%s", prefix, path);
path = resolved_path;
}

code = get_default_remote_submodule(path, &default_remote);
if (code) {
free(resolved_path);
return code;
}

printf("%s\n", default_remote);
free(default_remote);
free(resolved_path);
return 0;
}

/* the result should be freed by the caller. */
static char *get_submodule_displaypath(const char *path, const char *prefix,
const char *super_prefix)
Expand Down Expand Up @@ -3789,6 +3826,7 @@ int cmd_submodule__helper(int argc,
OPT_SUBCOMMAND("set-url", &fn, module_set_url),
OPT_SUBCOMMAND("set-branch", &fn, module_set_branch),
OPT_SUBCOMMAND("create-branch", &fn, module_create_branch),
OPT_SUBCOMMAND("get-default-remote", &fn, module_get_default_remote),
OPT_END()
};
argc = parse_options(argc, argv, prefix, options, usage, 0);
Expand Down
8 changes: 4 additions & 4 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -3518,15 +3518,15 @@ int get_sparse_checkout_patterns(struct pattern_list *pl)

int remove_path(const char *name)
{
char *slash;
const char *last;

if (unlink(name) && !is_missing_file_error(errno))
return -1;

slash = strrchr(name, '/');
if (slash) {
last = strrchr(name, '/');
if (last) {
char *dirs = xstrdup(name);
slash = dirs + (slash - name);
char *slash = dirs + (last - name);
do {
*slash = '\0';
if (startup_info->original_cwd &&
Expand Down
Loading