All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Tweedie <sct@redhat.com>
To: git@vger.kernel.org, Linus Torvalds <torvalds@transmeta.com>
Cc: Stephen Tweedie <sct@redhat.com>
Subject: [PATCH] Fix git-deltafy-script off-by-one errors
Date: Fri, 27 May 2005 06:36:31 -0400	[thread overview]
Message-ID: <20050527103631.GA17730@devserv.devel.redhat.com> (raw)

[-- Attachment #1: fix-deltafy-offbyone.patch --]
[-- Type: text/plain, Size: 2746 bytes --]

git-deltafy-script contains two off-by-one errors that prevent it from
deltafying either the last file it encounters, or the oldest version of
any file.

The script decides that it needs to run git-mkdelta when it encounters
the next filename in its inner loop.  The last file obviously doesn't 
have a next file, so does not get processed.  Fix this by factoring
out the test that runs the file processing, and forcibly run that test
again at the end of the loop to catch the last file.

There's a second problem; the script only passes one revision to
git-mkdelta per change it finds in the tree history.  For each change,
it only adds the hash of the file's new version to the list of hashes
being built up.  The oldest version is ignored.  Fix this by outputing
both the old AND new versions when we encounter an "M" line in the tree
diff; that will mean that hashes crop up multiple times if the old 
version from one commit matches the new version of an older commit, but
we're already doing a "uniq" which strips those duplicates out.

Signed-off-by: Stephen Tweedie <sct@redhat.com>

---
commit a1d358812e6796a1ebdac740dcd666a567adb462
tree 9bfe10668d8220dd1a6642e06fa9c8d726134675
parent a95abde1074b8bf5bb4e4dab930397188e1bb3fa
author Stephen Tweedie <sct@redhat.com> Fri, 27 May 2005 11:25:51 +0100
committer Stephen Tweedie <sct@redhat.com> Fri, 27 May 2005 11:25:51 +0100

 git-deltafy-script |   38 +++++++++++++++++++++++---------------
 1 files changed, 23 insertions(+), 15 deletions(-)

Index: git-deltafy-script
===================================================================
--- af5e58731609986ed53e05508b55f801b3d5c51d/git-deltafy-script  (mode:100644)
+++ 9bfe10668d8220dd1a6642e06fa9c8d726134675/git-deltafy-script  (mode:100644)
@@ -19,22 +19,30 @@
 depth=
 [ "$1" == "-d" ] && depth="--max-depth=$2" && shift 2
 
-curr_file=""
+function process_one () {
+	if [ "$list" ]; then
+		echo "Processing $curr_file"
+		echo "$head $list" | xargs git-mkdelta $depth -v
+	fi
+}
+
 
 git-rev-list HEAD |
 git-diff-tree -r --stdin |
-awk '/^:/ { if ($5 == "M" || $5 == "N") print $4, $6 }' |
-LC_ALL=C sort -s -k 2 | uniq |
-while read sha1 file; do
-	if [ "$file" == "$curr_file" ]; then
-		list="$list $sha1"
-	else
-		if [ "$list" ]; then
-			echo "Processing $curr_file"
-			echo "$head $list" | xargs git-mkdelta $depth -v
+awk '/^:/ { if ($5 == "M" || $5 == "N") print $4, $6; 
+	    if ($5 == "M") print $3, $6 }' |
+LC_ALL=C sort -s -k 2 | uniq | 
+{
+	curr_file=""
+	while read sha1 file; do
+		if [ "$file" == "$curr_file" ]; then
+			list="$list $sha1"
+		else
+			process_one
+			curr_file="$file"
+			list=""
+			head="$sha1"
 		fi
-		curr_file="$file"
-		list=""
-		head="$sha1"
-	fi
-done
+	done
+	process_one
+}

                 reply	other threads:[~2005-05-27 10:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20050527103631.GA17730@devserv.devel.redhat.com \
    --to=sct@redhat.com \
    --cc=git@vger.kernel.org \
    --cc=torvalds@transmeta.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.