All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Eddie Ash via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Eddie Ash <eddie@ashfamily.net>, Edward Ash <eddie@ashfamily.net>
Subject: [PATCH] git-p4: honor client spec when unshelving
Date: Sat, 28 Nov 2026 02:42:06 +0000	[thread overview]
Message-ID: <pull.2386.git.git.1795833726252.gitgitgadget@gmail.com> (raw)

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

                 reply	other threads:[~2026-11-28  2:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.2386.git.git.1795833726252.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=eddie@ashfamily.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.