Skip to content

Commit

Permalink
Merge branch 'lk/more-helpful-status-hints'
Browse files Browse the repository at this point in the history
Give finer classification to various states of paths in conflicted
state and offer advice messages in the "git status" output.
  • Loading branch information
Junio C Hamano committed Jun 28, 2012
2 parents fbc9724 + 2d1cceb commit 30e8e6f
Show file tree
Hide file tree
Showing 5 changed files with 1,004 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ advice.*::
specified a refspec that isn't your current branch) and
it resulted in a non-fast-forward error.
statusHints::
Directions on how to stage/unstage/add shown in the
output of linkgit:git-status[1] and the template shown
when writing commit messages.
Show directions on how to proceed from the current
state in the output of linkgit:git-status[1] and in
the template shown when writing commit messages in
linkgit:git-commit[1].
commitBeforeMerge::
Advice shown when linkgit:git-merge[1] refuses to
merge to avoid overwriting local changes.
Expand Down
96 changes: 96 additions & 0 deletions t/t7060-wtstatus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ test_expect_success 'Report new path with conflict' '

cat >expect <<EOF
# On branch side
# You have unmerged paths.
# (fix conflicts and run "git commit")
#
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
Expand Down Expand Up @@ -118,4 +121,97 @@ test_expect_success 'git diff-index --cached -C shows 2 copies + 1 unmerged' '
test_cmp expected actual
'


test_expect_success 'status when conflicts with add and rm advice (deleted by them)' '
git reset --hard &&
git checkout master &&
test_commit init main.txt init &&
git checkout -b second_branch &&
git rm main.txt &&
git commit -m "main.txt deleted on second_branch" &&
test_commit second conflict.txt second &&
git checkout master &&
test_commit on_second main.txt on_second &&
test_commit master conflict.txt master &&
test_must_fail git merge second_branch &&
cat >expected <<-\EOF &&
# On branch master
# You have unmerged paths.
# (fix conflicts and run "git commit")
#
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both added: conflict.txt
# deleted by them: main.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
EOF
git status --untracked-files=no >actual &&
test_i18ncmp expected actual
'


test_expect_success 'prepare for conflicts' '
git reset --hard &&
git checkout -b conflict &&
test_commit one main.txt one &&
git branch conflict_second &&
git mv main.txt sub_master.txt &&
git commit -m "main.txt renamed in sub_master.txt" &&
git checkout conflict_second &&
git mv main.txt sub_second.txt &&
git commit -m "main.txt renamed in sub_second.txt"
'


test_expect_success 'status when conflicts with add and rm advice (both deleted)' '
test_must_fail git merge conflict &&
cat >expected <<-\EOF &&
# On branch conflict_second
# You have unmerged paths.
# (fix conflicts and run "git commit")
#
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both deleted: main.txt
# added by them: sub_master.txt
# added by us: sub_second.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
EOF
git status --untracked-files=no >actual &&
test_i18ncmp expected actual
'


test_expect_success 'status when conflicts with only rm advice (both deleted)' '
git reset --hard conflict_second &&
test_must_fail git merge conflict &&
git add sub_master.txt &&
git add sub_second.txt &&
cat >expected <<-\EOF &&
# On branch conflict_second
# You have unmerged paths.
# (fix conflicts and run "git commit")
#
# Changes to be committed:
#
# new file: sub_master.txt
#
# Unmerged paths:
# (use "git rm <file>..." to mark resolution)
#
# both deleted: main.txt
#
# Untracked files not listed (use -u option to show untracked files)
EOF
git status --untracked-files=no >actual &&
test_i18ncmp expected actual &&
git reset --hard &&
git checkout master
'


test_done
Loading

0 comments on commit 30e8e6f

Please sign in to comment.