git/list[1] front-page[2] threads[3] people[4] search[5] about
 

bug: Removing branch and creating branch-directory with same name breaks

From
MBMatthias Braun <matze@braunis.de>
Date
Jan 6, 2025, 19:07 UTC
Message-ID
<25913110-E42E-4028-B39D-44045623FDC4@braunis.de>
(Note that I also tried this with latest git-2.47.1 after creating the repro script and it still fails there).
What did you do before the bug happened? (Steps to reproduce your issue)
- Removed remote branch. Created new directory (for branch names)
  with same name directory name as the previously used branch name.
  After that `git fetch` fails.

Reproduction script for your convenience: ``` #!/bin/bash

mkdir -p repro git init repro/remote.git git clone repro/remote.git repro/cloned pushd repro/cloned echo "hello" > hello.txt git add hello.txt git commit -m "test commit" git branch mystuff git push origin mystuff popd

git clone repro/remote.git repro/clone2

pushd repro/cloned git branch -D mystuff git push -d origin mystuff git branch mystuff/branch_in_subdir git push origin mystuff/branch_in_subdir popd

pushd repro/clone2 git fetch # This fails as branch turned into directory popd ```

What did you expect to happen? (Expected behavior)
`git fetch` should work...
What happened instead? (Actual behavior)

`git fetch origin` error: cannot lock ref 'refs/remotes/origin/mystuff/branch_in_subdir': 'refs/remotes/origin/mystuff' exists; cannot create 'refs/remotes/origin/mystuff/branch_in_subdir'

What's different between what you expected and what actually happened?
Anything else you want to add:

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.43.5 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 5.19.0-0_fbk12_hardened_11583_g0bef9520ca2b #1 SMP Fri Feb 2 17:56:12 PST 2024 x86_64 compiler info: gnuc: 11.4 libc info: glibc: 2.34 $SHELL (typically, interactive shell): /bin/zsh

[Enabled Hooks] not run from a git repository - no hooks to show

Next: brian m. carlson
Message 1 of 2 in “bug: Removing branch and creating branch-directory with same name breaks”
  1. Matthias BraunJan 6, 2025
  2. brian m. carlsonJan 6, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.