From: Bence Ferdinandy <bence@ferdinandy.com>
To: git@vger.kernel.org
Cc: johannes.schindelin@gmx.de,
Bence Ferdinandy <bence@ferdinandy.com>,
cc@mail.ferdinandy.com,
/tmp/FUboFpyPuH/0000-cover-letter.patch@mail.ferdinandy.com
Subject: [RFC PATCH 0/2] set remote/HEAD with fetch
Date: Tue, 10 Sep 2024 22:24:57 +0200 [thread overview]
Message-ID: <20240910203129.2251090-1-bence@ferdinandy.com> (raw)
Hi,
these two patches attempt to solve the issue raised in
https://lore.kernel.org/git/D3HBD7C1FR14.74FL1Q1S9UCB@ferdinandy.com/
As a quick summary: `clone` sets `refs/remotes/[remote]/HEAD` while going init
-> remote add -> fetch does not, one has to manually run `remote set-head -a
[remote]`.
The first patch adds a `--set-head` flag to `fetch` and `remote update` which
runs `remote set-head -a` for us. Unfortunately, with the current behaviour of
set-head this will always print a message, even though a no-op fetch doesn't
print anything, and I think this is also confusing for people who do not care
about remote/HEAD, so the second patch removes the print if `set-head -a` is
a no-op (and actually makes it into a no-op, instead of just idempotent).
Another way could of course be duplicating some of the code from remote
set-head in fetch.c instead of calling directly, but it didn't look like an
anti-pattern in the code-base and it felt the best way to insure identical
behaviour between a `git fetch --all --set-head` and a
`git fetch --all && git remote | xargs -i git remote set-head -a {}`.
What is missing for sure is:
- documentation
- tests (if needed)
- settings
For settings, my idea would be a fetch/remote.set_head that could take three values:
* never
* missing: run it only if the ref is missing, this setting would basically
allow replicating the result of a clone
* always (with the other patch, this would still be a no-op if it didn't change)
This would probably also require a --no-set-head flag, to disable an
always/missing setting. A --missing-set-head or something of the like also may
or may not make sense. Alternatively, only two behaviours might be enough
(missing and always) since clone already sort of does this.
I'm not sure if the general approach is fine or not, nor am I sure the code
itself is any good, but it "works on my computer" :) I'm also hoping that
I managed to read all the relevant parts for sending a patch.
Feedback would be highly appreciated!
Thanks,
Bence
Bence Ferdinandy (2):
fetch: set-head with --set-head option
set-head: do not update if there is no change
builtin/fetch.c | 29 ++++++++++++++++++++++++-----
builtin/remote.c | 15 +++++++++++----
2 files changed, 35 insertions(+), 9 deletions(-)
--
2.46.0
next reply other threads:[~2024-09-10 20:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 20:24 Bence Ferdinandy [this message]
2024-09-10 20:24 ` [RFC PATCH 1/2] fetch: set-head with --set-head option Bence Ferdinandy
2024-09-11 6:54 ` Jeff King
2024-09-11 12:16 ` Bence Ferdinandy
2024-09-10 20:24 ` [RFC PATCH 2/2] set-head: do not update if there is no change Bence Ferdinandy
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=20240910203129.2251090-1-bence@ferdinandy.com \
--to=bence@ferdinandy.com \
--cc=/tmp/FUboFpyPuH/0000-cover-letter.patch@mail.ferdinandy.com \
--cc=cc@mail.ferdinandy.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox