Browse Source

jgit.sh: Implement pager support

If the command is either `diff` or `log`, there is often a lot of
lines of output. Run these commands through $GIT_PAGER, $PAGER, or
`less` in order to make it easier to browse the output on a terminal.

Change-Id: I18b87ea4acf404b94788f2ac2101812bd13e6a0f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-1.0
Shawn O. Pearce 14 years ago
parent
commit
0a39fb2ab6
  1. 33
      org.eclipse.jgit.pgm/jgit.sh

33
org.eclipse.jgit.pgm/jgit.sh

@ -41,6 +41,20 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cmd=
for a in "$@"
do
case "$a" in
-*) continue ;;
*) cmd=$a; break; ;;
esac
done
use_pager=
case "$cmd" in
diff) use_pager=1 ;;
log) use_pager=1 ;;
esac
this_script=`which "$0" 2>/dev/null`
[ $? -gt 0 -a -f "$0" ] && this_script="$0"
@ -58,7 +72,7 @@ CYGWIN*)
cp=`cygpath --windows --mixed --path "$cp"`
;;
Darwin)
if test -e /System/Library/Frameworks/JavaVM.framework
if [ -e /System/Library/Frameworks/JavaVM.framework ]
then
java_args='
-Dcom.apple.mrj.application.apple.menu.about.name=JGit
@ -74,10 +88,25 @@ CLASSPATH="$cp"
export CLASSPATH
java=java
if test -n "$JAVA_HOME"
if [ -n "$JAVA_HOME" ]
then
java="$JAVA_HOME/bin/java"
fi
if [ -n "$use_pager" ]
then
use_pager=${GIT_PAGER:-${PAGER:-less}}
[ cat = "$use_pager" ] && use_pager=
fi
if [ -n "$use_pager" ]
then
LESS=${LESS:-FSRX}
export LESS
"$java" $java_args org.eclipse.jgit.pgm.Main "$@" | $use_pager
exit
else
exec "$java" $java_args org.eclipse.jgit.pgm.Main "$@"
exit 1
fi

Loading…
Cancel
Save