From: Junio C Hamano Date: Wed, 14 May 2025 13:28:56 GMT Subject: Re: [PATCH] stash: fix incorrect branch name in stash message Message-ID: In-Reply-To: JAYATHEERTH K writes: > On Tue, May 13, 2025 at 12:24 AM Eric Sunshine wrote: >> >> On Mon, May 12, 2025 at 1:50 PM Junio C Hamano wrote: >> > K Jayatheerth writes: >> > > @@ -1404,11 +1405,20 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b >> > > + if (flags & REF_ISSYMREF) { >> > > + const char *tmp = NULL; >> > > + if (skip_prefix(branch_ref, "refs/heads/", &tmp)) >> > > + branch_name_buf = xstrdup(tmp); >> > > + } >> > > + if (branch_name_buf) >> > > + branch_name = branch_name_buf; >> > > + else >> > > + branch_name = "(no branch)"; >> > > + >> > > + head_short_sha1 = repo_find_unique_abbrev(the_repository, >> > > + &head_commit->object.oid, >> > > + DEFAULT_ABBREV); >> > > strbuf_addf(&msg, "%s: %s ", branch_name, head_short_sha1); >> > > pp_commit_easy(CMIT_FMT_ONELINE, head_commit, &msg); >> > >> > Funny indentation, and branch_name_buf needs to be free'ed after use >> > but other than that, nice digging! >> >> This change should also be accompanied by a new test to verify the >> fixed behavior, right? > > I will be writing a patch series after checking CI and include tests, > the only reason I sent this patch was > if the bug reporter needed an immediate fix. > Will send a new patch with test case and improved indentation Don't forget to plug the leak, too ;-) > Thanks for pointing it out