git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>,
	ps@pks.im, Eric Sunshine <sunshine@sunshineco.com>,
	Stefan Beller <sbeller@google.com>,
	Lars Schneider <larsxschneider@gmail.com>,
	Michael Blume <blume.mike@gmail.com>
Subject: [PATCH v6 00/15] config: make git_config_set die on failure
Date: Mon, 22 Feb 2016 12:23:21 +0100	[thread overview]
Message-ID: <1456140216-24169-1-git-send-email-ps@pks.im> (raw)

Next revision of my patch series to improve error handling on
git_config_set. Only three small changes to v5 [1], thanks for
pointing these out:

    - fixed missing conversion of git_config_set_or_die in
      compat/precompose_utf8.c
    - fixed indentation in install_branch_config
    - improved advise message to give the complete command for
      fixing up the upstream configuration, including the actual
      tracking branch

[1]: http://article.gmane.org/gmane.comp.version-control.git/286355

Interdiff to v5:

diff --git a/branch.c b/branch.c
index 06942ef..c50ea42 100644
--- a/branch.c
+++ b/branch.c
@@ -53,7 +53,7 @@ static const char tracking_advice[] =
 N_("\n"
 "After fixing the error cause you may try to fix up\n"
 "the remote tracking information by invoking\n"
-"\"git branch --set-upstream-to=\".");
+"\"git branch --set-upstream-to=%s%s%s\".");
 
 int install_branch_config(int flag, const char *local, const char *origin, const char *remote)
 {
@@ -82,7 +82,7 @@ int install_branch_config(int flag, const char *local, const char *origin, const
 		strbuf_reset(&key);
 		strbuf_addf(&key, "branch.%s.rebase", local);
 		if (git_config_set_gently(key.buf, "true") < 0)
-		    goto out_err;
+			goto out_err;
 	}
 	strbuf_release(&key);
 
@@ -117,7 +117,12 @@ int install_branch_config(int flag, const char *local, const char *origin, const
 out_err:
 	strbuf_release(&key);
 	error(_("Unable to write upstream branch configuration"));
-	advise(_(tracking_advice));
+
+	advise(_(tracking_advice),
+	       origin ? origin : "",
+	       origin ? "/" : "",
+	       shortname ? shortname : remote);
+
 	return -1;
 }
 
diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c
index 9ff1ebe..dfbe6d8 100644
--- a/compat/precompose_utf8.c
+++ b/compat/precompose_utf8.c
@@ -50,8 +50,8 @@ void probe_utf8_pathname_composition(void)
 		close(output_fd);
 		git_path_buf(&path, "%s", auml_nfd);
 		precomposed_unicode = access(path.buf, R_OK) ? 0 : 1;
-		git_config_set_or_die("core.precomposeunicode",
-				      precomposed_unicode ? "true" : "false");
+		git_config_set("core.precomposeunicode",
+			       precomposed_unicode ? "true" : "false");
 		git_path_buf(&path, "%s", auml_nfc);
 		if (unlink(path.buf))
 			die_errno(_("failed to unlink '%s'"), path.buf);

Patrick Steinhardt (15):
  config: introduce set_or_die wrappers
  branch: report errors in tracking branch setup
  branch: die on config error when unsetting upstream
  branch: die on config error when editing branch description
  submodule: die on config error when linking modules
  submodule--helper: die on config error when cloning module
  remote: die on config error when setting URL
  remote: die on config error when setting/adding branches
  remote: die on config error when manipulating remotes
  clone: die on config error in cmd_clone
  init-db: die on config errors when initializing empty repo
  sequencer: die on config error when saving replay opts
  compat: die when unable to set core.precomposeunicode
  config: rename git_config_set to git_config_set_gently
  config: rename git_config_set_or_die to git_config_set

 branch.c                 | 50 ++++++++++++++++++++++++----------
 branch.h                 |  3 ++-
 builtin/branch.c         |  5 ++--
 builtin/clone.c          |  2 +-
 builtin/config.c         | 28 +++++++++----------
 builtin/init-db.c        |  2 +-
 builtin/remote.c         | 70 +++++++++++++++++-------------------------------
 cache.h                  | 14 ++++++----
 compat/precompose_utf8.c |  3 ++-
 config.c                 | 52 ++++++++++++++++++++++++++---------
 submodule.c              | 10 +++----
 t/t3200-branch.sh        | 16 ++++++++++-
 t/t5505-remote.sh        |  9 +++++++
 13 files changed, 159 insertions(+), 105 deletions(-)

-- 
2.7.1

             reply	other threads:[~2016-02-22 11:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22 11:23 Patrick Steinhardt [this message]
2016-02-22 11:23 ` [PATCH v6 01/15] config: introduce set_or_die wrappers Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 02/15] branch: report errors in tracking branch setup Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 03/15] branch: die on config error when unsetting upstream Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 04/15] branch: die on config error when editing branch description Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 05/15] submodule: die on config error when linking modules Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 06/15] submodule--helper: die on config error when cloning module Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 07/15] remote: die on config error when setting URL Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 08/15] remote: die on config error when setting/adding branches Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 09/15] remote: die on config error when manipulating remotes Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 10/15] clone: die on config error in cmd_clone Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 11/15] init-db: die on config errors when initializing empty repo Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 12/15] sequencer: die on config error when saving replay opts Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 13/15] compat: die when unable to set core.precomposeunicode Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 14/15] config: rename git_config_set to git_config_set_gently Patrick Steinhardt
2016-02-22 11:23 ` [PATCH v6 15/15] config: rename git_config_set_or_die to git_config_set Patrick Steinhardt

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=1456140216-24169-1-git-send-email-ps@pks.im \
    --to=ps@pks.im \
    --cc=blume.mike@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=larsxschneider@gmail.com \
    --cc=peff@peff.net \
    --cc=sbeller@google.com \
    --cc=sunshine@sunshineco.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).