git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Christian Wolf <account+git@christian-wolf.click>
To: git@vger.kernel.org
Subject: Bug report: git remote prune does not take negative refspecs into account
Date: Sun, 14 Feb 2021 10:18:34 +0100	[thread overview]
Message-ID: <1729665.CpSNW4ODmt@cwolf-work> (raw)

Hello,

I found an issue with git and wanted to report this. Here is the filled result 
from `git bugreport` (sorry for the intermixed German, but I think the English 
statements should suffice to understand the issue).

Vielen Dank für das Ausfüllen eines Git-Fehlerberichts!
Bitte antworten Sie auf die folgenden Fragen, um uns dabei zu helfen, Ihr
Problem zu verstehen.

Was haben Sie gemacht, bevor der Fehler auftrat? (Schritte, um Ihr Fehler
zu reproduzieren)

1. I have configured a remote `upstream` with a refspec like `+refs/heads/
*:refs/upstream/heads/*`.
2. I have fetched remote `upstream` fetching two branches `foo` and `bar`.
3. I add another line to `.git/config` with a negative refspec
```
fetch = ^refs/heads/bar
```
4. I called `git fetch upstream` and `git remote prune upstream`.
5. Remove the refspec from step 2 in `.git/config` with some arbitrary names 
(e.g. `+refs/heads/baz:refs/upstream/heads/baz`), keep the negative refspec as 
it is
6. Fetch and prune (see step 4)
7. Undo step 5 and restore the original state as after step 3
8. Fetch and prune (see step 4)

Was haben Sie erwartet, was passieren soll? (Erwartetes Verhalten)
Expected behavior:

After the fetch in step 2 both branches are mirrored locally.

After the prune in line 4 the branch `bar` is dropped from the remotely 
fetched branches.

After step 6 both both remote branches `foo` and `bar` are no longer visible.
A possible error about unmatching branch `baz`.

After step 8 again a remote branch `foo` is existing.

Was ist stattdessen passiert? (Wirkliches Verhalten)
Real behavior:

After step 2: As intended

After step 4: Both remote branches are still visible. Nothing is pruned.

After step 6: Both remote branches are gone.

After step 8: Only `foo` is existing/fetched as remote branch.

Was ist der Unterschied zwischen dem, was Sie erwartet haben und was
wirklich passiert ist?
The difference of real and ideal behavior:

The difference is that after step 4 the remote branch `bar` is not pruned.

Sonstige Anmerkungen, die Sie hinzufügen möchten:

The steps 5~8 are there to verify the negative pathspec is working in general.
Fetching freshly takes the negativbe pathspec into account.

So the problem is within the pruning code.

[System Info]
git Version:
git version 2.30.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 5.10.10-arch1-1 #1 SMP PREEMPT Sat, 23 Jan 2021 23:59:48 +0000 
x86_64
Compiler Info: gnuc: 10.2
libc Info: glibc: 2.33
$SHELL (typically, interactive shell): /bin/bash


[Aktivierte Hooks]

Thank you for looking into this.
Christian



                 reply	other threads:[~2021-02-14  9:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1729665.CpSNW4ODmt@cwolf-work \
    --to=account+git@christian-wolf.click \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).