Repository navigation
Preserve Git, GitHub, and task text under legacy locales #1529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d42a398
8bd260d
3aec211
c8c2f75
7f671a4
0a83c38
742752c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,8 +93,8 @@ def _require_push_target(wt: Path, repo: str) -> None: | |
|
|
||
|
|
||
| def _git_push(wt: Path, args: list[str], *, force_lease: bool) -> None: | ||
| done = _proc.run(["git", *args], cwd=wt, env_allowlist=worktree.GIT_ENV, | ||
| extra_env={"LC_ALL": "C"}, timeout=PUSH_TIMEOUT) | ||
| argv = ["git", *(os.fsdecode(arg.encode("utf-8", "surrogateescape")) for arg in args)] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reviewer location tests/test_worktree.py:45 is not in the diff; anchored here. important: The merge resolution removed every legacy-locale test, so the new conversions are never exercised Resolving the merge with origin/main dropped these tests:
The tests that remain ( The retained The acceptance criteria call for status and branch lookup to work under ASCII and ISO-8859-2, so they are no longer verified. Smallest fix: restore at least one subprocess-based test that runs |
||
| done = _proc.run(argv, cwd=wt, env_allowlist=worktree.GIT_ENV, extra_env={"LC_ALL": "C"}, timeout=PUSH_TIMEOUT) | ||
| if done.exit_code != 0: | ||
| detail = _proc.tail(done.stderr)[-2000:] | ||
| if force_lease and any(line.startswith("!\t") and line.endswith("\t[rejected] (stale info)") | ||
|
|
@@ -1816,10 +1816,10 @@ def _cleanup_remote_refs(wt: Path, config: Config, branch: str, expected_head: s | |
| def _delete_tracking_ref(wt: Path, branch: str, expected_head: str) -> None: | ||
| if not branch.startswith("lz/") or branch.count("/") != 1: | ||
| return | ||
| ref = f"refs/remotes/origin/{branch}" | ||
| ref = os.fsdecode(f"refs/remotes/origin/{branch}".encode("utf-8", "surrogateescape")) | ||
| try: | ||
| _repo_root(wt) | ||
| current = _git(wt, "for-each-ref", "--format=%(objectname) %(refname) %(symref)", ref) | ||
| current = _git(wt, "for-each-ref", "--format=%(objectname) %(refname) %(symref)", ref, paths=True).rstrip(" ") | ||
| if current == f"{expected_head} {ref}": | ||
| _git(wt, "update-ref", "--no-deref", "-d", ref, expected_head) | ||
| except (CliError, OSError, _proc.ProcTimeout) as exc: | ||
|
|
@@ -1862,10 +1862,9 @@ def cmd_status(args: argparse.Namespace) -> int: | |
| wt = _toplevel() | ||
| config = _load_config(args, wt, pin_checks=True) | ||
| branch, head = worktree.branch(wt), worktree.head(wt) | ||
| print(f"worktree: {wt}") | ||
| print(f"branch: {branch}") | ||
| print(f"head: {head}") | ||
| print(f"base: {config.base_branch}") | ||
| encoding = getattr(sys.stdout, "encoding", None) or "utf-8" | ||
| identity = f"worktree: {wt}\nbranch: {branch}\nhead: {head}\nbase: {config.base_branch}" | ||
| print(identity.encode(encoding, "backslashreplace").decode(encoding)) | ||
| print(f"dirty: {'yes' if worktree.is_dirty(wt) else 'no'}") | ||
| pr = github.pr_for_branch(config.repo, branch) | ||
| if pr is None: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewer location src/loopzero/cli.py:699 is not in the diff; anchored here.
important: Force-lease reflog lookup still passes the UTF-8 branch view to git without converting it to native form
worktree.branch(wt)now returns the UTF-8 view of the branch name (os.fsencode(name).decode("utf-8", "surrogateescape")). This delta converts that view back to the filesystem form in_git_push,_delete_tracking_refandgithub.delete_remote_branch. It does not convert_git(wt, "reflog", "show", "--format=%H", f"refs/heads/{branch}")on the force-lease path ofcmd_pr, so the plain str goes straight to Popen, which encodes it with the filesystem encoding.What goes wrong:
lz/Łódźraises UnicodeEncodeError.Łis encoded as 0xA3 instead of UTF-8 C5 81. Git reads a different ref, the reflog lookup fails or comes back empty, andloopzero prrefuses a legitimate force-with-lease update with an error saying the PR head is absent from the branch history.The acceptance criterion says Unicode branches must survive legacy locales, and this path breaks it.
Smallest fix: build the ref with the same conversion used elsewhere. Better, add one helper (for example
worktree.native_ref(text)) and use it at every call site: here, in_git_push,_delete_tracking_ref,delete_remote_branch, and for the inverse inbranch()/_lock_verified_ref. The four copies of the conversion in this diff are what let this call be missed.