[X2Go-Commits] [maintenancescripts] 04/04: git/hooks/update-script._irkerhook.py_: actually fetch the parent of the first uniquely new commit.
git-admin at x2go.org
git-admin at x2go.org
Thu Jan 2 11:47:46 CET 2020
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository maintenancescripts.
commit ce1e9271cfc83b3e005f7d9f41a761c33ec65b24
Author: Mihai Moldovan <ionic at ionic.de>
Date: Thu Jan 2 11:35:20 2020 +0100
git/hooks/update-script._irkerhook.py_: actually fetch the parent of the first uniquely new commit.
This is way trickier than it sounds, because it could be... anything. A
merge, a grafted commit, or other stuff.
We'll try to guess and use the very first parent.
---
git/hooks/update-script._irkerhook.py_ | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/git/hooks/update-script._irkerhook.py_ b/git/hooks/update-script._irkerhook.py_
index babaaae..94b2735 100755
--- a/git/hooks/update-script._irkerhook.py_
+++ b/git/hooks/update-script._irkerhook.py_
@@ -336,7 +336,14 @@ class GitExtractor(GenericExtractor):
parent = ''
if self.new:
# Generate a list of changed files that are part of uniquely new commits.
- parent = do("git rev-list --reverse -n 1 " + shellquote(commit.commit) + " --not --branches=" + shellquote("*") + " --tags=" + shellquote("*"))
+ parent = do("git rev-list --reverse " + shellquote(commit.commit) + " --not --branches=" + shellquote("*") + " --tags=" + shellquote("*")).split("\n")
+ # Take the first element only (oldest uniquely new commit).
+ parent = parent[0]
+ # Fetch its parent. That's a tricky operation. rev-parse won't do
+ # for grafted commits, so try to use something... safe. I guess.
+ parent = do("git cat-file -p " + shellquote(parent) + " | awk " + shellquote ('NR > 1 {if(/^parent/){print $2; next}{exit}}')).split()
+ # Take the first parent, again.
+ parent = parent[0]
commit.files = do("git diff-tree -r --name-only " + shellquote(parent) + " " + shellquote(commit.commit))
elif self.rebase == '':
commit.files = do("git diff-tree -r --name-only " + shellquote(commit.commit))
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/maintenancescripts.git
More information about the x2go-commits
mailing list