【问题标题】:git difftool: how to measure progress, that is number of files diff'ed and to diff?git difftool:如何衡量进度,即差异文件的数量和差异?
【发布时间】:2014-01-16 09:10:52
【问题描述】:

我知道我可以use git difftool with the --dir-diff option 一次性比较所有文件。

但是在提示符下使用difftool 有其用途(对于相当少量的文件进行比较),尤其是since git 1.7.8, where you can skip a file

但是,该提示不会显示差异队列中有多少文件或已经比较了多少文件。
您将如何在difftool 提示符中显示该信息?

【问题讨论】:

    标签: git prompt difftool


    【解决方案1】:

    单独使用 git,你不能(git 1.8.x)。
    但该功能即将推出(在 Git 1.9/2.0 Q1 2014 中)

    commit 6904f9a 来自Zoltan Klingerpatch

    当设置了--prompt 选项时,git-difftool 会提示在外部差异程序中查看每个已修改文件。此时显示一个计数器和差异队列中的文件总数可能很有用。

    以下是 5 个已修改文件中第一个的当前 difftool 提示:

    Viewing: 'diff.c'
    Launch 'vimdiff' [Y/n]:
    

    考虑修改后的提示:

    Viewing (1/5): 'diff.c'
    Launch 'vimdiff' [Y/n]:
    

    当前的GIT_EXTERNAL_DIFF 机制不会告诉差异队列中的路径数,也不会告诉当前计数器。
    要使此“counter/total”信息可用于GIT_EXTERNAL_DIFF 程序,而无需 打破现有的:

    1. 修改diff.c 中的run_external_diff() function,为计数器设置一个环境变量,为差异队列中的文件总数设置一个环境变量。
      diff_queue_struct 中已经提供了 diff 队列的大小。
      对于计数器,在 diff_options 结构中定义一个新变量,并在 diff_setup_done() 函数中将其重置为零。
      run_external_diff() 函数中预递增计数器。
    2. difftool 提示符中将git-difftool--helper.sh 脚本修改为display the counter and the diff queue count values

    结果:

    git-difftool--helper.sh @@ launch_merge_tool () {
    
     # the user with the real $MERGED name before launching $merge_tool.
     if should_prompt
     then
       printf "\nViewing (%s/%s): '%s'\n" "$GIT_DIFF_PATH_COUNTER" \
         "$GIT_DIFF_PATH_TOTAL" "$MERGED"
     if use_ext_cmd
     then
       printf "Launch '%s' [Y/n]: " \
    

    【讨论】:

    • 很高兴知道。不过,第四季度还有很长的路要走。无论如何,这是你的Sock Puppet ;-)
    • @janos 糟糕,我指的是 2014 年第一季度,而不是第四季度。谢谢你的帽子!
    猜你喜欢
    • 2010-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-24
    • 1970-01-01
    • 2011-05-03
    • 2021-11-26
    • 2018-10-19
    相关资源
    最近更新 更多