archive-source: also create a stash for submodules
PATCH 1/1 archive-source: also create a stash for submodules
"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.
--- scripts/archive-source.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
scripts/archive-source.sh +10 -8
@@ -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"
Signature · 1 line
2.22.0.214.g8dca754b1e
Quoted 40 lines · Marc-André Lureau
"git archive" fails when a submodule has a modification, because "git stash create" doesn't handle submodules. Let's teach our
archive-source.shto handle modifications in submodules the same way as qemu tree, by creating a stash.Signed-off-by Marc-André Lureau <[email protected]>--- scripts/archive-source.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)scripts/archive-source.sh +9
-7@@ -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")"
scripts/archive-source.sh for sm in $submodules; do · line 70
Quoted 8 lines
scripts/archive-source.sh +1
-1@@ -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"
Quoted 6 lines · Marc-André Lureau
"git archive" fails when a submodule has a modification, because "git stash create" doesn't handle submodules. Let's teach our
archive-source.shto handle modifications in submodules the same way as qemu tree, by creating a stash.Signed-off-by Marc-André Lureau <[email protected]>
Queued to testing/next, thanks.
Quoted 33 lines
--- scripts/archive-source.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)scripts/archive-source.sh +9
-7@@ -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")"
scripts/archive-source.sh for sm in $submodules; do · line 70
Quoted 8 lines
scripts/archive-source.sh +1
-1@@ -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