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 <file>..." to unstage)
|   (use "git add <file>..." 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 <root@web01b>;
| 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
mr10.1
Michael Prokop 5 years ago
parent 79ed4aa594
commit 39c5c91905

@ -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

Loading…
Cancel
Save