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

[PATCH 1/2] add-patch: do not use the_repository

From
PGPhilip Peterson via GitGitGadget <gitgitgadget@gmail.com>
Date
May 28, 2024, 06:32 UTC
Message-ID
<c0bb37db12ea8724431fe4294d591cd8cef73e66.1716877921.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1728.git.git.1716877921.gitgitgadget@gmail.com>
From: Philip Peterson <philip.c.peterson@gmail.com>

Because usage of the global the_repository is deprecated, remove the usage of it in favor of a passed arg representing the repository.

Signed-off-by: Philip Peterson <philip.c.peterson@gmail.com>
---
 add-patch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/add-patch.c b/add-patch.c
index 2252895c280..b7f09122e1f 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -399,7 +399,7 @@ static void complete_file(char marker, struct hunk *hunk)
 		hunk->splittable_into++;
 }
 
-static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
+static int parse_diff(struct repository *r, struct add_p_state *s, const struct pathspec *ps)
 {
 	struct strvec args = STRVEC_INIT;
 	const char *diff_algorithm = s->s.interactive_diff_algorithm;
@@ -419,7 +419,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 		strvec_push(&args,
 			    /* could be on an unborn branch */
 			    !strcmp("HEAD", s->revision) &&
-			    repo_get_oid(the_repository, "HEAD", &oid) ?
+			    repo_get_oid(r, "HEAD", &oid) ?
 			    empty_tree_oid_hex() : s->revision);
 	}
 	color_arg_index = args.nr;
@@ -1768,7 +1768,7 @@ int run_add_p(struct repository *r, enum add_p_mode mode,
 	    (!s.mode->index_only &&
 	     repo_refresh_and_write_index(r, REFRESH_QUIET, 0, 1,
 					  NULL, NULL, NULL) < 0) ||
-	    parse_diff(&s, ps) < 0) {
+	    parse_diff(r, &s, ps) < 0) {
 		add_p_state_clear(&s);
 		return -1;
 	}
-- 
gitgitgadget
Previous: Philip Peterson via GitGitGadgetNext: Junio C Hamano
Message 2 of 8 in “Remove some usages of the_repository”
  1. 0/2 Remove some usages of the_repositoryPhilip Peterson via GitGitGadget, May 28, 2024
  2. 1/2 add-patch: do not use the_repositoryPhilip Peterson via GitGitGadget, May 28, 2024
  3. Junio C HamanoMay 28, 2024
  4. 2/2 apply: do not use the_repositoryPhilip Peterson via GitGitGadget, May 28, 2024
  5. Patrick SteinhardtMay 28, 2024
  6. Junio C HamanoMay 28, 2024
  7. Patrick SteinhardtMay 28, 2024
  8. Junio C HamanoMay 28, 2024

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.