format-patch: clear UNINTERESTING flag before prepare_bases

When users specify the commit range with 'Z..C' pattern for format-patch, all the parents of Z (including Z) would be marked as UNINTERESTING which would prevent revision walk in prepare_bases from getting the prerequisite commits, thus `git format-patch --base <base_commit_sha> Z..C` won't be able to generate the list of prerequisite patch ids. Clear UNINTERESTING flag with clear_object_flags solves this issue. Reported-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Xiaolong Ye committed Jun 4, 2018 at 23:05 UTC 15b76c1fb3ab013b99498c9dca333aaa4808927e
2 files changed +5 -2
builtin/log.c
+1
@@ -1741,6 +1741,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1741 if (base_commit || base_auto) {
1742 struct commit *base = get_base_commit(base_commit, list, nr);
1743 reset_revision_walk();
1744 + clear_object_flags(UNINTERESTING);
1745 prepare_bases(&bases, base, list, nr);
1746 }
1747
t/t4014-format-patch.sh
+4 -2
@@ -1551,13 +1551,15 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
1551
1552 test_expect_success 'format-patch --base' '
1553 git checkout side &&
1554 - git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual &&
1554 + git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
1555 + git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
1556 echo >expected &&
1557 echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
1558 echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
1559 echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
1560 signature >> expected &&
1560 - test_cmp expected actual
1561 + test_cmp expected actual1 &&
1562 + test_cmp expected actual2
1563 '
1564
1565 test_expect_success 'format-patch --base errors out when base commit is in revision list' '