Re: Kernel SCM saga..

Randy.Dunlap
2005-04-09T07:10:05Z

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

On Sat, 9 Apr 2005 04:53:57 +0200 Petr Baudis wrote:

| Hello,
|
| Dear diary, on Fri, Apr 08, 2005 at 05:50:21PM CEST, I got a letter
| where Linus Torvalds <torvalds@osdl.org> told me that...
| >
| >
| > On Fri, 8 Apr 2005 ross@jose.lug.udel.edu wrote:
| > >
| > > Here's a partial solution. It does depend on a modified version of
| > > cat-file that behaves like cat. I found it easier to have cat-file
| > > just dump the object indicated on stdout. Trivial patch for that is included.
| >
| > Your trivial patch is trivially incorrect, though. First off, some files
| > may be binary (and definitely are - the "tree" type object contains
| > pathnames, and in order to avoid having to worry about special characters
| > they are NUL-terminated), and your modified "cat-file" breaks that.
| >
| > Secondly, it doesn't check or print the tag.
|
| FWIW, I made few small fixes (to prevent some trivial usage errors to
| cause cache corruption) and added scripts gitcommit.sh, gitadd.sh and
| gitlog.sh - heavily inspired by what already went through the mailing
| list. Everything is available at http://pasky.or.cz/~pasky/dev/git/
| (including .dircache, even though it isn't shown in the index), the
| cumulative patch can be found below. The scripts aim to provide some
| (obviously very interim) more high-level interface for git.
|
| I'm now working on tree-diff.c which will (surprise!) produce a diff
| of two trees (I'll finish it after I get some sleep, though), and then I
| will probably do some dwimmy gitdiff.sh wrapper for tree-diff and
| show-diff. At that point I might get my hand on some pull more kind to
| local changes.

Hi,

I'll look at your scripts this weekend. I've also been
working on some, but mine are a bit more experimental (cruder)
than yours are. Anyway, here they are (attached) -- also
available at http://developer.osdl.org/rddunlap/git/

gitin : checkin/commit
gitwhat sha1 : what is that sha1 file (type and contents if blob or commit)
gitlist (blob, commit, tree, or all) :
list all objects with type (commit, tree, blob, or all)

---
~Randy

[-- Attachment #2: gitin --]
[-- Type: application/octet-stream, Size: 742 bytes --]

#! /bin/sh
# gitin: checkin for git files

# grep show-diff for +++ => error, print 'run update-cache <filenames>', exit
# (better would be an error exit code)
# write-tree > current_tree_object
# print 'enter commit message:'
# commit-tree `cat current_tree_object` -p `cat .dircache/HEAD` > current_commit_object
# update .dircache/HEAD with current_commit_object

diffs=`show-diff | grep "+++"`
#echo diffs=/$diffs/

if [ x"$diffs" != x ]; then
echo "run update-cache <filenames>"
exit
fi

tree_object=`write-tree`
#echo tree_obj=/$tree_object/

head=`cat .dircache/HEAD`
echo "enter commit message: (end with ^D)"
commit_object=`commit-tree $tree_object -p $head`
#echo commit_obj=/$commit_object/

echo $commit_object > .dircache/HEAD

[-- Attachment #3: gitlist --]
[-- Type: application/octet-stream, Size: 580 bytes --]

#! /bin/sh
# gitlist: list some git objects/types
# (by selected target type: blob, tree, commit, all)

target=$1
if [ -z "$target" ]; then
echo "usage: gitlist type {blob, tree, commit, or all}"
exit 1
fi

subdir=.dircache/objects/

for high in 0 1 2 3 4 5 6 7 8 9 a b c d e f ; do
for low in 0 1 2 3 4 5 6 7 8 9 a b c d e f ; do
top=$high$low

for f in $subdir/$top/* ; do
if [ ! -r $f ]; then
continue
fi
base=`basename $f`
type=`cat-file -t $top$base`
if [ $target == "all" -o $target == $type ]; then
echo $top$base : $type
fi
done
done
done

[-- Attachment #4: gitwhat --]
[-- Type: application/octet-stream, Size: 533 bytes --]

#! /bin/sh
# gitwhat: what is that file

sha1=$1
if [ -z $sha1 ]; then
echo "usage: gitwhat sha1"
exit 1
fi

what=`cat-file -t $sha1`
if [ -z "$what" ]; then
exit 1
fi
echo "type is: $what"

topdir=${sha1:0:2}
last=${sha1:2}
file=.dircache/objects/$topdir/$last

if [ -z $PAGER ]; then
pager=more
else
pager=$PAGER
fi

case $what in
blob)
#head -10 $file
#$pager $file
cat-file blob $sha1 | $pager
;;
tree)
echo "cannot print binary tree"
#cat-file tree $sha1 | $pager
;;
commit)
cat-file commit $sha1 | $pager
;;
esac