🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
1 messages
1 total messages Started by "Eddie Ash via GitGitGadget" Sat, 28 Nov 2026 02:42
[PATCH] git-p4: honor client spec when unshelving
#4009
Author: "Eddie Ash via GitGitGadget"
Date: Sat, 28 Nov 2026 02:42
115 lines
13871 bytes
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads