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

[WIP PATCH 3/6] unpack_callback(): use unpack_failed() consistently

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 20, 2009, 05:06 UTC
Message-ID
<1253423175-6339-4-git-send-email-gitster@pobox.com>
In-Reply-To
<1253423175-6339-1-git-send-email-gitster@pobox.com>

When unpack_index_entry() failed, consistently call unpack_failed(), instead of silently returning -1.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 unpack-trees.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index d174fe0..c424bab 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -277,6 +277,17 @@ static int unpack_nondirectories(int n, unsigned long mask,
 	return 0;
 }
 
+static int unpack_failed(struct unpack_trees_options *o, const char *message)
+{
+	discard_index(&o->result);
+	if (!o->gently) {
+		if (message)
+			return error("%s", message);
+		return -1;
+	}
+	return -1;
+}
+
 static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *names, struct traverse_info *info)
 {
 	struct cache_entry *src[MAX_UNPACK_TREES + 1] = { NULL, };
@@ -294,7 +305,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
 			int cmp = compare_entry(ce, info, p);
 			if (cmp < 0) {
 				if (unpack_index_entry(ce, o) < 0)
-					return -1;
+					return unpack_failed(o, NULL);
 				continue;
 			}
 			if (!cmp) {
@@ -352,17 +363,6 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
 	return mask;
 }
 
-static int unpack_failed(struct unpack_trees_options *o, const char *message)
-{
-	discard_index(&o->result);
-	if (!o->gently) {
-		if (message)
-			return error("%s", message);
-		return -1;
-	}
-	return -1;
-}
-
 /*
  * N-way merge "len" trees.  Returns 0 on success, -1 on failure to manipulate the
  * resulting index, -2 on failure to reflect the changes to the work tree.
-- 
1.6.5.rc1.90.ga3b1b
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 7 in “Merging with D/F conflicts”
  1. 0/6 Merging with D/F conflictsJunio C Hamano, Sep 20, 2009
  2. 1/6 diff-lib.c: fix misleading comments on oneway_diff()Junio C Hamano, Sep 20, 2009
  3. 2/6 unpack-trees: typofixJunio C Hamano, Sep 20, 2009
  4. 3/6 unpack_callback(): use unpack_failed() consistentlyJunio C Hamano, Sep 20, 2009
  5. 4/6 traverse_trees(): handle D/F conflict case sanelyJunio C Hamano, Sep 20, 2009
  6. 5/6 unpack-trees.c: prepare for looking ahead in the indexJunio C Hamano, Sep 20, 2009
  7. 6/6 read-tree --debug-unpackJunio C Hamano, Sep 20, 2009

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.