Re: [PATCH v2 1/2] t7505: Add tests for cherry-pick and rebase -i/-p
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 23, 2018, 18:41 UTC
- Message-ID
- <xmqq4lncifjh.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20180123102420.19911-2-phillip.wood@talktalk.net>
Phillip Wood <phillip.wood@talktalk.net> writes:
Show 41 quoted lines
> @@ -31,17 +63,40 @@ mkdir -p "$HOOKDIR"
> echo "#!$SHELL_PATH" > "$HOOK"
> cat >> "$HOOK" <<'EOF'
>
> +GIT_DIR=$(git rev-parse --git-dir)
> +if test -d "$GIT_DIR/rebase-merge"
> +then
> + rebasing=1
> +else
> + rebasing=0
> +fi
> +
> +get_last_cmd () {
> + tail -n1 "$GIT_DIR/rebase-merge/done" | {
> + read cmd id _
> + git log --pretty="[$cmd %s]" -n1 $id
> + }
> +}
> +
> if test "$2" = commit; then
> - source=$(git rev-parse "$3")
> + if test $rebasing = 1
> + then
> + source="$3"
> + else
> + source=$(git rev-parse "$3")
> + fi
> else
> source=${2-default}
> fi
> -if test "$GIT_EDITOR" = :; then
> - sed -e "1s/.*/$source (no editor)/" "$1" > msg.tmp
> +test "$GIT_EDITOR" = : && source="$source (no editor)"
> +
> +if test $rebasing = 1
> +then
> + echo "$source $(get_last_cmd)" >"$1"
> else
> sed -e "1s/.*/$source/" "$1" > msg.tmp
> + mv msg.tmp "$1"
> fiIt is somewhat irritating that indentation is screwed up in this part of the file. Can we not make it even worse?