From: Stefan Sperling Subject: Re: File ordering of log -P vs. log -p To: Christian Weisgerber Cc: gameoftrees@openbsd.org Date: Mon, 20 Dec 2021 14:10:07 +0100 On Mon, Dec 20, 2021 at 12:55:11PM +0100, Christian Weisgerber wrote: > The list of paths show by "got log -P" can be ordered differently > than the modifications show by "got log -p". Is that a bug? > > For an example, look at commit b5cf4b705436b61a91a828308f35bfafac7134d4 > "add php-8.1.1" in OpenBSD ports.git: > > A lang/php/8.1/Makefile > A lang/php/8.1/distinfo > A lang/php/8.1/patches/patch-build_php_m4 > A lang/php/8.1/patches/patch-configure_ac > ... > A lang/php/8.1/pkg/PLIST-apache > A lang/php/8.1/pkg/PLIST-bz2 > ... > A lang/php/8.1/pkg/php81_fpm.rc > M lang/php/Makefile > M lang/php/pecl/pecl.port.mk > M lang/php/php.port.mk > > lang/php/Makefile is listed third from the bottom, but in the patch > it's the very first file. > > tog's diff view is equally affected. The -P list is sorted by path, and paths in the diff appear as a result of a tree walk. To make the -P case the same we can append paths to the -P list instead of using the smarter insert method that tries to keep paths in sorted order. Try the patch below. Regression tests are still passing. got log -P output for commit b5cf4b705436 changes like this: @@ -5,6 +5,7 @@ add php-8.1.1 + M lang/php/Makefile A lang/php/8.1/Makefile A lang/php/8.1/distinfo A lang/php/8.1/patches/patch-build_php_m4 @@ -55,7 +56,6 @@ A lang/php/8.1/pkg/PLIST-xsl A lang/php/8.1/pkg/PLIST-zip A lang/php/8.1/pkg/php81_fpm.rc - M lang/php/Makefile M lang/php/pecl/pecl.port.mk M lang/php/php.port.mk diff 487cd7d2bc0f29c4fb6800c8c815be552ad06ea6 /home/stsp/src/got blob - 8049aab224eea3bbfc105be06c2c34e8f89c21d3 file + lib/diff.c --- lib/diff.c +++ lib/diff.c @@ -626,7 +626,7 @@ got_diff_tree_collect_changed_paths(void *arg, struct change->status = GOT_STATUS_MODE_CHANGE; } - err = got_pathlist_insert(NULL, paths, path, change); + err = got_pathlist_append(paths, path, change); done: if (err) { free(path);