Skip to content

Commit

Permalink
git-show
Browse files Browse the repository at this point in the history
This is essentially 'git whatchanged -n1 --always --cc "$@"'.
Just like whatchanged takes default flags from
whatchanged.difftree configuration, this uses show.difftree
configuration.

Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Junio C Hamano committed Feb 6, 2006
1 parent df9892f commit 80d48ac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ git-send-pack
git-sh-setup
git-shell
git-shortlog
git-show
git-show-branch
git-show-index
git-ssh-fetch
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ SCRIPT_PYTHON = \
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
$(patsubst %.perl,%,$(SCRIPT_PERL)) \
$(patsubst %.py,%,$(SCRIPT_PYTHON)) \
git-cherry-pick
git-cherry-pick git-show

# The ones that do not have to link with lcrypto nor lz.
SIMPLE_PROGRAMS = \
Expand Down Expand Up @@ -440,6 +440,9 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
git-cherry-pick: git-revert
cp $< $@

git-show: git-whatchanged
cp $< $@

# These can record GIT_VERSION
git$X git.spec \
$(patsubst %.sh,%,$(SCRIPT_SH)) \
Expand Down
18 changes: 14 additions & 4 deletions git-whatchanged.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@ SUBDIRECTORY_OK='Yes'
. git-sh-setup

diff_tree_flags=$(git-rev-parse --sq --no-revs --flags "$@") || exit
case "$0" in
*whatchanged)
count=
test -z "$diff_tree_flags" &&
diff_tree_flags=$(git-repo-config --get whatchanged.difftree)
diff_tree_default_flags='-M --abbrev' ;;
*show)
count=-n1
test -z "$diff_tree_flags" &&
diff_tree_flags=$(git-repo-config --get show.difftree)
diff_tree_default_flags='--cc --always' ;;
esac
test -z "$diff_tree_flags" &&
diff_tree_flags=$(git-repo-config --get whatchanged.difftree)
test -z "$diff_tree_flags" &&
diff_tree_flags='-M --abbrev'
diff_tree_flags="$diff_tree_default_flags"

rev_list_args=$(git-rev-parse --sq --default HEAD --revs-only "$@") &&
diff_tree_args=$(git-rev-parse --sq --no-revs --no-flags "$@") &&

eval "git-rev-list $rev_list_args" |
eval "git-rev-list $count $rev_list_args" |
eval "git-diff-tree --stdin --pretty -r $diff_tree_flags $diff_tree_args" |
LESS="$LESS -S" ${PAGER:-less}

0 comments on commit 80d48ac

Please sign in to comment.