Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with core Git subcommand authoring features. #43

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

tomeon
Copy link

@tomeon tomeon commented Sep 8, 2023

Thank you for this handy tool!

This PR introduces integration with git-sh-setup, a library included with the
core Git distribution. It provides conveniences for authoring shell-based Git
subcommands.

Summary of features:

  1. Added help text (git redate -h).
  2. Added CLI options sanitation (git redate now bails upon unrecognized options).
  3. Updated to use $GIT_EDITOR / git var GIT_EDITOR for editing the re-dating specification file. This is a breaking change, though one that's likely to align git redate with the user's already-expressed preference (e.g. whatever they've defined as core.editor) rather than prompting them to express a preference interactively.
  4. Added support for specifying git redate preferences in the Git client configuration file.
  5. Added support for specifying arbitrary commit ranges.

Miscellaneous other changes:

  1. Streamlined some code (e.g. removing repeated checks of the value of $ALL, $DEBUG, etc., instead using conditionally-defined functions).
  2. Prevent trying to shift any arguments when $@ is already empty.
  3. Added a dry-run mode, which was helpful for testing the other changes and perhaps useful for end users before re-dating For Real.
  4. Fixed some shellcheck linting issues.
  5. Formatted the code with shfmt.
  6. Relocated the temporary file used for specifying date edits to the .git directory.

Thanks for your consideration!

rather than non-portable `/bin/bash`
with POSIX-compatible code.
@iitzrohan
Copy link

@tomeon Thanks for updating the tool.Can you add two more features.

  1. Don't change the hash when redating.
  2. Make it possible to sign commits with redating.

@tomeon
Copy link
Author

tomeon commented Nov 3, 2023

Hello @iitzrohan -- thanks for your feedback/requests.

Don't change the hash when redating.

This is not possible.

Make it possible to sign commits with redating.

Done.

@tomeon tomeon force-pushed the git-sh-setup-integration branch from e270ba1 to e694418 Compare November 6, 2023 13:41
@tomeon
Copy link
Author

tomeon commented Nov 6, 2023

@iitzrohan --

The latest changes doesn't opens the editor configured through gitconfig. Instead it uses the default editor nano.

I am unable to reproduce this; for me, git redate respects core.editor.

fatal: ambiguous argument [...]

Thanks; should be fixed now. I've updated git-redate to check the number of commits reachable from HEAD and choose the lower of (a) that number and (b) the number provided with git redate -c <count>. I've also updated git-redate to exit with nonzero status in case the provided commit range is invalid, or valid but causes git rev-list to emit no commits.

git-redate Outdated Show resolved Hide resolved
for features like CLI options processing and "am I in a git repo?"
sanity-checks.
That is, remove redundant `shift` calls in the `--debug` and `--all`
cases.
by conditionally defining a `debug` function based on whether the
`-d/--debug` option was provided.  If debugging is not enabled, the
`debug` function is a NOP; otherwise, it echoes its arguments to stderr.
BREAKING CHANGE: diagnostic output no longer goes to stdout.
rather than custom editor selection code.
BREAKING CHANGE: introduces type-checking of `COMMITS`, `DEBUG`, and
friends.
that provides a default value for the `COMMITS` variable.  This variable
is already guaranteed to be set to a positive integer (or else `git
redate` will have exited).
within the body of the loop that applies the redate logic.  Instead,
conditionally define an `apply_redate` function depending on whether we
saw `--all`, then call this function from within the loop.
rather than numbers of commits starting from HEAD (or all commits).
when generating the interactive commit selection list.
by passing the `-S`/`--gpg-sign` flag through to `commit-tree`.
by loading them via `git -c <name>=<value> --get <name>`.
BREAKING CHANGE: `git redate` exits with nonzero status in case no
commits were identified.
@tomeon tomeon force-pushed the git-sh-setup-integration branch from e694418 to 96e51ea Compare November 10, 2023 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants