<feed xmlns='http://www.w3.org/2005/Atom'>
<title>tools/git-repo.git/project.py, branch v2.65</title>
<subtitle>Mirror of gerrit.googlesource.com/git-repo</subtitle>
<id>https://git.enea.com/cgit/tools/git-repo.git/atom?h=v2.65</id>
<link rel='self' href='https://git.enea.com/cgit/tools/git-repo.git/atom?h=v2.65'/>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/'/>
<updated>2026-06-30T20:20:15+00:00</updated>
<entry>
<title>sync: Implement fetchcmd for standard Git layouts</title>
<updated>2026-06-30T20:20:15+00:00</updated>
<author>
<name>Gavin Mak</name>
<email>gavinmak@google.com</email>
</author>
<published>2026-06-15T23:23:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=ead4b2d7aa86fde803066f59c1dda94aefe2b9fe'/>
<id>urn:sha1:ead4b2d7aa86fde803066f59c1dda94aefe2b9fe</id>
<content type='text'>
Introduce support for `repo.fetchcmd` configuration, allowing users to
specify a custom command to fetch project data instead of
`_RemoteFetch`.

When `repo.fetchcmd` is specified, `repo` will execute it instead of
`_RemoteFetch` during the network half of sync. Note that
`repo.fetchcmd` requires `repo.uselocalgitdirs` to be enabled.

The command is executed in a subshell with project-context environment
variables, including the new `REPO_TREV` (target revision resolved to a
commit hash) and `REPO_PROJECT_FETCH_URL`.

After execution, `repo` verifies that the target commit is available and
that the tracking ref and FETCH_HEAD are correctly updated.

Tested with:
```
&gt; ~/git-repo/repo init -u https://android-review.googlesource.com/platform/manifest \
    --repo-url file:///usr/local/google/home/gavinmak/git-repo \
    --groups developers \
    --no-repo-verify \
    --use-local-gitdirs
...

&gt; git config --file .repo/manifests.git/config repo.fetchcmd 'mkdir -p $REPO_PATH &amp;&amp; cd $REPO_PATH &amp;&amp; if [ ! -d .git ]; then git init &amp;&amp; git remote add aosp $REPO_PROJECT_FETCH_URL; fi &amp;&amp; git fetch aosp $REPO_TREV &amp;&amp; git reset --hard $REPO_TREV &amp;&amp; mkdir -p .git/refs/remotes/aosp &amp;&amp; echo $REPO_TREV &gt; .git/refs/remotes/aosp/main &amp;&amp; echo $REPO_TREV &gt; .git/FETCH_HEAD'

&gt; ~/git-repo/repo sync -j32
warning: repo is not tracking a remote branch, so it will not receive updates; run `repo init --repo-rev=stable` to fix.
You are currently enrolled in Git submodules experiment (go/android-submodules-quickstart).  Use --no-use-superproject to override.

Syncing: 100% (4/4), done in 1m15.686s
Finalizing sync state...
repo sync has finished successfully.
```

Bug: 513329573
Change-Id: I754d3f3c78e86fdeee1a72115297a75b571bc497
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/583883
Reviewed-by: Becky Siegel &lt;beckysiegel@google.com&gt;
Tested-by: Gavin Mak &lt;gavinmak@google.com&gt;
Commit-Queue: Gavin Mak &lt;gavinmak@google.com&gt;
</content>
</entry>
<entry>
<title>status: Show ahead/behind info for local branches</title>
<updated>2026-06-30T18:13:14+00:00</updated>
<author>
<name>Brian Gan</name>
<email>brgan@google.com</email>
</author>
<published>2026-06-29T20:15:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=e7cac4bca6b8e4276a5a64287653b5c56555d6f4'/>
<id>urn:sha1:e7cac4bca6b8e4276a5a64287653b5c56555d6f4</id>
<content type='text'>
When viewing `repo status`, it is difficult to distinguish between branches that have active unpushed changes and stale branches that are fully synced. Previously, developers had to run commands like `repo forall -c "git status"` to see their ahead/behind counts.

This change updates Project.PrintWorkTreeStatus to automatically calculate and display the number of commits a branch is ahead and/or behind its upstream tracking branch. We use `git rev-list --left-right --count` to fetch this information natively and efficiently.

If the branch is completely synced with upstream, no extra text is shown.

Added tests for ahead-only, behind-only, diverged, no-tracking, and fully-synced branch states.

Bug: 319412954
Change-Id: I23879b2d472c7a7e11d01b565428a84b1b4f09c1
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/602423
Reviewed-by: Gavin Mak &lt;gavinmak@google.com&gt;
Tested-by: Brian Gan &lt;brgan@google.com&gt;
Commit-Queue: Brian Gan &lt;brgan@google.com&gt;
</content>
</entry>
<entry>
<title>info: Report actual checked-out HEAD revision</title>
<updated>2026-06-29T17:50:02+00:00</updated>
<author>
<name>Gavin Mak</name>
<email>gavinmak@google.com</email>
</author>
<published>2026-06-22T22:36:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=88a7e88e54d27f8d6068ba3d86fe61c291ab76a5'/>
<id>urn:sha1:88a7e88e54d27f8d6068ba3d86fe61c291ab76a5</id>
<content type='text'>
When `repo info` runs, the reported "Current revision" is resolved using
the manifest's target branch tracking ref (e.g. refs/remotes/goog/main).

Introduce Project.GetHeadRevisionId(), which gets the checked-out HEAD
commit in the worktree, and use it in `repo info` with a fallback to the
old behavior if the project is not checked out.

Bug: 526685287
Change-Id: I72280ce27daa210cada27d722a94e365644f06e0
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/599481
Reviewed-by: Brian Gan &lt;brgan@google.com&gt;
Commit-Queue: Gavin Mak &lt;gavinmak@google.com&gt;
Tested-by: Gavin Mak &lt;gavinmak@google.com&gt;
</content>
</entry>
<entry>
<title>git_config: Support SHA-256 object IDs</title>
<updated>2026-06-26T22:40:55+00:00</updated>
<author>
<name>Gavin Mak</name>
<email>gavinmak@google.com</email>
</author>
<published>2026-06-23T22:47:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=c21a41c7ccc0350841cb57733f845dd2054bd285'/>
<id>urn:sha1:c21a41c7ccc0350841cb57733f845dd2054bd285</id>
<content type='text'>
Update ID_RE to match both 40-char (SHA-1) and 64-char (SHA-256) IDs as
part of Git 3.0 support.

Bug: 483758905
Change-Id: Ie5d9a2a5df4c6e7adda7f1d89f1bfb7724846057
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/600341
Reviewed-by: Brian Gan &lt;brgan@google.com&gt;
Tested-by: Gavin Mak &lt;gavinmak@google.com&gt;
Reviewed-by: Mike Frysinger &lt;vapier@google.com&gt;
Commit-Queue: Gavin Mak &lt;gavinmak@google.com&gt;
</content>
</entry>
<entry>
<title>project: fix sync of shallow projects sharing objdir</title>
<updated>2026-06-25T22:28:46+00:00</updated>
<author>
<name>Sainath Varanasi</name>
<email>varanasisai@google.com</email>
</author>
<published>2026-06-25T22:09:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=3af9e2f1462a13a3e344b4fd2e6ed6c4f5403f72'/>
<id>urn:sha1:3af9e2f1462a13a3e344b4fd2e6ed6c4f5403f72</id>
<content type='text'>
Repo sync fails when the following conditions are met:

* There are several checkouts of the same project
  in different paths.
* The checkouts are using git hashes as revisions
  (not branches).
* There is a clone-depth set on these projects.
* sync-c="true" is set in the manifest.
* The revision specified in the manifest
  has moved forward since the first repo init.

The sync fails because only the first gitdir gets the "shallow" file,
and subsequent dirs can't be synced.

Do not optimize away the fetch when the conditions above happen.

Simplified the boolean check in Sync_NetworkHalf and _RemoteFetch
using has_shallow, renamed loop variable to avoid shadowing.

Test: create a manifest matching conditions above, repo init,
forward the hash, and repo sync.
Test: added tests in test_project.py
Bug: 505072873
Originally-by: Elvira Khabirova &lt;elvira.khabirova@volvocars.com&gt;

Change-Id: I37c533c382e34fc5ddab489c5593b9e5d3875be2
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/601441
Tested-by: Sainath Varanasi &lt;varanasisai@google.com&gt;
Reviewed-by: Gavin Mak &lt;gavinmak@google.com&gt;
Commit-Queue: Sainath Varanasi &lt;varanasisai@google.com&gt;
</content>
</entry>
<entry>
<title>project: Add REPO_PROJECT_FETCH_URL environment variable</title>
<updated>2026-06-16T17:30:47+00:00</updated>
<author>
<name>Gavin Mak</name>
<email>gavinmak@google.com</email>
</author>
<published>2026-06-15T23:22:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=cd307a6089f136e8f4f0fe85ce0393782cf99af1'/>
<id>urn:sha1:cd307a6089f136e8f4f0fe85ce0393782cf99af1</id>
<content type='text'>
Add REPO_PROJECT_FETCH_URL to Project.GetEnvVars(), which resolves to
the remote fetch URL of the project. This is useful for exposing the
URL to custom fetch commands or other external scripts.

Bug: 513329573
Change-Id: Ic2b0a83493934d16bb1152366ee4e1a2c35ea2dc
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/596121
Tested-by: Gavin Mak &lt;gavinmak@google.com&gt;
Reviewed-by: Mike Frysinger &lt;vapier@google.com&gt;
Commit-Queue: Gavin Mak &lt;gavinmak@google.com&gt;
</content>
</entry>
<entry>
<title>project: handle corrupted projects in DeleteWorktree</title>
<updated>2026-06-05T16:16:22+00:00</updated>
<author>
<name>Gavin Mak</name>
<email>gavinmak@google.com</email>
</author>
<published>2026-06-04T21:54:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=f7a24df00cdde9b1c2d51e5d0b03e8a36d655f76'/>
<id>urn:sha1:f7a24df00cdde9b1c2d51e5d0b03e8a36d655f76</id>
<content type='text'>
Catch GitError from IsDirty() during DeleteWorktree so corrupted
projects can be cleanly wiped instead of crashing.

Bug: 515415221
Change-Id: Ic03ae77c30a722f9aa06f2220747251e0aea4ab7
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/591001
Commit-Queue: Gavin Mak &lt;gavinmak@google.com&gt;
Reviewed-by: Mike Frysinger &lt;vapier@google.com&gt;
Tested-by: Gavin Mak &lt;gavinmak@google.com&gt;
</content>
</entry>
<entry>
<title>project: Extract project envvar generation to GetEnvVars</title>
<updated>2026-05-27T19:58:02+00:00</updated>
<author>
<name>Gavin Mak</name>
<email>gavinmak@google.com</email>
</author>
<published>2026-05-26T18:10:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=e0bd39c691e365ce1988e1f727ddf8b37637599c'/>
<id>urn:sha1:e0bd39c691e365ce1988e1f727ddf8b37637599c</id>
<content type='text'>
Move project environment variable setup from subcmds/forall.py to a
reusable Project.GetEnvVars() helper method.

Bug: 513329573
Change-Id: I3b4b113aa5a086e5fa5eaf4461c7ce517d928610
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/583881
Tested-by: Gavin Mak &lt;gavinmak@google.com&gt;
Commit-Queue: Gavin Mak &lt;gavinmak@google.com&gt;
Reviewed-by: Mike Frysinger &lt;vapier@google.com&gt;
</content>
</entry>
<entry>
<title>sync: Skip copyfile/linkfile for unavailable projects</title>
<updated>2026-05-27T17:36:32+00:00</updated>
<author>
<name>Xin Li</name>
<email>delphij@google.com</email>
</author>
<published>2026-05-26T22:52:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=c883613e317561579e164a7d92ea4347d502b86d'/>
<id>urn:sha1:c883613e317561579e164a7d92ea4347d502b86d</id>
<content type='text'>
Commit 5534f16 made UpdateCopyLinkfileList to retry _CopyAndLinkFiles
for all projects in the manifest to handle directory-to-symlink
transistions. However, for partial sync's (e.g. repo sync &lt;project&gt;),
projects not included in the sync may not have their local directories
populated, attempts to perform the operation on unavailable projects
would result in dangling symlinks, or errors like:

error: Cannot copy file &lt;source&gt; to &lt;destination&gt;

Fix this by adding a check inside _CopyAndLinkFiles in project.py to
so these operations happen only when the project's worktree exists
and is a directory.

TAG=agy
CONV=90f5fca7-2199-4017-8f62-a010b0ab1dbf

Change-Id: I9ae1e8d62d8fd129cb4535e574c38339c87af441
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/587501
Reviewed-by: Mike Frysinger &lt;vapier@google.com&gt;
Tested-by: Xin Li &lt;delphij@google.com&gt;
</content>
</entry>
<entry>
<title>init: Add --use-local-gitdirs for standard Git layouts</title>
<updated>2026-05-26T17:26:25+00:00</updated>
<author>
<name>Gavin Mak</name>
<email>gavinmak@google.com</email>
</author>
<published>2026-04-03T01:11:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=b8531133deb053b333a3e90ce3b91a6f448b034e'/>
<id>urn:sha1:b8531133deb053b333a3e90ce3b91a6f448b034e</id>
<content type='text'>
Introduce --use-local-gitdirs to bypass repo's symlink-based layouts in
favor of standard local .git directories.

Bug: 513329573
Bug: 508146070
Change-Id: I53d1602e61be0b86964529bcbea3dc801471f9c9
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/569001
Tested-by: Gavin Mak &lt;gavinmak@google.com&gt;
Commit-Queue: Gavin Mak &lt;gavinmak@google.com&gt;
Reviewed-by: Dan Willemsen &lt;dwillemsen@google.com&gt;
</content>
</entry>
</feed>
