From e00960dd7cb41078493daf3f24880e8158ae5336 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 9 Mar 2009 13:10:46 +0100 Subject: [PATCH] Fixed handling of refs if packed refs are used --- git-ftp-sync | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/git-ftp-sync b/git-ftp-sync index 412dd3b..7d3528b 100755 --- a/git-ftp-sync +++ b/git-ftp-sync @@ -266,19 +266,18 @@ def perror(str): def update_ref(hash): - remote = "ftp" - branch = "master" - if (not os.path.exists("refs/remotes/"+remote)): - os.makedirs("refs/remotes/"+remote) - file("refs/remotes/"+remote+"/"+branch, "w").write(newrev+"\n") + cmd = "git update-ref refs/remotes/ftp/master %s"%(hash) + #print "Runnging", cmd + os.system(cmd) def add_to_change_list(changes, git_command, oldrev, newrev): # Read changes + ##print "Running: ", git_command gitdiff = Popen(git_command, stdout=PIPE, stderr=PIPE, close_fds=True, shell=True) change_re = re.compile("(\S+)\s+(.*)$"); for line in gitdiff.stdout: - #print line, + ##print line, m = change_re.match(line) if (m): change = RepoChange(m.group(1), m.group(2), oldrev, newrev, options) @@ -304,11 +303,12 @@ if 'GIT_DIR' in os.environ: (oldrev, newrev, refname) = line.split() if refname == "refs/heads/master": try: - oldrev=file("refs/remotes/ftp/master").readline().strip(); - git_command = "/usr/bin/git diff --name-status %s %s"%(oldrev, newrev) + oldrev=os.popen('git show-ref --hash refs/remotes/ftp/master').read().strip() + if not oldrev: raise IOError, "No ref" # Simulate failure if the branch doesn't exist + git_command = "git diff --name-status %s %s"%(oldrev, newrev) except IOError: # We are run for the first time, so (A)dd all files in the repo. - oldrev = None; + oldrev = None git_command = r"git ls-tree -r --name-only %s | sed -e 's/\(.*\)/A \1/'"%(newrev); add_to_change_list(changes, git_command, oldrev, newrev) -- 2.11.4.GIT