]> git.ipfire.org Git - thirdparty/git.git/commitdiff
add-patch: add NEEDSWORK about comparing commits
authorDenton Liu <liu.denton@gmail.com>
Wed, 7 Oct 2020 07:56:17 +0000 (00:56 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 7 Oct 2020 16:49:06 +0000 (09:49 -0700)
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>
add-patch.c
git-add--interactive.perl

index f899389e2cc2359d255f9a74430ef2a995fba004..64ab7faa964fd6695d0fe9703c8a05e23c44f171 100644 (file)
@@ -1646,6 +1646,14 @@ int run_add_p(struct repository *r, enum add_p_mode mode,
        if (mode == ADD_P_STASH)
                s.mode = &patch_mode_stash;
        else if (mode == ADD_P_RESET) {
+               /*
+                * NEEDSWORK: Instead of comparing to the literal "HEAD",
+                * compare the commit objects instead so that other ways of
+                * saying the same thing (such as "@") are also handled
+                * appropriately.
+                *
+                * This applies to the cases below too.
+                */
                if (!revision || !strcmp(revision, "HEAD"))
                        s.mode = &patch_mode_reset_head;
                else
index f36c0078ac9a71758a7e1cab701d3a633b66c0d3..d5ef7fc2ebd11dc30374cf68b558876b329564c9 100755 (executable)
@@ -1807,6 +1807,13 @@ sub process_args {
                                $arg = shift @ARGV or die __("missing --");
                                if ($arg ne '--') {
                                        $patch_mode_revision = $arg;
+
+                                       # NEEDSWORK: Instead of comparing to the literal "HEAD",
+                                       # compare the commit objects instead so that other ways of
+                                       # saying the same thing (such as "@") are also handled
+                                       # appropriately.
+                                       #
+                                       # This applies to the cases below too.
                                        $patch_mode = ($arg eq 'HEAD' ?
                                                       'reset_head' : 'reset_nothead');
                                        $arg = shift @ARGV or die __("missing --");