magit-file-log: use magit-refresh-log-buffer

In `magit-file-log' use `magit-refresh-log-buffer' instead of the
"specialized" `magit-refresh-file-log-buffer'.

The latter refresher was wrong for several reasons:

* There ain't no "file log" buffer - file log uses the same buffer
  as "regular log".  Whether that is a good idea is a different
  issue.

* The file-log refresher effectively re-implemented the regular
  refresher but in a less feature full and buggy fashion.  The person
  who implemented the file-log refresher should instead just have made
  the, rather minimal, required adjustments to the log refresher and
  then have used that.

The last dozen commits were splitting atoms.  This commit could have
looked like this (keeping one of the other commits):

I must say I don't think that would I have actually done instead,
is *objectively* better.  It has advantages, but it also cost me more
than an hour to do.

(After the diff there are more comments).

diff --git a/magit.el b/magit.el
index 097a96b..0bd038f 100644
--- a/magit.el
+++ b/magit.el
@@ -5894,20 +5894,21 @@ With a prefix arg, do a submodule update --init."

 (defvar-local magit-file-log-file nil)

-(magit-define-command file-log (&optional all)
+(magit-define-command file-log (file &optional use-graph)
   "Display the log for the currently visited file or another one.

 With a prefix argument or if no file is currently visited, ask
 for the file whose log must be displayed."
-  (interactive "P")
+  (interactive
+   (list (magit-read-file-from-rev (magit-get-current-branch)
+                                   (magit-buffer-file-name t))
+         current-prefix-arg))
   (magit-mode-setup magit-log-buffer-name
                     #'magit-log-mode
-                    #'magit-refresh-file-log-buffer
+                    #'magit-refresh-log-buffer
                     'oneline "HEAD"
-                    (magit-file-relative-name
-                     (if (or current-prefix-arg (not buffer-file-name))
-                         (magit-read-file-from-rev (magit-get-current-branch))
-                       buffer-file-name))))
+                    (and use-graph (list "--graph"))
+                    file))

 (magit-define-command reflog (ref)
   (interactive (list (magit-read-rev "Reflog of"
@@ -5934,13 +5935,18 @@ from the parent keymap `magit-mode-map' are also available."
 (defvar magit-log-buffer-name "*magit-log*"
   "Name of buffer used to display log entries.")

-(defun magit-refresh-log-buffer (style range args)
+(defun magit-refresh-log-buffer (style range args &optional file)
   (setq magit-current-range range)
+  (setq magit-file-log-file file)
   (magit-create-log-buffer-sections
     (apply #'magit-git-section nil
-           (if (or (member "--all" args) (member "--all-match" args))
-               "Commits"
-             (magit-rev-range-describe range "Commits"))
+           (cond (file
+                  (magit-rev-range-describe
+                   range (format "Commits for file %s" file)))
+                 ((or (member "--all" args) (member "--all-match" args))
+                  "Commits")
+                 (t
+                  (magit-rev-range-describe range "Commits")))
            (apply-partially 'magit-wash-log style 'color)
            "log" (magit-log-cutoff-length-arg)
            "--decorate=full" "--abbrev-commit" "--color"
@@ -5956,29 +5962,6 @@ from the parent keymap `magit-mode-map' are also available."
                                 "[%an][%ar]%s"))))
              ,@args "--"))))

-(defun magit-refresh-file-log-buffer (style range file)
-  "Refresh the current file-log buffer by calling git.
-
-FILE is the path of the file whose log must be displayed.
-
-`magit-current-range' will be set to the value of RANGE.
-
-STYLE controls the display.  It is either `long', `oneline',
-or something else."
-  (setq magit-current-range range)
-  (setq magit-file-log-file file)
-  (magit-create-log-buffer-sections
-    (apply #'magit-git-section nil
-           (magit-rev-range-describe range (format "Commits for file %s" file))
-           (apply-partially 'magit-wash-log style)
-           "log" (magit-log-cutoff-length-arg)
-           "--decorate=full" "--abbrev-commit" "--graph"
-           (magit-diff-abbrev-arg)
-           `(,@(cl-case style
-                 (long    (list "--stat" "-z"))
-                 (oneline (list "--pretty=oneline")))
-             "--" ,file))))
-
 (defun magit-log-show-more-entries (&optional arg)
   "Grow the number of log entries shown.

---

Choosing between the above and what I have actually done probably isn't
what Pieter had in mind.  I could probably have committed the above
patch as two commits:

In the first commit the second and third hunk plus this from the first:
-                    #'magit-refresh-file-log-buffer
+                    #'magit-refresh-log-buffer

And then the rest of the first hunk in a second commit.

The reason I have not done so (aside the fact I have obviously not
developed my "keeping it atomic" skills enough yet) is that both of
these commits would change `magit-log-file' considerably, and that I
don't think the first set of changes makes sense without the second.

So, in *this* case, I see three options:

1) Splitting atoms.  Like I have actually done.  That takes a looong
   time.
2) One commit, that does "to much".  In this particular case that's what
   I still think would have been the best option.
3) Two commits.  On the surface that looks like the best options, but
   because it changes the behavior of a command considerably, twice,
   that is at least debatable.  Doing so would require notes like
   "now do X, which isn't good, but it will be changed to Y in the next
   commit".

So I still, in this case, think that this change is just one atom, and
that even just two commits still is "splitting atoms".  The first commit
wouldn't make much sense without the second.  Then again I might be
wrong, and only practice will allow me to form a more informed opinion.

And last but not least: in the past I would just have done (2) and not
have worry about the alternatives, because this is only the very first
step required to replace this:

- magit-log
- magit-log-ranged
- magit-long-log
- magit-long-log-ranged
- magit-log-file
- magit-log-file-ranged (missing)

With

- magit-log

In a first step (after the above) that would require generalizing
`magit-log' so that the other functions could call it while using
a "static" value for one or more of the "arguments".

In a second step the key-mode would have to be improved to make that
hack (defining commands to allow making certain values static, while
keeping to provide multiple "actions" in the popup) unnecessary.

Because of this focus on the big picture and because the changes
actually implemented now are only a very small part of this visions,
I might sometimes confuse molecules for atoms.

And yes, sometimes I am a bit annoyed by the code I find, and that
probably leads to me cutting corners.  If the person who implemented
"file log" had actually though about what the best way of doing that
was *at* the time he was doing it (which shouldn't be different from
the best way as of now) there would not have been an inferior
refresher to be replaced in the first place.