am: suppress error output from a conditional

When testing if the $dotest directory exists, and if $next is greater
than $last, the script currently executes `cat` on files that might
not exist.  So, suppress the error output from `cat`.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
rebase -i: don't error out if $state_dir already exists

Practically speaking, the only reason why a `mkdir $state_dir` would
fail is because $state_dir already exists.  There is no problem in
this case, and we can proceed as usual.  So, change the `mkdir` call
to `mkdir -p`, and strip the `|| die`.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
am: tighten a conditional that checks for basic state

We currently assume that, if the $dotest directory exists,
write_basic_state() has been called.  This might match a stray $dotest
directory created somewhere else and result in failures down the
line. So, tighten the conditional by additionally looking for the
first file written by write_basic_state(), $dotest/head-name.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
am: don't do housekeeping when rebasing

Perform these two tasks:

    git gc --auto
    rm -fr "$dotest"

only when not called with --rebasing (from git-rebase--am.sh).
Otherwise, return control to the caller so that it can do the needful.
The advantage of doing this is that the caller can implement a generic
cleanup routine (that possibly does other things) independent of
specific rebases.

Patch the ultimate caller, git-rebase.sh, to perform these two steps
for the moment.  Later patches will add functionality.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
rebase -i: return control to the caller, for housekeeping

On a successful interactive rebase, git-rebase--interactive.sh
currently cleans up and exits on its own.  Instead of doing these
two things ourselves:

    rm -fr "$dotest"
    git gc --auto

let us return control to the caller (git-rebase.sh), to do the
needful.  The advantage of doing this is that the caller can implement
a generic cleanup routine (and possibly other things) independent of
specific rebases.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
rebase: implement --[no-]autostash and rebase.autostash

This new feature allows a rebase to be executed on a dirty worktree.
It works by creating a temporary stash and storing it in
$state_dir/autostash, and applying it after a successful operation.

Most significantly, this feature means that a 'pull -r' can be
executed on a dirty worktree.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>