git-quiltimport and non-existent patches
Hi,
Unlike quilt itself, git-quiltimport doesn't ignore non-existent patches. Instead it bails out badly, leaving a .dotest directory that must be removed manually. This is with git 1.5.3.2.
It would be nice if git-quiltimport would just warn about non-existent patches, just like quilt. This will make it work with markers' we put in our quilt series files. Commenting out the markers is no solution as quilt series' doesn't show commented-out patches.
Thanks!
With kind regards,
Geert Uytterhoeven
Software Architect
Sony Network and Software Technology Center Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium
Phone: +32 (0)2 700 8453 Fax: +32 (0)2 700 8622 E-mail: [email protected] Internet: http://www.sony-europe.com/
Sony Network and Software Technology Center Europe
A division of Sony Service Centre (Europe) N.V. Registered office: Technologielaan 7 · B-1840 Londerzeel · Belgium VAT BE 0413.825.160 · RPR Brussels
Fortis Bank Zaventem · Swift GEBABEBB08A · IBAN BE39001382358619
PATCH 1/1 quiltimport: Skip non-existent patches
When quiltimport encounters a non-existent patch in the series file, just skip to the next patch. This matches the behavior of quilt.
--- git-quiltimport.sh | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
git-quiltimport.sh +4 -0
@@ -71,6 +71,10 @@ commit=$(git rev-parse HEAD) mkdir $tmp_dir || exit 2 for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do + if ! [ -f "$QUILT_PATCHES/$patch_name" ] ; then + echo "$patch_name doesn't exist. Skipping." + continue + fi echo $patch_name git mailinfo "$tmp_msg" "$tmp_patch" \ <"$QUILT_PATCHES/$patch_name" >"$tmp_info" || exit 3
Signature · 1 line
1.5.3.2
Re: [PATCH] quiltimport: Skip non-existent patches
Quoted 4 lines · Dan Nicholson
When quiltimport encounters a non-existent patch in the series file, just skip to the next patch. This matches the behavior of quilt.
Signed-off-by Dan Nicholson <[email protected]>
Quoted 21 lines
--- git-quiltimport.sh | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)git-quiltimport.sh +4
-0@@ -71,6 +71,10 @@ commit=$(git rev-parse HEAD) mkdir $tmp_dir || exit 2 for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do + if ! [ -f "$QUILT_PATCHES/$patch_name" ] ; then + echo "$patch_name doesn't exist. Skipping." + continue + fi echo $patch_name git mailinfo "$tmp_msg" "$tmp_patch" \ <"$QUILT_PATCHES/$patch_name" >"$tmp_info" || exit 3Signature · 1 line
1.5.3.2
With kind regards,
Geert Uytterhoeven
Software Architect
Sony Network and Software Technology Center Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium
Phone: +32 (0)2 700 8453 Fax: +32 (0)2 700 8622 E-mail: [email protected] Internet: http://www.sony-europe.com/
Sony Network and Software Technology Center Europe
A division of Sony Service Centre (Europe) N.V. Registered office: Technologielaan 7 · B-1840 Londerzeel · Belgium VAT BE 0413.825.160 · RPR Brussels
Fortis Bank Zaventem · Swift GEBABEBB08A · IBAN BE39001382358619
Re: [PATCH] quiltimport: Skip non-existent patches
In reply to Dan NicholsonQuoted 14 lines · Dan Nicholson <dbn.lists <at> gmail.com> writes:
When quiltimport encounters a non-existent patch in the series file, just skip to the next patch. This matches the behavior of quilt.
Signed-off-by Dan Nicholson <dbn.lists <at> gmail.com>--- git-quiltimport.sh | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)git-quiltimport.sh +0
-0
git-quiltimport.sh commit=$(git rev-parse HEAD) · line 80
Quoted 10 lines
git-quiltimport.sh +4
-0@@ -71,6 +71,10 @@ commit=$(git rev-parse HEAD) mkdir $tmp_dir || exit 2 for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do + if ! [ -f "$QUILT_PATCHES/$patch_name" ] ; then + echo "$patch_name doesn't exist. Skipping." + continue + fi echo $patch_name git mailinfo "$tmp_msg" "$tmp_patch" \ <"$QUILT_PATCHES/$patch_name" >"$tmp_info" || exit 3
I forgot to mention the rationale for this patch vs. what Junio sent. The issue with Junio's patch is that the failure will occur before $tmp_patch is created because the script tries to feed git-mailinfo a non-existent patch ($patch_name). You'll only get past the mailinfo if $patch_name exists.
The marker setting may still be useful in this context, though, to suppress the "doesn't exist" message.
--
Dan
Re: [PATCH] quiltimport: Skip non-existent patches
Quoted 32 lines · Dan Nicholson
Quoted 14 lines · Dan Nicholson <dbn.lists <at> gmail.com> writes:
When quiltimport encounters a non-existent patch in the series file, just skip to the next patch. This matches the behavior of quilt.
Signed-off-by Dan Nicholson <dbn.lists <at> gmail.com>--- git-quiltimport.sh | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)git-quiltimport.sh +0
-0git-quiltimport.sh commit=$(git rev-parse HEAD) · line 80
Quoted 10 lines
git-quiltimport.sh +4
-0@@ -71,6 +71,10 @@ commit=$(git rev-parse HEAD) mkdir $tmp_dir || exit 2 for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do + if ! [ -f "$QUILT_PATCHES/$patch_name" ] ; then + echo "$patch_name doesn't exist. Skipping." + continue + fi echo $patch_name git mailinfo "$tmp_msg" "$tmp_patch" \ <"$QUILT_PATCHES/$patch_name" >"$tmp_info" || exit 3I forgot to mention the rationale for this patch vs. what Junio sent. The issue with Junio's patch is that the failure will occur before $tmp_patch is created because the script tries to feed git-mailinfo a non-existent patch ($patch_name). You'll only get past the mailinfo if $patch_name exists.
Quoted 2 lines
The marker setting may still be useful in this context, though, to suppress the "doesn't exist" message.
Thanks. I did not know what "marker" meant by the original context and assumed there is a file referred to by the series file but there is no patch in that file. Instead it seems that a series file can contain something that is _not_ a file and that is called the marker, right?
Re: [PATCH] quiltimport: Skip non-existent patches
Quoted 34 lines · Junio C Hamano
Quoted 32 lines · Dan Nicholson
Quoted 14 lines · Dan Nicholson <dbn.lists <at> gmail.com> writes:
When quiltimport encounters a non-existent patch in the series file, just skip to the next patch. This matches the behavior of quilt.
Signed-off-by Dan Nicholson <dbn.lists <at> gmail.com>--- git-quiltimport.sh | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)git-quiltimport.sh +0
-0git-quiltimport.sh commit=$(git rev-parse HEAD) · line 80
Quoted 10 lines
git-quiltimport.sh +4
-0@@ -71,6 +71,10 @@ commit=$(git rev-parse HEAD) mkdir $tmp_dir || exit 2 for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do + if ! [ -f "$QUILT_PATCHES/$patch_name" ] ; then + echo "$patch_name doesn't exist. Skipping." + continue + fi echo $patch_name git mailinfo "$tmp_msg" "$tmp_patch" \ <"$QUILT_PATCHES/$patch_name" >"$tmp_info" || exit 3I forgot to mention the rationale for this patch vs. what Junio sent. The issue with Junio's patch is that the failure will occur before $tmp_patch is created because the script tries to feed git-mailinfo a non-existent patch ($patch_name). You'll only get past the mailinfo if $patch_name exists.
Quoted 8 lines
Quoted 2 lines
The marker setting may still be useful in this context, though, to suppress the "doesn't exist" message.
Thanks. I did not know what "marker" meant by the original context and assumed there is a file referred to by the series file but there is no patch in that file. Instead it seems that a series file can contain something that is _not_ a file and that is called the marker, right?
I'm actually not a quilt user, but I tested out that patch on a repo with a series containing a non-existent patch. I'm not sure what's actually in Geerd's "marker", but I believe it's just random text.
When you run the command quilt series', it just lists what's in the series file (minus any comments). And when you run quilt push' with a non-existent patch, it says "Patch foo.patch does not exist; applied empty patch"
So, I think the consistent thing to do is what's in my patch: just skip the patch with a message to the user. Maybe the message can be tailored to match quilt's output. Actually, it would be best to also skip on empty files since quiltimport will bomb in that case as well.
--
Dan
Re: [PATCH] quiltimport: Skip non-existent patches
Quoted 9 lines · Dan Nicholson
When you run the command
quilt series', it just lists what's in the series file (minus any comments). And when you runquilt push' with a non-existent patch, it says "Patch foo.patch does not exist; applied empty patch"So, I think the consistent thing to do is what's in my patch: just skip the patch with a message to the user. Maybe the message can be tailored to match quilt's output. Actually, it would be best to also skip on empty files since quiltimport will bomb in that case as well.
Thanks for your helpful explanation. So perhaps we can do this on top of yours to be safer and more consistent.
---
git-quiltimport.sh | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
git-quiltimport.sh +2 -2
@@ -79,8 +79,8 @@ for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do git mailinfo "$tmp_msg" "$tmp_patch" \ <"$QUILT_PATCHES/$patch_name" >"$tmp_info" || exit 3 test -s "$tmp_patch" || { - echo "Patch is empty. Was it split wrong?" - exit 1 + echo "Patch is empty. Skipping." + continue } # Parse the author information
Re: [PATCH] quiltimport: Skip non-existent patches
Quoted 25 lines · Junio C Hamano
Quoted 9 lines · Dan Nicholson
When you run the command
quilt series', it just lists what's in the series file (minus any comments). And when you runquilt push' with a non-existent patch, it says "Patch foo.patch does not exist; applied empty patch"So, I think the consistent thing to do is what's in my patch: just skip the patch with a message to the user. Maybe the message can be tailored to match quilt's output. Actually, it would be best to also skip on empty files since quiltimport will bomb in that case as well.
Thanks for your helpful explanation. So perhaps we can do this on top of yours to be safer and more consistent.
---
git-quiltimport.sh | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)git-quiltimport.sh +0
-0
git-quiltimport.sh for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do · line 86
Quoted 10 lines
git-quiltimport.sh +2
-2@@ -79,8 +79,8 @@ for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do git mailinfo "$tmp_msg" "$tmp_patch" \ <"$QUILT_PATCHES/$patch_name" >"$tmp_info" || exit 3 test -s "$tmp_patch" || { - echo "Patch is empty. Was it split wrong?" - exit 1 + echo "Patch is empty. Skipping." + continue } # Parse the author information
That's seems fine. IIUC, mailinfo will only create an empty patch if there's no actual patch content in the original mail/patch. In that case, you probably do want to skip and not bomb. I'd changed my patch to do 'if ! [ -s "$patch" ]' to catch an empty file, but this is probably better. Hmm, checking `quilt push' on a patch with no actual patch bombs. Here's the output:
$ quilt push Applying patch foo.patch patch: **** Only garbage was found in the patch input. Patch foo.patch does not apply (enforce with -f) $ echo $? 1 $ cat patches/foo.patch Here's info about an empty patch.
So, it might be better to leave the original behavior there to match quilt.
--
Dan
Quoted 5 lines · Geert Uytterhoeven
It would be nice if git-quiltimport would just warn about non-existent patches, just like quilt. This will make it work with
markers' we put in our quilt series files. Commenting out the markers is no solution asquilt series' doesn't show commented-out patches.
I cannot decide if this should be the default (that's up to heavy users of git-quiltimport script), but something along this line should do. Care to test it and ack?
---
git-quiltimport.sh | 21 +++++++++++++++++---- 1 files changed, 17 insertions(+), 4 deletions(-)
git-quiltimport.sh +17 -4
@@ -4,6 +4,7 @@ SUBDIRECTORY_ON=Yes . git-sh-setup dry_run="" +error_empty=t quilt_author="" while test $# != 0 do
@@ -25,6 +26,11 @@ do dry_run=1 ;; + --expect-marker) + shift + error_empty= + ;; + --pa=*|--pat=*|--patc=*|--patch=*|--patche=*|--patches=*) QUILT_PATCHES=$(expr "z$1" : 'z-[^=]*\(.*\)') shift
@@ -74,10 +80,17 @@ for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do echo $patch_name git mailinfo "$tmp_msg" "$tmp_patch" \ <"$QUILT_PATCHES/$patch_name" >"$tmp_info" || exit 3 - test -s "$tmp_patch" || { - echo "Patch is empty. Was it split wrong?" - exit 1 - } + if test ! -s "$tmp_patch" + then + if test -z "$error_empty" + then + echo "Patch is empty. Was it split wrong?" + exit 1 + else + echo "Marker seen." + continue + fi + fi # Parse the author information export GIT_AUTHOR_NAME=$(sed -ne 's/Author: //p' "$tmp_info")