From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Andreas Heiduk <asheiduk@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: RFC: How should we handle un-deleted remote branches?
Date: Sun, 22 Apr 2018 13:17:31 +0200 [thread overview]
Message-ID: <87d0yrebhw.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <3fcd1b50-2aeb-0ea4-fea7-b5705e76c027@gmail.com>
On Sun, Apr 22 2018, Andreas Heiduk wrote:
> Am 20.04.2018 um 14:14 schrieb Ævar Arnfjörð Bjarmason:
>> But this is a possible work-around:
>>
>> git init /tmp/empty.git
>> git remote add avar file:///tmp/empty.git
>> git remote prune avar
>> git remote remove avar
>
> This won't do it also?
>
> git remote prune origin
Yes, in this particular case, but that's just emergent behavior in how
we handle refspec prunign, and the fact that it "works" is arguably a
bug in "prune". i.e. this:
(
rm -rf /tmp/git &&
git clone --bare --mirror git@github.com:git/git.git /tmp/git &&
cd /tmp/git &&
git remote add avar git@github.com:avar/git.git &&
git remote add peff git@github.com:peff/git.git &&
git fetch --all &&
git remote remove avar &&
git remote prune origin
)
Will delete all the avar/* and peff/* branches, even though I still have
a "peff" remote.
IOW the guarding logic we have in add_branch_for_removal() for not
deleting the branches of other remotes isn't in the corresponding
"prune" function, and that's a bug.
In the specific example I picked "git remote prune origin" just so
happens to do the right thing since I have no other active remote, and
there *is* an alive remote so I can "prune" against it, but it doesn't
help in the general case. In my case I have a remote URL for a git
server called "upstream" that doesn't exist anymore (but as noted, I can
fake it with an empty repo...)>
>> I started to patch this, but I'm not sure what to do here. we could do
>> some combination of:
>>
>> 0. Just document the current behavior and leave it.
>>
>> 1. Dig further down to see what other remotes reference these refs, and
>> just ignore any refspecs that don't explicitly reference
>> refs/remotes/<our_deleted_remote>/*.
>>
>> I.e. isn't the intention here to preserve a case where you have two
>> URLs for the same effective remote, not whene you have something
>> like a --mirror refspec? Unfortunately I can't ask the original
>> author :(
>>
>> 2. Warn about each ref we didn't delete, or at least warn saying
>> there's undeleted refs under refs/remotes/<name>/*.
>>
>> 3. Make 'git remote remove --force-deletion <name>' (or whatever the
>> flag is called) be a thing. But unless we do the next item this
>> won't be useful.
>>
>> 4. Make 'git remote prune <name>' work in cases where we don't have a
>> remote called <name> anymore, just falling back to deleting
>> refs/remotes/<name>. In this case 'git remote remove
>> --force-deletion <name>' would also do the same thing.
>
> Possible 5):
>
> Don't fix "git remote remove" but "git remote add" to complain that its
> ref-namespace is already occupied by some other remote. Add "--force"
> for the experts.
Indeed, that's another bug here, i.e. in the above example:
git remote remove peff && # won't delete peff/ branches
git remote add peff git@github.com:peff/git.git
Will happily add the "peff" remote again, even though as you point out
it could be an entirely different remote.
next prev parent reply other threads:[~2018-04-22 11:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-20 12:14 RFC: How should we handle un-deleted remote branches? Ævar Arnfjörð Bjarmason
2018-04-22 7:41 ` Andreas Heiduk
2018-04-22 11:17 ` Ævar Arnfjörð Bjarmason [this message]
2018-04-22 14:30 ` Andreas Heiduk
2018-04-22 18:37 ` Ævar Arnfjörð Bjarmason
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d0yrebhw.fsf@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=asheiduk@gmail.com \
--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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.