"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: got tag -c option
To:
gameoftrees@openbsd.org
Date:
Mon, 24 Feb 2020 21:33:05 +0100

Download raw body.

Thread
  • Stefan Sperling:

    got tag -c option

    • Stefan Sperling:

      got tag -c option

On Mon, Feb 24, 2020 at 01:46:36PM +0100, Stefan Sperling wrote:
> For consistency with 'got branch', switch 'got tag tagname commit' to
> 'got tag -c commit tagname'.
> 
> ok?

I have just pushed this. If there are any concerns, please let me know.

> 
> diff 212b39d173639f6f9aab137db52b888d5e1022ec /home/stsp/src/got
> blob - b255255c35b0599f3ce3cfba03065a17637afdea
> file + got/got.1
> --- got/got.1
> +++ got/got.1
> @@ -587,7 +587,7 @@ Git's garbage collector.
>  .It Cm br
>  Short alias for
>  .Cm branch .
> -.It Cm tag Oo Fl m Ar message Oc Oo Fl r Ar repository-path Oc Oo Fl l Oc Ar name Op Ar commit
> +.It Cm tag Oo Fl c Ar commit Oc Oo Fl m Ar message Oc Oo Fl r Ar repository-path Oc Oo Fl l Oc Ar name
>  Manage tags in a repository.
>  .Pp
>  Tags are managed via references which live in the
> @@ -599,24 +599,29 @@ command operates on references in this namespace only.
>  References in this namespace point at tag objects which contain a pointer
>  to another object, a tag message, as well as author and timestamp information.
>  .Pp
> -Expect one or two arguments and attempt to create a tag with the given
> +Attempt to create a tag with the given
>  .Ar name ,
>  and make this tag point at the given
>  .Ar commit .
>  If no commit is specified, default to the latest commit on the work tree's
>  current branch if invoked in a work tree, and to a commit resolved via
>  the repository's HEAD reference otherwise.
> -Otherwise, the expected argument is a commit ID SHA1 hash or an existing
> -reference or tag name which will be resolved to a commit ID.
> -An abbreviated hash argument will be expanded to a full SHA1 hash
> -automatically, provided the abbreviation is unique.
>  .Pp
>  The options for
>  .Cm got tag
>  are as follows:
>  .Bl -tag -width Ds
> +.It Fl c Ar commit
> +Make the newly created tag reference point at the specified
> +.Ar commit .
> +The expected
> +.Ar commit
> +argument is a commit ID SHA1 hash or an existing reference or tag name which
> +will be resolved to a commit ID.
> +An abbreviated hash argument will be expanded to a full SHA1 hash
> +automatically, provided the abbreviation is unique.
>  .It Fl m Ar message
> -Use the specified tag message when creating the new tag
> +Use the specified tag message when creating the new tag.
>  Without the
>  .Fl m
>  option,
> blob - 7a50d3a7ec56e05bab9576a9e6d61188b261f9a5
> file + got/got.c
> --- got/got.c
> +++ got/got.c
> @@ -3597,8 +3597,8 @@ __dead static void
>  usage_tag(void)
>  {
>  	fprintf(stderr,
> -	    "usage: %s tag [-r repository] | -l | "
> -	        "[-m message] name [commit]\n", getprogname());
> +	    "usage: %s tag [-c commit] [-r repository] [-l] "
> +	        "[-m message] name\n", getprogname());
>  	exit(1);
>  }
>  
> @@ -3949,8 +3949,11 @@ cmd_tag(int argc, char *argv[])
>  	const char *tag_name, *commit_id_arg = NULL, *tagmsg = NULL;
>  	int ch, do_list = 0;
>  
> -	while ((ch = getopt(argc, argv, "m:r:l")) != -1) {
> +	while ((ch = getopt(argc, argv, "c:m:r:l")) != -1) {
>  		switch (ch) {
> +		case 'c':
> +			commit_id_arg = optarg;
> +			break;
>  		case 'm':
>  			tagmsg = optarg;
>  			break;
> @@ -3974,14 +3977,15 @@ cmd_tag(int argc, char *argv[])
>  	argv += optind;
>  
>  	if (do_list) {
> +		if (commit_id_arg != NULL)
> +			errx(1, "-c option can only be used when creating a tag");
>  		if (tagmsg)
> -			errx(1, "-l and -m options are mutually exclusive\n");
> +			errx(1, "-l and -m options are mutually exclusive");
>  		if (argc > 0)
>  			usage_tag();
> -	} else if (argc < 1 || argc > 2)
> +	} else if (argc != 1)
>  		usage_tag();
> -	else if (argc > 1)
> -		commit_id_arg = argv[1];
> +
>  	tag_name = argv[0];
>  
>  #ifndef PROFILE
> blob - 4fe82be2ade02d326fa45a5b99005bf6bda52252
> file + regress/cmdline/tag.sh
> --- regress/cmdline/tag.sh
> +++ regress/cmdline/tag.sh
> @@ -23,7 +23,7 @@ function test_tag_create {
>  	local tag2=2.0.0
>  
>  	# Create a tag based on repository's HEAD reference
> -	got tag -m 'test' -r $testroot/repo $tag HEAD > $testroot/stdout
> +	got tag -m 'test' -r $testroot/repo -c HEAD $tag > $testroot/stdout
>  	ret="$?"
>  	if [ "$ret" != "0" ]; then
>  		echo "got ref command failed unexpectedly"
> @@ -88,7 +88,7 @@ function test_tag_create {
>  
>  	# Attempt to create a tag pointing at a non-commit
>  	local tree_id=`git_show_tree $testroot/repo`
> -	(cd $testroot/wt && got tag -m 'test' foobar $tree_id \
> +	(cd $testroot/wt && got tag -m 'test' -c $tree_id foobar \
>  		2> $testroot/stderr)
>  	ret="$?"
>  	if [ "$ret" == "0" ]; then
> 
>