diff mbox series

sequencer: tolerate abbreviated stopped-sha file

Message ID 20201021220353.928067-1-jonathantanmy@google.com (mailing list archive)
State Accepted
Commit c77938618298539df9102c55fdb3817c5ac2f43d
Headers show
Series sequencer: tolerate abbreviated stopped-sha file | expand

Commit Message

Jonathan Tan Oct. 21, 2020, 10:03 p.m. UTC
In 0512eabd91 ("sequencer: stop abbreviating stopped-sha file",
2020-09-25), Git was taught both to write full object names to the
stopped-sha file and to require full object names when reading. However,
a user would experience a problem if they started an interactive rebase
using an old version of Git and then continued with a current version of
Git (for example, if the system version of Git was updated in the
meantime).

Teach Git to allow object names of any length when reading.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
---
Not sure how big of a problem this will potentially be, but I noticed it
and wanted to mention it.
---
 sequencer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Junio C Hamano Oct. 21, 2020, 10:56 p.m. UTC | #1
Jonathan Tan <jonathantanmy@google.com> writes:

> In 0512eabd91 ("sequencer: stop abbreviating stopped-sha file",
> 2020-09-25), Git was taught both to write full object names to the
> stopped-sha file and to require full object names when reading. However,
> a user would experience a problem if they started an interactive rebase
> using an old version of Git and then continued with a current version of
> Git (for example, if the system version of Git was updated in the
> meantime).
>
> Teach Git to allow object names of any length when reading.
>
> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
> ---
> Not sure how big of a problem this will potentially be, but I noticed it
> and wanted to mention it.

If I didn't mention that I deliberately chose to declare it a
non-issue during the discussion, that was my mistake.

If this is not causing real-world problem, I'd in principle prefer
to keep the "expect full hex when reading what's supposed to be
written as full hex" sanity checking, but this is a file that is
purely internal between the two invocation of the program and not
even known by mere end users, so I could be persuaded to change my
mind on this particular case.

Assuming that the "use case" is real, the patch is obviously
correct.  We won't write anything but a commit object name so
using oid_committish() would not change the behaviour in good
cases.

Thanks.

> ---
>  sequencer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index 00acb12496..37847d4534 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -2653,7 +2653,7 @@ static int read_populate_opts(struct replay_opts *opts)
>  		}
>  
>  		if (read_oneliner(&buf, rebase_path_squash_onto(), 0)) {
> -			if (get_oid_hex(buf.buf, &opts->squash_onto) < 0) {
> +			if (get_oid_committish(buf.buf, &opts->squash_onto) < 0) {
>  				ret = error(_("unusable squash-onto"));
>  				goto done_rebase_i;
>  			}
diff mbox series

Patch

diff --git a/sequencer.c b/sequencer.c
index 00acb12496..37847d4534 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2653,7 +2653,7 @@  static int read_populate_opts(struct replay_opts *opts)
 		}
 
 		if (read_oneliner(&buf, rebase_path_squash_onto(), 0)) {
-			if (get_oid_hex(buf.buf, &opts->squash_onto) < 0) {
+			if (get_oid_committish(buf.buf, &opts->squash_onto) < 0) {
 				ret = error(_("unusable squash-onto"));
 				goto done_rebase_i;
 			}