{"thread":{"id":"63940","subject":"[BUG] git credential url field ordering/documentation issue","startedAt":"2025-08-11T11:19:36Z","lastAt":"2025-08-11T11:19:36Z","messageCount":1,"participants":["Muhammad Fahri Muharram"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"523922","messageId":"CACEVnOLzZkR_oELBFg2Wfu83cos8VRCNprx3Vad_wtDncFPQtw@mail.gmail.com","threadId":"63940","inReplyTo":null,"subject":"[BUG] git credential url field ordering/documentation issue","fromName":"Muhammad Fahri Muharram","fromEmail":"mfahrim7@gmail.com","sentAt":"2025-08-11T11:19:24Z","receivedAt":"2025-08-11T11:19:36Z","isPatch":false,"sender":{"key":"mfahrim7@gmail.com","avatar":null},"body":"In git credential source code, whenever an url field is encountered it\nwill call credential_from_url_1 which will then call credential_clear\non the credential struct.\nhttps://github.com/git/git/blob/master/credential.c#L625\n\nThis means the credential struct is cleared whenever a url= line is\nprocessed, but the documentation does not mention that the url field\nmust be placed before other fields to avoid wiping them.\n\nThis causes confusing behaviour:\n\n$ printf \"host=github.com\\nusername=A\\nprotocol=https\" | git credential approve\n$ printf \"username=A\\nurl=https://github.com\" | git credential fill\nPassword for 'https://SeeStarz@github.com':\nprotocol=https\nhost=github.com\nusername=SeeStarz\npassword=\n$ printf \"url=https://github.com\\nusername=A\" | git credential fill\nprotocol=https\nhost=github.com\nusername=A\npassword=B\n\nOn the second command, due to username being wiped, git credential\nfill defaults to using ~/.gitconfig which in my case uses the username\nSeeStarz.\nThe expected behaviour is that both invocations of git credential fill\nshow username=A and password=B.\nPlease consider clarifying this behavior in the documentation or\nadjusting the implementation to avoid this surprising side effect.\n\nThank you.\n"}]}