Re: [PATCH v3] stash: fix incorrect branch name in stash message
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 11, 2025, 16:00 UTC
- Message-ID
- <xmqqqzzqi7yy.fsf@gitster.g>
- In-Reply-To
- <20250611014204.24994-1-jayatheerthkulkarni2005@gmail.com>
K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:
Show 15 quoted lines
> When creating a stash, Git uses the current branch name > of the superproject to construct the stash commit message. > However, in repositories with submodules, > the message may mistakenly display the submodule branch name instead. > > This is because `refs_resolve_ref_unsafe()` returns a pointer to a static buffer. > Subsequent calls to the same function overwrite the buffer, > corrupting the originally fetched `branch_name` used for the stash message. > > Use `xstrdup()` to duplicate the branch name immediately after resolving it, > so that later buffer overwrites do not affect the stash message. > > Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com> > --- > 1. Used the hook to remove trailing whitespaces
Huh? The pre-commit hook trick I showed was to detect and prevent you from creating such a commit; it does not remove them for you. Your trailing whitespaces still remain in the patch just fine ;-)
Show 7 quoted lines
> @@ -1401,11 +1402,15 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b > ret = 1; > goto done; > } > - > + > branch_ref = refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
which causes
.git/rebase-apply/patch:29: trailing whitespace.
.git/rebase-apply/patch:39: trailing whitespace.
warning: 2 lines applied after fixing whitespace errors.
Applying: stash: fix incorrect branch name in stash messageOther than that, looing good.
Thanks, will queue.