Re: git-rerere observations and feature suggestions

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Junio C Hamano <gitster@...>
Cc: <git@...>, Peter Zijlstra <a.p.zijlstra@...>, Chris Mason <chris.mason@...>, Thomas Gleixner <tglx@...>
Date: Monday, June 23, 2008 - 5:49 am

another git-rerere observation: occasionally it happens that i 
accidentally commit a merge marker into the source code.

That's obviously stupid, and it normally gets found by testing quickly, 
but still it would be a really useful avoid-shoot-self-in-foot feature 
if git-commit could warn about such stupidities of mine.

( and if i could configure git-commit to outright reject a commit like 
  that - i never want to commit lines with <<<<<< or >>>>> markers)

Another merge conflict observation is that Git is much worse at figuring 
out the right merge resolution than our previous Quilt based workflow 
was. I eventually found it to be mainly due to the following detail: 
sometimes it's more useful to first apply the merged branch and then 
attempt to merge HEAD, as a patch.

I've got a script for that which also combines it with the "rej" tool, 
and in about 70%-80% of the cases where Git is unable to resolve a merge 
automatically it figures things out. ('rej' is obviously a more relaxed 
merge utility, but it's fairly robust in my experience, with a very low 
false positive rate.)

The ad-hoc "tip-mergetool" script we are using is attached below. It's 
really just for demonstration purposes - it doesnt work when there's a 
rename related conflict, etc.

Peter Zijstra also wrote a git-mergetool extension for the 'rej' tool 
btw., he might want to post that patch. I've attached Chris Mason's rej 
tool too.

	Ingo


[ "$#" = 0 ] && {
  SRC=`git-ls-files -u | cut -f2 | head -1`
} || {
  SRC=`git-ls-files -u | grep $1 | cut -f2 | head -1`
}

[ "$SRC" = "" -o ! -f "$SRC" ] && { echo "$1 has no conflicts!"; exit -1; }

SRC_SED=`echo $SRC | sed 's/\//\\\\\//g'`

SHA_1=`git-ls-files -u | grep $SRC | grep '^.* .* 1\>' | cut -d' ' -f2`
SHA_2=`git-ls-files -u | grep $SRC | grep '^.* .* 2\>' | cut -d' ' -f2`
SHA_3=`git-ls-files -u | grep $SRC | grep '^.* .* 3\>' | cut -d' ' -f2`

mv -b $SRC $SRC.automerge             || { echo error1; exit -1; }

git-diff $SHA_1 $SHA_2 | sed "s/$SHA_1/$SRC_SED/g" |
   sed "s/$SHA_2/$SRC_SED/g" > $SRC.diff-v1 || { echo error2; exit -1; }

git-diff $SHA_1 $SHA_3 | sed "s/$SHA_1/$SRC_SED/g" |
   sed "s/$SHA_3/$SRC_SED/g" > $SRC.diff-v2 || { echo error2; exit -1; }

git-cat-file -p $SHA_1 > $SRC         || { echo error4; exit -1; }

ls -l $SRC.automerge $SRC $SRC.diff-v1 $SRC.diff-v2

patch -p1 < $SRC.diff-v2 || { echo error5; exit -1; }
patch -p1 < $SRC.diff-v1 || {
    echo "reject file ..."
    ls -l $SRC.rej
    echo "trying auto-merge ..."
    OK=$(rej -dry-run $SRC.rej 2>&1 | grep ', 0 conflicts remain')
    [ "$OK" = "" ] && { echo "$OK"; exit -1; }
    rej -a $SRC.rej
}

echo "adding $SRC to the commit"
git-add $SRC
echo 'if happy with the result, do: git-commit -m "Manual merge of conflicts."'

echo "merge successful!"
exit 0
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
git-rerere observations and feature suggestions, Ingo Molnar, (Mon Jun 16, 7:01 am)
Re: git-rerere observations and feature suggestions, Johannes Schindelin, (Tue Jun 17, 6:24 am)
Re: git-rerere observations and feature suggestions, Jakub Narebski, (Mon Jun 16, 4:11 pm)
Re: git-rerere observations and feature suggestions, Junio C Hamano, (Mon Jun 16, 2:46 pm)
Re: git-rerere observations and feature suggestions, Ingo Molnar, (Mon Jun 23, 5:49 am)
Re: git-rerere observations and feature suggestions, Jeff King, (Mon Jun 23, 11:12 am)
Re: git-rerere observations and feature suggestions, Ingo Molnar, (Mon Jun 23, 11:22 am)
Re: git-rerere observations and feature suggestions, Peter Zijlstra, (Mon Jun 23, 10:19 am)
Re: git-rerere observations and feature suggestions, Peter Zijlstra, (Mon Jun 23, 10:26 am)
Re: git-rerere observations and feature suggestions, Junio C Hamano, (Mon Jun 16, 3:10 pm)
Re: git-rerere observations and feature suggestions, Ingo Molnar, (Mon Jun 16, 3:44 pm)
Re: git-rerere observations and feature suggestions, Ingo Molnar, (Mon Jun 16, 3:09 pm)
Re: git-rerere observations and feature suggestions, Ingo Molnar, (Wed Jun 18, 6:57 am)
Re: git-rerere observations and feature suggestions, Jakub Narebski, (Wed Jun 18, 6:01 pm)
Re: git-rerere observations and feature suggestions, Miklos Vajna, (Wed Jun 18, 6:38 pm)
Re: git-rerere observations and feature suggestions, Junio C Hamano, (Thu Jun 19, 3:30 am)
Re: git-rerere observations and feature suggestions, Miklos Vajna, (Thu Jun 19, 4:33 am)
Re: git-rerere observations and feature suggestions, Miklos Vajna, (Thu Jun 19, 6:06 am)
Re: git-rerere observations and feature suggestions, Miklos Vajna, (Thu Jun 19, 3:29 am)
Re: git-rerere observations and feature suggestions, Ingo Molnar, (Wed Jun 18, 7:36 am)
Re: git-rerere observations and feature suggestions, Miklos Vajna, (Wed Jun 18, 7:29 am)
Re: git-rerere observations and feature suggestions, Ingo Molnar, (Wed Jun 18, 2:43 pm)
Re: git-rerere observations and feature suggestions, Miklos Vajna, (Wed Jun 18, 3:53 pm)
Re: git-rerere observations and feature suggestions, Junio C Hamano, (Mon Jun 16, 4:50 pm)
Re: git-rerere observations and feature suggestions, Theodore Tso, (Mon Jun 16, 7:27 am)
Re: git-rerere observations and feature suggestions, Ingo Molnar, (Mon Jun 16, 3:52 pm)
Re: git-rerere observations and feature suggestions, Junio C Hamano, (Mon Jun 16, 4:25 pm)
Re: git-rerere observations and feature suggestions, Ingo Molnar, (Mon Jun 16, 4:46 pm)
Re: git-rerere observations and feature suggestions, Junio C Hamano, (Mon Jun 16, 5:37 pm)
Re: git-rerere observations and feature suggestions, Mike Hommey, (Mon Jun 16, 7:09 am)
Re: git-rerere observations and feature suggestions, Pierre Habouzit, (Mon Jun 16, 11:48 am)
Re: git-rerere observations and feature suggestions, Pierre Habouzit, (Mon Jun 16, 11:57 am)
Re: git-rerere observations and feature suggestions, Sverre Rabbelier, (Mon Jun 16, 12:18 pm)