git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jörn Engel" <joern@logfs.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] git-quiltimport.sh: disallow fuzz
Date: Thu, 25 Sep 2014 18:08:31 -0400	[thread overview]
Message-ID: <20140925220831.GA14433@logfs.org> (raw)
In-Reply-To: <xmqqwq8sb81e.fsf@gitster.dls.corp.google.com>

On Wed, 24 September 2014 22:09:33 -0700, Junio C Hamano wrote:
> 
> This is fine for those who use quilt with --fuzz=0, but how are you
> helping those who use quilt without --fuzz=0?
> 
> I agree that unconditionally passing -C1 is a bad thing, but
> unconditionally passing -C2 is not that better.  Shouldn't this be
> done by introducing a new --fuzz=<number> option to quiltimport?

Maybe the patch below then?  Defaulting to no fuzz is both me
enforcing my (and Linus') preference and that alternatives are hard
and messy.  How would one specify fuzz=0?  -C3 would work for standard
patches, but be wrong for patches with more context.  -C0 would
arguably also be wrong.  There really is no good choice.  And I won't
add a fuzz parameter until git-apply has one, as it can only be
transformed to -C by either making assumptions about the context or
parsing the patches - ick!

Jörn

--
When I am working on a problem I never think about beauty.  I think
only how to solve the problem.  But when I have finished, if the
solution is not beautiful, I know it is wrong.
-- R. Buckminster Fuller

Subject: [PATCH] git-quiltimport.sh: disallow fuzz by default

git-quiltimport passed "-C1" to git-apply, supposedly to roughly match
the quilt default of --fuzz 2.  This is against the spirit of git.
Quoting Linus:
  Except unlike the standard "patch" program, "git apply" doesn't accept
  fuzz by default (which to me is a huge deal - I hate how "patch" tries
  to apply stuff that clearly isn't valid any more)

Users that want to want to emulate quilt defaults can pass "-C 1" to
git-quiltimport now.

Also note that -C1 and fuzz=2 is not identical.  Most patches have three
lines of context, so fuzz=2 leaves one relevant line of context.  But
for any patches with more or less context this is not true.  git-apply
has no option for fuzz, so any emulation will always be best-effort.

Signed-off-by: Joern Engel <joern@logfs.org>
---
 git-quiltimport.sh | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/git-quiltimport.sh b/git-quiltimport.sh
index 167d79fea809..f45ee5ff6599 100755
--- a/git-quiltimport.sh
+++ b/git-quiltimport.sh
@@ -4,8 +4,9 @@ OPTIONS_STUCKLONG=
 OPTIONS_SPEC="\
 git quiltimport [options]
 --
-n,dry-run     dry run
 author=       author name and email address for patches without any
+C=            minimum context (see git apply)
+n,dry-run     dry run
 patches=      path to the quilt series and patches
 "
 SUBDIRECTORY_ON=Yes
@@ -13,6 +14,7 @@ SUBDIRECTORY_ON=Yes
 
 dry_run=""
 quilt_author=""
+cflag=""
 while test $# != 0
 do
 	case "$1" in
@@ -20,6 +22,15 @@ do
 		shift
 		quilt_author="$1"
 		;;
+	-C)
+		shift
+		# ensure numerical parameter
+		case $1 in
+			''|*[!0-9]*) usage;;
+			*) ;;
+		esac
+		cflag="-C$1"
+		;;
 	-n|--dry-run)
 		dry_run=1
 		;;
@@ -130,7 +141,7 @@ do
 	fi
 
 	if [ -z "$dry_run" ] ; then
-		git apply --index -C1 ${level:+"$level"} "$tmp_patch" &&
+		git apply --index $cflag ${level:+"$level"} "$tmp_patch" &&
 		tree=$(git write-tree) &&
 		commit=$( (echo "$SUBJECT"; echo; cat "$tmp_msg") | git commit-tree $tree -p $commit) &&
 		git update-ref -m "quiltimport: $patch_name" HEAD $commit || exit 4
-- 
2.1.0

  reply	other threads:[~2014-09-25 22:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-24 21:35 [PATCH] git-quiltimport.sh: disallow fuzz Jörn Engel
2014-09-25  5:09 ` Junio C Hamano
2014-09-25 22:08   ` Jörn Engel [this message]
2014-09-25 22:48     ` Junio C Hamano
2014-09-25 22:59       ` Junio C Hamano
2014-09-26 21:02         ` Junio C Hamano
2014-10-21 21:32       ` Junio C Hamano
2014-10-21 21:38       ` [PATCH 2/2] git-quiltimport: flip the default not to allow fuzz Junio C Hamano

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=20140925220831.GA14433@logfs.org \
    --to=joern@logfs.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).