git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Marc Becker <marc.becker@astos.de>
To: git@vger.kernel.org
Subject: [BUG] fast-import crash on refs to in-flight commit SHA1
Date: Mon, 8 Apr 2024 17:18:04 +0200	[thread overview]
Message-ID: <d8415e36-bdd6-4e74-8240-eb71b669f178@astos.de> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2184 bytes --]

Using `from` with (not-yet-persistent) commit SHA1 crashes fast-import.

What did you do before the bug happened? (Steps to reproduce your issue)
  - use git-fast-import on a new repository
  - create an arbitrary (marked) initial commit
  - reference this commit by mark via `from` in `commit` or `reset`
  - reference same commit by SHA1 (output of `get-mark`)

What did you expect to happen? (Expected behavior)
  - in-flight commit SHA1 is usable in `from` (see doc for <commit-ish>)

What happened instead? (Actual behavior)
  - fast-import crashes when using SHA1 format, claims invalid commit ID

What's different between what you expected and what actually happened?
  - in-flight commit SHA1 is usable immediately (no need for mitigation)

Anything else you want to add:
  - referencing an in-flight commit via SHA1 in `ls` works (see below)
  - rerunning fast-import succeeds (commit already in initial data)
  - using in-flight commit SHA1 AFTER issuing `checkpoint` succeeds

...
git init
git fast-import <<EOF
# input to trigger Git fast-import bug
commit refs/heads/main
mark :1234
committer Bug <bugs@git-scm.com> 1712563200 +0000
data 14
commit message
M 644 inline test file
data 14
dummy content

get-mark :1234
# create new ref from existing mark
reset refs/heads/other
from :1234
# reference file in existing commit (SHA1 is valid)
ls 7f2839d29d46b5a9fff5572143f5370f152f7b33 test file
# checkpoint needed to use in-flight commit via SHA1
#checkpoint
# create new ref from existing commit
reset refs/heads/failed
from 7f2839d29d46b5a9fff5572143f5370f152f7b33
# use plain ref in commit
commit refs/heads/works
committer Bug <bugs@git-scm.com> 1712563300 +0000
data 18
new commit message
from 7f2839d29d46b5a9fff5572143f5370f152f7b33
# finish import
done
EOF


[System Info]
git version:
git version 2.39.2
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 4.4.0-19041-Microsoft #3996-Microsoft Thu Jan 18 16:36:00 
PST 2024 x86_64
compiler info: gnuc: 12.2
libc info: glibc: 2.36
$SHELL (typically, interactive shell): /bin/bash


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

                 reply	other threads:[~2024-04-08 15:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=d8415e36-bdd6-4e74-8240-eb71b669f178@astos.de \
    --to=marc.becker@astos.de \
    --cc=git@vger.kernel.org \
    /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).