From: Stefan Sperling Subject: Re: got: fix incorrect argc check when diffing blobs To: Omar Polo Cc: Mark Jamsek , Game of Trees Date: Tue, 30 Aug 2022 11:40:47 +0200 On Thu, Aug 25, 2022 at 10:13:26PM +0200, Omar Polo wrote: > agreed, and the similar codepath for diffing objects has the `argc > 2' check. > > ok for me. > > should we add something like this in regress? > > diff /home/op/w/got > commit - f0680473a7db1e5941bffdc2ab5f80ddec209122 > path + /home/op/w/got > blob - 136f659b08eaf6408f6c79e05f6440fe7c754523 > file + regress/cmdline/diff.sh > --- regress/cmdline/diff.sh > +++ regress/cmdline/diff.sh > @@ -385,6 +385,43 @@ test_diff_basic() { > diff -u $testroot/stderr.expected $testroot/stderr > return 1 > fi > + > + # diff two blob ids, but first commit the changes to alpha > + (cd $testroot/wt && got commit -m 'edit' alpha >/dev/null) > + ret=$? > + if [ $ret -ne 0 ]; then > + echo "got commit failed" >&2 > + test_done "$testroot" "$ret" > + return 1 > + fi > + > + (cd $testroot/wt && got log -l1 -p alpha) > $testroot/log > + local bold="$(awk '/^blob \-/{print $3}' $testroot/log)" > + local bnew="$(awk '/^blob \+/{print $3}' $testroot/log)" > + sed -n -e "s/^--- alpha/--- $bold/" \ > + -e "s/^\+\+\+ alpha/+++ $bnew/" \ > + -e '/^blob -/,$p' \ > + $testroot/log > $testroot/diff.expected Instead of the above, could this new test code fetch blob IDs with the get_blob_id() helper, before and after creating the commit? > + > + (cd $testroot/wt && got diff $bold $bnew) > $testroot/diff > + ret=$? > + if [ $ret -ne 0 ]; then > + echo "diff failed unexpectedly" >&2 > + test_done "$testroot" "$ret" > + return 1 > + fi > + > + # got log adds an empty line at the bottom of a diff. > + echo >> $testroot/diff > + > + cmp -s $testroot/diff.expected $testroot/diff > + ret=$? > + if [ $ret -ne 0 ]; then > + diff -u $testroot/diff.expected $testroot/diff > + test_done "$testroot" "$ret" > + return 1 > + fi > + > test_done "$testroot" "$ret" > } > > >