git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-quiltimport.sh: disallow fuzz

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 25, 2014, 22:59 UTC
Message-ID
<xmqq1tqz9uhm.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqq7g0r9v04.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> Let's have it the other way around, keep the same behaviour for
> those who run the command without the new option, while allowing
> people who know better and are aligned with the spirit of git to
> pass the parameter, at least for now, with a note in the
> documentation to warn that the default may change in the future to
> allow no fuzz, or something.

Perhaps like this, with some documentation added (do we have/need any test???).

-- >8 --
To: Jörn Engel <joern@logfs.org>
Date: Thu, 25 Sep 2014 18:08:31 -0400
Subject: [PATCH] git-quiltimport.sh: allow declining fuzz with --exact option

git-quiltimport unconditionally passes "-C1" to "git apply", supposedly to roughly match the quilt default of --fuzz 2. Allow users to pass --exact option to disable it, requiring the patch to apply without any fuzz.

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/git-quiltimport.txt | 12 ++++++++++++
 git-quiltimport.sh                | 17 ++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-quiltimport.txt b/Documentation/git-quiltimport.txt
index a356196..109918d 100644
--- a/Documentation/git-quiltimport.txt
+++ b/Documentation/git-quiltimport.txt
@@ -49,6 +49,18 @@ The default for the patch directory is patches
 or the value of the $QUILT_PATCHES environment
 variable.
 
+-C <number>::
+	Pass `-C<number>` to underlying `git apply` when applying
+	the patch, to reduce number of context lines to be matched.
+	By default, `-C1` is passed to `git apply` to emulate the
+	`--fuzz=2` behaviour of quilt (assuming the standard 3
+	context lines).
+
+--exact::
+	Do not pass any `-C<number>` option to `git apply` when
+	applying the patch, to require context lines to fully match.
+
+
 GIT
 ---
 Part of the linkgit:git[1] suite
diff --git a/git-quiltimport.sh b/git-quiltimport.sh
index 167d79f..2d2c377 100755
--- a/git-quiltimport.sh
+++ b/git-quiltimport.sh
@@ -6,6 +6,8 @@ git quiltimport [options]
 --
 n,dry-run     dry run
 author=       author name and email address for patches without any
+C=            minimum context (see git apply)
+exact         allow no-fuzz
 patches=      path to the quilt series and patches
 "
 SUBDIRECTORY_ON=Yes
@@ -13,6 +15,7 @@ SUBDIRECTORY_ON=Yes
 
 dry_run=""
 quilt_author=""
+cflag=-C1
 while test $# != 0
 do
 	case "$1" in
@@ -20,6 +23,18 @@ do
 		shift
 		quilt_author="$1"
 		;;
+	-C)
+		shift
+		# ensure numerical parameter
+		case "$1" in
+		''|*[!0-9]*) usage;;
+		*) ;;
+		esac
+		cflag="-C$1"
+		;;
+	--exact)
+		cflag=
+		;;
 	-n|--dry-run)
 		dry_run=1
 		;;
@@ -130,7 +145,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.1-394-g5293c25
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 8 in “git-quiltimport.sh: disallow fuzz”
  1. git-quiltimport.sh: disallow fuzzJörn Engel, Sep 24, 2014
  2. Junio C HamanoSep 25, 2014
  3. Jörn EngelSep 25, 2014
  4. Junio C HamanoSep 25, 2014
  5. Junio C HamanoSep 25, 2014
  6. Junio C HamanoSep 26, 2014
  7. Junio C HamanoOct 21, 2014
  8. 2/2 git-quiltimport: flip the default not to allow fuzzJunio C Hamano, Oct 21, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.