Changelog-merge¶
Problematic ChangeLog merges¶
bor@bik grimoire 0 $ git log -p -1
commit 83cac7378ad42bcd6bbcbb239c3107ee6f89bf86
Author: Bor Kraljič <pyrobor@ver.si>
Date: Thu Oct 6 12:12:21 2011 +0200
bbbbbbbbbbbbbbbbbbbbb
diff --git a/ChangeLog b/ChangeLog
index aaaa8e9..9c43442 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2011-10-07 Bor Kraljič <pyrobor@ver.si>
+ * something new on "master" branch
+
2011-10-05 Vlad Glagolev <stealth@sourcemage.org>
* python-pypi/fabric: new spell, simple, Pythonic tool for remote
execution and deployment
bor@bik grimoire 0 $ git log -p -1 problematic-changelog
commit e4490cbe10751fce61e81d6388f883b915634b9d
Author: Bor Kraljič <pyrobor@ver.si>
Date: Thu Oct 6 12:08:20 2011 +0200
ccccccccccccccc
diff --git a/ChangeLog b/ChangeLog
index aaaa8e9..036a8c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2011-10-06 Bor Kraljič <pyrobor@ver.si>
+ * some changes on one "devel" branch
+
2011-10-05 Vlad Glagolev <stealth@sourcemage.org>
* python-pypi/fabric: new spell, simple, Pythonic tool for remote
execution and deployment
bor@bik grimoire 0 $ git merge problematic-changelog
Auto-merging ChangeLog CONFLICT (content): Merge conflict in ChangeLog Automatic merge failed; fix conflicts and then commit the result.
bor@bik grimoire 1 $ head -n 10 ChangeLog
<<<<<<< HEAD
2011-10-07 Bor Kraljič <pyrobor@ver.si>
* something new on "master" branch
=======
2011-10-06 Bor Kraljič <pyrobor@ver.si>
* some changes on one "devel" branch
>>>>>>> problematic-changelog
2011-10-05 Vlad Glagolev <stealth@sourcemage.org>
* python-pypi/fabric: new spell, simple, Pythonic tool for remote
As we see the merge fails and we have to deal with conflicts
Lets add changelog-merge driver¶
bor@bik grimoire 0 $ echo "ChangeLog merge=merge-changelog" >> .git/info/attributes
bor@bik grimoire 0 $ cat .git/info/attributes
ChangeLog merge=merge-changelog
I already defined it in git config file:
bor@bik grimoire 0 $ grep -i change .git/config
[merge "merge-changelog"]
name = GNU-style ChangeLog merge driver
driver = /usr/bin/git-merge-changelog %O %A %B
Instructions for use with git from Upstream source code (line 50)
Same scenario with new merge driver¶
Lets first just reset changes done by that ugly merge:
bor@bik grimoire 0 $ git reset --hard HEAD
HEAD is now at 83cac73 bbbbbbbbbbbbbbbbbbbbb
bor@bik grimoire 0 $ git log -p -1
commit 83cac7378ad42bcd6bbcbb239c3107ee6f89bf86
Author: Bor Kraljič <pyrobor@ver.si>
Date: Thu Oct 6 12:12:21 2011 +0200
bbbbbbbbbbbbbbbbbbbbb
diff --git a/ChangeLog b/ChangeLog
index aaaa8e9..9c43442 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2011-10-07 Bor Kraljič <pyrobor@ver.si>
+ * something new on "master" branch
+
2011-10-05 Vlad Glagolev <stealth@sourcemage.org>
* python-pypi/fabric: new spell, simple, Pythonic tool for remote
execution and deployment
bor@bik grimoire 0 $ git log -p -1 problematic-changelog
commit e4490cbe10751fce61e81d6388f883b915634b9d
Author: Bor Kraljič <pyrobor@ver.si>
Date: Thu Oct 6 12:08:20 2011 +0200
ccccccccccccccc
diff --git a/ChangeLog b/ChangeLog
index aaaa8e9..036a8c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2011-10-06 Bor Kraljič <pyrobor@ver.si>
+ * some changes on one "devel" branch
+
2011-10-05 Vlad Glagolev <stealth@sourcemage.org>
* python-pypi/fabric: new spell, simple, Pythonic tool for remote
execution and deployment
bor@bik grimoire 0 $ git merge problematic-changelog
Auto-merging ChangeLog Merge made by recursive. ChangeLog | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
bor@bik grimoire 0 $ head -n 10 ChangeLog
2011-10-06 Bor Kraljič <pyrobor@ver.si>
* some changes on one "devel" branch
2011-10-07 Bor Kraljič <pyrobor@ver.si>
* something new on "master" branch
2011-10-05 Vlad Glagolev <stealth@sourcemage.org>
* python-pypi/fabric: new spell, simple, Pythonic tool for remote
execution and deployment
Merge is done without conflict!
Conclusions¶
- No more conflicts in ChangeLog
- works also with HISTORY files with adding "HISTORY merge=merge-changelog" to .gitattributes or .git/info/attributes
- changes from merging branch are on top... (at least in this testing)
- perhaps this is good or maybe not... depends on sorcery search for date ( http://www.sourcemage.org/issues/194 ) - getting git-merge-changelog installed was a bit tricky!
- I have made some spell for installing gnulib modules that more or less work... ( source:devel/gnulib ) (haven't really tested any other module as git-merge-changelog) It is in test grimoire. Feel free to improve it.
- We can package just git-merge-changelog module: http://www.mail-archive.com/bug-gnulib@gnu.org/msg09699.html
How to get this improvement?¶
Spell gnulib is now in test grimoire. Just cast it. (for now it only has option to install git-merge-changelog module)
cast gnulib
After that you only need to configure your git clone of grimoire repository by adding lines in .git/config:
[merge "merge-changelog"]
name = GNU-style ChangeLog merge driver
driver = /usr/bin/git-merge-changelog %O %A %B
And add rule about using this new driver (for ChangeLog and HISTORY) to file .git/info/attributes:
ChangeLog merge=merge-changelog HISTORY merge=merge-changelog
Or you can just copy & paste these lines (in your git clone grimoire directory):
echo "[merge \"merge-changelog\"]" >> .git/config echo -e "\tname = GNU-style ChangeLog merge driver" >> .git/config echo -e "\tdriver = /usr/bin/git-merge-changelog %O %A %B" >> .git/config echo "ChangeLog merge=merge-changelog" >> .git/info/attributes echo "HISTORY merge=merge-changelog" >> .git/info/attributes
And merging of Changelog or HISTORY will no longer be a problem. However I have few notices:
- Entry from merging branch is on top. (at least during my tests (all commits were from the same day if that matters...))
- I am not responsible if something goes wrong. But this is git. Just undo the merge
git reset --hard HEAD^, comment line (prefixing it with #) in .git/info/attributes and merge it old fashion way with resolving conflicts manually. - Spell gnulib is far from perfect. But it does the job... Feel free to improve it to maybe get more goodies from it.