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 19, 2010, 23:21 UTC
Message-ID
<1284938514-16663-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1284938514-16663-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: yj2133011Next: Nguyễn Thái Ngọc Duy
Message 5 of 22 in “Introduce pathspec struct”
  1. 0/6 Introduce pathspec structNguyễn Thái Ngọc Duy, Sep 19, 2010
  2. 1/6 Add struct pathspecNguyễn Thái Ngọc Duy, Sep 19, 2010
  3. Junio C HamanoSep 27, 2010
  4. yj2133011Sep 29, 2010
  5. 2/6 diff-no-index: use diff_tree_setup_paths()Nguyễn Thái Ngọc Duy, Sep 19, 2010
  6. 3/6 pathspec: cache string length when initialize pathspecNguyễn Thái Ngọc Duy, Sep 19, 2010
  7. Junio C HamanoSep 27, 2010
  8. Nguyen Thai Ngoc DuySep 28, 2010
  9. 4/6 Convert struct diff_options to use struct pathspecNguyễn Thái Ngọc Duy, Sep 19, 2010
  10. Junio C HamanoSep 27, 2010
  11. 5/6 tree_entry_interesting(): remove dependency on struct diff_optionsNguyễn Thái Ngọc Duy, Sep 19, 2010
  12. Junio C HamanoSep 27, 2010
  13. Nguyen Thai Ngoc DuySep 28, 2010
  14. 6/6 Move tree_entry_interesting() to tree-walk.c and export itNguyễn Thái Ngọc Duy, Sep 19, 2010
  15. Elijah NewrenSep 20, 2010
  16. Nguyen Thai Ngoc DuySep 20, 2010
  17. Junio C HamanoSep 28, 2010
  18. Bo YangSep 28, 2010
  19. Nguyen Thai Ngoc DuySep 28, 2010
  20. Junio C HamanoSep 29, 2010
  21. David RiptonSep 28, 2010
  22. Junio C HamanoSep 29, 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.