git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Schindelin <johannes.schindelin@gmx.de>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH v2 00/14] Lib'ify quite a few functions in sequencer.c
Date: Fri, 26 Aug 2016 15:47:03 +0200 (CEST)	[thread overview]
Message-ID: <cover.1472219214.git.johannes.schindelin@gmx.de> (raw)
In-Reply-To: <cover.1471968378.git.johannes.schindelin@gmx.de>

This patch series is one of the half dozen patch series left to move the
bulk of rebase -i into a builtin.

The purpose of this patch series is to switch the functions in
sequencer.c from die()ing to returning errors instead, as proper library
functions should do, to give callers a chance to clean up after an
error.

Changes since v1:

- two "return error()"s replacing "die_errno()"s were turned into "return
  error_errno()"s instead.

- an strbuf is now released when format_todo() failed (and may have left
  the strbuf with allocated memory).

- a superfluous space (which was inherited from the previous code) was
  fixed, while at it.

- fixed commit messages to report that callers of the libified functions
  are already libified.

- reordered patches to ensure that callers of libified functions are
  already libified.


Johannes Schindelin (14):
  sequencer: lib'ify sequencer_pick_revisions()
  sequencer: do not die() in do_pick_commit()
  sequencer: lib'ify write_message()
  sequencer: lib'ify do_recursive_merge()
  sequencer: lib'ify do_pick_commit()
  sequencer: lib'ify walk_revs_populate_todo()
  sequencer: lib'ify prepare_revs()
  sequencer: lib'ify read_and_refresh_cache()
  sequencer: lib'ify read_populate_todo()
  sequencer: lib'ify read_populate_opts()
  sequencer: lib'ify create_seq_dir()
  sequencer: lib'ify save_head()
  sequencer: lib'ify save_todo()
  sequencer: lib'ify save_opts()

 sequencer.c | 172 ++++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 104 insertions(+), 68 deletions(-)

Published-As: https://github.com/dscho/git/releases/tag/libify-sequencer-v2
Fetch-It-Via: git fetch https://github.com/dscho/git libify-sequencer-v2

Interdiff vs v1:

 diff --git a/sequencer.c b/sequencer.c
 index caba11d..b6481bb 100644
 --- a/sequencer.c
 +++ b/sequencer.c
 @@ -464,7 +464,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
  		 * to work on.
  		 */
  		if (write_cache_as_tree(head, 0, NULL))
 -			return error (_("Your index file is unmerged."));
 +			return error(_("Your index file is unmerged."));
  	} else {
  		unborn = get_sha1("HEAD", head);
  		if (unborn)
 @@ -756,8 +756,8 @@ static int read_populate_todo(struct commit_list **todo_list,
  
  	fd = open(git_path_todo_file(), O_RDONLY);
  	if (fd < 0)
 -		return error(_("Could not open %s (%s)"),
 -			git_path_todo_file(), strerror(errno));
 +		return error_errno(_("Could not open %s"),
 +				   git_path_todo_file());
  	if (strbuf_read(&buf, fd, 0) < 0) {
  		close(fd);
  		strbuf_release(&buf);
 @@ -841,8 +841,8 @@ static int create_seq_dir(void)
  		return -1;
  	}
  	else if (mkdir(git_path_seq_dir(), 0777) < 0)
 -		return error(_("Could not create sequencer directory %s (%s)"),
 -			  git_path_seq_dir(), strerror(errno));
 +		return error_errno(_("Could not create sequencer directory %s"),
 +				   git_path_seq_dir());
  	return 0;
  }
  
 @@ -941,8 +941,10 @@ static int save_todo(struct commit_list *todo_list, struct replay_opts *opts)
  	if (fd < 0)
  		return error_errno(_("Could not lock '%s'"),
  				   git_path_todo_file());
 -	if (format_todo(&buf, todo_list, opts) < 0)
 +	if (format_todo(&buf, todo_list, opts) < 0) {
 +		strbuf_release(&buf);
  		return error(_("Could not format %s."), git_path_todo_file());
 +	}
  	if (write_in_full(fd, buf.buf, buf.len) < 0) {
  		strbuf_release(&buf);
  		return error_errno(_("Could not write to %s"),

-- 
2.10.0.rc1.99.gcd66998

base-commit: 5cb0d5ad05e027cbddcb0a3c7518ddeea0f7c286

  parent reply	other threads:[~2016-08-26 14:03 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-23 16:06 [PATCH 00/15] Lib'ify quite a few functions in sequencer.c Johannes Schindelin
2016-08-23 16:06 ` [PATCH 01/15] sequencer: lib'ify write_message() Johannes Schindelin
2016-08-24  7:09   ` Eric Sunshine
2016-08-24 15:52     ` Johannes Schindelin
2016-08-23 16:06 ` [PATCH 02/15] sequencer: lib'ify do_recursive_merge() Johannes Schindelin
2016-08-24  7:16   ` Eric Sunshine
2016-08-24 15:53     ` Johannes Schindelin
2016-08-23 16:06 ` [PATCH 03/15] sequencer: lib'ify do_pick_commit() Johannes Schindelin
2016-08-25 21:17   ` Junio C Hamano
2016-08-26 11:56     ` Johannes Schindelin
2016-08-23 16:06 ` [PATCH 04/15] sequencer: lib'ify prepare_revs() Johannes Schindelin
2016-08-25 22:51   ` Junio C Hamano
2016-08-26 13:40     ` Johannes Schindelin
2016-08-23 16:07 ` [PATCH 05/15] sequencer: lib'ify read_and_refresh_cache() Johannes Schindelin
2016-08-24  7:20   ` Eric Sunshine
2016-08-24 15:54     ` Johannes Schindelin
2016-08-25 22:49   ` Junio C Hamano
2016-08-23 16:07 ` [PATCH 06/15] sequencer: lib'ify read_populate_todo() Johannes Schindelin
2016-08-24  7:24   ` Eric Sunshine
2016-08-24 15:57     ` Johannes Schindelin
2016-08-25 22:59   ` Junio C Hamano
2016-08-26 13:45     ` Johannes Schindelin
2016-08-26 16:58       ` Junio C Hamano
2016-08-23 16:07 ` [PATCH 07/15] sequencer: lib'ify read_populate_opts() Johannes Schindelin
2016-08-26 17:40   ` Junio C Hamano
2016-08-29 12:06     ` Johannes Schindelin
2016-08-23 16:07 ` [PATCH 08/15] sequencer: lib'ify walk_revs_populate_todo() Johannes Schindelin
2016-08-23 16:07 ` [PATCH 09/15] sequencer: lib'ify create_seq_dir() Johannes Schindelin
2016-08-24  7:28   ` Eric Sunshine
2016-08-24 15:58     ` Johannes Schindelin
2016-08-23 16:07 ` [PATCH 10/15] sequencer: lib'ify save_head() Johannes Schindelin
2016-08-24  7:30   ` Eric Sunshine
2016-08-24 15:59     ` Johannes Schindelin
2016-08-23 16:07 ` [PATCH 11/15] sequencer: lib'ify save_todo() Johannes Schindelin
2016-08-24  7:36   ` Eric Sunshine
2016-08-24 16:05     ` Johannes Schindelin
2016-08-23 16:07 ` [PATCH 12/15] sequencer: lib'ify save_opts() Johannes Schindelin
2016-08-26 17:44   ` Junio C Hamano
2016-08-29 12:09     ` Johannes Schindelin
2016-08-23 16:07 ` [PATCH 13/15] sequencer: lib'ify sequencer_pick_revisions() Johannes Schindelin
2016-08-23 16:07 ` [PATCH 14/15] sequencer: do not die() in do_pick_commit() Johannes Schindelin
2016-08-23 16:07 ` [PATCH 15/15] sequencer: do not die() in fast_forward_to() Johannes Schindelin
2016-08-26 13:47 ` Johannes Schindelin [this message]
2016-08-26 13:47   ` [PATCH v2 01/14] sequencer: lib'ify sequencer_pick_revisions() Johannes Schindelin
2016-08-26 13:47   ` [PATCH v2 02/14] sequencer: do not die() in do_pick_commit() Johannes Schindelin
2016-08-26 13:47   ` [PATCH v2 03/14] sequencer: lib'ify write_message() Johannes Schindelin
2016-08-29 20:27     ` Junio C Hamano
2016-08-30  7:49       ` Johannes Schindelin
2016-08-26 13:47   ` [PATCH v2 04/14] sequencer: lib'ify do_recursive_merge() Johannes Schindelin
2016-08-26 13:47   ` [PATCH v2 05/14] sequencer: lib'ify do_pick_commit() Johannes Schindelin
2016-08-29 20:32     ` Junio C Hamano
2016-08-26 13:47   ` [PATCH v2 06/14] sequencer: lib'ify walk_revs_populate_todo() Johannes Schindelin
2016-08-26 13:47   ` [PATCH v2 07/14] sequencer: lib'ify prepare_revs() Johannes Schindelin
2016-08-26 13:47   ` [PATCH v2 08/14] sequencer: lib'ify read_and_refresh_cache() Johannes Schindelin
2016-08-29 20:44     ` Junio C Hamano
2016-08-30  9:09       ` Johannes Schindelin
2016-08-30 17:20         ` Junio C Hamano
2016-08-26 13:47   ` [PATCH v2 09/14] sequencer: lib'ify read_populate_todo() Johannes Schindelin
2016-08-26 13:47   ` [PATCH v2 10/14] sequencer: lib'ify read_populate_opts() Johannes Schindelin
2016-08-29 20:46     ` Junio C Hamano
2016-08-29 21:14       ` Junio C Hamano
2016-08-30  9:17       ` Johannes Schindelin
2016-08-30 17:21         ` Junio C Hamano
2016-08-26 13:47   ` [PATCH v2 11/14] sequencer: lib'ify create_seq_dir() Johannes Schindelin
2016-08-26 13:48   ` [PATCH v2 12/14] sequencer: lib'ify save_head() Johannes Schindelin
2016-08-29 20:49     ` Junio C Hamano
2016-08-30  9:21       ` Johannes Schindelin
2016-08-26 13:48   ` [PATCH v2 13/14] sequencer: lib'ify save_todo() Johannes Schindelin
2016-08-26 13:48   ` [PATCH v2 14/14] sequencer: lib'ify save_opts() Johannes Schindelin
2016-08-29 20:51   ` [PATCH v2 00/14] Lib'ify quite a few functions in sequencer.c Junio C Hamano
2016-09-09 14:35   ` [PATCH v3 00/17] " Johannes Schindelin
2016-09-09 14:35     ` [PATCH v3 01/17] sequencer: lib'ify sequencer_pick_revisions() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 02/17] sequencer: do not die() in do_pick_commit() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 03/17] sequencer: lib'ify write_message() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 04/17] sequencer: lib'ify do_recursive_merge() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 05/17] sequencer: lib'ify do_pick_commit() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 06/17] sequencer: lib'ify walk_revs_populate_todo() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 07/17] sequencer: lib'ify prepare_revs() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 08/17] sequencer: lib'ify read_and_refresh_cache() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 09/17] sequencer: lib'ify read_populate_todo() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 10/17] sequencer: lib'ify read_populate_opts() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 11/17] sequencer: lib'ify create_seq_dir() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 12/17] sequencer: lib'ify save_head() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 13/17] sequencer: lib'ify save_todo() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 14/17] sequencer: lib'ify save_opts() Johannes Schindelin
2016-09-09 14:37     ` [PATCH v3 15/17] sequencer: lib'ify fast_forward_to() Johannes Schindelin
2016-09-09 14:38     ` [PATCH v3 16/17] lib'ify checkout_fast_forward_to() Johannes Schindelin
2016-09-09 18:23       ` Junio C Hamano
2016-09-11  8:09         ` Johannes Schindelin
2016-09-09 14:38     ` [PATCH v3 17/17] sequencer: ensure to release the lock when we could not read the index Johannes Schindelin
2016-09-09 18:26       ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1472219214.git.johannes.schindelin@gmx.de \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).