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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
diff --git a/got/got.c b/got/got.c
index b786141..7d306e8 100644
--- a/got/got.c
+++ b/got/got.c
@@ -3259,7 +3259,7 @@ print_commits(struct got_object_id *root_id, struct got_object_id *end_id,
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 got_object_id *end_id,
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:
diff --git a/regress/cmdline/log.sh b/regress/cmdline/log.sh
index c563ee1..6f9463f 100755
--- a/regress/cmdline/log.sh
+++ b/regress/cmdline/log.sh
@@ -577,6 +577,29 @@ 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"
}