byplayer / egg

Emacs Got Git. This is a clone of Marius's excellent magit. Egg is an emacs interface to git.
bogolisk.blogspot.com
97 stars 20 forks source link

egg-status error: wrong-number-of-arguments nil 2 #41

Open von opened 12 years ago

von commented 12 years ago

I have one particular repo in which I get the appended error when I run egg-status.

Based on 'egg-unstaged-lines-delta-before-hunk("emacs-config" nil)' in the backtrace, the problem is caused by the 'emacs-config' submodule, which diffs as follows:

$ git diff diff --git a/emacs-config b/emacs-config index 12e0c47..72a82c2 160000 --- a/emacs-config +++ b/emacs-config @@ -1 +1 @@ -Subproject commit 12e0c4781b5879d38c5635b774ab484865a93aa3 +Subproject commit 72a82c22cb34f517c917360e02927d2028f5ab6d

Debugger entered--Lisp error: (wrong-number-of-arguments nil 2) signal(wrong-number-of-arguments (nil 2)) (if (cdr (cdr --cl-rest--)) (pop --cl-rest--) (signal (quote wrong-number-of-arguments) (list nil ...))) (let* ((--cl-rest-- range) (l1 ...) (s1 ...) (l2 ...) (s2 ...)) (if --cl-rest-- (signal ... ...)) (when (< l2 line) (incf cnt ...))) (progn (let* (... ... ... ... ...) (if --cl-rest-- ...) (when ... ...))) (destructuring-bind (l1 s1 l2 &optional s2) range (when (< l2 line) (incf cnt ...))) (progn (destructuring-bind (l1 s1 l2 &optional s2) range (when ... ...))) (if (eq sect (quote unstaged)) (progn (destructuring-bind ... range ...))) (when (eq sect (quote unstaged)) (destructuring-bind (l1 s1 l2 &optional s2) range (when ... ...))) (let ((sect ...) (range ...) (real-range ...) (single-range ...)) (when (eq sect ...) (destructuring-bind ... range ...))) (while --cl-dolist-temp-- (setq elem (car --cl-dolist-temp--)) (let (... ... ... ...) (when ... ...)) (setq --cl-dolist-temp-- (cdr --cl-dolist-temp--))) (let ((--cl-dolist-temp-- ...) elem) (while --cl-dolist-temp-- (setq elem ...) (let ... ...) (setq --cl-dolist-temp-- ...)) nil) (catch (quote --cl-block-nil--) (let (... elem) (while --cl-dolist-temp-- ... ... ...) nil)) (cl-block-wrapper (catch (quote --cl-block-nil--) (let ... ... nil))) (block nil (let (... elem) (while --cl-dolist-temp-- ... ... ...) nil)) (dolist (elem (cdr ...)) (let (... ... ... ...) (when ... ...))) (let ((cnt 0)) (dolist (elem ...) (let ... ...)) cnt) egg-unstaged-lines-delta-before-hunk("emacs-config" nil) (let* ((delta-unstaged ...) (delta-staged ...)) (decf (first single-range) delta-staged) (decf (third single-range) (+ delta-unstaged delta-staged))) (if (eq (get-text-property pos :section) (quote unstaged)) (let* (... ...) (decf ... delta-staged) (decf ... ...)) (let (...) (decf ... delta))) (let* ((hunk-info ...) (file ...) (hunk-ranges ...) (buffer-range ...) (real-range ...) (single-range ...)) (if (eq ... ...) (let* ... ... ...) (let ... ...))) (progn (let* (... ... ... ... ... ...) (if ... ... ...))) (if (eq (get-text-property pos :sect-type) :hunk) (progn (let* ... ...))) (when (eq (get-text-property pos :sect-type) :hunk) (let* (... ... ... ... ... ...) (if ... ... ...))) (while (setq pos (next-single-property-change ... :navigation)) (when (eq ... :hunk) (let* ... ...))) (let ((pos ...) nav last-file list) (while (setq pos ...) (when ... ...))) (save-excursion (let (... nav last-file list) (while ... ...))) egg-calculate-hunk-ranges() (progn (when win (select-window win t)) (egg-save-section-visibility) (erase-buffer) (dolist (sect egg-status-buffer-sections) (cond ... ... ... ...)) (egg-calculate-hunk-ranges) (if init (egg-buffer-maybe-hide-all)) (if init (egg-buffer-maybe-hide-help "help" ...)) (egg-restore-section-visibility)) (unwind-protect (progn (when win ...) (egg-save-section-visibility) (erase-buffer) (dolist ... ...) (egg-calculate-hunk-ranges) (if init ...) (if init ...) (egg-restore-section-visibility)) (dolist (elt save-selected-window-alist) (and ... ... ...)) (if (window-live-p save-selected-window-window) (select-window save-selected-window-window))) (save-current-buffer (unwind-protect (progn ... ... ... ... ... ... ... ...) (dolist ... ...) (if ... ...))) (let ((save-selected-window-window ...) (save-selected-window-alist ...)) (save-current-buffer (unwind-protect ... ... ...))) (save-selected-window (when win (select-window win t)) (egg-save-section-visibility) (erase-buffer) (dolist (sect egg-status-buffer-sections) (cond ... ... ... ...)) (egg-calculate-hunk-ranges) (if init (egg-buffer-maybe-hide-all)) (if init (egg-buffer-maybe-hide-help "help" ...)) (egg-restore-section-visibility)) (let ((inhibit-read-only t) (win ...)) (save-selected-window (when win ...) (egg-save-section-visibility) (erase-buffer) (dolist ... ...) (egg-calculate-hunk-ranges) (if init ...) (if init ...) (egg-restore-section-visibility))) (save-current-buffer (set-buffer buf) (let (... ...) (save-selected-window ... ... ... ... ... ... ... ...))) (with-current-buffer buf (let (... ...) (save-selected-window ... ... ... ... ... ... ... ...))) egg-status-buffer-redisplay(#<buffer homestuff-status@/Users/vwelch/homestuff/.git> init) (save-current-buffer (set-buffer buf) (egg-status-buffer-redisplay buf (quote init))) (with-current-buffer buf (egg-status-buffer-redisplay buf (quote init))) (let* ((egg-internal-current-state ...) (buf ...)) (with-current-buffer buf (egg-status-buffer-redisplay buf ...)) (cond (... ...) (select ...) (egg-switch-to-buffer ...) (... ...) (t ...))) egg-status(nil)

von commented 12 years ago

I figured out how to reproduce this easily: Create a repo with a subrepro, then make one commit in each so that the subrepo is now one commit ahead of origin. Then run egg-status in the main repo and I see this error every time.

Here's a script that does it: https://gist.github.com/2597208 - run it and then run egg-status in repo/ and I see the error every time.

If you don't make a commit in repo, you get a similar but different error, which I'm guess has the same cause: egg-staged-lines-delta-before-hunk: Wrong type argument: number-or-marker-p, nil

7max commented 12 years ago

Ok this is my bug, I wonder just how many hunk header configurations there are.. So far I seen 4 numbers (normal), 6 numbers (for a 3 way diff), 3 numbers (adding symlink), and now one with 2 numbers.

Maybe I should just wrap it with (ignore-errors) instead of trying to fix on case-by-case basis

byplayer, do you mind adding me as collaborator, so I will fix it directly, rather then opening a pull request?

7max commented 12 years ago

Von, I had fixed it in my persistent-hunk-state branch, the fix is the only change there comparing to byplayer/master, can you please pull https://github.com/7max/egg branch "persistent-hunk-state" and see if you can break it?

von commented 12 years ago

@7max No change with your fix. Looks like you modified egg-get-hunk-range but that function isn't in the backtrace I'm seeing. It appears to be egg-unstaged-lines-delta-before-hunk that is crapping out if I'm reading the trace right.

7max commented 12 years ago

You sure you did not forgot to recompile .elc file or such? I was able to reproduce your error exactly with your script, and with my fix it now works.. You'll also need to kill and re-create status buffer.

The function egg-unstaged-lines-delta-before-hunk fails because it does not find 4 numbers in the hunk range, but these 4 numbers are calculated by egg-get-hunk-range, which I modified to always return 4 number range, no matter what is in the buffer.

von commented 12 years ago

@7max Yes, confusion on my end. Your fix looks good.

7max commented 12 years ago

@von My fix actually broke the 6 number hunk ranges (the ones from 3 way diff in merging), due to forgetting how to use SUBSEQ, I pushed a 2nd fix to my branch which corrects that.