Skip to content

Commit

Permalink
compare: always prefix git status output with manifest-rev
Browse files Browse the repository at this point in the history
It's not unusual to make "quick and dirty", temporary changes in a git
repo or to add some untracked files without creating a branch. As
expected, this makes the repository show in `west compare`. If such
repos and the manifest repo are the only repos appearing in the `west
compare` output, then no manifest-rev + HEAD banner ever appeared. When
no banner ever appears it's really not obvious which repos are on the
manifest-rev vs not. In other words: the main compare feature is not
obvious!

Clear this doubt by always showing the banner, even when `HEAD` and
`manifest-rev` are the same. See sample output below.

I think the original design idea was to follow diff's "spirit" not to
show anything that's identical and to save as many lines as
possible. However I don't think it works in this particular case because
invoking `git status` for a repo _without_ showing where its HEAD is at
is way too subtle, _especially_ when there is no other repo with a
banner to provide a comparison point and some contrast. Explicitly and
consistently prefixing every `git status` output with a manifest-rev
banner is much more clear and obvious.

Moreover, `git status` output is relatively verbose already so always
prefixing it with a 2 lines long banner makes negligible difference to
the total.

Before:
```
$ west compare

=== hal_xtensa (modules/hal/xtensa):
--- status:
    HEAD detached at 41a631d4aeee
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
         some_new_file

    nothing added to commit but untracked files present (use "git add"...
```

After:
```
$ west compare

=== hal_xtensa (modules/hal/xtensa):
--- manifest-rev: 41a631d4aeee (upstream/master, master) cmake:...
            HEAD: 41a631d4aeee (upstream/master, master) cmake:...
--- status:
    HEAD detached at 41a631d4aeee
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
         some_new_file

    nothing added to commit but untracked files present (use "git add"...
```

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
  • Loading branch information
marc-hb committed Jun 23, 2023
1 parent 9e8f500 commit 9415f37
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,8 @@ def rev_info(rev):
head_info = rev_info('HEAD')
# If manifest-rev is missing, we already failed earlier.
manifest_rev_info = rev_info('manifest-rev')
if head_info != manifest_rev_info:
self.small_banner(f'manifest-rev: {manifest_rev_info}')
self.inf(f' HEAD: {head_info}')
self.small_banner(f'manifest-rev: {manifest_rev_info}')
self.inf(f' HEAD: {head_info}')

def print_status(self, project):
# `git status` shows `manifest-rev` "sometimes", see #643.
Expand Down

0 comments on commit 9415f37

Please sign in to comment.