X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-reset.c;h=10dba60c39d3cf7dafe6d733a4d53977c285a73c;hb=7ee906694c28ab7281492d5114d2afabd964bd41;hp=44582f23a21c97507351773e2c0a342a1eaa8c64;hpb=620a6cd42ed5ea94684b22714181bf03871733dd;p=git.git diff --git a/builtin-reset.c b/builtin-reset.c index 44582f23a..10dba60c3 100644 --- a/builtin-reset.c +++ b/builtin-reset.c @@ -18,7 +18,7 @@ #include "tree.h" static const char builtin_reset_usage[] = -"git-reset [--mixed | --soft | --hard] [] [ [--] ...]"; +"git-reset [--mixed | --soft | --hard] [-q] [] [ [--] ...]"; static char *args_to_str(const char **argv) { @@ -158,6 +158,7 @@ static int read_from_tree(const char *prefix, const char **argv, return 1; diffcore_std(&opt); diff_flush(&opt); + diff_tree_release_paths(&opt); if (!index_was_discarded) /* The index is still clobbered from do_diff_cache() */ @@ -180,7 +181,7 @@ static const char *reset_type_names[] = { "mixed", "soft", "hard", NULL }; int cmd_reset(int argc, const char **argv, const char *prefix) { - int i = 1, reset_type = NONE, update_ref_status = 0; + int i = 1, reset_type = NONE, update_ref_status = 0, quiet = 0; const char *rev = "HEAD"; unsigned char sha1[20], *orig = NULL, sha1_orig[20], *old_orig = NULL, sha1_old_orig[20]; @@ -192,7 +193,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) reflog_action = args_to_str(argv); setenv("GIT_REFLOG_ACTION", reflog_action, 0); - if (i < argc) { + while (i < argc) { if (!strcmp(argv[i], "--mixed")) { reset_type = MIXED; i++; @@ -205,6 +206,12 @@ int cmd_reset(int argc, const char **argv, const char *prefix) reset_type = HARD; i++; } + else if (!strcmp(argv[i], "-q")) { + quiet = 1; + i++; + } + else + break; } if (i < argc && argv[i][0] != '-') @@ -237,6 +244,9 @@ int cmd_reset(int argc, const char **argv, const char *prefix) if (reset_type == NONE) reset_type = MIXED; /* by default */ + if (reset_type == HARD && is_bare_repository()) + die("hard reset makes no sense in a bare repository"); + /* Soft reset does not touch the index file nor the working tree * at all, but requires them in a good order. Other resets reset * the index file to the tree object we are switching to. */ @@ -263,7 +273,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) switch (reset_type) { case HARD: - if (!update_ref_status) + if (!update_ref_status && !quiet) print_new_head_line(commit); break; case SOFT: /* Nothing else to do. */