git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Robert P. J. Day" <rpjday@crashcourse.ca>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Git Mailing list <git@vger.kernel.org>
Subject: Re: easy way to demonstrate length of colliding SHA-1 prefixes?
Date: Sun, 2 Dec 2018 11:24:31 -0500 (EST)	[thread overview]
Message-ID: <alpine.LFD.2.21.1812021123050.5509@localhost.localdomain> (raw)
In-Reply-To: <87y398uknn.fsf@evledraar.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1835 bytes --]

On Sun, 2 Dec 2018, Ævar Arnfjörð Bjarmason wrote:

> On Sun, Dec 02 2018, Robert P. J. Day wrote:
>
> >   as part of an upcoming git class i'm delivering, i thought it
> > would be amusing to demonstrate the maximum length of colliding
> > SHA-1 prefixes in a repository (in my case, i use the linux kernel
> > git repo for most of my examples).
> >
> >   is there a way to display the objects in the object database
> > that clash in the longest object name SHA-1 prefix; i mean, short
> > of manually listing all object names, running that through cut and
> > sort and uniq and ... you get the idea.
> >
> >   is there a cute way to do that? thanks.
>
> You'll always need to list them all. It's inherently an operation
> where for each SHA-1 you need to search for other ones with that
> prefix up to a given length.

  i assumed as much, just wasn't sure about the esoteric dark corners
of git i've never gotten to yet.

> Perhaps you've missed that you can use --abbrev=N for this, and just
> grep for things that are loger than that N, e.g. for linux.git:
>
>     git log --oneline --abbrev=10 --pretty=format:%h |
>     grep -E -v '^.{10}$' |
>     perl -pe 's/^(.{10}).*/$1/'
>
> This will list the 4 objects that need more than 10 characters to be
> shown unambiguously. If you then "git cat-file -t" them you'll get
> the disambiguation help.

  that's pretty close to what i came up with, thanks.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

  reply	other threads:[~2018-12-02 16:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-02 11:50 easy way to demonstrate length of colliding SHA-1 prefixes? Robert P. J. Day
2018-12-02 13:23 ` Ævar Arnfjörð Bjarmason
2018-12-02 16:24   ` Robert P. J. Day [this message]
2018-12-03 22:30   ` Matthew DeVore
2018-12-03 22:57     ` Jeff King

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=alpine.LFD.2.21.1812021123050.5509@localhost.localdomain \
    --to=rpjday@crashcourse.ca \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.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).