git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 3/4] add-patch: add NEEDSWORK about comparing commits

From
Denton Liu <liu.denton@gmail.com>
Date
Oct 7, 2020, 07:56 UTC
Message-ID
<44ee78450e1cfe26b47cc4343c5d445df2b96d7b.1602057332.git.liu.denton@gmail.com>
In-Reply-To
<cover.1602057332.git.liu.denton@gmail.com>

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>
---
 add-patch.c               | 8 ++++++++
 git-add--interactive.perl | 7 +++++++
 2 files changed, 15 insertions(+)
diff --git a/add-patch.c b/add-patch.c
index bd94bd3a7c..be4cf6e9e5 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1695,6 +1695,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
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 8a72018712..e713fe3d02 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1830,6 +1830,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 --");
-- 
2.28.0.942.g77c4c6094c
Previous: Denton Liu
Message 9 of 9 in “checkout/restore: fix `git checkout -p HEAD...` bug”
  1. 0/2 checkout/restore: fix `git checkout -p HEAD...` bugDenton Liu, Oct 4, 2020
  2. 1/2 builtin/checkout: fix `git checkout -p HEAD...` bugDenton Liu, Oct 4, 2020
  3. Junio C HamanoOct 4, 2020
  4. 2/2 Doc: document "A...B" form for <tree-ish> in checkout and switchDenton Liu, Oct 4, 2020
  5. 0/4 checkout/restore: fix `git checkout -p HEAD...` bugDenton Liu, Oct 7, 2020
  6. 1/4 builtin/checkout: fix `git checkout -p HEAD...` bugDenton Liu, Oct 7, 2020
  7. 2/4 Doc: document "A...B" form for <tree-ish> in checkout and switchDenton Liu, Oct 7, 2020
  8. 4/4 t2016: add a NEEDSWORK about the PERL prerequisiteDenton Liu, Oct 7, 2020
  9. 3/4 add-patch: add NEEDSWORK about comparing commitsDenton Liu, Oct 7, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.