From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: "Kristian Høgsberg" <krh@redhat.com>
Subject: [PATCH] git-commit: squelch needless message during an empty merge
Date: Wed, 12 Dec 2007 19:09:16 -0800 [thread overview]
Message-ID: <7v1w9r5m03.fsf_-_@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7vbq8v5n0u.fsf_-_@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Wed, 12 Dec 2007 18:47:13 -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>
---
builtin-commit.c | 9 +++++----
wt-status.c | 2 ++
wt-status.h | 1 +
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 9cb7589..ad9f921 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -280,7 +280,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
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;
@@ -296,6 +296,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix)
s.untracked = untracked_files;
s.index_file = index_file;
s.fp = fp;
+ s.nowarn = nowarn;
wt_status_print(&s);
@@ -412,7 +413,7 @@ static int prepare_log_message(const char *index_file, const char *prefix)
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);
@@ -606,7 +607,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
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();
@@ -717,7 +718,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
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 51c1879..c0c2472 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -381,6 +381,8 @@ void wt_status_print(struct wt_status *s)
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 63d50f2..02afaa6 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -17,6 +17,7 @@ struct wt_status {
int verbose;
int amend;
int untracked;
+ int nowarn;
/* These are computed during processing of the individual sections */
int commitable;
int workdir_dirty;
next prev parent reply other threads:[~2007-12-13 3:09 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-22 6:11 What's in git/spearce.git (stable) Shawn O. Pearce
2007-11-01 5:39 ` What's in git.git (stable) Junio C Hamano
2007-11-04 3:52 ` Junio C Hamano
2007-11-08 8:06 ` Junio C Hamano
2007-11-08 11:38 ` Pierre Habouzit
2007-11-12 7:06 ` Junio C Hamano
2007-11-15 0:20 ` Junio C Hamano
2007-11-17 21:00 ` Junio C Hamano
2007-11-25 20:45 ` Junio C Hamano
2007-12-01 2:05 ` Junio C Hamano
2007-12-04 8:43 ` Junio C Hamano
2007-12-05 10:57 ` Junio C Hamano
2007-12-07 9:50 ` Junio C Hamano
2007-12-09 10:32 ` Junio C Hamano
2007-12-10 22:37 ` v1.5.4 plans Junio C Hamano
2007-12-10 23:49 ` Jeff King
2007-12-11 1:27 ` Junio C Hamano
2007-12-11 5:02 ` Junio C Hamano
2007-12-11 6:39 ` Jeff King
2007-12-11 6:47 ` Junio C Hamano
2007-12-11 6:54 ` Jeff King
2007-12-11 7:00 ` Junio C Hamano
2007-12-11 7:03 ` Jeff King
2007-12-11 6:17 ` Jeff King
2007-12-11 6:27 ` Jeff King
2007-12-11 6:28 ` [PATCH 2/2] git-svn: get color config from --get-colorbool Jeff King
2007-12-12 18:27 ` Eric Wong
2007-12-11 7:01 ` v1.5.4 plans Jeff King
2007-12-11 7:05 ` Andreas Ericsson
2007-12-11 12:53 ` Jeff King
2007-12-11 3:53 ` Nicolas Pitre
2007-12-11 12:57 ` Johannes Schindelin
2007-12-11 13:59 ` Nicolas Pitre
2007-12-11 15:24 ` Kristian Høgsberg
2007-12-11 19:13 ` Junio C Hamano
2007-12-12 18:40 ` Eric Wong
2007-12-12 19:50 ` Junio C Hamano
2007-12-12 22:21 ` David D. Kilzer
2007-12-31 3:56 ` David D. Kilzer
2007-12-31 20:07 ` [PATCH] Fix race condition in t9119-git-svn-info.sh David D. Kilzer
2007-12-31 22:29 ` Junio C Hamano
2007-12-31 23:33 ` [PATCH] Remove duplication " David D. Kilzer
2008-01-02 3:43 ` Eric Wong
2008-01-02 3:54 ` David D. Kilzer
2008-01-02 5:57 ` Junio C Hamano
2008-01-02 10:27 ` Junio C Hamano
2007-12-13 2:47 ` What's in git.git (stable frozen) Junio C Hamano
2007-12-13 3:09 ` Junio C Hamano [this message]
2007-12-13 4:34 ` [PATCH] git-commit: squelch needless message during an empty merge Jeff King
2007-12-13 7:46 ` Johannes Sixt
2007-12-17 8:40 ` What's in git.git (stable frozen) Junio C Hamano
2007-12-23 9:21 ` Junio C Hamano
2008-01-05 10:46 ` Junio C Hamano
2008-01-05 21:21 ` Dan McGee
2008-01-06 2:56 ` Junio C Hamano
2008-01-06 3:06 ` Junio C Hamano
2008-01-06 3:08 ` Dan McGee
2008-01-06 10:33 ` Junio C Hamano
[not found] ` <e5bfff550801050507x369976b7sd5e112451bc90331@mail.gmail.com>
2008-01-05 22:11 ` Junio C Hamano
2008-01-06 4:24 ` Jeff King
2008-01-06 4:29 ` Jeff King
2008-01-06 10:51 ` Junio C Hamano
2008-01-06 11:17 ` Jeff King
2008-01-06 12:32 ` Junio C Hamano
2008-01-06 20:59 ` Jeff King
2008-01-06 21:22 ` Junio C Hamano
2008-01-07 1:48 ` Jeff King
2008-01-07 8:27 ` Junio C Hamano
2008-01-07 21:58 ` Paul Mackerras
2008-01-07 22:05 ` Christian Stimming
2008-01-07 22:14 ` Junio C Hamano
2007-12-17 21:52 ` Steffen Prohaska
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v1w9r5m03.fsf_-_@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=krh@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).