Skip to content

Conversation

@Aidavdw
Copy link
Contributor

@Aidavdw Aidavdw commented Oct 17, 2025

Add functionality to display e.g. multiple artists.
Separation is done with ||, in line with the style that other popular mpc clients use (ncmpcpp, rmpc).

Example output of mpc status for a song with two artists using this fix:

Froukje || S10 - Ik Haat Hem Voor Jou
[playing] #4/4   1:27/2:35 (56%)
volume:100%   repeat: off   random: off   single: off   consume: off

Fixes #120.

@Aidavdw
Copy link
Contributor Author

Aidavdw commented Oct 17, 2025

Also tested new implementation, it correctly cuts off artists names that are too long.
Please have a look again!

{
const char *value = mpd_song_get_tag(song, tag, 0);
if (value == NULL)
return dest;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this line, song_value() returns an empty string instead of NULL when there is no tag value - did you intend to change the API contract or was this accidental?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops! That is indeed accidental.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: this line is actually more buggy than that - it returns a string that's not null-terminated, but your API docs say it's guaranteed to be null-terminated.

@Aidavdw
Copy link
Contributor Author

Aidavdw commented Oct 17, 2025

Alright, fixed the two more points you brought up.
Tested for empty tags as well, and it looks like it works as intended now.

@MaxKellermann
Copy link
Member

This looks good now - but can you please fold all fixup commits into the first commit?
Making separate commits for separate aspects is a good idea, but here it's really just fixup commits for mistakes in the first commit.

@Aidavdw
Copy link
Contributor Author

Aidavdw commented Oct 18, 2025

This looks good now - but can you please fold all fixup commits into the first commit? Making separate commits for separate aspects is a good idea, but here it's really just fixup commits for mistakes in the first commit.

Yeah! I thought github allows for a squash merge, but i can do it manually from this side as well.

@MaxKellermann
Copy link
Member

I don't use any web interface for anything (other than commenting here). I use git, not GitHub - GitHub is just a random git server.

@Aidavdw
Copy link
Contributor Author

Aidavdw commented Oct 20, 2025

I meant the git function, which is accessible from the github interface but also from git itself :)
Anyway, should be ready now.

@MaxKellermann
Copy link
Member

I meant the git function, which is accessible from the github interface but also from git itself

But that would make your job mine. And then happens what happens with your branch: just look at the confusing commit message.

"display tags with multiple values in song formatting
Allows displaying multiple artists, albums, etc.
style changes based on feedback
changed implementation of multiple tag concatenation to look more like the implementation used in ncmpc
Separated into its own function. Also changed separator to a comma.
clearly show that formatting buffer is arbitrarily sized
copy tags returns nullptr if nothing added."

When somebody looks at this commit in 10 years, what will they make from it?

@Aidavdw
Copy link
Contributor Author

Aidavdw commented Oct 20, 2025

In my humble opinion, it is not only the end result but also the process that matters, as that too can give insight into development history.
I understand now that you prefer to keep commit history to the point.

@MaxKellermann
Copy link
Member

There is no historical value in knowing what mistakes you made in commits that were never merged.
Your commit message also doesn't say what these texts mean - you did not specify that these are about unmerged stuff that was not fit for merging. You just concatenated all the fixup commit messages into one, and that long commit message does not describe the commit, it just confuses readers.

@MaxKellermann
Copy link
Member

clang found another bug in your code:

../../src/song_format.c:137:7: error: variable 'value' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
  137 |                 if (added_text != NULL) {
      |                     ^~~~~~~~~~~~~~~~~~
../../src/song_format.c:142:6: note: uninitialized use occurs here
  142 |         if (value != NULL)
      |             ^~~~~
../../src/song_format.c:137:3: note: remove the 'if' if its condition is always true
  137 |                 if (added_text != NULL) {
      |                 ^~~~~~~~~~~~~~~~~~~~~~~
../../src/song_format.c:96:19: note: initialize the variable 'value' to silence this warning
   96 |         const char *value;
      |                          ^
      |                           = NULL

And indeed, you forgot to initialize the variable in one code path.

@Aidavdw
Copy link
Contributor Author

Aidavdw commented Oct 20, 2025

Good catch. Curious, seems to not have been detected on my machine.
Added the initialisation.

@MaxKellermann
Copy link
Member

Unit tests fail.

@MaxKellermann
Copy link
Member

GH actions currently doesn't show details about the unit test failures; I just pushed a change that prints those details. Next time you push, rebase first!

@Aidavdw Aidavdw force-pushed the master branch 2 times, most recently from cdbce69 to 969c928 Compare October 20, 2025 10:01
@Aidavdw
Copy link
Contributor Author

Aidavdw commented Oct 20, 2025

rebased an fixed error that caused it to fail.

@MaxKellermann
Copy link
Member

Good to have unit tests - it caught another mistake.
Since you implemented a new feature, it would be very useful to have a unit test for that. Can you add tests, please? Should be in the same commit.

Replaced existing functionality that only took the first found tag with
a function that concatenates all the found tags with a comma delimiter.
Allows displaying multiple artists, albums, etc.
Function implemetation mostly based on the one in ncmpc.
@Aidavdw
Copy link
Contributor Author

Aidavdw commented Oct 20, 2025

Added unit test.

@MaxKellermann MaxKellermann merged commit 8963a55 into MusicPlayerDaemon:master Oct 20, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mpc only prints the first artist tag

2 participants