format-patch: clear UNINTERESTING flag before prepare_bases
authorXiaolong Ye <xiaolong.ye@intel.com>
Mon, 4 Jun 2018 15:05:43 +0000 (23:05 +0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Jun 2018 18:36:41 +0000 (11:36 -0700)
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>
builtin/log.c
t/t4014-format-patch.sh
index 14fdf39165d20602ad8b682b55660ec2466c1d20..9ee2bd1fd806e41497419b944c62c26b688e4884 100644 (file)
@@ -1741,6 +1741,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        if (base_commit || base_auto) {
                struct commit *base = get_base_commit(base_commit, list, nr);
                reset_revision_walk();
+               clear_object_flags(UNINTERESTING);
                prepare_bases(&bases, base, list, nr);
        }
 
index 482112ca339f05fc31e6f9c2c6168971a1121e87..b67d5729df5863cda8e371de6bd39d8368b4f965 100755 (executable)
@@ -1551,13 +1551,15 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
 
 test_expect_success 'format-patch --base' '
        git checkout side &&
-       git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual &&
+       git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
+       git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
        echo >expected &&
        echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
        echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
        echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
        signature >> expected &&
-       test_cmp expected actual
+       test_cmp expected actual1 &&
+       test_cmp expected actual2
 '
 
 test_expect_success 'format-patch --base errors out when base commit is in revision list' '