{"thread":{"id":"66860","subject":"[BUG] push: a remote group that lists a remote of its own name makes \"git push <name>\" recurse","startedAt":"2026-11-17T01:07:25Z","lastAt":"2026-11-17T01:07:25Z","messageCount":1,"participants":["wheakerd"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"558588","messageId":"CAFJdCSutexXts8ZUkwdzgyTn61qM97v=eD_ivm+zjt4=L8FkxQ@mail.gmail.com","threadId":"66860","inReplyTo":null,"subject":"[BUG] push: a remote group that lists a remote of its own name makes \"git push <name>\" recurse","fromName":"wheakerd","fromEmail":"wheakerd@gmail.com","sentAt":"2026-11-17T01:07:25Z","receivedAt":"2026-11-17T01:07:25Z","isPatch":false,"sender":{"key":"wheakerd@gmail.com","avatar":null},"body":"What did you do before the bug happened? (Steps to reproduce your issue)\n\n  git init -q -b main client\n  git init -q --bare -b main a.git\n  git init -q --bare -b main b.git\n  git -C client commit -q --allow-empty -m base\n  git -C client remote add origin ../a.git\n  git -C client remote add member ../b.git\n  git -C client config remotes.origin \"origin member\"\n  timeout -s KILL 12 git -C client push origin refs/heads/main:refs/heads/main\n\n  Caution: the last command starts several thousand nested \"git push\"\n  processes. Please keep the time limit.\n\nWhat did you expect to happen? (Expected behavior)\n\n  Either one push to the remote \"origin\" and one to \"member\", or an error\n  that says a group must not contain its own name.\n\nWhat happened instead? (Actual behavior)\n\n  The command prints \"Pushing to origin\" again and again and starts one\n  nested \"git push origin\" per line. In a 12-second run it printed that\n  line 5,945 times, and I sampled up to 5,898 \"git\" processes alive at the\n  same time. Once the nesting stops growing, each level reports \"error:\n  could not push to origin\", then prints \"Pushing to member\" and pushes to\n  member. When the 12 seconds were over, b.git had received main, and\n  a.git, the repository that the remote \"origin\" names, had no ref.\n\n  An earlier run without a time limit ended by itself with exit status 1.\n  I did not measure how long it took. There, too, the other member had\n  received the push and the repository of the remote \"origin\" had not.\n\nWhat's different between what you expected and what actually happened?\n\n  The remote that has the same name as the group is never pushed to, the\n  other member is pushed to once per nesting level, and the number of\n  processes is limited only by whatever makes the deepest child fail.\n\nAnything else you want to add:\n\n  Reading v2.56.0: push_multiple() in builtin/push.c runs\n  \"git push <member>\" as a child process for every member of the group,\n  and add_remote_or_group() in remote.c resolves a name as a group first\n  when remotes.<name> exists. The child for the member \"origin\" therefore\n  expands the same group again. On 2026-11-15 the two functions read\n  the same way on master, and push_multiple() on next and seen still\n  runs one child per member without a guard. I did not run the\n  reproduction on anything newer than 2.56.0.\n\n  \"git push <group>\" is new in 2.55.0. t/t5566-push-group.sh has no case\n  for a group that contains its own name, and git-push(1) does not\n  mention one.\n\n  The fetch side has an older report of the same cycle:\n\n    Fwd: Runaway \"git remote\" if group definition contains a remote by\n    the same name\n    https://mail-archive.com/git@vger.kernel.org/msg41422.html\n\n  Alex Riesen first sent it on 2010-11-17 and re-posted it on\n  2013-12-28, with\n\n    git -c remotes.origin='origin other' remote update origin\n\n  as the reproduction. Jeff King's reply names the reference cycle and\n  sketches a fix: expand groups in one process, tell the child\n  processes not to expand again, and detect cycles. I found no patch in\n  that thread, and fetch_multiple() in builtin/fetch.c on master passes\n  no such option to its children.\n\n  A group named like one of its members is easy to write by accident, for\n  example remotes.origin = \"origin backup\" to mean \"origin and its\n  backup\".\n\n[System Info]\ngit version:\ngit version 2.56.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nrust: disabled\nfeature: fsmonitor--daemon\nuname: Linux 7.2.11-200.fc44.x86_64 x86_64\n\n[Enabled Hooks]\nnone in the reproduction repository\n\n"}]}