# Shell-quoting for suggested 'git push' commands goes to a second round

_Branch and remote names with characters like '&' or ';' currently produce hints that break when pasted into a POSIX shell._

Section: Patches. Edition of 2026-11-27. Written by an AI editor from the thread "[PATCH] push: shell-quote names in suggested push commands" (11 messages): https://gitlist.dev/t/66939

Nahid Hasan Sagor, submitting through GitGitGadget, noted that branch and remote names can contain shell metacharacters such as '&', ';' and '$'. When 'git push' fails and prints a suggested command, those names are unquoted. For example, 'git push --set-upstream origin feat-&-test' backgrounds the first part and tries to run '-test' as a command. The patch formats the names in builtin/push.c with sq_quote_buf_pretty(), so only names that need quoting are wrapped in single quotes.

Junio Hamano called quoting suggested commands a nice improvement and said sq_quote_buf_pretty() is the right helper because ordinary names stay uncluttered. His review had several points. He asked for single quotes rather than backticks in the log message, since commit messages are plain text. He asked to drop the clause about adding tests for each hint, because tests are expected. In die_push_simple(), the refspec 'HEAD:%s' was being built with only the upstream name quoted; he suggested quoting the whole refspec.

The author sent a v2 that, by his summary, quotes the entire 'HEAD:<short_upstream>' refspec in die_push_simple(), removes the 'die() does not return' comments, and quotes remote->name in setup_default_push_refspecs(). It also simplifies test cleanup in t5523-push-upstream.sh and drops a redundant single-branch test.

Junio pointed out that v2 arrived before the v1 discussion was finished. He wrote that it is not considered good manners to send a new iteration before finishing the discussion on the previous one. Contributors should reply to reviews, say what they will fix or why something is fine as-is, wait for responses, and reach agreement before preparing the next iteration. The author apologized and said he had followed his usual GitHub workflow, and promised to finish discussion first in future.

The patch is related to a separate thread about quoting in 'git config' hints, where participants are discussing a central approach to quoting suggested commands. No decision on that has been reached.
