summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: be6ff20)
raw | patch | inline | side by side (parent: be6ff20)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Tue, 25 Sep 2007 15:42:51 +0000 (16:42 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 26 Sep 2007 00:46:50 +0000 (17:46 -0700) |
This patch indents ";;" consistently with the rest of git's shell scripts,
and makes sure that ";;" are before each "esac".
It introduces a helper function "has_action", to make it easier to read
the intentions of the code.
Errors from "git rev-parse --verify" are no longer ignored.
Spaces are quoted using single quotes instead of a backslash, for
readability.
A "test $preserve=f" (missing spaces) was fixed; hashes are no longer
written to "$DOTEST"/rewritten/ unnecessarily.
We used to quote the message for a squash, only to have "echo" unquote it.
Now we use "printf" and do not need to quote to start with.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
and makes sure that ";;" are before each "esac".
It introduces a helper function "has_action", to make it easier to read
the intentions of the code.
Errors from "git rev-parse --verify" are no longer ignored.
Spaces are quoted using single quotes instead of a backslash, for
readability.
A "test $preserve=f" (missing spaces) was fixed; hashes are no longer
written to "$DOTEST"/rewritten/ unnecessarily.
We used to quote the message for a squash, only to have "echo" unquote it.
Now we use "printf" and do not need to quote to start with.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-rebase--interactive.sh | patch | blob | history |
index 56e6f7f08a9003bd2ad463847fe345016808ae8d..cab5e93d60a46f4be76b7ba607b16425905d5e7b 100755 (executable)
test $status != 0 &&
cat "$DOTEST"/output
return $status
- ;;
+ ;;
*)
"$@"
+ ;;
esac
}
''|rebase*)
GIT_REFLOG_ACTION="rebase -i ($1)"
export GIT_REFLOG_ACTION
+ ;;
esac
}
die "$1"
}
+has_action () {
+ grep -vqe '^$' -e '^#' "$1"
+}
+
pick_one () {
no_ff=
case "$1" in -n) sha1=$2; no_ff=t ;; *) sha1=$1 ;; esac
output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
test -d "$REWRITTEN" &&
pick_one_preserving_merges "$@" && return
- parent_sha1=$(git rev-parse --verify $sha1^ 2>/dev/null)
+ parent_sha1=$(git rev-parse --verify $sha1^) ||
+ die "Could not get the parent of $sha1"
current_sha1=$(git rev-parse --verify HEAD)
if test $no_ff$current_sha1 = $parent_sha1; then
output git reset --hard $sha1
fast_forward=t
preserve=t
new_parents=
- for p in $(git rev-list --parents -1 $sha1 | cut -d\ -f2-)
+ for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)
do
if test -f "$REWRITTEN"/$p
then
;; # do nothing; that parent is already there
*)
new_parents="$new_parents $new_p"
+ ;;
esac
fi
done
case $fast_forward in
t)
output warn "Fast forward to $sha1"
- test $preserve=f && echo $sha1 > "$REWRITTEN"/$sha1
+ test $preserve = f || echo $sha1 > "$REWRITTEN"/$sha1
;;
f)
test "a$1" = a-n && die "Refusing to squash a merge: $sha1"
- first_parent=$(expr "$new_parents" : " \([^ ]*\)")
+ first_parent=$(expr "$new_parents" : ' \([^ ]*\)')
# detach HEAD to current parent
output git checkout $first_parent 2> /dev/null ||
die "Cannot move HEAD to $first_parent"
echo $sha1 > "$DOTEST"/current-commit
case "$new_parents" in
- \ *\ *)
+ ' '*' '*)
# redo merge
author_script=$(get_author_ident_from_commit $sha1)
eval "$author_script"
- msg="$(git cat-file commit $sha1 | \
- sed -e '1,/^$/d' -e "s/[\"\\]/\\\\&/g")"
+ msg="$(git cat-file commit $sha1 | sed -e '1,/^$/d')"
# NEEDSWORK: give rerere a chance
if ! output git merge $STRATEGY -m "$msg" $new_parents
then
- echo "$msg" > "$GIT_DIR"/MERGE_MSG
+ printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
die Error redoing merge $sha1
fi
;;
*)
output git cherry-pick $STRATEGY "$@" ||
die_with_patch $sha1 "Could not pick $sha1"
+ ;;
esac
+ ;;
esac
}
}
do_next () {
- test -f "$DOTEST"/message && rm "$DOTEST"/message
- test -f "$DOTEST"/author-script && rm "$DOTEST"/author-script
- test -f "$DOTEST"/amend && rm "$DOTEST"/amend
+ rm -f "$DOTEST"/message "$DOTEST"/author-script \
+ "$DOTEST"/amend || exit
read command sha1 rest < "$TODO"
case "$command" in
- \#|'')
+ '#'*|'')
mark_action_done
;;
pick)
squash)
comment_for_reflog squash
- test -z "$(grep -ve '^$' -e '^#' < $DONE)" &&
+ has_action "$DONE" ||
die "Cannot 'squash' without a previous commit"
mark_action_done
EDIT_COMMIT=
USE_OUTPUT=output
cp "$MSG" "$SQUASH_MSG"
- ;;
+ ;;
*)
EDIT_COMMIT=-e
USE_OUTPUT=
- test -f "$SQUASH_MSG" && rm "$SQUASH_MSG"
+ rm -f "$SQUASH_MSG" || exit
+ ;;
esac
failed=f
warn
warn "Could not apply $sha1... $rest"
die_with_patch $sha1 ""
+ ;;
esac
;;
*)
warn "Unknown command: $command $sha1 $rest"
die_with_patch $sha1 "Please fix this in the file $TODO."
+ ;;
esac
test -s "$TODO" && return
$UPSTREAM...$HEAD | \
sed -n "s/^>/pick /p" >> "$TODO"
- test -z "$(grep -ve '^$' -e '^#' < $TODO)" &&
+ has_action "$TODO" ||
die_abort "Nothing to do"
cp "$TODO" "$TODO".backup
git_editor "$TODO" ||
die "Could not execute editor"
- test -z "$(grep -ve '^$' -e '^#' < $TODO)" &&
+ has_action "$TODO" ||
die_abort "Nothing to do"
output git checkout $ONTO && do_rest
+ ;;
esac
shift
done