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

From:
Klemens Nanni <kn@openbsd.org>
Subject:
Re: allow checkout into non-empty directory
To:
gameoftrees@openbsd.org, kn@openbsd.org
Date:
Mon, 13 Jan 2020 09:19:25 +0100

Download raw body.

Thread
On Sun, Jan 12, 2020 at 11:44:24PM +0100, Stefan Sperling wrote:
> kn@ has a use case for running 'got checkout' on top of existing files.
>
> At present 'got checkout' refuses to operate on a non-empty directory.
> This adds a new 'got checkout -E' operation mode which ignores existing
> files and proceeds with the checkout operation anyway.
> See the new regress test for behaviour details.
OK kn with S_IF* fixed, rest are just comments.

> @@ -136,8 +136,14 @@ follows the globbing rules documented in
>  .It Cm im
>  Short alias for
>  .Cm import .
> -.It Cm checkout Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Oo Fl p Ar path-prefix Oc Ar repository-path Op Ar work-tree-path
> +.It Cm checkout Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Oo Fl E Oc Oo Fl p Ar path-prefix Oc Ar repository-path Op Ar work-tree-path
Flags without options usually go first, .e.g. 

	man [-acfhklw] [-C file] [-M path] [-m path] [-S subsection] [[-s] section]
	    name ...

> @@ -166,6 +172,11 @@ An abbreviated hash argument will be expanded to a ful
>  automatically, provided the abbreviation is unique.
>  If this option is not specified, the most recent commit on the selected
>  branch will be used.
> +.It Fl E
> +Proceed with the checkout operation even if the directory at
> +.Ar work-tree-path
> +is not empty.
> +Existing file contents will be left intact.
I'd omit "contents", you're leaving permissions alone as well of course.
The simpler the better.

> @@ -800,7 +800,7 @@ __dead static void
>  usage_checkout(void)
>  {
>  	fprintf(stderr, "usage: %s checkout [-b branch] [-c commit] "
> -	    "[-p prefix] repository-path [worktree-path]\n", getprogname());
> +	    "[-E] [-p prefix] repository-path [worktree-path]\n", getprogname());
Move `[-E]' after checkout as above.

> @@ -16,8 +16,10 @@
>  
>  /* Utilities for dealing with filesystem paths. */
>  
> -#define GOT_DEFAULT_FILE_MODE	(S_IRUSR|S_IWUSR | S_IRGRP | S_IROTH)
> -#define GOT_DEFAULT_DIR_MODE	(S_IRWXU | S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH)
> +#define GOT_DEFAULT_FILE_MODE	S_IFREG | \
> +	(S_IRUSR|S_IWUSR | S_IRGRP | S_IROTH)
> +#define GOT_DEFAULT_DIR_MODE	S_IFDIR | \
> +	(S_IRWXU | S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH)
S_IF* must be guarded inside the parantheses.