%^&^*%*&^% Git.



  • So I work at a company that uses VSTS and Git. Hopefully this title will be sufficiently offensive that people will come in here and tell me that my problem is, in fact, easy to solve, despite no amount of Googling making a dent.

    Goal: Clone 4 branches to specific locations through powershell, and then delete the folders thus created after running another thing on them.

    Problem: Git launches a UI WINDOW to log in, which I cannot do anything about, even when run from command line. This would be fine, but I'm doing this on the build server: it must not happen.

    What Other People Say:

    • "Oh, just install GCMFW and ..." - no. This is the build server. I don't want to mess anything up.
    • "Well you can run this command to globally disable logins." - yeah, great, it doesnt even work, and again, this is a build server. I don't want it to break.

    What would be best:
    An argument that makes git not spawn dialogs. It doesn't need to, it has login capabilities. But only if you close the stupid dialog.

    Git is the worst.



  • @Magus said in %^&^*%*&^% Git.:

    tell me that my problem is, in fact, easy to solve

    Of course it is. With 2434323 command line arguments, you can do ANYTHING in git!



  • @dcon So I hear.


  • Discourse touched me in a no-no place

    I can’t wait for git to be bought by Oracle.... that will up the fuckery level by 100....



  • I don't really know VSTS or whatever your environment is, but I doubt Git itself is popping up UI windows.
    I bet the very thought itself is sending shivers down Beardo mcLinux's spine.

    Rather, I bet the .gitconfig defines a program (perhaps as the credential.helper?) which is responsible for the rogue UI.
    Go find it and yell at it instead.


  • Java Dev

    @CHUDbert said in %^&^*%*&^% Git.:

    I can’t wait for git to be bought by Oracle.... that will up the fuckery level by 100....

    Does git even have a managing company owning copyrights &c which would make that possible?



  • @CreatedToDislikeThis said in %^&^*%*&^% Git.:

    Rather, I bet the .gitconfig defines a program (perhaps as the credential.helper?) which is responsible for the rogue UI.
    Go find it and yell at it instead.

    Did you read the OP? Yes, good job, you have noticed that its in some global place! I don't want to edit that, because this is a build server and not my local machine. What I want is a switch that says, "Hey, if something tells you to open a window, how about don't, okay?" - because if you close that window, the login prompt appears in the command line.


  • kills Dumbledore

    How about a GUI automation script to wait for a window with a specific title to open and close it immediately?



  • @Jaloopa I'm loving working with open source software that is more powerful than what I previously had, and doesn't require hacks for what should be basic functionality.


  • Java Dev

    @Magus If you weren't on windows I'd tell you to unset $DISPLAY.



  • @Magus Instead of a single commandline, how about a line of PowerShell to flip the "show a login dialog" settings, then a second to run Git?

    I believe most/all Git settings can be changed with git config --global "setting-name"



  • @blakeyrat Because I tried that and it did nothing. Well, at least the boolean one. I may have to try the "Go edit the global config and set this one value to 'None'" method, and then turn it back... I really don't like the idea of that, though.


  • ♿ (Parody)

    @Magus said in %^&^*%*&^% Git.:

    @blakeyrat Because I tried that and it did nothing. Well, at least the boolean one. I may have to try the "Go edit the global config and set this one value to 'None'" method, and then turn it back... I really don't like the idea of that, though.

    I've never used git on Windows but that seems like a perfectly reasonable sort of setting to change on a build server, although I'm not sure why you'd want to "set it back." But maybe "build server" means something unusual here.



  • @CHUDbert said in %^&^*%*&^% Git.:

    I can’t wait for git to be bought by Oracle.... that will up the fuckery level by 100....

    The nope thread is :arrows:



  • @Magus said in %^&^*%*&^% Git.:

    Because I tried that and it did nothing.

    Can you step through the script and verify it didn't change the setting? Because that's very odd.


  • Fake News

    @Magus said in %^&^*%*&^% Git.:be

    So I work at a company that uses VSTS and Git. Hopefully this title will be sufficiently offensive that people will come in here and tell me that my problem is, in fact, easy to solve, despite no amount of Googling making a dent.
    Goal: Clone 4 branches to specific locations through powershell, and then delete the folders thus created after running another thing on them.

    Are you also running that powershell script from a VSTS build / release job? If yes, does your build job get its sources from VSTS' git repos? In that case you could look into git submodules if those other git repos are always needed to do a build and would actually be cloned locally as well. It's then only a case of checking the "update git submodules" in the build and VSTS will take care of everything as long as those submodule definitions are correct. Submodules will never automatically track branches though, they're fixed to a given commit until someone points to another commit.

    If that scenario has too many drawbacks but we are still talking about a build / release job then you might want to enable the "Allow scripts to access OAuth token" option. This OAuth token should have full access to pretty much anything in VSTS for the duration of the build, and it should be stuffed into an environment variable which you can access from PowerShell using $env:SYSTEM_ACCESSTOKEN.

    It's been a while since I last looked at the logs of a build job during the "Getting Sources" phase, but I'm quite sure that you can then use that token to get some more Git sources by doing git clone "https://vsts:$env:SYSTEM_ACCESSTOKEN@myvstssite.visualstudio.com/_git/somethingsomething". Please check one of your own build logs to see if the username matters, though IIRC it didn't.


  • Notification Spam Recipient

    @Magus said in %^&^*%*&^% Git.:

    Hopefully this title will be sufficiently offensive that people will come in here and tell me that my problem is

    From the title I assumed your prompt variable was broke. But I'll read the rest of your post anyways.


  • Notification Spam Recipient

    @Magus said in %^&^*%*&^% Git.:

    Git launches a UI WINDOW to log in,

    Wat



  • @JBert said in %^&^*%*&^% Git.:

    Are you also running that powershell script from a VSTS build / release job?

    Yes.

    @JBert said in %^&^*%*&^% Git.:

    If yes, does your build job get its sources from VSTS' git repos?

    Yes, but these are separate repos.

    @JBert said in %^&^*%*&^% Git.:

    In that case you could look into git submodules if those other git repos are always needed to do a build and would actually be cloned locally as well.

    Normally they'd be totally independent. This is a special case.

    @JBert said in %^&^*%*&^% Git.:

    Submodules will never automatically track branches though, they're fixed to a given commit until someone points to another commit.

    Yeah, that wouldn't be what I want, then.

    @JBert said in %^&^*%*&^% Git.:

    It's been a while since I last looked at the logs of a build job during the "Getting Sources" phase, but I'm quite sure that you can then use that token to get some more Git sources by doing git clone "https://vsts:$env:SYSTEM_ACCESSTOKEN@myvstssite.visualstudio.com/_git/somethingsomething". Please check one of your own build logs to see if the username matters, though IIRC it didn't.

    THAT sounds like exactly what I need. I'll try it.


  • Considered Harmful

    @PleegWat I'm pretty sure it's got a copyleft enough license to make that unpossible. small mercies.



  • @JBert said in %^&^*%*&^% Git.:

    It's been a while since I last looked at the logs of a build job during the "Getting Sources" phase, but I'm quite sure that you can then use that token to get some more Git sources by doing git clone "https://vsts:$env:SYSTEM_ACCESSTOKEN@myvstssite.visualstudio.com/_git/somethingsomething". Please check one of your own build logs to see if the username matters, though IIRC it didn't.

    So, the environment variable doesn't work, but I generated an access token that seems to... now I'm having trouble with directory stuff, but I'll get it figured out. Thanks!


  • Fake News

    @Magus You're welcome.

    More advice though: did you enable the "Allow access to OAuth token from build" option I mentioned? While it's also possible that the name of the environment variable is slightly different, I would think that the VSTS devs would be reluctant to change it as it would break lots of builds.

    Also, a generated token might work for now but don't forget that they tend to have a time limit and are coupled to an account. Sooner or later they will stop working so I tend to prefer those temporary build-specific tokens as they keep on working by virtue of being a new one every time.



  • @JBert Trying that now, since yeah, it'd only last a year otherwise.


  • 🚽 Regular

    This post is deleted!

  • Winner of the 2016 Presidential Election

    @Magus said in %^&^*%*&^% Git.:

    @blakeyrat Because I tried that and it did nothing. Well, at least the boolean one. I may have to try the "Go edit the global config and set this one value to 'None'" method, and then turn it back... I really don't like the idea of that, though.

    I see that you already found a workaround, but for future reference: there are multiple levels of settings, with later ones overriding earlier ones in this order:

    1. --system (at $(prefix)/etc/gitconfig or C:\ProgramData\Git\config)
    2. --global (actually user-level) (at ~/.gitconfig or C:\Users\<username>\.gitconfig)
    3. --local (actually repository-level) (at <repo>\.git/config)

    So if the thing is controlled by a repository-level (--local) setting then setting it again at user-level (--global) won't matter. (Send complaints to source and/or reference.)



  • @Magus said in %^&^*%*&^% Git.:

    Problem: Git launches a UI WINDOW to log in

    Ok, one question: what does the UI window look like?

    Because I've never had git launch a UI window for any command other than mergetool (which launches Visual Studio on Windows).


  • Fake News

    @ben_lubar When you clone git repositories, do you use an URL with the ssh: protocol or with the https: one?

    What Magus is seeing is the OAuth credential helper which you get in Git for Windows when connecting to a git repo over https.



  • @JBert said in %^&^*%*&^% Git.:

    @ben_lubar When you clone git repositories, do you use an URL with the ssh: protocol or with the https: one?

    What Magus is seeing is the OAuth credential helper which you get in Git for Windows when connecting to a git repo over https.

    It didn't do that last time I used git on Windows.

    Who thought it would be a good idea to make a system-modal pop-up when a command-line program wanted to ask a question about a command someone just typed?

    ...oh


  • Fake News

    @Dreikin said in %^&^*%*&^% Git.:

    @Magus said in %^&^*%*&^% Git.:

    @blakeyrat Because I tried that and it did nothing. Well, at least the boolean one. I may have to try the "Go edit the global config and set this one value to 'None'" method, and then turn it back... I really don't like the idea of that, though.

    I see that you already found a workaround, but for future reference: there are multiple levels of settings, with later ones overriding earlier ones in this order:

    1. --system (at $(prefix)/etc/gitconfig or C:\ProgramData\Git\config)
    2. --global (actually user-level) (at ~/.gitconfig or C:\Users\<username>\.gitconfig)
    3. --local (actually repository-level) (at <repo>\.git/config)

    So if the thing is controlled by a repository-level (--local) setting then setting it again at user-level (--global) won't matter. (Send complaints to source and/or reference.)

    You are technically correct and yet still missing the target: the git config --local command can only be used after a git clone, but it's exactly the clone step where @Magus needs it.

    Instead you need to have a recent enough version of git and pass -c credential.helper= to git clone. This will set that setting in the local repository when the .git folder is created but before connecting to the remote.

    @Magus You actually still need that flag if you're doing a git clone https://user:pass@url on Mac because git for OSX has a built-in credential helper where it shows a UI window asking you to store the user:pass combo in its keyring rather than plaintext in .git/config remotes (guess how I found out about about that).


  • 🚽 Regular

    @ben_lubar said in %^&^*%*&^% Git.:

    Who thought it would be a good idea to make a system-modal pop-up

    I got it as a pop-under once. It was a nice moment of "why is this stuck?"



  • @JBert said in %^&^*%*&^% Git.:

    @ben_lubar When you clone git repositories, do you use an URL with the ssh: protocol or with the https: one?

    What Magus is seeing is the OAuth credential helper which you get in Git for Windows when connecting to a git repo over https.

    Maybe modifying the server install of Git to not include the credential helper would help?



  • @Dreikin said in %^&^*%*&^% Git.:

    --global (actually user-level) (at ~/.gitconfig or C:\Users<username>.gitconfig)
    --local (actually repository-level) (at <repo>.git/config)

    Huh? What a shocker that Git would choose misleading wrong names for settings! I have never been so surprised by anything ever.



  • @ben_lubar There's even a thread out there where someone is asking why anyone would ever want something like that, and the response is, "I mean, I programmed it not to, but then caved when people begged me. And anyway if you just close it it goes to the commandline version..." - GREAT, but that means it isn't scriptable. It turns out it IS, actually, but there was no documentation googleable that explained how. They just tell you to uninstall the credential manager.

    @dcon said in %^&^*%*&^% Git.:

    Maybe modifying the server install of Git to not include the credential helper would help?

    I imagine because if you're using the UI to debug something on the build server, like a failing build, you'd (after your credentials expire) launch VS, try to sync, and it'd say you don't have credentials and fail, instead of popping the login window.

    Again, messing up the build server is a thing I actually don't want to do. And don't need to do. I wish they'd just added a stupid -yeahdontlaunchmodalsyoujerk option.


  • Considered Harmful

    @blakeyrat Those names are right. Your repo is the only meaningful "local" scope, the only meaningful "global" scope you can affect is your user scope. And still there is no changeset number for you. Just a hash. Always just a hash...



  • @Gribnit Would you say they make a hash of providing proper information?


  • Considered Harmful

    @Benjamin-Hall After rearranging the sentence slightly, sure.



  • @Gribnit Not sure of :whoosh: status here, but for anyone else:

    make a hash of
    phrase of hash
    1.
    informal
    make a mess of; bungle.
    "listening to other board members make a hash of things"
    synonyms: bungle, fluff, flub, mess up, make a mess of; More


  • Considered Harmful

    @Benjamin-Hall

    1. To map destructively onto a fixed number of, usually fewer, bits.

    What the hell kind of dictionary are you using that puts archaisms so early in the definition list? :trollface:



  • @Gribnit said in %^&^*%*&^% Git.:

    Your repo is the only meaningful "local" scope, the only meaningful "global" scope you can affect is your user scope.

    System is global too. Should have called it "user" instead of "global".



  • Why is the first word in the topic censored?


  • Considered Harmful

    @stillwater No mortal may state the true name of the curse %^&^%&^% and live.



  • @Gribnit said in %^&^*%*&^% Git.:

    Those names are right.

    Nope.

    @Gribnit said in %^&^*%*&^% Git.:

    Your repo is the only meaningful "local" scope,

    I guess if your filesystem is a magical fairy tale land and you walk "in" to directories then exist inside of them, it makes a slight amount of sense kind of maybe not really.

    @Gribnit said in %^&^*%*&^% Git.:

    the only meaningful "global" scope you can affect is your user scope.

    Ok:

    1. Even if that were true (and it's not) why would you make the user have to be aware of that fact to use your product?
    2. Globes are round spherical things. Nothing in my computer user account is a round spherical thing. Nothing is even a physical thing, for that matter.
    3. Why is the "user" scope more "global" than the "system" scope, which is also "global"? Why does it deserve to be called "global" instead of "system" being called "global"? (In other words, even if you agree "global" is a good descriptive word for this, it's still being applied in the wrong place!)

    @Gribnit said in %^&^*%*&^% Git.:

    And still there is no changeset number for you. Just a hash. Always just a hash...

    I don't even know what this is. Poetry?


  • Considered Harmful

    @blakeyrat given that "navigation" metaphors are applied to filesystems, and that "global" is a well-recognized term, just go ahead and interpret it all as poetry.



  • @Gribnit Ok so the globe is my user account, then the "system" is, what, the solar system? The Milky Way galaxy?

    What's local if my user account is an ENTIRE PLANET? Like at that scale, "local" would be more "North America" than "Bellevue, Washington".


  • Considered Harmful

    @blakeyrat You're really running with this interpretation of "global" that you know is not the going interpretation,
    although this off-base confuscation will doubtless lead to an avoidable conflagration;
    I'm sending rhyme correctors to their battle-stations,
    your mom.



  • @Gribnit Hey you're the one saying it was a metaphor, I'm just trying to understand what the metaphor is.

    Of course you're wrong, because the makers of Git have no fucking clue and just named shit by rolling dice. But if you're going to claim there's some meaning to the words, I'm gonna try to find the meaning. Ain't no thang.


  • ♿ (Parody)

    @blakeyrat said in %^&^*%*&^% Git.:

    Hey you're the one saying it was a metaphor, I'm just trying to understand what the metaphor is.

    Local: This thing here that you're working on.
    Global: All the stuff you work on.



  • @Gribnit said in %^&^*%*&^% Git.:

    "global" is a well-recognized term

    It is. Means the system. Oh wait, I need to put my git-obfuscation hat on... Since the world revolves around Linus, obviously the user is global.


  • Considered Harmful

    @dcon you only need to wear it when you're using it


  • Banned

    @blakeyrat said in %^&^*%*&^% Git.:

    Globes are round spherical things. Nothing in my computer user account is a round spherical thing. Nothing is even a physical thing, for that matter.

    Ever heard of global variables?


Log in to reply