<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -11,6 +11,12 @@
 
 (eval-when-compile (require 'cl))
 
+(defcustom gitsum-reuse-buffer t
+  &quot;Whether `gitsum' should try to reuse an existing buffer
+if there is already one that displays the same directory.&quot;
+  :group 'git
+  :type 'boolean)
+
 (easy-mmode-defmap gitsum-diff-mode-shared-map
   '((&quot;A&quot; . gitsum-amend)
     (&quot;c&quot; . gitsum-commit)
@@ -167,13 +173,32 @@ A numeric argument serves as a repeat count.&quot;
     (when marked
       (gitsum-refresh (mapconcat 'identity marked &quot; &quot;)))))
 
+(defun gitsum-find-buffer (dir)
+  &quot;Find the gitsum buffer handling a specified directory.&quot;
+  (let ((list (buffer-list))
+        (fulldir (expand-file-name dir))
+        found)
+    (while (and list (not found))
+      (let ((buffer (car list)))
+        (with-current-buffer buffer
+          (when (and list-buffers-directory
+                     (string-equal fulldir
+                                   (expand-file-name list-buffers-directory))
+                     (eq major-mode 'gitsum-diff-mode))
+            (setq found buffer))))
+      (setq list (cdr list)))
+    found))
+
 (defun gitsum ()
   &quot;Entry point into gitsum-diff-mode.&quot;
   (interactive)
-  (switch-to-buffer (generate-new-buffer &quot;*gitsum*&quot;))
-  (gitsum-diff-mode)
-  (set (make-local-variable 'list-buffers-directory) default-directory)
-  (gitsum-refresh))
+  (let* ((dir default-directory)
+         (buffer (or (and gitsum-reuse-buffer (gitsum-find-buffer dir))
+                     (generate-new-buffer &quot;*gitsum*&quot;))))
+    (switch-to-buffer buffer)
+    (gitsum-diff-mode)
+    (set (make-local-variable 'list-buffers-directory) dir)
+    (gitsum-refresh)))
 
 ;; viper compatible
 (eval-after-load &quot;viper&quot;</diff>
      <filename>gitsum.el</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b95c77d61f9ff85205d4a815b8b8d68990494dae</id>
    </parent>
  </parents>
  <author>
    <name>Tomas Abrahamsson</name>
    <email>tab@lysator.liu.se</email>
  </author>
  <url>http://github.com/chneukirchen/gitsum/commit/e2f112f220db2b511471c02095e3a28f40d419fd</url>
  <id>e2f112f220db2b511471c02095e3a28f40d419fd</id>
  <committed-date>2008-08-09T10:21:31-07:00</committed-date>
  <authored-date>2008-08-09T09:30:58-07:00</authored-date>
  <message>Can now reuse an existing buffer displaying the same directory

Imported and adapted from `git.el', gitsum can now reuse an existing
buffer if there is one showing the same directory. This is useful if
you forget to quit/kill the gitsum buffer and then run gitsum again.</message>
  <tree>fdb5e01f730995bcb06ab9201a41f313a6904def</tree>
  <committer>
    <name>Tomas Abrahamsson</name>
    <email>tab@lysator.liu.se</email>
  </committer>
</commit>
