summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1e8df76)
raw | patch | inline | side by side (parent: 1e8df76)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 13 Dec 2007 03:09:16 +0000 (19:09 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 13 Dec 2007 04:50:33 +0000 (20:50 -0800) |
When recording a merge that conflicted and ends up in no changes after
manual resolution, commit callchain looked like this:
cmd_commit() ->
prepare_log_message() ->
run_status() ->
wt_status_print()
This invocation of run_status() is asked to find out if there is a
committable change, but it unconditionally gave instructions such as
"use git-add" at the same time. When in merge, we do allow an empty
change to be recorded, so after showing this message the code still went
ahead and made a commit.
This introduces "nowarn" parameter to run_status() to avoid these
useless messages. If we are not allowed to create an empty commit, we
already call run_status() again in the original codepath, and the
message will be shown from that call anyway.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
manual resolution, commit callchain looked like this:
cmd_commit() ->
prepare_log_message() ->
run_status() ->
wt_status_print()
This invocation of run_status() is asked to find out if there is a
committable change, but it unconditionally gave instructions such as
"use git-add" at the same time. When in merge, we do allow an empty
change to be recorded, so after showing this message the code still went
ahead and made a commit.
This introduces "nowarn" parameter to run_status() to avoid these
useless messages. If we are not allowed to create an empty commit, we
already call run_status() again in the original codepath, and the
message will be shown from that call anyway.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-commit.c | patch | blob | history | |
wt-status.c | patch | blob | history | |
wt-status.h | patch | blob | history |
diff --git a/builtin-commit.c b/builtin-commit.c
index 9cb7589ac68172591ae458a20031e7dedd65adee..ad9f9211b39af6cc7d1f319b6a8da7c514a33f12 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
return false_lock.filename;
}
-static int run_status(FILE *fp, const char *index_file, const char *prefix)
+static int run_status(FILE *fp, const char *index_file, const char *prefix, int nowarn)
{
struct wt_status s;
s.untracked = untracked_files;
s.index_file = index_file;
s.fp = fp;
+ s.nowarn = nowarn;
wt_status_print(&s);
saved_color_setting = wt_status_use_color;
wt_status_use_color = 0;
- commitable = run_status(fp, index_file, prefix);
+ commitable = run_status(fp, index_file, prefix, 1);
wt_status_use_color = saved_color_setting;
fclose(fp);
index_file = prepare_index(argc, argv, prefix);
- commitable = run_status(stdout, index_file, prefix);
+ commitable = run_status(stdout, index_file, prefix, 0);
rollback_index_files();
if (!prepare_log_message(index_file, prefix) && !in_merge &&
!allow_empty && !(amend && is_a_merge(head_sha1))) {
- run_status(stdout, index_file, prefix);
+ run_status(stdout, index_file, prefix, 0);
rollback_index_files();
unlink(commit_editmsg);
return 1;
diff --git a/wt-status.c b/wt-status.c
index 51c18796915c0a9e052806eadd460b0f9afa7fee..c0c247243b562a7579ff780b80dffef4774b60a9 100644 (file)
--- a/wt-status.c
+++ b/wt-status.c
if (!s->commitable) {
if (s->amend)
fprintf(s->fp, "# No changes\n");
+ else if (s->nowarn)
+ ; /* nothing */
else if (s->workdir_dirty)
printf("no changes added to commit (use \"git add\" and/or \"git commit -a\")\n");
else if (s->workdir_untracked)
diff --git a/wt-status.h b/wt-status.h
index 63d50f2871f51d4363afa2f7bbb21c81186b9f44..02afaa60eee74018e074a4dcb3bec97c2e0ce9dc 100644 (file)
--- a/wt-status.h
+++ b/wt-status.h
int verbose;
int amend;
int untracked;
+ int nowarn;
/* These are computed during processing of the individual sections */
int commitable;
int workdir_dirty;