Ramkumar Ramachandra <artag...@gmail.com> writes:

> +stash_required () {
> +     ! (git diff-files --quiet --ignore-submodules &&
> +     git diff-index --quiet --cached HEAD --ignore-submodules)
> +}

Isn't this too pessimistic? If the local changes do not overlap (in
terms of files) with the pulled changes, then autosquash is not needed.

There should be a test for the case of non-overlapping changes.

> +if test "$autostash" = true && stash_required
> +then
> +     git stash || die "$(gettext "Cannot autostash")" &&
> +     require_clean_work_tree "pull" "Please commit or stash them." &&
> +     if eval "$eval"
> +     then
> +             git stash pop || die "$(gettext "Cannot pop stash")"
> +     else
> +             exit_code=$?
> +             echo "Please run 'git stash pop' after commiting the conflict 
> resolution."
> +             exit $exit_code
> +     fi
> +else
> +     eval "exec $eval"
> +fi

Shouldn't this belong to "git merge" instead (i.e. implement "git merge
--autosquash" and call it from "git pull")? Users doing "git fetch &&
git merge" by hand should be able to use --autosquash, I think.

Something should be done for "git rebase" and "git pull --rebase" too.
In this case, the UI can be much smoother, since the user would have to
run "git rebase --continue" anyway, so you can do the auto-stash-pop for
him by adding something like "exec git stash pop" at the end of the todo-list.

Ideally, "git rebase --abort" should auto-stash-pop too, although this
is much less trivial to implement.

Maybe a good first step is to implement --autosquash only for non-rebase
pull, and later to implement "git rebase --autosquash" and call it from
"git pull".

Matthieu Moy
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to