PoshCode / PSGit

A PowerShell implementation of Git, mapping git commands to Verb-Noun and objects.
105 stars 15 forks source link

Save-Branch #4

Open Jaykul opened 9 years ago

Jaykul commented 9 years ago

Once you've added some work to the index, you have to commit it.

dahlbyk commented 9 years ago

Save-GitIndex or Save-GitCommit (since commit is also a noun)?

Jaykul commented 9 years ago

Convince me @dahlbyk ... Right now I've got a bunch of verbs with the same "Branch" noun: New-Branch, Remove-Branch, Get-Branch, Set-Branch, Save-Branch, Merge-Branch, etc.

dahlbyk commented 9 years ago

Maybe I'm too far in the weeds, but to me there is an important distinction between a Commit (content + parent(s) + metadata) and a Branch (a reference that updates when you commit while it's checked out). Would Save-Branch work if I don't actually have a branch checked out? Can I pipe a branch into Save-Branch? The noun just doesn't make sense to me for actions involving creating commits.

The same would go for Merge-Branch - you merge one or more commits that may or may not be identified by a branch reference.

The others align well for manipulating the branch references themselves, a la git branch.

Jaykul commented 9 years ago

I guess if we make "index" a noun, we could reuse it in a few other places.

And of course, maybe I'm not far enough in the weeds (If so, can you give me a simple script test-case/example?)

I guess the question is how much are we simplifying this command? I mean, I'm taking it for granted that we're not going to expose most of the built-in parameters. After all, I love a good fixup/squash/reuse with rebase interactive, but:

dahlbyk commented 9 years ago

I guess if we make "index" a noun, we could reuse it in a few other places.

Reset-GitIndex for the path version of reset sticks out in my mind. Not sure what else?

For the git commit analog, discoverability might drive toward Save-GitCommit or even New-Commit?

Is it possible for a working directory to be in a state where no branch is checked out?

Yep - it's called a "detached HEAD". You might get there if you checkout a tag, for example. You're also technically in that state in the middle of a rebase, though posh-git will show you the branch you're rebasing if possible.

Is it possible to make a commit that isn't against any branch?

Yep. Not super common since creating branches is so cheap, but nothing prevents it and I do so every once in a while. Simple example:

cat .git/HEAD                  # likely ref: refs/heads/some-branch
git checkout HEAD~0            # detach at current HEAD
cat .git/HEAD                  # now a 40-digit SHA
git commit --allow-empty -m 'Headless!'
git log --oneline --decorate   # should see previous branch as parent
git checkout -b new-branch     # create new-branch at new commit

I guess the question is how much are we simplifying this command? I mean, I'm taking it for granted that we're not going to expose most of the built-in parameters.

Agree 100% that many parameters won't have any use. Like --porcelain or -z for machine-readable output...because PowerShell. :grinning: The "ROI" for most parameters just won't be there unless you find a motivated contributor that really cares about GPG signing.

That said, I expect (hope?) you'll find enough more advanced