From 87346e3cc1990009cb5d62f9fde79274409e2628 Mon Sep 17 00:00:00 2001 From: Donald Curtis Date: Sun, 16 Sep 2012 18:11:21 -0500 Subject: [PATCH] Reset git repos to the HEAD branch on the remote. Not all repositories use 'master' as the name of the master branch. Therefore, we need to query the remote server and see which branch is actually supposed to be tracked by default. --- package-build.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/package-build.el b/package-build.el index 5786b5e4..00621521 100644 --- a/package-build.el +++ b/package-build.el @@ -294,6 +294,11 @@ Return a cons cell whose `car' is the root and whose `cdr' is the repository." (pb/run-process-match "Fetch URL: \\(.*\\)" dir "git" "remote" "show" "-n" "origin")) +(defun pb/git-head-branch (dir) + "Get the current git repo for DIR." + (pb/run-process-match + "HEAD branch: \\(.*\\)" dir "git" "remote" "show" "origin")) + (defun pb/checkout-git (name config dir) "Check package NAME with config CONFIG out of git into DIR." (let ((repo (plist-get config :url)) @@ -310,7 +315,8 @@ Return a cons cell whose `car' is the root and whose `cdr' is the repository." (delete-directory dir t nil)) (pb/princ-checkout repo dir) (pb/run-process nil "git" "clone" repo dir))) - (pb/run-process dir "git" "reset" "--hard" (or commit "origin/master")) + (pb/run-process dir "git" "reset" "--hard" + (or commit (concat "origin/" (pb/git-head-branch dir)))) (apply 'pb/run-process dir "git" "log" "-n1" "--pretty=format:'\%ci'" (pb/expand-source-file-list dir config)) (pb/find-parse-time