From: Omar Polo Subject: Re: add got patch subcommand To: Stefan Sperling Cc: gameoftrees@openbsd.org Date: Mon, 07 Mar 2022 23:29:00 +0100 Stefan Sperling wrote: > On Mon, Mar 07, 2022 at 09:27:28PM +0100, Omar Polo wrote: > > Hello, > > > > some time ago stsp suggested that got should be able to apply diffs by > > itself. Using the VCS to apply them allows in fact some nice > > comodities: for instance added and removed files are automatically > > tracked. > > > > The rather long diff attached is just that. It's a simple and (i think) > > straightforward implementation of patch(1) only integrated inside got. > > There's a new got-read-patch libexec helpers (which borrows some lines > > of code from Larry' patch, but it's mostly rewritten from scratch) that > > is used to parse the content of the diff, similarly to the others > > got-read-* helpers and under the same restrictions, and lib/patch.c that > > wraps it. > > Thanks, this is great! A very good starting point. > > I think you should go ahead and put these changes on the main branch. > They do not break the build and tests are passing. We do not lose anything > even if this feature gets shipped in an incomplete state, and you will be > able to make progress faster as people run into problems trying to use this. > > You could then also respond to reviews of your initial diff here by sending > smaller diffs with fixes back to the list, which makes things easier for all > of us. OK, so i went ahead and committed it with the following trivial bit on top. thanks :) diff 0e2e6a811e99fe2e73cae9d4c15cfcab0a966c80 /home/op/w/got blob - 97248718d40eaf3a712653112d62e64d0beca870 file + got/got.c --- got/got.c +++ got/got.c @@ -7113,7 +7113,7 @@ done: __dead static void usage_patch(void) { - fprintf(stderr, "usage: %s patch patchfile\n", + fprintf(stderr, "usage: %s patch [patchfile]\n", getprogname()); exit(1); } blob - 8d62a59817a8465d55c8c4770a983504c28e76fa file + regress/cmdline/patch.sh --- regress/cmdline/patch.sh +++ regress/cmdline/patch.sh @@ -386,6 +386,7 @@ EOF if [ $ret != 0 ]; then diff -u $testroot/wt/$f.expected $testroot/wt/$f test_done $testroot $ret + return 1 fi done