[PATCH] Cogito: Use git-rev-parse instead of cg-Xnormid.

DORMANTno replies

8 messages, 4 authors, 2016-06-15 · open the first message on its own page

[PATCH] Cogito: Use git-rev-parse instead of cg-Xnormid.

From: Brian Gerst <hidden>
Date: 2016-06-15 22:42:01

Use git-rev-parse instead of cg-Xnormid.  This allows Cogito to work 
properly with packed objects.

Signed off by: Brian Gerst [off-list ref]

Re: [PATCH] Cogito: Use git-rev-parse instead of cg-Xnormid.

From: Petr Baudis <hidden>
Date: 2016-06-15 22:42:01

Dear diary, on Sun, Jul 03, 2005 at 07:59:42AM CEST, I got a letter
where Brian Gerst [off-list ref] told me that...
Use git-rev-parse instead of cg-Xnormid.  This allows Cogito to work 
properly with packed objects.

Signed off by: Brian Gerst [off-list ref]
But git-rev-parse sucks. It won't detect invalid IDs (--revs-only?), and
does not support short object IDs (that's a must, it's tremendously
useful). You need to add that for it to be useful first.
quoted hunk
diff --git a/tree-id b/tree-id
--- a/tree-id
+++ b/tree-id
@@ -5,8 +5,8 @@
 #
 # Takes ID of the appropriate commit, defaults to HEAD.
 
-id="$1"
-normid=$(${COGITO_LIB}cg-Xnormid "$id") || exit 1
+id="${1:-HEAD}"
+normid=$(git-rev-parse "$id")
 type=$(git-cat-file -t "$normid")
 
 if [ "$type" = "commit" ]; then
This is broken too. You need to be able to pass _tree_ ID to tree-id too,
not just commit ID. Hmm, or is git-rev-parse able to process any ids?
Then it's terribly misnamed too. :-) A comment would be useful in that
case. (Or better a patch to rename it.)

Thanks,

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
<Espy> be careful, some twit might quote you out of context..

Re: [PATCH] Cogito: Use git-rev-parse instead of cg-Xnormid.

From: Brian Gerst <hidden>
Date: 2016-06-15 22:42:01

Petr Baudis wrote:
Dear diary, on Sun, Jul 03, 2005 at 07:59:42AM CEST, I got a letter
where Brian Gerst [off-list ref] told me that...
quoted
Use git-rev-parse instead of cg-Xnormid.  This allows Cogito to work 
properly with packed objects.

Signed off by: Brian Gerst [off-list ref]

But git-rev-parse sucks. It won't detect invalid IDs (--revs-only?), and
does not support short object IDs (that's a must, it's tremendously
useful). You need to add that for it to be useful first.
cg-Xnormid is terminally broken in the presence of packed files, since 
it cannot look into them to find objects.  Moreover, many uses of 
commit-id in the scripts can be eliminated because the underlying git 
commands can already understand tags directly, and will check for 
invalid ids then.  The only thing missing is the short id matching.
quoted
diff --git a/tree-id b/tree-id
--- a/tree-id
+++ b/tree-id
@@ -5,8 +5,8 @@
#
# Takes ID of the appropriate commit, defaults to HEAD.

-id="$1"
-normid=$(${COGITO_LIB}cg-Xnormid "$id") || exit 1
+id="${1:-HEAD}"
+normid=$(git-rev-parse "$id")
type=$(git-cat-file -t "$normid")

if [ "$type" = "commit" ]; then

This is broken too. You need to be able to pass _tree_ ID to tree-id too,
not just commit ID. Hmm, or is git-rev-parse able to process any ids?
Then it's terribly misnamed too. :-) A comment would be useful in that
case. (Or better a patch to rename it.)
Yes you can still pass in the tree id.

--
				Brian Gerst

Re: [PATCH] Cogito: Use git-rev-parse instead of cg-Xnormid.

From: Petr Baudis <hidden>
Date: 2016-06-15 22:42:01

Dear diary, on Sun, Jul 03, 2005 at 02:25:09PM CEST, I got a letter
where Brian Gerst [off-list ref] told me that...
Petr Baudis wrote:
quoted
Dear diary, on Sun, Jul 03, 2005 at 07:59:42AM CEST, I got a letter
where Brian Gerst [off-list ref] told me that...
quoted
Use git-rev-parse instead of cg-Xnormid.  This allows Cogito to work 
properly with packed objects.

Signed off by: Brian Gerst [off-list ref]

But git-rev-parse sucks. It won't detect invalid IDs (--revs-only?), and
does not support short object IDs (that's a must, it's tremendously
useful). You need to add that for it to be useful first.
cg-Xnormid is terminally broken in the presence of packed files, since 
it cannot look into them to find objects.
That's right. Well, for everything but the short id matching we could
just check the ID validity by git-rev-parse instead of peeking into
the object store - I just did that. If I'm not missing anything, that
will just make the short id matching for packed objects impossible, but
works fine otherwise...?
Moreover, many uses of commit-id in the scripts can be eliminated because
the underlying git commands can already understand tags directly, and will
check for invalid ids then.
I feel reserved about that. I want to have custom error handling here to
give the user less confusing output (no core GIT command name, since
that confuses users), and as I said, Cogito's rev resolving is more
powerful than Core Git's.
The only thing missing is the short id matching.
Yes, but as I said, I think it's very important to have. BTW, another
cool thing cg-Xnormid does and git-rev-parse does not: time specifiers.
E.g. you could specify revisions as "2 days ago" or so, very useful for
cg-log, cg-diff and such.

Thanks for pointing this out, BTW.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
<Espy> be careful, some twit might quote you out of context..

Re: [PATCH] Cogito: Use git-rev-parse instead of cg-Xnormid.

From: Sven Verdoolaege <hidden>
Date: 2016-06-15 22:42:01

On Sun, Jul 03, 2005 at 05:41:27PM +0200, Petr Baudis wrote:
That's right. Well, for everything but the short id matching we could
just check the ID validity by git-rev-parse instead of peeking into
the object store - I just did that. 
Why not use it to actually resolve ids ?
I really miss the '^' parent notation in cogito.

skimo

Re: [PATCH] Cogito: Use git-rev-parse instead of cg-Xnormid.

From: Petr Baudis <hidden>
Date: 2016-06-15 22:42:01

Dear diary, on Sun, Jul 03, 2005 at 05:40:49PM CEST, I got a letter
where Sven Verdoolaege [off-list ref] told me that...
On Sun, Jul 03, 2005 at 05:41:27PM +0200, Petr Baudis wrote:
quoted
That's right. Well, for everything but the short id matching we could
just check the ID validity by git-rev-parse instead of peeking into
the object store - I just did that. 
Why not use it to actually resolve ids ?
I really miss the '^' parent notation in cogito.
I've decided to go the less troublesome way and just teach cg-Xnormid
about the ^ prefix. ;-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
<Espy> be careful, some twit might quote you out of context..

Re: [PATCH] Cogito: Use git-rev-parse instead of cg-Xnormid.

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:01


On Sun, 3 Jul 2005, Petr Baudis wrote:
That's right. Well, for everything but the short id matching we could
just check the ID validity by git-rev-parse instead of peeking into
the object store - I just did that.
What's the format of the short ID? Minimum 6 characters of the SHA1 or
something?

Pack-files in many ways should be even easier to look up the ID in, since
the pack-file index has all the SHA1's for that pack file listed in sorted
order, so it should be fairly easy to just look it up based on the first
few bytes.. If somebody sends me a patch, that should be fine.
quoted
The only thing missing is the short id matching.
Yes, but as I said, I think it's very important to have. BTW, another
cool thing cg-Xnormid does and git-rev-parse does not: time specifiers.
E.g. you could specify revisions as "2 days ago" or so, very useful for
cg-log, cg-diff and such.
That is indeed something that seems to make more sense in cg-Xnormid.

		Linus

Re: [PATCH] Cogito: Use git-rev-parse instead of cg-Xnormid.

From: Petr Baudis <hidden>
Date: 2016-06-15 22:42:01

Dear diary, on Mon, Jul 04, 2005 at 12:40:52AM CEST, I got a letter
where Linus Torvalds [off-list ref] told me that...

On Sun, 3 Jul 2005, Petr Baudis wrote:
quoted
That's right. Well, for everything but the short id matching we could
just check the ID validity by git-rev-parse instead of peeking into
the object store - I just did that.
What's the format of the short ID? Minimum 6 characters of the SHA1 or
something?

Pack-files in many ways should be even easier to look up the ID in, since
the pack-file index has all the SHA1's for that pack file listed in sorted
order, so it should be fairly easy to just look it up based on the first
few bytes.. If somebody sends me a patch, that should be fine.
Actually, the minimum is 4 characters, but that shouldn't be much of an
issue. Cogito's behaviour is to raise an error in case of multiple
matches; but that could be controlled by a switch too...

	bash$ complete -C git-rev-parse git* cg*


I will cook up a patch in a day or two if noone outruns me.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
<Espy> be careful, some twit might quote you out of context..
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help