From: Linus Torvalds <torvalds@osdl.org>
To: Junio C Hamano <junkio@cox.net>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Add a "git show" command to show a commit
Date: Sun, 5 Feb 2006 11:49:11 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.64.0602051144580.3854@g5.osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0602051141020.3854@g5.osdl.org>
It's basically just "git-diff-tree" with pretty flags and a pager.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
This uses the "--always" flag, btw, so it depends on the previous patch I
sent. If you disagree with that, just remove it.
This is actually something I do pretty often, and I've grown tired of
doing
git-diff-tree -p --pretty cmit-id | less -S
so this is really nothing but a fairly flexible replacement for that.
It tries to have the same logic as "git diff" for the flags.
diff --git a/Makefile b/Makefile
index 2aa2385..473e58d 100644
--- a/Makefile
+++ b/Makefile
@@ -112,7 +112,7 @@ SCRIPT_SH = \
git-applymbox.sh git-applypatch.sh git-am.sh \
git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
git-merge-resolve.sh git-merge-ours.sh git-grep.sh \
- git-lost-found.sh
+ git-lost-found.sh git-show.sh
SCRIPT_PERL = \
git-archimport.perl git-cvsimport.perl git-relink.perl \
diff --git a/git-show.sh b/git-show.sh
new file mode 100644
index 0000000..476bca4
--- /dev/null
+++ b/git-show.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+rev=$(git-rev-parse --verify --revs-only --no-flags --sq --default HEAD "$@") || exit
+flags=$(git-rev-parse --no-revs --flags --sq "$@")
+files=$(git-rev-parse --no-revs --no-flags --sq "$@")
+
+# Match the behaviour of "git diff":
+# - if we do not have --name-status, --name-only nor -r, default to -p.
+# - if we do not have -B nor -C, default to -M.
+case " $flags " in
+*" '--name-status' "* | *" '--name-only' "* | *" '-r' "* )
+ ;;
+*)
+ flags="$flags'-p' " ;;
+esac
+case " $flags " in
+*" '-"[BCM]* | *" '--find-copies-harder' "*)
+ ;; # something like -M50.
+*)
+ flags="$flags'-M' " ;;
+esac
+
+eval "git-diff-tree --always --cc --pretty $flags $rev -- $files" | LESS=-S ${PAGER:-less}
next prev parent reply other threads:[~2006-02-05 19:49 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-02 6:28 The merge from hell Linus Torvalds
2006-02-02 7:05 ` Junio C Hamano
2006-02-02 7:40 ` [PATCH] combine-diff: reuse diff from the same blob Junio C Hamano
2006-02-02 7:51 ` The merge from hell Linus Torvalds
2006-02-02 7:55 ` Linus Torvalds
2006-02-02 8:08 ` Linus Torvalds
2006-02-02 8:18 ` [PATCH] combine-diff: update --cc "uninteresting hunks" logic Junio C Hamano
2006-02-02 9:34 ` [PATCH] combine-diff: add safety check to --cc Junio C Hamano
2006-02-02 23:03 ` Linus Torvalds
2006-02-03 0:02 ` Junio C Hamano
2006-02-03 1:05 ` Linus Torvalds
2006-02-03 5:49 ` [Attn - repository browser authors] diff-tree combined format Junio C Hamano
2006-02-03 12:17 ` Marco Costalba
2006-02-03 19:55 ` Junio C Hamano
2006-02-03 21:35 ` Junio C Hamano
2006-02-04 12:03 ` Marco Costalba
2006-02-04 11:23 ` Paul Mackerras
2006-02-03 5:28 ` [PATCH] combine-diff: add safety check to --cc Junio C Hamano
2006-02-04 5:38 ` Paul Mackerras
2006-02-04 6:12 ` Junio C Hamano
2006-02-04 10:46 ` The merge from hell Paul Mackerras
2006-02-04 12:22 ` Junio C Hamano
2006-02-04 19:42 ` Linus Torvalds
2006-02-04 20:59 ` Linus Torvalds
2006-02-02 7:25 ` Marco Costalba
2006-02-02 8:02 ` Linus Torvalds
2006-02-02 8:07 ` Aneesh Kumar
2006-02-02 8:27 ` Junio C Hamano
2006-02-02 8:44 ` Linus Torvalds
2006-02-02 10:41 ` Junio C Hamano
2006-02-05 19:42 ` Linus Torvalds
2006-02-05 19:49 ` Linus Torvalds [this message]
2006-02-05 19:58 ` Fix git-rev-parse over-eager errors Linus Torvalds
2006-02-05 20:11 ` Junio C Hamano
2006-02-05 22:03 ` Linus Torvalds
2006-02-06 6:20 ` Junio C Hamano
2006-02-05 22:45 ` Add a "git show" command to show a commit Junio C Hamano
2006-02-05 22:55 ` Linus Torvalds
2006-02-05 22:59 ` Linus Torvalds
2006-02-06 0:25 ` Junio C Hamano
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=Pine.LNX.4.64.0602051144580.3854@g5.osdl.org \
--to=torvalds@osdl.org \
--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).