From 9ebd9b6965e420c28441541117adc2a8034934a0 Mon Sep 17 00:00:00 2001
From: Raja Boujbel <raja.boujbel@ocamlpro.com>
Date: Wed, 27 Nov 2024 16:25:38 +0100
Subject: [PATCH 1/2] ci: add opam-rt branch lookup for the form of
 username/branchname

---
 .github/scripts/main/main.sh | 3 +++
 .github/workflows/ci.ml      | 4 +++-
 .github/workflows/main.yml   | 2 ++
 master_changes.md            | 1 +
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/.github/scripts/main/main.sh b/.github/scripts/main/main.sh
index 6f5385670f5..8e9e6e39049 100644
--- a/.github/scripts/main/main.sh
+++ b/.github/scripts/main/main.sh
@@ -127,6 +127,9 @@ if [ "$OPAM_TEST" = "1" ]; then
   fi
   cd $CACHE/opam-rt
   git fetch origin
+  if [ "$GITHUB_EVENT_NAME" = "pull_request" ] && git ls-remote --exit-code origin "$GITHUB_PR_USER/$BRANCH" ; then
+    BRANCH=$GITHUB_PR_USER/$BRANCH
+  fi
   if git ls-remote --exit-code origin $BRANCH ; then
     if git branch | grep -q $BRANCH; then
       git checkout $BRANCH
diff --git a/.github/workflows/ci.ml b/.github/workflows/ci.ml
index 9ff06d19121..d2c33c5414d 100644
--- a/.github/workflows/ci.ml
+++ b/.github/workflows/ci.ml
@@ -378,7 +378,9 @@ let main_test_job ~analyse_job ~build_linux_job ~build_windows_job:_ ~build_macO
   let matrix = platform_ocaml_matrix ~fail_fast:false start_latests_ocaml in
   let host = host_of_platform platform in
   let ocamlv = "${{ matrix.ocamlv }}" in
-  job ~oc ~workflow ?section ~runs_on:(Runner [runner]) ~env:[("OPAM_TEST", "1")] ~matrix ~needs ("Test-" ^ name_of_platform platform)
+  job ~oc ~workflow ?section ~runs_on:(Runner [runner])
+    ~env:[("OPAM_TEST", "1"); ("GITHUB_PR_USER", "${{ github.event.pull_request.user.login }}")]
+    ~matrix ~needs ("Test-" ^ name_of_platform platform)
     ++ only_on MacOS (install_sys_packages ["coreutils"; "gpatch"] ~descr:"Install gnu coreutils" [MacOS])
     ++ checkout ()
     ++ only_on Linux (run "Install bubblewrap" ["sudo apt install bubblewrap"])
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 5ee3dc78f71..4bfa4c4c034 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -282,6 +282,7 @@ jobs:
       fail-fast: false
     env:
       OPAM_TEST: 1
+      GITHUB_PR_USER: ${{ github.event.pull_request.user.login }}
     steps:
     - name: Checkout tree
       uses: actions/checkout@v4
@@ -336,6 +337,7 @@ jobs:
       fail-fast: false
     env:
       OPAM_TEST: 1
+      GITHUB_PR_USER: ${{ github.event.pull_request.user.login }}
     steps:
     - name: Install gnu coreutils
       run: brew install coreutils gpatch
diff --git a/master_changes.md b/master_changes.md
index 2efe7e53f99..0341bdcb2f5 100644
--- a/master_changes.md
+++ b/master_changes.md
@@ -136,6 +136,7 @@ users)
 ## Github Actions
   * Add a doc generation job under linux [#5349 @rjbou]
   * Update the github action scripts now that homebrew renamed the GNU patch binary to gpatch [#6296 @kit-ty-kate]
+  * Add branch scheme `username/branch` for opam-rt specific branch to use [#6274 @rjbou]
 
 ## Doc
   * Update the command to install opam to point to the new simplified url on opam.ocaml.org [#6226 @kit-ty-kate]

From 9ddd32f369c446f9b9f1121f574824bbd830b30f Mon Sep 17 00:00:00 2001
From: desumn <ilyess.tahar1505@gmail.com>
Date: Mon, 28 Oct 2024 21:23:49 +0100
Subject: [PATCH 2/2] Make it so pin list display the current revision of the
 pinned repo

---
 master_changes.md                 |   1 +
 src/client/opamCommands.ml        |   5 +-
 src/client/opamPinCommand.ml      |  17 +++-
 tests/reftests/pin.test           |  26 +++---
 tests/reftests/rec-pin.test       | 146 +++++++++++++++---------------
 tests/reftests/switch-import.test |   8 +-
 6 files changed, 111 insertions(+), 92 deletions(-)

diff --git a/master_changes.md b/master_changes.md
index 0341bdcb2f5..fe0e573f170 100644
--- a/master_changes.md
+++ b/master_changes.md
@@ -43,6 +43,7 @@ users)
 ## Config
 
 ## Pin
+  * [NEW] Make it so pin list display the current revision of a pinned repository in a new column [#6274 @desumn - fix #5533]
 
 ## List
 
diff --git a/src/client/opamCommands.ml b/src/client/opamCommands.ml
index 2521ec9f673..136814d7f90 100644
--- a/src/client/opamCommands.ml
+++ b/src/client/opamCommands.ml
@@ -3199,7 +3199,10 @@ let pin_doc = "Pin a given package to a specific version or source."
 let pin ?(unpin_only=false) cli =
   let doc = pin_doc in
   let commands = [
-    cli_original, "list", `list, [], "Lists pinned packages.";
+    cli_original, "list", `list, [], 
+    "Lists pinned packages. \
+     If the source is a remote repository, \
+     displays the hash representing its state.";
     cli_from cli2_1, "scan", `scan, ["DIR"],
     "Lists available packages to pin in directory.";
     cli_original, "add", `add, ["PACKAGE"; "TARGET"],
diff --git a/src/client/opamPinCommand.ml b/src/client/opamPinCommand.ml
index 0dfa97051d3..3a4506fb538 100644
--- a/src/client/opamPinCommand.ml
+++ b/src/client/opamPinCommand.ml
@@ -764,10 +764,25 @@ let list st ~short =
                   (OpamPackage.version_to_string inst))]
         with Not_found -> OpamConsole.colorise `yellow "(uninstalled)", []
       in
+      let vcs_revision =
+        let open OpamStd.Option.Op in
+        url >>| OpamFile.URL.url >>= fun url ->
+        match url.OpamUrl.backend with
+        | #OpamUrl.version_control ->
+          let srcdir = OpamSwitchState.source_dir st nv in
+          let color, rev =
+            match OpamProcess.Job.run (OpamRepository.revision srcdir url) with
+            | None -> (`red, "error while fetching current revision")
+            | Some ver -> (`magenta, OpamPackage.Version.to_string ver)
+          in
+          Some (Printf.sprintf "(at %s)" (OpamConsole.colorise color (rev)))
+        | _ -> None
+      in
       [ OpamPackage.to_string nv;
         state;
         OpamConsole.colorise `blue kind;
-        String.concat " " (target::extra) ]
+        String.concat " " (target::extra);
+        OpamStd.Option.default "" vcs_revision ]
     with Not_found ->
       [ OpamPackage.to_string nv;
         OpamConsole.colorise `red " (no definition found)" ]
diff --git a/tests/reftests/pin.test b/tests/reftests/pin.test
index 14a6681d439..0f70077adb5 100644
--- a/tests/reftests/pin.test
+++ b/tests/reftests/pin.test
@@ -182,9 +182,9 @@ The following actions will be performed:
 -> installed no-url.ved
 Done.
 ### : list
-### opam pin list
-nip-git.ved      git      git+file://${BASEDIR}/nip-git#master
-nip-git2.ved     git      git+file://${BASEDIR}/nip-git2#master
+### opam pin list | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+nip-git.ved      git      git+file://${BASEDIR}/nip-git#master   (at HASH)
+nip-git2.ved     git      git+file://${BASEDIR}/nip-git2#master  (at HASH)
 nip-path.ved     rsync    file://${BASEDIR}/nip-path
 nip-path2.ved    rsync    file://${BASEDIR}/nip-path2
 nip-path3.ved    rsync    file://${BASEDIR}/nip-path3
@@ -332,11 +332,11 @@ The following actions will be performed:
 [NOTE] Pinning command successful, but your installed packages may be out of sync.
 # Return code 31 #
 ### : list
-### opam pin list
+### opam pin list | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
 nip.1                         version           1
 nip-git.ved                   rsync             file://${BASEDIR}/nip-git
-nip-git2.ved                  git               git+file://${BASEDIR}/nip-git2#master
-nip-git3.ved                  git               git+file://${BASEDIR}/nip-git3#master
+nip-git2.ved                  git               git+file://${BASEDIR}/nip-git2#master  (at HASH)
+nip-git3.ved                  git               git+file://${BASEDIR}/nip-git3#master  (at HASH)
 nip-path.ved                  rsync             file://${BASEDIR}/nip-path
 nip-path3.ved                 rsync             file://${BASEDIR}/nip-path3
 no-url.1       (uninstalled)  local definition
@@ -407,8 +407,8 @@ The following actions will be performed:
 -> installed nip-path2.ved
 Done.
 ### : list
-### opam pin list
-nip-git.ved      git    git+file://${BASEDIR}/nip-git#master
+### opam pin list | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+nip-git.ved      git    git+file://${BASEDIR}/nip-git#master  (at HASH)
 nip-git2.ved     rsync  file://${BASEDIR}/nip-git2
 nip-path.ved     rsync  file://${BASEDIR}/nip-path
 nip-path2.ved    rsync  file://${BASEDIR}/nip-path2
@@ -452,8 +452,8 @@ Done.
 # Name    # Installed # Synopsis
 nip-path  ved         pinned to version ved at file://${BASEDIR}/nip-path
 nip-path2 ved         pinned to version ved at file://${BASEDIR}/nip-path2
-### opam pin list
-nip-git4.ved   (uninstalled)  git    git+file://${BASEDIR}/nip-git4#master
+### opam pin list | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+nip-git4.ved   (uninstalled)  git    git+file://${BASEDIR}/nip-git4#master  (at HASH)
 nip-path.ved                  rsync  file://${BASEDIR}/nip-path
 nip-path2.ved                 rsync  file://${BASEDIR}/nip-path2
 ### find OPAM/actions/lib -name '*.t' | sort
@@ -570,11 +570,11 @@ The following actions will be performed:
 ### :::::::::::::::::::::::
 ### opam switch kinds
 ### : pin list
-### opam pin list
+### opam pin list | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
 nip.1                         version           1
 nip-git.ved                   rsync             file://${BASEDIR}/nip-git
-nip-git2.ved                  git               git+file://${BASEDIR}/nip-git2#master
-nip-git3.ved                  git               git+file://${BASEDIR}/nip-git3#master
+nip-git2.ved                  git               git+file://${BASEDIR}/nip-git2#master  (at HASH)
+nip-git3.ved                  git               git+file://${BASEDIR}/nip-git3#master  (at HASH)
 nip-path.ved                  rsync             file://${BASEDIR}/nip-path
 nip-path3.ved                 rsync             file://${BASEDIR}/nip-path3
 no-url.1       (uninstalled)  local definition
diff --git a/tests/reftests/rec-pin.test b/tests/reftests/rec-pin.test
index a862a38f893..1cd76d3bf0e 100644
--- a/tests/reftests/rec-pin.test
+++ b/tests/reftests/rec-pin.test
@@ -75,13 +75,13 @@ root-a-k_p is now subpath-pinned to directory /a/k in file://${BASEDIR}/pinnes (
 Package root-b_g does not exist, create as a NEW package? [Y/n] y
 root-b_g is now subpath-pinned to directory /b in git+file://${BASEDIR}/pinnes#master (version dev)
 ### opam list -s
-### opam pin
-root-a-i-j_g.dev  (uninstalled)  git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master
-root-a-i_g.dev    (uninstalled)  git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i-j_g.dev  (uninstalled)  git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root-a-i_g.dev    (uninstalled)  git    directory /a/i in git+file://${BASEDIR}/pinnes#master    (at HASH)
 root-a-k_p.dev    (uninstalled)  rsync  directory /a/k in file://${BASEDIR}/pinnes
 root-a_p.dev      (uninstalled)  rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.dev      (uninstalled)  git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.dev        (uninstalled)  git    git+file://${BASEDIR}/pinnes#master
+root-b_g.dev      (uninstalled)  git    directory /b in git+file://${BASEDIR}/pinnes#master      (at HASH)
+root_g.dev        (uninstalled)  git    git+file://${BASEDIR}/pinnes#master                      (at HASH)
 ### opam unpin -n --recursive pinnes
 Ok, root-a-i-j_g is no longer pinned to directory /a/i/j in git+file://${BASEDIR}/pinnes#master (version dev)
 Ok, root-a-i_g is no longer pinned to directory /a/i in git+file://${BASEDIR}/pinnes#master (version dev)
@@ -180,8 +180,8 @@ The following actions will be performed:
 Done.
 ### opam list -s
 root_g
-### opam pin
-root_g.dev    git  git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root_g.dev    git  git+file://${BASEDIR}/pinnes#master  (at HASH)
 ### opam install ./pinnes --subpath a | unordered
 Package root-a_p does not exist, create as a NEW package? [Y/n] y
 root-a_p is now subpath-pinned to directory /a in file://${BASEDIR}/pinnes (version dev)
@@ -196,9 +196,9 @@ Done.
 ### opam list -s
 root-a_p
 root_g
-### opam pin
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
 root-a_p.dev    rsync  directory /a in file://${BASEDIR}/pinnes
-root_g.dev      git    git+file://${BASEDIR}/pinnes#master
+root_g.dev      git    git+file://${BASEDIR}/pinnes#master       (at HASH)
 ### opam install ./pinnes --subpath b | unordered
 Package root-b_g does not exist, create as a NEW package? [Y/n] y
 root-b_g is now subpath-pinned to directory /b in git+file://${BASEDIR}/pinnes#master (version dev)
@@ -214,10 +214,10 @@ Done.
 root-a_p
 root-b_g
 root_g
-### opam pin
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
 root-a_p.dev    rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.dev    git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.dev      git    git+file://${BASEDIR}/pinnes#master
+root-b_g.dev    git    directory /b in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root_g.dev      git    git+file://${BASEDIR}/pinnes#master                  (at HASH)
 ### opam install ./pinnes --subpath a/i | unordered
 Package root-a-i_g does not exist, create as a NEW package? [Y/n] y
 root-a-i_g is now subpath-pinned to directory /a/i in git+file://${BASEDIR}/pinnes#master (version dev)
@@ -234,11 +234,11 @@ root-a-i_g
 root-a_p
 root-b_g
 root_g
-### opam pin
-root-a-i_g.dev    git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i_g.dev    git    directory /a/i in git+file://${BASEDIR}/pinnes#master  (at HASH)
 root-a_p.dev      rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.dev      git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.dev        git    git+file://${BASEDIR}/pinnes#master
+root-b_g.dev      git    directory /b in git+file://${BASEDIR}/pinnes#master    (at HASH)
+root_g.dev        git    git+file://${BASEDIR}/pinnes#master                    (at HASH)
 ### opam install ./pinnes --subpath a/i/j | unordered
 Package root-a-i-j_g does not exist, create as a NEW package? [Y/n] y
 root-a-i-j_g is now subpath-pinned to directory /a/i/j in git+file://${BASEDIR}/pinnes#master (version dev)
@@ -256,12 +256,12 @@ root-a-i_g
 root-a_p
 root-b_g
 root_g
-### opam pin
-root-a-i-j_g.dev    git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master
-root-a-i_g.dev      git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i-j_g.dev    git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root-a-i_g.dev      git    directory /a/i in git+file://${BASEDIR}/pinnes#master    (at HASH)
 root-a_p.dev        rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.dev        git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.dev          git    git+file://${BASEDIR}/pinnes#master
+root-b_g.dev        git    directory /b in git+file://${BASEDIR}/pinnes#master      (at HASH)
+root_g.dev          git    git+file://${BASEDIR}/pinnes#master                      (at HASH)
 ### opam install ./pinnes --subpath a/k | unordered
 Package root-a-k_p does not exist, create as a NEW package? [Y/n] y
 root-a-k_p is now subpath-pinned to directory /a/k in file://${BASEDIR}/pinnes (version dev)
@@ -280,13 +280,13 @@ root-a-k_p
 root-a_p
 root-b_g
 root_g
-### opam pin
-root-a-i-j_g.dev    git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master
-root-a-i_g.dev      git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i-j_g.dev    git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root-a-i_g.dev      git    directory /a/i in git+file://${BASEDIR}/pinnes#master    (at HASH)
 root-a-k_p.dev      rsync  directory /a/k in file://${BASEDIR}/pinnes
 root-a_p.dev        rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.dev        git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.dev          git    git+file://${BASEDIR}/pinnes#master
+root-b_g.dev        git    directory /b in git+file://${BASEDIR}/pinnes#master      (at HASH)
+root_g.dev          git    git+file://${BASEDIR}/pinnes#master                      (at HASH)
 ### opam list --all --installed --columns=name,installed-files --normalise
 # Packages matching: any & installed
 # Name       # Installed files
@@ -387,13 +387,13 @@ root-a-k_p
 root-a_p
 root-b_g
 root_g
-### opam pin
-root-a-i-j_g.2    git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master
-root-a-i_g.2      git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i-j_g.2    git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root-a-i_g.2      git    directory /a/i in git+file://${BASEDIR}/pinnes#master    (at HASH)
 root-a-k_p.2      rsync  directory /a/k in file://${BASEDIR}/pinnes
 root-a_p.2        rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.2        git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.2          git    git+file://${BASEDIR}/pinnes#master
+root-b_g.2        git    directory /b in git+file://${BASEDIR}/pinnes#master      (at HASH)
+root_g.2          git    git+file://${BASEDIR}/pinnes#master                      (at HASH)
 ### opam remove ./pinnes
 Ok, root_g is no longer pinned to git+file://${BASEDIR}/pinnes#master (version 2)
 The following actions will be performed:
@@ -460,9 +460,9 @@ Package root-a-i-j_g does not exist, create as a NEW package? [Y/n] y
 root-a-i-j_g is now subpath-pinned to directory /a/i/j in git+file://${BASEDIR}/pinnes#master (version 2)
 Package root-a-k_p does not exist, create as a NEW package? [Y/n] y
 root-a-k_p is now subpath-pinned to directory /a/k in file://${BASEDIR}/pinnes (version 2)
-### opam pin
-root-a-i-j_g.2  (uninstalled)  git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master
-root-a-i_g.2    (uninstalled)  git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i-j_g.2  (uninstalled)  git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root-a-i_g.2    (uninstalled)  git    directory /a/i in git+file://${BASEDIR}/pinnes#master    (at HASH)
 root-a-k_p.2    (uninstalled)  rsync  directory /a/k in file://${BASEDIR}/pinnes
 root-a_p.2      (uninstalled)  rsync  directory /a in file://${BASEDIR}/pinnes
 ### opam-cat $OPAMROOT/devnull/.opam-switch/overlay/root-a_p/opam
@@ -547,13 +547,13 @@ root_g is now pinned to git+file://${BASEDIR}/pinnes#master (version 3)
 Package root-a-k_p does not exist, create as a NEW package? [Y/n] y
 [root-a-k_p.3] synchronised (no changes)
 root-a-k_p is now subpath-pinned to directory /a/k in file://${BASEDIR}/pinnes (version 3)
-### opam pin
-root-a-i-j_g.3  (uninstalled)  git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master
-root-a-i_g.3    (uninstalled)  git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i-j_g.3  (uninstalled)  git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root-a-i_g.3    (uninstalled)  git    directory /a/i in git+file://${BASEDIR}/pinnes#master    (at HASH)
 root-a-k_p.3    (uninstalled)  rsync  directory /a/k in file://${BASEDIR}/pinnes
 root-a_p.3      (uninstalled)  rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.3      (uninstalled)  git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.3        (uninstalled)  git    git+file://${BASEDIR}/pinnes#master
+root-b_g.3      (uninstalled)  git    directory /b in git+file://${BASEDIR}/pinnes#master      (at HASH)
+root_g.3        (uninstalled)  git    git+file://${BASEDIR}/pinnes#master                      (at HASH)
 ### ############################
 ### #     same with lock files #
 ### ############################
@@ -624,13 +624,13 @@ root-a-k_p is now subpath-pinned to directory /a/k in file://${BASEDIR}/pinnes (
 Package root-b_g does not exist, create as a NEW package? [Y/n] y
 root-b_g is now subpath-pinned to directory /b in git+file://${BASEDIR}/pinnes#master (version l1)
 ### opam list -s
-### opam pin
-root-a-i-j_g.l1  (uninstalled)  git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master
-root-a-i_g.l1    (uninstalled)  git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i-j_g.l1  (uninstalled)  git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root-a-i_g.l1    (uninstalled)  git    directory /a/i in git+file://${BASEDIR}/pinnes#master    (at HASH)
 root-a-k_p.l1    (uninstalled)  rsync  directory /a/k in file://${BASEDIR}/pinnes
 root-a_p.l1      (uninstalled)  rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.l1      (uninstalled)  git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.l1        (uninstalled)  git    git+file://${BASEDIR}/pinnes#master
+root-b_g.l1      (uninstalled)  git    directory /b in git+file://${BASEDIR}/pinnes#master      (at HASH)
+root_g.l1        (uninstalled)  git    git+file://${BASEDIR}/pinnes#master                      (at HASH)
 ### opam unpin -n --recursive pinnes
 Ok, root-a-i-j_g is no longer pinned to directory /a/i/j in git+file://${BASEDIR}/pinnes#master (version l1)
 Ok, root-a-i_g is no longer pinned to directory /a/i in git+file://${BASEDIR}/pinnes#master (version l1)
@@ -716,8 +716,8 @@ The following actions will be performed:
 Done.
 ### opam list -s
 root_g
-### opam pin
-root_g.l1    git  git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root_g.l1    git  git+file://${BASEDIR}/pinnes#master  (at HASH)
 ### opam install ./pinnes --subpath a | unordered
 Package root-a_p does not exist, create as a NEW package? [Y/n] y
 root-a_p is now subpath-pinned to directory /a in file://${BASEDIR}/pinnes (version l1)
@@ -732,9 +732,9 @@ Done.
 ### opam list -s
 root-a_p
 root_g
-### opam pin
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
 root-a_p.l1    rsync  directory /a in file://${BASEDIR}/pinnes
-root_g.l1      git    git+file://${BASEDIR}/pinnes#master
+root_g.l1      git    git+file://${BASEDIR}/pinnes#master       (at HASH)
 ### opam install ./pinnes --subpath b | unordered
 Package root-b_g does not exist, create as a NEW package? [Y/n] y
 root-b_g is now subpath-pinned to directory /b in git+file://${BASEDIR}/pinnes#master (version l1)
@@ -750,10 +750,10 @@ Done.
 root-a_p
 root-b_g
 root_g
-### opam pin
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
 root-a_p.l1    rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.l1    git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.l1      git    git+file://${BASEDIR}/pinnes#master
+root-b_g.l1    git    directory /b in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root_g.l1      git    git+file://${BASEDIR}/pinnes#master                  (at HASH)
 ### opam install ./pinnes --subpath a/i | unordered
 Package root-a-i_g does not exist, create as a NEW package? [Y/n] y
 root-a-i_g is now subpath-pinned to directory /a/i in git+file://${BASEDIR}/pinnes#master (version l1)
@@ -770,11 +770,11 @@ root-a-i_g
 root-a_p
 root-b_g
 root_g
-### opam pin
-root-a-i_g.l1    git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i_g.l1    git    directory /a/i in git+file://${BASEDIR}/pinnes#master  (at HASH)
 root-a_p.l1      rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.l1      git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.l1        git    git+file://${BASEDIR}/pinnes#master
+root-b_g.l1      git    directory /b in git+file://${BASEDIR}/pinnes#master    (at HASH)
+root_g.l1        git    git+file://${BASEDIR}/pinnes#master                    (at HASH)
 ### opam install ./pinnes --subpath a/i/j | unordered
 Package root-a-i-j_g does not exist, create as a NEW package? [Y/n] y
 root-a-i-j_g is now subpath-pinned to directory /a/i/j in git+file://${BASEDIR}/pinnes#master (version l1)
@@ -792,12 +792,12 @@ root-a-i_g
 root-a_p
 root-b_g
 root_g
-### opam pin
-root-a-i-j_g.l1    git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master
-root-a-i_g.l1      git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i-j_g.l1    git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root-a-i_g.l1      git    directory /a/i in git+file://${BASEDIR}/pinnes#master    (at HASH)
 root-a_p.l1        rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.l1        git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.l1          git    git+file://${BASEDIR}/pinnes#master
+root-b_g.l1        git    directory /b in git+file://${BASEDIR}/pinnes#master      (at HASH)
+root_g.l1          git    git+file://${BASEDIR}/pinnes#master                      (at HASH)
 ### opam install ./pinnes --subpath a/k | unordered
 Package root-a-k_p does not exist, create as a NEW package? [Y/n] y
 root-a-k_p is now subpath-pinned to directory /a/k in file://${BASEDIR}/pinnes (version l1)
@@ -816,13 +816,13 @@ root-a-k_p
 root-a_p
 root-b_g
 root_g
-### opam pin
-root-a-i-j_g.l1    git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master
-root-a-i_g.l1      git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i-j_g.l1    git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root-a-i_g.l1      git    directory /a/i in git+file://${BASEDIR}/pinnes#master    (at HASH)
 root-a-k_p.l1      rsync  directory /a/k in file://${BASEDIR}/pinnes
 root-a_p.l1        rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.l1        git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.l1          git    git+file://${BASEDIR}/pinnes#master
+root-b_g.l1        git    directory /b in git+file://${BASEDIR}/pinnes#master      (at HASH)
+root_g.l1          git    git+file://${BASEDIR}/pinnes#master                      (at HASH)
 ### <pin:pinnes/root_g.opam>
 version: "2"
 build: [ "false" ]
@@ -932,13 +932,13 @@ root-a-k_p
 root-a_p
 root-b_g
 root_g
-### opam pin
-root-a-i-j_g.l2    git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master
-root-a-i_g.l2      git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i-j_g.l2    git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root-a-i_g.l2      git    directory /a/i in git+file://${BASEDIR}/pinnes#master    (at HASH)
 root-a-k_p.l2      rsync  directory /a/k in file://${BASEDIR}/pinnes
 root-a_p.l2        rsync  directory /a in file://${BASEDIR}/pinnes
-root-b_g.l2        git    directory /b in git+file://${BASEDIR}/pinnes#master
-root_g.l2          git    git+file://${BASEDIR}/pinnes#master
+root-b_g.l2        git    directory /b in git+file://${BASEDIR}/pinnes#master      (at HASH)
+root_g.l2          git    git+file://${BASEDIR}/pinnes#master                      (at HASH)
 ### opam remove ./pinnes --recursive
 Ok, root_g is no longer pinned to git+file://${BASEDIR}/pinnes#master (version l2)
 Ok, root-b_g is no longer pinned to directory /b in git+file://${BASEDIR}/pinnes#master (version l2)
@@ -973,9 +973,9 @@ Package root-a-i-j_g does not exist, create as a NEW package? [Y/n] y
 root-a-i-j_g is now subpath-pinned to directory /a/i/j in git+file://${BASEDIR}/pinnes#master (version l2)
 Package root-a-k_p does not exist, create as a NEW package? [Y/n] y
 root-a-k_p is now subpath-pinned to directory /a/k in file://${BASEDIR}/pinnes (version l2)
-### opam pin
-root-a-i-j_g.l2  (uninstalled)  git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master
-root-a-i_g.l2    (uninstalled)  git    directory /a/i in git+file://${BASEDIR}/pinnes#master
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+root-a-i-j_g.l2  (uninstalled)  git    directory /a/i/j in git+file://${BASEDIR}/pinnes#master  (at HASH)
+root-a-i_g.l2    (uninstalled)  git    directory /a/i in git+file://${BASEDIR}/pinnes#master    (at HASH)
 root-a-k_p.l2    (uninstalled)  rsync  directory /a/k in file://${BASEDIR}/pinnes
 root-a_p.l2      (uninstalled)  rsync  directory /a in file://${BASEDIR}/pinnes
 ### opam-cat $OPAMROOT/devnull/.opam-switch/overlay/root-a_p/opam
diff --git a/tests/reftests/switch-import.test b/tests/reftests/switch-import.test
index 0033a008d50..726164740a2 100644
--- a/tests/reftests/switch-import.test
+++ b/tests/reftests/switch-import.test
@@ -93,8 +93,8 @@ The following actions will be performed:
 -> removed   nip.dev
 -> installed nip.dev
 Done.
-### opam pin
-nip.dev    git  git+file://${BASEDIR}/nip#snd-head
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+nip.dev    git  git+file://${BASEDIR}/nip#snd-head  (at HASH)
 ### opam list nip --installed --columns=name,installed-files --normalise | grep -v '^#'
 nip    ${BASEDIR}/OPAM/twice/lib/snd.out
 ### opam switch import twice.snd.xp --switch tierce
@@ -106,8 +106,8 @@ The following actions will be performed:
 -> retrieved nip.dev  (git+file://${BASEDIR}/nip#snd-head)
 -> installed nip.dev
 Done.
-### opam pin
-nip.dev    git  git+file://${BASEDIR}/nip#snd-head
+### opam pin | '  \(at [0-9a-f]+\)$' -> '  (at HASH)'
+nip.dev    git  git+file://${BASEDIR}/nip#snd-head  (at HASH)
 ### opam list nip --installed --columns=name,installed-files --normalise --switch tierce | grep -v '^#'
 nip    ${BASEDIR}/OPAM/tierce/lib/snd.out
 ### opam switch create test-switch-export-freeze --empty