On 10-Sep-15, Manuel Ortega wrote:
> 
> 
> On Thu, Sep 10, 2015 at 4:02 PM, Olaf Dabrunz <[email protected]> wrote:
> 
>     On 10-Sep-15, Manuel Ortega wrote:
>     > In the case of mercurial, there's no need to make branches or merges in 
> order to solve this problem.  Just add the following
>     to
>     > $REPO/.hg/hgrc:
>     >
>     > [hooks]
>     > pre-status = hg revert runtime/doc/tags
>     > pre-update = hg revert runtime/doc/tags
>     > pre-pull   = hg revert runtime/doc/tags
>     >
>     > I'm about to investigate whether (a) something similar can done in git, 
> and (b) if the answer is yes, whether Bram can set it
>     in
>     > the GitHub repo and have it percolate down to all of us.
> 
>     I don't think that git has *hooks* for 'git pull' or 'git merge' that
>     can affect the outcome of the merge (githooks(1)).  Also, hooks live
>     below .git/hooks/, which is not transmitted between repositories.
> 
>     But git offers custom merge drivers for this purpose.
> 
>         
> http://stackoverflow.com/questions/27920526/merge-strategy-in-gitattributes-not-working
> 
>     The merge driver itself needs to be defined in the local repository and
>     lives in .git/config or ~/.gitconfig (when "--global" is used):
> 
>         git config [--global] merge.theirs.name "always copy their version 
> during merge"
>         git config [--global] merge.theirs.driver "cp -f %B %A"
> 
>     The driver can then be used for merging "runtime/doc/tags".  As the
>     driver is only defined for the local repository, this setting should
>     also be done locally:
> 
>         echo "runtime/doc/tags merge=theirs" >> $(git rev-parse 
> --show-toplevel)/.git/info/attributes
> 
>     That should be all, but I did not test it.
> 
>     Note that the above line can alternatively be added to .gitattributes,
>     which is transferred to other repositories.  But the definition of a
>     merge driver is local to each repository, so this is not useful and
>     leads to merge errors when the driver is not defined.
> 
>     Merge drivers and hook scripts are not transferred between repositories
>     to prevent users from pushing malicious scripts to all other users.
> 
> 
> That's cool, but I don't want to modify a merge.  In fact, I don't want to 
> have to merge at all; I don't make local commits that
> differ from what Bram does, so `git pull` should suffice.  I want to do what 
> I did in hg, which is to automatically revert any

'git pull' is a 'git fetch' plus a 'git merge'.  This is how git updates
the local versions of remote branches.

git tries to never lose any changes, even in the working directory.
Using a merge driver to drop local changes is the only way I know to
override this.

(Note that git can also rebase local changes on top of remote updates
instead of merging the remote updates.  But this just turns the merge
direction around, and does not revert local changes either.)

> uncommitted changes to runtime/doc/tags BEFORE any pulling or fetching takes 
> place.

And AFAIU with the above 'pre-status' hook in hg calling 'hg status'
does the desired revert for you.

In git, I have not seen hooks for commands that do not make changes,
such as 'git status'.

-- 
Olaf Dabrunz (oda <at> fctrace.org)

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui