From: Eric Wong <normalperson@yhbt.net>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: simple git repository browser with vim
Date: Sat, 26 Nov 2005 14:05:17 -0800 [thread overview]
Message-ID: <20051126220517.GC3899@mail.yhbt.net> (raw)
In-Reply-To: <7v8xveuyq0.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
> Eric Wong <normalperson@yhbt.net> writes:
>
> > It relies on a simple shell script I wrote called 'git-show' that picks
> > a reasonable way to display each of the blob, tree, or commit object
> > types. I'm fairly sure somebody else has written something like
> > git-show before, I just couldn't find it. I'd imagine it's pretty
> > useful standalone without vim, too.
>
> Aha.
>
> It strikes me that the blob case could be enhanced to do
> git-unpack-file, run "file -i" on it to figure out the file's
> mimetype, and then give it to an appropriate MIME type viewer
> ;-).
Maybe somebody else will find this useful, overkill for me.
> For a tag object, you might want to deref it, and also if it is
> a signed kind, you may want to do git-verify-tag it.
This is pretty useful, I've added it to my version, and also added
extra vim foldmarkers for the dereferenced tag.
> The following should not taken too seriously, but you might find
> it instructive to learn how to unwrap tag objects, verify them
> for signature, and pretty-print a single commit without running
> whatchanged. I suspect the script as posted by you shows the
> commit message twice, BTW.
That was semi-intentional, I wanted the short diff format with the
sha1sums of the blobs so I could further expand those inside vim.
Fortunately, I've figured out that diff-tree is better for this.
Here's what I'm currently using:
---
#!/bin/sh
extract_tag_info='
s/^object /sha1=/p
/^type /{
s//type=/
p
q
}
'
sha1sums=
while : ; do
case "$1" in
-f|--fold-marker)
fold_marker=1
;;
*)
sha1sums="$sha1sums $1"
break
;;
esac
shift
done
for sha1 in $sha1sums
do
type=`git-cat-file -t $sha1` || continue
test -n "$fold_marker" && echo "$type($1) {{{"
while case "$type" in tag) ;; *) break ;; esac
do
git-cat-file tag "$sha1"
git-verify-tag "$sha1"
test -n "$fold_marker" && echo '}}}'
eval `git-cat-file tag "$sha1" | sed -n -e "$extract_tag_info"`
test -n "$fold_marker" && echo "$type($1) {{{"
done
case "$type" in
tree)
git-ls-tree -r "$sha1"
;;
blob)
git-cat-file blob "$sha1"
;;
commit)
git-diff-tree --pretty=raw -r -m -C --find-copies-harder "$sha1"
test -n "$fold_marker" && echo "commit_diff($1) {{{"
git-diff-tree -m -C --find-copies-harder -p "$sha1"
test -n "$fold_marker" && echo '}}}'
;;
esac
test -n "$fold_marker" && echo '}}}'
done
prev parent reply other threads:[~2005-11-26 22:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-24 9:33 simple git repository browser with vim Eric Wong
2005-11-24 10:28 ` Junio C Hamano
2005-11-26 22:05 ` Eric Wong [this message]
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=20051126220517.GC3899@mail.yhbt.net \
--to=normalperson@yhbt.net \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/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).