diff mbox

committed: [Re: [PATCH] gcc_update: support updating a git clone]

Message ID 20100615084241.GA24914@mx.loc
State New
Headers show

Commit Message

Bernhard Reutner-Fischer June 15, 2010, 8:42 a.m. UTC
On Tue, May 18, 2010 at 11:11:32PM +0200, Bernhard Reutner-Fischer wrote:
>On Sat, Mar 13, 2010 at 11:54:35AM +0100, Bernhard Reutner-Fischer wrote:
>>contrib/ChangeLog:
>>
>>2010-03-13  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
>>
>>	* gcc_update: Support updating a git clone.
>>
>>Ok for trunk?
>
>Revised patch attached, Changelog remains the same.
>Ok for trunk?

Incorporated Paolo's comments in
http://gcc.gnu.org/ml/gcc-patches/2010-06/msg00143.html
and committed the attached as revision 160774.

thanks,

Comments

Andrew Pinski June 15, 2010, 2:52 p.m. UTC | #1
I think gcc_update should do the stash automatically or at least git  
should do the merges just like svn and cvs does. This is my bigest  
reason why I have not moved over to git. I might be working on a patch  
which I don't want to commit to my local tree until after I do an  
update because I know some infrastrure has changed right after I  
started. And I don't need revision control on that version.

Sent from my iPhone

On Jun 15, 2010, at 1:42 AM, Bernhard Reutner-Fischer <rep.dot.nop@gmail.com 
 > wrote:

> On Tue, May 18, 2010 at 11:11:32PM +0200, Bernhard Reutner-Fischer  
> wrote:
>> On Sat, Mar 13, 2010 at 11:54:35AM +0100, Bernhard Reutner-Fischer  
>> wrote:
>>> contrib/ChangeLog:
>>>
>>> 2010-03-13  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
>>>
>>>    * gcc_update: Support updating a git clone.
>>>
>>> Ok for trunk?
>>
>> Revised patch attached, Changelog remains the same.
>> Ok for trunk?
>
> Incorporated Paolo's comments in
> http://gcc.gnu.org/ml/gcc-patches/2010-06/msg00143.html
> and committed the attached as revision 160774.
>
> thanks,
> <gcc-applied-controb-gcc_update-git.patch>
Paolo Bonzini June 15, 2010, 3:04 p.m. UTC | #2
On 06/15/2010 04:52 PM, Andrew Pinski wrote:
> I think gcc_update should do the stash automatically or at least git
> should do the merges just like svn and cvs does.

This patch does do that, as it uses "git pull --rebase".  But doing both 
rebasing _and_ stashing is a mess, since rebasing might fail and then 
you remain with stuff that you have to pop manually at the end.  Also, 
"git stash pop" doesn't drop the stash entry if there are conflicts, so 
it's better not to call it from scripts IMNSHO.

> I might be working on a patch
> which I don't want to commit to my local tree until after I do an update
> because I know some infrastrure has changed right after I started.

So what?  You'll get conflicts in the same way no matter if you stash, 
rebase, or merge.

> And I don't need revision control on that version.

Then use "git commit --amend" or "git reset --soft origin/master" right 
after gcc_update.

Paolo
diff mbox

Patch

Index: contrib/gcc_update
===================================================================
--- contrib/gcc_update	(revision 160773)
+++ contrib/gcc_update	(working copy)
@@ -245,8 +245,13 @@ 
 
 esac
 
+is_git=0
 # Check whether this indeed looks like a local SVN tree.
-if [ ! -d .svn ]; then
+if [ -d .git ]; then
+    GCC_GIT=${GCC_GIT-${GIT-git}}
+    GCC_SVN="true -"
+    is_git=1
+elif [ ! -d .svn ]; then
     echo "This does not seem to be a GCC SVN tree!"
     exit
 fi
@@ -258,6 +263,7 @@ 
     set -- $UPDATE_OPTIONS ${1+"$@"}
 fi
 
+if [ $is_git -eq 0 ]; then
 chat "Updating SVN tree"
 
 $GCC_SVN ${silent+-q}  --non-interactive update ${1+"$@"}
@@ -283,4 +289,27 @@ 
 
 echo "[$branch revision $revision]" > gcc/REVISION
 
+else
+    chat "Updating GIT tree"
+    $GCC_GIT diff --quiet --exit-code HEAD
+    if [ $? -ne 0 ]; then
+        echo "Attempting to update a dirty git tree!" >&2
+        echo "Commit or stash your changes first and retry." >&2
+        exit 1
+    fi
+    $GCC_GIT pull ${silent+-q} --rebase ${1+"$@"}
+    if [ $? -ne 0 ]; then
+        (touch_files_reexec)
+        echo "git pull of full tree failed." >&2
+        exit 1
+    fi
+    rm -f LAST_UPDATED gcc/REVISION
+    revision=`$GCC_GIT log -n1 --pretty=%p:%t:%H`
+    branch=`$GCC_GIT name-rev --name-only HEAD || :`
+    {
+      date
+      echo "`TZ=UTC date` (revision $revision)"
+    } > LAST_UPDATED
+    echo "[$branch revision $revision]" > gcc/REVISION
+fi
 touch_files_reexec