9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Alex Musolino <alex@musolino.id.au>
To: 9front@9front.org
Subject: hgfs(4) getrevinfo patch
Date: Thu, 5 Dec 2019 19:14:56 +1030	[thread overview]
Message-ID: <B502F295245F8E7687F9A256E946FDEE@musolino.id.au> (raw)

Hi again,

Another problem with hgfs(4) is that it incorrectly reports the size
of files under the 'changes' directory that were renamed in a commit.

Here's my fix.  Seems to work, but also seems too obvious not to have
been done this way already.  Thoughts?

diff -r 754916eeedf1 sys/src/cmd/hgfs/fs.c
--- a/sys/src/cmd/hgfs/fs.c	Tue Dec 03 18:32:30 2019 +1030
+++ b/sys/src/cmd/hgfs/fs.c	Thu Dec 05 19:13:06 2019 +1030
@@ -104,7 +104,6 @@
 getrevinfo(int rev)
 {
 	Revinfo *ri;
-
 	if(rev < 0 || rev >= changelog.nmap)
 		return nil;
 	if(ri = changelog.map[rev].aux)
@@ -236,7 +235,7 @@
 	char buf[64], *s;
 	Revnode *nd;
 	Revinfo *ri;
-	int rev;
+	int rev, fd;
 
 	memset(d, 0, sizeof(*d));
 
@@ -302,15 +301,9 @@
 				break;
 			if((rev = hashrev(rl, nd->hash)) >= 0){
 				if(level == Qtree){
-					/*
-					 * BUG: this is not correct. mercurial might
-					 * prefix the data log with random \1\n escaped
-					 * metadata strings (see fmetaheader()) and the flen
-					 * *includes* the metadata part. we try to compensate
-					 * for this once the revision got extracted and
-					 * subtract the metadata header in fsstat().
-					 */
-					d->length = rl->map[rev].flen;
+					fd = revlogopentemp(rl, rev);
+					d->length = rl->map[rev].flen - fmetaheader(fd);
+					close(fd);
 				}
 				ri = getrevinfo(rl->map[rev].linkrev);
 			}


                 reply	other threads:[~2019-12-05  8:44 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=B502F295245F8E7687F9A256E946FDEE@musolino.id.au \
    --to=alex@musolino.id.au \
    --cc=9front@9front.org \
    /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).