Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Fix hexdump command used for mercurial dirstate parsing
- X-seq: zsh-workers 39774
- From: Reed Riley <john.reed.riley@xxxxxxxxx>
- To: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [PATCH] Fix hexdump command used for mercurial dirstate parsing
- Date: Sun, 30 Oct 2016 10:43:17 -0400
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=f2VymlITkkNdAr7FMshLfCJ/IZ12Wmo+y0jgxhlZA1o=; b=xdlNGyBNe3RCsTd4iITeS1/xKHSi9ZYKz7Q+ULS05FvbnUfqo6TukWBhQLUymnJ0LB u+mcXiIJ5P18uBNAdWTqh5Ff/S28jCSJ3VmXXzEN7dPNL1T92Ha+q2bei+lNzhdA8m4P MqMs5a/jBwBxQQAyYrzMfckBs+0kg9QNbgGQRs33iXlkkY95Pa0DfX1p+oWTdhLFj+IL JSlvbNQqWA9HdJoLMt3NxjUWt1Yo5gA0971fkNMeNPKbYVuf40XxFvkvitysOO0Rby+k 1fZtAjjfpLaM48oq+F3i1QjDD6cpAr5uhN/Q7vDUco6Q1Yb9MYla1dz8vDlY/hADssYz Pbxg==
- In-reply-to: <87y416drcq.fsf@ft.bewatermyfriend.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20161030024723.62832-1-john.reed.riley@gmail.com> <87y416drcq.fsf@ft.bewatermyfriend.org>
Damn - I had no idea `xxd` was a part of Vim, sorry! The original version
of my patch was `hexdump -n 20 -e '20/1 "%02x"' ${dirstatefile}` - I only
switched to xxd at Daniel Shahaf's suggestion.
I sadly can't provide a full dirstate file for a repro, but I can provide
the relevant part as a hexdump:
❯ hexdump dirstate | head -n3
0000000 77 bb a6 65 e9 70 14 6b d2 be 0b 2d a4 00 92 e3
0000010 40 40 88 04 00 00 00 00 00 00 00 00 00 00 00 00
0000020 00 00 00 00 00 00 00 00 6e 00 00 81 a4 00 00 04
❯ hexdump -n20 -e '1/1 "%02x"' dirstate
77bba665e970146bd2be0b2da40092e340*
8804%
From the limited research I've done, the issue in the output is that '*' is
used to represent repetitions:
-
http://superuser.com/questions/494245/what-does-an-asterisk-mean-in-hexdump-output
- also described (partially?) in `man hexdump` in the description of the
`-v` option.
In other words, if you have repeated octets in your commit hash, the old
command doesn't work properly.
So, based on that, there are two versions of the command that work
correctly on this particular case for me:
hexdump -n 20 -e '20/1 "%02x"' ${dirstatefile}
hexdump -n 20 -v -e '1/1 "%02x"' ${dirstatefile}
Do you have any preference between them?
Thanks,
Reed
On Sun, Oct 30, 2016 at 7:11 AM, Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
wrote:
> Hi,
>
> Reed Riley wrote:
> > Normally, the old command works. But very rarely, it outputs a string
> > like the following instead:
> > ❯ hexdump -n20 -e '1/1 "%02x"' .hg/dirstate
> > 77bba665e970146bd2be0b2da40092e340*
> > 8804
> [...]
> > - r_csetid=$(hexdump -n 20 -e '1/1 "%02x"' ${dirstatefile})
> > + r_csetid=$(xxd -p -l20 ${dirstatefile})
>
> I would much rather know, what causes hexdump to behave like that. Is
> the way we are using it documented behavior? If so, that would suggest a
> bug in hexdump, that should be resolved instead. If no, we're probably
> using hexdump in a wrong way — maybe just in a non-portable way, and we
> should fix the way we're using hexdump.
>
> Are you able to provides example data, that causes the bug? Maybe even
> formulate a supposition as to what it is exactly, that triggers this
> behaviour.
>
> "xxd" is a command shipped with vim. Adding such a dependency is out of
> the question for me. It would be conceivable to make the command that is
> called in these places configurable via styles. But that is a separate
> issue to the one that fixes our use of hexdump.
>
>
> Regards, Frank
>
--
Reed Riley <john.reed.riley@xxxxxxxxx>
--------------------------------------------
Q: Why is this email five sentences or less?
A: http://five.sentenc.es
Messages sorted by:
Reverse Date,
Date,
Thread,
Author