Re: git push tags
- From
- Drew Northup <n1xim.email@gmail.com>
- Date
- Oct 26, 2012, 18:07 UTC
- Message-ID
- <CAM9Z-nkBO1dbF-sBFLuxM_S_MT79Cx=gLEL+83XKB7ys8VTqNQ@mail.gmail.com>
- In-Reply-To
- <20121026174255.GE10560@camk.edu.pl>
On Fri, Oct 26, 2012 at 1:42 PM, Kacper Kornet <draenog@pld-linux.org> wrote:
Show 33 quoted lines
> On Thu, Oct 25, 2012 at 05:16:00PM -0400, Drew Northup wrote:
>> On Thu, Oct 25, 2012 at 3:05 PM, Angelo Borsotti
>> <angelo.borsotti@gmail.com> wrote:
>> > Are remote repositories less protected than the local ones? I
>> > think that to be consistent, the same strategy should be used on all
>> > repositories, i.e. rejecting changes on tags by default, unless they
>> > are forced.
>
>> So here we come to the core argument. Is sounds to me like you want
>> changes to remote tags to work differently from push updates to ALL
>> other references. The required change, if I'm not mistaken, would be
>> for tags to not permit fast-forward updates while all other references
>> would be pushed normally. From my brief and un-enlightened look at the
>> push code I can't see that being as easy as it sounds.
>
> I think the patch below obtains the requested behaviour:
>
> diff --git a/remote.c b/remote.c
> index 04fd9ea..7fcb51e 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -1320,7 +1320,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
> !ref->deletion &&
> !is_null_sha1(ref->old_sha1) &&
> (!has_sha1_file(ref->old_sha1)
> - || !ref_newer(ref->new_sha1, ref->old_sha1));
> + || !prefixcmp(ref->name, "refs/tags") || !ref_newer(ref->new_sha1, ref->old_sha1));
>
> if (ref->nonfastforward && !ref->force && !force_update) {
> ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
>
> --
> Kacper KornetKacper, I obviously didn't dig deep enough. In any case, I presume that's what he's asking for. I can't remember if git is still forcing tags to always be located in "refs/tags" however. I didn't think it was.
-- -Drew Northup -------------------------------------------------------------- "As opposed to vegetable or mineral error?" -John Pescatore, SANS NewsBites Vol. 12 Num. 59