From 961d80dbf0e240bf3f0e371fc22832ba2a8eb08b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 24 Sep 2010 20:39:19 +0000 Subject: [PATCH 1/5] magit-rebase-info: solve the 'The "R" rebase method needs a small fix' issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the bug in magit-rebase-info that I introduced in 81bb2ba. Here's the description of the bug from a message of mine to the mailing list: I sent an incomplete fix for the "R" rebase method recently: http://github.com/philjackson/magit/pull/59 But Phil pulled it in as-is: http://github.com/philjackson/magit/commit/81bb2ba2d32fb3bbbc2baaba60b492afe372d831 Anyway, it needs a small fixup, this: (length (magit-file-lines ".git/rebase-merge/git-rebase-todo.backup")) Will be way off, because it'll count the (length) of lines like: ("pick cb925f0 check message..." "pick 2f811b6 take done length" "pick 29332e6 use backup" "" "# Rebase 19e2dd7..29332e6 onto 19e2dd7" "#" ... What it should do instead so we can get the correct count is to only count up until the "" (uninclusive) so the above example would return 3. I couldn't find an idiomatic way of doing this in elisp, I could with the (loop) macro, but that'd require cl.el. As it turns out magit already needs cl.el, so I can just use (loop) to fix this. Signed-off-by: Ævar Arnfjörð Bjarmason --- magit.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/magit.el b/magit.el index d0f98a1d..05971745 100644 --- a/magit.el +++ b/magit.el @@ -2929,9 +2929,18 @@ With a prefix-arg, the merge will be squashed. if any." (cond ((file-exists-p ".git/rebase-merge") (list + ;; The commit message of the commit we're at (magit-name-rev (car (magit-file-lines ".git/rebase-merge/message"))) + + ;; How many commits we've gone through (length (magit-file-lines ".git/rebase-merge/done")) - (length (magit-file-lines ".git/rebase-merge/git-rebase-todo.backup")))) + + ;; How many commits we have in total, without the comments + ;; at the end of git-rebase-todo.backup + (let ((todo-lines-with-comments (magit-file-lines ".git/rebase-merge/git-rebase-todo.backup"))) + (loop for i in todo-lines-with-comments + until (string= "" i) + count i)))) (t nil))) (defun magit-rebase-step () From c7b54cb065c2fd9518cdc537414ac3d15ea787eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 24 Sep 2010 21:13:48 +0000 Subject: [PATCH 2/5] rebase: add the "onto" information back & reformat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Head section already tells us what commit we're on. Now this looks like this: Local: (detached) ~/g/git/ Head: c6b2a51 gettextize: git-clone "Cloning into" message Rebasing: onto master (26 of 159) Signed-off-by: Ævar Arnfjörð Bjarmason --- magit.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/magit.el b/magit.el index 05971745..3f269fa4 100644 --- a/magit.el +++ b/magit.el @@ -2656,7 +2656,7 @@ insert a line to tell how to insert more of them" (mapcar 'magit-name-rev merge-heads)))))) (let ((rebase (magit-rebase-info))) (if rebase - (insert (apply 'format "Rebasing: %s (%s of %s)\n" rebase)))) + (insert (apply 'format "Rebasing: onto %s (%s of %s)\n" rebase)))) (insert "\n") (magit-git-exit-code "update-index" "--refresh") (magit-insert-untracked-files) @@ -2929,8 +2929,8 @@ With a prefix-arg, the merge will be squashed. if any." (cond ((file-exists-p ".git/rebase-merge") (list - ;; The commit message of the commit we're at - (magit-name-rev (car (magit-file-lines ".git/rebase-merge/message"))) + ;; The commit we're rebasing onto, i.e. git rebase -i + (magit-name-rev (car (magit-file-lines ".git/rebase-merge/onto"))) ;; How many commits we've gone through (length (magit-file-lines ".git/rebase-merge/done")) From aac348011e40964d2411618bd5d5c3a4a39d9be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 24 Sep 2010 21:14:33 +0000 Subject: [PATCH 3/5] rebase: tell the user he can press R to proceed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "R" may actually not be "R" here, but I where-is-internal hurt my brain, so I didn't use it. Signed-off-by: Ævar Arnfjörð Bjarmason --- magit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magit.el b/magit.el index 3f269fa4..af68ab59 100644 --- a/magit.el +++ b/magit.el @@ -2656,7 +2656,7 @@ insert a line to tell how to insert more of them" (mapcar 'magit-name-rev merge-heads)))))) (let ((rebase (magit-rebase-info))) (if rebase - (insert (apply 'format "Rebasing: onto %s (%s of %s)\n" rebase)))) + (insert (apply 'format "Rebasing: onto %s (%s of %s); Press \"R\" to Abort, Skip, or Continue\n" rebase)))) (insert "\n") (magit-git-exit-code "update-index" "--refresh") (magit-insert-untracked-files) From 19a8f263a0c9695422f1527f274c88d18cf4c488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 24 Sep 2010 21:16:47 +0000 Subject: [PATCH 4/5] rebase: add hint letters to "[A]bort, [S]kip, or [C]ontinue?" message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now it'll ask you: Rebase in progress. [A]bort, [S]kip, or [C]ontinue? The message didn't indicate how you made the selction before. Signed-off-by: Ævar Arnfjörð Bjarmason --- magit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magit.el b/magit.el index af68ab59..002c8c5e 100644 --- a/magit.el +++ b/magit.el @@ -2965,7 +2965,7 @@ if any." (magit-run-git "rebase" (magit-rev-to-git rev)))) (let ((cursor-in-echo-area t) (message-log-max nil)) - (message "Rebase in progress. Abort, Skip, or Continue? ") + (message "Rebase in progress. [A]bort, [S]kip, or [C]ontinue? ") (let ((reply (read-event))) (case reply ((?A ?a) From 26107dda6f20f68ec801583696f818a015997f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 24 Sep 2010 21:19:58 +0000 Subject: [PATCH 5/5] magit-refresh-status: align messages for rebase message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Rebasing:" was the longest message, but the status bar wasn't aligned before, now this: Local: (detached) ~/g/git/ Head: c6b2a51 gettextize: git-clone "Cloning into" message Rebasing: onto master (26 of 159); Press "R" to Abort, Skip, or Continue Is aligned like this: Local: (detached) ~/g/git/ Head: c6b2a51 gettextize: git-clone "Cloning into" message Rebasing: onto master (26 of 159); Press "R" to Abort, Skip, or Continue Signed-off-by: Ævar Arnfjörð Bjarmason --- magit.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/magit.el b/magit.el index 002c8c5e..d1837a83 100644 --- a/magit.el +++ b/magit.el @@ -2641,16 +2641,16 @@ insert a line to tell how to insert more of them" "log" "--max-count=1" "--abbrev-commit" "--pretty=oneline")) (no-commit (not head))) (when remote-string - (insert "Remote: " remote-string "\n")) - (insert (format "Local: %s %s\n" + (insert "Remote: " remote-string "\n")) + (insert (format "Local: %s %s\n" (propertize (or branch "(detached)") 'face 'magit-branch) (abbreviate-file-name default-directory))) - (insert (format "Head: %s\n" + (insert (format "Head: %s\n" (if no-commit "nothing commited (yet)" head))) (let ((merge-heads (magit-file-lines ".git/MERGE_HEAD"))) (if merge-heads - (insert (format "Merging: %s\n" + (insert (format "Merging: %s\n" (magit-concat-with-delim ", " (mapcar 'magit-name-rev merge-heads))))))