From d7e6360f8c90ccb36b7a9ab1d1c322b47ed4b4e4 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 26 Mar 2017 01:53:50 -0700 Subject: [PATCH] tg: support $tgdisplayac for --abort/--continue display The $tgdisplay variable shows the correct tg command to the user to re-run the same copy of tg with the same -C, -u and -r options and is used in various places. Introduce a new $tgdisplayac for use with --abort/--continue displays that should not show any -u or -r options because they are implicit in the --continue operation (and irrelevant for --abort). Update the status display and tg-update.sh to use the new $tgdisplayac variable. Also simplify the maintenance of $tgdisplay at the same time and correct a latent flaw where "-u" was inadvertently omitted due to an unfortunate typo. While doing this, the display used when multiple -C options are present has been somewhat improved -- previously it would only show the last -C option (which was wrong) and now it will still only show one -C option but it will be the effective $PWD if more than one -C option was given. Signed-off-by: Kyle J. McKay --- Makefile | 2 +- tg-update.sh | 12 ++++++------ tg.sh | 33 +++++++++++++++++++-------------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 9491d07..d06f553 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,7 @@ bin-wrappers/tg : $(commands_out) $(utils_out) $(hooks_out) $(helpers_out) tg echo "TG_INST_CMDDIR='$$curdir' && export TG_INST_CMDDIR" >>"$@" && \ echo "TG_INST_SHAREDIR='$$curdir' && export TG_INST_SHAREDIR" >>"$@" && \ echo "TG_INST_HOOKSDIR='$$curdir' && export TG_INST_HOOKSDIR" >>"$@" && \ - echo "[ -n \"\$$tg__include\" ] || exec '$$curdir/tg' \"\$$@\" || exit" >>"$@" && \ + echo '[ -n "$$tg__include" ] || exec $(SHELL_PATH_SQ) -c '\''. "$$TG_INST_CMDDIR/tg"'\'' tg "$$@" || exit' >>"$@" && \ echo ". '$$curdir/tg'" >>"$@" && \ chmod a+x "$@" diff --git a/tg-update.sh b/tg-update.sh index 91c6ce5..edcc07d 100644 --- a/tg-update.sh +++ b/tg-update.sh @@ -944,8 +944,8 @@ update_branch_internal() { then rm "$_depcheck" save_state - info "Please commit merge resolution and call \`$tgdisplay update --continue\`" - info "(use \`$tgdisplay status\` to see more options)" + info "Please commit merge resolution and call \`$tgdisplayac update --continue\`" + info "(use \`$tgdisplayac status\` to see more options)" exit 3 fi done @@ -993,8 +993,8 @@ update_branch_internal() { save_state \ "$(git rev-parse --verify --quiet "refs/$topbases/$_update_name^0" --)" \ "$(git rev-parse --verify --quiet "$_rname^0" --)" - info "Please commit merge resolution and call \`$tgdisplay update --continue\`" - info "(use \`$tgdisplay status\` to see more options)" + info "Please commit merge resolution and call \`$tgdisplayac update --continue\`" + info "(use \`$tgdisplayac status\` to see more options)" exit 3 fi # Go back but remember we want to merge with this, not base @@ -1032,8 +1032,8 @@ update_branch_internal() { no_auto= merging_topfiles="${brmmode:+1}" save_state - info "Please commit merge resolution and call \`$tgdisplay update --continue\`" - info "(use \`$tgdisplay status\` to see more options)" + info "Please commit merge resolution and call \`$tgdisplayac update --continue\`" + info "(use \`$tgdisplayac status\` to see more options)" exit 3 fi diff --git a/tg.sh b/tg.sh index 2e7621b..d293edd 100644 --- a/tg.sh +++ b/tg.sh @@ -1369,10 +1369,10 @@ do_status() fi fi if [ "$tg_state" = "update" ]; then - echol "${pfx}"' (use "tg update --continue" to continue)' - echol "${pfx}"' (use "tg update --skip" to skip this branch and continue)' - echol "${pfx}"' (use "tg update --stop" to stop and retain changes so far)' - echol "${pfx}"' (use "tg update --abort" to restore pre-update state)' + echol "${pfx} (use \"$tgdisplayac update --continue\" to continue)" + echol "${pfx} (use \"$tgdisplayac update --skip\" to skip this branch and continue)" + echol "${pfx} (use \"$tgdisplayac update --stop\" to stop and retain changes so far)" + echol "${pfx} (use \"$tgdisplayac update --abort\" to restore pre-update state)" fi fi [ -z "$git_state" ] || echo "${pfx}git $git_state in progress" @@ -1888,10 +1888,12 @@ else esac # If the tg in the PATH is the same as "$tg" just display the basename - # tgdisplay will include any explicit -C option whereas tg will not + # tgdisplay will include any explicit -C etc. options whereas tg will not + # tgdisplayac is the same as tgdisplay but without any -r or -u options (ac => abort/continue) tgdisplaydir="$tgdir" tgdisplay="$tg" + tgdisplayac="$tgdisplay" if v_get_abs_path _tgabs "$tg" && v_get_abs_path _tgnameabs "$(cmd_path "$tgname")" && @@ -1899,6 +1901,7 @@ else then tgdisplaydir="" tgdisplay="$tgname" + tgdisplayac="$tgdisplay" fi unset _tgabs _tgnameabs @@ -1946,18 +1949,14 @@ else base_remote="$1" explicit_remote="$base_remote" tg="$tgdir$tgname -r $explicit_remote" - tgdisplay="$tgdisplaydir$tgname" - [ -z "$explicit_dir" ] || tgdisplay="$tgdisplay -C \"$explicit_dir\"" - tgdisplay="$tgdisplay -r $explicit_remote" + tgdisplay="$tgdisplaydir$tgname$gitcdopt -r $explicit_remote" shift;; -u) unset base_remote explicit_remote noremote=1 tg="$tgdir$tgname -u" - tgdisplay="$tgdisplaydir$tgname" - [ -z "$explicit_dir" ] || tgdisplay="$tgdisplay -C \"$explicit_dir\"" - tgdisplay="$tgdisplay -u" + tgdisplay="$tgdisplaydir$tgname$gitcdopt -u" shift;; -C) @@ -1969,14 +1968,20 @@ else fi cd "$1" unset GIT_DIR GIT_COMMON_DIR - explicit_dir="$1" + if [ -z "$explicit_dir" ]; then + explicit_dir="$1" + else + explicit_dir="$PWD" + fi gitcdopt=" -C \"$explicit_dir\"" + [ "$explicit_dir" != "." ] || explicit_dir="." gitcdopt=" -C ." tg="$tgdir$tgname" - tgdisplay="$tgdisplaydir$tgname -C \"$explicit_dir\"" + tgdisplay="$tgdisplaydir$tgname$gitcdopt" + tgdisplayac="$tgdisplay" [ -z "$explicit_remote" ] || tg="$tg -r $explicit_remote" [ -z "$explicit_remote" ] || tgdisplay="$tgdisplay -r $explicit_remote" [ -z "$noremote" ] || tg="$tg -u" - [ -z "$noremote" ] || tg="$tgdisplay -u" + [ -z "$noremote" ] || tgdisplay="$tgdisplay -u" shift;; -c) -- 2.11.4.GIT