summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-02-01 03:33:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-02-01 04:30:55 (GMT)
commite28efb1998bb0b73057de13b9568f6aef439a583 (patch)
treec9770fd614cb3d75eb74e590fc5f1aa813d41f84 /builtin
parente2afb0be9073fbe9f565ad9e952155c0bf7dd7c6 (diff)
downloadgit-e28efb1998bb0b73057de13b9568f6aef439a583.zip
git-e28efb1998bb0b73057de13b9568f6aef439a583.tar.gz
git-e28efb1998bb0b73057de13b9568f6aef439a583.tar.bz2
apply: diagnose incomplete submodule object name better
"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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/apply.c6
1 files changed, 5 insertions, 1 deletions
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 */