Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-06-11 01:04:14 +0300
committerJunio C Hamano <gitster@pobox.com>2022-06-11 01:04:14 +0300
commit0b91d563d8d9615d1dc400b7c5e92ebd7933d01d (patch)
tree73745845c836a6b31a1ccd1159270cddb7c7e2ea /remote.c
parentc21fa3bb549a7769f9d508f0a5f95c654539e1f7 (diff)
parentf1dfbd9ee010e5cdf0d931d16b4b2892b33331e5 (diff)
Merge branch 'gc/zero-length-branch-config-fix'
A misconfigured 'branch..remote' led to a bug in configuration parsing. * gc/zero-length-branch-config-fix: remote.c: reject 0-length branch names remote.c: don't BUG() on 0-length branch names
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/remote.c b/remote.c
index dc270379e4..404e1e0a0d 100644
--- a/remote.c
+++ b/remote.c
@@ -196,9 +196,6 @@ static struct branch *find_branch(struct remote_state *remote_state,
struct branches_hash_key lookup;
struct hashmap_entry lookup_entry, *e;
- if (!len)
- len = strlen(name);
-
lookup.str = name;
lookup.len = len;
hashmap_entry_init(&lookup_entry, memhash(name, len));
@@ -215,7 +212,8 @@ static void die_on_missing_branch(struct repository *repo,
{
/* branch == NULL is always valid because it represents detached HEAD. */
if (branch &&
- branch != find_branch(repo->remote_state, branch->name, 0))
+ branch != find_branch(repo->remote_state, branch->name,
+ strlen(branch->name)))
die("branch %s was not found in the repository", branch->name);
}
@@ -355,8 +353,12 @@ static int handle_config(const char *key, const char *value, void *cb)
struct remote_state *remote_state = cb;
if (parse_config_key(key, "branch", &name, &namelen, &subkey) >= 0) {
+ /* There is no subsection. */
if (!name)
return 0;
+ /* There is a subsection, but it is empty. */
+ if (!namelen)
+ return -1;
branch = make_branch(remote_state, name, namelen);
if (!strcmp(subkey, "remote")) {
return git_config_string(&branch->remote_name, key, value);