Download raw body.
teach got patch how to strip
On Thu, Apr 07, 2022 at 12:37:15PM +0200, Stefan Sperling wrote: > On Thu, Apr 07, 2022 at 12:15:44PM +0200, Omar Polo wrote: > > Stefan Sperling <stsp@stsp.name> wrote: > > > 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 > > Ah sorry, no. My patch is wrong. > The error message should of course display the full path. > > I missed that the 'path' variable is changed in the loop. Flipping them around seems more obvious to me, in terms of style. diff 9d6cabd51222f7506db617ee8a7b282823dde999 /home/stsp/src/got blob - 9a0217a5e7d82ee2539af6b0e563a2c537f26621 file + lib/path.c --- lib/path.c +++ lib/path.c @@ -125,16 +125,16 @@ got_path_strip(char **out, const char *path, int n) p = path; *out = NULL; - while (n > 0 && (c = strchr(path, '/')) != NULL) { - path = c + 1; + while (n > 0 && (c = strchr(p, '/')) != NULL) { + p = c + 1; 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) + if ((*out = strdup(p)) == NULL) return got_error_from_errno("strdup"); return NULL; }
teach got patch how to strip