forked from magit/magit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmagit.el
7331 lines (6494 loc) · 279 KB
/
magit.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; magit.el --- control Git from Emacs
;; Copyright (C) 2008-2013 The Magit Project Developers.
;;
;; For a full list of contributors, see the AUTHORS.md file
;; at the top-level directory of this distribution and at
;; https://raw.github.com/magit/magit/master/AUTHORS.md
;; Author: Marius Vollmer <[email protected]>
;; Maintainers:
;; Jonas Bernoulli <[email protected]>
;; Nicolas Dudebout <[email protected]>
;; Rémi Vanicat <[email protected]>
;; Yann Hodique <[email protected]>
;; Former-Maintainers:
;; Peter J. Weisberg <[email protected]>
;; Phil Jackson <[email protected]>
;; Keywords: vc tools
;; Package: magit
;; Package-Requires: ((cl-lib "0.3") (git-commit-mode "0.14.0") (git-rebase-mode "0.14.0"))
;; Magit requires at least GNU Emacs 23.2 and Git 1.7.2.5.
;; These are the versions shipped by Debian oldstable (6.0, Squeeze).
;; Contains code from GNU Emacs <https://www.gnu.org/software/emacs/>,
;; released under the GNU General Public License version 3 or later.
;; Magit is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; Magit is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
;; License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with Magit. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Invoking the magit-status function will show a buffer with the
;; status of the current git repository and its working tree. That
;; buffer offers key bindings for manipulating the status in simple
;; ways.
;;
;; The status buffer mainly shows the difference between the working
;; tree and the index, and the difference between the index and the
;; current HEAD. You can add individual hunks from the working tree
;; to the index, and you can commit the index.
;;
;; See the Magit User Manual for more information.
;;; Code:
(defvar magit-version 'undefined
"The version of Magit that you're using.
Use the function by the same name instead of this variable.")
;; The value is set at the end of this file, using the
;; function `magit-version' which is also defined there.
(when (version< emacs-version "23.2")
(error "Magit requires at least GNU Emacs 23.2"))
;; Users may choose to use `magit-log-edit' instead of the preferred
;; `git-commit-mode', by simply putting it on the `load-path'. If
;; it can be found there then it is loaded at the end of this file.
(unless (locate-library "magit-log-edit")
(require 'git-commit-mode))
(require 'git-rebase-mode)
(require 'ansi-color)
(require 'cl-lib)
(require 'diff-mode)
(require 'easymenu)
(require 'epa)
(require 'format-spec)
(require 'grep)
(require 'ring)
(require 'server)
(eval-when-compile
(require 'dired)
(require 'dired-x)
(require 'ediff)
(require 'eshell)
(require 'ido)
(require 'iswitchb)
(require 'package nil t)
(require 'view))
(declare-function dired-jump 'dired-x)
(declare-function dired-uncache 'dired)
(declare-function ediff-cleanup-mess 'ediff)
(declare-function eshell-parse-arguments 'eshell)
(declare-function ido-completing-read 'ido)
(declare-function iswitchb-read-buffer 'iswitchb)
(declare-function package-desc-vers 'package)
(declare-function package-desc-version 'package)
(declare-function package-version-join 'package)
(declare-function view-mode 'view)
(defvar git-commit-previous-winconf)
(defvar magit-commit-buffer-name)
(defvar magit-custom-options)
(defvar magit-log-buffer-name)
(defvar magit-marked-commit)
(defvar magit-reflog-buffer-name)
(defvar magit-refresh-args)
(defvar magit-stash-buffer-name)
(defvar magit-status-buffer-name)
(defvar package-alist)
;;; Compatibility
;;;; Emacs
(eval-and-compile
;; Added in Emacs 24.3 (mirrors/emacs@b335efc3).
(unless (fboundp 'setq-local)
(defmacro setq-local (var val)
"Set variable VAR to value VAL in current buffer."
(list 'set (list 'make-local-variable (list 'quote var)) val)))
;; Added in Emacs 24.3 (mirrors/emacs@b335efc3).
(unless (fboundp 'defvar-local)
(defmacro defvar-local (var val &optional docstring)
"Define VAR as a buffer-local variable with default value VAL.
Like `defvar' but additionally marks the variable as being automatically
buffer-local wherever it is set."
(declare (debug defvar) (doc-string 3))
(list 'progn (list 'defvar var val docstring)
(list 'make-variable-buffer-local (list 'quote var)))))
)
;;; Options
;;;; Setters
(defun magit-set-variable-and-refresh (symbol value)
"Set SYMBOL to VALUE and call `magit-refresh-all'."
(set-default symbol value)
;; If magit isn't fully loaded yet no buffer that might
;; need refreshing can exist and we can take a shortcut.
;; We also don't want everything to repeatedly refresh
;; when evaluating this file.
(when (and (featurep 'magit) (not buffer-file-name))
(magit-refresh-all)))
(defun magit-set-default-diff-options (symbol value)
"Set the default for `magit-diff-options' based on popup value.
Also set the local value in all Magit buffers and refresh them.
\n(fn)" ; The arguments are an internal implementation detail.
(interactive (list 'magit-diff-options magit-custom-options))
(set-default symbol value)
(when (and (featurep 'magit) (not buffer-file-name))
(dolist (buffer (buffer-list))
(when (derived-mode-p 'magit-mode)
(with-current-buffer buffer
(with-no-warnings
(setq-local magit-diff-options value))
(magit-mode-refresh-buffer))))))
;;;; Variables
(defgroup magit nil
"Controlling Git from Emacs."
:prefix "magit-"
:group 'tools)
(when (featurep 'git-commit-mode)
(custom-add-to-group 'magit 'git-commit 'custom-group)
(custom-add-to-group 'magit 'git-rebase 'custom-group))
(custom-add-to-group 'magit 'vc-follow-symlinks 'custom-variable)
(define-obsolete-variable-alias 'magit-cherry-insert-sections-hook
'magit-cherry-sections-hook "2.0.0")
(define-obsolete-variable-alias 'magit-status-insert-sections-hook
'magit-status-sections-hook "2.0.0")
(define-obsolete-variable-alias 'magit-wazzup-insert-sections-hook
'magit-wazzup-sections-hook "2.0.0")
(defcustom magit-git-executable "git"
"The name of the Git executable."
:group 'magit
:type 'string)
(defcustom magit-gitk-executable (executable-find "gitk")
"The Gitk executable."
:group 'magit
:type 'string)
(defcustom magit-emacsclient-executable
(ignore-errors
(shell-quote-argument
(let ((version (format "%s.%s"
emacs-major-version
emacs-minor-version)))
(or (let ((exec-path (list (expand-file-name "bin" invocation-directory)
invocation-directory)))
(or (executable-find (format "emacsclient-%s" version))
(executable-find (format "emacsclient-%s.exe" version))
(executable-find "emacsclient")
(executable-find "emacsclient.exe")))
(executable-find (format "emacsclient-%s" version))
(executable-find (format "emacsclient-%s.exe" version))
(executable-find "emacsclient")
(executable-find "emacsclient.exe")))))
"The Emacsclient executable.
The default value is the full path to the emacsclient executable
located in the same directory as the executable of the current
Emacs instance. If the emacsclient cannot be located in that
directory then the first executable found anywhere on the
`exec-path' is used instead.
If no executable can be located then nil becomes the default
value, and some important Magit commands will fallback to an
alternative code path. However `magit-interactive-rebase'
will stop working at all."
:group 'magit
:type '(choice (string :tag "Executable")
(const :tag "Don't use Emacsclient" nil)))
(defcustom magit-quote-curly-braces
(and (eq system-type 'windows-nt)
(let ((case-fold-search t))
(string-match-p "cygwin" magit-git-executable))
t)
"Whether curly braces should be quoted when calling git.
This may be necessary when using Windows. On all other system
types this must always be nil.
We are not certain when quoting is needed, but it appears it is
needed when using Cygwin Git but not when using stand-alone Git.
The default value is set based on that assumptions. If this
turns out to be wrong you can customize this option but please
also comment on issue #816."
:group 'magit
:set-after '(magit-git-executable)
:type 'boolean)
(defcustom magit-repo-dirs nil
"Directories containing Git repositories.
Magit will look into these directories for Git repositories and
offer them as choices for `magit-status'."
:group 'magit
:type '(repeat string))
(defcustom magit-repo-dirs-depth 3
"The maximum depth to look for Git repos.
When looking for a Git repository below the directories in
`magit-repo-dirs', Magit will only descend this many levels
deep."
:group 'magit
:type 'integer)
(defcustom magit-set-upstream-on-push nil
"Whether `magit-push' may use --set-upstream when pushing a branch.
This only applies if the branch does not have an upstream set yet.
nil don't use --set-upstream.
t ask if --set-upstream should be used.
`dontask' always use --set-upstream.
`refuse' refuse to push unless a remote branch has already been set.
--set-upstream is supported with git > 1.7.0"
:group 'magit
:type '(choice (const :tag "Never" nil)
(const :tag "Ask" t)
(const :tag "Ask if not set" askifnotset)
(const :tag "Refuse" refuse)
(const :tag "Always" dontask)))
(defcustom magit-refresh-file-buffer-hook
'(magit-revert-buffer)
"List of functions to be called to refresh a file visiting buffer.
After many Magit commands, this hook is run for each file
visiting buffer inside the current git repository.
The functions are called without any arguments and with the the
file buffer current. They have to ensure the same buffer is
still current when they return which can be easily done using:
(with-current-buffer (current-buffer) DO-STUFF)"
:group 'magit
:type 'hook
:options '(magit-revert-buffer magit-update-vc-modeline))
(defcustom magit-save-some-buffers t
"Whether \\[magit-status] saves modified buffers before running.
nil don't save buffers.
t ask which buffers to save.
`dontask' save all buffers without asking."
:group 'magit
:type '(choice (const :tag "Never" nil)
(const :tag "Ask" t)
(const :tag "Save without asking" dontask)))
(defcustom magit-save-some-buffers-predicate
'magit-save-buffers-predicate-tree-only
"A predicate function to decide whether to save a buffer.
Used by function `magit-save-some-buffers' when the variable of
the same name is non-nil."
:group 'magit
:type '(radio (function-item magit-save-buffers-predicate-tree-only)
(function-item magit-save-buffers-predicate-all)
(function :tag "Other")))
(defcustom magit-default-tracking-name-function
'magit-default-tracking-name-remote-plus-branch
"Function used to generate default tracking branch names
when doing a \\[magit-checkout].
The default is `magit-default-tracking-name-remote-plus-branch',
which generates a tracking name of the form \"REMOTE-BRANCHNAME\"."
:group 'magit
:type '(radio (function-item magit-default-tracking-name-remote-plus-branch)
(function-item magit-default-tracking-name-branch-only)
(function :tag "Other")))
(defcustom magit-commit-ask-to-stage t
"Whether to ask to stage everything when committing and nothing is staged."
:group 'magit
:type 'boolean
:package-version '(magit . "1.3.0"))
(defcustom magit-commit-extend-override-date nil
"Whether using `magit-commit-extend' changes the committer date."
:group 'magit
:type 'boolean
:package-version '(magit . "1.3.0"))
(defcustom magit-commit-reword-override-date nil
"Whether using `magit-commit-reword' changes the committer date."
:group 'magit
:type 'boolean
:package-version '(magit . "1.3.0"))
(defcustom magit-commit-squash-commit nil
"Whether to target the marked or current commit when squashing.
When this is nil then the command `magit-commit-fixup' and
`magit-commit-squash' always require that the user explicitly
selects a commit. This is also the case when these commands are
used with a prefix argument, in which case this option is ignored.
Otherwise this controls which commit to target, either the
current or marked commit. Or if both can be used, which should
be preferred."
:group 'magit
:type
'(choice
(const :tag "Always prompt" nil)
(const :tag "Prefer current commit, else use marked" current-or-marked)
(const :tag "Prefer marked commit, else use current" marked-or-current)
(const :tag "Use current commit, if any" current)
(const :tag "Use marked commit, if any" marked))
:package-version '(magit . "1.3.0"))
(defcustom magit-commit-mode-show-buttons t
"Whether to show navigation buttons in the *magit-commit* buffer."
:group 'magit
:type 'boolean)
(defcustom magit-merge-warn-dirty-worktree t
"Whether to issue a warning when attempting to start a merge in a dirty worktree."
:group 'magit
:type 'boolean
:package-version '(magit . "1.3.0"))
(defcustom magit-sha1-abbrev-length 7
"The number of digits to show when a sha1 is displayed in abbreviated form."
:group 'magit
:type 'integer)
(defcustom magit-log-cutoff-length 100
"The maximum number of commits to show in the log and whazzup buffers."
:group 'magit
:type 'integer)
(defcustom magit-log-infinite-length 99999
"Number of log used to show as maximum for `magit-log-cutoff-length'."
:group 'magit
:type 'integer)
(defcustom magit-log-auto-more nil
"Insert more log entries automatically when moving past the last entry.
Only considered when moving past the last entry with
`magit-goto-*-section' commands."
:group 'magit
:type 'boolean)
(defcustom magit-log-format-graph-function nil
"Function used to format graphs in log buffers.
The function is called with one argument, the propertized graph
of a single line in as a string. It has to return the formatted
string. This option can also be nil, in which case the graph is
inserted as is."
:group 'magit
:type '(choice (const :tag "insert as is" nil)
function))
(defcustom magit-log-show-margin t
"Whether to use a margin when showing `oneline' logs.
When non-nil the author name and date are displayed in the margin
of the log buffer if that contains a `oneline' log. This can be
toggled temporarily using the command `magit-log-toggle-margin'."
:group 'magit
:type 'boolean)
(put 'magit-log-show-margin 'permanent-local t)
(defcustom magit-log-margin-spec '(25 nil magit-duration-spec)
"How to format the margin for `oneline' logs.
When the log buffer contains a `oneline' log, then it optionally
uses the right margin to display the author name and author date.
This option controls how that margin is formatted, the other
option affecting this is `magit-log-show-margin'; if that is nil
then no margin is displayed at all. To toggle this temporarily
use the command `magit-log-show-margin'.
Logs that are shown together with other non-log information (e.g.
in the status buffer) are never accompanied by a margin. The
same applies to `long' logs, in this case because that would be
redundant.
The value has the form (WIDTH CHARACTERP DURATION-SPEC). The
width of the margin is controlled using WIDTH, an integer. When
CHARACTERP is non-nil time units are shown as single characters,
otherwise the full name of the unit is displayed. DURATION-SPEC
has to be a variable, its value controls which time units are
used, how many seconds they contain, and what their names are."
:group 'magit
:type '(list (integer :tag "Margin width")
(choice :tag "Time unit style"
(const :tag "Character" t)
(const :tag "Word" nil))
(variable :tag "Duration spec variable")))
(defcustom magit-duration-spec
`((?Y "year" "years" ,(round (* 60 60 24 365.2425)))
(?M "month" "months" ,(round (* 60 60 24 30.436875)))
(?w "week" "weeks" ,(* 60 60 24 7))
(?d "day" "days" ,(* 60 60 24))
(?h "hour" "hours" ,(* 60 60))
(?m "minute" "minutes" 60)
(?s "second" "seconds" 1))
"Units used to display durations in a human format.
The value is a list of time units, beginning with the longest.
Each element has the form ((CHAR UNIT UNITS SECONDS)..). UNIT
is the time unit, UNITS is the plural of that unit. CHAR is a
character that can be used as abbreviation and must be unique
amoung all elements. SECONDS is the number of seconds in one
UNIT. Also see option `magit-log-margin-spec'."
:group 'magit
:type '(repeat (list (character :tag "Unit character")
(string :tag "Unit singular string")
(string :tag "Unit plural string")
(integer :tag "Seconds in unit"))))
(defcustom magit-log-show-gpg-status nil
"Display signature verification information as part of the log."
:group 'magit
:type 'boolean)
(defcustom magit-wazzup-sections-hook
'(magit-insert-wazzup-head-line
magit-insert-empty-line
magit-insert-wazzup-branches)
"Hook run to insert sections into the wazzup buffer."
:group 'magit
:type 'hook)
(defcustom magit-cherry-sections-hook
'(magit-insert-cherry-head-line
magit-insert-cherry-upstream-line
magit-insert-cherry-help-lines
magit-insert-empty-line
magit-insert-cherry-commits)
"Hook run to insert sections into the cherry buffer."
:group 'magit
:type 'hook)
(defcustom magit-mode-hook nil
"Hook run when entering a Magit mode derived mode."
:group 'magit
:type 'hook)
(defcustom magit-status-sections-hook
'(magit-insert-status-local-line
magit-insert-status-remote-line
magit-insert-status-head-line
magit-insert-status-tags-line
magit-insert-status-merge-line
magit-insert-status-rebase-lines
magit-insert-empty-line
magit-insert-bisect-output
magit-insert-bisect-rest
magit-insert-bisect-log
magit-insert-stashes
magit-insert-untracked-files
magit-insert-pending-changes
magit-insert-pending-commits
magit-insert-unstaged-changes
magit-insert-staged-changes
magit-insert-unpulled-commits
magit-insert-unpushed-commits)
"Hook run to insert sections into the status buffer.
This option allows reordering the sections and adding sections
that are by default displayed in other Magit buffers. Doing the
latter is currently not recommended because not all functions
that insert sections have been adapted yet. Only inserters that
take no argument can be used and some functions exist that begin
with the `magit-insert-' prefix but do not insert a section.
Note that there are already plans to improve this and to add
similar hooks for other Magit modes."
:group 'magit
:type 'hook)
(defcustom magit-status-tags-line-subject 'head
"Whether tag or head is the subject on tags line in status buffer.
This controls how the words \"ahead\" and \"behind\" are used on
the tags line in the status buffer. The tags line does not
actually display complete sentences, but when thinking about when
to use which term, it helps imagining it did. This option
controls whether the tag names should be considered the subjects
or objects in these sentences.
`tag' The previous tag is *behind* HEAD by N commits.
The next tag is *ahead* of HEAD by N commits.
`head' HEAD is *ahead* of the previous tag by N commits.
HEAD is *behind* the next tag by N commits.
If the value is `tag' the commit counts are fontified; otherwise
they are not (due to semantic considerations)."
:group 'magit
:type '(choice (const :tag "tags are the subjects" tag)
(const :tag "head is the subject" head)))
(defcustom magit-process-popup-time -1
"Popup the process buffer if a command takes longer than this many seconds."
:group 'magit
:type '(choice (const :tag "Never" -1)
(const :tag "Immediately" 0)
(integer :tag "After this many seconds")))
(defcustom magit-stage-all-confirm t
"Whether to require confirmation before staging all changes.
This reduces the risk of accidentally losing the index. If
nothing at all is staged yet, then always stage without requiring
confirmation, because it can be undone without the risk of losing
a carefully crafted index."
:package-version '(magit . "1.3.0")
:group 'magit
:type 'boolean)
(defcustom magit-unstage-all-confirm t
"Whether to require confirmation before unstaging all changes.
This reduces the risk of accidentally losing of the index. If
there are no staged changes at all, then always unstage without
confirmation, because it can be undone without the risk of losing
a carefully crafted index."
:package-version '(magit . "1.3.0")
:group 'magit
:type 'boolean)
(defcustom magit-process-keep-history nil
"Whether to always prevent clearing the process buffer."
:package-version '(magit . "1.3.0")
:group 'magit
:type 'boolean)
(defcustom magit-show-child-count nil
"Whether to append the number of childen to section headings."
:group 'magit
:type 'boolean)
(defcustom magit-revert-item-confirm t
"Require acknowledgment before reverting an item."
:group 'magit
:type 'boolean)
(defcustom magit-remote-ref-format 'remote-slash-branch
"How to format refs when autocompleting, in particular for remotes.
Autocompletion is used by functions like `magit-checkout',
`magit-interactive-rebase' and others which offer branch name
completion.
`remote-slash-branch' Format refs as \"remote/branch\".
`branch-then-remote' Format refs as \"branch (remote)\"."
:group 'magit
:type '(choice (const :tag "branch (remote)" branch-then-remote)
(const :tag "remote/branch" remote-slash-branch))
:package-version '(magit . "1.3.0"))
(defcustom magit-process-connection-type (not (eq system-type 'cygwin))
"Connection type used for the git process.
If nil, use pipes: this is usually more efficient, and works on Cygwin.
If t, use ptys: this enables magit to prompt for passphrases when needed."
:group 'magit
:type '(choice (const :tag "pipe" nil)
(const :tag "pty" t)))
(defcustom magit-process-yes-or-no-prompt-regexp
" [\[(]\\([Yy]\\(?:es\\)?\\)[/|]\\([Nn]o?\\)[\])] ?[?:] ?$"
"Regexp matching Yes-or-No prompts of git and its subprocesses."
:group 'magit
:type 'regexp)
(defcustom magit-process-password-prompt-regexps
'("^\\(Enter \\)?[Pp]assphrase\\( for \\(RSA \\)?key '.*'\\)?: ?$"
"^\\(Enter \\)?[Pp]assword\\( for '.*'\\)?: ?$"
"^.*'s password: ?$"
"^Yubikey for .*: ?$")
"List of regexps matching password prompts of git and its subprocesses."
:group 'magit
:type '(repeat (regexp)))
(defcustom magit-process-username-prompt-regexps
'("^Username for '.*': ?$")
"List of regexps matching username prompts of git and its subprocesses."
:group 'magit
:type '(repeat (regexp)))
(defconst magit-server-window-type
'(choice
(const :tag "Use selected window"
:match (lambda (widget value)
(not (functionp value)))
nil)
(function-item :tag "Display in new frame" switch-to-buffer-other-frame)
(function-item :tag "Use pop-to-buffer" pop-to-buffer)
(function :tag "Other function")))
(defcustom magit-server-window-for-commit 'pop-to-buffer
"Function used to select a window for displaying commit message buffers.
It should take one argument (a buffer) and display and select it.
A common value is `pop-to-buffer'. It can also be nil in which
case the selected window is used."
:group 'magit
:type magit-server-window-type)
(defcustom magit-server-window-for-rebase server-window
"Function used to select a window for displaying interactive rebase buffers.
It should take one argument (a buffer) and display and select it.
A common value is `pop-to-buffer'. It can also be nil in which
case the selected window is used."
:group 'magit
:type magit-server-window-type
:set-after '(server-window))
(defcustom magit-completing-read-function 'magit-builtin-completing-read
"Function to be called when requesting input from the user."
:group 'magit
:type '(radio (function-item magit-iswitchb-completing-read)
(function-item magit-ido-completing-read)
(function-item magit-builtin-completing-read)
(function :tag "Other")))
(defcustom magit-status-buffer-switch-function 'pop-to-buffer
"Function for `magit-status' to use for switching to the status buffer.
The function is given one argument, the status buffer."
:group 'magit
:type '(radio (function-item switch-to-buffer)
(function-item pop-to-buffer)
(function :tag "Other")))
(defcustom magit-restore-window-configuration nil
"Whether quitting a Magit buffer restores previous window configuration.
Function `magit-mode-display-buffer' is used to display and
select Magit buffers. Unless the buffer was already displayed in
a window of the selected frame it also stores the previous window
configuration. If this option is non-nil that configuration will
later be restored by `magit-mode-quit-window', provided the
buffer has not since been displayed in another frame.
This works best when only two windows are usually displayed in a
frame. If this isn't the case setting this to t might often lead
to undesirable behaviour. Also quitting a Magit buffer while
another Magit buffer that was created earlier is still displayed
will cause that buffer to be hidden, which might or might not be
what you want."
:group 'magit
:type 'boolean)
(defcustom magit-rewrite-inclusive t
"Whether magit includes the selected base commit in a rewrite operation.
t means both the selected commit as well as any subsequent
commits will be rewritten. This is magit's default behaviour,
equivalent to 'git rebase -i ${REV}~1'
A'---B'---C'---D'
^
nil means the selected commit will be literally used as 'base',
so only subsequent commits will be rewritten. This is consistent
with git-rebase, equivalent to 'git rebase -i ${REV}', yet more
cumbersome to use from the status buffer.
A---B'---C'---D'
^"
:group 'magit
:type '(choice (const :tag "Always" t)
(const :tag "Never" nil)
(const :tag "Ask" ask)))
(defcustom magit-highlight-whitespace t
"Specify where to highlight whitespace errors.
See `magit-highlight-trailing-whitespace',
`magit-highlight-indentation'. The symbol t means in all diffs,
`status' means only in the status buffer, and nil means nowhere."
:group 'magit
:type '(choice (const :tag "Always" t)
(const :tag "Never" nil)
(const :tag "In status buffer" status))
:set 'magit-set-variable-and-refresh)
(defcustom magit-highlight-trailing-whitespace t
"Whether to highlight whitespace at the end of a line in diffs.
Used only when `magit-highlight-whitespace' is non-nil."
:group 'magit
:type 'boolean
:set 'magit-set-variable-and-refresh)
(defcustom magit-highlight-indentation nil
"Highlight the \"wrong\" indentation style.
Used only when `magit-highlight-whitespace' is non-nil.
The value is a list of cons cells. The car is a regular
expression, and the cdr is the value that applies to repositories
whose directory matches the regular expression. If more than one
item matches, then the *last* item in the list applies. So, the
default value should come first in the list.
If the value is `tabs', highlight indentation with tabs. If the
value is an integer, highlight indentation with at least that
many spaces. Otherwise, highlight neither."
:group 'magit
:type `(repeat (cons (string :tag "Directory regexp")
(choice (const :tag "Tabs" tabs)
(integer :tag "Spaces" :value ,tab-width)
(const :tag "Neither" nil))))
:set 'magit-set-variable-and-refresh)
(defcustom magit-refs-namespaces
'(("^\\(HEAD\\)$" magit-log-head-label-head nil)
("^refs/tags/\\(.+\\)" magit-log-head-label-tags nil)
("^refs/heads/\\(.+\\)" magit-log-head-label-local nil)
("^refs/remotes/\\(.+\\)" magit-log-head-label-remote nil)
("^refs/bisect/\\(bad\\)" magit-log-head-label-bisect-bad nil)
("^refs/bisect/\\(skip.*\\)" magit-log-head-label-bisect-skip nil)
("^refs/bisect/\\(good.*\\)" magit-log-head-label-bisect-good nil)
("^refs/wip/\\(.+\\)" magit-log-head-label-wip nil)
("^refs/patches/\\(.+\\)" magit-log-head-label-patches nil)
("^\\(bad\\):" magit-log-head-label-bisect-bad nil)
("^\\(skip\\):" magit-log-head-label-bisect-skip nil)
("^\\(good\\):" magit-log-head-label-bisect-good nil)
("\\(.+\\)" magit-log-head-label-default nil))
"How different refs should be formatted for display.
Each entry controls how a certain type of ref is displayed, and
has the form (REGEXP FACE FORMATTER). REGEXP is a regular
expression used to match full refs. The first entry whose REGEXP
matches the reference is used. The first regexp submatch becomes
the \"label\" that represents the ref and is propertized with
font FONT. If FORMATTER is non-nil it should be a function that
takes two arguments, the full ref and the face. It is supposed
to return a propertized label that represents the ref.
Currently this variable is only used in logs and the branch
manager but it will be used in more places in the future."
:group 'magit
:type '(repeat
(list regexp
face
(choice (const :tag "first submatch is label" nil)
(function :tag "format using function")))))
(defcustom magit-show-diffstat t
"Whether to shod diffstat in diff and commit buffers."
:group 'magit
:type 'boolean)
(defcustom magit-diff-options nil
"Git options used to display diffs.
For more information about the options see man:git-diff.
This variable can be conveniently set in Magit buffers
using `magit-key-mode-popup-diff-options' (bound to \
\\<magit-mode-map>\\[magit-key-mode-popup-diff-options]).
Please note that not all of these options are supported by older
versions of Git, which could become a problem if you use tramp to
access repositories on a system with such a version. If you see
whitespace where you would have expected a diff, this likely is
the cause, and the only (currently) workaround is to not make the
problematic option a member of the default value."
:group 'magit
:type '(set :greedy t
(const :tag
"--minimal Show smallest possible diff"
"--minimal")
(const :tag
"--patience Use patience diff algorithm"
"--patience")
(const :tag
"--histogram Use histogram diff algorithm"
"--histogram")
(const :tag
"--ignore-space-change Ignore whitespace changes"
"--ignore-space-change")
(const :tag
"--ignore-all-space Ignore all whitespace"
"--ignore-all-space")
(const :tag
"--function-context Show surrounding functions"
"--function-context"))
:set 'magit-set-default-diff-options)
(put 'magit-diff-options 'permanent-local t)
(defcustom magit-diff-refine-hunk nil
"Show fine (word-granularity) differences within diff hunks.
There are three possible settings:
nil never show fine differences
t show fine differences for the selected diff hunk only
`all' show fine differences for all displayed diff hunks"
:group 'magit
:type '(choice (const :tag "Never" nil)
(const :tag "Selected only" t)
(const :tag "All" all))
:set 'magit-set-variable-and-refresh)
(defcustom magit-item-highlight-face 'magit-item-highlight
"The face used to highlight the current section.
By default the highlighting of the current section is done using
the background color specified by face `magit-item-highlight'.
If you don't want to use the background to do the highlighting,
this *might* by as easy as customizing that face. However if you
are using a theme, which in turn sets the background color of
that face then, due to limitations in face inheritance when using
themes, you might be forced to use another face.
Unfortunately it is only possible to override a face attribute,
set by a theme, but not to drop it entirely. This means that one
has to explicitly use the `default' background color, to make it
appear *as if* the background wasn't used.
One reason you might want to *not* use the background, is that
doing so forces the use of overlays for some components of diffs.
Using overlays potentially degrades performance when generating
large diffs. Also see option `magit-diff-use-overlays'."
:package-version '(magit . "1.3.0")
:group 'magit
:type '(choice (const magit-item-highlight)
(const bold)
(face :tag "Other face")
(const :tag "Don't highlight" nil)))
(defcustom magit-diff-use-overlays
(not (eq magit-item-highlight-face 'bold))
"Whether to use overlays to highlight various diff components.
This has to be non-nil if the current section is highlighted by
changing the background color. Otherwise background colors that
hold semantic meaning, like that of the added and removed lines
in diffs, as well as section headings, would be shadowed by the
highlighting.
To select the face used for highlighting customize the option
`magit-item-highlight-face'. If you set that to `bold' or some
other face that does not use the background then you can set this
option to nil. Doing so could potentially improve performance
when generating large diffs."
:package-version '(magit . "1.3.0")
:group 'magit
:type 'boolean
:set-after '(magit-item-highlight-face))
(defcustom magit-expand-staged-on-commit nil
"Whether to expand staged changes when creating a commit.
When this is non-nil and the current buffer is the status buffer
expand the section containing staged changes. If this is `full'
always expand all subsections; if it is t subsections that were
previously hidden remain hidden.
In the event that expanding very large patches takes a long time
\\<global-map>\\[keyboard-quit] can be used to abort that step.
This is especially useful when you would normally not look at the
changes, e.g. because you are committing some binary files."
:group 'magit
:type '(choice (const :tag "Expand all subsections" full)
(const :tag "Expand top section" t)
(const :tag "Don't expand" nil)))
(defcustom magit-ellipsis ?…
"Character appended to abreviated text.
Currently this is used only in the log margin, but might later
be used elsewhere too. Filenames that were abbreviated by Git
are left as-is."
:group 'magit
:type 'character)
(defvar magit-status-line-align-to 9)
;; Not an option to avoid advertising it.
(defvar magit-rigid-key-bindings nil
"Use rigid key bindings instead of thematic key popups.
If you enable this a lot of functionality is lost. You most
likely don't want that. This variable only has an effect if
set before loading libary `magit'.")
;;;; Faces
(defgroup magit-faces nil
"Customize the appearance of Magit."
:prefix "magit-"
:group 'faces
:group 'magit)
(custom-add-to-group 'magit-faces 'magit-item-highlight-face 'custom-variable)
(when (featurep 'git-commit-mode)
(custom-add-to-group 'magit-faces 'git-commit-faces 'custom-group)
(custom-add-to-group 'magit-faces 'git-rebase-faces 'custom-group))
(defface magit-header
'((t :inherit header-line))
"Face for generic header lines.
Many Magit faces inherit from this one by default."
:group 'magit-faces)
(defface magit-section-title
'((t :inherit magit-header))
"Face for section titles."
:group 'magit-faces)
(defface magit-branch
'((t :inherit magit-header))
"Face for branches."
:group 'magit-faces)
(defface magit-tag
'((t :inherit magit-header))
"Face for tags."
:group 'magit-faces)
(defface magit-diff-file-header
'((t :inherit diff-file-header))
"Face for diff file header lines."
:group 'magit-faces)
(defface magit-diff-hunk-header
'((t :inherit diff-hunk-header))
"Face for diff hunk header lines."
:group 'magit-faces)
(defface magit-diff-add
'((t :inherit diff-added))
"Face for lines in a diff that have been added."
:group 'magit-faces)
(defface magit-diff-del
'((t :inherit diff-removed))
"Face for lines in a diff that have been deleted."
:group 'magit-faces)
(defface magit-diff-none
'((t :inherit diff-context))
"Face for lines in a diff that are unchanged."
:group 'magit-faces)
(defface magit-diff-merge-current
'((t :inherit font-lock-preprocessor-face))
"Face for merge conflict marker 'current' line."
:group 'magit-faces)
(defface magit-diff-merge-separator