Browse Source

Add --subtree flag to checkout a portion of a project

master
Scott Wallace 12 years ago
parent
commit
6e9f32dcc4
  1. 15
      git-latexdiff

15
git-latexdiff

@ -88,6 +88,7 @@ Options:
included files) included files)
--ln-untracked symlink uncommited files from the working directory --ln-untracked symlink uncommited files from the working directory
--version show git-latexdiff version. --version show git-latexdiff version.
--subtree checkout the tree at and below the main file
--ignore-makefile ignore the Makefile, build as though it doesn't exist --ignore-makefile ignore the Makefile, build as though it doesn't exist
EOF EOF
} }
@ -133,6 +134,7 @@ output=
initial_dir=$PWD initial_dir=$PWD
tmpdir_prefix="/tmp" tmpdir_prefix="/tmp"
prepare_cmd= prepare_cmd=
subtree=0
uselatexmk= uselatexmk=
ln_untracked=0 ln_untracked=0
quiet=0 quiet=0
@ -197,6 +199,9 @@ while test $# -ne 0; do
echo "$git_latexdiff_version" echo "$git_latexdiff_version"
exit 0 exit 0
;; ;;
"--subtree")
subtree=1
;;
"--prepare") "--prepare")
shift shift
prepare_cmd="$1" prepare_cmd="$1"
@ -340,7 +345,13 @@ if test "$ln_untracked" = 1; then
ln -s "$initial_dir"/* . ln -s "$initial_dir"/* .
fi fi
git --git-dir="$git_dir" --work-tree=. checkout "$old" -- . || die "checkout failed for old/"
if test "$subtree" = 1; then
checkoutroot=$git_prefix
else
checkoutroot="."
fi
git --git-dir="$git_dir" --work-tree=. checkout "$old" -- "$checkoutroot" || die "checkout failed for old/"
verbose_progress verbose_progress
cd ../new || die "Cannot cd to new/" cd ../new || die "Cannot cd to new/"
if test "$ln_untracked" = 1; then if test "$ln_untracked" = 1; then
@ -349,7 +360,7 @@ fi
if test "$new" != "--"; then if test "$new" != "--"; then
# if new == "--" then diff working dir (already there thanks to ln # if new == "--" then diff working dir (already there thanks to ln
# -s above). # -s above).
git --git-dir="$git_dir" --work-tree=. checkout "$new" -- . || die "checkout failed for new/"
git --git-dir="$git_dir" --work-tree=. checkout "$new" -- "$checkoutroot" || die "checkout failed for new/"
fi fi
verbose_progress verbose_progress
cd .. cd ..

Loading…
Cancel
Save