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

[PATCH 3/3] apply: diagnose incomplete submodule object name better

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 1, 2013, 04:32 UTC
Message-ID
<1359693125-22357-4-git-send-email-gitster@pobox.com>
In-Reply-To
<1359693125-22357-1-git-send-email-gitster@pobox.com>

"git am -3" uses this function to build a tree that records how the preimage the patch was created from would have looked like. An abbreviated object name on the index line is ordinarily sufficient for us to figure out the object name the preimage tree would have contained, but a change to a submodule by definition shows an object name of a submodule commit which our repository should not have, and get_sha1_blob() is not an appropriate way to read it (or get_sha1() for that matter).

Use get_sha1_hex() and complain if we do not find a full object name there.

We could read from the payload part of the patch to learn the full object name of the commit, but the primary user "git rebase" has been fixed to give us a full object name, so this should suffice for now.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/apply.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/builtin/apply.c b/builtin/apply.c
index a1db7b4..1f78e2c 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3606,7 +3606,11 @@ static void build_fake_ancestor(struct patch *list, const char *filename)
 		if (0 < patch->is_new)
 			continue;
 
-		if (!get_sha1_blob(patch->old_sha1_prefix, sha1)) {
+		if (S_ISGITLINK(patch->old_mode)) {
+			if (get_sha1_hex(patch->old_sha1_prefix, sha1))
+				die("submoule change for %s without full index name",
+				    name);
+		} else if (!get_sha1_blob(patch->old_sha1_prefix, sha1)) {
 			; /* ok */
 		} else if (!patch->lines_added && !patch->lines_deleted) {
 			/* mode-only change: update the current */
-- 
1.8.1.2.612.g09f4be5
Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 11 in “"sha1 information is lacking or useless" when rebasing with a submodule pointer conflict”
  1. Michael SimsJan 30, 2013
  2. Heiko VoigtJan 30, 2013
  3. Heiko VoigtJan 30, 2013
  4. Junio C HamanoJan 30, 2013
  5. Junio C HamanoFeb 1, 2013
  6. 0/3 rebasing changes that update submodulesJunio C Hamano, Feb 1, 2013
  7. 1/3 git-am: record full index line in the patch used while rebasingJunio C Hamano, Feb 1, 2013
  8. Martin von ZweigbergkFeb 1, 2013
  9. 2/3 apply: simplify build_fake_ancestor()Junio C Hamano, Feb 1, 2013
  10. 3/3 apply: diagnose incomplete submodule object name betterJunio C Hamano, Feb 1, 2013
  11. Re* [PATCH 3/3] apply: diagnose incomplete submodule object name betterJunio C Hamano, Feb 5, 2013

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.