On Wed, Nov 10, 2021 at 07:55:06PM +0100, Daniel Hahler wrote: > 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. Yes, the C behavior just seems wrong (and came as part of the C rewrite, so doesn't seem intentional). Something like: diff --git a/builtin/stash.c b/builtin/stash.c index d441481d68..70dcb15cb7 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1334,7 +1334,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b branch_ref = resolve_ref_unsafe("HEAD", 0, NULL, &flags); if (flags & REF_ISSYMREF) - branch_name = strrchr(branch_ref, '/') + 1; + skip_prefix(branch_ref, "refs/heads/", &branch_name); head_short_sha1 = find_unique_abbrev(&head_commit->object.oid, DEFAULT_ABBREV); strbuf_addf(&msg, "%s: %s ", branch_name, head_short_sha1); seems like the right fix. Do you want to try to work that into a patch with a test? -Peff