Module: check_mk
Branch: master
Commit: 247e5cf52613729b2aa0b2fb46e063204d05c462
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=247e5cf5261372…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Mar 2 13:34:35 2018 +0100
5875 FIX Git: Fixed error "git add --all ... is outside repository" with older
git versions
When using older git versions (saw this with 1.7.1) an error could occur when enabling
the
git integration of WATO. This was caused by an incompatibility with the "git
add" command
used by WATO. It used absolute paths to add the new files that should be added to git
instead
of relative paths to the current working directory.
This issue was present in all 1.4.0 releases.
Change-Id: Iaffb451bb6b16840926093fa4b21742956c73128
---
.werks/5875 | 16 ++++++++++++++++
web/htdocs/watolib.py | 7 ++++---
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/.werks/5875 b/.werks/5875
new file mode 100644
index 0000000..190f957
--- /dev/null
+++ b/.werks/5875
@@ -0,0 +1,16 @@
+Title: Git: Fixed error "git add --all ... is outside repository" with older
git versions
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i4
+Date: 1519993814
+
+When using older git versions (saw this with 1.7.1) an error could occur when enabling
the
+git integration of WATO. This was caused by an incompatibility with the "git
add" command
+used by WATO. It used absolute paths to add the new files that should be added to git
instead
+of relative paths to the current working directory.
+
+This issue was present in all 1.4.0 releases.
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 66b8cde..de3e45e 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -9758,7 +9758,7 @@ def unlock_exclusive():
def git_command(args):
command = [ "git" ] + [ a.encode("utf-8") for a in args ]
- logger.debug("GIT: Execute %s" % subprocess.list2cmdline(command))
+ logger.debug("GIT: Execute in %s: %s" % (cmk.paths.default_config_dir,
subprocess.list2cmdline(command)))
try:
p = subprocess.Popen(command, cwd=cmk.paths.default_config_dir,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
@@ -9815,8 +9815,9 @@ def do_git_commit():
def git_add_files():
- git_command(["add", "--all", ".gitignore"]
- + glob.glob("%s/*.d/wato" % cmk.paths.default_config_dir))
+ path_pattern = os.path.join(cmk.paths.default_config_dir, "*.d/wato")
+ rel_paths = [ os.path.relpath(p, cmk.paths.default_config_dir) for p in
glob.glob(path_pattern) ]
+ git_command(["add", "--all", ".gitignore"] +
rel_paths)
def git_has_pending_changes():