]> Lady’s Gitweb - HOMEDIR/commitdiff
Fix submodule handling 0.1.3
authorLady <redacted>
Sun, 5 Apr 2026 20:05:34 +0000 (16:05 -0400)
committerLady <redacted>
Sun, 5 Apr 2026 20:05:34 +0000 (16:05 -0400)
Submodules are created with a `.git´ directory and so should not use
  the `--git-dir´ or `--work-tree´ options.

Message-type: text/lesml

sh/git.sh

index aef6cc0aa8c43f7d5b59f147115e9aa216cd7b12d2b004fc64ba18971961464e..4c82e98c300465f36df873c46fb07f51c19e298687235f3a1d3569868abd1199 100755 (executable)
--- a/sh/git.sh
+++ b/sh/git.sh
@@ -1,5 +1,5 @@
 #!/usr/bin/env sh
-# @(#)🏠📂 HOMEDIR       sh/git.sh       2026-04-05T20:04:14Z
+# @(#)🏠📂 HOMEDIR       sh/git.sh       2026-04-05T20:05:34Z
 # SPDX-FileCopyrightText: 2026 Lady <https://www.ladys.computer/about/#lady>
 # SPDX-License-Identifier: MPL-2.0
 
@@ -163,7 +163,6 @@ then :
 
 else :
   configfile="${path_REPODIR}"'/'"${pseudname}"'/.gitconfig'
-  baredir="${path_REPODIR}/${reponame}.git"
 
 ## If the pseud directory does not exist within `${path_REPODIR}´, it
 ##   is created.
@@ -180,25 +179,39 @@ else :
     "${cmd_TOUCH}" "${configfile}"
   fi
 
+## If a `.git´ file or directory exists, Git is simply provided with
+## the correct configuration but is otherwise called normally.
+
+  if "${cmd_TEST}" -e "${realpwd}"'/.git'
+  then :
+    "${cmd_GIT}" -c "include.path=${configfile}" "$@"
+
+## Otherwise, the Git directory must be found or created and then
+## provided to Git.
+
+  else :
+    baredir="${path_REPODIR}/${reponame}.git"
+
 ## If the repository does not already exist, it is initialized with a
 ##   Sha·256 format.
 
-  if "${cmd_TEST}" ! -d "${baredir}"
-  then :
-    cd -P "${workdir}"
-    "${cmd_GIT}" \
-      -c "include.path=${configfile}" \
-      --git-dir="${baredir}" init \
-      --object-format=sha256
-    cd -P "${OLDPWD}"
-  fi
+    if "${cmd_TEST}" ! -d "${baredir}"
+    then :
+      cd -P "${workdir}"
+      "${cmd_GIT}" \
+        -c "include.path=${configfile}" \
+        --git-dir="${baredir}" init \
+        --object-format=sha256
+      cd -P "${OLDPWD}"
+    fi
 
 ## Finally, Git is run with the appropriate Git directory and work
 ##   tree.
 
-  "${cmd_GIT}" \
-    -c "include.path=${configfile}" \
-    --git-dir="${baredir}" \
-    --work-tree="${workdir}" \
-    "$@"
+    "${cmd_GIT}" \
+      -c "include.path=${configfile}" \
+      --git-dir="${baredir}" \
+      --work-tree="${workdir}" \
+      "$@"
+  fi
 fi
This page took 0.347701 seconds and 4 git commands to generate.