Re: [RFC PATCH 4/4] submodule: cache superproject gitdir during 'update'

2 messages, 2 authors, 2021-06-15 · open the first message on its own page

Re: [RFC PATCH 4/4] submodule: cache superproject gitdir during 'update'

From: Junio C Hamano <hidden>
Date: 2021-06-14 06:22:34

Emily Shaffer [off-list ref] writes:
quoted hunk
A cached path to the superproject's gitdir might be added during 'git
submodule add', but in some cases - like submodules which were created
before 'git submodule add' learned to cache that info - it might be
useful to update the cache. Let's do it during 'git submodule update',
when we already have a handle to the superproject while calling
operations on the submodules.

Signed-off-by: Emily Shaffer <redacted>
---
 git-submodule.sh            |  9 +++++++++
 t/t7406-submodule-update.sh | 10 ++++++++++
 2 files changed, 19 insertions(+)
diff --git a/git-submodule.sh b/git-submodule.sh
index eb90f18229..ddda751cfa 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -648,6 +648,15 @@ cmd_update()
 			fi
 		fi
 
+		# Cache a pointer to the superproject's gitdir. This may have
+		# changed, so rewrite it unconditionally. Writes it to worktree
+		# if applicable, otherwise to local.
+
+		sp_gitdir="$(git rev-parse --absolute-git-dir)"
+		relative_gitdir="$(realpath --relative-to "$sm_path" "$sp_gitdir")"
realpath may not exist on the target system.  Discussions on the
patch [*1*] may be of interest.

It might be a good idea to push to your github repository to trigger
CI on macOS (I am guessing that you do not test locally on macs from
the two issues we saw in this series).

Thanks.


[Reference]

*1*
https://lore.kernel.org/git/20201206225349.3392790-3-sandals@crustytoothpaste.net/

Re: [RFC PATCH 4/4] submodule: cache superproject gitdir during 'update'

From: Emily Shaffer <hidden>
Date: 2021-06-15 21:27:55

On Mon, Jun 14, 2021 at 03:22:29PM +0900, Junio C Hamano wrote:
Emily Shaffer [off-list ref] writes:
quoted
A cached path to the superproject's gitdir might be added during 'git
submodule add', but in some cases - like submodules which were created
before 'git submodule add' learned to cache that info - it might be
useful to update the cache. Let's do it during 'git submodule update',
when we already have a handle to the superproject while calling
operations on the submodules.

Signed-off-by: Emily Shaffer <redacted>
---
 git-submodule.sh            |  9 +++++++++
 t/t7406-submodule-update.sh | 10 ++++++++++
 2 files changed, 19 insertions(+)
diff --git a/git-submodule.sh b/git-submodule.sh
index eb90f18229..ddda751cfa 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -648,6 +648,15 @@ cmd_update()
 			fi
 		fi
 
+		# Cache a pointer to the superproject's gitdir. This may have
+		# changed, so rewrite it unconditionally. Writes it to worktree
+		# if applicable, otherwise to local.
+
+		sp_gitdir="$(git rev-parse --absolute-git-dir)"
+		relative_gitdir="$(realpath --relative-to "$sm_path" "$sp_gitdir")"
realpath may not exist on the target system.  Discussions on the
patch [*1*] may be of interest.

It might be a good idea to push to your github repository to trigger
CI on macOS (I am guessing that you do not test locally on macs from
the two issues we saw in this series).
I typically do, sorry for forgetting to do so this time.
Thanks.


[Reference]

*1*
https://lore.kernel.org/git/20201206225349.3392790-3-sandals@crustytoothpaste.net/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help