git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git remote set-head automatically

From
Caleb Cushing <xenoterracide@gmail.com>
Date
Nov 15, 2024, 14:34 UTC
Message-ID
<CAAHKNRGv19rhnqCkJMpE2FomNQBHvSS36aC=fh0UwO+9-6RRfA@mail.gmail.com>
Context: recently I've been trying to develop a feature for my Gradle
plugin that derives a semantic version from git describe.  In order to
achieve my next level of feature I need the HEAD Branch. Now, I can
get this branch using git remote show <remote> and parsing the output.
I'm a firm believer that it should be possible for me to write code,
long term even, without the internet; I did this once with my job when
I needed to go home to my parents who were very rural and didn't have
internet; I was able to keep working without access. I want that for
anyone that uses this tool.
Problem: I don't want to have to do a network request every time I do
a build, in fact I'd rather almost never have to do a network request.
Gradle makes reducing the network request to less than once per build
something ... unsupported. jgit doesn't expose support for fetching
this information. Then I found out that you could do `git remote
set-head <remote> <branch>` which appears to behave exactly how I'd
want and expect. It doesn't easily solve my problem though because I
want my solution to be generally applicable.

Ideal Long-Term Solution: git remote set-head happens automatically on lone, and even fetch if it's not set. Explicit setting would override any automatic setting; and it might be a good idea to automatically unset if the HEAD branch disappears from the remote.

Could this change be made? is there a reason not to?
Please cc, I'm not on the list.
-- 
Caleb Cushing

Appointments https://calendly.com/caleb-cushing
https://xenoterracide.com
Next: Jeff King
Message 1 of 10 in “git remote set-head automatically”
  1. Caleb CushingNov 15, 2024
  2. Jeff KingNov 16, 2024
  3. Bence FerdinandyNov 16, 2024
  4. Caleb CushingNov 19, 2024
  5. Caleb CushingNov 19, 2024
  6. Jeff KingNov 19, 2024
  7. Junio C HamanoNov 20, 2024
  8. Junio C HamanoNov 20, 2024
  9. Bence FerdinandyNov 20, 2024
  10. Bence FerdinandyJan 12, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.