git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] completion: Add PS1 configuration for submodules

From
Scott Kyle <scott@appden.com>
Date
Dec 6, 2010, 23:22 UTC
Message-ID
<1291677763-55385-1-git-send-email-scott@appden.com>

For those who often work on repositories with submodules, the dirty indicator for unstaged changes will almost always show because development is simultaneously happening on those submodules. The config option diff.ignoreSubmodules is not appropriate for this use because it has larger implications.

Signed-off-by: Scott Kyle <scott@appden.com>
---
 contrib/completion/git-completion.bash |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 604fa79..539bcb1 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -37,7 +37,9 @@
 #       value, unstaged (*) and staged (+) changes will be shown next
 #       to the branch name.  You can configure this per-repository
 #       with the bash.showDirtyState variable, which defaults to true
-#       once GIT_PS1_SHOWDIRTYSTATE is enabled.
+#       once GIT_PS1_SHOWDIRTYSTATE is enabled.  You can also set
+#       GIT_PS1_IGNORESUBMODULES to a value that git diff understands
+#       to adjust the behavior of the dirty state indicator.
 #
 #       You can also see if currently something is stashed, by setting
 #       GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
@@ -286,7 +288,8 @@ __git_ps1 ()
 		elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
 			if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
 				if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
-					git diff --no-ext-diff --quiet --exit-code || w="*"
+					local ignore_submodules=${GIT_PS1_IGNORESUBMODULES+"--ignore-submodules=$GIT_PS1_IGNORESUBMODULES"}
+					git diff $ignore_submodules --no-ext-diff --quiet --exit-code || w="*"
 					if git rev-parse --quiet --verify HEAD >/dev/null; then
 						git diff-index --cached --quiet HEAD -- || i="+"
 					else
-- 
1.7.3.3.574.g98527
Next: SZEDER Gábor
Message 1 of 15 in “completion: Add PS1 configuration for submodules”
  1. completion: Add PS1 configuration for submodulesScott Kyle, Dec 6, 2010
  2. SZEDER GáborDec 7, 2010
  3. Ævar Arnfjörð BjarmasonDec 7, 2010
  4. Kevin BallardDec 7, 2010
  5. Jens LehmannDec 7, 2010
  6. Scott KyleDec 7, 2010
  7. Jens LehmannDec 7, 2010
  8. Jonathan NiederDec 7, 2010
  9. Scott KyleDec 7, 2010
  10. Jonathan NiederDec 12, 2010
  11. Jens LehmannDec 13, 2010
  12. Scott KyleDec 21, 2010
  13. Scott KyleDec 7, 2010
  14. Kevin BallardDec 7, 2010
  15. Ævar Arnfjörð BjarmasonDec 8, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.