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

[PATCH 3/3] submodule: use diff_tree_combined_merge() instead of diff_tree_combined()

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Dec 17, 2011, 10:27 UTC
Message-ID
<4EEC6E87.3060204@lsrfire.ath.cx>
In-Reply-To
<4EEC6CD7.2030408@lsrfire.ath.cx>
Use diff_tree_combined_merge() instead of open-coding it.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 submodule.c |   14 +++-----------
 1 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/submodule.c b/submodule.c
index 788d532..9a28060 100644
--- a/submodule.c
+++ b/submodule.c
@@ -371,23 +371,15 @@ static void collect_submodules_from_diff(struct diff_queue_struct *q,
 }
 
 
-static void commit_need_pushing(struct commit *commit, struct commit_list *parent, int *needs_pushing)
+static void commit_need_pushing(struct commit *commit, int *needs_pushing)
 {
-	struct sha1_array parents = SHA1_ARRAY_INIT;
 	struct rev_info rev;
 
-	while (parent) {
-		sha1_array_append(&parents, parent->item->object.sha1);
-		parent = parent->next;
-	}
-
 	init_revisions(&rev, NULL);
 	rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
 	rev.diffopt.format_callback = collect_submodules_from_diff;
 	rev.diffopt.format_callback_data = needs_pushing;
-	diff_tree_combined(commit->object.sha1, &parents, 1, &rev);
-
-	sha1_array_clear(&parents);
+	diff_tree_combined_merge(commit, 1, &rev);
 }
 
 int check_submodule_needs_pushing(unsigned char new_sha1[20], const char *remotes_name)
@@ -410,7 +402,7 @@ int check_submodule_needs_pushing(unsigned char new_sha1[20], const char *remote
 		die("revision walk setup failed");
 
 	while ((commit = get_revision(&rev)) && !needs_pushing)
-		commit_need_pushing(commit, commit->parents, &needs_pushing);
+		commit_need_pushing(commit, &needs_pushing);
 
 	free(sha1_copy);
 	strbuf_release(&remotes_arg);
-- 
1.7.8
Previous: René ScharfeNext: René Scharfe
Message 3 of 8 in “use struct sha1_array in diff_tree_combined()”
  1. 1/3 use struct sha1_array in diff_tree_combined()René Scharfe, Dec 17, 2011
  2. 2/3 pass struct commit to diff_tree_combined_merge()René Scharfe, Dec 17, 2011
  3. 3/3 submodule: use diff_tree_combined_merge() instead of diff_tree_combined()René Scharfe, Dec 17, 2011
  4. René ScharfeDec 17, 2011
  5. René ScharfeDec 17, 2011
  6. Jeff KingDec 17, 2011
  7. René ScharfeDec 17, 2011
  8. Jeff KingDec 17, 2011

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.