From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Tan Subject: [PATCH v3 06/19] pull: pass verbosity, --progress flags to fetch and merge Date: Sun, 14 Jun 2015 16:41:53 +0800 Message-ID: <1434271326-11349-7-git-send-email-pyokagan@gmail.com> References: <1434271326-11349-1-git-send-email-pyokagan@gmail.com> Cc: Johannes Schindelin , Stefan Beller , Stephen Robin , Paul Tan To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Sun Jun 14 10:43:01 2015 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z43VN-0006Iz-A8 for gcvg-git-2@plane.gmane.org; Sun, 14 Jun 2015 10:43:01 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752487AbbFNIm4 (ORCPT ); Sun, 14 Jun 2015 04:42:56 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:35017 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752289AbbFNImp (ORCPT ); Sun, 14 Jun 2015 04:42:45 -0400 Received: by pdbnf5 with SMTP id nf5so51488179pdb.2 for ; Sun, 14 Jun 2015 01:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GmxZVNQlWfxpGpJteWjojXGq0Zqi4123YiM5IZkFeA0=; b=Os0GIy8ypphjpmKuw4CQC7u8oyKHmWlgaUpMfTv9azu5h8bqMesWgB0IxfVrkr9puJ UudgyjGu7prFr1PbYLCl8oK8QJuvzuNbCbN+wloIWwZrFm0y1PFOVDy3c25UrtSDBTV9 oHlHSOkctH8VDiJwwkhhAuLWciEYeLRRkYCptt4Ahn6Kx4/Vg+/BJ8BV0rXC2tysTsye YZxlYpR0dgAnR0rOsQUmRT3L1wmySapfrQfTDE13EpELWrLymiN7UipoBYgRDjpVCVdv A1kpbiux5wI2+B0H2MiRimAJdkgYfL5/6GldJLAnTCuZYZiWvRaZ4n126jj5nkQBzXio 4noQ== X-Received: by 10.70.140.38 with SMTP id rd6mr37748366pdb.47.1434271364506; Sun, 14 Jun 2015 01:42:44 -0700 (PDT) Received: from yoshi.pyokagan.tan ([116.86.132.138]) by mx.google.com with ESMTPSA id kk6sm8622549pdb.94.2015.06.14.01.42.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Jun 2015 01:42:42 -0700 (PDT) X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434271326-11349-1-git-send-email-pyokagan@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: 7f87aff (Teach/Fix pull/fetch -q/-v options, 2008-11-15) taught git-pull to accept the verbosity -v and -q options and pass them to git-fetch and git-merge. Re-implement support for the verbosity flags by adding it to the options list and introducing argv_push_verbosity() to push the flags into the argv array used to execute git-fetch and git-merge. 9839018 (fetch and pull: learn --progress, 2010-02-24) and bebd2fd (pull: propagate --progress to merge, 2011-02-20) taught git-pull to accept the --progress option and pass it to git-fetch and git-merge. Use OPT_PASSTHRU() implemented earlier to pass the "--[no-]progress" command line options to git-fetch and git-merge. Helped-by: Junio C Hamano Signed-off-by: Paul Tan --- Notes: v3 * Re-worded commit message. builtin/pull.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/builtin/pull.c b/builtin/pull.c index 9157536..5d9f2b5 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -16,11 +16,35 @@ static const char * const pull_usage[] = { NULL }; +/* Shared options */ +static int opt_verbosity; +static char *opt_progress; + static struct option pull_options[] = { + /* Shared options */ + OPT__VERBOSITY(&opt_verbosity), + OPT_PASSTHRU(0, "progress", &opt_progress, NULL, + N_("force progress reporting"), + PARSE_OPT_NOARG), + OPT_END() }; /** + * Pushes "-q" or "-v" switches into arr to match the opt_verbosity level. + */ +static void argv_push_verbosity(struct argv_array *arr) +{ + int verbosity; + + for (verbosity = opt_verbosity; verbosity > 0; verbosity--) + argv_array_push(arr, "-v"); + + for (verbosity = opt_verbosity; verbosity < 0; verbosity++) + argv_array_push(arr, "-q"); +} + +/** * Parses argv into [ [...]], returning their values in `repo` * as a string and `refspecs` as a null-terminated array of strings. If `repo` * is not provided in argv, it is set to NULL. @@ -46,6 +70,12 @@ static int run_fetch(const char *repo, const char **refspecs) int ret; argv_array_pushl(&args, "fetch", "--update-head-ok", NULL); + + /* Shared options */ + argv_push_verbosity(&args); + if (opt_progress) + argv_array_push(&args, opt_progress); + if (repo) { argv_array_push(&args, repo); argv_array_pushv(&args, refspecs); @@ -65,6 +95,12 @@ static int run_merge(void) struct argv_array args = ARGV_ARRAY_INIT; argv_array_pushl(&args, "merge", NULL); + + /* Shared options */ + argv_push_verbosity(&args); + if (opt_progress) + argv_array_push(&args, opt_progress); + argv_array_push(&args, "FETCH_HEAD"); ret = run_command_v_opt(args.argv, RUN_GIT_CMD); argv_array_clear(&args); -- 2.1.4