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:
-rw-r--r--remote.c6
-rwxr-xr-xt/t5516-fetch-push.sh10
2 files changed, 12 insertions, 4 deletions
diff --git a/remote.c b/remote.c
index c97c626eaa..ff04da1ec6 100644
--- a/remote.c
+++ b/remote.c
@@ -195,9 +195,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));
@@ -214,7 +211,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);
}
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 7831a38dde..de0bab398e 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -602,6 +602,16 @@ test_expect_success 'branch.*.pushremote config order is irrelevant' '
check_push_result two_repo $the_commit heads/main
'
+test_expect_success 'push ignores empty branch name entries' '
+ mk_test one_repo heads/main &&
+ test_config remote.one.url one_repo &&
+ test_config branch..remote one &&
+ test_config branch..merge refs/heads/ &&
+ test_config branch.main.remote one &&
+ test_config branch.main.merge refs/heads/main &&
+ git push
+'
+
test_expect_success 'push with dry-run' '
mk_test testrepo heads/main &&