Git: How can I find a commit that most closely matches a directory?

前端 未结 5 616
[愿得一人]
[愿得一人] 2020-12-02 12:58

Someone took a version (unknown to me) of Moodle, applied many changes within a directory, and released it (tree here).

How can I determine which commit of t

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 13:32

    This was my solution:

    #!/bin/sh
    
    start_date="2012-03-01"
    end_date="2012-06-01"
    needle_ref="aaa"
    
    echo "" > /tmp/script.out;
    shas=$(git log --oneline --all --after="$start_date" --until="$end_date" | cut -d' ' -f 1)
    for sha in $shas
    do
        wc=$(git diff --name-only "$needle_ref" "$sha" | wc -l)
        wc=$(printf %04d $wc);
        echo "$wc $sha" >> /tmp/script.out
    done
    cat /tmp/script.out | grep -v ^$ | sort | head -5
    

提交回复
热议问题