aboutsummaryrefslogtreecommitdiff
path: root/load/load-with-metadata.in
diff options
context:
space:
mode:
Diffstat (limited to 'load/load-with-metadata.in')
-rw-r--r--load/load-with-metadata.in9
1 files changed, 6 insertions, 3 deletions
diff --git a/load/load-with-metadata.in b/load/load-with-metadata.in
index 293f8db..01ccd16 100644
--- a/load/load-with-metadata.in
+++ b/load/load-with-metadata.in
@@ -99,11 +99,14 @@ if ! remote_url="$(git -C "$repo_dir" config --get remote.origin.url)"; then
error "'$repo_dir' is not a git repository"
fi
-# Save the repository name and branch of where the latest commit has been
+# Save the repository name and branch of where the current commit has been
# fetched from, separated by space. For example 'origin master'.
#
-refs=$(git -C "$repo_dir" log -1 --format=%D FETCH_HEAD)
-repo_branch="$(sed -n -E 's%^.+ ([^/ ]+)/([^/ ]+)$%\1 \2%p' <<<"$refs")"
+# Note that if the commit belongs to multiple repositories/branches, then we
+# extract the first their pair from the git-log output.
+#
+refs=$(git -C "$repo_dir" log -1 --format=%D)
+repo_branch="$(sed -n -E 's%^[^/]+ ([^/ ]+)/([^/ ,]+).*$%\1 \2%p' <<<"$refs")"
if [[ -z "$repo_branch" ]]; then
error "unable to extract repository and branch from '$refs'"