how can I get a list of updated files when doing "repo sync"

1,061 views
Skip to first unread message

Si

unread,
Apr 19, 2011, 1:09:56 PM4/19/11
to Repo and Gerrit Discussion
Hi
I just started using repo. I wonder how can I get a list of updated
files, everytime I run "repo sync"?
Before I was using git, if I do a "git pull", it always outputs a list
of updated file, for example:

3 files changed, 1 insertions(+), 3 deletions(-)
delete mode 100644 README
create mode 100644 test.txt
How can I get the same thing with "repo sync"? Or, if there is any
other command can tell me what files are updated?

Thanks
Si

Shawn Pearce

unread,
Apr 19, 2011, 1:14:57 PM4/19/11
to Si, Repo and Gerrit Discussion

Probably something like this:

repo forall -p -c git diff --stat HEAD@{1} HEAD

Si Chen

unread,
Apr 19, 2011, 2:39:16 PM4/19/11
to Shawn Pearce, Repo and Gerrit Discussion
Shawn

Thank you for the reply. Could you briefly explain what @{1} means? I tried "repo forall -c git diff --stat HEAD@{1} HEAD", and got the following error message:

fatal: Log for 'HEAD' only has 1 entries.
fatal: ambiguous argument 'HEAD@{1}': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
fatal: ambiguous argument 'HEAD@{1}': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

Then I changed the command to "repo forall -c git diff --stat HEAD~1 HEAD", this command works fine, however it always show the diff of current version and previous version regardless of whether it is synced this time. For example, let's say I have git repository A and B in project list. Repo synced them. Then A has updates, and repo synced them again. We should only see file updates in A, however with this above command it will always show previous version of both A and B.


Thanks
Si

Magnus Bäck

unread,
Apr 20, 2011, 1:52:51 AM4/20/11
to Repo and Gerrit Discussion
On Tuesday, April 19, 2011 at 20:39 CEST,
Si Chen <si....@patterninsight.com> wrote:

> On Apr 19, 2011, at 10:14 AM, Shawn Pearce wrote:
>
> > Probably something like this:
> >
> > repo forall -p -c git diff --stat HEAD@{1} HEAD
>

> Thank you for the reply. Could you briefly explain what @{1} means?

It means the previous value of the immediately preceding ref, i.e.
it answers the question "what was HEAD before the last checkout
operation?". Quoting gitrevisions(7):

A ref followed by the suffix @ with an ordinal specification
enclosed in a brace pair (e.g. {1}, {15}) to specify the n-th
prior value of that ref. For example master@{1} is the
immediate prior value of master while master@{5} is the 5th
prior value of master. This suffix may only be used immediately
following a ref name and the ref must have an existing log
($GIT_DIR/logs/<ref>).

See also git-reflog(1).

> I tried "repo forall -c git diff --stat HEAD@{1} HEAD", and got the
> following error message:
>
> fatal: Log for 'HEAD' only has 1 entries.
> fatal: ambiguous argument 'HEAD@{1}': unknown revision or path not in the working tree.
> Use '--' to separate paths from revisions
> fatal: ambiguous argument 'HEAD@{1}': unknown revision or path not in the working tree.
> Use '--' to separate paths from revisions

That would indicate that those gits had an empty reflog, i.e. they
have not been checked out before. They could be new gits that were
just added to the manifest.

[...]

--
Magnus Bäck Opinions are my own and do not necessarily
SW Configuration Manager represent the ones of my employer, etc.
Sony Ericsson

Matthias Sohn

unread,
Apr 20, 2011, 4:52:19 AM4/20/11
to Repo and Gerrit Discussion
2011/4/20 Magnus Bäck <magnu...@sonyericsson.com>
this may have been caused by the trap [1] which causes some Gerrit versions to not configure
newly created repositories to write reflogs by default so you maybe have to configure that 
manually (check git configuration parameter core.logAllRefUpdates [2]).


--
Matthias
Reply all
Reply to author
Forward
0 new messages