git-submodule.sh: Do not try writing to source directory if not necessary
PATCH v2 1/1 git-submodule.sh: Do not try writing to source directory if not necessary
The new git-submodule.sh script writes .git-submodule-status to the source directory every time no matter what. This makes it conditional.
---
Changes:
v2:
* fixed "status" branch too
--- scripts/git-submodule.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
scripts/git-submodule.sh +10 -5
@@ -23,16 +23,21 @@ then exit 1 fi +substat_tmp=$(mktemp) + case "$command" in status) test -f "$substat" || exit 1 - trap "rm -f ${substat}.tmp" EXIT - git submodule status $modules > "${substat}.tmp" - diff "${substat}" "${substat}.tmp" >/dev/null - exit $? + git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" > /dev/null ;; update) git submodule update --init $modules 1>/dev/null 2>&1 - git submodule status $modules > "${substat}" + git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" || mv "${substat_tmp}" "${substat}" ;; esac + +myret=$? +rm "${substat_tmp}" 2>/dev/null +exit $myret
Signature · 1 line
2.11.0
Hi Alexey,
Quoted 34 lines · Alexey Kardashevskiy
The new
git-submodule.shscript writes .git-submodule-status to the source directory every time no matter what. This makes it conditional.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Changes:
v2:
* fixed "status" branch too
---scripts/git-submodule.sh| 15 ++++++++++-----1 file changed, 10 insertions(+), 5 deletions(-)scripts/git-submodule.sh +0
-0@@ -23,16 +23,21 @@ then exit 1fi
scripts/git-submodule.sh +2
-0+substat_tmp=$(mktemp) +case "$command" in
status)test -f "$substat" || exit 1scripts/git-submodule.sh +2
-4- trap "rm -f ${substat}.tmp" EXIT - git submodule status $modules > "${substat}.tmp" - diff "${substat}" "${substat}.tmp" >/dev/null - exit $? + git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" > /dev/null ;;update)
git submodule update --init $modules 1>/dev/null 2>&1
scripts/git-submodule.sh then · line 37
Quoted 3 lines
scripts/git-submodule.sh +2
-1- git submodule status $modules > "${substat}" + git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" || mv "${substat_tmp}" "${substat}"
Maybe you intended this, but the diff output here will be output to the screen - if you don't mean this to happen you might want to redirect the output.
scripts/git-submodule.sh
Quoted 6 lines
From other lines it looks like you would prefer it wasn't output.
;;esac
scripts/git-submodule.sh +2
-0+ +myret=$?
Any small change is likely to break the value of myret here.
You may want to put the above assignment as directly below the commands that you want to record as the exit status, and maybe initialize it before the case statement to the default value.
For example, if somehow (not sure it's possible today) $command was not one of the values in the case statement, the value of $? here would be the return value of mktemp, which may not be your intention.
Quoted 1 line
+rm "${substat_tmp}" 2>/dev/null
Rather than doing this redirect, a simple rm -f will achieve what you want here - that is why makefiles tend to use it.
Thanks,
Darren.
Quoted 5 lines
+exit $myret
Signature · 1 line
2.11.0
Quoted 36 lines · Darren Kenny
Hi Alexey,
Quoted 33 lines · Alexey Kardashevskiy
The new
git-submodule.shscript writes .git-submodule-status to the source directory every time no matter what. This makes it conditional.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Changes:
v2:
* fixed "status" branch too
---scripts/git-submodule.sh| 15 ++++++++++-----1 file changed, 10 insertions(+), 5 deletions(-)scripts/git-submodule.sh +0
-0@@ -23,16 +23,21 @@ thenexit 1
fiscripts/git-submodule.sh +2
-0+substat_tmp=$(mktemp) +case "$command" in
status)
test -f "$substat" || exit 1
- trap "rm -f ${substat}.tmp" EXIT
- git submodule status $modules > "${substat}.tmp" - diff "${substat}" "${substat}.tmp" >/dev/null - exit $?
+ git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" >/dev/null;;
update)
Quoted 8 lines
Quoted 4 lines
git submodule update --init $modules 1>/dev/null 2>&1
- git submodule status $modules > "${substat}"
+ git submodule status $modules > "$substat_tmp"
+ diff "${substat_tmp}" "${substat}" || mv "${substat_tmp}" "${substat}"Maybe you intended this, but the diff output here will be output to the screen - if you don't mean this to happen you might want to redirect the output.
Well, if I do:
diff "${substat_tmp}" "${substat}" 1>/dev/null 2>&1 || mv "${substat_tmp}" "${substat}"
mv: inter-device move failed: '/tmp/tmp.gfcsXCSv4W' to '.git-submodule-status'; unable to remove target: Read-only file system
and with my current variant it is:
GIT ui/keycodemapdb dtc
1d0
< 558cd81bdd432769b59bff01240c44f82cfb1a9d dtc (v1.4.4) 2a2
Quoted 1 line
558cd81bdd432769b59bff01240c44f82cfb1a9ddtc (v1.4.4)
mv: inter-device move failed: '/tmp/tmp.4ol9mymsZj' to '.git-submodule-status'; unable to remove target: Read-only file system
which gives some clue about what is going on (I swapped 2 lines in .git-submodule-status to trigger this).
Quoted 20 lines
From other lines it looks like you would prefer it wasn't output.
scripts/git-submodule.sh
Quoted 4 lines
;;
esacscripts/git-submodule.sh +2
-0+ +myret=$?Any small change is likely to break the value of myret here.
You may want to put the above assignment as directly below the commands that you want to record as the exit status, and maybe initialize it before the case statement to the default value.
For example, if somehow (not sure it's possible today) $command was not one of the values in the case statement, the value of $? here would be the return value of mktemp, which may not be your intention.
Quoted 4 lines
Quoted 1 line
+rm "${substat_tmp}" 2>/dev/null
Rather than doing this redirect, a simple rm -f will achieve what you want here - that is why makefiles tend to use it.
I really do not like shell :) I gave up to using "trap", seems doing the right thing and no messing is needed with "exit".
scripts/git-submodule.sh +7 -5
@@ -23,16 +23,18 @@ then exit 1 fi +substat_tmp=$(mktemp) +trap "rm -f $substat_tmp" 0 + case "$command" in status) test -f "$substat" || exit 1 - trap "rm -f ${substat}.tmp" EXIT - git submodule status $modules > "${substat}.tmp" - diff "${substat}" "${substat}.tmp" >/dev/null - exit $? + git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" > /dev/null ;; update) git submodule update --init $modules 1>/dev/null 2>&1 - git submodule status $modules > "${substat}" + git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" || mv "${substat_tmp}" "${substat}" ;; esac
Is this good enough to repost?
ps. out of curiosity - your mail has "Mail-Followup-To" - is that intentional?
Quoted 10 lines
Thanks,
Darren.
Quoted 5 lines
+exit $myret
--
2.11.0
Signature · 1 line
Alexey
Quoted 59 lines · Alexey Kardashevskiy
Quoted 36 lines · Darren Kenny
Hi Alexey,
Quoted 33 lines · Alexey Kardashevskiy
The new
git-submodule.shscript writes .git-submodule-status to the source directory every time no matter what. This makes it conditional.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Changes:
v2:
* fixed "status" branch too
---scripts/git-submodule.sh| 15 ++++++++++-----1 file changed, 10 insertions(+), 5 deletions(-)scripts/git-submodule.sh +0
-0@@ -23,16 +23,21 @@ thenexit 1
fiscripts/git-submodule.sh +2
-0+substat_tmp=$(mktemp) +case "$command" in
status)
test -f "$substat" || exit 1
- trap "rm -f ${substat}.tmp" EXIT
- git submodule status $modules > "${substat}.tmp" - diff "${substat}" "${substat}.tmp" >/dev/null - exit $?
+ git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" >/dev/null;;
update)Quoted 8 lines
Quoted 4 lines
git submodule update --init $modules 1>/dev/null 2>&1
- git submodule status $modules > "${substat}"
+ git submodule status $modules > "$substat_tmp"
+ diff "${substat_tmp}" "${substat}" || mv "${substat_tmp}" "${substat}"Maybe you intended this, but the diff output here will be output to the screen - if you don't mean this to happen you might want to redirect the output.
Well, if I do:
diff "${substat_tmp}" "${substat}" 1>/dev/null 2>&1 || mv "${substat_tmp}" "${substat}"
mv: inter-device move failed: '
/tmp/tmp.gfcsXCSv4W' to '.git-submodule-status'; unable to remove target: Read-only file systemand with my current variant it is:
Quoted 9 lines
GIT ui/keycodemapdb dtc
1d0
<558cd81bdd432769b59bff01240c44f82cfb1a9ddtc (v1.4.4) 2a2Quoted 1 line
558cd81bdd432769b59bff01240c44f82cfb1a9ddtc (v1.4.4)mv: inter-device move failed: '
/tmp/tmp.4ol9mymsZj' to '.git-submodule-status'; unable to remove target: Read-only file system
That's strange behaviour for adding a redirect... Maybe it's your use of 1>/dev/null instead of just >/dev/null.
TBH, /tmp should not be read-only in a normally running system.
To avoid the redirect at all then maybe use 'diff -q' instead.
Quoted 63 lines
which gives some clue about what is going on (I swapped 2 lines in .git-submodule-status to trigger this).
Quoted 20 lines
From other lines it looks like you would prefer it wasn't output.
scripts/git-submodule.sh
Quoted 4 lines
;;
esacscripts/git-submodule.sh +2
-0+ +myret=$?Any small change is likely to break the value of myret here.
You may want to put the above assignment as directly below the commands that you want to record as the exit status, and maybe initialize it before the case statement to the default value.
For example, if somehow (not sure it's possible today) $command was not one of the values in the case statement, the value of $? here would be the return value of mktemp, which may not be your intention.
Quoted 4 lines
Quoted 1 line
+rm "${substat_tmp}" 2>/dev/null
Rather than doing this redirect, a simple rm -f will achieve what you want here - that is why makefiles tend to use it.
I really do not like shell :) I gave up to using "trap", seems doing the right thing and no messing is needed with "exit".
scripts/git-submodule.sh +0
-0@@ -23,16 +23,18 @@ then exit 1fi
scripts/git-submodule.sh +3
-0+substat_tmp=$(mktemp) +trap "rm -f $substat_tmp" 0 +case "$command" in
status)test -f "$substat" || exit 1scripts/git-submodule.sh +2
-4- trap "rm -f ${substat}.tmp" EXIT - git submodule status $modules > "${substat}.tmp" - diff "${substat}" "${substat}.tmp" >/dev/null - exit $? + git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" > /dev/null ;;update)
git submodule update --init $modules 1>/dev/null 2>&1scripts/git-submodule.sh +2
-1- git submodule status $modules > "${substat}" + git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" || mv "${substat_tmp}" "${substat}" ;;esac
Quoted 1 line
Is this good enough to repost?
If the exit code is not important here, then it should be OK, subject to my comments about using 'diff -q' instead.
If the exit code is important in this script I would still suggest being explicit about it, by setting myret=0 before the case, and then myret=$? after calls to diff, and finally an exit $myret.
Quoted 4 lines
ps. out of curiosity - your mail has "Mail-Followup-To" - is that intentional?
I'm using the default in Neomutt, which suggests that is should be used to avoid duplicate e-mails when responding to lists.
https://www.neomutt.org/guide/advancedusage.html#using-lists
I've not changed from the default behaviour, but maybe it's not how people like to do it here... ;)
Thanks,
Darren.
Quoted 17 lines
Quoted 12 lines
Thanks,
Darren.
Quoted 5 lines
+exit $myret
--
2.11.0Signature · 1 line
Alexey
Quoted 71 lines · Darren Kenny
Quoted 60 lines · Alexey Kardashevskiy
Quoted 37 lines · Darren Kenny
Hi Alexey,
Quoted 34 lines · Alexey Kardashevskiy
The new
git-submodule.shscript writes .git-submodule-status to the source directory every time no matter what. This makes it conditional.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Changes:
v2:
* fixed "status" branch too
---scripts/git-submodule.sh| 15 ++++++++++-----1 file changed, 10 insertions(+), 5 deletions(-)scripts/git-submodule.sh +0
-0@@ -23,16 +23,21 @@ thenexit 1
fiscripts/git-submodule.sh +2
-0+substat_tmp=$(mktemp) +case "$command" in
status)
test -f "$substat" || exit 1
- trap "rm -f ${substat}.tmp" EXIT
- git submodule status $modules > "${substat}.tmp" - diff "${substat}" "${substat}.tmp" >/dev/null - exit $?
+ git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" >/dev/null;;
update)
git submodule update --init $modules 1>/dev/null 2>&1Quoted 8 lines
Quoted 4 lines
- git submodule status $modules > "${substat}"
+ git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" || mv "${substat_tmp}" "${substat}"Maybe you intended this, but the diff output here will be output to the screen - if you don't mean this to happen you might want to redirect the output.
Well, if I do:
diff "${substat_tmp}" "${substat}" 1>/dev/null 2>&1 || mv "${substat_tmp}" "${substat}"
mv: inter-device move failed: '
/tmp/tmp.gfcsXCSv4W' to '.git-submodule-status'; unable to remove target: Read-only file systemand with my current variant it is:
Quoted 9 lines
GIT ui/keycodemapdb dtc
1d0
<558cd81bdd432769b59bff01240c44f82cfb1a9ddtc (v1.4.4) 2a2Quoted 1 line
558cd81bdd432769b59bff01240c44f82cfb1a9d dtc (v1.4.4)
mv: inter-device move failed: '
/tmp/tmp.4ol9mymsZj' to '.git-submodule-status'; unable to remove target: Read-only file system
Quoted 4 lines
That's strange behaviour for adding a redirect... Maybe it's your use of 1>/dev/null instead of just >/dev/null.
TBH, /tmp should not be read-only in a normally running system.
It is not, this is why I am changing the script to write to /tmp instead of source directory.
Quoted 2 lines
To avoid the redirect at all then maybe use 'diff -q' instead.
I do not want to make diff silent, I want it to scream actually.
Quoted 63 lines
Quoted 63 lines
which gives some clue about what is going on (I swapped 2 lines in .git-submodule-status to trigger this).
Quoted 20 lines
From other lines it looks like you would prefer it wasn't output.
scripts/git-submodule.sh
Quoted 4 lines
;;
esacscripts/git-submodule.sh +2
-0+ +myret=$?Any small change is likely to break the value of myret here.
You may want to put the above assignment as directly below the commands that you want to record as the exit status, and maybe initialize it before the case statement to the default value.
For example, if somehow (not sure it's possible today) $command was not one of the values in the case statement, the value of $? here would be the return value of mktemp, which may not be your intention.
Quoted 4 lines
Quoted 1 line
+rm "${substat_tmp}" 2>/dev/null
Rather than doing this redirect, a simple rm -f will achieve what you want here - that is why makefiles tend to use it.
I really do not like shell :) I gave up to using "trap", seems doing the right thing and no messing is needed with "exit".
scripts/git-submodule.sh +0
-0@@ -23,16 +23,18 @@ thenexit 1
fiscripts/git-submodule.sh +3
-0+substat_tmp=$(mktemp) +trap "rm -f $substat_tmp" 0 +case "$command" in
status)
test -f "$substat" || exit 1
- trap "rm -f ${substat}.tmp" EXIT
- git submodule status $modules > "${substat}.tmp"
- diff "${substat}" "${substat}.tmp" >/dev/null
- exit $?
+ git submodule status $modules > "$substat_tmp"
+ diff "${substat_tmp}" "${substat}" >/dev/null
;;
update)
git submodule update --init $modules 1>/dev/null 2>&1
- git submodule status $modules > "${substat}"
+ git submodule status $modules > "$substat_tmp"
+ diff "${substat_tmp}" "${substat}" || mv "${substat_tmp}" "${substat}" ;;
esac
Quoted 8 lines
Quoted 1 line
Is this good enough to repost?
If the exit code is not important here, then it should be OK, subject to my comments about using 'diff -q' instead.
If the exit code is important in this script I would still suggest being explicit about it, by setting myret=0 before the case, and then myret=$? after calls to diff, and finally an exit $myret.
The last command exit code goes to the caller - this is quite explicit imho.
Quoted 5 lines
Quoted 2 lines
ps. out of curiosity - your mail has "Mail-Followup-To" - is that intentional?
I'm using the default in Neomutt, which suggests that is should be used to avoid duplicate e-mails when responding to lists.
A proper mailer will show a single copy, based on message-id (I know nothing about neomutt) :)
Quoted 30 lines
https://www.neomutt.org/guide/advancedusage.html#using-lists
I've not changed from the default behaviour, but maybe it's not how people like to do it here... ;)
Thanks,
Darren.
Quoted 17 lines
Quoted 12 lines
Thanks,
Darren.
Quoted 5 lines
+exit $myret
--
2.11.0--
Alexey
Signature · 1 line
Alexey
Quoted 72 lines · Alexey Kardashevskiy
Quoted 71 lines · Darren Kenny
Quoted 69 lines · Alexey Kardashevskiy
Quoted 37 lines · Darren Kenny
Hi Alexey,
Quoted 34 lines · Alexey Kardashevskiy
The new
git-submodule.shscript writes .git-submodule-status to the source directory every time no matter what. This makes it conditional.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Changes:
v2:
* fixed "status" branch too
---scripts/git-submodule.sh| 15 ++++++++++-----1 file changed, 10 insertions(+), 5 deletions(-)scripts/git-submodule.sh +0
-0@@ -23,16 +23,21 @@ thenexit 1
fiscripts/git-submodule.sh +2
-0+substat_tmp=$(mktemp) +case "$command" in
status)
test -f "$substat" || exit 1
- trap "rm -f ${substat}.tmp" EXIT
- git submodule status $modules > "${substat}.tmp" - diff "${substat}" "${substat}.tmp" >/dev/null - exit $?
+ git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" >/dev/null;;
update)
git submodule update --init $modules 1>/dev/null 2>&1Quoted 8 lines
Quoted 4 lines
- git submodule status $modules > "${substat}"
+ git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" || mv "${substat_tmp}" "${substat}"Maybe you intended this, but the diff output here will be output to the screen - if you don't mean this to happen you might want to redirect the output.
Well, if I do:
diff "${substat_tmp}" "${substat}" 1>/dev/null 2>&1 || mv "${substat_tmp}" "${substat}"
mv: inter-device move failed: '
/tmp/tmp.gfcsXCSv4W' to '.git-submodule-status'; unable to remove target: Read-only file systemand with my current variant it is:
GIT ui/keycodemapdb dtc
1d0
<558cd81bdd432769b59bff01240c44f82cfb1a9ddtc (v1.4.4) 2a2Quoted 1 line
558cd81bdd432769b59bff01240c44f82cfb1a9d dtc (v1.4.4)
mv: inter-device move failed: '
/tmp/tmp.4ol9mymsZj' to '.git-submodule-status'; unable to remove target: Read-only file system
Quoted 8 lines
Quoted 4 lines
That's strange behaviour for adding a redirect... Maybe it's your use of 1>/dev/null instead of just >/dev/null.
TBH, /tmp should not be read-only in a normally running system.
It is not, this is why I am changing the script to write to /tmp instead of source directory.
Ah, got it - didn't realise that you were referring to the old behaviour here.
Quoted 7 lines
Quoted 4 lines
To avoid the redirect at all then maybe use 'diff -q' instead.
I do not want to make diff silent, I want it to scream actually.
Fair enough then, wasn't sure if was intended :)
Quoted 70 lines
Quoted 70 lines
Quoted 65 lines
which gives some clue about what is going on (I swapped 2 lines in .git-submodule-status to trigger this).
Quoted 20 lines
From other lines it looks like you would prefer it wasn't output.
scripts/git-submodule.sh
Quoted 4 lines
;;
esacscripts/git-submodule.sh +2
-0+ +myret=$?Any small change is likely to break the value of myret here.
You may want to put the above assignment as directly below the commands that you want to record as the exit status, and maybe initialize it before the case statement to the default value.
For example, if somehow (not sure it's possible today) $command was not one of the values in the case statement, the value of $? here would be the return value of mktemp, which may not be your intention.
Quoted 4 lines
Quoted 1 line
+rm "${substat_tmp}" 2>/dev/null
Rather than doing this redirect, a simple rm -f will achieve what you want here - that is why makefiles tend to use it.
I really do not like shell :) I gave up to using "trap", seems doing the right thing and no messing is needed with "exit".
scripts/git-submodule.sh +0
-0@@ -23,16 +23,18 @@ thenexit 1
fiscripts/git-submodule.sh +3
-0+substat_tmp=$(mktemp) +trap "rm -f $substat_tmp" 0 +case "$command" in
status)
test -f "$substat" || exit 1
- trap "rm -f ${substat}.tmp" EXIT
- git submodule status $modules > "${substat}.tmp"
- diff "${substat}" "${substat}.tmp" >/dev/null
- exit $?
+ git submodule status $modules > "$substat_tmp"
+ diff "${substat_tmp}" "${substat}" >/dev/null
;;
update)
git submodule update --init $modules 1>/dev/null 2>&1
- git submodule status $modules > "${substat}"
+ git submodule status $modules > "$substat_tmp"
+ diff "${substat_tmp}" "${substat}" || mv "${substat_tmp}" "${substat}" ;;
esacQuoted 1 line
Is this good enough to repost?
If the exit code is not important here, then it should be OK, subject to my comments about using 'diff -q' instead.
Quoted 6 lines
Quoted 3 lines
If the exit code is important in this script I would still suggest being explicit about it, by setting myret=0 before the case, and then myret=$? after calls to diff, and finally an exit $myret.
The last command exit code goes to the caller - this is quite explicit imho.
It is, but the problem is that someone modifying this in the future may not be aware of the expectation that you actually want the last commands return value to be output.
So something as simple as putting in an echo at the end of the script would mess that up.
Which is why I suggest that if it IS important, then be explicit about it rather than implicit.
Quoted 11 lines
Quoted 7 lines
Quoted 4 lines
ps. out of curiosity - your mail has "Mail-Followup-To" - is that intentional?
I'm using the default in Neomutt, which suggests that is should be used to avoid duplicate e-mails when responding to lists.
A proper mailer will show a single copy, based on message-id (I know nothing about neomutt) :)
A proper mailing app? Is there such a thing? ;)
/me doesn't really want to start a mailer flame war, so bows out...
Thanks,
Darren.
Quoted 17 lines · Alexey Kardashevskiy
The new
git-submodule.shscript writes .git-submodule-status to the source directory every time no matter what. This makes it conditional.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Changes:
v2:
* fixed "status" branch too--- scripts/git-submodule.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)scripts/git-submodule.sh +0
-0
scripts/git-submodule.sh then · line 29
Quoted 9 lines
scripts/git-submodule.sh +2
-1@@ -23,16 +23,21 @@ then exit 1 fi +substat_tmp=$(mktemp) + case "$command" in status) test -f "$substat" || exit 1 - trap "rm -f ${substat}.tmp" EXIT
I don't see a need to change this to run a rm later - it is fine as is.
scripts/git-submodule.sh then · line 38
Quoted 12 lines
scripts/git-submodule.sh +4
-4- git submodule status $modules > "${substat}.tmp" - diff "${substat}" "${substat}.tmp" >/dev/null - exit $? + git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" > /dev/null ;; update) git submodule update --init $modules 1>/dev/null 2>&1 - git submodule status $modules > "${substat}" + git submodule status $modules > "$substat_tmp" + diff "${substat_tmp}" "${substat}" || mv "${substat_tmp}" "${substat}" ;;
This update command doesn't need changing - it is fine as it exists already. Once the status command is fix, the update command will never be run when the submodules are already up2date.
Essentially all we need is this
scripts/git-submodule.sh +4 -3
@@ -26,9 +26,10 @@ fi case "$command" in status) test -f "$substat" || exit 1 - trap "rm -f ${substat}.tmp" EXIT - git submodule status $modules > "${substat}.tmp" - diff "${substat}" "${substat}.tmp" >/dev/null + substat_tmp=$(mktemp) + trap "rm -f ${substat_tmp}" EXIT + git submodule status $modules > "${substat_tmp}" + diff "${substat}" "${substat_tmp}" >/dev/null exit $? ;; update)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|