Merge branch 'mm/status-without-comment-char'

"git status" now omits the prefix to make its output a comment in a
commit log editor, which is not necessary for human consumption.

We may want to tighten the output to omit unnecessary trailing blank
lines, but that does not have to be in the scope of this series.

* mm/status-without-comment-char:
  t7508: avoid non-portable sed expression
  status: add missing blank line after list of "other" files
  tests: don't set status.displayCommentPrefix file-wide
  status: disable display of '#' comment prefix by default
  submodule summary: ignore --for-status option
  wt-status: use argv_array API
  builtin/stripspace.c: fix broken indentation
This commit is contained in:
Junio C Hamano 2013-09-20 12:29:01 -07:00
Родитель 638924fec2 2e582df0e0
Коммит 6d3e1f2e45
11 изменённых файлов: 967 добавлений и 852 удалений

Просмотреть файл

@ -2183,6 +2183,13 @@ status.branch::
Set to true to enable --branch by default in linkgit:git-status[1]. Set to true to enable --branch by default in linkgit:git-status[1].
The option --no-branch takes precedence over this variable. The option --no-branch takes precedence over this variable.
status.displayCommentPrefix::
If set to true, linkgit:git-status[1] will insert a comment
prefix before each output line (starting with
`core.commentChar`, i.e. `#` by default). This was the
behavior of linkgit:git-status[1] in Git 1.8.4 and previous.
Defaults to false.
status.showUntrackedFiles:: status.showUntrackedFiles::
By default, linkgit:git-status[1] and linkgit:git-commit[1] show By default, linkgit:git-status[1] and linkgit:git-commit[1] show
files which are not currently tracked by Git. Directories which files which are not currently tracked by Git. Directories which

Просмотреть файл

@ -598,6 +598,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
const char *hook_arg2 = NULL; const char *hook_arg2 = NULL;
int ident_shown = 0; int ident_shown = 0;
int clean_message_contents = (cleanup_mode != CLEANUP_NONE); int clean_message_contents = (cleanup_mode != CLEANUP_NONE);
int old_display_comment_prefix;
/* This checks and barfs if author is badly specified */ /* This checks and barfs if author is badly specified */
determine_author_info(author_ident); determine_author_info(author_ident);
@ -695,6 +696,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
if (s->fp == NULL) if (s->fp == NULL)
die_errno(_("could not open '%s'"), git_path(commit_editmsg)); die_errno(_("could not open '%s'"), git_path(commit_editmsg));
/* Ignore status.displayCommentPrefix: we do need comments in COMMIT_EDITMSG. */
old_display_comment_prefix = s->display_comment_prefix;
s->display_comment_prefix = 1;
if (clean_message_contents) if (clean_message_contents)
stripspace(&sb, 0); stripspace(&sb, 0);
@ -820,6 +825,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
*/ */
if (!commitable && whence != FROM_MERGE && !allow_empty && if (!commitable && whence != FROM_MERGE && !allow_empty &&
!(amend && is_a_merge(current_head))) { !(amend && is_a_merge(current_head))) {
s->display_comment_prefix = old_display_comment_prefix;
run_status(stdout, index_file, prefix, 0, s); run_status(stdout, index_file, prefix, 0, s);
if (amend) if (amend)
fputs(_(empty_amend_advice), stderr); fputs(_(empty_amend_advice), stderr);
@ -1186,6 +1192,10 @@ static int git_status_config(const char *k, const char *v, void *cb)
s->use_color = git_config_colorbool(k, v); s->use_color = git_config_colorbool(k, v);
return 0; return 0;
} }
if (!strcmp(k, "status.displaycommentprefix")) {
s->display_comment_prefix = git_config_bool(k, v);
return 0;
}
if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) { if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
int slot = parse_status_slot(k, 13); int slot = parse_status_slot(k, 13);
if (slot < 0) if (slot < 0)

Просмотреть файл

@ -89,11 +89,11 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
if (argc == 2) { if (argc == 2) {
if (!strcmp(argv[1], "-s") || if (!strcmp(argv[1], "-s") ||
!strcmp(argv[1], "--strip-comments")) { !strcmp(argv[1], "--strip-comments")) {
strip_comments = 1; strip_comments = 1;
} else if (!strcmp(argv[1], "-c") || } else if (!strcmp(argv[1], "-c") ||
!strcmp(argv[1], "--comment-lines")) { !strcmp(argv[1], "--comment-lines")) {
mode = COMMENT_LINES; mode = COMMENT_LINES;
} else { } else {
mode = INVAL; mode = INVAL;
} }

Просмотреть файл

@ -1149,18 +1149,7 @@ cmd_summary() {
echo echo
fi fi
echo echo
done | done
if test -n "$for_status"; then
if [ -n "$files" ]; then
gettextln "Submodules changed but not updated:" | git stripspace -c
else
gettextln "Submodule changes to be committed:" | git stripspace -c
fi
printf "\n" | git stripspace -c
git stripspace -c
else
cat
fi
} }
# #
# List all submodules, prefixed with: # List all submodules, prefixed with:

Просмотреть файл

@ -115,7 +115,7 @@ EOF
git config core.excludesFile excludes-file git config core.excludesFile excludes-file
git status | grep "^# " > output git -c status.displayCommentPrefix=true status | grep "^# " > output
cat > expect << EOF cat > expect << EOF
# .gitignore # .gitignore

Просмотреть файл

@ -29,20 +29,19 @@ test_expect_success 'Report new path with conflict' '
test_cmp expect actual test_cmp expect actual
' '
cat >expect <<EOF test_expect_success 'M/D conflict does not segfault' '
# On branch side cat >expect <<EOF &&
# You have unmerged paths. On branch side
# (fix conflicts and run "git commit") You have unmerged paths.
# (fix conflicts and run "git commit")
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution) Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
# deleted by us: foo
# deleted by us: foo
no changes added to commit (use "git add" and/or "git commit -a") no changes added to commit (use "git add" and/or "git commit -a")
EOF EOF
test_expect_success 'M/D conflict does not segfault' '
mkdir mdconflict && mkdir mdconflict &&
( (
cd mdconflict && cd mdconflict &&
@ -135,19 +134,19 @@ test_expect_success 'status when conflicts with add and rm advice (deleted by th
test_commit on_second main.txt on_second && test_commit on_second main.txt on_second &&
test_commit master conflict.txt master && test_commit master conflict.txt master &&
test_must_fail git merge second_branch && test_must_fail git merge second_branch &&
cat >expected <<-\EOF && cat >expected <<\EOF &&
# On branch master On branch master
# You have unmerged paths. You have unmerged paths.
# (fix conflicts and run "git commit") (fix conflicts and run "git commit")
#
# Unmerged paths: Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution) (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both added: conflict.txt both added: conflict.txt
# deleted by them: main.txt deleted by them: main.txt
#
no changes added to commit (use "git add" and/or "git commit -a") no changes added to commit (use "git add" and/or "git commit -a")
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -168,20 +167,20 @@ test_expect_success 'prepare for conflicts' '
test_expect_success 'status when conflicts with add and rm advice (both deleted)' ' test_expect_success 'status when conflicts with add and rm advice (both deleted)' '
test_must_fail git merge conflict && test_must_fail git merge conflict &&
cat >expected <<-\EOF && cat >expected <<\EOF &&
# On branch conflict_second On branch conflict_second
# You have unmerged paths. You have unmerged paths.
# (fix conflicts and run "git commit") (fix conflicts and run "git commit")
#
# Unmerged paths: Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution) (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both deleted: main.txt both deleted: main.txt
# added by them: sub_master.txt added by them: sub_master.txt
# added by us: sub_second.txt added by us: sub_second.txt
#
no changes added to commit (use "git add" and/or "git commit -a") no changes added to commit (use "git add" and/or "git commit -a")
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -192,22 +191,22 @@ test_expect_success 'status when conflicts with only rm advice (both deleted)' '
test_must_fail git merge conflict && test_must_fail git merge conflict &&
git add sub_master.txt && git add sub_master.txt &&
git add sub_second.txt && git add sub_second.txt &&
cat >expected <<-\EOF && cat >expected <<\EOF &&
# On branch conflict_second On branch conflict_second
# You have unmerged paths. You have unmerged paths.
# (fix conflicts and run "git commit") (fix conflicts and run "git commit")
#
# Changes to be committed: Changes to be committed:
#
# new file: sub_master.txt new file: sub_master.txt
#
# Unmerged paths: Unmerged paths:
# (use "git rm <file>..." to mark resolution) (use "git rm <file>..." to mark resolution)
#
# both deleted: main.txt both deleted: main.txt
#
# Untracked files not listed (use -u option to show untracked files) Untracked files not listed (use -u option to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual && test_i18ncmp expected actual &&
git reset --hard && git reset --hard &&

Просмотреть файл

@ -265,13 +265,11 @@ EOF
test_expect_success '--for-status' " test_expect_success '--for-status' "
git submodule summary --for-status HEAD^ >actual && git submodule summary --for-status HEAD^ >actual &&
test_i18ncmp actual - <<EOF test_i18ncmp actual - <<EOF
# Submodule changes to be committed: * sm1 $head6...0000000:
#
# * sm1 $head6...0000000: * sm2 0000000...$head7 (2):
# > Add foo9
# * sm2 0000000...$head7 (2):
# > Add foo9
#
EOF EOF
" "

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -25,18 +25,18 @@ test_expect_success 'prepare for conflicts' '
test_expect_success 'status when conflicts unresolved' ' test_expect_success 'status when conflicts unresolved' '
test_must_fail git merge master && test_must_fail git merge master &&
cat >expected <<-\EOF && cat >expected <<\EOF &&
# On branch conflicts On branch conflicts
# You have unmerged paths. You have unmerged paths.
# (fix conflicts and run "git commit") (fix conflicts and run "git commit")
#
# Unmerged paths: Unmerged paths:
# (use "git add <file>..." to mark resolution) (use "git add <file>..." to mark resolution)
#
# both modified: main.txt both modified: main.txt
#
no changes added to commit (use "git add" and/or "git commit -a") no changes added to commit (use "git add" and/or "git commit -a")
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -47,17 +47,17 @@ test_expect_success 'status when conflicts resolved before commit' '
test_must_fail git merge master && test_must_fail git merge master &&
echo one >main.txt && echo one >main.txt &&
git add main.txt && git add main.txt &&
cat >expected <<-\EOF && cat >expected <<\EOF &&
# On branch conflicts On branch conflicts
# All conflicts fixed but you are still merging. All conflicts fixed but you are still merging.
# (use "git commit" to conclude merge) (use "git commit" to conclude merge)
#
# Changes to be committed: Changes to be committed:
#
# modified: main.txt modified: main.txt
#
# Untracked files not listed (use -u option to show untracked files) Untracked files not listed (use -u option to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -76,21 +76,21 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
test_when_finished "git rebase --abort" && test_when_finished "git rebase --abort" &&
ONTO=$(git rev-parse --short HEAD^^) && ONTO=$(git rev-parse --short HEAD^^) &&
test_must_fail git rebase HEAD^ --onto HEAD^^ && test_must_fail git rebase HEAD^ --onto HEAD^^ &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''. You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
# (fix conflicts and then run "git rebase --continue") (fix conflicts and then run "git rebase --continue")
# (use "git rebase --skip" to skip this patch) (use "git rebase --skip" to skip this patch)
# (use "git rebase --abort" to check out the original branch) (use "git rebase --abort" to check out the original branch)
#
# Unmerged paths: Unmerged paths:
# (use "git reset HEAD <file>..." to unstage) (use "git reset HEAD <file>..." to unstage)
# (use "git add <file>..." to mark resolution) (use "git add <file>..." to mark resolution)
#
# both modified: main.txt both modified: main.txt
#
no changes added to commit (use "git add" and/or "git commit -a") no changes added to commit (use "git add" and/or "git commit -a")
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -103,18 +103,18 @@ test_expect_success 'status when rebase in progress before rebase --continue' '
test_must_fail git rebase HEAD^ --onto HEAD^^ && test_must_fail git rebase HEAD^ --onto HEAD^^ &&
echo three >main.txt && echo three >main.txt &&
git add main.txt && git add main.txt &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''. You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
# (all conflicts fixed: run "git rebase --continue") (all conflicts fixed: run "git rebase --continue")
#
# Changes to be committed: Changes to be committed:
# (use "git reset HEAD <file>..." to unstage) (use "git reset HEAD <file>..." to unstage)
#
# modified: main.txt modified: main.txt
#
# Untracked files not listed (use -u option to show untracked files) Untracked files not listed (use -u option to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -135,21 +135,21 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '
test_when_finished "git rebase --abort" && test_when_finished "git rebase --abort" &&
ONTO=$(git rev-parse --short rebase_i_conflicts) && ONTO=$(git rev-parse --short rebase_i_conflicts) &&
test_must_fail git rebase -i rebase_i_conflicts && test_must_fail git rebase -i rebase_i_conflicts &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''. You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
# (fix conflicts and then run "git rebase --continue") (fix conflicts and then run "git rebase --continue")
# (use "git rebase --skip" to skip this patch) (use "git rebase --skip" to skip this patch)
# (use "git rebase --abort" to check out the original branch) (use "git rebase --abort" to check out the original branch)
#
# Unmerged paths: Unmerged paths:
# (use "git reset HEAD <file>..." to unstage) (use "git reset HEAD <file>..." to unstage)
# (use "git add <file>..." to mark resolution) (use "git add <file>..." to mark resolution)
#
# both modified: main.txt both modified: main.txt
#
no changes added to commit (use "git add" and/or "git commit -a") no changes added to commit (use "git add" and/or "git commit -a")
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -161,18 +161,18 @@ test_expect_success 'status during rebase -i after resolving conflicts' '
ONTO=$(git rev-parse --short rebase_i_conflicts) && ONTO=$(git rev-parse --short rebase_i_conflicts) &&
test_must_fail git rebase -i rebase_i_conflicts && test_must_fail git rebase -i rebase_i_conflicts &&
git add main.txt && git add main.txt &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''. You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
# (all conflicts fixed: run "git rebase --continue") (all conflicts fixed: run "git rebase --continue")
#
# Changes to be committed: Changes to be committed:
# (use "git reset HEAD <file>..." to unstage) (use "git reset HEAD <file>..." to unstage)
#
# modified: main.txt modified: main.txt
#
# Untracked files not listed (use -u option to show untracked files) Untracked files not listed (use -u option to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -189,14 +189,14 @@ test_expect_success 'status when rebasing -i in edit mode' '
test_when_finished "git rebase --abort" && test_when_finished "git rebase --abort" &&
ONTO=$(git rev-parse --short HEAD~2) && ONTO=$(git rev-parse --short HEAD~2) &&
git rebase -i HEAD~2 && git rebase -i HEAD~2 &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''. You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
# (use "git commit --amend" to amend the current commit) (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes) (use "git rebase --continue" once you are satisfied with your changes)
#
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -215,19 +215,19 @@ test_expect_success 'status when splitting a commit' '
ONTO=$(git rev-parse --short HEAD~3) && ONTO=$(git rev-parse --short HEAD~3) &&
git rebase -i HEAD~3 && git rebase -i HEAD~3 &&
git reset HEAD^ && git reset HEAD^ &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''. You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
# (Once your working directory is clean, run "git rebase --continue") (Once your working directory is clean, run "git rebase --continue")
#
# Changes not staged for commit: Changes not staged for commit:
# (use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory) (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: main.txt modified: main.txt
#
no changes added to commit (use "git add" and/or "git commit -a") no changes added to commit (use "git add" and/or "git commit -a")
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -246,14 +246,14 @@ test_expect_success 'status after editing the last commit with --amend during a
ONTO=$(git rev-parse --short HEAD~3) && ONTO=$(git rev-parse --short HEAD~3) &&
git rebase -i HEAD~3 && git rebase -i HEAD~3 &&
git commit --amend -m "foo" && git commit --amend -m "foo" &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''. You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
# (use "git commit --amend" to amend the current commit) (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes) (use "git rebase --continue" once you are satisfied with your changes)
#
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -276,14 +276,14 @@ test_expect_success 'status: (continue first edit) second edit' '
ONTO=$(git rev-parse --short HEAD~3) && ONTO=$(git rev-parse --short HEAD~3) &&
git rebase -i HEAD~3 && git rebase -i HEAD~3 &&
git rebase --continue && git rebase --continue &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
# (use "git commit --amend" to amend the current commit) (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes) (use "git rebase --continue" once you are satisfied with your changes)
#
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -298,19 +298,19 @@ test_expect_success 'status: (continue first edit) second edit and split' '
git rebase -i HEAD~3 && git rebase -i HEAD~3 &&
git rebase --continue && git rebase --continue &&
git reset HEAD^ && git reset HEAD^ &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
# (Once your working directory is clean, run "git rebase --continue") (Once your working directory is clean, run "git rebase --continue")
#
# Changes not staged for commit: Changes not staged for commit:
# (use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory) (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: main.txt modified: main.txt
#
no changes added to commit (use "git add" and/or "git commit -a") no changes added to commit (use "git add" and/or "git commit -a")
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -325,14 +325,14 @@ test_expect_success 'status: (continue first edit) second edit and amend' '
git rebase -i HEAD~3 && git rebase -i HEAD~3 &&
git rebase --continue && git rebase --continue &&
git commit --amend -m "foo" && git commit --amend -m "foo" &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
# (use "git commit --amend" to amend the current commit) (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes) (use "git rebase --continue" once you are satisfied with your changes)
#
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -347,14 +347,14 @@ test_expect_success 'status: (amend first edit) second edit' '
git rebase -i HEAD~3 && git rebase -i HEAD~3 &&
git commit --amend -m "a" && git commit --amend -m "a" &&
git rebase --continue && git rebase --continue &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
# (use "git commit --amend" to amend the current commit) (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes) (use "git rebase --continue" once you are satisfied with your changes)
#
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -370,19 +370,19 @@ test_expect_success 'status: (amend first edit) second edit and split' '
git commit --amend -m "b" && git commit --amend -m "b" &&
git rebase --continue && git rebase --continue &&
git reset HEAD^ && git reset HEAD^ &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
# (Once your working directory is clean, run "git rebase --continue") (Once your working directory is clean, run "git rebase --continue")
#
# Changes not staged for commit: Changes not staged for commit:
# (use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory) (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: main.txt modified: main.txt
#
no changes added to commit (use "git add" and/or "git commit -a") no changes added to commit (use "git add" and/or "git commit -a")
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -398,14 +398,14 @@ test_expect_success 'status: (amend first edit) second edit and amend' '
git commit --amend -m "c" && git commit --amend -m "c" &&
git rebase --continue && git rebase --continue &&
git commit --amend -m "d" && git commit --amend -m "d" &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
# (use "git commit --amend" to amend the current commit) (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes) (use "git rebase --continue" once you are satisfied with your changes)
#
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -422,14 +422,14 @@ test_expect_success 'status: (split first edit) second edit' '
git add main.txt && git add main.txt &&
git commit -m "e" && git commit -m "e" &&
git rebase --continue && git rebase --continue &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
# (use "git commit --amend" to amend the current commit) (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes) (use "git rebase --continue" once you are satisfied with your changes)
#
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -447,19 +447,19 @@ test_expect_success 'status: (split first edit) second edit and split' '
git commit --amend -m "f" && git commit --amend -m "f" &&
git rebase --continue && git rebase --continue &&
git reset HEAD^ && git reset HEAD^ &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
# (Once your working directory is clean, run "git rebase --continue") (Once your working directory is clean, run "git rebase --continue")
#
# Changes not staged for commit: Changes not staged for commit:
# (use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory) (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: main.txt modified: main.txt
#
no changes added to commit (use "git add" and/or "git commit -a") no changes added to commit (use "git add" and/or "git commit -a")
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -477,14 +477,14 @@ test_expect_success 'status: (split first edit) second edit and amend' '
git commit --amend -m "g" && git commit --amend -m "g" &&
git rebase --continue && git rebase --continue &&
git commit --amend -m "h" && git commit --amend -m "h" &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
# (use "git commit --amend" to amend the current commit) (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes) (use "git rebase --continue" once you are satisfied with your changes)
#
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -504,15 +504,15 @@ test_expect_success 'status in an am session: file already exists' '
test_when_finished "rm Maildir/* && git am --abort" && test_when_finished "rm Maildir/* && git am --abort" &&
git format-patch -1 -oMaildir && git format-patch -1 -oMaildir &&
test_must_fail git am Maildir/*.patch && test_must_fail git am Maildir/*.patch &&
cat >expected <<-\EOF && cat >expected <<\EOF &&
# On branch am_already_exists On branch am_already_exists
# You are in the middle of an am session. You are in the middle of an am session.
# (fix conflicts and then run "git am --continue") (fix conflicts and then run "git am --continue")
# (use "git am --skip" to skip this patch) (use "git am --skip" to skip this patch)
# (use "git am --abort" to restore the original branch) (use "git am --abort" to restore the original branch)
#
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -526,15 +526,15 @@ test_expect_success 'status in an am session: file does not exist' '
test_when_finished "rm Maildir/* && git am --abort" && test_when_finished "rm Maildir/* && git am --abort" &&
git format-patch -1 -oMaildir && git format-patch -1 -oMaildir &&
test_must_fail git am Maildir/*.patch && test_must_fail git am Maildir/*.patch &&
cat >expected <<-\EOF && cat >expected <<\EOF &&
# On branch am_not_exists On branch am_not_exists
# You are in the middle of an am session. You are in the middle of an am session.
# (fix conflicts and then run "git am --continue") (fix conflicts and then run "git am --continue")
# (use "git am --skip" to skip this patch) (use "git am --skip" to skip this patch)
# (use "git am --abort" to restore the original branch) (use "git am --abort" to restore the original branch)
#
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -549,15 +549,15 @@ test_expect_success 'status in an am session: empty patch' '
git commit -m "delete all am_empty" && git commit -m "delete all am_empty" &&
echo error >Maildir/0002-two_am.patch && echo error >Maildir/0002-two_am.patch &&
test_must_fail git am Maildir/*.patch && test_must_fail git am Maildir/*.patch &&
cat >expected <<-\EOF && cat >expected <<\EOF &&
# On branch am_empty On branch am_empty
# You are in the middle of an am session. You are in the middle of an am session.
# The current patch is empty. The current patch is empty.
# (use "git am --skip" to skip this patch) (use "git am --skip" to skip this patch)
# (use "git am --abort" to restore the original branch) (use "git am --abort" to restore the original branch)
#
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -574,13 +574,13 @@ test_expect_success 'status when bisecting' '
git bisect bad && git bisect bad &&
git bisect good one_bisect && git bisect good one_bisect &&
TGT=$(git rev-parse --short two_bisect) && TGT=$(git rev-parse --short two_bisect) &&
cat >expected <<-EOF && cat >expected <<EOF &&
# HEAD detached at $TGT HEAD detached at $TGT
# You are currently bisecting, started from branch '\''bisect'\''. You are currently bisecting, started from branch '\''bisect'\''.
# (use "git bisect reset" to get back to the original branch) (use "git bisect reset" to get back to the original branch)
#
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -597,15 +597,15 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '
test_when_finished "git rebase --abort" && test_when_finished "git rebase --abort" &&
ONTO=$(git rev-parse --short HEAD^^) && ONTO=$(git rev-parse --short HEAD^^) &&
test_must_fail git rebase HEAD^ --onto HEAD^^ && test_must_fail git rebase HEAD^ --onto HEAD^^ &&
cat >expected <<-EOF && cat >expected <<EOF &&
# rebase in progress; onto $ONTO rebase in progress; onto $ONTO
# You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''. You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
#
# Unmerged paths: Unmerged paths:
# both modified: main.txt both modified: main.txt
#
no changes added to commit no changes added to commit
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -626,19 +626,19 @@ test_expect_success 'prepare for cherry-pick conflicts' '
test_expect_success 'status when cherry-picking before resolving conflicts' ' test_expect_success 'status when cherry-picking before resolving conflicts' '
test_when_finished "git cherry-pick --abort" && test_when_finished "git cherry-pick --abort" &&
test_must_fail git cherry-pick cherry_branch_second && test_must_fail git cherry-pick cherry_branch_second &&
cat >expected <<-\EOF && cat >expected <<\EOF &&
# On branch cherry_branch On branch cherry_branch
# You are currently cherry-picking. You are currently cherry-picking.
# (fix conflicts and run "git cherry-pick --continue") (fix conflicts and run "git cherry-pick --continue")
# (use "git cherry-pick --abort" to cancel the cherry-pick operation) (use "git cherry-pick --abort" to cancel the cherry-pick operation)
#
# Unmerged paths: Unmerged paths:
# (use "git add <file>..." to mark resolution) (use "git add <file>..." to mark resolution)
#
# both modified: main.txt both modified: main.txt
#
no changes added to commit (use "git add" and/or "git commit -a") no changes added to commit (use "git add" and/or "git commit -a")
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -650,18 +650,18 @@ test_expect_success 'status when cherry-picking after resolving conflicts' '
test_must_fail git cherry-pick cherry_branch_second && test_must_fail git cherry-pick cherry_branch_second &&
echo end >main.txt && echo end >main.txt &&
git add main.txt && git add main.txt &&
cat >expected <<-\EOF && cat >expected <<\EOF &&
# On branch cherry_branch On branch cherry_branch
# You are currently cherry-picking. You are currently cherry-picking.
# (all conflicts fixed: run "git cherry-pick --continue") (all conflicts fixed: run "git cherry-pick --continue")
# (use "git cherry-pick --abort" to cancel the cherry-pick operation) (use "git cherry-pick --abort" to cancel the cherry-pick operation)
#
# Changes to be committed: Changes to be committed:
#
# modified: main.txt modified: main.txt
#
# Untracked files not listed (use -u option to show untracked files) Untracked files not listed (use -u option to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -669,18 +669,18 @@ test_expect_success 'status when cherry-picking after resolving conflicts' '
test_expect_success 'status showing detached at and from a tag' ' test_expect_success 'status showing detached at and from a tag' '
test_commit atag tagging && test_commit atag tagging &&
git checkout atag && git checkout atag &&
cat >expected <<-\EOF cat >expected <<\EOF
# HEAD detached at atag HEAD detached at atag
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual && test_i18ncmp expected actual &&
git reset --hard HEAD^ && git reset --hard HEAD^ &&
cat >expected <<-\EOF cat >expected <<\EOF
# HEAD detached from atag HEAD detached from atag
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -695,20 +695,20 @@ test_expect_success 'status while reverting commit (conflicts)' '
test_commit new to-revert.txt && test_commit new to-revert.txt &&
TO_REVERT=$(git rev-parse --short HEAD^) && TO_REVERT=$(git rev-parse --short HEAD^) &&
test_must_fail git revert $TO_REVERT && test_must_fail git revert $TO_REVERT &&
cat >expected <<-EOF cat >expected <<EOF
# On branch master On branch master
# You are currently reverting commit $TO_REVERT. You are currently reverting commit $TO_REVERT.
# (fix conflicts and run "git revert --continue") (fix conflicts and run "git revert --continue")
# (use "git revert --abort" to cancel the revert operation) (use "git revert --abort" to cancel the revert operation)
#
# Unmerged paths: Unmerged paths:
# (use "git reset HEAD <file>..." to unstage) (use "git reset HEAD <file>..." to unstage)
# (use "git add <file>..." to mark resolution) (use "git add <file>..." to mark resolution)
#
# both modified: to-revert.txt both modified: to-revert.txt
#
no changes added to commit (use "git add" and/or "git commit -a") no changes added to commit (use "git add" and/or "git commit -a")
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
@ -716,29 +716,29 @@ test_expect_success 'status while reverting commit (conflicts)' '
test_expect_success 'status while reverting commit (conflicts resolved)' ' test_expect_success 'status while reverting commit (conflicts resolved)' '
echo reverted >to-revert.txt && echo reverted >to-revert.txt &&
git add to-revert.txt && git add to-revert.txt &&
cat >expected <<-EOF cat >expected <<EOF
# On branch master On branch master
# You are currently reverting commit $TO_REVERT. You are currently reverting commit $TO_REVERT.
# (all conflicts fixed: run "git revert --continue") (all conflicts fixed: run "git revert --continue")
# (use "git revert --abort" to cancel the revert operation) (use "git revert --abort" to cancel the revert operation)
#
# Changes to be committed: Changes to be committed:
# (use "git reset HEAD <file>..." to unstage) (use "git reset HEAD <file>..." to unstage)
#
# modified: to-revert.txt modified: to-revert.txt
#
# Untracked files not listed (use -u option to show untracked files) Untracked files not listed (use -u option to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '
test_expect_success 'status after reverting commit' ' test_expect_success 'status after reverting commit' '
git revert --continue && git revert --continue &&
cat >expected <<-\EOF cat >expected <<\EOF
# On branch master On branch master
nothing to commit (use -u to show untracked files) nothing to commit (use -u to show untracked files)
EOF EOF
git status --untracked-files=no >actual && git status --untracked-files=no >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '

Просмотреть файл

@ -9,6 +9,7 @@
#include "diffcore.h" #include "diffcore.h"
#include "quote.h" #include "quote.h"
#include "run-command.h" #include "run-command.h"
#include "argv-array.h"
#include "remote.h" #include "remote.h"
#include "refs.h" #include "refs.h"
#include "submodule.h" #include "submodule.h"
@ -46,9 +47,11 @@ static void status_vprintf(struct wt_status *s, int at_bol, const char *color,
strbuf_vaddf(&sb, fmt, ap); strbuf_vaddf(&sb, fmt, ap);
if (!sb.len) { if (!sb.len) {
strbuf_addch(&sb, comment_line_char); if (s->display_comment_prefix) {
if (!trail) strbuf_addch(&sb, comment_line_char);
strbuf_addch(&sb, ' '); if (!trail)
strbuf_addch(&sb, ' ');
}
color_print_strbuf(s->fp, color, &sb); color_print_strbuf(s->fp, color, &sb);
if (trail) if (trail)
fprintf(s->fp, "%s", trail); fprintf(s->fp, "%s", trail);
@ -59,7 +62,7 @@ static void status_vprintf(struct wt_status *s, int at_bol, const char *color,
eol = strchr(line, '\n'); eol = strchr(line, '\n');
strbuf_reset(&linebuf); strbuf_reset(&linebuf);
if (at_bol) { if (at_bol && s->display_comment_prefix) {
strbuf_addch(&linebuf, comment_line_char); strbuf_addch(&linebuf, comment_line_char);
if (*line != '\n' && *line != '\t') if (*line != '\n' && *line != '\t')
strbuf_addch(&linebuf, ' '); strbuf_addch(&linebuf, ' ');
@ -129,6 +132,7 @@ void wt_status_prepare(struct wt_status *s)
s->untracked.strdup_strings = 1; s->untracked.strdup_strings = 1;
s->ignored.strdup_strings = 1; s->ignored.strdup_strings = 1;
s->show_branch = -1; /* unspecified */ s->show_branch = -1; /* unspecified */
s->display_comment_prefix = 0;
} }
static void wt_status_print_unmerged_header(struct wt_status *s) static void wt_status_print_unmerged_header(struct wt_status *s)
@ -661,29 +665,57 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
char summary_limit[64]; char summary_limit[64];
char index[PATH_MAX]; char index[PATH_MAX];
const char *env[] = { NULL, NULL }; const char *env[] = { NULL, NULL };
const char *argv[8]; struct argv_array argv = ARGV_ARRAY_INIT;
struct strbuf cmd_stdout = STRBUF_INIT;
env[0] = index; struct strbuf summary = STRBUF_INIT;
argv[0] = "submodule"; char *summary_content;
argv[1] = "summary"; size_t len;
argv[2] = uncommitted ? "--files" : "--cached";
argv[3] = "--for-status";
argv[4] = "--summary-limit";
argv[5] = summary_limit;
argv[6] = uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD");
argv[7] = NULL;
sprintf(summary_limit, "%d", s->submodule_summary); sprintf(summary_limit, "%d", s->submodule_summary);
snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file); snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
env[0] = index;
argv_array_push(&argv, "submodule");
argv_array_push(&argv, "summary");
argv_array_push(&argv, uncommitted ? "--files" : "--cached");
argv_array_push(&argv, "--for-status");
argv_array_push(&argv, "--summary-limit");
argv_array_push(&argv, summary_limit);
if (!uncommitted)
argv_array_push(&argv, s->amend ? "HEAD^" : "HEAD");
memset(&sm_summary, 0, sizeof(sm_summary)); memset(&sm_summary, 0, sizeof(sm_summary));
sm_summary.argv = argv; sm_summary.argv = argv.argv;
sm_summary.env = env; sm_summary.env = env;
sm_summary.git_cmd = 1; sm_summary.git_cmd = 1;
sm_summary.no_stdin = 1; sm_summary.no_stdin = 1;
fflush(s->fp); fflush(s->fp);
sm_summary.out = dup(fileno(s->fp)); /* run_command closes it */ sm_summary.out = -1;
run_command(&sm_summary); run_command(&sm_summary);
argv_array_clear(&argv);
len = strbuf_read(&cmd_stdout, sm_summary.out, 1024);
/* prepend header, only if there's an actual output */
if (len) {
if (uncommitted)
strbuf_addstr(&summary, _("Submodules changed but not updated:"));
else
strbuf_addstr(&summary, _("Submodule changes to be committed:"));
strbuf_addstr(&summary, "\n\n");
}
strbuf_addbuf(&summary, &cmd_stdout);
strbuf_release(&cmd_stdout);
if (s->display_comment_prefix) {
summary_content = strbuf_detach(&summary, &len);
strbuf_add_commented_lines(&summary, summary_content, len);
free(summary_content);
}
fputs(summary.buf, s->fp);
strbuf_release(&summary);
} }
static void wt_status_print_other(struct wt_status *s, static void wt_status_print_other(struct wt_status *s,
@ -717,10 +749,11 @@ static void wt_status_print_other(struct wt_status *s,
strbuf_release(&buf); strbuf_release(&buf);
if (!column_active(s->colopts)) if (!column_active(s->colopts))
return; goto conclude;
strbuf_addf(&buf, "%s#\t%s", strbuf_addf(&buf, "%s%s\t%s",
color(WT_STATUS_HEADER, s), color(WT_STATUS_HEADER, s),
s->display_comment_prefix ? "#" : "",
color(WT_STATUS_UNTRACKED, s)); color(WT_STATUS_UNTRACKED, s));
memset(&copts, 0, sizeof(copts)); memset(&copts, 0, sizeof(copts));
copts.padding = 1; copts.padding = 1;
@ -730,6 +763,8 @@ static void wt_status_print_other(struct wt_status *s,
print_columns(&output, s->colopts, &copts); print_columns(&output, s->colopts, &copts);
string_list_clear(&output, 0); string_list_clear(&output, 0);
strbuf_release(&buf); strbuf_release(&buf);
conclude:
status_printf_ln(s, GIT_COLOR_NORMAL, "");
} }
static void wt_status_print_verbose(struct wt_status *s) static void wt_status_print_verbose(struct wt_status *s)
@ -764,6 +799,8 @@ static void wt_status_print_tracking(struct wt_status *s)
struct strbuf sb = STRBUF_INIT; struct strbuf sb = STRBUF_INIT;
const char *cp, *ep; const char *cp, *ep;
struct branch *branch; struct branch *branch;
char comment_line_string[3];
int i;
assert(s->branch && !s->is_initial); assert(s->branch && !s->is_initial);
if (prefixcmp(s->branch, "refs/heads/")) if (prefixcmp(s->branch, "refs/heads/"))
@ -772,12 +809,22 @@ static void wt_status_print_tracking(struct wt_status *s)
if (!format_tracking_info(branch, &sb)) if (!format_tracking_info(branch, &sb))
return; return;
i = 0;
if (s->display_comment_prefix) {
comment_line_string[i++] = comment_line_char;
comment_line_string[i++] = ' ';
}
comment_line_string[i] = '\0';
for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1) for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s),
"%c %.*s", comment_line_char, "%s%.*s", comment_line_string,
(int)(ep - cp), cp); (int)(ep - cp), cp);
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c", if (s->display_comment_prefix)
comment_line_char); color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
comment_line_char);
else
fprintf_ln(s->fp, "");
} }
static int has_unmerged(struct wt_status *s) static int has_unmerged(struct wt_status *s)

Просмотреть файл

@ -50,6 +50,7 @@ struct wt_status {
enum commit_whence whence; enum commit_whence whence;
int nowarn; int nowarn;
int use_color; int use_color;
int display_comment_prefix;
int relative_paths; int relative_paths;
int submodule_summary; int submodule_summary;
int show_ignored_files; int show_ignored_files;