[Qemu-devel] [PATCH] archive-source: also create a stash for submodules

Marc-André Lureau posted 1 patch 4 years, 8 months ago
Test docker-clang@ubuntu passed
Test s390x passed
Test asan passed
Test docker-mingw@fedora passed
Test FreeBSD passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190708200250.12017-1-marcandre.lureau@redhat.com
Maintainers: Fam Zheng <fam@euphon.net>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>
scripts/archive-source.sh | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
[Qemu-devel] [PATCH] archive-source: also create a stash for submodules
Posted by Marc-André Lureau 4 years, 8 months ago
"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


Re: [Qemu-devel] [PATCH] archive-source: also create a stash for submodules
Posted by Philippe Mathieu-Daudé 4 years, 8 months ago
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>

Re: [Qemu-devel] [PATCH] archive-source: also create a stash for submodules
Posted by Alex Bennée 4 years, 8 months ago
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