Re: [PATCH] stash: fix incorrect branch name in stash message
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- May 12, 2025, 18:54 UTC
- Message-ID
- <CAPig+cSbwGdhq66tSk_A5oNGXqpbqFA=ZO5GS1E-ENb+_rY70A@mail.gmail.com>
- In-Reply-To
- <xmqqtt5psor5.fsf@gitster.g>
On Mon, May 12, 2025 at 1:50 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 20 quoted lines
> K Jayatheerth <jayatheerthkulkarni2005@gmail.com> 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?