From 06b02626aeabbe89bcd99d8fcc3e4bbf37fa54b5 Mon Sep 17 00:00:00 2001 From: James Youngman Date: Sun, 8 Mar 2009 13:20:37 +0000 Subject: [PATCH] Switch to using a merge driver for the ChangeLog file. * import-gnulib.sh (check_merge_driver): New function; verifies that we have a merge driver installed for the ChangeLog file (if we're on the master or release branch, the check is skipped). Also check that the .gitattributes file exists. * README-hacking: Point out that using a merge driver for ChangeLog is a good idea. * .gitattributes: new file Signed-off-by: James Youngman --- .gitattributes | 1 + ChangeLog | 9 ++++++ README-hacking | 9 ++++++ import-gnulib.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..384e031d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +ChangeLog merge=cl-merge diff --git a/ChangeLog b/ChangeLog index 8a9e28b9..ee9f8f07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2009-03-08 James Youngman + Switch to using a merge driver for the ChangeLog file. + * import-gnulib.sh (check_merge_driver): New function; verifies + that we have a merge driver installed for the ChangeLog file (if + we're on the master or release branch, the check is skipped). + Also check that the .gitattributes file exists. + * README-hacking: Point out that using a merge driver for + ChangeLog is a good idea. + * .gitattributes: New file + Optimise away calls to stat if all we need is the inode number. This fixes Savannah bug #24342. * find/util.c (get_info): call get_statinfo if need_inum and we diff --git a/README-hacking b/README-hacking index 224fb2e3..bd967f2d 100644 --- a/README-hacking +++ b/README-hacking @@ -96,6 +96,15 @@ example values: email = joe.user@example.com +In order to simplify the handling of merges, we recommend that you +use a specialised merge driver for the ChangeLog file. Otherwise, +you will end up spending time resolving merge conflicts for your +ChangeLog edits. You can install the ChangeLog merge driver by +following the instructions in the README section of the file +gnulib-git/gnulib/lib/git-merge-changelog.c. + + + Making commits locally ====================== diff --git a/import-gnulib.sh b/import-gnulib.sh index 3543e378..2d97f9fc 100755 --- a/import-gnulib.sh +++ b/import-gnulib.sh @@ -234,6 +234,73 @@ EOF } +check_merge_driver() { + local config_file=".git/config" + fixmsg=" + +We recommend that you use a git merge driver for the ChangeLog file. +This simplifies the task of merging branches. +Please see the README section in gnulib-git/gnulib/lib/git-merge-changelog.c + +If you've read that and don't want to use it, just set the environment variable +DO_NOT_WANT_CHANGELOG_DRIVER. + +Example: + git config merge.cl-merge.name 'GNU-style ChangeLog merge driver' + git config merge.cl-merge.driver /usr/local/bin/git-merge-changelog + echo 'ChangeLog merge=cl-merge' >> .gitattributes +" + if [[ -z "$DO_NOT_WANT_CHANGELOG_DRIVER" ]] ; then + if git branch | egrep -q '\* *(master|rel-)'; then + # We are on the master branch or a release branch. + # Perhaps the user is simply building from git sources. + # Issue our message as a warning rather than an error. + fatal=false + label="Warning" + else + fatal=true + label="ERROR" + fi + else + fatal=false + label="Warning" + fi + if git config --get merge.cl-merge.name >/dev/null ; then + driver="$(git config --get merge.cl-merge.driver)" + if [[ $? -eq 0 ]]; then + if ! [[ -x "$driver" ]]; then + echo "ERROR: Merge driver $driver is not executable." >&2 + echo "ERROR: Please fix $config_file or install $driver" >&2 + # Always fatal - if configured, the merge driver should work. + exit 1 + else + if [[ -f .gitattributes ]] ; then + echo "The ChangeLog merge driver configuration seems OK." + else + echo "$label"': you have no .gitattributes file' >&2 + echo "$fixmsg" >&2 + if $fatal; then + exit 1 + fi + fi + fi + else + echo "$label"': There is no driver specified in [merge "cl-merge"] in' "$config_file" >&2 + echo "$fixmsg" >&2 + if $fatal; then + exit 1 + fi + fi + else + echo "$label"': There is no name specified in [merge "cl-merge"] in' "$config_file" >&2 + echo "$fixmsg" >&2 + if $fatal; then + exit 1 + fi + fi +} + + move_cvsdir() { local cvs_git_root=":pserver:anonymous@pserver.git.sv.gnu.org:/gnulib.git" @@ -281,6 +348,7 @@ EOF fi move_cvsdir do_checkout gnulib-git + check_merge_driver gnulibdir=gnulib-git/gnulib else echo "Warning: using gnulib code which already exists in $gnulibdir" >&2 @@ -293,7 +361,8 @@ EOF hack_gnulib_tool_output "${gnulibdir}" && refresh_output_files && update_licenses && - update_version_file ; then + update_version_file + then echo Done. else echo FAILED >&2