{"thread":{"id":"66946","subject":"[PATCH] git-p4: honor client spec when unshelving","startedAt":"2026-11-28T02:42:06Z","lastAt":"2026-11-28T02:42:06Z","messageCount":1,"participants":["Eddie Ash via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"559573","messageId":"pull.2386.git.git.1795833726252.gitgitgadget@gmail.com","threadId":"66946","inReplyTo":null,"subject":"[PATCH] git-p4: honor client spec when unshelving","fromName":"Eddie Ash via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-11-28T02:42:06Z","receivedAt":"2026-11-28T02:42:06Z","isPatch":true,"sender":{"key":"name:Eddie Ash","avatar":null},"body":"From: Edward Ash <eddie@ashfamily.net>\n\nWhen git-p4.useclientspec is enabled, P4Unshelve creates P4Sync\nwithout loading its client-spec mapping. Unshelved files are then\nplaced relative to depot paths rather than client-relative paths.\n\nInitialize the mapping before unshelving and add a regression test\ncovering a depot-to-client remap.\n\nSigned-off-by: Edward Ash <eddie@ashfamily.net>\n---\n    git-p4: honor client spec when unshelving\n    \n    \n    Description\n    ===========\n    \n    When git-p4.useclientspec is enabled, git p4 unshelve creates a P4Sync\n    instance without initializing its client-spec mapping. The unshelved\n    files are therefore written relative to the depot path instead of their\n    client-relative paths.\n    \n    Initialize the client-spec mapping in P4Unshelve.run() and add a\n    regression test covering a depot-to-client remap.\n    \n    \n    Testing\n    =======\n    \n     * make -j4\n     * make test T=t9832-unshelve.sh (skipped: this environment does not\n       have p4/p4d)\n     * make test T=t9809-git-p4-client-view.sh (skipped: this environment\n       does not have p4/p4d)\n     * python3 -m py_compile git-p4.py\n     * sh -n t/t9832-unshelve.sh\n     * git diff --check\n    \n    GitHub Issues are disabled for git/git, so the problem description is\n    included here as the issue record.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2386%2Fcazador481%2Ffix%2Fgit-p4-unshelve-client-spec-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2386/cazador481/fix/git-p4-unshelve-client-spec-v1\nPull-Request: https://github.com/git/git/pull/2386\n\n git-p4.py           |  4 ++++\n t/t9832-unshelve.sh | 37 +++++++++++++++++++++++++++++++++++++\n 2 files changed, 41 insertions(+)\n\ndiff --git a/git-p4.py b/git-p4.py\nindex c0ca7becaf..038c09e9b6 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -4470,6 +4470,10 @@ class P4Unshelve(Command):\n         sync = P4Sync()\n         changes = args\n \n+        if gitConfigBool('git-p4.useclientspec'):\n+            sync.useClientSpec = True\n+            sync.clientSpecDirs = getClientSpec()\n+\n         # only one change at a time\n         change = changes[0]\n \ndiff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh\nindex f85a60a184..a8798621f4 100755\n--- a/t/t9832-unshelve.sh\n+++ b/t/t9832-unshelve.sh\n@@ -185,4 +185,41 @@ test_expect_success 'unshelve specifying the origin' '\n \t)\n '\n \n+# Make sure unshelve uses the client spec to map depot paths into the\n+# corresponding paths in the Git worktree.\n+test_expect_success 'unshelve with client spec' '\n+\tclient_view \"//depot/... //client/remapped/...\" &&\n+\ttest_when_finished cleanup_git &&\n+\tgit p4 clone --use-client-spec --dest=\"$git\" //depot/@all &&\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\tmkdir remapped &&\n+\t\t: >remapped/client_spec_file &&\n+\t\tp4 add remapped/client_spec_file &&\n+\t\tp4 shelve -i <<EOF\n+Change: new\n+Description:\n+\tClient spec unshelve\n+Files:\n+\t//depot/client_spec_file\n+EOF\n+\t) &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tchange=$(last_shelved_change) &&\n+\t\tgit p4 unshelve $change &&\n+\t\tgit ls-tree -r --name-only refs/remotes/p4-unshelved/$change >actual &&\n+\t\tcat >expected <<-EOF &&\n+\t\tremapped/client_spec_file\n+\t\tremapped/file1\n+\t\tremapped/file_to_delete\n+\t\tremapped/file_to_integrate\n+\t\tremapped/file_to_move\n+\t\tremapped/unrelated_file0\n+\t\tremapped/unrelated_file1\n+\t\tEOF\n+\t\ttest_cmp expected actual\n+\t)\n+'\n+\n test_done\n\nbase-commit: dea0ea3582e6980ddbc1173cc8e3e9f9db91cde0\n-- \ngitgitgadget\n\n"}]}