From: "Daniel P. Berrange" <berrange@redhat.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH qemu v2] git-submodule.sh: Do not try writing to source directory if not necessary
Date: Thu, 26 Oct 2017 13:23:16 +0100 [thread overview]
Message-ID: <20171026122316.GC10055@redhat.com> (raw)
In-Reply-To: <20171026013445.45605-1-aik@ozlabs.ru>
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 <aik@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 :|
prev parent reply other threads:[~2017-10-26 12:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-26 1:34 [Qemu-devel] [PATCH qemu v2] git-submodule.sh: Do not try writing to source directory if not necessary Alexey Kardashevskiy
2017-10-26 7:13 ` Darren Kenny
2017-10-26 8:18 ` Alexey Kardashevskiy
2017-10-26 8:51 ` Darren Kenny
2017-10-26 9:03 ` Alexey Kardashevskiy
2017-10-26 10:25 ` Darren Kenny
2017-10-26 12:23 ` Daniel P. Berrange [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171026122316.GC10055@redhat.com \
--to=berrange@redhat.com \
--cc=aik@ozlabs.ru \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).