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

Re: [PATCH 5/7] push: require force for refs under refs/tags/

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 26, 2012, 18:57 UTC
Message-ID
<7vfw3wry4d.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1353644515-17349-6-git-send-email-chris@rorvick.com>
Chris Rorvick <chris@rorvick.com> writes:
Show 25 quoted lines
> diff --git a/remote.c b/remote.c
> index 4a6f822..012b52f 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -1315,14 +1315,18 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
>  		 *
>  		 * (1) if the old thing does not exist, it is OK.
>  		 *
> -		 * (2) if you do not have the old thing, you are not allowed
> +		 * (2) if the destination is under refs/tags/ you are
> +		 *     not allowed to overwrite it; tags are expected
> +		 *     to be static once created
> +		 *
> +		 * (3) if you do not have the old thing, you are not allowed
>  		 *     to overwrite it; you would not know what you are losing
>  		 *     otherwise.
>  		 *
> -		 * (3) if both new and old are commit-ish, and new is a
> +		 * (4) if both new and old are commit-ish, and new is a
>  		 *     descendant of old, it is OK.
>  		 *
> -		 * (4) regardless of all of the above, removing :B is
> +		 * (5) regardless of all of the above, removing :B is
>  		 *     always allowed.
>  		 */

We may want to reword (0) to make it clear that --force (and +A:B) can be used to defeat all the other rules.

The updated logic in the patch looks sensible.  Thanks.
Show 22 quoted lines
> ...
> +test_expect_success 'push requires --force to update lightweight tag' '
> +	mk_test heads/master &&
> +	mk_child child1 &&
> +	mk_child child2 &&
> +	(
> +		cd child1 &&
> +		git tag Tag &&
> +		git push ../child2 Tag &&
> +		git push ../child2 Tag &&
> +		>file1 &&
> +		git add file1 &&
> +		git commit -m "file1" &&
> +		git tag -f Tag &&
> +		test_must_fail git push ../child2 Tag &&
> +		git push --force ../child2 Tag &&
> +		git tag -f Tag &&
> +		test_must_fail git push ../child2 Tag HEAD~ &&
> +		git push --force ../child2 Tag
> +	)
> +'
> +
Previous: Chris RorvickNext: Chris Rorvick
Message 9 of 18 in “push: update remote tags only with force”
  1. 0/7 push: update remote tags only with forceChris Rorvick, Nov 23, 2012
  2. 1/7 push: return reject reasons via a maskChris Rorvick, Nov 23, 2012
  3. Junio C HamanoNov 26, 2012
  4. Chris RorvickNov 27, 2012
  5. 2/7 push: add advice for rejected tag referenceChris Rorvick, Nov 23, 2012
  6. 3/7 push: flag updatesChris Rorvick, Nov 23, 2012
  7. 4/7 push: flag updates that require forceChris Rorvick, Nov 23, 2012
  8. 5/7 push: require force for refs under refs/tags/Chris Rorvick, Nov 23, 2012
  9. Junio C HamanoNov 26, 2012
  10. Chris RorvickNov 27, 2012
  11. Junio C HamanoNov 27, 2012
  12. push: cleanup push rules commentChris Rorvick, Nov 28, 2012
  13. Junio C HamanoNov 28, 2012
  14. 6/7 push: require force for annotated tagsChris Rorvick, Nov 23, 2012
  15. 7/7 push: clarify rejection of update to non-commit-ishChris Rorvick, Nov 23, 2012
  16. Junio C HamanoNov 26, 2012
  17. Chris RorvickNov 27, 2012
  18. Junio C HamanoNov 27, 2012

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.