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

Add uncommit command #33

Open
zombiezen opened this issue May 22, 2018 · 1 comment
Open

Add uncommit command #33

zombiezen opened this issue May 22, 2018 · 1 comment
Labels
enhancement New feature or request

Comments

@zombiezen
Copy link
Member

It would be nice to replicate the Mercurial uncommit command. Synopsis:

gg uncommit [FILE [...]]

uncommit part or all of a local commit

Running gg uncommit without any arguments should behave like git reset --soft HEAD~.

Running gg uncommit with arguments should do something like:

# Update index with previous state of files, but don't modify the working tree.
git reset -q HEAD~ -- FILE1 FILE2 ...
# Now roll back the HEAD ref.
git reset --soft HEAD~

Tricky part will be to ensure this works on the first commit as well: this shouldn't introduce any bugs like #30.

/cc @ianthehat, who requested this feature.

@zombiezen zombiezen added the enhancement New feature or request label May 22, 2018
@zombiezen zombiezen added this to the 0.6 milestone May 22, 2018
@zombiezen zombiezen removed this from the 0.6 milestone Jul 10, 2018
@zombiezen zombiezen added this to the 0.7 milestone Jul 18, 2018
@zombiezen zombiezen removed this from the 0.7 milestone Jan 4, 2019
@zombiezen
Copy link
Member Author

Correction: in the second case, it should amend the top commit to point to old content.

Oddly enough, I think the easiest way to implement this might be to read the HEAD tree, rewrite the content to point to the blobs for the given files at HEAD~, use git-commit-tree to create the new commit, then git reset --soft NEW_COMMIT_HASH. For merge commits, this would only work if the content of the blob was the same in all parents (it should error otherwise).

@zombiezen zombiezen added this to the 0.8 milestone Feb 7, 2019
@zombiezen zombiezen modified the milestones: 1.0, 1.1 Jul 23, 2019
@zombiezen zombiezen removed this from the 1.1 milestone Sep 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
1 participant