@matheusbsbs / matheus-bagliano / commits / f82a9e517f
Fork 0

add-patch: add NEEDSWORK about comparing commits

The two versions of add-patch has special-casing for the literal revision "HEAD". However, we want to handle other ways of saying "HEAD" in the same way.[0] Add a NEEDSWORK to the add-patch code that does this so that it can be addressed later. [0]: https://lore.kernel.org/git/xmqqsgat7ttf.fsf@gitster.c.googlers.com/ Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Denton Liu committed Oct 7, 2020 at 00:56 UTC f82a9e517fc063bb97063e4df2cdde2fd1f7ffbe
2 files changed +15
add-patch.c
+8
@@ -1646,6 +1646,14 @@ int run_add_p(struct repository *r, enum add_p_mode mode,
1646 if (mode == ADD_P_STASH)
1647 s.mode = &patch_mode_stash;
1648 else if (mode == ADD_P_RESET) {
1649 + /*
1650 + * NEEDSWORK: Instead of comparing to the literal "HEAD",
1651 + * compare the commit objects instead so that other ways of
1652 + * saying the same thing (such as "@") are also handled
1653 + * appropriately.
1654 + *
1655 + * This applies to the cases below too.
1656 + */
1657 if (!revision || !strcmp(revision, "HEAD"))
1658 s.mode = &patch_mode_reset_head;
1659 else
git-add--interactive.perl
+7
@@ -1807,6 +1807,13 @@ sub process_args {
1807 $arg = shift @ARGV or die __("missing --");
1808 if ($arg ne '--') {
1809 $patch_mode_revision = $arg;
1810 +
1811 + # NEEDSWORK: Instead of comparing to the literal "HEAD",
1812 + # compare the commit objects instead so that other ways of
1813 + # saying the same thing (such as "@") are also handled
1814 + # appropriately.
1815 + #
1816 + # This applies to the cases below too.
1817 $patch_mode = ($arg eq 'HEAD' ?
1818 'reset_head' : 'reset_nothead');
1819 $arg = shift @ARGV or die __("missing --");