summaryrefslogtreecommitdiff
path: root/builtin/stash.c
diff options
context:
space:
mode:
authorGlen Choo <chooglen@google.com>2022-01-24 20:53:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-02-24 19:06:18 (GMT)
commitceaf037f617eb774bb8a451c1779dd9b8b12152a (patch)
tree4ece51fdb41cdf63a8257d1a848c67037eb532b7 /builtin/stash.c
parentdab1b7905d0b295f1acef9785bb2b9cbb0fdec84 (diff)
downloadgit-ceaf037f617eb774bb8a451c1779dd9b8b12152a.zip
git-ceaf037f617eb774bb8a451c1779dd9b8b12152a.tar.gz
git-ceaf037f617eb774bb8a451c1779dd9b8b12152a.tar.bz2
stash: strip "refs/heads/" with skip_prefix
When generating a message for a stash, "git stash" only records the part of the branch name to the right of the last "/". e.g. if HEAD is at "foo/bar/baz", "git stash" generates a message prefixed with "WIP on baz:" instead of "WIP on foo/bar/baz:". Fix this by using skip_prefix() to skip "refs/heads/" instead of looking for the last instance of "/". Reported-by: Kraymer <kraymer@gmail.com> Reported-by: Daniel Hahler <git@thequod.de> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/stash.c')
-rw-r--r--builtin/stash.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/stash.c b/builtin/stash.c
index 5897feb..3e8af21 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -1327,7 +1327,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);