From: Jasper Mayone Date: Thu, 19 Nov 2026 15:14:36 GMT Subject: Re: [PATCH v8 4/4] branch: let --delete-integrated find branches merged onto changed files Message-ID: <20261119151436.86191-1-me@jaspermayone.com> In-Reply-To: Junio C Hamano writes: > ... this code to call merge_keeps_upstream(), causing read_mmfile() > on the gitlink commit from submodule object database, leading to a > crash, no? > > Or am I misreading the code flow? You are reading it right. I tried it on v8: the upstream has "lib" as a gitlink, the branch replaces it with a regular file, and the upstream replaces it with a different regular file. Then $ git branch --delete-integrated origin/main fatal: unable to read blob object dae1aadd914ecfe1e09b3adb3c15abdd0085e238 It does not segfault, because read_mmblob() checks the object type and dies, but the command stops and no branch is deleted. Recording the mode of the base and requiring a regular file there too fixes it for me. The branch is then kept, and t3200 still passes: --- a/builtin/branch.c +++ b/builtin/branch.c @@ -864,7 +864,7 @@ enum change_state { struct branch_change { char *path; struct object_id base_oid, branch_oid, upstream_oid; - unsigned short branch_mode; + unsigned short base_mode, branch_mode; enum change_state state; }; @@ -901,6 +901,7 @@ static void collect_branch_changes(struct landing_search *search, &p->one->oid : null_oid(the_hash_algo)); oidcpy(&change->branch_oid, DIFF_FILE_VALID(p->two) ? &p->two->oid : null_oid(the_hash_algo)); + change->base_mode = p->one->mode; change->branch_mode = p->two->mode; } diff_flush(&diffopt); @@ -943,7 +944,8 @@ static enum change_state change_state_at(struct branch_change *change, if (is_null_oid(&change->base_oid) || is_null_oid(&change->branch_oid) || oideq(&change->upstream_oid, &change->base_oid) || - mode != change->branch_mode || !S_ISREG(mode)) + mode != change->branch_mode || !S_ISREG(mode) || + !S_ISREG(change->base_mode)) return CHANGE_MISSING; return CHANGE_NEEDS_MERGE; } Harald, a test for this case in t3200 would be good too. Thanks Jasper