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

[PATCH 1/1] fast-import: show a warning for non-existent files.

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Sep 1, 2008, 13:20 UTC
Message-ID
<1220275214-6178-1-git-send-email-felipe.contreras@gmail.com>

This is useful in certain SCMs like monotone, where each 'merge revision' has the changes of all the micro-branches merged. So it appears as duplicated commands.

The delete command was ignoring the issue completely. The rename/copy commands
where throwing a fatal exception.
---
 fast-import.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 7089e6f..3dd2ab6 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1945,6 +1945,7 @@ static void file_change_d(struct branch *b)
 	const char *p = command_buf.buf + 2;
 	static struct strbuf uq = STRBUF_INIT;
 	const char *endp;
+	struct tree_entry leaf;
 
 	strbuf_reset(&uq);
 	if (!unquote_c_style(&uq, p, &endp)) {
@@ -1952,7 +1953,13 @@ static void file_change_d(struct branch *b)
 			die("Garbage after path in: %s", command_buf.buf);
 		p = uq.buf;
 	}
-	tree_content_remove(&b->branch_tree, p, NULL);
+	memset(&leaf, 0, sizeof(leaf));
+	tree_content_remove(&b->branch_tree, p, &leaf);
+	if (!leaf.versions[1].mode)
+	{
+		warning("Path %s not in branch", p);
+		return;
+	}
 }
 
 static void file_change_cr(struct branch *b, int rename)
@@ -1994,7 +2001,10 @@ static void file_change_cr(struct branch *b, int rename)
 	else
 		tree_content_get(&b->branch_tree, s, &leaf);
 	if (!leaf.versions[1].mode)
-		die("Path %s not in branch", s);
+	{
+		warning("Path %s not in branch", s);
+		return;
+	}
 	tree_content_set(&b->branch_tree, d,
 		leaf.versions[1].sha1,
 		leaf.versions[1].mode,
-- 
1.6.0.1
Next: Junio C Hamano
Message 1 of 17 in “fast-import: show a warning for non-existent files.”
  1. 1/1 fast-import: show a warning for non-existent files.Felipe Contreras, Sep 1, 2008
  2. Junio C HamanoSep 1, 2008
  3. Felipe ContrerasSep 1, 2008
  4. Shawn O. PearceSep 1, 2008
  5. Felipe ContrerasSep 1, 2008
  6. fast-import: add ignore non-existent files option.Felipe Contreras, Sep 1, 2008
  7. Shawn O. PearceSep 1, 2008
  8. Felipe ContrerasSep 1, 2008
  9. Shawn O. PearceSep 2, 2008
  10. Junio C HamanoSep 2, 2008
  11. Shawn O. PearceSep 2, 2008
  12. Junio C HamanoSep 2, 2008
  13. Felipe ContrerasSep 2, 2008
  14. Junio C HamanoSep 1, 2008
  15. Felipe ContrerasSep 1, 2008
  16. Junio C HamanoSep 2, 2008
  17. Felipe ContrerasSep 2, 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.