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

[PATCH 2/6] diff-no-index: use diff_tree_setup_paths()

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Sep 28, 2010, 12:00 UTC
Message-ID
<1285675229-28019-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1285675229-28019-1-git-send-email-pclouds@gmail.com>

diff_options.{paths,nr_paths} will be removed later. Do not modify them directly.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 diff-no-index.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/diff-no-index.c b/diff-no-index.c
index ce9e783..e48ab92 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -231,8 +231,9 @@ void diff_no_index(struct rev_info *revs,
 
 	if (prefix) {
 		int len = strlen(prefix);
+		const char *paths[3];
+		memset(paths, 0, sizeof(paths));
 
-		revs->diffopt.paths = xcalloc(2, sizeof(char *));
 		for (i = 0; i < 2; i++) {
 			const char *p = argv[argc - 2 + i];
 			/*
@@ -242,12 +243,12 @@ void diff_no_index(struct rev_info *revs,
 			p = (strcmp(p, "-")
 			     ? xstrdup(prefix_filename(prefix, len, p))
 			     : p);
-			revs->diffopt.paths[i] = p;
+			paths[i] = p;
 		}
+		diff_tree_setup_paths(paths, &revs->diffopt);
 	}
 	else
-		revs->diffopt.paths = argv + argc - 2;
-	revs->diffopt.nr_paths = 2;
+		diff_tree_setup_paths(argv + argc - 2, &revs->diffopt);
 	revs->diffopt.skip_stat_unmatch = 1;
 	if (!revs->diffopt.output_format)
 		revs->diffopt.output_format = DIFF_FORMAT_PATCH;
-- 
1.7.1.rc1.70.g788ca
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 3 of 7 in “Introduct pathspec struct”
  1. 0/6 Introduct pathspec structNguyễn Thái Ngọc Duy, Sep 28, 2010
  2. 1/6 Add struct pathspecNguyễn Thái Ngọc Duy, Sep 28, 2010
  3. 2/6 diff-no-index: use diff_tree_setup_paths()Nguyễn Thái Ngọc Duy, Sep 28, 2010
  4. 3/6 pathspec: cache string length when initializing pathspecNguyễn Thái Ngọc Duy, Sep 28, 2010
  5. 4/6 Convert struct diff_options to use struct pathspecNguyễn Thái Ngọc Duy, Sep 28, 2010
  6. 5/6 tree_entry_interesting(): remove dependency on struct diff_optionsNguyễn Thái Ngọc Duy, Sep 28, 2010
  7. 6/6 Move tree_entry_interesting() to tree-walk.c and export itNguyễn Thái Ngọc Duy, Sep 28, 2010

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.