From 39c5c91905ef05a2a4a3400e54f38627987e3338 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 24 Sep 2021 12:24:18 +0200 Subject: [PATCH] TT#142950 Avoid interactive autoedit merge commits Executing something like this: | root@web01a:~# touch /etc/ngcp-config/xz.yml | root@web01a:~# ngcpcfg set /etc/ngcp-config/xz.yml ha.gcs=pacemaker | [...] | root@web01a:~# ngcpcfg commit "xz" | root@web01a:~# DEBUG=1 ngcpcfg --debug push --nobuild --noapply | [...] This *might* result in merge conflicts, like: | 2021-09-21 10:06:31 web01b: Pulling changes: 2021-09-21 10:06:31 web01b: Error: FAILED: | interactive rebase in progress; onto ad0b99f | Last command done (1 command done): | pick 29bc5de /dev/fd/63 [2021-09-21 09:24:19.985891726+02:00] | No commands remaining. | You are currently rebasing branch 'master' on 'ad0b99f'. | (fix conflicts and then run "git rebase --continue") | (use "git rebase --skip" to skip this patch) | (use "git rebase --abort" to check out the original branch) | | Unmerged paths: | (use "git restore --staged ..." to unstage) | (use "git add ..." to mark resolution) | both modified: .ngcpcfg_perms The underlying permission issue causing the megre conflict was fixed via git commit 79ed4aa59 / Change-Id: I93017cdcdcf22fa1c5ef8e103d215aa7bc110b9a, but regarding the "/dev/fd/63" - commit 29bc5de looking as: | commit 29bc5debbe7e4015bcc689c828558d6a0420497b (HEAD -> master) | Author: ngcp-config ; | Date: Tue Sep 21 09:24:19 2021 +0200 | | /dev/fd/63 [2021-09-21 09:24:19.985891726+02:00] bash uses /dev/fd/63 in pipes (for sending results of process(es) to another process). We don't want to end with `/dev/fd/63` in the commit message during automatic merges like within `git pull --rebase` though. This can be avoided by setting GIT_MERGE_AUTOEDIT=no. Quoting from the Git v1.7.10 Release Notes: | * From this release on, the "git merge" command in an interactive | session will start an editor when it automatically resolves the | merge for the user to explain the resulting commit, just like the | "git commit" command does when it wasn't given a commit message. | | If you have a script that runs "git merge" and keeps its standard | input and output attached to the user's terminal, and if you do not | want the user to explain the resulting merge commits, you can | export GIT_MERGE_AUTOEDIT environment variable set to "no", like | this: | | #!/bin/sh | GIT_MERGE_AUTOEDIT=no | export GIT_MERGE_AUTOEDIT | | to disable this behavior (if you want your users to explain their | merge commits, you do not have to do anything). Alternatively, you | can give the "--no-edit" option to individual invocations of the | "git merge" command if you know everybody who uses your script has | Git v1.7.8 or newer. Change-Id: Iafe5e4adb9afb9caf74d1ea81a208fdf608ddf54 --- functions/main | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/main b/functions/main index 2cd9139a..b6f62fef 100644 --- a/functions/main +++ b/functions/main @@ -6,6 +6,9 @@ # support for testsuite, assume defaults if unset FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}" +# do not explain merge commits +export GIT_MERGE_AUTOEDIT=no + if ! [ -r "${FUNCTIONS}"/logs ] ; then printf "Error: %s/logs could not be read. Exiting.\n" "${FUNCTIONS}" >&2 exit 1