Merge branch 'gc/stash-on-branch-with-multi-level-name'

"git checkout -b branch/with/multi/level/name && git stash" only
recorded the last level component of the branch name, which has
been corrected.

* gc/stash-on-branch-with-multi-level-name:
  stash: strip "refs/heads/" with skip_prefix
This commit is contained in:
Junio C Hamano 2022-03-06 21:25:32 -08:00
Родитель 061fd5727d ceaf037f61
Коммит 11da0a5580
2 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -1045,6 +1045,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 &&