Skip to content

Instantly share code, notes, and snippets.

@henvic
Last active October 13, 2017 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henvic/e53d2bbcf7eb235701242876ccd92b96 to your computer and use it in GitHub Desktop.
Save henvic/e53d2bbcf7eb235701242876ccd92b96 to your computer and use it in GitHub Desktop.
gitless proposal: easier git stash area

This is a project work for the class I am taking (Advanced Topics in Software Engineering).

Context

legit is a complimentary Command-Line-Interface tool for git that adds some commands which proposes to simplify git interface. See Purposes, Concepts, Misfits, and a Redesign of Git.

Improvement idea: legit stash

git stash is a powerful git command for stashing changes in a dirty working directory.

This is very useful for when you are working on something, but have to stop for a while to do something else.

Stashing changes work akin to comitting them on a secondary branch and merging them back later to your working directories. It works similarly, even suffering from conflict issues.

There is, though, a common issue: while it is easy to master the command, it is not dead simple to learn it on a need-to-know basis. Therefore, many people never use it. Or use it seldom and/or only for immediate basic pop/stack operations, never adding messages to explain what the changes are about and so on.

This feature request for gitless should include a few commands (to be surveyed yet) that simplifies this process for git novice users.

Possibly list of commands

  • legit stash: alias to the command below
  • legit stash save <hash/id>: saves current staging area to stash, similar to git stash
  • legit stash list: list all stashes, similar to git stash list
  • legit stash apply <hash/id>: applies stash by hash or id, but requires hash/id argument
  • legit stash pop: applies stash by hash or id or on the top of the stack (not shown on legit help stash)
  • legit stash rm <hash/id>: removes stash by hash or id, similar to git stash drop, but requires hash/id argument
  • legit stash show <hash/id>: show contents of stasing area, similar to git stash show

Flags

  • --message (string)
  • --id (string)

Possible behavior to implement

  • Prompt user for stash id always, if not given by --id
  • Prompt user for stash messages always, if not given by --message
  • Make these settings globally configurable

I like none of these ideas, but others might like it.

User-friendly IDs

It might be useful for users to use a custom ID for their stashes, instead of using the sha1 git generates.

We are going to implement a local DB on the current user .git directory with a map from user-friendly ID to git native hash on a file. This file has to be garbage collected to clear old values from time to time, because the user might still use git itself to drop/pop stashes.

Risks of this implementation

The only risk I see are users stashing changes for complex work that are already good enough for committing, instead of adding them on 'under work' branches.

@henvic
Copy link
Author

henvic commented Oct 13, 2017

Another possibility is for the ID code to always be the first line of the message (and strip it when printing with gitless). This way, a local index is not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment