From: Omar Polo Subject: Re: teach got patch how to strip To: Stefan Sperling Cc: gameoftrees@openbsd.org Date: Thu, 07 Apr 2022 12:15:44 +0200 Stefan Sperling wrote: > On Tue, Apr 05, 2022 at 08:10:16PM +0200, Stefan Sperling wrote: > > On Tue, Apr 05, 2022 at 05:59:55PM +0200, Omar Polo wrote: > > > + (cd $testroot/wt && got patch -p3 patch) \ > > > + > $testroot/stdout 2> $testroot/stderr > > > + ret=$? > > > + if [ $ret -eq 0 ]; then > > > + echo "stripped more components than available!" > > > + test_done $testroot 1 > > > + return 1 > > > + fi > > > > This should check stderr against the error message we expect to see. > > But that can be fixed later. > > > > ok stsp@ > > > > Small follow-up tweak: Variable 'p' in got_path_strip() is redundant. > ok? oh, right, yes please! needs a tweak to the patch.sh too thought: -got: can't strip 1 path-components from foo/bar/alpha: bad path +got: can't strip 1 path-components from alpha: bad path also, i've only noticed it now, do we want to pluralize `components' only when n != 1? I think i've seen something to handle pluralization already somewhere in got, not sure. > diff 9d6cabd51222f7506db617ee8a7b282823dde999 /home/stsp/src/got > blob - 9a0217a5e7d82ee2539af6b0e563a2c537f26621 > file + lib/path.c > --- lib/path.c > +++ lib/path.c > @@ -120,9 +120,8 @@ got_path_skip_common_ancestor(char **child, const char > const struct got_error * > got_path_strip(char **out, const char *path, int n) > { > - const char *p, *c; > + const char *c; > > - p = path; > *out = NULL; > > while (n > 0 && (c = strchr(path, '/')) != NULL) { > @@ -132,7 +131,7 @@ got_path_strip(char **out, const char *path, int n) > > if (n > 0) > return got_error_fmt(GOT_ERR_BAD_PATH, > - "can't strip %d path-components from %s", n, p); > + "can't strip %d path-components from %s", n, path); > > if ((*out = strdup(path)) == NULL) > return got_error_from_errno("strdup");