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

[PATCH 2/4] merge-recursive: use strbuf_expand() instead of interpolate()

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Nov 22, 2008, 23:13 UTC
Message-ID
<492891FC.6000908@lsrfire.ath.cx>
In-Reply-To
<4928912A.5050307@lsrfire.ath.cx>
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 ll-merge.c        |   21 +++++++++------------
 merge-recursive.c |    1 -
 2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/ll-merge.c b/ll-merge.c
index 4a71614..fa2ca52 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -8,7 +8,6 @@
 #include "attr.h"
 #include "xdiff-interface.h"
 #include "run-command.h"
-#include "interpolate.h"
 #include "ll-merge.h"
 
 struct ll_merge_driver;
@@ -169,11 +168,12 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
 			int virtual_ancestor)
 {
 	char temp[3][50];
-	char cmdbuf[2048];
-	struct interp table[] = {
-		{ "%O" },
-		{ "%A" },
-		{ "%B" },
+	struct strbuf cmd = STRBUF_INIT;
+	struct strbuf_expand_dict_entry dict[] = {
+		{ "O", temp[0] },
+		{ "A", temp[1] },
+		{ "B", temp[2] },
+		{ NULL }
 	};
 	struct child_process child;
 	const char *args[20];
@@ -189,17 +189,13 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
 	create_temp(src1, temp[1]);
 	create_temp(src2, temp[2]);
 
-	interp_set_entry(table, 0, temp[0]);
-	interp_set_entry(table, 1, temp[1]);
-	interp_set_entry(table, 2, temp[2]);
-
-	interpolate(cmdbuf, sizeof(cmdbuf), fn->cmdline, table, 3);
+	strbuf_expand(&cmd, fn->cmdline, strbuf_expand_dict_cb, &dict);
 
 	memset(&child, 0, sizeof(child));
 	child.argv = args;
 	args[0] = "sh";
 	args[1] = "-c";
-	args[2] = cmdbuf;
+	args[2] = cmd.buf;
 	args[3] = NULL;
 
 	status = run_command(&child);
@@ -224,6 +220,7 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
  bad:
 	for (i = 0; i < 3; i++)
 		unlink(temp[i]);
+	strbuf_release(&cmd);
 	return status;
 }
 
diff --git a/merge-recursive.c b/merge-recursive.c
index 7472d3e..0e988f2 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -16,7 +16,6 @@
 #include "string-list.h"
 #include "xdiff-interface.h"
 #include "ll-merge.h"
-#include "interpolate.h"
 #include "attr.h"
 #include "merge-recursive.h"
 #include "dir.h"
-- 
1.6.0.4.755.g6e139
Previous: René ScharfeNext: René Scharfe
Message 2 of 7 in “add strbuf_expand_dict_cb(), a helper for simple cases”
  1. 1/4 add strbuf_expand_dict_cb(), a helper for simple casesRené Scharfe, Nov 22, 2008
  2. 2/4 merge-recursive: use strbuf_expand() instead of interpolate()René Scharfe, Nov 22, 2008
  3. 3/4 daemon: use strbuf_expand() instead of interpolate()René Scharfe, Nov 22, 2008
  4. 4/4 remove the unused files interpolate.c and interpolate.hRené Scharfe, Nov 22, 2008
  5. 1/4 daemon: inline fill_in_extra_table_entries()René Scharfe, Nov 22, 2008
  6. 2/4 daemon: deglobalize variable 'directory'René Scharfe, Nov 22, 2008
  7. Jon LoeligerDec 4, 2008

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.