On Thu, Oct 26, 2017 at 12:34:45PM +1100, Alexey Kardashevskiy wrote: > The new git-submodule.sh script writes .git-submodule-status to > the source directory every time no matter what. This makes it conditional. > > Signed-off-by: Alexey Kardashevskiy <a...@ozlabs.ru> > --- > Changes: > v2: > * fixed "status" branch too > --- > scripts/git-submodule.sh | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh > index d8fbc7e47e..ae038d2e58 100755 > --- a/scripts/git-submodule.sh > +++ b/scripts/git-submodule.sh > @@ -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. > - 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 diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh index 08932a35f0..67a33e5d79 100755 --- a/scripts/git-submodule.sh +++ b/scripts/git-submodule.sh @@ -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 -- |: 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 :|