Cogito: Use git-rev-parse instead of cg-Xnormid.
PATCH 1/1 Cogito: Use git-rev-parse instead of cg-Xnormid.
Use git-rev-parse instead of cg-Xnormid. This allows Cogito to work properly with packed objects.
Signed off by: Brian Gerst <[email protected]>
Use git-rev-parse instead of cg-Xnormid. This allows Cogito to work properly with packed objects.
Signed off by: Brian Gerst <[email protected]>
---
commit 32c6125190d7d183110790b556a8e1128f29c52d
tree 0e53bc37eb8ad12f093cfb0e903689ef95c54ece
parent 266e27c48ba20c1af33f6a3eb966e8cd0d3c8b65
author Brian Gerst <[email protected]> Sun, 03 Jul 2005 01:53:22 -0400 committer Brian Gerst <[email protected]> Sun, 03 Jul 2005 01:53:22 -0400
Makefile | 2 +- cg-Xnormid | 63 ------------------------------------------------------------ commit-id | 12 +---------- parent-id | 4 +--- tree-id | 4 ++-- 5 files changed, 5 insertions(+), 80 deletions(-)
Makefile +1 -1
@@ -67,7 +67,7 @@ SCRIPT= commit-id tree-id parent-id cg-a cg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update \ cg cg-admin-ls cg-push cg-branch-chg -LIB_SCRIPT=cg-Xlib cg-Xmergefile cg-Xnormid +LIB_SCRIPT=cg-Xlib cg-Xmergefile GEN_SCRIPT= cg-version
cg-Xnormid deleted +0 -63
63 lines not on this page · raw message
commit-id +1 -11
@@ -5,14 +5,4 @@ # # Takes the appropriate ID, defaults to HEAD. -. ${COGITO_LIB}cg-Xlib - -id="$1" -normid=$(${COGITO_LIB}cg-Xnormid "$id") || exit 1 - -if [ "$(git-cat-file -t "$normid")" != "commit" ]; then - echo "Invalid commit id: $id" >&2 - exit 1 -fi - -echo $normid +git-rev-parse "${1:-HEAD}"
parent-id +1 -3
@@ -7,6 +7,4 @@ # # NOTE: Will return multiple SHA1s if ID is a commit with multiple parents. -id=$(commit-id "$1") || exit 1 - -git-cat-file commit $id | awk '/^parent/{print $2};/^$/{exit}' +git-rev-parse "${1:-HEAD}^"
tree-id +2 -2
@@ -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
Dear diary, on Sun, Jul 03, 2005 at 07:59:42AM CEST, I got a letter where Brian Gerst <[email protected]> told me that...
Quoted 4 lines
Use git-rev-parse instead of cg-Xnormid. This allows Cogito to work properly with packed objects.
Signed off by: Brian Gerst <[email protected]>
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 4 lines
tree-id line 12
Quoted 10 lines
tree-id +2
-2@@ -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,
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ <Espy> be careful, some twit might quote you out of context..
Quoted 11 lines · Petr Baudis
Dear diary, on Sun, Jul 03, 2005 at 07:59:42AM CEST, I got a letter where Brian Gerst <[email protected]> told me that...
Quoted 3 lines
Use git-rev-parse instead of cg-Xnormid. This allows Cogito to work properly with packed objects.
Signed off by: Brian Gerst <[email protected]>
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 15 lines
Quoted 15 lines
tree-id +2
-2@@ -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")
Quoted 7 lines
Quoted 1 line
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
Dear diary, on Sun, Jul 03, 2005 at 02:25:09PM CEST, I got a letter where Brian Gerst <[email protected]> told me that...
Quoted 10 lines
Quoted 9 lines · Petr Baudis
Dear diary, on Sun, Jul 03, 2005 at 07:59:42AM CEST, I got a letter where Brian Gerst <[email protected]> told me that...
Quoted 4 lines
Use git-rev-parse instead of cg-Xnormid. This allows Cogito to work properly with packed objects.
Signed off by: Brian Gerst <[email protected]>
Quoted 6 lines
Quoted 3 lines
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...?
Quoted 3 lines
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.
Quoted 1 line
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.
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ <Espy> be careful, some twit might quote you out of context..
Quoted 3 lines · Petr Baudis
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
Dear diary, on Sun, Jul 03, 2005 at 05:40:49PM CEST, I got a letter where Sven Verdoolaege <[email protected]> told me that...
Quoted 7 lines · Petr Baudis
Quoted 3 lines
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. ;-)
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ <Espy> be careful, some twit might quote you out of context..
Quoted 4 lines · Petr Baudis
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 6 lines
Quoted 1 line
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
Dear diary, on Mon, Jul 04, 2005 at 12:40:52AM CEST, I got a letter where Linus Torvalds <[email protected]> told me that...
Quoted 8 lines · Petr Baudis
Quoted 4 lines
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.
Quoted 7 lines
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.
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ <Espy> be careful, some twit might quote you out of context..