* [PATCH] git-p4: honor client spec when unshelving
@ 2026-11-28 2:42 Eddie Ash via GitGitGadget
0 siblings, 0 replies; only message in thread
From: Eddie Ash via GitGitGadget @ 2026-11-28 2:42 UTC (permalink / raw)
To: git; +Cc: Eddie Ash, Edward Ash
From: Edward Ash <eddie@ashfamily.net>
When git-p4.useclientspec is enabled, P4Unshelve creates P4Sync
without loading its client-spec mapping. Unshelved files are then
placed relative to depot paths rather than client-relative paths.
Initialize the mapping before unshelving and add a regression test
covering a depot-to-client remap.
Signed-off-by: Edward Ash <eddie@ashfamily.net>
---
git-p4: honor client spec when unshelving
Description
===========
When git-p4.useclientspec is enabled, git p4 unshelve creates a P4Sync
instance without initializing its client-spec mapping. The unshelved
files are therefore written relative to the depot path instead of their
client-relative paths.
Initialize the client-spec mapping in P4Unshelve.run() and add a
regression test covering a depot-to-client remap.
Testing
=======
* make -j4
* make test T=t9832-unshelve.sh (skipped: this environment does not
have p4/p4d)
* make test T=t9809-git-p4-client-view.sh (skipped: this environment
does not have p4/p4d)
* python3 -m py_compile git-p4.py
* sh -n t/t9832-unshelve.sh
* git diff --check
GitHub Issues are disabled for git/git, so the problem description is
included here as the issue record.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2386%2Fcazador481%2Ffix%2Fgit-p4-unshelve-client-spec-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2386/cazador481/fix/git-p4-unshelve-client-spec-v1
Pull-Request: https://github.com/git/git/pull/2386
git-p4.py | 4 ++++
t/t9832-unshelve.sh | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/git-p4.py b/git-p4.py
index c0ca7becaf..038c09e9b6 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -4470,6 +4470,10 @@ class P4Unshelve(Command):
sync = P4Sync()
changes = args
+ if gitConfigBool('git-p4.useclientspec'):
+ sync.useClientSpec = True
+ sync.clientSpecDirs = getClientSpec()
+
# only one change at a time
change = changes[0]
diff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh
index f85a60a184..a8798621f4 100755
--- a/t/t9832-unshelve.sh
+++ b/t/t9832-unshelve.sh
@@ -185,4 +185,41 @@ test_expect_success 'unshelve specifying the origin' '
)
'
+# Make sure unshelve uses the client spec to map depot paths into the
+# corresponding paths in the Git worktree.
+test_expect_success 'unshelve with client spec' '
+ client_view "//depot/... //client/remapped/..." &&
+ test_when_finished cleanup_git &&
+ git p4 clone --use-client-spec --dest="$git" //depot/@all &&
+ (
+ cd "$cli" &&
+ mkdir remapped &&
+ : >remapped/client_spec_file &&
+ p4 add remapped/client_spec_file &&
+ p4 shelve -i <<EOF
+Change: new
+Description:
+ Client spec unshelve
+Files:
+ //depot/client_spec_file
+EOF
+ ) &&
+ (
+ cd "$git" &&
+ change=$(last_shelved_change) &&
+ git p4 unshelve $change &&
+ git ls-tree -r --name-only refs/remotes/p4-unshelved/$change >actual &&
+ cat >expected <<-EOF &&
+ remapped/client_spec_file
+ remapped/file1
+ remapped/file_to_delete
+ remapped/file_to_integrate
+ remapped/file_to_move
+ remapped/unrelated_file0
+ remapped/unrelated_file1
+ EOF
+ test_cmp expected actual
+ )
+'
+
test_done
base-commit: dea0ea3582e6980ddbc1173cc8e3e9f9db91cde0
--
gitgitgadget
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-28 2:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 2:42 [PATCH] git-p4: honor client spec when unshelving Eddie Ash via GitGitGadget
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.