[git] shellcheck, minor changes

This commit is contained in:
Matteo Cypriani 2018-04-11 23:28:36 +02:00
förälder 849f7d29fa
incheckning 81b60c133a
4 ändrade filer med 35 tillägg och 20 borttagningar

Visa fil

@ -43,21 +43,21 @@ if [ "$HEADER" != "" ] ; then
fi
for TAG in $(git tag -l | sort -r) ; do
if echo $TAG | egrep '^v[0-9]+(\.[0-9]+)+$' >/dev/null ; then
if echo "$TAG" | grep -Eq '^v[0-9]+(\.[0-9]+)+$' ; then
# Display current tag's name
echo $TAG >&2
echo "$TAG" >&2
# Print empty lines if needed
if [ $PRINTNL -eq 1 ] ; then
i=0
while [ $i -lt $NEWLINES ] ; do
echo
i=`expr $i + 1`
i=$((i + 1))
done
fi
# Print the tag message
git tag -l $TAG -n$NBLINES | sed 's/ \+$//'
git tag -l "$TAG" -n$NBLINES | sed 's/ \+$//'
PRINTNL=1
else

Visa fil

@ -11,9 +11,16 @@
# This script moves a commit from a branch head to another. It is
# the equivalent of git cherry-pick followed by git reset.
set -e
USAGE=$(cat <<EOF
Usage:
$0 <src-branch> <dst-branch> [ reset-arg ]
'reset-arg' is passed to the final reset (can be --hard for example).
EOF
)
assert_branch_exists()
{
if ! git for-each-ref refs/heads | grep "/${1}$" >/dev/null ; then
@ -23,14 +30,10 @@ assert_branch_exists()
}
if [ $# -lt 2 ] ; then
echo "Usage:"
echo " $0 <src-branch> <dst-branch> [ reset-arg ]"
echo -n "'reset-arg' is passed to the final reset"
echo " (can be --hard for example)."
printf '%s\n' "$USAGE" >&2
exit 1
fi
assert_branch_exists "$1"
SRC="$1"
shift
@ -43,4 +46,4 @@ shift
git checkout "$DST"
git cherry-pick "$SRC"
git checkout "$SRC"
git reset $1 HEAD^
git reset "$1" HEAD^

Visa fil

@ -16,9 +16,16 @@
set -e
USAGE=$(cat <<EOF
Usage:
$0 <main_branch> <topic_branch>"
<main_branch> will be fast-forwarded to <topic_branch> if possible."
EOF
)
if [ $# -ne 2 ] ; then
echo "Usage: $0 <main_branch> <topic_branch>"
echo "<main_branch> will be fast-forwarded to <topic_branch> if possible."
printf '%s\n' "$USAGE" >&2
exit 1
fi
@ -29,10 +36,10 @@ echo "Trying to merge $TOPIC_BRANCH into $MAIN_BRANCH..."
DIFF="$(git rev-list "$TOPIC_BRANCH".."$MAIN_BRANCH")"
if [ -z "$DIFF" ] ; then
echo "$TOPIC_BRANCH contains all the commits of $MAIN_BRANCH."
echo -- "$TOPIC_BRANCH contains all the commits of $MAIN_BRANCH."
echo "Fast-forwarding $MAIN_BRANCH to $TOPIC_BRANCH."
git branch -f "$MAIN_BRANCH" "$TOPIC_BRANCH"
else
echo "$TOPIC_BRANCH does not contain all the commits of $MAIN_BRANCH."
echo -- "$TOPIC_BRANCH does not contain all the commits of $MAIN_BRANCH."
echo "Fast-forward impossible, aborting."
fi

Visa fil

@ -17,16 +17,21 @@ set -e
#set -x
if [ $# -ne 1 ] ; then
echo "Usage: $0 <tag-name>"
echo "Usage: $0 <tag-name>" >&2
exit 1
fi
TAG=$1
commiter_date()
{
git tag -v "$TAG" 2>/dev/null | grep ^tagger | cut -f5- -d' '
}
GIT_COMMITTER_DATE="$(git tag -v $TAG 2>/dev/null|grep ^tagger | cut -f5- -d' ')"
TAG="$1"
GIT_COMMITTER_DATE="$(commiter_date)"
export GIT_COMMITTER_DATE
git tag -sf $TAG $TAG
git tag -sf "$TAG" "$TAG"
echo "Old tag commiter date: $GIT_COMMITTER_DATE"
GIT_COMMITTER_DATE="$(git tag -v $TAG 2>/dev/null|grep ^tagger | cut -f5- -d' ')"
GIT_COMMITTER_DATE="$(commiter_date)"
echo "New tag commiter date: $GIT_COMMITTER_DATE"