Commit fada767
setup_git_directory: delay core.bare/core.worktree errors
If both core.bare and core.worktree are set, we complain
about the bogus config and die. Dying is good, because it
avoids commands running and doing damage in a potentially
incorrect setup. But dying _there_ is bad, because it means
that commands which do not even care about the work tree
cannot run. This can make repairing the situation harder:
[setup]
$ git config core.bare true
$ git config core.worktree /some/path
[OK, expected.]
$ git status
fatal: core.bare and core.worktree do not make sense
[Hrm...]
$ git config --unset core.worktree
fatal: core.bare and core.worktree do not make sense
[Nope...]
$ git config --edit
fatal: core.bare and core.worktree do not make sense
[Gaaah.]
$ git help config
fatal: core.bare and core.worktree do not make sense
Instead, let's issue a warning about the bogus config when
we notice it (i.e., for all commands), but only die when the
command tries to use the work tree (by calling setup_work_tree).
So we now get:
$ git status
warning: core.bare and core.worktree do not make sense
fatal: unable to set up work tree using invalid config
$ git config --unset core.worktree
warning: core.bare and core.worktree do not make sense
We have to update t1510 to accomodate this; it uses
symbolic-ref to check whether the configuration works or
not, but of course that command does not use the working
tree. Instead, we switch it to use `git status`, as it
requires a work-tree, does not need any special setup, and
is read-only (so a failure will not adversely affect further
tests).
In addition, we add a new test that checks the desired
behavior (i.e., that running "git config" with the bogus
config does in fact work).
Reported-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent fdf96a2 commit fada767
2 files changed
+26
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
289 | 294 | | |
290 | 295 | | |
291 | 296 | | |
| |||
422 | 427 | | |
423 | 428 | | |
424 | 429 | | |
425 | | - | |
426 | | - | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
427 | 435 | | |
428 | 436 | | |
429 | 437 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
598 | 598 | | |
599 | 599 | | |
600 | 600 | | |
601 | | - | |
| 601 | + | |
602 | 602 | | |
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
606 | 615 | | |
607 | 616 | | |
608 | 617 | | |
| |||
611 | 620 | | |
612 | 621 | | |
613 | 622 | | |
614 | | - | |
| 623 | + | |
615 | 624 | | |
616 | 625 | | |
617 | 626 | | |
| |||
700 | 709 | | |
701 | 710 | | |
702 | 711 | | |
703 | | - | |
| 712 | + | |
704 | 713 | | |
705 | 714 | | |
706 | 715 | | |
707 | 716 | | |
708 | 717 | | |
709 | | - | |
| 718 | + | |
710 | 719 | | |
711 | 720 | | |
712 | 721 | | |
| |||
752 | 761 | | |
753 | 762 | | |
754 | 763 | | |
755 | | - | |
| 764 | + | |
756 | 765 | | |
757 | | - | |
758 | 766 | | |
759 | 767 | | |
760 | 768 | | |
| |||
766 | 774 | | |
767 | 775 | | |
768 | 776 | | |
769 | | - | |
| 777 | + | |
770 | 778 | | |
771 | 779 | | |
772 | 780 | | |
| |||
777 | 785 | | |
778 | 786 | | |
779 | 787 | | |
780 | | - | |
| 788 | + | |
781 | 789 | | |
782 | 790 | | |
783 | 791 | | |
| |||
0 commit comments