All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Stephan Beyer <s-beyer@gmx.net>
Cc: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	git@vger.kernel.org,
	"Christian Couder" <christian.couder@gmail.com>,
	"SZEDER Gábor" <szeder.dev@gmail.com>
Subject: Re: [PATCH 4/5] Make sequencer abort safer
Date: Fri, 09 Dec 2016 10:33:47 -0800	[thread overview]
Message-ID: <xmqq4m2drlys.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <c02708de-8b47-e490-4a1e-77f5727b1156@gmx.net> (Stephan Beyer's message of "Thu, 8 Dec 2016 20:17:29 +0100")

Stephan Beyer <s-beyer@gmx.net> writes:

> However:
>
>> -static void update_curr_file()
>> +static void update_current_file(void)
>
> This function name could lead to the impression that there is some
> current file (defined by a global state or whatever) that is updated.
>
> So I'd rather rename the *file* to one of
>
>  * sequencer/abort-safety (consistent to am, describes its purpose)
>  * sequencer/safety (shorter, still describes the purpose)
>  * sequencer/current-head (describes what it contains)
>  * sequencer/last (a four-letter word, not totally unambiguous though)

OK, so here is a patch that needs to be squashed further on top of
4/5.  I just picked the first one on your list ;-)

Thanks.

 sequencer.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index 874aaa4cd4..3ac4cb8d3b 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -27,7 +27,7 @@ GIT_PATH_FUNC(git_path_seq_dir, "sequencer")
 static GIT_PATH_FUNC(git_path_todo_file, "sequencer/todo")
 static GIT_PATH_FUNC(git_path_opts_file, "sequencer/opts")
 static GIT_PATH_FUNC(git_path_head_file, "sequencer/head")
-static GIT_PATH_FUNC(git_path_current_file, "sequencer/current")
+static GIT_PATH_FUNC(git_path_abort_safety_file, "sequencer/abort-safety")
 
 /*
  * A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
@@ -306,7 +306,7 @@ static int error_dirty_index(struct replay_opts *opts)
 	return -1;
 }
 
-static void update_current_file(void)
+static void update_abort_safety_file(void)
 {
 	struct object_id head;
 
@@ -315,9 +315,9 @@ static void update_current_file(void)
 		return;
 
 	if (!get_oid("HEAD", &head))
-		write_file(git_path_current_file(), "%s", oid_to_hex(&head));
+		write_file(git_path_abort_safety_file(), "%s", oid_to_hex(&head));
 	else
-		write_file(git_path_current_file(), "%s", "");
+		write_file(git_path_abort_safety_file(), "%s", "");
 }
 
 static int fast_forward_to(const unsigned char *to, const unsigned char *from,
@@ -349,7 +349,7 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
 	strbuf_release(&sb);
 	strbuf_release(&err);
 	ref_transaction_free(transaction);
-	update_current_file();
+	update_abort_safety_file();
 	return 0;
 }
 
@@ -824,7 +824,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
 
 leave:
 	free_message(commit, &msg);
-	update_current_file();
+	update_abort_safety_file();
 
 	return res;
 }
@@ -1149,18 +1149,18 @@ static int rollback_is_safe(void)
 	struct strbuf sb = STRBUF_INIT;
 	struct object_id expected_head, actual_head;
 
-	if (strbuf_read_file(&sb, git_path_current_file(), 0) >= 0) {
+	if (strbuf_read_file(&sb, git_path_abort_safety_file(), 0) >= 0) {
 		strbuf_trim(&sb);
 		if (get_oid_hex(sb.buf, &expected_head)) {
 			strbuf_release(&sb);
-			die(_("could not parse %s"), git_path_current_file());
+			die(_("could not parse %s"), git_path_abort_safety_file());
 		}
 		strbuf_release(&sb);
 	}
 	else if (errno == ENOENT)
 		oidclr(&expected_head);
 	else
-		die_errno(_("could not read '%s'"), git_path_current_file());
+		die_errno(_("could not read '%s'"), git_path_abort_safety_file());
 
 	if (get_oid("HEAD", &actual_head))
 		oidclr(&actual_head);
@@ -1436,7 +1436,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
 		return -1;
 	if (save_opts(opts))
 		return -1;
-	update_current_file();
+	update_abort_safety_file();
 	res = pick_commits(&todo_list, opts);
 	todo_list_release(&todo_list);
 	return res;

  reply	other threads:[~2016-12-09 18:33 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-06 18:58 BUG: "cherry-pick A..B || git reset --hard OTHER" Junio C Hamano
2016-12-07 14:31 ` Christian Couder
2016-12-07 18:36 ` Stephan Beyer
2016-12-07 20:04   ` Junio C Hamano
2016-12-07 20:35     ` Stephan Beyer
2016-12-07 23:21       ` Duy Nguyen
2016-12-09 11:33     ` Duy Nguyen
2016-12-09 11:34       ` [PATCH] rebase: rename --forget to be consistent with sequencer Nguyễn Thái Ngọc Duy
2016-12-09 11:34         ` [PATCH] revert, cherry-pick: rename --quit to be consistent with rebase Nguyễn Thái Ngọc Duy
2016-12-09 18:07       ` BUG: "cherry-pick A..B || git reset --hard OTHER" Junio C Hamano
2016-12-09 19:24         ` Stephan Beyer
2016-12-09 19:28           ` Stephan Beyer
2016-12-10 11:00           ` Duy Nguyen
2016-12-10 21:23             ` Junio C Hamano
2016-12-08  7:50   ` Christian Couder
2016-12-07 21:51 ` [PATCH 1/5] am: Fix filename in safe_to_abort() error message Stephan Beyer
2016-12-08 10:21   ` Paul Tan
2016-12-07 21:51 ` [PATCH 2/5] am: Change safe_to_abort()'s not rewinding error into a warning Stephan Beyer
2016-12-07 21:51 ` [PATCH 3/5] Add test that cherry-pick --abort does not unsafely change HEAD Stephan Beyer
2016-12-07 21:51 ` [PATCH 4/5] Make sequencer abort safer Stephan Beyer
2016-12-08 15:28   ` Johannes Schindelin
2016-12-08 17:27     ` Junio C Hamano
2016-12-08 19:17       ` Stephan Beyer
2016-12-09 18:33         ` Junio C Hamano [this message]
2016-12-09 19:01           ` [PATCH v2 1/5] am: Fix filename in safe_to_abort() error message Stephan Beyer
2016-12-09 19:01           ` [PATCH v2 2/5] am: Change safe_to_abort()'s not rewinding error into a warning Stephan Beyer
2016-12-09 19:01           ` [PATCH v2 3/5] Add test that cherry-pick --abort does not unsafely change HEAD Stephan Beyer
2016-12-09 19:01           ` [PATCH v2 4/5] Make sequencer abort safer Stephan Beyer
2016-12-10 19:56             ` Christian Couder
2016-12-10 20:04               ` Jeff King
2016-12-10 20:20                 ` Stephan Beyer
2016-12-09 19:01           ` [PATCH v2 5/5] sequencer: Remove useless get_dir() function Stephan Beyer
2016-12-07 21:51 ` [PATCH " Stephan Beyer

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=xmqq4m2drlys.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=s-beyer@gmx.net \
    --cc=szeder.dev@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.