代码之家  ›  专栏  ›  技术社区  ›  Era

Git Show/Log:限制补丁大小

git
  •  0
  • Era  · 技术社区  · 6 年前

    我想限制的补丁输出 git-show 和/或 git-log --patch ,这意味着,如果提交的修补程序长度超过X字节,我就不想让它返回。有可能吗?

    2 回复  |  直到 6 年前
        1
  •  0
  •   YesThatIsMyName Decu    6 年前

    --log-size 是你的朋友:

    Include a line “log size <number>” in the output for each commit, where <number> is the length of that commit’s message in bytes.
    

    旨在加速从git日志输出读取日志消息的工具

    然后可以根据提交的日志大小过滤输出。你需要一个自己的shell脚本。

    输出示例:

    commit 552904c8e49c53a690dc14d848b5517f3995be49
    log size 137
    Author: XXXXXXXXX XXXXXXX <YYYYYYY@ZZZZZZZZZ.com>
    Date:   Thu Jul 19 11:31:25 2018 +0200
    
        asd dziprecowss as diürtproject submodule
    
        2
  •  0
  •   ElpieKay    6 年前

    Git命令没有这样的选项。可以使用bash脚本:

    function foolog(){
        SIZE=$1
        for commit in `git log --pretty=%H`;do
          git show $commit --pretty="" | dd |& tail -1 | 
              if [[ `grep -oe '^[0-9]*'` -le $SIZE ]];then
                  git show $commit
              fi
        done
    }
    

    foolog 1200