Re: [PATCH 3/3] pull: introduce --[no-]autostash and pull.autostash
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Apr 15, 2013, 08:17 UTC
- Message-ID
- <vpq38us2oov.fsf@grenoble-inp.fr>
- In-Reply-To
- <1365887729-9630-4-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@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.
Show 15 quoted lines
> +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 http://www-verimag.imag.fr/~moy/