Re: [PATCH 1/3] rebase: guard against missing files in read_basic_state()

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 1/3] rebase: guard against missing files in read_basic_state()

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:44

Ramkumar Ramachandra [off-list ref] writes:
Signed-off-by: Ramkumar Ramachandra <redacted>
This does not affect correctness; i.e. head_name=$(cat that-file)
will error out if the file is missing, right?

A more troublesome is that nobody seems to check the return value of
this function.  If head-name, onto or orig-head is missing, is that
an error condition that should make the callers of read_basic_state
stop and refuse to proceed?

The way the && cascade is used seems to indicate that, but up to the
point where it sents $verbose. If and only if head-name, onto, orig-head
and quiet can be read in state-dir, verbose in state-dir is checked
and only then $verbose is set.

Martin, this seems to be from your series around early Feburary
2011.  Do you recall why these checks are cascaded this way?
I do not offhand think of a good reason.
quoted hunk
---
 git-rebase.sh | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/git-rebase.sh b/git-rebase.sh
index d0c11a9..2122fe0 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -84,6 +84,8 @@ keep_empty=
 test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
 
 read_basic_state () {
+	test -f "$state_dir/head-name" &&
+	test -f "$state_dir/onto" &&
 	head_name=$(cat "$state_dir"/head-name) &&
 	onto=$(cat "$state_dir"/onto) &&
 	# We always write to orig-head, but interactive rebase used to write to

Re: [PATCH 1/3] rebase: guard against missing files in read_basic_state()

From: Martin von Zweigbergk <hidden>
Date: 2016-06-15 22:57:46

On Thu, Jun 13, 2013 at 3:29 PM, Junio C Hamano [off-list ref] wrote:
Ramkumar Ramachandra [off-list ref] writes:

A more troublesome is that nobody seems to check the return value of
this function.  If head-name, onto or orig-head is missing, is that
an error condition that should make the callers of read_basic_state
stop and refuse to proceed?
Since we unconditionally write those three (and 'quiet'), it seems
reasonable to require all of them to be there when continuing, so I
think you're right that we should fail fast.
The way the && cascade is used seems to indicate that, but up to the
point where it sents $verbose. If and only if head-name, onto, orig-head
and quiet can be read in state-dir, verbose in state-dir is checked
and only then $verbose is set.

Martin, this seems to be from your series around early Feburary
2011.  Do you recall why these checks are cascaded this way?
I do not offhand think of a good reason.
Neither do I. I think the cascading after 'quiet' is just a mistake on
my part. The consequences are probably close to none, since if one of
earlier commands fail, the other files will probably not be there
either. (Not defending it; I'm happy if it gets fixed, e.g. by making
it fail fast.)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help