commit 502b9684f951602db159ea8e357e404480666eec from: Stefan Sperling date: Fri Jul 31 15:36:42 2020 UTC make 'got log' -R and -P options work in combination With -R, the -P option did not show any paths. Regression test added here demonstrates the problem. commit - 631179de38cd91f5e53311c37386314fa2504ccd commit + 502b9684f951602db159ea8e357e404480666eec blob - b786141f0da3d2e72828aa6588c6bb709920e2f1 blob + 7d306e82e5e51906ac29b7b1df6b2cc05f281e95 --- got/got.c +++ got/got.c @@ -3259,7 +3259,7 @@ print_commits(struct got_object_id *root_id, struct go if (err) break; - if (show_changed_paths) { + if (show_changed_paths && !reverse_display_order) { err = get_changed_paths(&changed_paths, commit, repo); if (err) break; @@ -3314,12 +3314,23 @@ print_commits(struct got_object_id *root_id, struct go err = got_object_open_as_commit(&commit, repo, qid->id); if (err) break; + if (show_changed_paths) { + err = get_changed_paths(&changed_paths, + commit, repo); + if (err) + break; + } err = print_commit(commit, qid->id, repo, path, show_changed_paths ? &changed_paths : NULL, show_patch, diff_context, refs); got_object_commit_close(commit); if (err) break; + TAILQ_FOREACH(pe, &changed_paths, entry) { + free((char *)pe->path); + free(pe->data); + } + got_pathlist_free(&changed_paths); } } done: blob - c563ee1744ab12c961f2d4a98fcb8a56e3f2df3f blob + 6f9463fae57dbf5ce1d3fc5565e0e61424794051 --- regress/cmdline/log.sh +++ regress/cmdline/log.sh @@ -577,7 +577,30 @@ function test_log_reverse_display { ret="$?" if [ "$ret" != "0" ]; then diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 fi + + # -R works in combination with -P + echo "" > $testroot/stdout.expected + (cd $testroot/wt && got log -R -P | grep -E '^(commit| [MDmA])' \ + > $testroot/stdout) + echo "commit $commit_id0" > $testroot/stdout.expected + echo " A alpha" >> $testroot/stdout.expected + echo " A beta" >> $testroot/stdout.expected + echo " A epsilon/zeta" >> $testroot/stdout.expected + echo " A gamma/delta" >> $testroot/stdout.expected + echo "commit $commit_id1" >> $testroot/stdout.expected + echo " M alpha" >> $testroot/stdout.expected + echo "commit $commit_id2" >> $testroot/stdout.expected + echo " D beta" >> $testroot/stdout.expected + echo "commit $commit_id3 (master)" >> $testroot/stdout.expected + echo " A new" >> $testroot/stdout.expected + cmp -s $testroot/stdout.expected $testroot/stdout + ret="$?" + if [ "$ret" != "0" ]; then + diff -u $testroot/stdout.expected $testroot/stdout + fi test_done "$testroot" "$ret" }