From 9fcfe17b049dd25fcc01b34683b593eb0c5e258c Mon Sep 17 00:00:00 2001
From: Eric Cronin <ecronin@macports.org>
Date: Sat, 15 Oct 2011 11:54:31 -0400
Subject: [PATCH] Add support for git managed portdirs
A little fragile on conflicts currently, but shouldn't lose data
due to git's protections
---
base/src/macports1.0/macports.tcl | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/base/src/macports1.0/macports.tcl b/base/src/macports1.0/macports.tcl
index 7a157ad..104b11c 100644
a
|
b
|
proc mportsync {{optionslist {}}} { |
1974 | 1974 | {^file$} { |
1975 | 1975 | set portdir [macports::getportdir $source] |
1976 | 1976 | set svn_cmd "" |
| 1977 | set git_cmd "" |
1977 | 1978 | catch {set svn_cmd [macports::findBinary svn]} |
| 1979 | catch {set git_cmd [macports::findBinary git]} |
1978 | 1980 | if {$svn_cmd != "" && ([file exists $portdir/.svn] || ![catch {exec $svn_cmd info $portdir > /dev/null 2>@1}])} { |
1979 | 1981 | set svn_commandline "$svn_cmd update --non-interactive ${portdir}" |
1980 | 1982 | ui_debug $svn_commandline |
… |
… |
proc mportsync {{optionslist {}}} { |
1999 | 2001 | incr numfailed |
2000 | 2002 | continue |
2001 | 2003 | } |
| 2004 | } elseif {$git_cmd != "" && ![catch {exec sh -c "cd ${portdir} && $git_cmd rev-parse --is-inside-work-tree"} result]} { |
| 2005 | # determine what type of git repository this is |
| 2006 | if {![catch {exec sh -c "cd ${portdir} && $git_cmd config --local --get svn-remote.svn.url"} result]} { |
| 2007 | set git_action "svn rebase" |
| 2008 | } else { |
| 2009 | set git_action "pull" |
| 2010 | } |
| 2011 | set git_commandline "cd ${portdir}; $git_cmd stash save; $git_cmd $git_action; $git_cmd stash pop" |
| 2012 | ui_debug $git_commandline |
| 2013 | if { |
| 2014 | [catch { |
| 2015 | if {[getuid] == 0} { |
| 2016 | set euid [geteuid] |
| 2017 | set egid [getegid] |
| 2018 | ui_debug "changing euid/egid - current euid: $euid - current egid: $egid" |
| 2019 | setegid [name_to_gid [file attributes $portdir -group]] |
| 2020 | seteuid [name_to_uid [file attributes $portdir -owner]] |
| 2021 | } |
| 2022 | system $git_commandline |
| 2023 | if {[getuid] == 0} { |
| 2024 | seteuid $euid |
| 2025 | setegid $egid |
| 2026 | } |
| 2027 | }] |
| 2028 | } { |
| 2029 | ui_debug "$::errorInfo" |
| 2030 | ui_error "Synchronization of the local ports tree failed doing a git update" |
| 2031 | incr numfailed |
| 2032 | continue |
| 2033 | } |
2002 | 2034 | } |
| 2035 | |
2003 | 2036 | set needs_portindex 1 |
2004 | 2037 | } |
2005 | 2038 | {^mports$} { |