Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-29 Thread Jacob Keller
On Thu, Sep 29, 2016 at 10:19 AM, Junio C Hamano wrote: > Jeff King writes: >> - "cat-file --batch-check" can show you the sha1 and type, but it >> won't abbreviate sha1s, and it won't show you commit/tag information >> >> - "log --stdin --no-walk" will

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-29 Thread Junio C Hamano
Jeff King writes: >> $ git rev-parse --disambiguate-list=b2e1 >> b2e1196 tag v2.8.0-rc1 >> b2e11d1 tree >> b2e1632 commit 2007-11-14 - Merge branch 'bs/maint-commit-options' >> b2e1759 blob >> b2e18954 blob >> b2e1895c blob > > I think the "right" way to do this is pipe the list

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-29 Thread Jeff King
On Thu, Sep 29, 2016 at 07:36:27AM -0700, Kyle J. McKay wrote: > On Sep 29, 2016, at 06:24, Jeff King wrote: > > > > If you are doing "git show 235234" it should pick the tag (if it > > > peels to a > > > committish) because Git has already set a precedent of preferring > > > tags over > > >

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-29 Thread Kyle J. McKay
On Sep 29, 2016, at 06:24, Jeff King wrote: If you are doing "git show 235234" it should pick the tag (if it peels to a committish) because Git has already set a precedent of preferring tags over commits when it disambiguates ref names and otherwise pick the commit. I'm not convinced

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-29 Thread Jeff King
On Thu, Sep 29, 2016 at 06:01:51AM -0700, Kyle J. McKay wrote: > But perhaps it makes sense to actually pick one if there's only one > disambiguation of the type you're looking for. > > For example given: > > 235234a blob > 2352347 tag > 235234f tree > 2352340 commit > > If you are doing "git

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-29 Thread Jeff King
On Thu, Sep 29, 2016 at 04:46:19AM -0700, Kyle J. McKay wrote: > This hint: information is excellent. There needs to be a way to show it on > demand. > > $ git rev-parse --disambiguate=b2e1 > b2e11962c5e6a9c81aa712c751c83a743fd4f384 > b2e11d1bb40c5f81a2f4e37b9f9a60ec7474eeab >

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-29 Thread Kyle J. McKay
On Sep 26, 2016, at 09:36, Linus Torvalds wrote: On Mon, Sep 26, 2016 at 5:00 AM, Jeff King wrote: This patch teaches get_short_sha1() to list the sha1s of the objects it found, along with a few bits of information that may help the user decide which one they meant. This

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-29 Thread Kyle J. McKay
On Sep 26, 2016, at 05:00, Jeff King wrote: $ git rev-parse b2e1 error: short SHA1 b2e1 is ambiguous hint: The candidates are: hint: b2e1196 tag v2.8.0-rc1 hint: b2e11d1 tree hint: b2e1632 commit 2007-11-14 - Merge branch 'bs/maint-commit- options' hint: b2e1759 blob hint:

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-27 Thread Jeff King
On Mon, Sep 26, 2016 at 09:36:23AM -0700, Linus Torvalds wrote: > On Mon, Sep 26, 2016 at 5:00 AM, Jeff King wrote: > > > > This patch teaches get_short_sha1() to list the sha1s of the > > objects it found, along with a few bits of information that > > may help the user decide

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-26 Thread Jacob Keller
On Mon, Sep 26, 2016 at 9:36 AM, Linus Torvalds wrote: > This looks very good to me, but I wonder if it couldn't be even more > aggressive. > > In particular, the only hashes that most people ever use in short form > are commit hashes. Those are the ones you'd use

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-26 Thread Junio C Hamano
Jeff King writes: > Since it's attached to an error path, I'm guessing nobody will be too > upset about it, so my inclination was to wait and let somebody add the > conditional advice code if they're bothered. Fair enough. At that point of getting an error message, the only

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-26 Thread Jeff King
On Mon, Sep 26, 2016 at 10:30:48AM -0700, Junio C Hamano wrote: > Jeff King writes: > > > We also restrict the list to those that match any > > disambiguation hint. E.g.: > > > > $ git rev-parse b2e1:foo > > error: short SHA1 b2e1 is ambiguous > > hint: The candidates are:

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-26 Thread Junio C Hamano
Jeff King writes: > We also restrict the list to those that match any > disambiguation hint. E.g.: > > $ git rev-parse b2e1:foo > error: short SHA1 b2e1 is ambiguous > hint: The candidates are: > hint: b2e1196 tag v2.8.0-rc1 > hint: b2e11d1 tree > hint: b2e1632

Re: [PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-26 Thread Linus Torvalds
On Mon, Sep 26, 2016 at 5:00 AM, Jeff King wrote: > > This patch teaches get_short_sha1() to list the sha1s of the > objects it found, along with a few bits of information that > may help the user decide which one they meant. This looks very good to me, but I wonder if it couldn't

[PATCH 10/10] get_short_sha1: list ambiguous objects on error

2016-09-26 Thread Jeff King
When the user gives us an ambiguous short sha1, we print an error and refuse to resolve it. In some cases, the next step is for them to feed us more characters (e.g., if they were retyping or cut-and-pasting from a full sha1). But in other cases, that might be all they have. For example, an old