On Fri, Feb 5, 2010 at 10:23 AM, Timur Tabi <timur@xxxxxxxxxxxxx> wrote: > Is there a way for me to tell if a particular file in my repository > has an update in the upstream repository? Thanks to everyone who replied. Here's what I came up with: def check_for_updates(): # Get the path to our script. This should be a git repository. script_path = os.path.dirname(os.path.realpath(__file__)) # Determine the upstream URL p = subprocess.Popen(['git', 'config', '-f', script_path + '/.git/config', '--get', 'remote.origin.url'], shell=False, stdout=subprocess.PIPE, stderr=open(os.devnull, 'w')) url = p.communicate()[0].strip() if not url: # The script is not running from a git repository return # Determine the HEAD of the upstream repository p = subprocess.Popen(['git', 'ls-remote', url, 'HEAD'], shell=False, stdout=subprocess.PIPE, stderr=open(os.devnull, 'w')) sha = p.communicate()[0].split() if not sha: # Something is wrong with the upstream repository return sha = sha[0] # The SHA of the upstream head # Check if the remote SHA is in the local repository. # git --git-dir=/home/b04825/bin/.git show-ref HEAD p = subprocess.Popen(['git', '--git-dir=' + script_path + '/.git', 'log', '-1', sha], shell=False, stdout=subprocess.PIPE, stderr=open(os.devnull, 'w')) if not p.communicate()[0]: # If we can't find the SHA locally, then it means that the local # repository is out of date. We pretend that it means that this script # is out of date. print 'There is an update for this script available. Please pull from the remote' print 'repository (e.g. "cd %s; git pull")' % script_path -- Timur Tabi Linux kernel developer at Freescale -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html