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
wip: some improvement suggestions #2151
Comments
|
Jonas Bernoulli notifications@github.com writes:
Ok, thanks, good to know.
Ok.
I guess it depends on your working style. I tend to commit stuff in Anyway, this is just a suggestion, I have written my own command for my Thanks, Michael. |
Yes I understand - and suggest you do that on the actual branch. Later you can squash, reword, rearrange, or even just reset to the commit right before the "wip commits", whatever is suitable in any given situation. There's nothing wrong with creating "unfinished commits" on an actual branch. I do it all the time.
With a prefix argument Here is a very early draft for the wip log command: (defun magit-wip-log-current (&optional args files)
(interactive (magit-log-arguments))
(let ((branch (magit-get-current-branch)))
(magit-log (list branch
(format "%sindex/refs/heads/%s" magit-wip-namespace branch)
(format "%swtree/refs/heads/%s" magit-wip-namespace branch))
args files)))
(magit-define-popup-action 'magit-log-popup ?w "Wip" 'magit-wip-log-current) |
Jonas Bernoulli notifications@github.com writes:
That's reasonable, thanks.
Seems to work well here. |
I have added |
Thanks, I will try them carefully. Looks fine at the first look. Will these commands become an official binding in the "magit-log-popup"? |
Maybe after turning on the wip modes by default, but that probably won't happen until v2.4.0. |
I found that a linear autosave history would fit much better to my working habits than the current behavior of In larger projects, one cannot assume that all file changes between two commits are related only to those two commits. You may work on different things you will commit later. What is the rationale for the current behavior? Would you consider to allow to use a linear autosave commit tree as well? The current behavior has also a disadvantage for logging: If you want to run git-log with -L:
(from man git-log) So AFAIU it is not possible to search autosaves prior to the last commit when you want to use -L. That's quite a restriction. |
I guess changing
more or less does what I want. |
This could also be a separated mode. If it doesn't fit into the current concept of magit's wip modes, I would even be willing to provide the functionality in a separate package, unless it is totally unwanted. I'm not allowed to reopen this issue - does this read somebody? I would be thankful for a reply, even a negative one. Thanks. |
Well for one thing old wip commits get garbage collected after a while. And... There are some uncommitted changes, you create a commit from some of that, and some other changes remain "uncommitted". I feel it makes sense to bring the two units of commits into a relation by "attaching" the "uncommitted" changes to the "committed" changes by creating a new "branch" of wip-development starting at what was just committed properly. It seems you value the other relationship the "wip internal sequence" more. I feel that isn't so important and that only maintaining that sequence of "events" (wip commits) actually loses information, namely "what hasn't been committed yet (on the actual branch)". In short: I value the "checkpoints". (And when I write that I can actually year the sound from old arcade games when you race below a banner :-) That might be a bit vague, but that's vague too (you might want to go into some details):
Okay you mention one thing: Anyways, you can have it both ways (but without the garbage collection) like this (untested): diff --git a/lisp/magit-wip.el b/lisp/magit-wip.el
index e424892..7c5bcb7 100644
--- a/lisp/magit-wip.el
+++ b/lisp/magit-wip.el
@@ -210,6 +210,8 @@ (defun magit-wip-update-wipref (wipref tree parent files msg start-msg)
(setq start-msg (concat "restart autosaving " start-msg))
(magit-call-git "update-ref" wipref "-m" start-msg
(magit-git-string "commit-tree" "-p" parent
+ (and (magit-rev-verify wipref)
+ (list "-p" wipref))
"-m" start-msg
(concat parent "^{tree}")))
(setq parent wipref)) |
Thanks for reopening! Jonas Bernoulli notifications@github.com writes:
By whom - git? That's bad.
That's what I expected. It's reasonable, also for me, but it doesn't
What effect will this have - how does this allow us to have it "both You wanted me to give details: I had added some code to my (laaarge) Then I had made some commits (totally unrelated to the code I had After a while, I found that the discarded code had not been a bad idea I thought "hey, you can find it with git-log -L", because I exactly knew With a linear history, it would have been easy to git-log -L, as would I repeat: my working style is different from yours, with your working I develop a few little things in parallel most of the time, try them for Regards! |
Tried it out now. Does exactly what I suspected I think I like the idea. However, I still can't use git-log -L like I want. The first autosave commit after any real commit has two parents, and two according diffs. It seems that git-log -L uses the diff against the real commit, not the diff against the preceding autosave commit, when searching. This diff includes all not-yet committed pending changes. This makes git-log -L completely useless to find the autosave commit that corresponds to a certain file change. |
I guess what I want would mean using something like
in the git-commit-tree call in your patch. Dunno if that would be acceptable for you. But it solves my problem of git-log -L usage. |
What about this? diff --git a/lisp/magit-wip.el b/lisp/magit-wip.el
index 431d805..ef899eb 100644
--- a/lisp/magit-wip.el
+++ b/lisp/magit-wip.el
@@ -195,6 +195,8 @@ (defun magit-wip-commit-worktree (ref files msg)
(when (magit-git-failure "diff-tree" "--quiet" parent tree "--" files)
(magit-wip-update-wipref wipref tree parent files msg "worktree"))))
+(defvar magit-wip-merge-ref t)
+
(defun magit-wip-update-wipref (wipref tree parent files msg start-msg)
(let ((len (length files)))
(unless (and msg (not (= (aref msg 0) ?\s)))
@@ -206,7 +208,9 @@ (defun magit-wip-update-wipref (wipref tree parent files msg start-msg)
(magit-toplevel)))))
msg)))
(magit-reflog-enable wipref)
- (unless (equal parent wipref)
+ (unless (or (equal parent wipref)
+ (and magit-wip-merge-ref
+ (magit-rev-verify wipref)))
(setq start-msg (concat "restart autosaving " start-msg))
(magit-call-git "update-ref" wipref "-m" start-msg
(magit-git-string "commit-tree" "-p" parent
@@ -215,6 +219,8 @@ (defun magit-wip-update-wipref (wipref tree parent files msg start-msg)
(setq parent wipref))
(magit-call-git "update-ref" wipref "-m" msg
(magit-git-string "commit-tree" tree
+ (and magit-wip-merge-ref
+ (list "-p" wipref))
"-p" parent "-m" msg))))
(defun magit-wip-get-ref () |
But I am afraid you'll have to figure this out yourself and create a separate package from the result. The fact that the wip refs are restarted after creating a real commit and that wip commits are eventually garbage collected are central ideas of this package (they are about the only things inherited from the If you do write your own package, then you can probably get away with just implementing substitutes for |
Jonas Bernoulli notifications@github.com writes:
I think I just use a separate tree under e.g. "refs/backup/", and the Question: if I do that and use a linear tree there (which doesn't Regards, Michael. |
For reference: here is the first try. Seems to do what I want.
|
If you release this as a package, then note that on pre-2.1
They are reachable from a ref, so they aren't garbage and won't be collected. |
Hello,
I like the idea behind the wip mode stuff. Here are some thoughts and ideas about it.
1 The manual says that the wip modes will come with a performance penalty. I think especially "magit-wip-after-save-mode" will lead to many additional commits into refs/wip.
I think it would be good if the manual would be more precise about what kind of performance loss this will cause - take this also as a question! Of course will it slow down saving a bit (naturally), but are there other, durable costs? Will the logs take longer to pop up? Even more important, will the effect accumulate and slow down git as a whole, because the references tree will grow much faster than without the mode?
2 The implementation details should be hidden from the user. Consequently, to view a log of wip saves, the user should not have to type
as mentioned in the doc; instead, there should be an own binding in "magit-invoke-popup-action" IMHO, or something like that.
3 Apart from the automatic saves performed by the wip modes, use the refs tree to allow the user to make named explicit backups/snapshots of the current state (of the worktree), a bit like stash snapshots. This would be easy to do, the infrastructure is already there ("magit-wip-commit-worktree").
Example: I have implemented some new feature, but am far away from committing. So I would type M-x magit-wip-make-named-backup RET, then I'm prompted for a name, it could be "try-to-implement-foo", and then it calls something like (magit-wip-commit-worktree (magit-wip-get-ref) nil "try-to-implement-foo").
This would be a good stand-alone alternative to automatic saving via wip modes, but also a good complement, because the user will be able to find the individually named commits easier than automatically created ones with unmeaningful names.
Thanks!
The text was updated successfully, but these errors were encountered: