qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] archive-source: also create a stash for submodules
@ 2019-07-08 20:02 Marc-André Lureau
  2019-07-13 15:49 ` Philippe Mathieu-Daudé
  2019-07-15 14:36 ` Alex Bennée
  0 siblings, 2 replies; 3+ messages in thread
From: Marc-André Lureau @ 2019-07-08 20:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, thuth, philmd, kraxel, Marc-André Lureau,
	alex.bennee

"git archive" fails when a submodule has a modification, because "git
stash create" doesn't handle submodules. Let's teach our
archive-source.sh to handle modifications in submodules the same way
as qemu tree, by creating a stash.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 scripts/archive-source.sh | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh
index ca94e49978..fb5d6b3918 100755
--- a/scripts/archive-source.sh
+++ b/scripts/archive-source.sh
@@ -39,14 +39,16 @@ function cleanup() {
 }
 trap "cleanup" 0 1 2 3 15
 
-if git diff-index --quiet HEAD -- &>/dev/null
-then
-    HEAD=HEAD
-else
-    HEAD=$(git stash create)
-fi
+function tree_ish() {
+    local retval='HEAD'
+    if ! git diff-index --quiet --ignore-submodules=all HEAD -- &>/dev/null
+    then
+        retval=$(git stash create)
+    fi
+    echo "$retval"
+}
 
-git archive --format tar $HEAD > "$tar_file"
+git archive --format tar "$(tree_ish)" > "$tar_file"
 test $? -ne 0 && error "failed to archive qemu"
 for sm in $submodules; do
     status="$(git submodule status "$sm")"
@@ -62,7 +64,7 @@ for sm in $submodules; do
             echo "WARNING: submodule $sm is out of sync"
             ;;
     esac
-    (cd $sm; git archive --format tar --prefix "$sm/" $smhash) > "$sub_file"
+    (cd $sm; git archive --format tar --prefix "$sm/" $(tree_ish)) > "$sub_file"
     test $? -ne 0 && error "failed to archive submodule $sm ($smhash)"
     tar --concatenate --file "$tar_file" "$sub_file"
     test $? -ne 0 && error "failed append submodule $sm to $tar_file"
-- 
2.22.0.214.g8dca754b1e



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] archive-source: also create a stash for submodules
  2019-07-08 20:02 [Qemu-devel] [PATCH] archive-source: also create a stash for submodules Marc-André Lureau
@ 2019-07-13 15:49 ` Philippe Mathieu-Daudé
  2019-07-15 14:36 ` Alex Bennée
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-07-13 15:49 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: Fam Zheng, thuth, alex.bennee, kraxel

On 7/8/19 10:02 PM, Marc-André Lureau wrote:
> "git archive" fails when a submodule has a modification, because "git
> stash create" doesn't handle submodules. Let's teach our
> archive-source.sh to handle modifications in submodules the same way
> as qemu tree, by creating a stash.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  scripts/archive-source.sh | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh
> index ca94e49978..fb5d6b3918 100755
> --- a/scripts/archive-source.sh
> +++ b/scripts/archive-source.sh
> @@ -39,14 +39,16 @@ function cleanup() {
>  }
>  trap "cleanup" 0 1 2 3 15
>  
> -if git diff-index --quiet HEAD -- &>/dev/null
> -then
> -    HEAD=HEAD
> -else
> -    HEAD=$(git stash create)
> -fi
> +function tree_ish() {
> +    local retval='HEAD'
> +    if ! git diff-index --quiet --ignore-submodules=all HEAD -- &>/dev/null
> +    then
> +        retval=$(git stash create)
> +    fi
> +    echo "$retval"
> +}
>  
> -git archive --format tar $HEAD > "$tar_file"
> +git archive --format tar "$(tree_ish)" > "$tar_file"
>  test $? -ne 0 && error "failed to archive qemu"
>  for sm in $submodules; do
>      status="$(git submodule status "$sm")"
> @@ -62,7 +64,7 @@ for sm in $submodules; do
>              echo "WARNING: submodule $sm is out of sync"
>              ;;
>      esac
> -    (cd $sm; git archive --format tar --prefix "$sm/" $smhash) > "$sub_file"
> +    (cd $sm; git archive --format tar --prefix "$sm/" $(tree_ish)) > "$sub_file"
>      test $? -ne 0 && error "failed to archive submodule $sm ($smhash)"
>      tar --concatenate --file "$tar_file" "$sub_file"
>      test $? -ne 0 && error "failed append submodule $sm to $tar_file"
> 

Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] archive-source: also create a stash for submodules
  2019-07-08 20:02 [Qemu-devel] [PATCH] archive-source: also create a stash for submodules Marc-André Lureau
  2019-07-13 15:49 ` Philippe Mathieu-Daudé
@ 2019-07-15 14:36 ` Alex Bennée
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Bennée @ 2019-07-15 14:36 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: Fam Zheng, thuth, philmd, qemu-devel, kraxel


Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> "git archive" fails when a submodule has a modification, because "git
> stash create" doesn't handle submodules. Let's teach our
> archive-source.sh to handle modifications in submodules the same way
> as qemu tree, by creating a stash.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Queued to testing/next, thanks.

> ---
>  scripts/archive-source.sh | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh
> index ca94e49978..fb5d6b3918 100755
> --- a/scripts/archive-source.sh
> +++ b/scripts/archive-source.sh
> @@ -39,14 +39,16 @@ function cleanup() {
>  }
>  trap "cleanup" 0 1 2 3 15
>
> -if git diff-index --quiet HEAD -- &>/dev/null
> -then
> -    HEAD=HEAD
> -else
> -    HEAD=$(git stash create)
> -fi
> +function tree_ish() {
> +    local retval='HEAD'
> +    if ! git diff-index --quiet --ignore-submodules=all HEAD -- &>/dev/null
> +    then
> +        retval=$(git stash create)
> +    fi
> +    echo "$retval"
> +}
>
> -git archive --format tar $HEAD > "$tar_file"
> +git archive --format tar "$(tree_ish)" > "$tar_file"
>  test $? -ne 0 && error "failed to archive qemu"
>  for sm in $submodules; do
>      status="$(git submodule status "$sm")"
> @@ -62,7 +64,7 @@ for sm in $submodules; do
>              echo "WARNING: submodule $sm is out of sync"
>              ;;
>      esac
> -    (cd $sm; git archive --format tar --prefix "$sm/" $smhash) > "$sub_file"
> +    (cd $sm; git archive --format tar --prefix "$sm/" $(tree_ish)) > "$sub_file"
>      test $? -ne 0 && error "failed to archive submodule $sm ($smhash)"
>      tar --concatenate --file "$tar_file" "$sub_file"
>      test $? -ne 0 && error "failed append submodule $sm to $tar_file"


--
Alex Bennée


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-15 14:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-08 20:02 [Qemu-devel] [PATCH] archive-source: also create a stash for submodules Marc-André Lureau
2019-07-13 15:49 ` Philippe Mathieu-Daudé
2019-07-15 14:36 ` Alex Bennée

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).