Re: [PATCH 3/3] make commit --verbose work with --no-status

2014-02-24 Thread Jeff King
On Mon, Feb 24, 2014 at 12:24:42PM +0800, Tay Ray Chuan wrote:

  What happens here when there is an alternate status format _and_
  --verbose is used? If I say git commit --porcelain it should imply
  --dry-run. But git commit --porcelain --verbose no longer does so
  after your patch.
 
 I should have just left the --dry-run inference alone, like this.
 
 --8--
 
 @@ -1141,7 +1146,12 @@ static int parse_and_validate_options
 if (all  argc  0)
 die(_(Paths with -a does not make sense.));
 
 -   if (status_format != STATUS_FORMAT_DEFAULT)
 +   if (verbose  !include_status) {
 +   include_status = 1;
 +   status_format = STATUS_FORMAT_NONE;
 +   } else if (status_format != STATUS_FORMAT_DEFAULT)
 dry_run = 1;
 
 return argc;

Hrm, not quite, because the way include_status works is weird. If I turn
it off in the config, like this:

  git config commit.status false

then asking explicitly for a status format should still dry-run and show
it:

  git commit --porcelain

IOW, include_status is only respected when we are generating the actual
commit. So I think you need something more like:

  if (status_format == STATUS_FORMAT_DEFAULT) {
  if (verbose  !include_status) {
  include_status = 1;
  status_format = STATUS_FORMAT_NONE;
  }
  } else
  dry_run = 1;

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] make commit --verbose work with --no-status

2014-02-23 Thread Tay Ray Chuan
On Sat, Feb 22, 2014 at 4:31 PM, Jeff King p...@peff.net wrote:
 On Sat, Feb 22, 2014 at 03:09:22AM +0800, Tay Ray Chuan wrote:

 @@ -1141,7 +1146,12 @@ static int parse_and_validate_options(int argc, const 
 char *argv[],
   if (all  argc  0)
   die(_(Paths with -a does not make sense.));

 - if (status_format != STATUS_FORMAT_DEFAULT)
 + if (verbose  !include_status) {
 + include_status = 1;
 + status_format = STATUS_FORMAT_NONE;
 + }
 +
 + if (status_format != STATUS_FORMAT_DEFAULT  !verbose)
   dry_run = 1;

 What happens here when there is an alternate status format _and_
 --verbose is used? If I say git commit --porcelain it should imply
 --dry-run. But git commit --porcelain --verbose no longer does so
 after your patch.

I should have just left the --dry-run inference alone, like this.

--8--

@@ -1141,7 +1146,12 @@ static int parse_and_validate_options
if (all  argc  0)
die(_(Paths with -a does not make sense.));

-   if (status_format != STATUS_FORMAT_DEFAULT)
+   if (verbose  !include_status) {
+   include_status = 1;
+   status_format = STATUS_FORMAT_NONE;
+   } else if (status_format != STATUS_FORMAT_DEFAULT)
dry_run = 1;

return argc;
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] make commit --verbose work with --no-status

2014-02-22 Thread Jeff King
On Sat, Feb 22, 2014 at 03:09:22AM +0800, Tay Ray Chuan wrote:

 @@ -1141,7 +1146,12 @@ static int parse_and_validate_options(int argc, const 
 char *argv[],
   if (all  argc  0)
   die(_(Paths with -a does not make sense.));
  
 - if (status_format != STATUS_FORMAT_DEFAULT)
 + if (verbose  !include_status) {
 + include_status = 1;
 + status_format = STATUS_FORMAT_NONE;
 + }
 +
 + if (status_format != STATUS_FORMAT_DEFAULT  !verbose)
   dry_run = 1;

What happens here when there is an alternate status format _and_
--verbose is used? If I say git commit --porcelain it should imply
--dry-run. But git commit --porcelain --verbose no longer does so
after your patch.

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] make commit --verbose work with --no-status

2014-02-21 Thread Tay Ray Chuan
One would expect 'git commit --verbose --no-status' to give a commit
message with a diff of the commit, sans the output of git-status.
However, this does not work currently; the commit message body is
entirely empty (diff is absent as well). This is because internally the
status machinery is used to provide both the diff and status output, but
it is skipped due to --no-status.

We introduce a new status_format, STATUS_FORMAT_NONE. Thus, we still
call run_status(), but produce nothing in place of the usual git-status
output. status_format is set only when git-commit is passed i)
--verbose, and ii) --no-status.

Signed-off-by: Tay Ray Chuan rcta...@gmail.com
---
 builtin/commit.c | 14 +-
 wt-status.c  |  2 +-
 wt-status.h  |  3 +++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 2e86b76..fca6a6b 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -126,6 +126,7 @@ static struct strbuf message = STRBUF_INIT;
 
 static enum status_format {
STATUS_FORMAT_DEFAULT = 0,
+   STATUS_FORMAT_NONE,
STATUS_FORMAT_LONG,
STATUS_FORMAT_SHORT,
STATUS_FORMAT_PORCELAIN,
@@ -478,6 +479,10 @@ static int run_status(FILE *fp, const char *index_file, 
const char *prefix, int
wt_status_collect(s);
 
switch (status_format) {
+   case STATUS_FORMAT_NONE:
+   wt_status_mark_commitable(s);
+   wt_status_print_verbose(s);
+   break;
case STATUS_FORMAT_SHORT:
wt_shortstatus_print(s);
break;
@@ -1141,7 +1146,12 @@ static int parse_and_validate_options(int argc, const 
char *argv[],
if (all  argc  0)
die(_(Paths with -a does not make sense.));
 
-   if (status_format != STATUS_FORMAT_DEFAULT)
+   if (verbose  !include_status) {
+   include_status = 1;
+   status_format = STATUS_FORMAT_NONE;
+   }
+
+   if (status_format != STATUS_FORMAT_DEFAULT  !verbose)
dry_run = 1;
 
return argc;
@@ -1305,6 +1315,8 @@ int cmd_status(int argc, const char **argv, const char 
*prefix)
s.prefix = prefix;
 
switch (status_format) {
+   case STATUS_FORMAT_NONE:
+   break;
case STATUS_FORMAT_SHORT:
wt_shortstatus_print(s);
break;
diff --git a/wt-status.c b/wt-status.c
index 9b0189c..e90fd0f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -822,7 +822,7 @@ void wt_status_truncate_message_at_cut_line(struct strbuf 
*buf)
strbuf_release(pattern);
 }
 
-static void wt_status_print_verbose(struct wt_status *s)
+void wt_status_print_verbose(struct wt_status *s)
 {
struct rev_info rev;
struct setup_revision_opt opt;
diff --git a/wt-status.h b/wt-status.h
index 30a4812..5c89f23 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -95,8 +95,11 @@ void wt_status_truncate_message_at_cut_line(struct strbuf *);
 void wt_status_prepare(struct wt_status *s);
 void wt_status_print(struct wt_status *s);
 void wt_status_collect(struct wt_status *s);
+void wt_status_mark_commitable(struct wt_status *state);
 void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
 
+void wt_status_print_verbose(struct wt_status *s);
+
 void wt_shortstatus_print(struct wt_status *s);
 void wt_porcelain_print(struct wt_status *s);
 
-- 
1.9.0.291.g027825b

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html