git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-difftool-helper.sh: learn a new way skip to save point

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 7, 2021, 18:29 UTC
Message-ID
<xmqqczxb91el.fsf@gitster.c.googlers.com>
In-Reply-To
<pull.870.git.1612711153591.gitgitgadget@gmail.com>
"阿德烈 via GitGitGadget"  <gitgitgadget@gmail.com> writes:
> From: ZheNing Hu <adlternative@gmail.com>

I am a bit confused. Are 胡哲宁 and 阿德烈 and ZeNing Hu all the same person (I am asking that an earlier question came under the name first listed in this sentence, and the patch uses the latter two names, where I guess )?

Show 90 quoted lines
>
> `git difftool` only allow us to select file to view In turn.
> If there is a commit with many files and we exit in search,
> We will have to traverse list again to get the file diff which
> we want to see.Therefore,here is a new method:every time before
> we view the file diff,the current coordinates will be stored in
> `GIT_DIR/difftool_skip_to`,this file will be deleted after
> successful traversing.But if an unexpected exit occurred midway,
> git will view the coordinates in the save point,ask user if they
> want continue from the last saved point.This will improve the
> user experience.
>
> Signed-off-by: ZheNing Hu <adlternative@gmail.com>
> ---
>     git-difftool-helper.sh: learn a new way skip to save point
>     
>     this patch's origin discuss is here:
>     https://lore.kernel.org/git/gOXOaoqn-E9A2ob7ykWEcDc7ZxmSwAjcP5CCFKfr5ejCOWZQ1lfAUZcbgYT9AyQCcDgJvCrnrtziXiels-Hxol3xlkGTVHk24SvAdaSUtKQ=@rtzoeller.com/
>     
>     git user may should travel the diff list to choice file diff to view, if
>     they exit in midway,they must travel it again. I’m on the basis of the
>     "difftool_skip_to" suggested by Junio,Provides a possibility for this
>     user-friendly solution.
>     
>     Thanks!
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-870%2Fadlternative%2Fdifftool_save_point-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-870/adlternative/difftool_save_point-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/870
>
>  git-difftool--helper.sh | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
>
> diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh
> index 46af3e60b718..56ec1d38a7a1 100755
> --- a/git-difftool--helper.sh
> +++ b/git-difftool--helper.sh
> @@ -6,6 +6,7 @@
>  # Copyright (c) 2009, 2010 David Aguilar
>  
>  TOOL_MODE=diff
> +GIT_DIFFTOOL_SKIP_TO_FILE="$GIT_DIR/difftool-skip-to"
>  . git-mergetool--lib
>  
>  # difftool.prompt controls the default prompt/no-prompt behavior
> @@ -40,6 +41,31 @@ launch_merge_tool () {
>  	# the user with the real $MERGED name before launching $merge_tool.
>  	if should_prompt
>  	then
> +		if test -f "$GIT_DIFFTOOL_SKIP_TO_FILE"
> +		then
> +			SAVE_POINT_NUM=$(cat "$GIT_DIFFTOOL_SKIP_TO_FILE")
> +			if test $SAVE_POINT_NUM -le $GIT_DIFF_PATH_TOTAL &&
> +				test $SAVE_POINT_NUM -gt $GIT_DIFF_PATH_COUNTER
> +			then
> +				# choice skip or not skip when check first file.
> +				if test $GIT_DIFF_PATH_COUNTER -eq "1"
> +				then
> +					printf "do you want to skip to last time difftool save point($SAVE_POINT_NUM) [Y/n]?"
> +					read skip_ans || return
> +					if test "$skip_ans" = y
> +					then
> +						return
> +					fi
> +				else
> +					return
> +				fi
> +			fi
> +		fi
> +		# write the current coordinates to .git/difftool-skip-to
> +		if test !$SAVE_POINT_NUM || $SAVE_POINT_NUM -ne $GIT_DIFF_PATH_COUNTER
> +		then
> +			echo $GIT_DIFF_PATH_COUNTER > $GIT_DIFFTOOL_SKIP_TO_FILE
> +		fi
>  		printf "\nViewing (%s/%s): '%s'\n" "$GIT_DIFF_PATH_COUNTER" \
>  			"$GIT_DIFF_PATH_TOTAL" "$MERGED"
>  		if use_ext_cmd
> @@ -102,4 +128,10 @@ else
>  	done
>  fi
>  
> +if test -f $GIT_DIFFTOOL_SKIP_TO_FILE &&
> +	test $GIT_DIFF_PATH_COUNTER -eq $GIT_DIFF_PATH_TOTAL
> +then
> +	rm $GIT_DIFFTOOL_SKIP_TO_FILE
> +
> +fi
>  exit 0
>
> base-commit: e6362826a0409539642a5738db61827e5978e2e4
Previous: 阿德烈 via GitGitGadgetNext: Junio C Hamano
Message 2 of 37 in “git-difftool-helper.sh: learn a new way skip to save point”
  1. git-difftool-helper.sh: learn a new way skip to save point阿德烈 via GitGitGadget, Feb 7, 2021
  2. Junio C HamanoFeb 7, 2021
  3. Junio C HamanoFeb 7, 2021
  4. 胡哲宁Feb 8, 2021
  5. git-difftool-helper.sh: learn a new way go back to last save pointZheNing Hu via GitGitGadget, Feb 8, 2021
  6. Junio C HamanoFeb 8, 2021
  7. David AguilarFeb 8, 2021
  8. Junio C HamanoFeb 8, 2021
  9. 胡哲宁Feb 9, 2021
  10. 胡哲宁Feb 9, 2021
  11. difftool.c: learn a new way start from specified fileZheNing Hu via GitGitGadget, Feb 9, 2021
  12. Junio C HamanoFeb 9, 2021
  13. 胡哲宁Feb 10, 2021
  14. Junio C HamanoFeb 10, 2021
  15. Junio C HamanoFeb 10, 2021
  16. ZheNing HuFeb 14, 2021
  17. difftool.c: learn a new way start at specified fileZheNing Hu via GitGitGadget, Feb 14, 2021
  18. Junio C HamanoFeb 16, 2021
  19. 0/2 difftool.c: learn a new way start at specified fileZheNing Hu via GitGitGadget, Feb 16, 2021
  20. 1/2 diff: --{rotate,skip}-to=<path>Junio C Hamano via GitGitGadget, Feb 16, 2021
  21. 2/2 difftool.c: learn a new way start at specified fileZheNing Hu via GitGitGadget, Feb 16, 2021
  22. Junio C HamanoFeb 17, 2021
  23. ZheNing HuFeb 17, 2021
  24. Junio C HamanoFeb 16, 2021
  25. ZheNing HuFeb 17, 2021
  26. Denton LiuFeb 17, 2021
  27. ZheNing HuFeb 17, 2021
  28. Junio C HamanoFeb 17, 2021
  29. ZheNing HuFeb 18, 2021
  30. ZheNing HuFeb 18, 2021
  31. Junio C HamanoFeb 18, 2021
  32. ZheNing HuFeb 19, 2021
  33. Johannes SchindelinFeb 25, 2021
  34. Junio C HamanoFeb 25, 2021
  35. difftool.c: learn a new way start at specified fileZheNing Hu via GitGitGadget, Feb 19, 2021
  36. ZheNing HuFeb 22, 2021
  37. Junio C HamanoFeb 22, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.