{"thread":{"id":"55147","subject":"Bug report: git remote prune does not take negative refspecs into account","startedAt":"2021-02-14T09:27:56Z","lastAt":"2021-02-14T09:27:56Z","messageCount":1,"participants":["Christian Wolf"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"416878","messageId":"1729665.CpSNW4ODmt@cwolf-work","threadId":"55147","inReplyTo":null,"subject":"Bug report: git remote prune does not take negative refspecs into account","fromName":"Christian Wolf","fromEmail":"account+git@christian-wolf.click","sentAt":"2021-02-14T09:18:34Z","receivedAt":"2021-02-14T09:27:56Z","isPatch":false,"sender":{"key":"account+git@christian-wolf.click","avatar":null},"body":"Hello,\n\nI found an issue with git and wanted to report this. Here is the filled result \nfrom `git bugreport` (sorry for the intermixed German, but I think the English \nstatements should suffice to understand the issue).\n\nVielen Dank für das Ausfüllen eines Git-Fehlerberichts!\nBitte antworten Sie auf die folgenden Fragen, um uns dabei zu helfen, Ihr\nProblem zu verstehen.\n\nWas haben Sie gemacht, bevor der Fehler auftrat? (Schritte, um Ihr Fehler\nzu reproduzieren)\n\n1. I have configured a remote `upstream` with a refspec like `+refs/heads/\n*:refs/upstream/heads/*`.\n2. I have fetched remote `upstream` fetching two branches `foo` and `bar`.\n3. I add another line to `.git/config` with a negative refspec\n```\nfetch = ^refs/heads/bar\n```\n4. I called `git fetch upstream` and `git remote prune upstream`.\n5. Remove the refspec from step 2 in `.git/config` with some arbitrary names \n(e.g. `+refs/heads/baz:refs/upstream/heads/baz`), keep the negative refspec as \nit is\n6. Fetch and prune (see step 4)\n7. Undo step 5 and restore the original state as after step 3\n8. Fetch and prune (see step 4)\n\nWas haben Sie erwartet, was passieren soll? (Erwartetes Verhalten)\nExpected behavior:\n\nAfter the fetch in step 2 both branches are mirrored locally.\n\nAfter the prune in line 4 the branch `bar` is dropped from the remotely \nfetched branches.\n\nAfter step 6 both both remote branches `foo` and `bar` are no longer visible.\nA possible error about unmatching branch `baz`.\n\nAfter step 8 again a remote branch `foo` is existing.\n\nWas ist stattdessen passiert? (Wirkliches Verhalten)\nReal behavior:\n\nAfter step 2: As intended\n\nAfter step 4: Both remote branches are still visible. Nothing is pruned.\n\nAfter step 6: Both remote branches are gone.\n\nAfter step 8: Only `foo` is existing/fetched as remote branch.\n\nWas ist der Unterschied zwischen dem, was Sie erwartet haben und was\nwirklich passiert ist?\nThe difference of real and ideal behavior:\n\nThe difference is that after step 4 the remote branch `bar` is not pruned.\n\nSonstige Anmerkungen, die Sie hinzufügen möchten:\n\nThe steps 5~8 are there to verify the negative pathspec is working in general.\nFetching freshly takes the negativbe pathspec into account.\n\nSo the problem is within the pruning code.\n\n[System Info]\ngit Version:\ngit version 2.30.1\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.10.10-arch1-1 #1 SMP PREEMPT Sat, 23 Jan 2021 23:59:48 +0000 \nx86_64\nCompiler Info: gnuc: 10.2\nlibc Info: glibc: 2.33\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Aktivierte Hooks]\n\nThank you for looking into this.\nChristian\n\n\n"}]}