Re: [android-building] repo sync and deleted/modified files

5299 views
Skip to first unread message

Jean-Baptiste Queru

unread,
Mar 8, 2013, 10:37:13 AM3/8/13
to android-...@googlegroups.com
repo is explicitly designed to not delete your local changes during a sync.

Your first friend is "repo status": that'll list all the files in
which you've made changes.

If you are sure that you want to lose all your changes, this'll most
probably do it. It is a destructive command with no turning back:
repo forall -c 'git reset --hard ; git clean -fdx'

Another simpler approach is "rm -rf * ; repo sync -l"

JBQ

On Thu, Mar 7, 2013 at 10:19 PM, JST <jst...@gmail.com> wrote:
> I've been dabbling in editing some source code and compiling it and running
> it. I've had some success, however would like to restore my source tree to
> its original state as in the main AOSP repository. However, "repo sync"
> doesn't seem to restore some files that I have edited. Is there a way I can
> get my soruce tree back to "stock"?
>
> --
> --
> You received this message because you are subscribed to the "Android
> Building" mailing list.
> To post to this group, send email to android-...@googlegroups.com
> To unsubscribe from this group, send email to
> android-buildi...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-building?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Building" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-buildi...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Jean-Baptiste M. "JBQ" Queru
Technical Lead, Android Open Source Project, Google.

Questions sent directly to me that have no reason for being private
will likely get ignored or forwarded to a public forum with no further
warning.

Mateor

unread,
Mar 8, 2013, 12:36:33 PM3/8/13
to android-...@googlegroups.com
On 03/08/2013 11:04 AM, JST wrote:
ok, with your hints, and a bit of googling (stackoverflow: How to revert all local changes in a GIT managed project to previous state?)

I did this in terminal:

repo forall ~/WORKING_DIRECTORY/frameworks/native/services/surfaceflinger/ -c 'git checkout .'

and that restored the deleted files.

Did it again for another directory and it restored the modified files. Was scared to do your exact suggestion as it sounded very severe, and I had only made a few small changes. Very awesome of you to be so helpful in this group, JBQ. Thank you so much!


The:

rm -rf *
repo sync -l

Steps do sound severe, but actually it is a quite fast operation. You just want to be sure and run it from inside your build root, and not simply delete the entire directory in a GUI or something. But the rm -rf will leave the hidden files, so .repo will remain.

The repo sync -l is just like a regular repo sync, except without the network. So it basically just rechecks out the exact state of your tree from the .repo folder.

Try running 'repo sync -l' right now, it won't hurt and takes less than a minute. It doesn't take too much longer to run the entire sequence. I use that all the time when switching between forks or Android versions (i.e. coming from building Gingerbread back to building Jellybean.)

Jim Stein

unread,
Mar 8, 2013, 1:11:21 PM3/8/13
to android-...@googlegroups.com
well... I don't want to delete my entire /WORKING_DIRECTORY and it sounds like rm -rf * will do that. I have only modified a small number of files and all seem to be back to original state as repo status doesn't list and modified or missing files (just a couple of -- ones, which are just the automatically generated by ubuntu  ~ backup files).

repo sync -l syncs to 100% just fine, but could it be possible that there are projects that repo hasn't "found"? i.e. is the only way to know if my .repo folder isn't "correct" is to do a 'repo sync'?


--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en
 
---
You received this message because you are subscribed to a topic in the Google Groups "Android Building" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-building/QIne5MVjO7U/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to android-buildi...@googlegroups.com.

Magnus Bäck

unread,
Mar 8, 2013, 1:45:42 PM3/8/13
to android-...@googlegroups.com
On Friday, March 08, 2013 at 13:11 EST,
Jim Stein <jst...@gmail.com> wrote:

> well... I don't want to delete my entire /WORKING_DIRECTORY and it
> sounds like rm -rf * will do that.

Yes, it'll just leave .repo (and other dotfiles) alone.

> I have only modified a small number of files and all seem to be back
> to original state as repo status doesn't list and modified or missing
> files (just a couple of -- ones, which are just the automatically
> generated by ubuntu ~ backup files).
>
> repo sync -l syncs to 100% just fine, but could it be possible that
> there are projects that repo hasn't "found"? i.e. is the only way to
> know if my .repo folder isn't "correct" is to do a 'repo sync'?

What does "found" and "correct" mean? "repo sync -l" will check out all
projects listed in the currently checked out manifest. Drop "-l" and
it'll sync up all gits from the network before checking stuff out.

--
Magnus Bäck
ba...@google.com

Magnus Bäck

unread,
Mar 8, 2013, 5:34:49 PM3/8/13
to android-...@googlegroups.com
On Friday, March 08, 2013 at 16:26 EST,
JST <jst...@gmail.com> wrote:

> Sorry... I used the wrong language.
>
> When doing repo sync, it mainly does 2 things: (1) fetching projects,
> and (2) syncing work tree. So if it has an error in the fetching
> projects stage, but the syncing work tree stage had no errors, then we
> know that my local work tree is syncing with whatever is in the local
> .repo folder, but the local .repo folder isn't necessarily synced with
> the non-local AOSP repository on google's ervers. Correct?

Yes, although I'm pretty sure "repo sync" won't do the local part unless
the network part completes successfully (but you can run "repo sync -l"
manually to take care of that).

> I'm not sure what it means to "check out a manifest".

By that I mean the manifest that is checked out in .repo/manifests.
"repo init" does that for you.

> If I do repo init -u
> https://android.googlesource.com/platform/manifest -b
> android-4.2.2_r1, even if the sync has one or more errors, does that
> mean I have "checked out the manifest" and thus all I have to do is
> repo sync -l in order to check my local work tree against my local
> .repo folder?

Yes, assuming that you somehow sync all the gits that are listed in the
manifest so that .repo/projects is complete.

--
Magnus Bäck
ba...@google.com
Reply all
Reply to author
Forward
0 new messages