Changes between Version 2 and Version 3 of LibavMerge


Ignore:
Timestamp:
Aug 4, 2016, 11:32:36 AM (3 years ago)
Author:
Timothy_Gu
Comment:

Rewrite script

Legend:

Unmodified
Added
Removed
Modified
  • LibavMerge

    v2 v3  
    4242#!/bin/sh
    4343
    44 if [ "$1" != "merge" -a "$1" != "noop" ]; then
    45     printf "Usage: $0 <merge|noop [REF_HASH]>\n"
    46     exit 0
    47 fi
     44op="$1"
     45next_rev=$(git rev-list libav/master --not HEAD --no-merges | tail -n1)
    4846
    49 [ "$1" = "noop" ] && merge_opts="-s ours"
     47do_merge() {
     48    if [ -z "$next_rev" ]; then
     49        printf "Nothing to merge..\n"
     50        return 0
     51    fi
    5052
    51 nextrev=$(git rev-list libav/master --not master --no-merges | tail -n1)
    52 if [ -z "$nextrev" ]; then
    53     printf "Nothing to merge..\n"
    54     exit 0
    55 fi
    56 printf "Merging $(git log -n 1 --oneline $nextrev)\n"
    57 git merge --no-commit $merge_opts --no-ff --log $nextrev
     53    merge_opts=
     54    [ "$op" = "noop" ] && merge_opts="-s ours"
    5855
    59 if [ "$1" = "noop" -a -n "$2" ]; then
    60     printf "\nThis commit is a noop, see $2\n" >> .git/MERGE_MSG
    61 fi
     56    printf "Merging $(git log -n 1 --oneline $next_rev)\n"
     57    git merge --no-commit $merge_opts --no-ff --log $next_rev
    6258
    63 printf "\nMerged-by: $(git config --get user.name) <$(git config --get user.email)>\n" >> .git/MERGE_MSG
     59    if [ "$op" = "noop" ]; then
     60        printf "\nThis commit is a no-op." >> .git/MERGE_MSG
     61        [ -n "$2" ] && printf " See $2." >> .git/MERGE_MSG
     62        printf "\n" >> .git/MERGE_MSG
     63    fi
     64
     65    printf "\nMerged-by: $(git config --get user.name) <$(git config --get user.email)>\n" >> .git/MERGE_MSG
     66}
     67
     68case "$op" in
     69next)
     70    echo $next_rev
     71    ;;
     72show)
     73    git show $next_rev
     74    ;;
     75merge|noop)
     76    do_merge
     77    ;;
     78*)
     79    echo "Usage: $0 <next|show|merge|noop [REF_HASH]>"
     80    echo "    next  - Echo hash of the commit to be merged next"
     81    echo '    show  - git show $next'
     82    echo '    merge - Prepare to merge the next commit'
     83    echo '    noop  - Pass up the next commit with an optional "See $REF_HASH" message'
     84    ;;
     85esac
    6486}}}
    6587