Live data from Hacker News

I found a useful Git one liner buried in leaked CIA developer docs

spencer.wtf

121–130 of 273 posts

Re: I found a useful Git one liner buried in leaked CIA developer docs

#121

Earlier quoted context omitted.

how do you trust the code claude wrote? don't you get anxiety "what if there's an error in tui code and it would mess up my git repo"?

Isn't it this case no matter who wrote the code? How do you ever run anything if you're worried about bugs?

Different type of creator, different type of bugs. I'd assume a human giving me a way to delete merged branches has probably had the same issue, solved the same problem and understands unspecified context around the problem (e.g protect local data). They probably run it themselves so bugs are most likely to occur in edge cases around none standard use as it works for them.

Ais are giving you what they get from common patterns, parsing documentation etc. Depending what you're asking this might be an entirely novel combination of commands never run before. And depending on the model/prompt it might solve in a way any human would balk at (push main to origin, delete .git, re-clone from origin. Merged local branches are gone!)

It's like the ai art issues - people struggle with relative proportions and tones and making it look real. Ai has no issues with tones, but will add extra fingers or arms etc that humans rarely struggle with. You have to look for different things, and Ai bugs are definitely more dangerous than (most) human bugs.

(Depends a little, it's pretty easy to tell if a human knows what they're talking about. There's for sure humans who could write super destructive code, but other elements usually make you suspicious and worried about the code before that)

Re: I found a useful Git one liner buried in leaked CIA developer docs

#122

Earlier quoted context omitted.

Can you explain TUI? I have never heard this before

It's definitely an acronym that got popular in the last year or so, though I'm sure there are people out there who will pretend otherwise. I've been in the industry 15+ years now and never heard it before. Previously it was just UI, GUI, or CLI.

As someone who came up using Borland's Turbo Pascal, Turbo C, and Turbo Vision (their OOP UI framework), it was called CUI (character-based user interface) to distinguish from GUI, which became relevant as Windows became dominant.

I never heard "TUI" until the last few years, but it may be due to my background being Microsoft-oriented.

One of the only references I can find is the PC Magazine encyclopedia: https://www.pcmag.com/encyclopedia/term/cui

Re: I found a useful Git one liner buried in leaked CIA developer docs

#123
post #116

I have a cleanup command that integrates with fzf. It pre selects every merged branch, so I can just hit return to delete them all. But it gives me the opportunity to deselect to preserve any branches if I want. It also prunes any remote branches # remove merged branches (local and remote) cleanup = "!git branch -vv | grep ': gone]' | awk '{print $1}' | fzf --multi --sync --bind start:select-all | xargs git branch -D…

> For that reason I always use a git config variable to reference such branches. In my global git config it's main $(git config user.primaryBranch) What about using git's own `init.defaultBranch`? I mean, while useless in terms of `git init` because the repo's already init'd, this works: git config --local init.defaultBranch main And if you have `init.defaultBranch` set up already globally for `git init` then it all…

Hmm that might be nice actually. I like not conflating those two things, but as you say if the repo is already init'd then there's no chance it'll be used for the wrong purpose.

In any case the main thrust was just to avoid embeddings assumptions about branch names in your scripts :)

Re: I found a useful Git one liner buried in leaked CIA developer docs

#124
post #62

[flagged]

agree, this just seems click-baity. if you're familiar with the UNIX Way, this is a one-liner you'd naturally write. CIA leaked docs mention and a blog post for this?

the Clandestine allure for clicks for sure but you know what - the comments have been pretty interesting.

Re: I found a useful Git one liner buried in leaked CIA developer docs

#125

I have a cleanup command that integrates with fzf. It pre selects every merged branch, so I can just hit return to delete them all. But it gives me the opportunity to deselect to preserve any branches if I want. It also prunes any remote branches # remove merged branches (local and remote) cleanup = "!git branch -vv | grep ': gone]' | awk '{print $1}' | fzf --multi --sync --bind start:select-all | xargs git branch -D…

You can pull another branch without switching first: git switch my-test-branch ... git pull origin main:main git rebase main

Nice. That'll make things a bit smoother. Changing branches often trips me up when I would later `git switch -`.

Re: I found a useful Git one liner buried in leaked CIA developer docs

#126
Here's my take on the one-liner that I use via a `git tidy` alias[1]. A few points:

* It ensures the default branch is not deleted (main, master)

* It does not touch the current branch

* It does not touch the branch in a different worktree[2]

* It also works with non-merge repos by deleting the local branches that are gone on the remote

    git branch --merged "$(git config init.defaultBranch)" \
    | grep -Fv "$(git config init.defaultBranch)" \
    | grep -vF '*' \
    | grep -vF '+' \
    | xargs git branch -d \
    && git fetch \
    && git remote prune origin \
    && git branch -v \
    | grep -F '[gone]' \
    | grep -vF '*' \
    | grep -vF '+' \
    | awk '{print $1}' \
    | xargs git branch -D

[1]: https://github.com/fphilipe/dotfiles/blob/ba9187d7c895e44c35...

[2]: https://git-scm.com/docs/git-worktree

Re: I found a useful Git one liner buried in leaked CIA developer docs

#128
post #2

I currently have a TUI addiction. Each time I want something to be easier, I open claude-code and ask for a TUI. Now I have a git worktree manager where I can add/rebase/delete. As TUI library I use Textual which claude handles quite well, especially as it can test-run quite some Python code.

how do you trust the code claude wrote? don't you get anxiety "what if there's an error in tui code and it would mess up my git repo"?

I push my branches daily, so I wouldn't lose that much work. If it breaks then I ask it to fix it.

But I do quickly check the output what it does, and especially the commands it runs. Sometimes it throws all code in a single file, so I ask for 'good architecture with abstractions'.

Re: I found a useful Git one liner buried in leaked CIA developer docs

#129

I have a cleanup command that integrates with fzf. It pre selects every merged branch, so I can just hit return to delete them all. But it gives me the opportunity to deselect to preserve any branches if I want. It also prunes any remote branches # remove merged branches (local and remote) cleanup = "!git branch -vv | grep ': gone]' | awk '{print $1}' | fzf --multi --sync --bind start:select-all | xargs git branch -D…

You can pull another branch without switching first: git switch my-test-branch ... git pull origin main:main git rebase main

I have always done `git pull origin main -r`

Re: I found a useful Git one liner buried in leaked CIA developer docs

#130

If you squash your PR before merging, then this alternative worked really well for me: git fetch --prune && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D

Almost identical to mine, but you've got smarter awk use: `git prune origin && git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -D`

I think I probably copied this from Stack Overflow close to a decade ago. Seems like a lot of people have very similar variations.

Post reply on HN