Skip to content

Commit

Permalink
status: disable deserialize when verbose output requested.
Browse files Browse the repository at this point in the history
Disable deserialization when verbose output requested.

Verbose mode causes Git to print diffs for modified files.
This requires the index to be loaded to have the currently
staged OID values.  Without loading the index, verbose output
make it look like everything was deleted.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
  • Loading branch information
jeffhostetler authored and dscho committed Sep 18, 2024
1 parent a92b304 commit 418ce15
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "commit-graph.h"
#include "pretty.h"
#include "trailer.h"
#include "trace2.h"

static const char * const builtin_commit_usage[] = {
N_("git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]\n"
Expand Down Expand Up @@ -1722,6 +1723,22 @@ int cmd_status(int argc, const char **argv, const char *prefix)
*/
try_deserialize = (!do_serialize &&
(do_implicit_deserialize || do_explicit_deserialize));

/*
* Disable deserialize when verbose is set because it causes us to
* print diffs for each modified file, but that requires us to have
* the index loaded and we don't want to do that (at least not now for
* this seldom used feature). My fear is that would further tangle
* the merge conflict with upstream.
*
* TODO Reconsider this in the future.
*/
if (try_deserialize && verbose) {
trace2_data_string("status", the_repository, "deserialize/reject",
"args/verbose");
try_deserialize = 0;
}

if (try_deserialize)
goto skip_init;

Expand Down

0 comments on commit 418ce15

Please sign in to comment.