See list of modified files in repo folder
Absolutely! Let's break down this full command character by character and explain each flag, each component, and what it does:
π§ FULL COMMAND:
repo forall -c 'git status --short | while read status file; do echo "$(pwd)/$file"; done'β
High-Level Goal:
This command prints the absolute paths of all modified or untracked files in your current AOSP repo working tree.
π PART 1: repo forall -c '...'
repo forall -c '...'1οΈβ£ repo
repoA command-line tool provided by AOSP (Android Open Source Project) to manage multiple Git repositories under one parent tree.
2οΈβ£ forall
forallTells
repoto run a command for each project (each Git repo) in your workspace.
3οΈβ£ -c
-cShort for command.
Tells
repoto run the command you provide in single quotes'...'inside each project directory.That command will execute in the context of each project directory, i.e., the shell will
cdinto that project folder first.
π PART 2: 'git status --short | while read status file; do echo "$(pwd)/$file"; done'
'git status --short | while read status file; do echo "$(pwd)/$file"; done'This is the actual shell command run inside each Git project.
πΉ git status --short
git status --shortπΈ git
Invokes Git, the version control system.
πΈ status
Shows the current status of the working directory and staging area (like changes to tracked and untracked files).
πΈ --short
Provides output in a compact format. Each line shows:
2-character status (staged/unstaged/untracked etc.)
Followed by the relative path of the file.
π§ Example output of git status --short:
πΉ |
|This pipe symbol takes the output of the left command (
git status --short) and feeds it as input to the command on the right (while read ...).
πΉ while read status file; do ...; done
while read status file; do ...; doneπΈ while read status file; do ...; done
A shell while-loop that reads each line from the input (here from
git status --short).Each line is split into:
statusβ the first column (likeM,??, etc.)fileβ the file path (likeAndroid.bp)
π‘ read will break a line into variables separated by whitespace. So in each loop iteration:
statusholds the two-character Git statusfileholds the relative file path
πΉ echo "$(pwd)/$file"
echo "$(pwd)/$file"πΈ echo
Prints a string to stdout (terminal).
πΈ "$(pwd)/$file"
"$(pwd)":Executes the
pwdcommand (print working directory).This gives the absolute path of the current project folder being processed by
repo forall.
"$file":Appends the relative file path from
git statusoutput.
π The combined string is:
For example, if:
Current directory =
/media/shreyas/AOSP/OperatorPreferenceMenuFile =
Android.bp
Then:
π FLOW DIAGRAM SUMMARY:
repo forall -c '...'β Loop through all Git projects in AOSP workspace.Inside each project: β Run
git status --shortβ Output like:M Android.bpPipe it into
while read status file; do ... doneβ For each line, extract status and file nameFor each file: β Run
echo "$(pwd)/$file"β Prints absolute path of the modified or untracked file.
π§ͺ Example:
Let's say your repo workspace is in:
And inside OperatorPreferenceMenu, you modified Android.bp.
Then this command would output:
π Notes:
This command doesn't list unchanged files.
It only shows files that are modified (M), added (A), deleted (D), or untracked (??) in each Git repo.
You can use this to script or locate modified files across a huge AOSP tree.
Would you like a version of this command that includes the Git status symbol along with the absolute path too?
Last updated