diff options
author | Glen Choo <chooglen@google.com> | 2022-01-24 23:53:42 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-02-24 22:06:18 +0300 |
commit | ceaf037f617eb774bb8a451c1779dd9b8b12152a (patch) | |
tree | 4ece51fdb41cdf63a8257d1a848c67037eb532b7 /t/t3903-stash.sh | |
parent | dab1b7905d0b295f1acef9785bb2b9cbb0fdec84 (diff) |
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 't/t3903-stash.sh')
-rwxr-xr-x | t/t3903-stash.sh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index b149e2af44..0e16a5b85d 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -1042,6 +1042,17 @@ test_expect_success 'create stores correct message' ' test_cmp expect actual ' +test_expect_success 'create when branch name has /' ' + test_when_finished "git checkout main" && + git checkout -b some/topic && + >foo && + git add foo && + STASH_ID=$(git stash create "create test message") && + echo "On some/topic: create test message" >expect && + git show --pretty=%s -s ${STASH_ID} >actual && + test_cmp expect actual +' + test_expect_success 'create with multiple arguments for the message' ' >foo && git add foo && |