diff options
author | Mathieu Poirier <mathieu.poirier@linaro.org> | 2021-03-11 16:39:34 -0700 |
---|---|---|
committer | Mathieu Poirier <mathieu.poirier@linaro.org> | 2021-03-11 16:39:34 -0700 |
commit | b88f1689be8ad562d013a0cbb7d63af7b6c628b9 (patch) | |
tree | a02780977fc53cf1ab26c34b1875fe3ef5c3223f | |
parent | f724547574ca80cbf41442c7d1fea49fd5d277c4 (diff) |
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
-rwxr-xr-x | get-mainline-commit | 27 | ||||
-rwxr-xr-x | positive-set | 16 |
2 files changed, 37 insertions, 6 deletions
diff --git a/get-mainline-commit b/get-mainline-commit index 7262e3f..ab26190 100755 --- a/get-mainline-commit +++ b/get-mainline-commit @@ -7,14 +7,19 @@ # # USAGE: # $ git log --format="%H" v4.14..v4.14.186 | parallel --link get-mainline-commit :::: - ::: $1 +# $ git log --format="%H" v4.14..v4.14.186 | parallel --link get-mainline-commit :::: - ::: $1 ::: limit # or # cat data.txt | parallel --link get-mainline-commit :::: - ::: output.file +# cat data.txt | parallel --link get-mainline-commit :::: - ::: output.file ::: limit # # INPUT: # $1: A git generated SHA1, i.e "bcf876870b95592b52519ed4aafcf9d95999bc9c" # $2: Name of the output file +# $3: Skip logging if $1 was developed after $limit # +declare -i limit_date_in_seconds commit_date_in_seconds + # Needed if input is coming from a file sha1=$(echo $1 | awk {'print $1'}) @@ -33,10 +38,30 @@ while read line ; do # Look for the SHA1, it is 40 character long for word in $line; do if [ ${#word} -eq 40 ]; then + + # Exit early if the SHA1 documented in the patch may not be valid + git log -1 $word &> /dev/NULL + if [ $? -ne 0 ]; then + exit 0 + fi + + # If a limit is present, make sure the commit we are processing + # hisn't going over that limit. + if [ -n "$3" ]; then + limit_date=$(git log -1 --date=short --format="%ad" $3) + limit_date_in_seconds=$(date -d $limit_date +%s) + commit_date=$(git log -1 --date=short --format="%ad" $word) + commit_date_in_seconds=$(date -d $commit_date +%s) + + if [ $commit_date_in_seconds -gt $limit_date_in_seconds ]; then + exit 0 + fi + fi + # We have the SHA1, add it to the list only if it is # not in there already if [ "$(grep $word $2 | wc -l)" -eq 0 ]; then - git log -1 --format="%H %s" $word >> $2 + git log -1 --date=short --format="%H %ad %s" $word >> $2 fi # No need to go further diff --git a/positive-set b/positive-set index 13dc57e..ca55fda 100755 --- a/positive-set +++ b/positive-set @@ -8,14 +8,15 @@ # checks for redundency. # # USAGE: -# $ positive-set <outputfilename.out> +# $ positive-set <outputfilename.out> <max_commit> # # INPUT: # $1: Name of the output file +# $2: Don't consider commits developed after this commit # -if [ $# -ne 1 ]; then - echo "Script only takes one argument" +if [ $# -gt 2 ]; then + echo "Script takes at most two arguments" exit 1 fi @@ -54,7 +55,12 @@ for tree in "${stable[@]}"; do echo Processing $base_tag to $top_tag - # For each commit, get the mainline equivalent - git log --format="%H" $base_tag..$top_tag | parallel --link get-mainline-commit :::: - ::: $1 + # For each commit, get the mainline equivalent using a limit if needed + if [ -z "$2" ]; then + git log --format="%H" $base_tag..$top_tag | parallel --link get-mainline-commit :::: - ::: $1 + else + git log --format="%H" $base_tag..$top_tag | parallel --link get-mainline-commit :::: - ::: $1 ::: $2 + fi + done |