[BUG] git-stash does not handle branch name with slash correctly
From: Daniel Hahler <hidden>
Date: 2021-11-10 19:02:45
Attachments
- OpenPGP_signature [application/pgp-signature] 833 bytes
From: Daniel Hahler <hidden>
Date: 2021-11-10 19:02:45
The default (commit) message when creating a stash strips the beginning of
branch names if they contain a slash,
e.g. "WIP on 3.2.x: …" instead of "WIP on stable/3.2.x: …"
From builtin/stash.c (in do_create_stash):
branch_ref = resolve_ref_unsafe("HEAD", 0, NULL, &flags);
if (flags & REF_ISSYMREF)
branch_name = strrchr(branch_ref, '/') + 1;
Whereas git-legacy-stash has this (in create_stash):
if branch=$(git symbolic-ref -q HEAD)
then
branch=${branch#refs/heads/}
else
branch='(no branch)'
fi
msg=$(printf '%s: %s' "$branch" "$head")
I think it should also strip only "refs/heads/" or use another method that
keeps the branch name intact.
(I have noticed this with a script/function that warns me when trying to
pop a stash to another branch than where it was stashed from initially,
which parses out the (original) branch name from this message.)
[System Info]
git version:
git version 2.33.1